@kaddo/cli 3.45.0 → 3.46.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 +193 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9975,7 +9975,8 @@ function buildUnderstandPlan(dir, config) {
9975
9975
  name: config.project.name,
9976
9976
  state,
9977
9977
  teamSize: config.team.size,
9978
- structure: config.project.structure
9978
+ structure: config.project.structure,
9979
+ language: "English"
9979
9980
  },
9980
9981
  scanAvailable: exists(join(dir, ".kaddo", "scan.json")),
9981
9982
  contextPackPath: ".kaddo/context-pack.md",
@@ -9984,6 +9985,18 @@ function buildUnderstandPlan(dir, config) {
9984
9985
  steps
9985
9986
  };
9986
9987
  }
9988
+ function enrichUnderstandPlan(plan, opts) {
9989
+ return {
9990
+ ...plan,
9991
+ project: { ...plan.project, language: opts.language },
9992
+ phase: opts.phase,
9993
+ nextStepRecommendation: opts.nextStepRecommendation,
9994
+ deliveryState: opts.deliveryState,
9995
+ activeWorkItems: opts.activeWorkItems,
9996
+ recommendedPaths: opts.recommendedPaths,
9997
+ recommendedSkillPaths: opts.recommendedSkillPaths
9998
+ };
9999
+ }
9987
10000
 
9988
10001
  // src/templates/understand-template.ts
9989
10002
  function stateLabel2(state) {
@@ -9994,42 +10007,140 @@ function agentName(file) {
9994
10007
  }
9995
10008
  function renderUnderstand(plan) {
9996
10009
  const { project, steps } = plan;
10010
+ const rec = plan.nextStepRecommendation;
10011
+ const ds = plan.deliveryState;
9997
10012
  const parts = [];
9998
10013
  parts.push("# Kaddo Understand Handoff\n");
9999
10014
  parts.push(
10000
10015
  "> Generated by `kaddo understand`. Kaddo does not call an LLM \u2014 you stay in control of the interpretation.\n"
10001
10016
  );
10002
10017
  parts.push("## Project\n");
10003
- parts.push(
10004
- [
10005
- `- Name: ${project.name}`,
10006
- `- State: ${project.state}`,
10007
- `- Team: ${project.teamSize}`,
10008
- `- Structure: ${project.structure}`
10009
- ].join("\n") + "\n"
10010
- );
10011
- parts.push("## Recommended Agent Flow\n");
10012
- parts.push(`Recommended order for a ${stateLabel2(project.state)} project:
10018
+ const projectLines = [
10019
+ `- Name: ${project.name}`,
10020
+ `- State: ${project.state}`,
10021
+ `- Team: ${project.teamSize}`,
10022
+ `- Structure: ${project.structure}`
10023
+ ];
10024
+ if (project.language) projectLines.push(`- Language: ${project.language}`);
10025
+ parts.push(projectLines.join("\n") + "\n");
10026
+ if (plan.phase && rec) {
10027
+ parts.push("## Current Phase\n");
10028
+ const phaseLines = [`- Phase: ${plan.phase}`];
10029
+ if (rec.agent) phaseLines.push(`- Recommended agent: ${agentName(rec.agent)}`);
10030
+ if (rec.skill) phaseLines.push(`- Recommended skill: ${rec.skill}`);
10031
+ phaseLines.push(`- Next step: ${rec.label}`);
10032
+ if (rec.reason) phaseLines.push(`- Reason: ${rec.reason}`);
10033
+ parts.push(phaseLines.join("\n") + "\n");
10034
+ }
10035
+ if (ds && ds.total_work_items > 0) {
10036
+ parts.push("## Delivery State\n");
10037
+ parts.push(
10038
+ [
10039
+ `- Draft Work Items: ${ds.draft_work_items}`,
10040
+ `- Ready Work Items: ${ds.ready_work_items}`,
10041
+ `- In-progress Work Items: ${ds.in_progress_work_items}`,
10042
+ `- Blocked Work Items: ${ds.blocked_work_items}`,
10043
+ `- Ownership coverage: ${ds.ownership_coverage}`,
10044
+ `- Remaining Work Item candidates: ${ds.remaining_work_item_candidates}`,
10045
+ `- Technical decision candidates: ${ds.decision_candidates}`,
10046
+ `- Accepted ADRs: ${ds.accepted_adrs}`,
10047
+ `- Installed adapters: ${ds.adapters_installed}`
10048
+ ].join("\n") + "\n"
10049
+ );
10050
+ }
10051
+ if (steps.length > 0) {
10052
+ parts.push("## Recommended Agent Flow\n");
10053
+ parts.push(`Recommended order for a ${stateLabel2(project.state)} project:
10013
10054
  `);
10014
- parts.push(
10015
- steps.map((s, i) => {
10016
- const flag = s.installed ? "" : " _(not installed \u2014 run `kaddo add agents`)_";
10017
- return `${i + 1}. ${agentName(s.agent)} \u2192 \`${s.output}\`${flag}`;
10018
- }).join("\n") + "\n"
10019
- );
10055
+ parts.push(
10056
+ steps.map((s, i) => {
10057
+ const flag = s.installed ? "" : " _(not installed \u2014 run `kaddo add agents`)_";
10058
+ return `${i + 1}. ${agentName(s.agent)} \u2192 \`${s.output}\`${flag}`;
10059
+ }).join("\n") + "\n"
10060
+ );
10061
+ } else if (rec) {
10062
+ parts.push("## Recommended Agent Flow\n");
10063
+ const flowSteps = [];
10064
+ if (rec.agent) flowSteps.push(agentName(rec.agent));
10065
+ if (rec.secondary) {
10066
+ for (const s of rec.secondary) {
10067
+ if (s.agent) flowSteps.push(agentName(s.agent));
10068
+ else if (s.skill) flowSteps.push(`${s.skill} skill`);
10069
+ else if (s.command) flowSteps.push(`\`${s.command}\``);
10070
+ }
10071
+ }
10072
+ if (flowSteps.length > 0) {
10073
+ parts.push(flowSteps.map((f, i) => `${i + 1}. ${f}`).join("\n") + "\n");
10074
+ }
10075
+ }
10076
+ if (rec) {
10077
+ parts.push("## Primary Recommendation\n");
10078
+ const recLines = [`- id: ${rec.id}`];
10079
+ if (rec.agent) recLines.push(`- agent: ${agentName(rec.agent)}`);
10080
+ if (rec.skill) recLines.push(`- skill: ${rec.skill}`);
10081
+ if (rec.command) recLines.push(`- command: \`${rec.command}\``);
10082
+ recLines.push(`- reason: ${rec.reason}`);
10083
+ parts.push(recLines.join("\n") + "\n");
10084
+ }
10085
+ if (rec?.secondary && rec.secondary.length > 0) {
10086
+ parts.push("## Secondary Recommendations\n");
10087
+ parts.push(rec.secondary.map((s, i) => `${i + 1}. ${s.label}`).join("\n") + "\n");
10088
+ }
10089
+ if (plan.activeWorkItems && plan.activeWorkItems.length > 0) {
10090
+ parts.push("## Active Work Items\n");
10091
+ parts.push(
10092
+ plan.activeWorkItems.map((w) => `- ${w.id} [${w.type}] ${w.lifecycle} \u2014 ${w.title}`).join("\n") + "\n"
10093
+ );
10094
+ }
10020
10095
  parts.push("## Context Pack\n");
10021
10096
  const scanNote = plan.scanAvailable ? "" : " (incomplete \u2014 run `kaddo scan` first for a richer baseline)";
10022
10097
  parts.push(`Use \`${plan.contextPackPath}\` as the primary input${scanNote}.
10023
10098
  `);
10099
+ const agentPaths = [];
10100
+ if (plan.recommendedPaths && plan.recommendedPaths.length > 0) {
10101
+ agentPaths.push(...plan.recommendedPaths);
10102
+ } else if (steps.length > 0) {
10103
+ agentPaths.push(...steps.map((s) => agentInstallPath(s.agent)));
10104
+ }
10105
+ if (plan.recommendedSkillPaths && plan.recommendedSkillPaths.length > 0) {
10106
+ agentPaths.push(...plan.recommendedSkillPaths);
10107
+ }
10108
+ agentPaths.push(plan.contextPackPath);
10024
10109
  parts.push("## Agent Prompts\n");
10025
- parts.push(
10026
- steps.map((s) => `- \`${agentInstallPath(s.agent)}\``).join("\n") + "\n"
10027
- );
10028
- parts.push("## Expected Outputs\n");
10029
- parts.push(steps.map((s) => `- \`${s.output}\``).join("\n") + "\n");
10110
+ if (agentPaths.length > 1) {
10111
+ parts.push("Use:\n");
10112
+ parts.push(agentPaths.map((p2) => `- \`${p2}\``).join("\n") + "\n");
10113
+ } else {
10114
+ parts.push(`- \`${plan.contextPackPath}\`
10115
+ `);
10116
+ }
10117
+ if (steps.length > 0) {
10118
+ parts.push("## Expected Outputs\n");
10119
+ parts.push(steps.map((s) => `- \`${s.output}\``).join("\n") + "\n");
10120
+ } else if (rec) {
10121
+ parts.push("## Expected Outputs\n");
10122
+ const outputs = [];
10123
+ if (rec.target) outputs.push(`- \`${rec.target}\``);
10124
+ if (rec.id === "refine-work-item" || rec.id === "resolve-blocker")
10125
+ outputs.push("- Refined Work Item content.");
10126
+ if (rec.id === "create-work-item")
10127
+ outputs.push("- A new Work Item under `knowledge/delivery/work-items/`.");
10128
+ if (rec.id === "implement")
10129
+ outputs.push("- Implementation plan or code changes guided by the Work Item.");
10130
+ if (rec.id === "guard")
10131
+ outputs.push("- Updated knowledge artifacts reflecting recent code changes.");
10132
+ if (rec.id === "install-adapter")
10133
+ outputs.push("- An adapter configured and injected (`kaddo adapters list`).");
10134
+ if (outputs.length > 0) {
10135
+ parts.push("The LLM should produce:\n");
10136
+ parts.push(outputs.join("\n") + "\n");
10137
+ } else {
10138
+ parts.push("_See the primary recommendation above._\n");
10139
+ }
10140
+ }
10030
10141
  parts.push("## Copy/Paste Instructions\n");
10031
- const first2 = steps[0];
10032
- if (first2) {
10142
+ if (steps.length > 0) {
10143
+ const first2 = steps[0];
10033
10144
  parts.push(
10034
10145
  [
10035
10146
  `Start with **${agentName(first2.agent)}**:`,
@@ -10041,9 +10152,31 @@ function renderUnderstand(plan) {
10041
10152
  `5. Save the result in: \`${first2.output}\``
10042
10153
  ].join("\n") + "\n"
10043
10154
  );
10155
+ } else if (agentPaths.length > 1) {
10156
+ parts.push("Paste the following into your LLM chat:\n");
10157
+ parts.push(agentPaths.map((p2, i) => `${i + 1}. \`${p2}\``).join("\n") + "\n");
10158
+ if (rec?.agent) {
10159
+ parts.push(`Ask the LLM to follow the ${agentName(rec.agent)} instructions.
10160
+ `);
10161
+ }
10162
+ } else {
10163
+ parts.push(`Paste \`${plan.contextPackPath}\` into your LLM chat.
10164
+ `);
10044
10165
  }
10045
10166
  parts.push("## Next Steps\n");
10046
- if (steps.length > 1) {
10167
+ if (rec) {
10168
+ const nextLines = [];
10169
+ nextLines.push(`1. ${rec.label}`);
10170
+ let n = 2;
10171
+ if (rec.secondary) {
10172
+ for (const s of rec.secondary) {
10173
+ nextLines.push(`${n}. ${s.label}`);
10174
+ n++;
10175
+ }
10176
+ }
10177
+ nextLines.push(`${n}. Re-run \`kaddo explain\`.`);
10178
+ parts.push(nextLines.join("\n") + "\n");
10179
+ } else if (steps.length > 1) {
10047
10180
  parts.push(
10048
10181
  `After saving \`${steps[0].output}\`, continue with **${agentName(steps[1].agent)}** (feed it the context pack plus the artifacts you already produced). Re-run \`kaddo understand\` any time to see this plan again.
10049
10182
  `
@@ -10268,7 +10401,41 @@ function runUnderstand() {
10268
10401
  console.log(`Other active work items: ${active.slice(1).map((w) => w.id).join(", ")}`);
10269
10402
  }
10270
10403
  }
10271
- writeFile(join(dir, ".kaddo", "understand.md"), renderUnderstand(plan));
10404
+ const ds = buildDeliveryState(dir);
10405
+ ds.phase = assessment.phase;
10406
+ const wis = discoverWorkItems(dir);
10407
+ const activeWis = wis.filter((w) => w.lifecycle && ["draft", "ready", "in-progress", "blocked"].includes(w.lifecycle)).map((w) => ({
10408
+ id: w.id,
10409
+ title: w.title,
10410
+ type: w.type,
10411
+ lifecycle: w.lifecycle ?? "draft",
10412
+ knowledgeLevel: w.knowledgeLevel,
10413
+ hasOwnership: w.codeGlobs.length > 0
10414
+ }));
10415
+ const recommendedPaths = [];
10416
+ if (rec.agent) {
10417
+ const agentFile = rec.agent.endsWith(".md") ? rec.agent : `${rec.agent}.md`;
10418
+ if (agentIsInstalled(dir, agentFile)) {
10419
+ recommendedPaths.push(agentInstallPath(agentFile));
10420
+ }
10421
+ }
10422
+ const recommendedSkillPaths = [];
10423
+ if (rec.skill) {
10424
+ const sp = skillInstallPath(rec.skill);
10425
+ if (exists(join(dir, sp))) {
10426
+ recommendedSkillPaths.push(sp);
10427
+ }
10428
+ }
10429
+ const enrichedPlan = enrichUnderstandPlan(plan, {
10430
+ phase: assessment.phase,
10431
+ nextStepRecommendation: rec,
10432
+ deliveryState: ds,
10433
+ activeWorkItems: activeWis,
10434
+ recommendedPaths,
10435
+ recommendedSkillPaths,
10436
+ language: languageLabel(projectLanguage(config))
10437
+ });
10438
+ writeFile(join(dir, ".kaddo", "understand.md"), renderUnderstand(enrichedPlan));
10272
10439
  log2.success("Wrote .kaddo/understand.md");
10273
10440
  printCommandFooter("understand");
10274
10441
  outro2("Handoff ready. CLI prepares context \u2014 your LLM creates the understanding.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.45.0",
3
+ "version": "3.46.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {