@jefuriiij/synthra 0.15.0 → 0.16.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,39 @@ For older versions, see [GitHub Releases](https://github.com/jefuriiij/synthra/r
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.16.1] — 2026-07-02
11
+
12
+ ### Added
13
+
14
+ - **Dashboard: a Commands page.** New sidebar entry (below Arsenal) listing every
15
+ `syn` command with its description and flags — including the macOS/Linux note
16
+ that the hooks need `jq`. No more digging through the README to remember
17
+ `syn remove --yes` or what `doctor` checks.
18
+
19
+ ---
20
+
21
+ ## [0.16.0] — 2026-07-02
22
+
23
+ ### Added
24
+
25
+ - **The Dispatcher — Synthra now routes your tasks.** On every prompt, Synthra
26
+ scores the request against every installed subagent and skill (plus the
27
+ project's language fingerprint) and — when it finds a clear fit — injects a
28
+ one-line hint: *"[Synthra route] This task fits agent 'X' (model: sonnet) +
29
+ skill 'Y'. Plan here first, then delegate execution."* Works for any domain
30
+ your arsenal covers: UI work routes to your frontend agents, security audits
31
+ to your security agents, and so on. Silent when unsure. Disable with
32
+ `SYN_NO_ROUTE`; tune the confidence bar with `SYN_ROUTE_MIN_SCORE`.
33
+ - **`route_task` tool** — the on-demand version: ask which installed
34
+ agent/skill fits a task and which model to run it on; returns ranked
35
+ candidates with match reasons.
36
+ - **Model policy baked in:** plan on the primary model, delegate execution to a
37
+ subagent on a cheaper one (Sonnet is ~5× cheaper than Opus on every rate).
38
+ Agents that pin their own `model:` are respected; everything else defaults to
39
+ a `sonnet` recommendation.
40
+
41
+ ---
42
+
10
43
  ## [0.15.0] — 2026-07-02
11
44
 
12
45
  ### Added
package/README.md CHANGED
@@ -1,226 +1,226 @@
1
- # Synthra
2
-
3
- > Local context engine for AI coding assistants. **Install once. Fire and forget.** Claude Code stops burning tokens on grep → glob → read → repeat — it queries a structured graph instead.
4
-
5
- Built first for Claude Code (IDE extension + CLI). Anything that speaks the Model Context Protocol can plug in.
6
-
7
- ```bash
8
- npm install -g @jefuriiij/synthra
9
- cd your-project
10
- syn .
11
- ```
12
-
13
- That's the whole setup. Open the Claude Code IDE extension in the same folder and work normally; `Ctrl+C` the terminal when you're done. Synthra hangs out in the background, watching for file saves, blocking redundant Greps, and tracking every turn — until you have a reason to look at the dashboard.
14
-
15
- ---
16
-
17
- ## What it saves you (real measurement)
18
-
19
- Same prompt, same Opus model, same Svelte/Node codebase. Dogfooding on a real production project (`windsor-stables`) shows:
20
-
21
- | Setup | Cost per session |
22
- |---|---|
23
- | Vanilla Claude Code | **$7.97** |
24
- | Synthra w/ MCP fixes (v0.1.6) | **$4.26** (-46%) |
25
- | Synthra w/ full graph tools (v0.1.7+) | **$2.05** (-74%) |
26
-
27
- A 3-turn WebSocket-auth walkthrough across 4 files. The savings come from Claude reading function signatures (`graph_read("file.ts::Symbol")`, ~50 tokens) instead of whole files (~2,000+), and from skipping Greps that the Moat blocks because the graph already has the answer.
28
-
29
- The math behind the dashboard's **Savings (floor)** card is shown live (`blocks × 500 tokens × $3/M`) so you can verify it for your own sessions instead of trusting the number on faith.
30
-
31
- ---
32
-
33
- ## What it does
34
-
35
- AI coding assistants burn tokens exploring the codebase on every turn. They lose context between turns and across sessions. They're blind to what *you* are doing in your editor between AI turns.
36
-
37
- Synthra is a tiny local CLI (~273 KB tarball, no SaaS, no telemetry, MIT) that sits between you and your AI:
38
-
39
- - **Pre-injects** a structured ~4K-token context pack (signatures + top function bodies + linked tests) at session start
40
- - **The Moat** — deterministically blocks Grep/Glob at the PreToolUse hook layer when the graph already has the answer. Returns `{"decision":"block"}` — Claude literally cannot disobey.
41
- - **Remembers** decisions and notes branch-by-branch in a git-tracked `.synthra/` directory so teammates inherit context
42
- - **Watches** file saves, branch switches, and uncommitted diffs (chokidar + a `.git/HEAD` watcher) so the AI knows what just changed
43
- - **Tracks** every token via Claude's transcript and reports estimated cost + savings on a live dashboard
44
- - **Updates with consent** — daily npm check prompts you on a TTY (`Update now? [y/N]`) and stays silent on CI
45
-
46
- When `syn .` runs, you see:
47
-
48
- ```
49
- [syn] ✅ scanned 123 files · 490 symbols · 574 edges
50
- [syn] 🧠 MCP http://127.0.0.1:8080 → registered as 'synthra'
51
- [syn] 📊 Dashboard http://127.0.0.1:8901
52
- [syn] 🪝 Hooks installed in .claude/settings.local.json
53
-
54
- [syn] 🤖 Ready — open the Claude Code IDE extension (or run `claude` in another terminal).
55
- ```
56
-
57
- ---
58
-
59
- ## MCP tools
60
-
61
- Ten tools exposed over HTTP MCP (namespaced as `mcp__synthra__*`). Claude calls these instead of Grep / Glob / Read for navigation:
62
-
63
- | Tool | Purpose |
64
- |---|---|
65
- | `graph_continue(query)` | Return the structured context pack — `Confidence` label + `Files` list + signatures + top function bodies |
66
- | `graph_read(target)` | Fetch source for `file/path.ts` or `file/path.ts::SymbolName` (the latter returns ~50 tokens vs thousands for a whole file) |
67
- | `graph_register_edit(files)` | Tell Synthra you edited files (boosts their ranking, avoids stale snapshots) |
68
- | `context_remember(text, kind)` | Persist a decision / task / fact / next-step / blocker, branch-aware |
69
- | `context_recall(kind?)` | Read previously-stored entries |
70
- | `recent_activity(since_ms?)` | What the human just saved / branch-switched / changed |
71
- | `count_tokens(text)` | Char/4 estimate for prompt budgeting |
72
- | `blast_radius(target, depth?)` | All files that depend on `target` transitively |
73
- | `dead_code(limit?)` | Files no other file imports and no test references |
74
-
75
- ---
76
-
77
- ## Languages
78
-
79
- Full symbol extraction:
80
-
81
- - **TypeScript** (`.ts`, `.tsx`, `.cts`, `.mts`, `.jsx`) — interfaces, type aliases, enums, classes, methods, arrow consts, ES imports
82
- - **JavaScript** (`.js`, `.cjs`, `.mjs`) — uses a JS-specific tree-sitter query (v0.1.7+) that captures CommonJS `require()` calls in addition to ES `import` statements, and uses the JS grammar's `(identifier)` node for class names
83
- - **Python** (`.py`, `.pyi`)
84
- - **Svelte** (`.svelte`) — `<script>` blocks reparsed as TS
85
- - **Vue** (`.vue`) — same
86
- - **Go** (`.go`)
87
- - **Rust** (`.rs`)
88
- - **Java** (`.java`)
89
- - **Kotlin** (`.kt`, `.kts`)
90
- - **PHP** (`.php`)
91
- - **Ruby** (`.rb`)
92
- - **C** (`.c`, `.h`)
93
- - **C++** (`.cpp`, `.cc`, `.cxx`, `.hpp`, `.hh`, `.hxx`)
94
- - **C#** / .NET (`.cs`)
95
- - **Dart** (`.dart`) — content indexed; symbol extraction is best-effort in v0.1
96
-
97
- Files in other formats (HTML, CSS, JSON, YAML, Markdown, images, etc.) are walked and content-indexed so keyword search still finds them — just no symbol-level granularity.
98
-
99
- ---
100
-
101
- ## Commands
102
-
103
- ```bash
104
- syn . # Default: scan + MCP + dashboard + hooks + claude mcp add.
105
- # Background-service; Ctrl+C to stop.
106
- syn . --launch-cli # Also spawn the `claude` CLI in this terminal.
107
- syn . --resume <id> # Resume a Claude session (requires --launch-cli).
108
- syn scan [path] # Scan only — walk + parse + write graph.
109
- syn serve [path] # Start the MCP server only.
110
- syn dashboard [path] # Run only the token dashboard (standalone process).
111
- syn doctor [path] # Diagnose this project's Synthra setup + environment.
112
- syn remove [path] # Uninstall Synthra from a project (accidental `syn .`?
113
- # This reverses it). Asks [y/N]; --yes to skip. Your own
114
- # gitignore lines / CLAUDE.md content / hooks survive.
115
- ```
116
-
117
- ---
118
-
119
- ## Storage layout
120
-
121
- When `syn .` runs in a project:
122
-
123
- ```
124
- your-project/
125
- ├── .gitignore # appended: .synthra-graph/, .mcp.json (with comments)
126
- ├── .mcp.json # Synthra registers here at --scope project so the IDE sees it.
127
- │ # Gitignored by default — remove the .gitignore line to share with teammates.
128
- ├── CLAUDE.md # appended: <!-- synthra-policy v2 ... -->
129
- ├── .claude/
130
- │ ├── settings.local.json # hooks merged (tagged with meta: "synthra-hook=true")
131
- │ └── hooks/ # synthra-prime.ps1, synthra-pre-tool-use.ps1, …
132
- ├── .synthra-graph/ # GITIGNORED — heavy machine-local state
133
- │ ├── info_graph.json
134
- │ ├── symbol_index.json
135
- │ ├── activity.jsonl
136
- │ ├── token_log.jsonl
137
- │ ├── gate_log.jsonl
138
- │ └── mcp_port
139
- └── .synthra/ # GIT-TRACKED — team's shared memory
140
- ├── context-store.json # decisions, tasks, facts (default branch)
141
- ├── CONTEXT.md # narrative summary
142
- └── branches/<sanitized>/ # per-branch overrides
143
- ```
144
-
145
- A global registry at `~/.synthra/projects.json` lists every project where Synthra has run, so `syn dashboard` can show aggregate stats across all of them.
146
-
147
- ---
148
-
149
- ## Coexistence
150
-
151
- Synthra plays nicely alongside other AI-context tools. It only writes to its own `.synthra/`, `.synthra-graph/`, and a single `synthra` entry inside `.mcp.json` (existing entries are preserved). It only modifies `CLAUDE.md` inside `<!-- synthra-policy v2 -->` markers. It tags hook entries with `meta: "synthra-hook=true"` so re-runs strip only its own entries from `settings.local.json`. If another tool also logs to a shared `token_log.jsonl`, the dashboard dedupes overlapping entries on read so totals don't double-count.
152
-
153
- ---
154
-
155
- ## Configuration
156
-
157
- Environment variables (all optional):
158
-
159
- | Variable | Default | Purpose |
160
- |---|---|---|
161
- | `SYN_MCP_PORT` | (auto 8080–8099) | Pin the MCP server port |
162
- | `SYN_DASHBOARD_PORT` | `8901` | Dashboard preferred port (falls back through 8901–8910) |
163
- | `SYN_HARD_MAX_READ_CHARS` | `4000` | Soft token budget for `graph_continue` packs |
164
- | `SYN_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
165
- | `SYN_CLAUDE_BIN` | `claude` | Override the `claude` binary location |
166
- | `SYN_NO_UPDATE_CHECK` | `0` | Set to `1` to disable the daily version-check ping |
167
-
168
- ---
169
-
170
- ## How the moat works
171
-
172
- The PreToolUse hook fires on every `Grep` / `Glob` call. The hook POSTs the tool input to Synthra's local server. The server runs the query through the graph and returns:
173
-
174
- - `decision: "allow"` if the graph has no confident match (low confidence)
175
- - `decision: "allow"` if the user just edited a matching file (recent-activity relaxation)
176
- - `decision: "block"` otherwise, with a reason pointing Claude at `graph_continue`
177
-
178
- Claude Code honors the block and pivots to the MCP tool. The structured pack is cheaper, faster, and pre-ranked. The CLAUDE.md policy block (managed by Synthra inside its own `<!-- synthra-policy v2 -->` markers) tells Claude when to call `graph_continue` and — importantly — when to skip it, so follow-up turns don't pay the pack cost again.
179
-
180
- ---
181
-
182
- ## Self-update
183
-
184
- Every `syn .` checks the npm registry for a newer version (no cache — always fresh; 2s hard timeout; silent fallthrough on network failure). When you're on latest, the check stays silent and `syn .` proceeds. When you're outdated:
185
-
186
- - **Interactive shell** (TTY) → you see `[syn] Synthra X.Y.Z is available (you have A.B.C). Update now? [y/N]:` *before* the scan starts. Type `y` to install; press Enter (or anything else) to skip and continue with the current version.
187
- - **Non-interactive** (CI, piped stdin) → silent one-line hint, no prompt.
188
- - **Disabled entirely** → set `SYN_NO_UPDATE_CHECK=1`.
189
-
190
- On `y`, Synthra spawns `npm install -g @jefuriiij/synthra@latest` with stdio inherited (you see npm's progress), then **prints the new version's `CHANGELOG.md` section** (so you know what you just got), then exits with re-run instructions — the running Node process is still the old version and can't hot-swap its own code mid-run.
191
-
192
- If you upgrade via `npm install -g @jefuriiij/synthra@latest` directly (outside Synthra's prompt), the next `syn .` notices and prints the changelog anyway. It tracks the last-seen version at `~/.synthra/last-seen-version.json`.
193
-
194
- ---
195
-
196
- ## Platform support
197
-
198
- | Platform | Status |
199
- |---|---|
200
- | **Windows** | ✅ Tested. PowerShell hook scripts; primary development target. |
201
- | **macOS / Linux** | ⚠️ Best-effort. Bash hook scripts ship and the installer selects them automatically, but the full `syn .` flow hasn't been verified on POSIX yet. The Stop hook (token logging) needs `jq` on PATH or it silently no-ops. |
202
-
203
- The platform-agnostic parts — `syn scan`, `syn serve`, `syn dashboard`, the MCP server, and the dashboard — are pure Node and run anywhere Node 18+ does. The hook integration is what's Windows-verified; POSIX is wired but untested. If you run it on macOS/Linux, [open an issue](https://github.com/jefuriiij/synthra/issues) with what you find.
204
-
205
- ---
206
-
207
- ## Development
208
-
209
- ```bash
210
- git clone https://github.com/jefuriiij/synthra
211
- cd synthra
212
- npm install
213
- npm link # makes `syn` available globally; rebuilds reflect immediately
214
- npm run build # tsup → dist/
215
- npm run dev # tsup --watch
216
- npm test # vitest
217
- npm run typecheck # tsc --noEmit
218
- ```
219
-
220
- See [`ROADMAP.md`](./ROADMAP.md) for milestone history (M1 scanner → M6 dashboard) and the v0.2 backlog.
221
-
222
- ---
223
-
224
- ## License
225
-
226
- [MIT](./LICENSE) — fork freely, ship freely, just keep the attribution. If Synthra ends up useful inside your own tool or product, a link back is appreciated but not required.
1
+ # Synthra
2
+
3
+ > Local context engine for AI coding assistants. **Install once. Fire and forget.** Claude Code stops burning tokens on grep → glob → read → repeat — it queries a structured graph instead.
4
+
5
+ Built first for Claude Code (IDE extension + CLI). Anything that speaks the Model Context Protocol can plug in.
6
+
7
+ ```bash
8
+ npm install -g @jefuriiij/synthra
9
+ cd your-project
10
+ syn .
11
+ ```
12
+
13
+ That's the whole setup. Open the Claude Code IDE extension in the same folder and work normally; `Ctrl+C` the terminal when you're done. Synthra hangs out in the background, watching for file saves, blocking redundant Greps, and tracking every turn — until you have a reason to look at the dashboard.
14
+
15
+ ---
16
+
17
+ ## What it saves you (real measurement)
18
+
19
+ Same prompt, same Opus model, same Svelte/Node codebase. Dogfooding on a real production project (`windsor-stables`) shows:
20
+
21
+ | Setup | Cost per session |
22
+ |---|---|
23
+ | Vanilla Claude Code | **$7.97** |
24
+ | Synthra w/ MCP fixes (v0.1.6) | **$4.26** (-46%) |
25
+ | Synthra w/ full graph tools (v0.1.7+) | **$2.05** (-74%) |
26
+
27
+ A 3-turn WebSocket-auth walkthrough across 4 files. The savings come from Claude reading function signatures (`graph_read("file.ts::Symbol")`, ~50 tokens) instead of whole files (~2,000+), and from skipping Greps that the Moat blocks because the graph already has the answer.
28
+
29
+ The math behind the dashboard's **Savings (floor)** card is shown live (`blocks × 500 tokens × $3/M`) so you can verify it for your own sessions instead of trusting the number on faith.
30
+
31
+ ---
32
+
33
+ ## What it does
34
+
35
+ AI coding assistants burn tokens exploring the codebase on every turn. They lose context between turns and across sessions. They're blind to what *you* are doing in your editor between AI turns.
36
+
37
+ Synthra is a tiny local CLI (~273 KB tarball, no SaaS, no telemetry, MIT) that sits between you and your AI:
38
+
39
+ - **Pre-injects** a structured ~4K-token context pack (signatures + top function bodies + linked tests) at session start
40
+ - **The Moat** — deterministically blocks Grep/Glob at the PreToolUse hook layer when the graph already has the answer. Returns `{"decision":"block"}` — Claude literally cannot disobey.
41
+ - **Remembers** decisions and notes branch-by-branch in a git-tracked `.synthra/` directory so teammates inherit context
42
+ - **Watches** file saves, branch switches, and uncommitted diffs (chokidar + a `.git/HEAD` watcher) so the AI knows what just changed
43
+ - **Tracks** every token via Claude's transcript and reports estimated cost + savings on a live dashboard
44
+ - **Updates with consent** — daily npm check prompts you on a TTY (`Update now? [y/N]`) and stays silent on CI
45
+
46
+ When `syn .` runs, you see:
47
+
48
+ ```
49
+ [syn] ✅ scanned 123 files · 490 symbols · 574 edges
50
+ [syn] 🧠 MCP http://127.0.0.1:8080 → registered as 'synthra'
51
+ [syn] 📊 Dashboard http://127.0.0.1:8901
52
+ [syn] 🪝 Hooks installed in .claude/settings.local.json
53
+
54
+ [syn] 🤖 Ready — open the Claude Code IDE extension (or run `claude` in another terminal).
55
+ ```
56
+
57
+ ---
58
+
59
+ ## MCP tools
60
+
61
+ Ten tools exposed over HTTP MCP (namespaced as `mcp__synthra__*`). Claude calls these instead of Grep / Glob / Read for navigation:
62
+
63
+ | Tool | Purpose |
64
+ |---|---|
65
+ | `graph_continue(query)` | Return the structured context pack — `Confidence` label + `Files` list + signatures + top function bodies |
66
+ | `graph_read(target)` | Fetch source for `file/path.ts` or `file/path.ts::SymbolName` (the latter returns ~50 tokens vs thousands for a whole file) |
67
+ | `graph_register_edit(files)` | Tell Synthra you edited files (boosts their ranking, avoids stale snapshots) |
68
+ | `context_remember(text, kind)` | Persist a decision / task / fact / next-step / blocker, branch-aware |
69
+ | `context_recall(kind?)` | Read previously-stored entries |
70
+ | `recent_activity(since_ms?)` | What the human just saved / branch-switched / changed |
71
+ | `count_tokens(text)` | Char/4 estimate for prompt budgeting |
72
+ | `blast_radius(target, depth?)` | All files that depend on `target` transitively |
73
+ | `dead_code(limit?)` | Files no other file imports and no test references |
74
+
75
+ ---
76
+
77
+ ## Languages
78
+
79
+ Full symbol extraction:
80
+
81
+ - **TypeScript** (`.ts`, `.tsx`, `.cts`, `.mts`, `.jsx`) — interfaces, type aliases, enums, classes, methods, arrow consts, ES imports
82
+ - **JavaScript** (`.js`, `.cjs`, `.mjs`) — uses a JS-specific tree-sitter query (v0.1.7+) that captures CommonJS `require()` calls in addition to ES `import` statements, and uses the JS grammar's `(identifier)` node for class names
83
+ - **Python** (`.py`, `.pyi`)
84
+ - **Svelte** (`.svelte`) — `<script>` blocks reparsed as TS
85
+ - **Vue** (`.vue`) — same
86
+ - **Go** (`.go`)
87
+ - **Rust** (`.rs`)
88
+ - **Java** (`.java`)
89
+ - **Kotlin** (`.kt`, `.kts`)
90
+ - **PHP** (`.php`)
91
+ - **Ruby** (`.rb`)
92
+ - **C** (`.c`, `.h`)
93
+ - **C++** (`.cpp`, `.cc`, `.cxx`, `.hpp`, `.hh`, `.hxx`)
94
+ - **C#** / .NET (`.cs`)
95
+ - **Dart** (`.dart`) — content indexed; symbol extraction is best-effort in v0.1
96
+
97
+ Files in other formats (HTML, CSS, JSON, YAML, Markdown, images, etc.) are walked and content-indexed so keyword search still finds them — just no symbol-level granularity.
98
+
99
+ ---
100
+
101
+ ## Commands
102
+
103
+ ```bash
104
+ syn . # Default: scan + MCP + dashboard + hooks + claude mcp add.
105
+ # Background-service; Ctrl+C to stop.
106
+ syn . --launch-cli # Also spawn the `claude` CLI in this terminal.
107
+ syn . --resume <id> # Resume a Claude session (requires --launch-cli).
108
+ syn scan [path] # Scan only — walk + parse + write graph.
109
+ syn serve [path] # Start the MCP server only.
110
+ syn dashboard [path] # Run only the token dashboard (standalone process).
111
+ syn doctor [path] # Diagnose this project's Synthra setup + environment.
112
+ syn remove [path] # Uninstall Synthra from a project (accidental `syn .`?
113
+ # This reverses it). Asks [y/N]; --yes to skip. Your own
114
+ # gitignore lines / CLAUDE.md content / hooks survive.
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Storage layout
120
+
121
+ When `syn .` runs in a project:
122
+
123
+ ```
124
+ your-project/
125
+ ├── .gitignore # appended: .synthra-graph/, .mcp.json (with comments)
126
+ ├── .mcp.json # Synthra registers here at --scope project so the IDE sees it.
127
+ │ # Gitignored by default — remove the .gitignore line to share with teammates.
128
+ ├── CLAUDE.md # appended: <!-- synthra-policy v2 ... -->
129
+ ├── .claude/
130
+ │ ├── settings.local.json # hooks merged (tagged with meta: "synthra-hook=true")
131
+ │ └── hooks/ # synthra-prime.ps1, synthra-pre-tool-use.ps1, …
132
+ ├── .synthra-graph/ # GITIGNORED — heavy machine-local state
133
+ │ ├── info_graph.json
134
+ │ ├── symbol_index.json
135
+ │ ├── activity.jsonl
136
+ │ ├── token_log.jsonl
137
+ │ ├── gate_log.jsonl
138
+ │ └── mcp_port
139
+ └── .synthra/ # GIT-TRACKED — team's shared memory
140
+ ├── context-store.json # decisions, tasks, facts (default branch)
141
+ ├── CONTEXT.md # narrative summary
142
+ └── branches/<sanitized>/ # per-branch overrides
143
+ ```
144
+
145
+ A global registry at `~/.synthra/projects.json` lists every project where Synthra has run, so `syn dashboard` can show aggregate stats across all of them.
146
+
147
+ ---
148
+
149
+ ## Coexistence
150
+
151
+ Synthra plays nicely alongside other AI-context tools. It only writes to its own `.synthra/`, `.synthra-graph/`, and a single `synthra` entry inside `.mcp.json` (existing entries are preserved). It only modifies `CLAUDE.md` inside `<!-- synthra-policy v2 -->` markers. It tags hook entries with `meta: "synthra-hook=true"` so re-runs strip only its own entries from `settings.local.json`. If another tool also logs to a shared `token_log.jsonl`, the dashboard dedupes overlapping entries on read so totals don't double-count.
152
+
153
+ ---
154
+
155
+ ## Configuration
156
+
157
+ Environment variables (all optional):
158
+
159
+ | Variable | Default | Purpose |
160
+ |---|---|---|
161
+ | `SYN_MCP_PORT` | (auto 8080–8099) | Pin the MCP server port |
162
+ | `SYN_DASHBOARD_PORT` | `8901` | Dashboard preferred port (falls back through 8901–8910) |
163
+ | `SYN_HARD_MAX_READ_CHARS` | `4000` | Soft token budget for `graph_continue` packs |
164
+ | `SYN_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
165
+ | `SYN_CLAUDE_BIN` | `claude` | Override the `claude` binary location |
166
+ | `SYN_NO_UPDATE_CHECK` | `0` | Set to `1` to disable the daily version-check ping |
167
+
168
+ ---
169
+
170
+ ## How the moat works
171
+
172
+ The PreToolUse hook fires on every `Grep` / `Glob` call. The hook POSTs the tool input to Synthra's local server. The server runs the query through the graph and returns:
173
+
174
+ - `decision: "allow"` if the graph has no confident match (low confidence)
175
+ - `decision: "allow"` if the user just edited a matching file (recent-activity relaxation)
176
+ - `decision: "block"` otherwise, with a reason pointing Claude at `graph_continue`
177
+
178
+ Claude Code honors the block and pivots to the MCP tool. The structured pack is cheaper, faster, and pre-ranked. The CLAUDE.md policy block (managed by Synthra inside its own `<!-- synthra-policy v2 -->` markers) tells Claude when to call `graph_continue` and — importantly — when to skip it, so follow-up turns don't pay the pack cost again.
179
+
180
+ ---
181
+
182
+ ## Self-update
183
+
184
+ Every `syn .` checks the npm registry for a newer version (no cache — always fresh; 2s hard timeout; silent fallthrough on network failure). When you're on latest, the check stays silent and `syn .` proceeds. When you're outdated:
185
+
186
+ - **Interactive shell** (TTY) → you see `[syn] Synthra X.Y.Z is available (you have A.B.C). Update now? [y/N]:` *before* the scan starts. Type `y` to install; press Enter (or anything else) to skip and continue with the current version.
187
+ - **Non-interactive** (CI, piped stdin) → silent one-line hint, no prompt.
188
+ - **Disabled entirely** → set `SYN_NO_UPDATE_CHECK=1`.
189
+
190
+ On `y`, Synthra spawns `npm install -g @jefuriiij/synthra@latest` with stdio inherited (you see npm's progress), then **prints the new version's `CHANGELOG.md` section** (so you know what you just got), then exits with re-run instructions — the running Node process is still the old version and can't hot-swap its own code mid-run.
191
+
192
+ If you upgrade via `npm install -g @jefuriiij/synthra@latest` directly (outside Synthra's prompt), the next `syn .` notices and prints the changelog anyway. It tracks the last-seen version at `~/.synthra/last-seen-version.json`.
193
+
194
+ ---
195
+
196
+ ## Platform support
197
+
198
+ | Platform | Status |
199
+ |---|---|
200
+ | **Windows** | ✅ Tested. PowerShell hook scripts; primary development target. |
201
+ | **macOS / Linux** | ⚠️ Best-effort. Bash hook scripts ship and the installer selects them automatically, but the full `syn .` flow hasn't been verified on POSIX yet. The Stop hook (token logging) needs `jq` on PATH or it silently no-ops. |
202
+
203
+ The platform-agnostic parts — `syn scan`, `syn serve`, `syn dashboard`, the MCP server, and the dashboard — are pure Node and run anywhere Node 18+ does. The hook integration is what's Windows-verified; POSIX is wired but untested. If you run it on macOS/Linux, [open an issue](https://github.com/jefuriiij/synthra/issues) with what you find.
204
+
205
+ ---
206
+
207
+ ## Development
208
+
209
+ ```bash
210
+ git clone https://github.com/jefuriiij/synthra
211
+ cd synthra
212
+ npm install
213
+ npm link # makes `syn` available globally; rebuilds reflect immediately
214
+ npm run build # tsup → dist/
215
+ npm run dev # tsup --watch
216
+ npm test # vitest
217
+ npm run typecheck # tsc --noEmit
218
+ ```
219
+
220
+ See [`ROADMAP.md`](./ROADMAP.md) for milestone history (M1 scanner → M6 dashboard) and the v0.2 backlog.
221
+
222
+ ---
223
+
224
+ ## License
225
+
226
+ [MIT](./LICENSE) — fork freely, ship freely, just keep the attribution. If Synthra ends up useful inside your own tool or product, a link back is appreciated but not required.