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