flow-comet 1.5.0-rc.3 → 1.5.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/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/reference/decision-points.md +2 -2
- package/.flow-comet/skills/flow-comet/reference/dsh-platform.md +2 -2
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +8 -201
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +10 -1
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +98 -2
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +7 -4
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +3 -2
- package/.flow-comet/skills/flow-comet-evolve/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-review/SKILL.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
- package/scripts/prepare-env.mjs +23 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
1.5.0
|
|
1
|
+
1.5.0
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|------|------|------|
|
|
9
9
|
| 用户决策 | ≥2 个会改变范围/行为/风险/不可逆结果的合法选项 | 用交互确认问(Claude Code 用 AskUserQuestion 优先;Codex 用文本提问+内联确认)或文本回退;相邻选择合并为一个问题,不重问已持久化选择 |
|
|
10
10
|
| 自动处理 | 唯一安全下一步 | 直接执行并汇报,不许制造确认 |
|
|
11
|
-
| 停止条件 | guard 失败 / 缺依赖 / 状态损坏 |
|
|
11
|
+
| 停止条件 | guard 失败 / 缺依赖 / 状态损坏 | 报告阻塞与恢复条件;存在多个会改变范围或风险的合法恢复动作时才升级为用户决策 |
|
|
12
12
|
| 手动交接 | `NEXT: manual`(若有) | 不是用户决策,直接继续 |
|
|
13
13
|
|
|
14
14
|
## 作者化决策点清单(按节点)
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
| 触发 | 处理 |
|
|
43
43
|
|------|------|
|
|
44
|
-
| Node guard 失败 |
|
|
44
|
+
| Node guard 失败 | 先自动诊断并执行唯一安全修复;无合法动作时报告停止条件;存在多个会改变范围或风险的合法恢复动作时才升级为用户决策 |
|
|
45
45
|
| 缺依赖 / 状态损坏无法继续 | 报告停止条件与恢复条件;恢复方式存在多个会改变范围或风险的合法选项时才升级为用户决策 |
|
|
46
46
|
|
|
47
47
|
### 手动交接(非用户决策)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
| 认证 dsh 版本 | `0.1.5-rc.1`(2026-09-10 全接缝运行时认证;历史锚 `0.1.0-rc.6` → `0.1.1-rc.2` 实测线) |
|
|
12
12
|
| 安装入口 | `node scripts/prepare-env.mjs --target <项目> --platform dsh`(或交互终端多选勾选 dsh)——唯一入口(D1) |
|
|
13
13
|
| 重置/重新生成(purge——删除后重建到完整安装态,**不是卸载**) | `node scripts/prepare-env.mjs --target <项目> --purge --platform dsh --yes` |
|
|
14
|
-
| npm 包 |
|
|
14
|
+
| npm 包 | **自 `1.5.0-rc.3` 起已发布**(`npm i -g flow-comet` → `fcomet init`,dist-tag `latest`)——分发的为**安装器**,非 dsh 插件包;旧 npm 插件包安装形态已废弃(verify 阶段推翻,见 ADR-005) |
|
|
15
15
|
| 破坏性变更 | dev-preview 中 `tools/pre-execute` 签名 / skill 发现 rank / `DSH_HOME` 语义可能变化;低于锚定版本时拦截/发现可能失效 |
|
|
16
16
|
|
|
17
17
|
> 版本不匹配时拦截可能失效——必须文档警示 + 级 3 实测兜底(D9)。
|
|
@@ -81,7 +81,7 @@ ctx.on('tools/pre-execute', async (exec, next) => {
|
|
|
81
81
|
### 激活(天然项目级)
|
|
82
82
|
|
|
83
83
|
- 目录物理存在即激活——dsh 启动自动发现 `/flow-comet`(rank 100,chokidar 热发现免重启);未安装该目录的项目不可见(无痕迹判定、无 chicken-and-egg)。
|
|
84
|
-
- dsh 对项目 AGENTS.md
|
|
84
|
+
- dsh 对项目 AGENTS.md 的注入行为**已认证**(0.1.5-rc.1 headless 会话:项目根 AGENTS.md 作为上下文注入,托管区内容被会话逐字引用——见下方认证记录);**边界**:认证面向 headless profile,dsh-tui / web 运行时未验。
|
|
85
85
|
|
|
86
86
|
### 重置/重新生成(prepare-env --purge --yes——删除后重建,**不是卸载**)
|
|
87
87
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { promises as fs, existsSync as fsExistsSync } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import {
|
|
6
|
+
inspectWorkflowProtectedPath,
|
|
6
7
|
parseProtocolWriteWhitelist,
|
|
7
8
|
readProtocolFile,
|
|
9
|
+
readWorkflowProtectedFile,
|
|
8
10
|
resolveProtocol,
|
|
9
11
|
validateProtocolSchema,
|
|
12
|
+
workflowPathInside,
|
|
10
13
|
} from './protocol-utils.mjs';
|
|
11
14
|
// 运行时路径常量(单一来源:state-schema.mjs)——本脚本每次工具调用都会执行,故此处只 import
|
|
12
15
|
// 同包内的本地 ESM 模块(与已存在的 protocol-utils.mjs import 同型,实测无可感知开销);
|
|
@@ -397,206 +400,10 @@ const WORKFLOW_PROJECT_FILE_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
397
400
|
// execute 的名单由 state.executionMode 动态收窄(subagent=协调者 .specs/;direct=逃生口允许主代理直写源码),
|
|
398
401
|
// 收窄规则对缺省/声明表同样生效,见 resolvePhaseWriteWhitelist()
|
|
399
402
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
(!path.isAbsolute(relative) &&
|
|
405
|
-
relative !== '..' &&
|
|
406
|
-
!relative.startsWith('..' + path.sep))
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
async function inspectWorkflowProtectedPath(
|
|
411
|
-
projectRoot,
|
|
412
|
-
target,
|
|
413
|
-
label,
|
|
414
|
-
expected = 'any',
|
|
415
|
-
) {
|
|
416
|
-
const lexicalRoot = path.resolve(projectRoot);
|
|
417
|
-
const lexicalTarget = path.resolve(target);
|
|
418
|
-
if (!workflowPathInside(lexicalRoot, lexicalTarget)) {
|
|
419
|
-
throw new Error(label + ' must stay inside the project root');
|
|
420
|
-
}
|
|
421
|
-
const rootStat = await fs.lstat(lexicalRoot);
|
|
422
|
-
if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) {
|
|
423
|
-
throw new Error(label + ' project root must be a real directory');
|
|
424
|
-
}
|
|
425
|
-
const realRoot = await fs.realpath(lexicalRoot);
|
|
426
|
-
const relative = path.relative(lexicalRoot, lexicalTarget);
|
|
427
|
-
const segments = relative === '' ? [] : relative.split(path.sep);
|
|
428
|
-
let cursor = lexicalRoot;
|
|
429
|
-
for (let index = 0; index < segments.length; index++) {
|
|
430
|
-
cursor = path.join(cursor, segments[index]);
|
|
431
|
-
let stat;
|
|
432
|
-
try {
|
|
433
|
-
stat = await fs.lstat(cursor);
|
|
434
|
-
} catch (error) {
|
|
435
|
-
if (
|
|
436
|
-
error &&
|
|
437
|
-
typeof error === 'object' &&
|
|
438
|
-
(error.code === 'ENOENT' || error.code === 'ENOTDIR')
|
|
439
|
-
) {
|
|
440
|
-
return { target: lexicalTarget, exists: false };
|
|
441
|
-
}
|
|
442
|
-
throw error;
|
|
443
|
-
}
|
|
444
|
-
const display = path.relative(lexicalRoot, cursor).replaceAll('\\', '/');
|
|
445
|
-
if (stat.isSymbolicLink()) {
|
|
446
|
-
throw new Error(label + ' crosses a symbolic link or junction at ' + display);
|
|
447
|
-
}
|
|
448
|
-
const final = index === segments.length - 1;
|
|
449
|
-
if (!final && !stat.isDirectory()) {
|
|
450
|
-
throw new Error(label + ' ancestor ' + display + ' must be a real directory');
|
|
451
|
-
}
|
|
452
|
-
if (
|
|
453
|
-
final &&
|
|
454
|
-
((expected === 'file' && !stat.isFile()) ||
|
|
455
|
-
(expected === 'directory' && !stat.isDirectory()) ||
|
|
456
|
-
(expected === 'any' && !stat.isFile() && !stat.isDirectory()))
|
|
457
|
-
) {
|
|
458
|
-
throw new Error(label + ' must be a real ' + expected);
|
|
459
|
-
}
|
|
460
|
-
const physical = await fs.realpath(cursor);
|
|
461
|
-
if (!workflowPathInside(realRoot, physical)) {
|
|
462
|
-
throw new Error(label + ' resolves outside the project root');
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return { target: lexicalTarget, exists: true };
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function workflowFileObjectIdentity(stat) {
|
|
469
|
-
return {
|
|
470
|
-
dev: stat.dev,
|
|
471
|
-
ino: stat.ino,
|
|
472
|
-
birthtime: typeof stat.birthtimeNs === 'bigint' ? stat.birthtimeNs : stat.birthtimeMs,
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function workflowHasIdentity(value) {
|
|
477
|
-
return value !== 0 && value !== 0n && value !== '0';
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
function workflowSameFileObject(left, right) {
|
|
481
|
-
const comparableDevice = workflowHasIdentity(left.dev) && workflowHasIdentity(right.dev);
|
|
482
|
-
const comparableInode = workflowHasIdentity(left.ino) && workflowHasIdentity(right.ino);
|
|
483
|
-
if (comparableDevice && left.dev !== right.dev) return false;
|
|
484
|
-
if (comparableInode && left.ino !== right.ino) return false;
|
|
485
|
-
if (comparableDevice && comparableInode) return true;
|
|
486
|
-
return left.birthtime === right.birthtime;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function workflowSameFileStat(left, right) {
|
|
490
|
-
return (
|
|
491
|
-
workflowSameFileObject(
|
|
492
|
-
workflowFileObjectIdentity(left),
|
|
493
|
-
workflowFileObjectIdentity(right),
|
|
494
|
-
) &&
|
|
495
|
-
left.size === right.size &&
|
|
496
|
-
left.ctimeNs === right.ctimeNs
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
async function readWorkflowProtectedFile(
|
|
501
|
-
projectRoot,
|
|
502
|
-
file,
|
|
503
|
-
label,
|
|
504
|
-
maxBytes,
|
|
505
|
-
hooks = {},
|
|
506
|
-
) {
|
|
507
|
-
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) {
|
|
508
|
-
throw new Error(label + ' byte limit must be a positive integer');
|
|
509
|
-
}
|
|
510
|
-
const inspection = await inspectWorkflowProtectedPath(
|
|
511
|
-
projectRoot,
|
|
512
|
-
file,
|
|
513
|
-
label,
|
|
514
|
-
'file',
|
|
515
|
-
);
|
|
516
|
-
if (!inspection.exists) {
|
|
517
|
-
const error = new Error(label + ' does not exist');
|
|
518
|
-
error.code = 'ENOENT';
|
|
519
|
-
throw error;
|
|
520
|
-
}
|
|
521
|
-
const before = await fs.lstat(file, { bigint: true });
|
|
522
|
-
if (!before.isFile() || before.isSymbolicLink()) {
|
|
523
|
-
throw new Error(label + ' must be a real file');
|
|
524
|
-
}
|
|
525
|
-
if (before.size > BigInt(maxBytes)) {
|
|
526
|
-
throw new Error(label + ' exceeds ' + String(maxBytes) + ' bytes');
|
|
527
|
-
}
|
|
528
|
-
const beforeRealPath = await fs.realpath(file);
|
|
529
|
-
await hooks.afterLstat?.();
|
|
530
|
-
const flags =
|
|
531
|
-
process.platform === 'win32'
|
|
532
|
-
? fsConstants.O_RDONLY
|
|
533
|
-
: fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK;
|
|
534
|
-
let handle;
|
|
535
|
-
try {
|
|
536
|
-
handle = await fs.open(file, flags);
|
|
537
|
-
} catch (error) {
|
|
538
|
-
if (error && typeof error === 'object' && error.code === 'ELOOP') {
|
|
539
|
-
throw new Error(label + ' must be a real file');
|
|
540
|
-
}
|
|
541
|
-
throw error;
|
|
542
|
-
}
|
|
543
|
-
try {
|
|
544
|
-
const [opened, afterOpen, afterOpenRealPath] = await Promise.all([
|
|
545
|
-
handle.stat({ bigint: true }),
|
|
546
|
-
fs.lstat(file, { bigint: true }),
|
|
547
|
-
fs.realpath(file),
|
|
548
|
-
]);
|
|
549
|
-
if (
|
|
550
|
-
!opened.isFile() ||
|
|
551
|
-
!afterOpen.isFile() ||
|
|
552
|
-
afterOpen.isSymbolicLink() ||
|
|
553
|
-
afterOpenRealPath !== beforeRealPath ||
|
|
554
|
-
!workflowSameFileStat(before, opened) ||
|
|
555
|
-
!workflowSameFileStat(before, afterOpen)
|
|
556
|
-
) {
|
|
557
|
-
throw new Error(label + ' changed while opening');
|
|
558
|
-
}
|
|
559
|
-
await inspectWorkflowProtectedPath(projectRoot, file, label, 'file');
|
|
560
|
-
await hooks.afterOpen?.();
|
|
561
|
-
const chunks = [];
|
|
562
|
-
let total = 0;
|
|
563
|
-
const buffer = Buffer.allocUnsafe(Math.min(64 * 1024, maxBytes + 1));
|
|
564
|
-
for (;;) {
|
|
565
|
-
const remaining = maxBytes + 1 - total;
|
|
566
|
-
const { bytesRead } = await handle.read(
|
|
567
|
-
buffer,
|
|
568
|
-
0,
|
|
569
|
-
Math.min(buffer.length, remaining),
|
|
570
|
-
null,
|
|
571
|
-
);
|
|
572
|
-
if (bytesRead === 0) break;
|
|
573
|
-
total += bytesRead;
|
|
574
|
-
if (total > maxBytes) {
|
|
575
|
-
throw new Error(label + ' exceeds ' + String(maxBytes) + ' bytes');
|
|
576
|
-
}
|
|
577
|
-
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
578
|
-
}
|
|
579
|
-
await hooks.beforeFinalCheck?.();
|
|
580
|
-
const [afterHandle, afterPath, afterRealPath] = await Promise.all([
|
|
581
|
-
handle.stat({ bigint: true }),
|
|
582
|
-
fs.lstat(file, { bigint: true }),
|
|
583
|
-
fs.realpath(file),
|
|
584
|
-
]);
|
|
585
|
-
if (
|
|
586
|
-
!afterPath.isFile() ||
|
|
587
|
-
afterPath.isSymbolicLink() ||
|
|
588
|
-
afterRealPath !== beforeRealPath ||
|
|
589
|
-
!workflowSameFileStat(before, afterHandle) ||
|
|
590
|
-
!workflowSameFileStat(before, afterPath)
|
|
591
|
-
) {
|
|
592
|
-
throw new Error(label + ' changed while reading');
|
|
593
|
-
}
|
|
594
|
-
await inspectWorkflowProtectedPath(projectRoot, file, label, 'file');
|
|
595
|
-
return Buffer.concat(chunks, total);
|
|
596
|
-
} finally {
|
|
597
|
-
await handle.close();
|
|
598
|
-
}
|
|
599
|
-
}
|
|
403
|
+
// 受保护路径三判据(workflowPathInside / inspectWorkflowProtectedPath /
|
|
404
|
+
// readWorkflowProtectedFile)与私有身份比较函数是 protocol-utils.mjs 的**单一来源**——
|
|
405
|
+
// 本文件此前各持一份逐字节相同的副本,两侧注释互指「同源」;副本已删除,改为 import
|
|
406
|
+
// (见文件头 import 列表)。改判据只需改 protocol-utils.mjs 一处。
|
|
600
407
|
|
|
601
408
|
function workflowRelativeSegments(value, label, allowWildcards = false) {
|
|
602
409
|
if (typeof value !== 'string') throw new Error(label + ' must be a string');
|
|
@@ -203,8 +203,17 @@ const CONTEXT_FORMAT_CHECKS = [
|
|
|
203
203
|
|
|
204
204
|
// 段名规范化:兼容「带 `## ` 前缀」(内置 fallback)与「不带前缀」(模板派生)两种来源,
|
|
205
205
|
// 并剥离模板标题的括注后缀(`已锁决策(ADR 摘要)` → `已锁决策`,与 deriveSections 同口径)。
|
|
206
|
+
// 第三项剥离 **ATX 闭合标记**(`## 名称 ##` 的尾部 `##`):它是合法 Markdown 语法,
|
|
207
|
+
// 不剥离时段名归一成 `名称 ##`,与模板段名不等 → 七段被整片判成缺失
|
|
208
|
+
// (INIT-VALIDATE-FAILED),依赖 CONTEXT 结构校验的正常路径被误阻断。
|
|
209
|
+
// 闭合标记按 CommonMark 收口:必须**前置空白**(故 `C#` 这类以井号结尾的段名不被误剥),
|
|
210
|
+
// 其后可跟空白。
|
|
206
211
|
function normalizeSectionName(name) {
|
|
207
|
-
return String(name ?? '')
|
|
212
|
+
return String(name ?? '')
|
|
213
|
+
.replace(/^#{1,6}\s*/, '')
|
|
214
|
+
.replace(/[((].*$/, '')
|
|
215
|
+
.replace(/[ \t]+#+[ \t]*$/, '')
|
|
216
|
+
.trim();
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
// 围栏代码块剥离:标题/格式判定的输入必须是「文档结构」,而代码示例里的 `## 段名` 只是示例文本。
|
|
@@ -3072,10 +3072,12 @@ const SCENARIOS = [
|
|
|
3072
3072
|
],
|
|
3073
3073
|
}, null, 2));
|
|
3074
3074
|
assertExit(runState(['init', CHANGE_ID, '--protocol', custom, '--init-skip'], dir), 0);
|
|
3075
|
-
// status:classic/native pathBase → fail-fast
|
|
3075
|
+
// status:classic/native pathBase → fail-fast 显式报错(不静默兜底)。
|
|
3076
|
+
// 措辞订正:guard 侧同样拒绝这三类 pathBase,故消息不再说「由 guard 校验支持」
|
|
3077
|
+
// (旧措辞会让人以为只有状态机推导缺支持)——断言随之锁新措辞。
|
|
3076
3078
|
const st = runState(['status', '--protocol', custom], dir);
|
|
3077
3079
|
assertExit(st, 1);
|
|
3078
|
-
assertOut(st, '
|
|
3080
|
+
assertOut(st, '已不受 guard 与状态机支持');
|
|
3079
3081
|
assertOut(st, 'specs-root');
|
|
3080
3082
|
},
|
|
3081
3083
|
},
|
|
@@ -7236,6 +7238,100 @@ const SCENARIOS = [
|
|
|
7236
7238
|
assertOut(notCommand, 'workflow-hook-guard-ok');
|
|
7237
7239
|
},
|
|
7238
7240
|
},
|
|
7241
|
+
|
|
7242
|
+
// 242: ATX 标题的**闭合标记**(`## 名称 ##`——合法 Markdown)须在段名归一中被剥离。
|
|
7243
|
+
// 不剥离时段名归一为 `名称 ##`,与模板段名不等 → 七段全判缺失 → INIT-VALIDATE-FAILED,
|
|
7244
|
+
// 依赖 CONTEXT 结构校验的流程被误阻断(记录扫描时间的正常路径走不通)。
|
|
7245
|
+
// 与场景 90(同夹具、无闭合标记)成对:唯一变量就是闭合标记本身。
|
|
7246
|
+
{
|
|
7247
|
+
name: '242 CONTEXT 段标题带 ATX 闭合标记 → 段存在判定通过(INIT-DONE)',
|
|
7248
|
+
run: (dir) => {
|
|
7249
|
+
writeFile(dir, '.specs/CONTEXT.md', [
|
|
7250
|
+
'# CONTEXT',
|
|
7251
|
+
'## 项目概要 ##', 'x',
|
|
7252
|
+
'## 技术栈 ##', 'x',
|
|
7253
|
+
'## 域语言 ##', '| 术语 | 定义 |', '|---|---|', '| 例 | 定义 |',
|
|
7254
|
+
'## 已锁决策 ##', '- [2026-08-01] 决策一',
|
|
7255
|
+
'## 默认偏好 ##', 'x',
|
|
7256
|
+
'## 既有抽象索引 ##', 'x',
|
|
7257
|
+
'## intel-scan 元数据 ##', '- **last_intel_scan**: x', '- **scanner**: x', '- **下次重扫建议**: x',
|
|
7258
|
+
'',
|
|
7259
|
+
].join('\n'));
|
|
7260
|
+
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
7261
|
+
const res = runState(['init', CHANGE_ID, '--init-context'], dir, { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
7262
|
+
assertExit(res, 0);
|
|
7263
|
+
assertOut(res, 'INIT-DONE');
|
|
7264
|
+
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
7265
|
+
if (!st.last_intel_scan) throw new Error('闭合标记形态应通过段存在判定并写 last_intel_scan');
|
|
7266
|
+
// ② 闭合标记须**前置空白**(CommonMark 语义):`## 项目概要#` 不是闭合形态,段名即
|
|
7267
|
+
// `项目概要#`——它不得被剥成 `项目概要`(否则缺段被假判为存在)。这条边界锁住剥离
|
|
7268
|
+
// 范围:将来把前置空白放宽成「任意位置」,此处即变红。
|
|
7269
|
+
writeFile(dir, '.specs/CONTEXT.md', [
|
|
7270
|
+
'# CONTEXT',
|
|
7271
|
+
'## 项目概要#', 'x',
|
|
7272
|
+
'## 技术栈 ##', 'x',
|
|
7273
|
+
'## 域语言 ##', '| 术语 | 定义 |', '|---|---|', '| 例 | 定义 |',
|
|
7274
|
+
'## 已锁决策 ##', '- [2026-08-01] 决策一',
|
|
7275
|
+
'## 默认偏好 ##', 'x',
|
|
7276
|
+
'## 既有抽象索引 ##', 'x',
|
|
7277
|
+
'## intel-scan 元数据 ##', '- **last_intel_scan**: x', '- **scanner**: x', '- **下次重扫建议**: x',
|
|
7278
|
+
'',
|
|
7279
|
+
].join('\n'));
|
|
7280
|
+
const boundary = runState(['init', CHANGE_ID + '-2', '--init-context'], dir, { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
7281
|
+
assertExit(boundary, 0);
|
|
7282
|
+
assertOut(boundary, 'INIT-VALIDATE-FAILED');
|
|
7283
|
+
assertOut(boundary, '项目概要');
|
|
7284
|
+
},
|
|
7285
|
+
},
|
|
7286
|
+
|
|
7287
|
+
// 243: `.gitignore` 读取的**访问类故障**(非「确实不存在」)不得当作「文件缺失」。
|
|
7288
|
+
// 当作缺失时 existing='' 且 fileExists=false → 后续 writeFileSync 用默认 flag 'w' 把用户既有
|
|
7289
|
+
// .gitignore **截断**为仅含受管条目(数据破坏);而该调用的自述契约是「失败即中止,可重跑自愈」。
|
|
7290
|
+
// 修复后访问类故障原样抛出 → 安装中止且用户文件逐字节不变(与 lstatIfExists 同语义)。
|
|
7291
|
+
// 故障注入用 `--require` 预加载(同场景 233 手法),只命中该项目的 .gitignore,其余读取走真实实现。
|
|
7292
|
+
{
|
|
7293
|
+
name: '243 .gitignore 读取访问类故障 → 中止安装且用户文件不被改写',
|
|
7294
|
+
run: (dir) => {
|
|
7295
|
+
if (!fs.existsSync(PREPARE_ENV)) return;
|
|
7296
|
+
const proj = path.join(dir, 'proj-gitignore-fault');
|
|
7297
|
+
fs.mkdirSync(proj, { recursive: true });
|
|
7298
|
+
const initial = '# 用户既有内容\nnode_modules/\ndist/\n';
|
|
7299
|
+
fs.writeFileSync(path.join(proj, '.gitignore'), initial, 'utf8');
|
|
7300
|
+
const preloadName = 'gitignore-read-fault-preload.cjs';
|
|
7301
|
+
writeFile(dir, preloadName, [
|
|
7302
|
+
"const fs = require('node:fs');",
|
|
7303
|
+
"const path = require('node:path');",
|
|
7304
|
+
"const target = path.resolve(String(process.env.GITIGNORE_FAULT_TARGET || ''));",
|
|
7305
|
+
'const realReadFileSync = fs.readFileSync;',
|
|
7306
|
+
'fs.readFileSync = function (file, ...rest) {',
|
|
7307
|
+
" if (target !== '' && path.resolve(String(file)) === target) {",
|
|
7308
|
+
" const error = new Error('EACCES: permission denied, open ' + JSON.stringify(String(file)));",
|
|
7309
|
+
" error.code = 'EACCES';",
|
|
7310
|
+
' throw error;',
|
|
7311
|
+
' }',
|
|
7312
|
+
' return realReadFileSync.call(fs, file, ...rest);',
|
|
7313
|
+
'};',
|
|
7314
|
+
'',
|
|
7315
|
+
].join('\n'));
|
|
7316
|
+
const spawned = spawnSync(
|
|
7317
|
+
process.execPath,
|
|
7318
|
+
['--require', path.join(dir, preloadName), PREPARE_ENV, '--target', proj, '--platform', 'claude-code'],
|
|
7319
|
+
{
|
|
7320
|
+
cwd: dir,
|
|
7321
|
+
env: { ...process.env, GITIGNORE_FAULT_TARGET: path.join(proj, '.gitignore') },
|
|
7322
|
+
encoding: 'utf8',
|
|
7323
|
+
timeout: 120000,
|
|
7324
|
+
},
|
|
7325
|
+
);
|
|
7326
|
+
const res = { status: spawned.status ?? 1, output: String(spawned.stdout || '') + String(spawned.stderr || '') };
|
|
7327
|
+
const after = fs.readFileSync(path.join(proj, '.gitignore'), 'utf8');
|
|
7328
|
+
if (after !== initial) {
|
|
7329
|
+
throw new Error('访问类故障下用户 .gitignore 被改写(应原样保留):\n' + JSON.stringify({ initial, after }, null, 2));
|
|
7330
|
+
}
|
|
7331
|
+
if (res.status === 0) throw new Error('读取访问类故障应中止安装(exit 非 0),实际 exit 0\n' + res.output);
|
|
7332
|
+
assertOut(res, 'EACCES');
|
|
7333
|
+
},
|
|
7334
|
+
},
|
|
7239
7335
|
];
|
|
7240
7336
|
|
|
7241
7337
|
// ---------- 运行 ----------
|
|
@@ -20,9 +20,12 @@ import path from 'path';
|
|
|
20
20
|
|
|
21
21
|
export const WORKFLOW_PROTOCOL_MAX_BYTES = 2 * 1024 * 1024;
|
|
22
22
|
|
|
23
|
-
// ----------
|
|
23
|
+
// ---------- 受保护文件读取(单一来源:写入守卫 import 本模块,全包共用同一份实现) ----------
|
|
24
|
+
// 这三个判据曾以逐字节相同的副本存在于 comet-hook-guard.mjs,两侧注释互指「同源」——
|
|
25
|
+
// 注释不是同步机制,副本必然分叉。现由本模块导出、守卫 import:
|
|
26
|
+
// 改一处即全改,消除「修了这份、漏了那份」的缺陷面。
|
|
24
27
|
|
|
25
|
-
function workflowPathInside(root, target) {
|
|
28
|
+
export function workflowPathInside(root, target) {
|
|
26
29
|
const relative = path.relative(root, target);
|
|
27
30
|
return (
|
|
28
31
|
relative === '' ||
|
|
@@ -32,7 +35,7 @@ function workflowPathInside(root, target) {
|
|
|
32
35
|
);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
async function inspectWorkflowProtectedPath(
|
|
38
|
+
export async function inspectWorkflowProtectedPath(
|
|
36
39
|
projectRoot,
|
|
37
40
|
target,
|
|
38
41
|
label,
|
|
@@ -122,7 +125,7 @@ function workflowSameFileStat(left, right) {
|
|
|
122
125
|
);
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
async function readWorkflowProtectedFile(
|
|
128
|
+
export async function readWorkflowProtectedFile(
|
|
126
129
|
projectRoot,
|
|
127
130
|
file,
|
|
128
131
|
label,
|
|
@@ -39,7 +39,7 @@ function buildNodeCompletionFlags(protocol, changeName) {
|
|
|
39
39
|
|| artifact.pathBase === 'classic-superpowers-root'
|
|
40
40
|
|| artifact.pathBase === 'native-root') {
|
|
41
41
|
throw new Error('产物根 pathBase "' + artifact.pathBase
|
|
42
|
-
+ '"
|
|
42
|
+
+ '" 已不受 guard 与状态机支持——请改用 specs-root/project + 完整路径(如 project + openspec/changes/xxx.md)');
|
|
43
43
|
}
|
|
44
44
|
artifacts.push({
|
|
45
45
|
id: schemaId + '.' + (artifact.id ?? 'artifact'),
|
|
@@ -86,7 +86,8 @@ async function pathPatternExists(root, relativePattern) {
|
|
|
86
86
|
// 产物推导 pathBase 感知: 产物根按 artifact.pathBase 解析——'specs-root' → specsRoot;'project'/缺省 → runRoot
|
|
87
87
|
// (与 workflow-guard.mjs 的 workflowPathBaseRoot 对齐:内置协议 10 个 artifacts 全部显式
|
|
88
88
|
// 声明 specs-root;compose 自定义协议可声明 project 根工件如 README.md)。
|
|
89
|
-
// classic/native
|
|
89
|
+
// classic/native 三类不属于二分——标志构建阶段即 fail-fast 拒绝(见上方 artifact 循环),
|
|
90
|
+
// 走不到这里,故此处无需为它们兜底。
|
|
90
91
|
async function nodeFlagsComplete(nodeFlags, nodeId, specsRoot, runRoot) {
|
|
91
92
|
for (const artifact of nodeFlags.get(nodeId) ?? []) {
|
|
92
93
|
let present = false;
|
|
@@ -7,7 +7,7 @@ description: "Use only when explicitly invoked as /flow-comet-evolve; scan archi
|
|
|
7
7
|
|
|
8
8
|
## 触发
|
|
9
9
|
|
|
10
|
-
用户说「同步架构 / 整理沉淀 / evolve / 同步 CONTEXT
|
|
10
|
+
用户说「同步架构 / 整理沉淀 / evolve / 同步 CONTEXT」;若 STATE.md 的 last_evolve_at 已超过 60 天,则**提示用户显式调用 `/flow-comet-evolve`**,不自动加载本 Skill(时间戳是提醒,不是与用户意图并列的触发条件——本命令只按显式调用与用户意图触发)。
|
|
11
11
|
|
|
12
12
|
> **载体说明(沿用 flow-kit 约定)**:`STATE.md` 与 `last_evolve_at` 是 flow-kit 的约定(A-evolve.md 定义:GO.md 按 last_evolve_at 提示、evolve 读/写该字段)——项目需有按 flow-kit 维护的 STATE.md;flow-comet 引擎不自动创建/维护该字段,无 STATE.md 的项目触发本命令时按「无 last_evolve_at 基线」处理(扫描全部未沉淀的归档 change 并人工确认)。
|
|
13
13
|
|
|
@@ -96,7 +96,7 @@ guard 校验见 workflow-guard.mjs NODE_TRANSITION_GATES / W1-B;「填得好
|
|
|
96
96
|
- `[已修]` — fixed via a fix task (linked in the entry)
|
|
97
97
|
- `[升级]` — escalated to the user for a decision (accept + reason recorded)
|
|
98
98
|
- `[转待办]` — deferred to `.specs/<change-id>/KNOWN-ISSUES.md` at archive time
|
|
99
|
-
The exit guard structurally checks these markers on the findings area
|
|
99
|
+
The exit guard structurally checks these markers on the findings area: a missing marker **blocks** the exit for a new change, and is a non-blocking warning for a legacy change (to avoid deadlocking legacy reviews). Add markers to clear it.
|
|
100
100
|
|
|
101
101
|
The full review protocol, templates, and checklists are in:
|
|
102
102
|
- `flow-kit/prompts/6-review.md` (REVIEW phase)
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<p align="center">
|
|
29
29
|
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node.js_%E2%89%A518-339933?style=flat&logo=node.js&logoColor=white" alt="Node.js 18+" /></a>
|
|
30
30
|
<a href="https://github.com/baobaolaodie/flow-comet/actions"><img src="https://img.shields.io/github/actions/workflow/status/baobaolaodie/flow-comet/ci.yml?style=flat" alt="CI" /></a>
|
|
31
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-1.5.0
|
|
31
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-1.5.0-blue.svg" alt="Version" /></a>
|
|
32
32
|
</p>
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -243,7 +243,7 @@ Full guide in [CONTRIBUTING.md](CONTRIBUTING.md) — branch model (`feature →
|
|
|
243
243
|
|
|
244
244
|
1. Branch from `dev`: `git checkout dev && git checkout -b feat/<description>`
|
|
245
245
|
2. Edit skills/scripts under `.flow-comet/skills/` (authoritative source); TDD with RED scenario first
|
|
246
|
-
3. Run regression: `node .flow-comet/skills/flow-comet/scripts/guard-self-test.mjs` → `ALL
|
|
246
|
+
3. Run regression: `node .flow-comet/skills/flow-comet/scripts/guard-self-test.mjs` → `ALL 243 SCENARIOS PASSED`
|
|
247
247
|
4. Open a PR into `dev` (squash — one change-level commit); release PR `dev → main` (merge — dev's change-level commits enter main, and dev stops leading after each release)
|
|
248
248
|
|
|
249
249
|
CI enforces the repository conventions automatically on every PR and push (regression, PR discipline, version consistency, dead links). Local hooks (commit/push message checks) install with `node scripts/install-commit-hook.mjs` — see [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-comet",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "An automated execution engine that turns AI coding discipline into a verifiable state machine for the flow-kit 9-stage workflow, built for Claude Code, Codex, and DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
package/scripts/dsh-bridge.mjs
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// 纯 ESM、零第三方依赖,仅使用 Node.js 内置模块。dsh 官方插件形态:
|
|
29
29
|
// ESM 模块导出 { name, apply },ctx 由 dsh 注入。
|
|
30
30
|
//
|
|
31
|
-
// BRIDGE_VERSION: 1.5.0
|
|
31
|
+
// BRIDGE_VERSION: 1.5.0
|
|
32
32
|
|
|
33
33
|
import { spawn } from 'node:child_process';
|
|
34
34
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
@@ -40,7 +40,7 @@ import path from 'node:path';
|
|
|
40
40
|
// 值语义 = 当前发布版本(随发布同步更新,与技能包 INSTALLED_VERSION 同值——
|
|
41
41
|
// bridge-check 的版本一致性检查据此判定 loader 与项目副本同版)。
|
|
42
42
|
export const name = 'dsh-flow-comet-bridge';
|
|
43
|
-
export const version = '1.5.0
|
|
43
|
+
export const version = '1.5.0';
|
|
44
44
|
|
|
45
45
|
// guard 在项目内的相对路径常量(随 skill 包分发)。
|
|
46
46
|
const HOOK_GUARD_REL = '.dsh/skills/flow-comet/scripts/comet-hook-guard.mjs';
|
package/scripts/prepare-env.mjs
CHANGED
|
@@ -607,20 +607,30 @@ function applyPathReplacements(root, replacements) {
|
|
|
607
607
|
// ---------- 运行时文件位置迁移(旧命名空间 .comet/ → 新命名空间 .flow-comet/) ----------
|
|
608
608
|
|
|
609
609
|
/**
|
|
610
|
-
*
|
|
611
|
-
*
|
|
610
|
+
* 「该路径确实不存在」一类错误的单一判定(迁移探测与 gitignore 纳管共用同一判据——
|
|
611
|
+
* 同一语义只有一处实现,改一处即全改,不会分叉):
|
|
612
612
|
* - ENOENT:路径缺失;
|
|
613
613
|
* - ENOTDIR:路径中某一段不是目录——该路径不可能存在为文件(跨平台等价于「不存在」:
|
|
614
614
|
* 同一形态在 Windows 报 ENOENT、在 POSIX 报 ENOTDIR)。
|
|
615
|
-
* 其余错误(EACCES / EPERM / EIO
|
|
616
|
-
*
|
|
617
|
-
*
|
|
615
|
+
* 其余错误(EACCES / EPERM / EIO 等访问类故障)**不算**「不存在」——把访问故障当成
|
|
616
|
+
* 「文件不存在」会让调用方按空内容继续(迁移静默跳过 / gitignore 被截断覆盖),
|
|
617
|
+
* 都是静默的数据丢失风险,必须原样抛出并中止。
|
|
618
|
+
*/
|
|
619
|
+
function isMissingPathError(err) {
|
|
620
|
+
return Boolean(err) && typeof err === 'object' && (err.code === 'ENOENT' || err.code === 'ENOTDIR');
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* lstat 探测:返回 stat 或 null(**不跟随符号链接**——isSymbolicLink() 判定依赖 lstat)。
|
|
625
|
+
* 只有「该路径确实不存在」一类错误返回 null(判定见 isMissingPathError);其余错误原样抛出——
|
|
626
|
+
* 迁移静默跳过会让安装照常继续并报告「已跳过:旧位置不存在」,用户的旧状态却永远留在旧位置
|
|
627
|
+
* (用户以为已迁移)。
|
|
618
628
|
*/
|
|
619
629
|
function lstatIfExists(target) {
|
|
620
630
|
try {
|
|
621
631
|
return fs.lstatSync(target);
|
|
622
632
|
} catch (err) {
|
|
623
|
-
if (
|
|
633
|
+
if (isMissingPathError(err)) {
|
|
624
634
|
return null;
|
|
625
635
|
}
|
|
626
636
|
throw err;
|
|
@@ -807,8 +817,13 @@ function manageGitignore(target) {
|
|
|
807
817
|
try {
|
|
808
818
|
existing = fs.readFileSync(gitignorePath, 'utf8');
|
|
809
819
|
fileExists = true;
|
|
810
|
-
} catch {
|
|
811
|
-
|
|
820
|
+
} catch (err) {
|
|
821
|
+
// 只有「确实不存在」才是首次纳管;访问类故障(EACCES/EPERM/EIO…)必须原样抛出中止——
|
|
822
|
+
// 按空内容继续会让下面的写回把用户既有 .gitignore **截断**为仅含受管条目
|
|
823
|
+
// (判定语义见 isMissingPathError;调用点契约即「失败即中止,可重跑自愈」)。
|
|
824
|
+
if (!isMissingPathError(err)) {
|
|
825
|
+
throw err;
|
|
826
|
+
}
|
|
812
827
|
}
|
|
813
828
|
if (existing.split(/\r?\n/).some(isRuntimeDirIgnoreLine)) {
|
|
814
829
|
console.log(`[prepare-env] .gitignore 已含 ${RUNTIME_DIR}/ 条目——保持原样(幂等)`);
|