@kaddo/cli 3.70.0 → 3.71.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/admin-dist/assets/index-BCR7rExw.css +2 -0
- package/dist/admin-dist/assets/index-rKOFsV1o.js +38 -0
- package/dist/admin-dist/index.html +2 -2
- package/dist/admin-server/index.js +113 -1
- package/dist/core.js +1 -0
- package/package.json +1 -1
- package/dist/admin-dist/assets/index-C81UXpGD.js +0 -10
- package/dist/admin-dist/assets/index-zcGzKcF4.css +0 -2
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>admin</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-rKOFsV1o.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BCR7rExw.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
|
@@ -54,8 +54,13 @@ import {
|
|
|
54
54
|
buildProjectExplanation,
|
|
55
55
|
buildReadinessReport,
|
|
56
56
|
buildProjectRoute,
|
|
57
|
+
knowledgeLayers,
|
|
57
58
|
loadConfig,
|
|
58
|
-
loadMappedModules
|
|
59
|
+
loadMappedModules,
|
|
60
|
+
discoverKnowledge,
|
|
61
|
+
exists,
|
|
62
|
+
join,
|
|
63
|
+
readFile
|
|
59
64
|
} from "@kaddo/cli/core";
|
|
60
65
|
function getProjectSummary(dir) {
|
|
61
66
|
const config = loadConfig(dir);
|
|
@@ -157,6 +162,71 @@ function getProjectOverview(dir) {
|
|
|
157
162
|
findings: getFindings(dir)
|
|
158
163
|
};
|
|
159
164
|
}
|
|
165
|
+
function getKnowledgeInventory(dir) {
|
|
166
|
+
const artifacts = discoverKnowledge(dir).filter((a) => !a.isWorkItem);
|
|
167
|
+
const layerSummary = knowledgeLayers(dir);
|
|
168
|
+
const layerMap = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const ls of layerSummary) {
|
|
170
|
+
const id = ls.layer.toLowerCase();
|
|
171
|
+
layerMap.set(id, { id, label: ls.layer, status: ls.status, artifacts: [] });
|
|
172
|
+
}
|
|
173
|
+
for (const a of artifacts) {
|
|
174
|
+
const layerId = a.layer === "module" ? "tech" : a.layer;
|
|
175
|
+
if (!layerMap.has(layerId)) {
|
|
176
|
+
layerMap.set(layerId, { id: layerId, label: layerId.charAt(0).toUpperCase() + layerId.slice(1), status: "unknown", artifacts: [] });
|
|
177
|
+
}
|
|
178
|
+
const layer = layerMap.get(layerId);
|
|
179
|
+
const status = a.status || "available";
|
|
180
|
+
layer.artifacts.push({
|
|
181
|
+
id: a.id || a.relPath.replace(/[/\\]/g, "-").replace(/\.md$/, ""),
|
|
182
|
+
title: a.title || a.relPath.split("/").pop()?.replace(/\.md$/, "").replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) || "Untitled",
|
|
183
|
+
layer: layerId,
|
|
184
|
+
path: a.relPath,
|
|
185
|
+
status: normalizeArtifactStatus(status),
|
|
186
|
+
type: a.type || void 0
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return { layers: Array.from(layerMap.values()) };
|
|
190
|
+
}
|
|
191
|
+
function normalizeArtifactStatus(status) {
|
|
192
|
+
if (!status || status === "active" || status === "ready") return "available";
|
|
193
|
+
if (status === "placeholder" || status === "draft") return "placeholder";
|
|
194
|
+
if (status === "missing") return "missing";
|
|
195
|
+
if (status === "not-applicable" || status === "n/a") return "not-applicable";
|
|
196
|
+
return "available";
|
|
197
|
+
}
|
|
198
|
+
function getKnowledgeArtifactDetail(dir, artifactId) {
|
|
199
|
+
if (artifactId.includes("..") || artifactId.startsWith("/") || artifactId.includes("\\")) {
|
|
200
|
+
throw new CoreError("INVALID_PATH", "Invalid artifact identifier.");
|
|
201
|
+
}
|
|
202
|
+
const artifacts = discoverKnowledge(dir).filter((a) => !a.isWorkItem);
|
|
203
|
+
const match = artifacts.find((a) => {
|
|
204
|
+
const derivedId = a.id || a.relPath.replace(/[/\\]/g, "-").replace(/\.md$/, "");
|
|
205
|
+
return derivedId === artifactId;
|
|
206
|
+
});
|
|
207
|
+
if (!match) {
|
|
208
|
+
throw new CoreError("ARTIFACT_NOT_FOUND", "Knowledge artifact not found.");
|
|
209
|
+
}
|
|
210
|
+
const fullPath = join(dir, match.relPath);
|
|
211
|
+
if (!exists(fullPath)) {
|
|
212
|
+
throw new CoreError("ARTIFACT_UNAVAILABLE", "This artifact existed when the Knowledge inventory was loaded but can no longer be read.");
|
|
213
|
+
}
|
|
214
|
+
const raw = readFile(fullPath);
|
|
215
|
+
const contentStart = raw.indexOf("---", raw.indexOf("---") + 3);
|
|
216
|
+
const content = contentStart > 0 ? raw.slice(contentStart + 3).trim() : raw;
|
|
217
|
+
const layerId = match.layer === "module" ? "tech" : match.layer;
|
|
218
|
+
const status = normalizeArtifactStatus(match.status || "available");
|
|
219
|
+
return {
|
|
220
|
+
id: match.id || match.relPath.replace(/[/\\]/g, "-").replace(/\.md$/, ""),
|
|
221
|
+
title: match.title || match.relPath.split("/").pop()?.replace(/\.md$/, "").replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) || "Untitled",
|
|
222
|
+
layer: layerId,
|
|
223
|
+
path: match.relPath,
|
|
224
|
+
status,
|
|
225
|
+
format: "markdown",
|
|
226
|
+
content,
|
|
227
|
+
type: match.type || void 0
|
|
228
|
+
};
|
|
229
|
+
}
|
|
160
230
|
var CoreError = class extends Error {
|
|
161
231
|
constructor(code, message) {
|
|
162
232
|
super(message);
|
|
@@ -223,6 +293,17 @@ async function createAdminServer(opts) {
|
|
|
223
293
|
app.get("/api/v1/admin/readiness", coreRoute(getProjectReadiness));
|
|
224
294
|
app.get("/api/v1/admin/route", coreRoute(getProjectRoute));
|
|
225
295
|
app.get("/api/v1/admin/findings", coreRoute(getFindings));
|
|
296
|
+
app.get("/api/v1/admin/knowledge/inventory", coreRoute(getKnowledgeInventory));
|
|
297
|
+
app.get("/api/v1/admin/knowledge/artifact/:artifactId", async (request) => {
|
|
298
|
+
try {
|
|
299
|
+
return getKnowledgeArtifactDetail(projectDir, request.params.artifactId);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
if (err instanceof CoreError) {
|
|
302
|
+
return { error: { code: err.code, message: err.message } };
|
|
303
|
+
}
|
|
304
|
+
throw err;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
226
307
|
if (staticDir) {
|
|
227
308
|
app.setNotFoundHandler(async (_request, reply) => {
|
|
228
309
|
return reply.sendFile("index.html");
|
|
@@ -427,6 +508,33 @@ var ProjectOverviewSchema = z.object({
|
|
|
427
508
|
route: ProjectRouteSchema,
|
|
428
509
|
findings: FindingsSummarySchema
|
|
429
510
|
});
|
|
511
|
+
var KnowledgeArtifactSummarySchema = z.object({
|
|
512
|
+
id: z.string(),
|
|
513
|
+
title: z.string(),
|
|
514
|
+
layer: z.string(),
|
|
515
|
+
path: z.string(),
|
|
516
|
+
status: z.string(),
|
|
517
|
+
type: z.string().optional()
|
|
518
|
+
});
|
|
519
|
+
var KnowledgeInventoryLayerSchema = z.object({
|
|
520
|
+
id: z.string(),
|
|
521
|
+
label: z.string(),
|
|
522
|
+
status: z.string(),
|
|
523
|
+
artifacts: z.array(KnowledgeArtifactSummarySchema)
|
|
524
|
+
});
|
|
525
|
+
var KnowledgeInventorySchema = z.object({
|
|
526
|
+
layers: z.array(KnowledgeInventoryLayerSchema)
|
|
527
|
+
});
|
|
528
|
+
var KnowledgeArtifactDetailSchema = z.object({
|
|
529
|
+
id: z.string(),
|
|
530
|
+
title: z.string(),
|
|
531
|
+
layer: z.string(),
|
|
532
|
+
path: z.string(),
|
|
533
|
+
status: z.string(),
|
|
534
|
+
format: z.string(),
|
|
535
|
+
content: z.string(),
|
|
536
|
+
type: z.string().optional()
|
|
537
|
+
});
|
|
430
538
|
var ErrorResponseSchema = z.object({
|
|
431
539
|
error: z.object({
|
|
432
540
|
code: z.string(),
|
|
@@ -436,6 +544,10 @@ var ErrorResponseSchema = z.object({
|
|
|
436
544
|
export {
|
|
437
545
|
ErrorResponseSchema,
|
|
438
546
|
FindingsSummarySchema,
|
|
547
|
+
KnowledgeArtifactDetailSchema,
|
|
548
|
+
KnowledgeArtifactSummarySchema,
|
|
549
|
+
KnowledgeInventoryLayerSchema,
|
|
550
|
+
KnowledgeInventorySchema,
|
|
439
551
|
KnowledgeSummarySchema,
|
|
440
552
|
ModuleSummarySchema,
|
|
441
553
|
ProjectOverviewSchema,
|
package/dist/core.js
CHANGED