@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/core.js
CHANGED
|
@@ -350,12 +350,12 @@ function classifyLayer(posixPath) {
|
|
|
350
350
|
return "unknown";
|
|
351
351
|
}
|
|
352
352
|
function enrich(dir, a) {
|
|
353
|
-
const
|
|
353
|
+
const posix2 = toPosix(a.filePath);
|
|
354
354
|
const isWi = isWorkItemArtifact(a);
|
|
355
355
|
return {
|
|
356
356
|
...a,
|
|
357
357
|
relPath: relativeTo(dir, a.filePath),
|
|
358
|
-
layer: classifyLayer(
|
|
358
|
+
layer: classifyLayer(posix2),
|
|
359
359
|
isWorkItem: isWi,
|
|
360
360
|
lifecycle: isWi ? lifecycleStateOf({ status: a.status, filePath: a.filePath }) : void 0
|
|
361
361
|
};
|
|
@@ -3069,8 +3069,8 @@ function buildOpenQuestionsReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
3069
3069
|
const project = loadConfig(dir)?.project.name ?? "unknown";
|
|
3070
3070
|
const questions = [];
|
|
3071
3071
|
let seq = 0;
|
|
3072
|
-
for (const
|
|
3073
|
-
const p = join(dir,
|
|
3072
|
+
for (const source2 of SOURCES) {
|
|
3073
|
+
const p = join(dir, source2);
|
|
3074
3074
|
if (!exists(p)) continue;
|
|
3075
3075
|
let md;
|
|
3076
3076
|
try {
|
|
@@ -3083,8 +3083,8 @@ function buildOpenQuestionsReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
3083
3083
|
const { classification, reason } = classifyQuestion(eq.text);
|
|
3084
3084
|
questions.push({
|
|
3085
3085
|
id: `OQ-${String(seq).padStart(3, "0")}`,
|
|
3086
|
-
source,
|
|
3087
|
-
sourcePath:
|
|
3086
|
+
source: source2,
|
|
3087
|
+
sourcePath: source2,
|
|
3088
3088
|
line: eq.line,
|
|
3089
3089
|
raw: eq.raw,
|
|
3090
3090
|
section: "Open Questions",
|
|
@@ -3447,6 +3447,146 @@ function readPocSummary(dir) {
|
|
|
3447
3447
|
};
|
|
3448
3448
|
}
|
|
3449
3449
|
|
|
3450
|
+
// src/core/poc-report.ts
|
|
3451
|
+
import { createHash } from "crypto";
|
|
3452
|
+
import matter6 from "gray-matter";
|
|
3453
|
+
var POC_REPORT_PREFIX = "poc-report-v";
|
|
3454
|
+
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;
|
|
3455
|
+
var reportName = /^poc-report-v(\d{3,})\.md$/;
|
|
3456
|
+
function sha(value) {
|
|
3457
|
+
return createHash("sha256").update(value).digest("hex");
|
|
3458
|
+
}
|
|
3459
|
+
function posix(value) {
|
|
3460
|
+
return value.replace(/\\/g, "/");
|
|
3461
|
+
}
|
|
3462
|
+
function redactSecrets(value) {
|
|
3463
|
+
return value.split(/\r?\n/).map((line) => {
|
|
3464
|
+
if (!SECRET_LINE.test(line)) return line;
|
|
3465
|
+
return line.replace(/([:=]\s*)\S+.*/, "$1[redacted]");
|
|
3466
|
+
}).join("\n");
|
|
3467
|
+
}
|
|
3468
|
+
function source(dir, path5, kind) {
|
|
3469
|
+
const absolute = join(dir, path5);
|
|
3470
|
+
if (!exists(absolute)) return null;
|
|
3471
|
+
const raw = readFile(absolute);
|
|
3472
|
+
return { path: posix(path5), kind, digest: sha(raw), content: redactSecrets(raw) };
|
|
3473
|
+
}
|
|
3474
|
+
function reportFiles(dir) {
|
|
3475
|
+
const delivery = join(dir, "knowledge", "delivery");
|
|
3476
|
+
return readDir(delivery).flatMap((name) => {
|
|
3477
|
+
const match = name.match(reportName);
|
|
3478
|
+
if (!match) return [];
|
|
3479
|
+
try {
|
|
3480
|
+
const parsed = matter6(readFile(join(delivery, name)));
|
|
3481
|
+
const fingerprint = typeof parsed.data.source_fingerprint === "string" ? parsed.data.source_fingerprint : "";
|
|
3482
|
+
const manifest = parsed.data.source_manifest;
|
|
3483
|
+
const sourceManifest = manifest && typeof manifest === "object" && !Array.isArray(manifest) ? Object.fromEntries(Object.entries(manifest).filter(([, digest]) => typeof digest === "string")) : {};
|
|
3484
|
+
return [{ path: `knowledge/delivery/${name}`, version: Number(match[1]), sourceFingerprint: fingerprint, sourceManifest }];
|
|
3485
|
+
} catch {
|
|
3486
|
+
return [];
|
|
3487
|
+
}
|
|
3488
|
+
}).sort((a, b) => b.version - a.version);
|
|
3489
|
+
}
|
|
3490
|
+
function reportPath(version) {
|
|
3491
|
+
return `knowledge/delivery/${POC_REPORT_PREFIX}${String(version).padStart(3, "0")}.md`;
|
|
3492
|
+
}
|
|
3493
|
+
function buildPocReportContext(dir) {
|
|
3494
|
+
const poc = readPocSummary(dir);
|
|
3495
|
+
const reports = reportFiles(dir);
|
|
3496
|
+
const latestReport = reports[0] ?? null;
|
|
3497
|
+
const nextPath = reportPath((latestReport?.version ?? 0) + 1);
|
|
3498
|
+
if (!poc.exists || poc.conclusion === "pending") {
|
|
3499
|
+
return {
|
|
3500
|
+
eligible: false,
|
|
3501
|
+
conclusion: poc.conclusion,
|
|
3502
|
+
status: latestReport ? "stale" : "missing",
|
|
3503
|
+
latestReport,
|
|
3504
|
+
nextPath,
|
|
3505
|
+
sourceFingerprint: "",
|
|
3506
|
+
sources: [],
|
|
3507
|
+
changesSinceLatest: [],
|
|
3508
|
+
handoff: "POC conclusion is still pending. Record validated, rejected, or inconclusive before generating a final report."
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
const sources = [];
|
|
3512
|
+
const add = (path5, kind) => {
|
|
3513
|
+
if (sources.some((item2) => item2.path === posix(path5))) return;
|
|
3514
|
+
const item = source(dir, path5, kind);
|
|
3515
|
+
if (item) sources.push(item);
|
|
3516
|
+
};
|
|
3517
|
+
add(POC_ARTIFACT_PATH, "poc");
|
|
3518
|
+
const pocText = readFile(join(dir, POC_ARTIFACT_PATH));
|
|
3519
|
+
const knowledge = discoverKnowledge(dir);
|
|
3520
|
+
const workItems = discoverWorkItems(dir);
|
|
3521
|
+
const referencedWorkItems = workItems.filter((wi) => wi.lifecycle === "completed" && wi.id && new RegExp(`\\b${wi.id}\\b`).test(pocText));
|
|
3522
|
+
const resourceIds = /* @__PURE__ */ new Set();
|
|
3523
|
+
const decisionIds = /* @__PURE__ */ new Set();
|
|
3524
|
+
for (const wi of referencedWorkItems) {
|
|
3525
|
+
add(wi.relPath, "work-item");
|
|
3526
|
+
for (const resource of parseWorkItemResources(wi.rawFrontmatter)) resourceIds.add(resource.id);
|
|
3527
|
+
const decisions = wi.rawFrontmatter.decisions;
|
|
3528
|
+
if (Array.isArray(decisions)) decisions.forEach((id) => decisionIds.add(String(id)));
|
|
3529
|
+
}
|
|
3530
|
+
for (const id of resourceIds) {
|
|
3531
|
+
const resource = getResource(dir, id);
|
|
3532
|
+
if (resource) add(resource.path, "resource");
|
|
3533
|
+
}
|
|
3534
|
+
for (const artifact of knowledge) {
|
|
3535
|
+
if (artifact.isWorkItem || !artifact.id) continue;
|
|
3536
|
+
if (decisionIds.has(artifact.id) || referencedWorkItems.some((wi) => new RegExp(`\\b${artifact.id}\\b`).test(readFile(wi.filePath)))) add(artifact.relPath, "knowledge");
|
|
3537
|
+
}
|
|
3538
|
+
sources.sort((a, b) => a.path.localeCompare(b.path));
|
|
3539
|
+
const sourceFingerprint = sha(sources.map((item) => `${item.path}\0${item.digest}`).join("\n"));
|
|
3540
|
+
const status = !latestReport ? "missing" : latestReport.sourceFingerprint === sourceFingerprint ? "current" : "stale";
|
|
3541
|
+
const currentManifest = Object.fromEntries(sources.map((item) => [item.path, item.digest]));
|
|
3542
|
+
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path5) => currentManifest[path5] !== latestReport?.sourceManifest[path5]).sort() : [];
|
|
3543
|
+
const sourceList = sources.map((item) => `- ${item.path} (${item.kind})`).join("\n") || "- No sources selected.";
|
|
3544
|
+
return {
|
|
3545
|
+
eligible: true,
|
|
3546
|
+
conclusion: poc.conclusion,
|
|
3547
|
+
status,
|
|
3548
|
+
latestReport,
|
|
3549
|
+
nextPath,
|
|
3550
|
+
sourceFingerprint,
|
|
3551
|
+
sources,
|
|
3552
|
+
changesSinceLatest,
|
|
3553
|
+
handoff: [
|
|
3554
|
+
"Create a POC Final Report from the supplied sources only. Do not explore the repository.",
|
|
3555
|
+
`Canonical conclusion: ${poc.conclusion}. Do not contradict it.`,
|
|
3556
|
+
"Use the 15 canonical sections. Mark missing evidence as Not evaluated, Not applicable, or No evidence available.",
|
|
3557
|
+
"Distinguish measured, calculated, estimated, and projected values. Never include secret values.",
|
|
3558
|
+
"",
|
|
3559
|
+
"Selected sources:",
|
|
3560
|
+
sourceList
|
|
3561
|
+
].join("\n")
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
function canonicalReport(context, proposal) {
|
|
3565
|
+
const supersedes = context.latestReport?.path.split("/").pop();
|
|
3566
|
+
const data = {
|
|
3567
|
+
type: "poc-report",
|
|
3568
|
+
report_version: Number(context.nextPath.match(/v(\d+)\.md$/)?.[1] ?? 1),
|
|
3569
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
3570
|
+
poc_conclusion: context.conclusion,
|
|
3571
|
+
source_fingerprint: context.sourceFingerprint,
|
|
3572
|
+
sources: context.sources.map((item) => item.path),
|
|
3573
|
+
source_manifest: Object.fromEntries(context.sources.map((item) => [item.path, item.digest]))
|
|
3574
|
+
};
|
|
3575
|
+
if (supersedes) data.supersedes = supersedes;
|
|
3576
|
+
return matter6.stringify(redactSecrets(proposal).trimEnd() + "\n", data);
|
|
3577
|
+
}
|
|
3578
|
+
function persistPocReport(dir, proposal, opts = {}) {
|
|
3579
|
+
const context = buildPocReportContext(dir);
|
|
3580
|
+
if (!context.eligible) throw new Error(context.handoff);
|
|
3581
|
+
if (context.status === "current" && !opts.force) return { status: "current", path: context.latestReport.path, message: "The current POC report already represents the latest evidence." };
|
|
3582
|
+
if (!opts.confirm) return { status: "needs_confirmation", path: context.nextPath, content: canonicalReport(context, proposal), message: "Review the proposed report and confirm persistence." };
|
|
3583
|
+
const output = join(dir, context.nextPath);
|
|
3584
|
+
if (exists(output)) throw new Error(`POC report already exists: ${context.nextPath}`);
|
|
3585
|
+
const content = canonicalReport(context, proposal);
|
|
3586
|
+
writeFile(output, content);
|
|
3587
|
+
return { status: "persisted", path: context.nextPath, content };
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3450
3590
|
// src/core/next-step.ts
|
|
3451
3591
|
function buildDeliveryState(dir) {
|
|
3452
3592
|
const wis = discoverWorkItems(dir);
|
|
@@ -3537,7 +3677,7 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
3537
3677
|
if (projectMode(config) === "poc") {
|
|
3538
3678
|
const poc = readPocSummary(dir);
|
|
3539
3679
|
if (!poc.exists) {
|
|
3540
|
-
return { id: "
|
|
3680
|
+
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}.` };
|
|
3541
3681
|
}
|
|
3542
3682
|
if (!poc.hypothesisDefined) {
|
|
3543
3683
|
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." };
|
|
@@ -3547,12 +3687,9 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
3547
3687
|
}
|
|
3548
3688
|
const qCurrentState2 = analyzeKnowledgeArtifact(dir, CS);
|
|
3549
3689
|
const qCodebase2 = analyzeKnowledgeArtifact(dir, CB);
|
|
3550
|
-
if (qCurrentState2 !== "useful" || qCodebase2 !== "useful") {
|
|
3690
|
+
if (exists(join(dir, ".kaddo", "scan.json")) && (qCurrentState2 !== "useful" || qCodebase2 !== "useful")) {
|
|
3551
3691
|
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." };
|
|
3552
3692
|
}
|
|
3553
|
-
if (!exists(join(dir, "knowledge", "resources"))) {
|
|
3554
|
-
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." };
|
|
3555
|
-
}
|
|
3556
3693
|
const delivery = buildDeliveryState(dir);
|
|
3557
3694
|
if (delivery.total_work_items === 0) {
|
|
3558
3695
|
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." };
|
|
@@ -3566,7 +3703,11 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
3566
3703
|
if (poc.conclusion === "pending") {
|
|
3567
3704
|
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." };
|
|
3568
3705
|
}
|
|
3569
|
-
|
|
3706
|
+
const report = buildPocReportContext(dir);
|
|
3707
|
+
if (report.status !== "current") {
|
|
3708
|
+
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." };
|
|
3709
|
+
}
|
|
3710
|
+
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." };
|
|
3570
3711
|
}
|
|
3571
3712
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
3572
3713
|
const resolveAgent = (agent) => {
|
|
@@ -4004,7 +4145,7 @@ function deriveDeliveryCompletedStatus(dir) {
|
|
|
4004
4145
|
}
|
|
4005
4146
|
|
|
4006
4147
|
// src/core/assets.ts
|
|
4007
|
-
import
|
|
4148
|
+
import matter7 from "gray-matter";
|
|
4008
4149
|
|
|
4009
4150
|
// src/core/version.ts
|
|
4010
4151
|
import { fileURLToPath } from "url";
|
|
@@ -4680,6 +4821,50 @@ their intersection with the affected areas, and recommended actions.
|
|
|
4680
4821
|
- The assessment is proportional \u2014 a small change gets a brief assessment.
|
|
4681
4822
|
`
|
|
4682
4823
|
);
|
|
4824
|
+
var POC_REPORT_WRITING = skill(
|
|
4825
|
+
"poc-report-writing",
|
|
4826
|
+
"POC Final Report Writing Skill",
|
|
4827
|
+
"delivery",
|
|
4828
|
+
["implementation-agent", "work-item-agent"],
|
|
4829
|
+
`
|
|
4830
|
+
# POC Final Report Writing Skill
|
|
4831
|
+
|
|
4832
|
+
## Purpose
|
|
4833
|
+
|
|
4834
|
+
Turn a supplied deterministic POC report context into a concise, traceable final report.
|
|
4835
|
+
|
|
4836
|
+
## When to use
|
|
4837
|
+
|
|
4838
|
+
After a POC has a canonical conclusion and Core has prepared its deterministic report context.
|
|
4839
|
+
|
|
4840
|
+
## Rules
|
|
4841
|
+
|
|
4842
|
+
- Use only the supplied context; do not scan the repository or infer missing results.
|
|
4843
|
+
- Treat \`poc.md\` as canonical for the conclusion. Never contradict it.
|
|
4844
|
+
- Keep facts, measurements, calculations, estimates, and recommendations distinct.
|
|
4845
|
+
- Never include credential values, tokens, private keys, passwords, or connection strings.
|
|
4846
|
+
- Use \`Not evaluated in this POC.\`, \`Not applicable.\`, or \`No evidence available.\` when sources do not support a section.
|
|
4847
|
+
- Return a proposal for human review; Core persists it only after confirmation.
|
|
4848
|
+
|
|
4849
|
+
## Required structure
|
|
4850
|
+
|
|
4851
|
+
1. Executive Summary
|
|
4852
|
+
2. Problem and Objective
|
|
4853
|
+
3. Hypothesis and Success Criteria
|
|
4854
|
+
4. Scope, Constraints and Non-goals
|
|
4855
|
+
5. Technical Approach and Architecture
|
|
4856
|
+
6. Infrastructure and Project Resources
|
|
4857
|
+
7. Implementation and Relevant Technical Decisions
|
|
4858
|
+
8. Experiments and Validation
|
|
4859
|
+
9. Results and Measurements
|
|
4860
|
+
10. Cost and Efficiency Analysis
|
|
4861
|
+
11. Observability and Operational Findings
|
|
4862
|
+
12. Findings, Learnings, Limitations and Risks
|
|
4863
|
+
13. Conclusion
|
|
4864
|
+
14. Recommendation and Next Steps
|
|
4865
|
+
15. Traceability and Sources
|
|
4866
|
+
`
|
|
4867
|
+
);
|
|
4683
4868
|
var SKILLS = [
|
|
4684
4869
|
ADR_WRITING,
|
|
4685
4870
|
WORK_ITEM_REFINEMENT,
|
|
@@ -4690,10 +4875,11 @@ var SKILLS = [
|
|
|
4690
4875
|
IMPLEMENTATION_PLANNING,
|
|
4691
4876
|
MODULE_CONTEXT_REFINEMENT,
|
|
4692
4877
|
EVIDENCE_VERIFICATION,
|
|
4693
|
-
LEGACY_RISK_ASSESSMENT
|
|
4878
|
+
LEGACY_RISK_ASSESSMENT,
|
|
4879
|
+
POC_REPORT_WRITING
|
|
4694
4880
|
];
|
|
4695
4881
|
var SKILL_GROUPS = {
|
|
4696
|
-
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment"],
|
|
4882
|
+
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing"],
|
|
4697
4883
|
tech: ["adr-writing", "ownership-suggestion", "graph-metadata-review", "module-context-refinement"],
|
|
4698
4884
|
integration: ["capsule-writing"]
|
|
4699
4885
|
};
|
|
@@ -7227,7 +7413,7 @@ function canonicalSkills() {
|
|
|
7227
7413
|
}
|
|
7228
7414
|
function versionOf(content) {
|
|
7229
7415
|
try {
|
|
7230
|
-
const v =
|
|
7416
|
+
const v = matter7(content).data.version;
|
|
7231
7417
|
return v === void 0 || v === null ? null : String(v);
|
|
7232
7418
|
} catch {
|
|
7233
7419
|
return null;
|
|
@@ -7790,6 +7976,11 @@ var definePocHypothesis = {
|
|
|
7790
7976
|
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." };
|
|
7791
7977
|
}
|
|
7792
7978
|
};
|
|
7979
|
+
var ensurePocArtifact = {
|
|
7980
|
+
id: "poc-artifact",
|
|
7981
|
+
label: "Create POC artifact",
|
|
7982
|
+
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." }
|
|
7983
|
+
};
|
|
7793
7984
|
var definePocCriteria = {
|
|
7794
7985
|
id: "poc-success-criteria",
|
|
7795
7986
|
label: "Define success criteria",
|
|
@@ -7798,11 +7989,15 @@ var definePocCriteria = {
|
|
|
7798
7989
|
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." };
|
|
7799
7990
|
}
|
|
7800
7991
|
};
|
|
7801
|
-
var describePocTech = {
|
|
7992
|
+
var describePocTech = {
|
|
7993
|
+
id: "poc-technical-context",
|
|
7994
|
+
label: "Document minimal technical context",
|
|
7995
|
+
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." }
|
|
7996
|
+
};
|
|
7802
7997
|
var identifyPocResources = {
|
|
7803
7998
|
id: "poc-resources",
|
|
7804
7999
|
label: "Identify relevant resources",
|
|
7805
|
-
evaluate: (ctx) => exists(join(ctx.dir, "knowledge/resources")) ? { status: "done", evidence: ["knowledge/resources/"] } : { status: "
|
|
8000
|
+
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." }
|
|
7806
8001
|
};
|
|
7807
8002
|
var createPocExperiment = {
|
|
7808
8003
|
id: "poc-create-experiment",
|
|
@@ -7822,7 +8017,17 @@ var concludePoc = {
|
|
|
7822
8017
|
return conclusion === "pending" ? { status: "pending", reason: "Record validated, rejected, or inconclusive from the evidence." } : { status: "done", evidence: [POC_ARTIFACT_PATH], reason: `Conclusion: ${conclusion}.` };
|
|
7823
8018
|
}
|
|
7824
8019
|
};
|
|
7825
|
-
var
|
|
8020
|
+
var finalPocReport = {
|
|
8021
|
+
id: "poc-final-report",
|
|
8022
|
+
label: "Generate final report (optional)",
|
|
8023
|
+
evaluate: (ctx) => {
|
|
8024
|
+
const report = buildPocReportContext(ctx.dir);
|
|
8025
|
+
if (!report.eligible) return { status: "optional", reason: "Available after recording a POC conclusion." };
|
|
8026
|
+
if (report.status === "current") return { status: "done", evidence: [report.latestReport.path] };
|
|
8027
|
+
return { status: "optional", command: "kaddo poc report", reason: report.status === "stale" ? "Latest report is stale." : "A final report is optional." };
|
|
8028
|
+
}
|
|
8029
|
+
};
|
|
8030
|
+
var POC_STEPS = [enableKaddo, ensurePocArtifact, definePocHypothesis, definePocCriteria, describePocTech, identifyPocResources, createPocExperiment, capturePocEvidence, concludePoc, finalPocReport];
|
|
7826
8031
|
function stepsForState(state) {
|
|
7827
8032
|
switch (state) {
|
|
7828
8033
|
case "new":
|
|
@@ -7926,6 +8131,7 @@ function mapNextStepId(id) {
|
|
|
7926
8131
|
"poc-resources": "poc-resources",
|
|
7927
8132
|
"poc-create-experiment": "poc-create-experiment",
|
|
7928
8133
|
"poc-evaluate": "poc-evaluate",
|
|
8134
|
+
"poc-final-report": "poc-final-report",
|
|
7929
8135
|
"poc-complete": "poc-evaluate"
|
|
7930
8136
|
};
|
|
7931
8137
|
return MAP[id] ?? id;
|
|
@@ -7940,7 +8146,7 @@ function buildProjectRoute(dir) {
|
|
|
7940
8146
|
return { id: d.id, label: d.label, ...result };
|
|
7941
8147
|
});
|
|
7942
8148
|
for (const s of steps) {
|
|
7943
|
-
if (s.id === ctx.nextStepId && s.status !== "done") {
|
|
8149
|
+
if (s.id === ctx.nextStepId && s.status !== "done" && s.status !== "optional") {
|
|
7944
8150
|
s.status = "current";
|
|
7945
8151
|
}
|
|
7946
8152
|
}
|
|
@@ -7952,8 +8158,8 @@ function buildProjectRoute(dir) {
|
|
|
7952
8158
|
break;
|
|
7953
8159
|
}
|
|
7954
8160
|
}
|
|
7955
|
-
const completed = steps.filter((s) => s.status === "done").length;
|
|
7956
|
-
const total = steps.length;
|
|
8161
|
+
const completed = steps.filter((s) => s.status === "done" && s.status !== "optional").length;
|
|
8162
|
+
const total = steps.filter((s) => s.status !== "optional").length;
|
|
7957
8163
|
const progressPercent = total > 0 ? Math.round(completed / total * 100) : 0;
|
|
7958
8164
|
return {
|
|
7959
8165
|
type: state,
|
|
@@ -7966,7 +8172,7 @@ function buildProjectRoute(dir) {
|
|
|
7966
8172
|
}
|
|
7967
8173
|
|
|
7968
8174
|
// src/core/metadata-health.ts
|
|
7969
|
-
import
|
|
8175
|
+
import matter8 from "gray-matter";
|
|
7970
8176
|
var KNOWLEDGE_FILES2 = [
|
|
7971
8177
|
"knowledge/business/business.md",
|
|
7972
8178
|
"knowledge/product/product.md",
|
|
@@ -7986,7 +8192,7 @@ function analyzeMetadataHealth(dir) {
|
|
|
7986
8192
|
let data;
|
|
7987
8193
|
try {
|
|
7988
8194
|
const raw = readFile(p);
|
|
7989
|
-
data =
|
|
8195
|
+
data = matter8(raw).data;
|
|
7990
8196
|
} catch {
|
|
7991
8197
|
continue;
|
|
7992
8198
|
}
|
|
@@ -8018,7 +8224,7 @@ function analyzeMetadataHealth(dir) {
|
|
|
8018
8224
|
if (isFile(p) && entry.endsWith(".md")) {
|
|
8019
8225
|
try {
|
|
8020
8226
|
const raw = readFile(p);
|
|
8021
|
-
const fm =
|
|
8227
|
+
const fm = matter8(raw).data;
|
|
8022
8228
|
if (fm.status === "done") {
|
|
8023
8229
|
const rel = p.replace(dir + "/", "").replace(dir + "\\", "").replace(/\\/g, "/");
|
|
8024
8230
|
findings.push({
|
|
@@ -8382,7 +8588,7 @@ function buildProjectExplanation(dir) {
|
|
|
8382
8588
|
// src/core/resource-write.ts
|
|
8383
8589
|
import fs2 from "fs";
|
|
8384
8590
|
import path2 from "path";
|
|
8385
|
-
import
|
|
8591
|
+
import matter9 from "gray-matter";
|
|
8386
8592
|
var RESOURCES_DIR = "knowledge/tech/resources";
|
|
8387
8593
|
var ResourceWriteError = class extends Error {
|
|
8388
8594
|
constructor(code, message) {
|
|
@@ -8462,7 +8668,7 @@ function buildFrontmatter(id, input, base = {}) {
|
|
|
8462
8668
|
return data;
|
|
8463
8669
|
}
|
|
8464
8670
|
function serialize(data, body) {
|
|
8465
|
-
return
|
|
8671
|
+
return matter9.stringify(`
|
|
8466
8672
|
${body.trim()}
|
|
8467
8673
|
`, data);
|
|
8468
8674
|
}
|
|
@@ -8502,7 +8708,7 @@ function updateResource(dir, id, input) {
|
|
|
8502
8708
|
throw new ResourceWriteError("VALIDATION_FAILED", findings.filter((f) => f.level === "error").map((f) => f.message).join("; "));
|
|
8503
8709
|
}
|
|
8504
8710
|
const raw = readFile(match.filePath);
|
|
8505
|
-
const parsed =
|
|
8711
|
+
const parsed = matter9(raw);
|
|
8506
8712
|
const base = parsed.data ?? {};
|
|
8507
8713
|
const data = buildFrontmatter(match.id || id, input, base);
|
|
8508
8714
|
let body = parsed.content.trim();
|
|
@@ -8773,7 +8979,7 @@ function analyzeCrossRepoEvidence(input) {
|
|
|
8773
8979
|
}
|
|
8774
8980
|
|
|
8775
8981
|
// src/core/work-items.ts
|
|
8776
|
-
import
|
|
8982
|
+
import matter10 from "gray-matter";
|
|
8777
8983
|
|
|
8778
8984
|
// src/core/system-topology.ts
|
|
8779
8985
|
import { parse as parseYaml8, stringify as stringifyYaml5 } from "yaml";
|
|
@@ -9209,7 +9415,7 @@ function parseOriginalSnapshot(fm) {
|
|
|
9209
9415
|
function readBody(filePath) {
|
|
9210
9416
|
try {
|
|
9211
9417
|
const raw = readFile(filePath);
|
|
9212
|
-
return
|
|
9418
|
+
return matter10(raw).content;
|
|
9213
9419
|
} catch {
|
|
9214
9420
|
return "";
|
|
9215
9421
|
}
|
|
@@ -9376,7 +9582,7 @@ function parseRelatedKnowledge(fm, knowledgeById) {
|
|
|
9376
9582
|
import fs4 from "fs";
|
|
9377
9583
|
import path4 from "path";
|
|
9378
9584
|
import crypto2 from "crypto";
|
|
9379
|
-
import
|
|
9585
|
+
import matter11 from "gray-matter";
|
|
9380
9586
|
|
|
9381
9587
|
// src/core/knowledge-levels.ts
|
|
9382
9588
|
var WORK_ITEM_TYPES2 = ["feature", "bugfix", "hotfix", "spike", "chore"];
|
|
@@ -9783,7 +9989,7 @@ function applyFrontmatter(data, input) {
|
|
|
9783
9989
|
return next;
|
|
9784
9990
|
}
|
|
9785
9991
|
function serialize2(data, body) {
|
|
9786
|
-
return
|
|
9992
|
+
return matter11.stringify(`
|
|
9787
9993
|
${body.trim()}
|
|
9788
9994
|
`, data);
|
|
9789
9995
|
}
|
|
@@ -9842,7 +10048,7 @@ function toInput(data, content) {
|
|
|
9842
10048
|
function getWorkItemForEdit(dir, id) {
|
|
9843
10049
|
const { filePath, relPath } = findArtifact(dir, id);
|
|
9844
10050
|
const raw = readFile(filePath);
|
|
9845
|
-
const { data, content } =
|
|
10051
|
+
const { data, content } = matter11(raw);
|
|
9846
10052
|
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
9847
10053
|
const input = toInput(data, content);
|
|
9848
10054
|
const editable = EDITABLE_STATES.includes(status);
|
|
@@ -9887,7 +10093,7 @@ function createWorkItem(dir, opts) {
|
|
|
9887
10093
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
9888
10094
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
9889
10095
|
const summary = opts.summary?.trim() || intent;
|
|
9890
|
-
const
|
|
10096
|
+
const source2 = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
9891
10097
|
const data = {
|
|
9892
10098
|
type,
|
|
9893
10099
|
id,
|
|
@@ -9895,7 +10101,7 @@ function createWorkItem(dir, opts) {
|
|
|
9895
10101
|
status: "draft",
|
|
9896
10102
|
work_type: type,
|
|
9897
10103
|
created_at: today2,
|
|
9898
|
-
source,
|
|
10104
|
+
source: source2,
|
|
9899
10105
|
generated_by: "kaddo-admin",
|
|
9900
10106
|
affected_modules: [],
|
|
9901
10107
|
summary
|
|
@@ -9935,7 +10141,7 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
9935
10141
|
if (revisionOf(raw) !== expectedRevision) {
|
|
9936
10142
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before saving.");
|
|
9937
10143
|
}
|
|
9938
|
-
const { data, content } =
|
|
10144
|
+
const { data, content } = matter11(raw);
|
|
9939
10145
|
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
9940
10146
|
if (!EDITABLE_STATES.includes(status)) {
|
|
9941
10147
|
throw new WorkItemWriteError("WORK_ITEM_NOT_EDITABLE", `A ${status} Work Item cannot be edited. Reopen it as Draft first.`);
|
|
@@ -9949,7 +10155,7 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
9949
10155
|
function validateWorkItem(dir, id) {
|
|
9950
10156
|
const { filePath } = findArtifact(dir, id);
|
|
9951
10157
|
const raw = readFile(filePath);
|
|
9952
|
-
const { data, content } =
|
|
10158
|
+
const { data, content } = matter11(raw);
|
|
9953
10159
|
const input = toInput(data, content);
|
|
9954
10160
|
const findings = [];
|
|
9955
10161
|
const modules = validModuleIds(dir);
|
|
@@ -10002,7 +10208,7 @@ function transitionWorkItem(dir, id, to, expectedRevision) {
|
|
|
10002
10208
|
if (revisionOf(raw) !== expectedRevision) {
|
|
10003
10209
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
|
|
10004
10210
|
}
|
|
10005
|
-
const { data, content } =
|
|
10211
|
+
const { data, content } = matter11(raw);
|
|
10006
10212
|
const from = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
10007
10213
|
if (!(ALLOWED[from] ?? []).includes(to)) {
|
|
10008
10214
|
throw new WorkItemWriteError("INVALID_TRANSITION", `Cannot transition a ${from} Work Item to ${to}.`);
|
|
@@ -10257,10 +10463,10 @@ function getSystemNeighbors(dir, nodeId, opts = {}) {
|
|
|
10257
10463
|
}
|
|
10258
10464
|
return { seed: nodeId, nodes, relationships: rels, truncated };
|
|
10259
10465
|
}
|
|
10260
|
-
function findSystemPaths(dir,
|
|
10466
|
+
function findSystemPaths(dir, source2, target, opts = {}) {
|
|
10261
10467
|
const projection = getSystemMapProjection(dir);
|
|
10262
10468
|
const byId = new Map(projection.nodes.map((n) => [n.id, n]));
|
|
10263
|
-
if (!byId.has(
|
|
10469
|
+
if (!byId.has(source2) || !byId.has(target)) return [];
|
|
10264
10470
|
const maxDepth = Math.max(1, opts.maxDepth ?? 4);
|
|
10265
10471
|
const out = /* @__PURE__ */ new Map();
|
|
10266
10472
|
for (const r of projection.relationships) {
|
|
@@ -10280,7 +10486,7 @@ function findSystemPaths(dir, source, target, opts = {}) {
|
|
|
10280
10486
|
walk(nxt, [...path5, nxt]);
|
|
10281
10487
|
}
|
|
10282
10488
|
};
|
|
10283
|
-
walk(
|
|
10489
|
+
walk(source2, [source2]);
|
|
10284
10490
|
return paths;
|
|
10285
10491
|
}
|
|
10286
10492
|
function getImpactCandidates(dir, seedIds, opts = {}) {
|
|
@@ -10881,7 +11087,7 @@ function deriveImplementationStatus(repos) {
|
|
|
10881
11087
|
// src/core/work-item-import.ts
|
|
10882
11088
|
import crypto3 from "crypto";
|
|
10883
11089
|
import fs5 from "fs";
|
|
10884
|
-
import
|
|
11090
|
+
import matter12 from "gray-matter";
|
|
10885
11091
|
var MAX_INPUT_BYTES = 102400;
|
|
10886
11092
|
var LIFECYCLE_FIELDS = /* @__PURE__ */ new Set([
|
|
10887
11093
|
"id",
|
|
@@ -10903,7 +11109,7 @@ function detectFormat(raw) {
|
|
|
10903
11109
|
if (!trimmed) throw new ImportError("EMPTY_INPUT", "Import content is empty.");
|
|
10904
11110
|
if (trimmed.startsWith("---")) {
|
|
10905
11111
|
try {
|
|
10906
|
-
const { data } =
|
|
11112
|
+
const { data } = matter12(trimmed);
|
|
10907
11113
|
if (data && typeof data === "object" && Object.keys(data).length > 0) {
|
|
10908
11114
|
const d = data;
|
|
10909
11115
|
if (d.type === "work-item" || d.id && typeof d.id === "string" && /^WI-\d+/.test(d.id)) {
|
|
@@ -10925,7 +11131,7 @@ function parseContent(raw) {
|
|
|
10925
11131
|
let bodyText = trimmed;
|
|
10926
11132
|
if (format === "kaddo-frontmatter" || format === "markdown-frontmatter") {
|
|
10927
11133
|
try {
|
|
10928
|
-
const parsed =
|
|
11134
|
+
const parsed = matter12(trimmed);
|
|
10929
11135
|
frontmatterFields = parsed.data ?? {};
|
|
10930
11136
|
bodyText = parsed.content.trim();
|
|
10931
11137
|
} catch {
|
|
@@ -10997,12 +11203,12 @@ function normalizeImportFields(parsed, opts) {
|
|
|
10997
11203
|
const intent = parsed.title;
|
|
10998
11204
|
const body = hasRealBody ? parsed.body : void 0;
|
|
10999
11205
|
const summary = hasRealBody ? deriveShortSummary(parsed) : parsed.title;
|
|
11000
|
-
const
|
|
11206
|
+
const source2 = {
|
|
11001
11207
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
11002
11208
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
11003
11209
|
};
|
|
11004
|
-
|
|
11005
|
-
|
|
11210
|
+
source2.source_format = opts.sourceFormat;
|
|
11211
|
+
source2.source_hash = opts.sourceHash;
|
|
11006
11212
|
const snapshot = { title: parsed.title };
|
|
11007
11213
|
if (summary !== parsed.title) snapshot.description = summary;
|
|
11008
11214
|
if (typeof parsed.candidateFields.type === "string") snapshot.type = parsed.candidateFields.type;
|
|
@@ -11011,7 +11217,7 @@ function normalizeImportFields(parsed, opts) {
|
|
|
11011
11217
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
11012
11218
|
if (labels.length > 0) snapshot.labels = labels;
|
|
11013
11219
|
}
|
|
11014
|
-
return { type, intent, summary, body, source, snapshot, discardedFields };
|
|
11220
|
+
return { type, intent, summary, body, source: source2, snapshot, discardedFields };
|
|
11015
11221
|
}
|
|
11016
11222
|
function computeContentHash(raw) {
|
|
11017
11223
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -11022,10 +11228,10 @@ function findDuplicateByHash(dir, hash) {
|
|
|
11022
11228
|
const raw = readFile(item.filePath);
|
|
11023
11229
|
if (!raw) continue;
|
|
11024
11230
|
try {
|
|
11025
|
-
const { data } =
|
|
11026
|
-
const
|
|
11027
|
-
if (
|
|
11028
|
-
const s =
|
|
11231
|
+
const { data } = matter12(raw);
|
|
11232
|
+
const source2 = data?.source;
|
|
11233
|
+
if (source2 && typeof source2 === "object" && !Array.isArray(source2)) {
|
|
11234
|
+
const s = source2;
|
|
11029
11235
|
if (s.source_hash === hash) {
|
|
11030
11236
|
return { workItemId: data.id ?? item.id ?? item.title, path: item.relPath };
|
|
11031
11237
|
}
|
|
@@ -11131,7 +11337,7 @@ var ImportError = class extends Error {
|
|
|
11131
11337
|
};
|
|
11132
11338
|
|
|
11133
11339
|
// src/services/integrations.ts
|
|
11134
|
-
import
|
|
11340
|
+
import matter13 from "gray-matter";
|
|
11135
11341
|
import { parse as parseYaml9, stringify as stringifyYaml6 } from "yaml";
|
|
11136
11342
|
|
|
11137
11343
|
// ../integrations/src/errors.ts
|
|
@@ -12473,12 +12679,12 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
12473
12679
|
for (const art of discoverWorkItems(dir)) {
|
|
12474
12680
|
let data;
|
|
12475
12681
|
try {
|
|
12476
|
-
data =
|
|
12682
|
+
data = matter13(readFile(art.filePath)).data;
|
|
12477
12683
|
} catch {
|
|
12478
12684
|
continue;
|
|
12479
12685
|
}
|
|
12480
|
-
const
|
|
12481
|
-
if (
|
|
12686
|
+
const source2 = parseWorkItemSource(data);
|
|
12687
|
+
if (source2.integration === integrationId && source2.id === externalId) {
|
|
12482
12688
|
return { workItemId: String(data.id ?? ""), title: String(data.title ?? "") };
|
|
12483
12689
|
}
|
|
12484
12690
|
}
|
|
@@ -12489,13 +12695,13 @@ function buildImportIndex(dir) {
|
|
|
12489
12695
|
for (const art of discoverWorkItems(dir)) {
|
|
12490
12696
|
let data;
|
|
12491
12697
|
try {
|
|
12492
|
-
data =
|
|
12698
|
+
data = matter13(readFile(art.filePath)).data;
|
|
12493
12699
|
} catch {
|
|
12494
12700
|
continue;
|
|
12495
12701
|
}
|
|
12496
|
-
const
|
|
12497
|
-
if (
|
|
12498
|
-
index.set(`${
|
|
12702
|
+
const source2 = parseWorkItemSource(data);
|
|
12703
|
+
if (source2.type === "external" && source2.integration && source2.id) {
|
|
12704
|
+
index.set(`${source2.integration}#${source2.id}`, { workItemId: String(data.id ?? ""), title: String(data.title ?? "") });
|
|
12499
12705
|
}
|
|
12500
12706
|
}
|
|
12501
12707
|
return index;
|
|
@@ -12665,7 +12871,7 @@ function getStatus(dir) {
|
|
|
12665
12871
|
}
|
|
12666
12872
|
|
|
12667
12873
|
// src/core/initiative-write.ts
|
|
12668
|
-
import
|
|
12874
|
+
import matter14 from "gray-matter";
|
|
12669
12875
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
12670
12876
|
var DRAFT_DIR = `${WORK_ITEMS_DIR2}/draft`;
|
|
12671
12877
|
var ROADMAP_PATH2 = "knowledge/delivery/roadmap.md";
|
|
@@ -12778,7 +12984,7 @@ function buildInitiativeContent(id, input) {
|
|
|
12778
12984
|
if (input.priority) data.priority = input.priority;
|
|
12779
12985
|
if (input.source) data.source = input.source;
|
|
12780
12986
|
if (input.sourceId) data.source_id = input.sourceId;
|
|
12781
|
-
return
|
|
12987
|
+
return matter14.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
|
|
12782
12988
|
}
|
|
12783
12989
|
function createInitiative(dir, input) {
|
|
12784
12990
|
if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
|
|
@@ -12802,10 +13008,10 @@ function transitionInitiative(dir, id, to) {
|
|
|
12802
13008
|
throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
|
|
12803
13009
|
}
|
|
12804
13010
|
const raw = readFile(ini.filePath);
|
|
12805
|
-
const { data, content } =
|
|
13011
|
+
const { data, content } = matter14(raw, {});
|
|
12806
13012
|
data.status = to;
|
|
12807
13013
|
if (to === "completed") data.completed_at = today();
|
|
12808
|
-
const newContent =
|
|
13014
|
+
const newContent = matter14.stringify(content, data);
|
|
12809
13015
|
writeFile(ini.filePath, newContent);
|
|
12810
13016
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
12811
13017
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
|
|
@@ -12815,7 +13021,7 @@ function addCandidate(dir, id, candidate) {
|
|
|
12815
13021
|
const ini = getInitiative(dir, id);
|
|
12816
13022
|
if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
|
|
12817
13023
|
const raw = readFile(ini.filePath);
|
|
12818
|
-
const { data, content } =
|
|
13024
|
+
const { data, content } = matter14(raw, {});
|
|
12819
13025
|
const existing = Array.isArray(data.candidates) ? data.candidates : [];
|
|
12820
13026
|
const fallbackId = `WI-CANDIDATE-${String(existing.length + 1).padStart(3, "0")}`;
|
|
12821
13027
|
const normalized = normalizeCandidate(candidate, fallbackId);
|
|
@@ -12823,7 +13029,7 @@ function addCandidate(dir, id, candidate) {
|
|
|
12823
13029
|
throw new InitiativeWriteError(`Candidate ${normalized.id} already exists in ${id}.`);
|
|
12824
13030
|
}
|
|
12825
13031
|
data.candidates = [...existing, candidateToData(normalized)];
|
|
12826
|
-
const newContent =
|
|
13032
|
+
const newContent = matter14.stringify(content, data);
|
|
12827
13033
|
writeFile(ini.filePath, newContent);
|
|
12828
13034
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
12829
13035
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after adding a candidate.");
|
|
@@ -12833,7 +13039,7 @@ function updateInitiative(dir, id, patch) {
|
|
|
12833
13039
|
const ini = getInitiative(dir, id);
|
|
12834
13040
|
if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
|
|
12835
13041
|
const raw = readFile(ini.filePath);
|
|
12836
|
-
const { data, content } =
|
|
13042
|
+
const { data, content } = matter14(raw, {});
|
|
12837
13043
|
if (patch.title !== void 0) {
|
|
12838
13044
|
if (!patch.title.trim()) throw new InitiativeWriteError("Initiative title cannot be empty.");
|
|
12839
13045
|
data.title = patch.title.trim();
|
|
@@ -12843,7 +13049,7 @@ function updateInitiative(dir, id, patch) {
|
|
|
12843
13049
|
if (patch.knowledgeLevel !== void 0) data.knowledge_level = patch.knowledgeLevel;
|
|
12844
13050
|
if (patch.domains !== void 0) data.domains = patch.domains;
|
|
12845
13051
|
if (patch.relatedCapabilities !== void 0) data.related_capabilities = patch.relatedCapabilities;
|
|
12846
|
-
const newContent =
|
|
13052
|
+
const newContent = matter14.stringify(content, data);
|
|
12847
13053
|
writeFile(ini.filePath, newContent);
|
|
12848
13054
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
12849
13055
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after update.");
|
|
@@ -12861,10 +13067,10 @@ function addExternalLink(dir, id, link) {
|
|
|
12861
13067
|
throw new InitiativeWriteError(`External link ${link.integration}:${link.externalId} already exists on ${id}.`);
|
|
12862
13068
|
}
|
|
12863
13069
|
const raw = readFile(ini.filePath);
|
|
12864
|
-
const { data, content } =
|
|
13070
|
+
const { data, content } = matter14(raw, {});
|
|
12865
13071
|
const existing = Array.isArray(data.external_links) ? data.external_links : [];
|
|
12866
13072
|
data.external_links = [...existing, externalLinkToData(link)];
|
|
12867
|
-
const newContent =
|
|
13073
|
+
const newContent = matter14.stringify(content, data);
|
|
12868
13074
|
writeFile(ini.filePath, newContent);
|
|
12869
13075
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
12870
13076
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after adding an external link.");
|
|
@@ -12933,7 +13139,7 @@ function buildWorkItemContent(wiId, iniId, candidate) {
|
|
|
12933
13139
|
"_What did we learn? Update after completion._",
|
|
12934
13140
|
""
|
|
12935
13141
|
].join("\n");
|
|
12936
|
-
return
|
|
13142
|
+
return matter14.stringify("\n" + body, data);
|
|
12937
13143
|
}
|
|
12938
13144
|
function materializeCandidate(dir, id, candidateId) {
|
|
12939
13145
|
const ini = getInitiative(dir, id);
|
|
@@ -12950,13 +13156,13 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
12950
13156
|
ensureDir(join(dir, DRAFT_DIR));
|
|
12951
13157
|
writeFile(join(dir, DRAFT_DIR, fileName), buildWorkItemContent(wiId, ini.id, candidate));
|
|
12952
13158
|
const raw = readFile(ini.filePath);
|
|
12953
|
-
const { data, content } =
|
|
13159
|
+
const { data, content } = matter14(raw, {});
|
|
12954
13160
|
const cands = Array.isArray(data.candidates) ? data.candidates : [];
|
|
12955
13161
|
for (const c of cands) {
|
|
12956
13162
|
if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
|
|
12957
13163
|
}
|
|
12958
13164
|
data.candidates = cands;
|
|
12959
|
-
const newContent =
|
|
13165
|
+
const newContent = matter14.stringify(content, data);
|
|
12960
13166
|
writeFile(ini.filePath, newContent);
|
|
12961
13167
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
12962
13168
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
|
|
@@ -13115,6 +13321,7 @@ export {
|
|
|
13115
13321
|
IntegrationError,
|
|
13116
13322
|
IntegrationServiceError,
|
|
13117
13323
|
POC_ARTIFACT_PATH,
|
|
13324
|
+
POC_REPORT_PREFIX,
|
|
13118
13325
|
RESOURCE_ARTIFACT_TYPE,
|
|
13119
13326
|
RESOURCE_ROLES,
|
|
13120
13327
|
RESOURCE_TYPES,
|
|
@@ -13134,6 +13341,7 @@ export {
|
|
|
13134
13341
|
associatedWorkItems,
|
|
13135
13342
|
buildImplementationHandoff,
|
|
13136
13343
|
buildImportIndex,
|
|
13344
|
+
buildPocReportContext,
|
|
13137
13345
|
buildProjectExplanation,
|
|
13138
13346
|
buildProjectRoute,
|
|
13139
13347
|
buildReadinessReport,
|
|
@@ -13216,10 +13424,12 @@ export {
|
|
|
13216
13424
|
parseSuccessCriteria,
|
|
13217
13425
|
parseWorkItemResources,
|
|
13218
13426
|
persistConsent,
|
|
13427
|
+
persistPocReport,
|
|
13219
13428
|
previewImport,
|
|
13220
13429
|
projectMode,
|
|
13221
13430
|
readFile,
|
|
13222
13431
|
readPocSummary,
|
|
13432
|
+
redactSecrets,
|
|
13223
13433
|
removeIntegrationSecret,
|
|
13224
13434
|
searchSystemNodes,
|
|
13225
13435
|
setIntegrationSecret,
|