Compare commits

...

6 Commits

Author SHA1 Message Date
github-actions[bot]
fb407ccfed chore(release): Update version to v1.4.384 2026-01-19 16:22:15 +00:00
Kayvan Sylvan
c9d4c19ef8 Merge pull request #1944 from ksylvan/1033_infermatic_provider
Add Infermatic AI Provider Support
2026-01-19 08:19:57 -08:00
Kayvan Sylvan
f4e7489d42 chore: incoming 1944 changelog entry 2026-01-19 08:16:05 -08:00
Kayvan Sylvan
7012acd12a fix: replace go-git status API with native git CLI for worktree compatibility
- Replace go-git status API with native `git status --porcelain` command
- Fix worktree detection issues caused by go-git library bugs
- Simplify `IsWorkingDirectoryClean` to use CLI output parsing
- Simplify `GetStatusDetails` to return raw porcelain output
- Use native `git rev-parse HEAD` to get commit hash after commit
- Remove unused `os` and `filepath` imports from walker.go
- Remove complex worktree file existence checking logic
2026-01-19 08:15:22 -08:00
Kayvan Sylvan
387610bcf8 Add Infermatic provider test case
Adds test coverage for the Infermatic AI provider in
TestCreateClient to verify the provider exists and
creates a valid client.

Part of #1033: Add Infermatic AI provider support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 06:38:38 -08:00
Kayvan Sylvan
9e1ee4d48e WIP: Phase 1 - Add Infermatic provider to ProviderMap
Issue: #1033
Phase: 1 of 2
Status: Pending verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 06:25:31 -08:00
7 changed files with 49 additions and 42 deletions

View File

@@ -1,5 +1,15 @@
# Changelog
## v1.4.384 (2026-01-19)
### PR [#1944](https://github.com/danielmiessler/Fabric/pull/1944) by [ksylvan](https://github.com/ksylvan): Add Infermatic AI Provider Support
- Add Infermatic provider to ProviderMap as part of Phase 1 implementation for issue #1033
- Add test coverage for the Infermatic AI provider in TestCreateClient to verify provider exists and creates valid client
- Replace go-git status API with native `git status --porcelain` command to fix worktree compatibility issues
- Simplify `IsWorkingDirectoryClean` and `GetStatusDetails` functions to use CLI output parsing instead of go-git library
- Use native `git rev-parse HEAD` to get commit hash after commit and remove unused imports from walker.go
## v1.4.383 (2026-01-18)
### PR [#1943](https://github.com/danielmiessler/Fabric/pull/1943) by [ksylvan](https://github.com/ksylvan): fix: Ollama server now respects the default context window

View File

@@ -1,3 +1,3 @@
package main
var version = "v1.4.383"
var version = "v1.4.384"

Binary file not shown.

View File

@@ -2,9 +2,7 @@ package git
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
@@ -425,64 +423,49 @@ func (w *Walker) Repository() *git.Repository {
}
// IsWorkingDirectoryClean checks if the working directory has any uncommitted changes
// Uses native git CLI instead of go-git to properly handle worktree scenarios
func (w *Walker) IsWorkingDirectoryClean() (bool, error) {
worktree, err := w.repo.Worktree()
if err != nil {
return false, fmt.Errorf("failed to get worktree: %w", err)
}
status, err := worktree.Status()
worktreePath := worktree.Filesystem.Root()
// Use native git status --porcelain to avoid go-git worktree issues
// go-git's status API has known bugs with linked worktrees
cmd := exec.Command("git", "status", "--porcelain")
cmd.Dir = worktreePath
output, err := cmd.Output()
if err != nil {
return false, fmt.Errorf("failed to get git status: %w", err)
}
worktreePath := worktree.Filesystem.Root()
// In worktrees, files staged in the main repo may appear in status but not exist in the worktree
// We need to check both the working directory status AND filesystem existence
for file, fileStatus := range status {
// Check if there are any changes in the working directory
if fileStatus.Worktree != git.Unmodified && fileStatus.Worktree != git.Untracked {
return false, nil
}
// For staged files (Added, Modified in index), verify they exist in this worktree's filesystem
// This handles the worktree case where the main repo has staged files that don't exist here
if fileStatus.Staging != git.Unmodified && fileStatus.Staging != git.Untracked {
filePath := filepath.Join(worktreePath, file)
if _, err := os.Stat(filePath); os.IsNotExist(err) {
// File is staged but doesn't exist in this worktree - ignore it
continue
}
// File is staged AND exists in this worktree - not clean
return false, nil
}
}
return true, nil
// If output is empty, working directory is clean
return len(strings.TrimSpace(string(output))) == 0, nil
}
// GetStatusDetails returns a detailed status of the working directory
// Uses native git CLI instead of go-git to properly handle worktree scenarios
func (w *Walker) GetStatusDetails() (string, error) {
worktree, err := w.repo.Worktree()
if err != nil {
return "", fmt.Errorf("failed to get worktree: %w", err)
}
status, err := worktree.Status()
worktreePath := worktree.Filesystem.Root()
// Use native git status --porcelain to avoid go-git worktree issues
cmd := exec.Command("git", "status", "--porcelain")
cmd.Dir = worktreePath
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to get git status: %w", err)
}
var details strings.Builder
for file, fileStatus := range status {
// Only include files with actual working directory changes
if fileStatus.Worktree != git.Unmodified && fileStatus.Worktree != git.Untracked {
details.WriteString(fmt.Sprintf(" %c%c %s\n", fileStatus.Staging, fileStatus.Worktree, file))
}
}
return details.String(), nil
return string(output), nil
}
// AddFile adds a file to the git index
@@ -526,13 +509,17 @@ func (w *Walker) CommitChanges(message string) (plumbing.Hash, error) {
return plumbing.ZeroHash, fmt.Errorf("failed to commit: %w (output: %s)", err, string(output))
}
// Get the commit hash from HEAD
ref, err := w.repo.Head()
// Get the commit hash from HEAD using native git to avoid go-git worktree issues
hashCmd := exec.Command("git", "rev-parse", "HEAD")
hashCmd.Dir = worktreePath
hashOutput, err := hashCmd.Output()
if err != nil {
return plumbing.ZeroHash, fmt.Errorf("failed to get HEAD after commit: %w", err)
}
return ref.Hash(), nil
hashStr := strings.TrimSpace(string(hashOutput))
return plumbing.NewHash(hashStr), nil
}
// PushToRemote pushes the current branch to the remote repository

View File

@@ -145,6 +145,11 @@ var ProviderMap = map[string]ProviderConfig{
ModelsURL: "https://models.github.ai/catalog", // FetchModelsDirectly will append /models
ImplementsResponses: false,
},
"Infermatic": {
Name: "Infermatic",
BaseURL: "https://api.totalgpt.ai/v1",
ImplementsResponses: false,
},
"GrokAI": {
Name: "GrokAI",
BaseURL: "https://api.x.ai/v1",

View File

@@ -30,6 +30,11 @@ func TestCreateClient(t *testing.T) {
provider: "Abacus",
exists: true,
},
{
name: "Existing provider - Infermatic",
provider: "Infermatic",
exists: true,
},
{
name: "Existing provider - MiniMax",
provider: "MiniMax",

View File

@@ -1 +1 @@
"1.4.383"
"1.4.384"