@kaddo/cli 3.7.2 → 3.9.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 +399 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -725,6 +725,17 @@ async function runScan() {
|
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
// src/core/knowledge-levels.ts
|
|
728
|
+
var WORK_ITEM_TYPES = ["feature", "bugfix", "hotfix", "spike", "chore"];
|
|
729
|
+
var TYPE_ALIASES = {
|
|
730
|
+
setup: "chore",
|
|
731
|
+
maintenance: "chore",
|
|
732
|
+
tooling: "chore",
|
|
733
|
+
infrastructure: "chore",
|
|
734
|
+
infra: "chore",
|
|
735
|
+
config: "chore",
|
|
736
|
+
configuration: "chore",
|
|
737
|
+
refactor: "chore"
|
|
738
|
+
};
|
|
728
739
|
var LEVELS = {
|
|
729
740
|
K0: {
|
|
730
741
|
level: "K0",
|
|
@@ -879,7 +890,9 @@ var TYPE_TO_LEVEL = {
|
|
|
879
890
|
hotfix: "K1",
|
|
880
891
|
bugfix: "K2",
|
|
881
892
|
feature: "K2",
|
|
882
|
-
spike: "K3"
|
|
893
|
+
spike: "K3",
|
|
894
|
+
// Chores are maintenance/config/tooling work — low ceremony (problem + expected result).
|
|
895
|
+
chore: "K1"
|
|
883
896
|
};
|
|
884
897
|
function getLevel(level) {
|
|
885
898
|
return LEVELS[level];
|
|
@@ -888,7 +901,13 @@ function getLevelForType(type) {
|
|
|
888
901
|
return TYPE_TO_LEVEL[type];
|
|
889
902
|
}
|
|
890
903
|
function isValidType(type) {
|
|
891
|
-
return
|
|
904
|
+
return WORK_ITEM_TYPES.includes(type);
|
|
905
|
+
}
|
|
906
|
+
function normalizeType(raw) {
|
|
907
|
+
if (!raw) return null;
|
|
908
|
+
const t = raw.trim().toLowerCase();
|
|
909
|
+
if (isValidType(t)) return t;
|
|
910
|
+
return TYPE_ALIASES[t] ?? null;
|
|
892
911
|
}
|
|
893
912
|
|
|
894
913
|
// src/modules/adr.ts
|
|
@@ -1375,6 +1394,220 @@ var guardAdvancedModule = {
|
|
|
1375
1394
|
]
|
|
1376
1395
|
};
|
|
1377
1396
|
|
|
1397
|
+
// src/agents/responsibility.ts
|
|
1398
|
+
var RESPONSIBILITY_MATRIX = {
|
|
1399
|
+
"business-agent": {
|
|
1400
|
+
agent: "business-agent",
|
|
1401
|
+
responsibleFor: ["Problem", "Users", "Rules", "Constraints"],
|
|
1402
|
+
produces: ["knowledge/business/business.md"],
|
|
1403
|
+
canSuggest: ["product-agent"],
|
|
1404
|
+
cannotSuggest: ["Git", "branches", "commits", "code"],
|
|
1405
|
+
next: ["product-agent"]
|
|
1406
|
+
},
|
|
1407
|
+
"product-agent": {
|
|
1408
|
+
agent: "product-agent",
|
|
1409
|
+
responsibleFor: ["Product", "Capabilities", "Scope"],
|
|
1410
|
+
produces: ["knowledge/product/product.md", "knowledge/product/capabilities.md"],
|
|
1411
|
+
canSuggest: ["roadmap-agent"],
|
|
1412
|
+
cannotSuggest: ["Git", "implementation", "branches", "code"],
|
|
1413
|
+
next: ["roadmap-agent"]
|
|
1414
|
+
},
|
|
1415
|
+
"capability-agent": {
|
|
1416
|
+
agent: "capability-agent",
|
|
1417
|
+
responsibleFor: ["Capabilities"],
|
|
1418
|
+
produces: ["knowledge/product/capabilities.md"],
|
|
1419
|
+
canSuggest: ["roadmap-agent"],
|
|
1420
|
+
cannotSuggest: ["Git", "implementation", "branches", "code"],
|
|
1421
|
+
next: ["roadmap-agent"]
|
|
1422
|
+
},
|
|
1423
|
+
"bootstrap-agent": {
|
|
1424
|
+
agent: "bootstrap-agent",
|
|
1425
|
+
responsibleFor: ["Initial direction", "Capabilities", "Quality attributes", "Roadmap seed"],
|
|
1426
|
+
produces: [
|
|
1427
|
+
"knowledge/bootstrap-summary.md",
|
|
1428
|
+
"knowledge/product/capabilities.md",
|
|
1429
|
+
"knowledge/delivery/roadmap.md"
|
|
1430
|
+
],
|
|
1431
|
+
canSuggest: ["capability-agent", "architecture-agent", "roadmap-agent"],
|
|
1432
|
+
cannotSuggest: ["Git", "branches", "commits", "code"],
|
|
1433
|
+
next: ["capability-agent", "architecture-agent"]
|
|
1434
|
+
},
|
|
1435
|
+
"codebase-agent": {
|
|
1436
|
+
agent: "codebase-agent",
|
|
1437
|
+
responsibleFor: ["Stack", "Structure", "Standards"],
|
|
1438
|
+
produces: ["knowledge/tech/codebase.md"],
|
|
1439
|
+
canSuggest: ["architecture-agent", "decision-agent"],
|
|
1440
|
+
cannotSuggest: ["Git", "branches", "commits", "production code"],
|
|
1441
|
+
next: ["architecture-agent"]
|
|
1442
|
+
},
|
|
1443
|
+
"stack-agent": {
|
|
1444
|
+
agent: "stack-agent",
|
|
1445
|
+
responsibleFor: ["Technologies", "Stack classification"],
|
|
1446
|
+
produces: ["knowledge/tech/stack.md"],
|
|
1447
|
+
canSuggest: ["architecture-agent", "standards-agent"],
|
|
1448
|
+
cannotSuggest: ["Git", "branches", "code"],
|
|
1449
|
+
next: ["architecture-agent"]
|
|
1450
|
+
},
|
|
1451
|
+
"standards-agent": {
|
|
1452
|
+
agent: "standards-agent",
|
|
1453
|
+
responsibleFor: ["Coding/doc/testing standards"],
|
|
1454
|
+
produces: ["knowledge/tech/standards.md"],
|
|
1455
|
+
canSuggest: ["architecture-agent"],
|
|
1456
|
+
cannotSuggest: ["Git", "branches", "code"],
|
|
1457
|
+
next: ["architecture-agent"]
|
|
1458
|
+
},
|
|
1459
|
+
"security-agent": {
|
|
1460
|
+
agent: "security-agent",
|
|
1461
|
+
responsibleFor: ["Security considerations"],
|
|
1462
|
+
produces: ["knowledge/tech/security.md"],
|
|
1463
|
+
canSuggest: ["architecture-agent", "decision-agent"],
|
|
1464
|
+
cannotSuggest: ["Git", "branches", "code", "vulnerability scanning"],
|
|
1465
|
+
next: ["architecture-agent"]
|
|
1466
|
+
},
|
|
1467
|
+
"module-design-agent": {
|
|
1468
|
+
agent: "module-design-agent",
|
|
1469
|
+
responsibleFor: ["Module design", "Boundaries"],
|
|
1470
|
+
produces: ["knowledge/tech/modules/<module>/module-design.md"],
|
|
1471
|
+
canSuggest: ["architecture-agent", "decision-agent"],
|
|
1472
|
+
cannotSuggest: ["Git", "branches", "code"],
|
|
1473
|
+
next: ["architecture-agent"]
|
|
1474
|
+
},
|
|
1475
|
+
"architecture-agent": {
|
|
1476
|
+
agent: "architecture-agent",
|
|
1477
|
+
responsibleFor: ["Architecture", "Technical state", "Risks"],
|
|
1478
|
+
produces: ["knowledge/tech/current-state.md"],
|
|
1479
|
+
canSuggest: ["decision-agent", "roadmap-agent"],
|
|
1480
|
+
cannotSuggest: ["Git", "branches", "commits", "code"],
|
|
1481
|
+
next: ["decision-agent", "roadmap-agent"]
|
|
1482
|
+
},
|
|
1483
|
+
"decision-agent": {
|
|
1484
|
+
agent: "decision-agent",
|
|
1485
|
+
responsibleFor: ["ADRs"],
|
|
1486
|
+
produces: ["knowledge/tech/decisions/"],
|
|
1487
|
+
canSuggest: ["implementation-agent"],
|
|
1488
|
+
cannotSuggest: ["Git", "branches", "commits", "code"],
|
|
1489
|
+
next: ["implementation-agent"]
|
|
1490
|
+
},
|
|
1491
|
+
// The shipped prompt file is `adr-agent.md`; it plays the decision-agent role.
|
|
1492
|
+
"adr-agent": {
|
|
1493
|
+
agent: "adr-agent",
|
|
1494
|
+
responsibleFor: ["ADRs", "Decision candidates"],
|
|
1495
|
+
produces: ["knowledge/tech/decision-candidates.md", "knowledge/tech/decisions/"],
|
|
1496
|
+
canSuggest: ["implementation-agent"],
|
|
1497
|
+
cannotSuggest: ["Git", "branches", "commits", "code"],
|
|
1498
|
+
next: ["implementation-agent"]
|
|
1499
|
+
},
|
|
1500
|
+
"roadmap-agent": {
|
|
1501
|
+
agent: "roadmap-agent",
|
|
1502
|
+
responsibleFor: ["Roadmap", "Initiatives", "Work Item candidates"],
|
|
1503
|
+
produces: ["knowledge/delivery/roadmap.md"],
|
|
1504
|
+
canSuggest: ["kaddo create --from roadmap", "work-item-agent"],
|
|
1505
|
+
cannotSuggest: ["branches", "commits", "pull requests", "code"],
|
|
1506
|
+
next: ["kaddo create --from roadmap", "work-item-agent"]
|
|
1507
|
+
},
|
|
1508
|
+
"work-item-agent": {
|
|
1509
|
+
agent: "work-item-agent",
|
|
1510
|
+
responsibleFor: ["Work Item refinement"],
|
|
1511
|
+
produces: ["knowledge/delivery/work-items/"],
|
|
1512
|
+
canSuggest: ["implementation-agent"],
|
|
1513
|
+
cannotSuggest: ["branches", "commits", "pull requests", "code"],
|
|
1514
|
+
next: ["implementation-agent"]
|
|
1515
|
+
},
|
|
1516
|
+
"implementation-agent": {
|
|
1517
|
+
agent: "implementation-agent",
|
|
1518
|
+
responsibleFor: ["Implementation"],
|
|
1519
|
+
produces: ["Code", "Tests", "Migrations"],
|
|
1520
|
+
// The ONLY agent allowed to suggest branches — and only respecting the Git strategy.
|
|
1521
|
+
canSuggest: [
|
|
1522
|
+
"a branch (per knowledge/tech/git-strategy.md / .kaddo/git.yml)",
|
|
1523
|
+
"kaddo scan",
|
|
1524
|
+
"kaddo owners suggest",
|
|
1525
|
+
"kaddo guard"
|
|
1526
|
+
],
|
|
1527
|
+
cannotSuggest: [
|
|
1528
|
+
"running git itself",
|
|
1529
|
+
"committing without human confirmation",
|
|
1530
|
+
"pushing or merging"
|
|
1531
|
+
],
|
|
1532
|
+
next: ["kaddo scan", "kaddo owners suggest", "kaddo guard", "kaddo explain"]
|
|
1533
|
+
},
|
|
1534
|
+
"guard-agent": {
|
|
1535
|
+
agent: "guard-agent",
|
|
1536
|
+
responsibleFor: ["Knowledge drift"],
|
|
1537
|
+
produces: ["Findings", "Warnings"],
|
|
1538
|
+
canSuggest: ["update knowledge", "update ownership"],
|
|
1539
|
+
cannotSuggest: ["branches", "commits", "code"],
|
|
1540
|
+
next: ["update knowledge", "kaddo owners suggest"]
|
|
1541
|
+
},
|
|
1542
|
+
"git-strategy-agent": {
|
|
1543
|
+
agent: "git-strategy-agent",
|
|
1544
|
+
responsibleFor: ["Branch/commit/tag/release strategy (documentation)"],
|
|
1545
|
+
produces: ["knowledge/tech/git-strategy.md"],
|
|
1546
|
+
canSuggest: ["implementation-agent"],
|
|
1547
|
+
// It documents a strategy; it never creates branches/commits itself.
|
|
1548
|
+
cannotSuggest: ["creating branches", "creating commits", "creating tags"],
|
|
1549
|
+
next: ["implementation-agent"]
|
|
1550
|
+
},
|
|
1551
|
+
"legacy-agent": {
|
|
1552
|
+
agent: "legacy-agent",
|
|
1553
|
+
responsibleFor: ["Risks", "Unknowns", "Safe first steps"],
|
|
1554
|
+
produces: ["knowledge/legacy/risks.md", "knowledge/legacy/unknowns.md"],
|
|
1555
|
+
canSuggest: ["architecture-agent", "capability-agent"],
|
|
1556
|
+
cannotSuggest: ["Git", "branches", "code", "large rewrites"],
|
|
1557
|
+
next: ["architecture-agent"]
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
function list(items) {
|
|
1561
|
+
return items.length > 0 ? items.join(", ") : "\u2014";
|
|
1562
|
+
}
|
|
1563
|
+
function renderAgentBoundaries(agent) {
|
|
1564
|
+
const r = RESPONSIBILITY_MATRIX[agent];
|
|
1565
|
+
if (!r) return "";
|
|
1566
|
+
return [
|
|
1567
|
+
"## Responsibility & Boundaries",
|
|
1568
|
+
"",
|
|
1569
|
+
`**Responsible for:** ${list(r.responsibleFor)}`,
|
|
1570
|
+
`**Produces:** ${list(r.produces)}`,
|
|
1571
|
+
`**May suggest:** ${list(r.canSuggest)}`,
|
|
1572
|
+
`**Must NOT suggest:** ${list(r.cannotSuggest)}`,
|
|
1573
|
+
"",
|
|
1574
|
+
"This agent produces **knowledge only**. It never runs Git, never runs code and never runs commands. It may only suggest actions inside its own responsibility.",
|
|
1575
|
+
""
|
|
1576
|
+
].join("\n");
|
|
1577
|
+
}
|
|
1578
|
+
function renderAgentTrace(agent) {
|
|
1579
|
+
const r = RESPONSIBILITY_MATRIX[agent];
|
|
1580
|
+
if (!r) return "";
|
|
1581
|
+
const produced = r.produces.length > 0 ? r.produces.join("\n") : "(none)";
|
|
1582
|
+
const next = r.next.length > 0 ? r.next.join("\n") : "(end of flow)";
|
|
1583
|
+
return [
|
|
1584
|
+
"## Agent Trace",
|
|
1585
|
+
"",
|
|
1586
|
+
"End **every** response with this trace block so the flow stays auditable:",
|
|
1587
|
+
"",
|
|
1588
|
+
"```text",
|
|
1589
|
+
"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
1590
|
+
`Agent: ${r.agent}`,
|
|
1591
|
+
"",
|
|
1592
|
+
"Produced:",
|
|
1593
|
+
produced,
|
|
1594
|
+
"",
|
|
1595
|
+
"Next:",
|
|
1596
|
+
next,
|
|
1597
|
+
"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
1598
|
+
"```",
|
|
1599
|
+
""
|
|
1600
|
+
].join("\n");
|
|
1601
|
+
}
|
|
1602
|
+
function withResponsibilityTrace(fileName, content) {
|
|
1603
|
+
const agent = fileName.replace(/\.md$/, "");
|
|
1604
|
+
if (!RESPONSIBILITY_MATRIX[agent]) return content;
|
|
1605
|
+
return `${content.trimEnd()}
|
|
1606
|
+
|
|
1607
|
+
${renderAgentBoundaries(agent)}
|
|
1608
|
+
${renderAgentTrace(agent)}`;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1378
1611
|
// src/agents/prompts.ts
|
|
1379
1612
|
var CAPABILITY_AGENT = `# Capability Agent
|
|
1380
1613
|
|
|
@@ -1618,6 +1851,9 @@ Produce a roadmap where each initiative includes:
|
|
|
1618
1851
|
7. Dependencies.
|
|
1619
1852
|
8. Why this comes now.
|
|
1620
1853
|
9. Candidate work items (each with type, suggested knowledge level, expected value, notes).
|
|
1854
|
+
Use only the official Work Item types: \`feature\`, \`bugfix\`, \`hotfix\`, \`spike\`, \`chore\`.
|
|
1855
|
+
Use \`chore\` for technical/maintenance/tooling/config/infra work (e.g. "Initialize
|
|
1856
|
+
TypeScript project", "Configure Vitest", "Setup CI") \u2014 do not label such work \`feature\`.
|
|
1621
1857
|
10. Open questions.
|
|
1622
1858
|
|
|
1623
1859
|
Then add a suggested execution order, risks and constraints, a "Not Now" list, and the
|
|
@@ -1634,6 +1870,9 @@ Adapt priorities to the project state from the context pack:
|
|
|
1634
1870
|
|
|
1635
1871
|
- Do not invent business priorities or business facts \u2014 mark them as assumptions when inferred.
|
|
1636
1872
|
- Do not write code or implementation details.
|
|
1873
|
+
- **Do not suggest branches, commits or pull requests.** Git and implementation belong to the
|
|
1874
|
+
implementation-agent, and only after Work Items are materialized. Your handoff is
|
|
1875
|
+
\`kaddo create --from roadmap\` \u2192 work-item-agent.
|
|
1637
1876
|
- Do not create the work items themselves; only propose candidates.
|
|
1638
1877
|
- Make clear that initiatives and work items are **candidates**, not final decisions.
|
|
1639
1878
|
- Mark any uncertain information as an assumption or open question.
|
|
@@ -1916,12 +2155,14 @@ A refined Work Item intended to be saved under the lifecycle workspace:
|
|
|
1916
2155
|
|
|
1917
2156
|
1. Restate the problem in one clear sentence.
|
|
1918
2157
|
2. Split the candidate if it is too large for a single Work Item.
|
|
1919
|
-
3.
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
2158
|
+
3. Preserve the candidate's type (\`feature\`, \`bugfix\`, \`hotfix\`, \`spike\`, \`chore\`).
|
|
2159
|
+
Keep \`chore\` for maintenance/tooling/config/infra work \u2014 never upgrade a chore to a feature.
|
|
2160
|
+
4. Validate the Knowledge Level (K0\u2013K4) and propose a different one if needed.
|
|
2161
|
+
5. Propose acceptance criteria.
|
|
2162
|
+
6. Propose Out of scope and Validation sections.
|
|
2163
|
+
7. Propose a Definition of Done.
|
|
2164
|
+
8. Identify open questions and assumptions.
|
|
2165
|
+
9. Suggest ownership candidates (code globs) if evident.
|
|
1925
2166
|
|
|
1926
2167
|
## Constraints
|
|
1927
2168
|
|
|
@@ -1960,23 +2201,12 @@ Save new output as a draft under \`knowledge/delivery/work-items/draft/\` unless
|
|
|
1960
2201
|
explicitly asks for another lifecycle state. Treat only \`draft\`, \`ready\`, \`in-progress\`
|
|
1961
2202
|
and \`blocked\` as active work; \`completed\` and \`archived\` are historical knowledge.
|
|
1962
2203
|
|
|
1963
|
-
##
|
|
1964
|
-
|
|
1965
|
-
When this Work Item is **implemented** (by you or the coding agent), follow the project's
|
|
1966
|
-
delivery protocol. **Never run git mutating commands without the human's confirmation.**
|
|
2204
|
+
## Handoff
|
|
1967
2205
|
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
2. Implement the change.
|
|
1973
|
-
3. Run \`kaddo scan\` after adding modules, migrations, contracts or significant structure.
|
|
1974
|
-
4. Run \`kaddo owners suggest\` and confirm the \`code:\` globs.
|
|
1975
|
-
5. Run \`kaddo guard\` before committing to detect possible knowledge drift.
|
|
1976
|
-
6. Update the affected knowledge (ADR / capabilities.md / current-state.md).
|
|
1977
|
-
7. **Commit only with explicit human confirmation.** Never commit, push or merge on your
|
|
1978
|
-
own \u2014 suggest a Conventional Commit message and wait for the human. The Kaddo CLI itself
|
|
1979
|
-
never touches git.
|
|
2206
|
+
When the Work Item is refined and ready to build, **hand off to the implementation-agent**.
|
|
2207
|
+
You do **not** suggest branches, commits or pull requests \u2014 implementation (including any Git
|
|
2208
|
+
branch suggestion) is the implementation-agent's responsibility, and only by respecting the
|
|
2209
|
+
project Git strategy. Your job ends at a clear, traceable Work Item.
|
|
1980
2210
|
|
|
1981
2211
|
## Quality Checklist
|
|
1982
2212
|
|
|
@@ -1984,8 +2214,9 @@ delivery protocol. **Never run git mutating commands without the human's confirm
|
|
|
1984
2214
|
- Large candidates are split.
|
|
1985
2215
|
- Knowledge Level is justified.
|
|
1986
2216
|
- Acceptance criteria are testable.
|
|
2217
|
+
- Out of scope and Validation are stated.
|
|
1987
2218
|
- Open questions are explicit.
|
|
1988
|
-
-
|
|
2219
|
+
- Handoff: next step is the implementation-agent (never a branch or commit).
|
|
1989
2220
|
`;
|
|
1990
2221
|
var GIT_STRATEGY_AGENT = `# Git Strategy Agent
|
|
1991
2222
|
|
|
@@ -2498,6 +2729,82 @@ Save as \`knowledge/tech/codebase.md\`.
|
|
|
2498
2729
|
- Minimum criteria to start development are explicit.
|
|
2499
2730
|
- Assumptions and open questions are listed.
|
|
2500
2731
|
`;
|
|
2732
|
+
var IMPLEMENTATION_AGENT = `# Implementation Agent
|
|
2733
|
+
|
|
2734
|
+
## Role
|
|
2735
|
+
|
|
2736
|
+
You are the Kaddo Implementation Agent. Your job is to implement a refined Work Item \u2014 code,
|
|
2737
|
+
tests and migrations \u2014 and keep the project knowledge in sync. You are the **only** agent that
|
|
2738
|
+
may suggest a Git branch, and only by respecting the project's Git strategy.
|
|
2739
|
+
|
|
2740
|
+
You never run Git yourself. The Kaddo CLI never runs Git either. Every git action is the
|
|
2741
|
+
human's, and commits/pushes/merges happen only with explicit human confirmation.
|
|
2742
|
+
|
|
2743
|
+
## When to Use
|
|
2744
|
+
|
|
2745
|
+
Use this agent after the work-item-agent has produced a clear, traceable Work Item under
|
|
2746
|
+
\`knowledge/delivery/work-items/\` (typically in \`ready/\`).
|
|
2747
|
+
|
|
2748
|
+
## Input Required
|
|
2749
|
+
|
|
2750
|
+
Provide \`.kaddo/context-pack.md\`, the Work Item to implement, and the Git strategy
|
|
2751
|
+
(\`knowledge/tech/git-strategy.md\` / \`.kaddo/git.yml\`) if it exists.
|
|
2752
|
+
|
|
2753
|
+
## Expected Output
|
|
2754
|
+
|
|
2755
|
+
Working code, tests and migrations, plus updated knowledge (ADR / capabilities / current-state)
|
|
2756
|
+
when the change affects them. You also produce a suggested branch name and a suggested
|
|
2757
|
+
Conventional Commit message \u2014 as suggestions, never executed.
|
|
2758
|
+
|
|
2759
|
+
## Instructions
|
|
2760
|
+
|
|
2761
|
+
1. **Suggest a branch first** (do not run it). Follow the Git strategy
|
|
2762
|
+
(\`.kaddo/git.yml\` \u2192 \`branchNaming.pattern\`, default \`feature/<work-item-id>-<slug>\`;
|
|
2763
|
+
also \`bugfix/\`, \`hotfix/\`, \`spike/\`). If no strategy exists, suggest the default and say so.
|
|
2764
|
+
2. Implement the change with tests.
|
|
2765
|
+
3. Suggest running \`kaddo scan\` after adding modules, migrations, contracts or significant
|
|
2766
|
+
structure.
|
|
2767
|
+
4. Suggest running \`kaddo owners suggest\` and confirm the \`code:\` globs.
|
|
2768
|
+
5. Suggest running \`kaddo guard\` before committing to detect knowledge drift.
|
|
2769
|
+
6. Update affected knowledge (ADR / capabilities.md / current-state.md).
|
|
2770
|
+
7. Suggest a Conventional Commit message and **wait for explicit human confirmation**. Never
|
|
2771
|
+
commit, push or merge on your own.
|
|
2772
|
+
|
|
2773
|
+
## Constraints
|
|
2774
|
+
|
|
2775
|
+
- Never run Git. Never commit, push or merge \u2014 suggest and wait for the human.
|
|
2776
|
+
- Respect \`knowledge/tech/git-strategy.md\` when it exists.
|
|
2777
|
+
- Keep knowledge in sync with the code you change.
|
|
2778
|
+
- Do not invent business facts.
|
|
2779
|
+
|
|
2780
|
+
## Output Format
|
|
2781
|
+
|
|
2782
|
+
\`\`\`markdown
|
|
2783
|
+
# Implementation Plan \u2014 <Work Item id>
|
|
2784
|
+
|
|
2785
|
+
## Suggested branch
|
|
2786
|
+
|
|
2787
|
+
## Changes
|
|
2788
|
+
|
|
2789
|
+
## Tests
|
|
2790
|
+
|
|
2791
|
+
## Knowledge to update
|
|
2792
|
+
|
|
2793
|
+
## Suggested commit (await human confirmation)
|
|
2794
|
+
\`\`\`
|
|
2795
|
+
|
|
2796
|
+
## Where to Save the Result
|
|
2797
|
+
|
|
2798
|
+
Code, tests and migrations live in the repository. Knowledge updates go under \`knowledge/\`.
|
|
2799
|
+
|
|
2800
|
+
## Quality Checklist
|
|
2801
|
+
|
|
2802
|
+
- A branch is suggested per the Git strategy (never executed).
|
|
2803
|
+
- Tests accompany the change.
|
|
2804
|
+
- \`kaddo scan\` / \`owners suggest\` / \`guard\` are suggested at the right moments.
|
|
2805
|
+
- Affected knowledge is updated.
|
|
2806
|
+
- Commit is suggested and awaits human confirmation \u2014 never run automatically.
|
|
2807
|
+
`;
|
|
2501
2808
|
var AGENT_PROMPTS = [
|
|
2502
2809
|
{ fileName: "capability-agent.md", content: CAPABILITY_AGENT },
|
|
2503
2810
|
{ fileName: "architecture-agent.md", content: ARCHITECTURE_AGENT },
|
|
@@ -2513,8 +2820,11 @@ var AGENT_PROMPTS = [
|
|
|
2513
2820
|
// Bootstrap agents (new projects)
|
|
2514
2821
|
{ fileName: "business-agent.md", content: BUSINESS_AGENT },
|
|
2515
2822
|
{ fileName: "bootstrap-agent.md", content: BOOTSTRAP_AGENT },
|
|
2516
|
-
{ fileName: "codebase-agent.md", content: CODEBASE_FOUNDATION_AGENT }
|
|
2517
|
-
|
|
2823
|
+
{ fileName: "codebase-agent.md", content: CODEBASE_FOUNDATION_AGENT },
|
|
2824
|
+
// Implementation (the only agent that may suggest a branch — VS-044)
|
|
2825
|
+
{ fileName: "implementation-agent.md", content: IMPLEMENTATION_AGENT }
|
|
2826
|
+
// Every official prompt ends with its responsibility boundaries + Agent Trace footer.
|
|
2827
|
+
].map((p2) => ({ fileName: p2.fileName, content: withResponsibilityTrace(p2.fileName, p2.content) }));
|
|
2518
2828
|
|
|
2519
2829
|
// src/agents/groups.ts
|
|
2520
2830
|
var AGENT_GROUPS = {
|
|
@@ -2529,7 +2839,12 @@ var AGENT_GROUPS = {
|
|
|
2529
2839
|
"module-design-agent.md",
|
|
2530
2840
|
"adr-agent.md"
|
|
2531
2841
|
],
|
|
2532
|
-
delivery: [
|
|
2842
|
+
delivery: [
|
|
2843
|
+
"roadmap-agent.md",
|
|
2844
|
+
"work-item-agent.md",
|
|
2845
|
+
"implementation-agent.md",
|
|
2846
|
+
"git-strategy-agent.md"
|
|
2847
|
+
],
|
|
2533
2848
|
utilities: ["legacy-agent.md"]
|
|
2534
2849
|
};
|
|
2535
2850
|
var AGENT_GROUP_NAMES = Object.keys(AGENT_GROUPS);
|
|
@@ -2551,20 +2866,23 @@ var RECOMMENDED_BY_STATE = {
|
|
|
2551
2866
|
"codebase-agent.md",
|
|
2552
2867
|
"roadmap-agent.md",
|
|
2553
2868
|
"work-item-agent.md",
|
|
2869
|
+
"implementation-agent.md",
|
|
2554
2870
|
"adr-agent.md"
|
|
2555
2871
|
],
|
|
2556
2872
|
"pre-ai": [
|
|
2557
2873
|
"capability-agent.md",
|
|
2558
2874
|
"architecture-agent.md",
|
|
2559
2875
|
"roadmap-agent.md",
|
|
2560
|
-
"work-item-agent.md"
|
|
2876
|
+
"work-item-agent.md",
|
|
2877
|
+
"implementation-agent.md"
|
|
2561
2878
|
],
|
|
2562
2879
|
legacy: [
|
|
2563
2880
|
"legacy-agent.md",
|
|
2564
2881
|
"architecture-agent.md",
|
|
2565
2882
|
"capability-agent.md",
|
|
2566
2883
|
"roadmap-agent.md",
|
|
2567
|
-
"work-item-agent.md"
|
|
2884
|
+
"work-item-agent.md",
|
|
2885
|
+
"implementation-agent.md"
|
|
2568
2886
|
]
|
|
2569
2887
|
};
|
|
2570
2888
|
function recommendedAgents(state) {
|
|
@@ -3381,20 +3699,21 @@ async function runCreate(type, opts = {}) {
|
|
|
3381
3699
|
}
|
|
3382
3700
|
if (!type) {
|
|
3383
3701
|
console.error("Missing work item type.");
|
|
3384
|
-
console.error("Usage: kaddo create <feature|bugfix|hotfix|spike> [--from roadmap]");
|
|
3702
|
+
console.error("Usage: kaddo create <feature|bugfix|hotfix|spike|chore> [--from roadmap]");
|
|
3385
3703
|
process.exit(1);
|
|
3386
3704
|
}
|
|
3387
3705
|
const modWorkItemType = findWorkItemType(type);
|
|
3388
3706
|
if (modWorkItemType) {
|
|
3389
3707
|
return runCreateModule(dir, modWorkItemType);
|
|
3390
3708
|
}
|
|
3391
|
-
|
|
3709
|
+
const workItemType = normalizeType(type);
|
|
3710
|
+
if (!workItemType) {
|
|
3392
3711
|
console.error(`Unknown work item type: "${type}"`);
|
|
3393
|
-
console.error("Valid types: feature, bugfix, hotfix, spike");
|
|
3712
|
+
console.error("Valid types: feature, bugfix, hotfix, spike, chore");
|
|
3713
|
+
console.error("Aliases: setup, maintenance, tooling, infrastructure, refactor \u2192 chore");
|
|
3394
3714
|
console.error("Module types: adr, incident, rfc, migration, legacy (run `kaddo add <module>` first)");
|
|
3395
3715
|
process.exit(1);
|
|
3396
3716
|
}
|
|
3397
|
-
const workItemType = type;
|
|
3398
3717
|
const level = getLevelForType(workItemType);
|
|
3399
3718
|
const levelDef = getLevel(level);
|
|
3400
3719
|
intro2(`kaddo create ${workItemType}`);
|
|
@@ -3402,7 +3721,7 @@ async function runCreate(type, opts = {}) {
|
|
|
3402
3721
|
printStateGuidance(dir);
|
|
3403
3722
|
const title = await text2({
|
|
3404
3723
|
message: "Title for this work item",
|
|
3405
|
-
placeholder: `e.g. ${workItemType === "feature" ? "Add email verification to checkout" : workItemType === "hotfix" ? "Fix null pointer in payment handler" : workItemType === "bugfix" ? "Fix broken pagination on orders list" : "Explore caching strategies for API responses"}`,
|
|
3724
|
+
placeholder: `e.g. ${workItemType === "feature" ? "Add email verification to checkout" : workItemType === "hotfix" ? "Fix null pointer in payment handler" : workItemType === "bugfix" ? "Fix broken pagination on orders list" : workItemType === "chore" ? "Configure Vitest and CI pipeline" : "Explore caching strategies for API responses"}`,
|
|
3406
3725
|
validate: (v) => v.trim().length === 0 ? "Title is required." : void 0
|
|
3407
3726
|
});
|
|
3408
3727
|
const answers = {};
|
|
@@ -3471,9 +3790,7 @@ ${body}`;
|
|
|
3471
3790
|
}
|
|
3472
3791
|
var K_LEVEL_RE = /^K[0-4]$/;
|
|
3473
3792
|
function resolveCandidateType(candidate, cliType) {
|
|
3474
|
-
|
|
3475
|
-
if (cliType && isValidType(cliType)) return cliType;
|
|
3476
|
-
return null;
|
|
3793
|
+
return normalizeType(candidate.type) ?? normalizeType(cliType);
|
|
3477
3794
|
}
|
|
3478
3795
|
function resolveCandidateLevel(candidate, type) {
|
|
3479
3796
|
const suggested = candidate.suggestedKnowledgeLevel?.trim().toUpperCase();
|
|
@@ -3635,7 +3952,8 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
3635
3952
|
{ value: "feature", label: "feature" },
|
|
3636
3953
|
{ value: "bugfix", label: "bugfix" },
|
|
3637
3954
|
{ value: "hotfix", label: "hotfix" },
|
|
3638
|
-
{ value: "spike", label: "spike" }
|
|
3955
|
+
{ value: "spike", label: "spike" },
|
|
3956
|
+
{ value: "chore", label: "chore" }
|
|
3639
3957
|
]
|
|
3640
3958
|
});
|
|
3641
3959
|
}
|
|
@@ -4431,7 +4749,7 @@ var STRUCTURED_TYPES = {
|
|
|
4431
4749
|
]),
|
|
4432
4750
|
Delivery: /* @__PURE__ */ new Set([])
|
|
4433
4751
|
};
|
|
4434
|
-
var
|
|
4752
|
+
var WORK_ITEM_TYPES2 = /* @__PURE__ */ new Set([
|
|
4435
4753
|
"work-item",
|
|
4436
4754
|
"feature",
|
|
4437
4755
|
"bugfix",
|
|
@@ -4444,7 +4762,7 @@ function layerForType(type) {
|
|
|
4444
4762
|
if (type === CONSOLIDATED_TYPE.Product || STRUCTURED_TYPES.Product.has(type)) return "Product";
|
|
4445
4763
|
if (type === CONSOLIDATED_TYPE.Tech || STRUCTURED_TYPES.Tech.has(type) || type === "knowledge")
|
|
4446
4764
|
return "Tech";
|
|
4447
|
-
if (type === "roadmap" ||
|
|
4765
|
+
if (type === "roadmap" || WORK_ITEM_TYPES2.has(type)) return "Delivery";
|
|
4448
4766
|
return null;
|
|
4449
4767
|
}
|
|
4450
4768
|
function layerFromPath(filePath) {
|
|
@@ -4475,7 +4793,7 @@ function discoverLayers(dir) {
|
|
|
4475
4793
|
slot.detected.add(basename(a.filePath));
|
|
4476
4794
|
if (layer === "Delivery") {
|
|
4477
4795
|
if (type === "roadmap" || basename(a.filePath) === "roadmap.md") slot.hasRoadmap = true;
|
|
4478
|
-
if (
|
|
4796
|
+
if (WORK_ITEM_TYPES2.has(type) || a.filePath.replace(/\\/g, "/").includes("/delivery/work-items/")) {
|
|
4479
4797
|
if (a.filePath.replace(/\\/g, "/").includes("/delivery/work-items/")) slot.hasWorkItem = true;
|
|
4480
4798
|
}
|
|
4481
4799
|
continue;
|
|
@@ -4695,6 +5013,7 @@ function buildProjectExplanation(dir) {
|
|
|
4695
5013
|
const items = workItemArtifacts.map((a) => ({
|
|
4696
5014
|
id: a.id || a.title,
|
|
4697
5015
|
title: a.title,
|
|
5016
|
+
type: a.type,
|
|
4698
5017
|
status: a.status,
|
|
4699
5018
|
lifecycle: lifecycleStateOf({ status: a.status, filePath: a.filePath }),
|
|
4700
5019
|
initiative: a.initiative,
|
|
@@ -4703,6 +5022,11 @@ function buildProjectExplanation(dir) {
|
|
|
4703
5022
|
domains: a.domains
|
|
4704
5023
|
}));
|
|
4705
5024
|
const byState = lifecycleCounts(items.map((i) => i.lifecycle));
|
|
5025
|
+
const byType = {};
|
|
5026
|
+
for (const i of items) {
|
|
5027
|
+
const t = i.type || "unknown";
|
|
5028
|
+
byType[t] = (byType[t] ?? 0) + 1;
|
|
5029
|
+
}
|
|
4706
5030
|
const initiativeMap = /* @__PURE__ */ new Map();
|
|
4707
5031
|
for (const i of items) {
|
|
4708
5032
|
const name = i.initiative || "Unassigned";
|
|
@@ -4716,6 +5040,7 @@ function buildProjectExplanation(dir) {
|
|
|
4716
5040
|
done: items.filter((i) => i.status === "done").length,
|
|
4717
5041
|
cancelled: items.filter((i) => i.status === "cancelled").length,
|
|
4718
5042
|
byState,
|
|
5043
|
+
byType,
|
|
4719
5044
|
initiatives,
|
|
4720
5045
|
items
|
|
4721
5046
|
};
|
|
@@ -4785,6 +5110,10 @@ function buildProjectExplanation(dir) {
|
|
|
4785
5110
|
function stateLabel(state) {
|
|
4786
5111
|
return state === "pre-ai" ? "pre-ai" : state;
|
|
4787
5112
|
}
|
|
5113
|
+
function typeLabel(type) {
|
|
5114
|
+
const cap = type.charAt(0).toUpperCase() + type.slice(1);
|
|
5115
|
+
return cap.endsWith("s") ? cap : `${cap}s`;
|
|
5116
|
+
}
|
|
4788
5117
|
var LIFECYCLE_LABEL = {
|
|
4789
5118
|
draft: "Draft",
|
|
4790
5119
|
ready: "Ready",
|
|
@@ -4846,6 +5175,12 @@ function renderExplanationHuman(exp) {
|
|
|
4846
5175
|
lines.push(`- ${LIFECYCLE_LABEL[s]}: ${exp.workItems.byState[s]}`);
|
|
4847
5176
|
}
|
|
4848
5177
|
lines.push("");
|
|
5178
|
+
const typeEntries = Object.entries(exp.workItems.byType).sort((a, b) => b[1] - a[1]);
|
|
5179
|
+
if (typeEntries.length > 0) {
|
|
5180
|
+
lines.push("## Work Items by Type");
|
|
5181
|
+
for (const [t, n] of typeEntries) lines.push(`- ${typeLabel(t)}: ${n}`);
|
|
5182
|
+
lines.push("");
|
|
5183
|
+
}
|
|
4849
5184
|
const grouped = exp.workItems.initiatives.filter(
|
|
4850
5185
|
(g) => LIFECYCLE_STATES.some((s) => g.states[s] > 0)
|
|
4851
5186
|
);
|
|
@@ -5218,6 +5553,13 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
|
|
|
5218
5553
|
(a) => a.filePath.replace(/\\/g, "/").includes("/delivery/work-items/") && Boolean(a.type)
|
|
5219
5554
|
).length;
|
|
5220
5555
|
const roadmap = roadmapStats(exists(roadmapPath) ? readFile(roadmapPath) : null, materialized);
|
|
5556
|
+
const deliveryMix = {};
|
|
5557
|
+
for (const a of allArtifacts) {
|
|
5558
|
+
const p2 = a.filePath.replace(/\\/g, "/");
|
|
5559
|
+
if (!a.type || !p2.includes("/delivery/work-items/")) continue;
|
|
5560
|
+
if (!isActiveState(lifecycleStateOf({ status: a.status, filePath: a.filePath }))) continue;
|
|
5561
|
+
deliveryMix[a.type] = (deliveryMix[a.type] ?? 0) + 1;
|
|
5562
|
+
}
|
|
5221
5563
|
const mappedModules = loadMappedModules(dir);
|
|
5222
5564
|
const layers = knowledgeLayers(dir);
|
|
5223
5565
|
return {
|
|
@@ -5248,6 +5590,7 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
|
|
|
5248
5590
|
},
|
|
5249
5591
|
layers,
|
|
5250
5592
|
roadmap,
|
|
5593
|
+
deliveryMix,
|
|
5251
5594
|
mappedModules,
|
|
5252
5595
|
missing,
|
|
5253
5596
|
handoff: {
|
|
@@ -5349,6 +5692,16 @@ function renderContextPack(pack) {
|
|
|
5349
5692
|
} else {
|
|
5350
5693
|
parts.push("No active work items found.\n");
|
|
5351
5694
|
}
|
|
5695
|
+
const mixEntries = Object.entries(pack.deliveryMix).sort((a, b) => b[1] - a[1]);
|
|
5696
|
+
if (mixEntries.length > 0) {
|
|
5697
|
+
parts.push("## Delivery Mix\n");
|
|
5698
|
+
parts.push("Active Work Items by type:\n");
|
|
5699
|
+
const label = (t) => {
|
|
5700
|
+
const c = t.charAt(0).toUpperCase() + t.slice(1);
|
|
5701
|
+
return c.endsWith("s") ? c : `${c}s`;
|
|
5702
|
+
};
|
|
5703
|
+
parts.push(mixEntries.map(([t, n]) => `- ${label(t)}: ${n}`).join("\n") + "\n");
|
|
5704
|
+
}
|
|
5352
5705
|
parts.push("## Artifacts and Ownership\n");
|
|
5353
5706
|
if (knowledge.artifacts.length > 0) {
|
|
5354
5707
|
const lines = knowledge.artifacts.map(
|
|
@@ -5696,7 +6049,9 @@ function runUnderstand() {
|
|
|
5696
6049
|
],
|
|
5697
6050
|
delivery: [
|
|
5698
6051
|
"Use roadmap-agent \u2192 knowledge/delivery/roadmap.md",
|
|
5699
|
-
"Run `kaddo create --from roadmap
|
|
6052
|
+
"Run `kaddo create --from roadmap` (candidates \u2192 Work Items)",
|
|
6053
|
+
"Use work-item-agent \u2192 refine into knowledge/delivery/work-items/",
|
|
6054
|
+
"Use implementation-agent \u2192 implement, then `kaddo scan`, `kaddo owners suggest`, `kaddo guard`"
|
|
5700
6055
|
],
|
|
5701
6056
|
utilities: ["Use legacy-agent to surface risks and unknowns"]
|
|
5702
6057
|
};
|
|
@@ -8449,7 +8804,7 @@ program.command("scan").description("Detect project stack and suggest domains").
|
|
|
8449
8804
|
program.command("bootstrap").description("Build the initial knowledge base for a new project (Business \u2192 Product \u2192 Tech \u2192 Delivery)").action(async () => {
|
|
8450
8805
|
await runBootstrap();
|
|
8451
8806
|
});
|
|
8452
|
-
program.command("create [type]").description("Create a work item (feature, bugfix, hotfix, spike). Use --from roadmap to create from a roadmap candidate.").option("--from <source>", "Create from a source artifact (currently: roadmap)").action(async (type, opts) => {
|
|
8807
|
+
program.command("create [type]").description("Create a work item (feature, bugfix, hotfix, spike, chore). Use --from roadmap to create from a roadmap candidate.").option("--from <source>", "Create from a source artifact (currently: roadmap)").action(async (type, opts) => {
|
|
8453
8808
|
await runCreate(type ?? "", opts);
|
|
8454
8809
|
});
|
|
8455
8810
|
program.command("guard").description("Check if modified code has related artifacts that were not updated").option("--staged", "Check only staged files").option("--no-interactive", "Disable interactive ignore prompts").option("--ci", "CI mode: output JSON, no prompts, non-blocking").option("--json", "Output JSON (alias for --ci)").option("--workspace", "Also check local mapped module repos from .kaddo/modules.yml (opt-in)").action(async (opts) => {
|