@kaddo/cli 3.117.0 → 3.119.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/README.md +18 -1
- package/dist/core.js +283 -73
- package/dist/index.js +435 -204
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,97 @@ async function ensureTelemetryConsent(dir, config) {
|
|
|
94
94
|
persistConsent(dir, accepted ? "enabled" : "disabled");
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// src/core/poc.ts
|
|
98
|
+
var POC_ARTIFACT_PATH = "knowledge/delivery/poc.md";
|
|
99
|
+
function pocTemplate(projectName) {
|
|
100
|
+
return `---
|
|
101
|
+
type: poc
|
|
102
|
+
status: active
|
|
103
|
+
generated_by: kaddo-init
|
|
104
|
+
template_version: 1
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
# ${projectName} \u2014 Proof of Concept
|
|
108
|
+
|
|
109
|
+
## Problem
|
|
110
|
+
|
|
111
|
+
_What are we trying to understand or solve?_
|
|
112
|
+
|
|
113
|
+
## Hypothesis
|
|
114
|
+
|
|
115
|
+
_What assumption are we testing?_
|
|
116
|
+
|
|
117
|
+
## Expected Value
|
|
118
|
+
|
|
119
|
+
_Why is validating this worth doing?_
|
|
120
|
+
|
|
121
|
+
## Scenario
|
|
122
|
+
|
|
123
|
+
_What concrete scenario will demonstrate the hypothesis?_
|
|
124
|
+
|
|
125
|
+
## Success Criteria
|
|
126
|
+
|
|
127
|
+
- [ ] _Observable result that would support the hypothesis._
|
|
128
|
+
|
|
129
|
+
## Constraints
|
|
130
|
+
|
|
131
|
+
_Technical, time, budget, compliance, or operational constraints._
|
|
132
|
+
|
|
133
|
+
## Non-goals
|
|
134
|
+
|
|
135
|
+
_What this experiment intentionally will not prove or deliver._
|
|
136
|
+
|
|
137
|
+
## Evidence
|
|
138
|
+
|
|
139
|
+
_Link experiments, Work Items, measurements, and observations here._
|
|
140
|
+
|
|
141
|
+
## Conclusion
|
|
142
|
+
|
|
143
|
+
Status: pending
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
function ensurePocArtifact(dir, projectName) {
|
|
147
|
+
const path13 = join(dir, POC_ARTIFACT_PATH);
|
|
148
|
+
if (exists(path13)) return false;
|
|
149
|
+
ensureDir(join(dir, "knowledge", "delivery"));
|
|
150
|
+
writeFile(path13, pocTemplate(projectName));
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
var PLACEHOLDER = /^[_<].*[_>]$|^(describe|list|document|what|how)\b/i;
|
|
154
|
+
function section(markdown, heading) {
|
|
155
|
+
const match = markdown.match(new RegExp(`^##\\s+${heading}\\s*$([\\s\\S]*?)(?=^##\\s+|(?![\\s\\S]))`, "im"));
|
|
156
|
+
return match?.[1] ?? "";
|
|
157
|
+
}
|
|
158
|
+
function meaningful(text2) {
|
|
159
|
+
return text2.split(/\r?\n/).some((line) => {
|
|
160
|
+
const value = line.trim().replace(/^[-*]\s+(?:\[[^\]]+\]\s*)?/, "");
|
|
161
|
+
return Boolean(value) && !PLACEHOLDER.test(value) && !/^status:\s*(pending|tbd)$/i.test(value);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function readPocSummary(dir) {
|
|
165
|
+
const path13 = join(dir, POC_ARTIFACT_PATH);
|
|
166
|
+
if (!exists(path13)) {
|
|
167
|
+
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
168
|
+
}
|
|
169
|
+
let markdown = "";
|
|
170
|
+
try {
|
|
171
|
+
markdown = readFile(path13);
|
|
172
|
+
} catch {
|
|
173
|
+
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
174
|
+
}
|
|
175
|
+
const criteria = section(markdown, "Success Criteria").split(/\r?\n/).filter((line) => /^\s*[-*]\s+(?:\[[ xX]\]\s+)?/.test(line)).filter((line) => meaningful(line)).length;
|
|
176
|
+
const conclusionBody = section(markdown, "Conclusion");
|
|
177
|
+
const conclusionMatch = conclusionBody.match(/\b(?:status|outcome)\s*:\s*(validated|rejected|inconclusive)\b/i);
|
|
178
|
+
return {
|
|
179
|
+
exists: true,
|
|
180
|
+
hypothesisDefined: meaningful(section(markdown, "Hypothesis")),
|
|
181
|
+
successCriteriaCount: criteria,
|
|
182
|
+
constraintsDefined: meaningful(section(markdown, "Constraints")),
|
|
183
|
+
nonGoalsDefined: meaningful(section(markdown, "Non-goals")),
|
|
184
|
+
conclusion: conclusionMatch ? conclusionMatch[1].toLowerCase() : "pending"
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
97
188
|
// src/commands/init.ts
|
|
98
189
|
var KADDO_DIR = ".kaddo";
|
|
99
190
|
var ARCH_DIR = "knowledge";
|
|
@@ -307,41 +398,6 @@ _What comes after the current cycle._
|
|
|
307
398
|
_Ideas and intentions not yet committed._
|
|
308
399
|
`;
|
|
309
400
|
}
|
|
310
|
-
function buildPoc(projectName) {
|
|
311
|
-
return `---
|
|
312
|
-
type: poc
|
|
313
|
-
status: active
|
|
314
|
-
generated_by: kaddo-init
|
|
315
|
-
template_version: 1
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
# ${projectName} \u2014 Proof of Concept
|
|
319
|
-
|
|
320
|
-
## Hypothesis
|
|
321
|
-
|
|
322
|
-
_What assumption are we testing?_
|
|
323
|
-
|
|
324
|
-
## Success Criteria
|
|
325
|
-
|
|
326
|
-
- [ ] _Observable result that would support the hypothesis._
|
|
327
|
-
|
|
328
|
-
## Constraints
|
|
329
|
-
|
|
330
|
-
_Technical, time, budget, compliance, or operational constraints._
|
|
331
|
-
|
|
332
|
-
## Non-goals
|
|
333
|
-
|
|
334
|
-
_What this experiment intentionally will not prove or deliver._
|
|
335
|
-
|
|
336
|
-
## Evidence
|
|
337
|
-
|
|
338
|
-
_Link experiments, Work Items, measurements, and observations here._
|
|
339
|
-
|
|
340
|
-
## Conclusion
|
|
341
|
-
|
|
342
|
-
Status: pending
|
|
343
|
-
`;
|
|
344
|
-
}
|
|
345
401
|
async function runInit(opts = {}) {
|
|
346
402
|
const dir = cwd();
|
|
347
403
|
intro("kaddo init");
|
|
@@ -474,7 +530,7 @@ async function runInit(opts = {}) {
|
|
|
474
530
|
}
|
|
475
531
|
if (mode === "poc") {
|
|
476
532
|
ensureDir(join(dir, ARCH_DIR, "delivery", "work-items"));
|
|
477
|
-
writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"),
|
|
533
|
+
writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"), pocTemplate(projectName.trim()));
|
|
478
534
|
log.success("Created knowledge/delivery/poc.md");
|
|
479
535
|
}
|
|
480
536
|
log.success("Created knowledge/tech/module/module-context.md");
|
|
@@ -489,7 +545,7 @@ async function runInit(opts = {}) {
|
|
|
489
545
|
ensureDir(join(dir, ARCH_DIR, "agents"));
|
|
490
546
|
ensureDir(join(dir, ARCH_DIR, "skills"));
|
|
491
547
|
writeFile(join(dir, ARCH_DIR, "knowledge.md"), buildKnowledge(projectName.trim()));
|
|
492
|
-
if (mode === "poc") writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"),
|
|
548
|
+
if (mode === "poc") writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"), pocTemplate(projectName.trim()));
|
|
493
549
|
else writeFile(join(dir, ARCH_DIR, "delivery", "roadmap.md"), buildRoadmap(projectName.trim()));
|
|
494
550
|
writeFile(join(dir, ARCH_DIR, "tech", "system", "system-context.md"), buildSystemContext(sysName));
|
|
495
551
|
writeFile(join(dir, ARCH_DIR, "tech", "modules", "modules.md"), buildModulesFile(sysName));
|
|
@@ -504,13 +560,13 @@ async function runInit(opts = {}) {
|
|
|
504
560
|
} else {
|
|
505
561
|
ensureDir(join(dir, ARCH_DIR, "delivery", "work-items"));
|
|
506
562
|
writeFile(join(dir, ARCH_DIR, "knowledge.md"), buildKnowledge(projectName.trim()));
|
|
507
|
-
if (mode === "poc") writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"),
|
|
563
|
+
if (mode === "poc") writeFile(join(dir, ARCH_DIR, "delivery", "poc.md"), pocTemplate(projectName.trim()));
|
|
508
564
|
else writeFile(join(dir, ARCH_DIR, "delivery", "roadmap.md"), buildRoadmap(projectName.trim()));
|
|
509
565
|
log.success("Created knowledge/knowledge.md");
|
|
510
566
|
if (mode === "poc") log.success("Created knowledge/delivery/poc.md");
|
|
511
567
|
else log.success("Created knowledge/delivery/roadmap.md");
|
|
512
568
|
log.success("Created knowledge/delivery/work-items/");
|
|
513
|
-
log.info(mode === "poc" ? "Next: define the POC hypothesis and success criteria
|
|
569
|
+
log.info(mode === "poc" ? "Next: define the POC hypothesis and success criteria in `knowledge/delivery/poc.md`." : "Next: run `kaddo scan` to detect your stack.");
|
|
514
570
|
}
|
|
515
571
|
if (isInteractive()) {
|
|
516
572
|
const enableTelemetry = await confirm({
|
|
@@ -722,9 +778,9 @@ function runProjectMode(mode) {
|
|
|
722
778
|
const dir = cwd();
|
|
723
779
|
try {
|
|
724
780
|
if (mode === void 0) {
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
727
|
-
console.log(`Project mode: ${projectMode(
|
|
781
|
+
const config2 = loadConfig(dir);
|
|
782
|
+
if (!config2) throw new ConfigError("No .kaddo/config.yml found. Run `kaddo init` first.");
|
|
783
|
+
console.log(`Project mode: ${projectMode(config2)}`);
|
|
728
784
|
return;
|
|
729
785
|
}
|
|
730
786
|
if (mode !== "standard" && mode !== "poc") {
|
|
@@ -732,7 +788,10 @@ function runProjectMode(mode) {
|
|
|
732
788
|
process.exitCode = 1;
|
|
733
789
|
return;
|
|
734
790
|
}
|
|
735
|
-
setProjectMode(dir, mode);
|
|
791
|
+
const config = setProjectMode(dir, mode);
|
|
792
|
+
if (mode === "poc" && ensurePocArtifact(dir, config.project.name)) {
|
|
793
|
+
console.log("Created knowledge/delivery/poc.md");
|
|
794
|
+
}
|
|
736
795
|
console.log(`Project mode set to: ${mode}`);
|
|
737
796
|
} catch (err) {
|
|
738
797
|
console.error(err instanceof ConfigError ? err.message : String(err));
|
|
@@ -1461,7 +1520,7 @@ import { parse as parseYaml4, stringify as stringifyYaml3 } from "yaml";
|
|
|
1461
1520
|
import { parse as parseYaml3 } from "yaml";
|
|
1462
1521
|
var SCAN_BASELINE_VERSION = "1";
|
|
1463
1522
|
var UNKNOWN = "unknown";
|
|
1464
|
-
function
|
|
1523
|
+
function meaningful2(...values) {
|
|
1465
1524
|
return values.filter((v) => v && v !== UNKNOWN && v !== "none");
|
|
1466
1525
|
}
|
|
1467
1526
|
function readProjectContext(dir) {
|
|
@@ -1505,9 +1564,9 @@ function buildBaseline(result, context, now = /* @__PURE__ */ new Date()) {
|
|
|
1505
1564
|
generatedAt: now.toISOString(),
|
|
1506
1565
|
project: context,
|
|
1507
1566
|
detected: {
|
|
1508
|
-
languages:
|
|
1509
|
-
frameworks:
|
|
1510
|
-
packageManagers:
|
|
1567
|
+
languages: meaningful2(result.language),
|
|
1568
|
+
frameworks: meaningful2(result.framework),
|
|
1569
|
+
packageManagers: meaningful2(result.packageManager),
|
|
1511
1570
|
sourceDirectories: result.codeDirs,
|
|
1512
1571
|
migrationDirectories: result.migrationDirs,
|
|
1513
1572
|
contractFiles: result.contractFiles,
|
|
@@ -1526,7 +1585,7 @@ function serializeBaseline(baseline) {
|
|
|
1526
1585
|
}
|
|
1527
1586
|
|
|
1528
1587
|
// src/templates/inventory-template.ts
|
|
1529
|
-
function
|
|
1588
|
+
function section2(title, items, emptyNote = "_(none detected)_") {
|
|
1530
1589
|
const body = items.length > 0 ? items.map((i) => `- ${i}`).join("\n") : emptyNote;
|
|
1531
1590
|
return `## ${title}
|
|
1532
1591
|
|
|
@@ -1541,30 +1600,30 @@ function renderInventory(baseline) {
|
|
|
1541
1600
|
"> Generated by `kaddo scan`. Deterministic technical baseline \u2014 not an interpretation of the system.\n"
|
|
1542
1601
|
);
|
|
1543
1602
|
parts.push(
|
|
1544
|
-
|
|
1603
|
+
section2("Project Context", [
|
|
1545
1604
|
`State: ${project.state}`,
|
|
1546
1605
|
`Structure: ${project.structure}`,
|
|
1547
1606
|
`Team size: ${project.teamSize}`
|
|
1548
1607
|
])
|
|
1549
1608
|
);
|
|
1550
1609
|
parts.push(
|
|
1551
|
-
|
|
1610
|
+
section2("Detected Stack", [
|
|
1552
1611
|
`Language: ${detected.languages.join(", ") || "unknown"}`,
|
|
1553
1612
|
`Framework: ${detected.frameworks.join(", ") || "unknown"}`,
|
|
1554
1613
|
`Package manager: ${detected.packageManagers.join(", ") || "unknown"}`
|
|
1555
1614
|
])
|
|
1556
1615
|
);
|
|
1557
|
-
parts.push(
|
|
1558
|
-
parts.push(
|
|
1559
|
-
parts.push(
|
|
1560
|
-
parts.push(
|
|
1561
|
-
parts.push(
|
|
1616
|
+
parts.push(section2("Source Directories", detected.sourceDirectories.map((d) => `${d}/`)));
|
|
1617
|
+
parts.push(section2("Migrations", detected.migrationDirectories.map((d) => `${d}/`)));
|
|
1618
|
+
parts.push(section2("Contracts", detected.contractFiles));
|
|
1619
|
+
parts.push(section2("Infrastructure", detected.infrastructureFiles));
|
|
1620
|
+
parts.push(section2("Tests", detected.testDirectories.map((d) => `${d}/`)));
|
|
1562
1621
|
if (signalCount(baseline.signals) > 0) {
|
|
1563
1622
|
parts.push("## Detected Signals\n");
|
|
1564
1623
|
parts.push(renderSignalsInventory(baseline.signals));
|
|
1565
1624
|
}
|
|
1566
|
-
parts.push(
|
|
1567
|
-
parts.push(
|
|
1625
|
+
parts.push(section2("Possible Domains", suggestions.possibleDomains));
|
|
1626
|
+
parts.push(section2("Open Questions", suggestions.openQuestions));
|
|
1568
1627
|
return parts.join("\n");
|
|
1569
1628
|
}
|
|
1570
1629
|
|
|
@@ -3130,6 +3189,50 @@ their intersection with the affected areas, and recommended actions.
|
|
|
3130
3189
|
- The assessment is proportional \u2014 a small change gets a brief assessment.
|
|
3131
3190
|
`
|
|
3132
3191
|
);
|
|
3192
|
+
var POC_REPORT_WRITING = skill(
|
|
3193
|
+
"poc-report-writing",
|
|
3194
|
+
"POC Final Report Writing Skill",
|
|
3195
|
+
"delivery",
|
|
3196
|
+
["implementation-agent", "work-item-agent"],
|
|
3197
|
+
`
|
|
3198
|
+
# POC Final Report Writing Skill
|
|
3199
|
+
|
|
3200
|
+
## Purpose
|
|
3201
|
+
|
|
3202
|
+
Turn a supplied deterministic POC report context into a concise, traceable final report.
|
|
3203
|
+
|
|
3204
|
+
## When to use
|
|
3205
|
+
|
|
3206
|
+
After a POC has a canonical conclusion and Core has prepared its deterministic report context.
|
|
3207
|
+
|
|
3208
|
+
## Rules
|
|
3209
|
+
|
|
3210
|
+
- Use only the supplied context; do not scan the repository or infer missing results.
|
|
3211
|
+
- Treat \`poc.md\` as canonical for the conclusion. Never contradict it.
|
|
3212
|
+
- Keep facts, measurements, calculations, estimates, and recommendations distinct.
|
|
3213
|
+
- Never include credential values, tokens, private keys, passwords, or connection strings.
|
|
3214
|
+
- Use \`Not evaluated in this POC.\`, \`Not applicable.\`, or \`No evidence available.\` when sources do not support a section.
|
|
3215
|
+
- Return a proposal for human review; Core persists it only after confirmation.
|
|
3216
|
+
|
|
3217
|
+
## Required structure
|
|
3218
|
+
|
|
3219
|
+
1. Executive Summary
|
|
3220
|
+
2. Problem and Objective
|
|
3221
|
+
3. Hypothesis and Success Criteria
|
|
3222
|
+
4. Scope, Constraints and Non-goals
|
|
3223
|
+
5. Technical Approach and Architecture
|
|
3224
|
+
6. Infrastructure and Project Resources
|
|
3225
|
+
7. Implementation and Relevant Technical Decisions
|
|
3226
|
+
8. Experiments and Validation
|
|
3227
|
+
9. Results and Measurements
|
|
3228
|
+
10. Cost and Efficiency Analysis
|
|
3229
|
+
11. Observability and Operational Findings
|
|
3230
|
+
12. Findings, Learnings, Limitations and Risks
|
|
3231
|
+
13. Conclusion
|
|
3232
|
+
14. Recommendation and Next Steps
|
|
3233
|
+
15. Traceability and Sources
|
|
3234
|
+
`
|
|
3235
|
+
);
|
|
3133
3236
|
var SKILLS = [
|
|
3134
3237
|
ADR_WRITING,
|
|
3135
3238
|
WORK_ITEM_REFINEMENT,
|
|
@@ -3140,10 +3243,11 @@ var SKILLS = [
|
|
|
3140
3243
|
IMPLEMENTATION_PLANNING,
|
|
3141
3244
|
MODULE_CONTEXT_REFINEMENT,
|
|
3142
3245
|
EVIDENCE_VERIFICATION,
|
|
3143
|
-
LEGACY_RISK_ASSESSMENT
|
|
3246
|
+
LEGACY_RISK_ASSESSMENT,
|
|
3247
|
+
POC_REPORT_WRITING
|
|
3144
3248
|
];
|
|
3145
3249
|
var SKILL_GROUPS = {
|
|
3146
|
-
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment"],
|
|
3250
|
+
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing"],
|
|
3147
3251
|
tech: ["adr-writing", "ownership-suggestion", "graph-metadata-review", "module-context-refinement"],
|
|
3148
3252
|
integration: ["capsule-writing"]
|
|
3149
3253
|
};
|
|
@@ -7077,12 +7181,12 @@ function classifyLayer(posixPath) {
|
|
|
7077
7181
|
return "unknown";
|
|
7078
7182
|
}
|
|
7079
7183
|
function enrich(dir, a) {
|
|
7080
|
-
const
|
|
7184
|
+
const posix2 = toPosix(a.filePath);
|
|
7081
7185
|
const isWi = isWorkItemArtifact(a);
|
|
7082
7186
|
return {
|
|
7083
7187
|
...a,
|
|
7084
7188
|
relPath: relativeTo(dir, a.filePath),
|
|
7085
|
-
layer: classifyLayer(
|
|
7189
|
+
layer: classifyLayer(posix2),
|
|
7086
7190
|
isWorkItem: isWi,
|
|
7087
7191
|
lifecycle: isWi ? lifecycleStateOf({ status: a.status, filePath: a.filePath }) : void 0
|
|
7088
7192
|
};
|
|
@@ -8490,7 +8594,7 @@ function runIgnoreRemove(artifactId) {
|
|
|
8490
8594
|
}
|
|
8491
8595
|
|
|
8492
8596
|
// src/commands/explain.ts
|
|
8493
|
-
import
|
|
8597
|
+
import matter9 from "gray-matter";
|
|
8494
8598
|
import { parse as parseYaml13 } from "yaml";
|
|
8495
8599
|
|
|
8496
8600
|
// src/core/delivery-phase.ts
|
|
@@ -10904,7 +11008,7 @@ function buildModuleCapsule(dir, moduleId, config) {
|
|
|
10904
11008
|
usageNotes: []
|
|
10905
11009
|
};
|
|
10906
11010
|
}
|
|
10907
|
-
function
|
|
11011
|
+
function section3(title, items, placeholder) {
|
|
10908
11012
|
if (items.length === 0) return `## ${title}
|
|
10909
11013
|
|
|
10910
11014
|
_${placeholder}_
|
|
@@ -10935,15 +11039,15 @@ function renderCapsuleMarkdown(c) {
|
|
|
10935
11039
|
|
|
10936
11040
|
${c.purpose || "_To be completed by the capsule-agent._"}
|
|
10937
11041
|
`,
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
11042
|
+
section3("Responsibilities", c.responsibilities, "List what this system is responsible for."),
|
|
11043
|
+
section3("Exposed Capabilities", c.capabilities, "List the capabilities this system exposes."),
|
|
11044
|
+
section3("Public Contracts", c.contracts, "List public APIs and events (e.g. `POST /orders`, `OrderCreated`)."),
|
|
11045
|
+
section3("Dependencies", c.dependencies, "List systems this one depends on."),
|
|
11046
|
+
section3("Known Risks", c.knownRisks, "List integration risks consumers should know."),
|
|
11047
|
+
section3("Relevant ADRs", c.adrs, "List decisions that affect how to integrate."),
|
|
11048
|
+
section3("Owners", c.owners, "Who owns this system."),
|
|
11049
|
+
section3("Out of Scope", c.outOfScope, "What this capsule deliberately does not cover."),
|
|
11050
|
+
section3("Usage Notes", c.usageNotes, "How consumers should integrate."),
|
|
10947
11051
|
"> Security: this capsule must never contain secrets, tokens, credentials, PII or source code.",
|
|
10948
11052
|
""
|
|
10949
11053
|
];
|
|
@@ -12288,8 +12392,8 @@ function buildOpenQuestionsReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
12288
12392
|
const project = loadConfig(dir)?.project.name ?? "unknown";
|
|
12289
12393
|
const questions = [];
|
|
12290
12394
|
let seq = 0;
|
|
12291
|
-
for (const
|
|
12292
|
-
const p = join(dir,
|
|
12395
|
+
for (const source2 of SOURCES) {
|
|
12396
|
+
const p = join(dir, source2);
|
|
12293
12397
|
if (!exists(p)) continue;
|
|
12294
12398
|
let md;
|
|
12295
12399
|
try {
|
|
@@ -12302,8 +12406,8 @@ function buildOpenQuestionsReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
12302
12406
|
const { classification, reason } = classifyQuestion(eq.text);
|
|
12303
12407
|
questions.push({
|
|
12304
12408
|
id: `OQ-${String(seq).padStart(3, "0")}`,
|
|
12305
|
-
source,
|
|
12306
|
-
sourcePath:
|
|
12409
|
+
source: source2,
|
|
12410
|
+
sourcePath: source2,
|
|
12307
12411
|
line: eq.line,
|
|
12308
12412
|
raw: eq.raw,
|
|
12309
12413
|
section: "Open Questions",
|
|
@@ -12898,40 +13002,118 @@ function buildTechDecisions(dir) {
|
|
|
12898
13002
|
};
|
|
12899
13003
|
}
|
|
12900
13004
|
|
|
12901
|
-
// src/core/poc.ts
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
13005
|
+
// src/core/poc-report.ts
|
|
13006
|
+
import { createHash } from "crypto";
|
|
13007
|
+
import matter7 from "gray-matter";
|
|
13008
|
+
var POC_REPORT_PREFIX = "poc-report-v";
|
|
13009
|
+
var SECRET_LINE = /(^|\s)(?:[A-Z][A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)|(?:token|secret|password|api[_-]?key))\s*[:=]\s*\S+/i;
|
|
13010
|
+
var reportName = /^poc-report-v(\d{3,})\.md$/;
|
|
13011
|
+
function sha(value) {
|
|
13012
|
+
return createHash("sha256").update(value).digest("hex");
|
|
13013
|
+
}
|
|
13014
|
+
function posix(value) {
|
|
13015
|
+
return value.replace(/\\/g, "/");
|
|
13016
|
+
}
|
|
13017
|
+
function redactSecrets(value) {
|
|
13018
|
+
return value.split(/\r?\n/).map((line) => {
|
|
13019
|
+
if (!SECRET_LINE.test(line)) return line;
|
|
13020
|
+
return line.replace(/([:=]\s*)\S+.*/, "$1[redacted]");
|
|
13021
|
+
}).join("\n");
|
|
12907
13022
|
}
|
|
12908
|
-
function
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
}
|
|
13023
|
+
function source(dir, path13, kind) {
|
|
13024
|
+
const absolute = join(dir, path13);
|
|
13025
|
+
if (!exists(absolute)) return null;
|
|
13026
|
+
const raw = readFile(absolute);
|
|
13027
|
+
return { path: posix(path13), kind, digest: sha(raw), content: redactSecrets(raw) };
|
|
13028
|
+
}
|
|
13029
|
+
function reportFiles(dir) {
|
|
13030
|
+
const delivery = join(dir, "knowledge", "delivery");
|
|
13031
|
+
return readDir(delivery).flatMap((name) => {
|
|
13032
|
+
const match = name.match(reportName);
|
|
13033
|
+
if (!match) return [];
|
|
13034
|
+
try {
|
|
13035
|
+
const parsed = matter7(readFile(join(delivery, name)));
|
|
13036
|
+
const fingerprint = typeof parsed.data.source_fingerprint === "string" ? parsed.data.source_fingerprint : "";
|
|
13037
|
+
const manifest = parsed.data.source_manifest;
|
|
13038
|
+
const sourceManifest = manifest && typeof manifest === "object" && !Array.isArray(manifest) ? Object.fromEntries(Object.entries(manifest).filter(([, digest]) => typeof digest === "string")) : {};
|
|
13039
|
+
return [{ path: `knowledge/delivery/${name}`, version: Number(match[1]), sourceFingerprint: fingerprint, sourceManifest }];
|
|
13040
|
+
} catch {
|
|
13041
|
+
return [];
|
|
13042
|
+
}
|
|
13043
|
+
}).sort((a, b) => b.version - a.version);
|
|
12913
13044
|
}
|
|
12914
|
-
function
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
return {
|
|
13045
|
+
function reportPath(version2) {
|
|
13046
|
+
return `knowledge/delivery/${POC_REPORT_PREFIX}${String(version2).padStart(3, "0")}.md`;
|
|
13047
|
+
}
|
|
13048
|
+
function buildPocReportContext(dir) {
|
|
13049
|
+
const poc = readPocSummary(dir);
|
|
13050
|
+
const reports = reportFiles(dir);
|
|
13051
|
+
const latestReport = reports[0] ?? null;
|
|
13052
|
+
const nextPath = reportPath((latestReport?.version ?? 0) + 1);
|
|
13053
|
+
if (!poc.exists || poc.conclusion === "pending") {
|
|
13054
|
+
return {
|
|
13055
|
+
eligible: false,
|
|
13056
|
+
conclusion: poc.conclusion,
|
|
13057
|
+
status: latestReport ? "stale" : "missing",
|
|
13058
|
+
latestReport,
|
|
13059
|
+
nextPath,
|
|
13060
|
+
sourceFingerprint: "",
|
|
13061
|
+
sources: [],
|
|
13062
|
+
changesSinceLatest: [],
|
|
13063
|
+
handoff: "POC conclusion is still pending. Record validated, rejected, or inconclusive before generating a final report."
|
|
13064
|
+
};
|
|
12924
13065
|
}
|
|
12925
|
-
const
|
|
12926
|
-
const
|
|
12927
|
-
|
|
13066
|
+
const sources = [];
|
|
13067
|
+
const add = (path13, kind) => {
|
|
13068
|
+
if (sources.some((item2) => item2.path === posix(path13))) return;
|
|
13069
|
+
const item = source(dir, path13, kind);
|
|
13070
|
+
if (item) sources.push(item);
|
|
13071
|
+
};
|
|
13072
|
+
add(POC_ARTIFACT_PATH, "poc");
|
|
13073
|
+
const pocText = readFile(join(dir, POC_ARTIFACT_PATH));
|
|
13074
|
+
const knowledge = discoverKnowledge(dir);
|
|
13075
|
+
const workItems = discoverWorkItems(dir);
|
|
13076
|
+
const referencedWorkItems = workItems.filter((wi) => wi.lifecycle === "completed" && wi.id && new RegExp(`\\b${wi.id}\\b`).test(pocText));
|
|
13077
|
+
const resourceIds = /* @__PURE__ */ new Set();
|
|
13078
|
+
const decisionIds = /* @__PURE__ */ new Set();
|
|
13079
|
+
for (const wi of referencedWorkItems) {
|
|
13080
|
+
add(wi.relPath, "work-item");
|
|
13081
|
+
for (const resource of parseWorkItemResources(wi.rawFrontmatter)) resourceIds.add(resource.id);
|
|
13082
|
+
const decisions = wi.rawFrontmatter.decisions;
|
|
13083
|
+
if (Array.isArray(decisions)) decisions.forEach((id) => decisionIds.add(String(id)));
|
|
13084
|
+
}
|
|
13085
|
+
for (const id of resourceIds) {
|
|
13086
|
+
const resource = getResource(dir, id);
|
|
13087
|
+
if (resource) add(resource.path, "resource");
|
|
13088
|
+
}
|
|
13089
|
+
for (const artifact of knowledge) {
|
|
13090
|
+
if (artifact.isWorkItem || !artifact.id) continue;
|
|
13091
|
+
if (decisionIds.has(artifact.id) || referencedWorkItems.some((wi) => new RegExp(`\\b${artifact.id}\\b`).test(readFile(wi.filePath)))) add(artifact.relPath, "knowledge");
|
|
13092
|
+
}
|
|
13093
|
+
sources.sort((a, b) => a.path.localeCompare(b.path));
|
|
13094
|
+
const sourceFingerprint = sha(sources.map((item) => `${item.path}\0${item.digest}`).join("\n"));
|
|
13095
|
+
const status = !latestReport ? "missing" : latestReport.sourceFingerprint === sourceFingerprint ? "current" : "stale";
|
|
13096
|
+
const currentManifest = Object.fromEntries(sources.map((item) => [item.path, item.digest]));
|
|
13097
|
+
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path13) => currentManifest[path13] !== latestReport?.sourceManifest[path13]).sort() : [];
|
|
13098
|
+
const sourceList = sources.map((item) => `- ${item.path} (${item.kind})`).join("\n") || "- No sources selected.";
|
|
12928
13099
|
return {
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
13100
|
+
eligible: true,
|
|
13101
|
+
conclusion: poc.conclusion,
|
|
13102
|
+
status,
|
|
13103
|
+
latestReport,
|
|
13104
|
+
nextPath,
|
|
13105
|
+
sourceFingerprint,
|
|
13106
|
+
sources,
|
|
13107
|
+
changesSinceLatest,
|
|
13108
|
+
handoff: [
|
|
13109
|
+
"Create a POC Final Report from the supplied sources only. Do not explore the repository.",
|
|
13110
|
+
`Canonical conclusion: ${poc.conclusion}. Do not contradict it.`,
|
|
13111
|
+
"Use the 15 canonical sections. Mark missing evidence as Not evaluated, Not applicable, or No evidence available.",
|
|
13112
|
+
"Distinguish measured, calculated, estimated, and projected values. Never include secret values.",
|
|
13113
|
+
"",
|
|
13114
|
+
"Selected sources:",
|
|
13115
|
+
sourceList
|
|
13116
|
+
].join("\n")
|
|
12935
13117
|
};
|
|
12936
13118
|
}
|
|
12937
13119
|
|
|
@@ -13025,7 +13207,7 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
13025
13207
|
if (projectMode(config) === "poc") {
|
|
13026
13208
|
const poc = readPocSummary(dir);
|
|
13027
13209
|
if (!poc.exists) {
|
|
13028
|
-
return { id: "
|
|
13210
|
+
return { id: "poc-artifact", phase: "POC Definition", label: "Create or restore the POC artifact.", command: "kaddo project mode poc", target: POC_ARTIFACT_PATH, reason: `Missing ${POC_ARTIFACT_PATH}.` };
|
|
13029
13211
|
}
|
|
13030
13212
|
if (!poc.hypothesisDefined) {
|
|
13031
13213
|
return { id: "poc-hypothesis", phase: "POC Definition", label: "Define the POC hypothesis.", target: POC_ARTIFACT_PATH, reason: "The POC needs a testable hypothesis before work begins." };
|
|
@@ -13035,12 +13217,9 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
13035
13217
|
}
|
|
13036
13218
|
const qCurrentState2 = analyzeKnowledgeArtifact(dir, CS);
|
|
13037
13219
|
const qCodebase2 = analyzeKnowledgeArtifact(dir, CB);
|
|
13038
|
-
if (qCurrentState2 !== "useful" || qCodebase2 !== "useful") {
|
|
13220
|
+
if (exists(join(dir, ".kaddo", "scan.json")) && (qCurrentState2 !== "useful" || qCodebase2 !== "useful")) {
|
|
13039
13221
|
return { id: "poc-technical-context", phase: "POC Discovery", label: "Document the minimal technical context for the experiment.", target: qCurrentState2 !== "useful" ? CS : CB, agent: "architecture-agent", reason: "The experiment surface and constraints are not yet sufficiently documented." };
|
|
13040
13222
|
}
|
|
13041
|
-
if (!exists(join(dir, "knowledge", "resources"))) {
|
|
13042
|
-
return { id: "poc-resources", phase: "POC Discovery", label: "Identify the project resources relevant to the experiment.", command: "kaddo resources list", reason: "No project resource catalog is available for the experiment context." };
|
|
13043
|
-
}
|
|
13044
13223
|
const delivery = buildDeliveryState(dir);
|
|
13045
13224
|
if (delivery.total_work_items === 0) {
|
|
13046
13225
|
return { id: "poc-create-experiment", phase: "Experiment", label: "Create the first experiment Work Item (prefer `spike`).", command: "kaddo create spike", reason: "The POC has no Work Item to produce evidence." };
|
|
@@ -13054,7 +13233,11 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
13054
13233
|
if (poc.conclusion === "pending") {
|
|
13055
13234
|
return { id: "poc-evaluate", phase: "Evaluation", label: "Evaluate the experiment evidence and record the POC conclusion.", target: POC_ARTIFACT_PATH, reason: "Experiment Work Items are complete but the POC conclusion is pending." };
|
|
13056
13235
|
}
|
|
13057
|
-
|
|
13236
|
+
const report = buildPocReportContext(dir);
|
|
13237
|
+
if (report.status !== "current") {
|
|
13238
|
+
return { id: "poc-final-report", phase: "Conclusion", label: `POC concluded: ${poc.conclusion}. Generate a final report if it would help communicate the result.`, command: "kaddo poc report", target: POC_ARTIFACT_PATH, reason: report.status === "stale" ? "The latest final report is stale after source changes." : "A final report is optional and has not been generated." };
|
|
13239
|
+
}
|
|
13240
|
+
return { id: "poc-complete", phase: "Conclusion", label: `POC concluded: ${poc.conclusion}. Decide whether to graduate it to standard delivery.`, target: POC_ARTIFACT_PATH, reason: "The POC conclusion and final report are current." };
|
|
13058
13241
|
}
|
|
13059
13242
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
13060
13243
|
const resolveAgent = (agent) => {
|
|
@@ -13492,7 +13675,7 @@ function deriveDeliveryCompletedStatus(dir) {
|
|
|
13492
13675
|
}
|
|
13493
13676
|
|
|
13494
13677
|
// src/core/assets.ts
|
|
13495
|
-
import
|
|
13678
|
+
import matter8 from "gray-matter";
|
|
13496
13679
|
function canonicalAgents() {
|
|
13497
13680
|
return AGENT_PROMPTS.map((a) => ({
|
|
13498
13681
|
name: a.fileName.replace(/\.md$/, ""),
|
|
@@ -13505,7 +13688,7 @@ function canonicalSkills() {
|
|
|
13505
13688
|
}
|
|
13506
13689
|
function versionOf(content) {
|
|
13507
13690
|
try {
|
|
13508
|
-
const v =
|
|
13691
|
+
const v = matter8(content).data.version;
|
|
13509
13692
|
return v === void 0 || v === null ? null : String(v);
|
|
13510
13693
|
} catch {
|
|
13511
13694
|
return null;
|
|
@@ -13730,9 +13913,9 @@ function parseWorkItemSource(frontmatter) {
|
|
|
13730
13913
|
reason: "No source metadata found."
|
|
13731
13914
|
};
|
|
13732
13915
|
}
|
|
13733
|
-
function renderSourceCompact(
|
|
13734
|
-
const parts = [
|
|
13735
|
-
if (
|
|
13916
|
+
function renderSourceCompact(source2) {
|
|
13917
|
+
const parts = [source2.type];
|
|
13918
|
+
if (source2.id) parts.push(source2.id);
|
|
13736
13919
|
return parts.join(" \xB7 ");
|
|
13737
13920
|
}
|
|
13738
13921
|
function optStr2(v) {
|
|
@@ -14068,6 +14251,11 @@ var definePocHypothesis = {
|
|
|
14068
14251
|
return { status: poc.hypothesisDefined ? "done" : "current", evidence: poc.hypothesisDefined ? [POC_ARTIFACT_PATH] : void 0, reason: poc.hypothesisDefined ? void 0 : "A POC starts with one testable hypothesis." };
|
|
14069
14252
|
}
|
|
14070
14253
|
};
|
|
14254
|
+
var ensurePocArtifact2 = {
|
|
14255
|
+
id: "poc-artifact",
|
|
14256
|
+
label: "Create POC artifact",
|
|
14257
|
+
evaluate: (ctx) => exists(join(ctx.dir, POC_ARTIFACT_PATH)) ? { status: "done", evidence: [POC_ARTIFACT_PATH] } : { status: "current", command: "kaddo project mode poc", reason: "Create the canonical POC artifact before defining the experiment." }
|
|
14258
|
+
};
|
|
14071
14259
|
var definePocCriteria = {
|
|
14072
14260
|
id: "poc-success-criteria",
|
|
14073
14261
|
label: "Define success criteria",
|
|
@@ -14076,11 +14264,15 @@ var definePocCriteria = {
|
|
|
14076
14264
|
return { status: poc.successCriteriaCount > 0 ? "done" : "pending", evidence: poc.successCriteriaCount > 0 ? [POC_ARTIFACT_PATH] : void 0, reason: poc.successCriteriaCount > 0 ? void 0 : "Define observable evidence for the hypothesis." };
|
|
14077
14265
|
}
|
|
14078
14266
|
};
|
|
14079
|
-
var describePocTech = {
|
|
14267
|
+
var describePocTech = {
|
|
14268
|
+
id: "poc-technical-context",
|
|
14269
|
+
label: "Document minimal technical context",
|
|
14270
|
+
evaluate: (ctx) => ctx.hasScan ? describeArchitecture.evaluate(ctx) : { status: "optional", command: "kaddo scan", reason: "Add technical context only when the experiment needs to inspect existing code." }
|
|
14271
|
+
};
|
|
14080
14272
|
var identifyPocResources = {
|
|
14081
14273
|
id: "poc-resources",
|
|
14082
14274
|
label: "Identify relevant resources",
|
|
14083
|
-
evaluate: (ctx) => exists(join(ctx.dir, "knowledge/resources")) ? { status: "done", evidence: ["knowledge/resources/"] } : { status: "
|
|
14275
|
+
evaluate: (ctx) => exists(join(ctx.dir, "knowledge/resources")) ? { status: "done", evidence: ["knowledge/resources/"] } : { status: "optional", command: "kaddo resources list", reason: "Add Project Resources only when the experiment depends on external systems." }
|
|
14084
14276
|
};
|
|
14085
14277
|
var createPocExperiment = {
|
|
14086
14278
|
id: "poc-create-experiment",
|
|
@@ -14100,7 +14292,17 @@ var concludePoc = {
|
|
|
14100
14292
|
return conclusion === "pending" ? { status: "pending", reason: "Record validated, rejected, or inconclusive from the evidence." } : { status: "done", evidence: [POC_ARTIFACT_PATH], reason: `Conclusion: ${conclusion}.` };
|
|
14101
14293
|
}
|
|
14102
14294
|
};
|
|
14103
|
-
var
|
|
14295
|
+
var finalPocReport = {
|
|
14296
|
+
id: "poc-final-report",
|
|
14297
|
+
label: "Generate final report (optional)",
|
|
14298
|
+
evaluate: (ctx) => {
|
|
14299
|
+
const report = buildPocReportContext(ctx.dir);
|
|
14300
|
+
if (!report.eligible) return { status: "optional", reason: "Available after recording a POC conclusion." };
|
|
14301
|
+
if (report.status === "current") return { status: "done", evidence: [report.latestReport.path] };
|
|
14302
|
+
return { status: "optional", command: "kaddo poc report", reason: report.status === "stale" ? "Latest report is stale." : "A final report is optional." };
|
|
14303
|
+
}
|
|
14304
|
+
};
|
|
14305
|
+
var POC_STEPS = [enableKaddo, ensurePocArtifact2, definePocHypothesis, definePocCriteria, describePocTech, identifyPocResources, createPocExperiment, capturePocEvidence, concludePoc, finalPocReport];
|
|
14104
14306
|
function stepsForState(state) {
|
|
14105
14307
|
switch (state) {
|
|
14106
14308
|
case "new":
|
|
@@ -14204,6 +14406,7 @@ function mapNextStepId(id) {
|
|
|
14204
14406
|
"poc-resources": "poc-resources",
|
|
14205
14407
|
"poc-create-experiment": "poc-create-experiment",
|
|
14206
14408
|
"poc-evaluate": "poc-evaluate",
|
|
14409
|
+
"poc-final-report": "poc-final-report",
|
|
14207
14410
|
"poc-complete": "poc-evaluate"
|
|
14208
14411
|
};
|
|
14209
14412
|
return MAP[id] ?? id;
|
|
@@ -14218,7 +14421,7 @@ function buildProjectRoute(dir) {
|
|
|
14218
14421
|
return { id: d.id, label: d.label, ...result };
|
|
14219
14422
|
});
|
|
14220
14423
|
for (const s of steps) {
|
|
14221
|
-
if (s.id === ctx.nextStepId && s.status !== "done") {
|
|
14424
|
+
if (s.id === ctx.nextStepId && s.status !== "done" && s.status !== "optional") {
|
|
14222
14425
|
s.status = "current";
|
|
14223
14426
|
}
|
|
14224
14427
|
}
|
|
@@ -14230,8 +14433,8 @@ function buildProjectRoute(dir) {
|
|
|
14230
14433
|
break;
|
|
14231
14434
|
}
|
|
14232
14435
|
}
|
|
14233
|
-
const completed = steps.filter((s) => s.status === "done").length;
|
|
14234
|
-
const total = steps.length;
|
|
14436
|
+
const completed = steps.filter((s) => s.status === "done" && s.status !== "optional").length;
|
|
14437
|
+
const total = steps.filter((s) => s.status !== "optional").length;
|
|
14235
14438
|
const progressPercent = total > 0 ? Math.round(completed / total * 100) : 0;
|
|
14236
14439
|
return {
|
|
14237
14440
|
type: state,
|
|
@@ -15036,7 +15239,7 @@ function readKnowledge(dir) {
|
|
|
15036
15239
|
if (!exists(knowledgePath)) return null;
|
|
15037
15240
|
try {
|
|
15038
15241
|
const raw = readFile(knowledgePath);
|
|
15039
|
-
const { data, content } =
|
|
15242
|
+
const { data, content } = matter9(raw);
|
|
15040
15243
|
return { content, data };
|
|
15041
15244
|
} catch {
|
|
15042
15245
|
return null;
|
|
@@ -15047,7 +15250,7 @@ function readRoadmap(dir) {
|
|
|
15047
15250
|
if (!exists(roadmapPath)) return null;
|
|
15048
15251
|
try {
|
|
15049
15252
|
const raw = readFile(roadmapPath);
|
|
15050
|
-
const { content } =
|
|
15253
|
+
const { content } = matter9(raw);
|
|
15051
15254
|
return content.trim();
|
|
15052
15255
|
} catch {
|
|
15053
15256
|
return null;
|
|
@@ -15216,7 +15419,7 @@ function runExplain(opts) {
|
|
|
15216
15419
|
}
|
|
15217
15420
|
|
|
15218
15421
|
// src/core/context-pack.ts
|
|
15219
|
-
import
|
|
15422
|
+
import matter10 from "gray-matter";
|
|
15220
15423
|
var CONTEXT_PACK_VERSION = "1";
|
|
15221
15424
|
var ARCH_DIR6 = "knowledge";
|
|
15222
15425
|
function readScanJson(dir) {
|
|
@@ -15229,7 +15432,7 @@ function readScanJson(dir) {
|
|
|
15229
15432
|
}
|
|
15230
15433
|
}
|
|
15231
15434
|
function firstParagraph2(markdown) {
|
|
15232
|
-
const body =
|
|
15435
|
+
const body = matter10(markdown).content.trim();
|
|
15233
15436
|
const para = body.split("\n\n").map((p) => p.trim()).find((p) => p && !p.startsWith("#"));
|
|
15234
15437
|
return para ?? "";
|
|
15235
15438
|
}
|
|
@@ -16878,12 +17081,12 @@ function runStatus() {
|
|
|
16878
17081
|
// src/commands/learn.ts
|
|
16879
17082
|
import fs3 from "fs";
|
|
16880
17083
|
import path7 from "path";
|
|
16881
|
-
import
|
|
17084
|
+
import matter11 from "gray-matter";
|
|
16882
17085
|
var ARCH_DIR9 = "knowledge";
|
|
16883
17086
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
16884
17087
|
function completedPathFor(filePath) {
|
|
16885
|
-
const
|
|
16886
|
-
const m =
|
|
17088
|
+
const posix2 = filePath.replace(/\\/g, "/");
|
|
17089
|
+
const m = posix2.match(/\/work-items\/(draft|ready|in-progress|blocked)\//);
|
|
16887
17090
|
if (!m) return filePath;
|
|
16888
17091
|
const completedDir = path7.dirname(filePath).replace(
|
|
16889
17092
|
new RegExp(`[/\\\\]${m[1]}$`),
|
|
@@ -16893,7 +17096,7 @@ function completedPathFor(filePath) {
|
|
|
16893
17096
|
}
|
|
16894
17097
|
function updateWorkItemFile(filePath, learning) {
|
|
16895
17098
|
const raw = readFile(filePath);
|
|
16896
|
-
const { data, content } =
|
|
17099
|
+
const { data, content } = matter11(raw);
|
|
16897
17100
|
data.status = "completed";
|
|
16898
17101
|
data.completed_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
16899
17102
|
let updatedContent = content;
|
|
@@ -16918,7 +17121,7 @@ ${learning.trim()}
|
|
|
16918
17121
|
${learning.trim()}
|
|
16919
17122
|
`;
|
|
16920
17123
|
}
|
|
16921
|
-
const newRaw =
|
|
17124
|
+
const newRaw = matter11.stringify(updatedContent, data);
|
|
16922
17125
|
const newPath = completedPathFor(filePath);
|
|
16923
17126
|
if (newPath !== filePath) {
|
|
16924
17127
|
ensureDir(path7.dirname(newPath));
|
|
@@ -16970,7 +17173,7 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16970
17173
|
process.exit(1);
|
|
16971
17174
|
}
|
|
16972
17175
|
const wiRaw = readFile(filePath);
|
|
16973
|
-
const wiData =
|
|
17176
|
+
const wiData = matter11(wiRaw).data;
|
|
16974
17177
|
if (!opts.force) {
|
|
16975
17178
|
const completionBlockers = [];
|
|
16976
17179
|
const releaseGates = Array.isArray(wiData.release_gates) ? wiData.release_gates : [];
|
|
@@ -17226,7 +17429,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
17226
17429
|
}
|
|
17227
17430
|
|
|
17228
17431
|
// src/core/ownership-suggest.ts
|
|
17229
|
-
import
|
|
17432
|
+
import matter12 from "gray-matter";
|
|
17230
17433
|
var SCAN_PATH = ".kaddo/scan.json";
|
|
17231
17434
|
function normalizeGlob(input) {
|
|
17232
17435
|
let g = input.trim().replace(/\\/g, "/");
|
|
@@ -17348,11 +17551,11 @@ function suggestGlobs(artifact, signals) {
|
|
|
17348
17551
|
return [...new Set(out)];
|
|
17349
17552
|
}
|
|
17350
17553
|
function applyOwnership(raw, globs, mode = "replace") {
|
|
17351
|
-
const parsed =
|
|
17554
|
+
const parsed = matter12(raw);
|
|
17352
17555
|
const existing = toStringArray3(parsed.data.code);
|
|
17353
17556
|
const next = mode === "append" ? [.../* @__PURE__ */ new Set([...existing, ...globs])] : [...new Set(globs)];
|
|
17354
17557
|
const data = { ...parsed.data, code: next };
|
|
17355
|
-
return
|
|
17558
|
+
return matter12.stringify(parsed.content, data);
|
|
17356
17559
|
}
|
|
17357
17560
|
|
|
17358
17561
|
// src/commands/owners.ts
|
|
@@ -18114,13 +18317,6 @@ var STANDARD_FILE_TARGETS = [
|
|
|
18114
18317
|
{ path: "knowledge/tech/current-state.md", kind: "current-state" },
|
|
18115
18318
|
{ path: "knowledge/delivery/roadmap.md", kind: "roadmap" }
|
|
18116
18319
|
];
|
|
18117
|
-
var POC_FILE_TARGETS = [
|
|
18118
|
-
{ path: "knowledge/business/business.md", kind: "business" },
|
|
18119
|
-
{ path: "knowledge/product/product.md", kind: "product" },
|
|
18120
|
-
{ path: "knowledge/tech/codebase.md", kind: "codebase" },
|
|
18121
|
-
{ path: "knowledge/tech/current-state.md", kind: "current-state" },
|
|
18122
|
-
{ path: "knowledge/delivery/poc.md", kind: "poc" }
|
|
18123
|
-
];
|
|
18124
18320
|
var DIR_TARGETS = ["knowledge/tech/decisions", "knowledge/tech/discovery", "knowledge/delivery/work-items"];
|
|
18125
18321
|
function withLanguageDirective(content, language) {
|
|
18126
18322
|
if (language !== "es") return content;
|
|
@@ -18146,7 +18342,8 @@ function bootstrap(dir) {
|
|
|
18146
18342
|
}
|
|
18147
18343
|
} catch {
|
|
18148
18344
|
}
|
|
18149
|
-
|
|
18345
|
+
if (mode === "poc") return { state, mode, written, skipped, createdDirs };
|
|
18346
|
+
for (const target of STANDARD_FILE_TARGETS) {
|
|
18150
18347
|
const full = join(dir, target.path);
|
|
18151
18348
|
if (exists(full)) {
|
|
18152
18349
|
skipped.push(target.path);
|
|
@@ -18189,7 +18386,12 @@ async function runBootstrap(dir = cwd()) {
|
|
|
18189
18386
|
const stateLabel3 = state === "pre-ai" ? "pre-ai" : state;
|
|
18190
18387
|
log.info(`Project state: ${stateLabel3}`);
|
|
18191
18388
|
log.info(`Project mode: ${mode}`);
|
|
18192
|
-
|
|
18389
|
+
if (mode === "poc") {
|
|
18390
|
+
log.info("POC mode does not require a standard bootstrap. Define the hypothesis and success criteria in `knowledge/delivery/poc.md`.");
|
|
18391
|
+
outro("Nothing changed. POC mode uses a proportional, experiment-first baseline.");
|
|
18392
|
+
return;
|
|
18393
|
+
}
|
|
18394
|
+
log.info(`Creating ${stateLabel3} knowledge baseline.`);
|
|
18193
18395
|
log.info("Existing files will not be overwritten.");
|
|
18194
18396
|
const result = bootstrap(dir);
|
|
18195
18397
|
console.log("");
|
|
@@ -18209,7 +18411,7 @@ async function runBootstrap(dir = cwd()) {
|
|
|
18209
18411
|
);
|
|
18210
18412
|
printCommandFooter("bootstrap");
|
|
18211
18413
|
outro(
|
|
18212
|
-
`${
|
|
18414
|
+
`${stateLabel3} knowledge baseline ready. Next: \`kaddo add agents\` (then \`kaddo add skills\`), and refine the knowledge with the relevant agents.`
|
|
18213
18415
|
);
|
|
18214
18416
|
}
|
|
18215
18417
|
|
|
@@ -18256,12 +18458,12 @@ function runCapsuleAdd(srcPath) {
|
|
|
18256
18458
|
process.exit(1);
|
|
18257
18459
|
}
|
|
18258
18460
|
const abs = join(dir, srcPath);
|
|
18259
|
-
const
|
|
18260
|
-
if (!exists(
|
|
18461
|
+
const source2 = exists(abs) ? abs : srcPath;
|
|
18462
|
+
if (!exists(source2)) {
|
|
18261
18463
|
console.error(`Capsule not found: ${srcPath}`);
|
|
18262
18464
|
process.exit(1);
|
|
18263
18465
|
}
|
|
18264
|
-
const result = addExternalCapsule(dir,
|
|
18466
|
+
const result = addExternalCapsule(dir, source2);
|
|
18265
18467
|
if (!result.isCapsuleType) {
|
|
18266
18468
|
log.warn("This file is not marked as a knowledge-capsule (front matter `type: knowledge-capsule`).");
|
|
18267
18469
|
}
|
|
@@ -18603,7 +18805,7 @@ async function runTopologyApply(file, opts = {}) {
|
|
|
18603
18805
|
// src/core/resource-write.ts
|
|
18604
18806
|
import fs5 from "fs";
|
|
18605
18807
|
import path9 from "path";
|
|
18606
|
-
import
|
|
18808
|
+
import matter13 from "gray-matter";
|
|
18607
18809
|
var RESOURCES_DIR = "knowledge/tech/resources";
|
|
18608
18810
|
var ResourceWriteError = class extends Error {
|
|
18609
18811
|
constructor(code, message) {
|
|
@@ -18683,7 +18885,7 @@ function buildFrontmatter(id, input, base = {}) {
|
|
|
18683
18885
|
return data;
|
|
18684
18886
|
}
|
|
18685
18887
|
function serialize(data, body) {
|
|
18686
|
-
return
|
|
18888
|
+
return matter13.stringify(`
|
|
18687
18889
|
${body.trim()}
|
|
18688
18890
|
`, data);
|
|
18689
18891
|
}
|
|
@@ -18723,7 +18925,7 @@ function updateResource(dir, id, input) {
|
|
|
18723
18925
|
throw new ResourceWriteError("VALIDATION_FAILED", findings.filter((f) => f.level === "error").map((f) => f.message).join("; "));
|
|
18724
18926
|
}
|
|
18725
18927
|
const raw = readFile(match.filePath);
|
|
18726
|
-
const parsed =
|
|
18928
|
+
const parsed = matter13(raw);
|
|
18727
18929
|
const base = parsed.data ?? {};
|
|
18728
18930
|
const data = buildFrontmatter(match.id || id, input, base);
|
|
18729
18931
|
let body = parsed.content.trim();
|
|
@@ -18958,14 +19160,14 @@ async function runResourcesDelete(id, opts = {}, dir = cwd()) {
|
|
|
18958
19160
|
}
|
|
18959
19161
|
|
|
18960
19162
|
// src/services/integrations.ts
|
|
18961
|
-
import
|
|
19163
|
+
import matter15 from "gray-matter";
|
|
18962
19164
|
import { parse as parseYaml18, stringify as stringifyYaml10 } from "yaml";
|
|
18963
19165
|
|
|
18964
19166
|
// src/core/work-item-write.ts
|
|
18965
19167
|
import fs6 from "fs";
|
|
18966
19168
|
import path10 from "path";
|
|
18967
19169
|
import crypto2 from "crypto";
|
|
18968
|
-
import
|
|
19170
|
+
import matter14 from "gray-matter";
|
|
18969
19171
|
var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
|
|
18970
19172
|
var WorkItemWriteError = class extends Error {
|
|
18971
19173
|
constructor(code, message) {
|
|
@@ -19069,7 +19271,7 @@ function ensureH1(body, title) {
|
|
|
19069
19271
|
${trimmed}`;
|
|
19070
19272
|
}
|
|
19071
19273
|
function serialize2(data, body) {
|
|
19072
|
-
return
|
|
19274
|
+
return matter14.stringify(`
|
|
19073
19275
|
${body.trim()}
|
|
19074
19276
|
`, data);
|
|
19075
19277
|
}
|
|
@@ -19104,7 +19306,7 @@ function createWorkItem(dir, opts) {
|
|
|
19104
19306
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
19105
19307
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
19106
19308
|
const summary = opts.summary?.trim() || intent;
|
|
19107
|
-
const
|
|
19309
|
+
const source2 = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
19108
19310
|
const data = {
|
|
19109
19311
|
type,
|
|
19110
19312
|
id,
|
|
@@ -19112,7 +19314,7 @@ function createWorkItem(dir, opts) {
|
|
|
19112
19314
|
status: "draft",
|
|
19113
19315
|
work_type: type,
|
|
19114
19316
|
created_at: today3,
|
|
19115
|
-
source,
|
|
19317
|
+
source: source2,
|
|
19116
19318
|
generated_by: "kaddo-admin",
|
|
19117
19319
|
affected_modules: [],
|
|
19118
19320
|
summary
|
|
@@ -20146,12 +20348,12 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
20146
20348
|
for (const art of discoverWorkItems(dir)) {
|
|
20147
20349
|
let data;
|
|
20148
20350
|
try {
|
|
20149
|
-
data =
|
|
20351
|
+
data = matter15(readFile(art.filePath)).data;
|
|
20150
20352
|
} catch {
|
|
20151
20353
|
continue;
|
|
20152
20354
|
}
|
|
20153
|
-
const
|
|
20154
|
-
if (
|
|
20355
|
+
const source2 = parseWorkItemSource(data);
|
|
20356
|
+
if (source2.integration === integrationId && source2.id === externalId) {
|
|
20155
20357
|
return { workItemId: String(data.id ?? ""), title: String(data.title ?? "") };
|
|
20156
20358
|
}
|
|
20157
20359
|
}
|
|
@@ -20359,7 +20561,7 @@ async function runIntegrationsImport(dir, id, externalId, opts) {
|
|
|
20359
20561
|
}
|
|
20360
20562
|
|
|
20361
20563
|
// src/core/impact-report.ts
|
|
20362
|
-
import
|
|
20564
|
+
import matter16 from "gray-matter";
|
|
20363
20565
|
function isBroadGlob(glob) {
|
|
20364
20566
|
if (!glob.endsWith("/**")) return false;
|
|
20365
20567
|
const prefix = glob.slice(0, -3);
|
|
@@ -20428,7 +20630,7 @@ function buildImpactReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
20428
20630
|
}
|
|
20429
20631
|
}
|
|
20430
20632
|
try {
|
|
20431
|
-
const body =
|
|
20633
|
+
const body = matter16(readFile(wi.filePath)).content;
|
|
20432
20634
|
if (hasSection(body, /acceptance|criterios de aceptaci/i)) withAcceptance++;
|
|
20433
20635
|
else gaps.missing_acceptance_criteria.push(gapItem(wi, "Add an `## Acceptance Criteria` section."));
|
|
20434
20636
|
if (hasSection(body, /definition of done|^#{1,6}\s*dod\b|definici[oó]n de (terminado|hecho)/i)) withDoD++;
|
|
@@ -20877,7 +21079,7 @@ function parseRatioNumerator(s) {
|
|
|
20877
21079
|
}
|
|
20878
21080
|
var SAVINGS_DISCLAIMER = "These are evidence-based estimates, not exact ROI. Adjust assumptions with real team data.";
|
|
20879
21081
|
function buildSavingsReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
20880
|
-
const { assumptions: a, source } = loadAssumptions(dir);
|
|
21082
|
+
const { assumptions: a, source: source2 } = loadAssumptions(dir);
|
|
20881
21083
|
const impact = buildImpactReport(dir, { scope: opts.scope, scopeSource: opts.scopeSource }, now);
|
|
20882
21084
|
const completed = impact.traceability.completed_work_items;
|
|
20883
21085
|
const wiWithOwnership = parseRatioNumerator(impact.traceability.work_items_connected_to_code);
|
|
@@ -20917,7 +21119,7 @@ function buildSavingsReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
20917
21119
|
if (impact.score === null || impact.score < 60 || graphQuality === "empty") {
|
|
20918
21120
|
level = "Low";
|
|
20919
21121
|
reasons.push("Impact score is low or the knowledge graph is empty.");
|
|
20920
|
-
} else if (impact.score >= 85 && graphQuality === "good" &&
|
|
21122
|
+
} else if (impact.score >= 85 && graphQuality === "good" && source2 === "file" && guard.available && guard.resolved > 0) {
|
|
20921
21123
|
level = "High";
|
|
20922
21124
|
reasons.push("Strong evidence, custom assumptions and recorded drift resolution.");
|
|
20923
21125
|
} else {
|
|
@@ -20931,9 +21133,9 @@ function buildSavingsReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
20931
21133
|
} else {
|
|
20932
21134
|
reasons.push("Guard history available, but no resolved drift warnings have been recorded yet.");
|
|
20933
21135
|
}
|
|
20934
|
-
reasons.push(
|
|
21136
|
+
reasons.push(source2 === "file" ? "Assumptions come from `.kaddo/savings.yml`." : "Savings assumptions are defaults and should be calibrated.");
|
|
20935
21137
|
const actions = [];
|
|
20936
|
-
if (
|
|
21138
|
+
if (source2 === "default") actions.push("Run `kaddo savings init` to customize assumptions.");
|
|
20937
21139
|
actions.push("Calibrate hourly cost and team assumptions with real team data.");
|
|
20938
21140
|
actions.push("Run `kaddo impact` to verify the underlying evidence quality.");
|
|
20939
21141
|
actions.push("Use this report as directional evidence, not accounting data.");
|
|
@@ -20951,7 +21153,7 @@ function buildSavingsReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
20951
21153
|
scope: impact.scope,
|
|
20952
21154
|
currency: a.currency,
|
|
20953
21155
|
disclaimer: SAVINGS_DISCLAIMER,
|
|
20954
|
-
assumptions_source:
|
|
21156
|
+
assumptions_source: source2,
|
|
20955
21157
|
assumptions: {
|
|
20956
21158
|
hourly_cost: a.hourly_cost,
|
|
20957
21159
|
context_preparation_minutes_saved_per_work_item: a.context_preparation_minutes_saved_per_work_item,
|
|
@@ -21606,7 +21808,7 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
21606
21808
|
// src/commands/ready.ts
|
|
21607
21809
|
import fs8 from "fs";
|
|
21608
21810
|
import path11 from "path";
|
|
21609
|
-
import
|
|
21811
|
+
import matter17 from "gray-matter";
|
|
21610
21812
|
function validateReadiness(content, frontmatter) {
|
|
21611
21813
|
const warnings = [];
|
|
21612
21814
|
const body = content.replace(/^---[\s\S]*?---/, "").trim();
|
|
@@ -21660,14 +21862,14 @@ function isResolvedSection(text2) {
|
|
|
21660
21862
|
}
|
|
21661
21863
|
function transitionToReady(filePath) {
|
|
21662
21864
|
const raw = readFile(filePath);
|
|
21663
|
-
const { data, content } =
|
|
21865
|
+
const { data, content } = matter17(raw);
|
|
21664
21866
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
21665
21867
|
data.status = "ready";
|
|
21666
21868
|
data.ready_at = today3;
|
|
21667
|
-
const newContent =
|
|
21668
|
-
const
|
|
21869
|
+
const newContent = matter17.stringify(content, data);
|
|
21870
|
+
const posix2 = filePath.replace(/\\/g, "/");
|
|
21669
21871
|
let newPath = filePath;
|
|
21670
|
-
if (
|
|
21872
|
+
if (posix2.includes("/work-items/draft/")) {
|
|
21671
21873
|
const readyDir = path11.dirname(filePath).replace(/[/\\]draft$/, path11.sep + "ready");
|
|
21672
21874
|
ensureDir(readyDir);
|
|
21673
21875
|
const fileName = path11.basename(filePath);
|
|
@@ -21704,8 +21906,8 @@ async function runReady(id, opts = {}) {
|
|
|
21704
21906
|
process.exit(1);
|
|
21705
21907
|
}
|
|
21706
21908
|
const raw = readFile(wi.filePath);
|
|
21707
|
-
const { data } =
|
|
21708
|
-
const
|
|
21909
|
+
const { data } = matter17(raw);
|
|
21910
|
+
const source2 = parseWorkItemSource(data);
|
|
21709
21911
|
const warnings = validateReadiness(raw, data);
|
|
21710
21912
|
log.info(`Work Item found:`);
|
|
21711
21913
|
log.info(` ${wi.id} \u2014 ${wi.title}`);
|
|
@@ -21714,7 +21916,7 @@ async function runReady(id, opts = {}) {
|
|
|
21714
21916
|
log.info(` Type: ${wi.type}`);
|
|
21715
21917
|
log.info(` Knowledge level: ${wi.knowledgeLevel || "unset"}`);
|
|
21716
21918
|
log.info(` Domains: ${wi.domains.length > 0 ? wi.domains.join(", ") : "none"}`);
|
|
21717
|
-
log.info(` Source: ${renderSourceCompact(
|
|
21919
|
+
log.info(` Source: ${renderSourceCompact(source2)}`);
|
|
21718
21920
|
if (wi.codeGlobs.length > 0) {
|
|
21719
21921
|
log.info(` Code ownership:`);
|
|
21720
21922
|
for (const g of wi.codeGlobs) log.info(` - ${g}`);
|
|
@@ -21880,10 +22082,10 @@ async function runAdmin(opts = {}) {
|
|
|
21880
22082
|
// src/core/work-item-import.ts
|
|
21881
22083
|
import crypto3 from "crypto";
|
|
21882
22084
|
import fs9 from "fs";
|
|
21883
|
-
import
|
|
22085
|
+
import matter19 from "gray-matter";
|
|
21884
22086
|
|
|
21885
22087
|
// src/core/work-items.ts
|
|
21886
|
-
import
|
|
22088
|
+
import matter18 from "gray-matter";
|
|
21887
22089
|
function computeRefinementStatus(wi) {
|
|
21888
22090
|
const aspects = {
|
|
21889
22091
|
outcome: Boolean(wi.currentBehavior?.trim() || wi.targetBehavior?.trim()),
|
|
@@ -22017,7 +22219,7 @@ function parseOriginalSnapshot(fm2) {
|
|
|
22017
22219
|
function readBody(filePath) {
|
|
22018
22220
|
try {
|
|
22019
22221
|
const raw = readFile(filePath);
|
|
22020
|
-
return
|
|
22222
|
+
return matter18(raw).content;
|
|
22021
22223
|
} catch {
|
|
22022
22224
|
return "";
|
|
22023
22225
|
}
|
|
@@ -22476,7 +22678,7 @@ function detectFormat(raw) {
|
|
|
22476
22678
|
if (!trimmed) throw new ImportError("EMPTY_INPUT", "Import content is empty.");
|
|
22477
22679
|
if (trimmed.startsWith("---")) {
|
|
22478
22680
|
try {
|
|
22479
|
-
const { data } =
|
|
22681
|
+
const { data } = matter19(trimmed);
|
|
22480
22682
|
if (data && typeof data === "object" && Object.keys(data).length > 0) {
|
|
22481
22683
|
const d = data;
|
|
22482
22684
|
if (d.type === "work-item" || d.id && typeof d.id === "string" && /^WI-\d+/.test(d.id)) {
|
|
@@ -22498,7 +22700,7 @@ function parseContent(raw) {
|
|
|
22498
22700
|
let bodyText = trimmed;
|
|
22499
22701
|
if (format === "kaddo-frontmatter" || format === "markdown-frontmatter") {
|
|
22500
22702
|
try {
|
|
22501
|
-
const parsed =
|
|
22703
|
+
const parsed = matter19(trimmed);
|
|
22502
22704
|
frontmatterFields = parsed.data ?? {};
|
|
22503
22705
|
bodyText = parsed.content.trim();
|
|
22504
22706
|
} catch {
|
|
@@ -22570,12 +22772,12 @@ function normalizeImportFields(parsed, opts) {
|
|
|
22570
22772
|
const intent = parsed.title;
|
|
22571
22773
|
const body = hasRealBody ? parsed.body : void 0;
|
|
22572
22774
|
const summary = hasRealBody ? deriveShortSummary(parsed) : parsed.title;
|
|
22573
|
-
const
|
|
22775
|
+
const source2 = {
|
|
22574
22776
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
22575
22777
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
22576
22778
|
};
|
|
22577
|
-
|
|
22578
|
-
|
|
22779
|
+
source2.source_format = opts.sourceFormat;
|
|
22780
|
+
source2.source_hash = opts.sourceHash;
|
|
22579
22781
|
const snapshot = { title: parsed.title };
|
|
22580
22782
|
if (summary !== parsed.title) snapshot.description = summary;
|
|
22581
22783
|
if (typeof parsed.candidateFields.type === "string") snapshot.type = parsed.candidateFields.type;
|
|
@@ -22584,7 +22786,7 @@ function normalizeImportFields(parsed, opts) {
|
|
|
22584
22786
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
22585
22787
|
if (labels.length > 0) snapshot.labels = labels;
|
|
22586
22788
|
}
|
|
22587
|
-
return { type, intent, summary, body, source, snapshot, discardedFields };
|
|
22789
|
+
return { type, intent, summary, body, source: source2, snapshot, discardedFields };
|
|
22588
22790
|
}
|
|
22589
22791
|
function computeContentHash(raw) {
|
|
22590
22792
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -22595,10 +22797,10 @@ function findDuplicateByHash(dir, hash) {
|
|
|
22595
22797
|
const raw = readFile(item.filePath);
|
|
22596
22798
|
if (!raw) continue;
|
|
22597
22799
|
try {
|
|
22598
|
-
const { data } =
|
|
22599
|
-
const
|
|
22600
|
-
if (
|
|
22601
|
-
const s =
|
|
22800
|
+
const { data } = matter19(raw);
|
|
22801
|
+
const source2 = data?.source;
|
|
22802
|
+
if (source2 && typeof source2 === "object" && !Array.isArray(source2)) {
|
|
22803
|
+
const s = source2;
|
|
22602
22804
|
if (s.source_hash === hash) {
|
|
22603
22805
|
return { workItemId: data.id ?? item.id ?? item.title, path: item.relPath };
|
|
22604
22806
|
}
|
|
@@ -22810,8 +23012,33 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
22810
23012
|
}
|
|
22811
23013
|
}
|
|
22812
23014
|
|
|
23015
|
+
// src/commands/poc.ts
|
|
23016
|
+
function runPocReport(opts = {}) {
|
|
23017
|
+
const report = buildPocReportContext(cwd());
|
|
23018
|
+
if (opts.json) {
|
|
23019
|
+
console.log(JSON.stringify(report, null, 2));
|
|
23020
|
+
return;
|
|
23021
|
+
}
|
|
23022
|
+
console.log("");
|
|
23023
|
+
console.log(`POC conclusion: ${report.conclusion}`);
|
|
23024
|
+
console.log(`Final report: ${report.status}`);
|
|
23025
|
+
if (!report.eligible) {
|
|
23026
|
+
console.log(`
|
|
23027
|
+
${report.handoff}
|
|
23028
|
+
`);
|
|
23029
|
+
process.exitCode = 1;
|
|
23030
|
+
return;
|
|
23031
|
+
}
|
|
23032
|
+
if (report.latestReport) console.log(`Latest report: v${report.latestReport.version} (${report.latestReport.path})`);
|
|
23033
|
+
console.log(`Next report: ${report.nextPath}`);
|
|
23034
|
+
console.log(`Sources: ${report.sources.length}`);
|
|
23035
|
+
console.log(`
|
|
23036
|
+
${report.handoff}
|
|
23037
|
+
`);
|
|
23038
|
+
}
|
|
23039
|
+
|
|
22813
23040
|
// src/commands/verify.ts
|
|
22814
|
-
import
|
|
23041
|
+
import matter20 from "gray-matter";
|
|
22815
23042
|
|
|
22816
23043
|
// src/core/implementation-evidence.ts
|
|
22817
23044
|
var WorkItemNotInProgressError = class extends Error {
|
|
@@ -23088,7 +23315,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
23088
23315
|
}
|
|
23089
23316
|
const changedPaths = await getModifiedFiles("head");
|
|
23090
23317
|
const raw = readFile(match.filePath);
|
|
23091
|
-
const parsed =
|
|
23318
|
+
const parsed = matter20(raw);
|
|
23092
23319
|
const fm2 = parsed.data;
|
|
23093
23320
|
const acs = extractACsFromBody(parsed.content);
|
|
23094
23321
|
const existingEvidence = fm2.implementation_evidence;
|
|
@@ -23205,13 +23432,13 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
23205
23432
|
if (shouldPersist) {
|
|
23206
23433
|
const filePath = match.filePath;
|
|
23207
23434
|
const wiRaw = readFile(filePath);
|
|
23208
|
-
const wiParsed =
|
|
23435
|
+
const wiParsed = matter20(wiRaw);
|
|
23209
23436
|
const data = wiParsed.data;
|
|
23210
23437
|
data.implementation_evidence = verification.implementationEvidence;
|
|
23211
23438
|
data.implementation_status = verification.implementationStatus;
|
|
23212
23439
|
data.validation_status = verification.validationStatus;
|
|
23213
23440
|
data.verified_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
23214
|
-
const newRaw =
|
|
23441
|
+
const newRaw = matter20.stringify(wiParsed.content, data);
|
|
23215
23442
|
writeFile(filePath, newRaw);
|
|
23216
23443
|
log.success("Work Item frontmatter updated with verification evidence.");
|
|
23217
23444
|
}
|
|
@@ -23276,14 +23503,14 @@ ${bodySha256}`;
|
|
|
23276
23503
|
|
|
23277
23504
|
// src/core/telemetry-events.ts
|
|
23278
23505
|
import crypto5 from "crypto";
|
|
23279
|
-
function createEvent(name, installationId,
|
|
23506
|
+
function createEvent(name, installationId, source2, properties) {
|
|
23280
23507
|
return {
|
|
23281
23508
|
schemaVersion: "1.0",
|
|
23282
23509
|
id: crypto5.randomUUID(),
|
|
23283
23510
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23284
23511
|
event: name,
|
|
23285
23512
|
installationId,
|
|
23286
|
-
source,
|
|
23513
|
+
source: source2,
|
|
23287
23514
|
properties
|
|
23288
23515
|
};
|
|
23289
23516
|
}
|
|
@@ -23394,7 +23621,7 @@ async function deliverBatch(identity, events) {
|
|
|
23394
23621
|
return false;
|
|
23395
23622
|
}
|
|
23396
23623
|
}
|
|
23397
|
-
async function emit(dir, name,
|
|
23624
|
+
async function emit(dir, name, source2, properties) {
|
|
23398
23625
|
try {
|
|
23399
23626
|
const config = loadConfig(dir);
|
|
23400
23627
|
if (!isEnabled(config)) return;
|
|
@@ -23403,12 +23630,12 @@ async function emit(dir, name, source, properties) {
|
|
|
23403
23630
|
const ok2 = await registerInstallation(identity);
|
|
23404
23631
|
if (ok2) markRegistered(dir, identity);
|
|
23405
23632
|
else {
|
|
23406
|
-
const event2 = createEvent(name, identity.installationId,
|
|
23633
|
+
const event2 = createEvent(name, identity.installationId, source2, properties);
|
|
23407
23634
|
enqueue(dir, [event2]);
|
|
23408
23635
|
return;
|
|
23409
23636
|
}
|
|
23410
23637
|
}
|
|
23411
|
-
const event = createEvent(name, identity.installationId,
|
|
23638
|
+
const event = createEvent(name, identity.installationId, source2, properties);
|
|
23412
23639
|
const buffered = readBuffer(dir);
|
|
23413
23640
|
const batch = [...buffered, event].slice(0, MAX_BATCH_SIZE);
|
|
23414
23641
|
const ok = await deliverBatch(identity, batch);
|
|
@@ -23489,7 +23716,7 @@ function runTelemetryDisable() {
|
|
|
23489
23716
|
}
|
|
23490
23717
|
|
|
23491
23718
|
// src/core/initiative-write.ts
|
|
23492
|
-
import
|
|
23719
|
+
import matter21 from "gray-matter";
|
|
23493
23720
|
var WORK_ITEMS_DIR4 = "knowledge/delivery/work-items";
|
|
23494
23721
|
var DRAFT_DIR2 = `${WORK_ITEMS_DIR4}/draft`;
|
|
23495
23722
|
var InitiativeWriteError = class extends Error {
|
|
@@ -23601,7 +23828,7 @@ function buildInitiativeContent(id, input) {
|
|
|
23601
23828
|
if (input.priority) data.priority = input.priority;
|
|
23602
23829
|
if (input.source) data.source = input.source;
|
|
23603
23830
|
if (input.sourceId) data.source_id = input.sourceId;
|
|
23604
|
-
return
|
|
23831
|
+
return matter21.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
|
|
23605
23832
|
}
|
|
23606
23833
|
function createInitiative(dir, input) {
|
|
23607
23834
|
if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
|
|
@@ -23625,10 +23852,10 @@ function transitionInitiative(dir, id, to) {
|
|
|
23625
23852
|
throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
|
|
23626
23853
|
}
|
|
23627
23854
|
const raw = readFile(ini.filePath);
|
|
23628
|
-
const { data, content } =
|
|
23855
|
+
const { data, content } = matter21(raw, {});
|
|
23629
23856
|
data.status = to;
|
|
23630
23857
|
if (to === "completed") data.completed_at = today2();
|
|
23631
|
-
const newContent =
|
|
23858
|
+
const newContent = matter21.stringify(content, data);
|
|
23632
23859
|
writeFile(ini.filePath, newContent);
|
|
23633
23860
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
23634
23861
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
|
|
@@ -23697,7 +23924,7 @@ function buildWorkItemContent(wiId, iniId, candidate) {
|
|
|
23697
23924
|
"_What did we learn? Update after completion._",
|
|
23698
23925
|
""
|
|
23699
23926
|
].join("\n");
|
|
23700
|
-
return
|
|
23927
|
+
return matter21.stringify("\n" + body, data);
|
|
23701
23928
|
}
|
|
23702
23929
|
function materializeCandidate(dir, id, candidateId) {
|
|
23703
23930
|
const ini = getInitiative(dir, id);
|
|
@@ -23714,13 +23941,13 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
23714
23941
|
ensureDir(join(dir, DRAFT_DIR2));
|
|
23715
23942
|
writeFile(join(dir, DRAFT_DIR2, fileName), buildWorkItemContent(wiId, ini.id, candidate));
|
|
23716
23943
|
const raw = readFile(ini.filePath);
|
|
23717
|
-
const { data, content } =
|
|
23944
|
+
const { data, content } = matter21(raw, {});
|
|
23718
23945
|
const cands = Array.isArray(data.candidates) ? data.candidates : [];
|
|
23719
23946
|
for (const c of cands) {
|
|
23720
23947
|
if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
|
|
23721
23948
|
}
|
|
23722
23949
|
data.candidates = cands;
|
|
23723
|
-
const newContent =
|
|
23950
|
+
const newContent = matter21.stringify(content, data);
|
|
23724
23951
|
writeFile(ini.filePath, newContent);
|
|
23725
23952
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
23726
23953
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
|
|
@@ -24074,6 +24301,10 @@ program.command("create [type]").description("Create a work item (feature, bugfi
|
|
|
24074
24301
|
program.command("ready <id>").description("Mark a draft Work Item as ready for implementation after human review").option("--yes", "Skip confirmation prompt").action(async (id, opts) => {
|
|
24075
24302
|
await runReady(id, opts);
|
|
24076
24303
|
});
|
|
24304
|
+
var pocCmd = program.command("poc").description("Proof of Concept lifecycle helpers");
|
|
24305
|
+
pocCmd.command("report").description("Prepare a deterministic final POC report handoff (no LLM call, no write)").option("--json", "Output the report context as JSON").action((opts) => {
|
|
24306
|
+
runPocReport(opts);
|
|
24307
|
+
});
|
|
24077
24308
|
var capsuleCmd = program.command("capsule").description("Export this project as a Knowledge Capsule, or import an external one as context");
|
|
24078
24309
|
capsuleCmd.command("export").description("Write a Knowledge Capsule about this project to .kaddo/exports/").option("--scope <scope>", 'Export scope: "system" includes all mapped modules').option("--module <id>", "Export a capsule for a specific mapped module").action((opts) => {
|
|
24079
24310
|
runCapsuleExport(opts);
|