@dikolab/kbdb 0.5.0 → 0.6.1

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.
Files changed (224) hide show
  1. package/CLA.md +68 -0
  2. package/LICENSE +676 -12
  3. package/LICENSING.md +58 -0
  4. package/README.md +50 -25
  5. package/README.md.bak +322 -0
  6. package/dist/README.md +322 -0
  7. package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
  8. package/dist/chunk-QLJ33C74.mjs.map +7 -0
  9. package/dist/cli.cjs +550 -232
  10. package/dist/cli.cjs.map +4 -4
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.mjs +483 -154
  13. package/dist/cli.mjs.map +4 -4
  14. package/dist/kbdb-worker.cjs +36 -5
  15. package/dist/kbdb-worker.cjs.map +3 -3
  16. package/dist/mod.cjs +89 -30
  17. package/dist/mod.cjs.map +4 -4
  18. package/dist/mod.mjs +88 -30
  19. package/dist/mod.mjs.map +4 -4
  20. package/dist/src/cli.d.ts +0 -8
  21. package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
  22. package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
  23. package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
  24. package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
  25. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
  26. package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
  27. package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
  28. package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
  29. package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
  30. package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
  31. package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
  32. package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
  33. package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
  34. package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
  35. package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
  36. package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
  37. package/dist/src/shared/cli/index.d.ts +4 -1
  38. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
  39. package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
  40. package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
  41. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  42. package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
  43. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
  44. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
  45. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
  46. package/dist/src/shared/wasm-codec/index.d.ts +1 -1
  47. package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
  48. package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
  49. package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
  50. package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
  51. package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
  52. package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
  53. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
  54. package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
  55. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
  56. package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
  57. package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
  58. package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
  59. package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
  60. package/dist/src/worker.d.ts +0 -7
  61. package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
  62. package/dist/wasm/default-embedding/package.json +1 -1
  63. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  64. package/dist/wasm/fs-database/package.json +1 -1
  65. package/dist/wasm/fs-migration/package.json +1 -1
  66. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  67. package/dist/wasm/kb-worker/package.json +1 -1
  68. package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
  69. package/dist/wasm/query-parser/package.json +1 -1
  70. package/dist/worker.d.ts +0 -7
  71. package/dist/worker.mjs +37 -6
  72. package/dist/worker.mjs.map +3 -3
  73. package/package.json +11 -10
  74. package/dist/chunk-BJXEVALU.mjs.map +0 -7
  75. package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
  76. package/docs/details/README.md +0 -30
  77. package/docs/details/agent-tooling.md +0 -132
  78. package/docs/details/cli.md +0 -777
  79. package/docs/details/knowledge-base.md +0 -180
  80. package/docs/details/library-api.md +0 -495
  81. package/docs/details/mcp-server.md +0 -482
  82. package/docs/details/search-and-ranking.md +0 -575
  83. package/docs/details/storage.md +0 -531
  84. package/docs/goals/agents.md +0 -751
  85. package/docs/goals/architecture.svg +0 -198
  86. package/docs/goals/auto-capture.md +0 -378
  87. package/docs/goals/benchmarking.md +0 -296
  88. package/docs/goals/cli.md +0 -2654
  89. package/docs/goals/concurrency.md +0 -259
  90. package/docs/goals/content-composer.md +0 -609
  91. package/docs/goals/content-parser.md +0 -279
  92. package/docs/goals/database.md +0 -1679
  93. package/docs/goals/document.md +0 -368
  94. package/docs/goals/hybrid-search.md +0 -465
  95. package/docs/goals/mcp.md +0 -1541
  96. package/docs/goals/overview.md +0 -124
  97. package/docs/goals/query-parser.md +0 -373
  98. package/docs/goals/query-result.md +0 -860
  99. package/docs/goals/semantic-dedup.md +0 -233
  100. package/docs/goals/skills.md +0 -810
  101. package/docs/goals/sync.md +0 -217
  102. package/docs/goals/worker-client.md +0 -1005
  103. package/docs/goals/worker-daemon.md +0 -1547
  104. package/docs/modules/overview.md +0 -319
  105. package/docs/modules/rust/embedding/module.md +0 -91
  106. package/docs/modules/rust/fs-database/functions/document.md +0 -48
  107. package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
  108. package/docs/modules/rust/fs-database/functions/io.md +0 -87
  109. package/docs/modules/rust/fs-database/functions/module.md +0 -22
  110. package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
  111. package/docs/modules/rust/fs-database/functions/section.md +0 -76
  112. package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
  113. package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
  114. package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
  115. package/docs/modules/rust/fs-database/indexes/module.md +0 -64
  116. package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
  117. package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
  118. package/docs/modules/rust/fs-database/module.md +0 -150
  119. package/docs/modules/rust/fs-database/types/catalog.md +0 -53
  120. package/docs/modules/rust/fs-database/types/module.md +0 -12
  121. package/docs/modules/rust/fs-database/types/section.md +0 -127
  122. package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
  123. package/docs/modules/rust/kb-worker/functions/module.md +0 -20
  124. package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
  125. package/docs/modules/rust/kb-worker/functions/search.md +0 -173
  126. package/docs/modules/rust/kb-worker/functions/write.md +0 -172
  127. package/docs/modules/rust/kb-worker/module.md +0 -171
  128. package/docs/modules/rust/kb-worker/types/cache.md +0 -90
  129. package/docs/modules/rust/kb-worker/types/context.md +0 -26
  130. package/docs/modules/rust/kb-worker/types/module.md +0 -16
  131. package/docs/modules/rust/kb-worker/types/status.md +0 -29
  132. package/docs/modules/rust/kb-worker/types/token.md +0 -50
  133. package/docs/modules/rust/overview.md +0 -531
  134. package/docs/modules/rust/query-parser/functions/extract.md +0 -56
  135. package/docs/modules/rust/query-parser/functions/module.md +0 -18
  136. package/docs/modules/rust/query-parser/functions/parse.md +0 -33
  137. package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
  138. package/docs/modules/rust/query-parser/functions/rank.md +0 -85
  139. package/docs/modules/rust/query-parser/module.md +0 -131
  140. package/docs/modules/rust/query-parser/types/cache.md +0 -39
  141. package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
  142. package/docs/modules/rust/query-parser/types/module.md +0 -18
  143. package/docs/modules/rust/query-parser/types/token.md +0 -46
  144. package/docs/modules/rust/shared/content-composer/functions.md +0 -114
  145. package/docs/modules/rust/shared/content-composer/module.md +0 -147
  146. package/docs/modules/rust/shared/content-composer/types.md +0 -93
  147. package/docs/modules/rust/shared/content-parser/functions.md +0 -72
  148. package/docs/modules/rust/shared/content-parser/module.md +0 -99
  149. package/docs/modules/rust/shared/content-parser/types.md +0 -71
  150. package/docs/modules/rust/shared/corpus/module.md +0 -24
  151. package/docs/modules/rust/shared/corpus/types.md +0 -141
  152. package/docs/modules/rust/shared/document/module.md +0 -25
  153. package/docs/modules/rust/shared/document/types.md +0 -154
  154. package/docs/modules/rust/shared/encode/module.md +0 -22
  155. package/docs/modules/rust/shared/encode/traits.md +0 -304
  156. package/docs/modules/rust/shared/error/module.md +0 -28
  157. package/docs/modules/rust/shared/error/types.md +0 -302
  158. package/docs/modules/rust/shared/kbid/module.md +0 -24
  159. package/docs/modules/rust/shared/kbid/types.md +0 -147
  160. package/docs/modules/rust/shared/memory/functions.md +0 -209
  161. package/docs/modules/rust/shared/memory/module.md +0 -24
  162. package/docs/modules/rust/shared/module.md +0 -196
  163. package/docs/modules/rust/shared/pipeline/functions.md +0 -141
  164. package/docs/modules/rust/shared/pipeline/module.md +0 -62
  165. package/docs/modules/rust/shared/pipeline/types.md +0 -43
  166. package/docs/modules/rust/shared/query/module.md +0 -27
  167. package/docs/modules/rust/shared/query/types.md +0 -236
  168. package/docs/modules/rust/shared/section/module.md +0 -25
  169. package/docs/modules/rust/shared/section/types.md +0 -294
  170. package/docs/modules/rust/shared/term/module.md +0 -25
  171. package/docs/modules/rust/shared/term/types.md +0 -139
  172. package/docs/modules/typescript/cli.md +0 -131
  173. package/docs/modules/typescript/kbdb-worker.md +0 -150
  174. package/docs/modules/typescript/overview.md +0 -400
  175. package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
  176. package/docs/modules/typescript/shared/cli/constants.md +0 -23
  177. package/docs/modules/typescript/shared/cli/functions.md +0 -809
  178. package/docs/modules/typescript/shared/cli/module.md +0 -138
  179. package/docs/modules/typescript/shared/cli/typings.md +0 -197
  180. package/docs/modules/typescript/shared/embedding/functions.md +0 -200
  181. package/docs/modules/typescript/shared/embedding/module.md +0 -77
  182. package/docs/modules/typescript/shared/embedding/typings.md +0 -124
  183. package/docs/modules/typescript/shared/hash/functions.md +0 -20
  184. package/docs/modules/typescript/shared/hash/module.md +0 -21
  185. package/docs/modules/typescript/shared/log/constants.md +0 -82
  186. package/docs/modules/typescript/shared/log/functions.md +0 -131
  187. package/docs/modules/typescript/shared/log/module.md +0 -153
  188. package/docs/modules/typescript/shared/log/typings.md +0 -82
  189. package/docs/modules/typescript/shared/mcp/classes.md +0 -179
  190. package/docs/modules/typescript/shared/mcp/functions.md +0 -386
  191. package/docs/modules/typescript/shared/mcp/module.md +0 -160
  192. package/docs/modules/typescript/shared/mcp/typings.md +0 -529
  193. package/docs/modules/typescript/shared/module.md +0 -110
  194. package/docs/modules/typescript/shared/platform/functions.md +0 -42
  195. package/docs/modules/typescript/shared/platform/module.md +0 -25
  196. package/docs/modules/typescript/shared/runtime/functions.md +0 -26
  197. package/docs/modules/typescript/shared/runtime/module.md +0 -27
  198. package/docs/modules/typescript/shared/runtime/typings.md +0 -13
  199. package/docs/modules/typescript/shared/version/module.md +0 -27
  200. package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
  201. package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
  202. package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
  203. package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
  204. package/docs/modules/typescript/shared/worker-client/module.md +0 -92
  205. package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
  206. package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
  207. package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
  208. package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
  209. package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
  210. package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
  211. package/docs/overview.md +0 -191
  212. package/docs/release-notes/0.1.0.md +0 -189
  213. package/docs/release-notes/0.1.1.md +0 -46
  214. package/docs/release-notes/0.1.2.md +0 -38
  215. package/docs/release-notes/0.1.3.md +0 -42
  216. package/docs/release-notes/0.2.0.md +0 -147
  217. package/docs/release-notes/0.3.0.md +0 -89
  218. package/docs/release-notes/0.3.1.md +0 -121
  219. package/docs/release-notes/0.3.2.md +0 -64
  220. package/docs/release-notes/0.4.0.md +0 -80
  221. package/docs/release-notes/0.4.1.md +0 -149
  222. package/docs/release-notes/0.4.3.md +0 -60
  223. package/docs/release-notes/0.5.0.md +0 -41
  224. package/docs/release-notes/README.md +0 -16
@@ -1,751 +0,0 @@
1
- # Agents -- Delegatable AI Agent Personas
2
-
3
- *Named AI agent personas stored as knowledge base
4
- documents, each carrying a system prompt and an ordered
5
- list of skill references that a host AI can discover
6
- and delegate work to.*
7
-
8
- ## Goal
9
-
10
- Agents are reusable AI agent persona definitions. Each
11
- agent has a persona (a system prompt that describes
12
- its role and behaviour) and an ordered list of skill
13
- references. A host AI agent can look up agents, retrieve
14
- their persona and skills, and delegate tasks to them.
15
-
16
- The motivation is composability: instead of encoding
17
- agent behaviour directly into application code, agent
18
- personas are stored in the knowledge base where they
19
- are discoverable, shareable, and independently
20
- updatable. The host AI decides how to use an agent
21
- definition -- the knowledge base does not execute
22
- agents.
23
-
24
- Agents are stored as knowledge base **documents** (not
25
- sections) with `type = 'agent'`. This distinguishes
26
- them from regular documents while reusing the same
27
- document manifest infrastructure. Skills are referenced
28
- by kbid, not by name, so that skill updates (which
29
- produce new kbids) make dangling references visible
30
- rather than silently binding to the wrong version.
31
-
32
- See [Skills](skills.md) for the skill definition
33
- format that agents reference.
34
-
35
- ## Agent Document Schema
36
-
37
- ### Agent Manifest Format
38
-
39
- Agents are persisted as TOML document manifests in
40
- `.kbdb/documents/{docid}.toml`. The format extends the
41
- standard document manifest with an `[agent]` table and
42
- `[[sections]]` entries that list skill kbids:
43
-
44
- ```toml
45
- [document]
46
- docid = "agent-code-reviewer"
47
- title = "Code Reviewer Agent"
48
- type = "agent"
49
- created_at = "2026-06-19T10:00:00Z"
50
-
51
- [agent]
52
- description = "Reviews code for bugs, style, and best
53
- practices"
54
- persona = """You are an expert code reviewer.
55
- You focus on correctness, readability, and
56
- maintainability. You provide actionable feedback
57
- with specific suggestions."""
58
-
59
- [[sections]]
60
- kbid = "abc123def456abc123def456ab"
61
- position = 0
62
-
63
- [[sections]]
64
- kbid = "def456abc123def456abc123de"
65
- position = 1
66
- ```
67
-
68
- Key conventions:
69
-
70
- - `[document].type = "agent"` identifies this manifest
71
- as an agent. Documents without a `type` field are
72
- regular documents (backward-compatible).
73
- - `[document].title` is the display name of the agent
74
- and is used as the prompt name in `prompts/list`.
75
- - `[agent].description` is the short description
76
- surfaced in `prompts/list`.
77
- - `[agent].persona` is the full system prompt text
78
- returned by `prompts/get`.
79
- - `[[sections]]` entries list skill kbids in ascending
80
- `position` order. These are the skills the agent is
81
- equipped with.
82
-
83
- ### AgentDefinition type
84
-
85
- The full definition of an agent as returned by
86
- `agent-get` and `prompts/get`:
87
-
88
- ```typescript
89
- interface AgentDefinition {
90
- /** Document ID of the agent manifest. */
91
- readonly docid: string;
92
- /** Display name of the agent. */
93
- readonly name: string;
94
- /** Short description of the agent's purpose. */
95
- readonly description: string;
96
- /** System prompt text (persona). */
97
- readonly persona: string;
98
- /** Ordered list of resolved skill references. */
99
- readonly skills: readonly {
100
- /** Skill kbid. */
101
- readonly kbid: string;
102
- /** Skill name, or null when the skill is missing. */
103
- readonly name: string | null;
104
- /** Position index (0-based). */
105
- readonly position: number;
106
- }[];
107
- }
108
- ```
109
-
110
- ## Storage
111
-
112
- ### Document Manifest File Format
113
-
114
- Agent manifests use the `.toml` extension and live in
115
- `.kbdb/documents/`. The file name is the `docid` with
116
- `.toml` appended:
117
-
118
- ```
119
- .kbdb/
120
- documents/
121
- agent-code-reviewer.toml
122
- agent-research-assistant.toml
123
- ```
124
-
125
- The `docid` is chosen by the caller at creation time
126
- (supplied as `--name` on the CLI or `name` in the MCP
127
- tool call). It must be unique among all document IDs.
128
- Conventionally it is the agent name in kebab-case.
129
-
130
- Unlike sections, agent manifests are **not**
131
- content-addressed. The `docid` is stable across
132
- persona or skill-list changes. Updating an agent
133
- overwrites its manifest file in place.
134
-
135
- ### Skill References
136
-
137
- Skills are referenced in `[[sections]]` entries by
138
- their kbid, ordered by `position`:
139
-
140
- - **kbid ordering.** The `position` field is an integer
141
- starting at 0. Skills are presented to the host AI
142
- in position order. The order is significant -- it
143
- controls the sequence in which skills appear in the
144
- `prompts/get` response.
145
- - **Validation at creation time.** When an agent is
146
- created, all supplied skill kbids are validated to
147
- exist as sections with `sectionType = 'skill'`. An
148
- invalid kbid causes the create operation to fail with
149
- an `INVALID_PARAMS` error.
150
- - **No re-validation on read.** When an agent is
151
- retrieved, skill kbids are looked up but a missing
152
- kbid is not an error. It appears as a dangling
153
- reference with `name: null` (see
154
- [Skill Resolution](#skill-resolution)).
155
-
156
- ### Relationship Model
157
-
158
- The relationship between agents and skills is
159
- many-to-many:
160
-
161
- - One agent may reference many skills (its toolkit).
162
- - One skill may be referenced by many agents (shared
163
- capability).
164
-
165
- Agents reference skills by kbid only. No inverse index
166
- tracks which agents reference a given skill. This means:
167
-
168
- - Deleting a skill does not cascade to agents. Agent
169
- manifests retain the kbid as a dangling reference.
170
- - Deleting an agent does not delete any skill sections.
171
- - There is no circular reference possible -- agents
172
- cannot reference other agents.
173
-
174
- ## MCP Surface
175
-
176
- ### Agents as MCP Prompts
177
-
178
- Agents appear in the MCP prompts protocol alongside
179
- skills. To distinguish agents from skills in
180
- `prompts/list`, agent prompt names use an `agent:`
181
- prefix followed by the agent's `docid`:
182
-
183
- ```
184
- agent:code-reviewer
185
- agent:research-assistant
186
- ```
187
-
188
- This prefix convention allows MCP clients to
189
- distinguish skill prompts (no prefix) from agent
190
- prompts (`agent:` prefix) without additional metadata.
191
- See [MCP](mcp.md) for the full prompt protocol
192
- specification.
193
-
194
- ### prompts/list (agent entries)
195
-
196
- Agents appear in the `prompts/list` response alongside
197
- skill entries. Agent entries have an empty `arguments`
198
- array (agents accept no per-invocation arguments):
199
-
200
- ```json
201
- {
202
- "prompts": [
203
- {
204
- "name": "summarize-document",
205
- "description": "Summarize a document into key
206
- points with configurable depth",
207
- "arguments": [
208
- {
209
- "name": "docid",
210
- "description": "Document identifier",
211
- "required": true
212
- }
213
- ]
214
- },
215
- {
216
- "name": "agent:code-reviewer",
217
- "description": "Reviews code for bugs, style,
218
- and best practices",
219
- "arguments": []
220
- }
221
- ]
222
- }
223
- ```
224
-
225
- ### prompts/get (agent retrieval)
226
-
227
- When `prompts/get` is called with an `agent:` prefixed
228
- name, the response contains two messages:
229
-
230
- 1. **First message** (role `assistant`): the agent's
231
- persona text. This becomes the system prompt for the
232
- delegated agent.
233
- 2. **Second message** (role `user`): a rendered listing
234
- of the agent's available skills with their names and
235
- descriptions.
236
-
237
- Request:
238
- ```json
239
- {
240
- "name": "agent:code-reviewer",
241
- "arguments": {}
242
- }
243
- ```
244
-
245
- Response:
246
- ```json
247
- {
248
- "messages": [
249
- {
250
- "role": "assistant",
251
- "content": {
252
- "type": "text",
253
- "text": "You are an expert code reviewer.\nYou
254
- focus on correctness, readability, and
255
- maintainability. You provide actionable
256
- feedback with specific suggestions."
257
- }
258
- },
259
- {
260
- "role": "user",
261
- "content": {
262
- "type": "text",
263
- "text": "You have access to the following
264
- skills:\n\n1. summarize-document --
265
- Summarize a document into key points with
266
- configurable depth\n2. code-review --
267
- Review code and provide structured
268
- feedback"
269
- }
270
- }
271
- ]
272
- }
273
- ```
274
-
275
- The skill listing in the second message is ordered by
276
- `position`. Dangling skill references (missing kbid)
277
- are omitted from the listing silently.
278
-
279
- ## MCP Tools
280
-
281
- ### agent-create
282
-
283
- Create a new agent in the knowledge base.
284
-
285
- | Parameter | Type | Required | Description |
286
- |---------------|----------|----------|-------------------------------|
287
- | `name` | string | yes | Agent name / docid (kebab-case)|
288
- | `description` | string | yes | Short description of the agent|
289
- | `persona` | string | yes | System prompt text |
290
- | `skills` | string[] | yes | Ordered skill kbid list |
291
-
292
- **Returns:** Agent creation result:
293
-
294
- ```json
295
- {
296
- "docid": "agent-code-reviewer",
297
- "name": "code-reviewer",
298
- "skills": [
299
- "abc123def456abc123def456ab",
300
- "def456abc123def456abc123de"
301
- ]
302
- }
303
- ```
304
-
305
- Fails with `INVALID_PARAMS` when any skill kbid in
306
- `skills` does not exist or does not have
307
- `sectionType = 'skill'`.
308
-
309
- Maps to client method: `client.createDocument({ type: 'agent', ... })`
310
-
311
- ### agent-list
312
-
313
- List all agents stored in the knowledge base.
314
-
315
- No parameters.
316
-
317
- **Returns:** JSON array of agent summary objects:
318
-
319
- ```json
320
- [
321
- {
322
- "docid": "agent-code-reviewer",
323
- "name": "Code Reviewer Agent",
324
- "description": "Reviews code for bugs, style,
325
- and best practices",
326
- "skillCount": 2
327
- }
328
- ]
329
- ```
330
-
331
- Empty array when no agents are stored.
332
-
333
- Maps to client method: `client.listDocumentsByType('agent')`
334
-
335
- ### agent-get
336
-
337
- Retrieve the full definition of an agent by docid.
338
-
339
- | Parameter | Type | Required | Description |
340
- |-----------|--------|----------|------------------------|
341
- | `docid` | string | yes | Agent document ID |
342
-
343
- **Returns:** Full `AgentDefinition` with resolved
344
- skills:
345
-
346
- ```json
347
- {
348
- "docid": "agent-code-reviewer",
349
- "name": "Code Reviewer Agent",
350
- "description": "Reviews code for bugs, style, and
351
- best practices",
352
- "persona": "You are an expert code reviewer.\nYou
353
- focus on correctness, readability, and
354
- maintainability.",
355
- "skills": [
356
- {
357
- "kbid": "abc123def456abc123def456ab",
358
- "name": "summarize-document",
359
- "position": 0
360
- },
361
- {
362
- "kbid": "def456abc123def456abc123de",
363
- "name": "code-review",
364
- "position": 1
365
- }
366
- ]
367
- }
368
- ```
369
-
370
- Dangling kbids appear with `"name": null`:
371
-
372
- ```json
373
- {
374
- "kbid": "abc123def456abc123def456ab",
375
- "name": null,
376
- "position": 0
377
- }
378
- ```
379
-
380
- Maps to client method: `client.getDocument(docid)` +
381
- `client.getSection(kbid)` per skill reference.
382
-
383
- ### agent-delete
384
-
385
- Remove an agent from the knowledge base by docid.
386
-
387
- | Parameter | Type | Required | Description |
388
- |-----------|--------|----------|------------------------|
389
- | `docid` | string | yes | Agent document ID |
390
-
391
- **Returns:** Removal confirmation:
392
-
393
- ```json
394
- {
395
- "docid": "agent-code-reviewer",
396
- "removed": true
397
- }
398
- ```
399
-
400
- When the docid does not exist, `removed` is `false`
401
- and no error is thrown. Skill sections referenced by
402
- the agent are **not** deleted.
403
-
404
- Maps to client method: `client.removeDocument(docid)`
405
-
406
- ## CLI Commands
407
-
408
- ### kbdb agent create
409
-
410
- ```
411
- kbdb agent create [options] --name <name>
412
- --persona <file|-> --skills <kbid,...>
413
- ```
414
-
415
- Create a new agent in the knowledge base.
416
-
417
- **Options:**
418
-
419
- | Option | Short | Required | Description |
420
- |--------------------|-------|----------|--------------------------------|
421
- | `--name <n>` | | yes | Agent name / docid (kebab-case)|
422
- | `--description` | | no | Short agent description |
423
- | `--persona <file>` | | yes | Persona file or `-` for stdin |
424
- | `--skills <kbids>` | | yes | Comma-separated skill kbids |
425
- | `--db <path>` | | no | Path to .kbdb directory |
426
-
427
- **Behaviour:**
428
-
429
- Reads the persona text from the specified file path or
430
- from stdin when `--persona -` is given. Parses
431
- `--skills` as a comma-separated list of kbids,
432
- validating each against the knowledge base. Creates a
433
- TOML agent manifest and stores it in
434
- `.kbdb/documents/`.
435
-
436
- **Output:**
437
-
438
- ```json
439
- {
440
- "docid": "agent-code-reviewer",
441
- "name": "code-reviewer",
442
- "skills": [
443
- "abc123def456abc123def456ab",
444
- "def456abc123def456abc123de"
445
- ]
446
- }
447
- ```
448
-
449
- **Delegation chain:**
450
- ```
451
- src/cli.ts parseArgs()
452
- -> findDb() / promptUser() / runInit()
453
- -> createWorkerClient({ contextPath })
454
- -> versionGate(client, dbDir)
455
- -> dispatchCommand(client, options)
456
- -> runAgentCreate(client, options)
457
- -> client.createDocument({
458
- type: 'agent',
459
- docid: name,
460
- title, description,
461
- persona,
462
- skills: kbidArray })
463
- -> IPC -> worker daemon
464
- -> kb-worker.wasm
465
- -> fs-database.wasm (write)
466
- ```
467
-
468
- **Examples:**
469
-
470
- ```sh
471
- # Create an agent from a persona file
472
- kbdb agent create --name code-reviewer \
473
- --description "Reviews code for quality" \
474
- --persona ./personas/code-reviewer.txt \
475
- --skills abc123def456abc123def456ab,\
476
- def456abc123def456abc123de
477
-
478
- # Create an agent reading persona from stdin
479
- cat ./personas/assistant.txt | kbdb agent create \
480
- --name research-assistant \
481
- --persona - \
482
- --skills abc123def456abc123def456ab
483
-
484
- # Specify database directory explicitly
485
- kbdb agent create --name my-agent \
486
- --persona ./persona.txt \
487
- --skills abc123def456abc123def456ab \
488
- --db /path/to/project
489
- ```
490
-
491
- ### kbdb agent list
492
-
493
- ```
494
- kbdb agent list [options]
495
- ```
496
-
497
- List all agents stored in the knowledge base.
498
-
499
- **Options:**
500
-
501
- | Option | Short | Required | Description |
502
- |---------------|-------|----------|-------------------------|
503
- | `--db <path>` | | no | Path to .kbdb directory |
504
-
505
- **Output:**
506
-
507
- JSON array of agent summary objects:
508
-
509
- ```json
510
- [
511
- {
512
- "docid": "agent-code-reviewer",
513
- "name": "Code Reviewer Agent",
514
- "description": "Reviews code for bugs, style,
515
- and best practices",
516
- "skillCount": 2
517
- }
518
- ]
519
- ```
520
-
521
- Empty array when no agents are stored.
522
-
523
- **Delegation chain:**
524
- ```
525
- src/cli.ts parseArgs()
526
- -> findDb() / promptUser() / runInit()
527
- -> createWorkerClient({ contextPath })
528
- -> versionGate(client, dbDir)
529
- -> dispatchCommand(client, options)
530
- -> runAgentList(client, options)
531
- -> client.listDocumentsByType('agent')
532
- -> IPC -> worker daemon
533
- -> kb-worker.wasm
534
- -> fs-database.wasm (scan)
535
- ```
536
-
537
- **Examples:**
538
-
539
- ```sh
540
- # List all agents
541
- kbdb agent list
542
-
543
- # List agents from a specific database
544
- kbdb agent list --db /path/to/project
545
- ```
546
-
547
- ### kbdb agent get
548
-
549
- ```
550
- kbdb agent get [options] <docid>
551
- ```
552
-
553
- Retrieve the full definition of an agent by its docid,
554
- including resolved skill names.
555
-
556
- **Arguments:**
557
-
558
- - `<docid>` -- the agent document ID. Required.
559
-
560
- **Options:**
561
-
562
- | Option | Short | Required | Description |
563
- |---------------|-------|----------|-------------------------|
564
- | `--db <path>` | | no | Path to .kbdb directory |
565
-
566
- **Output:**
567
-
568
- Full `AgentDefinition` with resolved skills. Dangling
569
- skill references appear with `"name": null`.
570
-
571
- ```json
572
- {
573
- "docid": "agent-code-reviewer",
574
- "name": "Code Reviewer Agent",
575
- "description": "Reviews code for bugs, style, and
576
- best practices",
577
- "persona": "You are an expert code reviewer...",
578
- "skills": [
579
- {
580
- "kbid": "abc123def456abc123def456ab",
581
- "name": "summarize-document",
582
- "position": 0
583
- }
584
- ]
585
- }
586
- ```
587
-
588
- **Delegation chain:**
589
- ```
590
- src/cli.ts parseArgs()
591
- -> findDb() / promptUser() / runInit()
592
- -> createWorkerClient({ contextPath })
593
- -> versionGate(client, dbDir)
594
- -> dispatchCommand(client, options)
595
- -> runAgentGet(client, options)
596
- -> client.getDocument(docid)
597
- -> IPC -> worker daemon
598
- -> kb-worker.wasm
599
- -> fs-database.wasm (fetch)
600
- -> client.getSection(kbid) per skill
601
- -> IPC -> worker daemon (resolve names)
602
- ```
603
-
604
- **Examples:**
605
-
606
- ```sh
607
- # Get an agent by docid
608
- kbdb agent get agent-code-reviewer
609
-
610
- # Get from a specific database
611
- kbdb agent get agent-code-reviewer \
612
- --db /path/to/project
613
- ```
614
-
615
- ### kbdb agent delete
616
-
617
- ```
618
- kbdb agent delete [options] <docid>
619
- ```
620
-
621
- Remove an agent from the knowledge base. Skill
622
- sections referenced by the agent are not deleted.
623
-
624
- **Arguments:**
625
-
626
- - `<docid>` -- the agent document ID. Required.
627
-
628
- **Options:**
629
-
630
- | Option | Short | Required | Description |
631
- |---------------|-------|----------|-------------------------|
632
- | `--db <path>` | | no | Path to .kbdb directory |
633
-
634
- **Output:**
635
-
636
- ```json
637
- {
638
- "docid": "agent-code-reviewer",
639
- "removed": true
640
- }
641
- ```
642
-
643
- **Delegation chain:**
644
- ```
645
- src/cli.ts parseArgs()
646
- -> findDb() / promptUser() / runInit()
647
- -> createWorkerClient({ contextPath })
648
- -> versionGate(client, dbDir)
649
- -> dispatchCommand(client, options)
650
- -> runAgentDelete(client, options)
651
- -> client.removeDocument(docid)
652
- -> IPC -> worker daemon
653
- -> kb-worker.wasm
654
- -> fs-database.wasm (delete)
655
- ```
656
-
657
- **Examples:**
658
-
659
- ```sh
660
- # Delete an agent by docid
661
- kbdb agent delete agent-code-reviewer
662
-
663
- # Delete from a specific database
664
- kbdb agent delete agent-code-reviewer \
665
- --db /path/to/project
666
- ```
667
-
668
- ## Skill Resolution
669
-
670
- When `agent-get` or `prompts/get` retrieves an agent,
671
- each kbid in the `[[sections]]` list is resolved to
672
- its skill name:
673
-
674
- 1. Look up the kbid in the section store via
675
- `client.getSection(kbid)`.
676
- 2. If found and `sectionType === 'skill'`, read the
677
- `title` field (which equals the skill `name`).
678
- Return `{ kbid, name: title, position }`.
679
- 3. If the kbid does not exist (skill was deleted),
680
- return `{ kbid, name: null, position }`. This is a
681
- warning condition, not an error.
682
- 4. If the kbid exists but `sectionType !== 'skill'`
683
- (non-skill section was referenced), the `name`
684
- field is set to the section `title` and a warning
685
- annotation is included in the response.
686
-
687
- The full `AgentDefinition` is returned in all cases.
688
- Callers can detect dangling references by checking
689
- for `name: null` in the `skills` array.
690
-
691
- ## Edge Cases
692
-
693
- **Agent with zero skills.** An agent with an empty
694
- `skills` list (or `--skills` not supplied) is a
695
- persona-only agent. This is allowed. It is useful when
696
- the agent persona is standalone and does not need
697
- toolkit skills.
698
-
699
- **Agent referencing a non-existent skill.** When a
700
- skill is deleted after the agent has been created, the
701
- agent manifest retains the kbid. On retrieval,
702
- `agent-get` returns the dangling kbid with
703
- `"name": null`. The agent document is not modified.
704
- The host AI receives a signal that a skill is missing
705
- and can decide how to proceed.
706
-
707
- **Duplicate agent names.** Two agents may share the
708
- same `--name` value if they are created with different
709
- docids. However, because the docid is derived from the
710
- `name` option, duplicate `--name` values at creation
711
- time will overwrite the existing manifest unless the
712
- caller uses a unique docid. This behaviour is
713
- intentional -- updating an agent reuses the same docid.
714
-
715
- **Agent referencing non-skill sections.** The
716
- `[[sections]]` kbid list is not validated for
717
- `sectionType` at creation time. If a non-skill kbid is
718
- included, it is stored and returned during resolution
719
- with a best-effort name. This is not recommended but
720
- not blocked.
721
-
722
- **Deleting an agent.** Only the agent document manifest
723
- (`.kbdb/documents/{docid}.toml`) is removed. Skill
724
- sections remain in the knowledge base and are
725
- unaffected. Other agents referencing the same skills
726
- continue to work normally.
727
-
728
- ## Design Constraints
729
-
730
- - **Agents are documents, not a separate entity type.**
731
- Agents reuse the document manifest infrastructure
732
- with `type = 'agent'`. No new storage schema,
733
- separate directory, or index is introduced.
734
- - **Skills are referenced by kbid, not by name.**
735
- Using kbids makes skill updates visible as dangling
736
- references rather than silently binding to a
737
- different skill version. The caller must look up the
738
- kbid of a skill before creating an agent.
739
- - **No agent versioning.** Updating an agent means
740
- writing a new manifest over the existing docid. The
741
- docid is stable; there is no version history.
742
- - **No agent execution.** Agents are definitions only.
743
- The knowledge base stores and surfaces them; the
744
- host AI decides how to instantiate and use them.
745
- The `prompts/get` response provides the persona and
746
- skill listing -- execution is entirely the host
747
- AI's responsibility.
748
- - **No circular references.** Agents reference skills
749
- only. Skills do not reference other skills or agents.
750
- An agent cannot reference another agent. There is no
751
- cycle possible in the reference graph.