@hasna/knowledge 0.2.3 → 0.2.5
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 +97 -4
- package/bin/open-knowledge-mcp.js +1067 -1569
- package/bin/open-knowledge.js +257 -4
- package/docs/architecture/ai-native-knowledge-base.md +191 -0
- package/docs/architecture/hybrid-semantic-search.md +135 -0
- package/package.json +12 -7
- package/src/artifact-store.ts +184 -0
- package/src/cli.ts +662 -0
- package/src/knowledge-db.ts +247 -0
- package/src/manifest-ingest.ts +423 -0
- package/src/mcp.js +533 -0
- package/src/schema.js +25 -0
- package/src/source-ref.ts +92 -0
- package/src/store.ts +16 -6
- package/src/wiki-layout.ts +104 -0
- package/src/workspace.ts +123 -0
package/README.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# open-knowledge
|
|
2
2
|
|
|
3
|
-
> Agent-friendly local knowledge CLI with JSON output,
|
|
3
|
+
> Agent-friendly local knowledge CLI/MCP with JSON output, project workspaces, durable artifacts, and safe destructive actions.
|
|
4
4
|
|
|
5
5
|
[](https://npm.im/@hasna/knowledge)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](.github/workflows/ci.yml)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`open-knowledge` is evolving from a flat note store into a local-first knowledge
|
|
10
|
+
engine for AI agents. It stores simple knowledge items today, creates a Hasna
|
|
11
|
+
project workspace under `.hasna/apps/knowledge`, initializes a versioned
|
|
12
|
+
`knowledge.db`, writes generated wiki artifacts, and exposes a stdio MCP server.
|
|
10
13
|
|
|
11
14
|
## Install
|
|
12
15
|
|
|
@@ -50,6 +53,18 @@ open-knowledge delete --id <id> --yes
|
|
|
50
53
|
|
|
51
54
|
# Export all notes as JSONL
|
|
52
55
|
open-knowledge export --format jsonl
|
|
56
|
+
|
|
57
|
+
# Show resolved workspace paths
|
|
58
|
+
open-knowledge paths --scope project --json
|
|
59
|
+
|
|
60
|
+
# Initialize the project SQLite catalog
|
|
61
|
+
open-knowledge db init --scope project
|
|
62
|
+
|
|
63
|
+
# Initialize scalable wiki/schema/index/log artifacts
|
|
64
|
+
open-knowledge wiki init --scope project
|
|
65
|
+
|
|
66
|
+
# Ingest an open-files source manifest into the project SQLite catalog
|
|
67
|
+
open-knowledge ingest manifest ./open-files-manifest.jsonl --scope project --json
|
|
53
68
|
```
|
|
54
69
|
|
|
55
70
|
## Commands
|
|
@@ -94,6 +109,25 @@ Update an existing item.
|
|
|
94
109
|
| `--url <url>` | New source URL |
|
|
95
110
|
| `-t, --tag <tag>` | Add a tag |
|
|
96
111
|
|
|
112
|
+
### archive / restore
|
|
113
|
+
```bash
|
|
114
|
+
open-knowledge archive --id <id>
|
|
115
|
+
open-knowledge restore --id <id>
|
|
116
|
+
```
|
|
117
|
+
Archive hides an item from default `list` output without deleting it.
|
|
118
|
+
|
|
119
|
+
### upsert
|
|
120
|
+
```bash
|
|
121
|
+
open-knowledge upsert [title] [content] [--id <id>] [--title <title>] [--content <content>]
|
|
122
|
+
```
|
|
123
|
+
Create or update an item by ID.
|
|
124
|
+
|
|
125
|
+
### untag
|
|
126
|
+
```bash
|
|
127
|
+
open-knowledge untag --id <id> -t <tag>
|
|
128
|
+
```
|
|
129
|
+
Remove one tag from an item.
|
|
130
|
+
|
|
97
131
|
### delete
|
|
98
132
|
```bash
|
|
99
133
|
open-knowledge delete|rm --id <id> --yes
|
|
@@ -106,6 +140,37 @@ open-knowledge export [--format jsonl]
|
|
|
106
140
|
```
|
|
107
141
|
Export all items. Use `--format jsonl` for newline-delimited JSON.
|
|
108
142
|
|
|
143
|
+
### paths
|
|
144
|
+
```bash
|
|
145
|
+
open-knowledge paths [--scope global|project|local] [--json]
|
|
146
|
+
```
|
|
147
|
+
Show the resolved Hasna app workspace, JSON compatibility store, SQLite path,
|
|
148
|
+
artifact directories, and config.
|
|
149
|
+
|
|
150
|
+
### db
|
|
151
|
+
```bash
|
|
152
|
+
open-knowledge db init [--scope project]
|
|
153
|
+
open-knowledge db stats [--scope project]
|
|
154
|
+
```
|
|
155
|
+
Initialize or inspect the versioned SQLite catalog at
|
|
156
|
+
`.hasna/apps/knowledge/knowledge.db`.
|
|
157
|
+
|
|
158
|
+
### wiki
|
|
159
|
+
```bash
|
|
160
|
+
open-knowledge wiki init [--scope project]
|
|
161
|
+
```
|
|
162
|
+
Create starter generated-knowledge artifacts through the artifact store:
|
|
163
|
+
`schemas/v1.md`, `indexes/root.md`, `wiki/README.md`, and a dated JSONL log
|
|
164
|
+
partition.
|
|
165
|
+
|
|
166
|
+
### ingest
|
|
167
|
+
```bash
|
|
168
|
+
open-knowledge ingest manifest <file|s3://bucket/key> [--scope project] [--json]
|
|
169
|
+
```
|
|
170
|
+
Import an open-files JSON or JSONL source manifest into `knowledge.db`. This
|
|
171
|
+
upserts sources and source revisions, stores hash/MIME/status/permission
|
|
172
|
+
metadata, and chunks embedded extracted text when the manifest includes it.
|
|
173
|
+
|
|
109
174
|
### help
|
|
110
175
|
```bash
|
|
111
176
|
open-knowledge help [command]
|
|
@@ -117,14 +182,42 @@ open-knowledge help [command]
|
|
|
117
182
|
|------|-------------|
|
|
118
183
|
| `--json` | Output raw JSON |
|
|
119
184
|
| `--store <path>` | Override store path |
|
|
185
|
+
| `--scope global\|project\|local` | Select global Hasna app workspace or project workspace |
|
|
120
186
|
| `--version, -v` | Show version |
|
|
121
187
|
| `--help, -h` | Show help |
|
|
122
188
|
|
|
123
189
|
## Store Location
|
|
124
190
|
|
|
125
|
-
Default store: `~/.
|
|
191
|
+
Default global compatibility store: `~/.hasna/apps/knowledge/db.json`
|
|
192
|
+
|
|
193
|
+
Project workspace: `.hasna/apps/knowledge/`
|
|
194
|
+
|
|
195
|
+
The legacy `~/.open-knowledge/db.json` store is migrated into the new global
|
|
196
|
+
Hasna app path on first use if the new store does not exist. Override item-store
|
|
197
|
+
location with `--store <path>`.
|
|
198
|
+
|
|
199
|
+
## MCP Server
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
open-knowledge-mcp
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The MCP server exposes item tools (`ok_add`, `ok_list`, `ok_get`, `ok_update`,
|
|
206
|
+
`ok_delete`, `ok_archive`, `ok_restore`, `ok_upsert`, `ok_untag`,
|
|
207
|
+
`ok_bulk_delete`, `ok_prune`, `ok_dedupe`, `ok_stats`, `ok_export`,
|
|
208
|
+
`ok_import`, `ok_batch`), workspace inspection (`ok_paths`), and source-ref
|
|
209
|
+
parsing (`ok_parse_source_ref`).
|
|
210
|
+
|
|
211
|
+
## Source And Artifact Boundary
|
|
212
|
+
|
|
213
|
+
Raw files should be stored and resolved through `open-files`. `open-knowledge`
|
|
214
|
+
stores source references such as `open-files://file/<id>`,
|
|
215
|
+
`open-files://file/<id>/revision/<revision_id>`, `s3://...`, `file://...`,
|
|
216
|
+
and `https://...`, plus citations, chunks, generated wiki pages, indexes,
|
|
217
|
+
logs, runs, and search metadata.
|
|
126
218
|
|
|
127
|
-
|
|
219
|
+
Generated knowledge artifacts can be stored locally under
|
|
220
|
+
`.hasna/apps/knowledge/artifacts` or through the S3 artifact-store adapter.
|
|
128
221
|
|
|
129
222
|
## JSON Output
|
|
130
223
|
|