cngkit 1.1.18 → 1.1.20
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/LICENSE +1 -1
- package/README.md +94 -19
- package/dist/chunk-CIZBVLN5.js +35 -0
- package/dist/chunk-CIZBVLN5.js.map +1 -0
- package/dist/{chunk-IB5B3BLY.js → chunk-E2GLGGKO.js} +16 -4
- package/dist/chunk-E2GLGGKO.js.map +1 -0
- package/dist/chunk-MRXGD6TC.js +42 -0
- package/dist/chunk-MRXGD6TC.js.map +1 -0
- package/dist/{chunk-ZA4YOWPB.js → chunk-NGEWD4BW.js} +2 -1
- package/dist/chunk-NODJM6SH.js +658 -0
- package/dist/chunk-NODJM6SH.js.map +1 -0
- package/dist/chunk-SKK2XLRZ.js +1590 -0
- package/dist/chunk-SKK2XLRZ.js.map +1 -0
- package/dist/chunk-SMTQ3W3F.js +271 -0
- package/dist/chunk-SMTQ3W3F.js.map +1 -0
- package/dist/{chunk-FJ34NVQ4.js → chunk-WDI43VPW.js} +578 -88
- package/dist/chunk-WDI43VPW.js.map +1 -0
- package/dist/cli.js +107 -27
- 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 +4 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/scrub.js +38 -15
- package/dist/commands/scrub.js.map +1 -1
- package/dist/commands/transcripts.js +44 -24
- package/dist/commands/transcripts.js.map +1 -1
- package/package.json +3 -4
- package/dist/chunk-C7HFDK4S.js +0 -393
- 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-TWQDLZ6F.js +0 -26
- package/dist/chunk-TWQDLZ6F.js.map +0 -1
- /package/dist/{chunk-ZA4YOWPB.js.map → chunk-NGEWD4BW.js.map} +0 -0
package/dist/chunk-C7HFDK4S.js
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
coerceLimit,
|
|
3
|
-
coerceOptionalNumber,
|
|
4
|
-
formatJson,
|
|
5
|
-
shouldPrintJson,
|
|
6
|
-
singleLine
|
|
7
|
-
} from "./chunk-XQGLUQFM.js";
|
|
8
|
-
import {
|
|
9
|
-
createCngApiClient
|
|
10
|
-
} from "./chunk-FJ34NVQ4.js";
|
|
11
|
-
import {
|
|
12
|
-
resolveOutputFormat
|
|
13
|
-
} from "./chunk-CBIVTEZP.js";
|
|
14
|
-
|
|
15
|
-
// src/features/knowledges/knowledges-api.ts
|
|
16
|
-
function createKnowledgesApi(options) {
|
|
17
|
-
const client = createCngApiClient(options);
|
|
18
|
-
return {
|
|
19
|
-
getCatalog: () => client.harnessKnowledges.getHarnessKnowledgesCatalog(),
|
|
20
|
-
listAudiences: () => client.harnessKnowledges.listHarnessKnowledgesAudiences(),
|
|
21
|
-
search: (query, limit) => client.harnessKnowledges.searchHarnessKnowledges({
|
|
22
|
-
q: query,
|
|
23
|
-
limit
|
|
24
|
-
}),
|
|
25
|
-
listSubskills: () => client.harnessKnowledges.listHarnessKnowledgesSubskills(),
|
|
26
|
-
listFiles: ({ query, audience, limit }) => client.harnessKnowledges.listHarnessSubskillAssets({
|
|
27
|
-
...query ? { q: query } : {},
|
|
28
|
-
...audience ? { audience } : {},
|
|
29
|
-
limit
|
|
30
|
-
}),
|
|
31
|
-
read: ({ filePath, offset, limit }) => client.harnessFilesystem.getHarnessFilesystemRead({
|
|
32
|
-
file_path: filePath,
|
|
33
|
-
offset,
|
|
34
|
-
limit
|
|
35
|
-
}),
|
|
36
|
-
grep: ({ pattern, path, include, mode, context, ignoreCase }) => client.harnessFilesystem.getHarnessFilesystemGrep({
|
|
37
|
-
pattern,
|
|
38
|
-
path,
|
|
39
|
-
include,
|
|
40
|
-
output_mode: mode,
|
|
41
|
-
context,
|
|
42
|
-
case_insensitive: ignoreCase ? "true" : void 0
|
|
43
|
-
}),
|
|
44
|
-
glob: ({ pattern, path }) => client.harnessFilesystem.getHarnessFilesystemGlob({
|
|
45
|
-
pattern,
|
|
46
|
-
path
|
|
47
|
-
}),
|
|
48
|
-
listDirectory: ({ path, limit }) => client.harnessFilesystem.getHarnessFilesystemLs({
|
|
49
|
-
path,
|
|
50
|
-
limit
|
|
51
|
-
}),
|
|
52
|
-
statPath: ({ path }) => client.harnessFilesystem.getHarnessFilesystemStat({
|
|
53
|
-
path
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// src/features/knowledges/knowledges-input.ts
|
|
59
|
-
function normalizeAudienceId(value) {
|
|
60
|
-
if (value === void 0) {
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
switch (value) {
|
|
64
|
-
case "all":
|
|
65
|
-
case "operators":
|
|
66
|
-
case "builders":
|
|
67
|
-
case "researchers":
|
|
68
|
-
case "agent-makers":
|
|
69
|
-
return value;
|
|
70
|
-
default:
|
|
71
|
-
throw new Error(
|
|
72
|
-
`Unknown audience "${value}". Run cngkit knowledges audiences to see supported values.`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function normalizeCatalogPath(value) {
|
|
77
|
-
const trimmed = value.trim();
|
|
78
|
-
if (trimmed === "/" || trimmed === "") {
|
|
79
|
-
return "skills";
|
|
80
|
-
}
|
|
81
|
-
const relativePath = trimmed.replace(/^\/+/, "");
|
|
82
|
-
if (relativePath.startsWith("skills/knowledges/")) {
|
|
83
|
-
return relativePath;
|
|
84
|
-
}
|
|
85
|
-
const [firstSegment, ...restSegments] = relativePath.split("/");
|
|
86
|
-
if (!firstSegment) {
|
|
87
|
-
return relativePath;
|
|
88
|
-
}
|
|
89
|
-
switch (firstSegment) {
|
|
90
|
-
case "concepts":
|
|
91
|
-
case "domains":
|
|
92
|
-
case "formats":
|
|
93
|
-
case "languages":
|
|
94
|
-
case "libraries":
|
|
95
|
-
case "patterns":
|
|
96
|
-
case "platforms":
|
|
97
|
-
case "procedures":
|
|
98
|
-
case "protocols":
|
|
99
|
-
case "tools":
|
|
100
|
-
return `skills/knowledges/subskills/${firstSegment}${restSegments.length > 0 ? `/${restSegments.join("/")}` : ""}`;
|
|
101
|
-
default:
|
|
102
|
-
return relativePath;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function normalizeFilesystemCatalogPath(value) {
|
|
106
|
-
const trimmed = value.trim();
|
|
107
|
-
if (trimmed === "/" || trimmed === "") {
|
|
108
|
-
return "skills/knowledges/subskills";
|
|
109
|
-
}
|
|
110
|
-
return normalizeCatalogPath(trimmed);
|
|
111
|
-
}
|
|
112
|
-
function normalizeGrepMode(value) {
|
|
113
|
-
if (value === void 0) {
|
|
114
|
-
return "content";
|
|
115
|
-
}
|
|
116
|
-
switch (value) {
|
|
117
|
-
case "content":
|
|
118
|
-
case "files_with_matches":
|
|
119
|
-
case "count":
|
|
120
|
-
return value;
|
|
121
|
-
default:
|
|
122
|
-
throw new Error("Unknown grep mode. Use one of: content, files_with_matches, count.");
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/features/knowledges/run-knowledges-command.ts
|
|
127
|
-
async function runKnowStatusCommand(options, output, dependencies) {
|
|
128
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
129
|
-
const response = await api.getCatalog();
|
|
130
|
-
if (shouldPrintJson(options)) {
|
|
131
|
-
output.raw(formatJson(response.data));
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const latestRun = response.data.latestRun;
|
|
135
|
-
const lines = [
|
|
136
|
-
`Catalog: ${response.data.name}`,
|
|
137
|
-
`Files: ${response.data.files}`,
|
|
138
|
-
`Blobs: ${response.data.blobs}`,
|
|
139
|
-
`Database: ${response.data.database.engine} (${response.data.database.binding})`
|
|
140
|
-
];
|
|
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
|
-
output.info(lines.join("\n"));
|
|
150
|
-
}
|
|
151
|
-
async function runKnowAudiencesCommand(options, output, dependencies) {
|
|
152
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
153
|
-
const response = await api.listAudiences();
|
|
154
|
-
if (shouldPrintJson(options)) {
|
|
155
|
-
output.raw(formatJson(response.data));
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const lines = response.data.audiences.flatMap((audience) => [
|
|
159
|
-
`${audience.id} - ${audience.label}`,
|
|
160
|
-
` ${singleLine(audience.help)}`
|
|
161
|
-
]);
|
|
162
|
-
output.info(lines.length > 0 ? lines.join("\n") : "No audiences available.");
|
|
163
|
-
}
|
|
164
|
-
async function runKnowSearchCommand(query, options, output, dependencies) {
|
|
165
|
-
if (!query) {
|
|
166
|
-
throw new Error("Missing search query. Usage: cngkit knowledges search <query>");
|
|
167
|
-
}
|
|
168
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
169
|
-
const response = await api.search(query, coerceLimit(options.limit, 5));
|
|
170
|
-
if (shouldPrintJson(options)) {
|
|
171
|
-
output.raw(formatJson(response.data));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const lines = response.data.results.flatMap((result, index) => [
|
|
175
|
-
`${index + 1}. ${result.title} (${result.subskillName})`,
|
|
176
|
-
` score ${result.score.toFixed(3)} | ${result.path}`,
|
|
177
|
-
` ${singleLine(result.description || result.contentPreview)}`
|
|
178
|
-
]);
|
|
179
|
-
if (lines.length > 0) {
|
|
180
|
-
output.info(lines.join("\n"));
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
output.warning(`No results for "${query}".`);
|
|
184
|
-
}
|
|
185
|
-
async function runKnowListCommand(query, options, output, dependencies) {
|
|
186
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
187
|
-
const response = await api.listSubskills();
|
|
188
|
-
const limit = coerceLimit(options.limit, 25);
|
|
189
|
-
const normalizedQuery = query?.toLowerCase();
|
|
190
|
-
const subskills = response.data.subskills.filter((subskill) => {
|
|
191
|
-
if (!normalizedQuery) {
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
return [subskill.name, subskill.title, subskill.description, subskill.type].join(" ").toLowerCase().includes(normalizedQuery);
|
|
195
|
-
}).slice(0, limit);
|
|
196
|
-
if (shouldPrintJson(options)) {
|
|
197
|
-
output.raw(formatJson({ subskills, total: subskills.length }));
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const lines = subskills.flatMap((subskill) => [
|
|
201
|
-
`${subskill.name} [${subskill.type}]`,
|
|
202
|
-
` ${subskill.title} | files ${subskill.fileCount} | rating ${subskill.rating}`,
|
|
203
|
-
` ${singleLine(subskill.description)}`
|
|
204
|
-
]);
|
|
205
|
-
if (lines.length > 0) {
|
|
206
|
-
output.info(lines.join("\n"));
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
output.warning("No matching subskills.");
|
|
210
|
-
}
|
|
211
|
-
async function runKnowFilesCommand(query, options, output, dependencies) {
|
|
212
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
213
|
-
const response = await api.listFiles({
|
|
214
|
-
query,
|
|
215
|
-
audience: normalizeAudienceId(options.audience),
|
|
216
|
-
limit: coerceLimit(options.limit, 25)
|
|
217
|
-
});
|
|
218
|
-
if (shouldPrintJson(options)) {
|
|
219
|
-
output.raw(formatJson(response.data));
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
const lines = response.data.files.map((file) => {
|
|
223
|
-
const title = file.display_title ?? file.title ?? file.subskill_name ?? "Untitled";
|
|
224
|
-
return `${file.path}
|
|
225
|
-
${title}`;
|
|
226
|
-
});
|
|
227
|
-
if (lines.length > 0) {
|
|
228
|
-
output.info(lines.join("\n"));
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
output.warning("No matching files.");
|
|
232
|
-
}
|
|
233
|
-
async function runKnowReadCommand(filePath, options, output, dependencies) {
|
|
234
|
-
if (!filePath) {
|
|
235
|
-
throw new Error("Missing file_path. Usage: cngkit knowledges read <file_path>");
|
|
236
|
-
}
|
|
237
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
238
|
-
const response = await api.read({
|
|
239
|
-
filePath: normalizeCatalogPath(filePath),
|
|
240
|
-
offset: coerceOptionalNumber(options.offset),
|
|
241
|
-
limit: coerceLimit(options.limit, 200, 2e3)
|
|
242
|
-
});
|
|
243
|
-
if (shouldPrintJson(options)) {
|
|
244
|
-
output.raw(formatJson(response.data));
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
if (resolveOutputFormat() === "markdown" || !response.data.file_path.endsWith(".md")) {
|
|
248
|
-
output.raw(response.data.content);
|
|
249
|
-
} else {
|
|
250
|
-
output.markdown(response.data.content);
|
|
251
|
-
}
|
|
252
|
-
if (response.data.truncated) {
|
|
253
|
-
output.warning(
|
|
254
|
-
`[truncated: showing ${response.data.limit} lines from offset ${response.data.offset} of ${response.data.total_lines}]`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
async function runKnowGrepCommand(pattern, options, output, dependencies) {
|
|
259
|
-
if (!pattern) {
|
|
260
|
-
throw new Error("Missing pattern. Usage: cngkit knowledges grep <pattern>");
|
|
261
|
-
}
|
|
262
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
263
|
-
const limit = options.limit !== void 0 ? coerceOptionalNumber(options.limit) : void 0;
|
|
264
|
-
const response = await api.grep({
|
|
265
|
-
pattern,
|
|
266
|
-
path: normalizeCatalogPath(options.path ?? "/"),
|
|
267
|
-
include: options.include ?? "*",
|
|
268
|
-
mode: normalizeGrepMode(options.outputMode),
|
|
269
|
-
context: coerceLimit(options.context, 0, 20),
|
|
270
|
-
ignoreCase: options.caseInsensitive === true
|
|
271
|
-
});
|
|
272
|
-
if (shouldPrintJson(options)) {
|
|
273
|
-
output.raw(formatJson(response.data));
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (response.data.mode === "files_with_matches") {
|
|
277
|
-
const files = limit ? response.data.files.slice(0, limit) : response.data.files;
|
|
278
|
-
if (files.length > 0) {
|
|
279
|
-
output.raw(files.join("\n"));
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
output.warning(`No files matched "${pattern}".`);
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if (response.data.mode === "count") {
|
|
286
|
-
const counts = limit ? response.data.counts.slice(0, limit) : response.data.counts;
|
|
287
|
-
const lines2 = counts.map((count) => `${count.file_path}: ${count.match_count}`);
|
|
288
|
-
if (lines2.length > 0) {
|
|
289
|
-
output.raw(lines2.join("\n"));
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
output.warning(`No matches for "${pattern}".`);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const matches = limit ? response.data.matches.slice(0, limit) : response.data.matches;
|
|
296
|
-
const lines = matches.flatMap((match) => [
|
|
297
|
-
`${match.file_path}:${match.line_number}`,
|
|
298
|
-
...match.context_before.map((line) => ` ${line}`),
|
|
299
|
-
`> ${match.line}`,
|
|
300
|
-
...match.context_after.map((line) => ` ${line}`)
|
|
301
|
-
]);
|
|
302
|
-
if (lines.length > 0) {
|
|
303
|
-
output.raw(lines.join("\n"));
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
output.warning(`No matches for "${pattern}".`);
|
|
307
|
-
}
|
|
308
|
-
async function runKnowGlobCommand(pattern, options, output, dependencies) {
|
|
309
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
310
|
-
const limit = options.limit !== void 0 ? coerceOptionalNumber(options.limit) : void 0;
|
|
311
|
-
const response = await api.glob({
|
|
312
|
-
pattern: pattern ?? "**/*.md",
|
|
313
|
-
path: normalizeCatalogPath(options.path ?? "/")
|
|
314
|
-
});
|
|
315
|
-
if (shouldPrintJson(options)) {
|
|
316
|
-
output.raw(formatJson(response.data));
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const files = limit ? response.data.files.slice(0, limit) : response.data.files;
|
|
320
|
-
const wasClientTruncated = limit ? response.data.files.length > limit : false;
|
|
321
|
-
if (files.length > 0) {
|
|
322
|
-
output.raw(files.join("\n"));
|
|
323
|
-
} else {
|
|
324
|
-
output.warning("No matching files.");
|
|
325
|
-
}
|
|
326
|
-
if (response.data.truncated || wasClientTruncated) {
|
|
327
|
-
output.warning(`[truncated: ${response.data.total_files} total files]`);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
async function runKnowLsCommand(path, options, output, dependencies) {
|
|
331
|
-
const api = dependencies?.api ?? createKnowledgesApi(options);
|
|
332
|
-
const response = await api.listDirectory({
|
|
333
|
-
path: normalizeFilesystemCatalogPath(path ?? "/"),
|
|
334
|
-
limit: coerceLimit(options.limit, 100, 1e3)
|
|
335
|
-
});
|
|
336
|
-
if (shouldPrintJson(options)) {
|
|
337
|
-
output.raw(formatJson(response.data));
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const entries = [...response.data.entries].sort(compareFilesystemEntries);
|
|
341
|
-
const lines = entries.map(formatFilesystemEntryLine);
|
|
342
|
-
if (lines.length > 0) {
|
|
343
|
-
output.raw(lines.join("\n"));
|
|
344
|
-
} else {
|
|
345
|
-
output.warning(`No entries under ${response.data.path}.`);
|
|
346
|
-
}
|
|
347
|
-
if (response.data.truncated) {
|
|
348
|
-
output.warning(`[truncated: ${response.data.total_entries} total entries]`);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
function compareFilesystemEntries(left, right) {
|
|
352
|
-
if (left.type !== right.type) {
|
|
353
|
-
return left.type === "directory" ? -1 : 1;
|
|
354
|
-
}
|
|
355
|
-
return left.path.localeCompare(right.path);
|
|
356
|
-
}
|
|
357
|
-
function formatFilesystemEntryLine(entry) {
|
|
358
|
-
const fields = [
|
|
359
|
-
entry.type,
|
|
360
|
-
entry.path,
|
|
361
|
-
...formatOptionalEntryFields([
|
|
362
|
-
["size", entry.size],
|
|
363
|
-
["files", entry.file_count],
|
|
364
|
-
["children", entry.child_count],
|
|
365
|
-
["total_size", entry.total_size],
|
|
366
|
-
["sha256", entry.sha256],
|
|
367
|
-
["asset_kind", entry.asset_kind],
|
|
368
|
-
["subskill", entry.subskill_name]
|
|
369
|
-
])
|
|
370
|
-
];
|
|
371
|
-
return fields.join(" ");
|
|
372
|
-
}
|
|
373
|
-
function formatOptionalEntryFields(fields) {
|
|
374
|
-
return fields.flatMap(([key, value]) => {
|
|
375
|
-
if (value === null || value === "") {
|
|
376
|
-
return [];
|
|
377
|
-
}
|
|
378
|
-
return [`${key}=${value}`];
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export {
|
|
383
|
-
runKnowStatusCommand,
|
|
384
|
-
runKnowAudiencesCommand,
|
|
385
|
-
runKnowSearchCommand,
|
|
386
|
-
runKnowListCommand,
|
|
387
|
-
runKnowFilesCommand,
|
|
388
|
-
runKnowReadCommand,
|
|
389
|
-
runKnowGrepCommand,
|
|
390
|
-
runKnowGlobCommand,
|
|
391
|
-
runKnowLsCommand
|
|
392
|
-
};
|
|
393
|
-
//# sourceMappingURL=chunk-C7HFDK4S.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 listSubskills(): Promise<CngApi.HarnessSubskillsApiResponse>;\n listFiles(options: {\n query?: string;\n audience?: CngApi.HarnessAudienceId;\n limit: number;\n }): Promise<CngApi.HarnessSubskillAssetsApiResponse>;\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 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 listSubskills: () => client.harnessKnowledges.listHarnessKnowledgesSubskills(),\n listFiles: ({ query, audience, limit }) =>\n client.harnessKnowledges.listHarnessSubskillAssets({\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 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/subskills/${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/subskills\";\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 { formatKnowledgesHelp } 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 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 };\n\nexport type KnowStatCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowRealpathCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowledgesCliOptions = KnowFilesCommandOptions &\n KnowGlobCommandOptions &\n KnowGrepCommandOptions &\n KnowReadCommandOptions &\n KnowSearchCommandOptions &\n KnowLsCommandOptions;\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.markdown(formatKnowledgesHelp(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(optionalJoinedArgument(subcommandArgs), options, output, dependencies);\n case \"list\":\n return runKnowListCommand(optionalJoinedArgument(subcommandArgs), options, output, dependencies);\n case \"files\":\n return runKnowFilesCommand(optionalJoinedArgument(subcommandArgs), options, output, dependencies);\n case \"read\":\n return runKnowReadCommand(subcommandArgs[0], options, output, dependencies);\n case \"grep\":\n return runKnowGrepCommand(optionalJoinedArgument(subcommandArgs), options, output, dependencies);\n case \"glob\":\n return runKnowGlobCommand(optionalJoinedArgument(subcommandArgs), options, output, dependencies);\n case \"ls\":\n return runKnowLsCommand(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|grep|glob|ls|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 latestRun = response.data.latestRun;\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 if (latestRun) {\n lines.push(`Latest run: ${latestRun.status} (${latestRun.id})`);\n if (latestRun.updated_at) {\n lines.push(`Updated: ${latestRun.updated_at}`);\n }\n } else {\n lines.push(\"Latest run: none\");\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.subskillName})`,\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.listSubskills();\n const limit = coerceLimit(options.limit, 25);\n const normalizedQuery = query?.toLowerCase();\n const subskills = response.data.subskills\n .filter((subskill) => {\n if (!normalizedQuery) {\n return true;\n }\n return [subskill.name, subskill.title, subskill.description, subskill.type]\n .join(\" \")\n .toLowerCase()\n .includes(normalizedQuery);\n })\n .slice(0, limit);\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson({ subskills, total: subskills.length }));\n return;\n }\n\n const lines = subskills.flatMap((subskill) => [\n `${subskill.name} [${subskill.type}]`,\n ` ${subskill.title} | files ${subskill.fileCount} | rating ${subskill.rating}`,\n ` ${singleLine(subskill.description)}`,\n ]);\n\n if (lines.length > 0) {\n output.info(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(\"No matching subskills.\");\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.subskill_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 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(formatFilesystemEntryLine);\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 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 formatFilesystemEntryLine(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 [\"subskill\", entry.subskill_name],\n ]),\n ];\n\n return fields.join(\"\\t\");\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 [\"subskill\", entry.subskill_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]) =>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C3B,WAAO,QAAQ,eAAe,SAAS,KAAK,aAAa,iBAAiB;AAAA,EAC5E;AACF;AA2CA,SAAS,yBACP,MACA,OACQ;AACR,MAAI,KAAK,SAAS,MAAM,MAAM;AAC5B,WAAO,KAAK,SAAS,cAAc,KAAK;AAAA,EAC1C;AAEA,SAAO,KAAK,KAAK,cAAc,MAAM,IAAI;AAC3C;AAEA,SAAS,0BAA0B,OAA8C;AAC/E,QAAM,SAAS;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,GAAG,0BAA0B;AAAA,MAC3B,CAAC,QAAQ,MAAM,IAAI;AAAA,MACnB,CAAC,SAAS,MAAM,UAAU;AAAA,MAC1B,CAAC,YAAY,MAAM,WAAW;AAAA,MAC9B,CAAC,cAAc,MAAM,UAAU;AAAA,MAC/B,CAAC,UAAU,MAAM,MAAM;AAAA,MACvB,CAAC,cAAc,MAAM,UAAU;AAAA,MAC/B,CAAC,YAAY,MAAM,aAAa;AAAA,IAClC,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,KAAK,GAAI;AACzB;AAsBA,SAAS,0BAA0B,QAA2D;AAC5F,SAAO,OAAO,QAAQ,CAAC,CAAC,KAAK,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"]}
|
package/dist/chunk-CBIVTEZP.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// src/shared/config.ts
|
|
2
|
-
import { randomBytes, randomUUID } from "crypto";
|
|
3
|
-
import process from "process";
|
|
4
|
-
var packageVersion = "1.1.18";
|
|
5
|
-
var defaultApiBaseUrl = "https://curly.ng";
|
|
6
|
-
function resolveApiBaseUrl(options) {
|
|
7
|
-
void options;
|
|
8
|
-
return defaultApiBaseUrl;
|
|
9
|
-
}
|
|
10
|
-
function resolveOutputFormat() {
|
|
11
|
-
const value = process.env.CNGKIT_FORMAT?.toLowerCase();
|
|
12
|
-
if (value === "json" || value === "markdown") {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
return "text";
|
|
16
|
-
}
|
|
17
|
-
function parseOutputFormat(value) {
|
|
18
|
-
const normalizedValue = value.toLowerCase();
|
|
19
|
-
if (normalizedValue === "text" || normalizedValue === "json" || normalizedValue === "markdown") {
|
|
20
|
-
return normalizedValue;
|
|
21
|
-
}
|
|
22
|
-
throw new Error("Unknown --format value. Use one of: text, json, markdown.");
|
|
23
|
-
}
|
|
24
|
-
function createRoomCode() {
|
|
25
|
-
return randomBytes(4).toString("hex").toUpperCase();
|
|
26
|
-
}
|
|
27
|
-
function createPeerId() {
|
|
28
|
-
return randomUUID();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/shared/output.ts
|
|
32
|
-
import process2 from "process";
|
|
33
|
-
import { createElement } from "react";
|
|
34
|
-
import { renderToString, Text } from "ink";
|
|
35
|
-
import Markdown from "@inkkit/ink-markdown";
|
|
36
|
-
import stripAnsi from "strip-ansi";
|
|
37
|
-
|
|
38
|
-
// src/shared/theme.ts
|
|
39
|
-
import { Chalk } from "chalk";
|
|
40
|
-
var statusStylePropsByOutputStyle = {
|
|
41
|
-
info: {
|
|
42
|
-
color: "cyan"
|
|
43
|
-
},
|
|
44
|
-
success: {
|
|
45
|
-
color: "green",
|
|
46
|
-
bold: true
|
|
47
|
-
},
|
|
48
|
-
warning: {
|
|
49
|
-
color: "yellow",
|
|
50
|
-
bold: true
|
|
51
|
-
},
|
|
52
|
-
muted: {
|
|
53
|
-
dimColor: true
|
|
54
|
-
},
|
|
55
|
-
error: {
|
|
56
|
-
color: "red",
|
|
57
|
-
bold: true
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
function createMarkdownTheme(useColor) {
|
|
61
|
-
const chalk = new Chalk({ level: useColor ? 1 : 0 });
|
|
62
|
-
const identity = (value) => value;
|
|
63
|
-
return {
|
|
64
|
-
code: chalk.green,
|
|
65
|
-
blockquote: chalk.dim.italic,
|
|
66
|
-
html: chalk.gray,
|
|
67
|
-
heading: chalk.blueBright.bold,
|
|
68
|
-
firstHeading: chalk.magentaBright.bold,
|
|
69
|
-
hr: chalk.gray,
|
|
70
|
-
listitem: identity,
|
|
71
|
-
table: identity,
|
|
72
|
-
paragraph: identity,
|
|
73
|
-
strong: chalk.bold,
|
|
74
|
-
em: chalk.italic,
|
|
75
|
-
codespan: chalk.cyanBright,
|
|
76
|
-
del: chalk.dim.strikethrough,
|
|
77
|
-
link: chalk.blueBright,
|
|
78
|
-
href: chalk.blue.underline,
|
|
79
|
-
text: identity,
|
|
80
|
-
showSectionPrefix: false,
|
|
81
|
-
reflowText: true,
|
|
82
|
-
unescape: true,
|
|
83
|
-
emoji: false,
|
|
84
|
-
tab: 2
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// src/shared/output.ts
|
|
89
|
-
var consoleOutput = createCommandOutput(process2.stdout, process2.stderr);
|
|
90
|
-
function createCommandOutput(stdout, stderr) {
|
|
91
|
-
return {
|
|
92
|
-
info(message) {
|
|
93
|
-
writeStyledMessage(stdout, "info", message);
|
|
94
|
-
},
|
|
95
|
-
success(message) {
|
|
96
|
-
writeStyledMessage(stdout, "success", message);
|
|
97
|
-
},
|
|
98
|
-
warning(message) {
|
|
99
|
-
writeStyledMessage(stdout, "warning", message);
|
|
100
|
-
},
|
|
101
|
-
muted(message) {
|
|
102
|
-
writeStyledMessage(stdout, "muted", message);
|
|
103
|
-
},
|
|
104
|
-
markdown(message) {
|
|
105
|
-
stdout.write(`${formatMarkdownMessage(stdout, message)}
|
|
106
|
-
`);
|
|
107
|
-
},
|
|
108
|
-
raw(message) {
|
|
109
|
-
stdout.write(`${message}
|
|
110
|
-
`);
|
|
111
|
-
},
|
|
112
|
-
error(message) {
|
|
113
|
-
writeStyledMessage(stderr, "error", message);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function formatError(error) {
|
|
118
|
-
return error instanceof Error ? error.message : String(error);
|
|
119
|
-
}
|
|
120
|
-
function writeStyledMessage(stream, style, message) {
|
|
121
|
-
stream.write(`${formatStyledMessage(stream, style, message)}
|
|
122
|
-
`);
|
|
123
|
-
}
|
|
124
|
-
function formatStyledMessage(stream, style, message) {
|
|
125
|
-
if (!shouldRenderColor(stream)) {
|
|
126
|
-
return message;
|
|
127
|
-
}
|
|
128
|
-
return renderToString(
|
|
129
|
-
createElement(
|
|
130
|
-
Text,
|
|
131
|
-
{
|
|
132
|
-
...statusStylePropsByOutputStyle[style],
|
|
133
|
-
wrap: "wrap"
|
|
134
|
-
},
|
|
135
|
-
message
|
|
136
|
-
),
|
|
137
|
-
{
|
|
138
|
-
columns: 1e4
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
function formatMarkdownMessage(stream, markdown) {
|
|
143
|
-
if (resolveOutputFormat() === "markdown") {
|
|
144
|
-
return markdown;
|
|
145
|
-
}
|
|
146
|
-
const useColor = shouldRenderColor(stream);
|
|
147
|
-
const markdownWidth = clampMarkdownWidth(stream.columns);
|
|
148
|
-
const preparedMarkdown = prepareMarkdownForTerminal(markdown);
|
|
149
|
-
const renderedMarkdown = renderToString(
|
|
150
|
-
createElement(
|
|
151
|
-
Markdown,
|
|
152
|
-
{
|
|
153
|
-
...createMarkdownTheme(useColor),
|
|
154
|
-
children: preparedMarkdown,
|
|
155
|
-
width: markdownWidth
|
|
156
|
-
}
|
|
157
|
-
),
|
|
158
|
-
{
|
|
159
|
-
columns: markdownWidth
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
return useColor ? renderedMarkdown.trimEnd() : stripAnsi(renderedMarkdown).trimEnd();
|
|
163
|
-
}
|
|
164
|
-
function prepareMarkdownForTerminal(markdown) {
|
|
165
|
-
if (!markdown.startsWith("---\n")) {
|
|
166
|
-
return markdown;
|
|
167
|
-
}
|
|
168
|
-
const frontmatterEndIndex = markdown.indexOf("\n---", 4);
|
|
169
|
-
if (frontmatterEndIndex < 0) {
|
|
170
|
-
return formatFrontmatterForTerminal(markdown.slice(4).trimEnd());
|
|
171
|
-
}
|
|
172
|
-
const frontmatter = markdown.slice(4, frontmatterEndIndex).trimEnd();
|
|
173
|
-
const body = markdown.slice(frontmatterEndIndex + "\n---".length).replace(/^\n+/, "");
|
|
174
|
-
return `${formatFrontmatterForTerminal(frontmatter)}
|
|
175
|
-
|
|
176
|
-
${body}`;
|
|
177
|
-
}
|
|
178
|
-
function formatFrontmatterForTerminal(frontmatter) {
|
|
179
|
-
return `## Metadata
|
|
180
|
-
|
|
181
|
-
\`\`\`yaml
|
|
182
|
-
${frontmatter}
|
|
183
|
-
\`\`\``;
|
|
184
|
-
}
|
|
185
|
-
function shouldRenderColor(stream) {
|
|
186
|
-
if (process2.env.CNGKIT_NO_COLOR === "1") {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
const colorMode = process2.env.CNGKIT_COLOR?.toLowerCase();
|
|
190
|
-
if (colorMode === "never" || colorMode === "0" || colorMode === "false") {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
if (colorMode === "always" || colorMode === "1" || colorMode === "true") {
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
if (process2.env.FORCE_COLOR !== void 0 && process2.env.FORCE_COLOR !== "0") {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
if (process2.env.NO_COLOR !== void 0) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
return stream.isTTY === true;
|
|
203
|
-
}
|
|
204
|
-
function clampMarkdownWidth(columns) {
|
|
205
|
-
if (columns === void 0) {
|
|
206
|
-
return 100;
|
|
207
|
-
}
|
|
208
|
-
return Math.max(72, Math.min(columns, 120));
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export {
|
|
212
|
-
packageVersion,
|
|
213
|
-
resolveApiBaseUrl,
|
|
214
|
-
resolveOutputFormat,
|
|
215
|
-
parseOutputFormat,
|
|
216
|
-
createRoomCode,
|
|
217
|
-
createPeerId,
|
|
218
|
-
consoleOutput,
|
|
219
|
-
createCommandOutput,
|
|
220
|
-
formatError
|
|
221
|
-
};
|
|
222
|
-
//# sourceMappingURL=chunk-CBIVTEZP.js.map
|