aodw-skill 0.11.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.
Files changed (48) hide show
  1. package/.aodw-next/01-core/ai-knowledge-rules.md +35 -2
  2. package/.aodw-next/01-core/aodw-constitution.md +22 -3
  3. package/.aodw-next/01-core/git-discipline.md +11 -0
  4. package/.aodw-next/01-core/test-discipline.md +2 -0
  5. package/.aodw-next/02-workflow/autopilot-protocol.md +4 -1
  6. package/.aodw-next/02-workflow/environment-roles.md +106 -0
  7. package/.aodw-next/02-workflow/orca-multi-session.md +4 -4
  8. package/.aodw-next/02-workflow/rt-manager.md +64 -0
  9. package/.aodw-next/02-workflow/shared-verification-host.md +103 -0
  10. package/.aodw-next/02-workflow/sub-agent-driven-profile.md +2 -1
  11. package/.aodw-next/04-auditors/aodw-development-auditor-rules.md +2 -6
  12. package/.aodw-next/04-auditors/aodw-full-auditor-rules.md +2 -6
  13. package/.aodw-next/README.md +168 -7
  14. package/.aodw-next/SKILL.md +4 -1
  15. package/.aodw-next/manifest.yaml +19 -1
  16. package/.aodw-next/templates/environments.template.md +54 -0
  17. package/.aodw-next/templates/lessons.template.md +7 -0
  18. package/.aodw-next/templates/orca-handoff-template.md +2 -1
  19. package/.aodw-next/templates/release/checklist.template.md +29 -0
  20. package/.aodw-next/templates/release/notes.template.md +22 -0
  21. package/.aodw-next/templates/release/plan.template.md +15 -0
  22. package/.aodw-next/templates/release/retro-index.template.md +8 -0
  23. package/.aodw-next/templates/release/retro-topic.template.md +33 -0
  24. package/.aodw-next/templates/rt-lite.template.md +1 -0
  25. package/.aodw-next/templates/shared-verification-host-profile.template.md +50 -0
  26. package/.aodw-next/tools/rel-plan.mjs +203 -0
  27. package/AODW_Adapters/README.md +22 -126
  28. package/AODW_Adapters/agents/AGENTS.md +11 -0
  29. package/AODW_Adapters/antigravity/.agent/rules/aodw-next.md +2 -72
  30. package/AODW_Adapters/claude/CLAUDE.md +2 -72
  31. package/AODW_Adapters/copilot/.github/copilot-instructions.md +3 -0
  32. package/AODW_Adapters/cursor/.cursor/rules/aodw-next.mdc +3 -75
  33. package/AODW_Adapters/openclaw/SKILL.md +3 -106
  34. package/README.md +60 -22
  35. package/bin/aodw.js +351 -333
  36. package/bin/commands/update.js +387 -0
  37. package/bin/commands/verify.js +420 -0
  38. package/bin/utils/lock.js +343 -0
  39. package/bin/utils/path-guard.js +449 -0
  40. package/bin/utils/release.js +36 -0
  41. package/bin/utils/tool-entries.js +506 -0
  42. package/package.json +8 -2
  43. package/.aodw-next/templates/aodw-kernel-loader-template.md +0 -71
  44. package/AODW_Adapters/cursor/.cursor/commands/README.md +0 -37
  45. package/AODW_Adapters/cursor/.cursor/rules/aodw-autopilot-continue.mdc +0 -42
  46. package/AODW_Adapters/openclaw/AGENTS.md +0 -142
  47. package/bin/processors/index.js +0 -98
  48. package/bin/update-adapters-from-template.js +0 -76
@@ -0,0 +1,420 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import {
4
+ LOCK_FILENAME,
5
+ isInsideDir,
6
+ resolveSafeFileInDir,
7
+ verifyCoreLock,
8
+ } from '../utils/lock.js';
9
+ import { refusalReason } from '../utils/path-guard.js';
10
+ import { KNOWN_TOOL_ENTRIES, verifyEntryRegistration } from '../utils/tool-entries.js';
11
+
12
+ const REFERENCE_END = String.raw`(?=$|[\s)\x60",;:<|)),。;:]|\.(?![\p{L}\p{N}_/.-]))`;
13
+ const ENTRY_FILE = String.raw`(?:AGENTS|CLAUDE|SKILL)\.md`;
14
+ const AT_TARGET_RE = new RegExp(String.raw`(?:^|[\s(>|,-])@((?:\./)?${ENTRY_FILE})${REFERENCE_END}`, 'gmu');
15
+ const AT_TRAVERSAL_RE = /(?:^|[\s(>|,-])@((?:\.\.\/|\/)[^\s)`"',<>]+)/gm;
16
+ const AODW_PATH_RE = kernelPathRegex(String.raw`(?:(?:\.\./)+|/)?\.aodw(?:-next)?`);
17
+ const ROOT_LITERAL_RE = /^(?:\.\/)?AGENTS\.md$/;
18
+
19
+ // Markdown 链接目标:说明类入口(如 Copilot 的 copilot-instructions.md)用它指向其他文件。
20
+ const LINK_TARGET_RE = /(?<![!\\])\[[^\]\r\n]+\]\(([^)\s]+)\)/g;
21
+ // URL、页内锚点与根绝对路径不是仓内相对引用。
22
+ const UNRESOLVED_LINK_RE = /^(?:[a-z][a-z0-9+.-]*:|#|\/)/i;
23
+ const ENTRY_NAME_RE = new RegExp(String.raw`(?:^|/)${ENTRY_FILE}$`);
24
+ const FRONTMATTER_RE = /^---[ \t]*\r?\n((?:[^\r\n]*\r?\n)*?)---[ \t]*(?:\r?\n|$)/;
25
+ const QUOTE_PREFIX = String.raw`(?: {0,3}>[ \t]?)*`;
26
+ const FENCE_OPEN = String.raw` {0,3}(?:\x60{3,}[^\x60\n]*|~{3,}[^\n]*)$`;
27
+ const QUOTE_PREFIX_RE = new RegExp(`^${QUOTE_PREFIX}`);
28
+ const FENCE_CLOSE_RE = /^ {0,3}(`{3,}|~{3,})[ \t]*$/;
29
+ const OUTER_TOKEN_RE = new RegExp(
30
+ String.raw`^(${QUOTE_PREFIX})(?:(${FENCE_OPEN})|(?: {4}| {0,3}\t)[^\n]*)|<!--|(?<![\\\x60])\x60+`,
31
+ 'gm',
32
+ );
33
+ const INLINE_END_RE = new RegExp(String.raw`\x60+|\n(?=${QUOTE_PREFIX}(?:[ \t]*$|${FENCE_OPEN}))`, 'gm');
34
+ const ENTRY_SYNTAX = {
35
+ 'CLAUDE.md': { kind: 'import', literalPaths: false },
36
+ '.claude/CLAUDE.md': { literalPaths: false },
37
+ '.github/copilot-instructions.md': { kind: 'link', literalPaths: false },
38
+ '.cursor/rules/aodw-next.mdc': {
39
+ kind: 'import', inlineImport: true,
40
+ activation: [/^alwaysApply[ \t]*:(.*)$/gm, /^[ \t]+true(?:[ \t]+#.*)?[ \t]*$/, 'alwaysApply: true'],
41
+ },
42
+ '.agent/rules/aodw-next.md': {
43
+ kind: 'import', inlineImport: true,
44
+ activation: [/^trigger[ \t]*:(.*)$/gm, /^[ \t]+(?:always_on|'always_on'|"always_on")(?:[ \t]+#.*)?[ \t]*$/, 'trigger: always_on'],
45
+ },
46
+ };
47
+
48
+ function escapeRegExp(text) {
49
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
50
+ }
51
+
52
+ function kernelPathRegex(dirPattern) {
53
+ return new RegExp(
54
+ String.raw`(?:^|[\s(>|@,-])(${dirPattern}/[A-Za-z0-9._/-]+\.(?:md|mdc|ya?ml|json|sh|py))${REFERENCE_END}`,
55
+ 'gmu',
56
+ );
57
+ }
58
+
59
+ function isKernelFile(refPath, patterns) {
60
+ return patterns.some((regex) => {
61
+ regex.lastIndex = 0;
62
+ return regex.exec(refPath)?.[1] === refPath;
63
+ });
64
+ }
65
+
66
+ function entryText(text) {
67
+ const frontmatter = FRONTMATTER_RE.exec(text);
68
+ const body = (frontmatter ? text.slice(frontmatter[0].length) : text).replace(/\r\n/g, '\n');
69
+ return { body, frontmatter: frontmatter?.[1] ?? '' };
70
+ }
71
+
72
+ function quoteDepth(prefix) {
73
+ return prefix ? prefix.match(/>/g).length : 0;
74
+ }
75
+
76
+ function fenceEnd(body, openerEnd, opening, depth) {
77
+ const fence = /[`~]+/.exec(opening)[0];
78
+ for (let start = openerEnd + 1; start < body.length;) {
79
+ const newline = body.indexOf('\n', start);
80
+ const end = newline === -1 ? body.length : newline;
81
+ const line = body.slice(start, end);
82
+ const quote = QUOTE_PREFIX_RE.exec(line)[0];
83
+ const lineDepth = quoteDepth(quote);
84
+ if (lineDepth < depth) return start;
85
+ if (lineDepth === depth) {
86
+ const closing = FENCE_CLOSE_RE.exec(line.slice(quote.length))?.[1];
87
+ if (closing?.[0] === fence[0] && closing.length >= fence.length) return end;
88
+ }
89
+ start = end + 1;
90
+ }
91
+ return body.length;
92
+ }
93
+
94
+ function inlineEnd(body, start, count) {
95
+ INLINE_END_RE.lastIndex = start;
96
+ for (const token of body.matchAll(INLINE_END_RE)) {
97
+ if (token[0] === '\n') break;
98
+ if (token[0].length === count) return token.index;
99
+ }
100
+ return -1;
101
+ }
102
+
103
+ // 只在正文识别开启标记;进入代码/注释就跳到由该外层语法决定的边界。
104
+ function effectiveProse(body, onLiteral) {
105
+ let parts;
106
+ let keptFrom = 0;
107
+ OUTER_TOKEN_RE.lastIndex = 0;
108
+ let token;
109
+ while ((token = OUTER_TOKEN_RE.exec(body)) !== null) {
110
+ let end = OUTER_TOKEN_RE.lastIndex;
111
+ if (token[1] !== undefined) {
112
+ if (token[2] !== undefined) end = fenceEnd(body, end, token[2], quoteDepth(token[1]));
113
+ } else if (token[0] === '<!--') {
114
+ const close = body.indexOf('-->', end);
115
+ end = close === -1 ? body.length : close + 3;
116
+ } else {
117
+ const close = inlineEnd(body, end, token[0].length);
118
+ if (close === -1) continue;
119
+ onLiteral?.(body.slice(end, close).trim());
120
+ end = close + token[0].length;
121
+ }
122
+ (parts ??= []).push(body.slice(keptFrom, token.index), ' ');
123
+ keptFrom = end;
124
+ OUTER_TOKEN_RE.lastIndex = end;
125
+ }
126
+ if (!parts) return body;
127
+ parts.push(body.slice(keptFrom));
128
+ return parts.join('');
129
+ }
130
+
131
+ function activationIssue(entryRelPath, frontmatter) {
132
+ const activation = ENTRY_SYNTAX[entryRelPath]?.activation;
133
+ if (!activation) return null;
134
+ const [field, value, required] = activation;
135
+ const settings = [...frontmatter.matchAll(field)];
136
+ return settings.length === 1 && value.test(settings[0][1]) ? null : `frontmatter 需要 ${required}`;
137
+ }
138
+
139
+ // 同一套有效引用既检查落点,也判断登记薄壳是否真的指向规范入口。
140
+ function extractEntryReferences(body, entryRelPath, coreDirName, expected) {
141
+ const syntax = ENTRY_SYNTAX[entryRelPath];
142
+ const kernels = coreDirName === '.aodw-next' ? [AODW_PATH_RE] : [AODW_PATH_RE, kernelPathRegex(escapeRegExp(coreDirName))];
143
+ const refs = new Set();
144
+ let pointsToExpected = false;
145
+ const add = (ref, kind) => {
146
+ const rel = ref.startsWith('./') ? ref.slice(2) : ref;
147
+ refs.add(rel);
148
+ if (rel === expected && (!syntax?.kind || kind === syntax.kind)) pointsToExpected = true;
149
+ };
150
+
151
+ const prose = effectiveProse(body, syntax?.literalPaths === false ? undefined : (literal) => {
152
+ // 只保留完整的独立路径;Cursor / Antigravity 模板特意把 @AGENTS.md 写在反引号中。
153
+ const imported = literal[0] === '@' ? literal.slice(1) : null;
154
+ if (syntax?.inlineImport && imported && ROOT_LITERAL_RE.test(imported)) {
155
+ add(imported, 'import');
156
+ } else if ((entryRelPath !== 'AGENTS.md' && ROOT_LITERAL_RE.test(literal)) || isKernelFile(literal, kernels)) {
157
+ add(literal, 'path');
158
+ }
159
+ });
160
+ for (const [kind, patterns] of [['import', [AT_TARGET_RE, AT_TRAVERSAL_RE]], ['path', kernels]]) {
161
+ for (const regex of patterns) {
162
+ regex.lastIndex = 0;
163
+ for (const [, target] of prose.matchAll(regex)) add(target, kind);
164
+ }
165
+ }
166
+ // 链接目标相对于入口所在目录,转换成仓根相对路径。
167
+ const entryDir = path.posix.dirname(entryRelPath);
168
+ for (const [, target] of prose.matchAll(LINK_TARGET_RE)) {
169
+ if (UNRESOLVED_LINK_RE.test(target)) continue;
170
+ const rel = path.posix.normalize(path.posix.join(entryDir, target));
171
+ if (ENTRY_NAME_RE.test(rel) || isKernelFile(rel, kernels)) add(rel, 'link');
172
+ }
173
+ return { refs, pointsToExpected };
174
+ }
175
+
176
+ // lstat 一次:不存在时 stat 为 null;操作系统拒绝时(上级不是目录、没有权限等)stat 为 null 且 refusal 是原因;程序错误照常抛出。
177
+ function lstatEntry(absPath) {
178
+ try {
179
+ return { stat: fs.lstatSync(absPath), refusal: null };
180
+ } catch (err) {
181
+ if (err.code === 'ENOENT') return { stat: null, refusal: null };
182
+ const refusal = refusalReason(err);
183
+ if (refusal === null) throw err;
184
+ return { stat: null, refusal };
185
+ }
186
+ }
187
+
188
+ function resolveRepoTarget(projectRoot, realProjectRoot, refPath) {
189
+ if (!refPath || refPath.includes('\0') || refPath.includes('\\')) {
190
+ return { ok: false, reason: '路径包含非法字符' };
191
+ }
192
+ if (path.posix.isAbsolute(refPath) || /^[A-Za-z]:/.test(refPath)) {
193
+ return { ok: false, reason: '不允许绝对路径引用' };
194
+ }
195
+
196
+ const candidate = path.resolve(projectRoot, ...refPath.split('/'));
197
+ if (!isInsideDir(projectRoot, candidate)) {
198
+ return { ok: false, reason: '引用路径越出项目根目录' };
199
+ }
200
+
201
+ const looked = lstatEntry(candidate);
202
+ if (looked.stat === null) {
203
+ return looked.refusal === null
204
+ ? { ok: false, reason: '目标文件不存在' }
205
+ : { ok: false, reason: `目标路径无法访问:${looked.refusal}`, refusal: looked.refusal };
206
+ }
207
+
208
+ let realTarget;
209
+ let stat;
210
+ try {
211
+ realTarget = fs.realpathSync(candidate);
212
+ stat = fs.statSync(realTarget);
213
+ } catch (err) {
214
+ const refusal = refusalReason(err);
215
+ if (refusal === null) throw err;
216
+ return err.code === 'ENOENT'
217
+ ? { ok: false, reason: '目标文件不存在或符号链接失效' }
218
+ : { ok: false, reason: `目标路径无法访问:${refusal}`, refusal };
219
+ }
220
+
221
+ if (!isInsideDir(realProjectRoot, realTarget)) {
222
+ return { ok: false, reason: '目标真实路径越出项目根目录' };
223
+ }
224
+ if (!stat.isFile()) {
225
+ return { ok: false, reason: '目标不是普通文件' };
226
+ }
227
+ return { ok: true, absPath: candidate, realPath: realTarget, stat };
228
+ }
229
+
230
+ function locateToolEntry(projectRoot, realProjectRoot, entryRel, registered) {
231
+ if (registered) {
232
+ const safe = resolveSafeFileInDir(projectRoot, realProjectRoot, entryRel);
233
+ if (safe.ok) return { realPath: safe.realPath };
234
+ if (safe.code === 'error') throw safe.error; // 保留 errno;由调用方统一分类
235
+ if (safe.code === 'not_dir') {
236
+ return { diagnostic: `工具入口无法检查 (${entryRel}): ${safe.reason}` };
237
+ }
238
+ return {
239
+ diagnostic: safe.code === 'missing'
240
+ ? `工具入口薄壳缺失 (${entryRel}):它由 aodw-skill 生成并登记,重跑 npx aodw-skill init 可补全`
241
+ : `工具入口薄壳异常 (${entryRel}):${safe.reason},请先移开异常路径再重跑 npx aodw-skill init`,
242
+ };
243
+ }
244
+
245
+ const absEntry = path.join(projectRoot, ...entryRel.split('/'));
246
+ const looked = lstatEntry(absEntry);
247
+ if (looked.stat === null) {
248
+ return { diagnostic: looked.refusal === null ? null : `工具入口无法检查 (${entryRel}): ${looked.refusal}` };
249
+ }
250
+ const realPath = fs.realpathSync(absEntry);
251
+ const stat = fs.statSync(realPath);
252
+ if (!isInsideDir(realProjectRoot, realPath) || !stat.isFile()) {
253
+ return { diagnostic: `工具入口异常 (${entryRel}): 必须位于项目根目录内且为普通文件` };
254
+ }
255
+ return { realPath };
256
+ }
257
+
258
+ export function verifyToolEntries(projectRoot, realProjectRoot, {
259
+ coreDirName = '.aodw-next',
260
+ onInvalidReference,
261
+ onEntryDiagnostic,
262
+ } = {}) {
263
+ const checkedEntries = [];
264
+ const { registered, errors } = verifyEntryRegistration(projectRoot, realProjectRoot, coreDirName);
265
+ const warnings = [];
266
+ const reportEntryDiagnostic = (error) => {
267
+ errors.push(error);
268
+ onEntryDiagnostic?.(error);
269
+ };
270
+
271
+ for (const entryRel of KNOWN_TOOL_ENTRIES) {
272
+ const owned = registered.has(entryRel);
273
+ // 登记的安全解析也是读取的一部分。个别入口失败要诊断,不能挡住后续入口,也不能降级为未登记。
274
+ let located;
275
+ try {
276
+ located = locateToolEntry(projectRoot, realProjectRoot, entryRel, owned);
277
+ } catch (err) {
278
+ const refusal = refusalReason(err);
279
+ if (refusal === null) throw err;
280
+ reportEntryDiagnostic(
281
+ err.code === 'ENOENT' && !owned
282
+ ? `工具入口失效 (${entryRel}): 符号链接目标不存在`
283
+ : `工具入口无法读取 (${entryRel}): ${refusal}`,
284
+ );
285
+ continue;
286
+ }
287
+
288
+ if (!located.realPath) {
289
+ if (located.diagnostic) reportEntryDiagnostic(located.diagnostic);
290
+ continue; // 无诊断的空落点是未安装的可选入口
291
+ }
292
+
293
+ let raw;
294
+ try {
295
+ raw = fs.readFileSync(located.realPath, 'utf8');
296
+ } catch (err) {
297
+ const refusal = refusalReason(err);
298
+ if (refusal === null) throw err;
299
+ reportEntryDiagnostic(`工具入口无法读取 (${entryRel}): ${refusal}`);
300
+ continue;
301
+ }
302
+ checkedEntries.push(entryRel);
303
+ const text = entryText(raw);
304
+ const expected = owned
305
+ ? (entryRel === 'AGENTS.md' ? `${coreDirName}/01-core/aodw-constitution.md` : 'AGENTS.md')
306
+ : null;
307
+ const { refs, pointsToExpected } = extractEntryReferences(text.body, entryRel, coreDirName, expected);
308
+ if (expected) {
309
+ const issue = activationIssue(entryRel, text.frontmatter) ??
310
+ (pointsToExpected ? null : `缺少指向 ${expected} 的有效引用`);
311
+ if (issue) {
312
+ errors.push(`工具入口薄壳指针失效 (${entryRel}):${issue}。请修回;若要保留已修改的自定义入口,请先备份并用原通道重跑 init,将其保留为项目自有。`);
313
+ }
314
+ }
315
+ for (const refPath of refs) {
316
+ const check = resolveRepoTarget(projectRoot, realProjectRoot, refPath);
317
+ if (!check.ok) {
318
+ const error = `工具入口 ${entryRel} 引用路径无效 (${refPath}): ${check.reason}`;
319
+ if (check.refusal !== undefined) reportEntryDiagnostic(error);
320
+ else {
321
+ errors.push(error);
322
+ onInvalidReference?.(refPath, error);
323
+ }
324
+ }
325
+ }
326
+ }
327
+
328
+ if (checkedEntries.length === 0) {
329
+ warnings.push('未检测到任何已知 AI 工具入口文件(已跳过入口指针校验)');
330
+ }
331
+ return { ok: errors.length === 0, checkedEntries, errors, warnings };
332
+ }
333
+
334
+ export function verifyGateScript(projectRoot, realProjectRoot) {
335
+ const check = resolveRepoTarget(projectRoot, realProjectRoot, 'gate.sh');
336
+ if (!check.ok) {
337
+ return { ok: false, errors: [`仓根门禁脚本校验失败 (gate.sh): ${check.reason}`] };
338
+ }
339
+ if (process.platform !== 'win32' && (check.stat.mode & 0o111) === 0) {
340
+ return { ok: false, errors: ['仓根门禁脚本 gate.sh 缺少可执行权限(请运行 chmod +x gate.sh)'] };
341
+ }
342
+ return { ok: true, errors: [] };
343
+ }
344
+
345
+ export function verifyProject(projectRoot, { coreDirName = '.aodw-next', requireGate = false } = {}) {
346
+ const realProjectRoot = fs.realpathSync(projectRoot);
347
+ const lockResult = verifyCoreLock(projectRoot, coreDirName);
348
+ const entryResult = verifyToolEntries(projectRoot, realProjectRoot, { coreDirName });
349
+ const gateResult = requireGate ? verifyGateScript(projectRoot, realProjectRoot) : null;
350
+
351
+ const errors = [
352
+ ...lockResult.errors,
353
+ ...entryResult.errors,
354
+ ...(gateResult ? gateResult.errors : []),
355
+ ];
356
+ const warnings = [...lockResult.warnings, ...entryResult.warnings];
357
+ return { ok: errors.length === 0, lockResult, entryResult, gateResult, errors, warnings };
358
+ }
359
+
360
+ // init 与 update 共用这段预检提示:init --force 直接覆盖私改、不做备份,只有 update --force 会先备份。
361
+ export function printUpdatePreflightError(preflight, coreDirName = '.aodw-next', { command = 'update' } = {}) {
362
+ const isInit = command === 'init';
363
+ console.error(isInit
364
+ ? `❌ 拒绝初始化:${coreDirName}/ 未通过完整性锁预检(状态: ${preflight.status})。`
365
+ : `❌ 拒绝覆盖更新:${coreDirName}/ 未通过完整性锁预检(状态: ${preflight.status})。`);
366
+ for (const err of preflight.errors) console.error(` - ${err}`);
367
+ if (preflight.status === 'missing_lock') {
368
+ console.error('提示:当前为旧版无锁安装,无法判定上游文件是否存在本地私改;不会静默认证或覆盖。');
369
+ console.error(isInit
370
+ ? `请先核对并把项目定制移至 ${coreDirName}/06-project/(或回推上游);要带着备份完成这次迁移,请运行 "aodw-skill update --force"。`
371
+ : `请先核对并把项目定制移至 ${coreDirName}/06-project/(或回推上游),确认后使用 "aodw-skill update --force" 备份并按新版上游重新加锁。`);
372
+ } else if (isInit) {
373
+ console.error(
374
+ `提示:请先将项目定制改动移至 ${coreDirName}/06-project/ 或回推上游 AODW-Next 并还原上游文件;"init --force" 会直接覆盖私改且不做备份,需要备份请用 "aodw-skill update --force"。`,
375
+ );
376
+ } else {
377
+ console.error(
378
+ `提示:请先将项目定制改动移至 ${coreDirName}/06-project/ 或回推上游 AODW-Next 并还原上游文件;若明确要备份并强制以新版上游覆盖,请加 "--force"。`,
379
+ );
380
+ }
381
+ }
382
+
383
+ export function printWriteBoundaryError(errors) {
384
+ console.error('❌ 拒绝写入:检测到非法通道目录或指向仓库内外的符号链接目标。');
385
+ for (const err of errors) console.error(` - ${err}`);
386
+ console.error('提示:--force 仅授权覆盖仓库内既有上游文件,不能绕过符号链接或通道目录边界。');
387
+ }
388
+
389
+ export function runVerify(options = {}) {
390
+ const coreDirName = process.env.AODW_CORE_DIR || '.aodw-next';
391
+ const requireGate = Boolean(options.requireGate);
392
+ const result = verifyProject(process.cwd(), { coreDirName, requireGate });
393
+
394
+ for (const warn of result.warnings) console.warn(`⚠️ ${warn}`);
395
+
396
+ if (result.ok) {
397
+ const fileCount = Object.keys(result.lockResult.lock.files).length;
398
+ console.log(
399
+ `✅ AODW-Next 完整性校验通过(上游锁定文件 ${fileCount} 项,检查工具入口 ${result.entryResult.checkedEntries.length} 项${requireGate ? ',gate.sh 有效' : ''})。`,
400
+ );
401
+ process.exitCode = 0;
402
+ return result;
403
+ }
404
+
405
+ console.error('❌ AODW-Next 完整性校验失败:');
406
+ for (const err of result.errors) console.error(` - ${err}`);
407
+
408
+ if (result.lockResult.status === 'missing_lock') {
409
+ console.error(
410
+ `\n提示:未找到 ${coreDirName}/${LOCK_FILENAME}。如为旧版安装,请先核对本地改动并将其移至 ${coreDirName}/06-project/(或回推上游),再运行 "aodw-skill update --force" 生成上游锁。`,
411
+ );
412
+ } else if (result.lockResult.modified.length > 0 || result.lockResult.missing.length > 0) {
413
+ console.error(
414
+ `\n提示:请将项目定制改动放入 ${coreDirName}/06-project/ 或提 PR 回推上游 AODW-Next,并还原上游文件(修回后重新运行 "aodw-skill verify" 即可通过)。`,
415
+ );
416
+ }
417
+
418
+ process.exitCode = 1;
419
+ return result;
420
+ }