comprehende 0.3.0 → 0.4.1
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 +9 -2
- package/dist/api/live.js +61 -15
- package/dist/api/paths.js +18 -0
- package/dist/git/diff.js +101 -2
- package/dist/git/log.js +18 -13
- package/dist/git/name-status.js +73 -0
- package/dist/review/coverage.js +5 -1
- package/dist/schema/lockfile.js +38 -0
- package/dist/schema/parse.js +18 -9
- package/dist/schema/skill-paths.js +2 -2
- package/dist/schema/skill-sync.js +63 -26
- package/dist/ui/assets/{index-D4bY-beP.js → index-CcecgzMY.js} +52 -52
- package/dist/ui/assets/index-CukSNLbz.css +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +2 -1
- package/skills/comprehende/SKILL.md +39 -9
- package/skills/comprehende/references/example.md +13 -3
- package/skills/comprehende/references/review.schema.json +20 -5
- package/dist/ui/assets/index-BxIxxAYx.css +0 -1
|
@@ -1,59 +1,96 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
3
|
-
import { join, relative } from "node:path";
|
|
4
|
-
import { cliPinErrors } from "./cli-pin.js";
|
|
2
|
+
import { cp, copyFile, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, relative } from "node:path";
|
|
4
|
+
import { applyCliPin, cliPinErrors, listedCliPins } from "./cli-pin.js";
|
|
5
5
|
import { skillPaths } from "./skill-paths.js";
|
|
6
|
-
import { findPackageRoot
|
|
6
|
+
import { findPackageRoot } from "../package-root.js";
|
|
7
7
|
export function skillSyncErrors(input) {
|
|
8
8
|
const errors = [];
|
|
9
|
-
if (input.
|
|
10
|
-
errors.push("skills/comprehende/references/review.schema.json drifted. Run: pnpm sync:skill");
|
|
9
|
+
if (input.nextSchema !== input.canonicalSchema) {
|
|
10
|
+
errors.push("skills-next/comprehende/references/review.schema.json drifted. Run: pnpm sync:skill");
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
errors.push(...cliPinErrors(input.nextSkillMd, input.version).map((error) => `skills-next/comprehende/${error}`));
|
|
13
|
+
if (listedCliPins(input.publishedSkillMd).length === 0) {
|
|
14
|
+
errors.push("skills/comprehende/SKILL.md must pin npx comprehende@<version>");
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
const publishedKeys = [...input.publishedFiles.keys()].sort();
|
|
16
|
+
const nextKeys = [...input.nextFiles.keys()].sort();
|
|
17
17
|
const installedKeys = [...input.installedFiles.keys()].sort();
|
|
18
|
-
if (
|
|
19
|
-
errors.push(".agents/skills/comprehende is not a copy of skills/comprehende. Run: pnpm sync:skill");
|
|
18
|
+
if (nextKeys.join("\n") !== installedKeys.join("\n")) {
|
|
19
|
+
errors.push(".agents/skills/comprehende is not a copy of skills-next/comprehende. Run: pnpm sync:skill");
|
|
20
20
|
return errors;
|
|
21
21
|
}
|
|
22
|
-
for (const rel of
|
|
23
|
-
if (input.
|
|
24
|
-
errors.push(`${rel} differs between skills/ and .agents/. Run: pnpm sync:skill`);
|
|
22
|
+
for (const rel of nextKeys) {
|
|
23
|
+
if (input.nextFiles.get(rel) !== input.installedFiles.get(rel)) {
|
|
24
|
+
errors.push(`${rel} differs between skills-next/ and .agents/. Run: pnpm sync:skill`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return errors;
|
|
28
28
|
}
|
|
29
29
|
export async function loadWorkingTreeSkillSync(root = findPackageRoot()) {
|
|
30
30
|
const paths = skillPaths(root);
|
|
31
|
-
const
|
|
31
|
+
const nextFiles = await readTree(paths.nextSkill);
|
|
32
32
|
const installedFiles = await readTree(paths.installedSkill);
|
|
33
33
|
return {
|
|
34
|
-
version:
|
|
34
|
+
version: await readVersion(root),
|
|
35
35
|
canonicalSchema: await readFile(paths.canonicalSchema, "utf8"),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
publishedFiles,
|
|
36
|
+
nextSchema: nextFiles.get("references/review.schema.json") ?? "",
|
|
37
|
+
nextSkillMd: nextFiles.get("SKILL.md") ?? "",
|
|
38
|
+
nextFiles,
|
|
40
39
|
installedFiles,
|
|
40
|
+
publishedSkillMd: await readFile(join(paths.publishedSkill, "SKILL.md"), "utf8"),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export function loadStagedSkillSync(root = findPackageRoot()) {
|
|
44
|
-
const
|
|
44
|
+
const nextFiles = gitStagedTree(root, "skills-next/comprehende");
|
|
45
45
|
const installedFiles = gitStagedTree(root, ".agents/skills/comprehende");
|
|
46
46
|
const pkg = JSON.parse(gitShowStaged(root, "package.json"));
|
|
47
47
|
return {
|
|
48
48
|
version: pkg.version,
|
|
49
49
|
canonicalSchema: gitShowStaged(root, "src/schema/review.schema.json"),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
publishedFiles,
|
|
50
|
+
nextSchema: nextFiles.get("references/review.schema.json") ?? "",
|
|
51
|
+
nextSkillMd: nextFiles.get("SKILL.md") ?? "",
|
|
52
|
+
nextFiles,
|
|
54
53
|
installedFiles,
|
|
54
|
+
publishedSkillMd: gitShowStaged(root, "skills/comprehende/SKILL.md"),
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
export async function syncNextSkill(options) {
|
|
58
|
+
const root = options?.root ?? findPackageRoot();
|
|
59
|
+
const release = options?.release === true;
|
|
60
|
+
const paths = skillPaths(root);
|
|
61
|
+
const version = await readVersion(root);
|
|
62
|
+
const skillFile = join(paths.nextSkill, "SKILL.md");
|
|
63
|
+
await mkdir(dirname(paths.nextSchema), { recursive: true });
|
|
64
|
+
await copyFile(paths.canonicalSchema, paths.nextSchema);
|
|
65
|
+
const original = await readFile(skillFile, "utf8");
|
|
66
|
+
const pinned = applyCliPin(original, version);
|
|
67
|
+
const pinProblems = cliPinErrors(pinned, version);
|
|
68
|
+
if (pinProblems.length > 0) {
|
|
69
|
+
throw new Error(pinProblems.join("\n"));
|
|
70
|
+
}
|
|
71
|
+
if (pinned !== original) {
|
|
72
|
+
await writeFile(skillFile, pinned);
|
|
73
|
+
}
|
|
74
|
+
await replaceDir(paths.nextSkill, paths.installedSkill);
|
|
75
|
+
const logs = [
|
|
76
|
+
`copied ${paths.canonicalSchema} -> ${paths.nextSchema}`,
|
|
77
|
+
`pinned npx comprehende@${version} in ${skillFile}`,
|
|
78
|
+
`copied ${paths.nextSkill} -> ${paths.installedSkill}`,
|
|
79
|
+
];
|
|
80
|
+
if (release) {
|
|
81
|
+
await replaceDir(paths.nextSkill, paths.publishedSkill);
|
|
82
|
+
logs.push(`copied ${paths.nextSkill} -> ${paths.publishedSkill}`);
|
|
83
|
+
}
|
|
84
|
+
return logs;
|
|
85
|
+
}
|
|
86
|
+
async function readVersion(root) {
|
|
87
|
+
const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
88
|
+
return pkg.version;
|
|
89
|
+
}
|
|
90
|
+
async function replaceDir(from, to) {
|
|
91
|
+
await rm(to, { recursive: true, force: true });
|
|
92
|
+
await cp(from, to, { recursive: true });
|
|
93
|
+
}
|
|
57
94
|
async function readTree(dir) {
|
|
58
95
|
const out = new Map();
|
|
59
96
|
const walk = async (current) => {
|