@kaddo/cli 3.63.0 → 3.64.0

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.
Files changed (2) hide show
  1. package/dist/index.js +157 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5067,7 +5067,8 @@ var RECOMMENDED_BY_STATE = {
5067
5067
  "backlog-agent.md",
5068
5068
  "work-item-agent.md",
5069
5069
  "implementation-agent.md",
5070
- "adr-agent.md"
5070
+ "adr-agent.md",
5071
+ "module-context-agent.md"
5071
5072
  ],
5072
5073
  "pre-ai": [
5073
5074
  "business-agent.md",
@@ -5077,7 +5078,8 @@ var RECOMMENDED_BY_STATE = {
5077
5078
  "backlog-agent.md",
5078
5079
  "work-item-agent.md",
5079
5080
  "implementation-agent.md",
5080
- "ownership-agent.md"
5081
+ "ownership-agent.md",
5082
+ "module-context-agent.md"
5081
5083
  ],
5082
5084
  legacy: [
5083
5085
  "legacy-agent.md",
@@ -7587,6 +7589,34 @@ function firstUnrefinedLayerAgent(layers) {
7587
7589
  return { agent: "architecture-agent", step: "Use architecture-agent to complete knowledge/tech/current-state.md" };
7588
7590
  }
7589
7591
  function assessPhase(input) {
7592
+ if (input.isModuleRepo) {
7593
+ const techStatus = layer(input.layers, "Tech");
7594
+ const techReady = !NOT_READY_LAYER.includes(techStatus);
7595
+ if (techReady) {
7596
+ return {
7597
+ phase: "Active Delivery",
7598
+ reasons: ["Module repo \u2014 Tech layer ready", "Business/Product managed by core"],
7599
+ recommendedAgents: [],
7600
+ nextStep: "Module knowledge is ready for core orchestration.",
7601
+ llmInstructions: [
7602
+ "This is a module repo. Business, Product, and Delivery are managed by the core repo.",
7603
+ "Do not create business, product, roadmap or Work Items here."
7604
+ ]
7605
+ };
7606
+ }
7607
+ return {
7608
+ phase: "Knowledge Refinement",
7609
+ reasons: ["Module repo \u2014 Tech layer incomplete", "Business/Product managed by core"],
7610
+ recommendedAgents: ["module-context-agent"],
7611
+ nextStep: "Use module-context-agent to refine knowledge/tech/module/module-context.md",
7612
+ llmInstructions: [
7613
+ "Use the module-context-agent to refine the module context.",
7614
+ "Do not create business, product, roadmap or Work Items in this module.",
7615
+ "Do not install agents or skills.",
7616
+ "Do not write application code."
7617
+ ]
7618
+ };
7619
+ }
7590
7620
  const phase = determinePhase(input);
7591
7621
  const reasons = buildReasons(input);
7592
7622
  const bs = input.workItems.byState;
@@ -10687,6 +10717,21 @@ function layerQuality(dir, layer2) {
10687
10717
  return worst;
10688
10718
  }
10689
10719
  function knowledgeLayers(dir) {
10720
+ const config = loadConfig(dir);
10721
+ if (config && isModule(config)) {
10722
+ return [
10723
+ { layer: "Business", status: "Not applicable", detected: [] },
10724
+ { layer: "Product", status: "Not applicable", detected: [] },
10725
+ ...discoverLayers(dir).filter((l) => l.layer === "Tech").map((l) => {
10726
+ if (l.status !== "Consolidated" && l.status !== "Structured") return l;
10727
+ const q = layerQuality(dir, l.layer);
10728
+ if (q === "placeholder") return { ...l, status: "Placeholder" };
10729
+ if (q === "weak") return { ...l, status: "Weak" };
10730
+ return l;
10731
+ }),
10732
+ { layer: "Delivery", status: "Managed by core", detected: [] }
10733
+ ];
10734
+ }
10690
10735
  return discoverLayers(dir).map((l) => {
10691
10736
  if (l.status !== "Consolidated" && l.status !== "Structured") return l;
10692
10737
  const q = layerQuality(dir, l.layer);
@@ -11547,6 +11592,13 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
11547
11592
  }
11548
11593
  const state = config.project.state;
11549
11594
  const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
11595
+ const resolveAgent = (agent) => {
11596
+ const file = agent.endsWith(".md") ? agent : `${agent}.md`;
11597
+ const path8 = agentInstallPath(file);
11598
+ const installed = isFile(join(dir, path8));
11599
+ const group = agentGroupOf(file);
11600
+ return { agentPath: path8, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
11601
+ };
11550
11602
  const moduleRepo = isModule(config);
11551
11603
  const coreRepo = isCore(config);
11552
11604
  const MC = exists(join(dir, "knowledge/tech/module/module-context.md")) ? "knowledge/tech/module/module-context.md" : "knowledge/module/module-context.md";
@@ -11562,15 +11614,26 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
11562
11614
  return { id: "context", phase: "Discovery", label: "Run `kaddo context` to prepare the LLM context pack.", command: "kaddo context", reason: "No context pack has been generated yet." };
11563
11615
  }
11564
11616
  if (qMC !== "useful") {
11617
+ const ar = resolveAgent("module-context-agent");
11565
11618
  return {
11566
11619
  id: "refine-module-context",
11567
11620
  phase: "Knowledge Refinement",
11568
- label: "Use module-context-agent to refine `knowledge/module/module-context.md`.",
11621
+ label: "Use module-context-agent to refine `knowledge/tech/module/module-context.md`.",
11569
11622
  agent: "module-context-agent",
11570
11623
  skill: "module-context-refinement",
11571
11624
  target: MC,
11625
+ agentPath: ar.agentPath,
11626
+ agentInstalled: ar.agentInstalled,
11627
+ installCommand: ar.installCommand,
11572
11628
  reason: "Module context is still a placeholder.",
11573
- instructions: ["Refine the module context with real knowledge about this module.", "Do not create business.md or product.md.", "Do not write code."]
11629
+ instructions: [
11630
+ "Refine the module context using evidence from this repository.",
11631
+ "Use the parent system context when available.",
11632
+ "Do not create business, product, roadmap or Work Items in this module.",
11633
+ "Do not install agents or skills in this module.",
11634
+ "Do not write application code.",
11635
+ "Preserve frontmatter and record unknowns as open questions."
11636
+ ]
11574
11637
  };
11575
11638
  }
11576
11639
  const qCurrentState2 = q(CS), qCodebase2 = q(CB);
@@ -11599,7 +11662,7 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
11599
11662
  if (!exists(join(dir, ".kaddo", "understand.md"))) {
11600
11663
  return { id: "understand", phase: "Discovery", label: "Run `kaddo understand` to summarize the project context.", command: "kaddo understand", reason: "No understand handoff has been generated yet." };
11601
11664
  }
11602
- return { id: "module-ready", phase: "Active Delivery", label: "Module context is complete. Create and manage Work Items from the core repository.", reason: "This module's knowledge is ready. Work Items are created and tracked in the core." };
11665
+ return { id: "module-ready", phase: "Ready for Core Orchestration", label: "Module knowledge is complete. Create and manage Work Items from the core repository.", reason: "This module's knowledge is ready for core orchestration. Work Items are created and tracked in the core." };
11603
11666
  }
11604
11667
  const qBusiness = q(B), qProduct = q(P), qCap = q(CAP), qCurrentState = q(CS), qCodebase = q(CB);
11605
11668
  if (!coreRepo && (qBusiness === "missing" || qProduct === "missing")) {
@@ -11625,13 +11688,6 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
11625
11688
  return { id: "context", phase: "Discovery", label: "Run `kaddo context` to prepare the LLM context pack.", command: "kaddo context", reason: "No context pack has been generated yet." };
11626
11689
  }
11627
11690
  const discovery = state === "pre-ai" || state === "legacy";
11628
- const resolveAgent = (agent) => {
11629
- const file = agent.endsWith(".md") ? agent : `${agent}.md`;
11630
- const path8 = agentInstallPath(file);
11631
- const installed = isFile(join(dir, path8));
11632
- const group = agentGroupOf(file);
11633
- return { agentPath: path8, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
11634
- };
11635
11691
  const refine = (id, agent, target, quality, verb = "complete") => {
11636
11692
  const ar = resolveAgent(agent);
11637
11693
  return {
@@ -12370,6 +12426,67 @@ var identifyRisks = {
12370
12426
  return { status: hasLegacy ? "done" : "pending", agent: hasLegacy ? void 0 : "legacy-agent" };
12371
12427
  }
12372
12428
  };
12429
+ var refineModuleContext = {
12430
+ id: "refine-module-context",
12431
+ label: "Refine module context",
12432
+ evaluate: (ctx) => {
12433
+ const newPath = join(ctx.dir, "knowledge/tech/module/module-context.md");
12434
+ const legacyPath = join(ctx.dir, "knowledge/module/module-context.md");
12435
+ const mcPath = exists(newPath) ? "knowledge/tech/module/module-context.md" : exists(legacyPath) ? "knowledge/module/module-context.md" : null;
12436
+ if (!mcPath) return { status: "pending", agent: "module-context-agent", skill: "module-context-refinement" };
12437
+ const q = analyzeKnowledgeArtifact(ctx.dir, mcPath);
12438
+ if (q === "useful") return { status: "done", evidence: [mcPath] };
12439
+ return { status: "current", agent: "module-context-agent", skill: "module-context-refinement", evidence: [mcPath], reason: "Module context is still a placeholder." };
12440
+ }
12441
+ };
12442
+ var describeModuleCurrentState = {
12443
+ id: "describe-current-state",
12444
+ label: "Describe current state",
12445
+ evaluate: (ctx) => ({
12446
+ status: isUseful(ctx.qCurrentState) ? "done" : "pending",
12447
+ evidence: isUseful(ctx.qCurrentState) ? ["knowledge/tech/current-state.md"] : void 0,
12448
+ agent: isUseful(ctx.qCurrentState) ? void 0 : "architecture-agent"
12449
+ })
12450
+ };
12451
+ var mapModuleCodebase = {
12452
+ id: "map-codebase",
12453
+ label: "Map codebase",
12454
+ evaluate: (ctx) => ({
12455
+ status: isUseful(ctx.qCodebase) ? "done" : "pending",
12456
+ evidence: isUseful(ctx.qCodebase) ? ["knowledge/tech/codebase.md"] : void 0,
12457
+ agent: isUseful(ctx.qCodebase) ? void 0 : "architecture-agent"
12458
+ })
12459
+ };
12460
+ var validateModuleKnowledge = {
12461
+ id: "validate-module-knowledge",
12462
+ label: "Validate module knowledge",
12463
+ evaluate: (ctx) => {
12464
+ const hasUnderstand = exists(join(ctx.dir, ".kaddo/understand.md"));
12465
+ if (hasUnderstand) return { status: "done", evidence: [".kaddo/understand.md"] };
12466
+ return { status: "pending", command: "kaddo understand" };
12467
+ }
12468
+ };
12469
+ var readyForCoreOrchestration = {
12470
+ id: "ready-for-core-orchestration",
12471
+ label: "Ready for core orchestration",
12472
+ evaluate: (ctx) => {
12473
+ const newPath = join(ctx.dir, "knowledge/tech/module/module-context.md");
12474
+ const legacyPath = join(ctx.dir, "knowledge/module/module-context.md");
12475
+ const mcPath = exists(newPath) ? "knowledge/tech/module/module-context.md" : exists(legacyPath) ? "knowledge/module/module-context.md" : null;
12476
+ const mcUseful = mcPath ? analyzeKnowledgeArtifact(ctx.dir, mcPath) === "useful" : false;
12477
+ const allDone = mcUseful && isUseful(ctx.qCurrentState) && isUseful(ctx.qCodebase);
12478
+ return { status: allDone ? "done" : "pending", reason: allDone ? void 0 : "Module knowledge is not yet complete." };
12479
+ }
12480
+ };
12481
+ var MODULE_STEPS = [
12482
+ enableKaddo,
12483
+ scanRepository,
12484
+ refineModuleContext,
12485
+ describeModuleCurrentState,
12486
+ mapModuleCodebase,
12487
+ validateModuleKnowledge,
12488
+ readyForCoreOrchestration
12489
+ ];
12373
12490
  var NEW_STEPS = [
12374
12491
  enableKaddo,
12375
12492
  defineBusiness,
@@ -12510,10 +12627,10 @@ function mapNextStepId(id) {
12510
12627
  "review-work-item": "refine-work-item",
12511
12628
  "prepare-implementation": "prepare-implementation",
12512
12629
  "implement-work-item": "prepare-implementation",
12513
- "refine-module-context": "refine-work-item",
12630
+ "refine-module-context": "refine-module-context",
12514
12631
  "init-module-context": "enable-kaddo",
12515
- "module-ready": "prepare-implementation",
12516
- "validate-work-item-modules": "prepare-implementation",
12632
+ "module-ready": "ready-for-core-orchestration",
12633
+ "validate-work-item-modules": "validate-module-knowledge",
12517
12634
  "modules-discover": "enable-kaddo"
12518
12635
  };
12519
12636
  return MAP[id] ?? id;
@@ -12521,7 +12638,7 @@ function mapNextStepId(id) {
12521
12638
  function buildProjectRoute(dir) {
12522
12639
  const config = loadConfig(dir);
12523
12640
  const state = config?.project.state ?? "pre-ai";
12524
- const defs = stepsForState(state);
12641
+ const defs = config && isModule(config) ? MODULE_STEPS : stepsForState(state);
12525
12642
  const ctx = buildRouteContext(dir);
12526
12643
  const steps = defs.map((d) => {
12527
12644
  const result = d.evaluate(ctx);
@@ -12860,7 +12977,8 @@ function buildProjectExplanation(dir) {
12860
12977
  roadmapQuality: buildRoadmapQuality(dir),
12861
12978
  projectRoute: buildProjectRoute(dir),
12862
12979
  scanSignals: loadScanSignals(dir),
12863
- metadataHealth: analyzeMetadataHealth(dir)
12980
+ metadataHealth: analyzeMetadataHealth(dir),
12981
+ isModuleRepo: config != null && isModule(config)
12864
12982
  };
12865
12983
  }
12866
12984
  function stateLabel(state) {
@@ -13454,15 +13572,16 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
13454
13572
  if (!knowledgeSummary) {
13455
13573
  missing.push("No project knowledge summary found yet.");
13456
13574
  }
13575
+ const moduleRepo = config != null && isModule(config);
13457
13576
  const roadmapSummary = readMarkdownSummary(dir, "delivery/roadmap.md") ?? "";
13458
- if (!roadmapSummary) {
13577
+ if (!roadmapSummary && !moduleRepo) {
13459
13578
  missing.push("No roadmap baseline found.");
13460
13579
  }
13461
13580
  const allArtifacts = discoverKnowledge(dir);
13462
13581
  const workItems = allArtifacts.filter(
13463
13582
  (a) => isDeliveryWorkItem(a) && isActiveState(lifecycleStateOf({ status: a.status, filePath: a.filePath }))
13464
13583
  );
13465
- if (workItems.length === 0) {
13584
+ if (workItems.length === 0 && !moduleRepo) {
13466
13585
  missing.push("No work items found.");
13467
13586
  }
13468
13587
  const state = config.project.state;
@@ -13494,8 +13613,8 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
13494
13613
  tech: { status: layerStatusOf("Tech"), artifacts: { "knowledge/tech/codebase.md": qCodebase, "knowledge/tech/current-state.md": qCurrentState } },
13495
13614
  delivery: { status: layerStatusOf("Delivery"), artifacts: { "knowledge/delivery/roadmap.md": qRoadmap } }
13496
13615
  };
13497
- if (qBusiness === "placeholder") missing.push("Business context exists but still looks like a bootstrap placeholder.");
13498
- if (qProduct === "placeholder" || qCapabilities === "placeholder") missing.push("Product capabilities exist but still look like a bootstrap placeholder.");
13616
+ if (qBusiness === "placeholder" && !moduleRepo) missing.push("Business context exists but still looks like a bootstrap placeholder.");
13617
+ if ((qProduct === "placeholder" || qCapabilities === "placeholder") && !moduleRepo) missing.push("Product capabilities exist but still look like a bootstrap placeholder.");
13499
13618
  if (qCurrentState === "placeholder") missing.push("Current state exists but still looks like a bootstrap placeholder.");
13500
13619
  if (qCodebase === "placeholder") missing.push("Codebase map exists but still looks like a bootstrap placeholder.");
13501
13620
  const allWorkItems = allArtifacts.filter((a) => a.isWorkItem);
@@ -13518,7 +13637,8 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
13518
13637
  workItemsTotal: allWorkItems.length,
13519
13638
  workItemsWithOwnership: wiWithOwnership,
13520
13639
  workItemsMissingOwnership: allWorkItems.length - wiWithOwnership
13521
- }
13640
+ },
13641
+ isModuleRepo: config != null && isModule(config)
13522
13642
  });
13523
13643
  const nextStepRecommendation = resolveNextStep(dir, now);
13524
13644
  const techDecisions = buildTechDecisions(dir);
@@ -14039,6 +14159,16 @@ function flowForState(state) {
14039
14159
  }
14040
14160
  function buildUnderstandPlan(dir, config) {
14041
14161
  const state = config.project.state;
14162
+ if (isModule(config)) {
14163
+ return {
14164
+ project: { name: config.project.name, state, teamSize: config.team.size, structure: config.project.structure, language: "English" },
14165
+ steps: [],
14166
+ missingAgents: [],
14167
+ agentsInstalled: true,
14168
+ scanAvailable: exists(join(dir, ".kaddo", "scan.json")),
14169
+ contextPackPath: ".kaddo/context-pack.md"
14170
+ };
14171
+ }
14042
14172
  const flow = flowForState(state).filter((s) => !exists(join(dir, s.output)));
14043
14173
  const steps = flow.map((s) => {
14044
14174
  const installed = agentIsInstalled(dir, s.agent);
@@ -15127,6 +15257,11 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
15127
15257
  console.error("Run `kaddo init` first.");
15128
15258
  process.exit(1);
15129
15259
  }
15260
+ const addConfig = loadConfig(dir);
15261
+ if ((mod.name === "agents" || mod.name === "skills") && addConfig && isModule(addConfig)) {
15262
+ console.error(`Module repos do not use ${mod.name}. ${mod.name === "agents" ? "Agents" : "Skills"} are managed by the core repo.`);
15263
+ process.exit(1);
15264
+ }
15130
15265
  const alreadyInstalled = isModuleInstalled(dir, mod.configKey);
15131
15266
  for (const d of mod.dirs) {
15132
15267
  ensureDir(join(dir, d));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.63.0",
3
+ "version": "3.64.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {