cngkit 1.1.21 → 1.1.23
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 +198 -4
- package/README.md +22 -12
- package/dist/{chunk-NGEWD4BW.js → chunk-25Q463MH.js} +1 -2
- package/dist/{chunk-SMTQ3W3F.js → chunk-3BATDTKU.js} +131 -112
- package/dist/chunk-3BATDTKU.js.map +1 -0
- package/dist/{chunk-DIJEVOVN.js → chunk-67FUBMNB.js} +71 -240
- package/dist/chunk-67FUBMNB.js.map +1 -0
- package/dist/chunk-AS7FIJWP.js +88 -0
- package/dist/chunk-AS7FIJWP.js.map +1 -0
- package/dist/chunk-BRFWVQI4.js +18 -0
- package/dist/chunk-BRFWVQI4.js.map +1 -0
- package/dist/{chunk-CVF2ODLP.js → chunk-BXS4IKUA.js} +300 -143
- package/dist/chunk-BXS4IKUA.js.map +1 -0
- package/dist/{chunk-YJXAH7D5.js → chunk-GYRLVNJX.js} +2 -2
- package/dist/chunk-GYRLVNJX.js.map +1 -0
- package/dist/{chunk-SKK2XLRZ.js → chunk-JNHW72SU.js} +21 -15
- package/dist/chunk-JNHW72SU.js.map +1 -0
- package/dist/chunk-U725ZHCI.js +67 -0
- package/dist/chunk-U725ZHCI.js.map +1 -0
- package/dist/chunk-VMTXY4KQ.js +111 -0
- package/dist/chunk-VMTXY4KQ.js.map +1 -0
- package/dist/chunk-WIEYHKQA.js +268 -0
- package/dist/chunk-WIEYHKQA.js.map +1 -0
- package/dist/chunk-YALWTRIP.js +102 -0
- package/dist/chunk-YALWTRIP.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/coderoom/index.js +4 -4
- package/dist/commands/coderoom/join.js +5 -5
- package/dist/commands/coderoom/share.js +8 -11
- package/dist/commands/coderoom/share.js.map +1 -1
- package/dist/commands/hookify/index.js +4 -4
- package/dist/commands/hookify/ingest.js +4 -4
- package/dist/commands/hooks/index.js +4 -4
- package/dist/commands/hooks/install.js +4 -4
- package/dist/commands/hooks/uninstall.js +4 -4
- package/dist/commands/index.js +3 -3
- package/dist/commands/knowledges/audiences.js +26 -8
- package/dist/commands/knowledges/audiences.js.map +1 -1
- package/dist/commands/knowledges/cat.js +26 -7
- package/dist/commands/knowledges/cat.js.map +1 -1
- package/dist/commands/knowledges/files.js +39 -8
- package/dist/commands/knowledges/files.js.map +1 -1
- package/dist/commands/knowledges/find.js +48 -8
- package/dist/commands/knowledges/find.js.map +1 -1
- package/dist/commands/knowledges/glob.js +41 -8
- package/dist/commands/knowledges/glob.js.map +1 -1
- package/dist/commands/knowledges/grep.js +73 -8
- package/dist/commands/knowledges/grep.js.map +1 -1
- package/dist/commands/knowledges/head.js +31 -8
- package/dist/commands/knowledges/head.js.map +1 -1
- package/dist/commands/knowledges/index.js +4 -4
- package/dist/commands/knowledges/list.js +39 -8
- package/dist/commands/knowledges/list.js.map +1 -1
- package/dist/commands/knowledges/ls.js +47 -8
- package/dist/commands/knowledges/ls.js.map +1 -1
- package/dist/commands/knowledges/read.js +46 -8
- package/dist/commands/knowledges/read.js.map +1 -1
- package/dist/commands/knowledges/realpath.js +23 -8
- package/dist/commands/knowledges/realpath.js.map +1 -1
- package/dist/commands/knowledges/search.js +34 -8
- package/dist/commands/knowledges/search.js.map +1 -1
- package/dist/commands/knowledges/stat.js +32 -8
- package/dist/commands/knowledges/stat.js.map +1 -1
- package/dist/commands/knowledges/status.js +26 -8
- package/dist/commands/knowledges/status.js.map +1 -1
- package/dist/commands/knowledges/tail.js +30 -8
- package/dist/commands/knowledges/tail.js.map +1 -1
- package/dist/commands/knowledges/tree.js +38 -8
- package/dist/commands/knowledges/tree.js.map +1 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/scrub.js +3 -3
- package/dist/commands/scrub.js.map +1 -1
- package/dist/commands/transcripts.js +137 -119
- package/dist/commands/transcripts.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-52PGDSFU.js +0 -42
- package/dist/chunk-52PGDSFU.js.map +0 -1
- package/dist/chunk-5WTRGYAO.js +0 -658
- package/dist/chunk-5WTRGYAO.js.map +0 -1
- package/dist/chunk-CVF2ODLP.js.map +0 -1
- package/dist/chunk-DIJEVOVN.js.map +0 -1
- package/dist/chunk-SKK2XLRZ.js.map +0 -1
- package/dist/chunk-SMTQ3W3F.js.map +0 -1
- package/dist/chunk-YJXAH7D5.js.map +0 -1
- /package/dist/{chunk-NGEWD4BW.js.map → chunk-25Q463MH.js.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hookToolIds,
|
|
3
3
|
runHooksInstallCommand
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-3BATDTKU.js";
|
|
5
5
|
import {
|
|
6
6
|
GlobalOptionsSchema
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-25Q463MH.js";
|
|
8
8
|
import {
|
|
9
9
|
CommandRunner
|
|
10
|
-
} from "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
10
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
11
|
+
import "../../chunk-67FUBMNB.js";
|
|
12
12
|
import "../../chunk-PZ5AY32C.js";
|
|
13
13
|
|
|
14
14
|
// src/commands/hooks/install.tsx
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hookToolIds,
|
|
3
3
|
runHooksUninstallCommand
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-3BATDTKU.js";
|
|
5
5
|
import {
|
|
6
6
|
GlobalOptionsSchema
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-25Q463MH.js";
|
|
8
8
|
import {
|
|
9
9
|
CommandRunner
|
|
10
|
-
} from "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
10
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
11
|
+
import "../../chunk-67FUBMNB.js";
|
|
12
12
|
import "../../chunk-PZ5AY32C.js";
|
|
13
13
|
|
|
14
14
|
// src/commands/hooks/uninstall.tsx
|
package/dist/commands/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderCngkitHelp
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-JNHW72SU.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandRunner
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-WIEYHKQA.js";
|
|
7
|
+
import "../chunk-67FUBMNB.js";
|
|
8
8
|
import "../chunk-PZ5AY32C.js";
|
|
9
9
|
|
|
10
10
|
// src/commands/index.tsx
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
KnowAudienceList
|
|
3
|
+
} from "../../chunk-VMTXY4KQ.js";
|
|
4
|
+
import {
|
|
5
|
+
createKnowledgesApi
|
|
6
|
+
} from "../../chunk-U725ZHCI.js";
|
|
7
|
+
import "../../chunk-AS7FIJWP.js";
|
|
8
|
+
import {
|
|
9
|
+
formatJson,
|
|
10
|
+
shouldPrintJson
|
|
11
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
12
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
13
|
import {
|
|
8
14
|
JsonOutputOptionsSchema
|
|
9
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-25Q463MH.js";
|
|
10
16
|
import {
|
|
11
17
|
CommandRunner
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
18
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
19
|
+
import "../../chunk-67FUBMNB.js";
|
|
14
20
|
import "../../chunk-PZ5AY32C.js";
|
|
15
21
|
|
|
22
|
+
// src/features/knowledges/handlers/audiences.ts
|
|
23
|
+
import { createElement } from "react";
|
|
24
|
+
async function runKnowAudiencesCommand(options2, output, dependencies) {
|
|
25
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
26
|
+
const response = await api.listAudiences();
|
|
27
|
+
if (shouldPrintJson(options2)) {
|
|
28
|
+
output.raw(formatJson(response.data));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
output.component(createElement(KnowAudienceList, { audiences: response.data.audiences }));
|
|
32
|
+
}
|
|
33
|
+
|
|
16
34
|
// src/commands/knowledges/audiences.tsx
|
|
17
35
|
import { jsx } from "react/jsx-runtime";
|
|
18
36
|
var description = "List valid audience filters";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/audiences.tsx"],"sourcesContent":["import { JsonOutputOptionsSchema } from \"../../cli/options.js\";\nimport { runKnowAudiencesCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/features/knowledges/handlers/audiences.ts","../../../src/commands/knowledges/audiences.tsx"],"sourcesContent":["import { createElement } from \"react\";\n\nimport { formatJson, shouldPrintJson } from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { KnowAudienceList } from \"../knowledges-output.js\";\nimport type { KnowAudiencesCommandOptions } from \"../knowledges-options.js\";\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 output.component(createElement(KnowAudienceList, { audiences: response.data.audiences }));\n}\n","import { JsonOutputOptionsSchema } from \"../../cli/options.js\";\nimport { runKnowAudiencesCommand } from \"../../features/knowledges/handlers/audiences.js\";\nimport type { KnowAudiencesCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"List valid audience filters\";\nexport const options = JsonOutputOptionsSchema;\n\ntype AudiencesCommandProps = {\n readonly options: KnowAudiencesCommandOptions;\n};\n\nexport default function AudiencesCommand({ options }: AudiencesCommandProps) {\n return <CommandRunner run={(output) => runKnowAudiencesCommand(options, output)} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAQ9B,eAAsB,wBACpBA,UACA,QACA,cACe;AACf,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,WAAW,MAAM,IAAI,cAAc;AAEzC,MAAI,gBAAgBA,QAAO,GAAG;AAC5B,WAAO,IAAI,WAAW,SAAS,IAAI,CAAC;AACpC;AAAA,EACF;AAEA,SAAO,UAAU,cAAc,kBAAkB,EAAE,WAAW,SAAS,KAAK,UAAU,CAAC,CAAC;AAC1F;;;ACTS;AARF,IAAM,cAAc;AACpB,IAAM,UAAU;AAMR,SAAR,iBAAkC,EAAE,SAAAC,SAAQ,GAA0B;AAC3E,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,wBAAwBA,UAAS,MAAM,GAAG;AACnF;","names":["options","options"]}
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
2
|
+
outputRawContent
|
|
3
|
+
} from "../../chunk-BRFWVQI4.js";
|
|
4
|
+
import {
|
|
5
|
+
createKnowledgesApi
|
|
6
|
+
} from "../../chunk-U725ZHCI.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeCatalogPath
|
|
9
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
4
10
|
import "../../chunk-XQGLUQFM.js";
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-YJXAH7D5.js";
|
|
11
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
12
|
import {
|
|
8
13
|
JsonOutputOptionsSchema,
|
|
9
14
|
RequiredFilePathArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
16
|
import {
|
|
12
17
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
18
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
19
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
20
|
import "../../chunk-PZ5AY32C.js";
|
|
16
21
|
|
|
22
|
+
// src/features/knowledges/handlers/cat.ts
|
|
23
|
+
async function runKnowCatCommand(filePath, options2, output, dependencies) {
|
|
24
|
+
if (!filePath) {
|
|
25
|
+
throw new Error("Missing file_path. Usage: cngkit knowledges cat <file_path>");
|
|
26
|
+
}
|
|
27
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
28
|
+
const response = await api.read({
|
|
29
|
+
filePath: normalizeCatalogPath(filePath),
|
|
30
|
+
offset: 0,
|
|
31
|
+
limit: 2e3
|
|
32
|
+
});
|
|
33
|
+
outputRawContent(response.data, options2, output);
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
// src/commands/knowledges/cat.tsx
|
|
18
37
|
import { jsx } from "react/jsx-runtime";
|
|
19
38
|
var description = "Print a remote catalog file as raw text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/cat.tsx"],"sourcesContent":["import { JsonOutputOptionsSchema, RequiredFilePathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowCatCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/features/knowledges/handlers/cat.ts","../../../src/commands/knowledges/cat.tsx"],"sourcesContent":["import type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { normalizeCatalogPath } from \"../knowledges-input.js\";\nimport type { KnowCatCommandOptions } from \"../knowledges-options.js\";\nimport { outputRawContent } from \"../format/content-format.js\";\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","import { JsonOutputOptionsSchema, RequiredFilePathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowCatCommand } from \"../../features/knowledges/handlers/cat.js\";\nimport type { KnowCatCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"Print a remote catalog file as raw text\";\nexport const args = RequiredFilePathArgsSchema;\nexport const options = JsonOutputOptionsSchema;\n\ntype CatCommandProps = {\n readonly args: [string];\n readonly options: KnowCatCommandOptions;\n};\n\nexport default function CatCommand({ args, options }: CatCommandProps) {\n return <CommandRunner run={(output) => runKnowCatCommand(args[0], options, output)} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,eAAsB,kBACpB,UACAA,UACA,QACA,cACe;AACf,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,6DAA6D;AAAA,EAC/E;AAEA,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,WAAW,MAAM,IAAI,KAAK;AAAA,IAC9B,UAAU,qBAAqB,QAAQ;AAAA,IACvC,QAAQ;AAAA,IACR,OAAO;AAAA,EACT,CAAC;AAED,mBAAiB,SAAS,MAAMA,UAAS,MAAM;AACjD;;;ACTS;AAVF,IAAM,cAAc;AACpB,IAAM,OAAO;AACb,IAAM,UAAU;AAOR,SAAR,WAA4B,EAAE,MAAAC,OAAM,SAAAC,SAAQ,GAAoB;AACrE,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,kBAAkBD,MAAK,CAAC,GAAGC,UAAS,MAAM,GAAG;AACtF;","names":["options","args","options"]}
|
|
@@ -1,22 +1,53 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
KnowTopicFileList
|
|
3
|
+
} from "../../chunk-VMTXY4KQ.js";
|
|
4
|
+
import {
|
|
5
|
+
createKnowledgesApi
|
|
6
|
+
} from "../../chunk-U725ZHCI.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeAudienceId
|
|
9
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
10
|
+
import {
|
|
11
|
+
coerceLimit,
|
|
12
|
+
formatJson,
|
|
13
|
+
shouldPrintJson
|
|
14
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
15
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
16
|
import {
|
|
8
17
|
JsonOutputOptionsSchema,
|
|
9
18
|
OptionalQueryArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
19
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
20
|
import {
|
|
12
21
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
22
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
23
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
24
|
import "../../chunk-PZ5AY32C.js";
|
|
16
25
|
|
|
17
26
|
// src/commands/knowledges/files.tsx
|
|
18
27
|
import { option } from "pastel";
|
|
19
28
|
import { z } from "zod";
|
|
29
|
+
|
|
30
|
+
// src/features/knowledges/handlers/files.ts
|
|
31
|
+
import { createElement } from "react";
|
|
32
|
+
async function runKnowFilesCommand(query, options2, output, dependencies) {
|
|
33
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
34
|
+
const response = await api.listFiles({
|
|
35
|
+
query,
|
|
36
|
+
audience: normalizeAudienceId(options2.audience),
|
|
37
|
+
limit: coerceLimit(options2.limit, 25)
|
|
38
|
+
});
|
|
39
|
+
if (shouldPrintJson(options2)) {
|
|
40
|
+
output.raw(formatJson(response.data));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (response.data.files.length > 0) {
|
|
44
|
+
output.component(createElement(KnowTopicFileList, { files: response.data.files }));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
output.warning("No matching files.");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/commands/knowledges/files.tsx
|
|
20
51
|
import { jsx } from "react/jsx-runtime";
|
|
21
52
|
var description = "List uploaded catalog files";
|
|
22
53
|
var args = OptionalQueryArgsSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/files.tsx"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, OptionalQueryArgsSchema } from \"../../cli/options.js\";\nimport { runKnowFilesCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/knowledges/files.tsx","../../../src/features/knowledges/handlers/files.ts"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, OptionalQueryArgsSchema } from \"../../cli/options.js\";\nimport { runKnowFilesCommand } from \"../../features/knowledges/handlers/files.js\";\nimport type { KnowFilesCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"List uploaded catalog files\";\nexport const args = OptionalQueryArgsSchema;\nexport const options = JsonOutputOptionsSchema.extend({\n audience: z\n .string()\n .optional()\n .describe(\n option({\n description: \"Audience filter\",\n valueDescription: \"id\",\n })\n ),\n limit: z\n .number()\n .optional()\n .describe(\n option({\n description: \"Maximum results\",\n valueDescription: \"n\",\n })\n ),\n});\n\ntype FilesCommandProps = {\n readonly args: [string?];\n readonly options: KnowFilesCommandOptions;\n};\n\nexport default function FilesCommand({ args, options }: FilesCommandProps) {\n return <CommandRunner run={(output) => runKnowFilesCommand(args[0], options, output)} />;\n}\n","import { createElement } from \"react\";\n\nimport { coerceLimit, formatJson, shouldPrintJson } from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { normalizeAudienceId } from \"../knowledges-input.js\";\nimport { KnowTopicFileList } from \"../knowledges-output.js\";\nimport type { KnowFilesCommandOptions } from \"../knowledges-options.js\";\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 if (response.data.files.length > 0) {\n output.component(createElement(KnowTopicFileList, { files: response.data.files }));\n return;\n }\n\n output.warning(\"No matching files.\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS;;;ACDlB,SAAS,qBAAqB;AAS9B,eAAsB,oBACpB,OACAA,UACA,QACA,cACe;AACf,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,WAAW,MAAM,IAAI,UAAU;AAAA,IACnC;AAAA,IACA,UAAU,oBAAoBA,SAAQ,QAAQ;AAAA,IAC9C,OAAO,YAAYA,SAAQ,OAAO,EAAE;AAAA,EACtC,CAAC;AAED,MAAI,gBAAgBA,QAAO,GAAG;AAC5B,WAAO,IAAI,WAAW,SAAS,IAAI,CAAC;AACpC;AAAA,EACF;AAEA,MAAI,SAAS,KAAK,MAAM,SAAS,GAAG;AAClC,WAAO,UAAU,cAAc,mBAAmB,EAAE,OAAO,SAAS,KAAK,MAAM,CAAC,CAAC;AACjF;AAAA,EACF;AAEA,SAAO,QAAQ,oBAAoB;AACrC;;;ADIS;AA7BF,IAAM,cAAc;AACpB,IAAM,OAAO;AACb,IAAM,UAAU,wBAAwB,OAAO;AAAA,EACpD,UAAU,EACP,OAAO,EACP,SAAS,EACT;AAAA,IACC,OAAO;AAAA,MACL,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EACF,OAAO,EACJ,OAAO,EACP,SAAS,EACT;AAAA,IACC,OAAO;AAAA,MACL,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACJ,CAAC;AAOc,SAAR,aAA8B,EAAE,MAAAC,OAAM,SAAAC,SAAQ,GAAsB;AACzE,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,oBAAoBD,MAAK,CAAC,GAAGC,UAAS,MAAM,GAAG;AACxF;","names":["options","args","options"]}
|
|
@@ -1,22 +1,62 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
2
|
+
coerceOptionalFiniteNumber,
|
|
3
|
+
compareFilesystemEntries,
|
|
4
|
+
formatFilesystemEntryPath
|
|
5
|
+
} from "../../chunk-YALWTRIP.js";
|
|
6
|
+
import {
|
|
7
|
+
createKnowledgesApi
|
|
8
|
+
} from "../../chunk-U725ZHCI.js";
|
|
9
|
+
import {
|
|
10
|
+
formatCatalogPathForDisplay,
|
|
11
|
+
normalizeFilesystemCatalogPath
|
|
12
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
13
|
+
import {
|
|
14
|
+
coerceLimit,
|
|
15
|
+
formatJson,
|
|
16
|
+
shouldPrintJson
|
|
17
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
18
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
19
|
import {
|
|
8
20
|
JsonOutputOptionsSchema,
|
|
9
21
|
OptionalPathArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
22
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
23
|
import {
|
|
12
24
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
25
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
26
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
27
|
import "../../chunk-PZ5AY32C.js";
|
|
16
28
|
|
|
17
29
|
// src/commands/knowledges/find.tsx
|
|
18
30
|
import { option } from "pastel";
|
|
19
31
|
import { z } from "zod";
|
|
32
|
+
|
|
33
|
+
// src/features/knowledges/handlers/find.ts
|
|
34
|
+
async function runKnowFindCommand(path, options2, output, dependencies) {
|
|
35
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
36
|
+
const response = await api.find({
|
|
37
|
+
path: normalizeFilesystemCatalogPath(path ?? "/"),
|
|
38
|
+
name: options2.name,
|
|
39
|
+
type: options2.type,
|
|
40
|
+
maxDepth: coerceOptionalFiniteNumber(options2.maxDepth),
|
|
41
|
+
limit: coerceLimit(options2.limit, 500, 2e3)
|
|
42
|
+
});
|
|
43
|
+
if (shouldPrintJson(options2)) {
|
|
44
|
+
output.raw(formatJson(response.data));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const entries = [...response.data.entries].sort(compareFilesystemEntries);
|
|
48
|
+
const lines = entries.map(formatFilesystemEntryPath);
|
|
49
|
+
if (lines.length > 0) {
|
|
50
|
+
output.raw(lines.join("\n"));
|
|
51
|
+
} else {
|
|
52
|
+
output.warning(`No entries found under ${formatCatalogPathForDisplay(response.data.path)}.`);
|
|
53
|
+
}
|
|
54
|
+
if (response.data.truncated) {
|
|
55
|
+
output.warning(`[truncated: ${response.data.total_entries} total entries]`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/commands/knowledges/find.tsx
|
|
20
60
|
import { jsx } from "react/jsx-runtime";
|
|
21
61
|
var description = "Find remote catalog paths";
|
|
22
62
|
var args = OptionalPathArgsSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/find.tsx"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, OptionalPathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowFindCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/knowledges/find.tsx","../../../src/features/knowledges/handlers/find.ts"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, OptionalPathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowFindCommand } from \"../../features/knowledges/handlers/find.js\";\nimport type { KnowFindCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"Find remote catalog paths\";\nexport const args = OptionalPathArgsSchema;\nexport const options = JsonOutputOptionsSchema.extend({\n name: z\n .string()\n .optional()\n .describe(\n option({\n description: \"Basename wildcard pattern\",\n valueDescription: \"pattern\",\n })\n ),\n type: z\n .enum([\"file\", \"directory\", \"f\", \"d\"])\n .transform((value) => {\n if (value === \"f\") {\n return \"file\";\n }\n\n if (value === \"d\") {\n return \"directory\";\n }\n\n return value;\n })\n .optional()\n .describe(\n option({\n description: \"Path type: file or directory\",\n valueDescription: \"type\",\n })\n ),\n maxDepth: z\n .number()\n .optional()\n .describe(\n option({\n description: \"Maximum descendant depth\",\n valueDescription: \"n\",\n })\n ),\n limit: z\n .number()\n .optional()\n .describe(\n option({\n description: \"Maximum results\",\n valueDescription: \"n\",\n })\n ),\n});\n\ntype FindCommandProps = {\n readonly args: [string?];\n readonly options: KnowFindCommandOptions;\n};\n\nexport default function FindCommand({ args, options }: FindCommandProps) {\n return <CommandRunner run={(output) => runKnowFindCommand(args[0], options, output)} />;\n}\n","import { coerceLimit, formatJson, shouldPrintJson } from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport {\n coerceOptionalFiniteNumber,\n compareFilesystemEntries,\n formatFilesystemEntryPath,\n} from \"../format/filesystem-format.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { formatCatalogPathForDisplay, normalizeFilesystemCatalogPath } from \"../knowledges-input.js\";\nimport type { KnowFindCommandOptions } from \"../knowledges-options.js\";\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 ${formatCatalogPathForDisplay(response.data.path)}.`);\n }\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS;;;ACUlB,eAAsB,mBACpB,MACAA,UACA,QACA,cACe;AACf,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,WAAW,MAAM,IAAI,KAAK;AAAA,IAC9B,MAAM,+BAA+B,QAAQ,GAAG;AAAA,IAChD,MAAMA,SAAQ;AAAA,IACd,MAAMA,SAAQ;AAAA,IACd,UAAU,2BAA2BA,SAAQ,QAAQ;AAAA,IACrD,OAAO,YAAYA,SAAQ,OAAO,KAAK,GAAI;AAAA,EAC7C,CAAC;AAED,MAAI,gBAAgBA,QAAO,GAAG;AAC5B,WAAO,IAAI,WAAW,SAAS,IAAI,CAAC;AACpC;AAAA,EACF;AAEA,QAAM,UAAU,CAA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AC,WAAW,mBAAmBD,MAAK,CAAC,GAAGC,UAAS,MAAM,GAAG;AACvF;","names":["options","args","options"]}
|
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
createKnowledgesApi
|
|
3
|
+
} from "../../chunk-U725ZHCI.js";
|
|
4
|
+
import {
|
|
5
|
+
formatCatalogPathForDisplay,
|
|
6
|
+
normalizeCatalogPath
|
|
7
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
8
|
+
import {
|
|
9
|
+
coerceOptionalNumber,
|
|
10
|
+
formatJson,
|
|
11
|
+
shouldPrintJson
|
|
12
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
13
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
14
|
import {
|
|
8
15
|
LimitOptionsSchema,
|
|
9
16
|
OptionalGlobPatternArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
17
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
18
|
import {
|
|
12
19
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
20
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
21
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
22
|
import "../../chunk-PZ5AY32C.js";
|
|
16
23
|
|
|
17
24
|
// src/commands/knowledges/glob.tsx
|
|
18
25
|
import { option } from "pastel";
|
|
19
26
|
import { z } from "zod";
|
|
27
|
+
|
|
28
|
+
// src/features/knowledges/handlers/glob.ts
|
|
29
|
+
async function runKnowGlobCommand(pattern, options2, output, dependencies) {
|
|
30
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
31
|
+
const limit = options2.limit !== void 0 ? coerceOptionalNumber(options2.limit) : void 0;
|
|
32
|
+
const response = await api.glob({
|
|
33
|
+
pattern: pattern ?? "**/*.md",
|
|
34
|
+
path: normalizeCatalogPath(options2.path ?? "/")
|
|
35
|
+
});
|
|
36
|
+
if (shouldPrintJson(options2)) {
|
|
37
|
+
output.raw(formatJson(response.data));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const files = limit ? response.data.files.slice(0, limit) : response.data.files;
|
|
41
|
+
const wasClientTruncated = limit ? response.data.files.length > limit : false;
|
|
42
|
+
if (files.length > 0) {
|
|
43
|
+
output.raw(files.map(formatCatalogPathForDisplay).join("\n"));
|
|
44
|
+
} else {
|
|
45
|
+
output.warning("No matching files.");
|
|
46
|
+
}
|
|
47
|
+
if (response.data.truncated || wasClientTruncated) {
|
|
48
|
+
output.warning(`[truncated: ${response.data.total_files} total files]`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/commands/knowledges/glob.tsx
|
|
20
53
|
import { jsx } from "react/jsx-runtime";
|
|
21
54
|
var description = "Claude-style file discovery";
|
|
22
55
|
var args = OptionalGlobPatternArgsSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/glob.tsx"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { LimitOptionsSchema, OptionalGlobPatternArgsSchema } from \"../../cli/options.js\";\nimport { runKnowGlobCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/knowledges/glob.tsx","../../../src/features/knowledges/handlers/glob.ts"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { LimitOptionsSchema, OptionalGlobPatternArgsSchema } from \"../../cli/options.js\";\nimport { runKnowGlobCommand } from \"../../features/knowledges/handlers/glob.js\";\nimport type { KnowGlobCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"Claude-style file discovery\";\nexport const args = OptionalGlobPatternArgsSchema;\nexport const options = LimitOptionsSchema.extend({\n path: z\n .string()\n .optional()\n .describe(\n option({\n description: \"Catalog path prefix\",\n valueDescription: \"path\",\n })\n ),\n});\n\ntype GlobCommandProps = {\n readonly args: string[];\n readonly options: KnowGlobCommandOptions;\n};\n\nexport default function GlobCommand({ args, options }: GlobCommandProps) {\n return <CommandRunner run={(output) => runKnowGlobCommand(args.join(\" \"), options, output)} />;\n}\n","import {\n coerceOptionalNumber,\n formatJson,\n shouldPrintJson,\n} from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { formatCatalogPathForDisplay, normalizeCatalogPath } from \"../knowledges-input.js\";\nimport type { KnowGlobCommandOptions } from \"../knowledges-options.js\";\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.map(formatCatalogPathForDisplay).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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS;;;ACSlB,eAAsB,mBACpB,SACAA,UACA,QACA,cACe;AACf,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,QAAQA,SAAQ,UAAU,SAAY,qBAAqBA,SAAQ,KAAK,IAAI;AAClF,QAAM,WAAW,MAAM,IAAI,KAAK;AAAA,IAC9B,SAAS,WAAW;AAAA,IACpB,MAAM,qBAAqBA,SAAQ,QAAQ,GAAG;AAAA,EAChD,CAAC;AAED,MAAI,gBAAgBA,QAAO,GAAG;AAC5B,WAAO,IAAI,WAAW,SAAS,IAAI,CAAC;AACpC;AAAA,EACF;AAEA,QAAM,QAAQ,QAAQ,SAAS,KAAK,MAAM,MAAM,GAAG,KAAK,IAAI,SAAS,KAAK;AAC1E,QAAM,qBAAqB,QAAQ,SAAS,KAAK,MAAM,SAAS,QAAQ;AAExE,MAAI,MAAM,SAAS,GAAG;AACpB,WAAO,IAAI,MAAM,IAAI,2BAA2B,EAAE,KAAK,IAAI,CAAC;AAAA,EAC9D,OAAO;AACL,WAAO,QAAQ,oBAAoB;AAAA,EACrC;AACA,MAAI,SAAS,KAAK,aAAa,oBAAoB;AACjD,WAAO,QAAQ,eAAe,SAAS,KAAK,WAAW,eAAe;AAAA,EACxE;AACF;;;ADXS;AApBF,IAAM,cAAc;AACpB,IAAM,OAAO;AACb,IAAM,UAAU,mBAAmB,OAAO;AAAA,EAC/C,MAAM,EACH,OAAO,EACP,SAAS,EACT;AAAA,IACC,OAAO;AAAA,MACL,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACJ,CAAC;AAOc,SAAR,YAA6B,EAAE,MAAAC,OAAM,SAAAC,SAAQ,GAAqB;AACvE,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,mBAAmBD,MAAK,KAAK,GAAG,GAAGC,UAAS,MAAM,GAAG;AAC9F;","names":["options","args","options"]}
|
|
@@ -1,22 +1,87 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
createKnowledgesApi
|
|
3
|
+
} from "../../chunk-U725ZHCI.js";
|
|
4
|
+
import {
|
|
5
|
+
formatCatalogPathForDisplay,
|
|
6
|
+
normalizeCatalogPath,
|
|
7
|
+
normalizeGrepMode
|
|
8
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
9
|
+
import {
|
|
10
|
+
coerceLimit,
|
|
11
|
+
coerceOptionalNumber,
|
|
12
|
+
formatJson,
|
|
13
|
+
shouldPrintJson
|
|
14
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
15
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
16
|
import {
|
|
8
17
|
LimitOptionsSchema,
|
|
9
18
|
RequiredPatternArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
19
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
20
|
import {
|
|
12
21
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
22
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
23
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
24
|
import "../../chunk-PZ5AY32C.js";
|
|
16
25
|
|
|
17
26
|
// src/commands/knowledges/grep.tsx
|
|
18
27
|
import { option } from "pastel";
|
|
19
28
|
import { z } from "zod";
|
|
29
|
+
|
|
30
|
+
// src/features/knowledges/handlers/grep.ts
|
|
31
|
+
async function runKnowGrepCommand(pattern, options2, output, dependencies) {
|
|
32
|
+
if (!pattern) {
|
|
33
|
+
throw new Error("Missing pattern. Usage: cngkit knowledges grep <pattern>");
|
|
34
|
+
}
|
|
35
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
36
|
+
const limit = options2.limit !== void 0 ? coerceOptionalNumber(options2.limit) : void 0;
|
|
37
|
+
const response = await api.grep({
|
|
38
|
+
pattern,
|
|
39
|
+
path: normalizeCatalogPath(options2.path ?? "/"),
|
|
40
|
+
include: options2.include ?? "*",
|
|
41
|
+
mode: normalizeGrepMode(options2.outputMode),
|
|
42
|
+
context: coerceLimit(options2.context, 0, 20),
|
|
43
|
+
ignoreCase: options2.caseInsensitive === true
|
|
44
|
+
});
|
|
45
|
+
if (shouldPrintJson(options2)) {
|
|
46
|
+
output.raw(formatJson(response.data));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (response.data.mode === "files_with_matches") {
|
|
50
|
+
const files = limit ? response.data.files.slice(0, limit) : response.data.files;
|
|
51
|
+
if (files.length > 0) {
|
|
52
|
+
output.raw(files.map(formatCatalogPathForDisplay).join("\n"));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
output.warning(`No files matched "${pattern}".`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (response.data.mode === "count") {
|
|
59
|
+
const counts = limit ? response.data.counts.slice(0, limit) : response.data.counts;
|
|
60
|
+
const lines2 = counts.map(
|
|
61
|
+
(count) => `${formatCatalogPathForDisplay(count.file_path)}: ${count.match_count}`
|
|
62
|
+
);
|
|
63
|
+
if (lines2.length > 0) {
|
|
64
|
+
output.raw(lines2.join("\n"));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
output.warning(`No matches for "${pattern}".`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const matches = limit ? response.data.matches.slice(0, limit) : response.data.matches;
|
|
71
|
+
const lines = matches.flatMap((match) => [
|
|
72
|
+
`${formatCatalogPathForDisplay(match.file_path)}:${match.line_number}`,
|
|
73
|
+
...match.context_before.map((line) => ` ${line}`),
|
|
74
|
+
`> ${match.line}`,
|
|
75
|
+
...match.context_after.map((line) => ` ${line}`)
|
|
76
|
+
]);
|
|
77
|
+
if (lines.length > 0) {
|
|
78
|
+
output.raw(lines.join("\n"));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
output.warning(`No matches for "${pattern}".`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/commands/knowledges/grep.tsx
|
|
20
85
|
import { jsx } from "react/jsx-runtime";
|
|
21
86
|
var description = "Claude-style content search";
|
|
22
87
|
var args = RequiredPatternArgsSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/grep.tsx"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { LimitOptionsSchema, RequiredPatternArgsSchema } from \"../../cli/options.js\";\nimport { runKnowGrepCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/knowledges/grep.tsx","../../../src/features/knowledges/handlers/grep.ts"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { LimitOptionsSchema, RequiredPatternArgsSchema } from \"../../cli/options.js\";\nimport { runKnowGrepCommand } from \"../../features/knowledges/handlers/grep.js\";\nimport type { KnowGrepCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"Claude-style content search\";\nexport const args = RequiredPatternArgsSchema;\nexport const options = LimitOptionsSchema.extend({\n path: z\n .string()\n .optional()\n .describe(\n option({\n description: \"Catalog path prefix\",\n valueDescription: \"path\",\n })\n ),\n include: z\n .string()\n .optional()\n .describe(\n option({\n description: \"Filename include filter\",\n valueDescription: \"glob\",\n })\n ),\n outputMode: z\n .enum([\"content\", \"files_with_matches\", \"count\"])\n .optional()\n .describe(\n option({\n description: \"Output mode: content, files_with_matches, count\",\n valueDescription: \"mode\",\n })\n ),\n context: z\n .number()\n .optional()\n .describe(\n option({\n description: \"Context lines around content matches\",\n valueDescription: \"n\",\n })\n ),\n caseInsensitive: z\n .boolean()\n .optional()\n .describe(\n option({\n description: \"Case-insensitive search\",\n })\n ),\n});\n\ntype GrepCommandProps = {\n readonly args: string[];\n readonly options: KnowGrepCommandOptions;\n};\n\nexport default function GrepCommand({ args, options }: GrepCommandProps) {\n return <CommandRunner run={(output) => runKnowGrepCommand(args.join(\" \"), options, output)} />;\n}\n","import {\n coerceLimit,\n coerceOptionalNumber,\n formatJson,\n shouldPrintJson,\n} from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { formatCatalogPathForDisplay, normalizeCatalogPath, normalizeGrepMode } from \"../knowledges-input.js\";\nimport type { KnowGrepCommandOptions } from \"../knowledges-options.js\";\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.map(formatCatalogPathForDisplay).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(\n (count) => `${formatCatalogPathForDisplay(count.file_path)}: ${count.match_count}`\n );\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 `${formatCatalogPathForDisplay(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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB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AAAA,MACL,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AACJ,CAAC;AAOc,SAAR,YAA6B,EAAE,MAAAC,OAAM,SAAAC,SAAQ,GAAqB;AACvE,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,mBAAmBD,MAAK,KAAK,GAAG,GAAGC,UAAS,MAAM,GAAG;AAC9F;","names":["options","lines","args","options"]}
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
outputRawContent
|
|
3
|
+
} from "../../chunk-BRFWVQI4.js";
|
|
4
|
+
import {
|
|
5
|
+
createKnowledgesApi
|
|
6
|
+
} from "../../chunk-U725ZHCI.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeCatalogPath
|
|
9
|
+
} from "../../chunk-AS7FIJWP.js";
|
|
10
|
+
import {
|
|
11
|
+
coerceLimit
|
|
12
|
+
} from "../../chunk-XQGLUQFM.js";
|
|
13
|
+
import "../../chunk-GYRLVNJX.js";
|
|
7
14
|
import {
|
|
8
15
|
JsonOutputOptionsSchema,
|
|
9
16
|
RequiredFilePathArgsSchema
|
|
10
|
-
} from "../../chunk-
|
|
17
|
+
} from "../../chunk-25Q463MH.js";
|
|
11
18
|
import {
|
|
12
19
|
CommandRunner
|
|
13
|
-
} from "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
20
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
21
|
+
import "../../chunk-67FUBMNB.js";
|
|
15
22
|
import "../../chunk-PZ5AY32C.js";
|
|
16
23
|
|
|
17
24
|
// src/commands/knowledges/head.tsx
|
|
18
25
|
import { option } from "pastel";
|
|
19
26
|
import { z } from "zod";
|
|
27
|
+
|
|
28
|
+
// src/features/knowledges/handlers/head.ts
|
|
29
|
+
async function runKnowHeadCommand(filePath, options2, output, dependencies) {
|
|
30
|
+
if (!filePath) {
|
|
31
|
+
throw new Error("Missing file_path. Usage: cngkit knowledges head <file_path> -n 10");
|
|
32
|
+
}
|
|
33
|
+
const api = dependencies?.api ?? createKnowledgesApi(options2);
|
|
34
|
+
const response = await api.read({
|
|
35
|
+
filePath: normalizeCatalogPath(filePath),
|
|
36
|
+
offset: 0,
|
|
37
|
+
limit: coerceLimit(options2.lines, 10, 2e3)
|
|
38
|
+
});
|
|
39
|
+
outputRawContent(response.data, options2, output);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/commands/knowledges/head.tsx
|
|
20
43
|
import { jsx } from "react/jsx-runtime";
|
|
21
44
|
var description = "Print the first lines of a remote catalog file";
|
|
22
45
|
var args = RequiredFilePathArgsSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/knowledges/head.tsx"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, RequiredFilePathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowHeadCommand
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/knowledges/head.tsx","../../../src/features/knowledges/handlers/head.ts"],"sourcesContent":["import { option } from \"pastel\";\nimport { z } from \"zod\";\n\nimport { JsonOutputOptionsSchema, RequiredFilePathArgsSchema } from \"../../cli/options.js\";\nimport { runKnowHeadCommand } from \"../../features/knowledges/handlers/head.js\";\nimport type { KnowHeadCommandOptions } from \"../../features/knowledges/knowledges-options.js\";\nimport { CommandRunner } from \"../../cli/command-runner.js\";\n\nexport const description = \"Print the first lines of a remote catalog file\";\nexport const args = RequiredFilePathArgsSchema;\nexport const options = JsonOutputOptionsSchema.extend({\n lines: z\n .number()\n .optional()\n .describe(\n option({\n alias: \"n\",\n description: \"Number of lines\",\n valueDescription: \"n\",\n })\n ),\n});\n\ntype HeadCommandProps = {\n readonly args: [string];\n readonly options: KnowHeadCommandOptions;\n};\n\nexport default function HeadCommand({ args, options }: HeadCommandProps) {\n return <CommandRunner run={(output) => runKnowHeadCommand(args[0], options, output)} />;\n}\n","import { coerceLimit } from \"../../../shared/command-utils.js\";\nimport type { CommandOutput } from \"../../../shared/output/types.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"../knowledges-api.js\";\nimport { normalizeCatalogPath } from \"../knowledges-input.js\";\nimport type { KnowHeadCommandOptions } from \"../knowledges-options.js\";\nimport { outputRawContent } from \"../format/content-format.js\";\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS;;;ACMlB,eAAsB,mBACpB,UACAA,UACA,QACA,cACe;AACf,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACtF;AAEA,QAAM,MAAM,cAAc,OAAO,oBAAoBA,QAAO;AAC5D,QAAM,WAAW,MAAM,IAAI,KAAK;AAAA,IAC9B,UAAU,qBAAqB,QAAQ;AAAA,IACvC,QAAQ;AAAA,IACR,OAAO,YAAYA,SAAQ,OAAO,IAAI,GAAI;AAAA,EAC5C,CAAC;AAED,mBAAiB,SAAS,MAAMA,UAAS,MAAM;AACjD;;;ADIS;AArBF,IAAM,cAAc;AACpB,IAAM,OAAO;AACb,IAAM,UAAU,wBAAwB,OAAO;AAAA,EACpD,OAAO,EACJ,OAAO,EACP,SAAS,EACT;AAAA,IACC,OAAO;AAAA,MACL,OAAO;AAAA,MACP,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACJ,CAAC;AAOc,SAAR,YAA6B,EAAE,MAAAC,OAAM,SAAAC,SAAQ,GAAqB;AACvE,SAAO,oBAAC,iBAAc,KAAK,CAAC,WAAW,mBAAmBD,MAAK,CAAC,GAAGC,UAAS,MAAM,GAAG;AACvF;","names":["options","args","options"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderKnowledgesHelp
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-JNHW72SU.js";
|
|
4
4
|
import {
|
|
5
5
|
GlobalOptionsSchema
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-25Q463MH.js";
|
|
7
7
|
import {
|
|
8
8
|
CommandRunner
|
|
9
|
-
} from "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
9
|
+
} from "../../chunk-WIEYHKQA.js";
|
|
10
|
+
import "../../chunk-67FUBMNB.js";
|
|
11
11
|
import "../../chunk-PZ5AY32C.js";
|
|
12
12
|
|
|
13
13
|
// src/commands/knowledges/index.tsx
|