@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.
- package/CLA.md +68 -0
- package/LICENSE +676 -12
- package/LICENSING.md +58 -0
- package/README.md +50 -25
- package/README.md.bak +322 -0
- package/dist/README.md +322 -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/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 +11 -10
- 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/0.5.0.md +0 -41
- package/docs/release-notes/README.md +0 -16
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
# TypeScript Layer -- Overview
|
|
2
|
-
|
|
3
|
-
*Module structure, file conventions, and source layout
|
|
4
|
-
for the TypeScript executables and shared modules.*
|
|
5
|
-
|
|
6
|
-
## Architecture
|
|
7
|
-
|
|
8
|
-
Two thin executables, all logic in `src/shared/`
|
|
9
|
-
sub-modules. Heavy computation (keyword extraction,
|
|
10
|
-
indexing, ranking) runs in the Rust/WASM engine.
|
|
11
|
-
TypeScript handles CLI parsing, MCP protocol, IPC
|
|
12
|
-
transport, and WASM module loading.
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
src/cli.ts ──────────────────────────────────┐
|
|
16
|
-
│ (CLI mode or MCP mode) │
|
|
17
|
-
├─ imports shared/cli/ │
|
|
18
|
-
├─ imports shared/mcp/ │
|
|
19
|
-
└─ imports shared/worker-client/ ──IPC──→ │
|
|
20
|
-
│
|
|
21
|
-
src/worker.ts ───────────────────────────────┤
|
|
22
|
-
│ (detached daemon process) │
|
|
23
|
-
└─ imports shared/worker-daemon/ │
|
|
24
|
-
└─ loads WASM modules │
|
|
25
|
-
(query-parser, fs-database, │
|
|
26
|
-
kb-worker) │
|
|
27
|
-
│
|
|
28
|
-
mod.ts ──→ library API (npm/JSR) │
|
|
29
|
-
└─ re-exports from shared/version/ │
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Entry Points
|
|
33
|
-
|
|
34
|
-
Two executable entry points at the project root. Both
|
|
35
|
-
are bundled by esbuild into `dist/` as ESM + CJS.
|
|
36
|
-
|
|
37
|
-
| Entry | Purpose | Lifecycle |
|
|
38
|
-
|-----------------------|------------------------|-------------|
|
|
39
|
-
| `src/cli.ts` | CLI + MCP executable | Short or long-lived |
|
|
40
|
-
| `src/worker.ts` | Worker daemon | Detached background |
|
|
41
|
-
| `mod.ts` | Library API (npm/JSR) | Import only |
|
|
42
|
-
|
|
43
|
-
### `src/cli.ts`
|
|
44
|
-
|
|
45
|
-
The `kbdb` command. Detects the run mode from the
|
|
46
|
-
first argument:
|
|
47
|
-
|
|
48
|
-
- `kbdb mcp [--db <path>]` → MCP server mode
|
|
49
|
-
(long-lived, stdio JSON-RPC 2.0)
|
|
50
|
-
- `kbdb <command> [options]` → CLI mode
|
|
51
|
-
(short-lived, runs one command and exits)
|
|
52
|
-
|
|
53
|
-
Both modes create a `WorkerClient` and delegate all
|
|
54
|
-
operations to the daemon. The executable itself
|
|
55
|
-
contains no business logic -- it dispatches to
|
|
56
|
-
`shared/cli/` or `shared/mcp/`.
|
|
57
|
-
|
|
58
|
-
### `src/worker.ts`
|
|
59
|
-
|
|
60
|
-
The worker daemon. Spawned as a detached child process
|
|
61
|
-
by the worker-client module. Loads the four WASM
|
|
62
|
-
modules, listens on a local IPC socket, and serves
|
|
63
|
-
JSON-RPC 2.0 requests until idle timeout.
|
|
64
|
-
|
|
65
|
-
Contains no business logic -- dispatches to
|
|
66
|
-
`shared/worker-daemon/`.
|
|
67
|
-
|
|
68
|
-
## Source Layout
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
src/cli.ts ← executable
|
|
72
|
-
src/worker.ts ← executable
|
|
73
|
-
mod.ts ← library API
|
|
74
|
-
|
|
75
|
-
src/shared/
|
|
76
|
-
├── cli/ ← CLI commands
|
|
77
|
-
│ ├── index.ts
|
|
78
|
-
│ ├── constants/
|
|
79
|
-
│ │ ├── defaults.constant.ts
|
|
80
|
-
│ │ └── help-text.constant.ts
|
|
81
|
-
│ ├── functions/
|
|
82
|
-
│ │ ├── dispatch-command.function.ts
|
|
83
|
-
│ │ ├── ensure-db.function.ts
|
|
84
|
-
│ │ ├── error-to-message.function.ts
|
|
85
|
-
│ │ ├── find-db.function.ts
|
|
86
|
-
│ │ ├── format-output.function.ts
|
|
87
|
-
│ │ ├── is-stdin-tty.function.ts
|
|
88
|
-
│ │ ├── parse-args.function.ts
|
|
89
|
-
│ │ ├── prompt-user.function.ts
|
|
90
|
-
│ │ ├── run-agent-create.function.ts
|
|
91
|
-
│ │ ├── run-agent-delete.function.ts
|
|
92
|
-
│ │ ├── run-agent-get.function.ts
|
|
93
|
-
│ │ ├── run-agent-list.function.ts
|
|
94
|
-
│ │ ├── run-check.function.ts
|
|
95
|
-
│ │ ├── run-cli.function.ts
|
|
96
|
-
│ │ ├── run-content.function.ts
|
|
97
|
-
│ │ ├── run-db-init.function.ts
|
|
98
|
-
│ │ ├── run-db-migrate.function.ts
|
|
99
|
-
│ │ ├── run-gc.function.ts
|
|
100
|
-
│ │ ├── run-init.function.ts
|
|
101
|
-
│ │ ├── run-learn.function.ts
|
|
102
|
-
│ │ ├── run-migrate.function.ts
|
|
103
|
-
│ │ ├── run-rebuild.function.ts
|
|
104
|
-
│ │ ├── run-search.function.ts
|
|
105
|
-
│ │ ├── run-skill-delete.function.ts
|
|
106
|
-
│ │ ├── run-skill-get.function.ts
|
|
107
|
-
│ │ ├── run-skill-learn.function.ts
|
|
108
|
-
│ │ ├── run-skill-list.function.ts
|
|
109
|
-
│ │ └── run-unlearn.function.ts
|
|
110
|
-
│ └── typings/
|
|
111
|
-
│ ├── cli-options.interface.ts
|
|
112
|
-
│ ├── command-result.model.ts
|
|
113
|
-
│ ├── learn-result.model.ts
|
|
114
|
-
│ └── search-display.model.ts
|
|
115
|
-
│
|
|
116
|
-
├── mcp/ ← MCP server
|
|
117
|
-
│ ├── index.ts
|
|
118
|
-
│ ├── classes/
|
|
119
|
-
│ │ └── mcp-server.class.ts
|
|
120
|
-
│ ├── functions/
|
|
121
|
-
│ │ ├── create-mcp-server.function.ts
|
|
122
|
-
│ │ ├── create-prompt-definitions.function.ts
|
|
123
|
-
│ │ ├── create-resource-templates.function.ts
|
|
124
|
-
│ │ ├── create-tool-definitions.function.ts
|
|
125
|
-
│ │ ├── handle-agent-create.function.ts
|
|
126
|
-
│ │ ├── handle-agent-delete.function.ts
|
|
127
|
-
│ │ ├── handle-agent-get.function.ts
|
|
128
|
-
│ │ ├── handle-agent-list.function.ts
|
|
129
|
-
│ │ ├── handle-completion.function.ts
|
|
130
|
-
│ │ ├── handle-prompt-get.function.ts
|
|
131
|
-
│ │ ├── handle-resource-read.function.ts
|
|
132
|
-
│ │ ├── handle-skill-delete.function.ts
|
|
133
|
-
│ │ ├── handle-skill-get.function.ts
|
|
134
|
-
│ │ ├── handle-skill-learn.function.ts
|
|
135
|
-
│ │ ├── handle-skill-list.function.ts
|
|
136
|
-
│ │ ├── handle-tool-call.function.ts
|
|
137
|
-
│ │ ├── parse-skill-content.function.ts
|
|
138
|
-
│ │ └── serialize-skill-content.function.ts
|
|
139
|
-
│ └── typings/
|
|
140
|
-
│ ├── mcp-client.interface.ts
|
|
141
|
-
│ └── mcp-types.interface.ts
|
|
142
|
-
│
|
|
143
|
-
├── worker-client/ ← IPC client
|
|
144
|
-
│ ├── index.ts
|
|
145
|
-
│ ├── classes/
|
|
146
|
-
│ │ └── worker-client.class.ts
|
|
147
|
-
│ ├── functions/
|
|
148
|
-
│ │ ├── compute-context-id.function.ts
|
|
149
|
-
│ │ ├── create-worker-client.function.ts
|
|
150
|
-
│ │ ├── discover-daemon.function.ts
|
|
151
|
-
│ │ ├── resolve-db-path.function.ts
|
|
152
|
-
│ │ ├── spawn-daemon.function.ts
|
|
153
|
-
│ │ └── wait-for-daemon.function.ts
|
|
154
|
-
│ └── typings/
|
|
155
|
-
│ ├── add-section-result.model.ts
|
|
156
|
-
│ ├── content-result.model.ts
|
|
157
|
-
│ ├── daemon-info.model.ts
|
|
158
|
-
│ ├── gc-result.model.ts
|
|
159
|
-
│ ├── integrity-check-result.model.ts
|
|
160
|
-
│ ├── migrate-result.model.ts
|
|
161
|
-
│ ├── rebuild-result.model.ts
|
|
162
|
-
│ ├── remove-section-result.model.ts
|
|
163
|
-
│ ├── search-params.model.ts
|
|
164
|
-
│ ├── search-result.model.ts
|
|
165
|
-
│ ├── section.model.ts
|
|
166
|
-
│ ├── status-result.model.ts
|
|
167
|
-
│ ├── version-status.model.ts
|
|
168
|
-
│ ├── worker-client-error.interface.ts
|
|
169
|
-
│ └── worker-client-options.interface.ts
|
|
170
|
-
│
|
|
171
|
-
├── worker-daemon/ ← Daemon process
|
|
172
|
-
│ ├── index.ts
|
|
173
|
-
│ ├── classes/
|
|
174
|
-
│ │ └── worker-daemon.class.ts
|
|
175
|
-
│ ├── functions/
|
|
176
|
-
│ │ ├── create-host-imports.function.ts
|
|
177
|
-
│ │ ├── create-ipc-server.function.ts
|
|
178
|
-
│ │ ├── load-wasm-modules.function.ts
|
|
179
|
-
│ │ ├── read-config.function.ts
|
|
180
|
-
│ │ ├── run-worker.function.ts
|
|
181
|
-
│ │ └── start-daemon.function.ts
|
|
182
|
-
│ ├── typings/
|
|
183
|
-
│ │ ├── daemon-config.interface.ts
|
|
184
|
-
│ │ ├── ipc-handler.interface.ts
|
|
185
|
-
│ │ └── wasm-modules.interface.ts
|
|
186
|
-
│ └── constants/
|
|
187
|
-
│ └── daemon-defaults.constant.ts
|
|
188
|
-
│
|
|
189
|
-
├── wasm-codec/ ← WASM binary codec
|
|
190
|
-
│ ├── index.ts
|
|
191
|
-
│ └── functions/
|
|
192
|
-
│ ├── decode-compose-output.function.ts
|
|
193
|
-
│ ├── decode-document-manifest.function.ts
|
|
194
|
-
│ ├── decode-f32.function.ts
|
|
195
|
-
│ ├── decode-key-value-text.function.ts
|
|
196
|
-
│ ├── decode-remove-flag.function.ts
|
|
197
|
-
│ ├── decode-scored-results.function.ts
|
|
198
|
-
│ ├── decode-section-records.function.ts
|
|
199
|
-
│ ├── decode-string.function.ts
|
|
200
|
-
│ ├── decode-u32.function.ts
|
|
201
|
-
│ ├── decode-u64.function.ts
|
|
202
|
-
│ ├── encode-add-section-params.function.ts
|
|
203
|
-
│ ├── encode-group-params.function.ts
|
|
204
|
-
│ ├── encode-identifier-list.function.ts
|
|
205
|
-
│ ├── encode-kbid-list.function.ts
|
|
206
|
-
│ ├── encode-option-string.function.ts
|
|
207
|
-
│ ├── encode-search-params.function.ts
|
|
208
|
-
│ ├── encode-section-type.function.ts
|
|
209
|
-
│ ├── encode-string.function.ts
|
|
210
|
-
│ ├── encode-u32.function.ts
|
|
211
|
-
│ └── encode-update-section-params.function.ts
|
|
212
|
-
│
|
|
213
|
-
├── version/ ← Package version
|
|
214
|
-
│ ├── index.ts
|
|
215
|
-
│ └── constants/
|
|
216
|
-
│ └── version.constant.ts
|
|
217
|
-
│
|
|
218
|
-
├── runtime/ ← Runtime detection
|
|
219
|
-
│ ├── index.ts
|
|
220
|
-
│ ├── functions/
|
|
221
|
-
│ │ ├── detect-runtime.function.ts
|
|
222
|
-
│ │ └── get-args.function.ts
|
|
223
|
-
│ └── typings/
|
|
224
|
-
│ └── runtime.type.ts
|
|
225
|
-
│
|
|
226
|
-
├── platform/ ← OS abstractions
|
|
227
|
-
│ ├── index.ts
|
|
228
|
-
│ └── functions/
|
|
229
|
-
│ ├── get-ipc-path.function.ts
|
|
230
|
-
│ ├── get-tmpdir.function.ts
|
|
231
|
-
│ └── is-process-alive.function.ts
|
|
232
|
-
│
|
|
233
|
-
├── hash/ ← SHA-256 hashing
|
|
234
|
-
│ ├── index.ts
|
|
235
|
-
│ └── functions/
|
|
236
|
-
│ └── compute-sha256.function.ts
|
|
237
|
-
│
|
|
238
|
-
└── log/ ← Structured logging
|
|
239
|
-
├── index.ts
|
|
240
|
-
├── constants/
|
|
241
|
-
│ ├── log-colors.constant.ts
|
|
242
|
-
│ ├── log-defaults.constant.ts
|
|
243
|
-
│ └── log-icons.constant.ts
|
|
244
|
-
├── functions/
|
|
245
|
-
│ ├── configure-log.function.ts
|
|
246
|
-
│ ├── log.function.ts
|
|
247
|
-
│ ├── parse-log-level.function.ts
|
|
248
|
-
│ ├── resolve-log-level.function.ts
|
|
249
|
-
│ └── write-stderr.function.ts
|
|
250
|
-
└── typings/
|
|
251
|
-
├── log-config.interface.ts
|
|
252
|
-
├── log-level.type.ts
|
|
253
|
-
└── log-output.interface.ts
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
## Module Conventions
|
|
257
|
-
|
|
258
|
-
Every module follows the directory structure defined
|
|
259
|
-
in the TypeScript skill (`.claude/skills/typescript.md`).
|
|
260
|
-
|
|
261
|
-
### Directory Roles
|
|
262
|
-
|
|
263
|
-
| Directory | Contents | File suffix |
|
|
264
|
-
|---------------|----------------------------|---------------------|
|
|
265
|
-
| `classes/` | One class per file | `.class.ts` |
|
|
266
|
-
| `functions/` | One function per file | `.function.ts` |
|
|
267
|
-
| `constants/` | Related constants grouped | `.constant.ts` |
|
|
268
|
-
| `typings/` | Type declarations | `.type.ts`, `.enum.ts`, `.interface.ts`, `.model.ts` |
|
|
269
|
-
| `tests/` | BDD module integration | `.spec.ts` |
|
|
270
|
-
| (root) | TDD unit specs + barrel | `.spec.ts`, `index.ts` |
|
|
271
|
-
|
|
272
|
-
### Import Conventions
|
|
273
|
-
|
|
274
|
-
All imports go to `src/shared/[module]/` -- there is
|
|
275
|
-
**no** `src/shared/index.ts` barrel.
|
|
276
|
-
|
|
277
|
-
```ts
|
|
278
|
-
// Import from sub-module barrel
|
|
279
|
-
import {
|
|
280
|
-
WorkerClient,
|
|
281
|
-
} from './shared/worker-client/index.ts';
|
|
282
|
-
|
|
283
|
-
// Import from specific file
|
|
284
|
-
import {
|
|
285
|
-
createWorkerClient,
|
|
286
|
-
} from './shared/worker-client/functions/create-worker-client.function.ts';
|
|
287
|
-
|
|
288
|
-
// Import shared utility
|
|
289
|
-
import {
|
|
290
|
-
computeSha256,
|
|
291
|
-
} from './shared/hash/functions/compute-sha256.function.ts';
|
|
292
|
-
|
|
293
|
-
// Type-only imports (separate statement)
|
|
294
|
-
import type {
|
|
295
|
-
WorkerClientOptions,
|
|
296
|
-
} from './shared/worker-client/typings/worker-client-options.interface.ts';
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
All imports use `.ts` extensions (Deno requires them).
|
|
300
|
-
Type-only imports use separate `import type`
|
|
301
|
-
statements.
|
|
302
|
-
|
|
303
|
-
### File Naming
|
|
304
|
-
|
|
305
|
-
| Category | Convention | Example |
|
|
306
|
-
|------------|---------------------|----------------------------|
|
|
307
|
-
| Module dir | kebab-case | `worker-client/` |
|
|
308
|
-
| Class file | `<name>.class.ts` | `worker-client.class.ts` |
|
|
309
|
-
| Function | `<name>.function.ts`| `spawn-daemon.function.ts` |
|
|
310
|
-
| Constant | `<name>.constant.ts`| `defaults.constant.ts` |
|
|
311
|
-
| Interface | `<name>.interface.ts`| `cli-options.interface.ts` |
|
|
312
|
-
| Type alias | `<name>.type.ts` | `daemon-status.type.ts` |
|
|
313
|
-
| Enum | `<name>.enum.ts` | `output-format.enum.ts` |
|
|
314
|
-
| Model | `<name>.model.ts` | `search-result.model.ts` |
|
|
315
|
-
| TDD spec | `<name>.spec.ts` | `spawn-daemon.spec.ts` |
|
|
316
|
-
| BDD spec | `<scenario>.spec.ts`| `search-workflow.spec.ts` |
|
|
317
|
-
| Barrel | `index.ts` | `index.ts` |
|
|
318
|
-
|
|
319
|
-
### Dual Runtime
|
|
320
|
-
|
|
321
|
-
All code must work on both Deno and Node.js >= 20:
|
|
322
|
-
|
|
323
|
-
- No `node:` protocol in library code
|
|
324
|
-
- No Deno-specific APIs (`Deno.readTextFile`) in
|
|
325
|
-
library code
|
|
326
|
-
- Runtime detection via `typeof Deno !== 'undefined'`
|
|
327
|
-
- Platform abstractions in `shared/platform/`
|
|
328
|
-
|
|
329
|
-
## Build Output
|
|
330
|
-
|
|
331
|
-
```
|
|
332
|
-
dist/
|
|
333
|
-
├── mod.mjs ← ESM library
|
|
334
|
-
├── mod.cjs ← CJS library
|
|
335
|
-
├── mod.d.ts ← declarations
|
|
336
|
-
├── cli.mjs ← ESM CLI+MCP (shebang)
|
|
337
|
-
├── cli.cjs ← CJS CLI+MCP (shebang)
|
|
338
|
-
├── worker.mjs ← ESM daemon (shebang)
|
|
339
|
-
├── worker.cjs ← CJS daemon (shebang)
|
|
340
|
-
├── chunk-*.mjs ← shared code chunks
|
|
341
|
-
└── src/
|
|
342
|
-
└── **/*.d.ts ← per-file declarations
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
## Doc Directory Structure
|
|
346
|
-
|
|
347
|
-
Documentation mirrors the source layout. All module
|
|
348
|
-
docs live under `shared/`, matching the source tree.
|
|
349
|
-
|
|
350
|
-
```
|
|
351
|
-
docs/modules/typescript/
|
|
352
|
-
├── overview.md ← this file
|
|
353
|
-
└── shared/
|
|
354
|
-
├── module.md ← shared overview
|
|
355
|
-
├── cli/
|
|
356
|
-
│ ├── module.md
|
|
357
|
-
│ ├── functions.md
|
|
358
|
-
│ ├── typings.md
|
|
359
|
-
│ └── constants.md
|
|
360
|
-
├── mcp/
|
|
361
|
-
│ ├── module.md
|
|
362
|
-
│ ├── classes.md
|
|
363
|
-
│ ├── functions.md
|
|
364
|
-
│ └── typings.md
|
|
365
|
-
├── worker-client/
|
|
366
|
-
│ ├── module.md
|
|
367
|
-
│ ├── classes.md
|
|
368
|
-
│ ├── functions.md
|
|
369
|
-
│ └── typings.md
|
|
370
|
-
├── worker-daemon/
|
|
371
|
-
│ ├── module.md
|
|
372
|
-
│ ├── classes.md
|
|
373
|
-
│ ├── functions.md
|
|
374
|
-
│ ├── typings.md
|
|
375
|
-
│ └── constants.md
|
|
376
|
-
├── wasm-codec/
|
|
377
|
-
│ ├── module.md
|
|
378
|
-
│ └── functions.md
|
|
379
|
-
├── version/
|
|
380
|
-
│ └── module.md
|
|
381
|
-
├── runtime/
|
|
382
|
-
│ ├── module.md
|
|
383
|
-
│ ├── functions.md
|
|
384
|
-
│ └── typings.md
|
|
385
|
-
├── platform/
|
|
386
|
-
│ ├── module.md
|
|
387
|
-
│ └── functions.md
|
|
388
|
-
├── hash/
|
|
389
|
-
│ ├── module.md
|
|
390
|
-
│ └── functions.md
|
|
391
|
-
└── log/
|
|
392
|
-
├── module.md
|
|
393
|
-
├── functions.md
|
|
394
|
-
├── typings.md
|
|
395
|
-
└── constants.md
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
`module.md` = `index.ts` (module entry point).
|
|
399
|
-
Category files document the implementations within
|
|
400
|
-
each subdirectory.
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# auto-capture -- MCP Sampling-Based Automatic Knowledge Capture
|
|
2
|
-
|
|
3
|
-
**Source:** `src/shared/auto-capture/`
|
|
4
|
-
|
|
5
|
-
## Responsibility
|
|
6
|
-
|
|
7
|
-
Automatic knowledge capture from AI agent conversations. Uses MCP
|
|
8
|
-
`sampling/createMessage` to ask the host LLM to identify knowledge
|
|
9
|
-
worth storing, then feeds extracted knowledge into kbdb via `learn`.
|
|
10
|
-
Operates as an MCP server-side feature -- the server proactively
|
|
11
|
-
requests captures based on configurable triggers.
|
|
12
|
-
|
|
13
|
-
## Directory Layout
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
src/shared/auto-capture/
|
|
17
|
-
index.ts
|
|
18
|
-
auto-capture.controller.ts
|
|
19
|
-
trigger.ts
|
|
20
|
-
sampling-prompt.ts
|
|
21
|
-
rate-limiter.ts
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Components
|
|
25
|
-
|
|
26
|
-
- **AutoCaptureController** (`auto-capture.controller.ts`) --
|
|
27
|
-
Orchestrates the capture flow. Tracks tool call count, checks
|
|
28
|
-
trigger conditions, invokes sampling, and feeds results to
|
|
29
|
-
`learn`. Stateful per MCP session.
|
|
30
|
-
- **Trigger logic** (`trigger.ts`) -- Evaluates whether a capture
|
|
31
|
-
check should fire. Conditions: (a) after N tool calls (default:
|
|
32
|
-
10), (b) configurable time interval, (c) explicit
|
|
33
|
-
`auto-capture-review` tool invocation. Multiple triggers can be
|
|
34
|
-
active simultaneously.
|
|
35
|
-
- **Sampling prompts** (`sampling-prompt.ts`) -- Prompt templates
|
|
36
|
-
sent via `sampling/createMessage`. The prompt asks the host LLM
|
|
37
|
-
to extract knowledge from the conversation that matches the
|
|
38
|
-
`memory-protocol` skill's storage criteria: facts, decisions,
|
|
39
|
-
rationale, procedures.
|
|
40
|
-
- **Rate limiter** (`rate-limiter.ts`) -- Prevents excessive
|
|
41
|
-
capture attempts. Enforces minimum interval between captures
|
|
42
|
-
(default: 60 s) and maximum captures per session (default: 20).
|
|
43
|
-
|
|
44
|
-
## Configuration
|
|
45
|
-
|
|
46
|
-
Configured via the `[auto_capture]` section of `worker.toml`:
|
|
47
|
-
|
|
48
|
-
```toml
|
|
49
|
-
[auto_capture]
|
|
50
|
-
enabled = false
|
|
51
|
-
trigger_after_tool_calls = 10
|
|
52
|
-
min_interval_seconds = 60
|
|
53
|
-
max_captures_per_session = 20
|
|
54
|
-
dry_run = false
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
When `dry_run = true`, the controller logs what would be captured
|
|
58
|
-
without actually writing to the database. Useful for tuning
|
|
59
|
-
triggers.
|
|
60
|
-
|
|
61
|
-
## Dependency Direction
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
shared/auto-capture/
|
|
65
|
-
└── (no shared module deps -- uses MCP sampling API)
|
|
66
|
-
|
|
67
|
-
shared/mcp/
|
|
68
|
-
└── shared/auto-capture/ (controller lifecycle)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The auto-capture module is instantiated by the MCP server module.
|
|
72
|
-
It uses the MCP protocol's sampling capability -- not direct imports
|
|
73
|
-
of other shared modules.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# cli/constants -- CLI Defaults
|
|
2
|
-
|
|
3
|
-
*Default values for CLI options.*
|
|
4
|
-
|
|
5
|
-
## Source
|
|
6
|
-
|
|
7
|
-
`src/shared/cli/constants/`
|
|
8
|
-
|
|
9
|
-
### `defaults`
|
|
10
|
-
|
|
11
|
-
**File:** `defaults.constant.ts`
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
const DEFAULT_LIMIT = 20;
|
|
15
|
-
const DEFAULT_FORMAT = OutputFormat.Json;
|
|
16
|
-
const DEFAULT_MODE = 'sections';
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
| Constant | Value | Used by |
|
|
20
|
-
|------------------|-------------|--------------|
|
|
21
|
-
| `DEFAULT_LIMIT` | `20` | `parseArgs` |
|
|
22
|
-
| `DEFAULT_FORMAT` | `'json'` | `parseArgs` |
|
|
23
|
-
| `DEFAULT_MODE` | `'sections'`| `parseArgs` |
|