flow-comet 1.6.5 → 1.7.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/SKILL.md +17 -5
- package/.flow-comet/skills/flow-comet/reference/commit-discipline.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/entry-detail.md +23 -4
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +26 -23
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +14 -94
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +97 -3
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +38 -2
- package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +52 -10
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +16 -3
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +2 -0
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +4 -0
- package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +20 -11
- package/.flow-comet/skills/flow-comet/scripts/lib/ac-coverage.mjs +317 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-artifact-skeleton.mjs +47 -5
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +297 -131
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +616 -151
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +96 -45
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-state-io.mjs +8 -6
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +204 -51
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +7 -9
- package/.flow-comet/skills/flow-comet/scripts/lib/lessons-hits.mjs +160 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/run-root.mjs +21 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/section-body.mjs +92 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +38 -20
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +439 -134
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +66 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +92 -13
- package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +55 -2
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +94 -39
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +6 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/task-graph.mjs +84 -31
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +57 -7
- package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +60 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +158 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/wave-projection.mjs +341 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +92 -17
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +1439 -11
- package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +1202 -8
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +1204 -76
- package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +753 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +32 -1
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +582 -3
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +5 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +5 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +16 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +2 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +5 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +2041 -66
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +135 -0
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +143 -16
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +312 -63
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +5 -2
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +30 -6
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +10 -3
- package/.flow-comet/skills/flow-comet-review/SKILL.md +20 -11
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +33 -8
- package/.flow-comet/skills/flow-comet-task/SKILL.md +2 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
|
@@ -12,6 +12,9 @@ import { taskOpeningAttrs } from '../task-parsing.mjs';
|
|
|
12
12
|
import { resolveNextNode, normalizeHeading, FIX_SECTION_TITLE_FALLBACK } from '../route-node.mjs';
|
|
13
13
|
import { runRoot, fileExists, workflowRelativeSegments } from './guard-state-io.mjs';
|
|
14
14
|
import { SUMMARY_REQUIRED_SECTIONS, buildSkeleton } from './guard-artifact-skeleton.mjs';
|
|
15
|
+
// 归档目录名「是不是本 change 的」判据单源在状态族的路径上下文模块(guard → state-* 是允许的
|
|
16
|
+
// 单向边):本模块只消费,不在这里另写一份后缀/日期匹配。
|
|
17
|
+
import { isArchivedChangeDirName } from './state-io.mjs';
|
|
15
18
|
|
|
16
19
|
// 新旧 change 区分——init 写入的 newChange: true = 新 change(严格,不依赖 entry——防系统性
|
|
17
20
|
// 跳 entry 绕过);缺失/非 true(旧 change)= 渐进 WARN 兼容。
|
|
@@ -247,57 +250,86 @@ export async function workflowArtifactRoot(pathBase) {
|
|
|
247
250
|
throw new Error('产物根 pathBase "' + pathBase + '" 不再支持——请改用 specs-root/project + 完整路径(如 project + openspec/changes/xxx.md)');
|
|
248
251
|
}
|
|
249
252
|
|
|
250
|
-
|
|
253
|
+
// 声明工件的存在性判据——**唯一的枚举处**:本节点 outputSchemas 引用的 schema → artifacts 中
|
|
254
|
+
// required 的那些,逐条解析路径并判定在场。出口的产物门禁(missingRequiredArtifacts)与结构预检
|
|
255
|
+
// (guard-gates 的缺件报告)都只消费本函数;任何一处再自行遍历 outputSchemas 就是第二份实现,
|
|
256
|
+
// 判据演进时必然分叉(重构前就已分叉:预检只判 file 类、未声明 paths 直接跳过,出口侧两项都不是)。
|
|
257
|
+
//
|
|
258
|
+
// 返回结构数组(每条 = 一份声明的必需产物):
|
|
259
|
+
// { schemaId, artifact, resolvedPaths, present, kind, unspecifiedPaths }
|
|
260
|
+
// resolvedPaths —— 已替换 <change-id> 的声明路径;同一 artifact 的 paths 是互斥备选(任一路径
|
|
261
|
+
// 在场即在场,与节点完成判定同语义);
|
|
262
|
+
// present —— 在场判定结果(pathPatternExists 任一命中);
|
|
263
|
+
// kind —— 声明的产物类别(未声明为 undefined);
|
|
264
|
+
// unspecifiedPaths —— 声明不完整(required 但未声明 paths):没有路径可查,present 恒为 false。
|
|
265
|
+
//
|
|
266
|
+
// 两侧的差异不抹平、也不在这里偷偷归一,而是留给**调用点显式**决定(调用点各写一行并注明理由):
|
|
267
|
+
// ① kind:预检只判 kind 为 file(未声明按文件处置)的产物——其它 kind 的「在场」语义不是文件
|
|
268
|
+
// 存在性;出口不判 kind(目录类产物同样按路径存在性校验)。
|
|
269
|
+
// ② 未声明 paths:报成**声明不完整**而不是「缺件」的普通一例——没有路径就没有可判的存在性,也没有
|
|
270
|
+
// 可创建的落点,报文必须指向协议本身要修,而不是让人去做一件做不到的事。两侧都阻断、且渲染
|
|
271
|
+
// **同一句**(unspecifiedPathsNotice);区别只在编排:出口把它列进缺件清单,预检给它单列一段
|
|
272
|
+
// (不给「按上述路径创建」的指令)。
|
|
273
|
+
// ③ 归档产出(.specs/archive/ 下):只在预检侧延后报告,出口照常校验——那是归档做完后的判据。
|
|
274
|
+
// 本函数只做 ①②③ 都不涉及的那部分:枚举 + <change-id> 替换 + 在场判定。
|
|
275
|
+
|
|
276
|
+
// 「声明不完整」的同一句报文:两侧消费方都渲染这一句,措辞只此一处(不各写一份)。
|
|
277
|
+
export function unspecifiedPathsNotice(schemaId, artifactId) {
|
|
278
|
+
return '协议声明不完整:' + schemaId + '.' + artifactId
|
|
279
|
+
+ ' 标记为 required 但未声明 paths —— 修协议(给它加一条路径),或在模板里改 required=false';
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export async function declaredRequiredArtifacts(protocol, node, change) {
|
|
251
283
|
const schemas = schemaMap(protocol);
|
|
252
|
-
const
|
|
284
|
+
const declared = [];
|
|
253
285
|
for (const schemaId of node.outputSchemas ?? []) {
|
|
254
286
|
const schema = schemas.get(schemaId);
|
|
255
287
|
for (const artifact of schema?.artifacts ?? []) {
|
|
256
288
|
if (!artifact.required) continue;
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
289
|
+
const declaredPaths = artifact.paths ?? [];
|
|
290
|
+
const unspecifiedPaths = declaredPaths.length === 0;
|
|
291
|
+
// <change-id> 替换:无活跃 change 时保留占位符原文(出口侧既有语义;预检侧在无 change 时更早
|
|
292
|
+
// 已退出,两侧因此共用这一条替换口径,不再各自写一份 replaceAll)。
|
|
293
|
+
const resolvedPaths = declaredPaths.map((declaredPath) => (change
|
|
294
|
+
? String(declaredPath).replaceAll('<change-id>', change)
|
|
295
|
+
: String(declaredPath)));
|
|
296
|
+
// 未声明路径时不解析产物根:没有路径就没有可查的存在性,「pathBase 非法」也不该由一件无路径的
|
|
297
|
+
// 产物引爆。present 保持 false——声明不完整不是「在场」,两侧据此阻断(差异②)。
|
|
298
|
+
let present = false;
|
|
299
|
+
if (!unspecifiedPaths) {
|
|
300
|
+
const artifactRoot = await workflowArtifactRoot(artifact.pathBase);
|
|
301
|
+
present = (await Promise.all(
|
|
302
|
+
resolvedPaths.map((declaredPath) => pathPatternExists(artifactRoot, declaredPath)),
|
|
303
|
+
)).some(Boolean);
|
|
304
|
+
}
|
|
305
|
+
declared.push({ schemaId, artifact, resolvedPaths, present, kind: artifact.kind, unspecifiedPaths });
|
|
267
306
|
}
|
|
268
307
|
}
|
|
269
|
-
return
|
|
308
|
+
return declared;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 出口侧的必需产物缺件清单(产物门禁与漂移容错的容错判据共用):取 declaredRequiredArtifacts 里
|
|
312
|
+
// 不在场者。本侧**不做**预检的 kind 过滤(①,见上式注释)——出口是完成判据:声明了却不在场就是
|
|
313
|
+
// 缺件,无论 kind 是不是 file。声明不完整者(②)同样进这份清单、同样阻断,但报的是可执行的那一句
|
|
314
|
+
// (指向协议),而不是一个空路径——与预检侧同一句、同一处措辞。
|
|
315
|
+
export async function missingRequiredArtifacts(protocol, node, change) {
|
|
316
|
+
return (await declaredRequiredArtifacts(protocol, node, change))
|
|
317
|
+
.filter((declared) => !declared.present)
|
|
318
|
+
.map((declared) => (declared.unspecifiedPaths
|
|
319
|
+
? unspecifiedPathsNotice(declared.schemaId, declared.artifact.id)
|
|
320
|
+
: declared.schemaId + '.' + declared.artifact.id));
|
|
270
321
|
}
|
|
271
322
|
|
|
272
|
-
// 历史归档 change 不强制真实跑验证命令(判断 .specs/archive/
|
|
323
|
+
// 历史归档 change 不强制真实跑验证命令(判断 .specs/archive/ 目录)。归档目录名按
|
|
324
|
+
// <日期>-<change-id> 精确形态比对(判据单源在 state-io):后缀匹配会把「名字恰好以本 change id
|
|
325
|
+
// 结尾」的别的 change 认作本 change 已归档,守卫于是**跳过真实跑验证命令的要求**——这是放行口,
|
|
326
|
+
// 不是显示问题。无日期前缀、名字逐字等于 change-id 的旧布局仍认(两处精确比对,都不做后缀)。
|
|
273
327
|
export async function isArchivedChange(changeName) {
|
|
274
328
|
if (!changeName) return false;
|
|
275
329
|
const archiveRoot = path.join(runRoot, '.specs', 'archive');
|
|
276
330
|
if (await fileExists(path.join(archiveRoot, changeName))) return true;
|
|
277
331
|
const entries = await fs.readdir(archiveRoot).catch(() => []);
|
|
278
|
-
return entries.some(
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// 声明标记目录解析——活动路径 .specs/<change-id>/.skill-loads/ 优先;归档路径兜底(archive 节点
|
|
282
|
-
// 「先移目录后 record/exit」顺序下 change 目录已在 .specs/archive/<前缀>-<change-id>/,标记只随
|
|
283
|
-
// 目录移动——只查活动路径会把「标记存在」误判成「机制未激活」)。归档扫描匹配后缀 -<change-id>
|
|
284
|
-
// (前缀可含日期等,与协议 flowkit.archive.v1 的 archive/*-<change-id> 同构)。两者皆无 → null
|
|
285
|
-
// (声明机制从未激活,调用方按旧 change 兼容跳过)。
|
|
286
|
-
export async function findSkillLoadsDir(root, changeName) {
|
|
287
|
-
const activeDir = path.join(root, '.specs', changeName, '.skill-loads');
|
|
288
|
-
if (await fileExists(activeDir)) {
|
|
289
|
-
return { dir: activeDir, display: '.specs/' + changeName + '/.skill-loads/' };
|
|
290
|
-
}
|
|
291
|
-
const archiveRoot = path.join(root, '.specs', 'archive');
|
|
292
|
-
const entries = await fs.readdir(archiveRoot).catch(() => []);
|
|
293
|
-
for (const entry of entries) {
|
|
294
|
-
if (!entry.endsWith('-' + changeName)) continue;
|
|
295
|
-
const candidate = path.join(archiveRoot, entry, '.skill-loads');
|
|
296
|
-
if (await fileExists(candidate)) {
|
|
297
|
-
return { dir: candidate, display: '.specs/archive/' + entry + '/.skill-loads/' };
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
332
|
+
return entries.some((entry) => entry === changeName || isArchivedChangeDirName(entry, changeName));
|
|
301
333
|
}
|
|
302
334
|
|
|
303
335
|
// 段名校验基准从模板自动派生——骨架计算统一委托 lib/guard-artifact-skeleton.mjs(单一实现:读
|
|
@@ -312,6 +344,32 @@ export { TEMPLATE_FALLBACK_SECTION_PATTERNS } from './guard-artifact-skeleton.mj
|
|
|
312
344
|
// 模板段名 → 宽松匹配正则:实现随段名归一移到骨架模块(单一出处),此处转出保持既有导出面。
|
|
313
345
|
export { headingPattern as templateSectionPattern } from './guard-artifact-skeleton.mjs';
|
|
314
346
|
|
|
347
|
+
// 命名段选取(唯一实现):候选集为空(模板整份缺席 / 该类段无从派生)⇒ TEMPLATE_SECTION_SKIP;
|
|
348
|
+
// 否则按关键词取首个命中的**模板段名**所派生的正则,关键词全不命中 ⇒ 调用方给的 fallback。
|
|
349
|
+
// H2 顶层段(pick)与登记表列举的结构子段(pickTemplateSection 的 level 3)共用这一条规则——
|
|
350
|
+
// 候选集来源不同,选段语义必须由同一个函数给出:同一份工件的同一段在两处被选出不同判据,就是
|
|
351
|
+
// 第二份实现(两个入口在同一候选集上给出同一判据,由套件场景逐态对账)。
|
|
352
|
+
function pickByKeywords(entries, keywords, fallback) {
|
|
353
|
+
if (entries.length === 0) return TEMPLATE_SECTION_SKIP;
|
|
354
|
+
for (const entry of entries) {
|
|
355
|
+
if (keywords.some((keyword) => entry.name.includes(keyword))) return entry.regex;
|
|
356
|
+
}
|
|
357
|
+
return fallback;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// 任意模板键 + 层级的选段入口:pick 只覆盖 change / requirement / design / summary 四个 H2 键,
|
|
361
|
+
// 而判据落在别的模板(TEST 的「第 1 轮」段与 1.1 测试矩阵一类)上时同样需要一个「段名从模板派生、
|
|
362
|
+
// 模板缺席即跳过、关键词不命中即回退」的口子——否则消费方只能自己遍历段名表,那是第二份选段实现。
|
|
363
|
+
// level 2 = 模板 H2 顶层段(骨架 sections) level 3 = 登记表列举的结构子段(structureSubsections)
|
|
364
|
+
// 返回正则或 TEMPLATE_SECTION_SKIP(调用方据此打印「未校验」而不是猜测段名)。opts.runRoot 与骨架
|
|
365
|
+
// 同一出入口(场景 / 临时夹具可指向别的项目根)。
|
|
366
|
+
export async function pickTemplateSection(key, { keywords = [], fallback, level = 2, runRoot } = {}) {
|
|
367
|
+
const skeleton = await buildSkeleton(key, runRoot === undefined ? {} : { runRoot });
|
|
368
|
+
const entries = (level === 3 ? skeleton.structureSubsections ?? [] : skeleton.sections)
|
|
369
|
+
.map((entry) => ({ name: entry.name, regex: entry.pattern }));
|
|
370
|
+
return pickByKeywords(entries, keywords, fallback);
|
|
371
|
+
}
|
|
372
|
+
|
|
315
373
|
// 读取模板全部段名生成模式列表:键形(change / requirement / design / summary)与 tpl[key] 的
|
|
316
374
|
// { name, regex } 数组形态、pick 的按关键词选段语义一律保持既有——只把数据源换成骨架模块(缓存与
|
|
317
375
|
// 模板读取归它一处负责,本模块不再自持 runRoot 键控的第二份缓存)。opts.runRoot 与骨架同一出入口
|
|
@@ -326,14 +384,7 @@ export async function templateSectionPatterns(opts = {}) {
|
|
|
326
384
|
// 模板派生判据全部跳过,fallback 只在「模板在场但某个具体段名缺失」时生效)。既有消费方里有闭包
|
|
327
385
|
// 外直接 `.test` 的调用点(「视觉调性」段读取),返回 null 会把「跳过」退化成 TypeError 崩溃——
|
|
328
386
|
// 未校验变成失败,同样不是 C9 的「跳过」,故返回可判别的跳过判据(见 TEMPLATE_SECTION_SKIP)。
|
|
329
|
-
result.pick = (key, keywords, fallback) =>
|
|
330
|
-
const sections = result[key] ?? [];
|
|
331
|
-
if (sections.length === 0) return TEMPLATE_SECTION_SKIP;
|
|
332
|
-
for (const section of sections) {
|
|
333
|
-
if (keywords.some((keyword) => section.name.includes(keyword))) return section.regex;
|
|
334
|
-
}
|
|
335
|
-
return fallback;
|
|
336
|
-
};
|
|
387
|
+
result.pick = (key, keywords, fallback) => pickByKeywords(result[key] ?? [], keywords, fallback);
|
|
337
388
|
return result;
|
|
338
389
|
}
|
|
339
390
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 受保护状态 I/O(守卫模块)+ 守卫侧运行上下文。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// 运行根(runRoot)的解析由 lib/run-root.mjs 单源提供:状态命令族与守卫族共用同一份事实,本模块
|
|
4
|
+
// 只取用并再导出(守卫入口的导入面因此不变)。packageRoot 与协议路径绑定仍在这里——各守卫模块
|
|
5
|
+
// 不再各自从环境变量推导同一事实,两份推导会在形态变化时静默分叉。
|
|
5
6
|
//
|
|
6
7
|
// 受保护读写通道(路径段判据 → 逐段目录校验 → 快照复核 → 唯一临时名原子落盘)在写入前与落盘前
|
|
7
8
|
// 都复核目标未被替换;任何一步不符即抛错(fail-closed),绝不退化为尽力而为的写。
|
|
@@ -12,6 +13,7 @@ import { constants as fsConstants, promises as fs } from 'fs';
|
|
|
12
13
|
import path from 'path';
|
|
13
14
|
import { fileURLToPath } from 'url';
|
|
14
15
|
import { RUNTIME_STATE_PATH, LEGACY_RUNTIME_STATE_PATH } from '../state-schema.mjs';
|
|
16
|
+
import { resolveRunRoot } from './run-root.mjs';
|
|
15
17
|
import {
|
|
16
18
|
inspectWorkflowProtectedPath,
|
|
17
19
|
readWorkflowProtectedFile,
|
|
@@ -24,9 +26,9 @@ import {
|
|
|
24
26
|
const scriptsRoot = path.dirname(fileURLToPath(import.meta.url));
|
|
25
27
|
// 技能包根:scripts/lib → scripts → skills/flow-comet(协议默认路径与包内资源以此为基准)
|
|
26
28
|
export const packageRoot = path.resolve(scriptsRoot, '..', '..');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
// 运行根:唯一解析在 lib/run-root.mjs(与状态命令族同一份事实)——本模块只取用并再导出。
|
|
30
|
+
// 行内再写一次 env/cwd 推导,就是本次要消灭的那份分叉(守卫认变量、状态命令认 cwd)。
|
|
31
|
+
export const runRoot = resolveRunRoot();
|
|
30
32
|
|
|
31
33
|
// 协议路径解析:显式 --protocol 全局参数(command=argv[2] 之后的剩余参数)> state.protocolPath
|
|
32
34
|
// (init 持久化绑定)> FLOW_COMET_PROTOCOL 环境变量 > 内置默认。选择在入口 main() 内执行
|
|
@@ -17,15 +17,19 @@ import { promises as fs } from 'fs';
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import { EXECUTE_FAMILY_NODE_IDS, normalizeHeading } from '../route-node.mjs';
|
|
19
19
|
import { taskOpeningAttrs, taskBlocks as extractTaskBlocks } from '../task-parsing.mjs';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
nodeTemplateDeclaration,
|
|
22
|
+
readProtocolFile,
|
|
23
|
+
templateKeyFromArtifactName,
|
|
24
|
+
templateKeyOf,
|
|
25
|
+
} from '../protocol-utils.mjs';
|
|
21
26
|
import { runRoot, fileExists, protocolPath } from './guard-state-io.mjs';
|
|
22
27
|
import { isNewChange } from './guard-routing.mjs';
|
|
23
28
|
import { buildSkeleton, LEGACY_SUMMARY_ORDER } from './guard-artifact-skeleton.mjs';
|
|
29
|
+
import { scanHeadings } from './section-body.mjs';
|
|
24
30
|
import { TASK7_REQUIRED } from './task-graph.mjs';
|
|
25
31
|
|
|
26
32
|
const HINT_FILE_NAME = '.template-hints.json';
|
|
27
|
-
const H2_LINE = /^##\s+(.+?)\s*$/u;
|
|
28
|
-
const H3_LINE = /^###\s+(.+?)\s*$/u;
|
|
29
33
|
const FRONTMATTER_KEY_LINE = /^([A-Za-z][\w-]*)\s*:\s*(.*)$/u;
|
|
30
34
|
|
|
31
35
|
// 空正文白名单(AC-5):判据是**整段取值**而非子串——词后必须是行尾 / 空白 / 标点 / 括注,
|
|
@@ -33,6 +37,43 @@ const FRONTMATTER_KEY_LINE = /^([A-Za-z][\w-]*)\s*:\s*(.*)$/u;
|
|
|
33
37
|
const NOT_APPLICABLE_BODY =
|
|
34
38
|
/^(?:无变更|不适用|未涉及|N\/A|无|—)(?=$|[\s,。;、,;.::!!??…—()()【】「」『』“”"'])/iu;
|
|
35
39
|
|
|
40
|
+
// 包裹符号(AC-8):粗体 / 下划线 / 引用 / 列表 / 有序列表 / 括号 / 反引号只是同一个词的写法,
|
|
41
|
+
// 不改变「整段只有一个白名单词」这一事实。剥离只用于本判据,**剥离后仍须以白名单词开头**
|
|
42
|
+
// (AC-9:「**见 N/A**」「(说明:N/A)」剥掉包装后开头是实词,仍是已填);只剥包装、不扩词表。
|
|
43
|
+
// 同族的另一种合法写法是「词 + 闭合标记 + 为什么」(`**N/A**(理由)`):说明紧跟闭合标记时
|
|
44
|
+
// 剥离只剥得掉尾部裸标记,词后不再紧邻边界——由 isNotApplicableBody 的第二条判据接住。
|
|
45
|
+
const NOT_APPLICABLE_WRAPPER_LEAD = /^(?:\*\*|__|>|[-*+]|\d+[.)、.]|[((]|`)\s*/u;
|
|
46
|
+
const NOT_APPLICABLE_WRAPPER_TAIL = /\s*(?:\*\*|__|`)$/u;
|
|
47
|
+
|
|
48
|
+
// 「N/A 意图痕迹」只喂补充提示,不参与缺子段判定:父段正文去掉子段标题行后,第一条非空内容行的
|
|
49
|
+
// **开头若干字符**内出现白名单词,才算当事人真想写「整段不适用」。「(说明:N/A)」「见 N/A」这类
|
|
50
|
+
// 带前置说明词 / 包裹的形态落在这个窗口里;普通正文(无白名单词)不落入——把提示挂在与 N/A 无关的
|
|
51
|
+
// 工件上,只会让当事人去改一个它本来没打算写的段落。
|
|
52
|
+
const NOT_APPLICABLE_INTENT = /(?:N\/A|不适用|无变更)/iu;
|
|
53
|
+
const NOT_APPLICABLE_INTENT_WINDOW = 24;
|
|
54
|
+
|
|
55
|
+
function bareNotApplicableBody(text) {
|
|
56
|
+
let stripped = text;
|
|
57
|
+
for (;;) {
|
|
58
|
+
const next = stripped.replace(NOT_APPLICABLE_WRAPPER_LEAD, '').replace(NOT_APPLICABLE_WRAPPER_TAIL, '');
|
|
59
|
+
if (next === stripped) return stripped;
|
|
60
|
+
stripped = next;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 整段「不适用」判定(唯一消费点):裸文本以白名单词开头即成立;另接受**闭合标记之后紧跟说明**的
|
|
65
|
+
// 形态——`**N/A**(本轮无变更)` 剥完是 `N/A**(本轮无变更)`,词后紧跟的是闭合标记而不是边界。
|
|
66
|
+
// 说明文字是「为什么不适用」,不改变「整段不适用」这一事实(旧实现据此判已填,于是同一份工件
|
|
67
|
+
// 既被判「写了 N/A」又被要求补子段)。前提仍是白名单词开头:`**见 N/A**` 剥完是 `见 N/A`,
|
|
68
|
+
// 开头是实词 ⇒ 仍是已填(否定式 / 指向式的句子不得吞成整段豁免)。
|
|
69
|
+
const NOT_APPLICABLE_CLOSE_THEN_NOTE = /\s*(?:\*\*|__|`)[\s\S]*$/u;
|
|
70
|
+
function isNotApplicableBody(text) {
|
|
71
|
+
const bare = bareNotApplicableBody(text);
|
|
72
|
+
if (NOT_APPLICABLE_BODY.test(bare)) return true;
|
|
73
|
+
const closed = bare.replace(NOT_APPLICABLE_CLOSE_THEN_NOTE, '');
|
|
74
|
+
return closed !== bare && NOT_APPLICABLE_BODY.test(closed);
|
|
75
|
+
}
|
|
76
|
+
|
|
36
77
|
function literalRegExp(text) {
|
|
37
78
|
return String(text ?? '').replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
38
79
|
}
|
|
@@ -48,8 +89,12 @@ function qualifiedHeading(raw) {
|
|
|
48
89
|
// 工件文本 → 行锚定轮廓(L-128:只认行首标题,正文里引用段名不劫持)。frontmatter 仅做顶层键
|
|
49
90
|
// 行级解析(不引入 YAML 库):一个键的值区 = 行内余下文本 + 到下一个顶层键之前的非空行
|
|
50
91
|
// (嵌套映射是缩进行,而「值另起一行且不缩进」也同样是已填——两种书写形态都不判空)。
|
|
92
|
+
// 段结构(哪些标题行真的开一段、段到哪里结束、哪些 H3 属于本段)一律取 lib/section-body.mjs 的
|
|
93
|
+
// 围栏感知扫描(scanHeadings):围栏代码块里的 `## ` / `### ` 是正文示例,不开段、也不算子段。
|
|
94
|
+
// 旧实现自带一份按行扫 `^##` 的循环(围栏盲),段序 / 缺段 / 空正文 / 增量段位置四个判据因此共用
|
|
95
|
+
// 同一处盲区:示例里贴一行段标题,那段就被读成「在场」——删段换到放行的写法。
|
|
51
96
|
function parseOutline(text) {
|
|
52
|
-
const lines =
|
|
97
|
+
const { lines, headings } = scanHeadings(text);
|
|
53
98
|
const outline = { frontmatter: { present: false, keys: [] }, titleLine: '', headerLines: [], sections: [] };
|
|
54
99
|
let cursor = 0;
|
|
55
100
|
if (lines[0] !== undefined && lines[0].trim() === '---') {
|
|
@@ -71,38 +116,43 @@ function parseOutline(text) {
|
|
|
71
116
|
cursor = end + 1;
|
|
72
117
|
}
|
|
73
118
|
}
|
|
119
|
+
const sectionHeadings = headings.filter((heading) => heading.level === 2);
|
|
120
|
+
const subsectionHeadings = headings.filter((heading) => heading.level === 3);
|
|
74
121
|
while (cursor < lines.length && lines[cursor].trim() === '') cursor += 1;
|
|
75
122
|
outline.titleLine = lines[cursor] ?? '';
|
|
76
123
|
cursor += 1;
|
|
77
|
-
|
|
124
|
+
const firstSection = sectionHeadings.length > 0 ? sectionHeadings[0].index : lines.length;
|
|
125
|
+
while (cursor < lines.length && cursor < firstSection) {
|
|
78
126
|
outline.headerLines.push(lines[cursor]);
|
|
79
127
|
cursor += 1;
|
|
80
128
|
}
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
norm: normalizeHeading(sub[1]),
|
|
102
|
-
qualified: qualifiedHeading(sub[1]),
|
|
129
|
+
for (let index = 0; index < sectionHeadings.length; index += 1) {
|
|
130
|
+
const heading = sectionHeadings[index];
|
|
131
|
+
const end = index + 1 < sectionHeadings.length ? sectionHeadings[index + 1].index : lines.length;
|
|
132
|
+
const section = {
|
|
133
|
+
raw: heading.text.trim(),
|
|
134
|
+
norm: normalizeHeading(heading.text),
|
|
135
|
+
qualified: qualifiedHeading(heading.text),
|
|
136
|
+
bodyLines: lines.slice(heading.index + 1, end),
|
|
137
|
+
// 直系正文(不含子段标题行)由同一次扫描给出:子段标题行的行下标在扫描里就是已知的,
|
|
138
|
+
// 不必回头对 bodyLines 再做一次文本匹配(那会重新掉进围栏盲区)。
|
|
139
|
+
directLines: [],
|
|
140
|
+
subsections: [],
|
|
141
|
+
};
|
|
142
|
+
const subsectionIndexes = new Set();
|
|
143
|
+
for (const sub of subsectionHeadings) {
|
|
144
|
+
if (sub.index <= heading.index || sub.index >= end) continue;
|
|
145
|
+
section.subsections.push({
|
|
146
|
+
raw: sub.text.trim(),
|
|
147
|
+
norm: normalizeHeading(sub.text),
|
|
148
|
+
qualified: qualifiedHeading(sub.text),
|
|
103
149
|
});
|
|
150
|
+
subsectionIndexes.add(sub.index);
|
|
151
|
+
}
|
|
152
|
+
for (let at = heading.index + 1; at < end; at += 1) {
|
|
153
|
+
if (!subsectionIndexes.has(at)) section.directLines.push(lines[at]);
|
|
104
154
|
}
|
|
105
|
-
|
|
155
|
+
outline.sections.push(section);
|
|
106
156
|
}
|
|
107
157
|
return outline;
|
|
108
158
|
}
|
|
@@ -117,6 +167,34 @@ function bodyText(lines) {
|
|
|
117
167
|
return trimmed.slice(start, end).join('\n');
|
|
118
168
|
}
|
|
119
169
|
|
|
170
|
+
// 父段的**直系正文**:parseOutline 在扫描时就把子段标题行记了下标(bodyLines 仍含它们,子段归属与
|
|
171
|
+
// 逐字比对要靠那份行序),directLines 是同一份 bodyLines 减去**围栏外**的子段标题行——不剥掉的话
|
|
172
|
+
// 「父段只要写了任一子段」就等同于「父段有正文」,补充提示随即对从未想写 N/A 的工件发声。
|
|
173
|
+
// 只剥标题行,子段的正文内容原样保留(它仍是父段正文的一部分)。
|
|
174
|
+
function directBodyLines(section) {
|
|
175
|
+
return section?.directLines ?? [];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 父段正文是否留下 N/A 意图痕迹:第一条非空内容行的开头若干字符里找白名单词——包裹符号
|
|
179
|
+
// (**N/A** / > N/A / (N/A))与前置说明词((说明:N/A)、见 N/A)都落在这个窗口内。
|
|
180
|
+
function hasNotApplicableIntent(lines) {
|
|
181
|
+
const first = (lines ?? []).map((line) => String(line)).find((line) => line.trim() !== '');
|
|
182
|
+
if (first === undefined) return false;
|
|
183
|
+
return NOT_APPLICABLE_INTENT.test(first.trim().slice(0, NOT_APPLICABLE_INTENT_WINDOW));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 父段名:报文里必须是**真实段名**。骨架里的段名(模板标题,同一份工件不管怎么改写都显示同一个
|
|
187
|
+
// 名字)优先;骨架未派生该段时退到文档段自己的标题行(parseOutline 的 raw 已剥离开栏井号,这里再
|
|
188
|
+
// 去编号)。两条都取不到才用兜底常量——「父段「」」既没有定位价值,也掩盖了「父段没被识别」。
|
|
189
|
+
const PARENT_NAME_FALLBACK = '(该父段名未派生)';
|
|
190
|
+
|
|
191
|
+
function parentSectionName(skeleton, parentNorm, docSection) {
|
|
192
|
+
const fromSkeleton = String(skeleton.sections.find((section) => section.norm === parentNorm)?.name ?? '').trim();
|
|
193
|
+
if (fromSkeleton !== '') return fromSkeleton;
|
|
194
|
+
const fromHeading = String(docSection?.raw ?? '').replace(/^\d+(?:\.\d+)*\.?\s*/u, '').trim();
|
|
195
|
+
return fromHeading === '' ? PARENT_NAME_FALLBACK : fromHeading;
|
|
196
|
+
}
|
|
197
|
+
|
|
120
198
|
// 模板轮廓缓存(键 = 模板绝对路径):逐字比对要模板该段正文,路径来自骨架(不在此推导模板位置)。
|
|
121
199
|
const templateOutlineCache = new Map();
|
|
122
200
|
|
|
@@ -145,6 +223,7 @@ function emptyIssues() {
|
|
|
145
223
|
empty: [],
|
|
146
224
|
verbatim: [],
|
|
147
225
|
structure: [],
|
|
226
|
+
structureAdvice: [],
|
|
148
227
|
increments: [],
|
|
149
228
|
};
|
|
150
229
|
}
|
|
@@ -186,6 +265,34 @@ function templateBodyIsFinishedForm(body) {
|
|
|
186
265
|
return templateBodyHasFillInSlot(body) || tableHasExampleRow(body);
|
|
187
266
|
}
|
|
188
267
|
|
|
268
|
+
// 结构子段的键:unique=false 的(如 Button (Primary)/(Secondary))按带括号的精确名,其余按
|
|
269
|
+
// 归一名——「在场判定」与「实际挂在哪的诊断」共用这一份键,避免同一口径写两处。
|
|
270
|
+
function structureSubsectionMatches(docSub, sub) {
|
|
271
|
+
return sub.unique === false
|
|
272
|
+
? docSub.qualified === qualifiedHeading(sub.name)
|
|
273
|
+
: docSub.norm === sub.norm;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 缺结构子段时的定位诊断:同名 H3 若实际写在别的骨架父段下、或落在模板骨架之外(文末的模板外
|
|
277
|
+
// 段落),报错点名它真正的位置。这里只读地找「同名 H3 出现在哪」——归属判定仍是
|
|
278
|
+
// 上面的 subsectionsByParent 一份,本函数不改归属、也不参与豁免。
|
|
279
|
+
function locateStructureSubsection(occurrences, lastSkeletonIndex, sub) {
|
|
280
|
+
for (const occurrence of occurrences) {
|
|
281
|
+
if (!structureSubsectionMatches(occurrence, sub)) continue;
|
|
282
|
+
if (occurrence.index > lastSkeletonIndex) return { kind: 'tail' };
|
|
283
|
+
if (occurrence.registered) {
|
|
284
|
+
// 挂在本父段下的同名 H3 已在候选集里(found 为真)——走到这里只可能是重复骨架段,
|
|
285
|
+
// 不给指向自己的误导性定位。
|
|
286
|
+
return occurrence.section.norm === sub.parentNorm
|
|
287
|
+
? null
|
|
288
|
+
: { kind: 'parent', heading: occurrence.section.raw };
|
|
289
|
+
}
|
|
290
|
+
// 模板外 H2 下的 H3:按「其上最近的骨架 H2」归因(与归属算法同口径)。
|
|
291
|
+
return { kind: 'parent', heading: occurrence.enclosing.raw };
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
|
|
189
296
|
function collectSectionIssues({ text, skeleton, template, issues }) {
|
|
190
297
|
const outline = parseOutline(text);
|
|
191
298
|
const indexByNorm = new Map();
|
|
@@ -221,15 +328,33 @@ function collectSectionIssues({ text, skeleton, template, issues }) {
|
|
|
221
328
|
if (sub.parentNorm !== null) parentNorms.add(sub.parentNorm);
|
|
222
329
|
}
|
|
223
330
|
// 结构子段归属到「其上最近的骨架 H2」:模板外多余段(如工具输出贴入的 `## Findings`)夹在父段与
|
|
224
|
-
// 子段之间时不切断归属(AC-10:多余段不参与骨架判定)。
|
|
331
|
+
// 子段之间时不切断归属(AC-10:多余段不参与骨架判定)。occurrences 是同一份归属数据的旁路记录
|
|
332
|
+
// (H3 所在的 H2 + 最近的骨架 H2),只供「缺子段时它实际挂在哪」的诊断使用,不参与归属判定。
|
|
225
333
|
const subsectionsByParent = new Map();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
334
|
+
const subsectionOccurrences = [];
|
|
335
|
+
let enclosing = null;
|
|
336
|
+
for (let index = 0; index < outline.sections.length; index += 1) {
|
|
337
|
+
const section = outline.sections[index];
|
|
338
|
+
const registered = indexByNorm.has(section.norm);
|
|
339
|
+
if (registered) enclosing = section;
|
|
340
|
+
if (enclosing === null) continue;
|
|
341
|
+
if (!subsectionsByParent.has(enclosing.norm)) subsectionsByParent.set(enclosing.norm, []);
|
|
342
|
+
subsectionsByParent.get(enclosing.norm).push(...section.subsections);
|
|
343
|
+
for (const docSub of section.subsections) {
|
|
344
|
+
subsectionOccurrences.push({
|
|
345
|
+
index,
|
|
346
|
+
registered,
|
|
347
|
+
section,
|
|
348
|
+
enclosing,
|
|
349
|
+
norm: docSub.norm,
|
|
350
|
+
qualified: docSub.qualified,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
232
353
|
}
|
|
354
|
+
const lastSkeletonIndex = outline.sections.reduce(
|
|
355
|
+
(last, section, index) => (indexByNorm.has(section.norm) ? index : last),
|
|
356
|
+
-1,
|
|
357
|
+
);
|
|
233
358
|
for (const section of skeleton.sections) {
|
|
234
359
|
const docSection = matched.get(section.norm);
|
|
235
360
|
if (!docSection) continue;
|
|
@@ -245,16 +370,27 @@ function collectSectionIssues({ text, skeleton, template, issues }) {
|
|
|
245
370
|
issues.verbatim.push(section.name);
|
|
246
371
|
}
|
|
247
372
|
}
|
|
248
|
-
// 结构子段:父段在场才要求;父段整段 N/A → 子段不要求(AC-8
|
|
373
|
+
// 结构子段:父段在场才要求;父段整段 N/A → 子段不要求(AC-8 ②)。父段的「整段不适用」接受
|
|
374
|
+
// 包裹符号(含「闭合标记 + 说明」形态),但剥掉包装后仍要以白名单词开头(AC-8 / AC-9)。
|
|
249
375
|
for (const sub of skeleton.structureSubsections) {
|
|
250
376
|
const parent = sub.parentNorm === null ? null : matched.get(sub.parentNorm);
|
|
251
377
|
if (!parent) continue;
|
|
252
|
-
|
|
378
|
+
const parentBody = bodyText(parent.bodyLines);
|
|
379
|
+
if (isNotApplicableBody(parentBody)) continue;
|
|
253
380
|
const candidates = subsectionsByParent.get(sub.parentNorm) ?? parent.subsections;
|
|
254
|
-
const found = candidates.some((docSub) => (sub
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
381
|
+
const found = candidates.some((docSub) => structureSubsectionMatches(docSub, sub));
|
|
382
|
+
if (found) continue;
|
|
383
|
+
issues.structure.push({
|
|
384
|
+
name: sub.name,
|
|
385
|
+
placement: locateStructureSubsection(subsectionOccurrences, lastSkeletonIndex, sub),
|
|
386
|
+
});
|
|
387
|
+
// 父段正文留下 N/A 意图痕迹(如「(说明:N/A)」/「见 N/A」)却写不进白名单:子段仍要求,并
|
|
388
|
+
// 给出可照抄的写法(AC-10)。触发条件是**意图痕迹**而不是「正文非空」——普通正文漏写子段时当事人
|
|
389
|
+
// 根本没想写整段不适用,这条提示只会把注意力引到无关段落上;空正文同理(父段正文由子段承载时
|
|
390
|
+
// 它本就是空的)。父段名用真实名,文案里的「父段「」」没有定位价值。
|
|
391
|
+
if (!hasNotApplicableIntent(directBodyLines(parent))) continue;
|
|
392
|
+
const parentName = parentSectionName(skeleton, sub.parentNorm, parent);
|
|
393
|
+
if (!issues.structureAdvice.includes(parentName)) issues.structureAdvice.push(parentName);
|
|
258
394
|
}
|
|
259
395
|
// 增量段:只校验在场者的位置(必填与否由登记表 required + 各自门禁决定,本模块不做存在性兜底)
|
|
260
396
|
for (const increment of skeleton.increments) {
|
|
@@ -346,7 +482,16 @@ function hintCategories(issues) {
|
|
|
346
482
|
return [...categories];
|
|
347
483
|
}
|
|
348
484
|
|
|
349
|
-
|
|
485
|
+
// 缺子段定位的人读文本:挂在另一个骨架父段下 / 落在模板骨架之外(文末)。
|
|
486
|
+
function placementText(placement) {
|
|
487
|
+
return placement.kind === 'tail' ? '实际在文末' : '实际挂在 ' + placement.heading + ' 段下';
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// 结构问题清单 → 人读片段(唯一实现):末尾的完整出口报告行与只读的结构预检共用这一个格式器,
|
|
491
|
+
// 两种模式的措辞因此不会各自漂移。escalate 只控制「缺段是否列出段名」(该工件上一轮也失败过才列);
|
|
492
|
+
// 预检不读提示账本,一律以 false 调用。本函数只拼文本——账本由 reportArtifactStructure 写,所以
|
|
493
|
+
// 调用方拿到同形报文不需要复制一份实现。
|
|
494
|
+
export function formatIssueParts(issues, { escalate }) {
|
|
350
495
|
const parts = [];
|
|
351
496
|
if (issues.title !== null) parts.push('标题形态不符(模板首行: `' + issues.title.expected + '`)');
|
|
352
497
|
if (issues.headerMissing.length > 0) parts.push('首部缺字段: ' + issues.headerMissing.join('、'));
|
|
@@ -366,7 +511,18 @@ function formatIssueParts(issues, { escalate }) {
|
|
|
366
511
|
parts.push('与模板该段正文逐字相同(判未填)' + issues.verbatim.length + ' 项: ' + issues.verbatim.join('、'));
|
|
367
512
|
}
|
|
368
513
|
if (issues.structure.length > 0) {
|
|
369
|
-
|
|
514
|
+
const entries = issues.structure.map((entry) => (entry.placement === null
|
|
515
|
+
? entry.name
|
|
516
|
+
: entry.name + '(' + placementText(entry.placement) + ')'));
|
|
517
|
+
parts.push('缺结构子段 ' + issues.structure.length + ' 项: ' + entries.join('、'));
|
|
518
|
+
}
|
|
519
|
+
if (issues.structureAdvice.length > 0) {
|
|
520
|
+
// 报文必须与判据一致:包裹符号(粗体 / 引用 / 括号)**本身就被接受**,旧措辞「不要加粗或引用」
|
|
521
|
+
// 与判据相反,会把人推去改一个本来能通过的写法;真正要的是「白名单词开头」,以及带说明时的
|
|
522
|
+
// 正确位置(闭合标记之后,见 isNotApplicableBody)。
|
|
523
|
+
parts.push('父段「' + issues.structureAdvice.join('」「') + '」正文不在「整段不适用」白名单——'
|
|
524
|
+
+ '若要整段不适用,请让整段以 N/A 开头(包裹符号本身就被接受:粗体 / 引用 / 括号都算);'
|
|
525
|
+
+ '闭合标记之后要跟说明,写成 `**N/A**(理由)` 这种形态');
|
|
370
526
|
}
|
|
371
527
|
if (issues.increments.length > 0) parts.push('增量段位置非法: ' + issues.increments.join('、'));
|
|
372
528
|
return parts;
|
|
@@ -563,15 +719,10 @@ export async function runSummaryTemplateFidelityGate({ node, state }) {
|
|
|
563
719
|
// 节点 → 待校验工件:单一来源 = 协议。**该节点是否受模板门禁**由 protocol-utils 的
|
|
564
720
|
// nodeTemplateDeclaration 决定(内置节点取引擎映射、自定义节点取协议 node.templates,未声明 =
|
|
565
721
|
// 零模板 ⇒ 不校验,ADR-002 特化层);**产出哪份工件**取该节点 outputSchemas 的 artifacts[].paths
|
|
566
|
-
// (`<change-id>/…`
|
|
567
|
-
//
|
|
722
|
+
// (`<change-id>/…` 基),工件名 → 模板键的派生取 protocol-utils 的 templateKeyFromArtifactName
|
|
723
|
+
// (与结构预检的模板指针**同一实现**:口径只有一处,本模块不再持副本)——本模块不另写节点→工件映射。
|
|
568
724
|
// SUMMARY 由 execute 家族的专用门负责(它还要消费无模板时的兜底段序),此处跳过以免同一工件被
|
|
569
725
|
// 两条门重复判定。
|
|
570
|
-
function templateKeyFromArtifactName(namePattern) {
|
|
571
|
-
const base = String(namePattern ?? '').split('*').pop().replace(/^[^A-Za-z0-9]+/u, '');
|
|
572
|
-
return base === '' ? null : templateKeyOf(base);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
726
|
async function nodeArtifactTargets(node) {
|
|
576
727
|
let protocol = null;
|
|
577
728
|
try {
|
|
@@ -587,7 +738,9 @@ async function nodeArtifactTargets(node) {
|
|
|
587
738
|
for (const pattern of artifact.paths ?? []) {
|
|
588
739
|
const segments = String(pattern ?? '').replaceAll('\\', '/').split('/');
|
|
589
740
|
if (segments.length !== 2 || segments[0] !== '<change-id>') continue;
|
|
590
|
-
|
|
741
|
+
// 传整条声明路径:路径归一(取末段、通配取末个 `*` 之后)由共享派生统一承担,
|
|
742
|
+
// 两处消费面因此走的是同一段归一逻辑,而不是各自先切一刀再交给共用的键归一。
|
|
743
|
+
const key = templateKeyFromArtifactName(pattern);
|
|
591
744
|
if (key === null) continue;
|
|
592
745
|
targets.push({ key, namePattern: segments[1] });
|
|
593
746
|
}
|
|
@@ -22,6 +22,8 @@ import path from 'path';
|
|
|
22
22
|
import { runRoot, fileExists } from './guard-state-io.mjs';
|
|
23
23
|
import { isNewChange, templateSectionPatterns, TEMPLATE_FALLBACK_SECTION_PATTERNS } from './guard-routing.mjs';
|
|
24
24
|
import { assessArtifact, evaluateArtifact, reportArtifactStructure } from './guard-template-fidelity.mjs';
|
|
25
|
+
// 段界(下一个二级标题 / 文末)取 lib/section-body.mjs 的唯一实现:围栏代码块里的 `## ` 是正文示例。
|
|
26
|
+
import { sectionBody } from './section-body.mjs';
|
|
25
27
|
|
|
26
28
|
export const UI_DESIGN_SKILL = 'flow-comet-ui-design';
|
|
27
29
|
const APPLICABILITY_GATED_BINDINGS = new Set(['design.' + UI_DESIGN_SKILL]);
|
|
@@ -65,15 +67,11 @@ async function visualToneSectionState(changeName) {
|
|
|
65
67
|
if (headingPattern !== null && typeof headingPattern === 'object' && headingPattern.skip === true) {
|
|
66
68
|
return { state: 'no-basis', body: null };
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (body !== null) body += line + '\n';
|
|
76
|
-
}
|
|
70
|
+
// 段界由 lib/section-body.mjs 单点决定(围栏代码块里的 `## ` 不结束本段)。此前这里是一份围栏盲
|
|
71
|
+
// 的按行扫描:段内贴一段 Markdown 示例后,示例之后的「不适用」声明整段消失,非前端 change 被误判
|
|
72
|
+
// 成前端(要求一份本不该存在的 UI-DESIGN.md)。本判据自己的语义保留:只认二级标题(level: 2)、
|
|
73
|
+
// 分隔线不结束本段(endOnSeparator: false)——「视觉调性」段以 `---` 分隔清单是既有书写形态。
|
|
74
|
+
const body = sectionBody(text, headingPattern, { level: 2, endOnSeparator: false });
|
|
77
75
|
return body === null ? { state: 'section-missing', body: null } : { state: 'present', body };
|
|
78
76
|
}
|
|
79
77
|
|