sdtk-wiki-kit 0.1.1 → 0.1.2
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 +99 -2
- package/package.json +1 -1
- package/src/commands/help.js +28 -0
- package/src/commands/operations.js +345 -0
- package/src/commands/search.js +1 -0
- package/src/index.js +32 -1
- package/src/lib/wiki-search.js +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Implemented in the Foundation/Beta package:
|
|
|
28
28
|
| Capability | Command |
|
|
29
29
|
|---|---|
|
|
30
30
|
| Initialize SDTK-WIKI workspace | `sdtk-wiki init` |
|
|
31
|
+
| Build a personal-brain without timestamp variables | `sdtk-wiki ingest`, `sdtk-wiki compile --mode safe --apply`, `sdtk-wiki query` |
|
|
31
32
|
| Build graph, viewer, generated pages, and provenance | `sdtk-wiki atlas build` |
|
|
32
33
|
| Open local viewer | `sdtk-wiki atlas open` |
|
|
33
34
|
| Watch markdown sources and rebuild | `sdtk-wiki atlas watch` |
|
|
@@ -36,10 +37,13 @@ Implemented in the Foundation/Beta package:
|
|
|
36
37
|
| Run non-destructive wiki lint | `sdtk-wiki lint` |
|
|
37
38
|
| Run stale-page prune dry-run report | `sdtk-wiki wiki prune --dry-run` |
|
|
38
39
|
| Generate local discovery plan from gap evidence | `sdtk-wiki wiki discover --plan` |
|
|
40
|
+
| Generate local discovery plan with beginner facade | `sdtk-wiki discover --plan` |
|
|
41
|
+
| Run report-first maintenance cycle | `sdtk-wiki maintain --mode safe` |
|
|
39
42
|
| Generate semantic extraction dry-run report | `sdtk-wiki wiki extract --dry-run` |
|
|
40
43
|
| Generate compile dry-run preview and JSON sidecar | `sdtk-wiki wiki compile --dry-run` |
|
|
41
44
|
| Apply an approved compile JSON sidecar | `sdtk-wiki wiki compile --apply --yes` |
|
|
42
45
|
| Search generated personal-brain pages locally | `sdtk-wiki search` |
|
|
46
|
+
| Query generated personal-brain pages locally | `sdtk-wiki query` |
|
|
43
47
|
| Ask grounded questions over built graph | `sdtk-wiki ask` with `wiki.ask` entitlement/runtime preconditions |
|
|
44
48
|
| Save one redacted query record after successful Ask | `sdtk-wiki ask --save-query` with `wiki.ask` entitlement/runtime preconditions |
|
|
45
49
|
|
|
@@ -91,6 +95,41 @@ Open the viewer:
|
|
|
91
95
|
sdtk-wiki atlas open --project-path .
|
|
92
96
|
```
|
|
93
97
|
|
|
98
|
+
## Simple Personal-Brain Flow
|
|
99
|
+
|
|
100
|
+
Use this when you want the shortest local second-brain path and do not need to
|
|
101
|
+
inspect timestamped JSON files:
|
|
102
|
+
|
|
103
|
+
```powershell
|
|
104
|
+
sdtk-wiki init --no-open
|
|
105
|
+
sdtk-wiki ingest .\source-md
|
|
106
|
+
sdtk-wiki compile --mode safe --apply
|
|
107
|
+
sdtk-wiki query "multi-agent"
|
|
108
|
+
sdtk-wiki lint
|
|
109
|
+
sdtk-wiki discover --plan
|
|
110
|
+
sdtk-wiki maintain --mode safe
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Behavior:
|
|
114
|
+
|
|
115
|
+
- `ingest` runs local semantic extraction and writes a report.
|
|
116
|
+
- `compile --mode safe --apply` creates or refreshes the compile preview/JSON
|
|
117
|
+
sidecar internally, then applies the sidecar contract.
|
|
118
|
+
- `query` is deterministic local search over `.sdtk/wiki/personal-brain`; it
|
|
119
|
+
does not use premium Ask, LLM/RAG, web fetch, or query history.
|
|
120
|
+
- `discover` and `maintain` are report-first and do not apply, delete, archive,
|
|
121
|
+
fetch web sources, or mutate `.sdtk/atlas`.
|
|
122
|
+
|
|
123
|
+
Interactive viewer flow:
|
|
124
|
+
|
|
125
|
+
```powershell
|
|
126
|
+
sdtk-wiki init
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Bare `sdtk-wiki init` may open/start the viewer and keep the terminal session
|
|
130
|
+
active. Use `sdtk-wiki init --no-open` for automation, CI, and local
|
|
131
|
+
non-interactive validation.
|
|
132
|
+
|
|
94
133
|
## Command Reference
|
|
95
134
|
|
|
96
135
|
### Init
|
|
@@ -131,6 +170,20 @@ Safety:
|
|
|
131
170
|
- no generated page updates
|
|
132
171
|
- no graph/viewer rebuild side effects
|
|
133
172
|
|
|
173
|
+
### Beginner Ingest Operation
|
|
174
|
+
|
|
175
|
+
```powershell
|
|
176
|
+
sdtk-wiki ingest <source-root> [--project-path <path>]
|
|
177
|
+
sdtk-wiki ingest --source-root <source-root> [--project-path <path>]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Runs semantic extraction over a local Markdown source root and writes the latest
|
|
181
|
+
`semantic-extraction-dry-run-*.json` report under `.sdtk/wiki/reports`.
|
|
182
|
+
|
|
183
|
+
This is the beginner-friendly facade for `sdtk-wiki wiki extract --dry-run`.
|
|
184
|
+
It does not mutate source files, personal-brain pages, raw/provenance state,
|
|
185
|
+
graph outputs, web sources, Ask state, or `.sdtk/atlas`.
|
|
186
|
+
|
|
134
187
|
### Lint
|
|
135
188
|
|
|
136
189
|
```powershell
|
|
@@ -167,6 +220,15 @@ Safety:
|
|
|
167
220
|
- no compile/apply
|
|
168
221
|
- no prune/delete/archive
|
|
169
222
|
|
|
223
|
+
Beginner facade:
|
|
224
|
+
|
|
225
|
+
```powershell
|
|
226
|
+
sdtk-wiki discover --plan [--project-path <path>]
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
This uses the same local-only discovery plan behavior and report-first safety
|
|
230
|
+
boundary.
|
|
231
|
+
|
|
170
232
|
### Semantic Extraction Dry-Run
|
|
171
233
|
|
|
172
234
|
```powershell
|
|
@@ -212,6 +274,24 @@ Supported operation types:
|
|
|
212
274
|
Unknown operation types are reported as `unsupported_operation`. Dry-run does
|
|
213
275
|
not modify wiki pages, raw sources, provenance, or `.sdtk/atlas`.
|
|
214
276
|
|
|
277
|
+
### Beginner Compile Operation
|
|
278
|
+
|
|
279
|
+
```powershell
|
|
280
|
+
sdtk-wiki compile --mode safe [--project-path <path>]
|
|
281
|
+
sdtk-wiki compile --mode safe --apply [--project-path <path>]
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The beginner facade hides timestamped JSON paths:
|
|
285
|
+
|
|
286
|
+
- without `--apply`, it finds the latest semantic extraction report and writes
|
|
287
|
+
the compile preview plus JSON sidecar
|
|
288
|
+
- with `--apply`, it finds the latest sidecar or creates one from the latest
|
|
289
|
+
extraction report, then applies through the same sidecar-only contract
|
|
290
|
+
|
|
291
|
+
`safe` is the only R1 mode. Auto mode, destructive cleanup, web fetch, Ask, raw
|
|
292
|
+
mutation, provenance mutation, source mutation, and `.sdtk/atlas` mutation are
|
|
293
|
+
not performed.
|
|
294
|
+
|
|
215
295
|
### Compile Apply
|
|
216
296
|
|
|
217
297
|
```powershell
|
|
@@ -245,6 +325,15 @@ Search is deterministic, read-only, and non-premium. It does not require
|
|
|
245
325
|
`wiki.ask` entitlement, does not call an LLM/RAG runtime, does not write query
|
|
246
326
|
history, and does not mutate project files.
|
|
247
327
|
|
|
328
|
+
Beginner query facade:
|
|
329
|
+
|
|
330
|
+
```powershell
|
|
331
|
+
sdtk-wiki query --project-path <path> "<query>"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
`query` is the simple local search command. It is not premium Ask and does not
|
|
335
|
+
require `wiki.ask`.
|
|
336
|
+
|
|
248
337
|
### Ask
|
|
249
338
|
|
|
250
339
|
```powershell
|
|
@@ -290,8 +379,8 @@ Run report-first maintenance checks:
|
|
|
290
379
|
|
|
291
380
|
```powershell
|
|
292
381
|
sdtk-wiki lint --project-path .
|
|
293
|
-
sdtk-wiki
|
|
294
|
-
sdtk-wiki
|
|
382
|
+
sdtk-wiki discover --plan --project-path .
|
|
383
|
+
sdtk-wiki maintain --mode safe --project-path .
|
|
295
384
|
```
|
|
296
385
|
|
|
297
386
|
Preview a compile plan without applying it:
|
|
@@ -302,6 +391,14 @@ sdtk-wiki wiki compile --plan <local-plan.md-or-json> --project-path . --dry-run
|
|
|
302
391
|
|
|
303
392
|
Build a personal-brain from local Markdown sources and search it:
|
|
304
393
|
|
|
394
|
+
```powershell
|
|
395
|
+
sdtk-wiki ingest docs
|
|
396
|
+
sdtk-wiki compile --mode safe --apply
|
|
397
|
+
sdtk-wiki query "multi-agent"
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Advanced/audit workflow with explicit report files:
|
|
401
|
+
|
|
305
402
|
```powershell
|
|
306
403
|
sdtk-wiki wiki extract --project-path . --source-root docs --dry-run
|
|
307
404
|
sdtk-wiki wiki compile --project-path . --plan .sdtk/wiki/reports/semantic-extraction-dry-run-<stamp>.json --dry-run
|
package/package.json
CHANGED
package/src/commands/help.js
CHANGED
|
@@ -7,6 +7,11 @@ Usage:
|
|
|
7
7
|
sdtk-wiki --help
|
|
8
8
|
sdtk-wiki --version
|
|
9
9
|
sdtk-wiki init --help
|
|
10
|
+
sdtk-wiki ingest --help
|
|
11
|
+
sdtk-wiki compile --help
|
|
12
|
+
sdtk-wiki query --help
|
|
13
|
+
sdtk-wiki discover --help
|
|
14
|
+
sdtk-wiki maintain --help
|
|
10
15
|
sdtk-wiki atlas build --help
|
|
11
16
|
sdtk-wiki atlas open --help
|
|
12
17
|
sdtk-wiki atlas watch --help
|
|
@@ -19,8 +24,22 @@ Usage:
|
|
|
19
24
|
sdtk-wiki search --help
|
|
20
25
|
sdtk-wiki lint --help
|
|
21
26
|
|
|
27
|
+
Simple personal-brain workflow:
|
|
28
|
+
sdtk-wiki init --no-open
|
|
29
|
+
sdtk-wiki ingest <source-root>
|
|
30
|
+
sdtk-wiki compile --mode safe [--apply]
|
|
31
|
+
sdtk-wiki query "<query>"
|
|
32
|
+
sdtk-wiki lint
|
|
33
|
+
sdtk-wiki discover --plan
|
|
34
|
+
sdtk-wiki maintain --mode safe
|
|
35
|
+
|
|
22
36
|
R1 command model:
|
|
23
37
|
init Initialize the SDTK-WIKI workspace.
|
|
38
|
+
ingest Run local semantic extraction without handling timestamped JSON.
|
|
39
|
+
compile Run safe personal-brain compile preview, optionally apply.
|
|
40
|
+
query Search generated personal-brain pages locally without premium Ask.
|
|
41
|
+
discover Write a local-only discovery plan from WIKI gap evidence.
|
|
42
|
+
maintain Run safe lint, discover, and compile-preview maintenance reports.
|
|
24
43
|
atlas build Build graph/viewer plus local wiki pages/provenance.
|
|
25
44
|
atlas open Open or serve the local graph viewer.
|
|
26
45
|
atlas watch Watch markdown sources and rebuild the graph.
|
|
@@ -33,6 +52,12 @@ R1 command model:
|
|
|
33
52
|
search Search generated personal-brain pages locally without premium Ask.
|
|
34
53
|
lint Write a report-first, non-destructive wiki lint report.
|
|
35
54
|
|
|
55
|
+
Advanced/audit workflow:
|
|
56
|
+
sdtk-wiki wiki extract --source-root <source-root> --dry-run
|
|
57
|
+
sdtk-wiki wiki compile --plan <extract-json> --dry-run
|
|
58
|
+
sdtk-wiki wiki compile --plan <apply-json> --apply --yes
|
|
59
|
+
sdtk-wiki search "<query>"
|
|
60
|
+
|
|
36
61
|
Workspace paths:
|
|
37
62
|
.sdtk/wiki New SDTK-WIKI workspace target.
|
|
38
63
|
.sdtk/wiki/graph New SDTK-WIKI graph output target.
|
|
@@ -53,10 +78,13 @@ Premium Ask:
|
|
|
53
78
|
Query history, discover, compile, and cleanup automation are not enabled in R1.
|
|
54
79
|
|
|
55
80
|
Local Search:
|
|
81
|
+
sdtk-wiki query Beginner-friendly local deterministic search over .sdtk/wiki/personal-brain.
|
|
56
82
|
sdtk-wiki search Deterministic, read-only local search over .sdtk/wiki/personal-brain.
|
|
57
83
|
Does not require wiki.ask entitlement and does not perform LLM/RAG behavior.
|
|
58
84
|
|
|
59
85
|
Maintenance:
|
|
86
|
+
sdtk-wiki discover --plan is a top-level alias for local-only discovery planning.
|
|
87
|
+
sdtk-wiki maintain --mode safe runs report-first lint/discover/compile-preview checks without apply.
|
|
60
88
|
sdtk-wiki wiki prune --dry-run is report-only and writes under .sdtk/wiki/reports.
|
|
61
89
|
It never deletes, archives, applies, or mutates .sdtk/atlas.`);
|
|
62
90
|
console.log(`
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { parseFlags } = require("../lib/args");
|
|
6
|
+
const { CliError, ValidationError } = require("../lib/errors");
|
|
7
|
+
const { runWikiCompileApply, runWikiCompileDryRun } = require("../lib/wiki-compile");
|
|
8
|
+
const { runWikiDiscoverPlan } = require("../lib/wiki-discover");
|
|
9
|
+
const { runWikiExtractDryRun } = require("../lib/wiki-extract");
|
|
10
|
+
const { runWikiLint } = require("../lib/wiki-lint");
|
|
11
|
+
const { runWikiSearch } = require("../lib/wiki-search");
|
|
12
|
+
const { getWikiReportsPath, resolveProjectPath } = require("../lib/wiki-paths");
|
|
13
|
+
const { printHumanResult } = require("./search");
|
|
14
|
+
|
|
15
|
+
const INGEST_FLAG_DEFS = {
|
|
16
|
+
help: { type: "boolean", alias: "h" },
|
|
17
|
+
"project-path": { type: "string" },
|
|
18
|
+
"source-root": { type: "string" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const COMPILE_FLAG_DEFS = {
|
|
22
|
+
help: { type: "boolean", alias: "h" },
|
|
23
|
+
"project-path": { type: "string" },
|
|
24
|
+
mode: { type: "string" },
|
|
25
|
+
apply: { type: "boolean" },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const QUERY_FLAG_DEFS = {
|
|
29
|
+
help: { type: "boolean", alias: "h" },
|
|
30
|
+
"project-path": { type: "string" },
|
|
31
|
+
json: { type: "boolean" },
|
|
32
|
+
limit: { type: "string" },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const DISCOVER_FLAG_DEFS = {
|
|
36
|
+
help: { type: "boolean", alias: "h" },
|
|
37
|
+
"project-path": { type: "string" },
|
|
38
|
+
plan: { type: "boolean" },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const MAINTAIN_FLAG_DEFS = {
|
|
42
|
+
help: { type: "boolean", alias: "h" },
|
|
43
|
+
"project-path": { type: "string" },
|
|
44
|
+
mode: { type: "string" },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function ensureProjectPath(projectPath) {
|
|
48
|
+
const resolved = resolveProjectPath(projectPath || process.cwd());
|
|
49
|
+
if (!fs.existsSync(resolved) || !fs.statSync(resolved).isDirectory()) {
|
|
50
|
+
throw new ValidationError(`--project-path is not a valid directory: ${resolved}`);
|
|
51
|
+
}
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ensureSafeMode(mode, commandName) {
|
|
56
|
+
const resolvedMode = mode || "safe";
|
|
57
|
+
if (resolvedMode !== "safe") {
|
|
58
|
+
throw new ValidationError(
|
|
59
|
+
`sdtk-wiki ${commandName} supports only --mode safe in R1. Auto mode is deferred. No project files were changed.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return resolvedMode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function findLatestReport(projectPath, pattern) {
|
|
66
|
+
const reportsPath = getWikiReportsPath(projectPath);
|
|
67
|
+
if (!fs.existsSync(reportsPath) || !fs.statSync(reportsPath).isDirectory()) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const matcher = new RegExp(`^${pattern}$`);
|
|
71
|
+
const files = fs.readdirSync(reportsPath)
|
|
72
|
+
.filter((name) => matcher.test(name))
|
|
73
|
+
.map((name) => {
|
|
74
|
+
const filePath = path.join(reportsPath, name);
|
|
75
|
+
return { filePath, mtimeMs: fs.statSync(filePath).mtimeMs };
|
|
76
|
+
})
|
|
77
|
+
.sort((a, b) => {
|
|
78
|
+
if (b.mtimeMs !== a.mtimeMs) return b.mtimeMs - a.mtimeMs;
|
|
79
|
+
return b.filePath.localeCompare(a.filePath);
|
|
80
|
+
});
|
|
81
|
+
return files.length > 0 ? files[0] : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function latestExtraction(projectPath) {
|
|
85
|
+
return findLatestReport(projectPath, "semantic-extraction-dry-run-.*\\.json");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function latestApplyPlan(projectPath) {
|
|
89
|
+
return findLatestReport(projectPath, "compile-apply-plan-.*\\.json");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function cmdIngestHelp() {
|
|
93
|
+
console.log(`SDTK-WIKI Ingest
|
|
94
|
+
|
|
95
|
+
Usage:
|
|
96
|
+
sdtk-wiki ingest <source-root> [--project-path <path>]
|
|
97
|
+
sdtk-wiki ingest --source-root <path> [--project-path <path>]
|
|
98
|
+
|
|
99
|
+
Purpose:
|
|
100
|
+
Run local semantic extraction over a Markdown source root and write a report under .sdtk/wiki/reports.
|
|
101
|
+
|
|
102
|
+
Safety:
|
|
103
|
+
Local sources only.
|
|
104
|
+
No source mutation, personal-brain page writes, graph rebuild, web fetch, Ask, raw/provenance mutation, or .sdtk/atlas mutation.
|
|
105
|
+
|
|
106
|
+
Next:
|
|
107
|
+
sdtk-wiki compile --mode safe`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function cmdCompileHelp() {
|
|
112
|
+
console.log(`SDTK-WIKI Compile
|
|
113
|
+
|
|
114
|
+
Usage:
|
|
115
|
+
sdtk-wiki compile --mode safe [--project-path <path>]
|
|
116
|
+
sdtk-wiki compile --mode safe --apply [--project-path <path>]
|
|
117
|
+
|
|
118
|
+
Purpose:
|
|
119
|
+
Use the latest semantic extraction report to write a compile preview and JSON sidecar, then optionally apply the sidecar.
|
|
120
|
+
|
|
121
|
+
Safety:
|
|
122
|
+
Safe mode is the only R1 mode.
|
|
123
|
+
--apply still uses the existing JSON sidecar contract.
|
|
124
|
+
No delete, archive, rewrite, raw/provenance mutation, source mutation, web fetch, Ask, or .sdtk/atlas mutation.`);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function cmdQueryHelp() {
|
|
129
|
+
console.log(`SDTK-WIKI Query
|
|
130
|
+
|
|
131
|
+
Usage:
|
|
132
|
+
sdtk-wiki query [--project-path <path>] [--json] [--limit <n>] "<query>"
|
|
133
|
+
|
|
134
|
+
Purpose:
|
|
135
|
+
Deterministically search generated personal-brain Markdown pages.
|
|
136
|
+
|
|
137
|
+
Behavior:
|
|
138
|
+
Local search only.
|
|
139
|
+
No wiki.ask entitlement, LLM/RAG runtime, query history, or project mutation.
|
|
140
|
+
Use sdtk-wiki ask for premium grounded Q&A when wiki.ask preconditions are available.`);
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function cmdDiscoverHelp() {
|
|
145
|
+
console.log(`SDTK-WIKI Discover
|
|
146
|
+
|
|
147
|
+
Usage:
|
|
148
|
+
sdtk-wiki discover --plan [--project-path <path>]
|
|
149
|
+
|
|
150
|
+
Purpose:
|
|
151
|
+
Write a local-only discovery plan from existing wiki gap evidence.
|
|
152
|
+
|
|
153
|
+
Safety:
|
|
154
|
+
Plan-only. No web fetch, source ingest, compile, apply, prune, delete, archive, query history, Ask, or .sdtk/atlas mutation.`);
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function cmdMaintainHelp() {
|
|
159
|
+
console.log(`SDTK-WIKI Maintain
|
|
160
|
+
|
|
161
|
+
Usage:
|
|
162
|
+
sdtk-wiki maintain --mode safe [--project-path <path>]
|
|
163
|
+
|
|
164
|
+
Purpose:
|
|
165
|
+
Run a report-first maintenance cycle: lint, discover plan, and compile preview when an extraction report exists.
|
|
166
|
+
|
|
167
|
+
Safety:
|
|
168
|
+
Safe mode only.
|
|
169
|
+
No apply, delete, archive, source mutation, web fetch, Ask, query history, or .sdtk/atlas mutation.`);
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function resolveSourceRoot(flags, positional) {
|
|
174
|
+
if (flags["source-root"]) return flags["source-root"];
|
|
175
|
+
if (positional.length === 1) return positional[0];
|
|
176
|
+
if (positional.length > 1) {
|
|
177
|
+
throw new ValidationError("sdtk-wiki ingest accepts one source root. Quote paths that contain spaces. No project files were changed.");
|
|
178
|
+
}
|
|
179
|
+
throw new ValidationError("sdtk-wiki ingest requires <source-root> or --source-root <path>. No project files were changed.");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function cmdIngest(args) {
|
|
183
|
+
const { flags, positional } = parseFlags(args || [], INGEST_FLAG_DEFS);
|
|
184
|
+
if (flags.help) return cmdIngestHelp();
|
|
185
|
+
const projectPath = ensureProjectPath(flags["project-path"]);
|
|
186
|
+
const result = runWikiExtractDryRun({
|
|
187
|
+
projectPath,
|
|
188
|
+
sourceRootArg: resolveSourceRoot(flags, positional),
|
|
189
|
+
});
|
|
190
|
+
const extraction = result.extraction;
|
|
191
|
+
|
|
192
|
+
console.log(`[wiki] Semantic extraction report: ${result.reportPath}`);
|
|
193
|
+
console.log(`[wiki] Sources scanned: ${extraction.source_counts.scanned}`);
|
|
194
|
+
console.log(`[wiki] Sources indexed: ${extraction.source_counts.indexed}`);
|
|
195
|
+
console.log(`[wiki] Tool candidates: ${extraction.tool_entities.length}`);
|
|
196
|
+
console.log(`[wiki] Concept candidates: ${extraction.concepts.length}`);
|
|
197
|
+
console.log(`[wiki] Quality findings: ${extraction.source_quality_findings.length}`);
|
|
198
|
+
console.log("[wiki] No source files, personal-brain pages, raw/provenance state, graph outputs, or atlas compatibility files were modified.");
|
|
199
|
+
console.log("[wiki] Next: sdtk-wiki compile --mode safe");
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function runCompileDryRunFromLatestExtraction(projectPath) {
|
|
204
|
+
const extraction = latestExtraction(projectPath);
|
|
205
|
+
if (!extraction) {
|
|
206
|
+
throw new ValidationError(
|
|
207
|
+
"No semantic extraction report found. Run \"sdtk-wiki ingest <source-root>\" first. No project files were changed."
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return runWikiCompileDryRun({ projectPath, planArg: extraction.filePath });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function ensureApplySidecar(projectPath) {
|
|
214
|
+
const extraction = latestExtraction(projectPath);
|
|
215
|
+
const sidecar = latestApplyPlan(projectPath);
|
|
216
|
+
if (!sidecar && !extraction) {
|
|
217
|
+
throw new ValidationError(
|
|
218
|
+
"No compile apply sidecar or semantic extraction report found. Run \"sdtk-wiki ingest <source-root>\" first. No project files were changed."
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
if (!sidecar || (extraction && extraction.mtimeMs > sidecar.mtimeMs)) {
|
|
222
|
+
const dryRun = runCompileDryRunFromLatestExtraction(projectPath);
|
|
223
|
+
return {
|
|
224
|
+
sidecarPath: dryRun.applyPlanPath,
|
|
225
|
+
dryRun,
|
|
226
|
+
createdFreshSidecar: true,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
sidecarPath: sidecar.filePath,
|
|
231
|
+
dryRun: null,
|
|
232
|
+
createdFreshSidecar: false,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function cmdCompile(args) {
|
|
237
|
+
const { flags } = parseFlags(args || [], COMPILE_FLAG_DEFS);
|
|
238
|
+
if (flags.help) return cmdCompileHelp();
|
|
239
|
+
ensureSafeMode(flags.mode, "compile");
|
|
240
|
+
const projectPath = ensureProjectPath(flags["project-path"]);
|
|
241
|
+
|
|
242
|
+
if (!flags.apply) {
|
|
243
|
+
const result = runCompileDryRunFromLatestExtraction(projectPath);
|
|
244
|
+
console.log(`[wiki] Compile dry-run preview: ${result.reportPath}`);
|
|
245
|
+
console.log(`[wiki] Compile apply JSON sidecar: ${result.applyPlanPath}`);
|
|
246
|
+
console.log(`[wiki] Operations: ${result.operations.length}`);
|
|
247
|
+
console.log(`[wiki] Unsupported operations: ${result.unsupportedCount}`);
|
|
248
|
+
console.log("[wiki] No wiki pages, raw sources, provenance, source files, or atlas compatibility files were modified.");
|
|
249
|
+
console.log("[wiki] Next: sdtk-wiki compile --mode safe --apply");
|
|
250
|
+
if (result.unsupportedCount > 0) {
|
|
251
|
+
throw new CliError(
|
|
252
|
+
`unsupported_operation: ${result.unsupportedCount} operation(s) are blocked. Review the compile dry-run preview report.`,
|
|
253
|
+
1
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const sidecar = ensureApplySidecar(projectPath);
|
|
260
|
+
const result = runWikiCompileApply({ projectPath, planArg: sidecar.sidecarPath });
|
|
261
|
+
console.log(`[wiki] Compile apply plan: ${result.planPath}`);
|
|
262
|
+
if (sidecar.createdFreshSidecar) {
|
|
263
|
+
console.log(`[wiki] Refreshed compile dry-run preview: ${sidecar.dryRun.reportPath}`);
|
|
264
|
+
}
|
|
265
|
+
console.log(`[wiki] Created files: ${result.created.length}`);
|
|
266
|
+
console.log(`[wiki] Unchanged files: ${result.unchanged.length}`);
|
|
267
|
+
console.log(`[wiki] Source-quality warnings: ${result.sourceQualityWarningCount}`);
|
|
268
|
+
console.log("[wiki] No source files, raw sources, provenance descriptors, or atlas compatibility files were modified.");
|
|
269
|
+
console.log("[wiki] Next: sdtk-wiki query \"multi-agent\"");
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function cmdQuery(args) {
|
|
274
|
+
const { flags, positional } = parseFlags(args || [], QUERY_FLAG_DEFS);
|
|
275
|
+
if (flags.help) return cmdQueryHelp();
|
|
276
|
+
const query = positional.join(" ");
|
|
277
|
+
const result = runWikiSearch({
|
|
278
|
+
projectPath: flags["project-path"],
|
|
279
|
+
query,
|
|
280
|
+
limit: flags.limit,
|
|
281
|
+
});
|
|
282
|
+
if (flags.json) {
|
|
283
|
+
console.log(JSON.stringify(result, null, 2));
|
|
284
|
+
} else {
|
|
285
|
+
console.log("[wiki] Query mode: local deterministic search. Premium Ask is not used.");
|
|
286
|
+
printHumanResult(result);
|
|
287
|
+
}
|
|
288
|
+
return 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function cmdDiscover(args) {
|
|
292
|
+
const { flags } = parseFlags(args || [], DISCOVER_FLAG_DEFS);
|
|
293
|
+
if (flags.help) return cmdDiscoverHelp();
|
|
294
|
+
if (!flags.plan) {
|
|
295
|
+
throw new ValidationError("sdtk-wiki discover requires --plan. No web/fetch/apply/auto behavior is enabled. No project files were changed.");
|
|
296
|
+
}
|
|
297
|
+
const projectPath = ensureProjectPath(flags["project-path"]);
|
|
298
|
+
const result = runWikiDiscoverPlan({ projectPath });
|
|
299
|
+
|
|
300
|
+
console.log(`[wiki] Discovery plan report: ${result.reportPath}`);
|
|
301
|
+
console.log(`[wiki] Pages scanned: ${result.pageCount}`);
|
|
302
|
+
console.log(`[wiki] Plan items: ${result.items.length}`);
|
|
303
|
+
console.log("[wiki] No sources were fetched, ingested, compiled, applied, pruned, deleted, archived, or persisted.");
|
|
304
|
+
return 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function cmdMaintain(args) {
|
|
308
|
+
const { flags } = parseFlags(args || [], MAINTAIN_FLAG_DEFS);
|
|
309
|
+
if (flags.help) return cmdMaintainHelp();
|
|
310
|
+
ensureSafeMode(flags.mode, "maintain");
|
|
311
|
+
const projectPath = ensureProjectPath(flags["project-path"]);
|
|
312
|
+
|
|
313
|
+
const lint = runWikiLint({ projectPath });
|
|
314
|
+
const discover = runWikiDiscoverPlan({ projectPath });
|
|
315
|
+
const extraction = latestExtraction(projectPath);
|
|
316
|
+
let compile = null;
|
|
317
|
+
if (extraction) {
|
|
318
|
+
compile = runWikiCompileDryRun({ projectPath, planArg: extraction.filePath });
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
console.log(`[wiki] Maintain mode: safe`);
|
|
322
|
+
console.log(`[wiki] Lint report: ${lint.reportPath}`);
|
|
323
|
+
console.log(`[wiki] Discovery plan report: ${discover.reportPath}`);
|
|
324
|
+
if (compile) {
|
|
325
|
+
console.log(`[wiki] Compile dry-run preview: ${compile.reportPath}`);
|
|
326
|
+
console.log(`[wiki] Compile apply JSON sidecar: ${compile.applyPlanPath}`);
|
|
327
|
+
} else {
|
|
328
|
+
console.log("[wiki] Compile preview skipped: no semantic extraction report found. Run \"sdtk-wiki ingest <source-root>\".");
|
|
329
|
+
}
|
|
330
|
+
console.log("[wiki] No apply, source mutation, web fetch, Ask, query history, delete/archive, or atlas compatibility mutation was performed.");
|
|
331
|
+
return 0;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
module.exports = {
|
|
335
|
+
cmdCompile,
|
|
336
|
+
cmdCompileHelp,
|
|
337
|
+
cmdDiscover,
|
|
338
|
+
cmdDiscoverHelp,
|
|
339
|
+
cmdIngest,
|
|
340
|
+
cmdIngestHelp,
|
|
341
|
+
cmdMaintain,
|
|
342
|
+
cmdMaintainHelp,
|
|
343
|
+
cmdQuery,
|
|
344
|
+
cmdQueryHelp,
|
|
345
|
+
};
|
package/src/commands/search.js
CHANGED
package/src/index.js
CHANGED
|
@@ -5,6 +5,13 @@ const { cmdAsk } = require("./commands/ask");
|
|
|
5
5
|
const { cmdHelp } = require("./commands/help");
|
|
6
6
|
const { cmdInit } = require("./commands/init");
|
|
7
7
|
const { cmdLint } = require("./commands/lint");
|
|
8
|
+
const {
|
|
9
|
+
cmdCompile,
|
|
10
|
+
cmdDiscover,
|
|
11
|
+
cmdIngest,
|
|
12
|
+
cmdMaintain,
|
|
13
|
+
cmdQuery,
|
|
14
|
+
} = require("./commands/operations");
|
|
8
15
|
const { cmdSearch } = require("./commands/search");
|
|
9
16
|
const { cmdWiki } = require("./commands/wiki");
|
|
10
17
|
const { ValidationError } = require("./lib/errors");
|
|
@@ -30,7 +37,21 @@ function parseCommand(argv) {
|
|
|
30
37
|
return { command: first, args: rest };
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
const COMMANDS = new Set([
|
|
40
|
+
const COMMANDS = new Set([
|
|
41
|
+
"help",
|
|
42
|
+
"version",
|
|
43
|
+
"init",
|
|
44
|
+
"atlas",
|
|
45
|
+
"wiki",
|
|
46
|
+
"ask",
|
|
47
|
+
"lint",
|
|
48
|
+
"search",
|
|
49
|
+
"ingest",
|
|
50
|
+
"compile",
|
|
51
|
+
"query",
|
|
52
|
+
"discover",
|
|
53
|
+
"maintain",
|
|
54
|
+
]);
|
|
34
55
|
|
|
35
56
|
async function run(argv) {
|
|
36
57
|
const { command, args } = parseCommand(argv);
|
|
@@ -59,6 +80,16 @@ async function run(argv) {
|
|
|
59
80
|
return cmdLint(args);
|
|
60
81
|
case "search":
|
|
61
82
|
return cmdSearch(args);
|
|
83
|
+
case "ingest":
|
|
84
|
+
return cmdIngest(args);
|
|
85
|
+
case "compile":
|
|
86
|
+
return cmdCompile(args);
|
|
87
|
+
case "query":
|
|
88
|
+
return cmdQuery(args);
|
|
89
|
+
case "discover":
|
|
90
|
+
return cmdDiscover(args);
|
|
91
|
+
case "maintain":
|
|
92
|
+
return cmdMaintain(args);
|
|
62
93
|
}
|
|
63
94
|
}
|
|
64
95
|
|
package/src/lib/wiki-search.js
CHANGED
|
@@ -126,7 +126,7 @@ function runWikiSearch({ projectPath, query, limit = DEFAULT_LIMIT }) {
|
|
|
126
126
|
}
|
|
127
127
|
if (!fs.existsSync(personalBrainPath) || !fs.statSync(personalBrainPath).isDirectory()) {
|
|
128
128
|
throw new ValidationError(
|
|
129
|
-
`No SDTK-WIKI personal brain found at ${personalBrainPath}. Run
|
|
129
|
+
`No SDTK-WIKI personal brain found at ${personalBrainPath}. Run "sdtk-wiki ingest <source-root>" and "sdtk-wiki compile --mode safe --apply" first. Advanced users can still use wiki extract/compile sidecar commands.`
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
|