@jefuriiij/synthra 0.1.6 → 0.1.8
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 +66 -10
- 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 +22 -3
- 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.8",
|
|
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.8</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) => {
|
|
@@ -4661,6 +4680,8 @@ async function dashboardCommand(rawPath) {
|
|
|
4661
4680
|
import { mkdir as mkdir10, readFile as readFile14, writeFile as writeFile9 } from "fs/promises";
|
|
4662
4681
|
import { homedir as homedir3 } from "os";
|
|
4663
4682
|
import { join as join10 } from "path";
|
|
4683
|
+
import { createInterface } from "readline/promises";
|
|
4684
|
+
import spawn from "cross-spawn";
|
|
4664
4685
|
var PKG_NAME = "@jefuriiij/synthra";
|
|
4665
4686
|
var CACHE_DIR = join10(homedir3(), ".synthra");
|
|
4666
4687
|
var CACHE_PATH = join10(CACHE_DIR, "version-check.json");
|
|
@@ -4743,14 +4764,49 @@ async function checkForUpdate() {
|
|
|
4743
4764
|
const hasUpdate = latest ? isNewer(latest, current) : false;
|
|
4744
4765
|
return { current, latest, hasUpdate };
|
|
4745
4766
|
}
|
|
4746
|
-
async function
|
|
4767
|
+
async function promptYesNo(question) {
|
|
4768
|
+
if (!process.stdin.isTTY) return false;
|
|
4769
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
4770
|
+
try {
|
|
4771
|
+
const answer = (await rl.question(question)).trim().toLowerCase();
|
|
4772
|
+
return answer === "y" || answer === "yes";
|
|
4773
|
+
} finally {
|
|
4774
|
+
rl.close();
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
function runNpmUpdate() {
|
|
4778
|
+
return new Promise((resolve5) => {
|
|
4779
|
+
const proc = spawn("npm", ["install", "-g", PKG_NAME + "@latest"], {
|
|
4780
|
+
stdio: "inherit"
|
|
4781
|
+
});
|
|
4782
|
+
proc.on("error", () => resolve5(false));
|
|
4783
|
+
proc.on("exit", (code) => resolve5(code === 0));
|
|
4784
|
+
});
|
|
4785
|
+
}
|
|
4786
|
+
async function promptForUpdateOrLog() {
|
|
4747
4787
|
try {
|
|
4748
4788
|
const r = await checkForUpdate();
|
|
4749
|
-
if (r.hasUpdate
|
|
4789
|
+
if (!r.hasUpdate || !r.latest) return;
|
|
4790
|
+
if (!process.stdin.isTTY) {
|
|
4750
4791
|
log.info(
|
|
4751
4792
|
`Synthra ${r.latest} is available (you have ${r.current}) \u2014 run: npm install -g @jefuriiij/synthra@latest`
|
|
4752
4793
|
);
|
|
4794
|
+
return;
|
|
4753
4795
|
}
|
|
4796
|
+
log.info(`Synthra ${r.latest} is available (you have ${r.current}).`);
|
|
4797
|
+
const yes = await promptYesNo("[syn] Update now? [y/N]: ");
|
|
4798
|
+
if (!yes) {
|
|
4799
|
+
log.info("Skipping update \u2014 continuing with current version.");
|
|
4800
|
+
return;
|
|
4801
|
+
}
|
|
4802
|
+
log.info(`Running: npm install -g ${PKG_NAME}@latest`);
|
|
4803
|
+
const ok2 = await runNpmUpdate();
|
|
4804
|
+
if (!ok2) {
|
|
4805
|
+
log.warn("npm install failed \u2014 continuing with current version.");
|
|
4806
|
+
return;
|
|
4807
|
+
}
|
|
4808
|
+
log.info(`\u2713 Updated to ${r.latest}. Please re-run: syn .`);
|
|
4809
|
+
process.exit(0);
|
|
4754
4810
|
} catch {
|
|
4755
4811
|
}
|
|
4756
4812
|
}
|
|
@@ -4786,11 +4842,11 @@ async function serveCommand(rawPath) {
|
|
|
4786
4842
|
}
|
|
4787
4843
|
|
|
4788
4844
|
// src/cli/start-claude.ts
|
|
4789
|
-
import
|
|
4845
|
+
import spawn2 from "cross-spawn";
|
|
4790
4846
|
var MCP_NAME = "synthra";
|
|
4791
4847
|
function runClaude(bin, args, cwd, stdio = "pipe") {
|
|
4792
4848
|
return new Promise((resolve5) => {
|
|
4793
|
-
const proc =
|
|
4849
|
+
const proc = spawn2(bin, args, {
|
|
4794
4850
|
cwd,
|
|
4795
4851
|
stdio: stdio === "inherit" ? "inherit" : ["ignore", "pipe", "pipe"]
|
|
4796
4852
|
});
|
|
@@ -4870,7 +4926,7 @@ async function defaultFlow(rawPath, opts) {
|
|
|
4870
4926
|
const projectRoot = resolve4(rawPath);
|
|
4871
4927
|
const paths = resolvePaths(projectRoot);
|
|
4872
4928
|
const cfg = loadConfig();
|
|
4873
|
-
|
|
4929
|
+
await promptForUpdateOrLog();
|
|
4874
4930
|
await recordProject(projectRoot);
|
|
4875
4931
|
const scan = await scanCommand(rawPath);
|
|
4876
4932
|
const mcpHandle = await startServer(paths);
|