@jefuriiij/synthra 0.1.5 → 0.1.7
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 +54 -17
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard/index.js.map +1 -1
- package/dist/server/index.js +49 -12
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
21
|
+
version: "0.1.7",
|
|
22
22
|
publishConfig: {
|
|
23
23
|
access: "public"
|
|
24
24
|
},
|
|
@@ -864,7 +864,7 @@ var public_default = `<!doctype html>
|
|
|
864
864
|
|
|
865
865
|
<!-- ============ Footer ============ -->
|
|
866
866
|
<footer class="foot">
|
|
867
|
-
<div>Synth<em>ra</em> \xB7 v0.1.
|
|
867
|
+
<div>Synth<em>ra</em> \xB7 v0.1.7</div>
|
|
868
868
|
<div>Cost figures approximate \xB7 @jefuriiij</div>
|
|
869
869
|
</footer>
|
|
870
870
|
|
|
@@ -2631,7 +2631,7 @@ async function parseRust(f, source) {
|
|
|
2631
2631
|
}
|
|
2632
2632
|
|
|
2633
2633
|
// src/scanner/parsers/typescript.ts
|
|
2634
|
-
var
|
|
2634
|
+
var TS_QUERY = `
|
|
2635
2635
|
(function_declaration name: (identifier) @function.name) @function
|
|
2636
2636
|
(class_declaration name: (type_identifier) @class.name) @class
|
|
2637
2637
|
(interface_declaration name: (type_identifier) @interface.name) @interface
|
|
@@ -2641,11 +2641,22 @@ var QUERY12 = `
|
|
|
2641
2641
|
(lexical_declaration (variable_declarator name: (identifier) @const-fn.name value: [(arrow_function) (function_expression)])) @const-fn
|
|
2642
2642
|
(import_statement source: (string) @import)
|
|
2643
2643
|
`;
|
|
2644
|
+
var JS_QUERY = `
|
|
2645
|
+
(function_declaration name: (identifier) @function.name) @function
|
|
2646
|
+
(class_declaration name: (identifier) @class.name) @class
|
|
2647
|
+
(method_definition name: (property_identifier) @method.name) @method
|
|
2648
|
+
(lexical_declaration (variable_declarator name: (identifier) @const-fn.name value: [(arrow_function) (function_expression)])) @const-fn
|
|
2649
|
+
(import_statement source: (string) @import)
|
|
2650
|
+
(call_expression function: (identifier) @_require_fn arguments: (arguments . (string) @require_source))
|
|
2651
|
+
`;
|
|
2644
2652
|
function grammarFor(ext) {
|
|
2645
2653
|
if (ext === ".tsx" || ext === ".jsx") return "tsx";
|
|
2646
2654
|
if (ext === ".js" || ext === ".cjs" || ext === ".mjs") return "javascript";
|
|
2647
2655
|
return "typescript";
|
|
2648
2656
|
}
|
|
2657
|
+
function queryFor(grammar) {
|
|
2658
|
+
return grammar === "javascript" ? JS_QUERY : TS_QUERY;
|
|
2659
|
+
}
|
|
2649
2660
|
function unquote(s) {
|
|
2650
2661
|
return s.replace(/^["'`]|["'`]$/g, "");
|
|
2651
2662
|
}
|
|
@@ -2669,7 +2680,7 @@ async function parseTypeScript(f, source) {
|
|
|
2669
2680
|
const { parser, language } = await createParser(grammar);
|
|
2670
2681
|
const tree = parser.parse(source);
|
|
2671
2682
|
if (!tree) return { file: f, source, symbols, imports, calls: [] };
|
|
2672
|
-
const query = language.query(
|
|
2683
|
+
const query = language.query(queryFor(grammar));
|
|
2673
2684
|
const matches = query.matches(tree.rootNode);
|
|
2674
2685
|
for (const match of matches) {
|
|
2675
2686
|
const byName = /* @__PURE__ */ new Map();
|
|
@@ -2686,7 +2697,15 @@ async function parseTypeScript(f, source) {
|
|
|
2686
2697
|
continue;
|
|
2687
2698
|
}
|
|
2688
2699
|
const importNode = byName.get("import");
|
|
2689
|
-
if (importNode)
|
|
2700
|
+
if (importNode) {
|
|
2701
|
+
imports.push(unquote(importNode.text));
|
|
2702
|
+
continue;
|
|
2703
|
+
}
|
|
2704
|
+
const requireFn = byName.get("_require_fn");
|
|
2705
|
+
const requireSource = byName.get("require_source");
|
|
2706
|
+
if (requireFn && requireSource && requireFn.text === "require") {
|
|
2707
|
+
imports.push(unquote(requireSource.text));
|
|
2708
|
+
}
|
|
2690
2709
|
}
|
|
2691
2710
|
const seen = /* @__PURE__ */ new Set();
|
|
2692
2711
|
symbols = symbols.filter((s) => {
|
|
@@ -3045,6 +3064,12 @@ function policyBlock() {
|
|
|
3045
3064
|
"Grep / Glob / Read** \u2014 they are faster, cheaper, and already filtered",
|
|
3046
3065
|
"to relevant files.",
|
|
3047
3066
|
"",
|
|
3067
|
+
"> **Tool namespace.** Synthra's MCP tools are exposed as",
|
|
3068
|
+
"> `mcp__synthra__graph_continue`, `mcp__synthra__graph_read`, and",
|
|
3069
|
+
"> `mcp__synthra__graph_register_edit`. Below they are referred to by",
|
|
3070
|
+
"> their short names (`graph_continue` etc.) for readability \u2014 use the",
|
|
3071
|
+
"> full namespaced form when actually invoking them.",
|
|
3072
|
+
"",
|
|
3048
3073
|
"### Tools",
|
|
3049
3074
|
"",
|
|
3050
3075
|
"- **`graph_continue(query)`** \u2014 returns a `Confidence` label, the list",
|
|
@@ -3081,8 +3106,11 @@ function policyBlock() {
|
|
|
3081
3106
|
"",
|
|
3082
3107
|
"- **`Confidence: high`** \u2192 Stop. Do NOT Grep, Glob, or further explore",
|
|
3083
3108
|
" for this query. The graph already has it.",
|
|
3084
|
-
"- **`Confidence: medium`**
|
|
3085
|
-
"
|
|
3109
|
+
"- **`Confidence: medium`** \u2192 Read the listed `Files` directly via",
|
|
3110
|
+
' `graph_read("file::symbol")` *before* trying Grep. The graph has',
|
|
3111
|
+
" narrowed the search space \u2014 use it, don't bypass it.",
|
|
3112
|
+
"- **`Confidence: low`** \u2192 You may use Grep / Glob, but the PreToolUse",
|
|
3113
|
+
" hook may still block redundant calls.",
|
|
3086
3114
|
"",
|
|
3087
3115
|
"### Reading code",
|
|
3088
3116
|
"",
|
|
@@ -3139,8 +3167,16 @@ async function patchClaudeMd(path) {
|
|
|
3139
3167
|
}
|
|
3140
3168
|
|
|
3141
3169
|
// src/cli/bootstrap.ts
|
|
3142
|
-
var
|
|
3143
|
-
|
|
3170
|
+
var GITIGNORE_ENTRIES = [
|
|
3171
|
+
{
|
|
3172
|
+
comment: "added by synthra (heavy generated state \u2014 gitignored by design)",
|
|
3173
|
+
entry: ".synthra-graph/"
|
|
3174
|
+
},
|
|
3175
|
+
{
|
|
3176
|
+
comment: "added by synthra \u2014 MCP registration. Remove this line if you want to share the synthra MCP entry with teammates via committed .mcp.json",
|
|
3177
|
+
entry: ".mcp.json"
|
|
3178
|
+
}
|
|
3179
|
+
];
|
|
3144
3180
|
async function exists(path) {
|
|
3145
3181
|
try {
|
|
3146
3182
|
await stat2(path);
|
|
@@ -3160,11 +3196,12 @@ async function patchGitignore(path) {
|
|
|
3160
3196
|
existing = await readFile10(path, "utf8");
|
|
3161
3197
|
} catch {
|
|
3162
3198
|
}
|
|
3163
|
-
const
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
${
|
|
3167
|
-
|
|
3199
|
+
const trimmed = new Set(existing.split(/\r?\n/).map((l) => l.trim()));
|
|
3200
|
+
const missing = GITIGNORE_ENTRIES.filter((e) => !trimmed.has(e.entry));
|
|
3201
|
+
if (missing.length === 0) return false;
|
|
3202
|
+
const block = missing.map((m) => `# ${m.comment}
|
|
3203
|
+
${m.entry}`).join("\n") + "\n";
|
|
3204
|
+
const appendix = (existing.length === 0 || existing.endsWith("\n") ? "" : "\n") + (existing.length ? "\n" : "") + block;
|
|
3168
3205
|
await writeFile5(path, existing + appendix, "utf8");
|
|
3169
3206
|
return true;
|
|
3170
3207
|
}
|
|
@@ -4786,10 +4823,10 @@ function runClaude(bin, args, cwd, stdio = "pipe") {
|
|
|
4786
4823
|
}
|
|
4787
4824
|
async function registerMcp(bin, mcpPort, cwd) {
|
|
4788
4825
|
const url = `http://127.0.0.1:${mcpPort}/mcp`;
|
|
4789
|
-
await runClaude(bin, ["mcp", "remove", MCP_NAME, "--scope", "
|
|
4826
|
+
await runClaude(bin, ["mcp", "remove", MCP_NAME, "--scope", "project"], cwd).catch(() => void 0);
|
|
4790
4827
|
const reg = await runClaude(
|
|
4791
4828
|
bin,
|
|
4792
|
-
["mcp", "add", MCP_NAME, "--transport", "http", "--scope", "
|
|
4829
|
+
["mcp", "add", MCP_NAME, "--transport", "http", "--scope", "project", url],
|
|
4793
4830
|
cwd
|
|
4794
4831
|
);
|
|
4795
4832
|
if (reg.code !== 0) {
|
|
@@ -4801,7 +4838,7 @@ async function registerMcp(bin, mcpPort, cwd) {
|
|
|
4801
4838
|
return true;
|
|
4802
4839
|
}
|
|
4803
4840
|
async function unregisterMcp(bin, cwd) {
|
|
4804
|
-
const r = await runClaude(bin, ["mcp", "remove", MCP_NAME, "--scope", "
|
|
4841
|
+
const r = await runClaude(bin, ["mcp", "remove", MCP_NAME, "--scope", "project"], cwd);
|
|
4805
4842
|
if (r.code === 0) log.debug("unregistered MCP server");
|
|
4806
4843
|
}
|
|
4807
4844
|
async function spawnClaude(bin, opts) {
|