@dikolab/kbdb 0.5.0 → 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 +47 -24
- 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/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 +10 -9
- 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
package/docs/goals/document.md
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
# Document -- Text Content Format
|
|
2
|
-
|
|
3
|
-
*Content format specification for text sections in
|
|
4
|
-
the knowledge base -- markdown body text with
|
|
5
|
-
embedding markers and cross-reference link markers.*
|
|
6
|
-
|
|
7
|
-
## Goal
|
|
8
|
-
|
|
9
|
-
Text sections in the knowledge base store
|
|
10
|
-
**markdown-formatted UTF-8** content. This document
|
|
11
|
-
specifies the content body format: what goes inside
|
|
12
|
-
a section after the TOML header and `---` separator,
|
|
13
|
-
how sections reference other sections and documents,
|
|
14
|
-
and how those references behave at render time.
|
|
15
|
-
|
|
16
|
-
This document covers content format only. See
|
|
17
|
-
[Database](database.md) for how sections are stored
|
|
18
|
-
on disk (file layout, TOML headers, sharding) and
|
|
19
|
-
[Query Parser](query-parser.md) for how content is
|
|
20
|
-
tokenized and indexed. See
|
|
21
|
-
[Content Parser](content-parser.md) for how markers
|
|
22
|
-
are extracted from content as structured data.
|
|
23
|
-
|
|
24
|
-
Content is stored **verbatim** -- no processing,
|
|
25
|
-
expansion, or transformation occurs at write time.
|
|
26
|
-
Markers are plain text in the stored content body.
|
|
27
|
-
All rendering and expansion happens at read time.
|
|
28
|
-
|
|
29
|
-
## Content Format
|
|
30
|
-
|
|
31
|
-
The content body of a text section (everything after
|
|
32
|
-
the `---` separator in the section file) is
|
|
33
|
-
**markdown-formatted UTF-8 text**. Any valid
|
|
34
|
-
markdown is permitted: headings, paragraphs, lists,
|
|
35
|
-
tables, fenced code blocks, inline formatting, and
|
|
36
|
-
standard markdown links and images.
|
|
37
|
-
|
|
38
|
-
In addition to standard markdown, text sections may
|
|
39
|
-
contain **markers** -- escape sequences that
|
|
40
|
-
reference other sections or documents in the
|
|
41
|
-
knowledge base.
|
|
42
|
-
|
|
43
|
-
Code sections (`text/*` and `application/json`)
|
|
44
|
-
store raw source code. Image sections (`image/*`)
|
|
45
|
-
store base64-encoded binary data. Neither code nor
|
|
46
|
-
image sections use markdown formatting, but both
|
|
47
|
-
may appear in text sections via embedding markers.
|
|
48
|
-
|
|
49
|
-
## Markers
|
|
50
|
-
|
|
51
|
-
Markers use the escape sequence `$(type: value)`:
|
|
52
|
-
|
|
53
|
-
- `$` followed by `(`
|
|
54
|
-
- A type identifier (lowercase, may contain hyphen)
|
|
55
|
-
- A colon and a space
|
|
56
|
-
- A value (kb-id or doc-id)
|
|
57
|
-
- A closing `)`
|
|
58
|
-
|
|
59
|
-
Example: `$(image: 7fa93b2e4c8d1076a93b2e4c8d)`
|
|
60
|
-
|
|
61
|
-
Markers are stored verbatim in the content body.
|
|
62
|
-
They are **not expanded or resolved at storage
|
|
63
|
-
time**. Rendering happens when the content is read
|
|
64
|
-
and returned to the caller.
|
|
65
|
-
|
|
66
|
-
There are two categories of markers:
|
|
67
|
-
|
|
68
|
-
- **Embedding markers** -- the referenced content is
|
|
69
|
-
expanded inline at render time. The marker is
|
|
70
|
-
replaced by the referenced content.
|
|
71
|
-
- **Link markers** -- the referenced entity appears
|
|
72
|
-
as a cross-reference. The marker is replaced by a
|
|
73
|
-
reference or hyperlink, not by inline content.
|
|
74
|
-
|
|
75
|
-
### Embedding Markers
|
|
76
|
-
|
|
77
|
-
Embedding markers expand the referenced content
|
|
78
|
-
inline when the section is rendered.
|
|
79
|
-
|
|
80
|
-
#### `$(image: {kbid})`
|
|
81
|
-
|
|
82
|
-
Embeds an image section. The `{kbid}` must reference
|
|
83
|
-
an existing section of type `image/*`.
|
|
84
|
-
|
|
85
|
-
At render time, the marker is replaced by the image
|
|
86
|
-
content. In markdown output, this renders as an
|
|
87
|
-
inline image. The image data is the base64-decoded
|
|
88
|
-
content of the referenced section.
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
Here is a diagram of the architecture:
|
|
92
|
-
|
|
93
|
-
$(image: 7fa93b2e4c8d1076a93b2e4c8d)
|
|
94
|
-
|
|
95
|
-
The diagram shows the five-layer stack.
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
#### `$(code: {kbid})`
|
|
99
|
-
|
|
100
|
-
Embeds a code section. The `{kbid}` must reference
|
|
101
|
-
an existing section of type `text/*` or
|
|
102
|
-
`application/json`.
|
|
103
|
-
|
|
104
|
-
At render time, the marker is replaced by a fenced
|
|
105
|
-
code block. The language tag is derived from the
|
|
106
|
-
referenced section's MIME type using the mapping
|
|
107
|
-
below.
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
See the greeting function:
|
|
111
|
-
|
|
112
|
-
$(code: c4e8a91d3f7b20564e8a91d3f7)
|
|
113
|
-
|
|
114
|
-
Call it with any name string.
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
##### MIME-to-Language Mapping
|
|
118
|
-
|
|
119
|
-
When a `$(code: {kbid})` marker is rendered, the
|
|
120
|
-
code section's MIME type determines the fenced code
|
|
121
|
-
block language tag:
|
|
122
|
-
|
|
123
|
-
| MIME Type | Language Tag |
|
|
124
|
-
|----------------------|--------------|
|
|
125
|
-
| `text/typescript` | `ts` |
|
|
126
|
-
| `text/javascript` | `js` |
|
|
127
|
-
| `text/html` | `html` |
|
|
128
|
-
| `text/css` | `css` |
|
|
129
|
-
| `text/xml` | `xml` |
|
|
130
|
-
| `text/plain` | *(none)* |
|
|
131
|
-
| `application/json` | `json` |
|
|
132
|
-
|
|
133
|
-
Other `text/*` subtypes use the subtype as the
|
|
134
|
-
language tag (e.g. `text/python` -> `python`,
|
|
135
|
-
`text/rust` -> `rust`).
|
|
136
|
-
|
|
137
|
-
#### `$(text: {kbid})`
|
|
138
|
-
|
|
139
|
-
Embeds a text section's content inline. The `{kbid}`
|
|
140
|
-
must reference an existing section of type
|
|
141
|
-
`text/markdown`.
|
|
142
|
-
|
|
143
|
-
At render time, the marker is replaced by the
|
|
144
|
-
referenced section's full content body. The
|
|
145
|
-
embedded content is rendered as markdown, inline
|
|
146
|
-
with the surrounding text.
|
|
147
|
-
|
|
148
|
-
This marker is **recursive** -- the embedded text
|
|
149
|
-
section may itself contain markers, which are
|
|
150
|
-
resolved in turn. See Recursion and Circular
|
|
151
|
-
References below.
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
## Introduction
|
|
155
|
-
|
|
156
|
-
$(text: a1b2c3d4e5f6a1b2c3d4e5f6a1)
|
|
157
|
-
|
|
158
|
-
## Next Steps
|
|
159
|
-
|
|
160
|
-
Continue with the setup guide.
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
#### `$(document: {docid})`
|
|
164
|
-
|
|
165
|
-
Embeds an entire document. The `{docid}` must
|
|
166
|
-
reference an existing document manifest.
|
|
167
|
-
|
|
168
|
-
At render time, the marker is replaced by all
|
|
169
|
-
sections in the document, expanded in position
|
|
170
|
-
order. Each section is rendered according to its
|
|
171
|
-
type: text sections as markdown, code sections as
|
|
172
|
-
fenced code blocks, image sections as inline images.
|
|
173
|
-
|
|
174
|
-
This marker is **recursive** -- sections within the
|
|
175
|
-
embedded document may contain their own markers.
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
For the full API reference, see below:
|
|
179
|
-
|
|
180
|
-
$(document: api-reference-v2)
|
|
181
|
-
|
|
182
|
-
End of the combined guide.
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Link Markers
|
|
186
|
-
|
|
187
|
-
Link markers produce cross-references without
|
|
188
|
-
expanding any content inline.
|
|
189
|
-
|
|
190
|
-
#### `$(link: {kbid})`
|
|
191
|
-
|
|
192
|
-
Links to a section by kb-id. The `{kbid}` must
|
|
193
|
-
reference an existing section of **any type** (text,
|
|
194
|
-
code, or image).
|
|
195
|
-
|
|
196
|
-
At render time, the marker is replaced by a
|
|
197
|
-
cross-reference to the linked section. The section's
|
|
198
|
-
content is not expanded inline.
|
|
199
|
-
|
|
200
|
-
```
|
|
201
|
-
For the implementation details, see
|
|
202
|
-
$(link: d5e6f7a8b9c0d5e6f7a8b9c0d5).
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
#### `$(doc-link: {docid})`
|
|
206
|
-
|
|
207
|
-
Links to a document by doc-id. The `{docid}` must
|
|
208
|
-
reference an existing document manifest.
|
|
209
|
-
|
|
210
|
-
At render time, the marker is replaced by a
|
|
211
|
-
cross-reference to the linked document. No content
|
|
212
|
-
is expanded inline.
|
|
213
|
-
|
|
214
|
-
```
|
|
215
|
-
This section is part of
|
|
216
|
-
$(doc-link: getting-started-guide).
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Marker Summary
|
|
220
|
-
|
|
221
|
-
| Marker | Value | Category | Referenced Entity | Render Behavior |
|
|
222
|
-
|--------|-------|----------|-------------------|-----------------|
|
|
223
|
-
| `$(image: {kbid})` | kb-id | embedding | `image/*` section | Inline image |
|
|
224
|
-
| `$(code: {kbid})` | kb-id | embedding | `text/*` or `application/json` section | Fenced code block |
|
|
225
|
-
| `$(text: {kbid})` | kb-id | embedding | `text/markdown` section | Inline markdown (recursive) |
|
|
226
|
-
| `$(document: {docid})` | doc-id | embedding | Document manifest | All sections expanded (recursive) |
|
|
227
|
-
| `$(link: {kbid})` | kb-id | link | Any section | Cross-reference |
|
|
228
|
-
| `$(doc-link: {docid})` | doc-id | link | Document manifest | Cross-reference |
|
|
229
|
-
|
|
230
|
-
## Syntax Rules
|
|
231
|
-
|
|
232
|
-
1. Markers start with `$(` and end with `)`.
|
|
233
|
-
2. The type identifier is followed by a colon and
|
|
234
|
-
a **space** before the value: `$(type: value)`.
|
|
235
|
-
3. The value is either a **kb-id** (26-character
|
|
236
|
-
base32-encoded identifier) or a **doc-id**
|
|
237
|
-
(document manifest identifier string).
|
|
238
|
-
4. Markers cannot be nested. A `$(` inside a marker
|
|
239
|
-
is treated as literal text.
|
|
240
|
-
5. Unrecognized type identifiers (e.g.
|
|
241
|
-
`$(formula: x+y)`) pass through unchanged --
|
|
242
|
-
they are not stripped or processed.
|
|
243
|
-
6. Unclosed markers (no closing `)`) are treated as
|
|
244
|
-
plain text and left unchanged.
|
|
245
|
-
7. Markers can appear anywhere in the content body:
|
|
246
|
-
inline with text, on their own line, or adjacent
|
|
247
|
-
to other markers.
|
|
248
|
-
|
|
249
|
-
## Recursion and Circular References
|
|
250
|
-
|
|
251
|
-
The `$(text: {kbid})` and `$(document: {docid})`
|
|
252
|
-
embedding markers cause **recursive expansion**.
|
|
253
|
-
When a text section is embedded, its content may
|
|
254
|
-
itself contain markers that must be resolved. When
|
|
255
|
-
a document is embedded, each of its sections may
|
|
256
|
-
contain markers.
|
|
257
|
-
|
|
258
|
-
Circular references occur when the expansion chain
|
|
259
|
-
loops back to a section or document already being
|
|
260
|
-
expanded. For example:
|
|
261
|
-
|
|
262
|
-
- Section A contains `$(text: B)`
|
|
263
|
-
- Section B contains `$(text: A)`
|
|
264
|
-
|
|
265
|
-
Circular references must be detected and reported
|
|
266
|
-
as errors. The resolution strategy:
|
|
267
|
-
|
|
268
|
-
1. Maintain a **visited set** of kb-ids and doc-ids
|
|
269
|
-
during expansion.
|
|
270
|
-
2. Before expanding a marker, check if the target
|
|
271
|
-
is already in the visited set.
|
|
272
|
-
3. If it is, the reference is **circular** -- stop
|
|
273
|
-
expansion and report an error for that marker.
|
|
274
|
-
4. If it is not, add the target to the visited set
|
|
275
|
-
and proceed with expansion.
|
|
276
|
-
|
|
277
|
-
Integrity checks detect circular references at
|
|
278
|
-
validation time (see Integrity below). The
|
|
279
|
-
expansion engine also guards against them at
|
|
280
|
-
render time.
|
|
281
|
-
|
|
282
|
-
## Tokenization
|
|
283
|
-
|
|
284
|
-
All six marker types are stripped from content
|
|
285
|
-
before tokenization and indexing. Markers are
|
|
286
|
-
**structural references**, not searchable text.
|
|
287
|
-
The tokenization pipeline removes them in Stage 1
|
|
288
|
-
(marker stripping) so they do not pollute the
|
|
289
|
-
search index.
|
|
290
|
-
|
|
291
|
-
See [Query Parser](query-parser.md) for the full
|
|
292
|
-
nine-stage tokenization pipeline and
|
|
293
|
-
[Content Parser](content-parser.md) for the marker
|
|
294
|
-
extraction functions used during stripping.
|
|
295
|
-
|
|
296
|
-
The `strip_content_markers()` function in `kbdb-shared`
|
|
297
|
-
recognizes all six marker types. See
|
|
298
|
-
[Content Parser](content-parser.md) for the shared
|
|
299
|
-
implementation that replaces the earlier
|
|
300
|
-
query-parser-internal version.
|
|
301
|
-
|
|
302
|
-
## Integrity
|
|
303
|
-
|
|
304
|
-
Integrity checks validate that all marker
|
|
305
|
-
references point to existing entities of the
|
|
306
|
-
expected type:
|
|
307
|
-
|
|
308
|
-
| Marker | Validation |
|
|
309
|
-
|--------|------------|
|
|
310
|
-
| `$(image: {kbid})` | Section exists, type is `image/*` |
|
|
311
|
-
| `$(code: {kbid})` | Section exists, type is `text/*` or `application/json` |
|
|
312
|
-
| `$(text: {kbid})` | Section exists, type is `text/markdown` |
|
|
313
|
-
| `$(document: {docid})` | Document manifest exists |
|
|
314
|
-
| `$(link: {kbid})` | Section exists (any type) |
|
|
315
|
-
| `$(doc-link: {docid})` | Document manifest exists |
|
|
316
|
-
|
|
317
|
-
Additionally, integrity checks detect **circular
|
|
318
|
-
references** in `$(text:)` and `$(document:)` marker
|
|
319
|
-
chains using the visited-set algorithm described
|
|
320
|
-
above.
|
|
321
|
-
|
|
322
|
-
See [Database](database.md) for the full integrity
|
|
323
|
-
and maintenance specification.
|
|
324
|
-
|
|
325
|
-
## Examples
|
|
326
|
-
|
|
327
|
-
### Text Section with All Marker Types
|
|
328
|
-
|
|
329
|
-
```
|
|
330
|
-
## API Overview
|
|
331
|
-
|
|
332
|
-
This module provides the core search interface.
|
|
333
|
-
|
|
334
|
-
$(image: 7fa93b2e4c8d1076a93b2e4c8d)
|
|
335
|
-
|
|
336
|
-
The search function accepts a query string and
|
|
337
|
-
returns ranked results. Here is the implementation:
|
|
338
|
-
|
|
339
|
-
$(code: c4e8a91d3f7b20564e8a91d3f7)
|
|
340
|
-
|
|
341
|
-
For additional context on the ranking algorithm,
|
|
342
|
-
see the following section:
|
|
343
|
-
|
|
344
|
-
$(text: a1b2c3d4e5f6a1b2c3d4e5f6a1)
|
|
345
|
-
|
|
346
|
-
The full API reference is available as a separate
|
|
347
|
-
document:
|
|
348
|
-
|
|
349
|
-
$(document: api-reference-v2)
|
|
350
|
-
|
|
351
|
-
Related sections:
|
|
352
|
-
- Ranking details: $(link: d5e6f7a8b9c0d5e6f7a8b9c0d5)
|
|
353
|
-
- See also: $(doc-link: getting-started-guide)
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
This example shows all six marker types in a single
|
|
357
|
-
text section. At render time:
|
|
358
|
-
- The `$(image:)` marker expands to an inline image.
|
|
359
|
-
- The `$(code:)` marker expands to a fenced code
|
|
360
|
-
block with the appropriate language tag.
|
|
361
|
-
- The `$(text:)` marker expands to the referenced
|
|
362
|
-
section's full markdown content.
|
|
363
|
-
- The `$(document:)` marker expands to all sections
|
|
364
|
-
in the referenced document.
|
|
365
|
-
- The `$(link:)` marker renders as a section
|
|
366
|
-
cross-reference.
|
|
367
|
-
- The `$(doc-link:)` marker renders as a document
|
|
368
|
-
cross-reference.
|