mancode 0.3.8 → 0.3.10
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.en.md +752 -0
- package/README.md +341 -377
- package/dist/chunk-KEIW7AEP.js +597 -0
- package/dist/chunk-KEIW7AEP.js.map +1 -0
- package/dist/chunk-O3QAKAPJ.js +7117 -0
- package/dist/chunk-O3QAKAPJ.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +41525 -7548
- package/dist/cli.js.map +1 -1
- package/dist/store-JUB2KAFT.js +9 -0
- package/dist/store-JUB2KAFT.js.map +1 -0
- package/dist/v3-adapter-3GJT3AID.js +27 -0
- package/dist/v3-adapter-3GJT3AID.js.map +1 -0
- package/package.json +4 -2
- package/README.zh-CN.md +0 -642
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
// src/installers/v3-adapter.ts
|
|
2
|
+
import {
|
|
3
|
+
lstat,
|
|
4
|
+
mkdir,
|
|
5
|
+
readFile,
|
|
6
|
+
rename,
|
|
7
|
+
rm,
|
|
8
|
+
writeFile
|
|
9
|
+
} from "fs/promises";
|
|
10
|
+
import path from "path";
|
|
11
|
+
|
|
12
|
+
// src/installers/managed-block.ts
|
|
13
|
+
var DEFAULT_MANCODE_START_MARKER = "<!-- mancode:start -->";
|
|
14
|
+
var DEFAULT_MANCODE_END_MARKER = "<!-- mancode:end -->";
|
|
15
|
+
function removeManagedBlock(existing, startMarker = DEFAULT_MANCODE_START_MARKER, endMarker = DEFAULT_MANCODE_END_MARKER) {
|
|
16
|
+
const start = findMarkerLine(existing, startMarker);
|
|
17
|
+
const end = findMarkerLine(existing, endMarker);
|
|
18
|
+
if (start === null && end === null) return existing;
|
|
19
|
+
if (start === null || end === null) return existing;
|
|
20
|
+
if (end.start < start.start) return existing;
|
|
21
|
+
const before = existing.slice(0, start.start);
|
|
22
|
+
const after = existing.slice(end.end);
|
|
23
|
+
const merged = `${before}${after}`;
|
|
24
|
+
return cleanUpOrphanedNewlines(merged);
|
|
25
|
+
}
|
|
26
|
+
function hasManagedBlock(existing, startMarker = DEFAULT_MANCODE_START_MARKER, endMarker = DEFAULT_MANCODE_END_MARKER) {
|
|
27
|
+
const start = findMarkerLine(existing, startMarker);
|
|
28
|
+
const end = findMarkerLine(existing, endMarker);
|
|
29
|
+
return start !== null && end !== null && end.start > start.start;
|
|
30
|
+
}
|
|
31
|
+
function cleanUpOrphanedNewlines(content) {
|
|
32
|
+
const trimmed = content.replace(/\n{3,}/gu, "\n\n").replace(/\n+$/u, "\n");
|
|
33
|
+
return trimmed || "";
|
|
34
|
+
}
|
|
35
|
+
function replaceManagedBlock(existing, block, startMarker = DEFAULT_MANCODE_START_MARKER, endMarker = DEFAULT_MANCODE_END_MARKER) {
|
|
36
|
+
const normalizedBlock = normalizeManagedBlock(block, startMarker, endMarker);
|
|
37
|
+
const start = findMarkerLine(existing, startMarker);
|
|
38
|
+
const end = findMarkerLine(existing, endMarker);
|
|
39
|
+
if (start === null !== (end === null)) {
|
|
40
|
+
throw new Error("managed block is malformed: missing start or end marker");
|
|
41
|
+
}
|
|
42
|
+
if (start === null && end === null) {
|
|
43
|
+
const trimmedExisting = trimTrailingNewlines(existing);
|
|
44
|
+
if (!trimmedExisting) return `${normalizedBlock}
|
|
45
|
+
`;
|
|
46
|
+
return `${trimmedExisting}
|
|
47
|
+
|
|
48
|
+
${normalizedBlock}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
if (!start || !end) {
|
|
52
|
+
throw new Error("managed block is malformed: missing start or end marker");
|
|
53
|
+
}
|
|
54
|
+
if (end.start < start.start) {
|
|
55
|
+
throw new Error("managed block is malformed: end marker precedes start");
|
|
56
|
+
}
|
|
57
|
+
return `${existing.slice(0, start.start)}${normalizedBlock}${existing.slice(
|
|
58
|
+
end.end
|
|
59
|
+
)}`;
|
|
60
|
+
}
|
|
61
|
+
function normalizeManagedBlock(block, startMarker, endMarker) {
|
|
62
|
+
const trimmedBlock = block.trim();
|
|
63
|
+
const hasStart = trimmedBlock.startsWith(startMarker);
|
|
64
|
+
const hasEnd = trimmedBlock.endsWith(endMarker);
|
|
65
|
+
if (hasStart && hasEnd) return trimmedBlock;
|
|
66
|
+
if (hasStart || hasEnd) {
|
|
67
|
+
throw new Error("managed block content includes only one marker");
|
|
68
|
+
}
|
|
69
|
+
return `${startMarker}
|
|
70
|
+
${trimmedBlock}
|
|
71
|
+
${endMarker}`;
|
|
72
|
+
}
|
|
73
|
+
function trimTrailingNewlines(value) {
|
|
74
|
+
return value.replace(/\n+$/u, "");
|
|
75
|
+
}
|
|
76
|
+
function findMarkerLine(content, marker) {
|
|
77
|
+
let offset = 0;
|
|
78
|
+
let inFence = null;
|
|
79
|
+
for (const lineWithBreak of content.matchAll(/[^\n]*(?:\n|$)/gu)) {
|
|
80
|
+
const rawLine = lineWithBreak[0];
|
|
81
|
+
if (!rawLine) break;
|
|
82
|
+
const line = rawLine.replace(/\n$/u, "").replace(/\r$/u, "");
|
|
83
|
+
const fence = line.match(/^(`{3,}|~{3,})/u)?.[1];
|
|
84
|
+
if (fence) {
|
|
85
|
+
const char = fence[0];
|
|
86
|
+
if (!inFence) {
|
|
87
|
+
inFence = { char, length: fence.length };
|
|
88
|
+
} else if (inFence.char === char && fence.length >= inFence.length) {
|
|
89
|
+
inFence = null;
|
|
90
|
+
}
|
|
91
|
+
} else if (!inFence && line === marker) {
|
|
92
|
+
return {
|
|
93
|
+
start: offset,
|
|
94
|
+
end: offset + marker.length
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
offset += rawLine.length;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/installers/v3-adapter.ts
|
|
103
|
+
var V3_ADAPTER_VERSION = "3";
|
|
104
|
+
var V3_ADAPTER_MANAGED_MARKER = "<!-- Managed by mancode:v3-adapter. Do not edit this marker. -->";
|
|
105
|
+
var V3_CODEX_START_MARKER = "<!-- mancode:v3:codex:start -->";
|
|
106
|
+
var V3_CODEX_END_MARKER = "<!-- mancode:v3:codex:end -->";
|
|
107
|
+
var V3_ZCODE_START_MARKER = "<!-- mancode:v3:zcode:start -->";
|
|
108
|
+
var V3_ZCODE_END_MARKER = "<!-- mancode:v3:zcode:end -->";
|
|
109
|
+
var V3_COPILOT_START_MARKER = "<!-- mancode:v3:copilot:start -->";
|
|
110
|
+
var V3_COPILOT_END_MARKER = "<!-- mancode:v3:copilot:end -->";
|
|
111
|
+
var RETRIABLE_ADAPTER_READ_CODES = /* @__PURE__ */ new Set(["EACCES", "EBUSY", "EPERM"]);
|
|
112
|
+
var ADAPTER_READ_MAX_ATTEMPTS = 4;
|
|
113
|
+
var ADAPTER_READ_RETRY_DELAY_MS = 25;
|
|
114
|
+
var V3_ADAPTER_FILE_TARGETS = [
|
|
115
|
+
"claude-skill",
|
|
116
|
+
"cursor-rule",
|
|
117
|
+
"agents",
|
|
118
|
+
"copilot-instructions"
|
|
119
|
+
];
|
|
120
|
+
async function planV3AdapterFiles(projectRoot) {
|
|
121
|
+
const root = path.resolve(projectRoot);
|
|
122
|
+
const existing = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const target of V3_ADAPTER_FILE_TARGETS) {
|
|
124
|
+
existing.set(target, await readAdapterTarget(root, target));
|
|
125
|
+
}
|
|
126
|
+
const agents = existing.get("agents") ?? "";
|
|
127
|
+
const nextAgents = replaceManagedV3BlockText(
|
|
128
|
+
replaceManagedV3BlockText(
|
|
129
|
+
agents,
|
|
130
|
+
V3_CODEX_START_MARKER,
|
|
131
|
+
V3_CODEX_END_MARKER,
|
|
132
|
+
renderV3Bootstrap("codex")
|
|
133
|
+
),
|
|
134
|
+
V3_ZCODE_START_MARKER,
|
|
135
|
+
V3_ZCODE_END_MARKER,
|
|
136
|
+
renderV3Bootstrap("zcode")
|
|
137
|
+
);
|
|
138
|
+
const plans = [
|
|
139
|
+
managedFilePlan(
|
|
140
|
+
"claude-skill",
|
|
141
|
+
existing.get("claude-skill") ?? null,
|
|
142
|
+
renderClaudeSkill(renderV3Bootstrap("claude-code"))
|
|
143
|
+
),
|
|
144
|
+
managedFilePlan(
|
|
145
|
+
"cursor-rule",
|
|
146
|
+
existing.get("cursor-rule") ?? null,
|
|
147
|
+
renderCursorRule(renderV3Bootstrap("cursor"))
|
|
148
|
+
),
|
|
149
|
+
{
|
|
150
|
+
target: "agents",
|
|
151
|
+
beforeContent: existing.get("agents") ?? null,
|
|
152
|
+
targetContent: nextAgents
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
target: "copilot-instructions",
|
|
156
|
+
beforeContent: existing.get("copilot-instructions") ?? null,
|
|
157
|
+
targetContent: replaceManagedV3BlockText(
|
|
158
|
+
existing.get("copilot-instructions") ?? "",
|
|
159
|
+
V3_COPILOT_START_MARKER,
|
|
160
|
+
V3_COPILOT_END_MARKER,
|
|
161
|
+
renderV3Bootstrap("copilot")
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
];
|
|
165
|
+
return plans;
|
|
166
|
+
}
|
|
167
|
+
async function applyV3AdapterFilePlan(projectRoot, plan) {
|
|
168
|
+
const root = path.resolve(projectRoot);
|
|
169
|
+
if (!V3_ADAPTER_FILE_TARGETS.includes(plan.target)) {
|
|
170
|
+
throw new Error("MANCODE_V3_ADAPTER_TARGET_INVALID");
|
|
171
|
+
}
|
|
172
|
+
if (typeof plan.targetContent !== "string" || !plan.targetContent.trim()) {
|
|
173
|
+
throw new Error("MANCODE_V3_ADAPTER_TARGET_INVALID");
|
|
174
|
+
}
|
|
175
|
+
const target = v3AdapterTargetPath(root, plan.target);
|
|
176
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
177
|
+
await atomicWrite(target, plan.targetContent);
|
|
178
|
+
}
|
|
179
|
+
async function stageV3Adapter(projectRoot, platform) {
|
|
180
|
+
const root = path.resolve(projectRoot);
|
|
181
|
+
const target = targetFor(platform);
|
|
182
|
+
const content = await renderV3AdapterCandidate(root, platform);
|
|
183
|
+
const stagingTarget = path.join(
|
|
184
|
+
".mancode",
|
|
185
|
+
"staging",
|
|
186
|
+
"adapters",
|
|
187
|
+
"v3",
|
|
188
|
+
platform,
|
|
189
|
+
target
|
|
190
|
+
);
|
|
191
|
+
const destination = path.join(root, stagingTarget);
|
|
192
|
+
await mkdir(path.dirname(destination), { recursive: true });
|
|
193
|
+
await atomicWrite(destination, content);
|
|
194
|
+
return { platform, target, stagingTarget };
|
|
195
|
+
}
|
|
196
|
+
function v3AdapterTargetPath(projectRoot, target) {
|
|
197
|
+
const root = path.resolve(projectRoot);
|
|
198
|
+
switch (target) {
|
|
199
|
+
case "claude-skill":
|
|
200
|
+
return path.join(root, ".claude", "skills", "mancode-v3", "SKILL.md");
|
|
201
|
+
case "cursor-rule":
|
|
202
|
+
return path.join(root, ".cursor", "rules", "mancode-v3.mdc");
|
|
203
|
+
case "agents":
|
|
204
|
+
return path.join(root, "AGENTS.md");
|
|
205
|
+
case "copilot-instructions":
|
|
206
|
+
return path.join(root, ".github", "copilot-instructions.md");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function installV3Adapter(projectRoot, platform) {
|
|
210
|
+
const root = path.resolve(projectRoot);
|
|
211
|
+
const content = renderV3Bootstrap(platform);
|
|
212
|
+
switch (platform) {
|
|
213
|
+
case "claude-code":
|
|
214
|
+
await writeManagedFile(
|
|
215
|
+
path.join(root, ".claude", "skills", "mancode-v3", "SKILL.md"),
|
|
216
|
+
renderClaudeSkill(content)
|
|
217
|
+
);
|
|
218
|
+
break;
|
|
219
|
+
case "cursor":
|
|
220
|
+
await writeManagedFile(
|
|
221
|
+
path.join(root, ".cursor", "rules", "mancode-v3.mdc"),
|
|
222
|
+
renderCursorRule(content)
|
|
223
|
+
);
|
|
224
|
+
break;
|
|
225
|
+
case "codex":
|
|
226
|
+
await replaceManagedV3Block(
|
|
227
|
+
path.join(root, "AGENTS.md"),
|
|
228
|
+
V3_CODEX_START_MARKER,
|
|
229
|
+
V3_CODEX_END_MARKER,
|
|
230
|
+
content
|
|
231
|
+
);
|
|
232
|
+
break;
|
|
233
|
+
case "copilot":
|
|
234
|
+
await replaceManagedV3Block(
|
|
235
|
+
path.join(root, ".github", "copilot-instructions.md"),
|
|
236
|
+
V3_COPILOT_START_MARKER,
|
|
237
|
+
V3_COPILOT_END_MARKER,
|
|
238
|
+
content
|
|
239
|
+
);
|
|
240
|
+
break;
|
|
241
|
+
case "zcode":
|
|
242
|
+
await replaceManagedV3Block(
|
|
243
|
+
path.join(root, "AGENTS.md"),
|
|
244
|
+
V3_ZCODE_START_MARKER,
|
|
245
|
+
V3_ZCODE_END_MARKER,
|
|
246
|
+
content
|
|
247
|
+
);
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
return inspectV3Adapter(root, platform);
|
|
251
|
+
}
|
|
252
|
+
async function inspectV3Adapter(projectRoot, platform) {
|
|
253
|
+
const root = path.resolve(projectRoot);
|
|
254
|
+
const target = targetFor(platform);
|
|
255
|
+
const installed = await adapterTargetPresent(root, platform);
|
|
256
|
+
return {
|
|
257
|
+
version: V3_ADAPTER_VERSION,
|
|
258
|
+
installed,
|
|
259
|
+
ready: installed,
|
|
260
|
+
target,
|
|
261
|
+
detail: installed ? "V3 bootstrap is present; session identity is explicit-required." : "V3 bootstrap is not installed.",
|
|
262
|
+
capabilities: capabilitiesFor(platform)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
async function inspectV3AdapterVersions(projectRoot) {
|
|
266
|
+
const platforms = [
|
|
267
|
+
"claude-code",
|
|
268
|
+
"codex",
|
|
269
|
+
"cursor",
|
|
270
|
+
"copilot",
|
|
271
|
+
"zcode"
|
|
272
|
+
];
|
|
273
|
+
const entries = await Promise.all(
|
|
274
|
+
platforms.map(async (platform) => {
|
|
275
|
+
const status = await inspectV3Adapter(projectRoot, platform);
|
|
276
|
+
return [platform, status.ready ? status.version : "missing"];
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
return Object.fromEntries(entries);
|
|
280
|
+
}
|
|
281
|
+
async function removeV3Adapter(projectRoot, platform) {
|
|
282
|
+
const root = path.resolve(projectRoot);
|
|
283
|
+
switch (platform) {
|
|
284
|
+
case "claude-code":
|
|
285
|
+
await removeManagedFile(
|
|
286
|
+
path.join(root, ".claude", "skills", "mancode-v3", "SKILL.md")
|
|
287
|
+
);
|
|
288
|
+
return;
|
|
289
|
+
case "cursor":
|
|
290
|
+
await removeManagedFile(
|
|
291
|
+
path.join(root, ".cursor", "rules", "mancode-v3.mdc")
|
|
292
|
+
);
|
|
293
|
+
return;
|
|
294
|
+
case "codex":
|
|
295
|
+
await removeManagedV3Block(
|
|
296
|
+
path.join(root, "AGENTS.md"),
|
|
297
|
+
V3_CODEX_START_MARKER,
|
|
298
|
+
V3_CODEX_END_MARKER
|
|
299
|
+
);
|
|
300
|
+
return;
|
|
301
|
+
case "copilot":
|
|
302
|
+
await removeManagedV3Block(
|
|
303
|
+
path.join(root, ".github", "copilot-instructions.md"),
|
|
304
|
+
V3_COPILOT_START_MARKER,
|
|
305
|
+
V3_COPILOT_END_MARKER
|
|
306
|
+
);
|
|
307
|
+
return;
|
|
308
|
+
case "zcode":
|
|
309
|
+
await removeManagedV3Block(
|
|
310
|
+
path.join(root, "AGENTS.md"),
|
|
311
|
+
V3_ZCODE_START_MARKER,
|
|
312
|
+
V3_ZCODE_END_MARKER
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function renderV3Bootstrap(platform) {
|
|
317
|
+
const platformLabel = platformLabelFor(platform);
|
|
318
|
+
const modeEntry = capabilitiesFor(platform).nativeModeEntry ? "Use the platform mode entry only as a shortcut; resolve a Context Pack first." : "This platform has no native V3 mode entry; use the CLI commands explicitly.";
|
|
319
|
+
return [
|
|
320
|
+
"# mancode V3 bootstrap",
|
|
321
|
+
"",
|
|
322
|
+
V3_ADAPTER_MANAGED_MARKER,
|
|
323
|
+
"",
|
|
324
|
+
`- Platform: ${platformLabel}. This file is a non-authoritative bootstrap.`,
|
|
325
|
+
"- Locate the project root before running mancode commands.",
|
|
326
|
+
`- Create or supply an explicit session: \`mancode context session new --client ${platform}\` or \`--session <id>\`.`,
|
|
327
|
+
"- Read current task context with `mancode context show --purpose orient --session <id>`; for anonymous diagnosis, include an explicit `--task <namespace:id>`.",
|
|
328
|
+
"- For a mode entry, request the matching Context Pack purpose: `plan`, `implement`, `review`, `verify`, or `handoff`.",
|
|
329
|
+
"- Perform mutations only through `mancode workflow`, `mancode team`, and `mancode context` commands with their required revision and session arguments.",
|
|
330
|
+
"- Do not persist task, mode, or session state in this adapter file or any legacy state file.",
|
|
331
|
+
`- ${modeEntry}`,
|
|
332
|
+
`- No approved session or prompt hook is assumed. After a real-host spike is recorded for ${platform}, a verified host may provide MANCODE_HOST_SESSION_KEY; otherwise mutations require an explicit \`--session\`.`
|
|
333
|
+
].join("\n");
|
|
334
|
+
}
|
|
335
|
+
async function renderV3AdapterCandidate(root, platform) {
|
|
336
|
+
switch (platform) {
|
|
337
|
+
case "claude-code": {
|
|
338
|
+
const existing = await readAdapterTarget(root, "claude-skill");
|
|
339
|
+
return managedFilePlan(
|
|
340
|
+
"claude-skill",
|
|
341
|
+
existing,
|
|
342
|
+
renderClaudeSkill(renderV3Bootstrap(platform))
|
|
343
|
+
).targetContent;
|
|
344
|
+
}
|
|
345
|
+
case "cursor": {
|
|
346
|
+
const existing = await readAdapterTarget(root, "cursor-rule");
|
|
347
|
+
return managedFilePlan(
|
|
348
|
+
"cursor-rule",
|
|
349
|
+
existing,
|
|
350
|
+
renderCursorRule(renderV3Bootstrap(platform))
|
|
351
|
+
).targetContent;
|
|
352
|
+
}
|
|
353
|
+
case "codex": {
|
|
354
|
+
const existing = await readAdapterTarget(root, "agents") ?? "";
|
|
355
|
+
return replaceManagedV3BlockText(
|
|
356
|
+
existing,
|
|
357
|
+
V3_CODEX_START_MARKER,
|
|
358
|
+
V3_CODEX_END_MARKER,
|
|
359
|
+
renderV3Bootstrap(platform)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
case "copilot": {
|
|
363
|
+
const existing = await readAdapterTarget(root, "copilot-instructions") ?? "";
|
|
364
|
+
return replaceManagedV3BlockText(
|
|
365
|
+
existing,
|
|
366
|
+
V3_COPILOT_START_MARKER,
|
|
367
|
+
V3_COPILOT_END_MARKER,
|
|
368
|
+
renderV3Bootstrap(platform)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
case "zcode": {
|
|
372
|
+
const existing = await readAdapterTarget(root, "agents") ?? "";
|
|
373
|
+
return replaceManagedV3BlockText(
|
|
374
|
+
existing,
|
|
375
|
+
V3_ZCODE_START_MARKER,
|
|
376
|
+
V3_ZCODE_END_MARKER,
|
|
377
|
+
renderV3Bootstrap(platform)
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function renderClaudeSkill(content) {
|
|
383
|
+
return [
|
|
384
|
+
"---",
|
|
385
|
+
"name: mancode-v3",
|
|
386
|
+
'description: "Stable bootstrap for mancode V3 context and workflow commands."',
|
|
387
|
+
"---",
|
|
388
|
+
"",
|
|
389
|
+
content,
|
|
390
|
+
""
|
|
391
|
+
].join("\n");
|
|
392
|
+
}
|
|
393
|
+
function renderCursorRule(content) {
|
|
394
|
+
return [
|
|
395
|
+
"---",
|
|
396
|
+
'description: "Stable bootstrap for mancode V3 context and workflow commands."',
|
|
397
|
+
"alwaysApply: true",
|
|
398
|
+
'globs: "**/*"',
|
|
399
|
+
"---",
|
|
400
|
+
"",
|
|
401
|
+
content,
|
|
402
|
+
""
|
|
403
|
+
].join("\n");
|
|
404
|
+
}
|
|
405
|
+
async function adapterTargetPresent(root, platform) {
|
|
406
|
+
switch (platform) {
|
|
407
|
+
case "claude-code":
|
|
408
|
+
return managedFilePresent(
|
|
409
|
+
path.join(root, ".claude", "skills", "mancode-v3", "SKILL.md")
|
|
410
|
+
);
|
|
411
|
+
case "cursor":
|
|
412
|
+
return managedFilePresent(
|
|
413
|
+
path.join(root, ".cursor", "rules", "mancode-v3.mdc")
|
|
414
|
+
);
|
|
415
|
+
case "codex":
|
|
416
|
+
return managedBlockPresent(
|
|
417
|
+
path.join(root, "AGENTS.md"),
|
|
418
|
+
V3_CODEX_START_MARKER,
|
|
419
|
+
V3_CODEX_END_MARKER
|
|
420
|
+
);
|
|
421
|
+
case "copilot":
|
|
422
|
+
return managedBlockPresent(
|
|
423
|
+
path.join(root, ".github", "copilot-instructions.md"),
|
|
424
|
+
V3_COPILOT_START_MARKER,
|
|
425
|
+
V3_COPILOT_END_MARKER
|
|
426
|
+
);
|
|
427
|
+
case "zcode":
|
|
428
|
+
return managedBlockPresent(
|
|
429
|
+
path.join(root, "AGENTS.md"),
|
|
430
|
+
V3_ZCODE_START_MARKER,
|
|
431
|
+
V3_ZCODE_END_MARKER
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
async function writeManagedFile(filePath, content) {
|
|
436
|
+
const existing = await readTextIfExists(filePath);
|
|
437
|
+
if (existing !== null && !existing.includes(V3_ADAPTER_MANAGED_MARKER)) {
|
|
438
|
+
throw new Error("MANCODE_V3_ADAPTER_TARGET_USER_AUTHORED");
|
|
439
|
+
}
|
|
440
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
441
|
+
await atomicWrite(filePath, content);
|
|
442
|
+
}
|
|
443
|
+
async function removeManagedFile(filePath) {
|
|
444
|
+
const existing = await readTextIfExists(filePath);
|
|
445
|
+
if (existing?.includes(V3_ADAPTER_MANAGED_MARKER)) {
|
|
446
|
+
await rm(filePath, { force: true });
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async function replaceManagedV3Block(filePath, startMarker, endMarker, content) {
|
|
450
|
+
const existing = await readTextIfExists(filePath) ?? "";
|
|
451
|
+
const block = [startMarker, content, endMarker].join("\n");
|
|
452
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
453
|
+
await atomicWrite(
|
|
454
|
+
filePath,
|
|
455
|
+
replaceManagedBlock(existing, block, startMarker, endMarker)
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function replaceManagedV3BlockText(existing, startMarker, endMarker, content) {
|
|
459
|
+
return replaceManagedBlock(
|
|
460
|
+
existing,
|
|
461
|
+
[startMarker, content, endMarker].join("\n"),
|
|
462
|
+
startMarker,
|
|
463
|
+
endMarker
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
function managedFilePlan(target, beforeContent, targetContent) {
|
|
467
|
+
if (beforeContent !== null && !beforeContent.includes(V3_ADAPTER_MANAGED_MARKER)) {
|
|
468
|
+
throw new Error("MANCODE_V3_ADAPTER_TARGET_USER_AUTHORED");
|
|
469
|
+
}
|
|
470
|
+
return { target, beforeContent, targetContent };
|
|
471
|
+
}
|
|
472
|
+
async function readAdapterTarget(root, target) {
|
|
473
|
+
const filePath = v3AdapterTargetPath(root, target);
|
|
474
|
+
try {
|
|
475
|
+
const entry = await lstat(filePath);
|
|
476
|
+
if (!entry.isFile() || entry.isSymbolicLink()) {
|
|
477
|
+
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
478
|
+
}
|
|
479
|
+
} catch (error) {
|
|
480
|
+
if (isNodeError(error) && error.code === "ENOENT") return null;
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
return readFile(filePath, "utf8");
|
|
484
|
+
}
|
|
485
|
+
async function removeManagedV3Block(filePath, startMarker, endMarker) {
|
|
486
|
+
const existing = await readTextIfExists(filePath);
|
|
487
|
+
if (existing === null || !hasManagedBlock(existing, startMarker, endMarker)) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const cleaned = removeManagedBlock(existing, startMarker, endMarker);
|
|
491
|
+
if (cleaned.trim()) {
|
|
492
|
+
await atomicWrite(filePath, `${cleaned.trimEnd()}
|
|
493
|
+
`);
|
|
494
|
+
} else {
|
|
495
|
+
await rm(filePath, { force: true });
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function managedFilePresent(filePath) {
|
|
499
|
+
const content = await readTextIfExists(filePath);
|
|
500
|
+
return content?.includes(V3_ADAPTER_MANAGED_MARKER) ?? false;
|
|
501
|
+
}
|
|
502
|
+
async function managedBlockPresent(filePath, startMarker, endMarker) {
|
|
503
|
+
const content = await readTextIfExists(filePath);
|
|
504
|
+
return content !== null && hasManagedBlock(content, startMarker, endMarker);
|
|
505
|
+
}
|
|
506
|
+
async function readTextIfExists(filePath) {
|
|
507
|
+
for (let attempt = 1; attempt <= ADAPTER_READ_MAX_ATTEMPTS; attempt += 1) {
|
|
508
|
+
try {
|
|
509
|
+
return await readFile(filePath, "utf8");
|
|
510
|
+
} catch (error) {
|
|
511
|
+
if (isNodeError(error) && error.code === "ENOENT") return null;
|
|
512
|
+
if (!isRetriableAdapterReadError(error) || attempt === ADAPTER_READ_MAX_ATTEMPTS) {
|
|
513
|
+
throw error;
|
|
514
|
+
}
|
|
515
|
+
await delay(ADAPTER_READ_RETRY_DELAY_MS * attempt);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
throw new Error("MANCODE_V3_ADAPTER_READ_RETRY_EXHAUSTED");
|
|
519
|
+
}
|
|
520
|
+
async function atomicWrite(filePath, content) {
|
|
521
|
+
const temporary = path.join(
|
|
522
|
+
path.dirname(filePath),
|
|
523
|
+
`.${path.basename(filePath)}.${process.pid}.${Date.now()}.tmp`
|
|
524
|
+
);
|
|
525
|
+
try {
|
|
526
|
+
await writeFile(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
527
|
+
await rename(temporary, filePath);
|
|
528
|
+
} finally {
|
|
529
|
+
await rm(temporary, { force: true }).catch(() => void 0);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function targetFor(platform) {
|
|
533
|
+
switch (platform) {
|
|
534
|
+
case "claude-code":
|
|
535
|
+
return ".claude/skills/mancode-v3/SKILL.md";
|
|
536
|
+
case "cursor":
|
|
537
|
+
return ".cursor/rules/mancode-v3.mdc";
|
|
538
|
+
case "codex":
|
|
539
|
+
case "zcode":
|
|
540
|
+
return "AGENTS.md";
|
|
541
|
+
case "copilot":
|
|
542
|
+
return ".github/copilot-instructions.md";
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function platformLabelFor(platform) {
|
|
546
|
+
switch (platform) {
|
|
547
|
+
case "claude-code":
|
|
548
|
+
return "Claude Code";
|
|
549
|
+
case "cursor":
|
|
550
|
+
return "Cursor";
|
|
551
|
+
case "codex":
|
|
552
|
+
return "Codex";
|
|
553
|
+
case "copilot":
|
|
554
|
+
return "GitHub Copilot";
|
|
555
|
+
case "zcode":
|
|
556
|
+
return "ZCode";
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function capabilitiesFor(platform) {
|
|
560
|
+
return {
|
|
561
|
+
nativeModeEntry: platform === "claude-code" || platform === "cursor",
|
|
562
|
+
sessionHook: false,
|
|
563
|
+
promptHook: false,
|
|
564
|
+
sessionIdentity: "explicit-required"
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
function isNodeError(error) {
|
|
568
|
+
return typeof error === "object" && error !== null && "code" in error;
|
|
569
|
+
}
|
|
570
|
+
function isRetriableAdapterReadError(error) {
|
|
571
|
+
return isNodeError(error) && RETRIABLE_ADAPTER_READ_CODES.has(error.code ?? "");
|
|
572
|
+
}
|
|
573
|
+
async function delay(milliseconds) {
|
|
574
|
+
await new Promise((resolve) => {
|
|
575
|
+
setTimeout(resolve, milliseconds);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export {
|
|
580
|
+
DEFAULT_MANCODE_START_MARKER,
|
|
581
|
+
DEFAULT_MANCODE_END_MARKER,
|
|
582
|
+
removeManagedBlock,
|
|
583
|
+
hasManagedBlock,
|
|
584
|
+
replaceManagedBlock,
|
|
585
|
+
V3_ADAPTER_VERSION,
|
|
586
|
+
V3_ADAPTER_MANAGED_MARKER,
|
|
587
|
+
planV3AdapterFiles,
|
|
588
|
+
applyV3AdapterFilePlan,
|
|
589
|
+
stageV3Adapter,
|
|
590
|
+
v3AdapterTargetPath,
|
|
591
|
+
installV3Adapter,
|
|
592
|
+
inspectV3Adapter,
|
|
593
|
+
inspectV3AdapterVersions,
|
|
594
|
+
removeV3Adapter,
|
|
595
|
+
renderV3Bootstrap
|
|
596
|
+
};
|
|
597
|
+
//# sourceMappingURL=chunk-KEIW7AEP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/installers/v3-adapter.ts","../src/installers/managed-block.ts"],"sourcesContent":["import {\n lstat,\n mkdir,\n readFile,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises';\nimport path from 'node:path';\nimport {\n hasManagedBlock,\n removeManagedBlock,\n replaceManagedBlock,\n} from './managed-block.js';\nimport type { PlatformName } from './registry.js';\n\n/**\n * This is the schema of the generated bootstrap, not a product version. The\n * schema manifest records the expected renderer schema while physical status\n * is derived from the managed files below.\n */\nexport const V3_ADAPTER_VERSION = '3';\n\nexport const V3_ADAPTER_MANAGED_MARKER =\n '<!-- Managed by mancode:v3-adapter. Do not edit this marker. -->';\n\nconst V3_CODEX_START_MARKER = '<!-- mancode:v3:codex:start -->';\nconst V3_CODEX_END_MARKER = '<!-- mancode:v3:codex:end -->';\nconst V3_ZCODE_START_MARKER = '<!-- mancode:v3:zcode:start -->';\nconst V3_ZCODE_END_MARKER = '<!-- mancode:v3:zcode:end -->';\nconst V3_COPILOT_START_MARKER = '<!-- mancode:v3:copilot:start -->';\nconst V3_COPILOT_END_MARKER = '<!-- mancode:v3:copilot:end -->';\nconst RETRIABLE_ADAPTER_READ_CODES = new Set(['EACCES', 'EBUSY', 'EPERM']);\nconst ADAPTER_READ_MAX_ATTEMPTS = 4;\nconst ADAPTER_READ_RETRY_DELAY_MS = 25;\n\nexport interface V3AdapterCapabilities {\n nativeModeEntry: boolean;\n sessionHook: false;\n promptHook: false;\n sessionIdentity: 'explicit-required';\n}\n\nexport interface V3PlatformAdapterStatus {\n version: string;\n installed: boolean;\n ready: boolean;\n target: string;\n detail: string;\n capabilities: V3AdapterCapabilities;\n}\n\n/**\n * A physical file touched by the V3 bootstrap renderer. Codex and ZCode\n * deliberately share the AGENTS target, so activation journals these files\n * rather than individual platform installs.\n */\nexport type V3AdapterFileTarget =\n | 'claude-skill'\n | 'cursor-rule'\n | 'agents'\n | 'copilot-instructions';\n\nexport interface V3AdapterFilePlan {\n target: V3AdapterFileTarget;\n beforeContent: string | null;\n targetContent: string;\n}\n\nexport interface V3StagedAdapter {\n platform: PlatformName;\n /** The corresponding live target, relative to the project root. */\n target: string;\n /** The generated candidate, kept under V3 staging rather than the live target. */\n stagingTarget: string;\n}\n\nconst V3_ADAPTER_FILE_TARGETS: V3AdapterFileTarget[] = [\n 'claude-skill',\n 'cursor-rule',\n 'agents',\n 'copilot-instructions',\n];\n\n/**\n * Calculates exact file replacements without publishing them. This lets a\n * migration journal bind the combined AGENTS.md result before its first\n * visible write and preserves all user-authored content outside our blocks.\n */\nexport async function planV3AdapterFiles(\n projectRoot: string,\n): Promise<V3AdapterFilePlan[]> {\n const root = path.resolve(projectRoot);\n const existing = new Map<V3AdapterFileTarget, string | null>();\n for (const target of V3_ADAPTER_FILE_TARGETS) {\n existing.set(target, await readAdapterTarget(root, target));\n }\n const agents = existing.get('agents') ?? '';\n const nextAgents = replaceManagedV3BlockText(\n replaceManagedV3BlockText(\n agents,\n V3_CODEX_START_MARKER,\n V3_CODEX_END_MARKER,\n renderV3Bootstrap('codex'),\n ),\n V3_ZCODE_START_MARKER,\n V3_ZCODE_END_MARKER,\n renderV3Bootstrap('zcode'),\n );\n const plans: V3AdapterFilePlan[] = [\n managedFilePlan(\n 'claude-skill',\n existing.get('claude-skill') ?? null,\n renderClaudeSkill(renderV3Bootstrap('claude-code')),\n ),\n managedFilePlan(\n 'cursor-rule',\n existing.get('cursor-rule') ?? null,\n renderCursorRule(renderV3Bootstrap('cursor')),\n ),\n {\n target: 'agents',\n beforeContent: existing.get('agents') ?? null,\n targetContent: nextAgents,\n },\n {\n target: 'copilot-instructions',\n beforeContent: existing.get('copilot-instructions') ?? null,\n targetContent: replaceManagedV3BlockText(\n existing.get('copilot-instructions') ?? '',\n V3_COPILOT_START_MARKER,\n V3_COPILOT_END_MARKER,\n renderV3Bootstrap('copilot'),\n ),\n },\n ];\n return plans;\n}\n\n/** Publishes one precomputed fixed-target replacement with atomic rename. */\nexport async function applyV3AdapterFilePlan(\n projectRoot: string,\n plan: V3AdapterFilePlan,\n): Promise<void> {\n const root = path.resolve(projectRoot);\n if (!V3_ADAPTER_FILE_TARGETS.includes(plan.target)) {\n throw new Error('MANCODE_V3_ADAPTER_TARGET_INVALID');\n }\n if (typeof plan.targetContent !== 'string' || !plan.targetContent.trim()) {\n throw new Error('MANCODE_V3_ADAPTER_TARGET_INVALID');\n }\n const target = v3AdapterTargetPath(root, plan.target);\n await mkdir(path.dirname(target), { recursive: true });\n await atomicWrite(target, plan.targetContent);\n}\n\n/**\n * Renders a complete adapter candidate under V3 staging. Shadow integration\n * may inspect this exact replacement without changing a live managed file.\n */\nexport async function stageV3Adapter(\n projectRoot: string,\n platform: PlatformName,\n): Promise<V3StagedAdapter> {\n const root = path.resolve(projectRoot);\n const target = targetFor(platform);\n const content = await renderV3AdapterCandidate(root, platform);\n const stagingTarget = path.join(\n '.mancode',\n 'staging',\n 'adapters',\n 'v3',\n platform,\n target,\n );\n const destination = path.join(root, stagingTarget);\n await mkdir(path.dirname(destination), { recursive: true });\n await atomicWrite(destination, content);\n return { platform, target, stagingTarget };\n}\n\nexport function v3AdapterTargetPath(\n projectRoot: string,\n target: V3AdapterFileTarget,\n): string {\n const root = path.resolve(projectRoot);\n switch (target) {\n case 'claude-skill':\n return path.join(root, '.claude', 'skills', 'mancode-v3', 'SKILL.md');\n case 'cursor-rule':\n return path.join(root, '.cursor', 'rules', 'mancode-v3.mdc');\n case 'agents':\n return path.join(root, 'AGENTS.md');\n case 'copilot-instructions':\n return path.join(root, '.github', 'copilot-instructions.md');\n }\n}\n\n/**\n * Writes only stable V3 bootstrap instructions. In particular, this never\n * creates legacy authority or copies task state into an adapter file.\n */\nexport async function installV3Adapter(\n projectRoot: string,\n platform: PlatformName,\n): Promise<V3PlatformAdapterStatus> {\n const root = path.resolve(projectRoot);\n const content = renderV3Bootstrap(platform);\n switch (platform) {\n case 'claude-code':\n await writeManagedFile(\n path.join(root, '.claude', 'skills', 'mancode-v3', 'SKILL.md'),\n renderClaudeSkill(content),\n );\n break;\n case 'cursor':\n await writeManagedFile(\n path.join(root, '.cursor', 'rules', 'mancode-v3.mdc'),\n renderCursorRule(content),\n );\n break;\n case 'codex':\n await replaceManagedV3Block(\n path.join(root, 'AGENTS.md'),\n V3_CODEX_START_MARKER,\n V3_CODEX_END_MARKER,\n content,\n );\n break;\n case 'copilot':\n await replaceManagedV3Block(\n path.join(root, '.github', 'copilot-instructions.md'),\n V3_COPILOT_START_MARKER,\n V3_COPILOT_END_MARKER,\n content,\n );\n break;\n case 'zcode':\n await replaceManagedV3Block(\n path.join(root, 'AGENTS.md'),\n V3_ZCODE_START_MARKER,\n V3_ZCODE_END_MARKER,\n content,\n );\n break;\n }\n return inspectV3Adapter(root, platform);\n}\n\n/** Physical adapter status intentionally does not infer hook approval. */\nexport async function inspectV3Adapter(\n projectRoot: string,\n platform: PlatformName,\n): Promise<V3PlatformAdapterStatus> {\n const root = path.resolve(projectRoot);\n const target = targetFor(platform);\n const installed = await adapterTargetPresent(root, platform);\n return {\n version: V3_ADAPTER_VERSION,\n installed,\n ready: installed,\n target,\n detail: installed\n ? 'V3 bootstrap is present; session identity is explicit-required.'\n : 'V3 bootstrap is not installed.',\n capabilities: capabilitiesFor(platform),\n };\n}\n\n/** Actual on-disk inventory for compatibility gates; never trust manifest echo. */\nexport async function inspectV3AdapterVersions(\n projectRoot: string,\n): Promise<Record<PlatformName, string>> {\n const platforms: PlatformName[] = [\n 'claude-code',\n 'codex',\n 'cursor',\n 'copilot',\n 'zcode',\n ];\n const entries = await Promise.all(\n platforms.map(async (platform) => {\n const status = await inspectV3Adapter(projectRoot, platform);\n return [platform, status.ready ? status.version : 'missing'] as const;\n }),\n );\n return Object.fromEntries(entries) as Record<PlatformName, string>;\n}\n\n/** Removes only the V3 bootstrap owned by this renderer, never V3 authority. */\nexport async function removeV3Adapter(\n projectRoot: string,\n platform: PlatformName,\n): Promise<void> {\n const root = path.resolve(projectRoot);\n switch (platform) {\n case 'claude-code':\n await removeManagedFile(\n path.join(root, '.claude', 'skills', 'mancode-v3', 'SKILL.md'),\n );\n return;\n case 'cursor':\n await removeManagedFile(\n path.join(root, '.cursor', 'rules', 'mancode-v3.mdc'),\n );\n return;\n case 'codex':\n await removeManagedV3Block(\n path.join(root, 'AGENTS.md'),\n V3_CODEX_START_MARKER,\n V3_CODEX_END_MARKER,\n );\n return;\n case 'copilot':\n await removeManagedV3Block(\n path.join(root, '.github', 'copilot-instructions.md'),\n V3_COPILOT_START_MARKER,\n V3_COPILOT_END_MARKER,\n );\n return;\n case 'zcode':\n await removeManagedV3Block(\n path.join(root, 'AGENTS.md'),\n V3_ZCODE_START_MARKER,\n V3_ZCODE_END_MARKER,\n );\n }\n}\n\nexport function renderV3Bootstrap(platform: PlatformName): string {\n const platformLabel = platformLabelFor(platform);\n const modeEntry = capabilitiesFor(platform).nativeModeEntry\n ? 'Use the platform mode entry only as a shortcut; resolve a Context Pack first.'\n : 'This platform has no native V3 mode entry; use the CLI commands explicitly.';\n return [\n '# mancode V3 bootstrap',\n '',\n V3_ADAPTER_MANAGED_MARKER,\n '',\n `- Platform: ${platformLabel}. This file is a non-authoritative bootstrap.`,\n '- Locate the project root before running mancode commands.',\n `- Create or supply an explicit session: \\`mancode context session new --client ${platform}\\` or \\`--session <id>\\`.`,\n '- Read current task context with `mancode context show --purpose orient --session <id>`; for anonymous diagnosis, include an explicit `--task <namespace:id>`.',\n '- For a mode entry, request the matching Context Pack purpose: `plan`, `implement`, `review`, `verify`, or `handoff`.',\n '- Perform mutations only through `mancode workflow`, `mancode team`, and `mancode context` commands with their required revision and session arguments.',\n '- Do not persist task, mode, or session state in this adapter file or any legacy state file.',\n `- ${modeEntry}`,\n `- No approved session or prompt hook is assumed. After a real-host spike is recorded for ${platform}, a verified host may provide MANCODE_HOST_SESSION_KEY; otherwise mutations require an explicit \\`--session\\`.`,\n ].join('\\n');\n}\n\nasync function renderV3AdapterCandidate(\n root: string,\n platform: PlatformName,\n): Promise<string> {\n switch (platform) {\n case 'claude-code': {\n const existing = await readAdapterTarget(root, 'claude-skill');\n return managedFilePlan(\n 'claude-skill',\n existing,\n renderClaudeSkill(renderV3Bootstrap(platform)),\n ).targetContent;\n }\n case 'cursor': {\n const existing = await readAdapterTarget(root, 'cursor-rule');\n return managedFilePlan(\n 'cursor-rule',\n existing,\n renderCursorRule(renderV3Bootstrap(platform)),\n ).targetContent;\n }\n case 'codex': {\n const existing = (await readAdapterTarget(root, 'agents')) ?? '';\n return replaceManagedV3BlockText(\n existing,\n V3_CODEX_START_MARKER,\n V3_CODEX_END_MARKER,\n renderV3Bootstrap(platform),\n );\n }\n case 'copilot': {\n const existing =\n (await readAdapterTarget(root, 'copilot-instructions')) ?? '';\n return replaceManagedV3BlockText(\n existing,\n V3_COPILOT_START_MARKER,\n V3_COPILOT_END_MARKER,\n renderV3Bootstrap(platform),\n );\n }\n case 'zcode': {\n const existing = (await readAdapterTarget(root, 'agents')) ?? '';\n return replaceManagedV3BlockText(\n existing,\n V3_ZCODE_START_MARKER,\n V3_ZCODE_END_MARKER,\n renderV3Bootstrap(platform),\n );\n }\n }\n}\n\nfunction renderClaudeSkill(content: string): string {\n return [\n '---',\n 'name: mancode-v3',\n 'description: \"Stable bootstrap for mancode V3 context and workflow commands.\"',\n '---',\n '',\n content,\n '',\n ].join('\\n');\n}\n\nfunction renderCursorRule(content: string): string {\n return [\n '---',\n 'description: \"Stable bootstrap for mancode V3 context and workflow commands.\"',\n 'alwaysApply: true',\n 'globs: \"**/*\"',\n '---',\n '',\n content,\n '',\n ].join('\\n');\n}\n\nasync function adapterTargetPresent(\n root: string,\n platform: PlatformName,\n): Promise<boolean> {\n switch (platform) {\n case 'claude-code':\n return managedFilePresent(\n path.join(root, '.claude', 'skills', 'mancode-v3', 'SKILL.md'),\n );\n case 'cursor':\n return managedFilePresent(\n path.join(root, '.cursor', 'rules', 'mancode-v3.mdc'),\n );\n case 'codex':\n return managedBlockPresent(\n path.join(root, 'AGENTS.md'),\n V3_CODEX_START_MARKER,\n V3_CODEX_END_MARKER,\n );\n case 'copilot':\n return managedBlockPresent(\n path.join(root, '.github', 'copilot-instructions.md'),\n V3_COPILOT_START_MARKER,\n V3_COPILOT_END_MARKER,\n );\n case 'zcode':\n return managedBlockPresent(\n path.join(root, 'AGENTS.md'),\n V3_ZCODE_START_MARKER,\n V3_ZCODE_END_MARKER,\n );\n }\n}\n\nasync function writeManagedFile(\n filePath: string,\n content: string,\n): Promise<void> {\n const existing = await readTextIfExists(filePath);\n if (existing !== null && !existing.includes(V3_ADAPTER_MANAGED_MARKER)) {\n throw new Error('MANCODE_V3_ADAPTER_TARGET_USER_AUTHORED');\n }\n await mkdir(path.dirname(filePath), { recursive: true });\n await atomicWrite(filePath, content);\n}\n\nasync function removeManagedFile(filePath: string): Promise<void> {\n const existing = await readTextIfExists(filePath);\n if (existing?.includes(V3_ADAPTER_MANAGED_MARKER)) {\n await rm(filePath, { force: true });\n }\n}\n\nasync function replaceManagedV3Block(\n filePath: string,\n startMarker: string,\n endMarker: string,\n content: string,\n): Promise<void> {\n const existing = (await readTextIfExists(filePath)) ?? '';\n const block = [startMarker, content, endMarker].join('\\n');\n await mkdir(path.dirname(filePath), { recursive: true });\n await atomicWrite(\n filePath,\n replaceManagedBlock(existing, block, startMarker, endMarker),\n );\n}\n\nfunction replaceManagedV3BlockText(\n existing: string,\n startMarker: string,\n endMarker: string,\n content: string,\n): string {\n return replaceManagedBlock(\n existing,\n [startMarker, content, endMarker].join('\\n'),\n startMarker,\n endMarker,\n );\n}\n\nfunction managedFilePlan(\n target: V3AdapterFileTarget,\n beforeContent: string | null,\n targetContent: string,\n): V3AdapterFilePlan {\n if (\n beforeContent !== null &&\n !beforeContent.includes(V3_ADAPTER_MANAGED_MARKER)\n ) {\n throw new Error('MANCODE_V3_ADAPTER_TARGET_USER_AUTHORED');\n }\n return { target, beforeContent, targetContent };\n}\n\nasync function readAdapterTarget(\n root: string,\n target: V3AdapterFileTarget,\n): Promise<string | null> {\n const filePath = v3AdapterTargetPath(root, target);\n try {\n const entry = await lstat(filePath);\n if (!entry.isFile() || entry.isSymbolicLink()) {\n throw new Error('MANCODE_ARTIFACT_PATH_UNSAFE');\n }\n } catch (error) {\n if (isNodeError(error) && error.code === 'ENOENT') return null;\n throw error;\n }\n return readFile(filePath, 'utf8');\n}\n\nasync function removeManagedV3Block(\n filePath: string,\n startMarker: string,\n endMarker: string,\n): Promise<void> {\n const existing = await readTextIfExists(filePath);\n if (existing === null || !hasManagedBlock(existing, startMarker, endMarker)) {\n return;\n }\n const cleaned = removeManagedBlock(existing, startMarker, endMarker);\n if (cleaned.trim()) {\n await atomicWrite(filePath, `${cleaned.trimEnd()}\\n`);\n } else {\n await rm(filePath, { force: true });\n }\n}\n\nasync function managedFilePresent(filePath: string): Promise<boolean> {\n const content = await readTextIfExists(filePath);\n return content?.includes(V3_ADAPTER_MANAGED_MARKER) ?? false;\n}\n\nasync function managedBlockPresent(\n filePath: string,\n startMarker: string,\n endMarker: string,\n): Promise<boolean> {\n const content = await readTextIfExists(filePath);\n return content !== null && hasManagedBlock(content, startMarker, endMarker);\n}\n\nasync function readTextIfExists(filePath: string): Promise<string | null> {\n for (let attempt = 1; attempt <= ADAPTER_READ_MAX_ATTEMPTS; attempt += 1) {\n try {\n return await readFile(filePath, 'utf8');\n } catch (error) {\n if (isNodeError(error) && error.code === 'ENOENT') return null;\n if (\n !isRetriableAdapterReadError(error) ||\n attempt === ADAPTER_READ_MAX_ATTEMPTS\n ) {\n throw error;\n }\n await delay(ADAPTER_READ_RETRY_DELAY_MS * attempt);\n }\n }\n throw new Error('MANCODE_V3_ADAPTER_READ_RETRY_EXHAUSTED');\n}\n\nasync function atomicWrite(filePath: string, content: string): Promise<void> {\n const temporary = path.join(\n path.dirname(filePath),\n `.${path.basename(filePath)}.${process.pid}.${Date.now()}.tmp`,\n );\n try {\n await writeFile(temporary, content, { encoding: 'utf8', flag: 'wx' });\n await rename(temporary, filePath);\n } finally {\n await rm(temporary, { force: true }).catch(() => undefined);\n }\n}\n\nfunction targetFor(platform: PlatformName): string {\n switch (platform) {\n case 'claude-code':\n return '.claude/skills/mancode-v3/SKILL.md';\n case 'cursor':\n return '.cursor/rules/mancode-v3.mdc';\n case 'codex':\n case 'zcode':\n return 'AGENTS.md';\n case 'copilot':\n return '.github/copilot-instructions.md';\n }\n}\n\nfunction platformLabelFor(platform: PlatformName): string {\n switch (platform) {\n case 'claude-code':\n return 'Claude Code';\n case 'cursor':\n return 'Cursor';\n case 'codex':\n return 'Codex';\n case 'copilot':\n return 'GitHub Copilot';\n case 'zcode':\n return 'ZCode';\n }\n}\n\nfunction capabilitiesFor(platform: PlatformName): V3AdapterCapabilities {\n return {\n nativeModeEntry: platform === 'claude-code' || platform === 'cursor',\n sessionHook: false,\n promptHook: false,\n sessionIdentity: 'explicit-required',\n };\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\nfunction isRetriableAdapterReadError(error: unknown): boolean {\n return (\n isNodeError(error) && RETRIABLE_ADAPTER_READ_CODES.has(error.code ?? '')\n );\n}\n\nasync function delay(milliseconds: number): Promise<void> {\n await new Promise<void>((resolve) => {\n setTimeout(resolve, milliseconds);\n });\n}\n","export const DEFAULT_MANCODE_START_MARKER = '<!-- mancode:start -->';\nexport const DEFAULT_MANCODE_END_MARKER = '<!-- mancode:end -->';\n\nexport function removeManagedBlock(\n existing: string,\n startMarker = DEFAULT_MANCODE_START_MARKER,\n endMarker = DEFAULT_MANCODE_END_MARKER,\n): string {\n const start = findMarkerLine(existing, startMarker);\n const end = findMarkerLine(existing, endMarker);\n\n if (start === null && end === null) return existing;\n if (start === null || end === null) return existing;\n if (end.start < start.start) return existing;\n\n const before = existing.slice(0, start.start);\n const after = existing.slice(end.end);\n const merged = `${before}${after}`;\n return cleanUpOrphanedNewlines(merged);\n}\n\nexport function hasManagedBlock(\n existing: string,\n startMarker = DEFAULT_MANCODE_START_MARKER,\n endMarker = DEFAULT_MANCODE_END_MARKER,\n): boolean {\n const start = findMarkerLine(existing, startMarker);\n const end = findMarkerLine(existing, endMarker);\n return start !== null && end !== null && end.start > start.start;\n}\n\nfunction cleanUpOrphanedNewlines(content: string): string {\n const trimmed = content.replace(/\\n{3,}/gu, '\\n\\n').replace(/\\n+$/u, '\\n');\n return trimmed || '';\n}\n\nexport function replaceManagedBlock(\n existing: string,\n block: string,\n startMarker = DEFAULT_MANCODE_START_MARKER,\n endMarker = DEFAULT_MANCODE_END_MARKER,\n): string {\n const normalizedBlock = normalizeManagedBlock(block, startMarker, endMarker);\n const start = findMarkerLine(existing, startMarker);\n const end = findMarkerLine(existing, endMarker);\n\n if ((start === null) !== (end === null)) {\n throw new Error('managed block is malformed: missing start or end marker');\n }\n\n if (start === null && end === null) {\n const trimmedExisting = trimTrailingNewlines(existing);\n if (!trimmedExisting) return `${normalizedBlock}\\n`;\n return `${trimmedExisting}\\n\\n${normalizedBlock}\\n`;\n }\n\n if (!start || !end) {\n throw new Error('managed block is malformed: missing start or end marker');\n }\n\n if (end.start < start.start) {\n throw new Error('managed block is malformed: end marker precedes start');\n }\n\n return `${existing.slice(0, start.start)}${normalizedBlock}${existing.slice(\n end.end,\n )}`;\n}\n\nfunction normalizeManagedBlock(\n block: string,\n startMarker: string,\n endMarker: string,\n): string {\n const trimmedBlock = block.trim();\n const hasStart = trimmedBlock.startsWith(startMarker);\n const hasEnd = trimmedBlock.endsWith(endMarker);\n\n if (hasStart && hasEnd) return trimmedBlock;\n if (hasStart || hasEnd) {\n throw new Error('managed block content includes only one marker');\n }\n\n return `${startMarker}\\n${trimmedBlock}\\n${endMarker}`;\n}\n\nfunction trimTrailingNewlines(value: string): string {\n return value.replace(/\\n+$/u, '');\n}\n\nfunction findMarkerLine(\n content: string,\n marker: string,\n): { start: number; end: number } | null {\n let offset = 0;\n let inFence: { char: '`' | '~'; length: number } | null = null;\n\n for (const lineWithBreak of content.matchAll(/[^\\n]*(?:\\n|$)/gu)) {\n const rawLine = lineWithBreak[0];\n if (!rawLine) break;\n\n const line = rawLine.replace(/\\n$/u, '').replace(/\\r$/u, '');\n const fence = line.match(/^(`{3,}|~{3,})/u)?.[1];\n if (fence) {\n const char = fence[0] as '`' | '~';\n if (!inFence) {\n inFence = { char, length: fence.length };\n } else if (inFence.char === char && fence.length >= inFence.length) {\n inFence = null;\n }\n } else if (!inFence && line === marker) {\n return {\n start: offset,\n end: offset + marker.length,\n };\n }\n\n offset += rawLine.length;\n }\n\n return null;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,UAAU;;;ACRV,IAAM,+BAA+B;AACrC,IAAM,6BAA6B;AAEnC,SAAS,mBACd,UACA,cAAc,8BACd,YAAY,4BACJ;AACR,QAAM,QAAQ,eAAe,UAAU,WAAW;AAClD,QAAM,MAAM,eAAe,UAAU,SAAS;AAE9C,MAAI,UAAU,QAAQ,QAAQ,KAAM,QAAO;AAC3C,MAAI,UAAU,QAAQ,QAAQ,KAAM,QAAO;AAC3C,MAAI,IAAI,QAAQ,MAAM,MAAO,QAAO;AAEpC,QAAM,SAAS,SAAS,MAAM,GAAG,MAAM,KAAK;AAC5C,QAAM,QAAQ,SAAS,MAAM,IAAI,GAAG;AACpC,QAAM,SAAS,GAAG,MAAM,GAAG,KAAK;AAChC,SAAO,wBAAwB,MAAM;AACvC;AAEO,SAAS,gBACd,UACA,cAAc,8BACd,YAAY,4BACH;AACT,QAAM,QAAQ,eAAe,UAAU,WA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