@kaddo/cli 3.54.0 → 3.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5378,6 +5378,42 @@ function domainsFromRelated(domain) {
|
|
|
5378
5378
|
var WORK_ITEMS_DIR = "knowledge/delivery/work-items";
|
|
5379
5379
|
var DRAFT_DIR = `${WORK_ITEMS_DIR}/draft`;
|
|
5380
5380
|
var ROADMAP_PATH = "knowledge/delivery/roadmap.md";
|
|
5381
|
+
function ensureWorkItemsDir(dir) {
|
|
5382
|
+
if (exists(join(dir, WORK_ITEMS_DIR))) return;
|
|
5383
|
+
if (!exists(join(dir, ".kaddo", "config.yml"))) {
|
|
5384
|
+
log2.warn("Kaddo is not initialized. Run `kaddo init` first.");
|
|
5385
|
+
process.exit(1);
|
|
5386
|
+
}
|
|
5387
|
+
ensureDir(join(dir, WORK_ITEMS_DIR));
|
|
5388
|
+
log2.info(`Created ${WORK_ITEMS_DIR}/`);
|
|
5389
|
+
}
|
|
5390
|
+
async function collectAcceptanceCriteria() {
|
|
5391
|
+
const criteria = [];
|
|
5392
|
+
while (true) {
|
|
5393
|
+
const criterion = await text2({
|
|
5394
|
+
message: criteria.length === 0 ? "Acceptance criterion" : "Acceptance criterion",
|
|
5395
|
+
placeholder: "e.g. Users see confirmation after checkout",
|
|
5396
|
+
validate: (v) => criteria.length === 0 && v.trim().length === 0 ? "At least one criterion is required." : void 0
|
|
5397
|
+
});
|
|
5398
|
+
const trimmed = criterion.trim();
|
|
5399
|
+
if (!trimmed && criteria.length > 0) break;
|
|
5400
|
+
if (trimmed.includes(";")) {
|
|
5401
|
+
criteria.push(...trimmed.split(";").map((s) => s.trim()).filter(Boolean));
|
|
5402
|
+
} else {
|
|
5403
|
+
criteria.push(trimmed);
|
|
5404
|
+
}
|
|
5405
|
+
const addMore = await confirm2({ message: "Add another acceptance criterion?" });
|
|
5406
|
+
if (!addMore) break;
|
|
5407
|
+
}
|
|
5408
|
+
return criteria.join("\n");
|
|
5409
|
+
}
|
|
5410
|
+
function renderAcceptanceCriteria(raw) {
|
|
5411
|
+
const items = raw.split(/\n|;/).map((l) => l.trim()).filter(Boolean);
|
|
5412
|
+
return items.map((item) => {
|
|
5413
|
+
const normalized = item.endsWith(".") ? item : `${item}.`;
|
|
5414
|
+
return `- [ ] ${normalized.charAt(0).toUpperCase() + normalized.slice(1)}`;
|
|
5415
|
+
}).join("\n");
|
|
5416
|
+
}
|
|
5381
5417
|
function printStateGuidance(dir) {
|
|
5382
5418
|
let config;
|
|
5383
5419
|
try {
|
|
@@ -5426,11 +5462,16 @@ function buildFrontMatter(id, type, level, title, answers) {
|
|
|
5426
5462
|
`knowledge_level: ${level}`,
|
|
5427
5463
|
`status: draft`,
|
|
5428
5464
|
`phase: now`,
|
|
5465
|
+
`work_type: ${type}`,
|
|
5429
5466
|
`initiative:`,
|
|
5430
5467
|
`domains: []`,
|
|
5431
5468
|
`code: []`,
|
|
5432
5469
|
`created_at: ${today2}`,
|
|
5433
|
-
`source
|
|
5470
|
+
`source:`,
|
|
5471
|
+
` type: manual`,
|
|
5472
|
+
` inferred: false`,
|
|
5473
|
+
`generated_by: kaddo-create`,
|
|
5474
|
+
`template_version: 1`,
|
|
5434
5475
|
`summary: "${answers.problem?.split(".")[0] ?? title}"`,
|
|
5435
5476
|
"---"
|
|
5436
5477
|
];
|
|
@@ -5461,10 +5502,9 @@ ${answers.impact}
|
|
|
5461
5502
|
`);
|
|
5462
5503
|
}
|
|
5463
5504
|
if (answers.acceptance_criteria) {
|
|
5464
|
-
const items = answers.acceptance_criteria.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
5465
5505
|
sections.push(`## Acceptance criteria
|
|
5466
5506
|
|
|
5467
|
-
${
|
|
5507
|
+
${renderAcceptanceCriteria(answers.acceptance_criteria)}
|
|
5468
5508
|
`);
|
|
5469
5509
|
}
|
|
5470
5510
|
if (answers.design) {
|
|
@@ -5587,6 +5627,7 @@ async function runCreate(type, opts = {}) {
|
|
|
5587
5627
|
intro2(`kaddo create ${workItemType}`);
|
|
5588
5628
|
log2.info(`Knowledge level: ${level} \u2014 ${levelDef.description}`);
|
|
5589
5629
|
printStateGuidance(dir);
|
|
5630
|
+
ensureWorkItemsDir(dir);
|
|
5590
5631
|
const title = await text2({
|
|
5591
5632
|
message: "Title for this work item",
|
|
5592
5633
|
placeholder: `e.g. ${workItemType === "feature" ? "Add email verification to checkout" : workItemType === "hotfix" ? "Fix null pointer in payment handler" : workItemType === "bugfix" ? "Fix broken pagination on orders list" : workItemType === "chore" ? "Configure Vitest and CI pipeline" : "Explore caching strategies for API responses"}`,
|
|
@@ -5594,6 +5635,10 @@ async function runCreate(type, opts = {}) {
|
|
|
5594
5635
|
});
|
|
5595
5636
|
const answers = {};
|
|
5596
5637
|
for (const question of levelDef.questions) {
|
|
5638
|
+
if (question.frontMatterField === "acceptance_criteria") {
|
|
5639
|
+
answers.acceptance_criteria = await collectAcceptanceCriteria();
|
|
5640
|
+
continue;
|
|
5641
|
+
}
|
|
5597
5642
|
const answer = await text2({
|
|
5598
5643
|
message: question.prompt,
|
|
5599
5644
|
placeholder: question.placeholder,
|
|
@@ -5610,10 +5655,6 @@ async function runCreate(type, opts = {}) {
|
|
|
5610
5655
|
const content = `${frontMatter2}
|
|
5611
5656
|
|
|
5612
5657
|
${body}`;
|
|
5613
|
-
if (!exists(join(dir, WORK_ITEMS_DIR))) {
|
|
5614
|
-
log2.warn(`${WORK_ITEMS_DIR}/ not found. Run \`kaddo init\` first.`);
|
|
5615
|
-
process.exit(1);
|
|
5616
|
-
}
|
|
5617
5658
|
writeFile(filePath, content);
|
|
5618
5659
|
log2.success(`Created ${DRAFT_DIR}/${fileName}`);
|
|
5619
5660
|
log2.info(`New Work Items start in \`draft\`. Move to \`ready\` when scope and acceptance are set.`);
|
|
@@ -5624,10 +5665,7 @@ async function runCreateModule(dir, modType) {
|
|
|
5624
5665
|
intro2(`kaddo create ${modType.name}`);
|
|
5625
5666
|
log2.info(`Knowledge level: ${modType.knowledgeLevel} \u2014 ${modType.description}`);
|
|
5626
5667
|
printStateGuidance(dir);
|
|
5627
|
-
|
|
5628
|
-
log2.warn(`${WORK_ITEMS_DIR}/ not found. Run \`kaddo init\` first.`);
|
|
5629
|
-
process.exit(1);
|
|
5630
|
-
}
|
|
5668
|
+
ensureWorkItemsDir(dir);
|
|
5631
5669
|
const title = await text2({
|
|
5632
5670
|
message: "Title for this work item",
|
|
5633
5671
|
placeholder: `e.g. ${modType.questions[0]?.placeholder ?? modType.description}`,
|
|
@@ -5764,10 +5802,9 @@ ${formatList(candidate.sourceSignals)}`);
|
|
|
5764
5802
|
${ctx.join("\n\n")}
|
|
5765
5803
|
`);
|
|
5766
5804
|
if (answers.acceptance_criteria) {
|
|
5767
|
-
const items = answers.acceptance_criteria.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
5768
5805
|
sections.push(`## Acceptance Criteria
|
|
5769
5806
|
|
|
5770
|
-
${
|
|
5807
|
+
${renderAcceptanceCriteria(answers.acceptance_criteria)}
|
|
5771
5808
|
`);
|
|
5772
5809
|
}
|
|
5773
5810
|
if (answers.design) sections.push(`## Design
|
|
@@ -5821,10 +5858,7 @@ ${body}` };
|
|
|
5821
5858
|
}
|
|
5822
5859
|
async function runCreateFromRoadmap(dir, cliType) {
|
|
5823
5860
|
intro2("kaddo create --from roadmap");
|
|
5824
|
-
|
|
5825
|
-
log2.warn(`${WORK_ITEMS_DIR}/ not found. Run \`kaddo init\` first.`);
|
|
5826
|
-
process.exit(1);
|
|
5827
|
-
}
|
|
5861
|
+
ensureWorkItemsDir(dir);
|
|
5828
5862
|
const roadmapFull = join(dir, ROADMAP_PATH);
|
|
5829
5863
|
if (!exists(roadmapFull)) {
|
|
5830
5864
|
console.error(`No roadmap found at ${ROADMAP_PATH}.`);
|