cngkit 1.1.18 → 1.1.19
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 +86 -11
- package/dist/chunk-3A6GRNEV.js +1590 -0
- package/dist/chunk-3A6GRNEV.js.map +1 -0
- package/dist/{chunk-FJ34NVQ4.js → chunk-7SO75QXJ.js} +538 -68
- package/dist/chunk-7SO75QXJ.js.map +1 -0
- package/dist/chunk-DBA3BZXP.js +231 -0
- package/dist/chunk-DBA3BZXP.js.map +1 -0
- package/dist/{chunk-IB5B3BLY.js → chunk-GBONV6XP.js} +16 -4
- package/dist/chunk-GBONV6XP.js.map +1 -0
- package/dist/{chunk-C7HFDK4S.js → chunk-L6ZVQRSY.js} +207 -31
- package/dist/chunk-L6ZVQRSY.js.map +1 -0
- package/dist/{chunk-ZA4YOWPB.js → chunk-NGEWD4BW.js} +2 -1
- package/dist/chunk-TYDIBWZV.js +35 -0
- package/dist/chunk-TYDIBWZV.js.map +1 -0
- package/dist/{chunk-TWQDLZ6F.js → chunk-X4E7NAN4.js} +2 -2
- package/dist/cli.js +55 -14
- package/dist/cli.js.map +1 -1
- package/dist/commands/coderoom/index.js +6 -6
- package/dist/commands/coderoom/index.js.map +1 -1
- package/dist/commands/coderoom/join.js +5 -5
- package/dist/commands/coderoom/share.js +5 -5
- package/dist/commands/hookify/index.js +6 -6
- package/dist/commands/hookify/index.js.map +1 -1
- package/dist/commands/hookify/ingest.js +52 -13
- package/dist/commands/hookify/ingest.js.map +1 -1
- package/dist/commands/hooks/index.js +25 -0
- package/dist/commands/hooks/index.js.map +1 -0
- package/dist/commands/hooks/install.js +40 -0
- package/dist/commands/hooks/install.js.map +1 -0
- package/dist/commands/hooks/uninstall.js +40 -0
- package/dist/commands/hooks/uninstall.js.map +1 -0
- package/dist/commands/index.js +5 -5
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/knowledges/audiences.js +6 -6
- package/dist/commands/knowledges/cat.js +31 -0
- package/dist/commands/knowledges/cat.js.map +1 -0
- package/dist/commands/knowledges/files.js +6 -6
- package/dist/commands/knowledges/find.js +66 -0
- package/dist/commands/knowledges/find.js.map +1 -0
- package/dist/commands/knowledges/glob.js +6 -6
- package/dist/commands/knowledges/grep.js +6 -6
- package/dist/commands/knowledges/head.js +41 -0
- package/dist/commands/knowledges/head.js.map +1 -0
- package/dist/commands/knowledges/index.js +6 -6
- package/dist/commands/knowledges/index.js.map +1 -1
- package/dist/commands/knowledges/list.js +7 -7
- package/dist/commands/knowledges/list.js.map +1 -1
- package/dist/commands/knowledges/ls.js +16 -7
- package/dist/commands/knowledges/ls.js.map +1 -1
- package/dist/commands/knowledges/read.js +6 -6
- package/dist/commands/knowledges/realpath.js +31 -0
- package/dist/commands/knowledges/realpath.js.map +1 -0
- package/dist/commands/knowledges/search.js +6 -6
- package/dist/commands/knowledges/stat.js +31 -0
- package/dist/commands/knowledges/stat.js.map +1 -0
- package/dist/commands/knowledges/status.js +6 -6
- package/dist/commands/knowledges/tail.js +41 -0
- package/dist/commands/knowledges/tail.js.map +1 -0
- package/dist/commands/knowledges/tree.js +46 -0
- package/dist/commands/knowledges/tree.js.map +1 -0
- package/dist/commands/login.js +3 -3
- package/dist/commands/scrub.js +3 -3
- package/dist/commands/transcripts.js +6 -6
- package/dist/commands/transcripts.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-C7HFDK4S.js.map +0 -1
- package/dist/chunk-CBIVTEZP.js +0 -222
- package/dist/chunk-CBIVTEZP.js.map +0 -1
- package/dist/chunk-FJ34NVQ4.js.map +0 -1
- package/dist/chunk-IB5B3BLY.js.map +0 -1
- package/dist/chunk-KSW6QT5Q.js +0 -628
- package/dist/chunk-KSW6QT5Q.js.map +0 -1
- /package/dist/{chunk-ZA4YOWPB.js.map → chunk-NGEWD4BW.js.map} +0 -0
- /package/dist/{chunk-TWQDLZ6F.js.map → chunk-X4E7NAN4.js.map} +0 -0
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "./chunk-XQGLUQFM.js";
|
|
8
8
|
import {
|
|
9
9
|
createCngApiClient
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TYDIBWZV.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveOutputFormat
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7SO75QXJ.js";
|
|
14
14
|
|
|
15
15
|
// src/features/knowledges/knowledges-api.ts
|
|
16
16
|
function createKnowledgesApi(options) {
|
|
@@ -22,8 +22,8 @@ function createKnowledgesApi(options) {
|
|
|
22
22
|
q: query,
|
|
23
23
|
limit
|
|
24
24
|
}),
|
|
25
|
-
|
|
26
|
-
listFiles: ({ query, audience, limit }) => client.harnessKnowledges.
|
|
25
|
+
listTopics: () => client.harnessKnowledges.listHarnessKnowledgesTopics(),
|
|
26
|
+
listFiles: ({ query, audience, limit }) => client.harnessKnowledges.listHarnessTopicAssets({
|
|
27
27
|
...query ? { q: query } : {},
|
|
28
28
|
...audience ? { audience } : {},
|
|
29
29
|
limit
|
|
@@ -49,6 +49,22 @@ function createKnowledgesApi(options) {
|
|
|
49
49
|
path,
|
|
50
50
|
limit
|
|
51
51
|
}),
|
|
52
|
+
tree: ({ path, depth, limit }) => client.harnessFilesystem.getHarnessFilesystemTree({
|
|
53
|
+
path,
|
|
54
|
+
depth,
|
|
55
|
+
limit
|
|
56
|
+
}),
|
|
57
|
+
find: ({ path, name, type, maxDepth, limit }) => client.harnessFilesystem.getHarnessFilesystemFind({
|
|
58
|
+
path,
|
|
59
|
+
...name ? { name } : {},
|
|
60
|
+
...type ? { type } : {},
|
|
61
|
+
...maxDepth !== void 0 ? { max_depth: maxDepth } : {},
|
|
62
|
+
limit
|
|
63
|
+
}),
|
|
64
|
+
tail: ({ filePath, lines }) => client.harnessFilesystem.getHarnessFilesystemTail({
|
|
65
|
+
file_path: filePath,
|
|
66
|
+
lines
|
|
67
|
+
}),
|
|
52
68
|
statPath: ({ path }) => client.harnessFilesystem.getHarnessFilesystemStat({
|
|
53
69
|
path
|
|
54
70
|
})
|
|
@@ -97,7 +113,7 @@ function normalizeCatalogPath(value) {
|
|
|
97
113
|
case "procedures":
|
|
98
114
|
case "protocols":
|
|
99
115
|
case "tools":
|
|
100
|
-
return `skills/knowledges/
|
|
116
|
+
return `skills/knowledges/topics/${firstSegment}${restSegments.length > 0 ? `/${restSegments.join("/")}` : ""}`;
|
|
101
117
|
default:
|
|
102
118
|
return relativePath;
|
|
103
119
|
}
|
|
@@ -105,7 +121,7 @@ function normalizeCatalogPath(value) {
|
|
|
105
121
|
function normalizeFilesystemCatalogPath(value) {
|
|
106
122
|
const trimmed = value.trim();
|
|
107
123
|
if (trimmed === "/" || trimmed === "") {
|
|
108
|
-
return "skills/knowledges/
|
|
124
|
+
return "skills/knowledges/topics";
|
|
109
125
|
}
|
|
110
126
|
return normalizeCatalogPath(trimmed);
|
|
111
127
|
}
|
|
@@ -131,21 +147,12 @@ async function runKnowStatusCommand(options, output, dependencies) {
|
|
|
131
147
|
output.raw(formatJson(response.data));
|
|
132
148
|
return;
|
|
133
149
|
}
|
|
134
|
-
const latestRun = response.data.latestRun;
|
|
135
150
|
const lines = [
|
|
136
151
|
`Catalog: ${response.data.name}`,
|
|
137
152
|
`Files: ${response.data.files}`,
|
|
138
153
|
`Blobs: ${response.data.blobs}`,
|
|
139
154
|
`Database: ${response.data.database.engine} (${response.data.database.binding})`
|
|
140
155
|
];
|
|
141
|
-
if (latestRun) {
|
|
142
|
-
lines.push(`Latest run: ${latestRun.status} (${latestRun.id})`);
|
|
143
|
-
if (latestRun.updated_at) {
|
|
144
|
-
lines.push(`Updated: ${latestRun.updated_at}`);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
lines.push("Latest run: none");
|
|
148
|
-
}
|
|
149
156
|
output.info(lines.join("\n"));
|
|
150
157
|
}
|
|
151
158
|
async function runKnowAudiencesCommand(options, output, dependencies) {
|
|
@@ -172,7 +179,7 @@ async function runKnowSearchCommand(query, options, output, dependencies) {
|
|
|
172
179
|
return;
|
|
173
180
|
}
|
|
174
181
|
const lines = response.data.results.flatMap((result, index) => [
|
|
175
|
-
`${index + 1}. ${result.title} (${result.
|
|
182
|
+
`${index + 1}. ${result.title} (${result.topicName})`,
|
|
176
183
|
` score ${result.score.toFixed(3)} | ${result.path}`,
|
|
177
184
|
` ${singleLine(result.description || result.contentPreview)}`
|
|
178
185
|
]);
|
|
@@ -184,29 +191,29 @@ async function runKnowSearchCommand(query, options, output, dependencies) {
|
|
|
184
191
|
}
|
|
185
192
|
async function runKnowListCommand(query, options, output, dependencies) {
|
|
186
193
|
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
187
|
-
const response = await api.
|
|
194
|
+
const response = await api.listTopics();
|
|
188
195
|
const limit = coerceLimit(options.limit, 25);
|
|
189
196
|
const normalizedQuery = query?.toLowerCase();
|
|
190
|
-
const
|
|
197
|
+
const topics = response.data.topics.filter((topic) => {
|
|
191
198
|
if (!normalizedQuery) {
|
|
192
199
|
return true;
|
|
193
200
|
}
|
|
194
|
-
return [
|
|
201
|
+
return [topic.name, topic.title, topic.description, topic.type].join(" ").toLowerCase().includes(normalizedQuery);
|
|
195
202
|
}).slice(0, limit);
|
|
196
203
|
if (shouldPrintJson(options)) {
|
|
197
|
-
output.raw(formatJson({
|
|
204
|
+
output.raw(formatJson({ topics, total: topics.length }));
|
|
198
205
|
return;
|
|
199
206
|
}
|
|
200
|
-
const lines =
|
|
201
|
-
`${
|
|
202
|
-
` ${
|
|
203
|
-
` ${singleLine(
|
|
207
|
+
const lines = topics.flatMap((topic) => [
|
|
208
|
+
`${topic.name} [${topic.type}]`,
|
|
209
|
+
` ${topic.title} | files ${topic.fileCount} | rating ${topic.rating}`,
|
|
210
|
+
` ${singleLine(topic.description)}`
|
|
204
211
|
]);
|
|
205
212
|
if (lines.length > 0) {
|
|
206
213
|
output.info(lines.join("\n"));
|
|
207
214
|
return;
|
|
208
215
|
}
|
|
209
|
-
output.warning("No matching
|
|
216
|
+
output.warning("No matching topics.");
|
|
210
217
|
}
|
|
211
218
|
async function runKnowFilesCommand(query, options, output, dependencies) {
|
|
212
219
|
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
@@ -220,7 +227,7 @@ async function runKnowFilesCommand(query, options, output, dependencies) {
|
|
|
220
227
|
return;
|
|
221
228
|
}
|
|
222
229
|
const lines = response.data.files.map((file) => {
|
|
223
|
-
const title = file.display_title ?? file.title ?? file.
|
|
230
|
+
const title = file.display_title ?? file.title ?? file.topic_name ?? "Untitled";
|
|
224
231
|
return `${file.path}
|
|
225
232
|
${title}`;
|
|
226
233
|
});
|
|
@@ -255,6 +262,41 @@ async function runKnowReadCommand(filePath, options, output, dependencies) {
|
|
|
255
262
|
);
|
|
256
263
|
}
|
|
257
264
|
}
|
|
265
|
+
async function runKnowCatCommand(filePath, options, output, dependencies) {
|
|
266
|
+
if (!filePath) {
|
|
267
|
+
throw new Error("Missing file_path. Usage: cngkit knowledges cat <file_path>");
|
|
268
|
+
}
|
|
269
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
270
|
+
const response = await api.read({
|
|
271
|
+
filePath: normalizeCatalogPath(filePath),
|
|
272
|
+
offset: 0,
|
|
273
|
+
limit: 2e3
|
|
274
|
+
});
|
|
275
|
+
outputRawContent(response.data, options, output);
|
|
276
|
+
}
|
|
277
|
+
async function runKnowHeadCommand(filePath, options, output, dependencies) {
|
|
278
|
+
if (!filePath) {
|
|
279
|
+
throw new Error("Missing file_path. Usage: cngkit knowledges head <file_path> -n 10");
|
|
280
|
+
}
|
|
281
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
282
|
+
const response = await api.read({
|
|
283
|
+
filePath: normalizeCatalogPath(filePath),
|
|
284
|
+
offset: 0,
|
|
285
|
+
limit: coerceLimit(options.lines, 10, 2e3)
|
|
286
|
+
});
|
|
287
|
+
outputRawContent(response.data, options, output);
|
|
288
|
+
}
|
|
289
|
+
async function runKnowTailCommand(filePath, options, output, dependencies) {
|
|
290
|
+
if (!filePath) {
|
|
291
|
+
throw new Error("Missing file_path. Usage: cngkit knowledges tail <file_path> -n 10");
|
|
292
|
+
}
|
|
293
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
294
|
+
const response = await api.tail({
|
|
295
|
+
filePath: normalizeCatalogPath(filePath),
|
|
296
|
+
lines: coerceLimit(options.lines, 10, 2e3)
|
|
297
|
+
});
|
|
298
|
+
outputRawContent(response.data, options, output);
|
|
299
|
+
}
|
|
258
300
|
async function runKnowGrepCommand(pattern, options, output, dependencies) {
|
|
259
301
|
if (!pattern) {
|
|
260
302
|
throw new Error("Missing pattern. Usage: cngkit knowledges grep <pattern>");
|
|
@@ -338,7 +380,9 @@ async function runKnowLsCommand(path, options, output, dependencies) {
|
|
|
338
380
|
return;
|
|
339
381
|
}
|
|
340
382
|
const entries = [...response.data.entries].sort(compareFilesystemEntries);
|
|
341
|
-
const lines = entries.map(
|
|
383
|
+
const lines = entries.map(
|
|
384
|
+
(entry) => options.long === true ? formatLongFilesystemEntryLine(entry) : formatShellFilesystemEntryName(entry)
|
|
385
|
+
);
|
|
342
386
|
if (lines.length > 0) {
|
|
343
387
|
output.raw(lines.join("\n"));
|
|
344
388
|
} else {
|
|
@@ -348,13 +392,116 @@ async function runKnowLsCommand(path, options, output, dependencies) {
|
|
|
348
392
|
output.warning(`[truncated: ${response.data.total_entries} total entries]`);
|
|
349
393
|
}
|
|
350
394
|
}
|
|
395
|
+
async function runKnowTreeCommand(path, options, output, dependencies) {
|
|
396
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
397
|
+
const response = await api.tree({
|
|
398
|
+
path: normalizeFilesystemCatalogPath(path ?? "/"),
|
|
399
|
+
depth: coerceLimit(options.depth, 3, 8),
|
|
400
|
+
limit: coerceLimit(options.limit, 500, 2e3)
|
|
401
|
+
});
|
|
402
|
+
if (shouldPrintJson(options)) {
|
|
403
|
+
output.raw(formatJson(response.data));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const lines = formatFilesystemTree(response.data.path, response.data.entries);
|
|
407
|
+
output.raw(lines.join("\n"));
|
|
408
|
+
if (response.data.truncated) {
|
|
409
|
+
output.warning(`[truncated: ${response.data.total_entries} total entries]`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async function runKnowFindCommand(path, options, output, dependencies) {
|
|
413
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
414
|
+
const response = await api.find({
|
|
415
|
+
path: normalizeFilesystemCatalogPath(path ?? "/"),
|
|
416
|
+
name: options.name,
|
|
417
|
+
type: options.type,
|
|
418
|
+
maxDepth: coerceOptionalFiniteNumber(options.maxDepth),
|
|
419
|
+
limit: coerceLimit(options.limit, 500, 2e3)
|
|
420
|
+
});
|
|
421
|
+
if (shouldPrintJson(options)) {
|
|
422
|
+
output.raw(formatJson(response.data));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const entries = [...response.data.entries].sort(compareFilesystemEntries);
|
|
426
|
+
const lines = entries.map(formatFilesystemEntryPath);
|
|
427
|
+
if (lines.length > 0) {
|
|
428
|
+
output.raw(lines.join("\n"));
|
|
429
|
+
} else {
|
|
430
|
+
output.warning(`No entries found under ${response.data.path}.`);
|
|
431
|
+
}
|
|
432
|
+
if (response.data.truncated) {
|
|
433
|
+
output.warning(`[truncated: ${response.data.total_entries} total entries]`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
async function runKnowStatCommand(path, options, output, dependencies) {
|
|
437
|
+
if (!path) {
|
|
438
|
+
throw new Error("Missing path. Usage: cngkit knowledges stat <path>");
|
|
439
|
+
}
|
|
440
|
+
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
441
|
+
const response = await api.statPath({
|
|
442
|
+
path: normalizeFilesystemCatalogPath(path)
|
|
443
|
+
});
|
|
444
|
+
if (shouldPrintJson(options)) {
|
|
445
|
+
output.raw(formatJson(response.data));
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
output.raw(formatFilesystemStat(response.data));
|
|
449
|
+
}
|
|
450
|
+
async function runKnowRealpathCommand(path, options, output) {
|
|
451
|
+
if (!path) {
|
|
452
|
+
throw new Error("Missing path. Usage: cngkit knowledges realpath <path>");
|
|
453
|
+
}
|
|
454
|
+
const resolvedPath = normalizeFilesystemCatalogPath(path);
|
|
455
|
+
if (shouldPrintJson(options)) {
|
|
456
|
+
output.raw(formatJson({ path: resolvedPath }));
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
output.raw(resolvedPath);
|
|
460
|
+
}
|
|
351
461
|
function compareFilesystemEntries(left, right) {
|
|
352
462
|
if (left.type !== right.type) {
|
|
353
463
|
return left.type === "directory" ? -1 : 1;
|
|
354
464
|
}
|
|
355
465
|
return left.path.localeCompare(right.path);
|
|
356
466
|
}
|
|
357
|
-
function
|
|
467
|
+
function outputRawContent(data, options, output) {
|
|
468
|
+
if (shouldPrintJson(options)) {
|
|
469
|
+
output.raw(formatJson(data));
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
output.raw(data.content);
|
|
473
|
+
}
|
|
474
|
+
function formatFilesystemTree(rootPath, entries) {
|
|
475
|
+
const normalizedRootPath = rootPath.replace(/\/+$/, "");
|
|
476
|
+
const rootLine = formatTreeDirectoryName(rootPath);
|
|
477
|
+
const entryLines = [...entries].sort(compareFilesystemEntries).map((entry) => {
|
|
478
|
+
const relativePath = stripRootPath(entry.path, normalizedRootPath);
|
|
479
|
+
const segmentCount = relativePath.split("/").filter(Boolean).length;
|
|
480
|
+
const indent = " ".repeat(Math.max(segmentCount - 1, 0));
|
|
481
|
+
return `${indent}${formatShellFilesystemEntryName(entry)}`;
|
|
482
|
+
});
|
|
483
|
+
return [rootLine, ...entryLines];
|
|
484
|
+
}
|
|
485
|
+
function stripRootPath(path, rootPath) {
|
|
486
|
+
if (path === rootPath) {
|
|
487
|
+
return "";
|
|
488
|
+
}
|
|
489
|
+
if (rootPath && path.startsWith(`${rootPath}/`)) {
|
|
490
|
+
return path.slice(rootPath.length + 1);
|
|
491
|
+
}
|
|
492
|
+
return path;
|
|
493
|
+
}
|
|
494
|
+
function formatTreeDirectoryName(path) {
|
|
495
|
+
const normalizedPath = path.replace(/\/+$/, "");
|
|
496
|
+
return normalizedPath ? `${normalizedPath}/` : "/";
|
|
497
|
+
}
|
|
498
|
+
function formatShellFilesystemEntryName(entry) {
|
|
499
|
+
return entry.type === "directory" ? `${entry.name}/` : entry.name;
|
|
500
|
+
}
|
|
501
|
+
function formatFilesystemEntryPath(entry) {
|
|
502
|
+
return entry.type === "directory" ? `${entry.path}/` : entry.path;
|
|
503
|
+
}
|
|
504
|
+
function formatLongFilesystemEntryLine(entry) {
|
|
358
505
|
const fields = [
|
|
359
506
|
entry.type,
|
|
360
507
|
entry.path,
|
|
@@ -365,11 +512,33 @@ function formatFilesystemEntryLine(entry) {
|
|
|
365
512
|
["total_size", entry.total_size],
|
|
366
513
|
["sha256", entry.sha256],
|
|
367
514
|
["asset_kind", entry.asset_kind],
|
|
368
|
-
["
|
|
515
|
+
["topic", entry.topic_name]
|
|
369
516
|
])
|
|
370
517
|
];
|
|
371
518
|
return fields.join(" ");
|
|
372
519
|
}
|
|
520
|
+
function coerceOptionalFiniteNumber(value) {
|
|
521
|
+
const normalizedValue = coerceOptionalNumber(value);
|
|
522
|
+
return normalizedValue === void 0 || Number.isNaN(normalizedValue) ? void 0 : Math.max(1, Math.trunc(normalizedValue));
|
|
523
|
+
}
|
|
524
|
+
function formatFilesystemStat(entry) {
|
|
525
|
+
const fields = [
|
|
526
|
+
["path", entry.path],
|
|
527
|
+
["type", entry.type],
|
|
528
|
+
["name", entry.name],
|
|
529
|
+
["depth", entry.depth],
|
|
530
|
+
["size", entry.size],
|
|
531
|
+
["files", entry.file_count],
|
|
532
|
+
["children", entry.child_count],
|
|
533
|
+
["total_size", entry.total_size],
|
|
534
|
+
["sha256", entry.sha256],
|
|
535
|
+
["asset_kind", entry.asset_kind],
|
|
536
|
+
["title", entry.title],
|
|
537
|
+
["topic", entry.topic_name],
|
|
538
|
+
["updated_at", entry.updated_at]
|
|
539
|
+
];
|
|
540
|
+
return formatOptionalEntryFields(fields).join("\n");
|
|
541
|
+
}
|
|
373
542
|
function formatOptionalEntryFields(fields) {
|
|
374
543
|
return fields.flatMap(([key, value]) => {
|
|
375
544
|
if (value === null || value === "") {
|
|
@@ -386,8 +555,15 @@ export {
|
|
|
386
555
|
runKnowListCommand,
|
|
387
556
|
runKnowFilesCommand,
|
|
388
557
|
runKnowReadCommand,
|
|
558
|
+
runKnowCatCommand,
|
|
559
|
+
runKnowHeadCommand,
|
|
560
|
+
runKnowTailCommand,
|
|
389
561
|
runKnowGrepCommand,
|
|
390
562
|
runKnowGlobCommand,
|
|
391
|
-
runKnowLsCommand
|
|
563
|
+
runKnowLsCommand,
|
|
564
|
+
runKnowTreeCommand,
|
|
565
|
+
runKnowFindCommand,
|
|
566
|
+
runKnowStatCommand,
|
|
567
|
+
runKnowRealpathCommand
|
|
392
568
|
};
|
|
393
|
-
//# sourceMappingURL=chunk-
|
|
569
|
+
//# sourceMappingURL=chunk-L6ZVQRSY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/knowledges/knowledges-api.ts","../src/features/knowledges/knowledges-input.ts","../src/features/knowledges/run-knowledges-command.ts"],"sourcesContent":["import type { CngApi } from \"@cng/client\";\n\nimport { createCngApiClient } from \"../../shared/api-client.js\";\nimport type { GlobalCommandOptions } from \"../../shared/config.js\";\n\nexport type KnowCommandDependencies = {\n api?: KnowledgesApi;\n};\n\nexport type KnowledgesApi = {\n getCatalog(): Promise<CngApi.HarnessCatalogSummaryApiResponse>;\n listAudiences(): Promise<CngApi.HarnessAudiencesApiResponse>;\n search(query: string, limit: number): Promise<CngApi.HarnessSemanticSearchApiResponse>;\n listTopics(): Promise<CngApi.HarnessTopicsApiResponse>;\n listFiles(options: {\n query?: string;\n audience?: CngApi.HarnessAudienceId;\n limit: number;\n }): Promise<CngApi.HarnessTopicAssetsApiResponse>;\n read(options: {\n filePath: string;\n offset?: number;\n limit: number;\n }): Promise<CngApi.HarnessReadApiResponse>;\n grep(options: {\n pattern: string;\n path: string;\n include: string;\n mode: CngApi.HarnessGrepOutputMode;\n context: number;\n ignoreCase: boolean;\n }): Promise<CngApi.HarnessGrepApiResponse>;\n glob(options: { pattern: string; path: string }): Promise<CngApi.HarnessGlobApiResponse>;\n listDirectory(options: {\n path: string;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemLsApiResponse>;\n tree(options: {\n path: string;\n depth: number;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemTreeApiResponse>;\n find(options: {\n path: string;\n name?: string;\n type?: CngApi.HarnessFilesystemFindType;\n maxDepth?: number;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemFindApiResponse>;\n tail(options: {\n filePath: string;\n lines: number;\n }): Promise<CngApi.HarnessFilesystemTailApiResponse>;\n statPath(options: { path: string }): Promise<CngApi.HarnessFilesystemStatApiResponse>;\n};\n\nexport function createKnowledgesApi(options: GlobalCommandOptions): KnowledgesApi {\n const client = createCngApiClient(options);\n\n return {\n getCatalog: () => client.harnessKnowledges.getHarnessKnowledgesCatalog(),\n listAudiences: () => client.harnessKnowledges.listHarnessKnowledgesAudiences(),\n search: (query, limit) =>\n client.harnessKnowledges.searchHarnessKnowledges({\n q: query,\n limit,\n }),\n listTopics: () => client.harnessKnowledges.listHarnessKnowledgesTopics(),\n listFiles: ({ query, audience, limit }) =>\n client.harnessKnowledges.listHarnessTopicAssets({\n ...(query ? { q: query } : {}),\n ...(audience ? { audience } : {}),\n limit,\n }),\n read: ({ filePath, offset, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemRead({\n file_path: filePath,\n offset,\n limit,\n }),\n grep: ({ pattern, path, include, mode, context, ignoreCase }) =>\n client.harnessFilesystem.getHarnessFilesystemGrep({\n pattern,\n path,\n include,\n output_mode: mode,\n context,\n case_insensitive: ignoreCase ? \"true\" : undefined,\n }),\n glob: ({ pattern, path }) =>\n client.harnessFilesystem.getHarnessFilesystemGlob({\n pattern,\n path,\n }),\n listDirectory: ({ path, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemLs({\n path,\n limit,\n }),\n tree: ({ path, depth, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemTree({\n path,\n depth,\n limit,\n }),\n find: ({ path, name, type, maxDepth, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemFind({\n path,\n ...(name ? { name } : {}),\n ...(type ? { type } : {}),\n ...(maxDepth !== undefined ? { max_depth: maxDepth } : {}),\n limit,\n }),\n tail: ({ filePath, lines }) =>\n client.harnessFilesystem.getHarnessFilesystemTail({\n file_path: filePath,\n lines,\n }),\n statPath: ({ path }) =>\n client.harnessFilesystem.getHarnessFilesystemStat({\n path,\n }),\n };\n}\n","import type { CngApi } from \"@cng/client\";\n\nexport function normalizeAudienceId(value: string | undefined): CngApi.HarnessAudienceId | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n switch (value) {\n case \"all\":\n case \"operators\":\n case \"builders\":\n case \"researchers\":\n case \"agent-makers\":\n return value;\n default:\n throw new Error(\n `Unknown audience \"${value}\". Run cngkit knowledges audiences to see supported values.`\n );\n }\n}\n\nexport function normalizeCatalogPath(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"/\" || trimmed === \"\") {\n return \"skills\";\n }\n\n const relativePath = trimmed.replace(/^\\/+/, \"\");\n if (relativePath.startsWith(\"skills/knowledges/\")) {\n return relativePath;\n }\n\n const [firstSegment, ...restSegments] = relativePath.split(\"/\");\n if (!firstSegment) {\n return relativePath;\n }\n\n switch (firstSegment) {\n case \"concepts\":\n case \"domains\":\n case \"formats\":\n case \"languages\":\n case \"libraries\":\n case \"patterns\":\n case \"platforms\":\n case \"procedures\":\n case \"protocols\":\n case \"tools\":\n return `skills/knowledges/topics/${firstSegment}${restSegments.length > 0 ? `/${restSegments.join(\"/\")}` : \"\"}`;\n default:\n return relativePath;\n }\n}\n\nexport function normalizeFilesystemCatalogPath(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"/\" || trimmed === \"\") {\n return \"skills/knowledges/topics\";\n }\n\n return normalizeCatalogPath(trimmed);\n}\n\nexport function normalizeGrepMode(value: string | undefined): CngApi.HarnessGrepOutputMode {\n if (value === undefined) {\n return \"content\";\n }\n\n switch (value) {\n case \"content\":\n case \"files_with_matches\":\n case \"count\":\n return value;\n default:\n throw new Error(\"Unknown grep mode. Use one of: content, files_with_matches, count.\");\n }\n}\n","import { renderKnowledgesHelp } from \"../../cli/help-specs.js\";\nimport type { CngApi } from \"@cng/client\";\nimport {\n coerceLimit,\n coerceOptionalNumber,\n formatJson,\n optionalJoinedArgument,\n shouldPrintJson,\n singleLine,\n type JsonOutputOptions,\n type NumberOption,\n} from \"../../shared/command-utils.js\";\nimport { resolveOutputFormat } from \"../../shared/config.js\";\nimport type { GlobalCommandOptions } from \"../../shared/config.js\";\nimport type { CommandOutput } from \"../../shared/output.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"./knowledges-api.js\";\nimport {\n normalizeAudienceId,\n normalizeCatalogPath,\n normalizeFilesystemCatalogPath,\n normalizeGrepMode,\n} from \"./knowledges-input.js\";\n\nexport type KnowStatusCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowAudiencesCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowSearchCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n };\n\nexport type KnowListCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n };\n\nexport type KnowFilesCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n audience?: string;\n limit?: NumberOption;\n };\n\nexport type KnowReadCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n offset?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowCatCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowHeadCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n lines?: NumberOption;\n };\n\nexport type KnowTailCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n lines?: NumberOption;\n };\n\nexport type KnowGrepCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n path?: string;\n include?: string;\n outputMode?: string;\n context?: NumberOption;\n caseInsensitive?: boolean;\n limit?: NumberOption;\n };\n\nexport type KnowGlobCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n path?: string;\n limit?: NumberOption;\n };\n\nexport type KnowLsCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n long?: boolean;\n };\n\nexport type KnowTreeCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n depth?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowFindCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n name?: string;\n type?: \"file\" | \"directory\";\n maxDepth?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowStatCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowRealpathCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowledgesCliOptions = KnowFilesCommandOptions &\n KnowGlobCommandOptions &\n KnowGrepCommandOptions &\n KnowCatCommandOptions &\n KnowHeadCommandOptions &\n KnowTailCommandOptions &\n KnowReadCommandOptions &\n KnowSearchCommandOptions &\n KnowLsCommandOptions &\n KnowTreeCommandOptions &\n KnowFindCommandOptions;\n\nexport async function runKnowledgesCommand(\n args: string[] | undefined,\n options: KnowledgesCliOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const [subcommand, ...subcommandArgs] = args ?? [];\n\n if (subcommand === undefined || subcommand === \"help\") {\n output.component(renderKnowledgesHelp(subcommandArgs[0]));\n return;\n }\n\n switch (subcommand) {\n case \"status\":\n return runKnowStatusCommand(options, output, dependencies);\n case \"audiences\":\n return runKnowAudiencesCommand(options, output, dependencies);\n case \"search\":\n return runKnowSearchCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"list\":\n return runKnowListCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"files\":\n return runKnowFilesCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"read\":\n return runKnowReadCommand(subcommandArgs[0], options, output, dependencies);\n case \"cat\":\n return runKnowCatCommand(subcommandArgs[0], options, output, dependencies);\n case \"head\":\n return runKnowHeadCommand(subcommandArgs[0], options, output, dependencies);\n case \"tail\":\n return runKnowTailCommand(subcommandArgs[0], options, output, dependencies);\n case \"grep\":\n return runKnowGrepCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"glob\":\n return runKnowGlobCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"ls\":\n return runKnowLsCommand(subcommandArgs[0], options, output, dependencies);\n case \"tree\":\n return runKnowTreeCommand(subcommandArgs[0], options, output, dependencies);\n case \"find\":\n return runKnowFindCommand(subcommandArgs[0], options, output, dependencies);\n case \"stat\":\n return runKnowStatCommand(subcommandArgs[0], options, output, dependencies);\n case \"realpath\":\n return runKnowRealpathCommand(subcommandArgs[0], options, output);\n default:\n throw new Error(\n \"Missing knowledges command. Usage: cngkit knowledges <status|audiences|search|list|files|read|cat|head|tail|grep|glob|ls|tree|find|stat|realpath>\"\n );\n }\n}\n\nexport async function runKnowStatusCommand(\n options: KnowStatusCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.getCatalog();\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = [\n `Catalog: ${response.data.name}`,\n `Files: ${response.data.files}`,\n `Blobs: ${response.data.blobs}`,\n `Database: ${response.data.database.engine} (${response.data.database.binding})`,\n ];\n\n output.info(lines.join(\"\\n\"));\n}\n\nexport async function runKnowAudiencesCommand(\n options: KnowAudiencesCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listAudiences();\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = response.data.audiences.flatMap((audience) => [\n `${audience.id} - ${audience.label}`,\n ` ${singleLine(audience.help)}`,\n ]);\n\n output.info(lines.length > 0 ? lines.join(\"\\n\") : \"No audiences available.\");\n}\n\nexport async function runKnowSearchCommand(\n query: string | undefined,\n options: KnowSearchCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!query) {\n throw new Error(\"Missing search query. Usage: cngkit knowledges search <query>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.search(query, coerceLimit(options.limit, 5));\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = response.data.results.flatMap((result, index) => [\n `${index + 1}. ${result.title} (${result.topicName})`,\n ` score ${result.score.toFixed(3)} | ${result.path}`,\n ` ${singleLine(result.description || result.contentPreview)}`,\n ]);\n\n if (lines.length > 0) {\n output.info(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(`No results for \"${query}\".`);\n}\n\nexport async function runKnowListCommand(\n query: string | undefined,\n options: KnowListCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listTopics();\n const limit = coerceLimit(options.limit, 25);\n const normalizedQuery = query?.toLowerCase();\n const topics = response.data.topics\n .filter((topic) => {\n if (!normalizedQuery) {\n return true;\n }\n return [topic.name, topic.title, topic.description, topic.type]\n .join(\" \")\n .toLowerCase()\n .includes(normalizedQuery);\n })\n .slice(0, limit);\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson({ topics, total: topics.length }));\n return;\n }\n\n const lines = topics.flatMap((topic) => [\n `${topic.name} [${topic.type}]`,\n ` ${topic.title} | files ${topic.fileCount} | rating ${topic.rating}`,\n ` ${singleLine(topic.description)}`,\n ]);\n\n if (lines.length > 0) {\n output.info(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(\"No matching topics.\");\n}\n\nexport async function runKnowFilesCommand(\n query: string | undefined,\n options: KnowFilesCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listFiles({\n query,\n audience: normalizeAudienceId(options.audience),\n limit: coerceLimit(options.limit, 25),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = response.data.files.map((file) => {\n const title = file.display_title ?? file.title ?? file.topic_name ?? \"Untitled\";\n return `${file.path}\\n ${title}`;\n });\n\n if (lines.length > 0) {\n output.info(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(\"No matching files.\");\n}\n\nexport async function runKnowReadCommand(\n filePath: string | undefined,\n options: KnowReadCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges read <file_path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: coerceOptionalNumber(options.offset),\n limit: coerceLimit(options.limit, 200, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (resolveOutputFormat() === \"markdown\" || !response.data.file_path.endsWith(\".md\")) {\n output.raw(response.data.content);\n } else {\n output.markdown(response.data.content);\n }\n\n if (response.data.truncated) {\n output.warning(\n `[truncated: showing ${response.data.limit} lines from offset ${response.data.offset} of ${response.data.total_lines}]`\n );\n }\n}\n\nexport async function runKnowCatCommand(\n filePath: string | undefined,\n options: KnowCatCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges cat <file_path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: 0,\n limit: 2000,\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowHeadCommand(\n filePath: string | undefined,\n options: KnowHeadCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges head <file_path> -n 10\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: 0,\n limit: coerceLimit(options.lines, 10, 2000),\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowTailCommand(\n filePath: string | undefined,\n options: KnowTailCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges tail <file_path> -n 10\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.tail({\n filePath: normalizeCatalogPath(filePath),\n lines: coerceLimit(options.lines, 10, 2000),\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowGrepCommand(\n pattern: string | undefined,\n options: KnowGrepCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!pattern) {\n throw new Error(\"Missing pattern. Usage: cngkit knowledges grep <pattern>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const limit = options.limit !== undefined ? coerceOptionalNumber(options.limit) : undefined;\n const response = await api.grep({\n pattern,\n path: normalizeCatalogPath(options.path ?? \"/\"),\n include: options.include ?? \"*\",\n mode: normalizeGrepMode(options.outputMode),\n context: coerceLimit(options.context, 0, 20),\n ignoreCase: options.caseInsensitive === true,\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (response.data.mode === \"files_with_matches\") {\n const files = limit ? response.data.files.slice(0, limit) : response.data.files;\n if (files.length > 0) {\n output.raw(files.join(\"\\n\"));\n return;\n }\n\n output.warning(`No files matched \"${pattern}\".`);\n return;\n }\n\n if (response.data.mode === \"count\") {\n const counts = limit ? response.data.counts.slice(0, limit) : response.data.counts;\n const lines = counts.map((count) => `${count.file_path}: ${count.match_count}`);\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(`No matches for \"${pattern}\".`);\n return;\n }\n\n const matches = limit ? response.data.matches.slice(0, limit) : response.data.matches;\n const lines = matches.flatMap((match) => [\n `${match.file_path}:${match.line_number}`,\n ...match.context_before.map((line) => ` ${line}`),\n `> ${match.line}`,\n ...match.context_after.map((line) => ` ${line}`),\n ]);\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(`No matches for \"${pattern}\".`);\n}\n\nexport async function runKnowGlobCommand(\n pattern: string | undefined,\n options: KnowGlobCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const limit = options.limit !== undefined ? coerceOptionalNumber(options.limit) : undefined;\n const response = await api.glob({\n pattern: pattern ?? \"**/*.md\",\n path: normalizeCatalogPath(options.path ?? \"/\"),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const files = limit ? response.data.files.slice(0, limit) : response.data.files;\n const wasClientTruncated = limit ? response.data.files.length > limit : false;\n\n if (files.length > 0) {\n output.raw(files.join(\"\\n\"));\n } else {\n output.warning(\"No matching files.\");\n }\n if (response.data.truncated || wasClientTruncated) {\n output.warning(`[truncated: ${response.data.total_files} total files]`);\n }\n}\n\nexport async function runKnowLsCommand(\n path: string | undefined,\n options: KnowLsCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listDirectory({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n limit: coerceLimit(options.limit, 100, 1000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const entries = [...response.data.entries].sort(compareFilesystemEntries);\n const lines = entries.map((entry) =>\n options.long === true\n ? formatLongFilesystemEntryLine(entry)\n : formatShellFilesystemEntryName(entry)\n );\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n } else {\n output.warning(`No entries under ${response.data.path}.`);\n }\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowTreeCommand(\n path: string | undefined,\n options: KnowTreeCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.tree({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n depth: coerceLimit(options.depth, 3, 8),\n limit: coerceLimit(options.limit, 500, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = formatFilesystemTree(response.data.path, response.data.entries);\n output.raw(lines.join(\"\\n\"));\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowFindCommand(\n path: string | undefined,\n options: KnowFindCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.find({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n name: options.name,\n type: options.type,\n maxDepth: coerceOptionalFiniteNumber(options.maxDepth),\n limit: coerceLimit(options.limit, 500, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const entries = [...response.data.entries].sort(compareFilesystemEntries);\n const lines = entries.map(formatFilesystemEntryPath);\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n } else {\n output.warning(`No entries found under ${response.data.path}.`);\n }\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowStatCommand(\n path: string | undefined,\n options: KnowStatCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!path) {\n throw new Error(\"Missing path. Usage: cngkit knowledges stat <path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.statPath({\n path: normalizeFilesystemCatalogPath(path),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n output.raw(formatFilesystemStat(response.data));\n}\n\nexport async function runKnowRealpathCommand(\n path: string | undefined,\n options: KnowRealpathCommandOptions,\n output: CommandOutput\n): Promise<void> {\n if (!path) {\n throw new Error(\"Missing path. Usage: cngkit knowledges realpath <path>\");\n }\n\n const resolvedPath = normalizeFilesystemCatalogPath(path);\n if (shouldPrintJson(options)) {\n output.raw(formatJson({ path: resolvedPath }));\n return;\n }\n\n output.raw(resolvedPath);\n}\n\nfunction compareFilesystemEntries(\n left: CngApi.HarnessFilesystemEntry,\n right: CngApi.HarnessFilesystemEntry\n): number {\n if (left.type !== right.type) {\n return left.type === \"directory\" ? -1 : 1;\n }\n\n return left.path.localeCompare(right.path);\n}\n\nfunction outputRawContent(\n data: CngApi.HarnessReadResponse,\n options: JsonOutputOptions,\n output: CommandOutput\n): void {\n if (shouldPrintJson(options)) {\n output.raw(formatJson(data));\n return;\n }\n\n output.raw(data.content);\n}\n\nfunction formatFilesystemTree(\n rootPath: string,\n entries: CngApi.HarnessFilesystemEntry[]\n): string[] {\n const normalizedRootPath = rootPath.replace(/\\/+$/, \"\");\n const rootLine = formatTreeDirectoryName(rootPath);\n const entryLines = [...entries].sort(compareFilesystemEntries).map((entry) => {\n const relativePath = stripRootPath(entry.path, normalizedRootPath);\n const segmentCount = relativePath.split(\"/\").filter(Boolean).length;\n const indent = \" \".repeat(Math.max(segmentCount - 1, 0));\n return `${indent}${formatShellFilesystemEntryName(entry)}`;\n });\n\n return [rootLine, ...entryLines];\n}\n\nfunction stripRootPath(path: string, rootPath: string): string {\n if (path === rootPath) {\n return \"\";\n }\n\n if (rootPath && path.startsWith(`${rootPath}/`)) {\n return path.slice(rootPath.length + 1);\n }\n\n return path;\n}\n\nfunction formatTreeDirectoryName(path: string): string {\n const normalizedPath = path.replace(/\\/+$/, \"\");\n return normalizedPath ? `${normalizedPath}/` : \"/\";\n}\n\nfunction formatShellFilesystemEntryName(entry: CngApi.HarnessFilesystemEntry): string {\n return entry.type === \"directory\" ? `${entry.name}/` : entry.name;\n}\n\nfunction formatFilesystemEntryPath(entry: CngApi.HarnessFilesystemEntry): string {\n return entry.type === \"directory\" ? `${entry.path}/` : entry.path;\n}\n\nfunction formatLongFilesystemEntryLine(entry: CngApi.HarnessFilesystemEntry): string {\n const fields = [\n entry.type,\n entry.path,\n ...formatOptionalEntryFields([\n [\"size\", entry.size],\n [\"files\", entry.file_count],\n [\"children\", entry.child_count],\n [\"total_size\", entry.total_size],\n [\"sha256\", entry.sha256],\n [\"asset_kind\", entry.asset_kind],\n [\"topic\", entry.topic_name],\n ]),\n ];\n\n return fields.join(\"\\t\");\n}\n\nfunction coerceOptionalFiniteNumber(value: NumberOption | undefined): number | undefined {\n const normalizedValue = coerceOptionalNumber(value);\n return normalizedValue === undefined || Number.isNaN(normalizedValue)\n ? undefined\n : Math.max(1, Math.trunc(normalizedValue));\n}\n\nfunction formatFilesystemStat(entry: CngApi.HarnessFilesystemStatResponse): string {\n const fields: Array<[string, string | number | null]> = [\n [\"path\", entry.path],\n [\"type\", entry.type],\n [\"name\", entry.name],\n [\"depth\", entry.depth],\n [\"size\", entry.size],\n [\"files\", entry.file_count],\n [\"children\", entry.child_count],\n [\"total_size\", entry.total_size],\n [\"sha256\", entry.sha256],\n [\"asset_kind\", entry.asset_kind],\n [\"title\", entry.title],\n [\"topic\", entry.topic_name],\n [\"updated_at\", entry.updated_at],\n ];\n\n return formatOptionalEntryFields(fields).join(\"\\n\");\n}\n\nfunction formatOptionalEntryFields(fields: Array<[string, string | number | null]>): string[] {\n return fields.flatMap(([key, value]) => {\n if (value === null || value === \"\") {\n return [];\n }\n\n return [`${key}=${value}`];\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwDO,SAAS,oBAAoB,SAA8C;AAChF,QAAM,SAAS,mBAAmB,OAAO;AAEzC,SAAO;AAAA,IACL,YAAY,MAAM,OAAO,kBAAkB,4BAA4B;AAAA,IACvE,eAAe,MAAM,OAAO,kBAAkB,+BAA+B;AAAA,IAC7E,QAAQ,CAAC,OAAO,UACd,OAAO,kBAAkB,wBAAwB;AAAA,MAC/C,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,IACH,YAAY,MAAM,OAAO,kBAAkB,4BAA4B;AAAA,IACvE,WAAW,CAAC,EAAE,OAAO,UAAU,MAAM,MACnC,OAAO,kBAAkB,uBAAuB;AAAA,MAC9C,GAAI,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC;AAAA,MAC5B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,MAC/B;AAAA,IACF,CAAC;AAAA,IACH,MAAM,CAAC,EAAE,UAAU,QAAQ,MAAM,MAC/B,OAAO,kBAAkB,yBAAyB;AAAA,MAChD,WAAW;AAAA,MACX;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,MAAM,CAAC,EAAE,SAAS,MAAM,SAAS,MAAM,SAAS,WAAW,MACzD,OAAO,kBAAkB,yBAAyB;AAAA,MAChD;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA,kBAAkB,aAAa,SAAS;AAAA,IAC1C,CAAC;AAAA,IACH,MAAM,CAAC,EAAE,SAAS,KAAK,MACrB,OAAO,kBAAkB,yBAAyB;AAAA,MAChD;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH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AAK,KAAK,MAAM;AACtC,QAAI,UAAU,QAAQ,UAAU,IAAI;AAClC,aAAO,CAAC;AAAA,IACV;AAEA,WAAO,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,EAC3B,CAAC;AACH;","names":["lines"]}
|
|
@@ -107,9 +107,10 @@ export {
|
|
|
107
107
|
OptionalQueryArgsSchema,
|
|
108
108
|
RequiredQueryArgsSchema,
|
|
109
109
|
RequiredFilePathArgsSchema,
|
|
110
|
+
RequiredCatalogPathArgsSchema,
|
|
110
111
|
RequiredPatternArgsSchema,
|
|
111
112
|
OptionalGlobPatternArgsSchema,
|
|
112
113
|
LimitOptionsSchema,
|
|
113
114
|
TranscriptArgsSchema
|
|
114
115
|
};
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
116
|
+
//# sourceMappingURL=chunk-NGEWD4BW.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CngApiClient,
|
|
3
|
+
formatError,
|
|
4
|
+
resolveApiBaseUrl
|
|
5
|
+
} from "./chunk-7SO75QXJ.js";
|
|
6
|
+
|
|
7
|
+
// src/shared/api-client.ts
|
|
8
|
+
function createCngApiClient(options) {
|
|
9
|
+
return new CngApiClient({
|
|
10
|
+
baseUrl: resolveApiBaseUrl(options),
|
|
11
|
+
timeoutInSeconds: 15,
|
|
12
|
+
maxRetries: 1
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async function readBackendHealth(options) {
|
|
16
|
+
try {
|
|
17
|
+
const client = createCngApiClient(options);
|
|
18
|
+
const health = await client.system.getHealth();
|
|
19
|
+
return {
|
|
20
|
+
ok: true,
|
|
21
|
+
service: health.service
|
|
22
|
+
};
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
message: formatError(error)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
createCngApiClient,
|
|
33
|
+
readBackendHealth
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-TYDIBWZV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/api-client.ts"],"sourcesContent":["import { CngApiClient } from \"@cng/client\";\n\nimport { resolveApiBaseUrl, type GlobalCommandOptions } from \"./config.js\";\nimport { formatError } from \"./output.js\";\n\nexport type BackendHealthStatus =\n | {\n ok: true;\n service: string;\n }\n | {\n ok: false;\n message: string;\n };\n\nexport function createCngApiClient(options: GlobalCommandOptions): CngApiClient {\n return new CngApiClient({\n baseUrl: resolveApiBaseUrl(options),\n timeoutInSeconds: 15,\n maxRetries: 1,\n });\n}\n\nexport async function readBackendHealth(\n options: GlobalCommandOptions\n): Promise<BackendHealthStatus> {\n try {\n const client = createCngApiClient(options);\n const health = await client.system.getHealth();\n return {\n ok: true,\n service: health.service,\n };\n } catch (error) {\n return {\n ok: false,\n message: formatError(error),\n };\n }\n}\n"],"mappings":";;;;;;;AAeO,SAAS,mBAAmB,SAA6C;AAC9E,SAAO,IAAI,aAAa;AAAA,IACtB,SAAS,kBAAkB,OAAO;AAAA,IAClC,kBAAkB;AAAA,IAClB,YAAY;AAAA,EACd,CAAC;AACH;AAEA,eAAsB,kBACpB,SAC8B;AAC9B,MAAI;AACF,UAAM,SAAS,mBAAmB,OAAO;AACzC,UAAM,SAAS,MAAM,OAAO,OAAO,UAAU;AAC7C,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,YAAY,KAAK;AAAA,IAC5B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCommandOutput,
|
|
3
3
|
formatError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7SO75QXJ.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/command-runner.tsx
|
|
7
7
|
import { useEffect } from "react";
|
|
@@ -23,4 +23,4 @@ function CommandRunner({ run }) {
|
|
|
23
23
|
export {
|
|
24
24
|
CommandRunner
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-X4E7NAN4.js.map
|