@gong-ym/ai-spec-auto 0.2.9 → 0.2.11

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.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ var cp = require('child_process');
3
+ var path = require('path');
4
+ var cliPath = path.join(__dirname, 'cli.js');
5
+ cp.execFileSync('node', [cliPath].concat(process.argv.slice(2)), {
6
+ stdio: 'inherit',
7
+ cwd: process.cwd(),
8
+ env: process.env
9
+ });
package/bin/cli.js CHANGED
@@ -54,7 +54,9 @@ function shouldUseIntegrityCommand(args, cwd) {
54
54
  (async () => {
55
55
  try {
56
56
  if (args.length > 0 && VERSION_FLAGS.has(args[0])) {
57
- const pkg = require(path.join(pkgRoot, 'package.json'));
57
+ const pkgPath = path.join(pkgRoot, 'package.json');
58
+ const pkgContent = fs.readFileSync(pkgPath, 'utf-8');
59
+ const pkg = JSON.parse(pkgContent);
58
60
  console.log(pkg.version);
59
61
  process.exit(0);
60
62
  }
@@ -63,7 +65,7 @@ function shouldUseIntegrityCommand(args, cwd) {
63
65
  // 任何失败都会静默降级为继续跑当前 CLI,不影响主流程。
64
66
  if (args[0] === 'update') {
65
67
  try {
66
- const selfUpgrade = require('./self-upgrade');
68
+ const selfUpgrade = await import('./self-upgrade.js');
67
69
  const result = selfUpgrade.maybeSelfUpgradeForUpdate({
68
70
  pkgRoot,
69
71
  args,
@@ -83,7 +85,7 @@ function shouldUseIntegrityCommand(args, cwd) {
83
85
 
84
86
  if (env.AI_SPEC_SKIP_LAUNCHER_SYNC !== '1') {
85
87
  try {
86
- const runtimeLauncher = require('./runtime-launcher');
88
+ const runtimeLauncher = await import('./runtime-launcher.js');
87
89
  runtimeLauncher.ensureGlobalLauncher({
88
90
  pkgRoot,
89
91
  env,
@@ -94,82 +96,82 @@ function shouldUseIntegrityCommand(args, cwd) {
94
96
  }
95
97
 
96
98
  if (args[0] === 'scan') {
97
- const scanCommand = require('./scan');
99
+ const scanCommand = await import('./scan.js');
98
100
  process.exit(await scanCommand.main(args.slice(1)));
99
101
  }
100
102
 
101
103
  if (shouldUseRecommendInit(args, opts.cwd)) {
102
- const initCommand = require('./init-command');
104
+ const initCommand = await import('./init-command.js');
103
105
  process.exit(await initCommand.main(args.slice(1)));
104
106
  }
105
107
 
106
108
  if (shouldUseIntegrityCommand(args, opts.cwd)) {
107
- const command = args[0] === 'sync' ? require('./sync-command') : require('./check-command');
109
+ const command = args[0] === 'sync' ? await import('./sync-command.js') : await import('./check-command.js');
108
110
  process.exit(await command.main(args.slice(1)));
109
111
  }
110
112
 
111
113
  if (args[0] === 'guard') {
112
- const guardCommand = require('./guard-command');
114
+ const guardCommand = await import('./guard-command.js');
113
115
  process.exit(await guardCommand.main(args.slice(1)));
114
116
  }
115
117
 
116
118
  if (args[0] === 'context') {
117
- const contextCommand = require('./context-command');
119
+ const contextCommand = await import('./context-command.js');
118
120
  process.exit(await contextCommand.main(args.slice(1)));
119
121
  }
120
122
 
121
123
  if (args[0] === 'worktree') {
122
- const worktreeCommand = require('./worktree-command');
124
+ const worktreeCommand = await import('./worktree-command.js');
123
125
  process.exit(await worktreeCommand.main(args.slice(1)));
124
126
  }
125
127
 
126
128
  if (args[0] === 'executor') {
127
- const executorCommand = require('./executor-command');
129
+ const executorCommand = await import('./executor-command.js');
128
130
  process.exit(await executorCommand.main(args.slice(1)));
129
131
  }
130
132
 
131
133
  if (args[0] === 'spec-start') {
132
- const specCommand = require('./spec-command');
134
+ const specCommand = await import('./spec-command.js');
133
135
  process.exit(await specCommand.mainStart(args.slice(1)));
134
136
  }
135
137
 
136
138
  if (args[0] === 'spec-status') {
137
- const specCommand = require('./spec-command');
139
+ const specCommand = await import('./spec-command.js');
138
140
  process.exit(await specCommand.mainStatus(args.slice(1)));
139
141
  }
140
142
 
141
143
  if (args[0] === 'spec-continue') {
142
- const specCommand = require('./spec-command');
144
+ const specCommand = await import('./spec-command.js');
143
145
  process.exit(await specCommand.mainContinue(args.slice(1)));
144
146
  }
145
147
 
146
148
  if (args[0] === 'spec-list') {
147
- const specCommand = require('./spec-command');
149
+ const specCommand = await import('./spec-command.js');
148
150
  process.exit(await specCommand.mainList(args.slice(1)));
149
151
  }
150
152
 
151
153
  if (args[0] === 'spec-detail') {
152
- const specCommand = require('./spec-command');
154
+ const specCommand = await import('./spec-command.js');
153
155
  process.exit(await specCommand.mainSpecStatus(args.slice(1)));
154
156
  }
155
157
 
156
158
  if (args[0] === 'repair') {
157
- const repairCommand = require('./repair-command');
159
+ const repairCommand = await import('./repair-command.js');
158
160
  process.exit(await repairCommand.main(args.slice(1)));
159
161
  }
160
162
 
161
163
  if (args[0] === 'report') {
162
- const reportCommand = require('./report-command');
164
+ const reportCommand = await import('./report-command.js');
163
165
  process.exit(await reportCommand.main(args.slice(1)));
164
166
  }
165
167
 
166
168
  if (args.length === 0 || INSTALL_COMMANDS.has(args[0])) {
167
- const installWorkflow = require('./install-workflow');
169
+ const installWorkflow = await import('./install-workflow.js');
168
170
  // 切面:遥测仅观测,不改变 main(args) 的返回值/副作用/异常。
169
171
  // 模块加载/运行失败均自动降级为透明 wrap,主流程零影响。
170
172
  let telemetry = { wrap: function (_c, fn) { return fn(); } };
171
173
  try {
172
- telemetry = require('./telemetry');
174
+ telemetry = await import('./telemetry.js');
173
175
  } catch (_error) {
174
176
  // 整个 telemetry 目录被移除或加载失败时,保持透明 wrap。
175
177
  }
@@ -179,29 +181,29 @@ function shouldUseIntegrityCommand(args, cwd) {
179
181
  }
180
182
 
181
183
  if (args[0] === 'runtime-state') {
182
- const runtimeState = require('./runtime-state');
184
+ const runtimeState = await import('./runtime-state.js');
183
185
  process.exit(runtimeState.main(args.slice(1)));
184
186
  }
185
187
 
186
188
  if (args[0] === 'validate-registry') {
187
- const validateRegistry = require('./validate-registry');
189
+ const validateRegistry = await import('./validate-registry.js');
188
190
  process.exit(validateRegistry.main(args.slice(1)));
189
191
  }
190
192
 
191
193
  if (args[0] === 'manifest-export') {
192
- const manifestExport = require('./manifest-export');
194
+ const manifestExport = await import('./manifest-export.js');
193
195
  process.exit(await manifestExport.main(args.slice(1)));
194
196
  }
195
197
 
196
198
  if (args[0] === 'ide') {
197
- const ideCommand = require('./ide-command');
199
+ const ideCommand = await import('./ide-command.js');
198
200
  process.exit(await ideCommand.main(args.slice(1)));
199
201
  }
200
202
 
201
203
  if (args[0] === 'hub') {
202
204
  // 切面接入:Hub 方案包能力独立在 hub-command 内部实现。
203
205
  // 加载或执行失败只影响 hub 子命令,不改变 init/sync/check 等旧主链。
204
- const hubCommand = require('./hub-command');
206
+ const hubCommand = await import('./hub-command.js');
205
207
  process.exit(await hubCommand.main(args.slice(1)));
206
208
  }
207
209
 
@@ -217,7 +219,7 @@ function shouldUseIntegrityCommand(args, cwd) {
217
219
  throw new Error('task-orchestrator-runner is an internal runtime module; call it from the AI host layer instead of ai-spec-auto CLI');
218
220
  }
219
221
 
220
- const runtimeBootstrap = require('./runtime-bootstrap');
222
+ const runtimeBootstrap = await import('./runtime-bootstrap.js');
221
223
  const runtimeHandOff = await runtimeBootstrap.maybeHandOffToRuntime({
222
224
  pkgRoot,
223
225
  args,
@@ -230,61 +232,61 @@ function shouldUseIntegrityCommand(args, cwd) {
230
232
  }
231
233
 
232
234
  if (args[0] === 'protocol-step') {
233
- await require('../internal/visual-hooks/inbox-consumer').consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
234
- const protocolWorkflow = require('./protocol-workflow');
235
+ await (await import('../internal/visual-hooks/inbox-consumer.js')).consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
236
+ const protocolWorkflow = await import('./protocol-workflow.js');
235
237
  process.exit(await protocolWorkflow.main('step', args.slice(1)));
236
238
  }
237
239
 
238
240
  if (args[0] === 'protocol-advance') {
239
- await require('../internal/visual-hooks/inbox-consumer').consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
240
- const protocolWorkflow = require('./protocol-workflow');
241
+ await (await import('../internal/visual-hooks/inbox-consumer.js')).consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
242
+ const protocolWorkflow = await import('./protocol-workflow.js');
241
243
  process.exit(await protocolWorkflow.main('advance', args.slice(1)));
242
244
  }
243
245
 
244
246
  if (args[0] === 'protocol-update') {
245
- await require('../internal/visual-hooks/inbox-consumer').consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
246
- const protocolWorkflow = require('./protocol-workflow');
247
+ await (await import('../internal/visual-hooks/inbox-consumer.js')).consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
248
+ const protocolWorkflow = await import('./protocol-workflow.js');
247
249
  process.exit(await protocolWorkflow.main('update', args.slice(1)));
248
250
  }
249
251
 
250
252
  if (args[0] === 'protocol-stop') {
251
- const protocolWorkflow = require('./protocol-workflow');
253
+ const protocolWorkflow = await import('./protocol-workflow.js');
252
254
  process.exit(await protocolWorkflow.main('stop', args.slice(1)));
253
255
  }
254
256
 
255
257
  if (args[0] === 'protocol-status') {
256
- await require('../internal/visual-hooks/inbox-consumer').consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
257
- const protocolWorkflow = require('./protocol-workflow');
258
+ await (await import('../internal/visual-hooks/inbox-consumer.js')).consumeInbox({ targetDir: opts.cwd, timeoutMs: 50 }).catch(() => {});
259
+ const protocolWorkflow = await import('./protocol-workflow.js');
258
260
  process.exit(await protocolWorkflow.main('status', args.slice(1)));
259
261
  }
260
262
 
261
263
  if (args[0] === 'expert-dispatch') {
262
- const expertDispatch = require('./expert-dispatch');
264
+ const expertDispatch = await import('./expert-dispatch.js');
263
265
  process.exit(expertDispatch.main(args.slice(1)));
264
266
  }
265
267
 
266
268
  if (args[0] === 'expert-executor') {
267
- const expertExecutor = require('./expert-executor');
269
+ const expertExecutor = await import('./expert-executor.js');
268
270
  process.exit(await expertExecutor.main(args.slice(1)));
269
271
  }
270
272
 
271
273
  if (args[0] === 'demo-runtime-smoke') {
272
- const demoRuntimeSmoke = require('./demo-runtime-smoke');
274
+ const demoRuntimeSmoke = await import('./demo-runtime-smoke.js');
273
275
  process.exit(demoRuntimeSmoke.main(args.slice(1)));
274
276
  }
275
277
 
276
278
  if (args[0] === 'archive-change') {
277
- const archiveChange = require('./archive-change');
279
+ const archiveChange = await import('./archive-change.js');
278
280
  process.exit(await archiveChange.main(args.slice(1)));
279
281
  }
280
282
 
281
283
  if (args[0] === 'visual-bridge') {
282
- const visualBridge = require('./visual-bridge');
284
+ const visualBridge = await import('./visual-bridge.js');
283
285
  process.exit(await visualBridge.main(args.slice(1)));
284
286
  }
285
287
 
286
288
  if (args[0] === 'visual') {
287
- const visualCommand = require('./visual-command');
289
+ const visualCommand = await import('./visual-command.js');
288
290
  process.exit(await visualCommand.main(args.slice(1)));
289
291
  }
290
292
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gong-ym/ai-spec-auto",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "type": "module",
5
5
  "description": "AI Coding 团队规范驱动开发 CLI — 一键安装规范、技能与工具配置",
6
6
  "homepage": "https://github.com/Colouful/engineered-spec#readme",
@@ -12,7 +12,7 @@
12
12
  "url": "https://github.com/Colouful/engineered-spec/issues"
13
13
  },
14
14
  "bin": {
15
- "ai-spec-auto": "./bin/ai-spec-auto.js"
15
+ "ai-spec-auto": "./bin/ai-spec-auto.cjs"
16
16
  },
17
17
  "maintainers": [
18
18
  "zhenwei.li",
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- // CommonJS wrapper for ES module CLI
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
-
6
- const cliPath = path.join(__dirname, 'cli.js');
7
-
8
- const child = spawn('node', [cliPath, ...process.argv.slice(2)], {
9
- stdio: 'inherit',
10
- cwd: process.cwd(),
11
- env: process.env
12
- });
13
-
14
- child.on('close', (code) => {
15
- process.exit(code);
16
- });