@jefuriiij/synthra 0.1.4 → 0.1.6
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 +93 -33
- 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 +88 -28
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1443,7 +1443,7 @@ import { mkdir as mkdir3, readFile as readFile7, stat as stat2, writeFile as wri
|
|
|
1443
1443
|
|
|
1444
1444
|
// src/hooks/claude-md.ts
|
|
1445
1445
|
import { readFile as readFile6, writeFile as writeFile2 } from "fs/promises";
|
|
1446
|
-
var POLICY_VERSION =
|
|
1446
|
+
var POLICY_VERSION = 2;
|
|
1447
1447
|
var POLICY_BEGIN = `<!-- synthra-policy v${POLICY_VERSION} BEGIN -->`;
|
|
1448
1448
|
var POLICY_END = `<!-- synthra-policy v${POLICY_VERSION} END -->`;
|
|
1449
1449
|
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;
|
|
@@ -1452,33 +1452,84 @@ function policyBlock() {
|
|
|
1452
1452
|
POLICY_BEGIN,
|
|
1453
1453
|
"## Synthra context policy",
|
|
1454
1454
|
"",
|
|
1455
|
-
"Synthra has pre-loaded
|
|
1456
|
-
"
|
|
1457
|
-
"
|
|
1455
|
+
"Synthra has pre-loaded structured context into this session and exposes",
|
|
1456
|
+
"the project's code graph through MCP tools. **Prefer these tools over",
|
|
1457
|
+
"Grep / Glob / Read** \u2014 they are faster, cheaper, and already filtered",
|
|
1458
1458
|
"to relevant files.",
|
|
1459
1459
|
"",
|
|
1460
|
+
"> **Tool namespace.** Synthra's MCP tools are exposed as",
|
|
1461
|
+
"> `mcp__synthra__graph_continue`, `mcp__synthra__graph_read`, and",
|
|
1462
|
+
"> `mcp__synthra__graph_register_edit`. Below they are referred to by",
|
|
1463
|
+
"> their short names (`graph_continue` etc.) for readability \u2014 use the",
|
|
1464
|
+
"> full namespaced form when actually invoking them.",
|
|
1465
|
+
"",
|
|
1460
1466
|
"### Tools",
|
|
1461
1467
|
"",
|
|
1462
|
-
"- **`graph_continue(query)`** \u2014
|
|
1463
|
-
"
|
|
1464
|
-
|
|
1465
|
-
"
|
|
1466
|
-
'
|
|
1467
|
-
|
|
1468
|
+
"- **`graph_continue(query)`** \u2014 returns a `Confidence` label, the list",
|
|
1469
|
+
" of relevant `Files`, and signatures + top function bodies for those",
|
|
1470
|
+
" files. Your default first move when you need project context.",
|
|
1471
|
+
"- **`graph_read(target)`** \u2014 fetch source. Prefer the",
|
|
1472
|
+
' `"file/path.ts::SymbolName"` form over a bare file path \u2014 reading one',
|
|
1473
|
+
" symbol is ~50 tokens, reading a whole file is thousands.",
|
|
1468
1474
|
"- **`graph_register_edit(files)`** \u2014 after you edit files, call this so",
|
|
1469
|
-
"
|
|
1475
|
+
" subsequent turns weight your changes and avoid stale snapshots.",
|
|
1476
|
+
"",
|
|
1477
|
+
"### When to call `graph_continue` \u2014 and when to skip",
|
|
1478
|
+
"",
|
|
1479
|
+
"**Call `graph_continue` only when you do NOT already know the relevant",
|
|
1480
|
+
"files.**",
|
|
1481
|
+
"",
|
|
1482
|
+
"Call it when:",
|
|
1483
|
+
"- This is the first message of a new task or conversation",
|
|
1484
|
+
"- The task shifts to a different area of the codebase",
|
|
1485
|
+
"- You need files you haven't seen yet in this session",
|
|
1486
|
+
"",
|
|
1487
|
+
"**Skip `graph_continue` when:**",
|
|
1488
|
+
"- You already identified the relevant files earlier in this conversation",
|
|
1489
|
+
"- You are doing follow-up work on files already read (verify, refactor,",
|
|
1490
|
+
" test, docs, cleanup, commit)",
|
|
1491
|
+
"- The task is pure text (commit message, explanation, summary)",
|
|
1492
|
+
"",
|
|
1493
|
+
'If skipping, go directly to `graph_read("file.ts::symbol")` on what',
|
|
1494
|
+
"you already know.",
|
|
1495
|
+
"",
|
|
1496
|
+
"### Confidence caps",
|
|
1497
|
+
"",
|
|
1498
|
+
"When `graph_continue` returns:",
|
|
1499
|
+
"",
|
|
1500
|
+
"- **`Confidence: high`** \u2192 Stop. Do NOT Grep, Glob, or further explore",
|
|
1501
|
+
" for this query. The graph already has it.",
|
|
1502
|
+
"- **`Confidence: medium`** \u2192 Read the listed `Files` directly via",
|
|
1503
|
+
' `graph_read("file::symbol")` *before* trying Grep. The graph has',
|
|
1504
|
+
" narrowed the search space \u2014 use it, don't bypass it.",
|
|
1505
|
+
"- **`Confidence: low`** \u2192 You may use Grep / Glob, but the PreToolUse",
|
|
1506
|
+
" hook may still block redundant calls.",
|
|
1507
|
+
"",
|
|
1508
|
+
"### Reading code",
|
|
1509
|
+
"",
|
|
1510
|
+
"- **Always use `file::symbol` notation** with `graph_read`. Whole-file",
|
|
1511
|
+
" reads should be rare \u2014 only when you genuinely need the full file.",
|
|
1512
|
+
"- If `graph_continue`'s `Files` list contains a `::` entry, pass it",
|
|
1513
|
+
" verbatim to `graph_read`.",
|
|
1470
1514
|
"",
|
|
1471
|
-
"###
|
|
1515
|
+
"### Don'ts",
|
|
1472
1516
|
"",
|
|
1473
|
-
"
|
|
1474
|
-
"
|
|
1475
|
-
"
|
|
1476
|
-
'
|
|
1477
|
-
"
|
|
1478
|
-
"
|
|
1479
|
-
"
|
|
1480
|
-
|
|
1481
|
-
"
|
|
1517
|
+
"- Don't Grep / Glob before calling `graph_continue` when required \u2014 the",
|
|
1518
|
+
" PreToolUse hook may block it.",
|
|
1519
|
+
"- Don't call `graph_continue` more than once per turn.",
|
|
1520
|
+
"- Don't read whole files when a symbol-level read would suffice.",
|
|
1521
|
+
"",
|
|
1522
|
+
"### Session-end resume note",
|
|
1523
|
+
"",
|
|
1524
|
+
`When the user signals they're done (e.g. "bye", "wrap up", "done"),`,
|
|
1525
|
+
"proactively update `.synthra/CONTEXT.md` with:",
|
|
1526
|
+
"",
|
|
1527
|
+
"- **Current Task**: one sentence on what was being worked on",
|
|
1528
|
+
"- **Key Decisions**: bullet list, max 3 items",
|
|
1529
|
+
"- **Next Steps**: bullet list, max 3 items",
|
|
1530
|
+
"",
|
|
1531
|
+
"Keep `CONTEXT.md` under 20 lines total. Don't summarise the conversation",
|
|
1532
|
+
"\u2014 write only what's needed to resume next session.",
|
|
1482
1533
|
"",
|
|
1483
1534
|
"_This block is managed by Synthra. Edits inside the BEGIN/END markers",
|
|
1484
1535
|
"are overwritten on every `syn .` run._",
|
|
@@ -1509,8 +1560,16 @@ async function patchClaudeMd(path) {
|
|
|
1509
1560
|
}
|
|
1510
1561
|
|
|
1511
1562
|
// src/cli/bootstrap.ts
|
|
1512
|
-
var
|
|
1513
|
-
|
|
1563
|
+
var GITIGNORE_ENTRIES = [
|
|
1564
|
+
{
|
|
1565
|
+
comment: "added by synthra (heavy generated state \u2014 gitignored by design)",
|
|
1566
|
+
entry: ".synthra-graph/"
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
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",
|
|
1570
|
+
entry: ".mcp.json"
|
|
1571
|
+
}
|
|
1572
|
+
];
|
|
1514
1573
|
async function exists(path) {
|
|
1515
1574
|
try {
|
|
1516
1575
|
await stat2(path);
|
|
@@ -1530,11 +1589,12 @@ async function patchGitignore(path) {
|
|
|
1530
1589
|
existing = await readFile7(path, "utf8");
|
|
1531
1590
|
} catch {
|
|
1532
1591
|
}
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
${
|
|
1537
|
-
|
|
1592
|
+
const trimmed = new Set(existing.split(/\r?\n/).map((l) => l.trim()));
|
|
1593
|
+
const missing = GITIGNORE_ENTRIES.filter((e) => !trimmed.has(e.entry));
|
|
1594
|
+
if (missing.length === 0) return false;
|
|
1595
|
+
const block = missing.map((m) => `# ${m.comment}
|
|
1596
|
+
${m.entry}`).join("\n") + "\n";
|
|
1597
|
+
const appendix = (existing.length === 0 || existing.endsWith("\n") ? "" : "\n") + (existing.length ? "\n" : "") + block;
|
|
1538
1598
|
await writeFile3(path, existing + appendix, "utf8");
|
|
1539
1599
|
return true;
|
|
1540
1600
|
}
|