@hasna/knowledge 0.2.27 → 0.2.29
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/README.md +140 -99
- package/bin/{open-knowledge-mcp.js → knowledge-mcp.js} +22 -15
- package/bin/{open-knowledge.js → knowledge.js} +5 -5
- package/dist/agent.d.ts +35 -0
- package/dist/artifact-store.d.ts +63 -0
- package/dist/auth.d.ts +35 -0
- package/dist/embeddings.d.ts +77 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +5709 -0
- package/dist/knowledge-db.d.ts +27 -0
- package/dist/manifest-ingest.d.ts +35 -0
- package/dist/outbox-consume.d.ts +25 -0
- package/dist/provenance.d.ts +50 -0
- package/dist/providers.d.ts +89 -0
- package/dist/reindex.d.ts +37 -0
- package/dist/remote-client.d.ts +108 -0
- package/dist/retrieval.d.ts +71 -0
- package/dist/safety.d.ts +70 -0
- package/dist/sdk.d.ts +72 -0
- package/dist/search.d.ts +65 -0
- package/dist/service.d.ts +117 -0
- package/dist/source-ingest.d.ts +18 -0
- package/dist/source-ref.d.ts +30 -0
- package/dist/source-resolver.d.ts +92 -0
- package/dist/storage-contract.d.ts +106 -0
- package/dist/web-search.d.ts +40 -0
- package/dist/wiki-compiler.d.ts +67 -0
- package/dist/wiki-layout.d.ts +23 -0
- package/dist/workspace.d.ts +111 -0
- package/docs/architecture/ai-native-knowledge-base.md +16 -16
- package/docs/architecture/hosted-wrapper-responsibilities.md +5 -5
- package/docs/architecture/hybrid-semantic-search.md +12 -12
- package/docs/canonical-secrets-bootstrap-2026-06-08.md +1 -1
- package/docs/examples/company-wiki-workflow.md +19 -19
- package/docs/migration/json-to-sqlite.md +17 -17
- package/package.json +17 -10
- package/src/agent.ts +0 -367
- package/src/artifact-store.ts +0 -184
- package/src/auth.ts +0 -123
- package/src/cli.ts +0 -1184
- package/src/embeddings.ts +0 -516
- package/src/knowledge-db.ts +0 -354
- package/src/manifest-ingest.ts +0 -515
- package/src/mcp-http.js +0 -110
- package/src/mcp.js +0 -1503
- package/src/outbox-consume.ts +0 -463
- package/src/provenance.ts +0 -93
- package/src/providers.ts +0 -308
- package/src/reindex.ts +0 -260
- package/src/remote-client.ts +0 -268
- package/src/retrieval.ts +0 -326
- package/src/safety.ts +0 -265
- package/src/schema.js +0 -25
- package/src/search.ts +0 -510
- package/src/service.ts +0 -443
- package/src/source-ingest.ts +0 -268
- package/src/source-ref.ts +0 -104
- package/src/source-resolver.ts +0 -436
- package/src/storage-contract.ts +0 -346
- package/src/store.ts +0 -113
- package/src/web-search.ts +0 -330
- package/src/wiki-compiler.ts +0 -711
- package/src/wiki-layout.ts +0 -251
- package/src/workspace.ts +0 -251
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# knowledge
|
|
2
2
|
|
|
3
3
|
> Agent-friendly local knowledge CLI/MCP with JSON output, project workspaces, durable artifacts, and safe destructive actions.
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](.github/workflows/ci.yml)
|
|
8
8
|
|
|
9
|
-
`
|
|
9
|
+
`knowledge` is evolving from a flat note store into a local-first knowledge
|
|
10
10
|
engine for AI agents. It stores simple knowledge items today, creates a Hasna
|
|
11
11
|
project workspace under `.hasna/apps/knowledge`, initializes a versioned
|
|
12
12
|
`knowledge.db`, writes generated wiki artifacts, and exposes a stdio MCP server.
|
|
@@ -32,94 +32,135 @@ Or run directly:
|
|
|
32
32
|
bun x @hasna/knowledge add "My Note" "Some content"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## SDK
|
|
36
|
+
|
|
37
|
+
Apps can install the package and use the public SDK without shelling out to the
|
|
38
|
+
CLI or importing internal source files:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createKnowledgeClient } from '@hasna/knowledge';
|
|
42
|
+
|
|
43
|
+
const knowledge = createKnowledgeClient({
|
|
44
|
+
scope: 'project',
|
|
45
|
+
cwd: process.cwd(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await knowledge.setup({ mode: 'hosted', canonicalHasnaXyz: true });
|
|
49
|
+
await knowledge.ingest.source('file:///absolute/path/to/handbook.md', 'knowledge_index');
|
|
50
|
+
|
|
51
|
+
const results = await knowledge.search({
|
|
52
|
+
query: 'company wiki policy',
|
|
53
|
+
semantic: true,
|
|
54
|
+
limit: 5,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const answer = await knowledge.ask('How do we cite handbook policy?', {
|
|
58
|
+
semantic: true,
|
|
59
|
+
limit: 5,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The stable package surface is the top-level `@hasna/knowledge` export:
|
|
64
|
+
`createKnowledgeClient`, `createKnowledgeSdk`, service/result types, workspace
|
|
65
|
+
helpers, source-ref helpers, storage contracts, search/retrieval types,
|
|
66
|
+
provider helpers, and remote contract types. CLI and MCP entrypoints remain
|
|
67
|
+
available as package bins.
|
|
68
|
+
|
|
69
|
+
The SDK uses the same `.hasna/apps/knowledge` project workspace as the CLI. In
|
|
70
|
+
local mode it writes the SQLite catalog and generated artifacts under that path.
|
|
71
|
+
In hosted/canonical mode it can point generated artifacts at S3 while keeping
|
|
72
|
+
raw source ownership outside knowledge. Source files remain referenced via
|
|
73
|
+
`open-files://`, `file://`, `s3://`, or web refs; knowledge stores derived
|
|
74
|
+
chunks, citations, indexes, run logs, and generated wiki artifacts.
|
|
75
|
+
|
|
35
76
|
## Quick Start
|
|
36
77
|
|
|
37
78
|
```bash
|
|
38
79
|
# Add a note
|
|
39
|
-
|
|
80
|
+
knowledge add "Rust ownership" "Every value has exactly one owner"
|
|
40
81
|
|
|
41
82
|
# List all notes
|
|
42
|
-
|
|
83
|
+
knowledge list
|
|
43
84
|
|
|
44
85
|
# List with search
|
|
45
|
-
|
|
86
|
+
knowledge list --search ownership
|
|
46
87
|
|
|
47
88
|
# List notes tagged "rust"
|
|
48
|
-
|
|
89
|
+
knowledge list --tag rust
|
|
49
90
|
|
|
50
91
|
# Get a note
|
|
51
|
-
|
|
92
|
+
knowledge get --id <id>
|
|
52
93
|
|
|
53
94
|
# Update a note
|
|
54
|
-
|
|
95
|
+
knowledge update --id <id> --title "Rust ownership model"
|
|
55
96
|
|
|
56
97
|
# Delete a note (requires --yes)
|
|
57
|
-
|
|
98
|
+
knowledge delete --id <id> --yes
|
|
58
99
|
|
|
59
100
|
# Export all notes as JSONL
|
|
60
|
-
|
|
101
|
+
knowledge export --format jsonl
|
|
61
102
|
|
|
62
103
|
# Show resolved workspace paths
|
|
63
|
-
|
|
104
|
+
knowledge paths --scope project --json
|
|
64
105
|
|
|
65
106
|
# Inspect local/S3 artifact storage and source ownership
|
|
66
|
-
|
|
107
|
+
knowledge storage status --scope project --json
|
|
67
108
|
|
|
68
109
|
# Configure optional hosted mode and inspect remote contracts
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
110
|
+
knowledge setup --mode hosted --api-url https://knowledge.hasna.xyz --scope project --json
|
|
111
|
+
knowledge auth whoami --scope project --json
|
|
112
|
+
knowledge remote contracts --scope project --json
|
|
72
113
|
|
|
73
114
|
# Initialize the project SQLite catalog
|
|
74
|
-
|
|
115
|
+
knowledge db init --scope project
|
|
75
116
|
|
|
76
117
|
# Initialize scalable wiki/schema/index/log artifacts
|
|
77
|
-
|
|
118
|
+
knowledge wiki init --scope project
|
|
78
119
|
|
|
79
120
|
# Compile cited wiki pages, file approved answers, and lint wiki health
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
121
|
+
knowledge wiki compile "handbook policy" --title "Handbook Policy" --scope project --json
|
|
122
|
+
knowledge wiki file-answer "How do we cite policy?" --content "Use cited source context." --approve-write --scope project --json
|
|
123
|
+
knowledge wiki lint --scope project --json
|
|
83
124
|
|
|
84
125
|
# Ingest an open-files source manifest into the project SQLite catalog
|
|
85
|
-
|
|
126
|
+
knowledge ingest manifest ./open-files-manifest.jsonl --scope project --json
|
|
86
127
|
|
|
87
128
|
# Ingest one read-only source ref directly
|
|
88
|
-
|
|
129
|
+
knowledge ingest source file:///absolute/path/to/handbook.md --purpose knowledge_index --scope project --json
|
|
89
130
|
|
|
90
131
|
# Consume open-files change events and invalidate stale source chunks
|
|
91
|
-
|
|
132
|
+
knowledge reindex outbox ./open-files-outbox.jsonl --scope project --json
|
|
92
133
|
|
|
93
134
|
# Inspect and refresh the embedding queue after source changes
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
135
|
+
knowledge reindex status --scope project --json
|
|
136
|
+
knowledge reindex enqueue --scope project --json
|
|
137
|
+
knowledge reindex embeddings --scope project --fake --json
|
|
97
138
|
|
|
98
139
|
# Resolve indexed source text and citation evidence through the read-only source boundary
|
|
99
|
-
|
|
140
|
+
knowledge source resolve open-files://file/f_123/revision/rev_456 --scope project --json
|
|
100
141
|
|
|
101
142
|
# Inspect local safety policy and approvals
|
|
102
|
-
|
|
143
|
+
knowledge safety status --scope project --json
|
|
103
144
|
|
|
104
145
|
# Inspect AI SDK provider credentials and model aliases
|
|
105
|
-
|
|
106
|
-
|
|
146
|
+
knowledge providers status --scope project --json
|
|
147
|
+
knowledge providers models --scope project --json
|
|
107
148
|
|
|
108
149
|
# Embed indexed chunks and run semantic search
|
|
109
|
-
|
|
110
|
-
|
|
150
|
+
knowledge embeddings index --scope project --model openai:text-embedding-3-small --json
|
|
151
|
+
knowledge embeddings search "company wiki policy" --scope project --json
|
|
111
152
|
|
|
112
153
|
# Hybrid search over source chunks, generated wiki pages, indexes, and optional vectors
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
154
|
+
knowledge search "company wiki policy" --scope project --json
|
|
155
|
+
knowledge search "company wiki policy" --scope project --semantic --json
|
|
156
|
+
knowledge search "company wiki policy" --scope project --context --json
|
|
116
157
|
|
|
117
158
|
# Build a citation answer/context draft for a prompt
|
|
118
|
-
|
|
159
|
+
knowledge ask "How do we cite handbook policy?" --scope project --json
|
|
119
160
|
knowledge "How do we cite handbook policy?" --scope project --json
|
|
120
161
|
|
|
121
162
|
# Provider-native web search, safety-gated for real network access
|
|
122
|
-
HASNA_KNOWLEDGE_WEB_SEARCH=1
|
|
163
|
+
HASNA_KNOWLEDGE_WEB_SEARCH=1 knowledge web search "latest AI SDK web search" --provider openai --json
|
|
123
164
|
```
|
|
124
165
|
|
|
125
166
|
## Guides
|
|
@@ -141,13 +182,13 @@ HASNA_KNOWLEDGE_WEB_SEARCH=1 open-knowledge web search "latest AI SDK web search
|
|
|
141
182
|
|
|
142
183
|
### add
|
|
143
184
|
```bash
|
|
144
|
-
|
|
185
|
+
knowledge add <title> <content> [--url <url>] [-t <tag>]
|
|
145
186
|
```
|
|
146
187
|
Add a new knowledge item.
|
|
147
188
|
|
|
148
189
|
### list
|
|
149
190
|
```bash
|
|
150
|
-
|
|
191
|
+
knowledge list|ls [options]
|
|
151
192
|
```
|
|
152
193
|
List items with pagination, search, and tag filtering.
|
|
153
194
|
|
|
@@ -162,13 +203,13 @@ List items with pagination, search, and tag filtering.
|
|
|
162
203
|
|
|
163
204
|
### get
|
|
164
205
|
```bash
|
|
165
|
-
|
|
206
|
+
knowledge get --id <id>
|
|
166
207
|
```
|
|
167
208
|
Retrieve a single item by ID.
|
|
168
209
|
|
|
169
210
|
### update
|
|
170
211
|
```bash
|
|
171
|
-
|
|
212
|
+
knowledge update|edit --id <id> [options]
|
|
172
213
|
```
|
|
173
214
|
Update an existing item.
|
|
174
215
|
|
|
@@ -181,46 +222,46 @@ Update an existing item.
|
|
|
181
222
|
|
|
182
223
|
### archive / restore
|
|
183
224
|
```bash
|
|
184
|
-
|
|
185
|
-
|
|
225
|
+
knowledge archive --id <id>
|
|
226
|
+
knowledge restore --id <id>
|
|
186
227
|
```
|
|
187
228
|
Archive hides an item from default `list` output without deleting it.
|
|
188
229
|
|
|
189
230
|
### upsert
|
|
190
231
|
```bash
|
|
191
|
-
|
|
232
|
+
knowledge upsert [title] [content] [--id <id>] [--title <title>] [--content <content>]
|
|
192
233
|
```
|
|
193
234
|
Create or update an item by ID.
|
|
194
235
|
|
|
195
236
|
### untag
|
|
196
237
|
```bash
|
|
197
|
-
|
|
238
|
+
knowledge untag --id <id> -t <tag>
|
|
198
239
|
```
|
|
199
240
|
Remove one tag from an item.
|
|
200
241
|
|
|
201
242
|
### delete
|
|
202
243
|
```bash
|
|
203
|
-
|
|
244
|
+
knowledge delete|rm --id <id> --yes
|
|
204
245
|
```
|
|
205
246
|
Delete an item. Requires `--yes` to confirm.
|
|
206
247
|
|
|
207
248
|
### export
|
|
208
249
|
```bash
|
|
209
|
-
|
|
250
|
+
knowledge export [--format jsonl]
|
|
210
251
|
```
|
|
211
252
|
Export all items. Use `--format jsonl` for newline-delimited JSON.
|
|
212
253
|
|
|
213
254
|
### paths
|
|
214
255
|
```bash
|
|
215
|
-
|
|
256
|
+
knowledge paths [--scope global|project|local] [--json]
|
|
216
257
|
```
|
|
217
258
|
Show the resolved Hasna app workspace, JSON compatibility store, SQLite path,
|
|
218
259
|
artifact directories, and config.
|
|
219
260
|
|
|
220
261
|
### storage
|
|
221
262
|
```bash
|
|
222
|
-
|
|
223
|
-
|
|
263
|
+
knowledge storage status [--scope project] [--json]
|
|
264
|
+
knowledge storage validate [--scope project] [--json]
|
|
224
265
|
```
|
|
225
266
|
Show the storage contract for local or S3-backed generated artifacts. Local mode
|
|
226
267
|
uses `.hasna/apps/knowledge` for config, SQLite, indexes, wiki artifacts, logs,
|
|
@@ -246,14 +287,14 @@ The future hosted database path, if provisioned, is
|
|
|
246
287
|
|
|
247
288
|
### setup / auth / remote
|
|
248
289
|
```bash
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
290
|
+
knowledge setup --mode local [--scope project] [--json]
|
|
291
|
+
knowledge setup --mode hosted [--api-url https://knowledge.hasna.xyz] [--scope project] [--json]
|
|
292
|
+
knowledge setup --mode hosted --canonical-hasna-xyz [--scope project] [--json]
|
|
293
|
+
knowledge auth login --api-key <key> [--email you@example.com] [--org <slug>] [--scope project] [--json]
|
|
294
|
+
knowledge auth whoami [--scope project] [--json]
|
|
295
|
+
knowledge auth logout [--scope project] [--json]
|
|
296
|
+
knowledge remote status [--scope project] [--json]
|
|
297
|
+
knowledge remote contracts [--scope project] [--json]
|
|
257
298
|
```
|
|
258
299
|
Hosted mode mirrors the `open-skills` open-core pattern: the OSS package stays
|
|
259
300
|
local-first, while `hosted.api_url`, `KNOWLEDGE_API_URL`, and
|
|
@@ -264,18 +305,18 @@ and artifact API contract that a future SaaS wrapper can implement.
|
|
|
264
305
|
|
|
265
306
|
### db
|
|
266
307
|
```bash
|
|
267
|
-
|
|
268
|
-
|
|
308
|
+
knowledge db init [--scope project]
|
|
309
|
+
knowledge db stats [--scope project]
|
|
269
310
|
```
|
|
270
311
|
Initialize or inspect the versioned SQLite catalog at
|
|
271
312
|
`.hasna/apps/knowledge/knowledge.db`.
|
|
272
313
|
|
|
273
314
|
### wiki
|
|
274
315
|
```bash
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
316
|
+
knowledge wiki init [--scope project]
|
|
317
|
+
knowledge wiki compile [query|source-ref...] [--title <title>] [--limit <n>] [--scope project] [--json]
|
|
318
|
+
knowledge wiki file-answer <prompt> --content <answer> [--approve-write] [--scope project] [--json]
|
|
319
|
+
knowledge wiki lint [--scope project] [--json]
|
|
279
320
|
```
|
|
280
321
|
Create starter generated-knowledge artifacts through the artifact store:
|
|
281
322
|
`schemas/v1.md`, `indexes/root.md`, `wiki/README.md`, and a dated JSONL log
|
|
@@ -291,7 +332,7 @@ source refs, contradiction markers, and new article candidates.
|
|
|
291
332
|
|
|
292
333
|
### source
|
|
293
334
|
```bash
|
|
294
|
-
|
|
335
|
+
knowledge source resolve <source-ref> [--purpose knowledge_answer|knowledge_index] [--limit <n>] [--scope project] [--json]
|
|
295
336
|
```
|
|
296
337
|
Resolve an indexed source through the read-only open-files boundary. The result
|
|
297
338
|
returns source metadata, permissions, the selected revision, derived chunk text,
|
|
@@ -300,8 +341,8 @@ raw source retrieval remains owned by `open-files`.
|
|
|
300
341
|
|
|
301
342
|
### ingest
|
|
302
343
|
```bash
|
|
303
|
-
|
|
304
|
-
|
|
344
|
+
knowledge ingest manifest <file|s3://bucket/key> [--scope project] [--json]
|
|
345
|
+
knowledge ingest source <source-ref> [--purpose knowledge_index] [--scope project] [--json]
|
|
305
346
|
```
|
|
306
347
|
Import an open-files JSON or JSONL source manifest into `knowledge.db`. This
|
|
307
348
|
upserts sources and source revisions, stores hash/MIME/status/permission
|
|
@@ -317,10 +358,10 @@ resolver API lands.
|
|
|
317
358
|
|
|
318
359
|
### reindex
|
|
319
360
|
```bash
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
361
|
+
knowledge reindex status [--model openai:text-embedding-3-small] [--scope project] [--json]
|
|
362
|
+
knowledge reindex enqueue [--model openai:text-embedding-3-small] [--scope project] [--json]
|
|
363
|
+
knowledge reindex embeddings [--full] [--limit <n>] [--model openai:text-embedding-3-small] [--scope project] [--json]
|
|
364
|
+
knowledge reindex outbox <file|s3://bucket/key> [--scope project] [--json]
|
|
324
365
|
```
|
|
325
366
|
Inspect and operate index refresh work. `reindex status` reports missing
|
|
326
367
|
embedding rows, stale revisions, queued jobs, and vector counts. `reindex
|
|
@@ -337,9 +378,9 @@ remain owned by `open-files`.
|
|
|
337
378
|
|
|
338
379
|
### search
|
|
339
380
|
```bash
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
381
|
+
knowledge search <query> [--scope project] [--limit <n>] [--json]
|
|
382
|
+
knowledge search <query> --semantic [--model openai:text-embedding-3-small] [--scope project] [--json]
|
|
383
|
+
knowledge search <query> --context [--semantic] [--scope project] [--json]
|
|
343
384
|
```
|
|
344
385
|
Run hybrid search over `chunks_fts`, generated wiki chunks, wiki/index catalog
|
|
345
386
|
rows, and optional vector results. The default path is local-only keyword and
|
|
@@ -354,8 +395,8 @@ assembled citations, freshness and permission notes, graph evidence from
|
|
|
354
395
|
|
|
355
396
|
### ask / build
|
|
356
397
|
```bash
|
|
357
|
-
|
|
358
|
-
|
|
398
|
+
knowledge ask <prompt> [--scope project] [--json]
|
|
399
|
+
knowledge build <prompt> [--generate] [--model default|provider:model] [--scope project] [--json]
|
|
359
400
|
knowledge <prompt> [--scope project] [--json]
|
|
360
401
|
```
|
|
361
402
|
Build an agent-native prompt run. The command first creates a read-only context
|
|
@@ -367,7 +408,7 @@ intent, but durable wiki writes remain deferred to the wiki compile/write task.
|
|
|
367
408
|
|
|
368
409
|
### web
|
|
369
410
|
```bash
|
|
370
|
-
|
|
411
|
+
knowledge web search <query> [--provider openai|anthropic] [--model provider:model] [--domain <domain>] [--file-results] [--scope project] [--json]
|
|
371
412
|
```
|
|
372
413
|
Run provider-native hosted web search and return cited web sources. Real network
|
|
373
414
|
search is disabled unless `safety.network.web_search_enabled=true` or
|
|
@@ -379,11 +420,11 @@ deterministic offline sources for tests.
|
|
|
379
420
|
|
|
380
421
|
### safety
|
|
381
422
|
```bash
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
423
|
+
knowledge safety status [--scope project] [--json]
|
|
424
|
+
knowledge safety check generated_write [target] [--scope project] [--json]
|
|
425
|
+
knowledge safety approve generated_write [target] [--scope project] [--json]
|
|
426
|
+
knowledge safety audit [--scope project] [--json]
|
|
427
|
+
knowledge safety redact <text> [--scope project] [--json]
|
|
387
428
|
```
|
|
388
429
|
Inspect and operate the local safety model. Source reads are read-only by
|
|
389
430
|
default, web search and S3 reads are opt-in, generated writes require approval
|
|
@@ -391,9 +432,9 @@ by default, and known secret patterns are redacted before chunk storage.
|
|
|
391
432
|
|
|
392
433
|
### providers
|
|
393
434
|
```bash
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
435
|
+
knowledge providers status [--scope project] [--json]
|
|
436
|
+
knowledge providers models [--scope project] [--json]
|
|
437
|
+
knowledge providers check [provider|model-alias] [--scope project] [--json]
|
|
397
438
|
```
|
|
398
439
|
Inspect AI SDK v6 provider readiness for OpenAI, Anthropic, and DeepSeek. The
|
|
399
440
|
provider layer resolves BYOK credentials from `OPENAI_API_KEY`,
|
|
@@ -404,9 +445,9 @@ reasoning, embeddings, and native web-search support.
|
|
|
404
445
|
|
|
405
446
|
### embeddings
|
|
406
447
|
```bash
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
448
|
+
knowledge embeddings status [--scope project] [--json]
|
|
449
|
+
knowledge embeddings index [--model openai:text-embedding-3-small] [--limit <n>] [--scope project] [--json]
|
|
450
|
+
knowledge embeddings search <query> [--model openai:text-embedding-3-small] [--limit <n>] [--scope project] [--json]
|
|
410
451
|
```
|
|
411
452
|
Build and query the local vector index over derived knowledge chunks. The first
|
|
412
453
|
implementation stores vectors in SQLite as JSON rows in `chunk_embeddings` and
|
|
@@ -420,7 +461,7 @@ deterministic local vectors for tests and offline smoke checks.
|
|
|
420
461
|
|
|
421
462
|
### help
|
|
422
463
|
```bash
|
|
423
|
-
|
|
464
|
+
knowledge help [command]
|
|
424
465
|
```
|
|
425
466
|
|
|
426
467
|
## Global Options
|
|
@@ -446,7 +487,7 @@ location with `--store <path>`.
|
|
|
446
487
|
## MCP Server
|
|
447
488
|
|
|
448
489
|
```bash
|
|
449
|
-
|
|
490
|
+
knowledge-mcp
|
|
450
491
|
```
|
|
451
492
|
|
|
452
493
|
The stable agent-facing MCP tools are:
|
|
@@ -500,18 +541,18 @@ run ledgers, and citation evidence. They do not expose raw source bytes from
|
|
|
500
541
|
|
|
501
542
|
## Source And Artifact Boundary
|
|
502
543
|
|
|
503
|
-
Raw files should be stored and resolved through `open-files`. `
|
|
544
|
+
Raw files should be stored and resolved through `open-files`. `knowledge`
|
|
504
545
|
stores source references such as `open-files://file/<id>`,
|
|
505
546
|
`open-files://file/<id>/revision/<revision_id>`, `s3://...`, `file://...`,
|
|
506
547
|
and `https://...`, plus citations, chunks, generated wiki pages, indexes,
|
|
507
548
|
logs, runs, and search metadata.
|
|
508
549
|
|
|
509
|
-
`
|
|
550
|
+
`knowledge source resolve` and the MCP `ok_resolve_source` tool resolve
|
|
510
551
|
only the indexed, derived knowledge catalog. The resolver enforces read-only
|
|
511
552
|
purpose labels from source permissions, returns chunk citation evidence, writes
|
|
512
553
|
an audit event, and keeps bytes/storage credentials inside `open-files`.
|
|
513
554
|
|
|
514
|
-
`
|
|
555
|
+
`knowledge ingest source` can also build derived chunks from an allowed
|
|
515
556
|
source ref. It does not copy raw files into the knowledge workspace; local file,
|
|
516
557
|
S3, web, and open-files inputs are converted into redacted chunks with offsets,
|
|
517
558
|
hashes, revision metadata, and FTS rows.
|
|
@@ -527,14 +568,14 @@ store raw S3 or local-file bytes in the knowledge app, so a future hosted/S3
|
|
|
527
568
|
wrapper can move generated artifacts to object storage while source ownership
|
|
528
569
|
and immutable object identity stay in `open-files`.
|
|
529
570
|
|
|
530
|
-
AI provider configuration is local/BYOK by default. `
|
|
571
|
+
AI provider configuration is local/BYOK by default. `knowledge` declares
|
|
531
572
|
AI SDK v6 provider support through `ai`, `@ai-sdk/openai`,
|
|
532
573
|
`@ai-sdk/anthropic`, and `@ai-sdk/deepseek`, but does not call providers until a
|
|
533
574
|
prompt, embedding, or agent command explicitly requests a model.
|
|
534
575
|
|
|
535
576
|
Generated knowledge artifacts can be stored locally under
|
|
536
577
|
`.hasna/apps/knowledge/artifacts` or through the S3 artifact-store adapter.
|
|
537
|
-
For Hasna XYZ production, `
|
|
578
|
+
For Hasna XYZ production, `knowledge setup --mode hosted
|
|
538
579
|
--canonical-hasna-xyz --scope project --json` configures generated artifacts
|
|
539
580
|
under `s3://hasna-xyz-opensource-knowledge-prod/.hasna/apps/knowledge/` and
|
|
540
581
|
keeps `open-files` as the raw-source owner.
|
|
@@ -567,7 +608,7 @@ Every command returns structured JSON when `--json` is passed:
|
|
|
567
608
|
## MCP Server
|
|
568
609
|
|
|
569
610
|
```bash
|
|
570
|
-
|
|
611
|
+
knowledge-mcp
|
|
571
612
|
```
|
|
572
613
|
|
|
573
614
|
## HTTP mode
|
|
@@ -575,9 +616,9 @@ open-knowledge-mcp
|
|
|
575
616
|
Run a shared Streamable HTTP MCP server (127.0.0.1 only):
|
|
576
617
|
|
|
577
618
|
```bash
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
MCP_HTTP=1
|
|
619
|
+
knowledge-mcp --http # default port 8819
|
|
620
|
+
knowledge-mcp --http --port 8819
|
|
621
|
+
MCP_HTTP=1 knowledge-mcp
|
|
581
622
|
```
|
|
582
623
|
|
|
583
624
|
- Health: `GET http://127.0.0.1:8819/health`
|
|
@@ -13660,17 +13660,24 @@ import { existsSync as existsSync8, readFileSync as readFileSync8, writeFileSync
|
|
|
13660
13660
|
// package.json
|
|
13661
13661
|
var package_default = {
|
|
13662
13662
|
name: "@hasna/knowledge",
|
|
13663
|
-
version: "0.2.
|
|
13663
|
+
version: "0.2.29",
|
|
13664
13664
|
description: "Agent-friendly local knowledge CLI with JSON output, pagination, and safe destructive actions",
|
|
13665
13665
|
type: "module",
|
|
13666
|
+
exports: {
|
|
13667
|
+
".": {
|
|
13668
|
+
import: "./dist/index.js",
|
|
13669
|
+
types: "./dist/index.d.ts"
|
|
13670
|
+
}
|
|
13671
|
+
},
|
|
13672
|
+
main: "./dist/index.js",
|
|
13673
|
+
types: "./dist/index.d.ts",
|
|
13666
13674
|
bin: {
|
|
13667
|
-
knowledge: "bin/
|
|
13668
|
-
"
|
|
13669
|
-
"open-knowledge-mcp": "bin/open-knowledge-mcp.js"
|
|
13675
|
+
knowledge: "bin/knowledge.js",
|
|
13676
|
+
"knowledge-mcp": "bin/knowledge-mcp.js"
|
|
13670
13677
|
},
|
|
13671
13678
|
files: [
|
|
13672
13679
|
"bin",
|
|
13673
|
-
"
|
|
13680
|
+
"dist",
|
|
13674
13681
|
"docs",
|
|
13675
13682
|
"LICENSE",
|
|
13676
13683
|
"README.md"
|
|
@@ -13678,9 +13685,8 @@ var package_default = {
|
|
|
13678
13685
|
scripts: {
|
|
13679
13686
|
test: "bun test",
|
|
13680
13687
|
"test:cli": "bun test tests/cli.test.ts",
|
|
13681
|
-
build: "bun build --target=bun --outfile=bin/
|
|
13682
|
-
prepublishOnly: "bun run build"
|
|
13683
|
-
postinstall: "bun run build"
|
|
13688
|
+
build: "rm -rf dist && bun build --target=bun --outfile=bin/knowledge.js --minify --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/cli.ts && bun build --target=bun --outfile=bin/knowledge-mcp.js --external @modelcontextprotocol/sdk --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/mcp.js && bun build ./src/index.ts --outdir ./dist --target bun --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek && bunx tsc -p tsconfig.build.json",
|
|
13689
|
+
prepublishOnly: "bun run build"
|
|
13684
13690
|
},
|
|
13685
13691
|
keywords: [
|
|
13686
13692
|
"knowledge",
|
|
@@ -13709,12 +13715,13 @@ var package_default = {
|
|
|
13709
13715
|
node: ">=18"
|
|
13710
13716
|
},
|
|
13711
13717
|
dependencies: {
|
|
13712
|
-
"@aws-sdk/client-s3": "^3.1063.0",
|
|
13713
|
-
"@aws-sdk/credential-providers": "^3.1063.0",
|
|
13714
13718
|
"@ai-sdk/anthropic": "^3.0.81",
|
|
13715
13719
|
"@ai-sdk/deepseek": "^2.0.35",
|
|
13716
13720
|
"@ai-sdk/openai": "^3.0.68",
|
|
13721
|
+
"@aws-sdk/client-s3": "^3.1063.0",
|
|
13722
|
+
"@aws-sdk/credential-providers": "^3.1063.0",
|
|
13717
13723
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13724
|
+
"@types/json-schema": "^7.0.15",
|
|
13718
13725
|
ai: "^6.0.197",
|
|
13719
13726
|
zod: "^4.3.6"
|
|
13720
13727
|
},
|
|
@@ -18874,7 +18881,7 @@ function agentSchemaTemplate() {
|
|
|
18874
18881
|
## Source Rules
|
|
18875
18882
|
|
|
18876
18883
|
- Treat open-files source references as the preferred source of truth.
|
|
18877
|
-
- Do not copy raw source files into
|
|
18884
|
+
- Do not copy raw source files into knowledge.
|
|
18878
18885
|
- Cite every durable fact with a source URI, revision/hash when available, and optional span.
|
|
18879
18886
|
- Mark uncertainty explicitly when sources disagree or are incomplete.
|
|
18880
18887
|
|
|
@@ -19135,7 +19142,7 @@ class KnowledgeService {
|
|
|
19135
19142
|
artifact_uri_prefix: storage.artifact_store.uri_prefix,
|
|
19136
19143
|
canonical_hasna_xyz: storage.canonical_hasna_xyz,
|
|
19137
19144
|
config_path: workspace.configPath,
|
|
19138
|
-
next: mode === "hosted" ? ["
|
|
19145
|
+
next: mode === "hosted" ? ["knowledge auth login --api-key <key>", "knowledge storage status --json", "knowledge remote contracts --json"] : ["knowledge search <query>", "knowledge <prompt>"],
|
|
19139
19146
|
message: `Set knowledge mode to ${mode}`
|
|
19140
19147
|
};
|
|
19141
19148
|
}
|
|
@@ -19922,7 +19929,7 @@ function registerKnowledgeResources(server) {
|
|
|
19922
19929
|
}
|
|
19923
19930
|
function buildServer() {
|
|
19924
19931
|
const server = new McpServer({
|
|
19925
|
-
name: "
|
|
19932
|
+
name: "knowledge",
|
|
19926
19933
|
version: package_default.version
|
|
19927
19934
|
});
|
|
19928
19935
|
registerKnowledgeResources(server);
|
|
@@ -20666,7 +20673,7 @@ function buildServer() {
|
|
|
20666
20673
|
return server;
|
|
20667
20674
|
}
|
|
20668
20675
|
function printHelp() {
|
|
20669
|
-
console.error(`Usage:
|
|
20676
|
+
console.error(`Usage: knowledge-mcp [options]
|
|
20670
20677
|
|
|
20671
20678
|
Runs the @hasna/knowledge MCP server (stdio by default).
|
|
20672
20679
|
|
|
@@ -20692,7 +20699,7 @@ async function main() {
|
|
|
20692
20699
|
const server = buildServer();
|
|
20693
20700
|
const transport = new StdioServerTransport;
|
|
20694
20701
|
await server.connect(transport);
|
|
20695
|
-
console.error("
|
|
20702
|
+
console.error("knowledge MCP server running on stdio");
|
|
20696
20703
|
}
|
|
20697
20704
|
if (import.meta.main) {
|
|
20698
20705
|
main().catch((err) => {
|