@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/index.js
CHANGED
|
@@ -1390,8 +1390,8 @@ function loadConfig(dir) {
|
|
|
1390
1390
|
const parsed = configSchema.safeParse(raw ?? {});
|
|
1391
1391
|
if (!parsed.success) {
|
|
1392
1392
|
const issues = parsed.error.issues.map((i) => {
|
|
1393
|
-
const
|
|
1394
|
-
return
|
|
1393
|
+
const path12 = i.path.join(".");
|
|
1394
|
+
return path12 ? ` - ${path12}: ${i.message}` : ` - ${i.message}`;
|
|
1395
1395
|
}).join("\n");
|
|
1396
1396
|
throw new ConfigError(`Invalid .kaddo/config.yml:
|
|
1397
1397
|
${issues}`);
|
|
@@ -7044,10 +7044,10 @@ function analyzeGuard(touchedFiles, artifacts, silentWithoutOwnership) {
|
|
|
7044
7044
|
import { parse as parseYaml5, stringify as stringifyYaml3 } from "yaml";
|
|
7045
7045
|
var IGNORE_FILE = ".kaddo/ignores.yml";
|
|
7046
7046
|
function loadIgnores(dir) {
|
|
7047
|
-
const
|
|
7048
|
-
if (!exists(
|
|
7047
|
+
const path12 = join(dir, IGNORE_FILE);
|
|
7048
|
+
if (!exists(path12)) return [];
|
|
7049
7049
|
try {
|
|
7050
|
-
const raw = readFile(
|
|
7050
|
+
const raw = readFile(path12);
|
|
7051
7051
|
const parsed = parseYaml5(raw);
|
|
7052
7052
|
return Array.isArray(parsed) ? parsed : [];
|
|
7053
7053
|
} catch {
|
|
@@ -7055,7 +7055,7 @@ function loadIgnores(dir) {
|
|
|
7055
7055
|
}
|
|
7056
7056
|
}
|
|
7057
7057
|
function saveIgnore(dir, entry) {
|
|
7058
|
-
const
|
|
7058
|
+
const path12 = join(dir, IGNORE_FILE);
|
|
7059
7059
|
const existing = loadIgnores(dir);
|
|
7060
7060
|
const idx = existing.findIndex((e) => e.artifact_id === entry.artifact_id);
|
|
7061
7061
|
if (idx >= 0) {
|
|
@@ -7063,17 +7063,17 @@ function saveIgnore(dir, entry) {
|
|
|
7063
7063
|
} else {
|
|
7064
7064
|
existing.push(entry);
|
|
7065
7065
|
}
|
|
7066
|
-
writeFile(
|
|
7066
|
+
writeFile(path12, stringifyYaml3(existing));
|
|
7067
7067
|
}
|
|
7068
7068
|
function isIgnored(ignores, artifactId) {
|
|
7069
7069
|
return ignores.find((e) => e.artifact_id === artifactId);
|
|
7070
7070
|
}
|
|
7071
7071
|
function removeIgnore(dir, artifactId) {
|
|
7072
|
-
const
|
|
7072
|
+
const path12 = join(dir, IGNORE_FILE);
|
|
7073
7073
|
const existing = loadIgnores(dir);
|
|
7074
7074
|
const filtered = existing.filter((e) => e.artifact_id !== artifactId);
|
|
7075
7075
|
if (filtered.length === existing.length) return false;
|
|
7076
|
-
writeFile(
|
|
7076
|
+
writeFile(path12, stringifyYaml3(filtered));
|
|
7077
7077
|
return true;
|
|
7078
7078
|
}
|
|
7079
7079
|
|
|
@@ -7095,11 +7095,11 @@ function moduleArtifactCoverage(dir, id) {
|
|
|
7095
7095
|
};
|
|
7096
7096
|
}
|
|
7097
7097
|
function loadMappedModules(dir) {
|
|
7098
|
-
const
|
|
7099
|
-
if (!exists(
|
|
7098
|
+
const path12 = join(dir, DESCRIPTOR_PATH);
|
|
7099
|
+
if (!exists(path12)) return [];
|
|
7100
7100
|
let parsed;
|
|
7101
7101
|
try {
|
|
7102
|
-
parsed = parseYaml6(readFile(
|
|
7102
|
+
parsed = parseYaml6(readFile(path12));
|
|
7103
7103
|
} catch {
|
|
7104
7104
|
return [];
|
|
7105
7105
|
}
|
|
@@ -7843,7 +7843,7 @@ function buildGuardHistory(dir) {
|
|
|
7843
7843
|
const d = hotspotDir(t.code_path);
|
|
7844
7844
|
hotspotMap.set(d, (hotspotMap.get(d) ?? 0) + 1);
|
|
7845
7845
|
}
|
|
7846
|
-
const hotspots = [...hotspotMap.entries()].map(([
|
|
7846
|
+
const hotspots = [...hotspotMap.entries()].map(([path12, warnings]) => ({ path: path12, warnings })).sort((a, b) => b.warnings - a.warnings);
|
|
7847
7847
|
return {
|
|
7848
7848
|
available: true,
|
|
7849
7849
|
total_runs: sorted.length,
|
|
@@ -10481,10 +10481,10 @@ function slugify2(name) {
|
|
|
10481
10481
|
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10482
10482
|
}
|
|
10483
10483
|
function readModulesDescriptor(dir) {
|
|
10484
|
-
const
|
|
10485
|
-
if (!exists(
|
|
10484
|
+
const path12 = join(dir, DESCRIPTOR_PATH2);
|
|
10485
|
+
if (!exists(path12)) return { version: 1, modules: [] };
|
|
10486
10486
|
try {
|
|
10487
|
-
const parsed = parseYaml10(readFile(
|
|
10487
|
+
const parsed = parseYaml10(readFile(path12));
|
|
10488
10488
|
return { version: parsed.version ?? 1, modules: parsed.modules ?? [] };
|
|
10489
10489
|
} catch {
|
|
10490
10490
|
return { version: 1, modules: [] };
|
|
@@ -10864,7 +10864,7 @@ function sectionParagraph(md, title) {
|
|
|
10864
10864
|
}
|
|
10865
10865
|
return "";
|
|
10866
10866
|
}
|
|
10867
|
-
function parseCapsule(id,
|
|
10867
|
+
function parseCapsule(id, path12, md) {
|
|
10868
10868
|
const { data } = matter3(md);
|
|
10869
10869
|
const updatedAt = data.updated_at ? String(data.updated_at) : void 0;
|
|
10870
10870
|
let ageDays = null;
|
|
@@ -10874,7 +10874,7 @@ function parseCapsule(id, path11, md) {
|
|
|
10874
10874
|
}
|
|
10875
10875
|
return {
|
|
10876
10876
|
id,
|
|
10877
|
-
path:
|
|
10877
|
+
path: path12,
|
|
10878
10878
|
system: data.system ? String(data.system) : id,
|
|
10879
10879
|
owner: data.owner ? String(data.owner) : void 0,
|
|
10880
10880
|
updatedAt,
|
|
@@ -11135,9 +11135,9 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
11135
11135
|
];
|
|
11136
11136
|
const presentLayers = [];
|
|
11137
11137
|
for (const layer2 of layerDocs) {
|
|
11138
|
-
const
|
|
11139
|
-
if (
|
|
11140
|
-
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path:
|
|
11138
|
+
const path12 = layer2.files.map((f) => `${KNOWLEDGE3}/${f}`).find((rel) => exists(join(dir, rel)));
|
|
11139
|
+
if (path12) {
|
|
11140
|
+
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path: path12 });
|
|
11141
11141
|
presentLayers.push(layer2.id);
|
|
11142
11142
|
}
|
|
11143
11143
|
}
|
|
@@ -12700,10 +12700,10 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
12700
12700
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
12701
12701
|
const resolveAgent = (agent) => {
|
|
12702
12702
|
const file = agent.endsWith(".md") ? agent : `${agent}.md`;
|
|
12703
|
-
const
|
|
12704
|
-
const installed = isFile(join(dir,
|
|
12703
|
+
const path12 = agentInstallPath(file);
|
|
12704
|
+
const installed = isFile(join(dir, path12));
|
|
12705
12705
|
const group = agentGroupOf(file);
|
|
12706
|
-
return { agentPath:
|
|
12706
|
+
return { agentPath: path12, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
|
|
12707
12707
|
};
|
|
12708
12708
|
const moduleRepo = isModule(config);
|
|
12709
12709
|
const coreRepo = isCore(config);
|
|
@@ -16442,15 +16442,20 @@ function runStatus() {
|
|
|
16442
16442
|
}
|
|
16443
16443
|
|
|
16444
16444
|
// src/commands/learn.ts
|
|
16445
|
+
import fs3 from "fs";
|
|
16446
|
+
import path7 from "path";
|
|
16445
16447
|
import matter9 from "gray-matter";
|
|
16446
16448
|
var ARCH_DIR9 = "knowledge";
|
|
16447
16449
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
16448
|
-
function
|
|
16449
|
-
const
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
const
|
|
16453
|
-
|
|
16450
|
+
function completedPathFor(filePath) {
|
|
16451
|
+
const posix = filePath.replace(/\\/g, "/");
|
|
16452
|
+
const m = posix.match(/\/work-items\/(draft|ready|in-progress|blocked)\//);
|
|
16453
|
+
if (!m) return filePath;
|
|
16454
|
+
const completedDir = path7.dirname(filePath).replace(
|
|
16455
|
+
new RegExp(`[/\\\\]${m[1]}$`),
|
|
16456
|
+
path7.sep + "completed"
|
|
16457
|
+
);
|
|
16458
|
+
return path7.join(completedDir, path7.basename(filePath));
|
|
16454
16459
|
}
|
|
16455
16460
|
function updateWorkItemFile(filePath, learning) {
|
|
16456
16461
|
const raw = readFile(filePath);
|
|
@@ -16480,7 +16485,15 @@ ${learning.trim()}
|
|
|
16480
16485
|
`;
|
|
16481
16486
|
}
|
|
16482
16487
|
const newRaw = matter9.stringify(updatedContent, data);
|
|
16483
|
-
|
|
16488
|
+
const newPath = completedPathFor(filePath);
|
|
16489
|
+
if (newPath !== filePath) {
|
|
16490
|
+
ensureDir(path7.dirname(newPath));
|
|
16491
|
+
writeFile(newPath, newRaw);
|
|
16492
|
+
fs3.unlinkSync(filePath);
|
|
16493
|
+
} else {
|
|
16494
|
+
writeFile(filePath, newRaw);
|
|
16495
|
+
}
|
|
16496
|
+
return newPath;
|
|
16484
16497
|
}
|
|
16485
16498
|
async function runLearn(artifactId, opts = {}) {
|
|
16486
16499
|
const dir = cwd();
|
|
@@ -16514,7 +16527,10 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16514
16527
|
});
|
|
16515
16528
|
targetId = chosen;
|
|
16516
16529
|
}
|
|
16517
|
-
const
|
|
16530
|
+
const targetArtifact = closable.find(
|
|
16531
|
+
(a) => (a.id || a.title) === targetId
|
|
16532
|
+
) ?? artifacts.find((a) => (a.id || a.title) === targetId);
|
|
16533
|
+
const filePath = targetArtifact?.filePath ?? null;
|
|
16518
16534
|
if (!filePath) {
|
|
16519
16535
|
log.error(`Work item "${targetId}" not found in ${WORK_ITEMS_DIR2}/`);
|
|
16520
16536
|
process.exit(1);
|
|
@@ -16563,9 +16579,9 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16563
16579
|
}
|
|
16564
16580
|
enrichedLearning += "\n\n> " + notes.join(" ");
|
|
16565
16581
|
}
|
|
16566
|
-
updateWorkItemFile(filePath, enrichedLearning);
|
|
16582
|
+
const finalPath = updateWorkItemFile(filePath, enrichedLearning);
|
|
16567
16583
|
log.success(`${targetId} marked as completed`);
|
|
16568
|
-
log.success(`Learning recorded in ${
|
|
16584
|
+
log.success(`Learning recorded in ${finalPath.replace(dir + path7.sep, "").replace(/\\/g, "/")}`);
|
|
16569
16585
|
if (hasExceptions) {
|
|
16570
16586
|
log.warn("Learning captured from a Work Item completed with validation exceptions.");
|
|
16571
16587
|
}
|
|
@@ -17713,8 +17729,8 @@ function runGraphExport(opts = {}) {
|
|
|
17713
17729
|
|
|
17714
17730
|
// src/core/system-topology.ts
|
|
17715
17731
|
import { parse as parseYaml17, stringify as stringifyYaml8 } from "yaml";
|
|
17716
|
-
import
|
|
17717
|
-
import
|
|
17732
|
+
import fs4 from "fs";
|
|
17733
|
+
import path8 from "path";
|
|
17718
17734
|
import crypto from "crypto";
|
|
17719
17735
|
var TOPOLOGY_FILE = "knowledge/tech/system-topology.yml";
|
|
17720
17736
|
var SYSTEM_ENTITY_KINDS = /* @__PURE__ */ new Set([
|
|
@@ -17880,14 +17896,14 @@ function serializeTopology(entities, relationships) {
|
|
|
17880
17896
|
return stringifyYaml8(doc);
|
|
17881
17897
|
}
|
|
17882
17898
|
function atomicWrite(filePath, content) {
|
|
17883
|
-
|
|
17899
|
+
fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
|
|
17884
17900
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
17885
|
-
|
|
17901
|
+
fs4.writeFileSync(tmp, content, "utf-8");
|
|
17886
17902
|
try {
|
|
17887
|
-
|
|
17903
|
+
fs4.renameSync(tmp, filePath);
|
|
17888
17904
|
} catch (err) {
|
|
17889
17905
|
try {
|
|
17890
|
-
|
|
17906
|
+
fs4.rmSync(tmp, { force: true });
|
|
17891
17907
|
} catch {
|
|
17892
17908
|
}
|
|
17893
17909
|
throw err;
|
|
@@ -17997,8 +18013,8 @@ import matter12 from "gray-matter";
|
|
|
17997
18013
|
import { parse as parseYaml18, stringify as stringifyYaml9 } from "yaml";
|
|
17998
18014
|
|
|
17999
18015
|
// src/core/work-item-write.ts
|
|
18000
|
-
import
|
|
18001
|
-
import
|
|
18016
|
+
import fs5 from "fs";
|
|
18017
|
+
import path9 from "path";
|
|
18002
18018
|
import crypto2 from "crypto";
|
|
18003
18019
|
import matter11 from "gray-matter";
|
|
18004
18020
|
var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
|
|
@@ -18021,7 +18037,7 @@ function nextWorkItemId2(dir) {
|
|
|
18021
18037
|
let max = 0;
|
|
18022
18038
|
const walk = (d) => {
|
|
18023
18039
|
if (!exists(d)) return;
|
|
18024
|
-
for (const entry of
|
|
18040
|
+
for (const entry of fs5.readdirSync(d)) {
|
|
18025
18041
|
const full = join(d, entry);
|
|
18026
18042
|
if (isFile(full)) {
|
|
18027
18043
|
const m = entry.match(/WI-(\d+)/);
|
|
@@ -18035,14 +18051,14 @@ function nextWorkItemId2(dir) {
|
|
|
18035
18051
|
return `WI-${String(max + 1).padStart(3, "0")}`;
|
|
18036
18052
|
}
|
|
18037
18053
|
function atomicWrite2(filePath, content) {
|
|
18038
|
-
|
|
18054
|
+
fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
18039
18055
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
18040
|
-
|
|
18056
|
+
fs5.writeFileSync(tmp, content, "utf-8");
|
|
18041
18057
|
try {
|
|
18042
|
-
|
|
18058
|
+
fs5.renameSync(tmp, filePath);
|
|
18043
18059
|
} catch (err) {
|
|
18044
18060
|
try {
|
|
18045
|
-
|
|
18061
|
+
fs5.rmSync(tmp, { force: true });
|
|
18046
18062
|
} catch {
|
|
18047
18063
|
}
|
|
18048
18064
|
throw err;
|
|
@@ -18095,24 +18111,13 @@ ${body}`);
|
|
|
18095
18111
|
${out.join("\n\n")}
|
|
18096
18112
|
`.replace(/\n{3,}/g, "\n\n");
|
|
18097
18113
|
}
|
|
18098
|
-
function
|
|
18099
|
-
const
|
|
18100
|
-
|
|
18101
|
-
|
|
18102
|
-
|
|
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}
|
|
18114
|
+
function ensureH1(body, title) {
|
|
18115
|
+
const trimmed = body.trim();
|
|
18116
|
+
const firstMeaningful = trimmed.split(/\r?\n/).find((l) => l.trim());
|
|
18117
|
+
if (firstMeaningful && /^#\s+/.test(firstMeaningful.trim())) return trimmed;
|
|
18118
|
+
return `# ${title}
|
|
18112
18119
|
|
|
18113
|
-
${
|
|
18114
|
-
` : `${preamble}
|
|
18115
|
-
`;
|
|
18120
|
+
${trimmed}`;
|
|
18116
18121
|
}
|
|
18117
18122
|
function serialize(data, body) {
|
|
18118
18123
|
return matter11.stringify(`
|
|
@@ -18148,8 +18153,8 @@ function createWorkItem(dir, opts) {
|
|
|
18148
18153
|
if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
|
|
18149
18154
|
const id = nextWorkItemId2(dir);
|
|
18150
18155
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
18151
|
-
const summary = opts.summary?.trim() ? opts.summary.trim() : intent;
|
|
18152
18156
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
18157
|
+
const summary = opts.summary?.trim() || intent;
|
|
18153
18158
|
const source = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
18154
18159
|
const data = {
|
|
18155
18160
|
type,
|
|
@@ -18166,10 +18171,11 @@ function createWorkItem(dir, opts) {
|
|
|
18166
18171
|
if (opts.originalSnapshot) data.original_snapshot = opts.originalSnapshot;
|
|
18167
18172
|
const answers = opts.answers ?? {};
|
|
18168
18173
|
const hasAnswers = Object.values(answers).some((v) => v?.trim());
|
|
18169
|
-
const
|
|
18174
|
+
const providedBody = opts.body?.trim();
|
|
18175
|
+
const body = providedBody ? ensureH1(providedBody, title) : hasAnswers ? captureBody(title, type, answers) : freshBody({
|
|
18170
18176
|
title,
|
|
18171
18177
|
type,
|
|
18172
|
-
summary
|
|
18178
|
+
summary,
|
|
18173
18179
|
scopeUnknowns: [],
|
|
18174
18180
|
affectedModules: [],
|
|
18175
18181
|
moduleCoverage: [],
|
|
@@ -18871,8 +18877,8 @@ async function handleJiraResponse(res) {
|
|
|
18871
18877
|
}
|
|
18872
18878
|
return await res.json();
|
|
18873
18879
|
}
|
|
18874
|
-
async function jiraFetch(baseUrl,
|
|
18875
|
-
const url = new URL(
|
|
18880
|
+
async function jiraFetch(baseUrl, path12, auth, timeoutMs, params) {
|
|
18881
|
+
const url = new URL(path12, baseUrl + "/");
|
|
18876
18882
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
18877
18883
|
const controller = new AbortController();
|
|
18878
18884
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -18890,8 +18896,8 @@ async function jiraFetch(baseUrl, path11, auth, timeoutMs, params) {
|
|
|
18890
18896
|
clearTimeout(timer);
|
|
18891
18897
|
}
|
|
18892
18898
|
}
|
|
18893
|
-
async function jiraPost(baseUrl,
|
|
18894
|
-
const url = new URL(
|
|
18899
|
+
async function jiraPost(baseUrl, path12, auth, timeoutMs, body) {
|
|
18900
|
+
const url = new URL(path12, baseUrl + "/");
|
|
18895
18901
|
const controller = new AbortController();
|
|
18896
18902
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
18897
18903
|
try {
|
|
@@ -20550,7 +20556,7 @@ function runAdr(opts = {}) {
|
|
|
20550
20556
|
}
|
|
20551
20557
|
|
|
20552
20558
|
// src/commands/tech.ts
|
|
20553
|
-
import
|
|
20559
|
+
import fs6 from "fs";
|
|
20554
20560
|
var DISCOVERY_FILES = ["architecture-notes.md", "decision-candidates.md"];
|
|
20555
20561
|
var DISCOVERY_DIR = "knowledge/tech/discovery";
|
|
20556
20562
|
function runTechOrganize(dir = cwd()) {
|
|
@@ -20567,7 +20573,7 @@ function runTechOrganize(dir = cwd()) {
|
|
|
20567
20573
|
continue;
|
|
20568
20574
|
}
|
|
20569
20575
|
ensureDir(join(dir, DISCOVERY_DIR));
|
|
20570
|
-
|
|
20576
|
+
fs6.renameSync(from, to);
|
|
20571
20577
|
moved.push(`knowledge/tech/${file} \u2192 ${DISCOVERY_DIR}/${file}`);
|
|
20572
20578
|
}
|
|
20573
20579
|
if (moved.length > 0) {
|
|
@@ -20649,8 +20655,8 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
20649
20655
|
}
|
|
20650
20656
|
|
|
20651
20657
|
// src/commands/ready.ts
|
|
20652
|
-
import
|
|
20653
|
-
import
|
|
20658
|
+
import fs7 from "fs";
|
|
20659
|
+
import path10 from "path";
|
|
20654
20660
|
import matter14 from "gray-matter";
|
|
20655
20661
|
function validateReadiness(content, frontmatter) {
|
|
20656
20662
|
const warnings = [];
|
|
@@ -20713,10 +20719,10 @@ function transitionToReady(filePath) {
|
|
|
20713
20719
|
const posix = filePath.replace(/\\/g, "/");
|
|
20714
20720
|
let newPath = filePath;
|
|
20715
20721
|
if (posix.includes("/work-items/draft/")) {
|
|
20716
|
-
const readyDir =
|
|
20722
|
+
const readyDir = path10.dirname(filePath).replace(/[/\\]draft$/, path10.sep + "ready");
|
|
20717
20723
|
ensureDir(readyDir);
|
|
20718
|
-
const fileName =
|
|
20719
|
-
newPath =
|
|
20724
|
+
const fileName = path10.basename(filePath);
|
|
20725
|
+
newPath = path10.join(readyDir, fileName);
|
|
20720
20726
|
}
|
|
20721
20727
|
return { newPath, newContent };
|
|
20722
20728
|
}
|
|
@@ -20784,11 +20790,11 @@ async function runReady(id, opts = {}) {
|
|
|
20784
20790
|
const { newPath, newContent } = transitionToReady(wi.filePath);
|
|
20785
20791
|
if (newPath !== wi.filePath) {
|
|
20786
20792
|
writeFile(newPath, newContent);
|
|
20787
|
-
|
|
20793
|
+
fs7.unlinkSync(wi.filePath);
|
|
20788
20794
|
log.success(`Updated status: ready`);
|
|
20789
20795
|
log.success(`Moved file:`);
|
|
20790
|
-
log.info(` ${
|
|
20791
|
-
log.info(` \u2192 ${
|
|
20796
|
+
log.info(` ${path10.relative(dir, wi.filePath)}`);
|
|
20797
|
+
log.info(` \u2192 ${path10.relative(dir, newPath)}`);
|
|
20792
20798
|
} else {
|
|
20793
20799
|
writeFile(wi.filePath, newContent);
|
|
20794
20800
|
log.success(`Updated status: ready`);
|
|
@@ -20799,7 +20805,7 @@ async function runReady(id, opts = {}) {
|
|
|
20799
20805
|
}
|
|
20800
20806
|
|
|
20801
20807
|
// src/commands/admin.ts
|
|
20802
|
-
import
|
|
20808
|
+
import path11 from "path";
|
|
20803
20809
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
20804
20810
|
import net from "net";
|
|
20805
20811
|
function isPortAvailable(port, host) {
|
|
@@ -20814,17 +20820,17 @@ function isPortAvailable(port, host) {
|
|
|
20814
20820
|
});
|
|
20815
20821
|
}
|
|
20816
20822
|
function resolveStaticDir() {
|
|
20817
|
-
const __dirname =
|
|
20823
|
+
const __dirname = path11.dirname(fileURLToPath2(import.meta.url));
|
|
20818
20824
|
const candidates = [
|
|
20819
20825
|
// Monorepo development: prefer the freshly built admin over the copy bundled into the CLI dist.
|
|
20820
20826
|
// The CLI build copies admin/dist into dist/admin-dist, but that copy can be stale when the admin
|
|
20821
20827
|
// was rebuilt after the CLI (build order is not guaranteed in `pnpm -r build`). Serving the admin
|
|
20822
20828
|
// package's own dist first ensures `kaddo admin` always shows the current frontend in dev. This
|
|
20823
20829
|
// path does not exist in a published npm install (admin is private), so it falls back below.
|
|
20824
|
-
|
|
20825
|
-
|
|
20830
|
+
path11.resolve(__dirname, "..", "..", "admin", "dist"),
|
|
20831
|
+
path11.resolve(__dirname, "..", "node_modules", "@kaddo", "admin", "dist"),
|
|
20826
20832
|
// Bundled inside CLI dist (npm install)
|
|
20827
|
-
|
|
20833
|
+
path11.resolve(__dirname, "admin-dist")
|
|
20828
20834
|
];
|
|
20829
20835
|
for (const c of candidates) {
|
|
20830
20836
|
if (exists(join(c, "index.html"))) return c;
|
|
@@ -20866,8 +20872,8 @@ async function runAdmin(opts = {}) {
|
|
|
20866
20872
|
}
|
|
20867
20873
|
let adminServer;
|
|
20868
20874
|
try {
|
|
20869
|
-
const __dirname =
|
|
20870
|
-
const bundled =
|
|
20875
|
+
const __dirname = path11.dirname(fileURLToPath2(import.meta.url));
|
|
20876
|
+
const bundled = path11.resolve(__dirname, "admin-server", "index.js");
|
|
20871
20877
|
if (exists(bundled)) {
|
|
20872
20878
|
const { pathToFileURL } = await import("url");
|
|
20873
20879
|
adminServer = await import(pathToFileURL(bundled).href);
|
|
@@ -20924,7 +20930,7 @@ async function runAdmin(opts = {}) {
|
|
|
20924
20930
|
|
|
20925
20931
|
// src/core/work-item-import.ts
|
|
20926
20932
|
import crypto3 from "crypto";
|
|
20927
|
-
import
|
|
20933
|
+
import fs8 from "fs";
|
|
20928
20934
|
import matter16 from "gray-matter";
|
|
20929
20935
|
|
|
20930
20936
|
// src/core/work-items.ts
|
|
@@ -21004,8 +21010,8 @@ function parseGraphReason(v) {
|
|
|
21004
21010
|
if (!v || typeof v !== "object") return null;
|
|
21005
21011
|
const o = v;
|
|
21006
21012
|
const relationship = typeof o.relationship === "string" && o.relationship.trim() ? o.relationship.trim() : null;
|
|
21007
|
-
const
|
|
21008
|
-
return relationship ||
|
|
21013
|
+
const path12 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
|
|
21014
|
+
return relationship || path12.length ? { relationship, path: path12 } : null;
|
|
21009
21015
|
}
|
|
21010
21016
|
function parseExplain(o) {
|
|
21011
21017
|
const refs = Array.isArray(o.evidence) ? o.evidence : Array.isArray(o.evidence_refs) ? o.evidence_refs : [];
|
|
@@ -21550,7 +21556,7 @@ function parseContent(raw) {
|
|
|
21550
21556
|
const title = extractTitle(frontmatterFields, bodyText);
|
|
21551
21557
|
const candidateType = extractType(frontmatterFields);
|
|
21552
21558
|
const sections = extractSections(bodyText);
|
|
21553
|
-
const summary =
|
|
21559
|
+
const summary = bodyText || title;
|
|
21554
21560
|
return {
|
|
21555
21561
|
format,
|
|
21556
21562
|
title,
|
|
@@ -21570,16 +21576,6 @@ function extractTitle(fields, body) {
|
|
|
21570
21576
|
const firstLine = body.split(/\r?\n/).find((l) => l.trim());
|
|
21571
21577
|
return (firstLine?.trim() ?? "Untitled Work Item").slice(0, 120);
|
|
21572
21578
|
}
|
|
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
21579
|
function extractType(fields) {
|
|
21584
21580
|
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
21581
|
if (!raw) return void 0;
|
|
@@ -21608,16 +21604,21 @@ function extractSections(body) {
|
|
|
21608
21604
|
flush2();
|
|
21609
21605
|
return sections;
|
|
21610
21606
|
}
|
|
21607
|
+
function deriveShortSummary(parsed) {
|
|
21608
|
+
const paragraph = parsed.body.split(/\n{2,}/).map((p) => p.trim()).find((p) => p && !/^#{1,6}\s/.test(p) && !/^>/.test(p) && p !== parsed.title);
|
|
21609
|
+
const base = paragraph ? paragraph.replace(/\s+/g, " ") : parsed.title;
|
|
21610
|
+
return base.length > 280 ? `${base.slice(0, 277).trimEnd()}\u2026` : base;
|
|
21611
|
+
}
|
|
21611
21612
|
function normalizeImportFields(parsed, opts) {
|
|
21612
21613
|
const discardedFields = [];
|
|
21613
21614
|
for (const key of Object.keys(parsed.candidateFields)) {
|
|
21614
21615
|
if (LIFECYCLE_FIELDS.has(key)) discardedFields.push(key);
|
|
21615
21616
|
}
|
|
21616
21617
|
const type = opts.userType ? normalizeType(opts.userType) ?? "feature" : parsed.type ?? "feature";
|
|
21617
|
-
const
|
|
21618
|
-
|
|
21619
|
-
|
|
21620
|
-
const
|
|
21618
|
+
const hasRealBody = !!parsed.body && parsed.body !== parsed.title;
|
|
21619
|
+
const intent = parsed.title;
|
|
21620
|
+
const body = hasRealBody ? parsed.body : void 0;
|
|
21621
|
+
const summary = hasRealBody ? deriveShortSummary(parsed) : parsed.title;
|
|
21621
21622
|
const source = {
|
|
21622
21623
|
type: opts.importSource === "chat" ? "chat" : "external",
|
|
21623
21624
|
imported_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
@@ -21625,14 +21626,14 @@ ${parsed.body}` : parsed.title;
|
|
|
21625
21626
|
source.source_format = opts.sourceFormat;
|
|
21626
21627
|
source.source_hash = opts.sourceHash;
|
|
21627
21628
|
const snapshot = { title: parsed.title };
|
|
21628
|
-
if (
|
|
21629
|
+
if (summary !== parsed.title) snapshot.description = summary;
|
|
21629
21630
|
if (typeof parsed.candidateFields.type === "string") snapshot.type = parsed.candidateFields.type;
|
|
21630
21631
|
if (typeof parsed.candidateFields.status === "string") snapshot.status = parsed.candidateFields.status;
|
|
21631
21632
|
if (Array.isArray(parsed.candidateFields.labels)) {
|
|
21632
21633
|
const labels = parsed.candidateFields.labels.filter((l) => typeof l === "string");
|
|
21633
21634
|
if (labels.length > 0) snapshot.labels = labels;
|
|
21634
21635
|
}
|
|
21635
|
-
return { type, intent, summary
|
|
21636
|
+
return { type, intent, summary, body, source, snapshot, discardedFields };
|
|
21636
21637
|
}
|
|
21637
21638
|
function computeContentHash(raw) {
|
|
21638
21639
|
return crypto3.createHash("sha256").update(raw.trim(), "utf-8").digest("hex");
|
|
@@ -21710,7 +21711,7 @@ function importWorkItem(dir, opts) {
|
|
|
21710
21711
|
};
|
|
21711
21712
|
}
|
|
21712
21713
|
if (opts.onConflict === "replace") {
|
|
21713
|
-
|
|
21714
|
+
fs8.rmSync(existing.filePath, { force: true });
|
|
21714
21715
|
replacedWorkItem = existing.workItemId;
|
|
21715
21716
|
}
|
|
21716
21717
|
}
|
|
@@ -21718,10 +21719,10 @@ function importWorkItem(dir, opts) {
|
|
|
21718
21719
|
const result = createWorkItem(dir, {
|
|
21719
21720
|
intent: normalized.intent,
|
|
21720
21721
|
type: normalized.type,
|
|
21721
|
-
source: normalized.source,
|
|
21722
|
-
originalSnapshot: normalized.snapshot,
|
|
21723
21722
|
summary: normalized.summary,
|
|
21724
|
-
body: normalized.body
|
|
21723
|
+
body: normalized.body,
|
|
21724
|
+
source: normalized.source,
|
|
21725
|
+
originalSnapshot: normalized.snapshot
|
|
21725
21726
|
});
|
|
21726
21727
|
let refinementHandoff;
|
|
21727
21728
|
try {
|
|
@@ -22309,9 +22310,9 @@ function markRegistered(dir, identity) {
|
|
|
22309
22310
|
ensureDir(join(dir, TELEMETRY_DIR));
|
|
22310
22311
|
writeFile(identityPath(dir), JSON.stringify(identity, null, 2));
|
|
22311
22312
|
}
|
|
22312
|
-
function signPayload(identity, method,
|
|
22313
|
+
function signPayload(identity, method, path12, timestamp, nonce, bodySha256) {
|
|
22313
22314
|
const canonical = `${method}
|
|
22314
|
-
${
|
|
22315
|
+
${path12}
|
|
22315
22316
|
${identity.installationId}
|
|
22316
22317
|
${timestamp}
|
|
22317
22318
|
${nonce}
|
|
@@ -23122,8 +23123,8 @@ var capsuleCmd = program.command("capsule").description("Export this project as
|
|
|
23122
23123
|
capsuleCmd.command("export").description("Write a Knowledge Capsule about this project to .kaddo/exports/").option("--scope <scope>", 'Export scope: "system" includes all mapped modules').option("--module <id>", "Export a capsule for a specific mapped module").action((opts) => {
|
|
23123
23124
|
runCapsuleExport(opts);
|
|
23124
23125
|
});
|
|
23125
|
-
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((
|
|
23126
|
-
runCapsuleAdd(
|
|
23126
|
+
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((path12) => {
|
|
23127
|
+
runCapsuleAdd(path12);
|
|
23127
23128
|
});
|
|
23128
23129
|
var graphCmd = program.command("graph").description("Export the lightweight, file-based knowledge graph of the project");
|
|
23129
23130
|
graphCmd.command("export").description("Write the knowledge graph to .kaddo/graph.json and .kaddo/graph.mmd").option("--scope <scope>", "Graph scope: active (default) or all").option("--format <format>", "Output format: json, mermaid (default: both)").action((opts) => {
|