mdkg 0.0.3 → 0.0.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 +181 -169
- package/dist/cli.js +1002 -624
- package/dist/commands/checkpoint.js +17 -6
- package/dist/commands/event.js +46 -0
- package/dist/commands/event_support.js +146 -0
- package/dist/commands/format.js +6 -7
- package/dist/commands/index.js +10 -4
- package/dist/commands/init.js +224 -16
- package/dist/commands/list.js +18 -1
- package/dist/commands/new.js +30 -5
- package/dist/commands/pack.js +194 -2
- package/dist/commands/query_output.js +84 -0
- package/dist/commands/search.js +22 -5
- package/dist/commands/show.js +26 -11
- package/dist/commands/skill.js +374 -0
- package/dist/commands/skill_mirror.js +290 -0
- package/dist/commands/skill_support.js +122 -0
- package/dist/commands/task.js +278 -0
- package/dist/commands/validate.js +106 -7
- package/dist/graph/edges.js +2 -2
- package/dist/graph/frontmatter.js +1 -0
- package/dist/graph/indexer.js +21 -0
- package/dist/graph/node.js +20 -4
- package/dist/graph/skills_index_cache.js +94 -0
- package/dist/graph/skills_indexer.js +160 -0
- package/dist/init/AGENTS.md +6 -41
- package/dist/init/AGENT_START.md +46 -0
- package/dist/init/CLAUDE.md +6 -35
- package/dist/init/CLI_COMMAND_MATRIX.md +29 -0
- package/dist/init/README.md +6 -4
- package/dist/init/core/HUMAN.md +36 -0
- package/dist/init/core/SOUL.md +257 -0
- package/dist/init/core/core.md +3 -1
- package/dist/init/core/rule-1-mdkg-conventions.md +9 -2
- package/dist/init/core/rule-3-cli-contract.md +81 -14
- package/dist/init/core/rule-4-repo-safety-and-ignores.md +9 -3
- package/dist/init/core/rule-6-templates-and-schemas.md +6 -2
- package/dist/init/llms.txt +17 -0
- package/dist/init/skills/SKILL.md.example +41 -0
- package/dist/init/templates/default/bug.md +1 -0
- package/dist/init/templates/default/chk.md +1 -0
- package/dist/init/templates/default/epic.md +1 -0
- package/dist/init/templates/default/feat.md +1 -0
- package/dist/init/templates/default/task.md +1 -0
- package/dist/init/templates/default/test.md +1 -0
- package/dist/pack/export_md.js +6 -0
- package/dist/pack/export_xml.js +6 -0
- package/dist/pack/pack.js +35 -0
- package/dist/util/argparse.js +36 -5
- package/dist/util/filter.js +18 -0
- package/dist/util/id.js +23 -0
- package/package.json +5 -2
package/dist/pack/pack.js
CHANGED
|
@@ -130,6 +130,24 @@ function buildPackNode(root, index, qid) {
|
|
|
130
130
|
function mergeWarnings(warnings, message) {
|
|
131
131
|
warnings.push(message);
|
|
132
132
|
}
|
|
133
|
+
function checkpointWorkspaceFromQid(qid) {
|
|
134
|
+
const [workspace] = qid.split(":");
|
|
135
|
+
return workspace ?? "root";
|
|
136
|
+
}
|
|
137
|
+
function resolveLatestCheckpointQid(index, workspace) {
|
|
138
|
+
const candidates = Object.values(index.nodes)
|
|
139
|
+
.filter((node) => node.ws === workspace && node.type === "checkpoint")
|
|
140
|
+
.sort((a, b) => {
|
|
141
|
+
if (a.updated !== b.updated) {
|
|
142
|
+
return b.updated.localeCompare(a.updated);
|
|
143
|
+
}
|
|
144
|
+
if (a.created !== b.created) {
|
|
145
|
+
return b.created.localeCompare(a.created);
|
|
146
|
+
}
|
|
147
|
+
return b.qid.localeCompare(a.qid);
|
|
148
|
+
});
|
|
149
|
+
return candidates[0]?.qid;
|
|
150
|
+
}
|
|
133
151
|
function applyMaxNodes(orderedQids, maxNodes, truncation) {
|
|
134
152
|
if (maxNodes <= 0 || orderedQids.length <= maxNodes) {
|
|
135
153
|
return { included: orderedQids, dropped: [] };
|
|
@@ -142,7 +160,22 @@ function applyMaxNodes(orderedQids, maxNodes, truncation) {
|
|
|
142
160
|
}
|
|
143
161
|
function buildPack(options) {
|
|
144
162
|
const warnings = [];
|
|
163
|
+
const includeLatestCheckpoint = options.includeLatestCheckpoint ?? true;
|
|
145
164
|
const { qids, depths } = collectNodes(options.index, options.rootQid, options.depth, options.edges);
|
|
165
|
+
const workspace = checkpointWorkspaceFromQid(options.rootQid);
|
|
166
|
+
const latestCheckpointHint = options.index.meta.latest_checkpoint_qid?.[workspace];
|
|
167
|
+
const latestCheckpointResolved = includeLatestCheckpoint
|
|
168
|
+
? resolveLatestCheckpointQid(options.index, workspace)
|
|
169
|
+
: undefined;
|
|
170
|
+
if (latestCheckpointResolved && latestCheckpointResolved !== options.rootQid) {
|
|
171
|
+
qids.add(latestCheckpointResolved);
|
|
172
|
+
}
|
|
173
|
+
if (includeLatestCheckpoint &&
|
|
174
|
+
latestCheckpointHint &&
|
|
175
|
+
latestCheckpointResolved &&
|
|
176
|
+
latestCheckpointHint !== latestCheckpointResolved) {
|
|
177
|
+
mergeWarnings(warnings, `latest_checkpoint_qid hint mismatch for ${workspace}: ${latestCheckpointHint} -> ${latestCheckpointResolved}`);
|
|
178
|
+
}
|
|
146
179
|
if (options.verbose) {
|
|
147
180
|
const coreIds = (0, verbose_core_1.readVerboseCoreList)(options.verboseCoreListPath);
|
|
148
181
|
for (const id of coreIds) {
|
|
@@ -173,6 +206,8 @@ function buildPack(options) {
|
|
|
173
206
|
verbose: options.verbose,
|
|
174
207
|
generated_at: new Date().toISOString(),
|
|
175
208
|
node_count: nodes.length,
|
|
209
|
+
latest_checkpoint_qid: latestCheckpointResolved,
|
|
210
|
+
latest_checkpoint_qid_hint: latestCheckpointHint,
|
|
176
211
|
truncated: truncation,
|
|
177
212
|
},
|
|
178
213
|
nodes,
|
package/dist/util/argparse.js
CHANGED
|
@@ -36,6 +36,24 @@ const VALUE_FLAGS = new Set([
|
|
|
36
36
|
"--max-tokens",
|
|
37
37
|
"--stats-out",
|
|
38
38
|
"--truncation-report",
|
|
39
|
+
"--description",
|
|
40
|
+
"--authors",
|
|
41
|
+
"--links",
|
|
42
|
+
"--tags-mode",
|
|
43
|
+
"--run-id",
|
|
44
|
+
"--note",
|
|
45
|
+
"--add-artifacts",
|
|
46
|
+
"--add-links",
|
|
47
|
+
"--add-refs",
|
|
48
|
+
"--add-skills",
|
|
49
|
+
"--add-tags",
|
|
50
|
+
"--add-blocked-by",
|
|
51
|
+
"--checkpoint",
|
|
52
|
+
"--kind",
|
|
53
|
+
"--notes",
|
|
54
|
+
"--agent",
|
|
55
|
+
"--skill",
|
|
56
|
+
"--tool",
|
|
39
57
|
]);
|
|
40
58
|
const BOOLEAN_FLAGS = new Set([
|
|
41
59
|
"--tolerant",
|
|
@@ -44,14 +62,17 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
44
62
|
"--quiet",
|
|
45
63
|
"--no-cache",
|
|
46
64
|
"--no-reindex",
|
|
65
|
+
"--no-update-ignores",
|
|
47
66
|
"--force",
|
|
48
67
|
"--update-gitignore",
|
|
49
68
|
"--update-npmignore",
|
|
50
69
|
"--update-dockerignore",
|
|
70
|
+
"--agent",
|
|
51
71
|
"--agents",
|
|
52
72
|
"--claude",
|
|
53
73
|
"--llm",
|
|
54
74
|
"--body",
|
|
75
|
+
"--meta",
|
|
55
76
|
"--strip-code",
|
|
56
77
|
"--stats",
|
|
57
78
|
"--concise",
|
|
@@ -59,10 +80,14 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
59
80
|
"--dry-run",
|
|
60
81
|
"--json",
|
|
61
82
|
"--list-profiles",
|
|
83
|
+
"--with-scripts",
|
|
84
|
+
"--clear-blocked-by",
|
|
85
|
+
"--no-update-gitignore",
|
|
62
86
|
]);
|
|
63
87
|
const FLAG_ALIASES = {
|
|
64
88
|
"--o": "--out",
|
|
65
89
|
"-o": "--out",
|
|
90
|
+
"--profile": "--pack-profile",
|
|
66
91
|
"--f": "--format",
|
|
67
92
|
"-f": "--format",
|
|
68
93
|
"--v": "--verbose",
|
|
@@ -143,13 +168,15 @@ function parseArgs(argv) {
|
|
|
143
168
|
result.flags[flag] = value;
|
|
144
169
|
continue;
|
|
145
170
|
}
|
|
146
|
-
if (BOOLEAN_FLAGS.has(flag)) {
|
|
147
|
-
result.flags[flag] = true;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
171
|
const value = inlineValue ?? argv[i + 1];
|
|
151
|
-
|
|
172
|
+
const supportsValue = VALUE_FLAGS.has(flag);
|
|
173
|
+
const supportsBoolean = BOOLEAN_FLAGS.has(flag);
|
|
174
|
+
if (supportsValue) {
|
|
152
175
|
if (value === undefined || isFlagToken(value)) {
|
|
176
|
+
if (supportsBoolean) {
|
|
177
|
+
result.flags[flag] = true;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
153
180
|
result.flags[flag] = true;
|
|
154
181
|
continue;
|
|
155
182
|
}
|
|
@@ -159,6 +186,10 @@ function parseArgs(argv) {
|
|
|
159
186
|
result.flags[flag] = NORMALIZE_VALUE_FLAGS.has(flag) ? value.toLowerCase() : value;
|
|
160
187
|
continue;
|
|
161
188
|
}
|
|
189
|
+
if (supportsBoolean) {
|
|
190
|
+
result.flags[flag] = true;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
162
193
|
if (value === undefined || isFlagToken(value)) {
|
|
163
194
|
result.flags[flag] = true;
|
|
164
195
|
continue;
|
package/dist/util/filter.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filterNodes = filterNodes;
|
|
4
|
+
function matchesTags(nodeTags, filterTags, mode) {
|
|
5
|
+
if (!filterTags || filterTags.length === 0) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (nodeTags.length === 0) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const nodeSet = new Set(nodeTags.map((value) => value.toLowerCase()));
|
|
12
|
+
if (mode === "all") {
|
|
13
|
+
return filterTags.every((value) => nodeSet.has(value));
|
|
14
|
+
}
|
|
15
|
+
return filterTags.some((value) => nodeSet.has(value));
|
|
16
|
+
}
|
|
4
17
|
function filterNodes(nodes, filters) {
|
|
18
|
+
const normalizedTags = filters.tags?.map((value) => value.toLowerCase()).filter(Boolean) ?? [];
|
|
19
|
+
const tagsMode = filters.tagsMode ?? "any";
|
|
5
20
|
return nodes.filter((node) => {
|
|
6
21
|
if (filters.ws && node.ws !== filters.ws) {
|
|
7
22
|
return false;
|
|
@@ -21,6 +36,9 @@ function filterNodes(nodes, filters) {
|
|
|
21
36
|
if (filters.blocked && node.status !== "blocked") {
|
|
22
37
|
return false;
|
|
23
38
|
}
|
|
39
|
+
if (!matchesTags(node.tags, normalizedTags, tagsMode)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
24
42
|
return true;
|
|
25
43
|
});
|
|
26
44
|
}
|
package/dist/util/id.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCanonicalId = isCanonicalId;
|
|
4
|
+
exports.isCanonicalIdRef = isCanonicalIdRef;
|
|
5
|
+
const NUMERIC_ID_RE = /^[a-z]+-[0-9]+$/;
|
|
6
|
+
const WORKSPACE_RE = /^[a-z][a-z0-9_]*$/;
|
|
7
|
+
const SPECIAL_IDS = new Set(["rule-guide", "rule-soul", "rule-human"]);
|
|
8
|
+
function isCanonicalId(value) {
|
|
9
|
+
return NUMERIC_ID_RE.test(value) || SPECIAL_IDS.has(value);
|
|
10
|
+
}
|
|
11
|
+
function isCanonicalIdRef(value) {
|
|
12
|
+
const normalized = value.toLowerCase();
|
|
13
|
+
const parts = normalized.split(":");
|
|
14
|
+
if (parts.length === 1) {
|
|
15
|
+
return isCanonicalId(parts[0] ?? "");
|
|
16
|
+
}
|
|
17
|
+
if (parts.length !== 2) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const workspace = parts[0] ?? "";
|
|
21
|
+
const id = parts[1] ?? "";
|
|
22
|
+
return WORKSPACE_RE.test(workspace) && isCanonicalId(id);
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdkg",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Markdown Knowledge Graph",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"build": "tsc -p tsconfig.build.json && node scripts/add-shebang.js && node scripts/copy-init-assets.js",
|
|
11
11
|
"build:test": "tsc -p tsconfig.test.json",
|
|
12
12
|
"test": "npm run build && npm run build:test && node --test dist/tests/**/*.test.js",
|
|
13
|
-
"
|
|
13
|
+
"test:coverage": "npm run build && npm run build:test && node --test --experimental-test-coverage dist/tests/**/*.test.js",
|
|
14
|
+
"smoke:consumer": "npm run build && node scripts/smoke-consumer.js",
|
|
15
|
+
"cli:snapshot": "npm run build && node scripts/cli_help_snapshot.js",
|
|
16
|
+
"cli:check": "npm run build && node scripts/cli_help_snapshot.js --check"
|
|
14
17
|
},
|
|
15
18
|
"devDependencies": {
|
|
16
19
|
"@types/node": "^18.19.0",
|