instar 0.28.115 → 0.28.117
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/dist/providers/parity/registry.d.ts +23 -0
- package/dist/providers/parity/registry.d.ts.map +1 -0
- package/dist/providers/parity/registry.js +41 -0
- package/dist/providers/parity/registry.js.map +1 -0
- package/dist/providers/parity/rules/hookParityRule.d.ts +34 -0
- package/dist/providers/parity/rules/hookParityRule.d.ts.map +1 -0
- package/dist/providers/parity/rules/hookParityRule.js +463 -0
- package/dist/providers/parity/rules/hookParityRule.js.map +1 -0
- package/dist/providers/parity/rules/skillParityRule.d.ts +47 -0
- package/dist/providers/parity/rules/skillParityRule.d.ts.map +1 -0
- package/dist/providers/parity/rules/skillParityRule.js +618 -0
- package/dist/providers/parity/rules/skillParityRule.js.map +1 -0
- package/dist/providers/parity/types.d.ts +100 -0
- package/dist/providers/parity/types.d.ts.map +1 -0
- package/dist/providers/parity/types.js +13 -0
- package/dist/providers/parity/types.js.map +1 -0
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +2 -2
- package/upgrades/0.28.116.md +23 -0
- package/upgrades/0.28.117.md +23 -0
- package/upgrades/side-effects/feat-hook-primitive.md +74 -0
- package/upgrades/side-effects/feat-skill-prototype.md +103 -0
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* skillParityRule — parity rule for the Skill functional primitive.
|
|
3
|
+
*
|
|
4
|
+
* Specs:
|
|
5
|
+
* - specs/instar-concepts/skill.md (canonical shape)
|
|
6
|
+
* - specs/frameworks/claude-code/skills.md (Claude rendering contract)
|
|
7
|
+
* - specs/frameworks/codex-cli/skills.md (Codex rendering contract)
|
|
8
|
+
*
|
|
9
|
+
* Reads canonical skills from `.instar/skills/<name>/` and verifies each
|
|
10
|
+
* framework's rendering is in sync. On drift, the sentinel can call
|
|
11
|
+
* remediate() to re-render from canonical.
|
|
12
|
+
*
|
|
13
|
+
* Convergence-round-1 hardening applied:
|
|
14
|
+
* - C1: strict slug grammar enforced at every entry point (path traversal
|
|
15
|
+
* and arbitrary-write are no longer reachable from canonical content).
|
|
16
|
+
* - C2: YAML parsing via js-yaml; fail-loud on parse error rather than
|
|
17
|
+
* silent truncation by regex.
|
|
18
|
+
* - C5: symmetric verify — orphan rendered files surfaced as
|
|
19
|
+
* `orphan-rendering-found`; remediate cleans them.
|
|
20
|
+
* - C7: rendered files carry an `x-instar-stamp` tag recording the
|
|
21
|
+
* canonical body hash that produced them. user-edits to renderings are
|
|
22
|
+
* detected and surfaced as `user-edit-conflict`; auto-remediate
|
|
23
|
+
* refuses to overwrite without explicit force.
|
|
24
|
+
* - C8: description length capped + control chars stripped at parse time
|
|
25
|
+
* to bound prompt-injection surface.
|
|
26
|
+
* - H1: directory name vs frontmatter `name` mismatch surfaced as
|
|
27
|
+
* `name-directory-mismatch`.
|
|
28
|
+
* - H5: canonical-read errors tagged with `framework: 'canonical'` rather
|
|
29
|
+
* than misleadingly attributing to a framework.
|
|
30
|
+
*
|
|
31
|
+
* Deferred to follow-up issues (tracked, not in this PR):
|
|
32
|
+
* - C3: render `allowed-tools` → Claude frontmatter + Codex
|
|
33
|
+
* `dependencies.tools`. Removed from canonical for v0.1 to avoid
|
|
34
|
+
* promise-without-delivery drift; will land with the Tool primitive.
|
|
35
|
+
* - C6: atomic-write tempfile+rename. Single-sentinel-pass + single-
|
|
36
|
+
* machine narrows the race window for v0.1; will add when sentinel
|
|
37
|
+
* ships.
|
|
38
|
+
* - H2/H3: BackupManager defaults + CLAUDE.md template — separate PRs.
|
|
39
|
+
* - H4: git-sync conflict-marker detection — operator-facing; surfaced
|
|
40
|
+
* in this PR as fail-loud `canonical-parse-error`.
|
|
41
|
+
*/
|
|
42
|
+
import { promises as fs } from 'node:fs';
|
|
43
|
+
import path from 'node:path';
|
|
44
|
+
import crypto from 'node:crypto';
|
|
45
|
+
import yaml from 'js-yaml';
|
|
46
|
+
const CANONICAL_ROOT = '.instar/skills';
|
|
47
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
48
|
+
const MAX_DESCRIPTION_LEN = 256;
|
|
49
|
+
const MAX_NAME_LEN = 64;
|
|
50
|
+
const STAMP_KEY = 'x-instar-stamp';
|
|
51
|
+
const STAMP_LINE_RE = /^x-instar-stamp:\s*([a-f0-9]{64})\s*$/m;
|
|
52
|
+
// ─── Slug + description validation ──────────────────────────────────────
|
|
53
|
+
export class CanonicalSkillError extends Error {
|
|
54
|
+
constructor(message) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = 'CanonicalSkillError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function validateSlug(name, context) {
|
|
60
|
+
if (typeof name !== 'string' || !SLUG_RE.test(name)) {
|
|
61
|
+
throw new CanonicalSkillError(`${context}: invalid skill name "${name}". Must match ${SLUG_RE.source} ` +
|
|
62
|
+
`(lowercase alphanumeric + hyphens, max ${MAX_NAME_LEN} chars).`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function sanitizeDescription(raw) {
|
|
66
|
+
// Strip control chars, collapse whitespace, cap length. Bounds
|
|
67
|
+
// prompt-injection surface and keeps metadata-layer payload small.
|
|
68
|
+
// eslint-disable-next-line no-control-regex
|
|
69
|
+
const cleaned = raw.replace(/[\x00-\x1f\x7f]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
70
|
+
return cleaned.length > MAX_DESCRIPTION_LEN
|
|
71
|
+
? cleaned.slice(0, MAX_DESCRIPTION_LEN - 3) + '...'
|
|
72
|
+
: cleaned;
|
|
73
|
+
}
|
|
74
|
+
function sha256(s) {
|
|
75
|
+
return crypto.createHash('sha256').update(s, 'utf-8').digest('hex');
|
|
76
|
+
}
|
|
77
|
+
function parseFrontmatter(raw, sourcePath) {
|
|
78
|
+
// Detect git-merge-conflict markers and fail loud rather than parsing past them.
|
|
79
|
+
if (/^<{7} |^={7}$|^>{7} /m.test(raw)) {
|
|
80
|
+
throw new CanonicalSkillError(`${sourcePath}: file contains unresolved git merge conflict markers`);
|
|
81
|
+
}
|
|
82
|
+
const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
83
|
+
if (!match) {
|
|
84
|
+
throw new CanonicalSkillError(`${sourcePath}: missing YAML frontmatter block`);
|
|
85
|
+
}
|
|
86
|
+
const [, fmRaw, body] = match;
|
|
87
|
+
let fm;
|
|
88
|
+
try {
|
|
89
|
+
fm = yaml.load(fmRaw, { schema: yaml.FAILSAFE_SCHEMA, json: false });
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw new CanonicalSkillError(`${sourcePath}: YAML frontmatter parse error — ${err.message}`);
|
|
93
|
+
}
|
|
94
|
+
if (fm === null || typeof fm !== 'object' || Array.isArray(fm)) {
|
|
95
|
+
throw new CanonicalSkillError(`${sourcePath}: frontmatter must be a YAML mapping`);
|
|
96
|
+
}
|
|
97
|
+
return { fm: fm, body };
|
|
98
|
+
}
|
|
99
|
+
async function readCanonicalSkill(projectRoot, dirName) {
|
|
100
|
+
validateSlug(dirName, `canonical skill dir name`);
|
|
101
|
+
const skillDir = path.join(projectRoot, CANONICAL_ROOT, dirName);
|
|
102
|
+
const skillMd = path.join(skillDir, 'SKILL.md');
|
|
103
|
+
let raw;
|
|
104
|
+
try {
|
|
105
|
+
raw = await fs.readFile(skillMd, 'utf-8');
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
throw new CanonicalSkillError(`canonical SKILL.md missing or unreadable: ${path.relative(projectRoot, skillMd)} — ${err.message}`);
|
|
109
|
+
}
|
|
110
|
+
const { fm, body } = parseFrontmatter(raw, path.relative(projectRoot, skillMd));
|
|
111
|
+
const name = fm.name;
|
|
112
|
+
const description = fm.description;
|
|
113
|
+
if (typeof name !== 'string') {
|
|
114
|
+
throw new CanonicalSkillError(`${path.relative(projectRoot, skillMd)}: frontmatter 'name' must be a string`);
|
|
115
|
+
}
|
|
116
|
+
if (typeof description !== 'string') {
|
|
117
|
+
throw new CanonicalSkillError(`${path.relative(projectRoot, skillMd)}: frontmatter 'description' must be a string`);
|
|
118
|
+
}
|
|
119
|
+
validateSlug(name, `${path.relative(projectRoot, skillMd)}: frontmatter 'name'`);
|
|
120
|
+
if (name !== dirName) {
|
|
121
|
+
throw new CanonicalSkillError(`${path.relative(projectRoot, skillMd)}: frontmatter 'name'="${name}" does not match directory name "${dirName}". Directory name is authoritative.`);
|
|
122
|
+
}
|
|
123
|
+
let metadataShortDescription;
|
|
124
|
+
const metadataRaw = fm.metadata;
|
|
125
|
+
if (metadataRaw && typeof metadataRaw === 'object' && !Array.isArray(metadataRaw)) {
|
|
126
|
+
const md = metadataRaw;
|
|
127
|
+
const short = md['short-description'] ?? md['short_description'];
|
|
128
|
+
if (typeof short === 'string') {
|
|
129
|
+
metadataShortDescription = sanitizeDescription(short);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const cleanedDescription = sanitizeDescription(description);
|
|
133
|
+
const bundledSubdirs = [];
|
|
134
|
+
for (const sub of ['scripts', 'references', 'assets']) {
|
|
135
|
+
try {
|
|
136
|
+
const st = await fs.stat(path.join(skillDir, sub));
|
|
137
|
+
if (st.isDirectory())
|
|
138
|
+
bundledSubdirs.push(sub);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
/* not present */
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
name,
|
|
146
|
+
description: cleanedDescription,
|
|
147
|
+
metadataShortDescription,
|
|
148
|
+
body,
|
|
149
|
+
bundledSubdirs,
|
|
150
|
+
bodyHash: sha256(body),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async function listCanonicalSkillNames(projectRoot) {
|
|
154
|
+
const dir = path.join(projectRoot, CANONICAL_ROOT);
|
|
155
|
+
try {
|
|
156
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
157
|
+
return entries
|
|
158
|
+
.filter((e) => e.isDirectory() && SLUG_RE.test(e.name))
|
|
159
|
+
.map((e) => e.name)
|
|
160
|
+
.sort();
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
if (err.code === 'ENOENT')
|
|
164
|
+
return [];
|
|
165
|
+
throw err;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// ─── Mirror + compare helpers ──────────────────────────────────────────
|
|
169
|
+
async function mirrorSubdir(src, dest) {
|
|
170
|
+
await fs.mkdir(dest, { recursive: true });
|
|
171
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (entry.isSymbolicLink()) {
|
|
174
|
+
// Skip symlinks — they can escape the canonical tree.
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const s = path.join(src, entry.name);
|
|
178
|
+
const d = path.join(dest, entry.name);
|
|
179
|
+
if (entry.isDirectory()) {
|
|
180
|
+
await mirrorSubdir(s, d);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
const content = await fs.readFile(s);
|
|
184
|
+
await fs.writeFile(d, content);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function readFileOrNull(p) {
|
|
189
|
+
try {
|
|
190
|
+
return await fs.readFile(p, 'utf-8');
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function compareSubdirs(src, dest) {
|
|
197
|
+
let srcEntries;
|
|
198
|
+
let destEntries;
|
|
199
|
+
try {
|
|
200
|
+
srcEntries = (await fs.readdir(src, { withFileTypes: true })).map((e) => ({
|
|
201
|
+
name: e.name,
|
|
202
|
+
isDir: e.isDirectory(),
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
srcEntries = [];
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
destEntries = (await fs.readdir(dest, { withFileTypes: true })).map((e) => ({
|
|
210
|
+
name: e.name,
|
|
211
|
+
isDir: e.isDirectory(),
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return { matches: false, reason: `destination subdir missing: ${dest}` };
|
|
216
|
+
}
|
|
217
|
+
const srcNames = new Set(srcEntries.map((e) => e.name));
|
|
218
|
+
const destNames = new Set(destEntries.map((e) => e.name));
|
|
219
|
+
for (const name of srcNames) {
|
|
220
|
+
if (!destNames.has(name))
|
|
221
|
+
return { matches: false, reason: `missing entry ${name}` };
|
|
222
|
+
}
|
|
223
|
+
for (const name of destNames) {
|
|
224
|
+
if (!srcNames.has(name))
|
|
225
|
+
return { matches: false, reason: `extraneous entry ${name}` };
|
|
226
|
+
}
|
|
227
|
+
for (const e of srcEntries) {
|
|
228
|
+
const s = path.join(src, e.name);
|
|
229
|
+
const d = path.join(dest, e.name);
|
|
230
|
+
if (e.isDir) {
|
|
231
|
+
const r = await compareSubdirs(s, d);
|
|
232
|
+
if (!r.matches)
|
|
233
|
+
return r;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
const sBuf = await fs.readFile(s);
|
|
237
|
+
const dBuf = await fs.readFile(d);
|
|
238
|
+
if (sBuf.compare(dBuf) !== 0) {
|
|
239
|
+
return { matches: false, reason: `content mismatch in ${path.relative(src, s)}` };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return { matches: true };
|
|
244
|
+
}
|
|
245
|
+
// ─── Stamp parsing ──────────────────────────────────────────────────────
|
|
246
|
+
function extractStamp(rendered) {
|
|
247
|
+
const m = rendered.match(STAMP_LINE_RE);
|
|
248
|
+
return m ? m[1] : null;
|
|
249
|
+
}
|
|
250
|
+
// ─── Per-framework renderers ───────────────────────────────────────────
|
|
251
|
+
const claudeCodeRenderer = {
|
|
252
|
+
skillDir(projectRoot, name) {
|
|
253
|
+
validateSlug(name, 'claude-code skillDir');
|
|
254
|
+
return path.join(projectRoot, '.claude/skills', name);
|
|
255
|
+
},
|
|
256
|
+
skillMdPath(projectRoot, name) {
|
|
257
|
+
return path.join(this.skillDir(projectRoot, name), 'SKILL.md');
|
|
258
|
+
},
|
|
259
|
+
async render(projectRoot, skill) {
|
|
260
|
+
const skillDir = this.skillDir(projectRoot, skill.name);
|
|
261
|
+
await fs.mkdir(skillDir, { recursive: true });
|
|
262
|
+
const fmLines = [
|
|
263
|
+
'---',
|
|
264
|
+
`name: ${skill.name}`,
|
|
265
|
+
`description: ${JSON.stringify(skill.description).slice(1, -1)}`,
|
|
266
|
+
`${STAMP_KEY}: ${skill.bodyHash}`,
|
|
267
|
+
'---',
|
|
268
|
+
'',
|
|
269
|
+
].join('\n');
|
|
270
|
+
await fs.writeFile(path.join(skillDir, 'SKILL.md'), fmLines + skill.body, 'utf-8');
|
|
271
|
+
const canonicalDir = path.join(projectRoot, CANONICAL_ROOT, skill.name);
|
|
272
|
+
for (const sub of skill.bundledSubdirs) {
|
|
273
|
+
await mirrorSubdir(path.join(canonicalDir, sub), path.join(skillDir, sub));
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
async verifyRendering(projectRoot, skill) {
|
|
277
|
+
const issues = [];
|
|
278
|
+
const skillMd = this.skillMdPath(projectRoot, skill.name);
|
|
279
|
+
const rendered = await readFileOrNull(skillMd);
|
|
280
|
+
if (!rendered) {
|
|
281
|
+
issues.push({
|
|
282
|
+
reasonCode: 'missing-rendered-file',
|
|
283
|
+
detail: `expected ${path.relative(projectRoot, skillMd)} to exist`,
|
|
284
|
+
});
|
|
285
|
+
return issues;
|
|
286
|
+
}
|
|
287
|
+
let parsed;
|
|
288
|
+
try {
|
|
289
|
+
parsed = parseFrontmatter(rendered, path.relative(projectRoot, skillMd));
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
issues.push({
|
|
293
|
+
reasonCode: 'rendering-parse-error',
|
|
294
|
+
detail: err.message,
|
|
295
|
+
});
|
|
296
|
+
return issues;
|
|
297
|
+
}
|
|
298
|
+
if (parsed.fm.name !== skill.name) {
|
|
299
|
+
issues.push({
|
|
300
|
+
reasonCode: 'frontmatter-name-mismatch',
|
|
301
|
+
detail: `claude rendering 'name'=${parsed.fm.name} vs canonical=${skill.name}`,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
if (parsed.fm.description !== skill.description) {
|
|
305
|
+
issues.push({
|
|
306
|
+
reasonCode: 'frontmatter-description-mismatch',
|
|
307
|
+
detail: `claude rendering 'description' differs from canonical`,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (parsed.body !== skill.body) {
|
|
311
|
+
const stamp = extractStamp(rendered);
|
|
312
|
+
if (stamp && stamp === skill.bodyHash) {
|
|
313
|
+
issues.push({
|
|
314
|
+
reasonCode: 'user-edit-conflict',
|
|
315
|
+
detail: `claude rendering body differs from canonical, but stamp matches current canonical hash — user appears to have edited the rendering directly`,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
issues.push({
|
|
320
|
+
reasonCode: 'body-content-mismatch',
|
|
321
|
+
detail: `claude rendering body differs from canonical (stamp ${stamp ? 'stale' : 'missing'})`,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const canonicalDir = path.join(projectRoot, CANONICAL_ROOT, skill.name);
|
|
326
|
+
const renderedDir = this.skillDir(projectRoot, skill.name);
|
|
327
|
+
for (const sub of skill.bundledSubdirs) {
|
|
328
|
+
const cmp = await compareSubdirs(path.join(canonicalDir, sub), path.join(renderedDir, sub));
|
|
329
|
+
if (!cmp.matches) {
|
|
330
|
+
issues.push({
|
|
331
|
+
reasonCode: cmp.reason?.startsWith('destination subdir missing')
|
|
332
|
+
? 'bundled-subdir-missing'
|
|
333
|
+
: 'bundled-subdir-mismatch',
|
|
334
|
+
detail: `claude rendering ${sub}/: ${cmp.reason}`,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return issues;
|
|
339
|
+
},
|
|
340
|
+
async removeOrphans(projectRoot, canonicalNames) {
|
|
341
|
+
const skillsRoot = path.join(projectRoot, '.claude/skills');
|
|
342
|
+
return removeOrphanSkillDirs(skillsRoot, canonicalNames);
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
function humanizeName(name) {
|
|
346
|
+
return name
|
|
347
|
+
.split(/[-_]/)
|
|
348
|
+
.filter(Boolean)
|
|
349
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
350
|
+
.join(' ');
|
|
351
|
+
}
|
|
352
|
+
function shortDescriptionFor(skill) {
|
|
353
|
+
const raw = skill.metadataShortDescription ?? skill.description;
|
|
354
|
+
const oneLine = raw.replace(/\s+/g, ' ').trim();
|
|
355
|
+
if (oneLine.length <= 64)
|
|
356
|
+
return oneLine;
|
|
357
|
+
return oneLine.slice(0, 61).trimEnd() + '...';
|
|
358
|
+
}
|
|
359
|
+
function buildOpenAiYaml(skill) {
|
|
360
|
+
const obj = {
|
|
361
|
+
interface: {
|
|
362
|
+
display_name: humanizeName(skill.name),
|
|
363
|
+
short_description: shortDescriptionFor(skill),
|
|
364
|
+
},
|
|
365
|
+
[STAMP_KEY]: skill.bodyHash,
|
|
366
|
+
};
|
|
367
|
+
return yaml.dump(obj, { lineWidth: 200, noRefs: true });
|
|
368
|
+
}
|
|
369
|
+
const codexCliRenderer = {
|
|
370
|
+
skillDir(projectRoot, name) {
|
|
371
|
+
validateSlug(name, 'codex-cli skillDir');
|
|
372
|
+
return path.join(projectRoot, '.agents/skills', name);
|
|
373
|
+
},
|
|
374
|
+
skillMdPath(projectRoot, name) {
|
|
375
|
+
return path.join(this.skillDir(projectRoot, name), 'SKILL.md');
|
|
376
|
+
},
|
|
377
|
+
async render(projectRoot, skill) {
|
|
378
|
+
const skillDir = this.skillDir(projectRoot, skill.name);
|
|
379
|
+
await fs.mkdir(skillDir, { recursive: true });
|
|
380
|
+
const fmObj = {
|
|
381
|
+
name: skill.name,
|
|
382
|
+
description: skill.description,
|
|
383
|
+
};
|
|
384
|
+
if (skill.metadataShortDescription) {
|
|
385
|
+
fmObj.metadata = { 'short-description': skill.metadataShortDescription };
|
|
386
|
+
}
|
|
387
|
+
fmObj[STAMP_KEY] = skill.bodyHash;
|
|
388
|
+
const fmYaml = yaml.dump(fmObj, { lineWidth: 200, noRefs: true });
|
|
389
|
+
await fs.writeFile(path.join(skillDir, 'SKILL.md'), `---\n${fmYaml}---\n${skill.body}`, 'utf-8');
|
|
390
|
+
const yamlDir = path.join(skillDir, 'agents');
|
|
391
|
+
await fs.mkdir(yamlDir, { recursive: true });
|
|
392
|
+
await fs.writeFile(path.join(yamlDir, 'openai.yaml'), buildOpenAiYaml(skill), 'utf-8');
|
|
393
|
+
const canonicalDir = path.join(projectRoot, CANONICAL_ROOT, skill.name);
|
|
394
|
+
for (const sub of skill.bundledSubdirs) {
|
|
395
|
+
await mirrorSubdir(path.join(canonicalDir, sub), path.join(skillDir, sub));
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
async verifyRendering(projectRoot, skill) {
|
|
399
|
+
const issues = [];
|
|
400
|
+
const skillMd = this.skillMdPath(projectRoot, skill.name);
|
|
401
|
+
const rendered = await readFileOrNull(skillMd);
|
|
402
|
+
if (!rendered) {
|
|
403
|
+
issues.push({
|
|
404
|
+
reasonCode: 'missing-rendered-file',
|
|
405
|
+
detail: `expected ${path.relative(projectRoot, skillMd)} to exist`,
|
|
406
|
+
});
|
|
407
|
+
return issues;
|
|
408
|
+
}
|
|
409
|
+
let parsed;
|
|
410
|
+
try {
|
|
411
|
+
parsed = parseFrontmatter(rendered, path.relative(projectRoot, skillMd));
|
|
412
|
+
}
|
|
413
|
+
catch (err) {
|
|
414
|
+
issues.push({
|
|
415
|
+
reasonCode: 'rendering-parse-error',
|
|
416
|
+
detail: err.message,
|
|
417
|
+
});
|
|
418
|
+
return issues;
|
|
419
|
+
}
|
|
420
|
+
if (parsed.fm.name !== skill.name) {
|
|
421
|
+
issues.push({
|
|
422
|
+
reasonCode: 'frontmatter-name-mismatch',
|
|
423
|
+
detail: `codex rendering 'name'=${parsed.fm.name} vs canonical=${skill.name}`,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (parsed.fm.description !== skill.description) {
|
|
427
|
+
issues.push({
|
|
428
|
+
reasonCode: 'frontmatter-description-mismatch',
|
|
429
|
+
detail: `codex rendering 'description' differs from canonical`,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (parsed.body !== skill.body) {
|
|
433
|
+
const stamp = extractStamp(rendered);
|
|
434
|
+
if (stamp && stamp === skill.bodyHash) {
|
|
435
|
+
issues.push({
|
|
436
|
+
reasonCode: 'user-edit-conflict',
|
|
437
|
+
detail: `codex rendering body differs from canonical, but stamp matches current canonical hash — user appears to have edited the rendering directly`,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
issues.push({
|
|
442
|
+
reasonCode: 'body-content-mismatch',
|
|
443
|
+
detail: `codex rendering body differs from canonical (stamp ${stamp ? 'stale' : 'missing'})`,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
const yamlPath = path.join(this.skillDir(projectRoot, skill.name), 'agents/openai.yaml');
|
|
448
|
+
const yamlRaw = await readFileOrNull(yamlPath);
|
|
449
|
+
if (!yamlRaw) {
|
|
450
|
+
issues.push({
|
|
451
|
+
reasonCode: 'sibling-artifact-missing',
|
|
452
|
+
detail: `expected ${path.relative(projectRoot, yamlPath)} to exist`,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
const expectedYaml = buildOpenAiYaml(skill);
|
|
457
|
+
if (yamlRaw !== expectedYaml) {
|
|
458
|
+
issues.push({
|
|
459
|
+
reasonCode: 'sibling-artifact-mismatch',
|
|
460
|
+
detail: `codex openai.yaml differs from canonical-derived expected`,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const canonicalDir = path.join(projectRoot, CANONICAL_ROOT, skill.name);
|
|
465
|
+
const renderedDir = this.skillDir(projectRoot, skill.name);
|
|
466
|
+
for (const sub of skill.bundledSubdirs) {
|
|
467
|
+
const cmp = await compareSubdirs(path.join(canonicalDir, sub), path.join(renderedDir, sub));
|
|
468
|
+
if (!cmp.matches) {
|
|
469
|
+
issues.push({
|
|
470
|
+
reasonCode: cmp.reason?.startsWith('destination subdir missing')
|
|
471
|
+
? 'bundled-subdir-missing'
|
|
472
|
+
: 'bundled-subdir-mismatch',
|
|
473
|
+
detail: `codex rendering ${sub}/: ${cmp.reason}`,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return issues;
|
|
478
|
+
},
|
|
479
|
+
async removeOrphans(projectRoot, canonicalNames) {
|
|
480
|
+
const skillsRoot = path.join(projectRoot, '.agents/skills');
|
|
481
|
+
return removeOrphanSkillDirs(skillsRoot, canonicalNames);
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
async function removeOrphanSkillDirs(skillsRoot, canonicalNames) {
|
|
485
|
+
const removed = [];
|
|
486
|
+
let entries;
|
|
487
|
+
try {
|
|
488
|
+
entries = (await fs.readdir(skillsRoot, { withFileTypes: true })).map((e) => ({
|
|
489
|
+
name: e.name,
|
|
490
|
+
isDir: e.isDirectory(),
|
|
491
|
+
}));
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
return removed;
|
|
495
|
+
}
|
|
496
|
+
for (const entry of entries) {
|
|
497
|
+
if (!entry.isDir)
|
|
498
|
+
continue;
|
|
499
|
+
if (canonicalNames.has(entry.name))
|
|
500
|
+
continue;
|
|
501
|
+
// Only remove dirs whose name is a valid slug — refuse to touch anything
|
|
502
|
+
// unexpected (paranoid: don't widen the blast radius).
|
|
503
|
+
if (!SLUG_RE.test(entry.name))
|
|
504
|
+
continue;
|
|
505
|
+
const fullPath = path.join(skillsRoot, entry.name);
|
|
506
|
+
await fs.rm(fullPath, { recursive: true, force: true });
|
|
507
|
+
removed.push(fullPath);
|
|
508
|
+
}
|
|
509
|
+
return removed;
|
|
510
|
+
}
|
|
511
|
+
const FRAMEWORK_RENDERERS = {
|
|
512
|
+
'claude-code': claudeCodeRenderer,
|
|
513
|
+
'codex-cli': codexCliRenderer,
|
|
514
|
+
};
|
|
515
|
+
// ─── The exported ParityRule ───────────────────────────────────────────
|
|
516
|
+
async function findOrphans(projectRoot, framework, canonicalNames) {
|
|
517
|
+
const renderer = FRAMEWORK_RENDERERS[framework];
|
|
518
|
+
const skillsRoot = framework === 'claude-code'
|
|
519
|
+
? path.join(projectRoot, '.claude/skills')
|
|
520
|
+
: path.join(projectRoot, '.agents/skills');
|
|
521
|
+
let entries;
|
|
522
|
+
try {
|
|
523
|
+
entries = (await fs.readdir(skillsRoot, { withFileTypes: true })).map((e) => ({
|
|
524
|
+
name: e.name,
|
|
525
|
+
isDir: e.isDirectory(),
|
|
526
|
+
}));
|
|
527
|
+
}
|
|
528
|
+
catch {
|
|
529
|
+
return [];
|
|
530
|
+
}
|
|
531
|
+
const orphans = [];
|
|
532
|
+
for (const entry of entries) {
|
|
533
|
+
if (!entry.isDir)
|
|
534
|
+
continue;
|
|
535
|
+
if (!SLUG_RE.test(entry.name))
|
|
536
|
+
continue;
|
|
537
|
+
if (canonicalNames.has(entry.name))
|
|
538
|
+
continue;
|
|
539
|
+
orphans.push({
|
|
540
|
+
primitive: 'skill',
|
|
541
|
+
instanceName: entry.name,
|
|
542
|
+
framework,
|
|
543
|
+
reasonCode: 'orphan-rendering-found',
|
|
544
|
+
detail: `rendered skill dir has no canonical counterpart: ${path.relative(projectRoot, renderer.skillDir(projectRoot, entry.name))}`,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return orphans;
|
|
548
|
+
}
|
|
549
|
+
export const skillParityRule = {
|
|
550
|
+
primitive: 'skill',
|
|
551
|
+
frameworks: ['claude-code', 'codex-cli'],
|
|
552
|
+
remediationPolicy: 'mirror-trust',
|
|
553
|
+
async listInstances(projectRoot) {
|
|
554
|
+
return listCanonicalSkillNames(projectRoot);
|
|
555
|
+
},
|
|
556
|
+
async verify(projectRoot, instanceName) {
|
|
557
|
+
let skill;
|
|
558
|
+
try {
|
|
559
|
+
skill = await readCanonicalSkill(projectRoot, instanceName);
|
|
560
|
+
}
|
|
561
|
+
catch (err) {
|
|
562
|
+
return {
|
|
563
|
+
ok: false,
|
|
564
|
+
mismatches: [
|
|
565
|
+
{
|
|
566
|
+
primitive: 'skill',
|
|
567
|
+
instanceName,
|
|
568
|
+
framework: 'canonical',
|
|
569
|
+
reasonCode: 'canonical-read-error',
|
|
570
|
+
detail: `canonical skill could not be read: ${err.message}`,
|
|
571
|
+
},
|
|
572
|
+
],
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
const mismatches = [];
|
|
576
|
+
for (const framework of this.frameworks) {
|
|
577
|
+
const renderer = FRAMEWORK_RENDERERS[framework];
|
|
578
|
+
const issues = await renderer.verifyRendering(projectRoot, skill);
|
|
579
|
+
for (const issue of issues) {
|
|
580
|
+
mismatches.push({
|
|
581
|
+
primitive: 'skill',
|
|
582
|
+
instanceName,
|
|
583
|
+
framework,
|
|
584
|
+
reasonCode: issue.reasonCode,
|
|
585
|
+
detail: issue.detail,
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return { ok: mismatches.length === 0, mismatches };
|
|
590
|
+
},
|
|
591
|
+
async remediate(projectRoot, instanceName, framework) {
|
|
592
|
+
const skill = await readCanonicalSkill(projectRoot, instanceName);
|
|
593
|
+
const renderer = FRAMEWORK_RENDERERS[framework];
|
|
594
|
+
// C7: refuse to overwrite if the current rendering is a user-edit-conflict.
|
|
595
|
+
// Sentinel/operator must explicitly resolve before remediation proceeds.
|
|
596
|
+
const issues = await renderer.verifyRendering(projectRoot, skill);
|
|
597
|
+
const conflict = issues.find((i) => i.reasonCode === 'user-edit-conflict');
|
|
598
|
+
if (conflict) {
|
|
599
|
+
throw new CanonicalSkillError(`refused to remediate ${instanceName} on ${framework}: ${conflict.detail}. ` +
|
|
600
|
+
`Resolve the user-edit-conflict explicitly before re-running.`);
|
|
601
|
+
}
|
|
602
|
+
await renderer.render(projectRoot, skill);
|
|
603
|
+
},
|
|
604
|
+
async listOrphans(projectRoot) {
|
|
605
|
+
const canonical = new Set(await listCanonicalSkillNames(projectRoot));
|
|
606
|
+
const out = [];
|
|
607
|
+
for (const framework of this.frameworks) {
|
|
608
|
+
out.push(...(await findOrphans(projectRoot, framework, canonical)));
|
|
609
|
+
}
|
|
610
|
+
return out;
|
|
611
|
+
},
|
|
612
|
+
async removeOrphans(projectRoot, framework) {
|
|
613
|
+
const canonical = new Set(await listCanonicalSkillNames(projectRoot));
|
|
614
|
+
const renderer = FRAMEWORK_RENDERERS[framework];
|
|
615
|
+
return renderer.removeOrphans(projectRoot, canonical);
|
|
616
|
+
},
|
|
617
|
+
};
|
|
618
|
+
//# sourceMappingURL=skillParityRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillParityRule.js","sourceRoot":"","sources":["../../../../src/providers/parity/rules/skillParityRule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAQ3B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AACxC,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAC5C,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,MAAM,aAAa,GAAG,wCAAwC,CAAC;AAwB/D,2EAA2E;AAE3E,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YA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