@madeinoz67/voice-server 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/codanna-explorer.md +30 -0
- package/.claude/agents/codanna-implementer.md +39 -0
- package/.claude/hooks/codanna-nudge.ts +100 -0
- package/.claude/hooks/codanna-reindex.ts +38 -0
- package/.claude/settings.json +67 -0
- package/.claude/settings.local.json +4 -1
- package/.codanna/settings.toml +71 -41
- package/.mcp.json +8 -0
- package/.orca/codanna-archive.ts +41 -0
- package/.orca/codanna-setup.ts +101 -0
- package/CHANGELOG.md +43 -65
- package/CLAUDE.md +51 -1
- package/Formula/madeinoz-voice-server.rb +1 -1
- package/cliff.toml +10 -5
- package/docs/assets/queue-system-overview-v2.png +0 -0
- package/docs/assets/voice-server-architecture-backup.png +0 -0
- package/homebrew.mxcl.voice-server.plist +33 -0
- package/orca.yaml +21 -0
- package/package.json +1 -1
- package/reports/agent/2025-02-09-12-00-fifo-queue-research.md +380 -0
- package/reports/agent/2026-02-09-queue-rate-limit-integration.md +250 -0
- package/reports/agent/2026-02-09-queued-async-error-handling.md +236 -0
- package/src/ts/services/notification-queue.ts +15 -12
- package/bun.lock +0 -208
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codanna-explorer
|
|
3
|
+
description: Read-only code exploration, impact analysis and review using the Codanna CLI (x-ray skill). Use for "where is X", "what calls Y", "what breaks if I change Z", architecture questions and pre-change investigations. Never edits files.
|
|
4
|
+
tools: Read, Grep, Glob, Bash
|
|
5
|
+
skills:
|
|
6
|
+
- codanna-toolset:x-ray
|
|
7
|
+
- codanna-toolset:graph
|
|
8
|
+
---
|
|
9
|
+
<!-- author: Stephen Eaton -->
|
|
10
|
+
|
|
11
|
+
You are a read-only code investigator. Use the preloaded `x-ray` skill's Reframe → Search → Inspect → Traverse loop with the `codanna` CLI. Do not use `mcp__codanna__*` tools; the CLI keeps you correct whichever checkout you're running in.
|
|
12
|
+
|
|
13
|
+
Process:
|
|
14
|
+
1. Reframe the request into an optimised technical query (x-ray "Reframe").
|
|
15
|
+
2. Search: `codanna mcp semantic_search_with_context query:"<q>" limit:5 --json`. Keep results with score > 0.6.
|
|
16
|
+
3. Inspect only the returned line ranges.
|
|
17
|
+
4. Traverse 1–2 important relationships per result: `codanna retrieve describe symbol_id:N`, `codanna mcp find_callers <Name> --json`.
|
|
18
|
+
5. For any "what breaks if…" question: `codanna mcp analyze_impact <Name> --json`.
|
|
19
|
+
6. Use `rg` for exact strings, config, HTML/CSS/templates and languages Codanna doesn't index.
|
|
20
|
+
7. Generate a visualisation (x-ray `visualize-*.js`, or the `graph` skill for whole-codebase shape) only when the user asks for one or the relationships are too tangled to explain in text. Report the output file path.
|
|
21
|
+
|
|
22
|
+
If a command exits with code 7, report that the index is stale. Do not re-index; that's a write.
|
|
23
|
+
|
|
24
|
+
Report back with:
|
|
25
|
+
- Answer first, in one or two sentences.
|
|
26
|
+
- Evidence: `path:line` references for every claim.
|
|
27
|
+
- For impact questions: every caller and affected file, grouped by module, with risk notes.
|
|
28
|
+
- Anything you could not resolve, stated plainly.
|
|
29
|
+
|
|
30
|
+
Hard limits: no file edits, no `codanna index`/`init`, no git writes. Use Bash only for `codanna mcp`, `codanna retrieve`, `rg`, `sed -n`, `git log`, `git diff`, `git show`, and the skills' `node` visualisation scripts.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codanna-implementer
|
|
3
|
+
description: Implements a scoped change in an isolated git worktree, using a worktree-local Codanna index through the CLI. Use for edits that must not touch the main checkout or that run in parallel with other agents.
|
|
4
|
+
isolation: worktree
|
|
5
|
+
disallowedTools: mcp__codanna__find_symbol, mcp__codanna__search_symbols, mcp__codanna__semantic_search_docs, mcp__codanna__semantic_search_with_context, mcp__codanna__get_calls, mcp__codanna__find_callers, mcp__codanna__analyze_impact, mcp__codanna__search_documents, mcp__codanna__get_index_info
|
|
6
|
+
---
|
|
7
|
+
<!-- author: Stephen Eaton -->
|
|
8
|
+
|
|
9
|
+
You work in your own git worktree. The `mcp__codanna__*` tools are disabled because they read the main checkout's index, which doesn't match your files. Use the `codanna` CLI from your worktree root.
|
|
10
|
+
|
|
11
|
+
## Step 0: build your index (once, before anything else)
|
|
12
|
+
Run from the worktree root:
|
|
13
|
+
```bash
|
|
14
|
+
test -f .codanna/settings.toml || codanna init
|
|
15
|
+
codanna index . --no-progress
|
|
16
|
+
```
|
|
17
|
+
If indexing takes more than a few minutes, mention it in your report. Don't skip it.
|
|
18
|
+
|
|
19
|
+
## Phase 1: explore (same loop as the x-ray skill)
|
|
20
|
+
1. Reframe the task into a technical query: search for what is meant, not the literal words.
|
|
21
|
+
2. Search: `codanna mcp semantic_search_with_context query:"<q>" limit:5 --json`. Keep results with score > 0.6. Use `codanna mcp find_symbol <Name> --json` for exact names.
|
|
22
|
+
3. Inspect only the returned line ranges (`sed -n 'A,Bp' file` or Read with offset/limit).
|
|
23
|
+
4. Traverse relationships: `codanna retrieve describe symbol_id:N`, `codanna mcp find_callers <Name> --json`, `codanna retrieve calls <Name>`.
|
|
24
|
+
5. Before changing any public symbol, signature or shared function: `codanna mcp analyze_impact <Name> --json`. Write down every caller you'll update.
|
|
25
|
+
6. Use `rg` for exact strings, config, HTML/CSS/templates and languages Codanna doesn't index.
|
|
26
|
+
7. Exit code 7 means the index is stale: run `codanna index . --no-progress` and retry.
|
|
27
|
+
|
|
28
|
+
## Phase 2: implement
|
|
29
|
+
1. Confirm the current file content before every edit.
|
|
30
|
+
2. A hook re-indexes each file you edit in this worktree. If results look inconsistent, run `codanna index . --no-progress`.
|
|
31
|
+
3. Re-run `analyze_impact` on changed symbols and check that no callers are missed.
|
|
32
|
+
4. Run the project's tests and linters in the worktree.
|
|
33
|
+
5. Commit on the worktree branch with a clear message. Do not push or merge.
|
|
34
|
+
|
|
35
|
+
## Report back
|
|
36
|
+
- What changed (files and the reason for each).
|
|
37
|
+
- Callers updated, and any that you deliberately left alone (with the reason).
|
|
38
|
+
- Test and lint results.
|
|
39
|
+
- The worktree branch name.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// codanna-nudge.ts — PostToolUse, one advisory per session.
|
|
3
|
+
//
|
|
4
|
+
// The "use Codanna before rg or grep" rule is prose, and prose loses to the default tool
|
|
5
|
+
// at the moment of a search. This fires once when a session reaches for rg, grep or Grep
|
|
6
|
+
// in a Codanna-indexed repo and has not used Codanna yet, then never again. PostToolUse
|
|
7
|
+
// exit 2 with stderr is the channel this repo already uses to reach the model
|
|
8
|
+
// (see ledger-guard.mjs); it cannot block a call.
|
|
9
|
+
//
|
|
10
|
+
// A nudge that nags is a hook people disable, so: once per session, and never for a
|
|
11
|
+
// tool that is not a search.
|
|
12
|
+
// author: Stephen Eaton
|
|
13
|
+
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
|
|
18
|
+
type HookEvent = {
|
|
19
|
+
cwd?: string;
|
|
20
|
+
session_id?: string;
|
|
21
|
+
tool_name?: string;
|
|
22
|
+
tool_input?: { command?: string };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type SessionState = { codanna: boolean; nudged: boolean };
|
|
26
|
+
|
|
27
|
+
const NUDGE = [
|
|
28
|
+
"",
|
|
29
|
+
"Codanna nudge: this repo is indexed, and this session has not used Codanna yet.",
|
|
30
|
+
'For symbol and "where is X" lookups, use Codanna before rg, grep or reading whole files:',
|
|
31
|
+
" main session: mcp__codanna__semantic_search_with_context, find_symbol, analyze_impact",
|
|
32
|
+
' worktree or subagent: codanna mcp semantic_search_with_context query:"..." limit:5 --json',
|
|
33
|
+
"rg stays right for exact strings, HTML, CSS, templates and config keys.",
|
|
34
|
+
"",
|
|
35
|
+
].join("\n");
|
|
36
|
+
|
|
37
|
+
function markerPath(sessionId: string | undefined): string {
|
|
38
|
+
const dir = join(tmpdir(), "claude-codanna-nudge");
|
|
39
|
+
try {
|
|
40
|
+
mkdirSync(dir, { recursive: true });
|
|
41
|
+
} catch {
|
|
42
|
+
// no marker means we nudge again; that is survivable
|
|
43
|
+
}
|
|
44
|
+
return join(dir, `${sessionId || "unknown"}.json`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function load(path: string): SessionState {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(readFileSync(path, "utf8")) as SessionState;
|
|
50
|
+
} catch {
|
|
51
|
+
return { codanna: false, nudged: false };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function save(path: string, state: SessionState): void {
|
|
56
|
+
try {
|
|
57
|
+
writeFileSync(path, JSON.stringify(state));
|
|
58
|
+
} catch {
|
|
59
|
+
// a nudge is never worth failing a tool call over
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function main(): Promise<number> {
|
|
64
|
+
let event: HookEvent;
|
|
65
|
+
try {
|
|
66
|
+
event = (await Bun.stdin.json()) as HookEvent;
|
|
67
|
+
} catch {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const cwd = event.cwd ?? process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
72
|
+
if (!existsSync(join(cwd, ".codanna", "settings.toml"))) return 0;
|
|
73
|
+
|
|
74
|
+
const path = markerPath(event.session_id);
|
|
75
|
+
const state = load(path);
|
|
76
|
+
const tool = String(event.tool_name ?? "");
|
|
77
|
+
const command = String(event.tool_input?.command ?? "");
|
|
78
|
+
|
|
79
|
+
// Any Codanna call disarms the nudge for the rest of the session. Both surfaces
|
|
80
|
+
// count: the MCP tools in the main session, and the CLI, which is the ONLY route
|
|
81
|
+
// for worktree subagents that cannot call mcp__codanna__* at all. Matching the
|
|
82
|
+
// command matters here — the tool name for a CLI call is just "Bash".
|
|
83
|
+
const isCodannaCall = tool.startsWith("mcp__codanna__") || /(?:^|&&|;|\|\|)\s*codanna\b/.test(command);
|
|
84
|
+
if (isCodannaCall) {
|
|
85
|
+
if (!state.codanna) save(path, { ...state, codanna: true });
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (state.codanna || state.nudged) return 0;
|
|
90
|
+
|
|
91
|
+
const isSearch =
|
|
92
|
+
tool === "Grep" || (tool === "Bash" && /^\s*(rg|grep)\b/.test(command));
|
|
93
|
+
if (!isSearch) return 0;
|
|
94
|
+
|
|
95
|
+
save(path, { codanna: false, nudged: true });
|
|
96
|
+
process.stderr.write(NUDGE);
|
|
97
|
+
return 2;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
process.exit(await main());
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// codanna-reindex.ts — Claude Code PostToolUse hook (Edit|Write).
|
|
3
|
+
// Re-indexes the edited file, but only inside a Claude Code subagent worktree
|
|
4
|
+
// (.claude/worktrees/*). The main checkout and Orca worktrees run
|
|
5
|
+
// `codanna serve --watch`, so the hook does nothing there.
|
|
6
|
+
// Skips silently when the worktree has no Codanna config yet. Always exits 0.
|
|
7
|
+
// author: Stephen Eaton
|
|
8
|
+
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
type HookInput = { cwd?: string; tool_input?: { file_path?: string } };
|
|
13
|
+
|
|
14
|
+
async function main(): Promise<void> {
|
|
15
|
+
let input: HookInput;
|
|
16
|
+
try { input = (await Bun.stdin.json()) as HookInput; } catch { return; }
|
|
17
|
+
|
|
18
|
+
const file = input.tool_input?.file_path;
|
|
19
|
+
const cwd = input.cwd;
|
|
20
|
+
if (!file || !cwd || !existsSync(cwd)) return;
|
|
21
|
+
if (!Bun.which("codanna") || !Bun.which("git")) return;
|
|
22
|
+
|
|
23
|
+
const git = Bun.spawnSync(["git", "rev-parse", "--show-toplevel"], { cwd, stdout: "pipe", stderr: "ignore" });
|
|
24
|
+
if (git.exitCode !== 0) return;
|
|
25
|
+
const top = git.stdout.toString().trim();
|
|
26
|
+
|
|
27
|
+
// Only Claude Code subagent worktrees need this.
|
|
28
|
+
if (!top.replaceAll("\\", "/").includes("/.claude/worktrees/")) return;
|
|
29
|
+
if (!existsSync(join(top, ".codanna", "settings.toml"))) return;
|
|
30
|
+
|
|
31
|
+
// Index just the changed file. Never use -f here: with a path, -f clears the whole index.
|
|
32
|
+
// Errors (unsupported file type, index not built yet) are ignored; the agent
|
|
33
|
+
// re-indexes on exit code 7 if the index goes stale.
|
|
34
|
+
Bun.spawnSync(["codanna", "index", file, "--no-progress"], { cwd: top, stdout: "ignore", stderr: "ignore" });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try { await main(); } catch { /* never fail the tool call */ }
|
|
38
|
+
process.exit(0);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extraKnownMarketplaces": {
|
|
3
|
+
"codanna": {
|
|
4
|
+
"source": {
|
|
5
|
+
"source": "github",
|
|
6
|
+
"repo": "bartolli/codanna"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"enabledPlugins": {
|
|
11
|
+
"codanna-toolset@codanna": true
|
|
12
|
+
},
|
|
13
|
+
"worktree": {
|
|
14
|
+
"baseRef": "head"
|
|
15
|
+
},
|
|
16
|
+
"permissions": {
|
|
17
|
+
"allow": [
|
|
18
|
+
"Bash(codanna mcp:*)",
|
|
19
|
+
"Bash(codanna retrieve:*)",
|
|
20
|
+
"Bash(codanna index:*)",
|
|
21
|
+
"Bash(codanna init)",
|
|
22
|
+
"Bash(codanna dump:*)",
|
|
23
|
+
"Bash(rg:*)",
|
|
24
|
+
"Bash(sed -n:*)",
|
|
25
|
+
"mcp__codanna__analyze_impact",
|
|
26
|
+
"mcp__codanna__find_callers",
|
|
27
|
+
"mcp__codanna__find_symbol",
|
|
28
|
+
"mcp__codanna__get_calls",
|
|
29
|
+
"mcp__codanna__get_index_info",
|
|
30
|
+
"mcp__codanna__search_documents",
|
|
31
|
+
"mcp__codanna__search_symbols",
|
|
32
|
+
"mcp__codanna__semantic_search_docs",
|
|
33
|
+
"mcp__codanna__semantic_search_with_context"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"hooks": {
|
|
37
|
+
"PostToolUse": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": "Edit|Write",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "bun \"${CLAUDE_PROJECT_DIR}/.claude/hooks/codanna-reindex.ts\""
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"matcher": "Bash|Grep",
|
|
49
|
+
"hooks": [
|
|
50
|
+
{
|
|
51
|
+
"type": "command",
|
|
52
|
+
"command": "bun \"${CLAUDE_PROJECT_DIR}/.claude/hooks/codanna-nudge.ts\""
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"matcher": "mcp__codanna__.*",
|
|
58
|
+
"hooks": [
|
|
59
|
+
{
|
|
60
|
+
"type": "command",
|
|
61
|
+
"command": "bun \"${CLAUDE_PROJECT_DIR}/.claude/hooks/codanna-nudge.ts\""
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"mcp__github__search_pull_requests",
|
|
18
18
|
"mcp__github__list_pull_requests",
|
|
19
19
|
"mcp__github__list_branches",
|
|
20
|
-
"mcp__github__list_issues"
|
|
20
|
+
"mcp__github__list_issues",
|
|
21
|
+
"mcp__github__create_pull_request",
|
|
22
|
+
"mcp__github__get_me",
|
|
23
|
+
"mcp__github__issue_write"
|
|
21
24
|
]
|
|
22
25
|
}
|
|
23
26
|
}
|
package/.codanna/settings.toml
CHANGED
|
@@ -22,22 +22,14 @@ tantivy_heap_mb = 50
|
|
|
22
22
|
# Exponential backoff: 100ms, 200ms, 400ms delays
|
|
23
23
|
max_retry_attempts = 3
|
|
24
24
|
|
|
25
|
-
# Additional patterns to ignore during indexing
|
|
26
|
-
ignore_patterns = [
|
|
27
|
-
"node_modules/**",
|
|
28
|
-
".git/**",
|
|
29
|
-
"*.generated.*",
|
|
30
|
-
]
|
|
31
|
-
|
|
32
25
|
# List of directories to index
|
|
26
|
+
# Ignore rules: .gitignore and .codannaignore (gitignore syntax)
|
|
33
27
|
# Add folders using: codanna add-dir <path>
|
|
34
28
|
# Remove folders using: codanna remove-dir <path>
|
|
35
29
|
# List all folders using: codanna list-dirs
|
|
36
30
|
indexed_paths = [
|
|
37
|
-
"src/ts",
|
|
38
|
-
"
|
|
39
|
-
"tests/ts", # TypeScript tests
|
|
40
|
-
"tests/py", # Python tests
|
|
31
|
+
"src/ts",
|
|
32
|
+
"tests/ts",
|
|
41
33
|
]
|
|
42
34
|
|
|
43
35
|
# Items per batch before flushing to index (default: 5000)
|
|
@@ -66,6 +58,16 @@ extensions = [
|
|
|
66
58
|
]
|
|
67
59
|
|
|
68
60
|
|
|
61
|
+
[languages.clojure]
|
|
62
|
+
enabled = true
|
|
63
|
+
extensions = [
|
|
64
|
+
"clj",
|
|
65
|
+
"cljc",
|
|
66
|
+
"cljs",
|
|
67
|
+
"edn",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
|
|
69
71
|
[languages.cpp]
|
|
70
72
|
enabled = true
|
|
71
73
|
extensions = [
|
|
@@ -167,8 +169,8 @@ extensions = [
|
|
|
167
169
|
|
|
168
170
|
[languages.python]
|
|
169
171
|
# Module resolution via pyproject.toml (Poetry, Hatch, Maturin, setuptools)
|
|
170
|
-
# Resolves imports like
|
|
171
|
-
config_files = ["pyproject.toml"]
|
|
172
|
+
# Resolves imports like mypackage.utils, src.models
|
|
173
|
+
# config_files = ["/path/to/project/pyproject.toml"]
|
|
172
174
|
enabled = true
|
|
173
175
|
extensions = [
|
|
174
176
|
"py",
|
|
@@ -198,6 +200,11 @@ extensions = ["swift"]
|
|
|
198
200
|
# "/path/to/project/tsconfig.json",
|
|
199
201
|
# "/path/to/project/packages/web/tsconfig.json",
|
|
200
202
|
# ]
|
|
203
|
+
# Register const bindings wrapped by higher-order functions
|
|
204
|
+
# (const View = memo(() => {})) as functions and index their bodies.
|
|
205
|
+
# Changing this list requires: codanna index --force
|
|
206
|
+
# [languages.typescript.parser_options]
|
|
207
|
+
# function_wrappers = ["memo", "forwardRef"]
|
|
201
208
|
enabled = true
|
|
202
209
|
extensions = [
|
|
203
210
|
"ts",
|
|
@@ -212,6 +219,14 @@ config_files = ["tsconfig.json"]
|
|
|
212
219
|
# Maximum context size in bytes for MCP server
|
|
213
220
|
max_context_size = 100000
|
|
214
221
|
|
|
222
|
+
# Host allowlist for Streamable HTTP inbound. None = loopback-only (localhost, 127.0.0.1, ::1).
|
|
223
|
+
# Required for non-loopback binds (0.0.0.0, public hostnames).
|
|
224
|
+
# allowed_hosts = ["codanna.example.com", "codanna.example.com:8080"]
|
|
225
|
+
|
|
226
|
+
# Origin allowlist for Streamable HTTP inbound. None = no Origin check. MCP clients are not browsers.
|
|
227
|
+
# Set when serving browser clients that send Origin headers.
|
|
228
|
+
# allowed_origins = ["https://app.example.com"]
|
|
229
|
+
|
|
215
230
|
|
|
216
231
|
[semantic_search]
|
|
217
232
|
# Semantic search for natural language code queries
|
|
@@ -233,6 +248,18 @@ threshold = 0.6
|
|
|
233
248
|
# Number of parallel embedding model instances (default: 3)
|
|
234
249
|
# Each instance uses ~86MB RAM. Higher values = faster indexing.
|
|
235
250
|
# Set to 1 for low-memory systems, 4-6 for high-end machines.
|
|
251
|
+
# Also sizes the ONNX Runtime thread pool every local embedding session
|
|
252
|
+
# shares (about 2N-1 busy threads at peak). Clamped to 1..=logical CPUs.
|
|
253
|
+
# Fixed at first use in a process; restart serve to change it.
|
|
254
|
+
|
|
255
|
+
# Remote embedding server (optional, replaces local fastembed)
|
|
256
|
+
# Supports OpenAI, Ollama, vLLM, Infinity, or any OpenAI-compatible endpoint.
|
|
257
|
+
# Uncomment and configure to use a remote server instead of local models.
|
|
258
|
+
# remote_url = "http://localhost:11434" # server base URL
|
|
259
|
+
# remote_model = "nomic-embed-text" # model name to send
|
|
260
|
+
# remote_dim = 768 # output dimension
|
|
261
|
+
# API key: set CODANNA_EMBED_API_KEY environment variable (not stored in config)
|
|
262
|
+
# Override any field with env vars: CODANNA_EMBED_URL, CODANNA_EMBED_MODEL, CODANNA_EMBED_DIM
|
|
236
263
|
embedding_threads = 3
|
|
237
264
|
|
|
238
265
|
|
|
@@ -283,29 +310,6 @@ tantivy = "warn"
|
|
|
283
310
|
[guidance]
|
|
284
311
|
enabled = true
|
|
285
312
|
|
|
286
|
-
[guidance.templates.find_symbol]
|
|
287
|
-
no_results = "Symbol not found. Use 'search_symbols' with fuzzy matching or 'semantic_search_docs' for broader search."
|
|
288
|
-
single_result = "Symbol found with full context. Explore 'get_calls' to see what it calls, 'find_callers' to see usage, or 'analyze_impact' to understand change implications."
|
|
289
|
-
multiple_results = "Found {result_count} symbols with that name. Review each to find the one you're looking for."
|
|
290
|
-
|
|
291
|
-
[guidance.templates.search_symbols]
|
|
292
|
-
no_results = "No symbols match your query. Try 'semantic_search_docs' for natural language search or adjust your pattern."
|
|
293
|
-
single_result = "Found exactly one match. Use 'find_symbol' to get full details about this symbol."
|
|
294
|
-
multiple_results = "Found {result_count} matching symbols. Use 'find_symbol' on specific results for full context or narrow your search with 'kind' parameter."
|
|
295
|
-
|
|
296
|
-
[guidance.templates.get_index_info]
|
|
297
|
-
single_result = "Index statistics loaded. Use search tools to explore the codebase."
|
|
298
|
-
|
|
299
|
-
[guidance.templates.semantic_search_with_context]
|
|
300
|
-
no_results = "No semantic matches found. Try different phrasing or ensure documentation exists for the concepts you're searching."
|
|
301
|
-
single_result = "Found one match with full context. Review the relationships to understand how this fits into the codebase."
|
|
302
|
-
multiple_results = "Rich context provided for {result_count} matches. Investigate specific relationships using targeted tools like 'get_calls' or 'find_callers'."
|
|
303
|
-
|
|
304
|
-
[guidance.templates.get_calls]
|
|
305
|
-
no_results = "No function calls found. This might be a leaf function or data structure."
|
|
306
|
-
single_result = "Found 1 function call. Use 'find_symbol' to explore this dependency."
|
|
307
|
-
multiple_results = "Found {result_count} function calls. Consider using 'find_symbol' on key dependencies or 'analyze_impact' to trace the call chain further."
|
|
308
|
-
|
|
309
313
|
[guidance.templates.analyze_impact]
|
|
310
314
|
no_results = "No impact detected. This symbol appears isolated. Consider using the codanna-navigator agent for comprehensive multi-hop analysis of complex relationships."
|
|
311
315
|
single_result = "Minimal impact radius. This symbol has limited dependencies."
|
|
@@ -320,6 +324,29 @@ template = "Limited impact radius with {result_count} affected symbols. This cha
|
|
|
320
324
|
min = 20
|
|
321
325
|
template = "Significant impact with {result_count} affected symbols. Consider breaking this change into smaller parts."
|
|
322
326
|
|
|
327
|
+
[guidance.templates.find_callers]
|
|
328
|
+
no_results = "No callers found. This might be an entry point, unused code, or called dynamically."
|
|
329
|
+
single_result = "Found 1 caller. Use 'find_symbol' to explore where this function is used."
|
|
330
|
+
multiple_results = "Found {result_count} callers. Consider 'analyze_impact' for complete dependency graph or investigate specific callers with 'find_symbol'."
|
|
331
|
+
|
|
332
|
+
[guidance.templates.find_symbol]
|
|
333
|
+
no_results = "Symbol not found. Use 'search_symbols' with fuzzy matching or 'semantic_search_docs' for broader search."
|
|
334
|
+
single_result = "Symbol found with full context. Explore 'get_calls' to see what it calls, 'find_callers' to see usage, or 'analyze_impact' to understand change implications."
|
|
335
|
+
multiple_results = "Found {result_count} symbols with that name. Review each to find the one you're looking for."
|
|
336
|
+
|
|
337
|
+
[guidance.templates.get_calls]
|
|
338
|
+
no_results = "No function calls found. This might be a leaf function or data structure."
|
|
339
|
+
single_result = "Found 1 function call. Use 'find_symbol' to explore this dependency."
|
|
340
|
+
multiple_results = "Found {result_count} function calls. Consider using 'find_symbol' on key dependencies or 'analyze_impact' to trace the call chain further."
|
|
341
|
+
|
|
342
|
+
[guidance.templates.get_index_info]
|
|
343
|
+
single_result = "Index statistics loaded. Use search tools to explore the codebase."
|
|
344
|
+
|
|
345
|
+
[guidance.templates.search_symbols]
|
|
346
|
+
no_results = "No symbols match your query. Try 'semantic_search_docs' for natural language search or adjust your pattern."
|
|
347
|
+
single_result = "Found exactly one match. Use 'find_symbol' to get full details about this symbol."
|
|
348
|
+
multiple_results = "Found {result_count} matching symbols. Use 'find_symbol' on specific results for full context or narrow your search with 'kind' parameter."
|
|
349
|
+
|
|
323
350
|
[guidance.templates.semantic_search_docs]
|
|
324
351
|
no_results = "No results found. Try broader search terms or check if the codebase is indexed."
|
|
325
352
|
single_result = "Found one match. Consider using 'find_symbol' or 'get_calls' to explore this symbol's relationships."
|
|
@@ -329,10 +356,10 @@ multiple_results = "Found {result_count} matches. Consider using 'find_symbol' o
|
|
|
329
356
|
min = 10
|
|
330
357
|
template = "Found {result_count} matches. Consider refining your search with more specific terms."
|
|
331
358
|
|
|
332
|
-
[guidance.templates.
|
|
333
|
-
no_results = "No
|
|
334
|
-
single_result = "Found
|
|
335
|
-
multiple_results = "
|
|
359
|
+
[guidance.templates.semantic_search_with_context]
|
|
360
|
+
no_results = "No semantic matches found. Try different phrasing or ensure documentation exists for the concepts you're searching."
|
|
361
|
+
single_result = "Found one match with full context. Review the relationships to understand how this fits into the codebase."
|
|
362
|
+
multiple_results = "Rich context provided for {result_count} matches. Investigate specific relationships using targeted tools like 'get_calls' or 'find_callers'."
|
|
336
363
|
|
|
337
364
|
[guidance.variables]
|
|
338
365
|
project = "codanna"
|
|
@@ -377,7 +404,10 @@ highlight = true
|
|
|
377
404
|
# paths: directories or files to include
|
|
378
405
|
# patterns: glob patterns to match (default: ["**/*.md"])
|
|
379
406
|
[documents.collections.docs]
|
|
380
|
-
paths = [
|
|
407
|
+
paths = [
|
|
408
|
+
"docs",
|
|
409
|
+
"specs",
|
|
410
|
+
]
|
|
381
411
|
patterns = [
|
|
382
412
|
"**/*.md",
|
|
383
413
|
"**/*.txt",
|
package/.mcp.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// codanna-archive.ts — Orca scripts.archive: stop any Codanna server still bound to
|
|
3
|
+
// this worktree before Orca deletes it. The index lives inside the worktree and is
|
|
4
|
+
// removed with it.
|
|
5
|
+
// author: Stephen Eaton
|
|
6
|
+
|
|
7
|
+
import { existsSync, readlinkSync, realpathSync } from "node:fs";
|
|
8
|
+
import { sep } from "node:path";
|
|
9
|
+
|
|
10
|
+
const wtRaw = process.env.ORCA_WORKTREE_PATH || process.cwd();
|
|
11
|
+
const wt = existsSync(wtRaw) ? realpathSync(wtRaw) : wtRaw;
|
|
12
|
+
|
|
13
|
+
function out(cmd: string[]): string {
|
|
14
|
+
if (!Bun.which(cmd[0])) return "";
|
|
15
|
+
const p = Bun.spawnSync(cmd, { stdout: "pipe", stderr: "ignore" });
|
|
16
|
+
return p.exitCode === 0 ? p.stdout.toString() : "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function cwdOf(pid: number): string {
|
|
20
|
+
const proc = `/proc/${pid}/cwd`;
|
|
21
|
+
if (existsSync(proc)) {
|
|
22
|
+
try { return readlinkSync(proc); } catch { return ""; }
|
|
23
|
+
}
|
|
24
|
+
// macOS: lsof prints the cwd as an "n<path>" field
|
|
25
|
+
const line = out(["lsof", "-a", "-p", String(pid), "-d", "cwd", "-Fn"])
|
|
26
|
+
.split("\n").find((l) => l.startsWith("n"));
|
|
27
|
+
return line ? line.slice(1) : "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const pids = out(["pgrep", "-f", "codanna.*serve"]).split(/\s+/).filter(Boolean).map(Number);
|
|
32
|
+
for (const pid of pids) {
|
|
33
|
+
if (pid === process.pid) continue;
|
|
34
|
+
const cwd = cwdOf(pid);
|
|
35
|
+
if (cwd && (cwd === wt || cwd.startsWith(wt + sep))) {
|
|
36
|
+
try { process.kill(pid, "SIGTERM"); process.stderr.write(`codanna-archive: stopped codanna serve pid ${pid}\n`); }
|
|
37
|
+
catch { /* already gone */ }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch { /* never block deletion */ }
|
|
41
|
+
process.exit(0);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// codanna-setup.ts — Orca scripts.setup: build a worktree-local Codanna index so
|
|
3
|
+
// the project .mcp.json server (codanna serve --watch) and the CLI both answer
|
|
4
|
+
// from THIS worktree's files.
|
|
5
|
+
// Fail-soft: never blocks worktree creation; problems go to the log and stderr.
|
|
6
|
+
// author: Stephen Eaton
|
|
7
|
+
//
|
|
8
|
+
// Options (environment):
|
|
9
|
+
// CODANNA_SEED_FROM_ROOT=1 copy the primary checkout's .codanna/index first, then
|
|
10
|
+
// re-index. Faster on big repos ONLY if the index stores
|
|
11
|
+
// relative paths (unverified). Test before enabling.
|
|
12
|
+
// CODANNA_SETUP_THREADS=N indexing threads (default: all cores)
|
|
13
|
+
|
|
14
|
+
import { appendFileSync, cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
|
|
17
|
+
const wt = process.env.ORCA_WORKTREE_PATH || process.cwd();
|
|
18
|
+
const root = process.env.ORCA_ROOT_PATH || "";
|
|
19
|
+
const name = process.env.ORCA_WORKSPACE_NAME || wt;
|
|
20
|
+
|
|
21
|
+
const codannaDir = join(wt, ".codanna");
|
|
22
|
+
const logFile = join(codannaDir, "setup.log");
|
|
23
|
+
|
|
24
|
+
const stamp = () => new Date().toLocaleString("sv-SE"); // local time, YYYY-MM-DD HH:MM:SS
|
|
25
|
+
function log(msg: string): void {
|
|
26
|
+
const line = `${stamp()} ${msg}\n`;
|
|
27
|
+
try { appendFileSync(logFile, line); } catch { /* log dir missing: stderr only */ }
|
|
28
|
+
process.stderr.write(line);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function codanna(args: string[]): number {
|
|
32
|
+
const p = Bun.spawnSync(["codanna", ...args], { cwd: wt, stdout: "pipe", stderr: "pipe" });
|
|
33
|
+
try {
|
|
34
|
+
appendFileSync(logFile, p.stdout);
|
|
35
|
+
appendFileSync(logFile, p.stderr);
|
|
36
|
+
} catch { /* ignore */ }
|
|
37
|
+
return p.exitCode ?? 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function main(): void {
|
|
41
|
+
if (!existsSync(wt)) {
|
|
42
|
+
process.stderr.write(`codanna-setup: worktree path not found: ${wt}\n`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
mkdirSync(codannaDir, { recursive: true });
|
|
46
|
+
|
|
47
|
+
if (!Bun.which("codanna")) {
|
|
48
|
+
log("codanna not on PATH: skipping index build (install: brew install codanna)");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 1. Config: prefer the committed settings.toml; else copy from root; else init.
|
|
53
|
+
const settings = join(codannaDir, "settings.toml");
|
|
54
|
+
if (!existsSync(settings)) {
|
|
55
|
+
const rootSettings = root ? join(root, ".codanna", "settings.toml") : "";
|
|
56
|
+
if (rootSettings && existsSync(rootSettings)) {
|
|
57
|
+
cpSync(rootSettings, settings);
|
|
58
|
+
log("copied settings.toml from primary checkout");
|
|
59
|
+
} else if (codanna(["init"]) === 0) {
|
|
60
|
+
log("ran codanna init");
|
|
61
|
+
} else {
|
|
62
|
+
log("codanna init failed; continuing with defaults");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 2. Optional seed (opt-in, unverified; see header).
|
|
67
|
+
const index = join(codannaDir, "index");
|
|
68
|
+
const rootIndex = root ? join(root, ".codanna", "index") : "";
|
|
69
|
+
if (process.env.CODANNA_SEED_FROM_ROOT === "1" && rootIndex && existsSync(rootIndex) && !existsSync(index)) {
|
|
70
|
+
cpSync(rootIndex, index, { recursive: true });
|
|
71
|
+
log("seeded index from primary checkout");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 3. Build the index. No path argument: passing "." makes codanna rewrite the tracked
|
|
75
|
+
// settings.toml with an absolute workspace_root and an extra absolute root entry.
|
|
76
|
+
const args = ["index", "--no-progress"];
|
|
77
|
+
if (process.env.CODANNA_SETUP_THREADS) args.push("--threads", process.env.CODANNA_SETUP_THREADS);
|
|
78
|
+
const start = performance.now();
|
|
79
|
+
const code = codanna(args);
|
|
80
|
+
const secs = Math.round((performance.now() - start) / 1000);
|
|
81
|
+
if (code === 0) log(`index built in ${secs}s for ${name}`);
|
|
82
|
+
else log(`codanna index failed (exit ${code}); agents will see exit code 7 and can re-run 'codanna index'`);
|
|
83
|
+
|
|
84
|
+
// 4. Document collections (search_documents reads these, and the code index does not
|
|
85
|
+
// cover them). Indexing appends, so clear the store first or every run duplicates
|
|
86
|
+
// every chunk.
|
|
87
|
+
const settingsText = existsSync(settings) ? readFileSync(settings, "utf8") : "";
|
|
88
|
+
const collections = [...settingsText.matchAll(/^\[documents\.collections\.([^\]]+)\]/gm)].map((m) => m[1].trim());
|
|
89
|
+
if (collections.length === 0) {
|
|
90
|
+
log("no document collections configured; skipping document index");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
rmSync(join(index, "documents"), { recursive: true, force: true });
|
|
94
|
+
for (const c of collections) {
|
|
95
|
+
const docCode = codanna(["documents", "index", "--collection", c, "--no-progress"]);
|
|
96
|
+
log(docCode === 0 ? `documents indexed for collection ${c}` : `codanna documents index failed for ${c} (exit ${docCode})`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
try { main(); } catch (err) { log(`setup error: ${(err as Error).message}`); }
|
|
101
|
+
process.exit(0);
|