aodw-skill 0.10.0 → 0.13.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/.aodw-next/01-core/ai-knowledge-rules.md +35 -2
- package/.aodw-next/01-core/aodw-constitution.md +22 -3
- package/.aodw-next/01-core/git-discipline.md +110 -52
- package/.aodw-next/01-core/test-discipline.md +2 -0
- package/.aodw-next/02-workflow/autopilot-protocol.md +4 -1
- package/.aodw-next/02-workflow/environment-roles.md +106 -0
- package/.aodw-next/02-workflow/orca-multi-session.md +80 -0
- package/.aodw-next/02-workflow/rt-manager.md +83 -12
- package/.aodw-next/02-workflow/shared-verification-host.md +103 -0
- package/.aodw-next/02-workflow/sub-agent-driven-profile.md +2 -1
- package/.aodw-next/04-auditors/aodw-development-auditor-rules.md +2 -6
- package/.aodw-next/04-auditors/aodw-full-auditor-rules.md +2 -6
- package/.aodw-next/README.md +168 -7
- package/.aodw-next/SKILL.md +4 -1
- package/.aodw-next/manifest.yaml +26 -2
- package/.aodw-next/project.yaml +4 -0
- package/.aodw-next/skills/handover-pack/scripts/next-number.sh +1 -1
- package/.aodw-next/skills/handover-pack/templates/handover-template.md +3 -1
- package/.aodw-next/templates/dev-session-guide-template.md +20 -0
- package/.aodw-next/templates/environments.template.md +54 -0
- package/.aodw-next/templates/lessons.template.md +7 -0
- package/.aodw-next/templates/main-session-handover-template.md +19 -0
- package/.aodw-next/templates/orca-handoff-template.md +31 -0
- package/.aodw-next/templates/release/checklist.template.md +29 -0
- package/.aodw-next/templates/release/notes.template.md +22 -0
- package/.aodw-next/templates/release/plan.template.md +15 -0
- package/.aodw-next/templates/release/retro-index.template.md +8 -0
- package/.aodw-next/templates/release/retro-topic.template.md +33 -0
- package/.aodw-next/templates/rt-lite.template.md +1 -0
- package/.aodw-next/templates/rt-meta-template.yaml +2 -2
- package/.aodw-next/templates/shared-verification-host-profile.template.md +50 -0
- package/.aodw-next/tools/next-rt-id.sh +39 -0
- package/.aodw-next/tools/rel-plan.mjs +203 -0
- package/.aodw-next/tools/worktree-gc.sh +260 -0
- package/AODW_Adapters/README.md +22 -126
- package/AODW_Adapters/agents/AGENTS.md +11 -0
- package/AODW_Adapters/antigravity/.agent/rules/aodw-next.md +2 -72
- package/AODW_Adapters/claude/CLAUDE.md +2 -72
- package/AODW_Adapters/copilot/.github/copilot-instructions.md +3 -0
- package/AODW_Adapters/cursor/.cursor/rules/aodw-next.mdc +3 -75
- package/AODW_Adapters/openclaw/SKILL.md +3 -106
- package/README.md +60 -22
- package/bin/aodw.js +374 -279
- package/bin/commands/new.js +21 -25
- package/bin/commands/update.js +387 -0
- package/bin/commands/verify.js +420 -0
- package/bin/utils/lock.js +343 -0
- package/bin/utils/path-guard.js +449 -0
- package/bin/utils/release.js +36 -0
- package/bin/utils/tool-entries.js +506 -0
- package/package.json +8 -2
- package/.aodw-next/templates/aodw-kernel-loader-template.md +0 -71
- package/AODW_Adapters/cursor/.cursor/commands/README.md +0 -37
- package/AODW_Adapters/cursor/.cursor/rules/aodw-autopilot-continue.mdc +0 -42
- package/AODW_Adapters/openclaw/AGENTS.md +0 -142
- package/bin/processors/index.js +0 -98
- package/bin/update-adapters-from-template.js +0 -76
package/bin/aodw.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
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';
|
|
@@ -9,12 +10,13 @@ import { createRequire } from 'module';
|
|
|
9
10
|
import { fileURLToPath } from 'url';
|
|
10
11
|
|
|
11
12
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
checkProjectChannel,
|
|
14
|
+
claimProjectChannel,
|
|
15
|
+
entryWriteTargets,
|
|
16
|
+
syncToolEntries,
|
|
17
|
+
uninstallProject,
|
|
18
|
+
validateUninstallCore
|
|
19
|
+
} from './utils/tool-entries.js';
|
|
18
20
|
|
|
19
21
|
import { serve } from './commands/serve.js';
|
|
20
22
|
import { createNewRT } from './commands/new.js';
|
|
@@ -22,6 +24,33 @@ import { initTools } from './commands/init-tools.js';
|
|
|
22
24
|
import { guardDocTrace, auditDocTrace } from './commands/trace-guard.js';
|
|
23
25
|
import { enableGuardHook } from './commands/install-guard-hook.js';
|
|
24
26
|
import { saveProjectConfig, saveUserConfig, getProjectConfig, getUserConfig } from './utils/config.js';
|
|
27
|
+
import {
|
|
28
|
+
LOCK_FILENAME,
|
|
29
|
+
assertSafeWriteTargets,
|
|
30
|
+
buildAndWriteLock,
|
|
31
|
+
collectUpstreamFiles,
|
|
32
|
+
hasExistingUpstreamFiles,
|
|
33
|
+
onDiskCorePath,
|
|
34
|
+
planReleaseIdentities,
|
|
35
|
+
replaceFileEntry,
|
|
36
|
+
resolveSafeFileInDir,
|
|
37
|
+
validateLockRelPath,
|
|
38
|
+
verifyCoreLock,
|
|
39
|
+
walkRealPath
|
|
40
|
+
} from './utils/lock.js';
|
|
41
|
+
import {
|
|
42
|
+
ORCA_GUIDE,
|
|
43
|
+
ORCA_RULE,
|
|
44
|
+
ORCA_UPSTREAM_FILES,
|
|
45
|
+
collectReleaseFiles,
|
|
46
|
+
readReleaseFile
|
|
47
|
+
} from './utils/release.js';
|
|
48
|
+
import {
|
|
49
|
+
printUpdatePreflightError,
|
|
50
|
+
printWriteBoundaryError,
|
|
51
|
+
runVerify
|
|
52
|
+
} from './commands/verify.js';
|
|
53
|
+
import { runUpdate } from './commands/update.js';
|
|
25
54
|
import {
|
|
26
55
|
detectTechStack,
|
|
27
56
|
analyzeDirectoryStructure,
|
|
@@ -36,88 +65,23 @@ const packageJson = require('../package.json');
|
|
|
36
65
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
37
66
|
const program = new Command();
|
|
38
67
|
|
|
39
|
-
// AODW Next 版本 -
|
|
40
|
-
const CORE_DIRNAME = '.aodw-next';
|
|
68
|
+
// AODW Next 版本 - 默认 .aodw-next,允许通过环境变量指定仓内合法通道目录
|
|
69
|
+
const CORE_DIRNAME = process.env.AODW_CORE_DIR || '.aodw-next';
|
|
41
70
|
const PACKAGE_NAME = packageJson.name || 'aodw-skill';
|
|
42
71
|
|
|
43
72
|
process.env.AODW_CORE_DIR = CORE_DIRNAME;
|
|
44
73
|
process.env.AODW_PACKAGE_NAME = PACKAGE_NAME;
|
|
45
74
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const packageRoot = path.join(__dirname, '..'); // cli/ or node_modules/aodw-skill/
|
|
50
|
-
|
|
51
|
-
// Try npm package paths first (production)
|
|
52
|
-
const npmCore = path.join(packageRoot, '.aodw-next');
|
|
53
|
-
const npmAdapters = path.join(packageRoot, 'AODW_Adapters');
|
|
54
|
-
|
|
55
|
-
// Try development paths (from source)
|
|
56
|
-
const devCore = path.join(packageRoot, '../templates/.aodw-next');
|
|
57
|
-
const devAdapters = path.join(packageRoot, '../templates/AODW_Adapters');
|
|
58
|
-
|
|
59
|
-
// Use npm package paths if they exist, otherwise use development paths
|
|
60
|
-
const SOURCE_CORE = fs.existsSync(npmCore) ? npmCore : devCore;
|
|
61
|
-
const SOURCE_ADAPTERS = fs.existsSync(npmAdapters) ? npmAdapters : devAdapters;
|
|
62
|
-
|
|
63
|
-
return { SOURCE_CORE, SOURCE_ADAPTERS };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const { SOURCE_CORE, SOURCE_ADAPTERS } = getSourcePaths();
|
|
67
|
-
const SOURCE_TEMPLATE = path.join(SOURCE_CORE, 'templates/aodw-kernel-loader-template.md');
|
|
75
|
+
// 优先使用 npm 包中的内核;源码工作区回退到发布模板。
|
|
76
|
+
const npmCore = path.resolve(__dirname, '../.aodw-next');
|
|
77
|
+
const SOURCE_CORE = fs.existsSync(npmCore) ? npmCore : path.resolve(__dirname, '../../templates/.aodw-next');
|
|
68
78
|
|
|
69
79
|
program
|
|
70
80
|
.version(packageJson.version)
|
|
71
81
|
.description('Initialize AODW-Next in your project');
|
|
72
82
|
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const processor = new processorClass(source, target);
|
|
76
|
-
await processor.process();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Helper: Recursive copy with processing
|
|
80
|
-
async function copyRecursive(sourceDir, targetDir, processorClass, renameFn = null) {
|
|
81
|
-
// Files to exclude from distribution (maintainer-only tools)
|
|
82
|
-
const excludeFiles = [
|
|
83
|
-
'aodw-governance.md', // AODW-Next 治理检查(仅维护者)
|
|
84
|
-
'aodw-init.md' // 初始化(CLI 已处理)
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
|
|
88
|
-
for (const entry of entries) {
|
|
89
|
-
// Skip excluded files
|
|
90
|
-
if (!entry.isDirectory() && excludeFiles.includes(entry.name)) {
|
|
91
|
-
console.log(chalk.gray(` ⊖ 跳过 ${entry.name} (仅供维护者使用)`));
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const srcPath = path.join(sourceDir, entry.name);
|
|
96
|
-
const destName = renameFn ? renameFn(entry.name) : entry.name;
|
|
97
|
-
const destPath = path.join(targetDir, destName);
|
|
98
|
-
|
|
99
|
-
if (entry.isDirectory()) {
|
|
100
|
-
await fs.ensureDir(destPath);
|
|
101
|
-
await copyRecursive(srcPath, destPath, processorClass, renameFn);
|
|
102
|
-
} else {
|
|
103
|
-
await installFile(srcPath, destPath, processorClass);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Helper: Check if a file is a user-generated file (not a template)
|
|
109
|
-
function isUserGeneratedFile(filePath, coreDir) {
|
|
110
|
-
const relativePath = path.relative(coreDir, filePath);
|
|
111
|
-
|
|
112
|
-
// User-generated files that should be preserved
|
|
113
|
-
const userGeneratedFiles = [
|
|
114
|
-
'06-project/ai-overview.md',
|
|
115
|
-
'06-project/modules-index.yaml',
|
|
116
|
-
'tools-status.yaml'
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
return userGeneratedFiles.some(pattern => relativePath === pattern || relativePath.endsWith(pattern));
|
|
120
|
-
}
|
|
83
|
+
// 初始化使用的项目缺省模板不是发行上游,由 init 管理,不进入上游路径计划或锁。
|
|
84
|
+
const PROJECT_DEFAULTS = ['project.yaml', 'config.yaml', 'tools-status.yaml'];
|
|
121
85
|
|
|
122
86
|
// Helper: Check if a file is still a template (has template markers)
|
|
123
87
|
async function isTemplateFile(filePath) {
|
|
@@ -143,55 +107,113 @@ async function isTemplateFile(filePath) {
|
|
|
143
107
|
return hasOnlyComments;
|
|
144
108
|
}
|
|
145
109
|
|
|
146
|
-
// tools-status.yaml is always user-generated if it exists
|
|
147
|
-
if (filePath.endsWith('tools-status.yaml')) {
|
|
148
|
-
return false; // If it exists, it's user-generated
|
|
149
|
-
}
|
|
150
|
-
|
|
151
110
|
return false;
|
|
152
111
|
} catch (e) {
|
|
153
112
|
return false;
|
|
154
113
|
}
|
|
155
114
|
}
|
|
156
115
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
await fs.ensureDir(destPath);
|
|
167
|
-
await copyCoreWithPreservation(srcPath, destPath, isUpdate);
|
|
116
|
+
async function copyCoreRelease(targetCore, { releaseFiles, entries }, devEnv) {
|
|
117
|
+
for (const rel of releaseFiles) {
|
|
118
|
+
const source = path.join(SOURCE_CORE, rel);
|
|
119
|
+
const target = path.join(targetCore, rel);
|
|
120
|
+
const existing = entries.get(rel);
|
|
121
|
+
if ((existing !== null && existing !== rel) || (devEnv === 'none' && rel === 'manifest.yaml')) {
|
|
122
|
+
// 同一目录项的新版拼写也由复制计划保留;按发行文件的权限和字节写入。
|
|
123
|
+
const mode = (await fs.stat(source)).mode & 0o777;
|
|
124
|
+
replaceFileEntry(target, readReleaseFile(SOURCE_CORE, rel, devEnv), mode);
|
|
168
125
|
} else {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
continue;
|
|
179
|
-
} else {
|
|
180
|
-
// File exists but is still a template, can be overwritten
|
|
181
|
-
console.log(chalk.yellow(` ↻ 更新模板文件: ${path.relative(process.cwd(), destPath)}`));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// During init, always copy (first time)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Copy the file
|
|
189
|
-
await fs.ensureDir(path.dirname(destPath));
|
|
190
|
-
await fs.copy(srcPath, destPath);
|
|
126
|
+
await fs.copy(source, target);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const rel of PROJECT_DEFAULTS) {
|
|
130
|
+
const target = path.join(targetCore, rel);
|
|
131
|
+
if (rel === 'tools-status.yaml' && fs.existsSync(target)) {
|
|
132
|
+
console.log(chalk.gray(` ⊖ 保留用户文件: ${path.relative(process.cwd(), target)}`));
|
|
133
|
+
} else {
|
|
134
|
+
await fs.copy(path.join(SOURCE_CORE, rel), target);
|
|
191
135
|
}
|
|
192
136
|
}
|
|
193
137
|
}
|
|
194
138
|
|
|
139
|
+
// 在发行计划探测新增落点(需要临时目录)之前,先只读检查现存目标的归属。
|
|
140
|
+
function findUnregisteredTargets(coreDir, releaseFiles, lockedFiles) {
|
|
141
|
+
let registered;
|
|
142
|
+
const conflicts = [];
|
|
143
|
+
for (const rel of releaseFiles) {
|
|
144
|
+
if (Object.prototype.hasOwnProperty.call(lockedFiles, rel)) continue;
|
|
145
|
+
const identity = onDiskCorePath(coreDir, rel);
|
|
146
|
+
if (identity === null) continue;
|
|
147
|
+
// 锁已校验。只有请求拼写不在锁里、但目标确实存在时,才需按实际目录项身份比较。
|
|
148
|
+
registered ??= new Set(Object.keys(lockedFiles).map(key => onDiskCorePath(coreDir, key)));
|
|
149
|
+
if (!registered.has(identity)) conflicts.push(rel);
|
|
150
|
+
}
|
|
151
|
+
return conflicts;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function planInitRelease(core, releaseFiles) {
|
|
155
|
+
const options = { coreDirName: CORE_DIRNAME };
|
|
156
|
+
if (core.ok) return planReleaseIdentities(core.absPath, releaseFiles, options);
|
|
157
|
+
|
|
158
|
+
// absPath 是首个不存在的路径段。在其现存父目录的卷上模拟空通道,不创建或认领真实通道目录。
|
|
159
|
+
let held;
|
|
160
|
+
try {
|
|
161
|
+
held = fs.mkdtempSync(path.join(path.dirname(core.absPath), '.aodw-init-'));
|
|
162
|
+
} catch (err) {
|
|
163
|
+
if (!err.syscall) throw err;
|
|
164
|
+
return { errors: [`无法为 ${CORE_DIRNAME}/ 建立空通道探测目录:${err.message}`] };
|
|
165
|
+
}
|
|
166
|
+
let plan;
|
|
167
|
+
try {
|
|
168
|
+
plan = planReleaseIdentities(held, releaseFiles, options);
|
|
169
|
+
} finally {
|
|
170
|
+
try {
|
|
171
|
+
fs.rmdirSync(held);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (!plan || !err.syscall) throw err;
|
|
174
|
+
plan.errors.push(`没能清除本次空通道探测目录 ${held}:${err.message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return plan;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function planOrcaRetirement(core, releaseEntries, preflight, errors) {
|
|
181
|
+
const wanted = new Set(releaseEntries.values());
|
|
182
|
+
const retired = new Map();
|
|
183
|
+
for (const rel of ORCA_UPSTREAM_FILES) {
|
|
184
|
+
const display = `${CORE_DIRNAME}/${rel}`;
|
|
185
|
+
const local = resolveSafeFileInDir(core.absPath, core.realPath, rel);
|
|
186
|
+
if (!local.ok) {
|
|
187
|
+
if (local.code !== 'missing') errors.push(`不能安全移除 Orca 上游文件 (${display}):${local.reason}`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const identity = onDiskCorePath(core.absPath, rel);
|
|
191
|
+
if (identity === null) errors.push(`不能确认 Orca 上游文件的目录项 (${display})`);
|
|
192
|
+
else if (!wanted.has(identity)) retired.set(identity, local.absPath);
|
|
193
|
+
}
|
|
194
|
+
if (retired.size === 0) return [];
|
|
195
|
+
|
|
196
|
+
// 用旧锁的逐项检查结果证明归属,而不是把历史文件名、目录内容或 --force 当删除授权。
|
|
197
|
+
const proven = new Map();
|
|
198
|
+
if (preflight.lock) {
|
|
199
|
+
const rejected = new Set(preflight.missing);
|
|
200
|
+
for (const item of [...preflight.boundaryErrors, ...preflight.invalidPaths, ...preflight.modified]) {
|
|
201
|
+
rejected.add(item.path);
|
|
202
|
+
}
|
|
203
|
+
for (const key of Object.keys(preflight.lock.files)) {
|
|
204
|
+
if (!validateLockRelPath(key).ok) continue;
|
|
205
|
+
const identity = onDiskCorePath(core.absPath, key);
|
|
206
|
+
if (retired.has(identity)) proven.set(identity, !proven.has(identity) && !rejected.has(key));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const removals = [];
|
|
210
|
+
for (const [identity, abs] of retired) {
|
|
211
|
+
if (proven.get(identity)) removals.push(abs);
|
|
212
|
+
else errors.push(`不能安全移除 Orca 上游文件 (${CORE_DIRNAME}/${identity}):无可信旧锁登记或内容已修改,请先备份并移走后重跑 init`);
|
|
213
|
+
}
|
|
214
|
+
return removals;
|
|
215
|
+
}
|
|
216
|
+
|
|
195
217
|
// Helper: Return to menu pause
|
|
196
218
|
async function returnToMenu() {
|
|
197
219
|
console.log(); // empty line
|
|
@@ -203,7 +225,25 @@ async function returnToMenu() {
|
|
|
203
225
|
}]);
|
|
204
226
|
}
|
|
205
227
|
|
|
206
|
-
|
|
228
|
+
// 入口薄壳按完整集合做写前检查(含可选的 OpenClaw 入口),在任何写入之前一次查完。
|
|
229
|
+
function checkInstallWriteBoundary(cwd, options) {
|
|
230
|
+
const channel = checkProjectChannel(cwd, CORE_DIRNAME, options);
|
|
231
|
+
if (!channel.ok) return channel;
|
|
232
|
+
const targets = [
|
|
233
|
+
CORE_DIRNAME,
|
|
234
|
+
`${CORE_DIRNAME}/${LOCK_FILENAME}`,
|
|
235
|
+
...PROJECT_DEFAULTS.map(rel => `${CORE_DIRNAME}/${rel}`),
|
|
236
|
+
`${CORE_DIRNAME}/06-project/ai-overview.md`,
|
|
237
|
+
`${CORE_DIRNAME}/06-project/modules-index.yaml`,
|
|
238
|
+
`${CORE_DIRNAME}/06-project/ai-init-prompt.md`,
|
|
239
|
+
`${CORE_DIRNAME}/06-project/dev-session-guide.md`,
|
|
240
|
+
...collectUpstreamFiles(SOURCE_CORE).map(rel => `${CORE_DIRNAME}/${rel}`),
|
|
241
|
+
...entryWriteTargets(CORE_DIRNAME, ['openclaw'])
|
|
242
|
+
];
|
|
243
|
+
return assertSafeWriteTargets(cwd, targets);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function runInit({ devEnv, force = false, confirmNewChannel = false } = {}) {
|
|
207
247
|
console.log(chalk.blue('🚀 正在初始化 AODW-Next...'));
|
|
208
248
|
|
|
209
249
|
// --- Safeguard: Prevent running in AODW-Next Source Repo ---
|
|
@@ -215,9 +255,78 @@ async function runInit() {
|
|
|
215
255
|
return;
|
|
216
256
|
}
|
|
217
257
|
|
|
258
|
+
const cwd = process.cwd();
|
|
259
|
+
const channelOptions = { confirmNewChannel };
|
|
260
|
+
const boundary = checkInstallWriteBoundary(cwd, channelOptions);
|
|
261
|
+
if (!boundary.ok) {
|
|
262
|
+
printWriteBoundaryError(boundary.errors);
|
|
263
|
+
process.exitCode = 1;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const targetCore = path.join(cwd, CORE_DIRNAME);
|
|
268
|
+
const core = walkRealPath(cwd, CORE_DIRNAME);
|
|
269
|
+
if (core.ok ? !core.stat.isDirectory() : core.code !== 'missing') {
|
|
270
|
+
printWriteBoundaryError([`${CORE_DIRNAME}/ 不是可安装的通道目录:${core.reason ?? '落点不是目录'}`]);
|
|
271
|
+
process.exitCode = 1;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
let preflight;
|
|
275
|
+
if (!force && core.ok && (fs.existsSync(path.join(targetCore, LOCK_FILENAME)) || hasExistingUpstreamFiles(targetCore))) {
|
|
276
|
+
preflight = verifyCoreLock(cwd, CORE_DIRNAME, { scanUntracked: false });
|
|
277
|
+
if (!preflight.ok) {
|
|
278
|
+
printUpdatePreflightError(preflight, CORE_DIRNAME, { command: 'init' });
|
|
279
|
+
process.exitCode = 1;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
218
284
|
// --- Step 1: Project Identity ---
|
|
219
285
|
const existingProjectConfig = getProjectConfig();
|
|
286
|
+
if (devEnv === undefined && (existingProjectConfig.dev_env === 'orca' || existingProjectConfig.dev_env === 'none')) {
|
|
287
|
+
devEnv = existingProjectConfig.dev_env;
|
|
288
|
+
} else if (devEnv === undefined && preflight?.ok) {
|
|
289
|
+
// none 不写入 project.yaml;已加锁的安装可按实际记录在提问前预检。
|
|
290
|
+
devEnv = preflight.lock.dev_env === 'orca' ? 'orca' : 'none';
|
|
291
|
+
}
|
|
292
|
+
let installPlan;
|
|
293
|
+
let previousDevEnv;
|
|
294
|
+
const planInstall = () => {
|
|
295
|
+
const releaseFiles = collectReleaseFiles(SOURCE_CORE, devEnv);
|
|
296
|
+
if (preflight?.ok) {
|
|
297
|
+
const conflicts = findUnregisteredTargets(core.absPath, releaseFiles, preflight.lock.files);
|
|
298
|
+
if (conflicts.length > 0) {
|
|
299
|
+
console.error('❌ 拒绝初始化:上游目标未登记,未写入任何文件。');
|
|
300
|
+
for (const rel of conflicts) console.error(` - 上游新增路径已被未登记的本地文件占用: ${CORE_DIRNAME}/${rel}`);
|
|
301
|
+
console.error('请先备份并移走占位后重跑 init;若明确要直接覆盖占位文件,可使用 init --force(不做备份)。');
|
|
302
|
+
process.exitCode = 1;
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const { entries, errors } = planInitRelease(core, releaseFiles);
|
|
307
|
+
let removals = [];
|
|
308
|
+
if (errors.length === 0 && core.ok) {
|
|
309
|
+
const lock = walkRealPath(core.absPath, LOCK_FILENAME, { allowMissing: true });
|
|
310
|
+
if (!lock.ok || (lock.exists && !lock.stat.isFile())) {
|
|
311
|
+
errors.push(`${CORE_DIRNAME}/${LOCK_FILENAME} 不能安全写入:${lock.reason ?? '落点不是普通文件'}`);
|
|
312
|
+
} else if (devEnv === 'none') {
|
|
313
|
+
preflight ??= verifyCoreLock(cwd, CORE_DIRNAME, { scanUntracked: false });
|
|
314
|
+
previousDevEnv = preflight.lock?.dev_env ?? existingProjectConfig.dev_env;
|
|
315
|
+
if (previousDevEnv === 'orca') removals = planOrcaRetirement(core, entries, preflight, errors);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (errors.length === 0) {
|
|
319
|
+
installPlan = { releaseFiles, entries, removals };
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
console.error('❌ 拒绝写入:无法安全安装发行文件或移除已停用的 Orca 文件;--force 不绕过路径和归属检查。');
|
|
323
|
+
for (const error of errors) console.error(` - ${error}`);
|
|
324
|
+
process.exitCode = 1;
|
|
325
|
+
return false;
|
|
326
|
+
};
|
|
327
|
+
if (devEnv !== undefined && !planInstall()) return;
|
|
220
328
|
let projectName = path.basename(process.cwd());
|
|
329
|
+
let saveProjectName = false;
|
|
221
330
|
|
|
222
331
|
// Try to get name from package.json
|
|
223
332
|
try {
|
|
@@ -249,7 +358,7 @@ async function runInit() {
|
|
|
249
358
|
suffix: chalk.gray(' (提示: 如果是加入团队项目, 请先 git pull!)')
|
|
250
359
|
}]);
|
|
251
360
|
projectName = answers.projectName;
|
|
252
|
-
|
|
361
|
+
saveProjectName = true;
|
|
253
362
|
}
|
|
254
363
|
} else {
|
|
255
364
|
const answers = await inquirer.prompt([{
|
|
@@ -260,49 +369,62 @@ async function runInit() {
|
|
|
260
369
|
suffix: chalk.gray(' (提示: 如果是加入团队项目, 请先 git pull!)')
|
|
261
370
|
}]);
|
|
262
371
|
projectName = answers.projectName;
|
|
263
|
-
|
|
372
|
+
saveProjectName = true;
|
|
264
373
|
}
|
|
265
374
|
|
|
266
|
-
// --- Step
|
|
375
|
+
// --- Step 3: Optional OpenClaw entry (the standard entry shells are always installed) ---
|
|
376
|
+
const { openclaw } = await inquirer.prompt([{
|
|
377
|
+
type: 'confirm',
|
|
378
|
+
name: 'openclaw',
|
|
379
|
+
message: '是否安装 OpenClaw 入口 (根目录 SKILL.md,选否不卸载已有入口)?',
|
|
380
|
+
default: false
|
|
381
|
+
}]);
|
|
382
|
+
|
|
383
|
+
if (devEnv === undefined) {
|
|
384
|
+
({ devEnv } = await inquirer.prompt([{
|
|
385
|
+
type: 'list',
|
|
386
|
+
name: 'devEnv',
|
|
387
|
+
message: '请选择开发环境:',
|
|
388
|
+
choices: [
|
|
389
|
+
{ name: 'Orca 多会话协作', value: 'orca' },
|
|
390
|
+
{ name: '其他', value: 'none' }
|
|
391
|
+
],
|
|
392
|
+
default: 'none'
|
|
393
|
+
}]));
|
|
394
|
+
if (!planInstall()) return;
|
|
395
|
+
}
|
|
396
|
+
const useOrca = devEnv === 'orca';
|
|
397
|
+
|
|
398
|
+
if (force && installPlan.releaseFiles.some(rel => installPlan.entries.get(rel) !== null)) {
|
|
399
|
+
console.warn(chalk.yellow('⚠️ init --force 将直接覆盖既有上游落点,不做备份。'));
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const claimed = claimProjectChannel(cwd, CORE_DIRNAME, channelOptions);
|
|
403
|
+
if (!claimed.ok) {
|
|
404
|
+
for (const error of claimed.errors) console.error(`❌ ${error}`);
|
|
405
|
+
process.exitCode = 1;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (saveProjectName) await saveProjectConfig({ project_name: projectName });
|
|
409
|
+
|
|
410
|
+
// Normalize legacy user config (no mode prompt).
|
|
267
411
|
const userConfig = getUserConfig();
|
|
268
412
|
if (userConfig.mode !== 'independent' || userConfig.server_url) {
|
|
269
413
|
await saveUserConfig({ mode: 'independent', server_url: '' });
|
|
270
414
|
}
|
|
271
415
|
|
|
272
|
-
// --- Step 3: Platform Selection (Multi-select) ---
|
|
273
|
-
const { platforms } = await inquirer.prompt([
|
|
274
|
-
{
|
|
275
|
-
type: 'checkbox',
|
|
276
|
-
name: 'platforms',
|
|
277
|
-
message: '选择要支持的 AI 平台 (空格选择, 回车确认):',
|
|
278
|
-
choices: [
|
|
279
|
-
{ name: 'Cursor (IDE with AI)', value: 'cursor', checked: true },
|
|
280
|
-
{ name: 'Antigravity (Google Gemini)', value: 'antigravity', checked: true },
|
|
281
|
-
{ name: 'Claude Desktop', value: 'claude', checked: false },
|
|
282
|
-
{ name: 'OpenClaw (AI Agent Orchestration)', value: 'openclaw', checked: false }
|
|
283
|
-
],
|
|
284
|
-
validate: (answer) => {
|
|
285
|
-
if (answer.length < 1) {
|
|
286
|
-
return '必须至少选择一个平台。';
|
|
287
|
-
}
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
]);
|
|
292
|
-
|
|
293
416
|
// 1. Install Core Rules (channel-aware core dir)
|
|
294
|
-
|
|
295
|
-
|
|
417
|
+
console.log(chalk.blue(core.ok ? '正在更新核心规则(保留用户生成的文件)...' : '正在安装核心规则...'));
|
|
418
|
+
await copyCoreRelease(targetCore, installPlan, devEnv);
|
|
419
|
+
for (const abs of installPlan.removals) await fs.unlink(abs);
|
|
296
420
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
await fs.copy(SOURCE_CORE, targetCore);
|
|
303
|
-
}
|
|
421
|
+
// 开发环境说明只留在源模板,安装产物保留原有 YAML 字节和注释。
|
|
422
|
+
const projectConfigPath = path.join(targetCore, 'project.yaml');
|
|
423
|
+
const projectConfig = (await fs.readFile(projectConfigPath, 'utf8'))
|
|
424
|
+
.replace(/^# ── 开发环境(可选).*\n(?:# .+\n)+\n/m, '');
|
|
425
|
+
await fs.writeFile(projectConfigPath, useOrca ? projectConfig + 'dev_env: orca\n' : projectConfig, 'utf8');
|
|
304
426
|
|
|
305
|
-
// 2. Initialize project files from templates (
|
|
427
|
+
// 2. Initialize project files from templates (missing or still placeholders)
|
|
306
428
|
console.log(chalk.blue('正在初始化项目文件...'));
|
|
307
429
|
const projectDir = path.join(targetCore, '06-project');
|
|
308
430
|
const aiOverviewPath = path.join(projectDir, 'ai-overview.md');
|
|
@@ -344,152 +466,100 @@ async function runInit() {
|
|
|
344
466
|
console.log(chalk.gray(' • 项目文件已存在且为用户内容,跳过初始化'));
|
|
345
467
|
}
|
|
346
468
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (fs.existsSync(sourceCursor)) {
|
|
360
|
-
await copyRecursive(sourceCursor, targetCursor, CursorProcessor);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// Cursor deployment scripts
|
|
365
|
-
const targetCursorDeploy = path.join(process.cwd(), '.cursor/deploy');
|
|
366
|
-
await fs.ensureDir(targetCursorDeploy);
|
|
367
|
-
const sourceCursorDeploy = path.join(SOURCE_ADAPTERS, 'cursor/.cursor/deploy');
|
|
368
|
-
if (fs.existsSync(sourceCursorDeploy)) {
|
|
369
|
-
await copyRecursive(sourceCursorDeploy, targetCursorDeploy, BaseProcessor);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Cursor commands
|
|
373
|
-
const targetCursorCommands = path.join(process.cwd(), '.cursor/commands');
|
|
374
|
-
await fs.ensureDir(targetCursorCommands);
|
|
375
|
-
const sourceCursorCommands = path.join(SOURCE_ADAPTERS, 'cursor/.cursor/commands');
|
|
376
|
-
if (fs.existsSync(sourceCursorCommands)) {
|
|
377
|
-
await copyRecursive(sourceCursorCommands, targetCursorCommands, BaseProcessor);
|
|
378
|
-
}
|
|
469
|
+
const guidePath = path.join(targetCore, ORCA_GUIDE);
|
|
470
|
+
if (useOrca && !fs.existsSync(guidePath)) {
|
|
471
|
+
const gitOptions = { encoding: 'utf8' };
|
|
472
|
+
const remoteHead = spawnSync('git', ['symbolic-ref', '--quiet', 'refs/remotes/origin/HEAD'], gitOptions).stdout?.trim();
|
|
473
|
+
const trunkRefs = ['refs/remotes/origin/main', 'refs/remotes/origin/master', 'refs/heads/main', 'refs/heads/master'];
|
|
474
|
+
const refs = spawnSync('git', ['for-each-ref', '--format=%(refname)', ...trunkRefs], gitOptions).stdout?.split('\n') || [];
|
|
475
|
+
const trunkRef = remoteHead || trunkRefs.find(ref => refs.includes(ref)) ||
|
|
476
|
+
spawnSync('git', ['symbolic-ref', '--quiet', 'HEAD'], gitOptions).stdout?.trim();
|
|
477
|
+
const trunk = trunkRef?.replace(/^refs\/(remotes\/origin|heads)\//, '') || 'main';
|
|
478
|
+
const template = await fs.readFile(path.join(targetCore, 'templates/dev-session-guide-template.md'), 'utf8');
|
|
479
|
+
const guide = template.replace(/\{\{(PROJECT_NAME|TRUNK)\}\}/g, (_, key) => key === 'PROJECT_NAME' ? projectName : trunk);
|
|
480
|
+
await fs.writeFile(guidePath, guide, 'utf8');
|
|
379
481
|
}
|
|
380
482
|
|
|
381
|
-
//
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
483
|
+
// 3. Install tool entries: AGENTS.md plus one thin shell per AI tool, all pointing to AGENTS.md
|
|
484
|
+
console.log(chalk.blue('正在安装入口薄壳...'));
|
|
485
|
+
const entries = syncToolEntries(process.cwd(), {
|
|
486
|
+
coreDirName: CORE_DIRNAME,
|
|
487
|
+
devEnv,
|
|
488
|
+
extras: openclaw ? ['openclaw'] : []
|
|
489
|
+
});
|
|
490
|
+
if (!entries.ok) {
|
|
491
|
+
if (entries.code === 'io') {
|
|
492
|
+
console.error('❌ AODW-Next 初始化未完成:入口写入失败。');
|
|
493
|
+
for (const error of entries.errors) console.error(` - ${error}`);
|
|
494
|
+
console.error('请修复路径或权限,核对并备份项目改动后用原通道重跑 init;若尚未加锁,须显式使用 init --force。');
|
|
388
495
|
} else {
|
|
389
|
-
|
|
390
|
-
if (fs.existsSync(sourceAodw)) {
|
|
391
|
-
await installFile(sourceAodw, path.join(targetAgentRules, 'aodw-next.md'), AntigravityProcessor);
|
|
392
|
-
}
|
|
496
|
+
printWriteBoundaryError(entries.errors);
|
|
393
497
|
}
|
|
498
|
+
process.exitCode = 1;
|
|
499
|
+
return;
|
|
394
500
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
501
|
+
for (const warning of entries.warnings) console.warn(chalk.yellow(`⚠️ ${warning}`));
|
|
502
|
+
for (const rel of entries.created) console.log(chalk.green(` • 已生成入口薄壳 ${rel}`));
|
|
503
|
+
for (const rel of entries.updated) console.log(chalk.yellow(` • 已更新入口薄壳 ${rel}`));
|
|
504
|
+
for (const rel of entries.kept) {
|
|
505
|
+
if (rel === 'AGENTS.md') {
|
|
506
|
+
console.log(chalk.gray(' • 沿用项目自有的 AGENTS.md(唯一规范入口,未改动)'));
|
|
507
|
+
if (useOrca) {
|
|
508
|
+
console.log(chalk.gray(` • 如需启用 Orca,请手动在 AGENTS.md 中加入 ${CORE_DIRNAME}/${ORCA_RULE} 与 ${CORE_DIRNAME}/${ORCA_GUIDE} 的引用。`));
|
|
509
|
+
} else if (previousDevEnv === 'orca') {
|
|
510
|
+
console.log(chalk.yellow(` ⚠ 切回标准流程:请手动移除 AGENTS.md 中指向已停用的 ${CORE_DIRNAME}/${ORCA_RULE} 的引用。`));
|
|
511
|
+
}
|
|
405
512
|
} else {
|
|
406
|
-
|
|
407
|
-
path.join(SOURCE_ADAPTERS, 'claude/CLAUDE.md'),
|
|
408
|
-
path.join(process.cwd(), `.claude/CLAUDE.md`),
|
|
409
|
-
ClaudeProcessor
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// OpenClaw
|
|
415
|
-
if (platforms.includes('openclaw')) {
|
|
416
|
-
console.log(chalk.yellow(' • 安装 OpenClaw 适配器...'));
|
|
417
|
-
const sourceOpenclaw = path.join(SOURCE_ADAPTERS, 'openclaw');
|
|
418
|
-
if (fs.existsSync(sourceOpenclaw)) {
|
|
419
|
-
// 安装 SKILL.md
|
|
420
|
-
await installFile(
|
|
421
|
-
path.join(sourceOpenclaw, 'SKILL.md'),
|
|
422
|
-
path.join(process.cwd(), 'SKILL.md'),
|
|
423
|
-
OpenClawProcessor
|
|
424
|
-
);
|
|
425
|
-
// 安装 AGENTS.md
|
|
426
|
-
await installFile(
|
|
427
|
-
path.join(sourceOpenclaw, 'AGENTS.md'),
|
|
428
|
-
path.join(process.cwd(), 'AGENTS.md'),
|
|
429
|
-
OpenClawProcessor
|
|
430
|
-
);
|
|
513
|
+
console.log(chalk.yellow(` ⚠ 已存在项目自有的 ${rel},保持不变;想换成 AODW 薄壳时,只迁移项目自有规则到 AGENTS.md,不要复制旧版全文 loader,再备份并移走原文件后重跑 init`));
|
|
431
514
|
}
|
|
432
515
|
}
|
|
433
516
|
|
|
434
517
|
// 4. Enable v0 guard hook automatically in user project
|
|
435
518
|
await enableGuardHook({ silent: true });
|
|
519
|
+
await printProjectInitPrompt({ writeFile: true });
|
|
520
|
+
|
|
521
|
+
buildAndWriteLock(targetCore, installPlan.releaseFiles, {
|
|
522
|
+
version: packageJson.version,
|
|
523
|
+
devEnv
|
|
524
|
+
});
|
|
436
525
|
|
|
437
526
|
console.log(chalk.green('\n✅ AODW-Next 初始化成功!'));
|
|
438
527
|
console.log(chalk.white(`项目: ${projectName}`));
|
|
439
|
-
console.log(chalk.white(
|
|
440
|
-
|
|
441
|
-
await printProjectInitPrompt({ writeFile: true });
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
async function runUpdate() {
|
|
445
|
-
// 升级保护:先备份现有规范目录,再执行更新(copyCoreWithPreservation 仅保留
|
|
446
|
-
// 06-project/ 与 tools-status.yaml,改过核心规则的项目需靠备份找回定制)
|
|
447
|
-
const targetCore = path.join(process.cwd(), CORE_DIRNAME);
|
|
448
|
-
if (fs.existsSync(targetCore)) {
|
|
449
|
-
const stamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 13); // YYYYMMDDHHmm
|
|
450
|
-
const backupPath = path.join(process.cwd(), `${CORE_DIRNAME}.backup-${stamp}`);
|
|
451
|
-
await fs.copy(targetCore, backupPath);
|
|
452
|
-
console.log(chalk.yellow(`📦 升级保护:已备份现有规范到 ${path.basename(backupPath)}`));
|
|
453
|
-
console.log(chalk.yellow(' 注意:核心规则文件会被新版覆盖(仅 06-project/ 与 tools-status.yaml 保留);'));
|
|
454
|
-
console.log(chalk.yellow(' 若本项目定制过核心规则,请在升级后 diff 备份目录找回定制。'));
|
|
455
|
-
}
|
|
456
|
-
console.log(chalk.blue('🔄 正在更新 AODW-Next...'));
|
|
457
|
-
await runInit();
|
|
528
|
+
console.log(chalk.white(`入口: AGENTS.md → CLAUDE.md、.cursor/rules/aodw-next.mdc、.agent/rules/aodw-next.md、.github/copilot-instructions.md${openclaw ? '、SKILL.md (OpenClaw)' : ''}`));
|
|
458
529
|
}
|
|
459
530
|
|
|
460
531
|
async function runUninstall() {
|
|
532
|
+
const cwd = process.cwd();
|
|
533
|
+
const check = validateUninstallCore(cwd, CORE_DIRNAME);
|
|
534
|
+
if (!check.ok) {
|
|
535
|
+
console.error('❌ 拒绝卸载:检测到非法通道目录或符号链接目标。');
|
|
536
|
+
for (const err of check.errors) console.error(` - ${err}`);
|
|
537
|
+
process.exitCode = 1;
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
|
|
461
541
|
const { confirm } = await inquirer.prompt([
|
|
462
542
|
{
|
|
463
543
|
type: 'confirm',
|
|
464
544
|
name: 'confirm',
|
|
465
|
-
message: `确定要卸载 AODW-Next 吗? 这将删除 ${CORE_DIRNAME} 目录(包含 ui-kit
|
|
545
|
+
message: `确定要卸载 AODW-Next 吗? 这将删除 ${CORE_DIRNAME} 目录(包含 ui-kit)以及由 aodw-skill 生成且未被修改的入口薄壳;项目自有的 AGENTS.md、SKILL.md 与自定义入口会保留。`,
|
|
466
546
|
default: false
|
|
467
547
|
}
|
|
468
548
|
]);
|
|
469
549
|
|
|
470
550
|
if (confirm) {
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// Antigravity (Gemini)
|
|
484
|
-
await removeIfExists(path.join(cwd, '.agent/rules', 'aodw-next.md'));
|
|
485
|
-
|
|
486
|
-
// Claude
|
|
487
|
-
await removeIfExists(path.join(cwd, '.claude', 'CLAUDE.md'));
|
|
488
|
-
|
|
489
|
-
// OpenClaw
|
|
490
|
-
await removeIfExists(path.join(cwd, 'SKILL.md'));
|
|
491
|
-
await removeIfExists(path.join(cwd, 'AGENTS.md'));
|
|
492
|
-
|
|
551
|
+
const result = uninstallProject(cwd, CORE_DIRNAME);
|
|
552
|
+
if (!result.ok) {
|
|
553
|
+
console.error('❌ 拒绝卸载:检测到非法通道目录或符号链接目标。');
|
|
554
|
+
for (const err of result.errors) console.error(` - ${err}`);
|
|
555
|
+
process.exitCode = 1;
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
for (const warning of result.warnings) console.warn(chalk.yellow(`⚠️ ${warning}`));
|
|
559
|
+
for (const rel of result.removed) console.log(chalk.gray(` • 已移除入口薄壳 ${rel}`));
|
|
560
|
+
if (result.kept.length > 0) {
|
|
561
|
+
console.log(chalk.yellow(` ⚠ 以下入口不是本版生成且未修改的薄壳,已保留,请自行决定是否删除:${result.kept.join(', ')}`));
|
|
562
|
+
}
|
|
493
563
|
console.log(chalk.green('✅ AODW-Next 已卸载。'));
|
|
494
564
|
}
|
|
495
565
|
}
|
|
@@ -548,7 +618,7 @@ async function printProjectInitPrompt(options = {}) {
|
|
|
548
618
|
|
|
549
619
|
if (heading) {
|
|
550
620
|
console.log(chalk.cyan('\n--- 下一步:项目深度初始化(复制到 AI 对话) ---'));
|
|
551
|
-
console.log(chalk.gray('
|
|
621
|
+
console.log(chalk.gray('请让 AI 阅读真实代码后完善 06-project 文档。\n'));
|
|
552
622
|
}
|
|
553
623
|
|
|
554
624
|
console.log(chalk.yellow('📋 请复制以下提示词到 Cursor / Claude / Antigravity:\n'));
|
|
@@ -663,15 +733,16 @@ async function showMainMenu() {
|
|
|
663
733
|
pageSize: 10,
|
|
664
734
|
choices: [
|
|
665
735
|
new inquirer.Separator('--- 核心功能 ---'),
|
|
666
|
-
{ name: '1. 初始化
|
|
736
|
+
{ name: '1. 初始化 AODW-Next (在本项目:首次安装,或重跑 init 刷新入口)', value: 'init' },
|
|
737
|
+
{ name: '2. 安全更新上游文件 (update:只改上游文件与 aodw.lock,不碰项目文件、入口与钩子)', value: 'update' },
|
|
667
738
|
|
|
668
739
|
new inquirer.Separator('--- 工具箱 ---'),
|
|
669
|
-
{ name: '
|
|
670
|
-
{ name: '
|
|
740
|
+
{ name: '3. 项目深度初始化 - 生成提示词', value: 'init-overview-prompt' },
|
|
741
|
+
{ name: '4. 工具初始化 (ESLint/Ruff/Stack) - 生成提示词', value: 'init-tools-prompt' },
|
|
671
742
|
|
|
672
743
|
new inquirer.Separator('--- 帮助与维护 ---'),
|
|
673
|
-
{ name: '
|
|
674
|
-
{ name: '
|
|
744
|
+
{ name: '5. 查看帮助 & 部署指南', value: 'help' },
|
|
745
|
+
{ name: '6. 卸载 AODW-Next', value: 'uninstall' },
|
|
675
746
|
new inquirer.Separator(),
|
|
676
747
|
{ name: '0. 退出 (Exit)', value: 'exit' }
|
|
677
748
|
]
|
|
@@ -688,6 +759,10 @@ async function showMainMenu() {
|
|
|
688
759
|
await runInit();
|
|
689
760
|
await returnToMenu();
|
|
690
761
|
break;
|
|
762
|
+
case 'update':
|
|
763
|
+
await startUpdate();
|
|
764
|
+
await returnToMenu();
|
|
765
|
+
break;
|
|
691
766
|
case 'init-overview-prompt':
|
|
692
767
|
await generateOverviewPrompt();
|
|
693
768
|
await returnToMenu();
|
|
@@ -712,17 +787,31 @@ async function showMainMenu() {
|
|
|
712
787
|
}
|
|
713
788
|
}
|
|
714
789
|
|
|
790
|
+
function startUpdate({ force = false } = {}) {
|
|
791
|
+
return runUpdate({
|
|
792
|
+
coreDirName: CORE_DIRNAME,
|
|
793
|
+
force,
|
|
794
|
+
sourceCore: SOURCE_CORE,
|
|
795
|
+
releaseVersion: packageJson.version,
|
|
796
|
+
recordedDevEnv: getProjectConfig().dev_env
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
|
|
715
800
|
// --- Commands ---
|
|
716
801
|
|
|
717
802
|
program
|
|
718
803
|
.command('init')
|
|
719
804
|
.description('Initialize AODW-Next')
|
|
805
|
+
.addOption(new Option('--dev-env <environment>', '开发环境,跳过提问').choices(['orca', 'none']))
|
|
806
|
+
.option('-f, --force', '直接覆盖既有上游文件和未登记占位(不做备份)')
|
|
807
|
+
.option('--confirm-new-channel', '确认无法识别来源的既有入口为项目预置,且没有旧安装')
|
|
720
808
|
.action(runInit);
|
|
721
809
|
|
|
722
810
|
program
|
|
723
811
|
.command('update')
|
|
724
812
|
.description('Update AODW-Next')
|
|
725
|
-
.
|
|
813
|
+
.option('-f, --force', '按新版发行模板覆盖已漂移、无锁或占位的本地文件(先备份)')
|
|
814
|
+
.action((options) => startUpdate({ force: options.force }));
|
|
726
815
|
|
|
727
816
|
program
|
|
728
817
|
.command('uninstall')
|
|
@@ -767,6 +856,12 @@ program
|
|
|
767
856
|
.description('Install pre-commit hook to enforce AODW v0 trace guard')
|
|
768
857
|
.action(enableGuardHook);
|
|
769
858
|
|
|
859
|
+
program
|
|
860
|
+
.command('verify')
|
|
861
|
+
.description('Verify AODW-Next upstream file integrity and tool entry references')
|
|
862
|
+
.option('--require-gate', 'Require executable ./gate.sh in repository root')
|
|
863
|
+
.action(runVerify);
|
|
864
|
+
|
|
770
865
|
|
|
771
866
|
// Main Entry Point
|
|
772
867
|
if (!process.argv.slice(2).length) {
|