Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions cmd/sin-code/chat_tools_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
"strings"
"time"

"github.com/OpenSIN-Code/SIN-Code/pkg/browser/cdp"
"github.com/chromedp/chromedp"

"github.com/OpenSIN-Code/SIN-Code/pkg/browser/cdp"
)

const (
Expand Down Expand Up @@ -362,12 +363,12 @@ func toolBrowserSnapshot() (string, error) {
}

snap := map[string]interface{}{
"total_events": len(events),
"first_wall": events[0].WallTime,
"last_wall": events[len(events)-1].WallTime,
"event_counts": counts,
"report": report,
"jsonl": browserSession.jsonlPath,
"total_events": len(events),
"first_wall": events[0].WallTime,
"last_wall": events[len(events)-1].WallTime,
"event_counts": counts,
"report": report,
"jsonl": browserSession.jsonlPath,
}
b, err := json.MarshalIndent(snap, "", " ")
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/sin-code/compile_spec_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// .sin-code.yml, validates it, and writes the four derived
// JSON outputs to disk. Has three modes:
//
// sin-code compile-spec # compile .sin-code.yml in cwd
// sin-code compile-spec --init # write a starter .sin-code.yml
// sin-code compile-spec --check # check that derived files are in sync
// sin-code compile-spec --out <dir> # override the output directory
// sin-code compile-spec # compile .sin-code.yml in cwd
// sin-code compile-spec --init # write a starter .sin-code.yml
// sin-code compile-spec --check # check that derived files are in sync
// sin-code compile-spec --out <dir> # override the output directory
//
// Docs: docs/SPEC-COMPILER.md
package main
Expand All @@ -25,7 +25,7 @@ import (
// NewCompileSpecCmd builds the `compile-spec` cobra subcommand.
func NewCompileSpecCmd() *cobra.Command {
var (
outDir string
outDir string
initMode bool
check bool
dryRun bool
Expand Down
6 changes: 3 additions & 3 deletions cmd/sin-code/goal_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ func NewGoalCmd() *cobra.Command {
switch reportFormat {
case "json":
payload := map[string]any{
"total": len(goals),
"by_status": byStatus,
"goals": goals,
"total": len(goals),
"by_status": byStatus,
"goals": goals,
}
enc := json.NewEncoder(cmd.OutOrStdout())
enc.SetIndent("", " ")
Expand Down
10 changes: 5 additions & 5 deletions cmd/sin-code/grill_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
//
// Subcommands:
//
// sin-code grill start <topic> begin a grilling session
// sin-code grill next <id> ask the next adversarial question
// sin-code grill answer <id> <d-id> <text> record the operator's response
// sin-code grill status <id> show resolved + open decision branches
// sin-code grill synthesize <id> produce a summary of decisions
// sin-code grill start <topic> begin a grilling session
// sin-code grill next <id> ask the next adversarial question
// sin-code grill answer <id> <d-id> <text> record the operator's response
// sin-code grill status <id> show resolved + open decision branches
// sin-code grill synthesize <id> produce a summary of decisions
//
// Sessions are stored in $SIN_CODE_HOME/grill/<id>.json as
// content-addressed JSON files. v0 ships in-memory + JSON storage;
Expand Down
10 changes: 5 additions & 5 deletions cmd/sin-code/internal/agentloop/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ type StopDecision struct {
type StopGate func(ctx context.Context, snap StopSnapshot) StopDecision

type Loop struct {
Gate *verify.Gate
LocalTool LocalToolFunc
LocalSpec []ToolSpec
Workspace string
MaxTurns int
Gate *verify.Gate
LocalTool LocalToolFunc
LocalSpec []ToolSpec
Workspace string
MaxTurns int
// MaxStopRejects caps how many times the stop-gate can reject
// completion before the run errors. Zero falls back to the
// default of 3. Independent of StallThreshold (issue #150):
Expand Down
2 changes: 1 addition & 1 deletion cmd/sin-code/internal/apiweb/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type nonFlusherRecorder struct {
rec *httptest.ResponseRecorder
}

func (n nonFlusherRecorder) Header() http.Header { return n.rec.Header() }
func (n nonFlusherRecorder) Header() http.Header { return n.rec.Header() }
func (n nonFlusherRecorder) Write(b []byte) (int, error) { return n.rec.Write(b) }
func (n nonFlusherRecorder) WriteHeader(code int) { n.rec.WriteHeader(code) }

Expand Down
20 changes: 10 additions & 10 deletions cmd/sin-code/internal/assets/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,29 +281,29 @@ func TestValidate_AllIssueBranches(t *testing.T) {
want: 1,
},
{
name: "short body",
name: "short body",
asset: &Asset{Kind: KindSkill, Name: "n", Description: "d", Path: "x.md", Body: "short"},
want: 2,
want: 2,
},
{
name: "agent no model",
name: "agent no model",
asset: &Asset{Kind: KindAgent, Name: "n", Description: "d", Path: "x.md", Body: strings.Repeat("x", 20)},
want: 2,
want: 2,
},
{
name: "command no dollar",
name: "command no dollar",
asset: &Asset{Kind: KindCommand, Name: "n", Description: "d", Path: "x.md", Argument: "arg", Body: "no placeholder"},
want: 2,
want: 2,
},
{
name: "skill no sections",
name: "skill no sections",
asset: &Asset{Kind: KindSkill, Name: "n", Description: "d", Path: "x.md", Body: strings.Repeat("x", 20)},
want: 1,
want: 1,
},
{
name: "unsafe unicode",
name: "unsafe unicode",
asset: &Asset{Kind: KindSkill, Name: "n", Description: "d", Path: "x.md", Body: "## S\n" + "\u200B"},
want: 2,
want: 2,
},
}
for _, tc := range cases {
Expand Down
4 changes: 2 additions & 2 deletions cmd/sin-code/internal/assets/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

// package-level hooks to make import error branches testable.
var (
osMkdirAllHook = os.MkdirAll
osWriteFileHook = os.WriteFile
osMkdirAllHook = os.MkdirAll
osWriteFileHook = os.WriteFile
loadSourceSkillsHook = loadSourceSkills
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/sin-code/internal/assets/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// package-level hooks to make filesystem error branches testable.
var (
walkDirHook = filepath.WalkDir
walkDirHook = filepath.WalkDir
osReadFileHook = os.ReadFile
)

Expand Down
10 changes: 5 additions & 5 deletions cmd/sin-code/internal/dox/dox.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (

// Filesystem hooks for deterministic error-path testing. Set only in tests.
var (
fsReadFile = os.ReadFile
fsReadFile = os.ReadFile
fsWriteFile = os.WriteFile
fsStat = os.Stat
fsMkdirAll = os.MkdirAll
fsReadDir = os.ReadDir
fsAbsPath = filepath.Abs
fsStat = os.Stat
fsMkdirAll = os.MkdirAll
fsReadDir = os.ReadDir
fsAbsPath = filepath.Abs
)

// ── Markers ────────────────────────────────────────────────────────────
Expand Down
1 change: 0 additions & 1 deletion cmd/sin-code/internal/ghbridge/ghbridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1590,4 +1590,3 @@ type errWriter struct {
func (e *errWriter) Write([]byte) (int, error) {
return 0, e.err
}

1 change: 0 additions & 1 deletion cmd/sin-code/internal/ghbridge/mcpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,3 @@ func writeJSONAtomic(path string, v any) error {
}
return os.Rename(tmpName, path)
}

6 changes: 3 additions & 3 deletions cmd/sin-code/internal/grill/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
// The catalog is intentionally a Go slice (not a YAML file) so
// that:
// 1. The CLI has zero file-deps for `grill next`.
// 2. The questions are typed (no string-template magic).
// 3. Operators can grep the binary for the question set.
// 1. The CLI has zero file-deps for `grill next`.
// 2. The questions are typed (no string-template magic).
// 3. Operators can grep the binary for the question set.
package grill

// AntiPattern is one entry in the catalog: the "what to look for"
Expand Down
12 changes: 6 additions & 6 deletions cmd/sin-code/internal/grill/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// `grill answer` in parallel from a TUI shell, for example).
type Manager struct {
mu sync.Mutex
dir string // JSON file directory (e.g. ~/.local/share/sin-code/grill)
dir string // JSON file directory (e.g. ~/.local/share/sin-code/grill)
sessions map[string]*Session // keyed by ID
}

Expand Down Expand Up @@ -109,11 +109,11 @@ func (m *Manager) Next(id string) (decision Decision, parentID string, err error
// Append a sub-question from the catalog.
q := catalogQuestion(s.Topic, len(s.Decisions))
child := Decision{
ID: fmt.Sprintf("d%d", len(s.Decisions)),
ParentID: d.ID,
Question: q,
Status: "open",
AskedAt: time.Now().UTC(),
ID: fmt.Sprintf("d%d", len(s.Decisions)),
ParentID: d.ID,
Question: q,
Status: "open",
AskedAt: time.Now().UTC(),
}
s.Decisions = append(s.Decisions, child)
s.UpdatedAt = child.AskedAt
Expand Down
16 changes: 8 additions & 8 deletions cmd/sin-code/internal/grill/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type Session struct {
// - "resolved" — operator is satisfied, the decision is final
// - "deferred" — operator wants to come back later
type Decision struct {
ID string `json:"id"`
ParentID string `json:"parent_id,omitempty"`
Question string `json:"question"`
Answer string `json:"answer,omitempty"`
Status string `json:"status"`
AskedAt time.Time `json:"asked_at"`
ID string `json:"id"`
ParentID string `json:"parent_id,omitempty"`
Question string `json:"question"`
Answer string `json:"answer,omitempty"`
Status string `json:"status"`
AskedAt time.Time `json:"asked_at"`
ResolvedAt time.Time `json:"resolved_at,omitempty"`
}

Expand All @@ -51,8 +51,8 @@ type Decision struct {
// during the interview. The CLI emits this in both human-readable
// text and JSON.
type Synthesize struct {
Resolved []string `json:"resolved"`
Open []string `json:"open"`
Resolved []string `json:"resolved"`
Open []string `json:"open"`
Assumptions []string `json:"assumptions"`
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/sin-code/internal/hooklife/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type mockHook struct {
run func(context.Context, Event) Decision
}

func (m mockHook) ID() string { return m.id }
func (m mockHook) Phases() []Phase { return m.phases }
func (m mockHook) ID() string { return m.id }
func (m mockHook) Phases() []Phase { return m.phases }
func (m mockHook) Run(ctx context.Context, ev Event) Decision {
if m.run != nil {
return m.run(ctx, ev)
Expand Down
4 changes: 2 additions & 2 deletions cmd/sin-code/internal/learning/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func TestBeforeTool_allowAndBlock(t *testing.T) {

type warnHook struct{}

func (warnHook) ID() string { return "test-warn" }
func (warnHook) Phases() []hooklife.Phase { return []hooklife.Phase{hooklife.PostToolUse} }
func (warnHook) ID() string { return "test-warn" }
func (warnHook) Phases() []hooklife.Phase { return []hooklife.Phase{hooklife.PostToolUse} }
func (warnHook) Run(context.Context, hooklife.Event) hooklife.Decision {
return hooklife.Decision{Verdict: hooklife.Warn, Message: "test warning"}
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/sin-code/internal/memory/memory_more_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
//go:build coverage

// SPDX-License-Identifier: MIT
// Purpose: targeted coverage tests for the memory package. These hit the
// error branches and edge cases that require package-level hooks.
// Docs: memory.doc.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
//go:build coverage

// SPDX-License-Identifier: MIT
// Purpose: coverage tests for the remaining branches in the notifications package.
package notifications

Expand Down
11 changes: 8 additions & 3 deletions cmd/sin-code/internal/orchestrator/stcov_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
//go:build coverage

// SPDX-License-Identifier: MIT
// Purpose: targeted coverage tests for remaining uncovered statements in the
// orchestrator package. Uses the package-level test hooks added to files that
// call external subprocesses.
Expand Down Expand Up @@ -4503,7 +4504,9 @@ func TestGovernorRunRungSpecRunError(t *testing.T) {
Ladder: []Rung{{Name: "multi", Agents: 2, RepairRounds: 1, Timeout: time.Second}},
Verifier: NewVerifier(t.TempDir()),
Checks: []Check{{Kind: CheckBuild, Name: "c", Cmd: []string{"true"}}},
Factory: func(rung Rung) []Agent { return []Agent{stcovAgent{name: "a1", out: "ok"}, stcovAgent{name: "a2", out: "ok"}} },
Factory: func(rung Rung) []Agent {
return []Agent{stcovAgent{name: "a1", out: "ok"}, stcovAgent{name: "a2", out: "ok"}}
},
}
res, err := g.Execute(context.Background(), &Task{ID: "t"}, NewScratchpad())
if err == nil || !strings.Contains(err.Error(), "spec run fail") {
Expand All @@ -4522,7 +4525,9 @@ func TestGovernorRunRungNoWinner(t *testing.T) {
Ladder: []Rung{{Name: "multi", Agents: 2, RepairRounds: 1, Timeout: time.Second}},
Verifier: NewVerifier(t.TempDir()),
Checks: []Check{{Kind: CheckBuild, Name: "c", Cmd: []string{"true"}}},
Factory: func(rung Rung) []Agent { return []Agent{stcovAgent{name: "a1", out: "ok"}, stcovAgent{name: "a2", out: "ok"}} },
Factory: func(rung Rung) []Agent {
return []Agent{stcovAgent{name: "a1", out: "ok"}, stcovAgent{name: "a2", out: "ok"}}
},
}
res, err := g.Execute(context.Background(), &Task{ID: "t"}, NewScratchpad())
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/sin-code/internal/plugins/plugins_coverage_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: MIT
//go:build coverage

// SPDX-License-Identifier: MIT
// Purpose: targeted coverage tests for the remaining error branches in the
// plugin manifest and registry packages.
package plugins
Expand Down
12 changes: 6 additions & 6 deletions cmd/sin-code/internal/rag/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ var ErrPoolClosed = errors.New("rag: worker pool closed")
// (size 1) so the worker can send without blocking, and the
// caller can read without coordinating with the worker.
type job struct {
ctx context.Context
text string
done chan result
ctx context.Context
text string
done chan result
}

type result struct {
Expand All @@ -34,9 +34,9 @@ type result struct {

// WorkerPool is the bounded-concurrency embedder.
type WorkerPool struct {
embedder Embedder
queue chan job
wg sync.WaitGroup
embedder Embedder
queue chan job
wg sync.WaitGroup
closeOnce sync.Once
closed chan struct{}
}
Expand Down
Loading
Loading