catenext 0.6.0 → 0.6.1
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 +12 -1
- package/README.md +112 -14
- package/dist/index.js +382 -283
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2466,219 +2466,101 @@ var init_store = __esm({
|
|
|
2466
2466
|
}
|
|
2467
2467
|
});
|
|
2468
2468
|
|
|
2469
|
-
// src/
|
|
2470
|
-
|
|
2471
|
-
__export(interview_exports, {
|
|
2472
|
-
buildInterviewSetup: () => buildInterviewSetup,
|
|
2473
|
-
parsePlatformChoices: () => parsePlatformChoices,
|
|
2474
|
-
runInitInterview: () => runInitInterview
|
|
2475
|
-
});
|
|
2476
|
-
import { existsSync } from "node:fs";
|
|
2469
|
+
// src/init/detect.ts
|
|
2470
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
2477
2471
|
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);
|
|
2472
|
+
async function detectStack(root) {
|
|
2473
|
+
const stack = /* @__PURE__ */ new Set();
|
|
2474
|
+
const goMod = await exists(join6(root, "go.mod"));
|
|
2475
|
+
if (goMod !== null) stack.add("go");
|
|
2476
|
+
const pkg = await exists(join6(root, "package.json"));
|
|
2477
|
+
if (pkg !== null) {
|
|
2478
|
+
stack.add("node");
|
|
2479
|
+
try {
|
|
2480
|
+
const json2 = JSON.parse(pkg);
|
|
2481
|
+
const deps = { ...json2.dependencies, ...json2.devDependencies };
|
|
2482
|
+
const known = {
|
|
2483
|
+
typescript: "typescript",
|
|
2484
|
+
next: "nextjs",
|
|
2485
|
+
react: "react",
|
|
2486
|
+
vue: "vue",
|
|
2487
|
+
svelte: "svelte",
|
|
2488
|
+
hono: "hono",
|
|
2489
|
+
express: "express",
|
|
2490
|
+
"@nestjs/core": "nestjs",
|
|
2491
|
+
"drizzle-orm": "drizzle",
|
|
2492
|
+
prisma: "prisma"
|
|
2493
|
+
};
|
|
2494
|
+
for (const [dep, label] of Object.entries(known)) if (deps[dep]) stack.add(label);
|
|
2495
|
+
} catch {
|
|
2496
|
+
}
|
|
2579
2497
|
}
|
|
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();
|
|
2498
|
+
const composer = await exists(join6(root, "composer.json"));
|
|
2499
|
+
if (composer !== null) {
|
|
2500
|
+
stack.add("php");
|
|
2501
|
+
if (composer.includes('"laravel/framework"')) stack.add("laravel");
|
|
2592
2502
|
}
|
|
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}`);
|
|
2503
|
+
if (await exists(join6(root, "pyproject.toml")) !== null) stack.add("python");
|
|
2504
|
+
else if (await exists(join6(root, "requirements.txt")) !== null) stack.add("python");
|
|
2505
|
+
if (await exists(join6(root, "Cargo.toml")) !== null) stack.add("rust");
|
|
2506
|
+
const androidHints = [
|
|
2507
|
+
"build.gradle",
|
|
2508
|
+
"build.gradle.kts",
|
|
2509
|
+
"settings.gradle",
|
|
2510
|
+
"settings.gradle.kts",
|
|
2511
|
+
join6("app", "src", "main", "AndroidManifest.xml")
|
|
2512
|
+
];
|
|
2513
|
+
for (const rel of androidHints) {
|
|
2514
|
+
if (await exists(join6(root, rel)) !== null) {
|
|
2515
|
+
stack.add("android");
|
|
2516
|
+
break;
|
|
2621
2517
|
}
|
|
2622
|
-
locale = await ask("Locale", "follow_user");
|
|
2623
2518
|
}
|
|
2624
|
-
return
|
|
2519
|
+
return [...stack].slice(0, 20);
|
|
2625
2520
|
}
|
|
2626
|
-
var
|
|
2627
|
-
var
|
|
2628
|
-
"src/
|
|
2521
|
+
var exists;
|
|
2522
|
+
var init_detect = __esm({
|
|
2523
|
+
"src/init/detect.ts"() {
|
|
2629
2524
|
"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
|
-
})
|
|
2525
|
+
exists = async (p) => readFile5(p, "utf8").then(
|
|
2526
|
+
(s) => s,
|
|
2527
|
+
() => null
|
|
2662
2528
|
);
|
|
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
2529
|
}
|
|
2677
2530
|
});
|
|
2678
2531
|
|
|
2679
2532
|
// src/seed.ts
|
|
2680
|
-
function
|
|
2533
|
+
function recommendPersonaAliases(stack) {
|
|
2534
|
+
const tags = new Set(stack.map((s) => s.toLowerCase()));
|
|
2535
|
+
const aliases = /* @__PURE__ */ new Set(["reviewer"]);
|
|
2536
|
+
const wantsFe = [...FRONTEND_STACK].some((t) => tags.has(t));
|
|
2537
|
+
const wantsBe = [...BACKEND_STACK].some((t) => tags.has(t));
|
|
2538
|
+
const wantsAndroid = tags.has("android") || tags.has("kotlin");
|
|
2539
|
+
if (wantsFe) aliases.add("fe");
|
|
2540
|
+
if (wantsBe) aliases.add("be");
|
|
2541
|
+
if (wantsAndroid) aliases.add("android");
|
|
2542
|
+
if (!wantsFe && !wantsBe && !wantsAndroid && (tags.has("node") || tags.has("typescript"))) {
|
|
2543
|
+
aliases.add("be");
|
|
2544
|
+
}
|
|
2545
|
+
if (aliases.size === 1) {
|
|
2546
|
+
aliases.add("be");
|
|
2547
|
+
aliases.add("fe");
|
|
2548
|
+
}
|
|
2549
|
+
const order = DEFAULT_PERSONAS.map((p) => p.alias);
|
|
2550
|
+
return order.filter((alias) => aliases.has(alias));
|
|
2551
|
+
}
|
|
2552
|
+
function personasForSeed(mode, stack = []) {
|
|
2553
|
+
if (mode === "none") return [];
|
|
2554
|
+
const aliases = mode === "all" ? DEFAULT_PERSONAS.map((p) => p.alias) : mode === "minimal" ? ["be", "fe", "reviewer"] : recommendPersonaAliases(stack);
|
|
2555
|
+
return DEFAULT_PERSONAS.filter((persona2) => aliases.includes(persona2.alias)).map((persona2) => ({
|
|
2556
|
+
...persona2,
|
|
2557
|
+
rules: [...persona2.rules],
|
|
2558
|
+
repos: [...persona2.repos]
|
|
2559
|
+
}));
|
|
2560
|
+
}
|
|
2561
|
+
function starterDocuments(updatedBy = "catenext-init", seededAliases = []) {
|
|
2681
2562
|
const at = iso();
|
|
2563
|
+
const seeded = seededAliases.length > 0 ? seededAliases.join(", ") : "matched to this repo (add more with `catenext persona set`)";
|
|
2682
2564
|
const docs = [
|
|
2683
2565
|
{
|
|
2684
2566
|
slug: "blueprint",
|
|
@@ -2690,7 +2572,8 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2690
2572
|
"Local Catenext project. Orchestrator asks the user first (user language), then delegates to English-persona subagents.",
|
|
2691
2573
|
"",
|
|
2692
2574
|
"- Storage: `.catenext/catenext.sqlite`",
|
|
2693
|
-
|
|
2575
|
+
`- Seeded personas: ${seeded}`,
|
|
2576
|
+
"- Add roles later: `catenext persona set <alias> --role <role>` then `catenext sync`",
|
|
2694
2577
|
"- Kickoff: cross-agent brainstorm \u2192 document `sync-board`",
|
|
2695
2578
|
"- External folders: register with `catenext root add` and assign an owning persona"
|
|
2696
2579
|
].join("\n")
|
|
@@ -2707,7 +2590,7 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2707
2590
|
"3. Before parallel work: short brainstorm with involved personas; save to `sync-board` (skill `cross-agent-sync`).",
|
|
2708
2591
|
"4. Delegate only; concurrent personas each use a separate git worktree.",
|
|
2709
2592
|
"5. Watch all worktrees; after handoffs integrate if needed, then ask: PR | merge | revise | next.",
|
|
2710
|
-
"6. Docs tidy:
|
|
2593
|
+
"6. Docs tidy: add persona `scribe` if needed, then skill `docs-hygiene`.",
|
|
2711
2594
|
"7. Keep tool outputs brief; no code dumps or secrets."
|
|
2712
2595
|
].join("\n")
|
|
2713
2596
|
},
|
|
@@ -2765,19 +2648,18 @@ function starterDocuments(updatedBy = "catenext-init") {
|
|
|
2765
2648
|
}));
|
|
2766
2649
|
}
|
|
2767
2650
|
function applyProjectSeed(project, options = {}) {
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
project.personas =
|
|
2771
|
-
...persona2,
|
|
2772
|
-
rules: [...persona2.rules],
|
|
2773
|
-
repos: [...persona2.repos]
|
|
2774
|
-
}));
|
|
2651
|
+
const mode = options.personaSeed === "default" || options.personaSeed === void 0 ? "matched" : options.personaSeed;
|
|
2652
|
+
if (project.personas.length === 0 && mode !== "none") {
|
|
2653
|
+
project.personas = personasForSeed(mode, options.stack ?? []);
|
|
2775
2654
|
}
|
|
2776
2655
|
if (project.permissions.length === 0) {
|
|
2777
2656
|
project.permissions = DEFAULT_PERMISSIONS.map((row) => ({ ...row }));
|
|
2778
2657
|
}
|
|
2779
2658
|
if (project.documents.length === 0) {
|
|
2780
|
-
project.documents = starterDocuments(
|
|
2659
|
+
project.documents = starterDocuments(
|
|
2660
|
+
"catenext-init",
|
|
2661
|
+
project.personas.map((p) => p.alias)
|
|
2662
|
+
);
|
|
2781
2663
|
}
|
|
2782
2664
|
if (options.platforms?.length) {
|
|
2783
2665
|
project.platform_setup = [
|
|
@@ -2788,7 +2670,7 @@ function applyProjectSeed(project, options = {}) {
|
|
|
2788
2670
|
project.session_prefs = { ...project.session_prefs, locale: options.locale };
|
|
2789
2671
|
}
|
|
2790
2672
|
}
|
|
2791
|
-
var DEFAULT_PERSONAS, DEFAULT_PERMISSIONS, iso;
|
|
2673
|
+
var DEFAULT_PERSONAS, FRONTEND_STACK, BACKEND_STACK, DEFAULT_PERMISSIONS, iso;
|
|
2792
2674
|
var init_seed = __esm({
|
|
2793
2675
|
"src/seed.ts"() {
|
|
2794
2676
|
"use strict";
|
|
@@ -2863,6 +2745,19 @@ var init_seed = __esm({
|
|
|
2863
2745
|
]
|
|
2864
2746
|
}
|
|
2865
2747
|
];
|
|
2748
|
+
FRONTEND_STACK = /* @__PURE__ */ new Set(["react", "vue", "svelte", "nextjs"]);
|
|
2749
|
+
BACKEND_STACK = /* @__PURE__ */ new Set([
|
|
2750
|
+
"hono",
|
|
2751
|
+
"express",
|
|
2752
|
+
"nestjs",
|
|
2753
|
+
"go",
|
|
2754
|
+
"php",
|
|
2755
|
+
"laravel",
|
|
2756
|
+
"python",
|
|
2757
|
+
"rust",
|
|
2758
|
+
"drizzle",
|
|
2759
|
+
"prisma"
|
|
2760
|
+
]);
|
|
2866
2761
|
DEFAULT_PERMISSIONS = [
|
|
2867
2762
|
{ action: "approve_plan", principal: "human" },
|
|
2868
2763
|
{ action: "edit_setup", principal: "human" },
|
|
@@ -2876,11 +2771,237 @@ var init_seed = __esm({
|
|
|
2876
2771
|
}
|
|
2877
2772
|
});
|
|
2878
2773
|
|
|
2774
|
+
// src/interview.ts
|
|
2775
|
+
var interview_exports = {};
|
|
2776
|
+
__export(interview_exports, {
|
|
2777
|
+
buildInterviewSetup: () => buildInterviewSetup,
|
|
2778
|
+
parsePlatformChoices: () => parsePlatformChoices,
|
|
2779
|
+
runInitInterview: () => runInitInterview
|
|
2780
|
+
});
|
|
2781
|
+
import { existsSync } from "node:fs";
|
|
2782
|
+
import { join as join7 } from "node:path";
|
|
2783
|
+
import { createInterface } from "node:readline";
|
|
2784
|
+
function detectPlatformHints(root) {
|
|
2785
|
+
const hits = [];
|
|
2786
|
+
const checks = [
|
|
2787
|
+
["cursor", ".cursor"],
|
|
2788
|
+
["claude-code", ".mcp.json"],
|
|
2789
|
+
["codex", ".codex"],
|
|
2790
|
+
["antigravity", ".agents"],
|
|
2791
|
+
["opencode", ".opencode"],
|
|
2792
|
+
["vscode", ".vscode"]
|
|
2793
|
+
];
|
|
2794
|
+
for (const [id, rel] of checks) {
|
|
2795
|
+
if (existsSync(join7(root, rel))) hits.push(id);
|
|
2796
|
+
}
|
|
2797
|
+
return hits;
|
|
2798
|
+
}
|
|
2799
|
+
function buildInterviewSetup(root, step = "platform", stack = []) {
|
|
2800
|
+
if (step === "locale") {
|
|
2801
|
+
return {
|
|
2802
|
+
step,
|
|
2803
|
+
locale_hint: "follow_user",
|
|
2804
|
+
options: [
|
|
2805
|
+
{
|
|
2806
|
+
id: "follow_user",
|
|
2807
|
+
label: "Mirror the user's language",
|
|
2808
|
+
recommended: true,
|
|
2809
|
+
why: "Orchestrator Q&A should match the user; agent files stay English."
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
id: "en",
|
|
2813
|
+
label: "English Q&A",
|
|
2814
|
+
recommended: false,
|
|
2815
|
+
why: "Force English for both Q&A and agents."
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
id: "id",
|
|
2819
|
+
label: "Indonesian Q&A",
|
|
2820
|
+
recommended: false,
|
|
2821
|
+
why: "Force Indonesian Q&A; agents remain English."
|
|
2822
|
+
}
|
|
2823
|
+
],
|
|
2824
|
+
recommended_ids: ["follow_user"],
|
|
2825
|
+
ask: "Which language should the orchestrator use when asking you questions?"
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
if (step === "personas") {
|
|
2829
|
+
const matched = recommendPersonaAliases(stack);
|
|
2830
|
+
const stackHint = stack.length ? stack.join(", ") : "unknown";
|
|
2831
|
+
return {
|
|
2832
|
+
step,
|
|
2833
|
+
locale_hint: "follow_user",
|
|
2834
|
+
options: [
|
|
2835
|
+
{
|
|
2836
|
+
id: "matched",
|
|
2837
|
+
label: `Seed for this repo: ${matched.join(", ")}`,
|
|
2838
|
+
recommended: true,
|
|
2839
|
+
why: `Matched to stack [${stackHint}]. Add more later with persona set / sync.`
|
|
2840
|
+
},
|
|
2841
|
+
{
|
|
2842
|
+
id: "minimal",
|
|
2843
|
+
label: "Seed be, fe, reviewer only",
|
|
2844
|
+
recommended: false,
|
|
2845
|
+
why: "Fixed small starter set; ignore stack match."
|
|
2846
|
+
},
|
|
2847
|
+
{
|
|
2848
|
+
id: "all",
|
|
2849
|
+
label: "Seed be, fe, tester, android, security, reviewer, scribe",
|
|
2850
|
+
recommended: false,
|
|
2851
|
+
why: "Full catalog; use when you want every role stubbed up front."
|
|
2852
|
+
},
|
|
2853
|
+
{
|
|
2854
|
+
id: "none",
|
|
2855
|
+
label: "Skip persona seed",
|
|
2856
|
+
recommended: false,
|
|
2857
|
+
why: "You will create personas manually."
|
|
2858
|
+
}
|
|
2859
|
+
],
|
|
2860
|
+
recommended_ids: ["matched"],
|
|
2861
|
+
ask: "Which persona seed should this project use?"
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
const detected = detectPlatformHints(root);
|
|
2865
|
+
const recommended = detected.length ? detected.filter((id) => id !== "windsurf") : [...DEFAULT_PLATFORMS];
|
|
2866
|
+
const options = SUPPORTED_PLATFORMS.filter((id) => id !== "windsurf").map(
|
|
2867
|
+
(id) => ({
|
|
2868
|
+
id,
|
|
2869
|
+
label: id,
|
|
2870
|
+
recommended: recommended.includes(id),
|
|
2871
|
+
why: detected.includes(id) ? PLATFORM_WHY[id] ?? "Detected in this checkout." : recommended.includes(id) ? "Common default for this CLI." : "Optional platform."
|
|
2872
|
+
})
|
|
2873
|
+
);
|
|
2874
|
+
return {
|
|
2875
|
+
step: "platform",
|
|
2876
|
+
locale_hint: "follow_user",
|
|
2877
|
+
options,
|
|
2878
|
+
recommended_ids: recommended,
|
|
2879
|
+
ask: "Which IDE/CLI platforms should Catenext install MCP for?"
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
function parsePlatformChoices(raw) {
|
|
2883
|
+
const parts = raw.split(/[,\s]+/).map((part) => part.trim()).filter(Boolean);
|
|
2884
|
+
if (parts.length === 1 && (parts[0] === "recommended" || parts[0] === "default")) {
|
|
2885
|
+
return [...DEFAULT_PLATFORMS];
|
|
2886
|
+
}
|
|
2887
|
+
const out = [];
|
|
2888
|
+
for (const part of parts) {
|
|
2889
|
+
const parsed = PlatformIdSchema.safeParse(part);
|
|
2890
|
+
if (!parsed.success) throw new Error(`Unsupported platform: ${part}`);
|
|
2891
|
+
if (parsed.data !== "windsurf") out.push(parsed.data);
|
|
2892
|
+
}
|
|
2893
|
+
return [...new Set(out)];
|
|
2894
|
+
}
|
|
2895
|
+
async function ask(question, fallback) {
|
|
2896
|
+
if (!process.stdin.isTTY) return fallback;
|
|
2897
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2898
|
+
try {
|
|
2899
|
+
const answer = await new Promise((resolve8) => {
|
|
2900
|
+
rl.question(`${question} [${fallback}]: `, resolve8);
|
|
2901
|
+
});
|
|
2902
|
+
return answer.trim() || fallback;
|
|
2903
|
+
} finally {
|
|
2904
|
+
rl.close();
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
function parsePersonaSeed(raw) {
|
|
2908
|
+
if (raw === "all" || raw === "default") return "all";
|
|
2909
|
+
if (raw === "minimal" || raw === "none" || raw === "matched") return raw;
|
|
2910
|
+
return "matched";
|
|
2911
|
+
}
|
|
2912
|
+
async function runInitInterview(root, opts) {
|
|
2913
|
+
const stack = await detectStack(root);
|
|
2914
|
+
const platformCards = buildInterviewSetup(root, "platform", stack);
|
|
2915
|
+
const defaultPlatforms = opts.platforms?.length ? opts.platforms : platformCards.recommended_ids;
|
|
2916
|
+
let platforms = defaultPlatforms;
|
|
2917
|
+
let personaSeed = "matched";
|
|
2918
|
+
let locale = "follow_user";
|
|
2919
|
+
if (!opts.yes && process.stdin.isTTY) {
|
|
2920
|
+
console.log(platformCards.ask);
|
|
2921
|
+
for (const card of platformCards.options) {
|
|
2922
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2923
|
+
}
|
|
2924
|
+
const platformAnswer = await ask(
|
|
2925
|
+
"Platforms (comma-separated, or 'recommended')",
|
|
2926
|
+
defaultPlatforms.join(",")
|
|
2927
|
+
);
|
|
2928
|
+
platforms = parsePlatformChoices(platformAnswer);
|
|
2929
|
+
const personaCards = buildInterviewSetup(root, "personas", stack);
|
|
2930
|
+
console.log(personaCards.ask);
|
|
2931
|
+
for (const card of personaCards.options) {
|
|
2932
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2933
|
+
}
|
|
2934
|
+
const personaAnswer = await ask("Persona seed", "matched");
|
|
2935
|
+
personaSeed = parsePersonaSeed(personaAnswer);
|
|
2936
|
+
const localeCards = buildInterviewSetup(root, "locale", stack);
|
|
2937
|
+
console.log(localeCards.ask);
|
|
2938
|
+
for (const card of localeCards.options) {
|
|
2939
|
+
console.log(` ${card.recommended ? "*" : " "} ${card.id} \u2014 ${card.why}`);
|
|
2940
|
+
}
|
|
2941
|
+
locale = await ask("Locale", "follow_user");
|
|
2942
|
+
}
|
|
2943
|
+
return { platforms, personaSeed, locale, stack };
|
|
2944
|
+
}
|
|
2945
|
+
var PLATFORM_WHY;
|
|
2946
|
+
var init_interview = __esm({
|
|
2947
|
+
"src/interview.ts"() {
|
|
2948
|
+
"use strict";
|
|
2949
|
+
init_src();
|
|
2950
|
+
init_detect();
|
|
2951
|
+
init_seed();
|
|
2952
|
+
PLATFORM_WHY = {
|
|
2953
|
+
cursor: "Detected Cursor project files.",
|
|
2954
|
+
"claude-code": "Detected Claude Code MCP config.",
|
|
2955
|
+
codex: "Detected Codex config.",
|
|
2956
|
+
antigravity: "Detected Antigravity agents config.",
|
|
2957
|
+
opencode: "Detected OpenCode config.",
|
|
2958
|
+
vscode: "Detected VS Code MCP config.",
|
|
2959
|
+
windsurf: "Windsurf MCP is unsupported in this CLI."
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
});
|
|
2963
|
+
|
|
2964
|
+
// src/local-search.ts
|
|
2965
|
+
function searchLocalContext(query, items, limit) {
|
|
2966
|
+
const terms = [...new Set(words(query))];
|
|
2967
|
+
if (terms.length === 0) return [];
|
|
2968
|
+
return items.flatMap(({ text: text2, ...item }) => {
|
|
2969
|
+
const tokens = new Set(words(text2));
|
|
2970
|
+
const title = new Set(words(item.title));
|
|
2971
|
+
const score = terms.reduce(
|
|
2972
|
+
(sum, term) => sum + (title.has(term) ? 2 : 0) + (tokens.has(term) ? 1 : 0),
|
|
2973
|
+
0
|
|
2974
|
+
);
|
|
2975
|
+
if (!score) return [];
|
|
2976
|
+
const compact = text2.replace(/\s+/g, " ").trim();
|
|
2977
|
+
const lower = compact.toLowerCase();
|
|
2978
|
+
const offset = Math.min(
|
|
2979
|
+
...terms.map((term) => {
|
|
2980
|
+
const index = lower.indexOf(term);
|
|
2981
|
+
return index === -1 ? Infinity : index;
|
|
2982
|
+
})
|
|
2983
|
+
);
|
|
2984
|
+
const start = Number.isFinite(offset) ? Math.max(0, offset - 80) : 0;
|
|
2985
|
+
return [
|
|
2986
|
+
{ ...item, score: score / (3 * terms.length), snippet: compact.slice(start, start + 800) }
|
|
2987
|
+
];
|
|
2988
|
+
}).sort(
|
|
2989
|
+
(a, b) => b.score - a.score || a.source.localeCompare(b.source) || a.ref.localeCompare(b.ref)
|
|
2990
|
+
).slice(0, limit);
|
|
2991
|
+
}
|
|
2992
|
+
var words;
|
|
2993
|
+
var init_local_search = __esm({
|
|
2994
|
+
"src/local-search.ts"() {
|
|
2995
|
+
"use strict";
|
|
2996
|
+
words = (text2) => text2.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
2999
|
+
|
|
2879
3000
|
// src/skills.ts
|
|
2880
3001
|
import { execFile as execFile2 } from "node:child_process";
|
|
2881
3002
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2882
|
-
import { mkdir as mkdir3, readdir as readdir3, readFile as
|
|
2883
|
-
import { join as
|
|
3003
|
+
import { mkdir as mkdir3, readdir as readdir3, readFile as readFile6, rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
3004
|
+
import { join as join8 } from "node:path";
|
|
2884
3005
|
import { promisify as promisify2 } from "node:util";
|
|
2885
3006
|
import { parse as parse2, stringify } from "yaml";
|
|
2886
3007
|
function parseSkill(source, fileName) {
|
|
@@ -2915,7 +3036,7 @@ ${skill.content.trim()}
|
|
|
2915
3036
|
async function listSkills(root) {
|
|
2916
3037
|
let files;
|
|
2917
3038
|
try {
|
|
2918
|
-
files = await readdir3(
|
|
3039
|
+
files = await readdir3(join8(root, SKILLS_DIR));
|
|
2919
3040
|
} catch {
|
|
2920
3041
|
return { skills: [], invalid: [] };
|
|
2921
3042
|
}
|
|
@@ -2923,7 +3044,7 @@ async function listSkills(root) {
|
|
|
2923
3044
|
const invalid = [];
|
|
2924
3045
|
for (const file of files.filter((f) => f.endsWith(".md")).sort()) {
|
|
2925
3046
|
try {
|
|
2926
|
-
const skill = parseSkill(await
|
|
3047
|
+
const skill = parseSkill(await readFile6(join8(root, SKILLS_DIR, file), "utf8"), file);
|
|
2927
3048
|
if (`${skill.name}.md` !== file) {
|
|
2928
3049
|
throw new SkillError(`${file}: name "${skill.name}" harus sama dengan nama file.`);
|
|
2929
3050
|
}
|
|
@@ -2955,7 +3076,7 @@ async function loadSkill(root, name, revision) {
|
|
|
2955
3076
|
}
|
|
2956
3077
|
let source;
|
|
2957
3078
|
try {
|
|
2958
|
-
source = await
|
|
3079
|
+
source = await readFile6(join8(root, SKILLS_DIR, file), "utf8");
|
|
2959
3080
|
} catch {
|
|
2960
3081
|
const { skills } = await listSkills(root);
|
|
2961
3082
|
const names = skills.map((s) => s.name).join(", ") || "(belum ada)";
|
|
@@ -2970,12 +3091,12 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
2970
3091
|
if (!when || when.length > SKILL_LIMITS.maxWhenToUseLength) {
|
|
2971
3092
|
throw new SkillError(`when_to_use wajib, maks ${SKILL_LIMITS.maxWhenToUseLength} karakter.`);
|
|
2972
3093
|
}
|
|
2973
|
-
const dir =
|
|
3094
|
+
const dir = join8(root, SKILLS_DIR);
|
|
2974
3095
|
await mkdir3(dir, { recursive: true });
|
|
2975
|
-
const target =
|
|
3096
|
+
const target = join8(dir, `${name}.md`);
|
|
2976
3097
|
let created = true;
|
|
2977
3098
|
try {
|
|
2978
|
-
await
|
|
3099
|
+
await readFile6(target);
|
|
2979
3100
|
created = false;
|
|
2980
3101
|
} catch {
|
|
2981
3102
|
}
|
|
@@ -2987,14 +3108,14 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
2987
3108
|
} finally {
|
|
2988
3109
|
await rm(tmp, { force: true });
|
|
2989
3110
|
}
|
|
2990
|
-
return { path:
|
|
3111
|
+
return { path: join8(SKILLS_DIR, `${name}.md`), created, skill };
|
|
2991
3112
|
}
|
|
2992
3113
|
var SKILLS_DIR, SkillError, exec, FRONTMATTER;
|
|
2993
3114
|
var init_skills = __esm({
|
|
2994
3115
|
"src/skills.ts"() {
|
|
2995
3116
|
"use strict";
|
|
2996
3117
|
init_src();
|
|
2997
|
-
SKILLS_DIR =
|
|
3118
|
+
SKILLS_DIR = join8(".catenext", "skills");
|
|
2998
3119
|
SkillError = class extends Error {
|
|
2999
3120
|
constructor(message) {
|
|
3000
3121
|
super(message);
|
|
@@ -3013,14 +3134,14 @@ __export(seed_skills_exports, {
|
|
|
3013
3134
|
ensureDefaultSkills: () => ensureDefaultSkills
|
|
3014
3135
|
});
|
|
3015
3136
|
import { mkdir as mkdir4, writeFile as writeFile3 } from "node:fs/promises";
|
|
3016
|
-
import { join as
|
|
3137
|
+
import { join as join9 } from "node:path";
|
|
3017
3138
|
async function ensureDefaultSkills(root, now = /* @__PURE__ */ new Date()) {
|
|
3018
|
-
const dir =
|
|
3139
|
+
const dir = join9(root, SKILLS_DIR);
|
|
3019
3140
|
await mkdir4(dir, { recursive: true, mode: 448 });
|
|
3020
3141
|
const created = [];
|
|
3021
3142
|
const stamp = now.toISOString();
|
|
3022
3143
|
for (const skill of DEFAULT_SKILLS) {
|
|
3023
|
-
const path =
|
|
3144
|
+
const path = join9(dir, `${skill.name}.md`);
|
|
3024
3145
|
try {
|
|
3025
3146
|
await writeFile3(
|
|
3026
3147
|
path,
|
|
@@ -3230,7 +3351,10 @@ var init_local_service = __esm({
|
|
|
3230
3351
|
(project, dirty) => {
|
|
3231
3352
|
const beforePersonas = project.personas.length;
|
|
3232
3353
|
const beforeDocs = project.documents.length;
|
|
3233
|
-
applyProjectSeed(project,
|
|
3354
|
+
applyProjectSeed(project, {
|
|
3355
|
+
...options,
|
|
3356
|
+
stack: options.stack ?? this.config.stack ?? []
|
|
3357
|
+
});
|
|
3234
3358
|
if (project.personas.length !== beforePersonas || project.documents.length !== beforeDocs || options.platforms?.length || options.locale) {
|
|
3235
3359
|
dirty();
|
|
3236
3360
|
}
|
|
@@ -3321,7 +3445,7 @@ var init_local_service = __esm({
|
|
|
3321
3445
|
return { ...skill, ...revision ? { revision } : {} };
|
|
3322
3446
|
},
|
|
3323
3447
|
save_repo_skill: (input) => saveSkill(this.root, input, new Date(this.now)),
|
|
3324
|
-
interview_setup: (input) => buildInterviewSetup(this.root, input.step),
|
|
3448
|
+
interview_setup: (input) => buildInterviewSetup(this.root, input.step, this.config.stack ?? []),
|
|
3325
3449
|
session_brief: (input) => this.sessionBrief(Boolean(input.verbose)),
|
|
3326
3450
|
manage_roots: (input) => this.manageRoots(input),
|
|
3327
3451
|
graph_neighbors: (input) => ({
|
|
@@ -4086,7 +4210,7 @@ var init_local_service = __esm({
|
|
|
4086
4210
|
|
|
4087
4211
|
// src/init/repo-files.ts
|
|
4088
4212
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
4089
|
-
import { lstat as lstat3, mkdir as mkdir5, readFile as
|
|
4213
|
+
import { lstat as lstat3, mkdir as mkdir5, readFile as readFile8, rename as rename3, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
4090
4214
|
import { dirname as dirname5, isAbsolute, relative as relative3, resolve as resolve3, sep } from "node:path";
|
|
4091
4215
|
async function repoTarget(root, path) {
|
|
4092
4216
|
const target = resolve3(root, path);
|
|
@@ -4116,7 +4240,7 @@ async function repoTarget(root, path) {
|
|
|
4116
4240
|
async function readRepoFile(root, path) {
|
|
4117
4241
|
const { target } = await repoTarget(resolve3(root), path);
|
|
4118
4242
|
try {
|
|
4119
|
-
return await
|
|
4243
|
+
return await readFile8(target, "utf8");
|
|
4120
4244
|
} catch (error) {
|
|
4121
4245
|
if (isMissingFile(error)) return null;
|
|
4122
4246
|
throw error;
|
|
@@ -4190,6 +4314,20 @@ function renderMasterPrompt() {
|
|
|
4190
4314
|
"- Persona subagents (`be`, `fe`, `tester`, `android`, `security`, `reviewer`, \u2026) do the implementation work.",
|
|
4191
4315
|
"- Ask the human first; mirror **their language**. Agent stubs and tool names stay English.",
|
|
4192
4316
|
"",
|
|
4317
|
+
"## Bootstrap (install if missing)",
|
|
4318
|
+
"",
|
|
4319
|
+
"If `.catenext/config.yaml` is missing, or `catenext` / MCP is not usable yet, **set up first** \u2014 do not invent a cloud login.",
|
|
4320
|
+
"",
|
|
4321
|
+
"1. Require **Node.js \u2265 22.12**. If missing, tell the human how to install it.",
|
|
4322
|
+
"2. Install CLI: `npm install -g catenext` (or `npx -y catenext \u2026` for one-off).",
|
|
4323
|
+
"3. Detect IDE/CLI and **ask the human** which `--platform` to use (recommend what you detect):",
|
|
4324
|
+
" `cursor` \xB7 `claude-code` \xB7 `codex` \xB7 `antigravity` \xB7 `opencode` \xB7 `vscode`",
|
|
4325
|
+
"4. Show a dry-run, wait for OK, then apply:",
|
|
4326
|
+
" `catenext init --platform <id> --dry-run`",
|
|
4327
|
+
" `catenext init --platform <id>` (TTY interview) or `catenext init --platform <id> --yes`",
|
|
4328
|
+
"5. `catenext verify --platform <id>` \u2014 then ask the human to **restart the IDE/CLI** and trust the `catenext` MCP server.",
|
|
4329
|
+
"6. Only after verify: continue with **First 60 seconds** below (read this file / `AGENTS.md`, then `catenext brief`).",
|
|
4330
|
+
"",
|
|
4193
4331
|
"## First 60 seconds",
|
|
4194
4332
|
"",
|
|
4195
4333
|
"1. Read **AGENTS.md** (detailed rules) and note project stack from `.catenext/config.yaml` / context.",
|
|
@@ -4240,6 +4378,10 @@ function renderMasterPrompt() {
|
|
|
4240
4378
|
"",
|
|
4241
4379
|
"| Need | Command |",
|
|
4242
4380
|
"| --- | --- |",
|
|
4381
|
+
"| Install CLI | `npm install -g catenext` |",
|
|
4382
|
+
"| First-time setup | `catenext init --platform <id>` (`--dry-run` / `--yes`) |",
|
|
4383
|
+
"| Verify MCP | `catenext verify --platform <id>` |",
|
|
4384
|
+
"| Add persona | `catenext persona set <alias> --role <role>` then `catenext sync` |",
|
|
4243
4385
|
"| Session snapshot | `catenext brief` |",
|
|
4244
4386
|
"| Board | `catenext board` |",
|
|
4245
4387
|
"| Claim (parallel-safe) | `catenext claim <id> --as <alias> --worktree` |",
|
|
@@ -4250,7 +4392,8 @@ function renderMasterPrompt() {
|
|
|
4250
4392
|
"",
|
|
4251
4393
|
"## Do / Don't",
|
|
4252
4394
|
"",
|
|
4253
|
-
"- **Do**
|
|
4395
|
+
"- **Do** install/init when setup is missing; seed only personas that match this repo; add more with `persona set` when needed.",
|
|
4396
|
+
"- **Don't** invent cloud accounts, API keys, or dashboards \u2014 this CLI is local SQLite only.",
|
|
4254
4397
|
"- **Don't** implement persona tasks yourself unless the human explicitly asks.",
|
|
4255
4398
|
"- **Don't** merge to main without explicit human choice; prefer PR when unsure.",
|
|
4256
4399
|
"- **Don't** invent test/merge results or paste secrets into handoffs/docs.",
|
|
@@ -5328,7 +5471,7 @@ import { promisify as promisify3 } from "node:util";
|
|
|
5328
5471
|
|
|
5329
5472
|
// src/planning.ts
|
|
5330
5473
|
init_src();
|
|
5331
|
-
import { readFile as
|
|
5474
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
5332
5475
|
|
|
5333
5476
|
// src/code-search.ts
|
|
5334
5477
|
init_src();
|
|
@@ -5570,7 +5713,7 @@ async function readJsonInput(file) {
|
|
|
5570
5713
|
});
|
|
5571
5714
|
process.stdin.on("end", () => res(data));
|
|
5572
5715
|
process.stdin.on("error", rej);
|
|
5573
|
-
}) : await
|
|
5716
|
+
}) : await readFile7(file, "utf8");
|
|
5574
5717
|
} catch (err) {
|
|
5575
5718
|
throw new PlanningInputError(`Tidak bisa membaca ${file}: ${err.message}`);
|
|
5576
5719
|
}
|
|
@@ -5680,7 +5823,7 @@ async function docGet(service, slug, asJson) {
|
|
|
5680
5823
|
console.log(res.content);
|
|
5681
5824
|
}
|
|
5682
5825
|
async function docSave(service, slug, opts) {
|
|
5683
|
-
const content = await
|
|
5826
|
+
const content = await readFile7(opts.file, "utf8");
|
|
5684
5827
|
const body = prepare(
|
|
5685
5828
|
SaveDocumentInput,
|
|
5686
5829
|
{
|
|
@@ -5962,58 +6105,13 @@ init_entry_pointers();
|
|
|
5962
6105
|
init_config2();
|
|
5963
6106
|
init_agents_md();
|
|
5964
6107
|
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
|
|
6108
|
+
init_detect();
|
|
6014
6109
|
init_gitignore();
|
|
6015
6110
|
init_mcp_config();
|
|
6016
6111
|
init_repo_files();
|
|
6112
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
6113
|
+
import { basename as basename3, resolve as resolve5 } from "node:path";
|
|
6114
|
+
import { createTwoFilesPatch } from "diff";
|
|
6017
6115
|
function slugifyRepoName(name) {
|
|
6018
6116
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64).replace(/-+$/g, "") || "repo";
|
|
6019
6117
|
}
|
|
@@ -6358,7 +6456,7 @@ function formatChecks(lines) {
|
|
|
6358
6456
|
}
|
|
6359
6457
|
|
|
6360
6458
|
// src/index.ts
|
|
6361
|
-
var VERSION = "0.6.
|
|
6459
|
+
var VERSION = "0.6.1";
|
|
6362
6460
|
var program = new Command();
|
|
6363
6461
|
program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
|
|
6364
6462
|
async function friendly(fn) {
|
|
@@ -6459,7 +6557,8 @@ program.command("init").description("Siapkan orkestrasi lokal dan pasang entri M
|
|
|
6459
6557
|
await service.ensureSeed({
|
|
6460
6558
|
platforms,
|
|
6461
6559
|
locale: answers.locale,
|
|
6462
|
-
personaSeed: answers.personaSeed
|
|
6560
|
+
personaSeed: answers.personaSeed,
|
|
6561
|
+
stack: answers.stack.length ? answers.stack : config.stack ?? []
|
|
6463
6562
|
});
|
|
6464
6563
|
const { planSubagents: planSubagents2 } = await Promise.resolve().then(() => (init_subagents(), subagents_exports));
|
|
6465
6564
|
const personas = (await service.callTool("list_personas", {})).personas;
|