@adamchanadam/agent-handoff-kit 0.1.5 → 0.1.6

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.1.5` 已正式發佈到 GitHub 與 npm。這是早期可用版本,尚未宣稱所有需求已完成。
3
+ 狀態:`v0.1.6` 已正式發佈到 GitHub 與 npm。這是早期可用版本,尚未宣稱所有需求已完成。
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
 
@@ -201,7 +201,7 @@ GitHub Pages 上的新手介紹頁 `agent-handoff-kit-intro.html` 由原始碼
201
201
 
202
202
  ## 目前限制
203
203
 
204
- - `v0.1.5` 是 GitHub 與 npm 同步發佈版本。
204
+ - `v0.1.6` 是 GitHub 與 npm 同步發佈版本。
205
205
  - 這是早期可用版本,尚未宣稱完整穩定。
206
206
  - 升級合併仍是窄範圍策略,不是完整的複雜合併工具。
207
207
  - `doctor` 能檢查結構,不能代替 AI 對專案內容的理解。
@@ -162,6 +162,24 @@ const requiredAnchors = [
162
162
  ];
163
163
 
164
164
  const schemaChecks = [
165
+ {
166
+ target: "AGENTS.md",
167
+ label: "core runtime uniqueness",
168
+ checks: [
169
+ {
170
+ label: "exactly one Agent Handoff Kit Core Runtime heading",
171
+ test: (text) => countOccurrences(text, "# Agent Handoff Kit Core Runtime") === 1
172
+ },
173
+ {
174
+ label: "managed core markers are paired and not duplicated",
175
+ test: (text) => {
176
+ const starts = countOccurrences(text, managedCoreStart);
177
+ const ends = countOccurrences(text, managedCoreEnd);
178
+ return starts === ends && starts <= 1;
179
+ }
180
+ }
181
+ ]
182
+ },
165
183
  {
166
184
  target: "dev/SESSION_HANDOFF.md",
167
185
  label: "handoff required sections",
@@ -594,7 +612,7 @@ function classifyExistingFile(command, sourceRel, targetRel, sourceAbs, targetAb
594
612
  return {
595
613
  ...base,
596
614
  action: "merge",
597
- reason: "append managed core while preserving existing AGENTS.md content",
615
+ reason: "replace stale Agent Handoff Kit core or add managed core while preserving existing AGENTS.md content",
598
616
  mergedText: mergeManagedBlock(targetText, sourceText)
599
617
  };
600
618
  }
@@ -608,9 +626,29 @@ function mergeManagedBlock(targetText, sourceText) {
608
626
  const block = `${managedCoreStart}\n${sourceText.trim()}\n${managedCoreEnd}`;
609
627
  const existingBlock = new RegExp(`${escapeRegExp(managedCoreStart)}[\\s\\S]*?${escapeRegExp(managedCoreEnd)}`);
610
628
  if (existingBlock.test(targetText)) return `${targetText.replace(existingBlock, block).trimEnd()}\n`;
629
+ const unmarkedCore = findUnmarkedCoreRange(targetText);
630
+ if (unmarkedCore) {
631
+ return `${targetText.slice(0, unmarkedCore.start).trimEnd()}${targetText.slice(0, unmarkedCore.start).trimEnd() ? "\n\n" : ""}${block}${targetText.slice(unmarkedCore.end).trimStart() ? `\n\n${targetText.slice(unmarkedCore.end).trimStart()}` : ""}\n`;
632
+ }
611
633
  return `${targetText.trimEnd()}\n\n${block}\n`;
612
634
  }
613
635
 
636
+ function findUnmarkedCoreRange(text) {
637
+ const start = text.indexOf("# Agent Handoff Kit Core Runtime");
638
+ if (start < 0) return null;
639
+ const terminal = "keep the core within budget.";
640
+ const terminalIndex = text.indexOf(terminal, start);
641
+ if (terminalIndex >= 0) return { start, end: terminalIndex + terminal.length };
642
+ const afterTitle = start + "# Agent Handoff Kit Core Runtime".length;
643
+ const nextTopLevel = text.slice(afterTitle).search(/\n# (?!Agent Handoff Kit Core Runtime\b)/);
644
+ if (nextTopLevel < 0) return { start, end: text.length };
645
+ return { start, end: afterTitle + nextTopLevel + 1 };
646
+ }
647
+
648
+ function countOccurrences(text, needle) {
649
+ return text.split(needle).length - 1;
650
+ }
651
+
614
652
  function escapeRegExp(text) {
615
653
  return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
616
654
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamchanadam/agent-handoff-kit",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Lightweight agent harness for project memory, handoff, and multi-session continuity.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,7 +6,7 @@ Purpose: give a stateless AI a compact map of the project before it reads or edi
6
6
 
7
7
  | Field | Value | Last verified |
8
8
  |---|---|---|
9
- | Agent Handoff Kit template version | 0.1.5 | package prototype |
9
+ | Agent Handoff Kit template version | 0.1.6 | package prototype |
10
10
  | Runtime | TBD | TBD |
11
11
  | Framework | TBD | TBD |
12
12
  | Package manager | TBD | TBD |