@kaddo/cli 3.11.2 → 3.13.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.
- package/dist/index.js +203 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1546,6 +1546,20 @@ var RESPONSIBILITY_MATRIX = {
|
|
|
1546
1546
|
cannotSuggest: ["branches", "commits", "pull requests", "code"],
|
|
1547
1547
|
next: ["kaddo create --from roadmap", "work-item-agent"]
|
|
1548
1548
|
},
|
|
1549
|
+
"backlog-agent": {
|
|
1550
|
+
agent: "backlog-agent",
|
|
1551
|
+
responsibleFor: ["Capturing ideas", "Structuring new work"],
|
|
1552
|
+
produces: ["knowledge/delivery/work-items/draft/", "roadmap candidates"],
|
|
1553
|
+
canSuggest: ["work-item-agent", "roadmap-agent"],
|
|
1554
|
+
cannotSuggest: [
|
|
1555
|
+
"code",
|
|
1556
|
+
"branches",
|
|
1557
|
+
"commits",
|
|
1558
|
+
"editing the roadmap automatically",
|
|
1559
|
+
"auto-executing other agents"
|
|
1560
|
+
],
|
|
1561
|
+
next: ["human decision (refine / add candidate / split / keep draft)"]
|
|
1562
|
+
},
|
|
1549
1563
|
"work-item-agent": {
|
|
1550
1564
|
agent: "work-item-agent",
|
|
1551
1565
|
responsibleFor: ["Work Item refinement"],
|
|
@@ -2249,6 +2263,12 @@ You do **not** suggest branches, commits or pull requests \u2014 implementation
|
|
|
2249
2263
|
branch suggestion) is the implementation-agent's responsibility, and only by respecting the
|
|
2250
2264
|
project Git strategy. Your job ends at a clear, traceable Work Item.
|
|
2251
2265
|
|
|
2266
|
+
## Git boundaries
|
|
2267
|
+
|
|
2268
|
+
Never run Git. Do not create or switch branches, create worktrees, stash, commit, push or merge.
|
|
2269
|
+
Work only inside the currently selected workspace. If a workspace or branch change is required,
|
|
2270
|
+
stop and ask the human.
|
|
2271
|
+
|
|
2252
2272
|
## Quality Checklist
|
|
2253
2273
|
|
|
2254
2274
|
- The problem is one clear sentence.
|
|
@@ -2814,6 +2834,10 @@ Conventional Commit message \u2014 as suggestions, never executed.
|
|
|
2814
2834
|
## Constraints
|
|
2815
2835
|
|
|
2816
2836
|
- Never run Git. Never commit, push or merge \u2014 suggest and wait for the human.
|
|
2837
|
+
- **Do not create branches, switch branches, create worktrees, or stash changes.** You may
|
|
2838
|
+
*suggest* a branch name; the human creates the branch and selects the workspace.
|
|
2839
|
+
- **Work only inside the currently selected workspace** (repository root or the active Git
|
|
2840
|
+
worktree). If a branch or workspace change is required, stop and ask the human.
|
|
2817
2841
|
- Respect \`knowledge/tech/git-strategy.md\` when it exists.
|
|
2818
2842
|
- Keep knowledge in sync with the code you change.
|
|
2819
2843
|
- Do not invent business facts.
|
|
@@ -2846,6 +2870,98 @@ Code, tests and migrations live in the repository. Knowledge updates go under \`
|
|
|
2846
2870
|
- Affected knowledge is updated.
|
|
2847
2871
|
- Commit is suggested and awaits human confirmation \u2014 never run automatically.
|
|
2848
2872
|
`;
|
|
2873
|
+
var BACKLOG_AGENT = `# Backlog Agent
|
|
2874
|
+
|
|
2875
|
+
## Role
|
|
2876
|
+
|
|
2877
|
+
You are the Kaddo Backlog Agent. Your job is to capture raw ideas, requests, meeting notes,
|
|
2878
|
+
conversations and transcripts and turn them into **structured backlog** compatible with Kaddo \u2014
|
|
2879
|
+
either a Work Item draft or a roadmap candidate.
|
|
2880
|
+
|
|
2881
|
+
You answer one question: **"where should this idea live?"** \u2014 not "how is it implemented?". You do
|
|
2882
|
+
not write code, you do not refine Work Items fully, and you never trigger the next step.
|
|
2883
|
+
|
|
2884
|
+
## When to Use
|
|
2885
|
+
|
|
2886
|
+
Use this agent whenever new work appears outside the roadmap: a one-line idea, a bullet list, a
|
|
2887
|
+
meeting transcript, a Slack/Teams/email thread. It sits before the work-item-agent:
|
|
2888
|
+
|
|
2889
|
+
\`Idea \u2192 backlog-agent \u2192 draft / roadmap candidate \u2192 (human decides) \u2192 work-item-agent\`
|
|
2890
|
+
|
|
2891
|
+
## Input Required
|
|
2892
|
+
|
|
2893
|
+
Provide \`.kaddo/context-pack.md\` as the primary input, plus the raw idea/notes/transcript. Use
|
|
2894
|
+
\`knowledge/business/business.md\`, \`knowledge/product/product.md\`, \`knowledge/product/capabilities.md\`,
|
|
2895
|
+
\`knowledge/tech/codebase.md\` and \`knowledge/delivery/roadmap.md\` when they exist to place the idea
|
|
2896
|
+
in the right initiative and avoid duplicates.
|
|
2897
|
+
|
|
2898
|
+
## Expected Output
|
|
2899
|
+
|
|
2900
|
+
One of:
|
|
2901
|
+
|
|
2902
|
+
1. A **Work Item draft** under \`knowledge/delivery/work-items/draft/\` when the scope is clear and
|
|
2903
|
+
small.
|
|
2904
|
+
2. A **roadmap candidate** (\`WI-CANDIDATE-XXX\`) to add later when the scope is too large.
|
|
2905
|
+
3. **Multiple** backlog items when the input contains several distinct ideas (split them).
|
|
2906
|
+
|
|
2907
|
+
## Instructions
|
|
2908
|
+
|
|
2909
|
+
1. Read the idea and the available knowledge.
|
|
2910
|
+
2. Decide: clear & small \u2192 Work Item draft; large \u2192 roadmap candidate; multiple ideas \u2192 split.
|
|
2911
|
+
3. For each item infer: initiative, domains, suggested type (feature/bugfix/hotfix/spike/chore),
|
|
2912
|
+
suggested Knowledge Level (K1\u2013K4) and a suggested priority.
|
|
2913
|
+
4. Detect duplicates, overlaps and obvious dependencies with existing knowledge.
|
|
2914
|
+
5. Place each item under the most appropriate initiative.
|
|
2915
|
+
6. End with the mandatory handoff (below) \u2014 the human decides the next step.
|
|
2916
|
+
|
|
2917
|
+
## Constraints
|
|
2918
|
+
|
|
2919
|
+
- Do not write code.
|
|
2920
|
+
- Do not fully refine Work Items (that is the work-item-agent).
|
|
2921
|
+
- Do not modify \`knowledge/delivery/roadmap.md\` automatically \u2014 propose the candidate.
|
|
2922
|
+
- Never run Git (no branches, commits, pushes, merges).
|
|
2923
|
+
- **Never auto-execute the next step.** Do not run the work-item-agent or implementation-agent.
|
|
2924
|
+
- Always require a human decision before anything continues.
|
|
2925
|
+
|
|
2926
|
+
## Output Format
|
|
2927
|
+
|
|
2928
|
+
\`\`\`markdown
|
|
2929
|
+
# Backlog capture
|
|
2930
|
+
|
|
2931
|
+
## Item 1 \u2014 <title>
|
|
2932
|
+
- Output: Work Item draft | Roadmap candidate
|
|
2933
|
+
- Suggested type: feature | bugfix | hotfix | spike | chore
|
|
2934
|
+
- Suggested Knowledge Level: K1 / K2 / K3 / K4
|
|
2935
|
+
- Initiative:
|
|
2936
|
+
- Domains:
|
|
2937
|
+
- Suggested priority:
|
|
2938
|
+
- Duplicates / overlaps / dependencies:
|
|
2939
|
+
- Summary:
|
|
2940
|
+
|
|
2941
|
+
## Handoff
|
|
2942
|
+
Created: WI-023 (draft) \xB7or\xB7 Roadmap candidate: WI-CANDIDATE-014
|
|
2943
|
+
|
|
2944
|
+
Suggested next actions (human decides \u2014 nothing runs automatically):
|
|
2945
|
+
1. Refine with the work-item-agent
|
|
2946
|
+
2. Add as a roadmap candidate
|
|
2947
|
+
3. Split into multiple items
|
|
2948
|
+
4. Keep as a draft
|
|
2949
|
+
\`\`\`
|
|
2950
|
+
|
|
2951
|
+
## Where to Save the Result
|
|
2952
|
+
|
|
2953
|
+
Save a Work Item draft under \`knowledge/delivery/work-items/draft/\`. For a roadmap candidate,
|
|
2954
|
+
propose the \`WI-CANDIDATE-XXX\` text for a human to add to \`knowledge/delivery/roadmap.md\` (do not
|
|
2955
|
+
edit the roadmap yourself).
|
|
2956
|
+
|
|
2957
|
+
## Quality Checklist
|
|
2958
|
+
|
|
2959
|
+
- The idea is captured without being implemented or fully refined.
|
|
2960
|
+
- Output is clearly a draft or a roadmap candidate.
|
|
2961
|
+
- Multiple ideas are split into separate items.
|
|
2962
|
+
- Duplicates, overlaps and dependencies are flagged.
|
|
2963
|
+
- The response ends with a human-decision handoff \u2014 no agent is auto-executed.
|
|
2964
|
+
`;
|
|
2849
2965
|
var AGENT_PROMPTS = [
|
|
2850
2966
|
{ fileName: "capability-agent.md", content: CAPABILITY_AGENT },
|
|
2851
2967
|
{ fileName: "architecture-agent.md", content: ARCHITECTURE_AGENT },
|
|
@@ -2863,7 +2979,9 @@ var AGENT_PROMPTS = [
|
|
|
2863
2979
|
{ fileName: "bootstrap-agent.md", content: BOOTSTRAP_AGENT },
|
|
2864
2980
|
{ fileName: "codebase-agent.md", content: CODEBASE_FOUNDATION_AGENT },
|
|
2865
2981
|
// Implementation (the only agent that may suggest a branch — VS-044)
|
|
2866
|
-
{ fileName: "implementation-agent.md", content: IMPLEMENTATION_AGENT }
|
|
2982
|
+
{ fileName: "implementation-agent.md", content: IMPLEMENTATION_AGENT },
|
|
2983
|
+
// Backlog capture (idea → draft / roadmap candidate — VS-050)
|
|
2984
|
+
{ fileName: "backlog-agent.md", content: BACKLOG_AGENT }
|
|
2867
2985
|
// Every official prompt ends with its responsibility boundaries + Agent Trace footer.
|
|
2868
2986
|
].map((p2) => ({ fileName: p2.fileName, content: withResponsibilityTrace(p2.fileName, p2.content) }));
|
|
2869
2987
|
|
|
@@ -2881,6 +2999,7 @@ var AGENT_GROUPS = {
|
|
|
2881
2999
|
"adr-agent.md"
|
|
2882
3000
|
],
|
|
2883
3001
|
delivery: [
|
|
3002
|
+
"backlog-agent.md",
|
|
2884
3003
|
"roadmap-agent.md",
|
|
2885
3004
|
"work-item-agent.md",
|
|
2886
3005
|
"implementation-agent.md",
|
|
@@ -2906,6 +3025,7 @@ var RECOMMENDED_BY_STATE = {
|
|
|
2906
3025
|
"architecture-agent.md",
|
|
2907
3026
|
"codebase-agent.md",
|
|
2908
3027
|
"roadmap-agent.md",
|
|
3028
|
+
"backlog-agent.md",
|
|
2909
3029
|
"work-item-agent.md",
|
|
2910
3030
|
"implementation-agent.md",
|
|
2911
3031
|
"adr-agent.md"
|
|
@@ -2914,6 +3034,7 @@ var RECOMMENDED_BY_STATE = {
|
|
|
2914
3034
|
"capability-agent.md",
|
|
2915
3035
|
"architecture-agent.md",
|
|
2916
3036
|
"roadmap-agent.md",
|
|
3037
|
+
"backlog-agent.md",
|
|
2917
3038
|
"work-item-agent.md",
|
|
2918
3039
|
"implementation-agent.md"
|
|
2919
3040
|
],
|
|
@@ -2922,6 +3043,7 @@ var RECOMMENDED_BY_STATE = {
|
|
|
2922
3043
|
"architecture-agent.md",
|
|
2923
3044
|
"capability-agent.md",
|
|
2924
3045
|
"roadmap-agent.md",
|
|
3046
|
+
"backlog-agent.md",
|
|
2925
3047
|
"work-item-agent.md",
|
|
2926
3048
|
"implementation-agent.md"
|
|
2927
3049
|
]
|
|
@@ -4959,6 +5081,42 @@ function assessPhase(input) {
|
|
|
4959
5081
|
return { phase, reasons, recommendedAgents: recommendedAgents2, nextStep };
|
|
4960
5082
|
}
|
|
4961
5083
|
|
|
5084
|
+
// src/core/workspace.ts
|
|
5085
|
+
import { dirname, resolve, basename } from "path";
|
|
5086
|
+
function findGitEntry(startDir) {
|
|
5087
|
+
let cur = resolve(startDir);
|
|
5088
|
+
while (true) {
|
|
5089
|
+
const g = join(cur, ".git");
|
|
5090
|
+
if (exists(g)) return { dir: cur, gitPath: g };
|
|
5091
|
+
const parent = dirname(cur);
|
|
5092
|
+
if (parent === cur) return null;
|
|
5093
|
+
cur = parent;
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
function readBranch(gitDir) {
|
|
5097
|
+
try {
|
|
5098
|
+
const head = readFile(join(gitDir, "HEAD")).trim();
|
|
5099
|
+
const m = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
5100
|
+
if (m) return m[1].trim();
|
|
5101
|
+
return head ? head.slice(0, 12) : null;
|
|
5102
|
+
} catch {
|
|
5103
|
+
return null;
|
|
5104
|
+
}
|
|
5105
|
+
}
|
|
5106
|
+
function detectWorkspace(startDir) {
|
|
5107
|
+
const found = findGitEntry(startDir);
|
|
5108
|
+
if (!found) return { isGitRepo: false, root: null, branch: null, isWorktree: false };
|
|
5109
|
+
const { dir, gitPath } = found;
|
|
5110
|
+
if (!isFile(gitPath)) {
|
|
5111
|
+
return { isGitRepo: true, root: dir, branch: readBranch(gitPath), isWorktree: false };
|
|
5112
|
+
}
|
|
5113
|
+
let gitDir = gitPath;
|
|
5114
|
+
const m = readFile(gitPath).match(/gitdir:\s*(.+)/);
|
|
5115
|
+
if (m) gitDir = m[1].trim();
|
|
5116
|
+
const isWorktree = basename(dirname(gitDir)) === "worktrees";
|
|
5117
|
+
return { isGitRepo: true, root: dir, branch: readBranch(gitDir), isWorktree };
|
|
5118
|
+
}
|
|
5119
|
+
|
|
4962
5120
|
// src/core/knowledge-discovery.ts
|
|
4963
5121
|
var KNOWLEDGE = "knowledge";
|
|
4964
5122
|
var CONSOLIDATED_TYPE = {
|
|
@@ -5008,7 +5166,7 @@ function layerFromPath(filePath) {
|
|
|
5008
5166
|
if (p2.includes(`/${KNOWLEDGE}/delivery/`)) return "Delivery";
|
|
5009
5167
|
return null;
|
|
5010
5168
|
}
|
|
5011
|
-
function
|
|
5169
|
+
function basename2(p2) {
|
|
5012
5170
|
return p2.replace(/\\/g, "/").split("/").pop() ?? p2;
|
|
5013
5171
|
}
|
|
5014
5172
|
function discoverLayers(dir) {
|
|
@@ -5025,9 +5183,9 @@ function discoverLayers(dir) {
|
|
|
5025
5183
|
const layer2 = layerForType(type) ?? layerFromPath(a.filePath);
|
|
5026
5184
|
if (!layer2) continue;
|
|
5027
5185
|
const slot = acc[layer2];
|
|
5028
|
-
slot.detected.add(
|
|
5186
|
+
slot.detected.add(basename2(a.filePath));
|
|
5029
5187
|
if (layer2 === "Delivery") {
|
|
5030
|
-
if (type === "roadmap" ||
|
|
5188
|
+
if (type === "roadmap" || basename2(a.filePath) === "roadmap.md") slot.hasRoadmap = true;
|
|
5031
5189
|
if (WORK_ITEM_TYPES2.has(type) || a.filePath.replace(/\\/g, "/").includes("/delivery/work-items/")) {
|
|
5032
5190
|
if (a.filePath.replace(/\\/g, "/").includes("/delivery/work-items/")) slot.hasWorkItem = true;
|
|
5033
5191
|
}
|
|
@@ -5210,6 +5368,7 @@ function buildProjectExplanation(dir) {
|
|
|
5210
5368
|
workItemsMissingOwnership: items.length - withOwnership
|
|
5211
5369
|
};
|
|
5212
5370
|
const domains = [...new Set(workItemArtifacts.flatMap((a) => a.domains))].filter(Boolean);
|
|
5371
|
+
const workspace = detectWorkspace(dir);
|
|
5213
5372
|
const roadmapPath = join(dir, ARCH_DIR4, "delivery", "roadmap.md");
|
|
5214
5373
|
const roadmapMd = exists(roadmapPath) ? readFile(roadmapPath) : null;
|
|
5215
5374
|
const roadmap = roadmapStats(roadmapMd, items.length);
|
|
@@ -5259,6 +5418,7 @@ function buildProjectExplanation(dir) {
|
|
|
5259
5418
|
workItems,
|
|
5260
5419
|
ownership,
|
|
5261
5420
|
domains,
|
|
5421
|
+
workspace,
|
|
5262
5422
|
layers,
|
|
5263
5423
|
roadmap,
|
|
5264
5424
|
mappedModules,
|
|
@@ -5291,6 +5451,21 @@ function renderExplanationHuman(exp) {
|
|
|
5291
5451
|
lines.push(`- Team: ${exp.project.teamSize}`);
|
|
5292
5452
|
lines.push(`- Structure: ${exp.project.structure}`);
|
|
5293
5453
|
lines.push("");
|
|
5454
|
+
lines.push("## Workspace");
|
|
5455
|
+
if (exp.workspace.isGitRepo) {
|
|
5456
|
+
lines.push(`- Repository root: ${exp.workspace.root ?? "unknown"}`);
|
|
5457
|
+
lines.push(`- Git worktree: ${exp.workspace.isWorktree ? "yes" : "no"}`);
|
|
5458
|
+
lines.push(`- Active branch: ${exp.workspace.branch ?? "unknown"}`);
|
|
5459
|
+
if (exp.workspace.isWorktree) {
|
|
5460
|
+
lines.push("");
|
|
5461
|
+
lines.push(
|
|
5462
|
+
"> Worktree detected. Run all Kaddo commands (scan, guard, owners suggest, explain) from this worktree while implementation is active, so they observe the same files the agent is changing."
|
|
5463
|
+
);
|
|
5464
|
+
}
|
|
5465
|
+
} else {
|
|
5466
|
+
lines.push("- Not a Git repository");
|
|
5467
|
+
}
|
|
5468
|
+
lines.push("");
|
|
5294
5469
|
lines.push("## Knowledge Layers");
|
|
5295
5470
|
lines.push(renderLayersMarkdown(exp.layers));
|
|
5296
5471
|
lines.push("");
|
|
@@ -5781,6 +5956,7 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
|
|
|
5781
5956
|
layers,
|
|
5782
5957
|
roadmap,
|
|
5783
5958
|
phase,
|
|
5959
|
+
workspace: detectWorkspace(dir),
|
|
5784
5960
|
deliveryMix,
|
|
5785
5961
|
mappedModules,
|
|
5786
5962
|
missing,
|
|
@@ -5818,6 +5994,23 @@ function renderContextPack(pack) {
|
|
|
5818
5994
|
`- Structure: ${project.structure}`
|
|
5819
5995
|
].join("\n") + "\n"
|
|
5820
5996
|
);
|
|
5997
|
+
parts.push("## Execution Context\n");
|
|
5998
|
+
if (pack.workspace.isGitRepo) {
|
|
5999
|
+
parts.push(
|
|
6000
|
+
[
|
|
6001
|
+
`- Repository root: ${pack.workspace.root ?? "unknown"}`,
|
|
6002
|
+
`- Current branch: ${pack.workspace.branch ?? "unknown"}`,
|
|
6003
|
+
`- Git worktree: ${pack.workspace.isWorktree ? "yes" : "no"}`
|
|
6004
|
+
].join("\n") + "\n"
|
|
6005
|
+
);
|
|
6006
|
+
if (pack.workspace.isWorktree) {
|
|
6007
|
+
parts.push(
|
|
6008
|
+
"You are inside a Git worktree. Work only in this workspace; run Kaddo commands from here.\n"
|
|
6009
|
+
);
|
|
6010
|
+
}
|
|
6011
|
+
} else {
|
|
6012
|
+
parts.push("- Not a Git repository\n");
|
|
6013
|
+
}
|
|
5821
6014
|
parts.push("## Current Phase\n");
|
|
5822
6015
|
parts.push(`Phase: ${pack.phase.phase}
|
|
5823
6016
|
`);
|
|
@@ -6252,6 +6445,12 @@ function runUnderstand() {
|
|
|
6252
6445
|
if (assessment.nextStep) {
|
|
6253
6446
|
console.log(`Next step: ${assessment.nextStep}`);
|
|
6254
6447
|
}
|
|
6448
|
+
if (exp.workspace.isWorktree) {
|
|
6449
|
+
console.log("");
|
|
6450
|
+
console.log(`Current implementation workspace: ${exp.workspace.branch ?? "(detached)"}`);
|
|
6451
|
+
console.log(" \u2192 You are inside a Git worktree. Run scan, owners suggest, guard and explain");
|
|
6452
|
+
console.log(" from this worktree so they reflect the code being changed here.");
|
|
6453
|
+
}
|
|
6255
6454
|
const active = activeWorkItems(dir);
|
|
6256
6455
|
if (active.length > 0) {
|
|
6257
6456
|
console.log("");
|