@kaddo/cli 3.112.0 → 3.112.2
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/core.js +38 -5
- package/dist/index.js +38 -5
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -9253,6 +9253,25 @@ ${body}`);
|
|
|
9253
9253
|
${out.join("\n\n")}
|
|
9254
9254
|
`.replace(/\n{3,}/g, "\n\n");
|
|
9255
9255
|
}
|
|
9256
|
+
function importedBody(title, type, sourceBody) {
|
|
9257
|
+
const lines = sourceBody.split(/\r?\n/);
|
|
9258
|
+
let i = 0;
|
|
9259
|
+
while (i < lines.length && !lines[i].trim()) i++;
|
|
9260
|
+
if (i < lines.length && /^#\s+/.test(lines[i])) {
|
|
9261
|
+
i++;
|
|
9262
|
+
while (i < lines.length && !lines[i].trim()) i++;
|
|
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
|
+
`;
|
|
9274
|
+
}
|
|
9256
9275
|
function applyFrontmatter(data, input) {
|
|
9257
9276
|
const next = { ...data };
|
|
9258
9277
|
next.title = input.title;
|
|
@@ -9391,6 +9410,7 @@ function createWorkItem(dir, opts) {
|
|
|
9391
9410
|
if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
|
|
9392
9411
|
const id = nextWorkItemId(dir);
|
|
9393
9412
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
9413
|
+
const summary = opts.summary?.trim() ? opts.summary.trim() : intent;
|
|
9394
9414
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
9395
9415
|
const source = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
9396
9416
|
const data = {
|
|
@@ -9403,12 +9423,12 @@ function createWorkItem(dir, opts) {
|
|
|
9403
9423
|
source,
|
|
9404
9424
|
generated_by: "kaddo-admin",
|
|
9405
9425
|
affected_modules: [],
|
|
9406
|
-
summary
|
|
9426
|
+
summary
|
|
9407
9427
|
};
|
|
9408
9428
|
if (opts.originalSnapshot) data.original_snapshot = opts.originalSnapshot;
|
|
9409
9429
|
const answers = opts.answers ?? {};
|
|
9410
9430
|
const hasAnswers = Object.values(answers).some((v) => v?.trim());
|
|
9411
|
-
const body = hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
9431
|
+
const body = opts.body?.trim() ? importedBody(title, type, opts.body) : hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
9412
9432
|
title,
|
|
9413
9433
|
type,
|
|
9414
9434
|
summary: intent,
|
|
@@ -10401,7 +10421,7 @@ function parseContent(raw) {
|
|
|
10401
10421
|
const title = extractTitle(frontmatterFields, bodyText);
|
|
10402
10422
|
const candidateType = extractType(frontmatterFields);
|
|
10403
10423
|
const sections = extractSections(bodyText);
|
|
10404
|
-
const summary = bodyText
|
|
10424
|
+
const summary = deriveSummary(bodyText, title);
|
|
10405
10425
|
return {
|
|
10406
10426
|
format,
|
|
10407
10427
|
title,
|
|
@@ -10421,6 +10441,16 @@ function extractTitle(fields, body) {
|
|
|
10421
10441
|
const firstLine = body.split(/\r?\n/).find((l) => l.trim());
|
|
10422
10442
|
return (firstLine?.trim() ?? "Untitled Work Item").slice(0, 120);
|
|
10423
10443
|
}
|
|
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
|
+
}
|
|
10424
10454
|
function extractType(fields) {
|
|
10425
10455
|
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;
|
|
10426
10456
|
if (!raw) return void 0;
|
|
@@ -10458,6 +10488,7 @@ function normalizeImportFields(parsed, opts) {
|
|
|
10458
10488
|
const intent = parsed.body && parsed.body !== parsed.title ? `${parsed.title}
|
|
10459
10489
|
|
|
10460
10490
|
${parsed.body}` : parsed.title;
|
|
10491
|
+
const body = parsed.body && parsed.body.trim() !== parsed.title.trim() ? parsed.body : void 0;
|
|
10461
10492
|
const source = {
|
|
10462
10493
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
10463
10494
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
@@ -10472,7 +10503,7 @@ ${parsed.body}` : parsed.title;
|
|
|
10472
10503
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
10473
10504
|
if (labels.length > 0) snapshot.labels = labels;
|
|
10474
10505
|
}
|
|
10475
|
-
return { type, intent, source, snapshot, discardedFields };
|
|
10506
|
+
return { type, intent, summary: parsed.summary, body, source, snapshot, discardedFields };
|
|
10476
10507
|
}
|
|
10477
10508
|
function computeContentHash(raw) {
|
|
10478
10509
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -10559,7 +10590,9 @@ function importWorkItem(dir, opts) {
|
|
|
10559
10590
|
intent: normalized.intent,
|
|
10560
10591
|
type: normalized.type,
|
|
10561
10592
|
source: normalized.source,
|
|
10562
|
-
originalSnapshot: normalized.snapshot
|
|
10593
|
+
originalSnapshot: normalized.snapshot,
|
|
10594
|
+
summary: normalized.summary,
|
|
10595
|
+
body: normalized.body
|
|
10563
10596
|
});
|
|
10564
10597
|
let refinementHandoff;
|
|
10565
10598
|
try {
|
package/dist/index.js
CHANGED
|
@@ -18095,6 +18095,25 @@ ${body}`);
|
|
|
18095
18095
|
${out.join("\n\n")}
|
|
18096
18096
|
`.replace(/\n{3,}/g, "\n\n");
|
|
18097
18097
|
}
|
|
18098
|
+
function importedBody(title, type, sourceBody) {
|
|
18099
|
+
const lines = sourceBody.split(/\r?\n/);
|
|
18100
|
+
let i = 0;
|
|
18101
|
+
while (i < lines.length && !lines[i].trim()) i++;
|
|
18102
|
+
if (i < lines.length && /^#\s+/.test(lines[i])) {
|
|
18103
|
+
i++;
|
|
18104
|
+
while (i < lines.length && !lines[i].trim()) i++;
|
|
18105
|
+
if (i < lines.length && /^>\s*Type:/i.test(lines[i])) i++;
|
|
18106
|
+
}
|
|
18107
|
+
const rest = lines.slice(i).join("\n").trim();
|
|
18108
|
+
const preamble = `# ${title}
|
|
18109
|
+
|
|
18110
|
+
> Type: ${type}`;
|
|
18111
|
+
return rest ? `${preamble}
|
|
18112
|
+
|
|
18113
|
+
${rest}
|
|
18114
|
+
` : `${preamble}
|
|
18115
|
+
`;
|
|
18116
|
+
}
|
|
18098
18117
|
function serialize(data, body) {
|
|
18099
18118
|
return matter11.stringify(`
|
|
18100
18119
|
${body.trim()}
|
|
@@ -18129,6 +18148,7 @@ function createWorkItem(dir, opts) {
|
|
|
18129
18148
|
if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
|
|
18130
18149
|
const id = nextWorkItemId2(dir);
|
|
18131
18150
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
18151
|
+
const summary = opts.summary?.trim() ? opts.summary.trim() : intent;
|
|
18132
18152
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
18133
18153
|
const source = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
18134
18154
|
const data = {
|
|
@@ -18141,12 +18161,12 @@ function createWorkItem(dir, opts) {
|
|
|
18141
18161
|
source,
|
|
18142
18162
|
generated_by: "kaddo-admin",
|
|
18143
18163
|
affected_modules: [],
|
|
18144
|
-
summary
|
|
18164
|
+
summary
|
|
18145
18165
|
};
|
|
18146
18166
|
if (opts.originalSnapshot) data.original_snapshot = opts.originalSnapshot;
|
|
18147
18167
|
const answers = opts.answers ?? {};
|
|
18148
18168
|
const hasAnswers = Object.values(answers).some((v) => v?.trim());
|
|
18149
|
-
const body = hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
18169
|
+
const body = opts.body?.trim() ? importedBody(title, type, opts.body) : hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
18150
18170
|
title,
|
|
18151
18171
|
type,
|
|
18152
18172
|
summary: intent,
|
|
@@ -21530,7 +21550,7 @@ function parseContent(raw) {
|
|
|
21530
21550
|
const title = extractTitle(frontmatterFields, bodyText);
|
|
21531
21551
|
const candidateType = extractType(frontmatterFields);
|
|
21532
21552
|
const sections = extractSections(bodyText);
|
|
21533
|
-
const summary = bodyText
|
|
21553
|
+
const summary = deriveSummary(bodyText, title);
|
|
21534
21554
|
return {
|
|
21535
21555
|
format,
|
|
21536
21556
|
title,
|
|
@@ -21550,6 +21570,16 @@ function extractTitle(fields, body) {
|
|
|
21550
21570
|
const firstLine = body.split(/\r?\n/).find((l) => l.trim());
|
|
21551
21571
|
return (firstLine?.trim() ?? "Untitled Work Item").slice(0, 120);
|
|
21552
21572
|
}
|
|
21573
|
+
function deriveSummary(body, title) {
|
|
21574
|
+
for (const line of body.split(/\r?\n/)) {
|
|
21575
|
+
const t = line.trim();
|
|
21576
|
+
if (!t) continue;
|
|
21577
|
+
if (/^#{1,6}\s/.test(t)) continue;
|
|
21578
|
+
if (/^>/.test(t)) continue;
|
|
21579
|
+
return t.slice(0, 280);
|
|
21580
|
+
}
|
|
21581
|
+
return title;
|
|
21582
|
+
}
|
|
21553
21583
|
function extractType(fields) {
|
|
21554
21584
|
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;
|
|
21555
21585
|
if (!raw) return void 0;
|
|
@@ -21587,6 +21617,7 @@ function normalizeImportFields(parsed, opts) {
|
|
|
21587
21617
|
const intent = parsed.body && parsed.body !== parsed.title ? `${parsed.title}
|
|
21588
21618
|
|
|
21589
21619
|
${parsed.body}` : parsed.title;
|
|
21620
|
+
const body = parsed.body && parsed.body.trim() !== parsed.title.trim() ? parsed.body : void 0;
|
|
21590
21621
|
const source = {
|
|
21591
21622
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
21592
21623
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
@@ -21601,7 +21632,7 @@ ${parsed.body}` : parsed.title;
|
|
|
21601
21632
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
21602
21633
|
if (labels.length > 0) snapshot.labels = labels;
|
|
21603
21634
|
}
|
|
21604
|
-
return { type, intent, source, snapshot, discardedFields };
|
|
21635
|
+
return { type, intent, summary: parsed.summary, body, source, snapshot, discardedFields };
|
|
21605
21636
|
}
|
|
21606
21637
|
function computeContentHash(raw) {
|
|
21607
21638
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -21688,7 +21719,9 @@ function importWorkItem(dir, opts) {
|
|
|
21688
21719
|
intent: normalized.intent,
|
|
21689
21720
|
type: normalized.type,
|
|
21690
21721
|
source: normalized.source,
|
|
21691
|
-
originalSnapshot: normalized.snapshot
|
|
21722
|
+
originalSnapshot: normalized.snapshot,
|
|
21723
|
+
summary: normalized.summary,
|
|
21724
|
+
body: normalized.body
|
|
21692
21725
|
});
|
|
21693
21726
|
let refinementHandoff;
|
|
21694
21727
|
try {
|