@adamchanadam/agent-handoff-kit 0.3.26 → 0.3.27

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Agent Handoff Kit
2
2
 
3
- 狀態:目前版本為 `v0.3.26`。這是早期可用版本,仍在持續完善中。
3
+ 狀態:目前版本為 `v0.3.27`。這是早期可用版本,仍在持續完善中。
4
4
 
5
5
  ![Agent Handoff Kit 主視覺](https://raw.githubusercontent.com/Adamchanadam/agent-handoff-kit/main/images/agent-handoff-kit-main-visual2.png)
6
6
 
@@ -35,7 +35,7 @@ Agent Handoff Kit 是 **AI 對話之間的接力棒**。
35
35
  | 問題 | Agent Handoff Kit 怎樣處理 |
36
36
  |---|---|
37
37
  | 新 AI 不知做到哪 | 用 `dev/SESSION_HANDOFF.md` 保存目前狀態、下一步、風險與驗收。 |
38
- | 新建檔案、參考資料變孤兒 | 用 `dev/PROJECT_INDEX.md` 與 `dev/DOC_SYNC_REGISTRY.md` 登記檔案角色、真源與同步責任。 |
38
+ | 新建檔案、參考資料變孤兒 | 你可以叫 AI 做「治理打通」,用 `dev/PROJECT_INDEX.md` 與 `dev/DOC_SYNC_REGISTRY.md` 登記檔案角色、真源與同步責任。 |
39
39
  | 不同 AI 工具入口不同 | 同時安裝 `AGENTS.md`、`CLAUDE.md`、`GEMINI.md`,全部指向同一套開工流程;Antigravity CLI 會讀工作資料夾內的 `AGENTS.md` 與 `GEMINI.md`。 |
40
40
  | AI 可能亂改、亂刪或誤發佈 | 內置安全規則;高風險操作必須先講計劃,破壞性指令與未批准發佈一律禁止。 |
41
41
 
@@ -225,9 +225,37 @@ dev/rules/*.md
225
225
 
226
226
  當交接文件中的決策清單累積到三十條以上,AI 會自動把較舊的條目搬入本檔,保持交接文件簡潔。
227
227
 
228
- 新手用戶完全不需要打開本檔,也不需要記任何結構 —— 一切由 AI 自動處理。
229
-
230
- ## 外部工具治理
228
+ 新手用戶完全不需要打開本檔,也不需要記任何結構 —— 一切由 AI 自動處理。
229
+
230
+ ## 治理打通:讓重要文件不要變孤兒
231
+
232
+ 長期項目常會產生新文件,例如 stock list、production guide、runbook、workflow、checklist、研究真源或操作清單。文件本身做完,不代表下一個 AI 一定知道它存在,也不代表 AI 知道何時要讀、何時要更新、是否有另一份舊版真源。
233
+
234
+ 這時可以在 AI 對話中直接說:
235
+
236
+ ```text
237
+ 治理打通 docs/production-guide.md
238
+ ```
239
+
240
+ 英文也可以說:
241
+
242
+ ```text
243
+ bridge governance for docs/production-guide.md
244
+ connect this document to governance
245
+ ```
246
+
247
+ AI 會檢查這份文件是否已接入項目記憶:文件本身是否講清楚用途與更新時機、`dev/PROJECT_INDEX.md` 是否登記它、`dev/DOC_SYNC_REGISTRY.md` 是否記下同類變更要同步哪裡、相關 workflow 是否會提醒更新它,以及 handoff / log 是否各自放在正確角色。
248
+
249
+ 如果你不確定整個 repo 有沒有漏接的文件,可以說:
250
+
251
+ ```text
252
+ 掃描 repo 有沒有未接合文件
253
+ scan for unbridged governance documents
254
+ ```
255
+
256
+ 這個掃描只列出候選與缺口,不會自動刪除、改名或合併文件。若發現兩份文件像是同一個真源,AI 只會列出合併、引用或退役建議,等你確認。
257
+
258
+ ## 外部工具治理
231
259
 
232
260
  如你的項目涉及外部工具(例如 Notion、Google Drive、Slack、Linear、GitHub 等),Agent Handoff Kit 提供跨對話的治理紀律,確保 AI 在不同對話之間能穩定使用這些工具。
233
261
 
@@ -248,9 +276,10 @@ dev/rules/*.md
248
276
  | 寫或改代碼、檢查錯誤、執行測試 | 寫代碼規則;涉及刪除、覆寫、Git、套件管理或外部服務時,再讀安全規則 |
249
277
  | 查資料、比較來源、整理證據 | 研究規則 |
250
278
  | 改 README、寫說明、整理文案 | 寫作規則,通常再加溝通規則 |
251
- | 整理 Notion、Google Drive 或知識庫 | 知識整理規則 |
252
- | 準備發佈說明 | 發佈規則;真正發佈、上傳或建立版本前必須再讀安全規則 |
253
- | 改規則、改流程、整理交接 | AI 治理規則;先找既有真源,不盲目新增規則 |
279
+ | 整理 Notion、Google Drive 或知識庫 | 知識整理規則 |
280
+ | 準備發佈說明 | 發佈規則;真正發佈、上傳或建立版本前必須再讀安全規則 |
281
+ | 改規則、改流程、整理交接 | AI 治理規則;先找既有真源,不盲目新增規則 |
282
+ | 新建重要文件後想避免變孤兒 | AI 治理規則;說「治理打通 <檔案>」,讓 AI 檢查索引、同步責任、相關流程與重複真源風險 |
254
283
 
255
284
  原則是只讀當前任務需要的規則,不是每次讀全部文件。
256
285
 
@@ -285,7 +314,7 @@ Agent Handoff Kit 可與 [Adam-AI-Instructions](https://github.com/prompt-templa
285
314
 
286
315
  ## 目前限制
287
316
 
288
- - 目前版本為 `v0.3.26`;正式安裝請以 npm registry `latest` 顯示為準。
317
+ - 目前版本為 `v0.3.27`;正式安裝請以 npm registry `latest` 顯示為準。
289
318
  - 這是早期可用版本,仍在持續完善中。
290
319
  - 升級合併屬窄範圍策略,不是完整的複雜合併工具。
291
320
  - `doctor` 能檢查結構,不能代替 AI 對專案內容的理解。
@@ -363,11 +363,11 @@ const schemaChecks = [
363
363
  tableHeader("Change type", "Also check/update", "Verification")
364
364
  ]
365
365
  },
366
- {
367
- target: "dev/RULE_PACKS.md",
368
- label: "rule pack router coverage",
369
- checks: [
370
- heading("Routing Rule"),
366
+ {
367
+ target: "dev/RULE_PACKS.md",
368
+ label: "rule pack router coverage",
369
+ checks: [
370
+ heading("Routing Rule"),
371
371
  includes("Load the minimum set"),
372
372
  includes("cannot weaken core safety"),
373
373
  includes("dev/rules/safety.md"),
@@ -379,10 +379,27 @@ const schemaChecks = [
379
379
  // stale routing table that does not route onboarding signals.
380
380
  includes("First-time user signals"),
381
381
  includes("dev/rules/onboarding.md"),
382
- // R-030 v0.3.0+: routing table must include integrations pack row.
383
- includes("dev/rules/integrations.md")
384
- ]
385
- },
382
+ // R-030 v0.3.0+: routing table must include integrations pack row.
383
+ includes("dev/rules/integrations.md"),
384
+ includes("Governance bridge / 治理打通"),
385
+ includes("scan for unbridged governance documents")
386
+ ]
387
+ },
388
+ {
389
+ target: "dev/rules/agent-governance.md",
390
+ label: "agent governance pack structure",
391
+ checks: [
392
+ heading("Scope"),
393
+ heading("Load When"),
394
+ heading("Rules"),
395
+ heading("Governance Bridge Workflow"),
396
+ heading("Checks"),
397
+ heading("Closeout"),
398
+ includes("Governance bridge is a triggered review"),
399
+ includes("Status: bridged / partially bridged / unbridged / blocked"),
400
+ includes("duplicate source-of-truth risk")
401
+ ]
402
+ },
386
403
  {
387
404
  target: "dev/PROJECT_DECISIONS.md",
388
405
  label: "project decisions log structure",
@@ -1545,18 +1562,46 @@ function classifyExistingFile(command, sourceRel, targetRel, sourceAbs, targetAb
1545
1562
  };
1546
1563
  }
1547
1564
  // R-030 v0.3.0+: dev/RULE_PACKS.md must also include integrations pack routing row.
1548
- if (targetRel === "dev/RULE_PACKS.md" && command === "upgrade" && !targetText.includes("External tool integrations")) {
1549
- const mergedRulePacks = mergeRulePacksRows(targetText, sourceText);
1550
- if (!mergedRulePacks) {
1551
- return { ...base, action: "conflict", reason: "RULE_PACKS.md routing table header was changed; manual merge required to preserve custom rows" };
1565
+ if (targetRel === "dev/RULE_PACKS.md" && command === "upgrade" && !targetText.includes("External tool integrations")) {
1566
+ const mergedRulePacks = mergeRulePacksRows(targetText, sourceText);
1567
+ if (!mergedRulePacks) {
1568
+ return { ...base, action: "conflict", reason: "RULE_PACKS.md routing table header was changed; manual merge required to preserve custom rows" };
1552
1569
  }
1553
1570
  return {
1554
1571
  ...base,
1555
1572
  action: "merge",
1556
1573
  reason: "merge missing v0.3.0+ routing rows while preserving existing custom rows (Integration governance routing)",
1557
- mergedText: mergedRulePacks
1558
- };
1559
- }
1574
+ mergedText: mergedRulePacks
1575
+ };
1576
+ }
1577
+ // Governance bridge v0.3.27+: route durable document bridging requests to
1578
+ // agent-governance without replacing user-added routing rows.
1579
+ if (targetRel === "dev/RULE_PACKS.md" && command === "upgrade" && !targetText.includes("Governance bridge / 治理打通")) {
1580
+ const mergedRulePacks = mergeRulePacksRows(targetText, sourceText);
1581
+ if (!mergedRulePacks) {
1582
+ return { ...base, action: "conflict", reason: "RULE_PACKS.md routing table header was changed; manual merge required to preserve custom rows" };
1583
+ }
1584
+ return {
1585
+ ...base,
1586
+ action: "merge",
1587
+ reason: "merge missing governance bridge routing row while preserving existing custom rows",
1588
+ mergedText: mergedRulePacks
1589
+ };
1590
+ }
1591
+ // Governance bridge v0.3.27+: add the triggered review workflow to the
1592
+ // agent-governance pack only when the pack still has a trusted Checks section.
1593
+ if (targetRel === "dev/rules/agent-governance.md" && command === "upgrade" && !targetText.includes("## Governance Bridge Workflow")) {
1594
+ const mergedGovernancePack = mergeAgentGovernanceBridgeWorkflow(targetText, sourceText);
1595
+ if (!mergedGovernancePack) {
1596
+ return { ...base, action: "conflict", reason: "agent-governance pack structure was changed; manual merge required to add governance bridge workflow" };
1597
+ }
1598
+ return {
1599
+ ...base,
1600
+ action: "merge",
1601
+ reason: "insert governance bridge workflow into agent-governance pack without replacing local additions",
1602
+ mergedText: mergedGovernancePack
1603
+ };
1604
+ }
1560
1605
  // R-030 v0.3.0+: dev/PROJECT_INDEX.md gets ## Installed Integrations section auto-inserted before
1561
1606
  // ## Local QC Commands on upgrade if missing. NON-DESTRUCTIVE: existing ## External Sources content
1562
1607
  // is fully preserved (including any user-filled rows). User can later manually add the `via` column
@@ -1729,7 +1774,7 @@ function isUpgradeFromOlderTemplate(context) {
1729
1774
  && compareSemver(rootTemplateVersion, currentVersion) < 0;
1730
1775
  }
1731
1776
 
1732
- function looksLikeExpandedKitBridge(targetRel, text) {
1777
+ function looksLikeExpandedKitBridge(targetRel, text) {
1733
1778
  if (text.includes("This file is a bridge only")) return false;
1734
1779
  if (targetRel === "CLAUDE.md") {
1735
1780
  return (text.includes("This file provides guidance to Claude Code") && text.includes("## Session Startup"))
@@ -1758,6 +1803,25 @@ function mergeOnboardingScenarioALabel(targetText) {
1758
1803
  return merged;
1759
1804
  }
1760
1805
 
1806
+ function mergeAgentGovernanceBridgeWorkflow(targetText, sourceText) {
1807
+ const sourceMatch = sourceText.match(/9\. Governance bridge[\s\S]*?(?=\n## Checks)/);
1808
+ const workflowMatch = sourceText.match(/\n## Governance Bridge Workflow[\s\S]*?(?=\n## Checks)/);
1809
+ if (!sourceMatch || !workflowMatch || !targetText.includes("\n## Checks")) return null;
1810
+
1811
+ let merged = targetText;
1812
+ if (!merged.includes("Governance bridge is a triggered review")) {
1813
+ const rulePrefix = sourceMatch[0].trimEnd();
1814
+ merged = merged.replace(/\n## Checks/, `\n${rulePrefix}\n${workflowMatch[0]}\n## Checks`);
1815
+ }
1816
+ if (!merged.includes("For governance bridge work, confirm the target file")) {
1817
+ merged = merged.replace(
1818
+ "- Confirm reusable operating procedure knowledge is not stored only in `dev/SESSION_HANDOFF.md`, `dev/SESSION_LOG.md`, or a decision narrative when it belongs in a pack or registered reference.",
1819
+ "- Confirm reusable operating procedure knowledge is not stored only in `dev/SESSION_HANDOFF.md`, `dev/SESSION_LOG.md`, or a decision narrative when it belongs in a pack or registered reference.\n- For governance bridge work, confirm the target file, project index, sync registry, related workflow, handoff/log role split, and duplicate-source risk were all checked or explicitly marked not applicable."
1820
+ );
1821
+ }
1822
+ return merged;
1823
+ }
1824
+
1761
1825
  function hasTrustedOnboardingScenarioLibrary(text) {
1762
1826
  const bounds = textSectionBounds(text, "## Application Scenario Library", "## Cross-reference to guide.html");
1763
1827
  if (!bounds) return false;
@@ -2371,8 +2435,9 @@ function mergeHandoffArchiveContinuityRule(targetText, sourceText) {
2371
2435
  function mergeRulePacksRows(targetText, sourceText) {
2372
2436
  const requiredPacks = [
2373
2437
  "dev/rules/onboarding.md",
2374
- "dev/rules/integrations.md"
2375
- ];
2438
+ "dev/rules/integrations.md",
2439
+ "dev/rules/agent-governance.md"
2440
+ ];
2376
2441
  const sourceRows = sourceText
2377
2442
  .split(/\r?\n/)
2378
2443
  .filter((line) => line.startsWith("|") && requiredPacks.some((pack) => line.includes(pack)));
@@ -2389,10 +2454,11 @@ function mergeRulePacksRows(targetText, sourceText) {
2389
2454
  const table = lines.slice(tableStart, tableEnd);
2390
2455
  const after = lines.slice(tableEnd);
2391
2456
  const sourceRowsToApply = sourceRows.filter((row) => {
2392
- if (row.includes("dev/rules/onboarding.md")) return !targetText.includes("First-time user signals");
2393
- if (row.includes("dev/rules/integrations.md")) return !targetText.includes("External tool integrations");
2394
- return false;
2395
- });
2457
+ if (row.includes("dev/rules/onboarding.md")) return !targetText.includes("First-time user signals");
2458
+ if (row.includes("dev/rules/integrations.md")) return !targetText.includes("External tool integrations");
2459
+ if (row.includes("Governance bridge / 治理打通")) return !targetText.includes("Governance bridge / 治理打通");
2460
+ return false;
2461
+ });
2396
2462
  if (sourceRowsToApply.length === 0) return targetText;
2397
2463
 
2398
2464
  const merged = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamchanadam/agent-handoff-kit",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Lightweight agent harness for project memory, handoff, and multi-session continuity.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@ Use for governance rules, prompts, agent instructions, handoff systems, startup/
8
8
 
9
9
  - User asks to change AI behavior, project governance, prompts, handoff, startup, closeout, or tool-use rules.
10
10
  - A change affects `AGENTS.md`, `dev/*`, rule packs, installer templates, or durable workflow docs.
11
+ - User asks to "治理打通", "bridge governance", "connect this document to governance", or scan for unbridged governance documents.
11
12
 
12
13
  ## Rules
13
14
 
@@ -19,6 +20,31 @@ Use for governance rules, prompts, agent instructions, handoff systems, startup/
19
20
  6. Before creating durable workflow, runbook, or instruction files, first classify the knowledge type and verify whether an existing home can carry it without a new file: current state belongs in `dev/SESSION_HANDOFF.md`; trace evidence belongs in `dev/SESSION_LOG.md`; file / command / reference maps belong in `dev/PROJECT_INDEX.md`; sync obligations belong in `dev/DOC_SYNC_REGISTRY.md`; reusable operating procedures belong in the relevant rule pack or registered reference. New runbooks are last resort only.
20
21
  7. When a task uses external skills, subagents, demo workspaces, or another tool's closeout, treat those flows as subordinate to the active root's Agent Handoff Kit governance. The active root still needs the `runtime-core/AGENTS.core.md` persistence gate decision; do not duplicate the gate thresholds in this pack.
21
22
  8. For long-running projects, maintain `dev/PROJECT_DECISIONS.md` per R-028 closeout discipline (see `runtime-core/AGENTS.core.md` closeout maintenance trigger check): capture major decisions when they happen, run the short trigger check at every closeout, and do full long-term maintenance only when a hard trigger, semantic trigger, or 10-closeout backstop applies. Short single-task projects keep this as a no-op default; users are not expected to edit this file manually.
23
+ 9. Governance bridge is a triggered review, not a default startup scan. Use it when an important file, source-of-truth document, runbook, production guide, workflow, checklist, stock list, or similar durable document may need to be connected to project governance.
24
+
25
+ ## Governance Bridge Workflow
26
+
27
+ Use this workflow when the user asks for governance bridge / 治理打通 / connect this document to governance, or asks to scan for unbridged governance documents.
28
+
29
+ 1. Identify the target. If the user named a file, inspect that file and its surrounding directory. If no file is named, run a bounded repo scan for likely durable documents such as source-of-truth files, runbooks, workflows, guides, checklists, stock lists, production guides, and rules.
30
+ 2. Check the target file itself: it should state its role, scope, update trigger, owner or responsible workflow when known, and what must not be inferred from it.
31
+ 3. Check `dev/PROJECT_INDEX.md`: the file should be discoverable with its role and "read when" condition. Source-of-truth or reference files should appear in Fact Base, External Sources, Directory Map, Entry Points, or another existing indexed home that fits the project.
32
+ 4. Check `dev/DOC_SYNC_REGISTRY.md`: future same-type changes should have a matching change type or an explicit reason no durable sync rule is needed.
33
+ 5. Check related workflows, guides, runbooks, or rule packs: if a process creates or updates the file, that process should say when to update the file or its index row.
34
+ 6. Check `dev/SESSION_HANDOFF.md`: only current state, next action, unresolved risk, blocker, or a startup-needed fact should be in handoff. Do not copy whole documents or old evidence into handoff.
35
+ 7. Check `dev/SESSION_LOG.md`: this session's bridge review, validation, and evidence can be logged when it affects future action, but log entries must not become current state.
36
+ 8. Search for duplicate source-of-truth risk. If another file has the same durable role, recommend merge, reference, or retire options; do not delete, rename, or move files without explicit approval.
37
+
38
+ For repo-wide scans, report candidates as candidates. Do not fail ordinary docs merely because they are not indexed; only durable files that future agents need to discover, update, or distinguish from drafts should be bridged.
39
+
40
+ Output format:
41
+
42
+ - Status: bridged / partially bridged / unbridged / blocked.
43
+ - Already bridged: list the governance links that are present.
44
+ - Gaps: list missing links and why they matter for the next agent.
45
+ - Suggested patches: list exact files and sections to update.
46
+ - Manual decisions: list duplicates, naming choices, deletion, renaming, external sync, or ownership questions requiring user confirmation.
47
+ - Acceptance: give one concrete check that proves the bridge is complete.
22
48
 
23
49
  ## Checks
24
50
 
@@ -27,6 +53,7 @@ Use for governance rules, prompts, agent instructions, handoff systems, startup/
27
53
  - Confirm old overlapping wording was retired or marked legacy.
28
54
  - Confirm any new durable file is reachable from `dev/PROJECT_INDEX.md` and does not rely only on a one-session handoff note.
29
55
  - Confirm reusable operating procedure knowledge is not stored only in `dev/SESSION_HANDOFF.md`, `dev/SESSION_LOG.md`, or a decision narrative when it belongs in a pack or registered reference.
56
+ - For governance bridge work, confirm the target file, project index, sync registry, related workflow, handoff/log role split, and duplicate-source risk were all checked or explicitly marked not applicable.
30
57
  - Before claiming completion, apply the active root's core persistence gate and record the result only when that gate selects a checkpoint or full closeout; do not assume child or demo workspaces cover the parent/root workspace.
31
58
  - For long-running projects, confirm `dev/PROJECT_DECISIONS.md` retains its four H2 sections in order (Evolution Timeline / Decisions Archive / Architecture Choices / Insights & Learnings) and that the closeout maintenance trigger check was recorded, with full maintenance applied where its trigger conditions were met.
32
59
 
@@ -9,7 +9,8 @@ Read only the packs needed for the current task.
9
9
  | Code, tests, build, package manager, SDK, CLI, API | `dev/rules/coding.md` | development workflow and verification |
10
10
  | Draft, edit, style, publication content | `dev/rules/writing.md` | writing workflow and tone control |
11
11
  | Sources, evidence, comparison, fact finding | `dev/rules/research.md` | source handling and uncertainty |
12
- | Governance, prompts, agents, handoff, startup/closeout, skills | `dev/rules/agent-governance.md` | governance changes and boundary control |
12
+ | Governance, prompts, agents, handoff, startup/closeout, skills | `dev/rules/agent-governance.md` | governance changes and boundary control |
13
+ | Governance bridge / 治理打通 / bridge governance / connect this document to governance / scan for unbridged governance documents | `dev/rules/agent-governance.md` | connect important files, source-of-truth documents, runbooks, workflows, checklists, and guides to the project index, sync registry, handoff/log roles, and related workflows without creating duplicate sources of truth |
13
14
  | Release, publish, deploy, tag, hotfix, GA | `dev/rules/release.md` | release verification and evidence |
14
15
  | External notes, knowledge base, Notion, Obsidian, Google Drive | `dev/rules/knowledge.md` | external knowledge source integration |
15
16
  | External tool integrations (Connector / MCP / Plugin / Skill) — declared in `## Installed Integrations`; tasks involving Notion / Google Drive / Slack / Linear / Dropbox / HubSpot / GitHub / etc. external read-write | `dev/rules/integrations.md` | Connector-first default + credential separation + multi-layer source-of-truth + cross-session resilience |