sdtk-wiki-kit 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,12 @@
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
5
  const { CliError, ValidationError } = require("../lib/errors");
6
- const { runWikiCompileDryRun } = require("../lib/wiki-compile");
6
+ const { runWikiCompileApply, runWikiCompileDryRun } = require("../lib/wiki-compile");
7
7
  const { runWikiDiscoverPlan } = require("../lib/wiki-discover");
8
+ const { runWikiExtractDryRun } = require("../lib/wiki-extract");
8
9
  const { ingestLocalSource } = require("../lib/wiki-ingest");
9
10
  const { runWikiPruneDryRun } = require("../lib/wiki-prune");
10
- const { COMPILE_FLAG_DEFS, DISCOVER_FLAG_DEFS, PRUNE_FLAG_DEFS, parseWikiFlags } = require("../lib/wiki-flags");
11
+ const { COMPILE_FLAG_DEFS, DISCOVER_FLAG_DEFS, EXTRACT_FLAG_DEFS, PRUNE_FLAG_DEFS, parseWikiFlags } = require("../lib/wiki-flags");
11
12
 
12
13
  function hasHelp(args) {
13
14
  return args.includes("-h") || args.includes("--help");
@@ -20,30 +21,53 @@ function cmdWikiHelp() {
20
21
  sdtk-wiki wiki prune --help
21
22
  sdtk-wiki wiki discover --help
22
23
  sdtk-wiki wiki compile --help
24
+ sdtk-wiki wiki extract --help
23
25
 
24
26
  Purpose:
25
27
  Native SDTK-WIKI command namespace.
26
28
 
27
29
  Deferred:
28
- web discover/fetch, compile/apply, destructive cleanup/archive, and payload snapshots remain deferred.
30
+ web discover/fetch, destructive cleanup/archive, and payload snapshots remain deferred.
29
31
  Web discover/improve must not be enabled by default in R1.`);
30
32
  return 0;
31
33
  }
32
34
 
35
+ function cmdWikiExtractHelp() {
36
+ console.log(`Usage:
37
+ sdtk-wiki wiki extract --project-path <path> --source-root <path> --dry-run
38
+
39
+ Purpose:
40
+ Write a local semantic extraction dry-run report for SDTK-WIKI personal-brain generation.
41
+
42
+ Writes:
43
+ .sdtk/wiki/reports/semantic-extraction-dry-run-YYYYMMDD-HHMMSSZ.json
44
+
45
+ Safety:
46
+ Dry-run report only.
47
+ Local Markdown source roots only; remote URLs are rejected.
48
+ No personal-brain pages, managed pages, raw sources, provenance state, atlas compatibility files, web fetch, Ask, compile/apply, prune, delete, archive, or source files are modified.`);
49
+ return 0;
50
+ }
51
+
33
52
  function cmdWikiCompileHelp() {
34
53
  console.log(`Usage:
35
54
  sdtk-wiki wiki compile --plan <path> --project-path <path> --dry-run
55
+ sdtk-wiki wiki compile --plan <compile-apply-plan.json> --project-path <path> --apply --yes
36
56
 
37
57
  Purpose:
38
- Write a compile dry-run preview from a local markdown or JSON plan.
58
+ Write a compile dry-run preview and machine-readable apply plan, or explicitly apply an approved apply plan.
39
59
 
40
60
  Writes:
41
61
  .sdtk/wiki/reports/compile-dry-run-preview-YYYY-MM-DD.md
62
+ .sdtk/wiki/reports/compile-apply-plan-YYYY-MM-DD.json
63
+ .sdtk/wiki/personal-brain/... only when --apply --yes is used with an apply JSON sidecar
42
64
 
43
65
  Safety:
44
- Preview-only.
45
- No --apply behavior is implemented in BK-126.
46
- No wiki page, raw source, provenance, atlas compatibility, discover, prune, query-history, or release mutation.
66
+ Dry-run remains preview-only.
67
+ Apply consumes only record_type sdtk_wiki_compile_apply_plan JSON sidecars.
68
+ Markdown plans and semantic extraction JSON are rejected for apply.
69
+ Apply is create-only or same-content no-op under .sdtk/wiki/personal-brain.
70
+ No delete, archive, rewrite, reorder, raw source, provenance, atlas compatibility, discover, prune, query-history, or release mutation.
47
71
  Unknown operation types are reported as unsupported_operation and cause a non-zero exit after the report is written.`);
48
72
  return 0;
49
73
  }
@@ -117,6 +141,10 @@ function parseDiscoverFlags(args) {
117
141
  return parseWikiFlags(args, DISCOVER_FLAG_DEFS);
118
142
  }
119
143
 
144
+ function parseExtractFlags(args) {
145
+ return parseWikiFlags(args, EXTRACT_FLAG_DEFS);
146
+ }
147
+
120
148
  function parseCompileFlags(args) {
121
149
  return parseWikiFlags(args, COMPILE_FLAG_DEFS);
122
150
  }
@@ -185,10 +213,27 @@ function cmdWikiCompile(args) {
185
213
  if (hasHelp(args)) return cmdWikiCompileHelp();
186
214
  const { flags } = parseCompileFlags(args);
187
215
  if (flags.apply) {
188
- throw new ValidationError("--apply is deferred to BK-127. BK-126 supports compile dry-run preview only. No project files were changed.");
216
+ if (!flags.yes) {
217
+ throw new ValidationError("sdtk-wiki wiki compile --apply requires --yes. No project files were changed.");
218
+ }
219
+ if (!flags.plan) {
220
+ throw new ValidationError("sdtk-wiki wiki compile --apply requires --plan <compile-apply-plan.json>. No project files were changed.");
221
+ }
222
+ const projectPath = ensureProjectPath(flags["project-path"]);
223
+ const result = runWikiCompileApply({ projectPath, planArg: flags.plan });
224
+
225
+ console.log(`[wiki] Compile apply plan: ${result.planPath}`);
226
+ console.log(`[wiki] Created files: ${result.created.length}`);
227
+ console.log(`[wiki] Unchanged files: ${result.unchanged.length}`);
228
+ console.log(`[wiki] Source-quality warnings: ${result.sourceQualityWarningCount}`);
229
+ if (result.sourceQualityWarningCount > 0) {
230
+ console.log("[wiki] Source-quality findings were present in the apply plan; pages were still applied because --yes was explicit.");
231
+ }
232
+ console.log("[wiki] No source files, raw sources, provenance descriptors, or atlas compatibility files were modified.");
233
+ return 0;
189
234
  }
190
235
  if (!flags["dry-run"]) {
191
- throw new ValidationError("sdtk-wiki wiki compile requires --dry-run in BK-126. No project files were changed.");
236
+ throw new ValidationError("sdtk-wiki wiki compile requires --dry-run or --apply --yes. No project files were changed.");
192
237
  }
193
238
  if (!flags.plan) {
194
239
  throw new ValidationError("sdtk-wiki wiki compile requires --plan <path>. No project files were changed.");
@@ -197,6 +242,7 @@ function cmdWikiCompile(args) {
197
242
  const result = runWikiCompileDryRun({ projectPath, planArg: flags.plan });
198
243
 
199
244
  console.log(`[wiki] Compile dry-run preview: ${result.reportPath}`);
245
+ console.log(`[wiki] Compile apply JSON sidecar: ${result.applyPlanPath}`);
200
246
  console.log(`[wiki] Operations: ${result.operations.length}`);
201
247
  console.log(`[wiki] Unsupported operations: ${result.unsupportedCount}`);
202
248
  console.log("[wiki] No wiki pages, raw sources, provenance, or atlas compatibility files were modified.");
@@ -209,6 +255,29 @@ function cmdWikiCompile(args) {
209
255
  return 0;
210
256
  }
211
257
 
258
+ function cmdWikiExtract(args) {
259
+ if (hasHelp(args)) return cmdWikiExtractHelp();
260
+ const { flags } = parseExtractFlags(args);
261
+ if (!flags["dry-run"]) {
262
+ throw new ValidationError("sdtk-wiki wiki extract requires --dry-run. Runtime extraction writes a report only; no project files were changed.");
263
+ }
264
+ if (!flags["source-root"]) {
265
+ throw new ValidationError("sdtk-wiki wiki extract requires --source-root <path>. No project files were changed.");
266
+ }
267
+ const projectPath = ensureProjectPath(flags["project-path"]);
268
+ const result = runWikiExtractDryRun({ projectPath, sourceRootArg: flags["source-root"] });
269
+ const extraction = result.extraction;
270
+
271
+ console.log(`[wiki] Semantic extraction dry-run report: ${result.reportPath}`);
272
+ console.log(`[wiki] Sources scanned: ${extraction.source_counts.scanned}`);
273
+ console.log(`[wiki] Sources indexed: ${extraction.source_counts.indexed}`);
274
+ console.log(`[wiki] Tool candidates: ${extraction.tool_entities.length}`);
275
+ console.log(`[wiki] Concept candidates: ${extraction.concepts.length}`);
276
+ console.log(`[wiki] Quality findings: ${extraction.source_quality_findings.length}`);
277
+ console.log("[wiki] No personal-brain pages, raw sources, provenance state, or atlas compatibility files were modified.");
278
+ return 0;
279
+ }
280
+
212
281
  function cmdWiki(args) {
213
282
  if (!args || args.length === 0) {
214
283
  return cmdWikiHelp();
@@ -230,6 +299,9 @@ function cmdWiki(args) {
230
299
  if (subcommand === "compile") {
231
300
  return cmdWikiCompile(rest);
232
301
  }
302
+ if (subcommand === "extract") {
303
+ return cmdWikiExtract(rest);
304
+ }
233
305
 
234
306
  throw new CliError(
235
307
  `Unknown wiki command: "${subcommand}". Run "sdtk-wiki wiki --help". No project files were changed.`,
@@ -243,6 +315,8 @@ module.exports = {
243
315
  cmdWikiCompileHelp,
244
316
  cmdWikiDiscover,
245
317
  cmdWikiDiscoverHelp,
318
+ cmdWikiExtract,
319
+ cmdWikiExtractHelp,
246
320
  cmdWikiHelp,
247
321
  cmdWikiIngest,
248
322
  cmdWikiIngestHelp,
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ 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 { cmdSearch } = require("./commands/search");
8
9
  const { cmdWiki } = require("./commands/wiki");
9
10
  const { ValidationError } = require("./lib/errors");
10
11
 
@@ -29,7 +30,7 @@ function parseCommand(argv) {
29
30
  return { command: first, args: rest };
30
31
  }
31
32
 
32
- const COMMANDS = new Set(["help", "version", "init", "atlas", "wiki", "ask", "lint"]);
33
+ const COMMANDS = new Set(["help", "version", "init", "atlas", "wiki", "ask", "lint", "search"]);
33
34
 
34
35
  async function run(argv) {
35
36
  const { command, args } = parseCommand(argv);
@@ -56,6 +57,8 @@ async function run(argv) {
56
57
  return cmdAsk(args);
57
58
  case "lint":
58
59
  return cmdLint(args);
60
+ case "search":
61
+ return cmdSearch(args);
59
62
  }
60
63
  }
61
64