@dikolab/kbdb 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLA.md +68 -0
- package/LICENSE +676 -12
- package/LICENSING.md +58 -0
- package/README.md +50 -27
- package/README.md.bak +320 -0
- package/dist/README.md +320 -0
- package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
- package/dist/chunk-QLJ33C74.mjs.map +7 -0
- package/dist/cli.cjs +550 -232
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.d.ts +0 -8
- package/dist/cli.mjs +483 -154
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +36 -5
- package/dist/kbdb-worker.cjs.map +3 -3
- package/dist/mod.cjs +89 -30
- package/dist/mod.cjs.map +4 -4
- package/dist/mod.mjs +88 -30
- package/dist/mod.mjs.map +4 -4
- package/dist/src/cli.d.ts +0 -8
- package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
- package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
- package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
- package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
- package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
- package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
- package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
- package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
- package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
- package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
- package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
- package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
- package/dist/src/shared/cli/index.d.ts +4 -1
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
- package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
- package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
- package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
- package/dist/src/shared/wasm-codec/index.d.ts +1 -1
- package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
- package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
- package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
- package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
- package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
- package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
- package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
- package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
- package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
- package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
- package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
- package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
- package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
- package/dist/src/worker.d.ts +0 -7
- package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
- package/dist/wasm/default-embedding/package.json +1 -1
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/package.json +1 -1
- package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm +0 -0
- package/dist/wasm/fs-migration/package.json +1 -1
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/package.json +1 -1
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/wasm/query-parser/package.json +1 -1
- package/dist/worker.d.ts +0 -7
- package/dist/worker.mjs +37 -6
- package/dist/worker.mjs.map +3 -3
- package/package.json +13 -12
- package/dist/chunk-BJXEVALU.mjs.map +0 -7
- package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
- package/docs/details/README.md +0 -30
- package/docs/details/agent-tooling.md +0 -132
- package/docs/details/cli.md +0 -777
- package/docs/details/knowledge-base.md +0 -180
- package/docs/details/library-api.md +0 -495
- package/docs/details/mcp-server.md +0 -482
- package/docs/details/search-and-ranking.md +0 -575
- package/docs/details/storage.md +0 -531
- package/docs/goals/agents.md +0 -751
- package/docs/goals/architecture.svg +0 -198
- package/docs/goals/auto-capture.md +0 -378
- package/docs/goals/benchmarking.md +0 -296
- package/docs/goals/cli.md +0 -2654
- package/docs/goals/concurrency.md +0 -259
- package/docs/goals/content-composer.md +0 -609
- package/docs/goals/content-parser.md +0 -279
- package/docs/goals/database.md +0 -1679
- package/docs/goals/document.md +0 -368
- package/docs/goals/hybrid-search.md +0 -465
- package/docs/goals/mcp.md +0 -1541
- package/docs/goals/overview.md +0 -124
- package/docs/goals/query-parser.md +0 -373
- package/docs/goals/query-result.md +0 -860
- package/docs/goals/semantic-dedup.md +0 -233
- package/docs/goals/skills.md +0 -810
- package/docs/goals/sync.md +0 -217
- package/docs/goals/worker-client.md +0 -1005
- package/docs/goals/worker-daemon.md +0 -1547
- package/docs/modules/overview.md +0 -319
- package/docs/modules/rust/embedding/module.md +0 -91
- package/docs/modules/rust/fs-database/functions/document.md +0 -48
- package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
- package/docs/modules/rust/fs-database/functions/io.md +0 -87
- package/docs/modules/rust/fs-database/functions/module.md +0 -22
- package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
- package/docs/modules/rust/fs-database/functions/section.md +0 -76
- package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
- package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
- package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
- package/docs/modules/rust/fs-database/indexes/module.md +0 -64
- package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
- package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
- package/docs/modules/rust/fs-database/module.md +0 -150
- package/docs/modules/rust/fs-database/types/catalog.md +0 -53
- package/docs/modules/rust/fs-database/types/module.md +0 -12
- package/docs/modules/rust/fs-database/types/section.md +0 -127
- package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
- package/docs/modules/rust/kb-worker/functions/module.md +0 -20
- package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
- package/docs/modules/rust/kb-worker/functions/search.md +0 -173
- package/docs/modules/rust/kb-worker/functions/write.md +0 -172
- package/docs/modules/rust/kb-worker/module.md +0 -171
- package/docs/modules/rust/kb-worker/types/cache.md +0 -90
- package/docs/modules/rust/kb-worker/types/context.md +0 -26
- package/docs/modules/rust/kb-worker/types/module.md +0 -16
- package/docs/modules/rust/kb-worker/types/status.md +0 -29
- package/docs/modules/rust/kb-worker/types/token.md +0 -50
- package/docs/modules/rust/overview.md +0 -531
- package/docs/modules/rust/query-parser/functions/extract.md +0 -56
- package/docs/modules/rust/query-parser/functions/module.md +0 -18
- package/docs/modules/rust/query-parser/functions/parse.md +0 -33
- package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
- package/docs/modules/rust/query-parser/functions/rank.md +0 -85
- package/docs/modules/rust/query-parser/module.md +0 -131
- package/docs/modules/rust/query-parser/types/cache.md +0 -39
- package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
- package/docs/modules/rust/query-parser/types/module.md +0 -18
- package/docs/modules/rust/query-parser/types/token.md +0 -46
- package/docs/modules/rust/shared/content-composer/functions.md +0 -114
- package/docs/modules/rust/shared/content-composer/module.md +0 -147
- package/docs/modules/rust/shared/content-composer/types.md +0 -93
- package/docs/modules/rust/shared/content-parser/functions.md +0 -72
- package/docs/modules/rust/shared/content-parser/module.md +0 -99
- package/docs/modules/rust/shared/content-parser/types.md +0 -71
- package/docs/modules/rust/shared/corpus/module.md +0 -24
- package/docs/modules/rust/shared/corpus/types.md +0 -141
- package/docs/modules/rust/shared/document/module.md +0 -25
- package/docs/modules/rust/shared/document/types.md +0 -154
- package/docs/modules/rust/shared/encode/module.md +0 -22
- package/docs/modules/rust/shared/encode/traits.md +0 -304
- package/docs/modules/rust/shared/error/module.md +0 -28
- package/docs/modules/rust/shared/error/types.md +0 -302
- package/docs/modules/rust/shared/kbid/module.md +0 -24
- package/docs/modules/rust/shared/kbid/types.md +0 -147
- package/docs/modules/rust/shared/memory/functions.md +0 -209
- package/docs/modules/rust/shared/memory/module.md +0 -24
- package/docs/modules/rust/shared/module.md +0 -196
- package/docs/modules/rust/shared/pipeline/functions.md +0 -141
- package/docs/modules/rust/shared/pipeline/module.md +0 -62
- package/docs/modules/rust/shared/pipeline/types.md +0 -43
- package/docs/modules/rust/shared/query/module.md +0 -27
- package/docs/modules/rust/shared/query/types.md +0 -236
- package/docs/modules/rust/shared/section/module.md +0 -25
- package/docs/modules/rust/shared/section/types.md +0 -294
- package/docs/modules/rust/shared/term/module.md +0 -25
- package/docs/modules/rust/shared/term/types.md +0 -139
- package/docs/modules/typescript/cli.md +0 -131
- package/docs/modules/typescript/kbdb-worker.md +0 -150
- package/docs/modules/typescript/overview.md +0 -400
- package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
- package/docs/modules/typescript/shared/cli/constants.md +0 -23
- package/docs/modules/typescript/shared/cli/functions.md +0 -809
- package/docs/modules/typescript/shared/cli/module.md +0 -138
- package/docs/modules/typescript/shared/cli/typings.md +0 -197
- package/docs/modules/typescript/shared/embedding/functions.md +0 -200
- package/docs/modules/typescript/shared/embedding/module.md +0 -77
- package/docs/modules/typescript/shared/embedding/typings.md +0 -124
- package/docs/modules/typescript/shared/hash/functions.md +0 -20
- package/docs/modules/typescript/shared/hash/module.md +0 -21
- package/docs/modules/typescript/shared/log/constants.md +0 -82
- package/docs/modules/typescript/shared/log/functions.md +0 -131
- package/docs/modules/typescript/shared/log/module.md +0 -153
- package/docs/modules/typescript/shared/log/typings.md +0 -82
- package/docs/modules/typescript/shared/mcp/classes.md +0 -179
- package/docs/modules/typescript/shared/mcp/functions.md +0 -386
- package/docs/modules/typescript/shared/mcp/module.md +0 -160
- package/docs/modules/typescript/shared/mcp/typings.md +0 -529
- package/docs/modules/typescript/shared/module.md +0 -110
- package/docs/modules/typescript/shared/platform/functions.md +0 -42
- package/docs/modules/typescript/shared/platform/module.md +0 -25
- package/docs/modules/typescript/shared/runtime/functions.md +0 -26
- package/docs/modules/typescript/shared/runtime/module.md +0 -27
- package/docs/modules/typescript/shared/runtime/typings.md +0 -13
- package/docs/modules/typescript/shared/version/module.md +0 -27
- package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
- package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
- package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
- package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
- package/docs/modules/typescript/shared/worker-client/module.md +0 -92
- package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
- package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
- package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
- package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
- package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
- package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
- package/docs/overview.md +0 -191
- package/docs/release-notes/0.1.0.md +0 -189
- package/docs/release-notes/0.1.1.md +0 -46
- package/docs/release-notes/0.1.2.md +0 -38
- package/docs/release-notes/0.1.3.md +0 -42
- package/docs/release-notes/0.2.0.md +0 -147
- package/docs/release-notes/0.3.0.md +0 -89
- package/docs/release-notes/0.3.1.md +0 -121
- package/docs/release-notes/0.3.2.md +0 -64
- package/docs/release-notes/0.4.0.md +0 -80
- package/docs/release-notes/0.4.1.md +0 -149
- package/docs/release-notes/0.4.3.md +0 -60
- package/docs/release-notes/README.md +0 -13
|
@@ -1,809 +0,0 @@
|
|
|
1
|
-
# cli/functions -- Command Functions
|
|
2
|
-
|
|
3
|
-
*CLI orchestrator, command dispatcher, argument parser,
|
|
4
|
-
utility helpers, and one function per CLI sub-command.*
|
|
5
|
-
|
|
6
|
-
## Source
|
|
7
|
-
|
|
8
|
-
`src/shared/cli/functions/`
|
|
9
|
-
|
|
10
|
-
## Functions
|
|
11
|
-
|
|
12
|
-
### `runCli`
|
|
13
|
-
|
|
14
|
-
**File:** `run-cli.function.ts`
|
|
15
|
-
|
|
16
|
-
Full CLI orchestrator. Parses arguments, configures the
|
|
17
|
-
log level from `-v`/`-vv`/`-vvv` or `KBDB_LOG_LEVEL`,
|
|
18
|
-
resolves non-interactive mode from `--non-interactive`
|
|
19
|
-
or `KBDB_NON_INTERACTIVE` before dispatching commands,
|
|
20
|
-
routes to the appropriate sub-flow, and returns a
|
|
21
|
-
`CommandResult` without touching process globals.
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
async function runCli(
|
|
25
|
-
argv: string[],
|
|
26
|
-
deps: CliDeps,
|
|
27
|
-
): Promise<CommandResult>;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
`CliDeps` is an injectable dependency record:
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
interface CliDeps {
|
|
34
|
-
isStdinTty: () => boolean;
|
|
35
|
-
promptUser: (question: string) => Promise<string>;
|
|
36
|
-
createWorkerClient: (opts: {
|
|
37
|
-
contextPath: string;
|
|
38
|
-
}) => Promise<DisconnectableClient>;
|
|
39
|
-
findDb: (basePath?: string) => string | null;
|
|
40
|
-
runInit: (options: CliOptions) => InitResult;
|
|
41
|
-
startMcpServer?: (contextPath: string) => Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Routes:
|
|
46
|
-
|
|
47
|
-
| Command | Handler |
|
|
48
|
-
|------------------|----------------------------------|
|
|
49
|
-
| `help` | returns `HELP_TEXT` |
|
|
50
|
-
| `version` | returns `VERSION` |
|
|
51
|
-
| `init` | calls `deps.runInit` |
|
|
52
|
-
| `mcp` | calls `deps.startMcpServer` |
|
|
53
|
-
| `migrate` | version check + migrate daemon |
|
|
54
|
-
| `worker-stop` | `runWorkerStop(dbDir)` |
|
|
55
|
-
| `worker-restart` | `runWorkerRestart(dbDir)` |
|
|
56
|
-
| *(other)* | `dispatchCommand(client, opts)` |
|
|
57
|
-
|
|
58
|
-
### `dispatchCommand`
|
|
59
|
-
|
|
60
|
-
**File:** `dispatch-command.function.ts`
|
|
61
|
-
|
|
62
|
-
Routes a parsed CLI command to the appropriate handler
|
|
63
|
-
and returns a `CommandResult` without touching process
|
|
64
|
-
globals.
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
async function dispatchCommand(
|
|
68
|
-
client: DispatchClient,
|
|
69
|
-
options: CliOptions,
|
|
70
|
-
io?: LearnIO,
|
|
71
|
-
): Promise<CommandResult>;
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
`DispatchClient` is the intersection of all per-command
|
|
75
|
-
client interfaces (`SearchClient & LearnClient &
|
|
76
|
-
UnlearnClient & RecallClient & ContentClient &
|
|
77
|
-
CheckClient & GcClient & RebuildClient & StatusClient &
|
|
78
|
-
ExportClient & SkillClient & AgentClient`).
|
|
79
|
-
|
|
80
|
-
| Command | Handler |
|
|
81
|
-
|----------------|----------------------------------|
|
|
82
|
-
| `learn` | `runLearn(client, options, io)` |
|
|
83
|
-
| `export` | `runExport(client, options)` |
|
|
84
|
-
| `unlearn` | `runUnlearn(client, options)` |
|
|
85
|
-
| `search` | `runSearch(client, options)` |
|
|
86
|
-
| `recall` | `runRecall(client, options)` |
|
|
87
|
-
| `content` | `runContent(client, options)` |
|
|
88
|
-
| `check` | `runCheck(client, options)` |
|
|
89
|
-
| `gc` | `runGc(client, options)` |
|
|
90
|
-
| `status` | `runStatus(client, options)` |
|
|
91
|
-
| `rebuild` | `runRebuild(client, options)` |
|
|
92
|
-
| `skill-learn` | `runSkillLearn(client, options)` |
|
|
93
|
-
| `skill-list` | `runSkillList(client, options)` |
|
|
94
|
-
| `skill-get` | `runSkillGet(client, options)` |
|
|
95
|
-
| `skill-delete` | `runSkillDelete(client, options)`|
|
|
96
|
-
| `agent-create` | `runAgentCreate(client, options)`|
|
|
97
|
-
| `agent-list` | `runAgentList(client, options)` |
|
|
98
|
-
| `agent-get` | `runAgentGet(client, options)` |
|
|
99
|
-
| `agent-delete` | `runAgentDelete(client, options)`|
|
|
100
|
-
|
|
101
|
-
### `parseArgs`
|
|
102
|
-
|
|
103
|
-
**File:** `parse-args.function.ts`
|
|
104
|
-
|
|
105
|
-
Parses command-line arguments into a typed `CliOptions`
|
|
106
|
-
object. Supports both Deno (`Deno.args`) and Node.js
|
|
107
|
-
(`process.argv.slice(2)`) argument sources.
|
|
108
|
-
|
|
109
|
-
```ts
|
|
110
|
-
function parseArgs(
|
|
111
|
-
argv: string[],
|
|
112
|
-
): CliOptions;
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Throws on invalid or missing required arguments.
|
|
116
|
-
Prints help text and exits for `--help`. Prints the
|
|
117
|
-
version string and exits for `--version`.
|
|
118
|
-
|
|
119
|
-
`-v` maps to `--verbose` (log level WARNING), not to
|
|
120
|
-
`--version`. Use `--version` (long form only) to print
|
|
121
|
-
the version. `-vv` sets log level INFO; `-vvv` sets
|
|
122
|
-
DEBUG. The resolved level is stored in
|
|
123
|
-
`CliOptions.logLevel`.
|
|
124
|
-
|
|
125
|
-
**Compound command handling**: when the first positional
|
|
126
|
-
argument is `db`, `skill`, `agent`, or `worker`, the
|
|
127
|
-
parser consumes the next positional as the subcommand
|
|
128
|
-
and sets `command` to the hyphenated form:
|
|
129
|
-
|
|
130
|
-
| First positional | Second positional | `command` value |
|
|
131
|
-
|------------------|-------------------|------------------|
|
|
132
|
-
| `db` | `init` | `db-init` |
|
|
133
|
-
| `db` | `migrate` | `db-migrate` |
|
|
134
|
-
| `skill` | `learn` | `skill-learn` |
|
|
135
|
-
| `skill` | `list` | `skill-list` |
|
|
136
|
-
| `skill` | `get` | `skill-get` |
|
|
137
|
-
| `skill` | `delete` | `skill-delete` |
|
|
138
|
-
| `agent` | `create` | `agent-create` |
|
|
139
|
-
| `agent` | `list` | `agent-list` |
|
|
140
|
-
| `agent` | `get` | `agent-get` |
|
|
141
|
-
| `agent` | `delete` | `agent-delete` |
|
|
142
|
-
| `worker` | `stop` | `worker-stop` |
|
|
143
|
-
| `worker` | `restart` | `worker-restart` |
|
|
144
|
-
|
|
145
|
-
**New options parsed:**
|
|
146
|
-
|
|
147
|
-
| Flag | `CliOptions` field | Description |
|
|
148
|
-
|-----------------|--------------------|-----------------------|
|
|
149
|
-
| `--name <n>` | `name` | Skill or agent name |
|
|
150
|
-
| `--persona <p>` | `persona` | Agent persona file |
|
|
151
|
-
| `--body <b>` | `body` | Skill body file |
|
|
152
|
-
| `--skills <s>` | `skills` | Comma-separated kbids |
|
|
153
|
-
| `--non-interactive` | `nonInteractive` | Suppress prompts |
|
|
154
|
-
|
|
155
|
-
### `findDb`
|
|
156
|
-
|
|
157
|
-
**File:** `find-db.function.ts`
|
|
158
|
-
|
|
159
|
-
Resolves the absolute path to the `.kbdb` directory
|
|
160
|
-
under the given base path. Returns `null` when the
|
|
161
|
-
directory does not exist. Pure read-only -- never
|
|
162
|
-
creates the directory.
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
function findDb(
|
|
166
|
-
dbPath?: string,
|
|
167
|
-
): string | null;
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### `runInit`
|
|
171
|
-
|
|
172
|
-
**File:** `run-init.function.ts`
|
|
173
|
-
|
|
174
|
-
Creates the `.kbdb` directory scaffold directly on disk
|
|
175
|
-
without requiring a running worker daemon.
|
|
176
|
-
|
|
177
|
-
```ts
|
|
178
|
-
function runInit(
|
|
179
|
-
options: CliOptions,
|
|
180
|
-
): InitResult;
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
interface InitResult {
|
|
185
|
-
readonly ok: boolean;
|
|
186
|
-
readonly targetPath: string;
|
|
187
|
-
readonly errorMessage?: string;
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### `runMigrate`
|
|
192
|
-
|
|
193
|
-
**File:** `run-migrate.function.ts`
|
|
194
|
-
|
|
195
|
-
Checks the database version and runs pending migrations
|
|
196
|
-
when needed.
|
|
197
|
-
|
|
198
|
-
```ts
|
|
199
|
-
async function runMigrate(
|
|
200
|
-
client: MigrateClient,
|
|
201
|
-
options: CliOptions,
|
|
202
|
-
): Promise<MigrateCommandResult>;
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
```ts
|
|
206
|
-
interface MigrateCommandResult {
|
|
207
|
-
readonly status: VersionCompatibility;
|
|
208
|
-
readonly versionStatus: VersionStatus;
|
|
209
|
-
readonly migrateResult?: MigrateResult;
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
Resolution order:
|
|
214
|
-
|
|
215
|
-
| Version status | Action |
|
|
216
|
-
|-------------------|-------------------------------------|
|
|
217
|
-
| `compatible` | returns without running migrations |
|
|
218
|
-
| `needs_migration` | calls `client.migrateDatabase` |
|
|
219
|
-
| `too_new` | returns without running migrations |
|
|
220
|
-
|
|
221
|
-
### `runLearn`
|
|
222
|
-
|
|
223
|
-
**File:** `run-learn.function.ts`
|
|
224
|
-
|
|
225
|
-
Imports and indexes documents into the knowledge base.
|
|
226
|
-
|
|
227
|
-
```ts
|
|
228
|
-
async function runLearn(
|
|
229
|
-
client: LearnClient,
|
|
230
|
-
options: CliOptions,
|
|
231
|
-
io?: LearnIO,
|
|
232
|
-
): Promise<LearnResult[]>;
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
- If input is a **directory**: recursively scans for
|
|
236
|
-
supported text files (`.md`, `.txt`, `.rst`,
|
|
237
|
-
`.adoc`). Image files are silently skipped during
|
|
238
|
-
directory scans. Computes content hash for each,
|
|
239
|
-
skips duplicates, calls `client.addSection()` per
|
|
240
|
-
file.
|
|
241
|
-
- If input is a **text file**: adds that single file.
|
|
242
|
-
`--title` and `--description` are optional.
|
|
243
|
-
- If input is **stdin** (`-`): reads `text/markdown`.
|
|
244
|
-
- `--tags <t,...>` attaches comma-separated tags for
|
|
245
|
-
scoping and filtering.
|
|
246
|
-
- `--replace` enables supersession by source key:
|
|
247
|
-
if a section with the same source key exists, the
|
|
248
|
-
old section is replaced.
|
|
249
|
-
- Returns a `LearnResult[]` with one record per file
|
|
250
|
-
processed. Each result includes `superseded` (kbid
|
|
251
|
-
of replaced section or `null`), `warnings` (e.g.
|
|
252
|
-
`"heading_missing"`), and `near_duplicates`.
|
|
253
|
-
|
|
254
|
-
### `runUnlearn`
|
|
255
|
-
|
|
256
|
-
**File:** `run-unlearn.function.ts`
|
|
257
|
-
|
|
258
|
-
Removes knowledge base contents by KB ID.
|
|
259
|
-
|
|
260
|
-
```ts
|
|
261
|
-
async function runUnlearn(
|
|
262
|
-
client: UnlearnClient,
|
|
263
|
-
options: CliOptions,
|
|
264
|
-
): Promise<unknown>;
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
Accepts a list of KB IDs from `options.args`. Calls
|
|
268
|
-
`client.removeSection()` for each.
|
|
269
|
-
|
|
270
|
-
### `runSearch`
|
|
271
|
-
|
|
272
|
-
**File:** `run-search.function.ts`
|
|
273
|
-
|
|
274
|
-
Searches the knowledge base by query string.
|
|
275
|
-
|
|
276
|
-
```ts
|
|
277
|
-
async function runSearch(
|
|
278
|
-
client: SearchClient,
|
|
279
|
-
options: CliOptions,
|
|
280
|
-
): Promise<SearchDisplay[]>;
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Calls `client.search()` with the query, mode, and
|
|
284
|
-
limit from options. Returns `SearchDisplay[]` for
|
|
285
|
-
use by `dispatchCommand`.
|
|
286
|
-
|
|
287
|
-
### `runContent`
|
|
288
|
-
|
|
289
|
-
**File:** `run-content.function.ts`
|
|
290
|
-
|
|
291
|
-
Composes and outputs a rendered Markdown document from
|
|
292
|
-
one or more kbid or docid identifiers.
|
|
293
|
-
|
|
294
|
-
```ts
|
|
295
|
-
async function runContent(
|
|
296
|
-
client: ContentClient,
|
|
297
|
-
options: CliOptions,
|
|
298
|
-
): Promise<unknown>;
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
Takes identifiers from `options.args`. Calls
|
|
302
|
-
`client.content(ids)`.
|
|
303
|
-
|
|
304
|
-
### `runRecall`
|
|
305
|
-
|
|
306
|
-
**File:** `run-recall.function.ts`
|
|
307
|
-
|
|
308
|
-
Retrieves full content and progressive context for one
|
|
309
|
-
or more sections by kbid.
|
|
310
|
-
|
|
311
|
-
```ts
|
|
312
|
-
async function runRecall(
|
|
313
|
-
client: RecallClient,
|
|
314
|
-
options: CliOptions,
|
|
315
|
-
): Promise<CommandResult>;
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
`RecallClient` interface:
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
interface RecallClient {
|
|
322
|
-
recall(
|
|
323
|
-
params: RecallParams,
|
|
324
|
-
): Promise<RecallResult | RecallResult[]>;
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
Takes kbid(s) from `options.args` and depth from
|
|
329
|
-
`options.depth` (default 0, clamped 0-3). When a
|
|
330
|
-
single kbid is provided, returns a `RecallResult`
|
|
331
|
-
JSON object. When multiple kbids are provided, returns
|
|
332
|
-
a `RecallResult[]` JSON array.
|
|
333
|
-
|
|
334
|
-
### `runCheck`
|
|
335
|
-
|
|
336
|
-
**File:** `run-check.function.ts`
|
|
337
|
-
|
|
338
|
-
Runs an integrity check on the database.
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
async function runCheck(
|
|
342
|
-
client: CheckClient,
|
|
343
|
-
options: CliOptions,
|
|
344
|
-
): Promise<{ ok: boolean }>;
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
Calls `client.integrityCheck()`.
|
|
348
|
-
|
|
349
|
-
### `runGc`
|
|
350
|
-
|
|
351
|
-
**File:** `run-gc.function.ts`
|
|
352
|
-
|
|
353
|
-
Runs garbage collection on the database.
|
|
354
|
-
|
|
355
|
-
```ts
|
|
356
|
-
async function runGc(
|
|
357
|
-
client: GcClient,
|
|
358
|
-
options: CliOptions,
|
|
359
|
-
): Promise<unknown>;
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
Calls `client.gc()`.
|
|
363
|
-
|
|
364
|
-
### `runRebuild`
|
|
365
|
-
|
|
366
|
-
**File:** `run-rebuild.function.ts`
|
|
367
|
-
|
|
368
|
-
Rebuilds all indexes from sections and documents.
|
|
369
|
-
|
|
370
|
-
```ts
|
|
371
|
-
async function runRebuild(
|
|
372
|
-
client: RebuildClient,
|
|
373
|
-
options: CliOptions,
|
|
374
|
-
): Promise<unknown>;
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
Calls `client.rebuildIndexes()`.
|
|
378
|
-
|
|
379
|
-
### `runExport`
|
|
380
|
-
|
|
381
|
-
**File:** `run-export.function.ts`
|
|
382
|
-
|
|
383
|
-
Exports the knowledge base as a self-contained
|
|
384
|
-
directory snapshot for backup or versioning.
|
|
385
|
-
|
|
386
|
-
```ts
|
|
387
|
-
async function runExport(
|
|
388
|
-
client: ExportClient,
|
|
389
|
-
options: CliOptions,
|
|
390
|
-
): Promise<CommandResult>;
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
Copies sections, documents, and catalog (no indexes
|
|
394
|
-
-- they are rebuildable via `rebuild`). The export
|
|
395
|
-
destination defaults to `./kbdb-export/` and can be
|
|
396
|
-
overridden via `options.args[0]`.
|
|
397
|
-
|
|
398
|
-
Output: JSON `{ "path": "...",
|
|
399
|
-
"sections_exported": number,
|
|
400
|
-
"documents_exported": number,
|
|
401
|
-
"elapsed_ms": number }`.
|
|
402
|
-
|
|
403
|
-
### `runStatus`
|
|
404
|
-
|
|
405
|
-
**File:** `run-status.function.ts`
|
|
406
|
-
|
|
407
|
-
Retrieves the database status summary report from the
|
|
408
|
-
worker daemon.
|
|
409
|
-
|
|
410
|
-
```ts
|
|
411
|
-
async function runStatus(
|
|
412
|
-
client: StatusClient,
|
|
413
|
-
options: CliOptions,
|
|
414
|
-
): Promise<unknown>;
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
`StatusClient` interface:
|
|
418
|
-
|
|
419
|
-
```ts
|
|
420
|
-
interface StatusClient {
|
|
421
|
-
dbStatus(): Promise<unknown>;
|
|
422
|
-
}
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
Delegates to `client.dbStatus()`. The caller is
|
|
426
|
-
responsible for serialising the result and setting
|
|
427
|
-
the process exit code.
|
|
428
|
-
|
|
429
|
-
### `runWorkerStop`
|
|
430
|
-
|
|
431
|
-
**File:** `run-worker-stop.function.ts`
|
|
432
|
-
|
|
433
|
-
Stops the background worker daemon for the current
|
|
434
|
-
database. Discovers the daemon via its PID file and
|
|
435
|
-
sends `SIGTERM`. Returns success when the daemon was
|
|
436
|
-
stopped or was not running.
|
|
437
|
-
|
|
438
|
-
```ts
|
|
439
|
-
async function runWorkerStop(
|
|
440
|
-
dbDir: string,
|
|
441
|
-
): Promise<CommandResult>;
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
Routed directly by `runCli` (not via
|
|
445
|
-
`dispatchCommand`) because the worker-stop command
|
|
446
|
-
does not require a live worker client connection.
|
|
447
|
-
|
|
448
|
-
### `runWorkerRestart`
|
|
449
|
-
|
|
450
|
-
**File:** `run-worker-restart.function.ts`
|
|
451
|
-
|
|
452
|
-
Stops and restarts the background worker daemon.
|
|
453
|
-
Calls `runWorkerStop` internally; the daemon
|
|
454
|
-
auto-spawns on the next CLI command, so restart only
|
|
455
|
-
needs to stop the current instance.
|
|
456
|
-
|
|
457
|
-
```ts
|
|
458
|
-
async function runWorkerRestart(
|
|
459
|
-
dbDir: string,
|
|
460
|
-
): Promise<CommandResult>;
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
Routed directly by `runCli` (not via
|
|
464
|
-
`dispatchCommand`) for the same reason as
|
|
465
|
-
`runWorkerStop`.
|
|
466
|
-
|
|
467
|
-
### `ensureDb`
|
|
468
|
-
|
|
469
|
-
**File:** `ensure-db.function.ts`
|
|
470
|
-
|
|
471
|
-
Ensures the database directory exists, prompting the
|
|
472
|
-
user if stdin is a TTY or failing if stdin is piped.
|
|
473
|
-
|
|
474
|
-
```ts
|
|
475
|
-
async function ensureDb(
|
|
476
|
-
dbPath: string,
|
|
477
|
-
): Promise<void>;
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
### `formatOutput`
|
|
481
|
-
|
|
482
|
-
**File:** `format-output.function.ts`
|
|
483
|
-
|
|
484
|
-
Formats a result object for the selected output format.
|
|
485
|
-
|
|
486
|
-
```ts
|
|
487
|
-
function formatOutput(
|
|
488
|
-
result: unknown,
|
|
489
|
-
format: OutputFormat,
|
|
490
|
-
): string;
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
| Format | Output |
|
|
494
|
-
|--------|-----------------------------|
|
|
495
|
-
| `json` | JSON string (default) |
|
|
496
|
-
| `text` | Human-readable list |
|
|
497
|
-
| `mcp` | MCP tool result format |
|
|
498
|
-
|
|
499
|
-
### `errorToMessage`
|
|
500
|
-
|
|
501
|
-
**File:** `error-to-message.function.ts`
|
|
502
|
-
|
|
503
|
-
Converts an unknown thrown value to a human-readable
|
|
504
|
-
message.
|
|
505
|
-
|
|
506
|
-
```ts
|
|
507
|
-
function errorToMessage(
|
|
508
|
-
err: unknown,
|
|
509
|
-
): string;
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
Returns `err.message` for `Error` instances, or
|
|
513
|
-
`String(err)` for all other values.
|
|
514
|
-
|
|
515
|
-
### `isStdinTty`
|
|
516
|
-
|
|
517
|
-
**File:** `is-stdin-tty.function.ts`
|
|
518
|
-
|
|
519
|
-
Returns `true` when stdin is an interactive terminal.
|
|
520
|
-
|
|
521
|
-
```ts
|
|
522
|
-
function isStdinTty(
|
|
523
|
-
stdin?: NodeJS.ReadStream,
|
|
524
|
-
): boolean;
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
`stdin` defaults to `process.stdin`.
|
|
528
|
-
|
|
529
|
-
### `promptUser`
|
|
530
|
-
|
|
531
|
-
**File:** `prompt-user.function.ts`
|
|
532
|
-
|
|
533
|
-
Prompts the user on stdin (TTY only) and returns the
|
|
534
|
-
trimmed reply.
|
|
535
|
-
|
|
536
|
-
```ts
|
|
537
|
-
async function promptUser(
|
|
538
|
-
question: string,
|
|
539
|
-
io?: PromptIO,
|
|
540
|
-
): Promise<string>;
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
`io` is an injectable interface for testing:
|
|
544
|
-
|
|
545
|
-
```ts
|
|
546
|
-
interface PromptIO {
|
|
547
|
-
ask: (question: string) => Promise<string>;
|
|
548
|
-
}
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
Defaults to readline on `process.stdin`/`process.stdout`.
|
|
552
|
-
|
|
553
|
-
### `resolveKbidPrefix`
|
|
554
|
-
|
|
555
|
-
**File:** `resolve-kbid-prefix.function.ts`
|
|
556
|
-
|
|
557
|
-
Resolves a short kbid prefix to a full 26-character
|
|
558
|
-
kbid. Scans all section types (`text`, `code`, `image`)
|
|
559
|
-
for kbids matching the prefix and returns the full
|
|
560
|
-
identifier when exactly one match exists. Full-length
|
|
561
|
-
identifiers (>= 26 chars) are returned as-is. Throws
|
|
562
|
-
when the prefix is ambiguous (multiple matches) or
|
|
563
|
-
unrecognized (no matches).
|
|
564
|
-
|
|
565
|
-
```ts
|
|
566
|
-
async function resolveKbidPrefix(
|
|
567
|
-
prefix: string,
|
|
568
|
-
client: PrefixResolver,
|
|
569
|
-
): Promise<string>;
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
`PrefixResolver` interface:
|
|
573
|
-
|
|
574
|
-
```ts
|
|
575
|
-
interface PrefixResolver {
|
|
576
|
-
listByType(
|
|
577
|
-
sectionType: string,
|
|
578
|
-
): Promise<readonly { kbid: string }[]>;
|
|
579
|
-
}
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
### `runDbInit`
|
|
583
|
-
|
|
584
|
-
**File:** `run-db-init.function.ts`
|
|
585
|
-
|
|
586
|
-
Creates the `.kbdb` directory scaffold directly on disk
|
|
587
|
-
without requiring a running worker daemon. Replaces
|
|
588
|
-
the deprecated `runInit` for the `kbdb db init`
|
|
589
|
-
subcommand.
|
|
590
|
-
|
|
591
|
-
```ts
|
|
592
|
-
async function runDbInit(
|
|
593
|
-
options: CliOptions,
|
|
594
|
-
): Promise<CommandResult>;
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
Output on success: JSON `{ "path": "...", "created": true }`.
|
|
598
|
-
|
|
599
|
-
### `runDbMigrate`
|
|
600
|
-
|
|
601
|
-
**File:** `run-db-migrate.function.ts`
|
|
602
|
-
|
|
603
|
-
Checks the database version and runs pending migrations
|
|
604
|
-
when needed. Successor to the deprecated `runMigrate`
|
|
605
|
-
for the `kbdb db migrate` subcommand.
|
|
606
|
-
|
|
607
|
-
```ts
|
|
608
|
-
async function runDbMigrate(
|
|
609
|
-
client: MigrateClient,
|
|
610
|
-
options: CliOptions,
|
|
611
|
-
): Promise<CommandResult>;
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
Calls `client.migrateDatabase(dbDir)` after resolving
|
|
615
|
-
the database directory from options.
|
|
616
|
-
|
|
617
|
-
### `runSkillLearn`
|
|
618
|
-
|
|
619
|
-
**File:** `run-skill-learn.function.ts`
|
|
620
|
-
|
|
621
|
-
Creates a new skill definition in the knowledge base.
|
|
622
|
-
Reads the skill body from the file path in
|
|
623
|
-
`options.body` (or stdin when `options.body` is `-`),
|
|
624
|
-
constructs the skill JSON, and adds it as a section
|
|
625
|
-
with `sectionType: 'skill'`.
|
|
626
|
-
|
|
627
|
-
```ts
|
|
628
|
-
async function runSkillLearn(
|
|
629
|
-
client: SkillLearnClient,
|
|
630
|
-
options: CliOptions,
|
|
631
|
-
): Promise<CommandResult>;
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
| Parameter | Source | Required |
|
|
635
|
-
|-------------------|-----------------|----------|
|
|
636
|
-
| `options.name` | `--name` | yes |
|
|
637
|
-
| `options.body` | `--body` | yes |
|
|
638
|
-
| `options.description` | `--description` | no |
|
|
639
|
-
|
|
640
|
-
Output: JSON `{ "kbid": "...", "name": "...",
|
|
641
|
-
"arguments": ["argName", ...] }`.
|
|
642
|
-
|
|
643
|
-
### `runSkillList`
|
|
644
|
-
|
|
645
|
-
**File:** `run-skill-list.function.ts`
|
|
646
|
-
|
|
647
|
-
Lists all skill sections stored in the knowledge base.
|
|
648
|
-
|
|
649
|
-
```ts
|
|
650
|
-
async function runSkillList(
|
|
651
|
-
client: SkillListClient,
|
|
652
|
-
options: CliOptions,
|
|
653
|
-
): Promise<CommandResult>;
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
Calls `client.listByType('skill')`. Output: JSON array
|
|
657
|
-
of `{ kbid, name, description, argumentCount }`.
|
|
658
|
-
|
|
659
|
-
### `runSkillGet`
|
|
660
|
-
|
|
661
|
-
**File:** `run-skill-get.function.ts`
|
|
662
|
-
|
|
663
|
-
Retrieves a single skill by name or kbid.
|
|
664
|
-
|
|
665
|
-
```ts
|
|
666
|
-
async function runSkillGet(
|
|
667
|
-
client: SkillGetClient,
|
|
668
|
-
options: CliOptions,
|
|
669
|
-
): Promise<CommandResult>;
|
|
670
|
-
```
|
|
671
|
-
|
|
672
|
-
The name-or-kbid argument is taken from `options.args[0]`.
|
|
673
|
-
Output: JSON `SkillDefinition` with `kbid` field.
|
|
674
|
-
|
|
675
|
-
### `runSkillDelete`
|
|
676
|
-
|
|
677
|
-
**File:** `run-skill-delete.function.ts`
|
|
678
|
-
|
|
679
|
-
Removes a skill section from the knowledge base.
|
|
680
|
-
|
|
681
|
-
```ts
|
|
682
|
-
async function runSkillDelete(
|
|
683
|
-
client: SkillDeleteClient,
|
|
684
|
-
options: CliOptions,
|
|
685
|
-
): Promise<CommandResult>;
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
The kbid argument is taken from `options.args[0]`.
|
|
689
|
-
Calls `client.removeSection(kbid)`. Output: JSON
|
|
690
|
-
`{ "kbid": "...", "removed": true }`.
|
|
691
|
-
|
|
692
|
-
### `runAgentCreate`
|
|
693
|
-
|
|
694
|
-
**File:** `run-agent-create.function.ts`
|
|
695
|
-
|
|
696
|
-
Creates a new agent document with a persona and
|
|
697
|
-
ordered skill references. Reads the persona from the
|
|
698
|
-
file path in `options.persona` (or stdin when `-`),
|
|
699
|
-
validates the skill kbids from `options.skills`, and
|
|
700
|
-
creates the agent document manifest.
|
|
701
|
-
|
|
702
|
-
```ts
|
|
703
|
-
async function runAgentCreate(
|
|
704
|
-
client: AgentCreateClient,
|
|
705
|
-
options: CliOptions,
|
|
706
|
-
): Promise<CommandResult>;
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
| Parameter | Source | Required |
|
|
710
|
-
|---------------------|-------------|----------|
|
|
711
|
-
| `options.name` | `--name` | yes |
|
|
712
|
-
| `options.persona` | `--persona` | yes |
|
|
713
|
-
| `options.skills` | `--skills` | yes |
|
|
714
|
-
| `options.description` | `--description` | no |
|
|
715
|
-
|
|
716
|
-
Output: JSON `{ "docid": "agent-...", "name": "...",
|
|
717
|
-
"skills": [...] }`.
|
|
718
|
-
|
|
719
|
-
### `runAgentList`
|
|
720
|
-
|
|
721
|
-
**File:** `run-agent-list.function.ts`
|
|
722
|
-
|
|
723
|
-
Lists all agent documents stored in the knowledge base.
|
|
724
|
-
|
|
725
|
-
```ts
|
|
726
|
-
async function runAgentList(
|
|
727
|
-
client: AgentListClient,
|
|
728
|
-
options: CliOptions,
|
|
729
|
-
): Promise<CommandResult>;
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
Calls `client.listDocumentsByType('agent')`. Output:
|
|
733
|
-
JSON array of `{ docid, name, description, skillCount }`.
|
|
734
|
-
|
|
735
|
-
### `runAgentGet`
|
|
736
|
-
|
|
737
|
-
**File:** `run-agent-get.function.ts`
|
|
738
|
-
|
|
739
|
-
Retrieves a single agent by document ID, with resolved
|
|
740
|
-
skill definitions.
|
|
741
|
-
|
|
742
|
-
```ts
|
|
743
|
-
async function runAgentGet(
|
|
744
|
-
client: AgentGetClient,
|
|
745
|
-
options: CliOptions,
|
|
746
|
-
): Promise<CommandResult>;
|
|
747
|
-
```
|
|
748
|
-
|
|
749
|
-
The docid argument is taken from `options.args[0]`.
|
|
750
|
-
Output: JSON `AgentDefinition` with resolved skills.
|
|
751
|
-
|
|
752
|
-
### `runAgentDelete`
|
|
753
|
-
|
|
754
|
-
**File:** `run-agent-delete.function.ts`
|
|
755
|
-
|
|
756
|
-
Removes an agent document manifest. The skill sections
|
|
757
|
-
referenced by the agent are not deleted.
|
|
758
|
-
|
|
759
|
-
```ts
|
|
760
|
-
async function runAgentDelete(
|
|
761
|
-
client: AgentDeleteClient,
|
|
762
|
-
options: CliOptions,
|
|
763
|
-
): Promise<CommandResult>;
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
The docid argument is taken from `options.args[0]`.
|
|
767
|
-
Output: JSON `{ "docid": "...", "removed": true }`.
|
|
768
|
-
|
|
769
|
-
## Testing
|
|
770
|
-
|
|
771
|
-
Each function has a `.spec.ts` at the module root:
|
|
772
|
-
|
|
773
|
-
```
|
|
774
|
-
src/shared/cli/
|
|
775
|
-
├── run-cli.spec.ts
|
|
776
|
-
├── dispatch-command.spec.ts
|
|
777
|
-
├── parse-args.spec.ts
|
|
778
|
-
├── find-db.spec.ts
|
|
779
|
-
├── run-init.spec.ts
|
|
780
|
-
├── run-migrate.spec.ts
|
|
781
|
-
├── run-db-init.spec.ts
|
|
782
|
-
├── run-db-migrate.spec.ts
|
|
783
|
-
├── run-learn.spec.ts
|
|
784
|
-
├── run-export.spec.ts
|
|
785
|
-
├── run-unlearn.spec.ts
|
|
786
|
-
├── run-search.spec.ts
|
|
787
|
-
├── run-recall.spec.ts
|
|
788
|
-
├── run-content.spec.ts
|
|
789
|
-
├── run-status.spec.ts
|
|
790
|
-
├── run-check.spec.ts
|
|
791
|
-
├── run-gc.spec.ts
|
|
792
|
-
├── run-rebuild.spec.ts
|
|
793
|
-
├── run-worker-stop.spec.ts
|
|
794
|
-
├── run-worker-restart.spec.ts
|
|
795
|
-
├── resolve-kbid-prefix.spec.ts
|
|
796
|
-
├── run-skill-learn.spec.ts
|
|
797
|
-
├── run-skill-list.spec.ts
|
|
798
|
-
├── run-skill-get.spec.ts
|
|
799
|
-
├── run-skill-delete.spec.ts
|
|
800
|
-
├── run-agent-create.spec.ts
|
|
801
|
-
├── run-agent-list.spec.ts
|
|
802
|
-
├── run-agent-get.spec.ts
|
|
803
|
-
├── run-agent-delete.spec.ts
|
|
804
|
-
├── ensure-db.spec.ts
|
|
805
|
-
├── format-output.spec.ts
|
|
806
|
-
├── error-to-message.spec.ts
|
|
807
|
-
├── is-stdin-tty.spec.ts
|
|
808
|
-
└── prompt-user.spec.ts
|
|
809
|
-
```
|