catenext 0.6.0 → 0.6.2
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 +25 -1
- package/README.md +197 -15
- package/dist/index.js +450 -290
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1274,13 +1274,42 @@ var init_orchestrator = __esm({
|
|
|
1274
1274
|
"",
|
|
1275
1275
|
"Do not claim tests passed or approval done without evidence. Never invent merge status.",
|
|
1276
1276
|
"",
|
|
1277
|
+
"### Missing tools / access (research, fetch, browser, \u2026)",
|
|
1278
|
+
"",
|
|
1279
|
+
"If the orchestrator or a persona lacks a required capability (web research, fetch/HTTP, browser,",
|
|
1280
|
+
"private URL, login, paid API, OS permission, etc.):",
|
|
1281
|
+
"",
|
|
1282
|
+
"1. Stop \u2014 do **not** invent page contents, API bodies, or pretend the tool ran.",
|
|
1283
|
+
"2. Ask the human in **their language** for permission or help (enable tool, paste info, skip).",
|
|
1284
|
+
"3. Wait for an explicit reply before that path continues.",
|
|
1285
|
+
"",
|
|
1286
|
+
"```text",
|
|
1287
|
+
"ACCESS NEEDED",
|
|
1288
|
+
"need: <research | fetch | browser | login | other>",
|
|
1289
|
+
"why: <one line>",
|
|
1290
|
+
"Options: 1) allow / enable tool 2) paste the info yourself 3) skip this path 4) other",
|
|
1291
|
+
"Reply with 1 / 2 / 3 / 4.",
|
|
1292
|
+
"```",
|
|
1293
|
+
"",
|
|
1294
|
+
"Personas that hit a missing-access wall report it to the orchestrator (or via `sync-board` ASK);",
|
|
1295
|
+
"the orchestrator asks the human \u2014 personas do not invent external facts.",
|
|
1296
|
+
"",
|
|
1297
|
+
"### Secrets & credentials (never publish)",
|
|
1298
|
+
"",
|
|
1299
|
+
"- **Never** publish or store credentials / critical secrets in handoffs, project docs, `sync-board`,",
|
|
1300
|
+
" git commits, PRs, issues, shared chat dumps, or CI logs.",
|
|
1301
|
+
"- Covers API keys, tokens, passwords, private keys, cookies, raw `.env` values, DB URLs with passwords,",
|
|
1302
|
+
" signing/OTA keys, and similar. Cite **paths** only; use env / secret managers the human controls.",
|
|
1303
|
+
"- If the human pastes a secret into chat, do not copy it into durable Catenext or git artifacts.",
|
|
1304
|
+
"- Scrubber is best-effort redaction \u2014 agents must still refuse to paste secrets on purpose.",
|
|
1305
|
+
"",
|
|
1277
1306
|
"### Subagent briefing template",
|
|
1278
1307
|
"",
|
|
1279
1308
|
"```text",
|
|
1280
1309
|
"GOAL: measurable outcome",
|
|
1281
1310
|
"SCOPE: dirs/files allowed",
|
|
1282
1311
|
"CONTEXT: stack, docs, prior handoffs, graph neighbors if useful",
|
|
1283
|
-
"CONSTRAINTS: dedicated worktree/branch; no merge to main;
|
|
1312
|
+
"CONSTRAINTS: dedicated worktree/branch; no merge to main; never publish credentials/secrets",
|
|
1284
1313
|
"DONE WHEN: tests/verify command and handoff fields from that worktree",
|
|
1285
1314
|
"```",
|
|
1286
1315
|
"",
|
|
@@ -1299,7 +1328,7 @@ var init_orchestrator = __esm({
|
|
|
1299
1328
|
'- Blocked: `catenext block <id> --category <\u2026> --reason "..."`.'
|
|
1300
1329
|
];
|
|
1301
1330
|
GENERAL_RULES = [
|
|
1302
|
-
"Rules:
|
|
1331
|
+
"Rules: never publish credentials or critical secrets (handoffs/docs/git/PR \u2014 cite paths only); no code dumps; do not hand-edit `.catenext/config.yaml` or IDE MCP configs \u2014 use init/sync after user confirmation. Skills: `.catenext/skills/`. Prefer compact tool JSON. Missing research/fetch/browser \u2192 ask the human (`ACCESS NEEDED`); never invent external results."
|
|
1303
1332
|
];
|
|
1304
1333
|
}
|
|
1305
1334
|
});
|
|
@@ -2466,219 +2495,101 @@ var init_store = __esm({
|
|
|
2466
2495
|
}
|
|
2467
2496
|
});
|
|
2468
2497
|
|
|
2469
|
-
// src/
|
|
2470
|
-
|
|
2471
|
-
__export(interview_exports, {
|
|
2472
|
-
buildInterviewSetup: () => buildInterviewSetup,
|
|
2473
|
-
parsePlatformChoices: () => parsePlatformChoices,
|
|
2474
|
-
runInitInterview: () => runInitInterview
|
|
2475
|
-
});
|
|
2476
|
-
import { existsSync } from "node:fs";
|
|
2498
|
+
// src/init/detect.ts
|
|
2499
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
2477
2500
|
import { join as join6 } from "node:path";
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
const
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
recommended: true,
|
|
2504
|
-
why: "Orchestrator Q&A should match the user; agent files stay English."
|
|
2505
|
-
},
|
|
2506
|
-
{
|
|
2507
|
-
id: "en",
|
|
2508
|
-
label: "English Q&A",
|
|
2509
|
-
recommended: false,
|
|
2510
|
-
why: "Force English for both Q&A and agents."
|
|
2511
|
-
},
|
|
2512
|
-
{
|
|
2513
|
-
id: "id",
|
|
2514
|
-
label: "Indonesian Q&A",
|
|
2515
|
-
recommended: false,
|
|
2516
|
-
why: "Force Indonesian Q&A; agents remain English."
|
|
2517
|
-
}
|
|
2518
|
-
],
|
|
2519
|
-
recommended_ids: ["follow_user"],
|
|
2520
|
-
ask: "Which language should the orchestrator use when asking you questions?"
|
|
2521
|
-
};
|
|
2522
|
-
}
|
|
2523
|
-
if (step === "personas") {
|
|
2524
|
-
return {
|
|
2525
|
-
step,
|
|
2526
|
-
locale_hint: "follow_user",
|
|
2527
|
-
options: [
|
|
2528
|
-
{
|
|
2529
|
-
id: "default",
|
|
2530
|
-
label: "Seed be, fe, tester, android, security, reviewer, scribe",
|
|
2531
|
-
recommended: true,
|
|
2532
|
-
why: "Delivery roles plus scribe for docs hygiene; add more later with persona set."
|
|
2533
|
-
},
|
|
2534
|
-
{
|
|
2535
|
-
id: "minimal",
|
|
2536
|
-
label: "Seed be, fe, reviewer only",
|
|
2537
|
-
recommended: false,
|
|
2538
|
-
why: "Smaller starter set for tiny repos."
|
|
2539
|
-
},
|
|
2540
|
-
{
|
|
2541
|
-
id: "none",
|
|
2542
|
-
label: "Skip persona seed",
|
|
2543
|
-
recommended: false,
|
|
2544
|
-
why: "You will create personas manually."
|
|
2545
|
-
}
|
|
2546
|
-
],
|
|
2547
|
-
recommended_ids: ["default"],
|
|
2548
|
-
ask: "Which persona seed should this project use?"
|
|
2549
|
-
};
|
|
2550
|
-
}
|
|
2551
|
-
const detected = detectPlatformHints(root);
|
|
2552
|
-
const recommended = detected.length ? detected.filter((id) => id !== "windsurf") : [...DEFAULT_PLATFORMS];
|
|
2553
|
-
const options = SUPPORTED_PLATFORMS.filter((id) => id !== "windsurf").map(
|
|
2554
|
-
(id) => ({
|
|
2555
|
-
id,
|
|
2556
|
-
label: id,
|
|
2557
|
-
recommended: recommended.includes(id),
|
|
2558
|
-
why: detected.includes(id) ? PLATFORM_WHY[id] ?? "Detected in this checkout." : recommended.includes(id) ? "Common default for this CLI." : "Optional platform."
|
|
2559
|
-
})
|
|
2560
|
-
);
|
|
2561
|
-
return {
|
|
2562
|
-
step: "platform",
|
|
2563
|
-
locale_hint: "follow_user",
|
|
2564
|
-
options,
|
|
2565
|
-
recommended_ids: recommended,
|
|
2566
|
-
ask: "Which IDE/CLI platforms should Catenext install MCP for?"
|
|
2567
|
-
};
|
|
2568
|
-
}
|
|
2569
|
-
function parsePlatformChoices(raw) {
|
|
2570
|
-
const parts = raw.split(/[,\s]+/).map((part) => part.trim()).filter(Boolean);
|
|
2571
|
-
if (parts.length === 1 && (parts[0] === "recommended" || parts[0] === "default")) {
|
|
2572
|
-
return [...DEFAULT_PLATFORMS];
|
|
2573
|
-
}
|
|
2574
|
-
const out = [];
|
|
2575
|
-
for (const part of parts) {
|
|
2576
|
-
const parsed = PlatformIdSchema.safeParse(part);
|
|
2577
|
-
if (!parsed.success) throw new Error(`Unsupported platform: ${part}`);
|
|
2578
|
-
if (parsed.data !== "windsurf") out.push(parsed.data);
|
|
2501
|
+
async function detectStack(root) {
|
|
2502
|
+
const stack = /* @__PURE__ */ new Set();
|
|
2503
|
+
const goMod = await exists(join6(root, "go.mod"));
|
|
2504
|
+
if (goMod !== null) stack.add("go");
|
|
2505
|
+
const pkg = await exists(join6(root, "package.json"));
|
|
2506
|
+
if (pkg !== null) {
|
|
2507
|
+
stack.add("node");
|
|
2508
|
+
try {
|
|
2509
|
+
const json2 = JSON.parse(pkg);
|
|
2510
|
+
const deps = { ...json2.dependencies, ...json2.devDependencies };
|
|
2511
|
+
const known = {
|
|
2512
|
+
typescript: "typescript",
|
|
2513
|
+
next: "nextjs",
|
|
2514
|
+
react: "react",
|
|
2515
|
+
vue: "vue",
|
|
2516
|
+
svelte: "svelte",
|
|
2517
|
+
hono: "hono",
|
|
2518
|
+
express: "express",
|
|
2519
|
+
"@nestjs/core": "nestjs",
|
|
2520
|
+
"drizzle-orm": "drizzle",
|
|
2521
|
+
prisma: "prisma"
|
|
2522
|
+
};
|
|
2523
|
+
for (const [dep, label] of Object.entries(known)) if (deps[dep]) stack.add(label);
|
|
2524
|
+
} catch {
|
|
2525
|
+
}
|
|
2579
2526
|
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2585
|
-
try {
|
|
2586
|
-
const answer = await new Promise((resolve8) => {
|
|
2587
|
-
rl.question(`${question} [${fallback}]: `, resolve8);
|
|
2588
|
-
});
|
|
2589
|
-
return answer.trim() || fallback;
|
|
2590
|
-
} finally {
|
|
2591
|
-
rl.close();
|
|
2527
|
+
const composer = await exists(join6(root, "composer.json"));
|
|
2528
|
+
if (composer !== null) {
|
|
2529
|
+
stack.add("php");
|
|
2530
|
+
if (composer.includes('"laravel/framework"')) stack.add("laravel");
|
|
2592
2531
|
}
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
defaultPlatforms.join(",")
|
|
2608
|
-
);
|
|
2609
|
-
platforms = parsePlatformChoices(platformAnswer);
|
|
2610
|
-
const personaCards = buildInterviewSetup(root, "personas");
|
|
2611
|
-
console.log(personaCards.ask);
|
|
2612
|
-
for (const card of personaCards.options) {
|
|
2613
|
-
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2614
|
-
}
|
|
2615
|
-
const personaAnswer = await ask("Persona seed", "default");
|
|
2616
|
-
if (personaAnswer === "minimal" || personaAnswer === "none") personaSeed = personaAnswer;
|
|
2617
|
-
const localeCards = buildInterviewSetup(root, "locale");
|
|
2618
|
-
console.log(localeCards.ask);
|
|
2619
|
-
for (const card of localeCards.options) {
|
|
2620
|
-
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2532
|
+
if (await exists(join6(root, "pyproject.toml")) !== null) stack.add("python");
|
|
2533
|
+
else if (await exists(join6(root, "requirements.txt")) !== null) stack.add("python");
|
|
2534
|
+
if (await exists(join6(root, "Cargo.toml")) !== null) stack.add("rust");
|
|
2535
|
+
const androidHints = [
|
|
2536
|
+
"build.gradle",
|
|
2537
|
+
"build.gradle.kts",
|
|
2538
|
+
"settings.gradle",
|
|
2539
|
+
"settings.gradle.kts",
|
|
2540
|
+
join6("app", "src", "main", "AndroidManifest.xml")
|
|
2541
|
+
];
|
|
2542
|
+
for (const rel of androidHints) {
|
|
2543
|
+
if (await exists(join6(root, rel)) !== null) {
|
|
2544
|
+
stack.add("android");
|
|
2545
|
+
break;
|
|
2621
2546
|
}
|
|
2622
|
-
locale = await ask("Locale", "follow_user");
|
|
2623
2547
|
}
|
|
2624
|
-
return
|
|
2548
|
+
return [...stack].slice(0, 20);
|
|
2625
2549
|
}
|
|
2626
|
-
var
|
|
2627
|
-
var
|
|
2628
|
-
"src/
|
|
2550
|
+
var exists;
|
|
2551
|
+
var init_detect = __esm({
|
|
2552
|
+
"src/init/detect.ts"() {
|
|
2629
2553
|
"use strict";
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
"claude-code": "Detected Claude Code MCP config.",
|
|
2634
|
-
codex: "Detected Codex config.",
|
|
2635
|
-
antigravity: "Detected Antigravity agents config.",
|
|
2636
|
-
opencode: "Detected OpenCode config.",
|
|
2637
|
-
vscode: "Detected VS Code MCP config.",
|
|
2638
|
-
windsurf: "Windsurf MCP is unsupported in this CLI."
|
|
2639
|
-
};
|
|
2640
|
-
}
|
|
2641
|
-
});
|
|
2642
|
-
|
|
2643
|
-
// src/local-search.ts
|
|
2644
|
-
function searchLocalContext(query, items, limit) {
|
|
2645
|
-
const terms = [...new Set(words(query))];
|
|
2646
|
-
if (terms.length === 0) return [];
|
|
2647
|
-
return items.flatMap(({ text: text2, ...item }) => {
|
|
2648
|
-
const tokens = new Set(words(text2));
|
|
2649
|
-
const title = new Set(words(item.title));
|
|
2650
|
-
const score = terms.reduce(
|
|
2651
|
-
(sum, term) => sum + (title.has(term) ? 2 : 0) + (tokens.has(term) ? 1 : 0),
|
|
2652
|
-
0
|
|
2653
|
-
);
|
|
2654
|
-
if (!score) return [];
|
|
2655
|
-
const compact = text2.replace(/\s+/g, " ").trim();
|
|
2656
|
-
const lower = compact.toLowerCase();
|
|
2657
|
-
const offset = Math.min(
|
|
2658
|
-
...terms.map((term) => {
|
|
2659
|
-
const index = lower.indexOf(term);
|
|
2660
|
-
return index === -1 ? Infinity : index;
|
|
2661
|
-
})
|
|
2554
|
+
exists = async (p) => readFile5(p, "utf8").then(
|
|
2555
|
+
(s) => s,
|
|
2556
|
+
() => null
|
|
2662
2557
|
);
|
|
2663
|
-
const start = Number.isFinite(offset) ? Math.max(0, offset - 80) : 0;
|
|
2664
|
-
return [
|
|
2665
|
-
{ ...item, score: score / (3 * terms.length), snippet: compact.slice(start, start + 800) }
|
|
2666
|
-
];
|
|
2667
|
-
}).sort(
|
|
2668
|
-
(a, b) => b.score - a.score || a.source.localeCompare(b.source) || a.ref.localeCompare(b.ref)
|
|
2669
|
-
).slice(0, limit);
|
|
2670
|
-
}
|
|
2671
|
-
var words;
|
|
2672
|
-
var init_local_search = __esm({
|
|
2673
|
-
"src/local-search.ts"() {
|
|
2674
|
-
"use strict";
|
|
2675
|
-
words = (text2) => text2.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
2676
2558
|
}
|
|
2677
2559
|
});
|
|
2678
2560
|
|
|
2679
2561
|
// src/seed.ts
|
|
2680
|
-
function
|
|
2562
|
+
function recommendPersonaAliases(stack) {
|
|
2563
|
+
const tags = new Set(stack.map((s) => s.toLowerCase()));
|
|
2564
|
+
const aliases = /* @__PURE__ */ new Set(["reviewer"]);
|
|
2565
|
+
const wantsFe = [...FRONTEND_STACK].some((t) => tags.has(t));
|
|
2566
|
+
const wantsBe = [...BACKEND_STACK].some((t) => tags.has(t));
|
|
2567
|
+
const wantsAndroid = tags.has("android") || tags.has("kotlin");
|
|
2568
|
+
if (wantsFe) aliases.add("fe");
|
|
2569
|
+
if (wantsBe) aliases.add("be");
|
|
2570
|
+
if (wantsAndroid) aliases.add("android");
|
|
2571
|
+
if (!wantsFe && !wantsBe && !wantsAndroid && (tags.has("node") || tags.has("typescript"))) {
|
|
2572
|
+
aliases.add("be");
|
|
2573
|
+
}
|
|
2574
|
+
if (aliases.size === 1) {
|
|
2575
|
+
aliases.add("be");
|
|
2576
|
+
aliases.add("fe");
|
|
2577
|
+
}
|
|
2578
|
+
const order = DEFAULT_PERSONAS.map((p) => p.alias);
|
|
2579
|
+
return order.filter((alias) => aliases.has(alias));
|
|
2580
|
+
}
|
|
2581
|
+
function personasForSeed(mode, stack = []) {
|
|
2582
|
+
if (mode === "none") return [];
|
|
2583
|
+
const aliases = mode === "all" ? DEFAULT_PERSONAS.map((p) => p.alias) : mode === "minimal" ? ["be", "fe", "reviewer"] : recommendPersonaAliases(stack);
|
|
2584
|
+
return DEFAULT_PERSONAS.filter((persona2) => aliases.includes(persona2.alias)).map((persona2) => ({
|
|
2585
|
+
...persona2,
|
|
2586
|
+
rules: [...persona2.rules],
|
|
2587
|
+
repos: [...persona2.repos]
|
|
2588
|
+
}));
|
|
2589
|
+
}
|
|
2590
|
+
function starterDocuments(updatedBy = "catenext-init", seededAliases = []) {
|
|
2681
2591
|
const at = iso();
|
|
2592
|
+
const seeded = seededAliases.length > 0 ? seededAliases.join(", ") : "matched to this repo (add more with `catenext persona set`)";
|
|
2682
2593
|
const docs = [
|
|
2683
2594
|
{
|
|
2684
2595
|
slug: "blueprint",
|
|
@@ -2690,7 +2601,8 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2690
2601
|
"Local Catenext project. Orchestrator asks the user first (user language), then delegates to English-persona subagents.",
|
|
2691
2602
|
"",
|
|
2692
2603
|
"- Storage: `.catenext/catenext.sqlite`",
|
|
2693
|
-
|
|
2604
|
+
`- Seeded personas: ${seeded}`,
|
|
2605
|
+
"- Add roles later: `catenext persona set <alias> --role <role>` then `catenext sync`",
|
|
2694
2606
|
"- Kickoff: cross-agent brainstorm \u2192 document `sync-board`",
|
|
2695
2607
|
"- External folders: register with `catenext root add` and assign an owning persona"
|
|
2696
2608
|
].join("\n")
|
|
@@ -2707,8 +2619,10 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2707
2619
|
"3. Before parallel work: short brainstorm with involved personas; save to `sync-board` (skill `cross-agent-sync`).",
|
|
2708
2620
|
"4. Delegate only; concurrent personas each use a separate git worktree.",
|
|
2709
2621
|
"5. Watch all worktrees; after handoffs integrate if needed, then ask: PR | merge | revise | next.",
|
|
2710
|
-
"6. Docs tidy:
|
|
2711
|
-
"7.
|
|
2622
|
+
"6. Docs tidy: add persona `scribe` if needed, then skill `docs-hygiene`.",
|
|
2623
|
+
"7. Missing research/fetch/browser (or other access): ask the human with ACCESS NEEDED \u2014 never invent results.",
|
|
2624
|
+
"8. Never publish credentials or critical secrets (handoffs/docs/git/PR) \u2014 cite paths only.",
|
|
2625
|
+
"9. Keep tool outputs brief; no code dumps."
|
|
2712
2626
|
].join("\n")
|
|
2713
2627
|
},
|
|
2714
2628
|
{
|
|
@@ -2765,19 +2679,18 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2765
2679
|
}));
|
|
2766
2680
|
}
|
|
2767
2681
|
function applyProjectSeed(project, options = {}) {
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
project.personas =
|
|
2771
|
-
...persona2,
|
|
2772
|
-
rules: [...persona2.rules],
|
|
2773
|
-
repos: [...persona2.repos]
|
|
2774
|
-
}));
|
|
2682
|
+
const mode = options.personaSeed === "default" || options.personaSeed === void 0 ? "matched" : options.personaSeed;
|
|
2683
|
+
if (project.personas.length === 0 && mode !== "none") {
|
|
2684
|
+
project.personas = personasForSeed(mode, options.stack ?? []);
|
|
2775
2685
|
}
|
|
2776
2686
|
if (project.permissions.length === 0) {
|
|
2777
2687
|
project.permissions = DEFAULT_PERMISSIONS.map((row) => ({ ...row }));
|
|
2778
2688
|
}
|
|
2779
2689
|
if (project.documents.length === 0) {
|
|
2780
|
-
project.documents = starterDocuments(
|
|
2690
|
+
project.documents = starterDocuments(
|
|
2691
|
+
"catenext-init",
|
|
2692
|
+
project.personas.map((p) => p.alias)
|
|
2693
|
+
);
|
|
2781
2694
|
}
|
|
2782
2695
|
if (options.platforms?.length) {
|
|
2783
2696
|
project.platform_setup = [
|
|
@@ -2788,7 +2701,7 @@ function applyProjectSeed(project, options = {}) {
|
|
|
2788
2701
|
project.session_prefs = { ...project.session_prefs, locale: options.locale };
|
|
2789
2702
|
}
|
|
2790
2703
|
}
|
|
2791
|
-
var DEFAULT_PERSONAS, DEFAULT_PERMISSIONS, iso;
|
|
2704
|
+
var DEFAULT_PERSONAS, FRONTEND_STACK, BACKEND_STACK, DEFAULT_PERMISSIONS, iso;
|
|
2792
2705
|
var init_seed = __esm({
|
|
2793
2706
|
"src/seed.ts"() {
|
|
2794
2707
|
"use strict";
|
|
@@ -2863,6 +2776,19 @@ var init_seed = __esm({
|
|
|
2863
2776
|
]
|
|
2864
2777
|
}
|
|
2865
2778
|
];
|
|
2779
|
+
FRONTEND_STACK = /* @__PURE__ */ new Set(["react", "vue", "svelte", "nextjs"]);
|
|
2780
|
+
BACKEND_STACK = /* @__PURE__ */ new Set([
|
|
2781
|
+
"hono",
|
|
2782
|
+
"express",
|
|
2783
|
+
"nestjs",
|
|
2784
|
+
"go",
|
|
2785
|
+
"php",
|
|
2786
|
+
"laravel",
|
|
2787
|
+
"python",
|
|
2788
|
+
"rust",
|
|
2789
|
+
"drizzle",
|
|
2790
|
+
"prisma"
|
|
2791
|
+
]);
|
|
2866
2792
|
DEFAULT_PERMISSIONS = [
|
|
2867
2793
|
{ action: "approve_plan", principal: "human" },
|
|
2868
2794
|
{ action: "edit_setup", principal: "human" },
|
|
@@ -2876,11 +2802,237 @@ var init_seed = __esm({
|
|
|
2876
2802
|
}
|
|
2877
2803
|
});
|
|
2878
2804
|
|
|
2805
|
+
// src/interview.ts
|
|
2806
|
+
var interview_exports = {};
|
|
2807
|
+
__export(interview_exports, {
|
|
2808
|
+
buildInterviewSetup: () => buildInterviewSetup,
|
|
2809
|
+
parsePlatformChoices: () => parsePlatformChoices,
|
|
2810
|
+
runInitInterview: () => runInitInterview
|
|
2811
|
+
});
|
|
2812
|
+
import { existsSync } from "node:fs";
|
|
2813
|
+
import { join as join7 } from "node:path";
|
|
2814
|
+
import { createInterface } from "node:readline";
|
|
2815
|
+
function detectPlatformHints(root) {
|
|
2816
|
+
const hits = [];
|
|
2817
|
+
const checks = [
|
|
2818
|
+
["cursor", ".cursor"],
|
|
2819
|
+
["claude-code", ".mcp.json"],
|
|
2820
|
+
["codex", ".codex"],
|
|
2821
|
+
["antigravity", ".agents"],
|
|
2822
|
+
["opencode", ".opencode"],
|
|
2823
|
+
["vscode", ".vscode"]
|
|
2824
|
+
];
|
|
2825
|
+
for (const [id, rel] of checks) {
|
|
2826
|
+
if (existsSync(join7(root, rel))) hits.push(id);
|
|
2827
|
+
}
|
|
2828
|
+
return hits;
|
|
2829
|
+
}
|
|
2830
|
+
function buildInterviewSetup(root, step = "platform", stack = []) {
|
|
2831
|
+
if (step === "locale") {
|
|
2832
|
+
return {
|
|
2833
|
+
step,
|
|
2834
|
+
locale_hint: "follow_user",
|
|
2835
|
+
options: [
|
|
2836
|
+
{
|
|
2837
|
+
id: "follow_user",
|
|
2838
|
+
label: "Mirror the user's language",
|
|
2839
|
+
recommended: true,
|
|
2840
|
+
why: "Orchestrator Q&A should match the user; agent files stay English."
|
|
2841
|
+
},
|
|
2842
|
+
{
|
|
2843
|
+
id: "en",
|
|
2844
|
+
label: "English Q&A",
|
|
2845
|
+
recommended: false,
|
|
2846
|
+
why: "Force English for both Q&A and agents."
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
id: "id",
|
|
2850
|
+
label: "Indonesian Q&A",
|
|
2851
|
+
recommended: false,
|
|
2852
|
+
why: "Force Indonesian Q&A; agents remain English."
|
|
2853
|
+
}
|
|
2854
|
+
],
|
|
2855
|
+
recommended_ids: ["follow_user"],
|
|
2856
|
+
ask: "Which language should the orchestrator use when asking you questions?"
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2859
|
+
if (step === "personas") {
|
|
2860
|
+
const matched = recommendPersonaAliases(stack);
|
|
2861
|
+
const stackHint = stack.length ? stack.join(", ") : "unknown";
|
|
2862
|
+
return {
|
|
2863
|
+
step,
|
|
2864
|
+
locale_hint: "follow_user",
|
|
2865
|
+
options: [
|
|
2866
|
+
{
|
|
2867
|
+
id: "matched",
|
|
2868
|
+
label: `Seed for this repo: ${matched.join(", ")}`,
|
|
2869
|
+
recommended: true,
|
|
2870
|
+
why: `Matched to stack [${stackHint}]. Add more later with persona set / sync.`
|
|
2871
|
+
},
|
|
2872
|
+
{
|
|
2873
|
+
id: "minimal",
|
|
2874
|
+
label: "Seed be, fe, reviewer only",
|
|
2875
|
+
recommended: false,
|
|
2876
|
+
why: "Fixed small starter set; ignore stack match."
|
|
2877
|
+
},
|
|
2878
|
+
{
|
|
2879
|
+
id: "all",
|
|
2880
|
+
label: "Seed be, fe, tester, android, security, reviewer, scribe",
|
|
2881
|
+
recommended: false,
|
|
2882
|
+
why: "Full catalog; use when you want every role stubbed up front."
|
|
2883
|
+
},
|
|
2884
|
+
{
|
|
2885
|
+
id: "none",
|
|
2886
|
+
label: "Skip persona seed",
|
|
2887
|
+
recommended: false,
|
|
2888
|
+
why: "You will create personas manually."
|
|
2889
|
+
}
|
|
2890
|
+
],
|
|
2891
|
+
recommended_ids: ["matched"],
|
|
2892
|
+
ask: "Which persona seed should this project use?"
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
const detected = detectPlatformHints(root);
|
|
2896
|
+
const recommended = detected.length ? detected.filter((id) => id !== "windsurf") : [...DEFAULT_PLATFORMS];
|
|
2897
|
+
const options = SUPPORTED_PLATFORMS.filter((id) => id !== "windsurf").map(
|
|
2898
|
+
(id) => ({
|
|
2899
|
+
id,
|
|
2900
|
+
label: id,
|
|
2901
|
+
recommended: recommended.includes(id),
|
|
2902
|
+
why: detected.includes(id) ? PLATFORM_WHY[id] ?? "Detected in this checkout." : recommended.includes(id) ? "Common default for this CLI." : "Optional platform."
|
|
2903
|
+
})
|
|
2904
|
+
);
|
|
2905
|
+
return {
|
|
2906
|
+
step: "platform",
|
|
2907
|
+
locale_hint: "follow_user",
|
|
2908
|
+
options,
|
|
2909
|
+
recommended_ids: recommended,
|
|
2910
|
+
ask: "Which IDE/CLI platforms should Catenext install MCP for?"
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
function parsePlatformChoices(raw) {
|
|
2914
|
+
const parts = raw.split(/[,\s]+/).map((part) => part.trim()).filter(Boolean);
|
|
2915
|
+
if (parts.length === 1 && (parts[0] === "recommended" || parts[0] === "default")) {
|
|
2916
|
+
return [...DEFAULT_PLATFORMS];
|
|
2917
|
+
}
|
|
2918
|
+
const out = [];
|
|
2919
|
+
for (const part of parts) {
|
|
2920
|
+
const parsed = PlatformIdSchema.safeParse(part);
|
|
2921
|
+
if (!parsed.success) throw new Error(`Unsupported platform: ${part}`);
|
|
2922
|
+
if (parsed.data !== "windsurf") out.push(parsed.data);
|
|
2923
|
+
}
|
|
2924
|
+
return [...new Set(out)];
|
|
2925
|
+
}
|
|
2926
|
+
async function ask(question, fallback) {
|
|
2927
|
+
if (!process.stdin.isTTY) return fallback;
|
|
2928
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2929
|
+
try {
|
|
2930
|
+
const answer = await new Promise((resolve8) => {
|
|
2931
|
+
rl.question(`${question} [${fallback}]: `, resolve8);
|
|
2932
|
+
});
|
|
2933
|
+
return answer.trim() || fallback;
|
|
2934
|
+
} finally {
|
|
2935
|
+
rl.close();
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
function parsePersonaSeed(raw) {
|
|
2939
|
+
if (raw === "all" || raw === "default") return "all";
|
|
2940
|
+
if (raw === "minimal" || raw === "none" || raw === "matched") return raw;
|
|
2941
|
+
return "matched";
|
|
2942
|
+
}
|
|
2943
|
+
async function runInitInterview(root, opts) {
|
|
2944
|
+
const stack = await detectStack(root);
|
|
2945
|
+
const platformCards = buildInterviewSetup(root, "platform", stack);
|
|
2946
|
+
const defaultPlatforms = opts.platforms?.length ? opts.platforms : platformCards.recommended_ids;
|
|
2947
|
+
let platforms = defaultPlatforms;
|
|
2948
|
+
let personaSeed = "matched";
|
|
2949
|
+
let locale = "follow_user";
|
|
2950
|
+
if (!opts.yes && process.stdin.isTTY) {
|
|
2951
|
+
console.log(platformCards.ask);
|
|
2952
|
+
for (const card of platformCards.options) {
|
|
2953
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2954
|
+
}
|
|
2955
|
+
const platformAnswer = await ask(
|
|
2956
|
+
"Platforms (comma-separated, or 'recommended')",
|
|
2957
|
+
defaultPlatforms.join(",")
|
|
2958
|
+
);
|
|
2959
|
+
platforms = parsePlatformChoices(platformAnswer);
|
|
2960
|
+
const personaCards = buildInterviewSetup(root, "personas", stack);
|
|
2961
|
+
console.log(personaCards.ask);
|
|
2962
|
+
for (const card of personaCards.options) {
|
|
2963
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2964
|
+
}
|
|
2965
|
+
const personaAnswer = await ask("Persona seed", "matched");
|
|
2966
|
+
personaSeed = parsePersonaSeed(personaAnswer);
|
|
2967
|
+
const localeCards = buildInterviewSetup(root, "locale", stack);
|
|
2968
|
+
console.log(localeCards.ask);
|
|
2969
|
+
for (const card of localeCards.options) {
|
|
2970
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2971
|
+
}
|
|
2972
|
+
locale = await ask("Locale", "follow_user");
|
|
2973
|
+
}
|
|
2974
|
+
return { platforms, personaSeed, locale, stack };
|
|
2975
|
+
}
|
|
2976
|
+
var PLATFORM_WHY;
|
|
2977
|
+
var init_interview = __esm({
|
|
2978
|
+
"src/interview.ts"() {
|
|
2979
|
+
"use strict";
|
|
2980
|
+
init_src();
|
|
2981
|
+
init_detect();
|
|
2982
|
+
init_seed();
|
|
2983
|
+
PLATFORM_WHY = {
|
|
2984
|
+
cursor: "Detected Cursor project files.",
|
|
2985
|
+
"claude-code": "Detected Claude Code MCP config.",
|
|
2986
|
+
codex: "Detected Codex config.",
|
|
2987
|
+
antigravity: "Detected Antigravity agents config.",
|
|
2988
|
+
opencode: "Detected OpenCode config.",
|
|
2989
|
+
vscode: "Detected VS Code MCP config.",
|
|
2990
|
+
windsurf: "Windsurf MCP is unsupported in this CLI."
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
|
|
2995
|
+
// src/local-search.ts
|
|
2996
|
+
function searchLocalContext(query, items, limit) {
|
|
2997
|
+
const terms = [...new Set(words(query))];
|
|
2998
|
+
if (terms.length === 0) return [];
|
|
2999
|
+
return items.flatMap(({ text: text2, ...item }) => {
|
|
3000
|
+
const tokens = new Set(words(text2));
|
|
3001
|
+
const title = new Set(words(item.title));
|
|
3002
|
+
const score = terms.reduce(
|
|
3003
|
+
(sum, term) => sum + (title.has(term) ? 2 : 0) + (tokens.has(term) ? 1 : 0),
|
|
3004
|
+
0
|
|
3005
|
+
);
|
|
3006
|
+
if (!score) return [];
|
|
3007
|
+
const compact = text2.replace(/\s+/g, " ").trim();
|
|
3008
|
+
const lower = compact.toLowerCase();
|
|
3009
|
+
const offset = Math.min(
|
|
3010
|
+
...terms.map((term) => {
|
|
3011
|
+
const index = lower.indexOf(term);
|
|
3012
|
+
return index === -1 ? Infinity : index;
|
|
3013
|
+
})
|
|
3014
|
+
);
|
|
3015
|
+
const start = Number.isFinite(offset) ? Math.max(0, offset - 80) : 0;
|
|
3016
|
+
return [
|
|
3017
|
+
{ ...item, score: score / (3 * terms.length), snippet: compact.slice(start, start + 800) }
|
|
3018
|
+
];
|
|
3019
|
+
}).sort(
|
|
3020
|
+
(a, b) => b.score - a.score || a.source.localeCompare(b.source) || a.ref.localeCompare(b.ref)
|
|
3021
|
+
).slice(0, limit);
|
|
3022
|
+
}
|
|
3023
|
+
var words;
|
|
3024
|
+
var init_local_search = __esm({
|
|
3025
|
+
"src/local-search.ts"() {
|
|
3026
|
+
"use strict";
|
|
3027
|
+
words = (text2) => text2.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
|
|
2879
3031
|
// src/skills.ts
|
|
2880
3032
|
import { execFile as execFile2 } from "node:child_process";
|
|
2881
3033
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2882
|
-
import { mkdir as mkdir3, readdir as readdir3, readFile as
|
|
2883
|
-
import { join as
|
|
3034
|
+
import { mkdir as mkdir3, readdir as readdir3, readFile as readFile6, rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
3035
|
+
import { join as join8 } from "node:path";
|
|
2884
3036
|
import { promisify as promisify2 } from "node:util";
|
|
2885
3037
|
import { parse as parse2, stringify } from "yaml";
|
|
2886
3038
|
function parseSkill(source, fileName) {
|
|
@@ -2915,7 +3067,7 @@ ${skill.content.trim()}
|
|
|
2915
3067
|
async function listSkills(root) {
|
|
2916
3068
|
let files;
|
|
2917
3069
|
try {
|
|
2918
|
-
files = await readdir3(
|
|
3070
|
+
files = await readdir3(join8(root, SKILLS_DIR));
|
|
2919
3071
|
} catch {
|
|
2920
3072
|
return { skills: [], invalid: [] };
|
|
2921
3073
|
}
|
|
@@ -2923,7 +3075,7 @@ async function listSkills(root) {
|
|
|
2923
3075
|
const invalid = [];
|
|
2924
3076
|
for (const file of files.filter((f) => f.endsWith(".md")).sort()) {
|
|
2925
3077
|
try {
|
|
2926
|
-
const skill = parseSkill(await
|
|
3078
|
+
const skill = parseSkill(await readFile6(join8(root, SKILLS_DIR, file), "utf8"), file);
|
|
2927
3079
|
if (`${skill.name}.md` !== file) {
|
|
2928
3080
|
throw new SkillError(`${file}: name "${skill.name}" harus sama dengan nama file.`);
|
|
2929
3081
|
}
|
|
@@ -2955,7 +3107,7 @@ async function loadSkill(root, name, revision) {
|
|
|
2955
3107
|
}
|
|
2956
3108
|
let source;
|
|
2957
3109
|
try {
|
|
2958
|
-
source = await
|
|
3110
|
+
source = await readFile6(join8(root, SKILLS_DIR, file), "utf8");
|
|
2959
3111
|
} catch {
|
|
2960
3112
|
const { skills } = await listSkills(root);
|
|
2961
3113
|
const names = skills.map((s) => s.name).join(", ") || "(belum ada)";
|
|
@@ -2970,12 +3122,12 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
2970
3122
|
if (!when || when.length > SKILL_LIMITS.maxWhenToUseLength) {
|
|
2971
3123
|
throw new SkillError(`when_to_use wajib, maks ${SKILL_LIMITS.maxWhenToUseLength} karakter.`);
|
|
2972
3124
|
}
|
|
2973
|
-
const dir =
|
|
3125
|
+
const dir = join8(root, SKILLS_DIR);
|
|
2974
3126
|
await mkdir3(dir, { recursive: true });
|
|
2975
|
-
const target =
|
|
3127
|
+
const target = join8(dir, `${name}.md`);
|
|
2976
3128
|
let created = true;
|
|
2977
3129
|
try {
|
|
2978
|
-
await
|
|
3130
|
+
await readFile6(target);
|
|
2979
3131
|
created = false;
|
|
2980
3132
|
} catch {
|
|
2981
3133
|
}
|
|
@@ -2987,14 +3139,14 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
2987
3139
|
} finally {
|
|
2988
3140
|
await rm(tmp, { force: true });
|
|
2989
3141
|
}
|
|
2990
|
-
return { path:
|
|
3142
|
+
return { path: join8(SKILLS_DIR, `${name}.md`), created, skill };
|
|
2991
3143
|
}
|
|
2992
3144
|
var SKILLS_DIR, SkillError, exec, FRONTMATTER;
|
|
2993
3145
|
var init_skills = __esm({
|
|
2994
3146
|
"src/skills.ts"() {
|
|
2995
3147
|
"use strict";
|
|
2996
3148
|
init_src();
|
|
2997
|
-
SKILLS_DIR =
|
|
3149
|
+
SKILLS_DIR = join8(".catenext", "skills");
|
|
2998
3150
|
SkillError = class extends Error {
|
|
2999
3151
|
constructor(message) {
|
|
3000
3152
|
super(message);
|
|
@@ -3013,14 +3165,14 @@ __export(seed_skills_exports, {
|
|
|
3013
3165
|
ensureDefaultSkills: () => ensureDefaultSkills
|
|
3014
3166
|
});
|
|
3015
3167
|
import { mkdir as mkdir4, writeFile as writeFile3 } from "node:fs/promises";
|
|
3016
|
-
import { join as
|
|
3168
|
+
import { join as join9 } from "node:path";
|
|
3017
3169
|
async function ensureDefaultSkills(root, now = /* @__PURE__ */ new Date()) {
|
|
3018
|
-
const dir =
|
|
3170
|
+
const dir = join9(root, SKILLS_DIR);
|
|
3019
3171
|
await mkdir4(dir, { recursive: true, mode: 448 });
|
|
3020
3172
|
const created = [];
|
|
3021
3173
|
const stamp = now.toISOString();
|
|
3022
3174
|
for (const skill of DEFAULT_SKILLS) {
|
|
3023
|
-
const path =
|
|
3175
|
+
const path = join9(dir, `${skill.name}.md`);
|
|
3024
3176
|
try {
|
|
3025
3177
|
await writeFile3(
|
|
3026
3178
|
path,
|
|
@@ -3230,7 +3382,10 @@ var init_local_service = __esm({
|
|
|
3230
3382
|
(project, dirty) => {
|
|
3231
3383
|
const beforePersonas = project.personas.length;
|
|
3232
3384
|
const beforeDocs = project.documents.length;
|
|
3233
|
-
applyProjectSeed(project,
|
|
3385
|
+
applyProjectSeed(project, {
|
|
3386
|
+
...options,
|
|
3387
|
+
stack: options.stack ?? this.config.stack ?? []
|
|
3388
|
+
});
|
|
3234
3389
|
if (project.personas.length !== beforePersonas || project.documents.length !== beforeDocs || options.platforms?.length || options.locale) {
|
|
3235
3390
|
dirty();
|
|
3236
3391
|
}
|
|
@@ -3321,7 +3476,7 @@ var init_local_service = __esm({
|
|
|
3321
3476
|
return { ...skill, ...revision ? { revision } : {} };
|
|
3322
3477
|
},
|
|
3323
3478
|
save_repo_skill: (input) => saveSkill(this.root, input, new Date(this.now)),
|
|
3324
|
-
interview_setup: (input) => buildInterviewSetup(this.root, input.step),
|
|
3479
|
+
interview_setup: (input) => buildInterviewSetup(this.root, input.step, this.config.stack ?? []),
|
|
3325
3480
|
session_brief: (input) => this.sessionBrief(Boolean(input.verbose)),
|
|
3326
3481
|
manage_roots: (input) => this.manageRoots(input),
|
|
3327
3482
|
graph_neighbors: (input) => ({
|
|
@@ -4086,7 +4241,7 @@ var init_local_service = __esm({
|
|
|
4086
4241
|
|
|
4087
4242
|
// src/init/repo-files.ts
|
|
4088
4243
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
4089
|
-
import { lstat as lstat3, mkdir as mkdir5, readFile as
|
|
4244
|
+
import { lstat as lstat3, mkdir as mkdir5, readFile as readFile8, rename as rename3, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
4090
4245
|
import { dirname as dirname5, isAbsolute, relative as relative3, resolve as resolve3, sep } from "node:path";
|
|
4091
4246
|
async function repoTarget(root, path) {
|
|
4092
4247
|
const target = resolve3(root, path);
|
|
@@ -4116,7 +4271,7 @@ async function repoTarget(root, path) {
|
|
|
4116
4271
|
async function readRepoFile(root, path) {
|
|
4117
4272
|
const { target } = await repoTarget(resolve3(root), path);
|
|
4118
4273
|
try {
|
|
4119
|
-
return await
|
|
4274
|
+
return await readFile8(target, "utf8");
|
|
4120
4275
|
} catch (error) {
|
|
4121
4276
|
if (isMissingFile(error)) return null;
|
|
4122
4277
|
throw error;
|
|
@@ -4190,6 +4345,20 @@ function renderMasterPrompt() {
|
|
|
4190
4345
|
"- Persona subagents (`be`, `fe`, `tester`, `android`, `security`, `reviewer`, \u2026) do the implementation work.",
|
|
4191
4346
|
"- Ask the human first; mirror **their language**. Agent stubs and tool names stay English.",
|
|
4192
4347
|
"",
|
|
4348
|
+
"## Bootstrap (install if missing)",
|
|
4349
|
+
"",
|
|
4350
|
+
"If `.catenext/config.yaml` is missing, or `catenext` / MCP is not usable yet, **set up first** \u2014 do not invent a cloud login.",
|
|
4351
|
+
"",
|
|
4352
|
+
"1. Require **Node.js \u2265 22.12**. If missing, tell the human how to install it.",
|
|
4353
|
+
"2. Install CLI: `npm install -g catenext` (or `npx -y catenext \u2026` for one-off).",
|
|
4354
|
+
"3. Detect IDE/CLI and **ask the human** which `--platform` to use (recommend what you detect):",
|
|
4355
|
+
" `cursor` \xB7 `claude-code` \xB7 `codex` \xB7 `antigravity` \xB7 `opencode` \xB7 `vscode`",
|
|
4356
|
+
"4. Show a dry-run, wait for OK, then apply:",
|
|
4357
|
+
" `catenext init --platform <id> --dry-run`",
|
|
4358
|
+
" `catenext init --platform <id>` (TTY interview) or `catenext init --platform <id> --yes`",
|
|
4359
|
+
"5. `catenext verify --platform <id>` \u2014 then ask the human to **restart the IDE/CLI** and trust the `catenext` MCP server.",
|
|
4360
|
+
"6. Only after verify: continue with **First 60 seconds** below (read this file / `AGENTS.md`, then `catenext brief`).",
|
|
4361
|
+
"",
|
|
4193
4362
|
"## First 60 seconds",
|
|
4194
4363
|
"",
|
|
4195
4364
|
"1. Read **AGENTS.md** (detailed rules) and note project stack from `.catenext/config.yaml` / context.",
|
|
@@ -4224,6 +4393,31 @@ function renderMasterPrompt() {
|
|
|
4224
4393
|
"",
|
|
4225
4394
|
"- Tidy pass: persona `scribe` + skill `docs-hygiene`.",
|
|
4226
4395
|
"",
|
|
4396
|
+
"## Missing tools / access",
|
|
4397
|
+
"",
|
|
4398
|
+
"If you lack a capability the work needs (web research, fetch/HTTP, browser, private URL, login, paid API, OS permission, etc.):",
|
|
4399
|
+
"1. **Stop guessing** \u2014 do not invent page contents, API responses, or \u201CI browsed it\u201D.",
|
|
4400
|
+
"2. **Ask the human** (their language) for permission or help, with a concrete ask.",
|
|
4401
|
+
"3. Wait for OK / paste / enable-tool before continuing that path.",
|
|
4402
|
+
"4. If the human pastes a secret into chat, **do not** copy it into docs, handoffs, commits, PRs, or issues \u2014 use env/local files they control.",
|
|
4403
|
+
"",
|
|
4404
|
+
"```text",
|
|
4405
|
+
"ACCESS NEEDED",
|
|
4406
|
+
"need: <research | fetch | browser | login | other>",
|
|
4407
|
+
"why: <one line>",
|
|
4408
|
+
"Options: 1) allow / enable tool 2) paste the info yourself 3) skip this path 4) other",
|
|
4409
|
+
"Reply with 1 / 2 / 3 / 4.",
|
|
4410
|
+
"```",
|
|
4411
|
+
"",
|
|
4412
|
+
"## Secrets & credentials (never publish)",
|
|
4413
|
+
"",
|
|
4414
|
+
"Never publish or persist credentials or other critical secrets anywhere durable or shared:",
|
|
4415
|
+
"handoffs, docs, `sync-board`, commits, PRs, issues, chat logs meant for others, screenshots, CI logs.",
|
|
4416
|
+
"Includes: API keys, tokens, passwords, private keys, cookies, `.env` values, connection strings with passwords,",
|
|
4417
|
+
"OTA/signing keys, session cookies, personal data that must stay private.",
|
|
4418
|
+
"Cite **paths** (e.g. `.env`, `secrets/\u2026`) only. Prefer env vars / secret managers the human already uses.",
|
|
4419
|
+
"Catenext scrubbing is best-effort \u2014 you still must not paste secrets on purpose.",
|
|
4420
|
+
"",
|
|
4227
4421
|
"## Human approval template",
|
|
4228
4422
|
"",
|
|
4229
4423
|
"```text",
|
|
@@ -4240,6 +4434,11 @@ function renderMasterPrompt() {
|
|
|
4240
4434
|
"",
|
|
4241
4435
|
"| Need | Command |",
|
|
4242
4436
|
"| --- | --- |",
|
|
4437
|
+
"| Install CLI | `npm install -g catenext` |",
|
|
4438
|
+
"| Upgrade CLI | `npm install -g catenext@latest` then `catenext sync --force` + restart IDE |",
|
|
4439
|
+
"| First-time setup | `catenext init --platform <id>` (`--dry-run` / `--yes`) |",
|
|
4440
|
+
"| Verify MCP | `catenext verify --platform <id>` |",
|
|
4441
|
+
"| Add persona | `catenext persona set <alias> --role <role>` then `catenext sync` |",
|
|
4243
4442
|
"| Session snapshot | `catenext brief` |",
|
|
4244
4443
|
"| Board | `catenext board` |",
|
|
4245
4444
|
"| Claim (parallel-safe) | `catenext claim <id> --as <alias> --worktree` |",
|
|
@@ -4250,10 +4449,13 @@ function renderMasterPrompt() {
|
|
|
4250
4449
|
"",
|
|
4251
4450
|
"## Do / Don't",
|
|
4252
4451
|
"",
|
|
4253
|
-
"- **Do**
|
|
4452
|
+
"- **Do** install/init when setup is missing; seed only personas that match this repo; add more with `persona set` when needed.",
|
|
4453
|
+
"- **Do** ask the human when research/fetch/browser (or any required access) is missing \u2014 never fake the result.",
|
|
4454
|
+
"- **Don't** invent cloud accounts, dashboards, or fake credentials \u2014 this CLI is local SQLite only.",
|
|
4455
|
+
"- **Don't** publish credentials or critical secrets (handoffs, docs, git, PR, issues) \u2014 paths only.",
|
|
4254
4456
|
"- **Don't** implement persona tasks yourself unless the human explicitly asks.",
|
|
4255
4457
|
"- **Don't** merge to main without explicit human choice; prefer PR when unsure.",
|
|
4256
|
-
"- **Don't** invent test/merge results
|
|
4458
|
+
"- **Don't** invent test/merge results.",
|
|
4257
4459
|
"",
|
|
4258
4460
|
"Full rules \u2192 [AGENTS.md](./AGENTS.md). Persona stubs \u2192 platform `agents/` folders (English, stack-aware).",
|
|
4259
4461
|
""
|
|
@@ -4946,7 +5148,7 @@ function renderSubagent(p, ctx = { stack: [], personas: [] }) {
|
|
|
4946
5148
|
"- After claim, read document `sync-board` if present (kickoff contracts / open asks).",
|
|
4947
5149
|
"- Prefer MCP `get_project_context` + claim payload over dumping the whole repo.",
|
|
4948
5150
|
"- Use `graph_neighbors` / `symbol_search` only for files you will touch.",
|
|
4949
|
-
"- Cite paths in handoffs; never
|
|
5151
|
+
"- Cite paths in handoffs; **never publish** credentials or critical secrets (or large code dumps).",
|
|
4950
5152
|
"",
|
|
4951
5153
|
"## Cross-agent asks",
|
|
4952
5154
|
"",
|
|
@@ -4972,6 +5174,8 @@ function renderSubagent(p, ctx = { stack: [], personas: [] }) {
|
|
|
4972
5174
|
"- Do not call `create_tasks`, `manage_task`, or `upsert_persona`.",
|
|
4973
5175
|
...p.alias === "scribe" ? ["- Exception: you may `save_document` for project docs hygiene (skill `docs-hygiene`)."] : ["- Do not call `save_document` unless you are persona `scribe` on a docs task."],
|
|
4974
5176
|
"- Do not integrate other personas' worktrees or merge to main \u2014 orchestrator + human decide PR vs merge.",
|
|
5177
|
+
"- If you lack research/fetch/browser (or other required access): stop, report to orchestrator \u2014 do not invent external facts.",
|
|
5178
|
+
"- Never copy API keys, tokens, passwords, private keys, or `.env` values into handoffs/docs/git.",
|
|
4975
5179
|
"",
|
|
4976
5180
|
"## Rules (customizable)",
|
|
4977
5181
|
"",
|
|
@@ -5042,7 +5246,7 @@ function renderOrchestratorAgent(ctx) {
|
|
|
5042
5246
|
"## Safety",
|
|
5043
5247
|
"",
|
|
5044
5248
|
"- No invented test/merge results.",
|
|
5045
|
-
"-
|
|
5249
|
+
"- Never publish credentials/secrets in handoffs, docs, commits, or PRs \u2014 paths only.",
|
|
5046
5250
|
"- Never merge default without explicit human choice (prefer PR).",
|
|
5047
5251
|
"- Destructive actions require explicit human confirmation.",
|
|
5048
5252
|
""
|
|
@@ -5328,7 +5532,7 @@ import { promisify as promisify3 } from "node:util";
|
|
|
5328
5532
|
|
|
5329
5533
|
// src/planning.ts
|
|
5330
5534
|
init_src();
|
|
5331
|
-
import { readFile as
|
|
5535
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
5332
5536
|
|
|
5333
5537
|
// src/code-search.ts
|
|
5334
5538
|
init_src();
|
|
@@ -5570,7 +5774,7 @@ async function readJsonInput(file) {
|
|
|
5570
5774
|
});
|
|
5571
5775
|
process.stdin.on("end", () => res(data));
|
|
5572
5776
|
process.stdin.on("error", rej);
|
|
5573
|
-
}) : await
|
|
5777
|
+
}) : await readFile7(file, "utf8");
|
|
5574
5778
|
} catch (err) {
|
|
5575
5779
|
throw new PlanningInputError(`Tidak bisa membaca ${file}: ${err.message}`);
|
|
5576
5780
|
}
|
|
@@ -5680,7 +5884,7 @@ async function docGet(service, slug, asJson) {
|
|
|
5680
5884
|
console.log(res.content);
|
|
5681
5885
|
}
|
|
5682
5886
|
async function docSave(service, slug, opts) {
|
|
5683
|
-
const content = await
|
|
5887
|
+
const content = await readFile7(opts.file, "utf8");
|
|
5684
5888
|
const body = prepare(
|
|
5685
5889
|
SaveDocumentInput,
|
|
5686
5890
|
{
|
|
@@ -5962,58 +6166,13 @@ init_entry_pointers();
|
|
|
5962
6166
|
init_config2();
|
|
5963
6167
|
init_agents_md();
|
|
5964
6168
|
init_config_file();
|
|
5965
|
-
|
|
5966
|
-
import { basename as basename3, resolve as resolve5 } from "node:path";
|
|
5967
|
-
import { createTwoFilesPatch } from "diff";
|
|
5968
|
-
|
|
5969
|
-
// src/init/detect.ts
|
|
5970
|
-
import { readFile as readFile8 } from "node:fs/promises";
|
|
5971
|
-
import { join as join9 } from "node:path";
|
|
5972
|
-
var exists = async (p) => readFile8(p, "utf8").then(
|
|
5973
|
-
(s) => s,
|
|
5974
|
-
() => null
|
|
5975
|
-
);
|
|
5976
|
-
async function detectStack(root) {
|
|
5977
|
-
const stack = /* @__PURE__ */ new Set();
|
|
5978
|
-
const goMod = await exists(join9(root, "go.mod"));
|
|
5979
|
-
if (goMod !== null) stack.add("go");
|
|
5980
|
-
const pkg = await exists(join9(root, "package.json"));
|
|
5981
|
-
if (pkg !== null) {
|
|
5982
|
-
stack.add("node");
|
|
5983
|
-
try {
|
|
5984
|
-
const json2 = JSON.parse(pkg);
|
|
5985
|
-
const deps = { ...json2.dependencies, ...json2.devDependencies };
|
|
5986
|
-
const known = {
|
|
5987
|
-
typescript: "typescript",
|
|
5988
|
-
next: "nextjs",
|
|
5989
|
-
react: "react",
|
|
5990
|
-
vue: "vue",
|
|
5991
|
-
svelte: "svelte",
|
|
5992
|
-
hono: "hono",
|
|
5993
|
-
express: "express",
|
|
5994
|
-
"@nestjs/core": "nestjs",
|
|
5995
|
-
"drizzle-orm": "drizzle",
|
|
5996
|
-
prisma: "prisma"
|
|
5997
|
-
};
|
|
5998
|
-
for (const [dep, label] of Object.entries(known)) if (deps[dep]) stack.add(label);
|
|
5999
|
-
} catch {
|
|
6000
|
-
}
|
|
6001
|
-
}
|
|
6002
|
-
const composer = await exists(join9(root, "composer.json"));
|
|
6003
|
-
if (composer !== null) {
|
|
6004
|
-
stack.add("php");
|
|
6005
|
-
if (composer.includes('"laravel/framework"')) stack.add("laravel");
|
|
6006
|
-
}
|
|
6007
|
-
if (await exists(join9(root, "pyproject.toml")) !== null) stack.add("python");
|
|
6008
|
-
else if (await exists(join9(root, "requirements.txt")) !== null) stack.add("python");
|
|
6009
|
-
if (await exists(join9(root, "Cargo.toml")) !== null) stack.add("rust");
|
|
6010
|
-
return [...stack].slice(0, 20);
|
|
6011
|
-
}
|
|
6012
|
-
|
|
6013
|
-
// src/init/index.ts
|
|
6169
|
+
init_detect();
|
|
6014
6170
|
init_gitignore();
|
|
6015
6171
|
init_mcp_config();
|
|
6016
6172
|
init_repo_files();
|
|
6173
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
6174
|
+
import { basename as basename3, resolve as resolve5 } from "node:path";
|
|
6175
|
+
import { createTwoFilesPatch } from "diff";
|
|
6017
6176
|
function slugifyRepoName(name) {
|
|
6018
6177
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64).replace(/-+$/g, "") || "repo";
|
|
6019
6178
|
}
|
|
@@ -6124,7 +6283,7 @@ var SERVER_INSTRUCTIONS = [
|
|
|
6124
6283
|
"Workers: get_ready_tasks then claim_task (worktree required for monorepo). complete_handoff \u2192 NEEDS_REVIEW.",
|
|
6125
6284
|
"Human approve_plan/approve stays on the CLI. Revisions reuse the same task.",
|
|
6126
6285
|
"External folders: manage_roots. Code graph: catenext index then graph_neighbors / symbol_search.",
|
|
6127
|
-
"
|
|
6286
|
+
"Never publish credentials or critical secrets (handoffs/docs/git \u2014 paths only). No code dumps. Do not hand-edit .catenext/config.yaml or IDE MCP configs."
|
|
6128
6287
|
].join(" ");
|
|
6129
6288
|
var text = (body) => ({
|
|
6130
6289
|
content: [{ type: "text", text: body }],
|
|
@@ -6358,7 +6517,7 @@ function formatChecks(lines) {
|
|
|
6358
6517
|
}
|
|
6359
6518
|
|
|
6360
6519
|
// src/index.ts
|
|
6361
|
-
var VERSION = "0.6.
|
|
6520
|
+
var VERSION = "0.6.2";
|
|
6362
6521
|
var program = new Command();
|
|
6363
6522
|
program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
|
|
6364
6523
|
async function friendly(fn) {
|
|
@@ -6459,7 +6618,8 @@ program.command("init").description("Siapkan orkestrasi lokal dan pasang entri M
|
|
|
6459
6618
|
await service.ensureSeed({
|
|
6460
6619
|
platforms,
|
|
6461
6620
|
locale: answers.locale,
|
|
6462
|
-
personaSeed: answers.personaSeed
|
|
6621
|
+
personaSeed: answers.personaSeed,
|
|
6622
|
+
stack: answers.stack.length ? answers.stack : config.stack ?? []
|
|
6463
6623
|
});
|
|
6464
6624
|
const { planSubagents: planSubagents2 } = await Promise.resolve().then(() => (init_subagents(), subagents_exports));
|
|
6465
6625
|
const personas = (await service.callTool("list_personas", {})).personas;
|