@kaddo/cli 3.112.2 → 3.114.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 +199 -452
- package/dist/core.js +26 -41
- package/dist/index.js +117 -116
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -9253,24 +9253,13 @@ ${body}`);
|
|
|
9253
9253
|
${out.join("\n\n")}
|
|
9254
9254
|
`.replace(/\n{3,}/g, "\n\n");
|
|
9255
9255
|
}
|
|
9256
|
-
function
|
|
9257
|
-
const
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
if (i < lines.length && /^>\s*Type:/i.test(lines[i])) i++;
|
|
9264
|
-
}
|
|
9265
|
-
const rest = lines.slice(i).join("\n").trim();
|
|
9266
|
-
const preamble = `# ${title}
|
|
9267
|
-
|
|
9268
|
-
> Type: ${type}`;
|
|
9269
|
-
return rest ? `${preamble}
|
|
9270
|
-
|
|
9271
|
-
${rest}
|
|
9272
|
-
` : `${preamble}
|
|
9273
|
-
`;
|
|
9256
|
+
function ensureH1(body, title) {
|
|
9257
|
+
const trimmed = body.trim();
|
|
9258
|
+
const firstMeaningful = trimmed.split(/\r?\n/).find((l) => l.trim());
|
|
9259
|
+
if (firstMeaningful && /^#\s+/.test(firstMeaningful.trim())) return trimmed;
|
|
9260
|
+
return `# ${title}
|
|
9261
|
+
|
|
9262
|
+
${trimmed}`;
|
|
9274
9263
|
}
|
|
9275
9264
|
function applyFrontmatter(data, input) {
|
|
9276
9265
|
const next = { ...data };
|
|
@@ -9410,8 +9399,8 @@ function createWorkItem(dir, opts) {
|
|
|
9410
9399
|
if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
|
|
9411
9400
|
const id = nextWorkItemId(dir);
|
|
9412
9401
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
9413
|
-
const summary = opts.summary?.trim() ? opts.summary.trim() : intent;
|
|
9414
9402
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
9403
|
+
const summary = opts.summary?.trim() || intent;
|
|
9415
9404
|
const source = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
9416
9405
|
const data = {
|
|
9417
9406
|
type,
|
|
@@ -9428,10 +9417,11 @@ function createWorkItem(dir, opts) {
|
|
|
9428
9417
|
if (opts.originalSnapshot) data.original_snapshot = opts.originalSnapshot;
|
|
9429
9418
|
const answers = opts.answers ?? {};
|
|
9430
9419
|
const hasAnswers = Object.values(answers).some((v) => v?.trim());
|
|
9431
|
-
const
|
|
9420
|
+
const providedBody = opts.body?.trim();
|
|
9421
|
+
const body = providedBody ? ensureH1(providedBody, title) : hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
9432
9422
|
title,
|
|
9433
9423
|
type,
|
|
9434
|
-
summary
|
|
9424
|
+
summary,
|
|
9435
9425
|
scopeUnknowns: [],
|
|
9436
9426
|
affectedModules: [],
|
|
9437
9427
|
moduleCoverage: [],
|
|
@@ -10421,7 +10411,7 @@ function parseContent(raw) {
|
|
|
10421
10411
|
const title = extractTitle(frontmatterFields, bodyText);
|
|
10422
10412
|
const candidateType = extractType(frontmatterFields);
|
|
10423
10413
|
const sections = extractSections(bodyText);
|
|
10424
|
-
const summary =
|
|
10414
|
+
const summary = bodyText || title;
|
|
10425
10415
|
return {
|
|
10426
10416
|
format,
|
|
10427
10417
|
title,
|
|
@@ -10441,16 +10431,6 @@ function extractTitle(fields, body) {
|
|
|
10441
10431
|
const firstLine = body.split(/\r?\n/).find((l) => l.trim());
|
|
10442
10432
|
return (firstLine?.trim() ?? "Untitled Work Item").slice(0, 120);
|
|
10443
10433
|
}
|
|
10444
|
-
function deriveSummary(body, title) {
|
|
10445
|
-
for (const line of body.split(/\r?\n/)) {
|
|
10446
|
-
const t = line.trim();
|
|
10447
|
-
if (!t) continue;
|
|
10448
|
-
if (/^#{1,6}\s/.test(t)) continue;
|
|
10449
|
-
if (/^>/.test(t)) continue;
|
|
10450
|
-
return t.slice(0, 280);
|
|
10451
|
-
}
|
|
10452
|
-
return title;
|
|
10453
|
-
}
|
|
10454
10434
|
function extractType(fields) {
|
|
10455
10435
|
const raw = typeof fields.work_type === "string" && fields.work_type.trim() ? fields.work_type.trim() : typeof fields.type === "string" && fields.type.trim() && fields.type !== "work-item" ? fields.type.trim() : void 0;
|
|
10456
10436
|
if (!raw) return void 0;
|
|
@@ -10479,16 +10459,21 @@ function extractSections(body) {
|
|
|
10479
10459
|
flush();
|
|
10480
10460
|
return sections;
|
|
10481
10461
|
}
|
|
10462
|
+
function deriveShortSummary(parsed) {
|
|
10463
|
+
const paragraph = parsed.body.split(/\n{2,}/).map((p) => p.trim()).find((p) => p && !/^#{1,6}\s/.test(p) && !/^>/.test(p) && p !== parsed.title);
|
|
10464
|
+
const base = paragraph ? paragraph.replace(/\s+/g, " ") : parsed.title;
|
|
10465
|
+
return base.length > 280 ? `${base.slice(0, 277).trimEnd()}\u2026` : base;
|
|
10466
|
+
}
|
|
10482
10467
|
function normalizeImportFields(parsed, opts) {
|
|
10483
10468
|
const discardedFields = [];
|
|
10484
10469
|
for (const key of Object.keys(parsed.candidateFields)) {
|
|
10485
10470
|
if (LIFECYCLE_FIELDS.has(key)) discardedFields.push(key);
|
|
10486
10471
|
}
|
|
10487
10472
|
const type = opts.userType ? normalizeType(opts.userType) ?? "feature" : parsed.type ?? "feature";
|
|
10488
|
-
const
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
const
|
|
10473
|
+
const hasRealBody = !!parsed.body && parsed.body !== parsed.title;
|
|
10474
|
+
const intent = parsed.title;
|
|
10475
|
+
const body = hasRealBody ? parsed.body : void 0;
|
|
10476
|
+
const summary = hasRealBody ? deriveShortSummary(parsed) : parsed.title;
|
|
10492
10477
|
const source = {
|
|
10493
10478
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
10494
10479
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
@@ -10496,14 +10481,14 @@ ${parsed.body}` : parsed.title;
|
|
|
10496
10481
|
source.source_format = opts.sourceFormat;
|
|
10497
10482
|
source.source_hash = opts.sourceHash;
|
|
10498
10483
|
const snapshot = { title: parsed.title };
|
|
10499
|
-
if (
|
|
10484
|
+
if (summary !== parsed.title) snapshot.description = summary;
|
|
10500
10485
|
if (typeof parsed.candidateFields.type === "string") snapshot.type = parsed.candidateFields.type;
|
|
10501
10486
|
if (typeof parsed.candidateFields.status === "string") snapshot.status = parsed.candidateFields.status;
|
|
10502
10487
|
if (Array.isArray(parsed.candidateFields.labels)) {
|
|
10503
10488
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
10504
10489
|
if (labels.length > 0) snapshot.labels = labels;
|
|
10505
10490
|
}
|
|
10506
|
-
return { type, intent, summary
|
|
10491
|
+
return { type, intent, summary, body, source, snapshot, discardedFields };
|
|
10507
10492
|
}
|
|
10508
10493
|
function computeContentHash(raw) {
|
|
10509
10494
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -10589,10 +10574,10 @@ function importWorkItem(dir, opts) {
|
|
|
10589
10574
|
const result = createWorkItem(dir, {
|
|
10590
10575
|
intent: normalized.intent,
|
|
10591
10576
|
type: normalized.type,
|
|
10592
|
-
source: normalized.source,
|
|
10593
|
-
originalSnapshot: normalized.snapshot,
|
|
10594
10577
|
summary: normalized.summary,
|
|
10595
|
-
body: normalized.body
|
|
10578
|
+
body: normalized.body,
|
|
10579
|
+
source: normalized.source,
|
|
10580
|
+
originalSnapshot: normalized.snapshot
|
|
10596
10581
|
});
|
|
10597
10582
|
let refinementHandoff;
|
|
10598
10583
|
try {
|