@elvis1513/auto-coding-skill 2.0.5 → 2.1.0

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/cli/src/index.js CHANGED
@@ -16,7 +16,7 @@ function takeValue(rest, index, flag){
16
16
  }
17
17
 
18
18
  function parseArgs(argv){
19
- const args = { cmd: null, ai: null, mode: "project", dest: null, force: false };
19
+ const args = { cmd: null, ai: null, mode: "project", dest: null, force: false, dryRun: false, json: false, projects: [] };
20
20
  const [,, cmd, ...rest] = argv;
21
21
  args.cmd = (!cmd || cmd === "-h" || cmd === "--help") ? "help" : cmd;
22
22
  for (let i = 0; i < rest.length; i++) {
@@ -33,8 +33,15 @@ function parseArgs(argv){
33
33
  args.dest = takeValue(rest, i, a);
34
34
  i += 1;
35
35
  }
36
+ else if (a === "--projects") {
37
+ args.projects.push(...takeValue(rest, i, a).split(",").map(x => x.trim()).filter(Boolean));
38
+ i += 1;
39
+ }
40
+ else if (a === "--dry-run") args.dryRun = true;
41
+ else if (a === "--json") args.json = true;
36
42
  else if (a === "--force") args.force = true;
37
43
  else if (a === "-h" || a === "--help") args.cmd = "help";
44
+ else if (!a.startsWith("--")) args.projects.push(a);
38
45
  else die(`unknown argument: ${a}`);
39
46
  }
40
47
  return args;
@@ -57,6 +64,153 @@ function copyDir(src, dst){
57
64
  }
58
65
  }
59
66
 
67
+ function listFiles(root, base = root){
68
+ if (!exists(root)) return [];
69
+ const out = [];
70
+ for (const ent of fs.readdirSync(root, { withFileTypes: true })) {
71
+ if (shouldSkip(ent.name)) continue;
72
+ const p = path.join(root, ent.name);
73
+ if (ent.isDirectory()) out.push(...listFiles(p, base));
74
+ else out.push(path.relative(base, p));
75
+ }
76
+ return out.sort();
77
+ }
78
+
79
+ function compareDirs(src, dst){
80
+ const diffs = [];
81
+ const srcFiles = listFiles(src);
82
+ const dstFiles = listFiles(dst);
83
+ const srcSet = new Set(srcFiles);
84
+ const dstSet = new Set(dstFiles);
85
+ for (const rel of srcFiles) {
86
+ if (!dstSet.has(rel)) {
87
+ diffs.push({ path: rel, status: "missing" });
88
+ continue;
89
+ }
90
+ const srcBuf = fs.readFileSync(path.join(src, rel));
91
+ const dstBuf = fs.readFileSync(path.join(dst, rel));
92
+ if (!srcBuf.equals(dstBuf)) diffs.push({ path: rel, status: "stale" });
93
+ }
94
+ for (const rel of dstFiles) {
95
+ if (!srcSet.has(rel)) diffs.push({ path: rel, status: "extra" });
96
+ }
97
+ return diffs;
98
+ }
99
+
100
+ function copyMissingDocs(assetSkill, project){
101
+ const srcDocs = path.join(assetSkill, "data", "templates", "docs");
102
+ const dstDocs = path.join(project, "docs");
103
+ const copied = [];
104
+ for (const rel of listFiles(srcDocs)) {
105
+ const src = path.join(srcDocs, rel);
106
+ const dst = path.join(dstDocs, rel);
107
+ if (!exists(dst)) {
108
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
109
+ fs.copyFileSync(src, dst);
110
+ copied.push(path.join("docs", rel));
111
+ }
112
+ }
113
+ return copied;
114
+ }
115
+
116
+ function readPackageVersion(){
117
+ const here = path.dirname(fileURLToPath(import.meta.url));
118
+ const pkgPath = path.resolve(here, "..", "..", "package.json");
119
+ try {
120
+ return JSON.parse(fs.readFileSync(pkgPath, "utf8")).version ?? "unknown";
121
+ } catch {
122
+ return "unknown";
123
+ }
124
+ }
125
+
126
+ function projectStatus(project, assetSkill, assetAgents){
127
+ const root = path.resolve(project);
128
+ const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
129
+ const agentsDir = path.join(root, ".agents", "agents");
130
+ const toolDir = path.join(root, "docs", "tools", "autopipeline");
131
+ const engineering = path.join(root, "docs", "ENGINEERING.md");
132
+ const requiredConfigTokens = [
133
+ "structure:",
134
+ "optimization:",
135
+ "evidence_log:",
136
+ "health_baseline:",
137
+ "optimization_backlog:",
138
+ "structure_standard:",
139
+ ];
140
+ let missingConfigTokens = requiredConfigTokens;
141
+ if (exists(engineering)) {
142
+ const text = fs.readFileSync(engineering, "utf8");
143
+ missingConfigTokens = requiredConfigTokens.filter(token => !text.includes(token));
144
+ }
145
+ const scriptDiffs = [];
146
+ for (const name of ["ap.py", "core.py", "http_checks.py"]) {
147
+ const src = path.join(assetSkill, "scripts", name);
148
+ const dst = path.join(toolDir, name);
149
+ if (!exists(dst)) scriptDiffs.push({ path: path.join("docs/tools/autopipeline", name), status: "missing" });
150
+ else if (!fs.readFileSync(src).equals(fs.readFileSync(dst))) scriptDiffs.push({ path: path.join("docs/tools/autopipeline", name), status: "stale" });
151
+ }
152
+ const missingDocs = [];
153
+ const srcDocs = path.join(assetSkill, "data", "templates", "docs");
154
+ for (const rel of listFiles(srcDocs)) {
155
+ if (!exists(path.join(root, "docs", rel))) missingDocs.push(path.join("docs", rel));
156
+ }
157
+ const skillDiffs = exists(skillDir) ? compareDirs(assetSkill, skillDir) : [{ path: ".agents/skills/auto-coding-skill", status: "missing" }];
158
+ const agentDiffs = exists(agentsDir) ? compareDirs(assetAgents, agentsDir) : [{ path: ".agents/agents", status: "missing" }];
159
+ const ok = skillDiffs.length === 0 && agentDiffs.length === 0 && scriptDiffs.length === 0 && missingDocs.length === 0 && missingConfigTokens.length === 0;
160
+ return {
161
+ project: root,
162
+ ok,
163
+ skillDiffs,
164
+ agentDiffs,
165
+ scriptDiffs,
166
+ missingDocs,
167
+ missingConfigTokens,
168
+ next: missingConfigTokens.length ? "run project-local ap.py upgrade --write to merge docs/ENGINEERING.md safely" : "",
169
+ };
170
+ }
171
+
172
+ function printProjectStatus(result){
173
+ console.log(`[autocoding] project=${result.project}`);
174
+ console.log(`[autocoding] ok=${result.ok}`);
175
+ for (const [label, items] of [["skill", result.skillDiffs], ["agents", result.agentDiffs], ["scripts", result.scriptDiffs]]) {
176
+ for (const item of items) console.log(`[autocoding] ${label} ${item.status}: ${item.path}`);
177
+ }
178
+ for (const item of result.missingDocs) console.log(`[autocoding] doc missing: ${item}`);
179
+ for (const item of result.missingConfigTokens) console.log(`[autocoding] config missing token: ${item}`);
180
+ if (result.next) console.log(`[autocoding] next: ${result.next}`);
181
+ }
182
+
183
+ function syncProject(project, assetSkill, assetAgents, dryRun){
184
+ const root = path.resolve(project);
185
+ const actions = [];
186
+ const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
187
+ const agentsDir = path.join(root, ".agents", "agents");
188
+ const toolDir = path.join(root, "docs", "tools", "autopipeline");
189
+ actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, skillDir) });
190
+ actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, agentsDir) });
191
+ for (const name of ["ap.py", "core.py", "http_checks.py"]) {
192
+ actions.push({ action: dryRun ? "would-sync" : "sync", path: path.join("docs/tools/autopipeline", name) });
193
+ }
194
+ if (!dryRun) {
195
+ rmrf(skillDir);
196
+ copyDir(assetSkill, skillDir);
197
+ rmrf(agentsDir);
198
+ copyDir(assetAgents, agentsDir);
199
+ fs.mkdirSync(toolDir, { recursive: true });
200
+ for (const name of ["ap.py", "core.py", "http_checks.py"]) {
201
+ fs.copyFileSync(path.join(assetSkill, "scripts", name), path.join(toolDir, name));
202
+ }
203
+ for (const copied of copyMissingDocs(assetSkill, root)) actions.push({ action: "create", path: copied });
204
+ } else {
205
+ const srcDocs = path.join(assetSkill, "data", "templates", "docs");
206
+ for (const rel of listFiles(srcDocs)) {
207
+ if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
208
+ }
209
+ }
210
+ actions.push({ action: "manual", path: "docs/ENGINEERING.md", detail: "merge with ap.py upgrade --write" });
211
+ return { project: root, dryRun, actions };
212
+ }
213
+
60
214
  function projectRoot(){ return process.cwd(); }
61
215
 
62
216
  function resolveTargetDir(ai, mode, destOverride){
@@ -99,28 +253,61 @@ autocoding - install auto-coding-skill (Claude Code + Codex CLI)
99
253
 
100
254
  Usage:
101
255
  autocoding init --ai claude|codex|all [--mode project|global] [--dest <path>] [--force]
256
+ autocoding status --projects <path[,path...]> [--json]
257
+ autocoding sync --projects <path[,path...]> [--dry-run] [--json]
102
258
 
103
259
  Examples:
104
260
  autocoding init --ai claude
105
261
  autocoding init --ai codex
106
262
  autocoding init --ai all --mode project
107
263
  autocoding init --ai all --dest /tmp/skills
264
+ autocoding status --projects /Users/elvis/Product/xjmate,/Users/elvis/Product/geesight
265
+ autocoding sync --projects /Users/elvis/Product/xjmate --dry-run
108
266
  `);
109
267
  process.exit(0);
110
268
  }
111
269
 
112
- if (args.cmd !== "init") die(`unknown command: ${args.cmd}`);
113
-
114
- const ai = (args.ai ?? "").toLowerCase();
115
- const targets = ai === "all" ? ["claude", "codex"] : [ai];
116
- if (!(["claude", "codex", "all"].includes(ai))) die(`--ai must be claude|codex|all`);
117
-
118
270
  const here = path.dirname(fileURLToPath(import.meta.url));
119
271
  const assetSkill = path.resolve(here, "..", "assets", "skill");
120
272
  const assetAgents = path.resolve(here, "..", "assets", "agents");
121
273
  if (!exists(assetSkill)) die(`missing assets at ${assetSkill}`);
122
274
  if (!exists(assetAgents)) die(`missing assets at ${assetAgents}`);
123
275
 
276
+ if (args.cmd === "status") {
277
+ const projects = args.projects.length ? args.projects : [projectRoot()];
278
+ const results = projects.map(project => projectStatus(project, assetSkill, assetAgents));
279
+ if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
280
+ else {
281
+ console.log(`[autocoding] version=${readPackageVersion()}`);
282
+ for (const result of results) printProjectStatus(result);
283
+ }
284
+ process.exit(results.every(result => result.ok) ? 0 : 2);
285
+ }
286
+
287
+ if (args.cmd === "sync") {
288
+ const projects = args.projects.length ? args.projects : [projectRoot()];
289
+ const results = projects.map(project => syncProject(project, assetSkill, assetAgents, args.dryRun));
290
+ if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
291
+ else {
292
+ console.log(`[autocoding] version=${readPackageVersion()}`);
293
+ for (const result of results) {
294
+ console.log(`[autocoding] project=${result.project}`);
295
+ console.log(`[autocoding] dryRun=${result.dryRun}`);
296
+ for (const item of result.actions) {
297
+ const detail = item.detail ? ` - ${item.detail}` : "";
298
+ console.log(`[autocoding] ${item.action}: ${item.path}${detail}`);
299
+ }
300
+ }
301
+ }
302
+ process.exit(0);
303
+ }
304
+
305
+ if (args.cmd !== "init") die(`unknown command: ${args.cmd}`);
306
+
307
+ const ai = (args.ai ?? "").toLowerCase();
308
+ const targets = ai === "all" ? ["claude", "codex"] : [ai];
309
+ if (!(["claude", "codex", "all"].includes(ai))) die(`--ai must be claude|codex|all`);
310
+
124
311
  for (const t of targets) {
125
312
  const dstOverride = args.dest
126
313
  ? (targets.length > 1 ? path.join(args.dest, t) : args.dest)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvis1513/auto-coding-skill",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "CLI installer for auto-coding-skill (Claude Code + Codex CLI) with Go fullstack + Jenkins workflow support.",
5
5
  "type": "module",
6
6
  "bin": {