@elvis1513/auto-coding-skill 4.1.7 → 4.1.9
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 +42 -20
- package/cli/assets/managed-install.json +1 -0
- package/cli/assets/skill/SKILL.md +11 -7
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +2 -2
- package/cli/assets/skill/data/templates/ENGINEERING.md +12 -21
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +12 -6
- package/cli/assets/skill/scripts/ap.py +355 -7
- package/cli/assets/skill/scripts/install_integrity.py +424 -0
- package/cli/assets/skill/scripts/scaffold_templates.py +9 -0
- package/cli/src/check-package.js +4 -0
- package/cli/src/index.js +275 -30
- package/cli/src/sync-assets.js +30 -1
- package/cli/tests/index.test.js +218 -83
- package/package.json +4 -3
package/cli/src/index.js
CHANGED
|
@@ -138,8 +138,95 @@ function requireRuntimeDependencies(assetSkill){
|
|
|
138
138
|
+ `Run: ${install}\nThen rerun autocoding init.`,
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
|
+
|
|
142
|
+
function runtimePython(){
|
|
143
|
+
const fallback = process.platform === "win32" ? "python" : "python3";
|
|
144
|
+
return String(process.env.AUTOCODING_PYTHON || fallback).trim() || fallback;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function readInstallManifest(file){
|
|
148
|
+
let manifest;
|
|
149
|
+
try {
|
|
150
|
+
manifest = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
151
|
+
} catch (error) {
|
|
152
|
+
die(`invalid managed install manifest ${file}: ${error.message}`);
|
|
153
|
+
}
|
|
154
|
+
if (manifest?.schema_version !== 1 || !/^\d+\.\d+\.\d+$/.test(String(manifest?.skill_version || ""))) {
|
|
155
|
+
die(`invalid managed install manifest schema/version: ${file}`);
|
|
156
|
+
}
|
|
157
|
+
if (!Array.isArray(manifest.entries) || !Array.isArray(manifest.managed_namespaces)) {
|
|
158
|
+
die(`invalid managed install manifest entries/namespaces: ${file}`);
|
|
159
|
+
}
|
|
160
|
+
return manifest;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function installManifestTarget(root){
|
|
164
|
+
return path.join(root, ".agents", "managed-install.json");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function copyInstallManifest(assetManifest, root){
|
|
168
|
+
const target = installManifestTarget(root);
|
|
169
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
170
|
+
fs.copyFileSync(assetManifest, target);
|
|
171
|
+
return target;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function applyManifestExecutableBits(root, manifest, mode){
|
|
175
|
+
if (process.platform === "win32") return;
|
|
176
|
+
const scopes = new Set(mode === "project" ? ["shared", "project"] : ["shared"]);
|
|
177
|
+
for (const entry of manifest.entries) {
|
|
178
|
+
if (!scopes.has(entry.scope) || typeof entry.path !== "string" || typeof entry.executable !== "boolean") continue;
|
|
179
|
+
const target = path.join(root, ...entry.path.split("/"));
|
|
180
|
+
if (!exists(target) || fs.lstatSync(target).isSymbolicLink()) continue;
|
|
181
|
+
const current = fs.statSync(target).mode & 0o777;
|
|
182
|
+
const desired = entry.executable ? (current | 0o111) : (current & ~0o111);
|
|
183
|
+
if (desired !== current) fs.chmodSync(target, desired);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function installIntegrityStatus(root, mode, expectedVersion){
|
|
188
|
+
const script = path.join(root, ".agents", "skills", "auto-coding-skill", "scripts", "install_integrity.py");
|
|
189
|
+
if (!exists(script)) {
|
|
190
|
+
return { ok: false, version: "", checked: 0, errors: ["managed integrity verifier is missing"] };
|
|
191
|
+
}
|
|
192
|
+
const result = spawnSync(
|
|
193
|
+
runtimePython(),
|
|
194
|
+
[script, "verify", "--repo", root, "--mode", mode, "--expected-version", expectedVersion, "--json"],
|
|
195
|
+
{ encoding: "utf8", stdio: "pipe" },
|
|
196
|
+
);
|
|
197
|
+
try {
|
|
198
|
+
const parsed = JSON.parse(result.stdout || "{}");
|
|
199
|
+
if (typeof parsed.ok === "boolean" && Array.isArray(parsed.errors)) return parsed;
|
|
200
|
+
} catch {
|
|
201
|
+
// Fall through to a deterministic diagnostic below.
|
|
202
|
+
}
|
|
203
|
+
const detail = String(result.stderr || result.stdout || result.error?.message || "integrity verifier failed").trim();
|
|
204
|
+
return { ok: false, version: "", checked: 0, errors: [detail || "integrity verifier returned invalid output"] };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function requireInstallIntegrity(root, mode, expectedVersion){
|
|
208
|
+
const result = installIntegrityStatus(root, mode, expectedVersion);
|
|
209
|
+
if (!result.ok) die(`managed install integrity verification failed:\n- ${result.errors.join("\n- ")}`);
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function runEngineeringConvergence(project, skillRoot, write){
|
|
214
|
+
const script = path.join(skillRoot, "scripts", "ap.py");
|
|
215
|
+
const command = [script, "--repo", project, "project-converge", "--json"];
|
|
216
|
+
if (write) command.push("--write");
|
|
217
|
+
const result = spawnSync(runtimePython(), command, { encoding: "utf8", stdio: "pipe" });
|
|
218
|
+
if (result.status !== 0) {
|
|
219
|
+
const detail = String(result.stderr || result.stdout || result.error?.message || "project convergence failed").trim();
|
|
220
|
+
die(`unable to converge docs/ENGINEERING.md: ${detail}`);
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
return JSON.parse(result.stdout);
|
|
224
|
+
} catch {
|
|
225
|
+
die("project convergence returned invalid JSON");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
141
228
|
function shouldSkip(name){
|
|
142
|
-
return name === "__pycache__" || name === ".DS_Store" ||
|
|
229
|
+
return name === "__pycache__" || name === ".DS_Store" || /\.py[cod]$/i.test(name);
|
|
143
230
|
}
|
|
144
231
|
|
|
145
232
|
function copyDir(src, dst){
|
|
@@ -359,6 +446,7 @@ function compareManagedAgents(assetAgents, agentsDir){
|
|
|
359
446
|
function syncManagedAgents(assetAgents, agentsDir, options = {}){
|
|
360
447
|
fs.mkdirSync(agentsDir, { recursive: true });
|
|
361
448
|
const bindings = [];
|
|
449
|
+
const managedFiles = new Set(listFiles(assetAgents));
|
|
362
450
|
for (const rel of listFiles(assetAgents)) {
|
|
363
451
|
const src = path.join(assetAgents, rel);
|
|
364
452
|
const dst = path.join(agentsDir, rel);
|
|
@@ -370,6 +458,11 @@ function syncManagedAgents(assetAgents, agentsDir, options = {}){
|
|
|
370
458
|
const model = inspectTopLevelModel(rendered);
|
|
371
459
|
bindings.push({ agent: rel, model: model.present ? model.value : "inherit" });
|
|
372
460
|
}
|
|
461
|
+
if (options.removeExtra === true) {
|
|
462
|
+
for (const rel of listFiles(agentsDir)) {
|
|
463
|
+
if (!managedFiles.has(rel)) fs.rmSync(path.join(agentsDir, rel), { force: true });
|
|
464
|
+
}
|
|
465
|
+
}
|
|
373
466
|
return bindings;
|
|
374
467
|
}
|
|
375
468
|
|
|
@@ -947,8 +1040,8 @@ function frontmatterSequenceHasItems(text, keyPath){
|
|
|
947
1040
|
for (let child = index + 1; child < lines.length; child += 1) {
|
|
948
1041
|
if (!lines[child].trim() || lines[child].trim().startsWith("#")) continue;
|
|
949
1042
|
const childIndent = lines[child].match(/^\s*/)[0].replace(/\t/g, " ").length;
|
|
1043
|
+
if (/^\s*-\s+\S/.test(lines[child]) && childIndent >= indent) return true;
|
|
950
1044
|
if (childIndent <= indent) return false;
|
|
951
|
-
if (/^\s*-\s+\S/.test(lines[child])) return true;
|
|
952
1045
|
}
|
|
953
1046
|
return false;
|
|
954
1047
|
}
|
|
@@ -1077,7 +1170,7 @@ function frontmatterScalarValue(raw){
|
|
|
1077
1170
|
return value;
|
|
1078
1171
|
}
|
|
1079
1172
|
|
|
1080
|
-
function projectStatus(project, assetSkill, assetAgents){
|
|
1173
|
+
function projectStatus(project, assetSkill, assetAgents, assetManifest, releaseManifest){
|
|
1081
1174
|
const root = path.resolve(project);
|
|
1082
1175
|
const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
|
|
1083
1176
|
const agentsDir = path.join(root, ".agents", "agents");
|
|
@@ -1174,27 +1267,63 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1174
1267
|
scriptDiffs.push({ path: "docs/tools/autopipeline/ap.py", status: "stale" });
|
|
1175
1268
|
}
|
|
1176
1269
|
const missingDocs = [];
|
|
1177
|
-
const srcDocs = path.join(assetSkill, "data", "templates", "docs");
|
|
1178
1270
|
for (const rel of CORE_DOCS) {
|
|
1179
1271
|
if (!exists(path.join(root, "docs", rel))) missingDocs.push(path.join("docs", rel));
|
|
1180
1272
|
}
|
|
1273
|
+
let docsDiffs = [];
|
|
1274
|
+
const convergenceCheck = spawnSync(
|
|
1275
|
+
runtimePython(),
|
|
1276
|
+
[path.join(assetSkill, "scripts", "ap.py"), "--repo", root, "project-converge", "--json"],
|
|
1277
|
+
{ encoding: "utf8", stdio: "pipe" },
|
|
1278
|
+
);
|
|
1279
|
+
if (convergenceCheck.status === 0) {
|
|
1280
|
+
try {
|
|
1281
|
+
docsDiffs = (JSON.parse(convergenceCheck.stdout).actions || []).filter(item =>
|
|
1282
|
+
item.path === "docs/ENGINEERING.md" || item.path.startsWith("docs/"),
|
|
1283
|
+
);
|
|
1284
|
+
} catch {
|
|
1285
|
+
docsDiffs = [{ action: "invalid", path: "docs", detail: "convergence check returned invalid JSON" }];
|
|
1286
|
+
}
|
|
1287
|
+
} else {
|
|
1288
|
+
docsDiffs = [{
|
|
1289
|
+
action: "invalid",
|
|
1290
|
+
path: "docs",
|
|
1291
|
+
detail: String(convergenceCheck.stderr || convergenceCheck.stdout || "convergence check failed").trim(),
|
|
1292
|
+
}];
|
|
1293
|
+
}
|
|
1181
1294
|
const skillDiffs = exists(skillDir) ? compareDirs(assetSkill, skillDir, { includeExtra: true }) : [{ path: ".agents/skills/auto-coding-skill", status: "missing" }];
|
|
1182
1295
|
const agentStatus = exists(agentsDir)
|
|
1183
1296
|
? compareManagedAgents(assetAgents, agentsDir)
|
|
1184
1297
|
: { diffs: [{ path: ".agents/agents", status: "missing" }], bindings: [] };
|
|
1185
1298
|
const agentDiffs = agentStatus.diffs;
|
|
1186
|
-
const
|
|
1299
|
+
const installedManifest = installManifestTarget(root);
|
|
1300
|
+
const installManifestDiffs = [];
|
|
1301
|
+
if (!exists(installedManifest)) installManifestDiffs.push({ path: ".agents/managed-install.json", status: "missing" });
|
|
1302
|
+
else if (!fs.readFileSync(assetManifest).equals(fs.readFileSync(installedManifest))) {
|
|
1303
|
+
installManifestDiffs.push({ path: ".agents/managed-install.json", status: "stale" });
|
|
1304
|
+
}
|
|
1305
|
+
const installIntegrity = installIntegrityStatus(root, "project", releaseManifest.skill_version);
|
|
1306
|
+
const ok = skillDiffs.length === 0
|
|
1307
|
+
&& agentDiffs.length === 0
|
|
1308
|
+
&& scriptDiffs.length === 0
|
|
1309
|
+
&& installManifestDiffs.length === 0
|
|
1310
|
+
&& installIntegrity.ok
|
|
1311
|
+
&& missingDocs.length === 0
|
|
1312
|
+
&& docsDiffs.length === 0
|
|
1313
|
+
&& missingConfigTokens.length === 0
|
|
1314
|
+
&& managedWorkflow.state === "current"
|
|
1315
|
+
&& managedAgentsDocument.state === "current";
|
|
1187
1316
|
let next = "";
|
|
1188
1317
|
if (!exists(skillDir) || !exists(agentsDir)) {
|
|
1189
|
-
next = "run autocoding init
|
|
1190
|
-
} else if (skillDiffs.length || agentDiffs.length) {
|
|
1191
|
-
next = "run autocoding
|
|
1192
|
-
} else if (engineeringMissing || managedWorkflow.state !== "current" || managedAgentsDocument.state !== "current" || scriptDiffs.length || missingDocs.length) {
|
|
1193
|
-
next = "run autocoding
|
|
1318
|
+
next = "run autocoding init";
|
|
1319
|
+
} else if (skillDiffs.length || agentDiffs.length || installManifestDiffs.length || !installIntegrity.ok) {
|
|
1320
|
+
next = "run autocoding init";
|
|
1321
|
+
} else if (engineeringMissing || managedWorkflow.state !== "current" || managedAgentsDocument.state !== "current" || scriptDiffs.length || missingDocs.length || docsDiffs.length) {
|
|
1322
|
+
next = "run autocoding init";
|
|
1194
1323
|
} else if (missingConfigPaths.length) {
|
|
1195
|
-
next = "run
|
|
1324
|
+
next = "run autocoding init, fill every required value in docs/ENGINEERING.md, then run doctor";
|
|
1196
1325
|
} else if (invalidConfigTokens.length) {
|
|
1197
|
-
next = "run
|
|
1326
|
+
next = "run autocoding init, then run doctor";
|
|
1198
1327
|
} else if (unfilledConfigTokens.length) {
|
|
1199
1328
|
next = "fill every required value in docs/ENGINEERING.md, then run project-local ap.py doctor";
|
|
1200
1329
|
}
|
|
@@ -1205,6 +1334,9 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1205
1334
|
agentDiffs,
|
|
1206
1335
|
agentBindings: agentStatus.bindings,
|
|
1207
1336
|
scriptDiffs,
|
|
1337
|
+
installManifestDiffs,
|
|
1338
|
+
installIntegrity,
|
|
1339
|
+
docsDiffs,
|
|
1208
1340
|
missingDocs,
|
|
1209
1341
|
missingConfigTokens,
|
|
1210
1342
|
missingConfigPaths,
|
|
@@ -1225,7 +1357,17 @@ function printProjectStatus(result){
|
|
|
1225
1357
|
console.log(`[autocoding] ${label} ${item.status}: ${item.path}${detail}`);
|
|
1226
1358
|
}
|
|
1227
1359
|
}
|
|
1360
|
+
for (const item of result.installManifestDiffs || []) {
|
|
1361
|
+
console.log(`[autocoding] manifest ${item.status}: ${item.path}`);
|
|
1362
|
+
}
|
|
1363
|
+
for (const issue of result.installIntegrity?.errors || []) {
|
|
1364
|
+
console.log(`[autocoding] install integrity: ${issue}`);
|
|
1365
|
+
}
|
|
1228
1366
|
for (const item of result.missingDocs) console.log(`[autocoding] doc missing: ${item}`);
|
|
1367
|
+
for (const item of result.docsDiffs || []) {
|
|
1368
|
+
const detail = item.detail ? ` - ${item.detail}` : "";
|
|
1369
|
+
console.log(`[autocoding] docs ${item.action}: ${item.path}${detail}`);
|
|
1370
|
+
}
|
|
1229
1371
|
for (const item of result.missingConfigTokens) console.log(`[autocoding] config missing path: ${item}`);
|
|
1230
1372
|
if (result.managedWorkflow?.state !== "current") {
|
|
1231
1373
|
const detail = result.managedWorkflow?.detail ? ` - ${result.managedWorkflow.detail}` : "";
|
|
@@ -1245,15 +1387,17 @@ function engineeringPlanDetail(plan){
|
|
|
1245
1387
|
return `managed workflow ${plan.state} -> ${plan.version}`;
|
|
1246
1388
|
}
|
|
1247
1389
|
|
|
1248
|
-
function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels = false, components = "all", controlledPlans = null){
|
|
1390
|
+
function syncProject(project, assetSkill, assetAgents, assetManifest, releaseManifest, dryRun, resetAgentModels = false, components = "all", controlledPlans = null){
|
|
1249
1391
|
const root = path.resolve(project);
|
|
1250
1392
|
const actions = [];
|
|
1251
1393
|
const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
|
|
1252
1394
|
const skillOnly = components === "skill";
|
|
1253
1395
|
actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, skillDir) });
|
|
1396
|
+
actions.push({ action: dryRun ? "would-sync" : "sync", path: ".agents/managed-install.json" });
|
|
1254
1397
|
if (!dryRun) {
|
|
1255
1398
|
rmrf(skillDir);
|
|
1256
1399
|
copyDir(assetSkill, skillDir);
|
|
1400
|
+
copyInstallManifest(assetManifest, root);
|
|
1257
1401
|
}
|
|
1258
1402
|
if (skillOnly) return { project: root, dryRun, components, actions };
|
|
1259
1403
|
|
|
@@ -1304,6 +1448,9 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1304
1448
|
detail: `managed agents ${agentsDocumentPlan.state} -> ${agentsDocumentPlan.version}`,
|
|
1305
1449
|
});
|
|
1306
1450
|
}
|
|
1451
|
+
applyManifestExecutableBits(root, releaseManifest, "project");
|
|
1452
|
+
const integrity = requireInstallIntegrity(root, "project", releaseManifest.skill_version);
|
|
1453
|
+
actions.push({ action: "verify", path: ".agents/managed-install.json", detail: `${integrity.checked} managed files` });
|
|
1307
1454
|
} else {
|
|
1308
1455
|
for (const rel of CORE_DOCS) {
|
|
1309
1456
|
if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
|
|
@@ -1347,6 +1494,77 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1347
1494
|
};
|
|
1348
1495
|
}
|
|
1349
1496
|
|
|
1497
|
+
function convergeProjectInstall(project, assetSkill, assetAgents, assetManifest, releaseManifest, resetAgentModels){
|
|
1498
|
+
const root = path.resolve(project);
|
|
1499
|
+
const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
|
|
1500
|
+
const agentsDir = path.join(root, ".agents", "agents");
|
|
1501
|
+
const toolDir = path.join(root, "docs", "tools", "autopipeline");
|
|
1502
|
+
const actions = [];
|
|
1503
|
+
|
|
1504
|
+
// Validate the authoritative template and legacy input before the first write.
|
|
1505
|
+
runEngineeringConvergence(root, assetSkill, false);
|
|
1506
|
+
|
|
1507
|
+
rmrf(skillDir);
|
|
1508
|
+
copyDir(assetSkill, skillDir);
|
|
1509
|
+
actions.push({ action: "replace", path: path.relative(root, skillDir) });
|
|
1510
|
+
|
|
1511
|
+
copyInstallManifest(assetManifest, root);
|
|
1512
|
+
actions.push({ action: "replace", path: ".agents/managed-install.json" });
|
|
1513
|
+
|
|
1514
|
+
syncManagedAgents(assetAgents, agentsDir, { resetModel: resetAgentModels });
|
|
1515
|
+
actions.push({ action: "sync", path: path.relative(root, agentsDir) });
|
|
1516
|
+
|
|
1517
|
+
fs.mkdirSync(toolDir, { recursive: true });
|
|
1518
|
+
fs.copyFileSync(
|
|
1519
|
+
path.join(assetSkill, "data", "templates", "tools", "ap.py"),
|
|
1520
|
+
path.join(toolDir, "ap.py"),
|
|
1521
|
+
);
|
|
1522
|
+
actions.push({ action: "replace", path: "docs/tools/autopipeline/ap.py" });
|
|
1523
|
+
|
|
1524
|
+
const agentsDocument = path.join(root, "AGENTS.md");
|
|
1525
|
+
const canonicalAgents = fs.readFileSync(
|
|
1526
|
+
path.join(assetSkill, "data", "templates", "bridges", "AGENTS.md"),
|
|
1527
|
+
"utf8",
|
|
1528
|
+
);
|
|
1529
|
+
const currentAgents = exists(agentsDocument) ? fs.readFileSync(agentsDocument, "utf8") : "";
|
|
1530
|
+
if (currentAgents !== canonicalAgents) {
|
|
1531
|
+
if (currentAgents) {
|
|
1532
|
+
let archive = path.join(
|
|
1533
|
+
root,
|
|
1534
|
+
".agents",
|
|
1535
|
+
"archive",
|
|
1536
|
+
"auto-coding-skill",
|
|
1537
|
+
readPackageVersion(),
|
|
1538
|
+
"AGENTS.md",
|
|
1539
|
+
);
|
|
1540
|
+
if (exists(archive) && fs.readFileSync(archive, "utf8") !== currentAgents) {
|
|
1541
|
+
archive = path.join(
|
|
1542
|
+
path.dirname(archive),
|
|
1543
|
+
`AGENTS-${crypto.createHash("sha256").update(currentAgents).digest("hex").slice(0, 12)}.md`,
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
if (!exists(archive)) {
|
|
1547
|
+
fs.mkdirSync(path.dirname(archive), { recursive: true });
|
|
1548
|
+
fs.writeFileSync(archive, currentAgents);
|
|
1549
|
+
actions.push({
|
|
1550
|
+
action: "archive",
|
|
1551
|
+
path: path.relative(root, archive),
|
|
1552
|
+
detail: "historical and non-authoritative",
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
fs.writeFileSync(agentsDocument, canonicalAgents);
|
|
1557
|
+
actions.push({ action: "replace", path: "AGENTS.md" });
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
const engineering = runEngineeringConvergence(root, skillDir, true);
|
|
1561
|
+
actions.push(...engineering.actions);
|
|
1562
|
+
applyManifestExecutableBits(root, releaseManifest, "project");
|
|
1563
|
+
const integrity = requireInstallIntegrity(root, "project", releaseManifest.skill_version);
|
|
1564
|
+
actions.push({ action: "verify", path: ".agents/managed-install.json", detail: `${integrity.checked} managed files` });
|
|
1565
|
+
return { project: root, actions };
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1350
1568
|
function projectRoot(){ return process.cwd(); }
|
|
1351
1569
|
|
|
1352
1570
|
function resolveInstallDirs(mode, destOverride){
|
|
@@ -1360,29 +1578,34 @@ function resolveInstallDirs(mode, destOverride){
|
|
|
1360
1578
|
return {
|
|
1361
1579
|
skillDir: dest,
|
|
1362
1580
|
agentsDir: path.join(grandparent, "agents"),
|
|
1581
|
+
projectDir: path.dirname(grandparent),
|
|
1363
1582
|
};
|
|
1364
1583
|
}
|
|
1365
1584
|
if (path.basename(dest) === "skills" && path.basename(parent) === ".agents") {
|
|
1366
1585
|
return {
|
|
1367
1586
|
skillDir: path.join(dest, "auto-coding-skill"),
|
|
1368
1587
|
agentsDir: path.join(parent, "agents"),
|
|
1588
|
+
projectDir: path.dirname(parent),
|
|
1369
1589
|
};
|
|
1370
1590
|
}
|
|
1371
1591
|
if (path.basename(dest) === "agents" && path.basename(parent) === ".agents") {
|
|
1372
1592
|
return {
|
|
1373
1593
|
skillDir: path.join(parent, "skills", "auto-coding-skill"),
|
|
1374
1594
|
agentsDir: dest,
|
|
1595
|
+
projectDir: path.dirname(parent),
|
|
1375
1596
|
};
|
|
1376
1597
|
}
|
|
1377
1598
|
if (path.basename(dest) === ".agents") {
|
|
1378
1599
|
return {
|
|
1379
1600
|
skillDir: path.join(dest, "skills", "auto-coding-skill"),
|
|
1380
1601
|
agentsDir: path.join(dest, "agents"),
|
|
1602
|
+
projectDir: path.dirname(dest),
|
|
1381
1603
|
};
|
|
1382
1604
|
}
|
|
1383
1605
|
return {
|
|
1384
1606
|
skillDir: path.join(dest, ".agents", "skills", "auto-coding-skill"),
|
|
1385
1607
|
agentsDir: path.join(dest, ".agents", "agents"),
|
|
1608
|
+
projectDir: dest,
|
|
1386
1609
|
};
|
|
1387
1610
|
}
|
|
1388
1611
|
|
|
@@ -1390,6 +1613,7 @@ function resolveInstallDirs(mode, destOverride){
|
|
|
1390
1613
|
return {
|
|
1391
1614
|
skillDir: path.join(root, ".agents", "skills", "auto-coding-skill"),
|
|
1392
1615
|
agentsDir: path.join(root, ".agents", "agents"),
|
|
1616
|
+
projectDir: root,
|
|
1393
1617
|
};
|
|
1394
1618
|
}
|
|
1395
1619
|
|
|
@@ -1401,7 +1625,7 @@ function main(){
|
|
|
1401
1625
|
autocoding - install auto-coding-skill into generic .agents paths
|
|
1402
1626
|
|
|
1403
1627
|
Usage:
|
|
1404
|
-
autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--
|
|
1628
|
+
autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--reset-agent-models]
|
|
1405
1629
|
autocoding status --projects <path[,path...]> [--json]
|
|
1406
1630
|
autocoding sync --projects <path[,path...]> [--dry-run] [--json] [--reset-agent-models]
|
|
1407
1631
|
|
|
@@ -1412,6 +1636,7 @@ Examples:
|
|
|
1412
1636
|
|
|
1413
1637
|
Compatibility:
|
|
1414
1638
|
--ai <value> is accepted for old scripts and ignored.
|
|
1639
|
+
--force is accepted for old scripts; project init is already an idempotent full convergence.
|
|
1415
1640
|
Existing managed-agent model lines are preserved unless --reset-agent-models is used.
|
|
1416
1641
|
`);
|
|
1417
1642
|
process.exit(0);
|
|
@@ -1422,6 +1647,7 @@ Compatibility:
|
|
|
1422
1647
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
1423
1648
|
const packagedAssetSkill = path.resolve(here, "..", "assets", "skill");
|
|
1424
1649
|
const packagedAssetAgents = path.resolve(here, "..", "assets", "agents");
|
|
1650
|
+
const assetManifest = path.resolve(here, "..", "assets", "managed-install.json");
|
|
1425
1651
|
const sourceAssetSkill = path.resolve(here, "..", "..", "src", "auto-coding-skill");
|
|
1426
1652
|
const sourceAssetAgents = path.resolve(here, "..", "..", "src", "agents");
|
|
1427
1653
|
const useSourceAssets = exists(sourceAssetSkill) && exists(sourceAssetAgents);
|
|
@@ -1429,10 +1655,15 @@ Compatibility:
|
|
|
1429
1655
|
const assetAgents = useSourceAssets ? sourceAssetAgents : packagedAssetAgents;
|
|
1430
1656
|
if (!exists(assetSkill)) die(`missing assets at ${assetSkill}`);
|
|
1431
1657
|
if (!exists(assetAgents)) die(`missing assets at ${assetAgents}`);
|
|
1658
|
+
if (!exists(assetManifest)) die(`missing managed install manifest at ${assetManifest}`);
|
|
1659
|
+
const releaseManifest = readInstallManifest(assetManifest);
|
|
1660
|
+
if (releaseManifest.skill_version !== readPackageVersion()) {
|
|
1661
|
+
die(`managed install manifest version ${releaseManifest.skill_version} does not match package ${readPackageVersion()}`);
|
|
1662
|
+
}
|
|
1432
1663
|
|
|
1433
1664
|
if (args.cmd === "status") {
|
|
1434
1665
|
const projects = args.projects.length ? args.projects : [projectRoot()];
|
|
1435
|
-
const results = projects.map(project => projectStatus(project, assetSkill, assetAgents));
|
|
1666
|
+
const results = projects.map(project => projectStatus(project, assetSkill, assetAgents, assetManifest, releaseManifest));
|
|
1436
1667
|
if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
|
|
1437
1668
|
else {
|
|
1438
1669
|
console.log(`[autocoding] version=${readPackageVersion()}`);
|
|
@@ -1464,6 +1695,8 @@ Compatibility:
|
|
|
1464
1695
|
root,
|
|
1465
1696
|
assetSkill,
|
|
1466
1697
|
assetAgents,
|
|
1698
|
+
assetManifest,
|
|
1699
|
+
releaseManifest,
|
|
1467
1700
|
args.dryRun,
|
|
1468
1701
|
args.resetAgentModels,
|
|
1469
1702
|
args.components,
|
|
@@ -1492,22 +1725,34 @@ Compatibility:
|
|
|
1492
1725
|
|
|
1493
1726
|
requireRuntimeDependencies(assetSkill);
|
|
1494
1727
|
|
|
1495
|
-
const { skillDir, agentsDir } = resolveInstallDirs(args.mode, args.dest);
|
|
1496
|
-
const existingTargets = [skillDir, agentsDir].filter(target => exists(target));
|
|
1497
|
-
if (existingTargets.length && !args.force) {
|
|
1498
|
-
die(`target exists: ${existingTargets.join(", ")}\nRe-run with --force to overwrite managed templates.`);
|
|
1499
|
-
}
|
|
1500
|
-
if (exists(skillDir)) {
|
|
1501
|
-
rmrf(skillDir);
|
|
1502
|
-
}
|
|
1503
|
-
copyDir(assetSkill, skillDir);
|
|
1504
|
-
console.log(`[autocoding] installed skill to: ${skillDir}`);
|
|
1505
|
-
|
|
1506
|
-
syncManagedAgents(assetAgents, agentsDir, { resetModel: args.resetAgentModels });
|
|
1507
|
-
console.log(`[autocoding] installed agents to: ${agentsDir}`);
|
|
1508
|
-
|
|
1728
|
+
const { skillDir, agentsDir, projectDir } = resolveInstallDirs(args.mode, args.dest);
|
|
1509
1729
|
if (args.mode === "project") {
|
|
1510
|
-
|
|
1730
|
+
assertNoRegisteredTasks([projectDir]);
|
|
1731
|
+
const result = convergeProjectInstall(
|
|
1732
|
+
projectDir,
|
|
1733
|
+
assetSkill,
|
|
1734
|
+
assetAgents,
|
|
1735
|
+
assetManifest,
|
|
1736
|
+
releaseManifest,
|
|
1737
|
+
args.resetAgentModels,
|
|
1738
|
+
);
|
|
1739
|
+
console.log(`[autocoding] project=${result.project}`);
|
|
1740
|
+
for (const item of result.actions) {
|
|
1741
|
+
const detail = item.detail ? ` - ${item.detail}` : "";
|
|
1742
|
+
console.log(`[autocoding] ${item.action}: ${item.path}${detail}`);
|
|
1743
|
+
}
|
|
1744
|
+
console.log("[autocoding] next: fill any blank access.* values and validation.routes in docs/ENGINEERING.md, then run doctor.");
|
|
1745
|
+
} else {
|
|
1746
|
+
rmrf(skillDir);
|
|
1747
|
+
copyDir(assetSkill, skillDir);
|
|
1748
|
+
syncManagedAgents(assetAgents, agentsDir, { resetModel: args.resetAgentModels });
|
|
1749
|
+
copyInstallManifest(assetManifest, projectDir);
|
|
1750
|
+
applyManifestExecutableBits(projectDir, releaseManifest, "global");
|
|
1751
|
+
const integrity = requireInstallIntegrity(projectDir, "global", releaseManifest.skill_version);
|
|
1752
|
+
console.log(`[autocoding] installed skill to: ${skillDir}`);
|
|
1753
|
+
console.log(`[autocoding] installed agents to: ${agentsDir}`);
|
|
1754
|
+
console.log(`[autocoding] installed manifest to: ${installManifestTarget(projectDir)}`);
|
|
1755
|
+
console.log(`[autocoding] verified managed install files: ${integrity.checked}`);
|
|
1511
1756
|
}
|
|
1512
1757
|
console.log("[autocoding] done.");
|
|
1513
1758
|
}
|
package/cli/src/sync-assets.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
|
|
5
6
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
@@ -7,12 +8,35 @@ const srcSkill = path.join(repoRoot, "src", "auto-coding-skill");
|
|
|
7
8
|
const dstSkill = path.join(repoRoot, "cli", "assets", "skill");
|
|
8
9
|
const srcAgents = path.join(repoRoot, "src", "agents");
|
|
9
10
|
const dstAgents = path.join(repoRoot, "cli", "assets", "agents");
|
|
11
|
+
const manifestDst = path.join(repoRoot, "cli", "assets", "managed-install.json");
|
|
10
12
|
const checkOnly = process.argv.includes("--check");
|
|
11
13
|
|
|
14
|
+
function generateManifest(){
|
|
15
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
|
|
16
|
+
const python = String(process.env.AUTOCODING_PYTHON || (process.platform === "win32" ? "python" : "python3")).trim();
|
|
17
|
+
const result = spawnSync(
|
|
18
|
+
python,
|
|
19
|
+
[
|
|
20
|
+
path.join(srcSkill, "scripts", "install_integrity.py"),
|
|
21
|
+
"generate",
|
|
22
|
+
"--skill-root", srcSkill,
|
|
23
|
+
"--agents-root", srcAgents,
|
|
24
|
+
"--version", pkg.version,
|
|
25
|
+
],
|
|
26
|
+
{ encoding: "utf8", stdio: "pipe" },
|
|
27
|
+
);
|
|
28
|
+
if (result.status !== 0) {
|
|
29
|
+
const detail = String(result.stderr || result.stdout || result.error?.message || "manifest generation failed").trim();
|
|
30
|
+
throw new Error(detail);
|
|
31
|
+
}
|
|
32
|
+
JSON.parse(result.stdout);
|
|
33
|
+
return result.stdout;
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
function exists(p){ try { fs.accessSync(p); return true; } catch { return false; } }
|
|
13
37
|
function rmrf(p){ fs.rmSync(p, { recursive:true, force:true }); }
|
|
14
38
|
function shouldSkip(name){
|
|
15
|
-
return name === "__pycache__" || name === ".DS_Store" ||
|
|
39
|
+
return name === "__pycache__" || name === ".DS_Store" || /\.py[cod]$/i.test(name);
|
|
16
40
|
}
|
|
17
41
|
function copyDir(src, dst){
|
|
18
42
|
fs.mkdirSync(dst, { recursive:true });
|
|
@@ -60,10 +84,13 @@ function compareDirs(src, dst, label){
|
|
|
60
84
|
}
|
|
61
85
|
|
|
62
86
|
if (checkOnly) {
|
|
87
|
+
const expectedManifest = generateManifest();
|
|
63
88
|
const diffs = [
|
|
64
89
|
...compareDirs(srcSkill, dstSkill, "skill"),
|
|
65
90
|
...compareDirs(srcAgents, dstAgents, "agents"),
|
|
66
91
|
];
|
|
92
|
+
if (!exists(manifestDst)) diffs.push("manifest: missing cli/assets/managed-install.json");
|
|
93
|
+
else if (fs.readFileSync(manifestDst, "utf8") !== expectedManifest) diffs.push("manifest: stale cli/assets/managed-install.json");
|
|
67
94
|
if (diffs.length > 0) {
|
|
68
95
|
console.error("[sync-assets] assets are out of sync:");
|
|
69
96
|
for (const diff of diffs) console.error(`- ${diff}`);
|
|
@@ -78,5 +105,7 @@ rmrf(dstSkill);
|
|
|
78
105
|
copyDir(srcSkill, dstSkill);
|
|
79
106
|
rmrf(dstAgents);
|
|
80
107
|
copyDir(srcAgents, dstAgents);
|
|
108
|
+
fs.writeFileSync(manifestDst, generateManifest());
|
|
81
109
|
console.log("[sync-assets] updated cli/assets/skill from src/auto-coding-skill");
|
|
82
110
|
console.log("[sync-assets] updated cli/assets/agents from src/agents");
|
|
111
|
+
console.log("[sync-assets] updated cli/assets/managed-install.json");
|