mdkg 0.1.1 → 0.1.3
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/CHANGELOG.md +104 -0
- package/README.md +124 -18
- package/dist/cli.js +567 -15
- package/dist/commands/archive.js +486 -0
- package/dist/commands/bundle.js +743 -0
- package/dist/commands/bundle_import.js +255 -0
- package/dist/commands/capability.js +162 -0
- package/dist/commands/checkpoint.js +31 -5
- package/dist/commands/doctor.js +269 -9
- package/dist/commands/format.js +38 -9
- package/dist/commands/index.js +12 -12
- package/dist/commands/init.js +194 -63
- package/dist/commands/init_manifest.js +19 -6
- package/dist/commands/list.js +5 -2
- package/dist/commands/new.js +36 -7
- package/dist/commands/next.js +7 -0
- package/dist/commands/node_card.js +4 -1
- package/dist/commands/pack.js +62 -2
- package/dist/commands/query_output.js +1 -0
- package/dist/commands/search.js +5 -2
- package/dist/commands/show.js +7 -14
- package/dist/commands/skill_mirror.js +22 -0
- package/dist/commands/task.js +23 -6
- package/dist/commands/upgrade.js +24 -1
- package/dist/commands/validate.js +20 -1
- package/dist/commands/work.js +397 -0
- package/dist/commands/workspace.js +12 -2
- package/dist/core/config.js +115 -1
- package/dist/graph/agent_file_types.js +78 -5
- package/dist/graph/archive_file.js +125 -0
- package/dist/graph/archive_integrity.js +66 -0
- package/dist/graph/bundle_imports.js +418 -0
- package/dist/graph/capabilities_index_cache.js +103 -0
- package/dist/graph/capabilities_indexer.js +231 -0
- package/dist/graph/frontmatter.js +19 -0
- package/dist/graph/index_cache.js +23 -6
- package/dist/graph/indexer.js +4 -1
- package/dist/graph/node.js +23 -4
- package/dist/graph/node_body.js +37 -0
- package/dist/graph/reindex.js +46 -0
- package/dist/graph/skills_index_cache.js +2 -2
- package/dist/graph/skills_indexer.js +8 -3
- package/dist/graph/sqlite_index.js +293 -0
- package/dist/graph/validate_graph.js +83 -7
- package/dist/graph/visibility.js +214 -0
- package/dist/graph/workspace_files.js +22 -0
- package/dist/init/AGENT_START.md +24 -0
- package/dist/init/CLI_COMMAND_MATRIX.md +61 -3
- package/dist/init/README.md +70 -4
- package/dist/init/config.json +18 -2
- package/dist/init/core/guide.md +6 -2
- package/dist/init/core/rule-1-mdkg-conventions.md +2 -1
- package/dist/init/core/rule-3-cli-contract.md +72 -4
- package/dist/init/core/rule-4-repo-safety-and-ignores.md +47 -11
- package/dist/init/core/rule-5-release-and-versioning.md +4 -3
- package/dist/init/core/rule-6-templates-and-schemas.md +7 -0
- package/dist/init/init-manifest.json +21 -16
- package/dist/init/skills/default/build-pack-and-execute-task/SKILL.md +2 -1
- package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +26 -0
- package/dist/init/templates/default/archive.md +33 -0
- package/dist/init/templates/default/receipt.md +15 -1
- package/dist/init/templates/default/work.md +6 -1
- package/dist/init/templates/default/work_order.md +15 -1
- package/dist/pack/export_md.js +3 -0
- package/dist/pack/export_xml.js +3 -0
- package/dist/pack/order.js +1 -0
- package/dist/pack/pack.js +3 -13
- package/dist/util/argparse.js +30 -0
- package/dist/util/atomic.js +44 -0
- package/dist/util/lock.js +72 -0
- package/dist/util/refs.js +40 -0
- package/dist/util/zip.js +153 -0
- package/package.json +14 -5
package/dist/commands/doctor.js
CHANGED
|
@@ -8,32 +8,42 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const config_1 = require("../core/config");
|
|
10
10
|
const index_cache_1 = require("../graph/index_cache");
|
|
11
|
+
const capabilities_index_cache_1 = require("../graph/capabilities_index_cache");
|
|
12
|
+
const bundle_imports_1 = require("../graph/bundle_imports");
|
|
11
13
|
const node_1 = require("../graph/node");
|
|
12
14
|
const template_schema_1 = require("../graph/template_schema");
|
|
15
|
+
const visibility_1 = require("../graph/visibility");
|
|
16
|
+
const sqlite_index_1 = require("../graph/sqlite_index");
|
|
13
17
|
const errors_1 = require("../util/errors");
|
|
14
|
-
const REQUIRED_NODE_MAJOR =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const REQUIRED_NODE_MAJOR = 24;
|
|
19
|
+
const REQUIRED_NODE_MINOR = 15;
|
|
20
|
+
const ARCHIVE_RAW_ALLOWED_DIRS = new Set(["source"]);
|
|
21
|
+
function parseNodeVersion(version) {
|
|
22
|
+
const [majorRaw, minorRaw, patchRaw] = version.split(".");
|
|
23
|
+
const major = Number.parseInt(majorRaw ?? "", 10);
|
|
24
|
+
const minor = Number.parseInt(minorRaw ?? "", 10);
|
|
25
|
+
const patch = Number.parseInt(patchRaw ?? "", 10);
|
|
26
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor) || !Number.isInteger(patch)) {
|
|
18
27
|
return null;
|
|
19
28
|
}
|
|
20
|
-
return major;
|
|
29
|
+
return { major, minor, patch };
|
|
21
30
|
}
|
|
22
31
|
function runNodeVersionCheck() {
|
|
23
32
|
const nodeVersion = process.versions.node;
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
33
|
+
const parsed = parseNodeVersion(nodeVersion);
|
|
34
|
+
if (parsed === null) {
|
|
26
35
|
return {
|
|
27
36
|
name: "node-version",
|
|
28
37
|
ok: false,
|
|
29
38
|
detail: `unable to parse Node.js version: ${nodeVersion}`,
|
|
30
39
|
};
|
|
31
40
|
}
|
|
32
|
-
if (major < REQUIRED_NODE_MAJOR
|
|
41
|
+
if (parsed.major < REQUIRED_NODE_MAJOR ||
|
|
42
|
+
(parsed.major === REQUIRED_NODE_MAJOR && parsed.minor < REQUIRED_NODE_MINOR)) {
|
|
33
43
|
return {
|
|
34
44
|
name: "node-version",
|
|
35
45
|
ok: false,
|
|
36
|
-
detail: `Node.js ${nodeVersion} is unsupported (requires >=${REQUIRED_NODE_MAJOR})`,
|
|
46
|
+
detail: `Node.js ${nodeVersion} is unsupported (requires >=${REQUIRED_NODE_MAJOR}.${REQUIRED_NODE_MINOR}.0)`,
|
|
37
47
|
};
|
|
38
48
|
}
|
|
39
49
|
return {
|
|
@@ -42,6 +52,213 @@ function runNodeVersionCheck() {
|
|
|
42
52
|
detail: `Node.js ${nodeVersion} (ok)`,
|
|
43
53
|
};
|
|
44
54
|
}
|
|
55
|
+
function runSqliteCheck(root, config) {
|
|
56
|
+
if (!(0, sqlite_index_1.isSqliteBackend)(config)) {
|
|
57
|
+
return {
|
|
58
|
+
name: "sqlite-cache",
|
|
59
|
+
ok: true,
|
|
60
|
+
detail: "SQLite backend disabled; JSON cache backend active",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const health = (0, sqlite_index_1.sqliteHealth)(root, config);
|
|
64
|
+
if (health.errors.length > 0) {
|
|
65
|
+
return {
|
|
66
|
+
name: "sqlite-cache",
|
|
67
|
+
ok: false,
|
|
68
|
+
detail: health.errors.join("; "),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (health.warnings.length > 0) {
|
|
72
|
+
return {
|
|
73
|
+
name: "sqlite-cache",
|
|
74
|
+
ok: true,
|
|
75
|
+
level: "warn",
|
|
76
|
+
detail: health.warnings.join("; "),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
name: "sqlite-cache",
|
|
81
|
+
ok: true,
|
|
82
|
+
detail: `.mdkg SQLite cache ok (${health.size} bytes)`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function walkFiles(root) {
|
|
86
|
+
if (!fs_1.default.existsSync(root)) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const entries = fs_1.default.readdirSync(root, { withFileTypes: true });
|
|
90
|
+
const files = [];
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
const fullPath = path_1.default.join(root, entry.name);
|
|
93
|
+
if (entry.isDirectory()) {
|
|
94
|
+
files.push(...walkFiles(fullPath));
|
|
95
|
+
}
|
|
96
|
+
else if (entry.isFile()) {
|
|
97
|
+
files.push(fullPath);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return files;
|
|
101
|
+
}
|
|
102
|
+
function runArchiveStorageCheck(root) {
|
|
103
|
+
const archiveRoot = path_1.default.join(root, ".mdkg", "archive");
|
|
104
|
+
const files = walkFiles(archiveRoot);
|
|
105
|
+
const strayRaw = files
|
|
106
|
+
.filter((filePath) => {
|
|
107
|
+
const relative = path_1.default.relative(archiveRoot, filePath).split(path_1.default.sep);
|
|
108
|
+
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
109
|
+
if (ext === ".md" || ext === ".zip") {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return !relative.some((segment) => ARCHIVE_RAW_ALLOWED_DIRS.has(segment));
|
|
113
|
+
})
|
|
114
|
+
.map((filePath) => path_1.default.relative(root, filePath).split(path_1.default.sep).join("/"))
|
|
115
|
+
.sort();
|
|
116
|
+
if (strayRaw.length === 0) {
|
|
117
|
+
return {
|
|
118
|
+
name: "archive-storage",
|
|
119
|
+
ok: true,
|
|
120
|
+
detail: ".mdkg/archive has no stray raw files outside managed source directories",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
name: "archive-storage",
|
|
125
|
+
ok: true,
|
|
126
|
+
level: "warn",
|
|
127
|
+
detail: `stray uncompressed archive file(s) found without managed sidecars: ${strayRaw.join(", ")}; run \`mdkg archive add <file>\` or move raw files under a managed archive source directory`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function runArchiveLargeCacheCheck(root, warningBytes) {
|
|
131
|
+
if (warningBytes === 0) {
|
|
132
|
+
return {
|
|
133
|
+
name: "archive-large-cache",
|
|
134
|
+
ok: true,
|
|
135
|
+
detail: "archive large-cache warning disabled",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const archiveRoot = path_1.default.join(root, ".mdkg", "archive");
|
|
139
|
+
const largeCaches = walkFiles(archiveRoot)
|
|
140
|
+
.filter((filePath) => filePath.endsWith(".zip"))
|
|
141
|
+
.map((filePath) => ({
|
|
142
|
+
path: path_1.default.relative(root, filePath).split(path_1.default.sep).join("/"),
|
|
143
|
+
size: fs_1.default.statSync(filePath).size,
|
|
144
|
+
}))
|
|
145
|
+
.filter((entry) => entry.size > warningBytes)
|
|
146
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
147
|
+
if (largeCaches.length === 0) {
|
|
148
|
+
return {
|
|
149
|
+
name: "archive-large-cache",
|
|
150
|
+
ok: true,
|
|
151
|
+
detail: `no archive ZIP cache exceeds ${warningBytes} bytes`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
name: "archive-large-cache",
|
|
156
|
+
ok: true,
|
|
157
|
+
level: "warn",
|
|
158
|
+
detail: `archive ZIP cache(s) exceed ${warningBytes} bytes: ${largeCaches
|
|
159
|
+
.map((entry) => `${entry.path} (${entry.size} bytes)`)
|
|
160
|
+
.join(", ")}; keep large caches private or move bulky originals to repo policy-managed storage`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function runBundleStorageCheck(root, outputDir) {
|
|
164
|
+
const bundleRoot = path_1.default.resolve(root, outputDir);
|
|
165
|
+
if (!fs_1.default.existsSync(bundleRoot)) {
|
|
166
|
+
return {
|
|
167
|
+
name: "bundle-storage",
|
|
168
|
+
ok: true,
|
|
169
|
+
detail: `no bundle directory found; run \`mdkg bundle create --profile private\` when a snapshot should be tracked`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const bundles = walkFiles(bundleRoot)
|
|
173
|
+
.filter((filePath) => filePath.endsWith(".mdkg.zip"))
|
|
174
|
+
.map((filePath) => path_1.default.relative(root, filePath).split(path_1.default.sep).join("/"))
|
|
175
|
+
.sort();
|
|
176
|
+
if (bundles.length === 0) {
|
|
177
|
+
return {
|
|
178
|
+
name: "bundle-storage",
|
|
179
|
+
ok: true,
|
|
180
|
+
detail: `bundle directory has no .mdkg.zip files; run \`mdkg bundle create --profile private\` when a snapshot should be tracked`,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
name: "bundle-storage",
|
|
185
|
+
ok: true,
|
|
186
|
+
detail: `${bundles.length} bundle(s) found; run \`mdkg bundle verify <path>\` to check freshness before handoff`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function runBundleImportChecks(root, config) {
|
|
190
|
+
const projection = (0, bundle_imports_1.buildBundleImportsIndex)(root, config);
|
|
191
|
+
if (projection.index.imports.length === 0) {
|
|
192
|
+
return [
|
|
193
|
+
{
|
|
194
|
+
name: "bundle-imports",
|
|
195
|
+
ok: true,
|
|
196
|
+
detail: "no bundle imports configured",
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
return projection.index.imports.map((item) => {
|
|
201
|
+
if (!item.enabled) {
|
|
202
|
+
return {
|
|
203
|
+
name: `bundle-import:${item.alias}`,
|
|
204
|
+
ok: true,
|
|
205
|
+
level: "warn",
|
|
206
|
+
detail: `disabled import at ${item.path}`,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (item.error_count > 0) {
|
|
210
|
+
return {
|
|
211
|
+
name: `bundle-import:${item.alias}`,
|
|
212
|
+
ok: false,
|
|
213
|
+
detail: item.errors.join("; "),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (item.stale || item.warning_count > 0) {
|
|
217
|
+
return {
|
|
218
|
+
name: `bundle-import:${item.alias}`,
|
|
219
|
+
ok: true,
|
|
220
|
+
level: "warn",
|
|
221
|
+
detail: `import is stale or has warnings; run \`mdkg bundle import verify ${item.alias}\` (${item.warnings.join("; ")})`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
name: `bundle-import:${item.alias}`,
|
|
226
|
+
ok: true,
|
|
227
|
+
detail: `import loaded from ${item.path}`,
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function runVisibilityPolicyCheck(root, config, options) {
|
|
232
|
+
try {
|
|
233
|
+
const { index } = (0, index_cache_1.loadIndex)({
|
|
234
|
+
root,
|
|
235
|
+
config,
|
|
236
|
+
useCache: !options.noCache,
|
|
237
|
+
allowReindex: !options.noReindex,
|
|
238
|
+
});
|
|
239
|
+
const messages = (0, visibility_1.visibilityViolationMessages)((0, visibility_1.collectVisibilityViolations)(index, config));
|
|
240
|
+
if (messages.length === 0) {
|
|
241
|
+
return {
|
|
242
|
+
name: "visibility-policy",
|
|
243
|
+
ok: true,
|
|
244
|
+
detail: "public/internal records do not reference less-visible mdkg records",
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
name: "visibility-policy",
|
|
249
|
+
ok: false,
|
|
250
|
+
detail: `${messages.length} violation(s): ${messages.join("; ")}`,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
255
|
+
return {
|
|
256
|
+
name: "visibility-policy",
|
|
257
|
+
ok: false,
|
|
258
|
+
detail: message,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
45
262
|
function runDoctorCommand(options) {
|
|
46
263
|
const results = [];
|
|
47
264
|
results.push(runNodeVersionCheck());
|
|
@@ -78,6 +295,12 @@ function runDoctorCommand(options) {
|
|
|
78
295
|
});
|
|
79
296
|
}
|
|
80
297
|
if (config) {
|
|
298
|
+
results.push(runArchiveStorageCheck(options.root));
|
|
299
|
+
results.push(runArchiveLargeCacheCheck(options.root, config.archive.large_cache_warning_bytes));
|
|
300
|
+
results.push(runBundleStorageCheck(options.root, config.bundles.output_dir));
|
|
301
|
+
results.push(runSqliteCheck(options.root, config));
|
|
302
|
+
results.push(...runBundleImportChecks(options.root, config));
|
|
303
|
+
results.push(runVisibilityPolicyCheck(options.root, config, options));
|
|
81
304
|
try {
|
|
82
305
|
const templateSchemaInfo = (0, template_schema_1.loadTemplateSchemasWithInfo)(options.root, config, node_1.ALLOWED_TYPES);
|
|
83
306
|
results.push({
|
|
@@ -139,6 +362,43 @@ function runDoctorCommand(options) {
|
|
|
139
362
|
detail: message,
|
|
140
363
|
});
|
|
141
364
|
}
|
|
365
|
+
try {
|
|
366
|
+
const { rebuilt, stale } = (0, capabilities_index_cache_1.loadCapabilitiesIndex)({
|
|
367
|
+
root: options.root,
|
|
368
|
+
config,
|
|
369
|
+
useCache: !options.noCache,
|
|
370
|
+
allowReindex: !options.noReindex,
|
|
371
|
+
});
|
|
372
|
+
if (rebuilt) {
|
|
373
|
+
results.push({
|
|
374
|
+
name: "capabilities-index",
|
|
375
|
+
ok: true,
|
|
376
|
+
detail: "capabilities cache rebuilt and loaded",
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
else if (stale) {
|
|
380
|
+
results.push({
|
|
381
|
+
name: "capabilities-index",
|
|
382
|
+
ok: true,
|
|
383
|
+
detail: "capabilities cache is stale (run mdkg index to refresh)",
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
results.push({
|
|
388
|
+
name: "capabilities-index",
|
|
389
|
+
ok: true,
|
|
390
|
+
detail: "capabilities cache loaded",
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
396
|
+
results.push({
|
|
397
|
+
name: "capabilities-index",
|
|
398
|
+
ok: false,
|
|
399
|
+
detail: message,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
142
402
|
}
|
|
143
403
|
const failures = results.filter((result) => !result.ok);
|
|
144
404
|
if (options.json) {
|
package/dist/commands/format.js
CHANGED
|
@@ -10,16 +10,34 @@ const config_1 = require("../core/config");
|
|
|
10
10
|
const frontmatter_1 = require("../graph/frontmatter");
|
|
11
11
|
const template_schema_1 = require("../graph/template_schema");
|
|
12
12
|
const node_1 = require("../graph/node");
|
|
13
|
+
const agent_file_types_1 = require("../graph/agent_file_types");
|
|
14
|
+
const archive_file_1 = require("../graph/archive_file");
|
|
13
15
|
const workspace_files_1 = require("../graph/workspace_files");
|
|
14
16
|
const errors_1 = require("../util/errors");
|
|
15
17
|
const date_1 = require("../util/date");
|
|
16
18
|
const id_1 = require("../util/id");
|
|
19
|
+
const refs_1 = require("../util/refs");
|
|
17
20
|
const DEC_ID_RE = /^dec-[0-9]+$/;
|
|
18
21
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
19
22
|
const ID_LIST_KEYS = new Set(["refs", "scope"]);
|
|
20
23
|
const ID_REF_LIST_KEYS = new Set(["relates", "blocked_by", "blocks"]);
|
|
21
24
|
const ID_REF_SCALAR_KEYS = new Set(["epic", "parent", "prev", "next"]);
|
|
22
|
-
const PRESERVE_CASE_LIST_KEYS = new Set([
|
|
25
|
+
const PRESERVE_CASE_LIST_KEYS = new Set([
|
|
26
|
+
"links",
|
|
27
|
+
"artifacts",
|
|
28
|
+
"work_contracts",
|
|
29
|
+
"input_refs",
|
|
30
|
+
"constraint_refs",
|
|
31
|
+
"proof_refs",
|
|
32
|
+
"attestation_refs",
|
|
33
|
+
]);
|
|
34
|
+
const EXTERNAL_REF_LIST_KEYS = new Set([
|
|
35
|
+
"input_refs",
|
|
36
|
+
"constraint_refs",
|
|
37
|
+
"proof_refs",
|
|
38
|
+
"attestation_refs",
|
|
39
|
+
]);
|
|
40
|
+
const HASH_REF_LIST_KEYS = new Set(["input_hashes", "output_hashes"]);
|
|
23
41
|
function isValidId(value) {
|
|
24
42
|
return (0, id_1.isCanonicalId)(value);
|
|
25
43
|
}
|
|
@@ -48,7 +66,7 @@ function sortList(values) {
|
|
|
48
66
|
return 0;
|
|
49
67
|
});
|
|
50
68
|
}
|
|
51
|
-
function normalizeList(values, key, errors, filePath) {
|
|
69
|
+
function normalizeList(values, key, errors, filePath, allowPortableRefs = false) {
|
|
52
70
|
const trimmed = values.map((value) => normalizeScalar(value));
|
|
53
71
|
const shouldLowercase = !PRESERVE_CASE_LIST_KEYS.has(key);
|
|
54
72
|
const normalized = shouldLowercase ? trimmed.map((value) => value.toLowerCase()) : trimmed;
|
|
@@ -57,12 +75,18 @@ function normalizeList(values, key, errors, filePath) {
|
|
|
57
75
|
errors.push(`${filePath}: ${key} entries must be non-empty`);
|
|
58
76
|
continue;
|
|
59
77
|
}
|
|
60
|
-
if (ID_LIST_KEYS.has(key) && !isValidId(entry)) {
|
|
78
|
+
if (ID_LIST_KEYS.has(key) && !(allowPortableRefs ? (0, id_1.isPortableId)(entry) : isValidId(entry))) {
|
|
61
79
|
errors.push(`${filePath}: ${key} entries must match <prefix>-<number> or reserved id`);
|
|
62
80
|
}
|
|
63
|
-
if (ID_REF_LIST_KEYS.has(key) && !(0, id_1.isCanonicalIdRef)(entry)) {
|
|
81
|
+
if (ID_REF_LIST_KEYS.has(key) && !(allowPortableRefs ? (0, id_1.isPortableIdRef)(entry) : (0, id_1.isCanonicalIdRef)(entry))) {
|
|
64
82
|
errors.push(`${filePath}: ${key} entries must be valid id references`);
|
|
65
83
|
}
|
|
84
|
+
if (EXTERNAL_REF_LIST_KEYS.has(key) && !(0, refs_1.validatePortableOrUriRef)(entry)) {
|
|
85
|
+
errors.push(`${filePath}: ${key} entries must be portable ids or URI refs`);
|
|
86
|
+
}
|
|
87
|
+
if (HASH_REF_LIST_KEYS.has(key) && !(0, refs_1.isSha256Ref)(entry)) {
|
|
88
|
+
errors.push(`${filePath}: ${key} entries must be sha256:<64 lowercase hex chars>`);
|
|
89
|
+
}
|
|
66
90
|
}
|
|
67
91
|
return sortList(normalized);
|
|
68
92
|
}
|
|
@@ -73,14 +97,15 @@ function normalizeIdRef(value, key, errors, filePath) {
|
|
|
73
97
|
}
|
|
74
98
|
return normalized;
|
|
75
99
|
}
|
|
76
|
-
function normalizeFrontmatterValue(key, value, schema, errors, filePath) {
|
|
100
|
+
function normalizeFrontmatterValue(key, value, schema, errors, filePath, type) {
|
|
77
101
|
const expected = schema.keyKinds[key];
|
|
78
102
|
if (expected === "list") {
|
|
79
103
|
if (!Array.isArray(value)) {
|
|
80
104
|
errors.push(`${filePath}: ${key} must be a list`);
|
|
81
105
|
return [];
|
|
82
106
|
}
|
|
83
|
-
|
|
107
|
+
const allowPortableRefs = (0, agent_file_types_1.isAgentFileType)(type) || (0, archive_file_1.isArchiveType)(type);
|
|
108
|
+
return normalizeList(value, key, errors, filePath, allowPortableRefs);
|
|
84
109
|
}
|
|
85
110
|
if (expected === "boolean") {
|
|
86
111
|
if (typeof value !== "boolean") {
|
|
@@ -111,7 +136,7 @@ function normalizeFrontmatter(frontmatter, schema, type, workStatusEnum, priorit
|
|
|
111
136
|
}
|
|
112
137
|
continue;
|
|
113
138
|
}
|
|
114
|
-
const normalizedValue = normalizeFrontmatterValue(key, value, schema, errors, filePath);
|
|
139
|
+
const normalizedValue = normalizeFrontmatterValue(key, value, schema, errors, filePath, type);
|
|
115
140
|
if (normalizedValue !== undefined) {
|
|
116
141
|
normalized[key] = normalizedValue;
|
|
117
142
|
}
|
|
@@ -122,8 +147,12 @@ function normalizeFrontmatter(frontmatter, schema, type, workStatusEnum, priorit
|
|
|
122
147
|
}
|
|
123
148
|
else {
|
|
124
149
|
const normalizedId = idValue.toLowerCase();
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
const allowPortableId = (0, agent_file_types_1.isAgentFileType)(type) || (0, archive_file_1.isArchiveType)(type);
|
|
151
|
+
if (!(allowPortableId ? (0, id_1.isPortableId)(normalizedId) : isValidId(normalizedId))) {
|
|
152
|
+
const requirement = allowPortableId
|
|
153
|
+
? "<prefix>-<number>, reserved id, or allowed portable id"
|
|
154
|
+
: "<prefix>-<number> or reserved id";
|
|
155
|
+
errors.push(`${filePath}: id must match ${requirement}`);
|
|
127
156
|
}
|
|
128
157
|
normalized.id = normalizedId;
|
|
129
158
|
}
|
package/dist/commands/index.js
CHANGED
|
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runIndexCommand = runIndexCommand;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const config_1 = require("../core/config");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const skills_index_cache_1 = require("../graph/skills_index_cache");
|
|
12
|
-
const skills_indexer_1 = require("../graph/skills_indexer");
|
|
9
|
+
const reindex_1 = require("../graph/reindex");
|
|
10
|
+
const lock_1 = require("../util/lock");
|
|
13
11
|
function runIndexCommand(options) {
|
|
14
12
|
const config = (0, config_1.loadConfig)(options.root);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
(0, lock_1.withMutationLock)(options.root, config.index.lock_timeout_ms, () => {
|
|
14
|
+
const result = (0, reindex_1.writeDerivedIndexes)(options.root, config, undefined, { tolerant: options.tolerant });
|
|
15
|
+
console.log(`index written: ${path_1.default.relative(options.root, result.paths.nodes)}`);
|
|
16
|
+
console.log(`skills index written: ${path_1.default.relative(options.root, result.paths.skills)}`);
|
|
17
|
+
console.log(`capabilities index written: ${path_1.default.relative(options.root, result.paths.capabilities)}`);
|
|
18
|
+
console.log(`bundle imports index written: ${path_1.default.relative(options.root, result.paths.imports)}`);
|
|
19
|
+
if (result.paths.sqlite) {
|
|
20
|
+
console.log(`sqlite index written: ${path_1.default.relative(options.root, result.paths.sqlite)}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
23
|
}
|