sdtk-wiki-kit 0.2.0 → 0.2.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 +8 -0
- package/assets/atlas/build_atlas.py +775 -775
- package/assets/atlas/doc_atlas_viewer_template.html +4054 -3796
- package/assets/atlas/vendor/mermaid.min.js +2029 -2029
- package/bin/sdtk-wiki.js +0 -0
- package/package.json +45 -45
- package/src/commands/ask.js +2 -0
- package/src/commands/context.js +67 -67
- package/src/commands/help.js +7 -0
- package/src/commands/init.js +1 -1
- package/src/commands/update.js +11 -0
- package/src/index.js +111 -107
- package/src/lib/update.js +217 -0
- package/src/lib/wiki-ask.js +254 -19
- package/src/lib/wiki-config.js +3 -1
- package/src/lib/wiki-context-pack.js +267 -267
package/bin/sdtk-wiki.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sdtk-wiki-kit",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Project-local wiki and knowledge graph toolkit for SDTK workspaces.",
|
|
5
|
-
"bin": {
|
|
6
|
-
"sdtk-wiki": "bin/sdtk-wiki.js"
|
|
7
|
-
},
|
|
8
|
-
"main": "src/index.js",
|
|
9
|
-
"type": "commonjs",
|
|
10
|
-
"files": [
|
|
11
|
-
"bin/",
|
|
12
|
-
"src/",
|
|
13
|
-
"assets/keys/sdtk-entitlement-public.pem",
|
|
14
|
-
"assets/atlas/build_atlas.py",
|
|
15
|
-
"assets/atlas/doc_atlas_viewer_template.html",
|
|
16
|
-
"assets/atlas/vendor/mermaid.min.js"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_wiki_cli tests.test_sdtk_wiki_context\"",
|
|
20
|
-
"pack:smoke": "npm pack --dry-run"
|
|
21
|
-
},
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": ">=18.13.0"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"sdtk-wiki",
|
|
27
|
-
"wiki",
|
|
28
|
-
"knowledge-graph",
|
|
29
|
-
"cli",
|
|
30
|
-
"toolkit"
|
|
31
|
-
],
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/codexsdtk/sdtk-toolkit.git",
|
|
36
|
-
"directory": "products/sdtk-wiki/distribution/sdtk-wiki-kit"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-wiki/distribution/sdtk-wiki-kit",
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
|
|
41
|
-
},
|
|
42
|
-
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "sdtk-wiki-kit",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Project-local wiki and knowledge graph toolkit for SDTK workspaces.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"sdtk-wiki": "bin/sdtk-wiki.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"type": "commonjs",
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"assets/keys/sdtk-entitlement-public.pem",
|
|
14
|
+
"assets/atlas/build_atlas.py",
|
|
15
|
+
"assets/atlas/doc_atlas_viewer_template.html",
|
|
16
|
+
"assets/atlas/vendor/mermaid.min.js"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_wiki_cli tests.test_sdtk_wiki_context\"",
|
|
20
|
+
"pack:smoke": "npm pack --dry-run"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.13.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"sdtk-wiki",
|
|
27
|
+
"wiki",
|
|
28
|
+
"knowledge-graph",
|
|
29
|
+
"cli",
|
|
30
|
+
"toolkit"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/codexsdtk/sdtk-toolkit.git",
|
|
36
|
+
"directory": "products/sdtk-wiki/distribution/sdtk-wiki-kit"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-wiki/distribution/sdtk-wiki-kit",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/commands/ask.js
CHANGED
|
@@ -57,6 +57,8 @@ Inputs:
|
|
|
57
57
|
Behavior:
|
|
58
58
|
Executes a local premium wiki.ask runtime pack when entitlement and graph preconditions pass.
|
|
59
59
|
Fails closed when the graph, entitlement, or runtime pack is missing.
|
|
60
|
+
--source grounds on the chosen doc plus its directly-related siblings (docs sharing
|
|
61
|
+
the same BK issue, knowledge id, skill, or family), bounded and labelled as related.
|
|
60
62
|
Query history is off by default.
|
|
61
63
|
--save-query writes one redacted JSON record under .sdtk/wiki/queries after a successful answer.
|
|
62
64
|
Full question and full answer are not stored by default.`);
|
package/src/commands/context.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { parseFlags } = require("../lib/args");
|
|
4
|
-
const { ValidationError } = require("../lib/errors");
|
|
5
|
-
const { writeContextPack } = require("../lib/wiki-context-pack");
|
|
6
|
-
|
|
7
|
-
const CONTEXT_FLAG_DEFS = {
|
|
8
|
-
help: { type: "boolean", alias: "h" },
|
|
9
|
-
topic: { type: "string" },
|
|
10
|
-
budget: { type: "string" },
|
|
11
|
-
"project-path": { type: "string" },
|
|
12
|
-
out: { type: "string" },
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function parseContextFlags(args) {
|
|
16
|
-
return parseFlags(args || [], CONTEXT_FLAG_DEFS);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function printContextHelp() {
|
|
20
|
-
console.log(`SDTK-WIKI Context Pack
|
|
21
|
-
|
|
22
|
-
Usage:
|
|
23
|
-
sdtk-wiki context --topic launch --budget 4000 --project-path .
|
|
24
|
-
|
|
25
|
-
Purpose:
|
|
26
|
-
Write a budgeted, source-linked context pack for compact/resume handoff.
|
|
27
|
-
|
|
28
|
-
Behavior:
|
|
29
|
-
Local-only. No network, no iii-sdk, no raw prompt dump.`);
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function parseBudget(value) {
|
|
34
|
-
if (value === undefined) {
|
|
35
|
-
return 4000;
|
|
36
|
-
}
|
|
37
|
-
const budget = Number(value);
|
|
38
|
-
if (!Number.isInteger(budget) || budget <= 0) {
|
|
39
|
-
throw new ValidationError("--budget must be a positive integer.");
|
|
40
|
-
}
|
|
41
|
-
return budget;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function cmdContext(args) {
|
|
45
|
-
const { flags } = parseContextFlags(args || []);
|
|
46
|
-
if (flags.help) {
|
|
47
|
-
return printContextHelp();
|
|
48
|
-
}
|
|
49
|
-
if (!flags.topic || !String(flags.topic).trim()) {
|
|
50
|
-
throw new ValidationError("--topic is required.");
|
|
51
|
-
}
|
|
52
|
-
const result = writeContextPack(flags["project-path"], {
|
|
53
|
-
topic: flags.topic,
|
|
54
|
-
budget: parseBudget(flags.budget),
|
|
55
|
-
out: flags.out,
|
|
56
|
-
});
|
|
57
|
-
console.log(
|
|
58
|
-
`Context pack: ${result.selected} items, ${result.pinned} pinned, ${result.tokens}/${result.budget} tokens, ${result.pagedOut} paged out -> ${result.path}`
|
|
59
|
-
);
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = {
|
|
64
|
-
cmdContext,
|
|
65
|
-
parseContextFlags,
|
|
66
|
-
printContextHelp,
|
|
67
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { parseFlags } = require("../lib/args");
|
|
4
|
+
const { ValidationError } = require("../lib/errors");
|
|
5
|
+
const { writeContextPack } = require("../lib/wiki-context-pack");
|
|
6
|
+
|
|
7
|
+
const CONTEXT_FLAG_DEFS = {
|
|
8
|
+
help: { type: "boolean", alias: "h" },
|
|
9
|
+
topic: { type: "string" },
|
|
10
|
+
budget: { type: "string" },
|
|
11
|
+
"project-path": { type: "string" },
|
|
12
|
+
out: { type: "string" },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function parseContextFlags(args) {
|
|
16
|
+
return parseFlags(args || [], CONTEXT_FLAG_DEFS);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function printContextHelp() {
|
|
20
|
+
console.log(`SDTK-WIKI Context Pack
|
|
21
|
+
|
|
22
|
+
Usage:
|
|
23
|
+
sdtk-wiki context --topic launch --budget 4000 --project-path .
|
|
24
|
+
|
|
25
|
+
Purpose:
|
|
26
|
+
Write a budgeted, source-linked context pack for compact/resume handoff.
|
|
27
|
+
|
|
28
|
+
Behavior:
|
|
29
|
+
Local-only. No network, no iii-sdk, no raw prompt dump.`);
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function parseBudget(value) {
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return 4000;
|
|
36
|
+
}
|
|
37
|
+
const budget = Number(value);
|
|
38
|
+
if (!Number.isInteger(budget) || budget <= 0) {
|
|
39
|
+
throw new ValidationError("--budget must be a positive integer.");
|
|
40
|
+
}
|
|
41
|
+
return budget;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function cmdContext(args) {
|
|
45
|
+
const { flags } = parseContextFlags(args || []);
|
|
46
|
+
if (flags.help) {
|
|
47
|
+
return printContextHelp();
|
|
48
|
+
}
|
|
49
|
+
if (!flags.topic || !String(flags.topic).trim()) {
|
|
50
|
+
throw new ValidationError("--topic is required.");
|
|
51
|
+
}
|
|
52
|
+
const result = writeContextPack(flags["project-path"], {
|
|
53
|
+
topic: flags.topic,
|
|
54
|
+
budget: parseBudget(flags.budget),
|
|
55
|
+
out: flags.out,
|
|
56
|
+
});
|
|
57
|
+
console.log(
|
|
58
|
+
`Context pack: ${result.selected} items, ${result.pinned} pinned, ${result.tokens}/${result.budget} tokens, ${result.pagedOut} paged out -> ${result.path}`
|
|
59
|
+
);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
cmdContext,
|
|
65
|
+
parseContextFlags,
|
|
66
|
+
printContextHelp,
|
|
67
|
+
};
|
package/src/commands/help.js
CHANGED
|
@@ -24,6 +24,7 @@ Usage:
|
|
|
24
24
|
sdtk-wiki ask --help
|
|
25
25
|
sdtk-wiki search --help
|
|
26
26
|
sdtk-wiki lint --help
|
|
27
|
+
sdtk-wiki update --check-only
|
|
27
28
|
|
|
28
29
|
Simple local wiki workflow:
|
|
29
30
|
sdtk-wiki init --no-open
|
|
@@ -31,6 +32,7 @@ Simple local wiki workflow:
|
|
|
31
32
|
sdtk-wiki compile --mode safe [--apply]
|
|
32
33
|
sdtk-wiki query "<query>"
|
|
33
34
|
sdtk-wiki lint
|
|
35
|
+
sdtk-wiki update --check-only
|
|
34
36
|
sdtk-wiki discover --plan
|
|
35
37
|
sdtk-wiki maintain --mode safe
|
|
36
38
|
|
|
@@ -53,6 +55,11 @@ R1 command model:
|
|
|
53
55
|
ask Ask grounded questions over the built SDTK-WIKI graph.
|
|
54
56
|
search Search generated local wiki pages without premium Ask.
|
|
55
57
|
lint Write a report-first, non-destructive wiki lint report.
|
|
58
|
+
update Package-only updater; no wiki/.sdtk/wiki/.sdtk/atlas files are mutated in R1.
|
|
59
|
+
|
|
60
|
+
Update workflow:
|
|
61
|
+
sdtk-wiki update --check-only
|
|
62
|
+
npm install -g sdtk-wiki-kit@<version>
|
|
56
63
|
|
|
57
64
|
Advanced/audit workflow:
|
|
58
65
|
sdtk-wiki wiki extract --source-root <source-root> --dry-run
|
package/src/commands/init.js
CHANGED
|
@@ -32,7 +32,7 @@ BK-102 behavior:
|
|
|
32
32
|
Options:
|
|
33
33
|
--project-path <path> Project root. Defaults to current working directory.
|
|
34
34
|
--output-dir <path> Graph output dir under .sdtk/wiki. Defaults to .sdtk/wiki/graph.
|
|
35
|
-
--scan-root <path> Repeatable markdown scan root.
|
|
35
|
+
--scan-root <path> Repeatable markdown scan root. Defaults to ./docs if it exists, otherwise the project root.
|
|
36
36
|
--force Overwrite existing config.
|
|
37
37
|
--no-build Write config only.
|
|
38
38
|
--no-open Build graph but do not launch viewer.
|
package/src/index.js
CHANGED
|
@@ -1,107 +1,111 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { cmdAtlas } = require("./commands/atlas");
|
|
4
|
-
const { cmdAsk } = require("./commands/ask");
|
|
5
|
-
const { cmdHelp } = require("./commands/help");
|
|
6
|
-
const { cmdInit } = require("./commands/init");
|
|
7
|
-
const { cmdLint } = require("./commands/lint");
|
|
8
|
-
const {
|
|
9
|
-
cmdCompile,
|
|
10
|
-
cmdDiscover,
|
|
11
|
-
cmdIngest,
|
|
12
|
-
cmdMaintain,
|
|
13
|
-
cmdQuery,
|
|
14
|
-
} = require("./commands/operations");
|
|
15
|
-
const { cmdEnrich } = require("./commands/enrich");
|
|
16
|
-
const { cmdContext } = require("./commands/context");
|
|
17
|
-
const { cmdSearch } = require("./commands/search");
|
|
18
|
-
const {
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case "
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
case "
|
|
78
|
-
return
|
|
79
|
-
case "
|
|
80
|
-
return
|
|
81
|
-
case "
|
|
82
|
-
return
|
|
83
|
-
case "
|
|
84
|
-
return
|
|
85
|
-
case "
|
|
86
|
-
return
|
|
87
|
-
case "
|
|
88
|
-
return
|
|
89
|
-
case "
|
|
90
|
-
return
|
|
91
|
-
case "
|
|
92
|
-
return
|
|
93
|
-
case "
|
|
94
|
-
return
|
|
95
|
-
case "
|
|
96
|
-
return
|
|
97
|
-
case "
|
|
98
|
-
return
|
|
99
|
-
case "
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { cmdAtlas } = require("./commands/atlas");
|
|
4
|
+
const { cmdAsk } = require("./commands/ask");
|
|
5
|
+
const { cmdHelp } = require("./commands/help");
|
|
6
|
+
const { cmdInit } = require("./commands/init");
|
|
7
|
+
const { cmdLint } = require("./commands/lint");
|
|
8
|
+
const {
|
|
9
|
+
cmdCompile,
|
|
10
|
+
cmdDiscover,
|
|
11
|
+
cmdIngest,
|
|
12
|
+
cmdMaintain,
|
|
13
|
+
cmdQuery,
|
|
14
|
+
} = require("./commands/operations");
|
|
15
|
+
const { cmdEnrich } = require("./commands/enrich");
|
|
16
|
+
const { cmdContext } = require("./commands/context");
|
|
17
|
+
const { cmdSearch } = require("./commands/search");
|
|
18
|
+
const { cmdUpdate } = require("./commands/update");
|
|
19
|
+
const { cmdWiki } = require("./commands/wiki");
|
|
20
|
+
const { ValidationError } = require("./lib/errors");
|
|
21
|
+
|
|
22
|
+
function getVersion() {
|
|
23
|
+
const pkg = require("../package.json");
|
|
24
|
+
return pkg.version;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseCommand(argv) {
|
|
28
|
+
if (!argv || argv.length === 0) {
|
|
29
|
+
return { command: "help", args: [] };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const [first, ...rest] = argv;
|
|
33
|
+
if (first === "-h" || first === "--help") {
|
|
34
|
+
return { command: "help", args: [] };
|
|
35
|
+
}
|
|
36
|
+
if (first === "-v" || first === "--version") {
|
|
37
|
+
return { command: "version", args: [] };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { command: first, args: rest };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const COMMANDS = new Set([
|
|
44
|
+
"help",
|
|
45
|
+
"version",
|
|
46
|
+
"init",
|
|
47
|
+
"atlas",
|
|
48
|
+
"wiki",
|
|
49
|
+
"ask",
|
|
50
|
+
"lint",
|
|
51
|
+
"search",
|
|
52
|
+
"ingest",
|
|
53
|
+
"compile",
|
|
54
|
+
"query",
|
|
55
|
+
"discover",
|
|
56
|
+
"maintain",
|
|
57
|
+
"enrich",
|
|
58
|
+
"context",
|
|
59
|
+
"update",
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
async function run(argv) {
|
|
63
|
+
const { command, args } = parseCommand(argv);
|
|
64
|
+
|
|
65
|
+
if (!COMMANDS.has(command)) {
|
|
66
|
+
throw new ValidationError(
|
|
67
|
+
`Unknown command: "${command}". Run "sdtk-wiki --help" for available commands.`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
switch (command) {
|
|
72
|
+
case "help":
|
|
73
|
+
return cmdHelp();
|
|
74
|
+
case "version":
|
|
75
|
+
console.log(`sdtk-wiki-kit ${getVersion()}`);
|
|
76
|
+
return 0;
|
|
77
|
+
case "init":
|
|
78
|
+
return cmdInit(args);
|
|
79
|
+
case "atlas":
|
|
80
|
+
return cmdAtlas(args);
|
|
81
|
+
case "wiki":
|
|
82
|
+
return cmdWiki(args);
|
|
83
|
+
case "ask":
|
|
84
|
+
return cmdAsk(args);
|
|
85
|
+
case "lint":
|
|
86
|
+
return cmdLint(args);
|
|
87
|
+
case "search":
|
|
88
|
+
return cmdSearch(args);
|
|
89
|
+
case "ingest":
|
|
90
|
+
return cmdIngest(args);
|
|
91
|
+
case "compile":
|
|
92
|
+
return cmdCompile(args);
|
|
93
|
+
case "query":
|
|
94
|
+
return cmdQuery(args);
|
|
95
|
+
case "discover":
|
|
96
|
+
return cmdDiscover(args);
|
|
97
|
+
case "maintain":
|
|
98
|
+
return cmdMaintain(args);
|
|
99
|
+
case "enrich":
|
|
100
|
+
return cmdEnrich(args);
|
|
101
|
+
case "context":
|
|
102
|
+
return cmdContext(args);
|
|
103
|
+
case "update":
|
|
104
|
+
return cmdUpdate(args);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = {
|
|
109
|
+
parseCommand,
|
|
110
|
+
run,
|
|
111
|
+
};
|