mdkg 0.0.2 → 0.0.4
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 +171 -151
- package/dist/cli.js +920 -422
- package/dist/commands/checkpoint.js +17 -6
- package/dist/commands/doctor.js +156 -0
- 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 +202 -11
- package/dist/commands/list.js +18 -1
- package/dist/commands/new.js +30 -5
- package/dist/commands/pack.js +332 -10
- 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 +359 -0
- package/dist/commands/skill_support.js +121 -0
- package/dist/commands/task.js +270 -0
- package/dist/commands/validate.js +104 -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/README.md +43 -0
- package/dist/init/core/rule-1-mdkg-conventions.md +9 -2
- package/dist/init/core/rule-3-cli-contract.md +73 -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/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/budget.js +186 -0
- package/dist/pack/export_md.js +17 -1
- package/dist/pack/export_xml.js +15 -0
- package/dist/pack/metrics.js +66 -0
- package/dist/pack/pack.js +35 -0
- package/dist/pack/profile.js +222 -0
- package/dist/pack/stats.js +37 -0
- package/dist/templates/headings.js +34 -0
- package/dist/util/argparse.js +47 -1
- package/dist/util/filter.js +18 -0
- package/dist/util/id.js +23 -0
- package/dist/util/output.js +2 -2
- package/package.json +6 -2
package/dist/util/argparse.js
CHANGED
|
@@ -29,15 +29,40 @@ const VALUE_FLAGS = new Set([
|
|
|
29
29
|
"--supersedes",
|
|
30
30
|
"--cases",
|
|
31
31
|
"--mdkg-dir",
|
|
32
|
+
"--pack-profile",
|
|
33
|
+
"--max-code-lines",
|
|
34
|
+
"--max-chars",
|
|
35
|
+
"--max-lines",
|
|
36
|
+
"--max-tokens",
|
|
37
|
+
"--stats-out",
|
|
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",
|
|
32
57
|
]);
|
|
33
58
|
const BOOLEAN_FLAGS = new Set([
|
|
34
59
|
"--tolerant",
|
|
35
60
|
"--blocked",
|
|
36
|
-
"--body",
|
|
37
61
|
"--verbose",
|
|
38
62
|
"--quiet",
|
|
39
63
|
"--no-cache",
|
|
40
64
|
"--no-reindex",
|
|
65
|
+
"--no-update-ignores",
|
|
41
66
|
"--force",
|
|
42
67
|
"--update-gitignore",
|
|
43
68
|
"--update-npmignore",
|
|
@@ -45,10 +70,24 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
45
70
|
"--agents",
|
|
46
71
|
"--claude",
|
|
47
72
|
"--llm",
|
|
73
|
+
"--omni",
|
|
74
|
+
"--body",
|
|
75
|
+
"--meta",
|
|
76
|
+
"--strip-code",
|
|
77
|
+
"--stats",
|
|
78
|
+
"--concise",
|
|
79
|
+
"--version",
|
|
80
|
+
"--dry-run",
|
|
81
|
+
"--json",
|
|
82
|
+
"--list-profiles",
|
|
83
|
+
"--with-scripts",
|
|
84
|
+
"--clear-blocked-by",
|
|
85
|
+
"--no-update-gitignore",
|
|
48
86
|
]);
|
|
49
87
|
const FLAG_ALIASES = {
|
|
50
88
|
"--o": "--out",
|
|
51
89
|
"-o": "--out",
|
|
90
|
+
"--profile": "--pack-profile",
|
|
52
91
|
"--f": "--format",
|
|
53
92
|
"-f": "--format",
|
|
54
93
|
"--v": "--verbose",
|
|
@@ -63,6 +102,8 @@ const FLAG_ALIASES = {
|
|
|
63
102
|
"-r": "--root",
|
|
64
103
|
"--q": "--quiet",
|
|
65
104
|
"-q": "--quiet",
|
|
105
|
+
"--V": "--version",
|
|
106
|
+
"-V": "--version",
|
|
66
107
|
};
|
|
67
108
|
function normalizeFlag(flag) {
|
|
68
109
|
return FLAG_ALIASES[flag] ?? flag;
|
|
@@ -89,6 +130,7 @@ function isFlagToken(token) {
|
|
|
89
130
|
function parseArgs(argv) {
|
|
90
131
|
const result = {
|
|
91
132
|
help: false,
|
|
133
|
+
version: false,
|
|
92
134
|
positionals: [],
|
|
93
135
|
flags: {},
|
|
94
136
|
};
|
|
@@ -98,6 +140,10 @@ function parseArgs(argv) {
|
|
|
98
140
|
result.help = true;
|
|
99
141
|
continue;
|
|
100
142
|
}
|
|
143
|
+
if (arg === "--version" || arg === "-V") {
|
|
144
|
+
result.version = true;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
101
147
|
let normalizedArg = arg;
|
|
102
148
|
if (normalizedArg.startsWith("-") && !normalizedArg.startsWith("--")) {
|
|
103
149
|
if (normalizedArg.length === 2) {
|
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/dist/util/output.js
CHANGED
|
@@ -40,8 +40,8 @@ function formatTimestampForFilename(date, useUtc = false) {
|
|
|
40
40
|
pad(millis, 3),
|
|
41
41
|
].join("");
|
|
42
42
|
}
|
|
43
|
-
function buildDefaultPackPath(root, rootId, format, verbose, now) {
|
|
44
|
-
const kind = verbose ? "verbose" : "standard";
|
|
43
|
+
function buildDefaultPackPath(root, rootId, format, verbose, now, profile = "standard") {
|
|
44
|
+
const kind = verbose ? "verbose" : sanitizeFilename(profile.toLowerCase() || "standard");
|
|
45
45
|
const safeId = sanitizeFilename(rootId.toLowerCase());
|
|
46
46
|
const safeFormat = sanitizeFilename(format.toLowerCase());
|
|
47
47
|
const timestamp = formatTimestampForFilename(now);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdkg",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Markdown Knowledge Graph",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
"scripts": {
|
|
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
|
-
"test": "npm run build && npm run build:test && node --test dist/tests/**/*.test.js"
|
|
12
|
+
"test": "npm run build && npm run build:test && node --test dist/tests/**/*.test.js",
|
|
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"
|
|
13
17
|
},
|
|
14
18
|
"devDependencies": {
|
|
15
19
|
"@types/node": "^18.19.0",
|