@adamchanadam/agent-handoff-kit 0.3.52 → 0.3.54
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/LICENSE +21 -21
- package/README.en.md +4 -4
- package/README.md +1 -1
- package/bin/agent-handoff-kit.mjs +4165 -7153
- package/bin/installed-file-contract.mjs +11 -11
- package/bin/migration-baselines/official-origin-catalog.json +381 -1
- package/bin/prompt-mirror-core.mjs +84 -84
- package/bin/upgrade-inventory.mjs +192 -463
- package/package.json +1 -1
- package/packs/agent-governance.md +103 -103
- package/packs/closeout.md +5 -5
- package/packs/coding.md +28 -28
- package/packs/integrations.md +7 -7
- package/packs/knowledge.md +1 -1
- package/packs/research.md +30 -30
- package/runtime-core/AGENTS.core.md +12 -12
- package/runtime-core/CLAUDE.md +13 -13
- package/runtime-core/DOC_SYNC_REGISTRY.md +24 -24
- package/runtime-core/GEMINI.md +17 -17
- package/runtime-core/PROJECT_DECISIONS.md +43 -43
- package/runtime-core/PROJECT_INDEX.md +5 -5
- package/runtime-core/SESSION_HANDOFF.md +1 -1
- package/runtime-core/SESSION_LOG.md +35 -35
- package/runtime-core/START_NEXT_SESSION_PROMPT.txt +1 -1
- package/bin/semantic-candidate.mjs +0 -594
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
1
|
+
import { lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
const openingSectionMarker = "<!-- ack:section:next-session-opening-message -->";
|
|
@@ -26,28 +26,28 @@ export function assessPromptMirrorRoot(root) {
|
|
|
26
26
|
return { status: "missing", ok: false, reason: "prompt copy unreadable" };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const otherTexts = collectCurrentGovernanceTexts(root, new Set([
|
|
30
|
-
path.resolve(handoffPath),
|
|
31
|
-
path.resolve(promptPath)
|
|
32
|
-
]));
|
|
33
|
-
return assessPromptMirrorTexts(handoffText, promptText, otherTexts);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function assessPromptMirrorTexts(handoffText, promptText, otherTexts = []) {
|
|
37
|
-
const markerCount = countLiteral(handoffText, openingSectionMarker);
|
|
38
|
-
const headingCount = (handoffText.match(new RegExp(openingHeadingPattern.source, "gm")) ?? []).length;
|
|
39
|
-
const contentMarkerCount = openingContentMarkers.reduce((sum, marker) => sum + countLiteral(handoffText, marker), 0);
|
|
40
|
-
const openingSection = markerCount === 1 ? handoffText.slice(handoffText.indexOf(openingSectionMarker)) : "";
|
|
41
|
-
const fenceCount = (openingSection.match(/```text[^\r\n]*(?:\r\n?|\n)[\s\S]*?(?:\r\n?|\n)```/g) ?? []).length;
|
|
42
|
-
if (markerCount !== 1 || headingCount > 1 || contentMarkerCount !== 1 || fenceCount !== 1) {
|
|
43
|
-
return {
|
|
44
|
-
status: "structure-invalid",
|
|
45
|
-
ok: false,
|
|
46
|
-
reason: `opening structure must be unique (section marker=${markerCount}, heading=${headingCount}, copy marker=${contentMarkerCount}, fenced text=${fenceCount})`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const openingMessage = extractOpeningMessage(handoffText);
|
|
29
|
+
const otherTexts = collectCurrentGovernanceTexts(root, new Set([
|
|
30
|
+
path.resolve(handoffPath),
|
|
31
|
+
path.resolve(promptPath)
|
|
32
|
+
]));
|
|
33
|
+
return assessPromptMirrorTexts(handoffText, promptText, otherTexts);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function assessPromptMirrorTexts(handoffText, promptText, otherTexts = []) {
|
|
37
|
+
const markerCount = countLiteral(handoffText, openingSectionMarker);
|
|
38
|
+
const headingCount = (handoffText.match(new RegExp(openingHeadingPattern.source, "gm")) ?? []).length;
|
|
39
|
+
const contentMarkerCount = openingContentMarkers.reduce((sum, marker) => sum + countLiteral(handoffText, marker), 0);
|
|
40
|
+
const openingSection = markerCount === 1 ? handoffText.slice(handoffText.indexOf(openingSectionMarker)) : "";
|
|
41
|
+
const fenceCount = (openingSection.match(/```text[^\r\n]*(?:\r\n?|\n)[\s\S]*?(?:\r\n?|\n)```/g) ?? []).length;
|
|
42
|
+
if (markerCount !== 1 || headingCount > 1 || contentMarkerCount !== 1 || fenceCount !== 1) {
|
|
43
|
+
return {
|
|
44
|
+
status: "structure-invalid",
|
|
45
|
+
ok: false,
|
|
46
|
+
reason: `opening structure must be unique (section marker=${markerCount}, heading=${headingCount}, copy marker=${contentMarkerCount}, fenced text=${fenceCount})`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const openingMessage = extractOpeningMessage(handoffText);
|
|
51
51
|
if (openingMessage == null) {
|
|
52
52
|
return {
|
|
53
53
|
status: "missing",
|
|
@@ -56,19 +56,19 @@ export function assessPromptMirrorTexts(handoffText, promptText, otherTexts = []
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const normalizedOpening = normalizePrompt(openingMessage);
|
|
60
|
-
const thirdCopies = otherTexts.filter(({ text }) => normalizePrompt(text).includes(normalizedOpening));
|
|
61
|
-
if (thirdCopies.length > 0) {
|
|
62
|
-
return {
|
|
63
|
-
status: "third-copy",
|
|
64
|
-
ok: false,
|
|
65
|
-
reason: `full opening message also appears in: ${thirdCopies.map(({ relative }) => relative).join(", ")}`,
|
|
66
|
-
openingMessage,
|
|
67
|
-
thirdCopies: thirdCopies.map(({ relative }) => relative)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (openingMessage === promptText) {
|
|
59
|
+
const normalizedOpening = normalizePrompt(openingMessage);
|
|
60
|
+
const thirdCopies = otherTexts.filter(({ text }) => normalizePrompt(text).includes(normalizedOpening));
|
|
61
|
+
if (thirdCopies.length > 0) {
|
|
62
|
+
return {
|
|
63
|
+
status: "third-copy",
|
|
64
|
+
ok: false,
|
|
65
|
+
reason: `full opening message also appears in: ${thirdCopies.map(({ relative }) => relative).join(", ")}`,
|
|
66
|
+
openingMessage,
|
|
67
|
+
thirdCopies: thirdCopies.map(({ relative }) => relative)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (openingMessage === promptText) {
|
|
72
72
|
return {
|
|
73
73
|
status: "match",
|
|
74
74
|
ok: true,
|
|
@@ -78,7 +78,7 @@ export function assessPromptMirrorTexts(handoffText, promptText, otherTexts = []
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const normalizedPrompt = normalizePrompt(promptText);
|
|
81
|
+
const normalizedPrompt = normalizePrompt(promptText);
|
|
82
82
|
if (normalizedOpening === normalizedPrompt) {
|
|
83
83
|
return {
|
|
84
84
|
status: "newline-only",
|
|
@@ -125,7 +125,7 @@ function findOpeningSectionStart(text) {
|
|
|
125
125
|
return headingMatch ? headingMatch.index : -1;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
function firstDiff(left, right) {
|
|
128
|
+
function firstDiff(left, right) {
|
|
129
129
|
const leftLines = left.split("\n");
|
|
130
130
|
const rightLines = right.split("\n");
|
|
131
131
|
const count = Math.max(leftLines.length, rightLines.length);
|
|
@@ -139,49 +139,49 @@ function firstDiff(left, right) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function countLiteral(text, token) {
|
|
145
|
-
if (!token) return 0;
|
|
146
|
-
let count = 0;
|
|
147
|
-
let offset = 0;
|
|
148
|
-
while ((offset = text.indexOf(token, offset)) >= 0) {
|
|
149
|
-
count += 1;
|
|
150
|
-
offset += token.length;
|
|
151
|
-
}
|
|
152
|
-
return count;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function collectCurrentGovernanceTexts(root, excluded) {
|
|
156
|
-
const candidates = [
|
|
157
|
-
"AGENTS.md",
|
|
158
|
-
"CLAUDE.md",
|
|
159
|
-
"GEMINI.md",
|
|
160
|
-
"dev/SESSION_LOG.md",
|
|
161
|
-
"dev/PROJECT_INDEX.md",
|
|
162
|
-
"dev/DOC_SYNC_REGISTRY.md",
|
|
163
|
-
"dev/RULE_PACKS.md",
|
|
164
|
-
"dev/PROJECT_DECISIONS.md"
|
|
165
|
-
];
|
|
166
|
-
const rulesDir = path.join(root, "dev", "rules");
|
|
167
|
-
try {
|
|
168
|
-
for (const entry of readdirSync(rulesDir, { withFileTypes: true })) {
|
|
169
|
-
if (entry.isFile() && entry.name.endsWith(".md")) candidates.push(`dev/rules/${entry.name}`);
|
|
170
|
-
}
|
|
171
|
-
} catch {
|
|
172
|
-
// Missing rules are reported by normal doctor checks.
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const results = [];
|
|
176
|
-
for (const relative of candidates) {
|
|
177
|
-
const absolute = path.resolve(root, relative);
|
|
178
|
-
if (excluded.has(absolute)) continue;
|
|
179
|
-
try {
|
|
180
|
-
if (lstatSync(absolute).isSymbolicLink()) continue;
|
|
181
|
-
results.push({ relative, text: readFileSync(absolute, "utf8") });
|
|
182
|
-
} catch {
|
|
183
|
-
// Missing or unreadable files are handled by their owning checks.
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return results;
|
|
187
|
-
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function countLiteral(text, token) {
|
|
145
|
+
if (!token) return 0;
|
|
146
|
+
let count = 0;
|
|
147
|
+
let offset = 0;
|
|
148
|
+
while ((offset = text.indexOf(token, offset)) >= 0) {
|
|
149
|
+
count += 1;
|
|
150
|
+
offset += token.length;
|
|
151
|
+
}
|
|
152
|
+
return count;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function collectCurrentGovernanceTexts(root, excluded) {
|
|
156
|
+
const candidates = [
|
|
157
|
+
"AGENTS.md",
|
|
158
|
+
"CLAUDE.md",
|
|
159
|
+
"GEMINI.md",
|
|
160
|
+
"dev/SESSION_LOG.md",
|
|
161
|
+
"dev/PROJECT_INDEX.md",
|
|
162
|
+
"dev/DOC_SYNC_REGISTRY.md",
|
|
163
|
+
"dev/RULE_PACKS.md",
|
|
164
|
+
"dev/PROJECT_DECISIONS.md"
|
|
165
|
+
];
|
|
166
|
+
const rulesDir = path.join(root, "dev", "rules");
|
|
167
|
+
try {
|
|
168
|
+
for (const entry of readdirSync(rulesDir, { withFileTypes: true })) {
|
|
169
|
+
if (entry.isFile() && entry.name.endsWith(".md")) candidates.push(`dev/rules/${entry.name}`);
|
|
170
|
+
}
|
|
171
|
+
} catch {
|
|
172
|
+
// Missing rules are reported by normal doctor checks.
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const results = [];
|
|
176
|
+
for (const relative of candidates) {
|
|
177
|
+
const absolute = path.resolve(root, relative);
|
|
178
|
+
if (excluded.has(absolute)) continue;
|
|
179
|
+
try {
|
|
180
|
+
if (lstatSync(absolute).isSymbolicLink()) continue;
|
|
181
|
+
results.push({ relative, text: readFileSync(absolute, "utf8") });
|
|
182
|
+
} catch {
|
|
183
|
+
// Missing or unreadable files are handled by their owning checks.
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return results;
|
|
187
|
+
}
|