aodw-skill 0.9.0 → 0.11.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.
Files changed (38) hide show
  1. package/.aodw-next/01-core/git-discipline.md +99 -52
  2. package/.aodw-next/02-workflow/autopilot-goal-spec.md +122 -23
  3. package/.aodw-next/02-workflow/autopilot-protocol.md +31 -13
  4. package/.aodw-next/02-workflow/orca-multi-session.md +80 -0
  5. package/.aodw-next/02-workflow/rt-autopilot-readiness.md +13 -10
  6. package/.aodw-next/02-workflow/rt-manager.md +25 -18
  7. package/.aodw-next/02-workflow/spec-lite-autopilot-profile.md +6 -3
  8. package/.aodw-next/README.md +1 -1
  9. package/.aodw-next/SKILL.md +1 -1
  10. package/.aodw-next/manifest.yaml +8 -2
  11. package/.aodw-next/project.yaml +4 -0
  12. package/.aodw-next/skills/handover-pack/scripts/_common.sh +1 -1
  13. package/.aodw-next/skills/handover-pack/scripts/next-number.sh +3 -3
  14. package/.aodw-next/skills/handover-pack/templates/handover-template.md +3 -1
  15. package/.aodw-next/templates/aodw-kernel-loader-template.md +1 -0
  16. package/.aodw-next/templates/dev-session-guide-template.md +20 -0
  17. package/.aodw-next/templates/main-session-handover-template.md +19 -0
  18. package/.aodw-next/templates/orca-handoff-template.md +30 -0
  19. package/.aodw-next/templates/rt-autopilot-preflight.template.md +5 -4
  20. package/.aodw-next/templates/rt-lite.template.md +35 -0
  21. package/.aodw-next/templates/rt-loop-prompt.template.md +33 -14
  22. package/.aodw-next/templates/rt-meta-template.yaml +2 -2
  23. package/.aodw-next/templates/rt-plan.template.md +22 -12
  24. package/.aodw-next/templates/rt-state.template.json +1 -0
  25. package/.aodw-next/tools/install-skills.sh +2 -2
  26. package/.aodw-next/tools/next-rt-id.sh +39 -0
  27. package/.aodw-next/tools/rt-grv-continue.sh +183 -0
  28. package/.aodw-next/tools/rt-guard.sh +3 -3
  29. package/.aodw-next/tools/worktree-gc.sh +260 -0
  30. package/AODW_Adapters/antigravity/.agent/rules/aodw-next.md +1 -0
  31. package/AODW_Adapters/claude/CLAUDE.md +1 -0
  32. package/AODW_Adapters/cursor/.cursor/rules/aodw-autopilot-continue.mdc +42 -0
  33. package/AODW_Adapters/cursor/.cursor/rules/aodw-next.mdc +1 -0
  34. package/AODW_Adapters/openclaw/AGENTS.md +1 -0
  35. package/AODW_Adapters/openclaw/SKILL.md +1 -1
  36. package/bin/aodw.js +85 -8
  37. package/bin/commands/new.js +21 -25
  38. package/package.json +1 -1
package/bin/aodw.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { Command } from 'commander';
3
+ import { spawnSync } from 'child_process';
4
+ import { Command, Option } from 'commander';
4
5
  import inquirer from 'inquirer';
5
6
  import chalk from 'chalk';
6
7
  import fs from 'fs-extra';
@@ -65,6 +66,14 @@ function getSourcePaths() {
65
66
 
66
67
  const { SOURCE_CORE, SOURCE_ADAPTERS } = getSourcePaths();
67
68
  const SOURCE_TEMPLATE = path.join(SOURCE_CORE, 'templates/aodw-kernel-loader-template.md');
69
+ const ORCA_RULE = '02-workflow/orca-multi-session.md';
70
+ const ORCA_GUIDE = '06-project/dev-session-guide.md';
71
+ const ORCA_FILES = [
72
+ ORCA_RULE,
73
+ 'templates/orca-handoff-template.md',
74
+ 'templates/dev-session-guide-template.md',
75
+ 'templates/main-session-handover-template.md'
76
+ ];
68
77
 
69
78
  program
70
79
  .version(packageJson.version)
@@ -155,16 +164,17 @@ async function isTemplateFile(filePath) {
155
164
  }
156
165
 
157
166
  // Helper: Smart copy that preserves user-generated files
158
- async function copyCoreWithPreservation(sourceDir, targetDir, isUpdate = false) {
167
+ async function copyCoreWithPreservation(sourceDir, targetDir, isUpdate, excluded) {
159
168
  const entries = await fs.readdir(sourceDir, { withFileTypes: true });
160
169
 
161
170
  for (const entry of entries) {
162
171
  const srcPath = path.join(sourceDir, entry.name);
172
+ if (excluded.has(srcPath)) continue;
163
173
  const destPath = path.join(targetDir, entry.name);
164
174
 
165
175
  if (entry.isDirectory()) {
166
176
  await fs.ensureDir(destPath);
167
- await copyCoreWithPreservation(srcPath, destPath, isUpdate);
177
+ await copyCoreWithPreservation(srcPath, destPath, isUpdate, excluded);
168
178
  } else {
169
179
  // Check if this is a user-generated file
170
180
  if (isUserGeneratedFile(destPath, targetDir)) {
@@ -203,7 +213,7 @@ async function returnToMenu() {
203
213
  }]);
204
214
  }
205
215
 
206
- async function runInit() {
216
+ async function runInit({ devEnv, updating = false } = {}) {
207
217
  console.log(chalk.blue('🚀 正在初始化 AODW-Next...'));
208
218
 
209
219
  // --- Safeguard: Prevent running in AODW-Next Source Repo ---
@@ -290,16 +300,51 @@ async function runInit() {
290
300
  }
291
301
  ]);
292
302
 
303
+ if (devEnv === undefined) {
304
+ const previous = existingProjectConfig.dev_env;
305
+ if (previous === 'orca' || previous === 'none') {
306
+ devEnv = previous;
307
+ } else if (!updating) {
308
+ ({ devEnv } = await inquirer.prompt([{
309
+ type: 'list',
310
+ name: 'devEnv',
311
+ message: '请选择开发环境:',
312
+ choices: [
313
+ { name: 'Orca 多会话协作', value: 'orca' },
314
+ { name: '其他', value: 'none' }
315
+ ],
316
+ default: 'none'
317
+ }]));
318
+ }
319
+ }
320
+ const useOrca = devEnv === 'orca';
321
+
293
322
  // 1. Install Core Rules (channel-aware core dir)
294
323
  const targetCore = path.join(process.cwd(), CORE_DIRNAME);
295
324
  const isUpdate = fs.existsSync(targetCore);
325
+ const excluded = new Set(useOrca ? [] : ORCA_FILES.map(file => path.join(SOURCE_CORE, file)));
296
326
 
297
327
  if (isUpdate) {
298
328
  console.log(chalk.blue('正在更新核心规则(保留用户生成的文件)...'));
299
- await copyCoreWithPreservation(SOURCE_CORE, targetCore, true);
329
+ await copyCoreWithPreservation(SOURCE_CORE, targetCore, true, excluded);
300
330
  } else {
301
331
  console.log(chalk.blue('正在安装核心规则...'));
302
- await fs.copy(SOURCE_CORE, targetCore);
332
+ await fs.copy(SOURCE_CORE, targetCore, { filter: source => !excluded.has(source) });
333
+ }
334
+
335
+ // 开发环境说明只留在源模板,安装产物保留原有 YAML 字节和注释。
336
+ const projectConfigPath = path.join(targetCore, 'project.yaml');
337
+ const projectConfig = (await fs.readFile(projectConfigPath, 'utf8'))
338
+ .replace(/^# ── 开发环境(可选).*\n(?:# .+\n)+\n/m, '');
339
+ await fs.writeFile(projectConfigPath, useOrca ? projectConfig + 'dev_env: orca\n' : projectConfig, 'utf8');
340
+
341
+ if (!useOrca) {
342
+ const manifestPath = path.join(targetCore, 'manifest.yaml');
343
+ const manifest = await fs.readFile(manifestPath, 'utf8');
344
+ await fs.writeFile(manifestPath, manifest.replace(/^ - id: orca-multi-session\n(?: .+\n)+\n/m, ''), 'utf8');
345
+ if (existingProjectConfig.dev_env === 'orca') {
346
+ for (const file of ORCA_FILES) await fs.remove(path.join(targetCore, file));
347
+ }
303
348
  }
304
349
 
305
350
  // 2. Initialize project files from templates (for both init and update)
@@ -344,6 +389,20 @@ async function runInit() {
344
389
  console.log(chalk.gray(' • 项目文件已存在且为用户内容,跳过初始化'));
345
390
  }
346
391
 
392
+ const guidePath = path.join(targetCore, ORCA_GUIDE);
393
+ if (useOrca && !fs.existsSync(guidePath)) {
394
+ const gitOptions = { encoding: 'utf8' };
395
+ const remoteHead = spawnSync('git', ['symbolic-ref', '--quiet', 'refs/remotes/origin/HEAD'], gitOptions).stdout?.trim();
396
+ const trunkRefs = ['refs/remotes/origin/main', 'refs/remotes/origin/master', 'refs/heads/main', 'refs/heads/master'];
397
+ const refs = spawnSync('git', ['for-each-ref', '--format=%(refname)', ...trunkRefs], gitOptions).stdout?.split('\n') || [];
398
+ const trunkRef = remoteHead || trunkRefs.find(ref => refs.includes(ref)) ||
399
+ spawnSync('git', ['symbolic-ref', '--quiet', 'HEAD'], gitOptions).stdout?.trim();
400
+ const trunk = trunkRef?.replace(/^refs\/(remotes\/origin|heads)\//, '') || 'main';
401
+ const template = await fs.readFile(path.join(targetCore, 'templates/dev-session-guide-template.md'), 'utf8');
402
+ const guide = template.replace(/\{\{(PROJECT_NAME|TRUNK)\}\}/g, (_, key) => key === 'PROJECT_NAME' ? projectName : trunk);
403
+ await fs.writeFile(guidePath, guide, 'utf8');
404
+ }
405
+
347
406
  // 3. Install Adapters based on selected platforms
348
407
  console.log(chalk.blue('正在安装适配器...'));
349
408
 
@@ -431,6 +490,22 @@ async function runInit() {
431
490
  }
432
491
  }
433
492
 
493
+ if (useOrca) {
494
+ const platformEntries = {
495
+ cursor: ['.cursor/rules/aodw-next.mdc'],
496
+ antigravity: ['.agent/rules/aodw-next.md'],
497
+ claude: ['.claude/CLAUDE.md'],
498
+ openclaw: ['AGENTS.md', 'SKILL.md']
499
+ };
500
+ for (const platform of platforms) {
501
+ const prefix = platform === 'cursor' ? '@' : '';
502
+ const reference = `\n本项目用 Orca 多会话协作。先读 ${prefix}${CORE_DIRNAME}/${ORCA_RULE} 和 ${prefix}${CORE_DIRNAME}/${ORCA_GUIDE}\n`;
503
+ for (const entry of platformEntries[platform]) {
504
+ if (fs.existsSync(entry)) await fs.appendFile(entry, reference, 'utf8');
505
+ }
506
+ }
507
+ }
508
+
434
509
  // 4. Enable v0 guard hook automatically in user project
435
510
  await enableGuardHook({ silent: true });
436
511
 
@@ -441,7 +516,7 @@ async function runInit() {
441
516
  await printProjectInitPrompt({ writeFile: true });
442
517
  }
443
518
 
444
- async function runUpdate() {
519
+ async function runUpdate(options) {
445
520
  // 升级保护:先备份现有规范目录,再执行更新(copyCoreWithPreservation 仅保留
446
521
  // 06-project/ 与 tools-status.yaml,改过核心规则的项目需靠备份找回定制)
447
522
  const targetCore = path.join(process.cwd(), CORE_DIRNAME);
@@ -454,7 +529,7 @@ async function runUpdate() {
454
529
  console.log(chalk.yellow(' 若本项目定制过核心规则,请在升级后 diff 备份目录找回定制。'));
455
530
  }
456
531
  console.log(chalk.blue('🔄 正在更新 AODW-Next...'));
457
- await runInit();
532
+ await runInit({ ...options, updating: true });
458
533
  }
459
534
 
460
535
  async function runUninstall() {
@@ -717,11 +792,13 @@ async function showMainMenu() {
717
792
  program
718
793
  .command('init')
719
794
  .description('Initialize AODW-Next')
795
+ .addOption(new Option('--dev-env <environment>', '开发环境,跳过提问').choices(['orca', 'none']))
720
796
  .action(runInit);
721
797
 
722
798
  program
723
799
  .command('update')
724
800
  .description('Update AODW-Next')
801
+ .addOption(new Option('--dev-env <environment>', '覆盖已记录的开发环境').choices(['orca', 'none']))
725
802
  .action(runUpdate);
726
803
 
727
804
  program
@@ -1,3 +1,4 @@
1
+ import { spawnSync } from 'child_process';
1
2
  import fs from 'fs-extra';
2
3
  import path from 'path';
3
4
  import { fileURLToPath } from 'url';
@@ -43,29 +44,6 @@ function getProjectName() {
43
44
  return path.basename(process.cwd());
44
45
  }
45
46
 
46
- function getLocalMaxSeq() {
47
- const rtDir = path.join(process.cwd(), 'RT');
48
- if (!fs.existsSync(rtDir)) return 0;
49
-
50
- const dirs = fs.readdirSync(rtDir);
51
- let maxSeq = 0;
52
-
53
- for (const dir of dirs) {
54
- const match = dir.match(/^RT-(\d+)$/);
55
- if (match) {
56
- const seq = parseInt(match[1], 10);
57
- if (seq > maxSeq) maxSeq = seq;
58
- }
59
- }
60
-
61
- return maxSeq;
62
- }
63
-
64
- function getLocalNextId() {
65
- const maxSeq = getLocalMaxSeq();
66
- return `RT-${String(maxSeq + 1).padStart(3, '0')}`;
67
- }
68
-
69
47
  const EXECUTION_MODES = ['collaborative', 'autopilot'];
70
48
 
71
49
  async function resolveExecutionMode(options) {
@@ -101,6 +79,14 @@ async function resolveExecutionMode(options) {
101
79
  }
102
80
 
103
81
  export async function createNewRT(options) {
82
+ const root = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
83
+ if (root.status !== 0) {
84
+ console.error(chalk.red('错误:请在 Git 工作树里创建 RT。'));
85
+ process.exitCode = 1;
86
+ return;
87
+ }
88
+ process.chdir(root.stdout.replace(/\r?\n$/, ''));
89
+
104
90
  // Determine Project Name: Flag > Config/Package/Dir
105
91
  const project = options.project || getProjectName();
106
92
 
@@ -118,8 +104,18 @@ export async function createNewRT(options) {
118
104
 
119
105
  const executionMode = await resolveExecutionMode(options);
120
106
 
121
- // 固定独立模式:始终本地生成 RT-ID
122
- const id = getLocalNextId();
107
+ // 从 CLI 包取脚本,老项目无需先安装新版内核。
108
+ const binDir = path.dirname(fileURLToPath(import.meta.url));
109
+ const packagedScript = path.join(binDir, '../../.aodw-next/tools/next-rt-id.sh');
110
+ const script = fs.existsSync(packagedScript) ? packagedScript :
111
+ path.join(binDir, '../../../templates/.aodw-next/tools/next-rt-id.sh');
112
+ const result = spawnSync('bash', [script, '.'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] });
113
+ if (result.status !== 0) {
114
+ console.error(chalk.red('错误:next-rt-id.sh 开号失败,未创建 RT。'));
115
+ process.exitCode = 1;
116
+ return;
117
+ }
118
+ const id = result.stdout.trim();
123
119
  console.log(chalk.yellow(`Using local ID generation: ${id}`));
124
120
 
125
121
  // Create Directory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aodw-skill",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Next-channel CLI tool to scaffold AODW in your project",
5
5
  "main": "bin/aodw.js",
6
6
  "files": [