@jefuriiij/synthra 0.1.3 → 0.1.5

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/dist/cli/index.js CHANGED
@@ -18,7 +18,7 @@ var init_package = __esm({
18
18
  "package.json"() {
19
19
  package_default = {
20
20
  name: "@jefuriiij/synthra",
21
- version: "0.1.3",
21
+ version: "0.1.5",
22
22
  publishConfig: {
23
23
  access: "public"
24
24
  },
@@ -66,6 +66,7 @@ var init_package = __esm({
66
66
  dependencies: {
67
67
  "@hono/node-server": "^1.18.0",
68
68
  chokidar: "^5.0.0",
69
+ "cross-spawn": "^7.0.6",
69
70
  hono: "^4.12.23",
70
71
  ignore: "^7.0.0",
71
72
  sade: "^1.8.1",
@@ -73,6 +74,7 @@ var init_package = __esm({
73
74
  "web-tree-sitter": "~0.22.6"
74
75
  },
75
76
  devDependencies: {
77
+ "@types/cross-spawn": "^6.0.6",
76
78
  "@types/node": "^25.9.1",
77
79
  tsup: "^8.5.1",
78
80
  typescript: "^6.0.3",
@@ -862,7 +864,7 @@ var public_default = `<!doctype html>
862
864
 
863
865
  <!-- ============ Footer ============ -->
864
866
  <footer class="foot">
865
- <div>Synth<em>ra</em> \xB7 v0.1.3</div>
867
+ <div>Synth<em>ra</em> \xB7 v0.1.5</div>
866
868
  <div>Cost figures approximate \xB7 @jefuriiij</div>
867
869
  </footer>
868
870
 
@@ -3029,7 +3031,7 @@ import { mkdir as mkdir5, readFile as readFile10, stat as stat2, writeFile as wr
3029
3031
 
3030
3032
  // src/hooks/claude-md.ts
3031
3033
  import { readFile as readFile9, writeFile as writeFile4 } from "fs/promises";
3032
- var POLICY_VERSION = 1;
3034
+ var POLICY_VERSION = 2;
3033
3035
  var POLICY_BEGIN = `<!-- synthra-policy v${POLICY_VERSION} BEGIN -->`;
3034
3036
  var POLICY_END = `<!-- synthra-policy v${POLICY_VERSION} END -->`;
3035
3037
  var ANY_BLOCK_RE = /<!--\s*synthra-policy\s+v\d+\s+BEGIN\s*-->[\s\S]*?<!--\s*synthra-policy\s+v\d+\s+END\s*-->\s*/g;
@@ -3038,33 +3040,75 @@ function policyBlock() {
3038
3040
  POLICY_BEGIN,
3039
3041
  "## Synthra context policy",
3040
3042
  "",
3041
- "Synthra has pre-loaded a structured context pack into this session and",
3042
- "exposes the project's code graph through three MCP tools. **Prefer these",
3043
- "tools over Grep / Glob** \u2014 they are faster, cheaper, and already filtered",
3043
+ "Synthra has pre-loaded structured context into this session and exposes",
3044
+ "the project's code graph through MCP tools. **Prefer these tools over",
3045
+ "Grep / Glob / Read** \u2014 they are faster, cheaper, and already filtered",
3044
3046
  "to relevant files.",
3045
3047
  "",
3046
3048
  "### Tools",
3047
3049
  "",
3048
- "- **`graph_continue(query)`** \u2014 your default first move when you need",
3049
- " project context. Returns signatures + top function bodies + linked test",
3050
- ' files, with a `confidence` label. If `confidence === "high"`, **stop**:',
3051
- " do not call Grep/Glob for the same query.",
3052
- '- **`graph_read(target)`** \u2014 fetch source for a specific `"file/path.ts"`',
3053
- ' or `"file/path.ts::SymbolName"`. Use this once you know what you want.',
3050
+ "- **`graph_continue(query)`** \u2014 returns a `Confidence` label, the list",
3051
+ " of relevant `Files`, and signatures + top function bodies for those",
3052
+ " files. Your default first move when you need project context.",
3053
+ "- **`graph_read(target)`** \u2014 fetch source. Prefer the",
3054
+ ' `"file/path.ts::SymbolName"` form over a bare file path \u2014 reading one',
3055
+ " symbol is ~50 tokens, reading a whole file is thousands.",
3054
3056
  "- **`graph_register_edit(files)`** \u2014 after you edit files, call this so",
3055
- " Synthra ranks them higher and avoids surfacing stale snapshots.",
3057
+ " subsequent turns weight your changes and avoid stale snapshots.",
3056
3058
  "",
3057
- "### Rules",
3059
+ "### When to call `graph_continue` \u2014 and when to skip",
3058
3060
  "",
3059
- "1. Call `graph_continue` **before** Grep / Glob for any question about",
3060
- " project code. Grep / Glob calls for the same query may be blocked at",
3061
- " the hook layer when the graph already has a confident answer.",
3062
- '2. When `graph_continue` returns `confidence: "high"`, treat the pack as',
3063
- " authoritative \u2014 don't second-guess it with a Grep.",
3064
- "3. Use `graph_read` instead of `Read` when you only need a specific symbol",
3065
- " from a file (you get less noise + line numbers).",
3066
- "4. After editing files, call `graph_register_edit(files)` so subsequent",
3067
- " turns weight your changes correctly.",
3061
+ "**Call `graph_continue` only when you do NOT already know the relevant",
3062
+ "files.**",
3063
+ "",
3064
+ "Call it when:",
3065
+ "- This is the first message of a new task or conversation",
3066
+ "- The task shifts to a different area of the codebase",
3067
+ "- You need files you haven't seen yet in this session",
3068
+ "",
3069
+ "**Skip `graph_continue` when:**",
3070
+ "- You already identified the relevant files earlier in this conversation",
3071
+ "- You are doing follow-up work on files already read (verify, refactor,",
3072
+ " test, docs, cleanup, commit)",
3073
+ "- The task is pure text (commit message, explanation, summary)",
3074
+ "",
3075
+ 'If skipping, go directly to `graph_read("file.ts::symbol")` on what',
3076
+ "you already know.",
3077
+ "",
3078
+ "### Confidence caps",
3079
+ "",
3080
+ "When `graph_continue` returns:",
3081
+ "",
3082
+ "- **`Confidence: high`** \u2192 Stop. Do NOT Grep, Glob, or further explore",
3083
+ " for this query. The graph already has it.",
3084
+ "- **`Confidence: medium`** or **`low`** \u2192 You may use Grep / Glob",
3085
+ " sparingly, but the PreToolUse hook may still block redundant calls.",
3086
+ "",
3087
+ "### Reading code",
3088
+ "",
3089
+ "- **Always use `file::symbol` notation** with `graph_read`. Whole-file",
3090
+ " reads should be rare \u2014 only when you genuinely need the full file.",
3091
+ "- If `graph_continue`'s `Files` list contains a `::` entry, pass it",
3092
+ " verbatim to `graph_read`.",
3093
+ "",
3094
+ "### Don'ts",
3095
+ "",
3096
+ "- Don't Grep / Glob before calling `graph_continue` when required \u2014 the",
3097
+ " PreToolUse hook may block it.",
3098
+ "- Don't call `graph_continue` more than once per turn.",
3099
+ "- Don't read whole files when a symbol-level read would suffice.",
3100
+ "",
3101
+ "### Session-end resume note",
3102
+ "",
3103
+ `When the user signals they're done (e.g. "bye", "wrap up", "done"),`,
3104
+ "proactively update `.synthra/CONTEXT.md` with:",
3105
+ "",
3106
+ "- **Current Task**: one sentence on what was being worked on",
3107
+ "- **Key Decisions**: bullet list, max 3 items",
3108
+ "- **Next Steps**: bullet list, max 3 items",
3109
+ "",
3110
+ "Keep `CONTEXT.md` under 20 lines total. Don't summarise the conversation",
3111
+ "\u2014 write only what's needed to resume next session.",
3068
3112
  "",
3069
3113
  "_This block is managed by Synthra. Edits inside the BEGIN/END markers",
3070
3114
  "are overwritten on every `syn .` run._",
@@ -4724,14 +4768,13 @@ async function serveCommand(rawPath) {
4724
4768
  }
4725
4769
 
4726
4770
  // src/cli/start-claude.ts
4727
- import { spawn } from "child_process";
4771
+ import spawn from "cross-spawn";
4728
4772
  var MCP_NAME = "synthra";
4729
4773
  function runClaude(bin, args, cwd, stdio = "pipe") {
4730
4774
  return new Promise((resolve5) => {
4731
4775
  const proc = spawn(bin, args, {
4732
4776
  cwd,
4733
- stdio: stdio === "inherit" ? "inherit" : ["ignore", "pipe", "pipe"],
4734
- shell: process.platform === "win32"
4777
+ stdio: stdio === "inherit" ? "inherit" : ["ignore", "pipe", "pipe"]
4735
4778
  });
4736
4779
  let stdout = "";
4737
4780
  let stderr = "";