aodw-skill 0.7.3

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 (188) hide show
  1. package/.aodw/01-core/ai-interaction-rules.md +218 -0
  2. package/.aodw/01-core/ai-knowledge-rules.md +302 -0
  3. package/.aodw/01-core/ai-project-overview-rules.md +284 -0
  4. package/.aodw/01-core/aodw-constitution-summary.md +20 -0
  5. package/.aodw/01-core/aodw-constitution.md +419 -0
  6. package/.aodw/01-core/csf-thinking-framework.md +373 -0
  7. package/.aodw/01-core/git-discipline.md +226 -0
  8. package/.aodw/01-core/module-doc-rules.md +90 -0
  9. package/.aodw/02-workflow/aodw-development-stages.md +235 -0
  10. package/.aodw/02-workflow/rt-id-generation-rules.md +267 -0
  11. package/.aodw/02-workflow/rt-manager-summary.md +15 -0
  12. package/.aodw/02-workflow/rt-manager.md +399 -0
  13. package/.aodw/02-workflow/spec-full-profile-summary.md +13 -0
  14. package/.aodw/02-workflow/spec-full-profile.md +391 -0
  15. package/.aodw/02-workflow/spec-lite-profile.md +313 -0
  16. package/.aodw/02-workflow/ui-workflow-rules.md +334 -0
  17. package/.aodw/03-standards/ai-coding-rules-common.md +89 -0
  18. package/.aodw/03-standards/ai-coding-rules.md +370 -0
  19. package/.aodw/03-standards/stacks/java-springboot/ai-coding-rules-backend.md +100 -0
  20. package/.aodw/03-standards/stacks/python-fastapi/ai-coding-rules-backend.md +612 -0
  21. package/.aodw/03-standards/stacks/react-typescript/ai-coding-rules-frontend.md +291 -0
  22. package/.aodw/03-standards/stacks/vue2/ai-coding-rules-frontend.md +97 -0
  23. package/.aodw/03-standards/ui-kit/ui-kit.md +163 -0
  24. package/.aodw/04-auditors/aodw-development-auditor-rules.md +470 -0
  25. package/.aodw/04-auditors/aodw-full-auditor-rules.md +365 -0
  26. package/.aodw/04-auditors/aodw-requirement-auditor-rules.md +408 -0
  27. package/.aodw/05-tooling/ai-tools-init-rules.md +465 -0
  28. package/.aodw/06-project/ai-overview.md +116 -0
  29. package/.aodw/06-project/modules-index.yaml +11 -0
  30. package/.aodw/07-optimization/token-usage-analysis.md +253 -0
  31. package/.aodw/README.md +26 -0
  32. package/.aodw/RELEASE-CHECKLIST.md +144 -0
  33. package/.aodw/config.yaml +2 -0
  34. package/.aodw/manifest.yaml +98 -0
  35. package/.aodw/templates/SOURCE-TO-DISTRIBUTION-GUIDE.md +276 -0
  36. package/.aodw/templates/TEMPLATE-APPLICATION-GUIDE.md +246 -0
  37. package/.aodw/templates/aodw-kernel-loader-template.md +70 -0
  38. package/.aodw/templates/audit-report-template.md +232 -0
  39. package/.aodw/templates/changelog-template.md +16 -0
  40. package/.aodw/templates/checklists/coding-standards-template.md +110 -0
  41. package/.aodw/templates/csf-review-template.md +201 -0
  42. package/.aodw/templates/impact-template.md +17 -0
  43. package/.aodw/templates/invariants-template.md +12 -0
  44. package/.aodw/templates/module-readme-template.md +39 -0
  45. package/.aodw/templates/plan-lite-template.md +11 -0
  46. package/.aodw/templates/rt-decision-template.md +13 -0
  47. package/.aodw/templates/rt-intake-template.md +33 -0
  48. package/.aodw/templates/rt-meta-template.yaml +43 -0
  49. package/.aodw/templates/spec-lite-template.md +17 -0
  50. package/.aodw/templates/tests-template.md +13 -0
  51. package/.aodw/templates/tools-config/README.md +80 -0
  52. package/.aodw/templates/tools-config/backend/black.config.template.toml +6 -0
  53. package/.aodw/templates/tools-config/backend/pre-commit.config.template.yaml +16 -0
  54. package/.aodw/templates/tools-config/backend/ruff.config.template.toml +23 -0
  55. package/.aodw/templates/tools-config/frontend/eslint.config.template.json +113 -0
  56. package/.aodw/templates/tools-config/frontend/prettier.config.template.json +10 -0
  57. package/.aodw/templates/tools-config/frontend/tsconfig.paths.template.json +11 -0
  58. package/.aodw/workflow-guide.md +51 -0
  59. package/AODW_Adapters/README.md +143 -0
  60. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-check.md +7 -0
  61. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-done.md +7 -0
  62. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-full.md +7 -0
  63. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-governance.md +7 -0
  64. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-impact.md +7 -0
  65. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-init.md +7 -0
  66. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-invariants.md +7 -0
  67. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-lite.md +7 -0
  68. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-module.md +7 -0
  69. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-new.md +7 -0
  70. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-open.md +7 -0
  71. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-pause.md +7 -0
  72. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-resume.md +7 -0
  73. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-tests.md +7 -0
  74. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw-upgrade.md +7 -0
  75. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/.agent/rules/aodw.md +35 -0
  76. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-check.md +16 -0
  77. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-done.md +16 -0
  78. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-full.md +14 -0
  79. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-governance.md +13 -0
  80. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-impact.md +13 -0
  81. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-init.md +13 -0
  82. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-invariants.md +13 -0
  83. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-lite.md +14 -0
  84. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-module.md +13 -0
  85. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-new.md +30 -0
  86. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-open.md +10 -0
  87. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-pause.md +12 -0
  88. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-resume.md +12 -0
  89. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-tests.md +13 -0
  90. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw-upgrade.md +12 -0
  91. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/antigravity/global_workflows/aodw.md +18 -0
  92. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/claude/CLAUDE.md +17 -0
  93. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-check.md +30 -0
  94. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-done.md +52 -0
  95. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-full.md +31 -0
  96. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-governance.md +34 -0
  97. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-impact.md +25 -0
  98. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-init.md +75 -0
  99. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-invariants.md +29 -0
  100. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-lite.md +23 -0
  101. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-module.md +24 -0
  102. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-new.md +70 -0
  103. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-open.md +19 -0
  104. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-pause.md +19 -0
  105. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-resume.md +20 -0
  106. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-tests.md +26 -0
  107. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw-upgrade.md +27 -0
  108. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/aodw.md +69 -0
  109. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/deploypromote.md +20 -0
  110. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/commands/featuretotester.md +32 -0
  111. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/deploy/feature_to_master_push_test_local.sh +390 -0
  112. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/deploy/promote_only.sh +210 -0
  113. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/deploy/rollback_prod.sh +99 -0
  114. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/cursor/.cursor/rules/aodw.mdc +26 -0
  115. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-check.md +29 -0
  116. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-done.md +52 -0
  117. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-full.md +30 -0
  118. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-governance.md +33 -0
  119. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-impact.md +24 -0
  120. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-init.md +75 -0
  121. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-invariants.md +28 -0
  122. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-lite.md +22 -0
  123. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-module.md +23 -0
  124. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-new.md +92 -0
  125. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-open.md +18 -0
  126. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-pause.md +18 -0
  127. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-resume.md +19 -0
  128. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-tests.md +25 -0
  129. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw-upgrade.md +26 -0
  130. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/.agent/rules/aodw.md +68 -0
  131. package/AODW_Adapters/_backup/v3.1.0-pre-refactor/gemini/GEMINI.md +17 -0
  132. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-analyze.md +15 -0
  133. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-complete.md +15 -0
  134. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-control.md +14 -0
  135. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-decide.md +16 -0
  136. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-governance.md +7 -0
  137. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-implement.md +16 -0
  138. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-init.md +7 -0
  139. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-intake.md +15 -0
  140. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-open.md +7 -0
  141. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-simplified.md +107 -0
  142. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/.agent/rules/aodw-verify.md +14 -0
  143. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-analyze.md +24 -0
  144. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-complete.md +23 -0
  145. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-control.md +21 -0
  146. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-decide.md +26 -0
  147. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-governance.md +13 -0
  148. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-implement.md +21 -0
  149. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-init.md +13 -0
  150. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-intake.md +28 -0
  151. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-open.md +10 -0
  152. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw-verify.md +20 -0
  153. package/AODW_Adapters/_backup/v4.0.0-simplified/antigravity/global_workflows/aodw.md +18 -0
  154. package/AODW_Adapters/antigravity/.agent/rules/aodw.md +74 -0
  155. package/AODW_Adapters/claude/CLAUDE.md +70 -0
  156. package/AODW_Adapters/cursor/.cursor/commands/README.md +37 -0
  157. package/AODW_Adapters/cursor/.cursor/rules/aodw.mdc +77 -0
  158. package/AODW_Adapters/gemini/.agent/rules/aodw-analyze.md +15 -0
  159. package/AODW_Adapters/gemini/.agent/rules/aodw-complete.md +15 -0
  160. package/AODW_Adapters/gemini/.agent/rules/aodw-control.md +14 -0
  161. package/AODW_Adapters/gemini/.agent/rules/aodw-decide.md +16 -0
  162. package/AODW_Adapters/gemini/.agent/rules/aodw-governance.md +33 -0
  163. package/AODW_Adapters/gemini/.agent/rules/aodw-implement.md +16 -0
  164. package/AODW_Adapters/gemini/.agent/rules/aodw-init.md +75 -0
  165. package/AODW_Adapters/gemini/.agent/rules/aodw-intake.md +15 -0
  166. package/AODW_Adapters/gemini/.agent/rules/aodw-open.md +18 -0
  167. package/AODW_Adapters/gemini/.agent/rules/aodw-verify.md +14 -0
  168. package/AODW_Adapters/gemini/.agent/rules/aodw.md +70 -0
  169. package/AODW_Adapters/gemini/GEMINI.md +17 -0
  170. package/AODW_Adapters/general/.github/copilot-instructions.md +34 -0
  171. package/AODW_Adapters/general/AGENTS.md +70 -0
  172. package/README.md +118 -0
  173. package/bin/aodw.js +627 -0
  174. package/bin/commands/init-overview.js +801 -0
  175. package/bin/commands/init-tools.js +811 -0
  176. package/bin/commands/new.js +235 -0
  177. package/bin/commands/serve.js +79 -0
  178. package/bin/processors/index.js +109 -0
  179. package/bin/update-adapters-from-template.js +89 -0
  180. package/bin/utils/config.js +56 -0
  181. package/docs/README.md +26 -0
  182. package/docs/adapter-evaluation.md +55 -0
  183. package/docs/backend-guidelines.md +335 -0
  184. package/docs/frontend-guidelines.md +266 -0
  185. package/docs/installation-variants.md +88 -0
  186. package/docs/migration-guide-0.2.0.md +250 -0
  187. package/docs/platform-matrix.md +83 -0
  188. package/package.json +40 -0
package/bin/aodw.js ADDED
@@ -0,0 +1,627 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import inquirer from 'inquirer';
5
+ import chalk from 'chalk';
6
+ import fs from 'fs-extra';
7
+ import path from 'path';
8
+ import { createRequire } from 'module';
9
+ import { fileURLToPath } from 'url';
10
+ import fetch from 'node-fetch';
11
+
12
+ import {
13
+ AntigravityProcessor,
14
+ CursorProcessor,
15
+ CopilotProcessor,
16
+ ClaudeProcessor,
17
+ GeminiProcessor,
18
+ GeneralProcessor,
19
+ BaseProcessor
20
+ } from './processors/index.js';
21
+
22
+ import { serve } from './commands/serve.js';
23
+ import { createNewRT } from './commands/new.js';
24
+ import { initTools } from './commands/init-tools.js';
25
+ import { initOverview } from './commands/init-overview.js';
26
+ import { saveProjectConfig, saveUserConfig, getProjectConfig, getUserConfig } from './utils/config.js';
27
+
28
+ const require = createRequire(import.meta.url);
29
+ const packageJson = require('../package.json');
30
+
31
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
32
+ const program = new Command();
33
+
34
+ // Channel detection (legacy / next)
35
+ const DEFAULT_CHANNEL = packageJson.name === 'aodw-skill' ? 'next' : 'legacy';
36
+ const CHANNEL = process.env.AODW_CHANNEL || DEFAULT_CHANNEL;
37
+ const CORE_DIRNAME = CHANNEL === 'next' ? '.aodw-next' : '.aodw';
38
+ const ADAPTER_SUFFIX = CHANNEL === 'next' ? '-next' : '';
39
+ const PACKAGE_NAME = process.env.AODW_PACKAGE_NAME || packageJson.name || 'aodw';
40
+
41
+ process.env.AODW_CHANNEL = CHANNEL;
42
+ process.env.AODW_CORE_DIR = CORE_DIRNAME;
43
+ process.env.AODW_PACKAGE_NAME = PACKAGE_NAME;
44
+
45
+ function channelizeName(name) {
46
+ if (CHANNEL !== 'next') return name;
47
+ if (name === 'aodw.mdc') return `aodw${ADAPTER_SUFFIX}.mdc`;
48
+ if (name === 'aodw.md') return `aodw${ADAPTER_SUFFIX}.md`;
49
+ if (name === 'AGENTS.md') return `AGENTS-NEXT.md`;
50
+ if (name === 'CLAUDE.md') return 'CLAUDE-NEXT.md';
51
+ if (name === 'GEMINI.md') return 'GEMINI-NEXT.md';
52
+ if (name === 'copilot-instructions.md') return 'copilot-instructions-next.md';
53
+ if (name.startsWith('aodw-') && name.endsWith('.md')) {
54
+ return name.replace(/^aodw-/, 'aodw-next-');
55
+ }
56
+ return name;
57
+ }
58
+
59
+ const GEMINI_RULE_FILES = [
60
+ 'aodw.md',
61
+ 'aodw-analyze.md',
62
+ 'aodw-complete.md',
63
+ 'aodw-control.md',
64
+ 'aodw-decide.md',
65
+ 'aodw-governance.md',
66
+ 'aodw-implement.md',
67
+ 'aodw-init.md',
68
+ 'aodw-intake.md',
69
+ 'aodw-open.md',
70
+ 'aodw-verify.md'
71
+ ];
72
+
73
+ // Define source paths
74
+ const SOURCE_CORE = path.join(__dirname, '../.aodw');
75
+ const SOURCE_ADAPTERS = path.join(__dirname, '../AODW_Adapters');
76
+ const SOURCE_DOCS = path.join(__dirname, '../docs');
77
+ const SOURCE_TEMPLATE = path.join(SOURCE_CORE, 'templates/aodw-kernel-loader-template.md');
78
+
79
+ program
80
+ .version(packageJson.version)
81
+ .description('Initialize AODW in your project');
82
+
83
+ // Helper: Install file with processor
84
+ async function installFile(source, target, processorClass = BaseProcessor) {
85
+ const processor = new processorClass(source, target);
86
+ await processor.process();
87
+ }
88
+
89
+ // Helper: Recursive copy with processing
90
+ async function copyRecursive(sourceDir, targetDir, processorClass, renameFn = null) {
91
+ // Files to exclude from distribution (maintainer-only tools)
92
+ const excludeFiles = [
93
+ 'aodw-governance.md', // AODW 治理检查(仅维护者)
94
+ 'aodw-init.md' // 初始化(CLI 已处理)
95
+ ];
96
+
97
+ const entries = await fs.readdir(sourceDir, { withFileTypes: true });
98
+ for (const entry of entries) {
99
+ // Skip excluded files
100
+ if (!entry.isDirectory() && excludeFiles.includes(entry.name)) {
101
+ console.log(chalk.gray(` ⊖ 跳过 ${entry.name} (仅供维护者使用)`));
102
+ continue;
103
+ }
104
+
105
+ const srcPath = path.join(sourceDir, entry.name);
106
+ const destName = renameFn ? renameFn(entry.name) : entry.name;
107
+ const destPath = path.join(targetDir, destName);
108
+
109
+ if (entry.isDirectory()) {
110
+ await fs.ensureDir(destPath);
111
+ await copyRecursive(srcPath, destPath, processorClass, renameFn);
112
+ } else {
113
+ await installFile(srcPath, destPath, processorClass);
114
+ }
115
+ }
116
+ }
117
+
118
+ // Helper: Return to menu pause
119
+ async function returnToMenu() {
120
+ console.log(); // empty line
121
+ await inquirer.prompt([{
122
+ type: 'input',
123
+ name: 'pause',
124
+ message: chalk.dim('按回车键返回主菜单...'),
125
+ prefix: '🔙'
126
+ }]);
127
+ }
128
+
129
+ // Helper: Check server health
130
+ async function checkServerHealth(url) {
131
+ try {
132
+ // Ensure URL has protocol
133
+ if (!url.startsWith('http')) {
134
+ url = `http://${url}`;
135
+ }
136
+
137
+ // Create timeout signal
138
+ const controller = new AbortController();
139
+ const timeout = setTimeout(() => controller.abort(), 3000); // 3s timeout
140
+
141
+ const res = await fetch(`${url}/api/health`, {
142
+ method: 'GET',
143
+ signal: controller.signal
144
+ });
145
+
146
+ clearTimeout(timeout);
147
+ return res.ok;
148
+ } catch (error) {
149
+ return false;
150
+ }
151
+ }
152
+
153
+ async function runInit() {
154
+ console.log(chalk.blue('🚀 正在初始化 AODW...'));
155
+
156
+ // --- Safeguard: Prevent running in AODW Source Repo ---
157
+ if (fs.existsSync(path.join(process.cwd(), 'cli/bin/aodw.js')) &&
158
+ (fs.existsSync(path.join(process.cwd(), 'templates/.aodw')) ||
159
+ fs.existsSync(path.join(process.cwd(), 'templates/.aodw-next')))) {
160
+ console.log(chalk.red('\n🛑 严重错误: 您正在 AODW 源码仓库中运行 "aodw init"!'));
161
+ console.log(chalk.yellow(' 这将导致开发模板覆盖源文件。'));
162
+ console.log(chalk.yellow(' 如需更新模板,请使用: cd cli && ./build-local.sh'));
163
+ return;
164
+ }
165
+
166
+ // --- Step 1: Project Identity ---
167
+ const existingProjectConfig = getProjectConfig();
168
+ let projectName = path.basename(process.cwd());
169
+
170
+ // Try to get name from package.json
171
+ try {
172
+ const pkgPath = path.join(process.cwd(), 'package.json');
173
+ if (fs.existsSync(pkgPath)) {
174
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
175
+ if (pkg.name) projectName = pkg.name;
176
+ }
177
+ } catch (e) {
178
+ // ignore
179
+ }
180
+
181
+ if (existingProjectConfig.project_name) {
182
+ console.log(chalk.yellow(`⚠️ 发现现有项目配置: ${existingProjectConfig.project_name}`));
183
+ const { overwrite } = await inquirer.prompt([{
184
+ type: 'confirm',
185
+ name: 'overwrite',
186
+ message: '是否重新配置 (覆盖)?',
187
+ default: false
188
+ }]);
189
+ if (!overwrite) {
190
+ projectName = existingProjectConfig.project_name;
191
+ } else {
192
+ const answers = await inquirer.prompt([{
193
+ type: 'input',
194
+ name: 'projectName',
195
+ message: '请输入项目唯一名称:',
196
+ default: projectName,
197
+ suffix: chalk.gray(' (提示: 如果是加入团队项目, 请先 git pull!)')
198
+ }]);
199
+ projectName = answers.projectName;
200
+ await saveProjectConfig({ project_name: projectName });
201
+ }
202
+ } else {
203
+ const answers = await inquirer.prompt([{
204
+ type: 'input',
205
+ name: 'projectName',
206
+ message: '请输入项目唯一名称:',
207
+ default: projectName,
208
+ suffix: chalk.gray(' (提示: 如果是加入团队项目, 请先 git pull!)')
209
+ }]);
210
+ projectName = answers.projectName;
211
+ await saveProjectConfig({ project_name: projectName });
212
+ }
213
+
214
+ // --- Step 2: Configure Mode (if not configured) ---
215
+ const userConfig = getUserConfig();
216
+ if (!userConfig.mode) {
217
+ await configureMode(false); // Run config first time, no pause
218
+ }
219
+
220
+ // --- Step 3: Platform Selection (Multi-select) ---
221
+ const { platforms } = await inquirer.prompt([
222
+ {
223
+ type: 'checkbox',
224
+ name: 'platforms',
225
+ message: '选择要支持的 AI 平台 (空格选择, 回车确认):',
226
+ choices: [
227
+ { name: 'Cursor (IDE with AI)', value: 'cursor', checked: true },
228
+ { name: 'Antigravity (Google Gemini)', value: 'antigravity', checked: true },
229
+ { name: 'Claude Desktop', value: 'claude', checked: false },
230
+ { name: 'Gemini (Web / API)', value: 'gemini', checked: false },
231
+ { name: 'General Agents (OpenAI, etc.)', value: 'general', checked: false }
232
+ ],
233
+ validate: (answer) => {
234
+ if (answer.length < 1) {
235
+ return '必须至少选择一个平台。';
236
+ }
237
+ return true;
238
+ }
239
+ }
240
+ ]);
241
+
242
+ // 1. Install Core Rules (channel-aware core dir)
243
+ const targetCore = path.join(process.cwd(), CORE_DIRNAME);
244
+ await fs.copy(SOURCE_CORE, targetCore);
245
+
246
+ // 3. Install Adapters based on selected platforms
247
+ console.log(chalk.blue('正在安装适配器...'));
248
+
249
+ // Cursor
250
+ if (platforms.includes('cursor')) {
251
+ console.log(chalk.yellow(' • 安装 Cursor 适配器...'));
252
+ const targetCursor = path.join(process.cwd(), '.cursor/rules');
253
+ await fs.ensureDir(targetCursor);
254
+ if (fs.existsSync(SOURCE_TEMPLATE)) {
255
+ await installFile(SOURCE_TEMPLATE, path.join(targetCursor, channelizeName('aodw.mdc')), CursorProcessor);
256
+ } else {
257
+ const sourceCursor = path.join(SOURCE_ADAPTERS, 'cursor/.cursor/rules');
258
+ if (fs.existsSync(sourceCursor)) {
259
+ await copyRecursive(sourceCursor, targetCursor, CursorProcessor, channelizeName);
260
+ }
261
+ }
262
+
263
+ // Cursor deployment scripts
264
+ const targetCursorDeploy = path.join(process.cwd(), '.cursor/deploy');
265
+ await fs.ensureDir(targetCursorDeploy);
266
+ const sourceCursorDeploy = path.join(SOURCE_ADAPTERS, 'cursor/.cursor/deploy');
267
+ if (fs.existsSync(sourceCursorDeploy)) {
268
+ await copyRecursive(sourceCursorDeploy, targetCursorDeploy, BaseProcessor);
269
+ }
270
+
271
+ // Cursor commands
272
+ const targetCursorCommands = path.join(process.cwd(), '.cursor/commands');
273
+ await fs.ensureDir(targetCursorCommands);
274
+ const sourceCursorCommands = path.join(SOURCE_ADAPTERS, 'cursor/.cursor/commands');
275
+ if (fs.existsSync(sourceCursorCommands)) {
276
+ await copyRecursive(sourceCursorCommands, targetCursorCommands, BaseProcessor);
277
+ }
278
+ }
279
+
280
+ // Antigravity
281
+ if (platforms.includes('antigravity')) {
282
+ console.log(chalk.yellow(' • 安装 Antigravity 适配器...'));
283
+ const targetAgentRules = path.join(process.cwd(), '.agent/rules');
284
+ await fs.ensureDir(targetAgentRules);
285
+ if (fs.existsSync(SOURCE_TEMPLATE)) {
286
+ await installFile(SOURCE_TEMPLATE, path.join(targetAgentRules, channelizeName('aodw.md')), AntigravityProcessor);
287
+ } else {
288
+ const sourceAodw = path.join(SOURCE_ADAPTERS, 'antigravity/.agent/rules/aodw.md');
289
+ if (fs.existsSync(sourceAodw)) {
290
+ await installFile(sourceAodw, path.join(targetAgentRules, channelizeName('aodw.md')), AntigravityProcessor);
291
+ }
292
+ }
293
+ }
294
+
295
+ // Claude
296
+ if (platforms.includes('claude')) {
297
+ console.log(chalk.yellow(' • 安装 Claude 适配器...'));
298
+ if (fs.existsSync(SOURCE_TEMPLATE)) {
299
+ await installFile(
300
+ SOURCE_TEMPLATE,
301
+ path.join(process.cwd(), `.claude/${channelizeName('CLAUDE.md')}`),
302
+ ClaudeProcessor
303
+ );
304
+ } else {
305
+ await installFile(
306
+ path.join(SOURCE_ADAPTERS, 'claude/CLAUDE.md'),
307
+ path.join(process.cwd(), `.claude/${channelizeName('CLAUDE.md')}`),
308
+ ClaudeProcessor
309
+ );
310
+ }
311
+ }
312
+
313
+ // Gemini
314
+ if (platforms.includes('gemini')) {
315
+ console.log(chalk.yellow(' • 安装 Gemini 适配器...'));
316
+ const targetGeminiRules = path.join(process.cwd(), '.agent/rules');
317
+ await fs.ensureDir(targetGeminiRules);
318
+ if (fs.existsSync(SOURCE_TEMPLATE)) {
319
+ await installFile(SOURCE_TEMPLATE, path.join(targetGeminiRules, channelizeName('aodw.md')), GeminiProcessor);
320
+ } else {
321
+ const sourceGeminiRules = path.join(SOURCE_ADAPTERS, 'gemini/.agent/rules');
322
+ if (fs.existsSync(sourceGeminiRules)) {
323
+ await copyRecursive(sourceGeminiRules, targetGeminiRules, AntigravityProcessor, channelizeName);
324
+ }
325
+ }
326
+ const sourceGemini = path.join(SOURCE_ADAPTERS, 'gemini/GEMINI.md');
327
+ if (fs.existsSync(sourceGemini)) {
328
+ await installFile(
329
+ sourceGemini,
330
+ path.join(process.cwd(), `.gemini/${channelizeName('GEMINI.md')}`),
331
+ BaseProcessor
332
+ );
333
+ }
334
+ }
335
+
336
+ // General
337
+ if (platforms.includes('general')) {
338
+ console.log(chalk.yellow(' • 安装通用适配器 (General)...'));
339
+ if (fs.existsSync(SOURCE_TEMPLATE)) {
340
+ await installFile(
341
+ SOURCE_TEMPLATE,
342
+ path.join(process.cwd(), CORE_DIRNAME, channelizeName('AGENTS.md')),
343
+ GeneralProcessor
344
+ );
345
+ } else {
346
+ await installFile(
347
+ path.join(SOURCE_ADAPTERS, 'general/AGENTS.md'),
348
+ path.join(process.cwd(), CORE_DIRNAME, channelizeName('AGENTS.md')),
349
+ BaseProcessor
350
+ );
351
+ }
352
+ const sourceCopilot = path.join(SOURCE_ADAPTERS, 'general/.github/copilot-instructions.md');
353
+ if (fs.existsSync(sourceCopilot)) {
354
+ await installFile(
355
+ sourceCopilot,
356
+ path.join(process.cwd(), `.github/${channelizeName('copilot-instructions.md')}`),
357
+ BaseProcessor
358
+ );
359
+ }
360
+ }
361
+
362
+ console.log(chalk.green('\n✅ AODW 初始化成功!'));
363
+ console.log(chalk.white(`项目: ${projectName}`));
364
+ console.log(chalk.white(`渠道: ${CHANNEL}`));
365
+
366
+ const updatedConfig = getUserConfig();
367
+ console.log(chalk.white(`模式: ${updatedConfig.mode === 'independent' ? '独立模式 (本地)' : '协作模式 (联网)'}`));
368
+ if (updatedConfig.mode === 'collaborative') {
369
+ console.log(chalk.white(`服务器: ${updatedConfig.server_url}`));
370
+ }
371
+ console.log(chalk.white(`平台: ${platforms.join(', ')}`));
372
+ }
373
+
374
+ async function runUpdate() {
375
+ console.log(chalk.blue('🔄 正在更新 AODW...'));
376
+ await runInit();
377
+ }
378
+
379
+ async function runUninstall() {
380
+ const { confirm } = await inquirer.prompt([
381
+ {
382
+ type: 'confirm',
383
+ name: 'confirm',
384
+ message: `确定要卸载 AODW (${CHANNEL}) 吗? 这将删除 ${CORE_DIRNAME} 目录(包含 ui-kit)。`,
385
+ default: false
386
+ }
387
+ ]);
388
+
389
+ if (confirm) {
390
+ const cwd = process.cwd();
391
+ await fs.remove(path.join(cwd, CORE_DIRNAME));
392
+
393
+ const removeIfExists = async (filePath) => {
394
+ if (fs.existsSync(filePath)) {
395
+ await fs.remove(filePath);
396
+ }
397
+ };
398
+
399
+ // Cursor
400
+ await removeIfExists(path.join(cwd, '.cursor/rules', channelizeName('aodw.mdc')));
401
+
402
+ // Antigravity
403
+ await removeIfExists(path.join(cwd, '.agent/rules', channelizeName('aodw.md')));
404
+
405
+ // Claude
406
+ await removeIfExists(path.join(cwd, '.claude', channelizeName('CLAUDE.md')));
407
+
408
+ // Gemini rules
409
+ for (const ruleFile of GEMINI_RULE_FILES) {
410
+ await removeIfExists(path.join(cwd, '.agent/rules', channelizeName(ruleFile)));
411
+ }
412
+ await removeIfExists(path.join(cwd, '.gemini', channelizeName('GEMINI.md')));
413
+
414
+ // General
415
+ await removeIfExists(path.join(cwd, CORE_DIRNAME, channelizeName('AGENTS.md')));
416
+ await removeIfExists(path.join(cwd, '.github', channelizeName('copilot-instructions.md')));
417
+
418
+ console.log(chalk.green('✅ AODW 已卸载。'));
419
+ }
420
+ }
421
+
422
+ async function showHelp() {
423
+ const deployDocPath = path.join(__dirname, '../DEPLOY.md');
424
+ if (fs.existsSync(deployDocPath)) {
425
+ const content = fs.readFileSync(deployDocPath, 'utf8');
426
+ console.log(chalk.cyan('\n=== AODW 部署指南 ===\n'));
427
+ console.log(content);
428
+ } else {
429
+ console.log(chalk.red('未找到帮助文件。'));
430
+ }
431
+ }
432
+
433
+ async function configureMode(pause = true, forceConnect = false) {
434
+ const { mode } = await inquirer.prompt([{
435
+ type: 'list',
436
+ name: 'mode',
437
+ message: '选择开发模式:',
438
+ choices: [
439
+ { name: '独立模式 (本地生成 ID, 适合个人开发)', value: 'independent' },
440
+ { name: '协作模式 (联网获取 ID, 适合团队开发)', value: 'collaborative' }
441
+ ]
442
+ }]);
443
+
444
+ let serverUrl = '';
445
+ if (mode === 'collaborative') {
446
+ while (true) {
447
+ const answers = await inquirer.prompt([{
448
+ type: 'input',
449
+ name: 'serverUrl',
450
+ message: '请输入 AODW ID 服务器地址:',
451
+ default: 'http://114.67.218.31:2005',
452
+ validate: (input) => {
453
+ if (!input || input.trim() === '') {
454
+ return '协作模式必须提供服务器地址';
455
+ }
456
+ return true;
457
+ }
458
+ }]);
459
+ serverUrl = answers.serverUrl.trim();
460
+
461
+ process.stdout.write(chalk.gray(`正在测试连接 ${serverUrl}... `));
462
+ const healthy = await checkServerHealth(serverUrl);
463
+
464
+ if (healthy) {
465
+ console.log(chalk.green('✅ 连接成功'));
466
+ break;
467
+ } else {
468
+ console.log(chalk.red('❌ 连接失败'));
469
+ const { action } = await inquirer.prompt([{
470
+ type: 'list',
471
+ name: 'action',
472
+ message: '无法连接到 ID 服务器,请选择:',
473
+ choices: [
474
+ { name: '重试输入', value: 'retry' },
475
+ { name: '强制保存 (离线使用)', value: 'force' },
476
+ { name: '切换回独立模式', value: 'switch_independent' }
477
+ ]
478
+ }]);
479
+
480
+ if (action === 'force') break;
481
+ if (action === 'switch_independent') {
482
+ await saveUserConfig({ mode: 'independent', server_url: '' });
483
+ console.log(chalk.green('✅ 全局配置已保存 (切换为独立模式)'));
484
+ return;
485
+ }
486
+ // retry continues loop
487
+ }
488
+ }
489
+ }
490
+
491
+ await saveUserConfig({ mode, server_url: serverUrl });
492
+ console.log(chalk.green('✅ 全局配置已保存!'));
493
+ }
494
+
495
+ async function showMainMenu() {
496
+ while (true) {
497
+ console.clear();
498
+ console.log(chalk.bold.blue('=== AODW CLI 管理器 ==='));
499
+ console.log(chalk.gray('版本: ' + packageJson.version));
500
+
501
+ // Show current config summary
502
+ const config = getUserConfig();
503
+ const modeStr = config.mode === 'independent' ? '🏠 独立模式' : '🌐 协作模式';
504
+ console.log(chalk.gray(`当前配置: ${modeStr} ${config.mode === 'collaborative' ? `(${config.server_url})` : ''}`));
505
+ console.log('');
506
+
507
+ const { action } = await inquirer.prompt([{
508
+ type: 'list',
509
+ name: 'action',
510
+ message: '请选择操作:',
511
+ pageSize: 10,
512
+ choices: [
513
+ new inquirer.Separator('--- 核心功能 ---'),
514
+ { name: '1. 初始化 / 更新 AODW (在本项目)', value: 'init' },
515
+ { name: '2. 配置全局开发模式 (单机/联网)', value: 'config' },
516
+
517
+ new inquirer.Separator('--- 工具箱 ---'),
518
+ { name: '3. 工具初始化 (ESLint/Ruff/Stack)', value: 'init-tools' },
519
+ { name: '4. 项目概览初始化 (Architecture)', value: 'init-overview' },
520
+
521
+ new inquirer.Separator('--- 帮助与维护 ---'),
522
+ { name: '5. 查看帮助 & 部署指南', value: 'help' },
523
+ { name: '6. 卸载 AODW', value: 'uninstall' },
524
+ new inquirer.Separator(),
525
+ { name: '0. 退出 (Exit)', value: 'exit' }
526
+ ]
527
+ }]);
528
+
529
+ if (action === 'exit') {
530
+ console.log(chalk.blue('再见! 👋'));
531
+ process.exit(0);
532
+ }
533
+
534
+ try {
535
+ switch (action) {
536
+ case 'init':
537
+ await runInit();
538
+ await returnToMenu();
539
+ break;
540
+ case 'config':
541
+ await configureMode();
542
+ await returnToMenu();
543
+ break;
544
+ case 'init-tools':
545
+ await initTools();
546
+ await returnToMenu();
547
+ break;
548
+ case 'init-overview':
549
+ await initOverview({ interactive: true });
550
+ await returnToMenu();
551
+ break;
552
+ case 'help':
553
+ await showHelp();
554
+ await returnToMenu();
555
+ break;
556
+ case 'uninstall':
557
+ await runUninstall();
558
+ await returnToMenu();
559
+ break;
560
+ }
561
+ } catch (error) {
562
+ console.error(chalk.red('\n执行出错:'), error);
563
+ await returnToMenu();
564
+ }
565
+ }
566
+ }
567
+
568
+ // --- Commands ---
569
+
570
+ program
571
+ .command('init')
572
+ .description('Initialize AODW')
573
+ .action(runInit);
574
+
575
+ program
576
+ .command('update')
577
+ .description('Update AODW')
578
+ .action(runUpdate);
579
+
580
+ program
581
+ .command('uninstall')
582
+ .description('Uninstall AODW')
583
+ .action(runUninstall);
584
+
585
+ program
586
+ .command('serve')
587
+ .description('Start the AODW ID Server')
588
+ .option('-p, --port <number>', 'Port to listen on', 2005)
589
+ .action(serve);
590
+
591
+ program
592
+ .command('new')
593
+ .description('Create a new Request Ticket (RT)')
594
+ .option('--server <url>', 'URL of the ID server')
595
+ .option('--project <name>', 'Project identifier')
596
+ .option('--title <string>', 'Title of the RT')
597
+ .action(createNewRT);
598
+
599
+ program
600
+ .command('init-tools')
601
+ .alias('tools')
602
+ .description('Initialize development tools (ESLint, Prettier, Ruff, Black, etc.)')
603
+ .action(initTools);
604
+
605
+ program
606
+ .command('init-overview')
607
+ .alias('overview')
608
+ .description('Initialize or update project overview (tech stack, architecture, modules)')
609
+ .option('--update', 'Update mode: only update changed parts (default)', true)
610
+ .option('--force', 'Force mode: full rescan and update', false)
611
+ .option('--scan-only', 'Scan only: detect changes without updating files', false)
612
+ .option('--no-interactive', 'Non-interactive mode: skip confirmations', false)
613
+ .action((options) => {
614
+ initOverview({
615
+ update: options.update !== false,
616
+ force: options.force || false,
617
+ scanOnly: options.scanOnly || false,
618
+ interactive: options.interactive !== false,
619
+ });
620
+ });
621
+
622
+ // Main Entry Point
623
+ if (!process.argv.slice(2).length) {
624
+ showMainMenu();
625
+ } else {
626
+ program.parse(process.argv);
627
+ }