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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cache: true
- name: gofumpt
run: |
go install mvdan.cc/gofumpt@v0.7.0
go install mvdan.cc/gofumpt@v0.10.0
out=$(gofumpt -l .)
if [ -n "$out" ]; then
echo "::error::gofumpt would reformat:"
Expand Down
9 changes: 6 additions & 3 deletions cmd/ai_comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ func formatDirectivePrompt(d AIDirective) string {
if d.Mode == "?" {
b.WriteString(fmt.Sprintf(
"An AI question comment was found at %s:%d.\n\nQuestion: %s\n\n",
d.Path, d.Line, d.Instruction))
d.Path, d.Line, d.Instruction,
))
b.WriteString("Answer the question. If a code change is warranted, make it. ")
} else {
b.WriteString(fmt.Sprintf(
"An AI instruction comment was found at %s:%d.\n\nInstruction: %s\n\n",
d.Path, d.Line, d.Instruction))
d.Path, d.Line, d.Instruction,
))
b.WriteString("Implement this change now, editing the file in place. ")
}
b.WriteString(fmt.Sprintf(
"The directive lives in the file %s; after you finish, the AI comment token will be removed automatically.\n",
d.Path))
d.Path,
))
return b.String()
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,8 @@ func (m chatModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case compactMsg:
m.compacting = false
m.brailleSpinner.SetLabel(m.spinnerVerb)
line := fmt.Sprintf("Context compacted (%s): ~%s → ~%s tokens",
line := fmt.Sprintf(
"Context compacted (%s): ~%s → ~%s tokens",
msg.strategy,
formatHawkTokenCount(msg.tokensBefore),
formatHawkTokenCount(msg.tokensAfter),
Expand Down
3 changes: 2 additions & 1 deletion cmd/statusbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func renderStatusBarRight(m *chatModel) string {
meta = append(meta, dim.Render("⏸"))
}

parts := append(meta,
parts := append(
meta,
tokenStyle.Render(tokenText),
costStyle.Render(costText),
timeStyle.Render(timerText),
Expand Down
9 changes: 6 additions & 3 deletions internal/codegraph/algorithms_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ func (cg *CodeGraph) FindDeadCode() ([]DeadCodeEntry, error) {
defer cg.mu.RUnlock()

// Get all nodes
rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`,
Expand Down Expand Up @@ -769,7 +770,8 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult,
result.Impacted[s.id] = s.depth

// Get all nodes that depend on this one
rows, _ := cg.db.QueryContext(context.Background(),
rows, _ := cg.db.QueryContext(
context.Background(),
`SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.id,
)
if rows != nil {
Expand All @@ -790,7 +792,8 @@ func (cg *CodeGraph) ImpactAnalysis(nodeID string, maxDepth int) (*ImpactResult,
// Load node details
for id, depth := range result.Impacted {
var n Node
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE id = ?`, id,
Expand Down
54 changes: 36 additions & 18 deletions internal/codegraph/codegraph_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error {
defer cg.mu.Unlock()

for _, n := range nodes {
_, err := cg.db.ExecContext(context.Background(),
_, err := cg.db.ExecContext(
context.Background(),
`INSERT OR REPLACE INTO nodes (id, kind, name, qualified_name, file_path, language, start_line, end_line, signature, docstring, visibility, is_exported, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
n.ID, n.Kind, n.Name, n.QualifiedName, n.FilePath, n.Language,
Expand All @@ -378,7 +379,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error {
}

for _, e := range edges {
_, err := cg.db.ExecContext(context.Background(),
_, err := cg.db.ExecContext(
context.Background(),
`INSERT INTO edges (source, target, kind, line, metadata) VALUES (?, ?, ?, ?, ?)`,
e.Source, e.Target, e.Kind, e.Line, e.Metadata,
)
Expand All @@ -388,7 +390,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error {
}

for _, ref := range unresolvedRefs {
_, err := cg.db.ExecContext(context.Background(),
_, err := cg.db.ExecContext(
context.Background(),
`INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, file_path, language)
VALUES (?, ?, ?, ?, ?, ?)`,
ref.FromNodeID, ref.ReferenceName, ref.ReferenceKind, ref.Line, ref.FilePath, ref.Language,
Expand All @@ -400,7 +403,8 @@ func (cg *CodeGraph) IndexFile(filePath string) error {

// Update file record
hash := sha256Sum(source)
_, _ = cg.db.ExecContext(context.Background(),
_, _ = cg.db.ExecContext(
context.Background(),
`INSERT OR REPLACE INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
filePath, hash, ext, len(source), time.Now().Unix(), time.Now().Unix(), len(nodes),
Expand Down Expand Up @@ -439,7 +443,8 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) {
cg.mu.RLock()
defer cg.mu.RUnlock()

rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language,
n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported
FROM nodes_fts fts
Expand All @@ -450,7 +455,8 @@ func (cg *CodeGraph) Search(query string, limit int) ([]Node, error) {
)
if err != nil {
// Fallback to LIKE search
rows, err = cg.db.QueryContext(context.Background(),
rows, err = cg.db.QueryContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE name LIKE ? ORDER BY name LIMIT ?`,
Expand Down Expand Up @@ -491,7 +497,8 @@ func (cg *CodeGraph) GetCallers(nodeID string, maxDepth int) ([]Node, error) {
}
visited[current.id] = true

rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language,
n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported
FROM edges e JOIN nodes n ON n.id = e.source
Expand Down Expand Up @@ -542,7 +549,8 @@ func (cg *CodeGraph) GetCallees(nodeID string, maxDepth int) ([]Node, error) {
}
visited[current.id] = true

rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT n.id, n.kind, n.name, n.qualified_name, n.file_path, n.language,
n.start_line, n.end_line, n.signature, n.docstring, n.visibility, n.is_exported
FROM edges e JOIN nodes n ON n.id = e.target
Expand Down Expand Up @@ -578,7 +586,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error

// Get the focal node
var focalNode Node
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE id = ?`, nodeID,
Expand Down Expand Up @@ -615,7 +624,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error

// Get node
var n Node
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE id = ?`, s.nodeID,
Expand All @@ -630,7 +640,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error

// If container, expand children at same depth
if containerKinds[n.Kind] {
childRows, _ := cg.db.QueryContext(context.Background(),
childRows, _ := cg.db.QueryContext(
context.Background(),
`SELECT target FROM edges WHERE source = ? AND kind = 'contains'`, s.nodeID,
)
if childRows != nil {
Expand All @@ -646,7 +657,8 @@ func (cg *CodeGraph) GetImpactRadius(nodeID string, maxDepth int) ([]Node, error
}

// Traverse incoming edges (things that depend on this node)
depRows, _ := cg.db.QueryContext(context.Background(),
depRows, _ := cg.db.QueryContext(
context.Background(),
`SELECT source FROM edges WHERE target = ? AND kind IN ('calls', 'references', 'imports', 'extends', 'implements')`, s.nodeID,
)
if depRows != nil {
Expand Down Expand Up @@ -763,7 +775,8 @@ func (cg *CodeGraph) ResolveRefs() error {
for _, r := range refs {
// Try to find target by name
var targetID string
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id FROM nodes WHERE name = ? OR qualified_name LIKE ? LIMIT 1`,
r.name, "%"+r.name,
).Scan(&targetID)
Expand All @@ -772,7 +785,8 @@ func (cg *CodeGraph) ResolveRefs() error {
}

// Create edge
_, err = cg.db.ExecContext(context.Background(),
_, err = cg.db.ExecContext(
context.Background(),
`INSERT INTO edges (source, target, kind, line) VALUES (?, ?, ?, ?)`,
r.fromID, targetID, r.kind, r.line,
)
Expand Down Expand Up @@ -1200,7 +1214,8 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) {
var path []Node
for _, id := range current.path {
var n Node
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE id = ?`, id,
Expand All @@ -1216,7 +1231,8 @@ func (cg *CodeGraph) Trace(fromName, toName string) ([]Node, error) {
}

// Expand via call edges
edgeRows, _ := cg.db.QueryContext(context.Background(),
edgeRows, _ := cg.db.QueryContext(
context.Background(),
`SELECT target FROM edges WHERE source = ? AND kind IN ('calls', 'references') LIMIT 20`, current.nodeID,
)
if edgeRows != nil {
Expand Down Expand Up @@ -1438,7 +1454,8 @@ func (cg *CodeGraph) Status() (*StatusResult, error) {

// searchByName is an internal search that returns nodes matching a name.
func (cg *CodeGraph) searchByName(name string, limit int) ([]Node, error) {
rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE name = ? OR name LIKE ? LIMIT ?`,
Expand All @@ -1457,7 +1474,8 @@ func (cg *CodeGraph) GetNode(id string) (Node, error) {
defer cg.mu.RUnlock()

var n Node
err := cg.db.QueryRowContext(context.Background(),
err := cg.db.QueryRowContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE id = ?`, id,
Expand Down
3 changes: 2 additions & 1 deletion internal/codegraph/embeddings_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func (cg *CodeGraph) SemanticSearch(query string, limit int) ([]Node, error) {
queryVec := GenerateEmbedding(queryNode)

// Get all nodes
rows, err := cg.db.QueryContext(context.Background(),
rows, err := cg.db.QueryContext(
context.Background(),
`SELECT id, kind, name, qualified_name, file_path, language,
start_line, end_line, signature, docstring, visibility, is_exported
FROM nodes WHERE kind IN ('function', 'method', 'class', 'interface', 'struct')`,
Expand Down
3 changes: 2 additions & 1 deletion internal/engine/project/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ func runGit(t *testing.T, dir string, args ...string) {
}
cmd := exec.CommandContext(context.Background(), "git", args...)
cmd.Dir = dir
cmd.Env = append(os.Environ(),
cmd.Env = append(
os.Environ(),
"GIT_AUTHOR_DATE=2024-01-01T00:00:00Z",
"GIT_COMMITTER_DATE=2024-01-01T00:00:00Z",
"GIT_CONFIG_COUNT=2",
Expand Down
6 changes: 4 additions & 2 deletions internal/engine/structured_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ func (s *Session) ChatStructured(ctx context.Context, msgs []types.EyrieMessage,
} else {
// Retry once with a corrective instruction.
retryMsgs := append([]types.EyrieMessage(nil), msgs...)
retryMsgs = append(retryMsgs,
retryMsgs = append(
retryMsgs,
types.EyrieMessage{Role: "assistant", Content: responseText(resp)},
types.EyrieMessage{Role: "user", Content: fmt.Sprintf(
"Your previous response did not conform to the required JSON schema (%s). "+
"Respond again with ONLY valid JSON that matches the schema. Schema:\n%s",
vErr.Error(), schema)},
vErr.Error(), schema,
)},
)
retryResp, retryErr := s.client.Chat(ctx, retryMsgs, opts)
if retryErr != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/sandbox/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func (c *ContainerSandbox) Start(ctx context.Context) error {
}
// Inject declarative startup env vars (additive; nil when none configured).
args = append(args, c.runtime.StartupEnvArgs()...)
args = append(args,
args = append(
args,
c.image,
"sleep", "infinity",
)
Expand Down
3 changes: 2 additions & 1 deletion internal/session/session_gain.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func (g *GainTracker) Record(ctx context.Context, ev GainEvent) error {
if ev.Timestamp.IsZero() {
ev.Timestamp = time.Now()
}
_, err := g.store.db.ExecContext(ctx, `
_, err := g.store.db.ExecContext(
ctx, `
INSERT INTO gains
(session_id, ts, command, original_bytes, compressed_bytes,
original_tokens, compressed_tokens, mode, tier, model)
Expand Down
Loading