@namewta/skills-hub 0.1.28 → 0.1.30

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 (105) hide show
  1. package/README.md +23 -4
  2. package/THIRD_PARTY_NOTICES.md +4 -0
  3. package/cli.mjs +5 -1
  4. package/install.mjs +172 -39
  5. package/licenses/nanobot-MIT.txt +21 -0
  6. package/package.json +2 -1
  7. package/scripts/init-persistence.mjs +26 -6
  8. package/scripts/persistence/home.md +11 -0
  9. package/skills/dev/dev-architecture/references/alternative-designs.md +1 -1
  10. package/skills/dev/dev-architecture/references/architecture-method.md +1 -1
  11. package/skills/dev/dev-archive/SKILL.md +1 -1
  12. package/skills/dev/dev-archive/references/parallel-retrospective.md +1 -1
  13. package/skills/dev/dev-benchmark/SKILL.md +1 -1
  14. package/skills/dev/dev-build/SKILL.md +1 -1
  15. package/skills/dev/dev-build/references/delegation.md +2 -2
  16. package/skills/dev/dev-build/references/implement-task-graph.md +4 -4
  17. package/skills/dev/dev-deploy/SKILL.md +2 -2
  18. package/skills/dev/dev-formal-verify/SKILL.md +1 -1
  19. package/skills/dev/dev-grill/references/decision-interview.md +1 -1
  20. package/skills/dev/dev-handoff/SKILL.md +1 -1
  21. package/skills/dev/dev-handoff/assets/handoff.md +2 -2
  22. package/skills/dev/dev-handoff/references/handoff-method.md +1 -1
  23. package/skills/dev/dev-handoff/references/safe-pause.md +1 -1
  24. package/skills/dev/dev-handoff/references/session-resume.md +1 -1
  25. package/skills/dev/dev-help/references/capabilities.md +0 -1
  26. package/skills/dev/dev-help/references/guide-setup.md +9 -9
  27. package/skills/dev/dev-help/references/harness-adapter.md +1 -1
  28. package/skills/dev/dev-help/references/help-method.md +3 -4
  29. package/skills/dev/dev-issue-fix/references/fix-method.md +1 -1
  30. package/skills/dev/dev-learn/references/module-exploration.md +1 -1
  31. package/skills/dev/dev-parallel/SKILL.md +2 -2
  32. package/skills/dev/dev-parallel/assets/worker-brief.md +1 -1
  33. package/skills/dev/dev-parallel/references/candidate-comparison.md +1 -1
  34. package/skills/dev/dev-parallel/references/parallel-coverage.md +1 -1
  35. package/skills/dev/dev-parallel/references/program-coordination.md +3 -3
  36. package/skills/dev/dev-plan/SKILL.md +1 -1
  37. package/skills/dev/dev-plan/references/plan-template.md +1 -1
  38. package/skills/dev/dev-plan/references/research-method.md +1 -1
  39. package/skills/dev/dev-program/SKILL.md +1 -1
  40. package/skills/dev/dev-program/assets/program.md +1 -1
  41. package/skills/dev/dev-program/references/batch.md +1 -1
  42. package/skills/dev/dev-review/references/adversarial-review.md +1 -1
  43. package/skills/dev/dev-review/references/eval.md +1 -1
  44. package/skills/dev/dev-review/references/two-axis-review.md +1 -1
  45. package/skills/dev/dev-setup/SKILL.md +3 -1
  46. package/skills/dev/dev-setup/assets/team.md +4 -0
  47. package/skills/dev/dev-setup/references/configure-team.md +13 -3
  48. package/skills/dev/dev-setup/references/formal-options.md +1 -1
  49. package/skills/dev/dev-verify/SKILL.md +1 -1
  50. package/skills/dev/dev-verify/references/verification-maintenance.md +1 -1
  51. package/skills/dev/dev-why/references/investigation-method.md +1 -1
  52. package/skills/dev/dev-workflow/SKILL.md +1 -2
  53. package/skills/dev/dev-workflow/references/autonomous-execution.md +1 -1
  54. package/skills/dev/dev-workflow/references/delegate-role.md +1 -1
  55. package/skills/dev/dev-workflow/references/execution-support.md +2 -2
  56. package/skills/dev/dev-workflow/references/operating-method.md +3 -3
  57. package/skills/dev/dev-workflow/references/phase-boundaries.md +3 -3
  58. package/skills/dev/dev-worktree/SKILL.md +1 -1
  59. package/skills/dev/dev-worktree/references/lifecycle.md +1 -1
  60. package/skills/dev/dev-worktree/references/worktree-cleanup.md +1 -1
  61. package/skills/home/home-doctor/SKILL.md +30 -0
  62. package/skills/home/home-doctor/references/diagnosis.md +40 -0
  63. package/skills/home/home-doctor/scripts/doctor.mjs +179 -0
  64. package/skills/home/home-history/SKILL.md +35 -0
  65. package/skills/home/home-history/assets/event.md +22 -0
  66. package/skills/home/home-history/assets/resumption.md +19 -0
  67. package/skills/home/home-history/references/history-method.md +90 -0
  68. package/skills/home/home-history/references/tools.md +57 -0
  69. package/skills/home/home-history/scripts/files.mjs +252 -0
  70. package/skills/home/home-history/scripts/history.mjs +184 -0
  71. package/skills/home/home-integrate/SKILL.md +23 -0
  72. package/skills/home/home-integrate/assets/integration.md +25 -0
  73. package/skills/home/home-integrate/references/integration.md +59 -0
  74. package/skills/home/home-knowledge/SKILL.md +37 -0
  75. package/skills/home/home-knowledge/assets/candidate.md +19 -0
  76. package/skills/home/home-knowledge/assets/exclusions.md +6 -0
  77. package/skills/home/home-knowledge/assets/topic.md +27 -0
  78. package/skills/home/home-knowledge/references/knowledge-method.md +55 -0
  79. package/skills/home/home-knowledge/references/maintenance.md +74 -0
  80. package/skills/home/home-knowledge/references/tools.md +55 -0
  81. package/skills/home/home-knowledge/scripts/files.mjs +252 -0
  82. package/skills/home/home-knowledge/scripts/knowledge.mjs +150 -0
  83. package/skills/home/home-map/SKILL.md +23 -0
  84. package/skills/home/home-map/assets/relations.md +25 -0
  85. package/skills/home/home-map/references/relations.md +60 -0
  86. package/skills/home/home-route/SKILL.md +32 -0
  87. package/skills/home/home-route/references/routing.md +48 -0
  88. package/skills/home/home-route/scripts/route.mjs +273 -0
  89. package/skills/home/home-setup/SKILL.md +46 -0
  90. package/skills/home/home-setup/assets/environment.md +18 -0
  91. package/skills/home/home-setup/assets/home-navigation.md +7 -0
  92. package/skills/home/home-setup/assets/local.schema.json +15 -0
  93. package/skills/home/home-setup/assets/preferences.md +16 -0
  94. package/skills/home/home-setup/assets/profile.md +19 -0
  95. package/skills/home/home-setup/assets/repos.schema.json +27 -0
  96. package/skills/home/home-setup/assets/team.md +24 -0
  97. package/skills/home/home-setup/references/configuration.md +71 -0
  98. package/skills/home/home-setup/references/environment.md +34 -0
  99. package/skills/home/home-setup/references/registry.md +110 -0
  100. package/skills/home/home-setup/scripts/registry.mjs +231 -0
  101. package/skills/home/home-workflow/SKILL.md +37 -0
  102. package/skills/home/home-workflow/assets/coordination.md +24 -0
  103. package/skills/home/home-workflow/assets/project-brief.md +25 -0
  104. package/skills/home/home-workflow/references/coordination.md +41 -0
  105. package/skills/home/home-workflow/references/delegation.md +86 -0
@@ -0,0 +1,57 @@
1
+ # 历史文件工具参考
2
+
3
+ `scripts/history.mjs` 使用 Node.js 22.14+ 标准库,维护明确 Home 根中的 Markdown 历史。所有脚本资源在本包内;单独安装后仍可调用,缺少其他方法时按准确技能名说明缺项。
4
+
5
+ ## 输入和身份
6
+
7
+ 事件输入包含非空 `scope`、`sources`、`event_key`、`status` 和 `occurred_at`。平面 frontmatter 的字符串使用 JSON 双引号,列表使用 JSON 字符串数组;复杂 YAML 不在工具支持范围。正文说明目标、理由、实际结果和限制。
8
+
9
+ `event_key` 是原来源事件的稳定身份,与 scope 共同查重;标题不是身份。`id` 可省略,由工具生成;指定时只允许字母、数字、下划线、连字符,最多 101 字符。新文件保存到 `history/YYYY/MM/<id>.md`;事件时间未知时仅用整理年月放置文件,正文仍标 unknown。
10
+
11
+ `occurred_at` 可为 `YYYY-MM-DD`、带时区偏移的 ISO 时间或 `unknown`。ISO 时间的秒数必填,小数秒可省略或为 1~3 位,使用 Node Date 的毫秒精度;例如 `2026-11-25T15:20:00.123+08:00`。更高精度输入明确拒绝,不静默截断,owner 需决定是否按毫秒精度转换并保留必要的原始来源。`recorded_at` 由首次记录操作生成,修订保留它并增加 `updated_at`。工具不从文件 mtime、目录或整理时间推断事件实际时间。
12
+
13
+ ## 命令
14
+
15
+ 将示例 Home 根和输入文件换成本次实际路径,从 Home 根调用:
16
+
17
+ ```sh
18
+ node .agents/skills/home-history/scripts/history.mjs record --home /path/to/home --input /path/to/checked-event.md
19
+ node .agents/skills/home-history/scripts/history.mjs query --home /path/to/home --text 项目A
20
+ node .agents/skills/home-history/scripts/history.mjs query --home /path/to/home --from 2026-11-01T00:00:00+08:00 --until 2026-11-30T23:59:59.999+08:00
21
+ node .agents/skills/home-history/scripts/history.mjs index --home /path/to/home
22
+ ```
23
+
24
+ | 命令 | 行为 |
25
+ | --- | --- |
26
+ | `record --input FILE或-` | 校验来源、事件身份与时间,锁内查重、保存并更新索引 |
27
+ | `read --path PATH` | 读取指定 `history/` 或 `archive/history/` 正文及 SHA-256 |
28
+ | `update --path PATH --input FILE或- --expect HASH` | 保留事件身份、id 与首次整理时间,旧稿 hash 不匹配时拒绝覆盖 |
29
+ | `remove --path PATH --expect HASH` | 删除指定原件并更新索引,不代表跨 owner 忘记全部完成 |
30
+ | `query` | 在实际历史正文中按时间、scope 和关键字检索,独立于索引 |
31
+ | `index` | 稳定生成 `history/index.md`,不改原件或排除依据 |
32
+
33
+ 查询支持 `--scope`、`--text`、`--limit`、`--from`、`--until`。加 `--include-archive` 才查询归档;有时间过滤时未知时间默认不进入结果,加 `--include-undated` 可保留并显示其未知状态。`from/until` 只有日期时按 UTC 日边界;用户本地日期应换成实际带偏移时间。
34
+
35
+ 确定的事件按实际时间倒序排列,不按时区字符串排序;相同时间按路径稳定排序,未知或无效时间在最后。只有日期的事件按当天起点用于排序,日期过滤按全天重叠处理,不赋予其精确发生时刻。
36
+
37
+ `query/index` 支持 `--max-files`、`--max-bytes`,默认最多 2000 个正文与 8 MiB。索引预算默认 6000 Unicode 字符,可用 `--budget` 调整至 512~50000。单文件最多 512 KiB。身份查重另读取 history 和 archive/history,最多 10000 个正文与 32 MiB,读取未完成或元数据无法解析时停止新增,不能宣称去重完成。
38
+
39
+ 既有纯 Markdown 可以参与正文检索;缺少时间或身份明确显示 unknown。`unidentifiedRecords` 说明新增前读到了多少无事件身份记录,不能证明这些记录与新事件无关。
40
+
41
+ ## 排除、并发与失败
42
+
43
+ 工具读取 knowledge 维护的 `exclusions.md`,匹配 `sources` 与 `derived_from` 的准确标识及范围,不修改排除文件。历史有被排除的来源时停止重导和默认返回,索引也不展示。定点 `read` 供维护使用,不应把被排除原文重新写入答案或新摘要。
44
+
45
+ knowledge 与 history 共用 Home 的 `.home-content-write.lock`。写入在同一锁内查原件、版本、排除和身份,正文使用可读回的单文件替换;不提供跨 owner 全局事务或对非配合编辑器的互斥保证。`STALE` 时重读合并,`BUSY` 时核实原写者,不能按年龄自动删锁。
46
+
47
+ | 返回 | 含义 |
48
+ | --- | --- |
49
+ | 退出码 `0` | 本命令完成,仍需按范围、来源与 warning 限定结论 |
50
+ | `status: unchanged` | 同身份且有效负载相同,未新建重复事件 |
51
+ | 退出码 `1` | 参数、路径、身份、排除、并发或 IO 错误 |
52
+ | `EVENT_EXISTS` | 同事件内容不同,先 read 再用 update 修订 |
53
+ | `ID_EXISTS`、`IDENTITY_CONFLICT` | 已有 ID 或多份相同事件,保留原件交 owner 核查 |
54
+ | `INCOMPLETE` | 去重范围未读完或无法解析,不能安全新增 |
55
+ | 退出码 `2`、`status: partial` | 正文已保存或删除,索引待修;保留正文并修复导航 |
56
+
57
+ 查询返回实际发生时间、整理时间、状态、来源、检索范围与截断信息。它没有核验服务、部署或会话状态;摘要更不会因为命令退出成功而变成验收通过。
@@ -0,0 +1,252 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createHash, randomUUID } from 'node:crypto';
4
+
5
+ export const digest = (text) => createHash('sha256').update(text).digest('hex');
6
+ export const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
7
+ export function fail(code, message, details = {}) {
8
+ throw Object.assign(new Error(message), { code, ...details });
9
+ }
10
+ export function integer(value, fallback, maximum = 10000) {
11
+ if (value === undefined) return fallback;
12
+ const number = Number(value);
13
+ if (!Number.isSafeInteger(number) || number < 1 || number > maximum) fail('ARGUMENT', `整数必须在 1 到 ${maximum} 之间`);
14
+ return number;
15
+ }
16
+
17
+ export function parseDocument(content) {
18
+ const text = content.replaceAll('\r\n', '\n');
19
+ const metadata = Object.create(null);
20
+ if (!text.startsWith('---\n')) return { metadata, body: text };
21
+ const end = text.indexOf('\n---\n', 4);
22
+ if (end < 0) fail('METADATA', 'frontmatter 缺少结束行');
23
+ for (const line of text.slice(4, end).split('\n')) {
24
+ if (!line.trim() || line.trimStart().startsWith('#')) continue;
25
+ const match = /^([a-z][a-z0-9_]*):\s*(.*)$/.exec(line);
26
+ if (!match || Object.hasOwn(metadata, match[1])) fail('METADATA', '工具仅接受不重复的平面 frontmatter 字段');
27
+ const [, key, raw] = match;
28
+ let value = raw.trim();
29
+ if (value.startsWith('[') || value.startsWith('"')) {
30
+ try { value = JSON.parse(value); } catch { fail('METADATA', `${key} 的字符串或列表格式无效`); }
31
+ } else if (value.startsWith("'")) {
32
+ if (!value.endsWith("'")) fail('METADATA', `${key} 的引号未闭合`);
33
+ value = value.slice(1, -1).replaceAll("''", "'");
34
+ } else if (/^[{>|&*!]/.test(value)) fail('METADATA', `${key} 需要普通字符串或 JSON 字符串列表`);
35
+ if (typeof value !== 'string' && !(Array.isArray(value) && value.every((item) => typeof item === 'string'))) fail('METADATA', `${key} 需要字符串或字符串列表`);
36
+ metadata[key] = value;
37
+ }
38
+ sourceMetadata(metadata);
39
+ return { metadata, body: text.slice(end + 5) };
40
+ }
41
+
42
+ export function renderDocument(metadata, body) {
43
+ const lines = Object.keys(metadata).sort(compare).map((key) => `${key}: ${JSON.stringify(metadata[key])}`);
44
+ return `---\n${lines.join('\n')}\n---\n${body.replace(/^\n*/, '\n')}`.replace(/\n*$/, '\n');
45
+ }
46
+
47
+ function sourceMetadata(metadata, required = false) {
48
+ const nonempty = (value) => typeof value === 'string' && Boolean(value.trim());
49
+ if ((required || Object.hasOwn(metadata, 'scope')) && !nonempty(metadata.scope)) fail('PROVENANCE', 'scope 必须是非空字符串');
50
+ if ((required || Object.hasOwn(metadata, 'sources')) && (!Array.isArray(metadata.sources) || !metadata.sources.length || !metadata.sources.every(nonempty))) fail('PROVENANCE', 'sources 必须是非空字符串列表');
51
+ if (Object.hasOwn(metadata, 'derived_from') && (!Array.isArray(metadata.derived_from) || !metadata.derived_from.every(nonempty))) fail('PROVENANCE', 'derived_from 必须是非空字符串组成的列表;没有派生来源时可省略或使用空列表');
52
+ }
53
+ export function provenance(metadata) { sourceMetadata(metadata, true); }
54
+
55
+ function tableCells(line) {
56
+ const source = line.trim(); const cells = []; let value = ''; let lastSeparator = -1;
57
+ for (let index = 0; index < source.length; index += 1) {
58
+ const char = source[index];
59
+ if (char === '\\' && ['|', '\\'].includes(source[index + 1])) value += source[++index];
60
+ else if (char === '|') { cells.push(value.trim()); value = ''; lastSeparator = index; }
61
+ else value += char;
62
+ }
63
+ if (lastSeparator < 0) return null;
64
+ cells.push(value.trim());
65
+ if (source.startsWith('|')) cells.shift();
66
+ if (lastSeparator === source.length - 1) cells.pop();
67
+ return cells;
68
+ }
69
+
70
+ export function parseExclusions(content) {
71
+ if (content === null) return { entries: [], lines: [], end: -1 };
72
+ const lines = content.replaceAll('\r\n', '\n').split('\n');
73
+ const headers = lines.map((line, index) => ({ cells: tableCells(line), index })).filter(({ cells }) => cells?.join('\0') === 'source_ref\0scope\0basis_ref');
74
+ if (headers.length !== 1) fail('EXCLUSIONS_FORMAT', 'exclusions.md 需要唯一的 source_ref / scope / basis_ref 三列表;先人工核对,不能当空文件忽略');
75
+ let end = headers[0].index + 1; const separator = tableCells(lines[end] ?? '');
76
+ if (separator?.length !== 3 || !separator.every((cell) => /^:?-+:?$/.test(cell))) fail('EXCLUSIONS_FORMAT', '排除表缺少有效分隔行');
77
+ const entries = [];
78
+ while (end + 1 < lines.length) {
79
+ const line = lines[end + 1];
80
+ if (!line.trim()) break;
81
+ const cells = tableCells(line);
82
+ if (!cells) fail('EXCLUSIONS_FORMAT', '排除表含无法解释的数据行;需有来源、范围和依据三列,表后正文用空行分隔');
83
+ if (cells.length !== 3 || cells.some((cell) => !cell)) fail('EXCLUSIONS_FORMAT', '排除项必须有来源身份、范围和依据引用');
84
+ if (entries.length >= 1000) fail('EXCLUSIONS_FORMAT', '排除表超过 1000 项,需要按授权整理');
85
+ entries.push({ source_ref: cells[0], scope: cells[1], basis_ref: cells[2] }); end += 1;
86
+ }
87
+ return { entries, lines, end };
88
+ }
89
+
90
+ export function excluded(metadata, entries) {
91
+ sourceMetadata(metadata);
92
+ const sources = [...(Array.isArray(metadata.sources) ? metadata.sources : []), ...(Array.isArray(metadata.derived_from) ? metadata.derived_from : [])];
93
+ return entries.some((entry) => (entry.scope === '*' || entry.scope === metadata.scope) && sources.includes(entry.source_ref));
94
+ }
95
+
96
+ export function appendExclusion(content, entry) {
97
+ for (const key of ['source_ref', 'scope', 'basis_ref']) if (typeof entry[key] !== 'string' || !entry[key].trim() || /[\r\n\0]/.test(entry[key])) fail('ARGUMENT', `${key} 必须是非空单行值`);
98
+ if (entry.source_ref === '*') fail('ARGUMENT', 'source_ref 必须是准确来源身份,不能使用通配符');
99
+ const initial = content ?? '# 不再摄取的来源\n\n只保留用户允许保存的最小来源身份、范围与依据,不保存被忘记的正文。\n\n| source_ref | scope | basis_ref |\n| --- | --- | --- |\n';
100
+ const parsed = parseExclusions(initial);
101
+ if (parsed.entries.some((row) => row.source_ref === entry.source_ref && row.scope === entry.scope)) return { content: initial, changed: false };
102
+ const cell = (value) => value.replaceAll('\\', '\\\\').replaceAll('|', '\\|');
103
+ parsed.lines.splice(parsed.end + 1, 0, `| ${cell(entry.source_ref)} | ${cell(entry.scope)} | ${cell(entry.basis_ref)} |`);
104
+ return { content: parsed.lines.join('\n').replace(/\n*$/, '\n'), changed: true };
105
+ }
106
+
107
+ export function openFiles(homeRoot, { writable, lockName, fsOps = fs }) {
108
+ if (!homeRoot) fail('ARGUMENT', '必须显式传入 --home,不能从 cwd 推定知识归属');
109
+ const requested = path.resolve(homeRoot);
110
+ if (fsOps.lstatSync(requested).isSymbolicLink()) fail('PATH', 'Home 根本身不能是符号链接');
111
+ const root = fsOps.realpathSync(requested);
112
+ if (!fsOps.statSync(root).isDirectory()) fail('PATH', 'Home 根必须是已有目录');
113
+ const base = path.join(root, '.agents', 'home');
114
+
115
+ function checked(relative, createParents = false) {
116
+ if (typeof relative !== 'string' || !relative || /[:\\\0\r\n]/.test(relative) || path.posix.isAbsolute(relative) || path.win32.isAbsolute(relative) || path.posix.normalize(relative) !== relative || relative.split('/').some((part) => !part || part === '..' || part === '.')) fail('PATH', '需要 .agents/home 内的规范相对路径');
117
+ if (fsOps.realpathSync(requested) !== root || fsOps.lstatSync(requested).isSymbolicLink()) fail('PATH', 'Home 根在操作期间发生变化');
118
+ const segments = ['.agents', 'home', ...relative.split('/')]; let current = root;
119
+ for (let index = 0; index < segments.length; index += 1) {
120
+ current = path.join(current, segments[index]); let stat;
121
+ try { stat = fsOps.lstatSync(current); }
122
+ catch (error) {
123
+ if (error.code !== 'ENOENT') throw error;
124
+ if (!createParents || index === segments.length - 1) continue;
125
+ try { fsOps.mkdirSync(current, { mode: 0o700 }); } catch (mkdirError) { if (mkdirError.code !== 'EEXIST') throw mkdirError; }
126
+ stat = fsOps.lstatSync(current);
127
+ }
128
+ if (!stat) continue;
129
+ if (stat.isSymbolicLink()) fail('PATH', `拒绝符号链接路径:${relative}`);
130
+ if (index < segments.length - 1 && !stat.isDirectory()) fail('PATH', `父路径不是目录:${relative}`);
131
+ }
132
+ return current;
133
+ }
134
+
135
+ function read(relative, maximumBytes = 524288) {
136
+ const filename = checked(relative); let stat;
137
+ try { stat = fsOps.lstatSync(filename); } catch (error) { if (error.code === 'ENOENT') return null; throw error; }
138
+ if (!stat.isFile() || stat.isSymbolicLink()) fail('PATH', `需要普通文件:${relative}`);
139
+ if (stat.size > maximumBytes) fail('LIMIT', `文件超过 ${maximumBytes} 字节:${relative}`);
140
+ const fd = fsOps.openSync(filename, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
141
+ let content;
142
+ try { if (!fsOps.fstatSync(fd).isFile()) fail('PATH', '读取目标不是普通文件'); content = fsOps.readFileSync(fd, 'utf8'); }
143
+ finally { fsOps.closeSync(fd); }
144
+ checked(relative);
145
+ if (Buffer.byteLength(content) > maximumBytes) fail('LIMIT', `文件读取期间超过限制:${relative}`);
146
+ return { path: relative, content, sha256: digest(content) };
147
+ }
148
+
149
+ function expectation(relative, expected) {
150
+ if (expected !== 'missing' && !/^[0-9a-f]{64}$/.test(expected ?? '')) fail('EXPECTED_HASH', '写入/删除必须提供 read 返回的 SHA-256;新文件使用 missing');
151
+ const before = read(relative);
152
+ if ((expected === 'missing' && before) || (expected !== 'missing' && before?.sha256 !== expected)) fail('STALE', `原件已变化或存在冲突,重新读取:${relative}`);
153
+ return before;
154
+ }
155
+
156
+ function replace(relative, content, expected) {
157
+ if (!writable(relative)) fail('OWNER', `该包不维护此路径:${relative}`);
158
+ if (typeof content !== 'string' || Buffer.byteLength(content) > 524288) fail('LIMIT', '正文必须是最多 524288 字节的 UTF-8 文本');
159
+ const filename = checked(relative, true); const before = expectation(relative, expected);
160
+ if (before?.content === content) return { path: relative, sha256: before.sha256, changed: false };
161
+ const temporary = path.join(path.dirname(filename), `.${path.basename(filename)}.${randomUUID()}.tmp`);
162
+ let fd;
163
+ try {
164
+ fd = fsOps.openSync(temporary, 'wx', 0o600); fsOps.writeFileSync(fd, content); fsOps.fsyncSync(fd); fsOps.closeSync(fd); fd = undefined;
165
+ checked(relative); expectation(relative, expected);
166
+ if (before) fsOps.renameSync(temporary, filename);
167
+ else { fsOps.linkSync(temporary, filename); fsOps.unlinkSync(temporary); }
168
+ } finally {
169
+ if (fd !== undefined) fsOps.closeSync(fd);
170
+ try { fsOps.unlinkSync(temporary); } catch (error) { if (error.code !== 'ENOENT') throw error; }
171
+ }
172
+ const after = read(relative);
173
+ if (after?.sha256 !== digest(content)) fail('READBACK', `写入后读回不一致:${relative}`, { sourceSaved: true });
174
+ return { path: relative, sha256: after.sha256, changed: true };
175
+ }
176
+
177
+ function remove(relative, expected) {
178
+ if (!writable(relative)) fail('OWNER', `该包不维护此路径:${relative}`);
179
+ if (expected === 'missing') fail('EXPECTED_HASH', '删除需要已读取原件的 SHA-256');
180
+ expectation(relative, expected); fsOps.unlinkSync(checked(relative));
181
+ return { path: relative, deleted: true };
182
+ }
183
+
184
+ function locked(action) {
185
+ const filename = checked(lockName, true); const token = `${process.pid}\n${randomUUID()}\n`;
186
+ let fd;
187
+ try { fd = fsOps.openSync(filename, 'wx', 0o600); }
188
+ catch (error) { if (error.code === 'EEXIST') fail('BUSY', `写入锁已存在:${lockName};先核实原写入者,不按时间自动删锁`); throw error; }
189
+ try { fsOps.writeFileSync(fd, token); fsOps.closeSync(fd); fd = undefined; return action(); }
190
+ finally {
191
+ if (fd !== undefined) fsOps.closeSync(fd);
192
+ const current = read(lockName);
193
+ if (current?.content === token) fsOps.unlinkSync(checked(lockName));
194
+ }
195
+ }
196
+
197
+ function scan(areas, { maxFiles = 2000, maxBytes = 8388608, maxDepth = 10 } = {}) {
198
+ const documents = []; const warnings = []; let visited = 0; let bytes = 0; let directories = 0; let complete = true; let metadataComplete = true;
199
+ const walk = (relative, depth) => {
200
+ if (!complete) return;
201
+ if (depth > maxDepth || ++directories > 1000) { complete = false; warnings.push('目录范围超过限制'); return; }
202
+ let entries;
203
+ try { const directory = checked(`${relative}/.scan-check`); entries = fsOps.readdirSync(path.dirname(directory), { withFileTypes: true }); }
204
+ catch (error) { if (error.code === 'ENOENT') return; complete = false; warnings.push(`${relative}: ${error.message}`); return; }
205
+ for (const entry of entries.sort((a, b) => compare(a.name, b.name))) {
206
+ const rel = `${relative}/${entry.name}`;
207
+ if (entry.isSymbolicLink()) { complete = false; warnings.push(`未读取符号链接:${rel}`); continue; }
208
+ if (entry.isDirectory()) { walk(rel, depth + 1); continue; }
209
+ if (!entry.isFile() || !entry.name.endsWith('.md') || entry.name === 'index.md') continue;
210
+ if (++visited > maxFiles) { complete = false; warnings.push(`文件超过 ${maxFiles} 个,范围未读完`); return; }
211
+ try {
212
+ const document = read(rel); if (!document) continue;
213
+ bytes += Buffer.byteLength(document.content);
214
+ if (bytes > maxBytes) { complete = false; warnings.push(`读取预算超过 ${maxBytes} 字节`); return; }
215
+ try { Object.assign(document, parseDocument(document.content)); }
216
+ catch (error) { metadataComplete = false; warnings.push(`${rel}: ${error.message};未用于查询或导航,需 owner 核对原文`); continue; }
217
+ document.title = document.metadata.title || /^#\s+(.+)$/m.exec(document.body)?.[1] || path.posix.basename(rel, '.md');
218
+ documents.push(document);
219
+ } catch (error) { complete = false; warnings.push(`${rel}: ${error.message}`); }
220
+ }
221
+ };
222
+ for (const area of areas) walk(area, 0);
223
+ return { documents, complete: complete && metadataComplete, warnings, scanned: documents.length, bytes, areas };
224
+ }
225
+ return { root, base, checked, read, replace, remove, locked, scan };
226
+ }
227
+
228
+ export function indexText(title, documents, indexPath, { maxChars = 6000, complete = true } = {}) {
229
+ const escape = (value) => String(value).replace(/[\r\n]+/g, ' ').replace(/[\\[\]`*_]/g, '\\$&').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
230
+ const lines = [`# ${title}`, '', '此文件是可重建导航;正文及来源约定为真源。未列出不表示没有记录。', ''];
231
+ let shown = 0;
232
+ for (const doc of documents) {
233
+ const destination = path.posix.relative(path.posix.dirname(indexPath), doc.path).split('/').map(encodeURIComponent).join('/');
234
+ const summary = doc.metadata.summary ? `:${escape(doc.metadata.summary).slice(0, 160)}` : '';
235
+ const line = `- [${escape(doc.title).slice(0, 160)}](${destination})${summary}`;
236
+ if ([...lines.join('\n')].length + [...line].length + 180 > maxChars) break;
237
+ lines.push(line); shown += 1;
238
+ }
239
+ lines.push('', `已列 ${shown} / 本次可读 ${documents.length} 项;枚举${complete ? '完整' : '未完成'};导航${shown < documents.length ? '已截断' : '未截断'}。`, '需要未列内容时,按本次范围检索正文;候选和归档须分别明确选择。', '');
240
+ return { content: lines.join('\n'), shown, truncated: shown < documents.length || !complete };
241
+ }
242
+
243
+ export function argumentsMap(argv) {
244
+ const [command, ...rest] = argv; const options = Object.create(null);
245
+ for (let index = 0; index < rest.length; index += 1) {
246
+ const key = rest[index];
247
+ if (!/^--[a-z][a-z-]*$/.test(key) || Object.hasOwn(options, key.slice(2))) fail('ARGUMENT', `无效或重复参数:${key}`);
248
+ if (['--include-archive', '--include-undated'].includes(key)) options[key.slice(2)] = true;
249
+ else { const value = rest[++index]; if (value === undefined || value.startsWith('--')) fail('ARGUMENT', `${key} 缺少值`); options[key.slice(2)] = value; }
250
+ }
251
+ return { command, options };
252
+ }
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { argumentsMap, compare, excluded, fail, indexText, integer, openFiles, parseDocument, parseExclusions, provenance, renderDocument } from './files.mjs';
6
+
7
+ const documentPath = (relative) => /^(?:history|archive\/history)\/.+\.md$/.test(relative) && !relative.endsWith('/index.md');
8
+ const writable = (relative) => documentPath(relative) || relative === 'history/index.md';
9
+
10
+ export function eventTime(value) {
11
+ if (['unknown', '未知'].includes(value)) return null;
12
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2}))?$/.test(value)) fail('DATE', '时间须为 YYYY-MM-DD、带时区且小数最多三位的 ISO 时间或 unknown');
13
+ const day = value.slice(0, 10); const calendar = new Date(`${day}T00:00:00Z`);
14
+ if (!Number.isFinite(calendar.getTime()) || calendar.toISOString().slice(0, 10) !== day || !Number.isFinite(Date.parse(value))) fail('DATE', `无效时间:${value}`);
15
+ if (value.length > 10 && (Number(value.slice(11, 13)) > 23 || Number(value.slice(14, 16)) > 59 || Number(value.slice(17, 19)) > 59)) fail('DATE', `无效时刻:${value}`);
16
+ return Date.parse(value);
17
+ }
18
+ function compareEvents(a, b) {
19
+ const timestamp = (document) => { try { return eventTime(document.metadata.occurred_at); } catch { return null; } };
20
+ const first = timestamp(a); const second = timestamp(b);
21
+ if (first === null && second !== null) return 1;
22
+ if (second === null && first !== null) return -1;
23
+ return (first === null ? 0 : second - first) || compare(a.path, b.path);
24
+ }
25
+ function validateEvent(metadata) {
26
+ provenance(metadata);
27
+ for (const key of ['event_key', 'status']) if (typeof metadata[key] !== 'string' || !metadata[key].trim()) fail('METADATA', `事件需要 ${key};不能靠标题去重或默认为完成`);
28
+ eventTime(metadata.occurred_at);
29
+ }
30
+ function payload(metadata, body) {
31
+ const values = { ...metadata }; delete values.id; delete values.recorded_at; delete values.updated_at;
32
+ return renderDocument(values, body);
33
+ }
34
+
35
+ export function createHistory(homeRoot, options = {}) {
36
+ const files = openFiles(homeRoot, { writable, lockName: '.home-content-write.lock', fsOps: options.fsOps });
37
+ const now = options.now ?? (() => new Date().toISOString());
38
+ const newId = options.newId ?? (() => randomUUID());
39
+ const exclusions = () => parseExclusions(files.read('exclusions.md')?.content ?? null).entries;
40
+ function owned(relative) { if (!documentPath(relative)) fail('OWNER', '只能操作 history 或 archive/history 正文;不会修改配置、知识或原生会话'); }
41
+ function read(relative) { owned(relative); const result = files.read(relative); if (!result) fail('MISSING', `没有此历史原件:${relative}`); return result; }
42
+ function scan(settings = {}) {
43
+ const result = files.scan(['history', ...(settings.includeArchive ? ['archive/history'] : [])], settings);
44
+ const entries = exclusions(); let excludedCount = 0;
45
+ result.documents = result.documents.filter((document) => { if (excluded(document.metadata, entries)) { excludedCount += 1; return false; } return true; });
46
+ return { ...result, excluded: excludedCount };
47
+ }
48
+ function buildIndex(settings = {}) {
49
+ const result = scan(settings);
50
+ const documents = result.documents.sort(compareEvents);
51
+ const rendered = indexText('Home 历史导航', documents, 'history/index.md', { maxChars: settings.budget ?? 6000, complete: result.complete });
52
+ const before = files.read('history/index.md');
53
+ return { ...files.replace('history/index.md', rendered.content, before?.sha256 ?? 'missing'), shown: rendered.shown, truncated: rendered.truncated, complete: result.complete, warnings: result.warnings, excluded: result.excluded };
54
+ }
55
+ function afterWrite(result) {
56
+ try { return { ...result, status: 'saved', sourceSaved: true, index: { status: 'updated', ...buildIndex() } }; }
57
+ catch (error) { return { ...result, status: 'partial', sourceSaved: true, index: { status: 'pending', code: error.code ?? 'IO', message: error.message } }; }
58
+ }
59
+ function identityDocuments() {
60
+ const result = files.scan(['history', 'archive/history'], { maxFiles: 10000, maxBytes: 33554432 });
61
+ if (!result.complete || result.documents.some((document) => document.metadataError)) fail('INCOMPLETE', '事件身份范围未读完或元数据不可解析,不能宣称去重完成后继续新增', { warnings: result.warnings });
62
+ return result.documents;
63
+ }
64
+ function record(content) {
65
+ const { metadata, body } = parseDocument(content); validateEvent(metadata);
66
+ return files.locked(() => {
67
+ if (excluded(metadata, exclusions())) fail('EXCLUDED', '此来源在该范围被排除,先按原 owner 的保留决定处理');
68
+ const documents = identityDocuments();
69
+ const same = documents.filter((document) => document.metadata.scope === metadata.scope && document.metadata.event_key === metadata.event_key);
70
+ if (same.length > 1) fail('IDENTITY_CONFLICT', '同一范围和事件身份已对应多份记录,先核对原件');
71
+ if (same.length === 1) {
72
+ if (payload(same[0].metadata, same[0].body) !== payload(metadata, body)) fail('EVENT_EXISTS', `事件已记录且内容不同;读取后用 update 修订:${same[0].path}`, { existingPath: same[0].path });
73
+ return { status: 'unchanged', path: same[0].path, id: same[0].metadata.id, sha256: same[0].sha256, sourceSaved: false, deduplication: 'scope + event_key;只涵盖带身份的记录' };
74
+ }
75
+ const id = metadata.id || newId();
76
+ if (!/^[\p{L}\p{N}][\p{L}\p{N}_-]{0,100}$/u.test(id)) fail('ID', 'id 仅使用字母、数字、下划线或连字符,最多 101 字符');
77
+ if (documents.some((document) => document.metadata.id === id)) fail('ID_EXISTS', '事件 ID 已存在,不覆盖原件');
78
+ const recordedAt = now(); eventTime(recordedAt);
79
+ const bucket = eventTime(metadata.occurred_at) === null ? recordedAt : metadata.occurred_at;
80
+ const relative = `history/${bucket.slice(0, 4)}/${bucket.slice(5, 7)}/${id}.md`;
81
+ const finalText = renderDocument({ ...metadata, id, recorded_at: recordedAt }, body);
82
+ return afterWrite({ ...files.replace(relative, finalText, 'missing'), id, deduplication: 'scope + event_key;只有标题相似不会合并', unidentifiedRecords: documents.filter((document) => !document.metadata.event_key || !document.metadata.scope).length });
83
+ });
84
+ }
85
+ function update(relative, content, expectedHash) {
86
+ owned(relative); const next = parseDocument(content); validateEvent(next.metadata);
87
+ return files.locked(() => {
88
+ const before = read(relative);
89
+ if (before.sha256 !== expectedHash) fail('STALE', '历史已改变,重新读取并核对修改');
90
+ const old = parseDocument(before.content);
91
+ for (const key of ['scope', 'event_key']) if (old.metadata[key] && next.metadata[key] !== old.metadata[key]) fail('IDENTITY', `修订不能改写 ${key};真实新事件另建记录`);
92
+ for (const key of ['id', 'recorded_at']) {
93
+ if (old.metadata[key] && next.metadata[key] && next.metadata[key] !== old.metadata[key]) fail('IDENTITY', `修订保留原 ${key}`);
94
+ if (old.metadata[key]) next.metadata[key] = old.metadata[key];
95
+ }
96
+ if (excluded(next.metadata, exclusions())) fail('EXCLUDED', '来源已被排除;需要删除或定点移除有关内容,不可重新保存为可用摘要');
97
+ const documents = identityDocuments().filter((document) => document.path !== relative);
98
+ const duplicate = documents.find((document) => document.metadata.scope === next.metadata.scope && document.metadata.event_key === next.metadata.event_key);
99
+ if (duplicate) fail('IDENTITY_CONFLICT', `其他记录已有同一事件身份:${duplicate.path}`);
100
+ if (next.metadata.id !== undefined) {
101
+ if (typeof next.metadata.id !== 'string' || !/^[\p{L}\p{N}][\p{L}\p{N}_-]{0,100}$/u.test(next.metadata.id)) fail('ID', 'id 仅使用字母、数字、下划线或连字符,最多 101 字符');
102
+ if (documents.some((document) => document.metadata.id === next.metadata.id)) fail('ID_EXISTS', '事件 ID 已被其他原件使用,不覆盖或合并事件');
103
+ }
104
+ if (payload(next.metadata, next.body) === payload(old.metadata, old.body)) return { status: 'unchanged', path: relative, sha256: before.sha256, sourceSaved: false };
105
+ next.metadata.updated_at = now();
106
+ return afterWrite(files.replace(relative, renderDocument(next.metadata, next.body), expectedHash));
107
+ });
108
+ }
109
+ function remove(relative, expectedHash) { owned(relative); return files.locked(() => afterWrite(files.remove(relative, expectedHash))); }
110
+ function query(text = '', settings = {}) {
111
+ if (typeof text !== 'string') fail('ARGUMENT', 'text 必须是字符串');
112
+ let from = -Infinity; let until = Infinity;
113
+ if (settings.from) { from = eventTime(settings.from); if (from === null) fail('DATE', 'from 需要确定时间'); }
114
+ if (settings.until) { until = eventTime(settings.until); if (until === null) fail('DATE', 'until 需要确定时间'); if (settings.until.length === 10) until += 86399999; }
115
+ if (from > until) fail('DATE', 'from 不能晚于 until');
116
+ const result = scan(settings); const needle = text.toLowerCase(); const findings = []; let undated = 0;
117
+ const matches = result.documents.filter((document) => {
118
+ if (settings.scope && document.metadata.scope !== settings.scope) return false;
119
+ if (needle && !document.content.toLowerCase().includes(needle)) return false;
120
+ let timestamp;
121
+ try { timestamp = eventTime(document.metadata.occurred_at); }
122
+ catch (error) { findings.push(`${document.path}: ${error.message}`); timestamp = null; }
123
+ if (timestamp === null) { undated += 1; return settings.includeUndated || (!settings.from && !settings.until); }
124
+ const end = timestamp + (document.metadata.occurred_at.length === 10 ? 86399999 : 0);
125
+ return end >= from && timestamp <= until;
126
+ }).sort(compareEvents);
127
+ const entries = matches.slice(0, settings.limit ?? 10).map((document) => ({ path: document.path, title: document.title, id: document.metadata.id ?? null, event_key: document.metadata.event_key ?? null, scope: document.metadata.scope ?? 'unknown', status: document.metadata.status ?? 'unknown', occurred_at: document.metadata.occurred_at ?? 'unknown', recorded_at: document.metadata.recorded_at ?? null, sources: document.metadata.sources ?? [], sha256: document.sha256, snippet: document.body.slice(0, 200).replaceAll('\n', ' ') }));
128
+ return { entries, matches: matches.length, complete: result.complete, truncated: entries.length < matches.length || !result.complete, scanned: result.scanned, areas: result.areas, excluded: result.excluded, undated, range: { from: settings.from ?? null, until: settings.until ?? null }, warnings: [...result.warnings, ...findings], basis: '按正文的 occurred_at 检索;目录、mtime 和 recorded_at 不替代事件时间;不是当前任务状态或原生 resume' };
129
+ }
130
+ return { read, record, update, remove, query, index: (settings) => files.locked(() => buildIndex(settings)) };
131
+ }
132
+
133
+ const help = `Home 历史工具(Node.js 22.14+)
134
+ record --home ROOT --input FILE|-
135
+ read --home ROOT --path history/YYYY/MM/ID.md
136
+ update --home ROOT --path history/YYYY/MM/ID.md --input FILE|- --expect SHA256
137
+ remove --home ROOT --path history/YYYY/MM/ID.md --expect SHA256
138
+ query --home ROOT [--text TEXT] [--from DATE] [--until DATE] [--scope SCOPE]
139
+ [--include-archive] [--include-undated] [--limit 10]
140
+ index --home ROOT [--budget 6000]
141
+ query/index 可加 --max-files 2000 --max-bytes 8388608。日期边界为 UTC,带时区时间保留其偏移语义。
142
+ 事件输入需 event_key、scope、sources、occurred_at、status;时间未知用 unknown。
143
+ 重导依 scope + event_key 去重,修改用 read 返回的 SHA-256;不解析 CLI 原生 transcript。
144
+ partial 表示正文已保存、索引待修,退出码为 2。remove 不宣称完成跨 owner 遗忘。
145
+ `;
146
+ function inputText(filename) {
147
+ if (filename !== '-') {
148
+ if (!filename) fail('ARGUMENT', '需要 --input FILE 或 -');
149
+ if (fs.statSync(filename).size > 524288) fail('LIMIT', '输入超过 524288 字节');
150
+ return fs.readFileSync(filename, 'utf8');
151
+ }
152
+ const chunks = []; let size = 0; const buffer = Buffer.alloc(8192);
153
+ for (;;) { const count = fs.readSync(0, buffer, 0, buffer.length, null); if (!count) break; size += count; if (size > 524288) fail('LIMIT', '输入超过 524288 字节'); chunks.push(Buffer.from(buffer.subarray(0, count))); }
154
+ return Buffer.concat(chunks).toString('utf8');
155
+ }
156
+ export function main(argv = process.argv.slice(2)) {
157
+ if (!argv.length || ['--help', 'help'].includes(argv[0])) { process.stdout.write(help); return 0; }
158
+ try {
159
+ const { command, options } = argumentsMap(argv);
160
+ const allowed = new Set(['home', 'path', 'input', 'expect', 'scope', 'text', 'from', 'until', 'include-archive', 'include-undated', 'limit', 'budget', 'max-files', 'max-bytes']);
161
+ for (const key of Object.keys(options)) if (!allowed.has(key)) fail('ARGUMENT', `不支持参数:--${key}`);
162
+ const tool = createHistory(options.home);
163
+ const settings = { scope: options.scope, from: options.from, until: options.until, includeArchive: options['include-archive'], includeUndated: options['include-undated'], limit: integer(options.limit, 10, 1000), budget: integer(options.budget, 6000, 50000), maxFiles: integer(options['max-files'], 2000), maxBytes: integer(options['max-bytes'], 8388608, 67108864) };
164
+ if (settings.budget < 512) fail('ARGUMENT', '索引预算至少 512 字符');
165
+ let result;
166
+ if (command === 'record') result = tool.record(inputText(options.input));
167
+ else if (command === 'read') result = tool.read(options.path);
168
+ else if (command === 'update') result = tool.update(options.path, inputText(options.input), options.expect);
169
+ else if (command === 'remove') result = tool.remove(options.path, options.expect);
170
+ else if (command === 'query') result = tool.query(options.text ?? '', settings);
171
+ else if (command === 'index') result = tool.index(settings);
172
+ else fail('ARGUMENT', `未知命令:${command}`);
173
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`); return result.status === 'partial' ? 2 : 0;
174
+ } catch (error) {
175
+ process.stderr.write(`${JSON.stringify({ error: error.code ?? 'IO', message: error.message, existingPath: error.existingPath, sourceSaved: error.sourceSaved ?? false })}\n`); return 1;
176
+ }
177
+ }
178
+ function isDirectInvocation() {
179
+ if (!process.argv[1]) return false;
180
+ try { return fs.realpathSync.native(process.argv[1]) === fs.realpathSync.native(fileURLToPath(import.meta.url)); }
181
+ catch { return false; }
182
+ }
183
+
184
+ if (isDirectInvocation()) process.exitCode = main();
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: home-integrate
3
+ description: 为跨项目工作定义共同验收条件、选定实际联调执行者,并核对 checkout、版本、依赖产物、环境与验证证据形成组合结论。用于“联合验证 A 和 B”“确认改动一起可用”“核对新包是否真的被消费”;项目内部实现和测试由当地 Agent 执行,不把各项目分别完成当成联合通过,不重建发布系统。
4
+ ---
5
+
6
+ # 跨项目联合验收
7
+
8
+ 交付针对真实组合的通过、失败、部分完成或受阻结论,以及项目内原始证据引用。Home 定义和核对组合条件;实际联调由用户指定或任务中明确选定的项目 Agent/已有集成测试项目执行。
9
+
10
+ ## 执行
11
+
12
+ 先读[组合验证方法](references/integration.md),采用[组合验收模板](assets/integration.md)补齐已有权威任务,不强制新建中心测试仓库。
13
+
14
+ 1. 明确用户可观察的共同目标、参与 repo ID、影响关系和完成条件。关系不清交 `home-map`,实际位置交 `home-route`,项目内部调查交当地 Agent。
15
+ 2. 指定一个实际联调执行者、交付顺序、所需输入和最终证据位置。执行者按自己项目规则工作,必要协作通过各项目直接负责人;Home 不直接接管所有服务。
16
+ 3. 核对每个项目的实际 checkout、HEAD、dirty 和被验证产物,记录包来源/锁文件/依赖解析、环境、服务身份及就绪证据。信息来自项目报告,Home 不扫描原件建立镜像。
17
+ 4. 将组合目标和已有资料交 `home-workflow`,按用户选择的当地派遣方法调用实际执行者;无须要求项目使用 dev 或固定 CLI。
18
+ 5. 比较执行结果与验收目标,检查实际使用新产物、关键输入输出、绑定版本及范围。mock、缺环境、外部服务未接入和未覆盖路径分别说明。
19
+ 6. 失败按最小证据交有关直接 owner 修订;影响组合的变化发生后复验有关范围。最终 Home 只保存组合摘要与引用,原始日志、测试与项目报告留实际执行项目。
20
+
21
+ ## 完成条件
22
+
23
+ 项目分别报告完成不替代联合验收;dirty 通过只能称相应本地工作状态通过,不能凭一个 SHA 宣称完全复现。无法验证的条件标未知或受阻。项目发布、回滚与内部交付继续归当地方法,多仓提交和发布不被描述为原子事务。
@@ -0,0 +1,25 @@
1
+ # <组合验收目标>
2
+
3
+ 权威任务/规格、共同目标、完成条件、实际执行者与更新时间:
4
+
5
+ ## 组合与输入
6
+
7
+ | repo ID / 项目负责人 | 实际 checkout | HEAD / dirty / 被测产物 | 依赖来源与锁定信息 | 交付/先决条件 |
8
+ | --- | --- | --- | --- | --- |
9
+
10
+ 环境、服务身份、就绪依据、共享资源 owner 和必要权限范围:
11
+
12
+ ## 验证结果
13
+
14
+ | 验收条件 | 实际操作与关键输入输出 | 执行项目内证据引用 | 结论与时间 | mock/未覆盖/限制 |
15
+ | --- | --- | --- | --- | --- |
16
+
17
+ ## 组合结论
18
+
19
+ 通过、失败、部分完成、受阻或未执行;说明绑定版本与实际工作状态。项目各自通过不等于本组合通过,dirty 证据不等于单 SHA 可完全复现。
20
+
21
+ ## 变化、复验与下一 owner
22
+
23
+ 影响结论的后续变化、需复验范围、相关项目负责人、未完成条件:
24
+
25
+ 原始验证材料留实际执行项目,Home 只保留本摘要和引用。发布/回滚沿当地方法,不从本报告推导多仓原子发布。
@@ -0,0 +1,59 @@
1
+ # 组合验证方法
2
+
3
+ ## 确定真正要验证的组合
4
+
5
+ 从用户目标和 `home-map` 已核实的关系取得生产者、消费者、契约 owner 与受影响条件。若目标只是单项目测试,让当地项目方法完成;若需要证明 A 的输出被 B 正确消费,就不能以 A、B 各自测试通过替代。
6
+
7
+ 先复用已有跨项目任务、规格和验收位置;需要新增摘要时使用[组合验收模板](../assets/integration.md)补在有关 coordination 中。它描述本次组合结果,不建立会话、发布或原始日志第二真源。
8
+
9
+ ## 明确执行者和先决条件
10
+
11
+ 1. 用户可指定其中一个项目 Agent 或已有集成测试项目负责真实联调。没有执行者且现有授权不能合理确定时,只问这一具体缺口;不为图形完整另建中心仓库。
12
+ 2. 规定共同功能/契约、真实关键操作、输入、预期输出与失败判据;保留已有规格和用户认可范围。不要只写“跑完所有测试”。
13
+ 3. 说明生产者交付物、消费者接入条件、环境/账号/服务前提、测试数据及权限范围。角色名称不绑定厂商,执行工具由项目当地有效规则决定。
14
+ 4. 由 `home-route` 定位准确 checkout;通过 `home-workflow` 的普通项目任务交执行者,要求按当地 AGENTS、永久知识和所需 SKILL 处理,并把原始证据留本项目。
15
+ 5. 同一资源池的容量只引用其现有 owner。临时服务和测试进程的启动、停止、恢复归执行项目已有方法,不由 Home 建新调度器。
16
+
17
+ ## 取得足够的组合证据
18
+
19
+ 以下是项目/联调报告需要回答的信息,不是强制项目接收 schema;已有报告可以直接引用。
20
+
21
+ | 信息 | 为什么需要 |
22
+ | --- | --- |
23
+ | 准确 repo ID、实际 checkout、HEAD、dirty | 确认实现与验证针对同一工作状态 |
24
+ | 实际被测文件/构建产物身份 | dirty 或构建结果可能不由 HEAD 单独表示 |
25
+ | 包声明、锁文件、解析来源、构建/发布物版本 | 排除消费者仍读旧包、旧缓存或另一 checkout |
26
+ | 相关运行配置与实际环境 | 同一代码在不同环境可能使用不同服务 |
27
+ | 服务身份、连接目标与就绪证据 | 进程存在或旧服务可达不证明目标实例就绪 |
28
+ | 实际命令/操作、关键输入输出、退出与观察结果 | 让结论能被复查,而不只有“通过”自报 |
29
+ | 项目内原始报告、日志、测试与截图位置 | Home 保存引用,原件由执行者负责 |
30
+ | mock、跳过条件、外部缺项和未覆盖路径 | 限定通过范围,避免模拟冒充真实运行 |
31
+ | commit/PR 与测试时间 | 连接项目交付和这次证据;后续更改需再判断 |
32
+
33
+ 需要读取代码、日志或环境证据时,仍交实际项目/联调执行者核对。Home 可对比报告、引用、版本和结论,不直接重新扫描项目并维护镜像。
34
+
35
+ ## 执行与判断
36
+
37
+ 按实际依赖顺序准备产物和环境。允许用户已授权的独立准备工作并行,但不能在关键输入未就绪时把跳过测试写成通过。
38
+
39
+ 执行者先确认消费者实际使用目标产物,再完成至少覆盖共同功能/契约的关键操作;其他项目方法和必要测试由当地选择。若使用 mock、手工替代、只做静态检查或未接真实外部系统,单独标明,不扩大成完整端到端通过。
40
+
41
+ | 状态 | 报告条件 |
42
+ | --- | --- |
43
+ | 通过 | 所定义组合与关键条件有真实证据,明确绑定版本/工作状态和范围 |
44
+ | 失败 | 已实际执行并观察到不满足条件;给最小可复查证据与相关 owner |
45
+ | 部分完成 | 一些独立条件已验证,其他条件未满足;分别列出 |
46
+ | 受阻 | 必要输入/环境/权限缺失,无法执行有关验证 |
47
+ | 未执行/未知 | 没有足够运行证据,不以推断补通过 |
48
+
49
+ dirty 工作区可验证,但应报告“本地工作状态通过”,附实际变更/产物证据与限制。HEAD 是参考,不代表整个测试对象已经提交或可从一个 SHA 完全复现。
50
+
51
+ ## 失败、复验和交付
52
+
53
+ 失败先交直接负责人,保留实际组合、失败输入、关键输出和原证据位置。区分契约不一致、消费旧产物、环境/服务问题与实现缺陷,再由当地 owner 选择修复方法;Home 不越级重启子 Agent 或修改各项目发布设置。
54
+
55
+ 变化影响被验证的契约、产物、环境或服务身份时,要求执行者复验相应范围,并明确新证据覆盖旧结论的哪一部分。早期 review 或旧包测试不能覆盖后来修改;不相关的 HEAD 变化也不自动抹掉全部证据。
56
+
57
+ 交付组合结论、依据、未覆盖项、下一 owner 和项目报告引用。有价值的联合事件交 `home-history`;长期协调经验交 `home-knowledge`,当前关系变更交 `home-map`。原始测试材料与项目内知识不迁移到 Home。
58
+
59
+ 多仓提交/发布没有自动原子性。需要发布、回滚或分阶段兼容策略时,交当地负责方法按已授权要求处理;不因联调通过自动对外发布,也不由 Home 再造统一发布引擎。