@modootoday/pmcp 0.20.0 → 0.21.0
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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/dist/{apply-QJ6MGLBX.js → apply-6FLMTJDV.js} +57 -23
- package/dist/{available-HYSDAFYH.js → available-BFXLII4A.js} +7 -7
- package/dist/{broadcast-LYOA6BEW.js → broadcast-ZALGUJVR.js} +4 -4
- package/dist/chunk-2GI5RM3M.js +53 -0
- package/dist/{chunk-ICF2JZSN.js → chunk-2MAD4WNZ.js} +2 -2
- package/dist/{chunk-YDICIB2A.js → chunk-33KGCJB2.js} +2 -2
- package/dist/{chunk-FQAJSNNU.js → chunk-3X5JQYKN.js} +3 -3
- package/dist/{chunk-IQD4W53M.js → chunk-57Q75MS4.js} +18 -18
- package/dist/{chunk-EKPMVEIA.js → chunk-5FW7A6TG.js} +7 -4
- package/dist/chunk-5YCKFU5Q.js +1672 -0
- package/dist/{chunk-QYH2NR6G.js → chunk-7FV2LORT.js} +2 -2
- package/dist/{chunk-66F3HLW4.js → chunk-DEY23WTH.js} +122 -4
- package/dist/chunk-DJZPPCJP.js +274 -0
- package/dist/{chunk-MZEMLFFD.js → chunk-G6JXCUSK.js} +2 -2
- package/dist/{chunk-T6GOWHK6.js → chunk-GFOQDLPL.js} +6 -1
- package/dist/{chunk-OAIQ7A3R.js → chunk-GQP4GWU4.js} +5 -5
- package/dist/chunk-H4ZOKIER.js +7 -0
- package/dist/{chunk-RBNMNKNN.js → chunk-JQVSDPFL.js} +3 -3
- package/dist/{chunk-OG7QR2DP.js → chunk-KEHB4FZP.js} +17 -2
- package/dist/chunk-KUBHGVTD.js +126 -0
- package/dist/{chunk-IZABPDAO.js → chunk-KVNNVLJR.js} +2 -2
- package/dist/chunk-LFFIQBNY.js +115 -0
- package/dist/{chunk-PQTM27GU.js → chunk-MR5IBS6L.js} +6 -7
- package/dist/{chunk-M2RYXWX2.js → chunk-NHUMPEPV.js} +2 -2
- package/dist/{chunk-ONP6JRFZ.js → chunk-OFJIMBTL.js} +2 -2
- package/dist/{chunk-J6HNP6HA.js → chunk-OFPNCLG7.js} +2 -2
- package/dist/{chunk-FD6VGFYZ.js → chunk-OS5DF3LL.js} +207 -15
- package/dist/{chunk-L4MFGGSI.js → chunk-POTI2RJ6.js} +2 -2
- package/dist/{chunk-RMHZFWHF.js → chunk-R3MVL67T.js} +33 -33
- package/dist/{chunk-YN5GQCHN.js → chunk-RHJEGLYM.js} +6 -1
- package/dist/{chunk-4VK5G3SV.js → chunk-TBKVC2TA.js} +3 -5
- package/dist/{chunk-K2C3KFGB.js → chunk-UFWQTZDX.js} +29 -17
- package/dist/{chunk-JBHGJKSL.js → chunk-VBDDFO2V.js} +2 -2
- package/dist/{chunk-QOFSPFJ6.js → chunk-VUM6LO77.js} +3417 -3395
- package/dist/{chunk-CQZYQAAV.js → chunk-YLITJLTR.js} +3 -3
- package/dist/{chunk-O2JWF7ZM.js → chunk-Z4Q6RYJH.js} +2 -2
- package/dist/{chunk-QSIADSMQ.js → chunk-Z6WRFOFT.js} +3 -3
- package/dist/{chunk-5JPD6VIH.js → chunk-ZIJ5IUXH.js} +9 -3
- package/dist/{claude-GT2BPXEL.js → claude-XVLF4N4S.js} +3 -3
- package/dist/{cli-IV5DJCXU.js → cli-6FWRBCWM.js} +8 -8
- package/dist/{cli-6HTAJ54L.js → cli-RVPR3MH3.js} +7 -7
- package/dist/cli.js +11 -11
- package/dist/{completion-PPM7MEI2.js → completion-YTPHEVEW.js} +7 -7
- package/dist/{diagnostics-EWU2ROTG.js → diagnostics-IW54MLFK.js} +5 -6
- package/dist/{doctor-ZWZQMDKZ.js → doctor-EN4JPSKV.js} +35 -35
- package/dist/{entry-NDICBQ2F.js → entry-TQWSDTJ4.js} +14 -15
- package/dist/{exec-mcp-AG4G7SG7.js → exec-mcp-KKQ75N5O.js} +15 -13
- package/dist/{harness-JABSZCAA.js → harness-EB76F6BG.js} +6 -6
- package/dist/harness-launch-gate.js +3 -4
- package/dist/harness-worker.js +5 -6
- package/dist/hook-body.js +247 -86
- package/dist/{hook-spec-C7umArqw.d.ts → hook-spec-hZL4MSgi.d.ts} +8 -3
- package/dist/hooks-YWSHUNLM.js +24 -0
- package/dist/{host-2SZRMHZX.js → host-LSVITS6M.js} +6 -7
- package/dist/{host-BWZ5LA4Q.js → host-OGGADMBT.js} +17 -15
- package/dist/{host-run-SXLV4LHI.js → host-run-XO2TS4JC.js} +5 -7
- package/dist/http.js +1 -1
- package/dist/{import-mcp-2M7SZRVQ.js → import-mcp-BJDJTPVS.js} +14 -11
- package/dist/index.d.ts +11 -2
- package/dist/index.js +24 -24
- package/dist/{init-HOOIFBAD.js → init-773PTQM5.js} +3 -3
- package/dist/{install-HF6CROQP.js → install-7V6NIA7W.js} +4 -4
- package/dist/{invoke-JP4MILYY.js → invoke-Y7XH5S2L.js} +7 -8
- package/dist/{list-UBSBUZKS.js → list-5W65XVES.js} +20 -17
- package/dist/{logout-OO3DERRK.js → logout-XO6ALD45.js} +15 -12
- package/dist/{logs-K3QXKRD4.js → logs-74JGLQG6.js} +4 -4
- package/dist/{mailbox-DAJV6VAI.js → mailbox-VK5AVTHI.js} +7 -7
- package/dist/{mainline-6K5BA3WX.js → mainline-M2NSTAGC.js} +70 -24
- package/dist/{mcp-JXNTKRJG.js → mcp-R62ZNVGJ.js} +2 -2
- package/dist/{pause-GRVTSKOK.js → pause-CZ2OZYLC.js} +4 -4
- package/dist/project/hook-adapter.d.ts +1 -1
- package/dist/{project-M672MKQH.js → project-W5DQIZA6.js} +5 -5
- package/dist/{pty-LHKJKY2E.js → pty-CDLQ4NP2.js} +3 -3
- package/dist/report-Z3JV2PCT.js +105 -0
- package/dist/{resume-6DMPGG3N.js → resume-DFIHT2RO.js} +4 -4
- package/dist/{run-5W566T3V.js → run-OZLGSRHF.js} +14 -11
- package/dist/{run-ORBIERI3.js → run-WYJMTLX7.js} +4 -4
- package/dist/{serve-73SRPAV4.js → serve-DCQGAGB7.js} +3 -3
- package/dist/{session-XM2CR425.js → session-YZVX4NGN.js} +4 -4
- package/dist/{setup-ULKDPF5B.js → setup-D3KEJBGO.js} +4 -4
- package/dist/smoke-FQQJOQBD.js +16 -0
- package/dist/{start-login-BGFAMCZL.js → start-login-EKXM75XQ.js} +15 -12
- package/dist/{status-YCW6YJ3S.js → status-23UDIYYP.js} +39 -22
- package/dist/{status-YHXEAJ7U.js → status-3RTGDN2K.js} +10 -10
- package/dist/{status-73FEFQUQ.js → status-EDSEG32U.js} +15 -12
- package/dist/stdio.js +2 -2
- package/dist/{sweep-XF2HG3EO.js → sweep-EPJMEZR6.js} +4 -4
- package/dist/{test-IMNBXOYW.js → test-TM6PIZTV.js} +30 -20
- package/dist/{tui-5GDA22TB.js → tui-EQNJIDN5.js} +4 -4
- package/dist/{unbroadcast-XP3OCVN3.js → unbroadcast-NTOC3PY3.js} +4 -4
- package/dist/{worker-RV6NGSXT.js → worker-7X6WBPEI.js} +9 -10
- package/dist/{worktree-list-4PLE7K6L.js → worktree-list-EMKUMCTQ.js} +2 -2
- package/dist/{worktree-sync-GQVYAXGJ.js → worktree-sync-T6C5YEYS.js} +3 -3
- package/docs/commands.md +13 -6
- package/docs/git-workflow.md +28 -9
- package/docs/hooks.md +138 -10
- package/docs/project-configuration.md +27 -1
- package/docs/upgrading.md +42 -0
- package/gemini-extension.json +2 -2
- package/mcp.json +1 -1
- package/package.json +5 -5
- package/plugin.json +1 -1
- package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
- package/plugins/pmcp/.mcp.json +1 -1
- package/plugins/pmcp/gemini-extension.json +2 -2
- package/plugins/pmcp/mcp.json +1 -1
- package/plugins/pmcp/mod/sessions/format.ts +2 -2
- package/plugins/pmcp/plugin.json +1 -1
- package/dist/chunk-7SDOSTW7.js +0 -130
- package/dist/chunk-AWZF72SH.js +0 -1025
- package/dist/chunk-FGYFA6JY.js +0 -7
- package/dist/chunk-ISNRDHSD.js +0 -74
- package/dist/chunk-QDY6BWE6.js +0 -396
- package/dist/hooks-YVQSDQV3.js +0 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openStore,
|
|
3
3
|
readStoreSettings
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MR5IBS6L.js";
|
|
5
5
|
import {
|
|
6
6
|
ArgumentError,
|
|
7
7
|
one
|
|
@@ -73,4 +73,4 @@ export {
|
|
|
73
73
|
storeFrom,
|
|
74
74
|
change
|
|
75
75
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-7FV2LORT.js.map
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-OEH47H6A.js";
|
|
4
4
|
import {
|
|
5
5
|
VERSION
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H4ZOKIER.js";
|
|
7
7
|
import {
|
|
8
8
|
ConfigError
|
|
9
9
|
} from "./chunk-GJXOFDJT.js";
|
|
10
10
|
import {
|
|
11
|
-
envNames
|
|
11
|
+
envNames,
|
|
12
|
+
pickEnv
|
|
12
13
|
} from "./chunk-J6KL3COD.js";
|
|
13
14
|
|
|
14
15
|
// src/native/binary.ts
|
|
@@ -204,6 +205,11 @@ function writeLock(root, outputs) {
|
|
|
204
205
|
);
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
// src/project/host.ts
|
|
209
|
+
import { createHash as createHash2 } from "crypto";
|
|
210
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
211
|
+
import { join as join4 } from "path";
|
|
212
|
+
|
|
207
213
|
// src/project/host-spec.ts
|
|
208
214
|
import { isAbsolute, normalize } from "path";
|
|
209
215
|
|
|
@@ -447,6 +453,111 @@ function readHost(path, raw) {
|
|
|
447
453
|
};
|
|
448
454
|
}
|
|
449
455
|
|
|
456
|
+
// src/project/host.ts
|
|
457
|
+
var HOST_DIRECTORY = ".agents/pmcp-pty";
|
|
458
|
+
var HOST_MANIFEST = `${HOST_DIRECTORY}/host.json`;
|
|
459
|
+
var HOST_POLICY = `${HOST_DIRECTORY}/policy.json`;
|
|
460
|
+
function hostPolicy(host) {
|
|
461
|
+
const browser = host.browser.allowPrivate;
|
|
462
|
+
const launch = host.desktop.launch;
|
|
463
|
+
return {
|
|
464
|
+
version: 1,
|
|
465
|
+
mcp_write: host.mcpWrite,
|
|
466
|
+
roots: host.roots,
|
|
467
|
+
allow: host.answers.map((a) => ({
|
|
468
|
+
profile: a.runtime,
|
|
469
|
+
dialog: a.dialog,
|
|
470
|
+
options: a.options
|
|
471
|
+
})),
|
|
472
|
+
...browser.length > 0 ? { browser: { allow_private: browser } } : {},
|
|
473
|
+
...launch.length > 0 ? { desktop: { launch } } : {}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function hostManifest(host) {
|
|
477
|
+
return {
|
|
478
|
+
version: 1,
|
|
479
|
+
sessions: host.sessions.map((s) => ({
|
|
480
|
+
name: s.name,
|
|
481
|
+
profile: s.runtime,
|
|
482
|
+
cwd: s.cwd,
|
|
483
|
+
argv: s.argv,
|
|
484
|
+
labels: { ...s.labels, "pmcp.host": s.name },
|
|
485
|
+
restart: s.restart,
|
|
486
|
+
max_restarts: s.maxRestarts,
|
|
487
|
+
delivery_setup: true,
|
|
488
|
+
// Only when declared, so an approval made before env existed stays valid.
|
|
489
|
+
...s.env.length > 0 ? { env: s.env } : {}
|
|
490
|
+
}))
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
var json = (value) => `${JSON.stringify(value, null, 2)}
|
|
494
|
+
`;
|
|
495
|
+
function hostOutputs(spec) {
|
|
496
|
+
if (!spec.host) return [];
|
|
497
|
+
return [
|
|
498
|
+
{
|
|
499
|
+
kind: "file",
|
|
500
|
+
path: HOST_MANIFEST,
|
|
501
|
+
content: json(hostManifest(spec.host))
|
|
502
|
+
},
|
|
503
|
+
{ kind: "file", path: HOST_POLICY, content: json(hostPolicy(spec.host)) }
|
|
504
|
+
];
|
|
505
|
+
}
|
|
506
|
+
function ptyBinary(env) {
|
|
507
|
+
return nativeBinary("pmcp-pty", "PMCP_PTY_BIN", env);
|
|
508
|
+
}
|
|
509
|
+
function ptyBinaryDoctor(env) {
|
|
510
|
+
const found = ptyBinary(env);
|
|
511
|
+
return found ? { tool: "project", check: "pmcp-pty binary", status: "ok", detail: found } : {
|
|
512
|
+
tool: "project",
|
|
513
|
+
check: "pmcp-pty binary",
|
|
514
|
+
status: "warn",
|
|
515
|
+
detail: missingBinary("pmcp-pty", "PMCP_PTY_BIN", VERSION)
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function hostEnvDoctor(spec, env) {
|
|
519
|
+
return (spec.host?.sessions ?? []).filter((s) => s.env.length > 0).map((s) => {
|
|
520
|
+
const { missing } = pickEnv(s.env, env);
|
|
521
|
+
return missing.length === 0 ? {
|
|
522
|
+
tool: "project",
|
|
523
|
+
check: `host env (${s.name})`,
|
|
524
|
+
status: "ok",
|
|
525
|
+
detail: `set: ${s.env.join(", ")}`
|
|
526
|
+
} : {
|
|
527
|
+
tool: "project",
|
|
528
|
+
check: `host env (${s.name})`,
|
|
529
|
+
status: "warn",
|
|
530
|
+
detail: `not set: ${missing.join(", ")}; host up refuses ${s.name} until they are`
|
|
531
|
+
};
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
var sha256 = (text2) => createHash2("sha256").update(text2).digest("hex");
|
|
535
|
+
function hostDoctor(spec) {
|
|
536
|
+
if (!spec.host) return [];
|
|
537
|
+
const lock = new Map(readLock(spec.root).map((e) => [e.path, e]));
|
|
538
|
+
const bad = [HOST_MANIFEST, HOST_POLICY].filter((path) => {
|
|
539
|
+
const file = join4(spec.root, path);
|
|
540
|
+
if (!existsSync3(file)) return true;
|
|
541
|
+
const entry = lock.get(path);
|
|
542
|
+
return entry?.sha256 !== sha256(readFileSync3(file, "utf8"));
|
|
543
|
+
});
|
|
544
|
+
const { sessions, answers, mcpWrite } = spec.host;
|
|
545
|
+
const summary = `${sessions.length} session(s), ${answers.length} answer rule(s), mcp_write ${mcpWrite}`;
|
|
546
|
+
return [
|
|
547
|
+
bad.length === 0 ? {
|
|
548
|
+
tool: "project",
|
|
549
|
+
check: "pmcp-pty host projected",
|
|
550
|
+
status: "ok",
|
|
551
|
+
detail: summary
|
|
552
|
+
} : {
|
|
553
|
+
tool: "project",
|
|
554
|
+
check: "pmcp-pty host projected",
|
|
555
|
+
status: "fail",
|
|
556
|
+
detail: `run pmcp project: ${bad.join(", ")}`
|
|
557
|
+
}
|
|
558
|
+
];
|
|
559
|
+
}
|
|
560
|
+
|
|
450
561
|
export {
|
|
451
562
|
packagedBinary,
|
|
452
563
|
missingBinary,
|
|
@@ -458,6 +569,13 @@ export {
|
|
|
458
569
|
LOCK_FILE,
|
|
459
570
|
readLock,
|
|
460
571
|
writeLock,
|
|
461
|
-
readHost
|
|
572
|
+
readHost,
|
|
573
|
+
HOST_MANIFEST,
|
|
574
|
+
HOST_POLICY,
|
|
575
|
+
hostOutputs,
|
|
576
|
+
ptyBinary,
|
|
577
|
+
ptyBinaryDoctor,
|
|
578
|
+
hostEnvDoctor,
|
|
579
|
+
hostDoctor
|
|
462
580
|
};
|
|
463
|
-
//# sourceMappingURL=chunk-
|
|
581
|
+
//# sourceMappingURL=chunk-DEY23WTH.js.map
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SETTINGS,
|
|
3
|
+
block,
|
|
4
|
+
censusDirs,
|
|
5
|
+
changedSincePlan,
|
|
6
|
+
deleteKey,
|
|
7
|
+
fingerprint,
|
|
8
|
+
getKey,
|
|
9
|
+
isPermissionPath,
|
|
10
|
+
linkOf,
|
|
11
|
+
permissionProblems,
|
|
12
|
+
permissionWarnings,
|
|
13
|
+
plan,
|
|
14
|
+
programVersion,
|
|
15
|
+
readJson,
|
|
16
|
+
same,
|
|
17
|
+
setKey,
|
|
18
|
+
splitFrontmatter,
|
|
19
|
+
splitKeyed,
|
|
20
|
+
versionMatches,
|
|
21
|
+
withoutBlock
|
|
22
|
+
} from "./chunk-VUM6LO77.js";
|
|
23
|
+
import {
|
|
24
|
+
ProjectError,
|
|
25
|
+
RULES_DIR,
|
|
26
|
+
trackedFiles
|
|
27
|
+
} from "./chunk-NRBQK6UX.js";
|
|
28
|
+
import {
|
|
29
|
+
lockVersionProblem,
|
|
30
|
+
readLock,
|
|
31
|
+
replaceFile
|
|
32
|
+
} from "./chunk-DEY23WTH.js";
|
|
33
|
+
|
|
34
|
+
// src/project/apply/census.ts
|
|
35
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
36
|
+
import { join, posix } from "path";
|
|
37
|
+
function undeclared(spec, outputs) {
|
|
38
|
+
const declared = new Set(outputs.map((o) => o.path));
|
|
39
|
+
const found = [];
|
|
40
|
+
for (const dir of censusDirs(spec)) {
|
|
41
|
+
const abs = join(spec.root, dir);
|
|
42
|
+
if (!existsSync(abs)) continue;
|
|
43
|
+
for (const entry of readdirSync(abs)) {
|
|
44
|
+
const path = `${dir}/${entry}`;
|
|
45
|
+
if (!declared.has(path)) found.push(path);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const rules = join(spec.root, RULES_DIR);
|
|
49
|
+
if (spec.tools.has("grok") && existsSync(rules)) {
|
|
50
|
+
for (const entry of readdirSync(rules, { withFileTypes: true })) {
|
|
51
|
+
if (entry.isDirectory()) continue;
|
|
52
|
+
found.push(`${RULES_DIR}/${entry.name}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return found.sort();
|
|
56
|
+
}
|
|
57
|
+
function deadGlobs(root, outputs) {
|
|
58
|
+
const rules = outputs.filter(
|
|
59
|
+
(o) => (o.kind === "link" || o.kind === "file") && o.path.startsWith(`${RULES_DIR}/`)
|
|
60
|
+
);
|
|
61
|
+
if (rules.length === 0) return [];
|
|
62
|
+
const tracked = trackedFiles(root, true);
|
|
63
|
+
if (tracked.length === 0) return [];
|
|
64
|
+
const seen = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const file of tracked) {
|
|
66
|
+
const parts = file.split("/");
|
|
67
|
+
for (let i = 1; i <= parts.length; i += 1)
|
|
68
|
+
seen.add(parts.slice(0, i).join("/"));
|
|
69
|
+
}
|
|
70
|
+
const dead = [];
|
|
71
|
+
for (const rule of rules) {
|
|
72
|
+
let text;
|
|
73
|
+
if (rule.kind === "file") {
|
|
74
|
+
text = rule.content;
|
|
75
|
+
} else if (rule.kind === "link") {
|
|
76
|
+
const abs = join(root, posix.join(posix.dirname(rule.path), rule.target));
|
|
77
|
+
if (!existsSync(abs)) continue;
|
|
78
|
+
text = readFileSync(abs, "utf8");
|
|
79
|
+
} else {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const paths = splitFrontmatter(text).meta["paths"];
|
|
83
|
+
for (const glob of [paths ?? []].flat()) {
|
|
84
|
+
if (typeof glob !== "string") continue;
|
|
85
|
+
const prefix = glob.replace(/\*.*$/u, "").replace(/\/$/u, "");
|
|
86
|
+
if (prefix !== "" && !seen.has(prefix))
|
|
87
|
+
dead.push(`${rule.path}: ${glob}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return dead;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/project/guard-versions.ts
|
|
94
|
+
function guardVersionProblems(spec, env = process.env) {
|
|
95
|
+
const problems = [];
|
|
96
|
+
for (const entry of spec.hookBundle?.policy?.custom ?? []) {
|
|
97
|
+
if (entry.version === void 0) continue;
|
|
98
|
+
const program = entry.command[0] ?? "";
|
|
99
|
+
const output = programVersion(program, spec.root, env);
|
|
100
|
+
if (output === null)
|
|
101
|
+
problems.push(
|
|
102
|
+
`custom guard ${entry.name}: ${program} --version did not run; install ${program} ${entry.version}`
|
|
103
|
+
);
|
|
104
|
+
else if (!versionMatches(output, entry.version))
|
|
105
|
+
problems.push(
|
|
106
|
+
`custom guard ${entry.name}: ${program} --version reports "${output.split("\n")[0]}", not ${entry.version}; review the program and update version`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return problems;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/project/apply/native.ts
|
|
113
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rmSync } from "fs";
|
|
114
|
+
import { dirname, join as join2 } from "path";
|
|
115
|
+
function readNativeJson(root, outputs, stale) {
|
|
116
|
+
const jsonPaths = new Set(
|
|
117
|
+
outputs.filter((output) => output.kind === "json").map((output) => output.file)
|
|
118
|
+
);
|
|
119
|
+
for (const entry of stale) {
|
|
120
|
+
const keyed = splitKeyed(entry.path);
|
|
121
|
+
if (entry.kind === "json" && keyed) {
|
|
122
|
+
jsonPaths.add(keyed.file);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const path of jsonPaths) {
|
|
126
|
+
readJson(join2(root, path));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function writeJson(root, file, sets, drops) {
|
|
130
|
+
const abs = join2(root, file);
|
|
131
|
+
const before = readJson(abs);
|
|
132
|
+
const after = structuredClone(before);
|
|
133
|
+
for (const key of drops) deleteKey(after, key);
|
|
134
|
+
for (const output of sets) {
|
|
135
|
+
if (output.kind !== "json") {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (output.managed && Array.isArray(output.value) && output.value.length === 0) {
|
|
139
|
+
deleteKey(after, output.key);
|
|
140
|
+
} else {
|
|
141
|
+
setKey(after, output.key, output.value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (same(before, after)) return;
|
|
145
|
+
if (!existsSync2(abs) && Object.keys(after).length === 0) return;
|
|
146
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
147
|
+
replaceFile(abs, `${JSON.stringify(after, null, 2)}
|
|
148
|
+
`);
|
|
149
|
+
}
|
|
150
|
+
function separator(before) {
|
|
151
|
+
if (before === "" || before.endsWith("\n\n")) return "";
|
|
152
|
+
return before.endsWith("\n") ? "\n" : "\n\n";
|
|
153
|
+
}
|
|
154
|
+
function writeBlock(root, file, content) {
|
|
155
|
+
const abs = join2(root, file);
|
|
156
|
+
const before = existsSync2(abs) ? readFileSync2(abs, "utf8") : "";
|
|
157
|
+
let after = withoutBlock(before);
|
|
158
|
+
if (content !== null) {
|
|
159
|
+
const sep = separator(after);
|
|
160
|
+
after = `${after}${sep}${block(content)}`;
|
|
161
|
+
}
|
|
162
|
+
if (after === before) return;
|
|
163
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
164
|
+
replaceFile(abs, after);
|
|
165
|
+
}
|
|
166
|
+
function writeNative(root, outputs, stale, basis = /* @__PURE__ */ new Map()) {
|
|
167
|
+
const moved = changedSincePlan(root, basis);
|
|
168
|
+
if (moved.length > 0) throw new ProjectError(moved.join("; "));
|
|
169
|
+
let pruned = 0;
|
|
170
|
+
const jsonFiles = /* @__PURE__ */ new Map();
|
|
171
|
+
const blockFiles = /* @__PURE__ */ new Map();
|
|
172
|
+
for (const output of outputs) {
|
|
173
|
+
if (output.kind === "json") {
|
|
174
|
+
const entry = jsonFiles.get(output.file) ?? { sets: [], drops: [] };
|
|
175
|
+
entry.sets.push(output);
|
|
176
|
+
jsonFiles.set(output.file, entry);
|
|
177
|
+
}
|
|
178
|
+
if (output.kind === "block") blockFiles.set(output.file, output.content);
|
|
179
|
+
}
|
|
180
|
+
for (const entry of stale) {
|
|
181
|
+
const keyed = splitKeyed(entry.path);
|
|
182
|
+
if (keyed && keyed.key.length === 1 && keyed.key[0] === "pmcp") {
|
|
183
|
+
if (!blockFiles.has(keyed.file)) blockFiles.set(keyed.file, null);
|
|
184
|
+
} else if (keyed) {
|
|
185
|
+
const group = jsonFiles.get(keyed.file) ?? { sets: [], drops: [] };
|
|
186
|
+
group.drops.push(keyed.key);
|
|
187
|
+
jsonFiles.set(keyed.file, group);
|
|
188
|
+
} else {
|
|
189
|
+
rmSync(join2(root, entry.path), { force: true, recursive: true });
|
|
190
|
+
}
|
|
191
|
+
pruned += 1;
|
|
192
|
+
}
|
|
193
|
+
for (const [file, { sets, drops }] of jsonFiles)
|
|
194
|
+
writeJson(root, file, sets, drops);
|
|
195
|
+
for (const [file, content] of blockFiles) writeBlock(root, file, content);
|
|
196
|
+
return pruned;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/project/apply/prepare.ts
|
|
200
|
+
import { join as join3 } from "path";
|
|
201
|
+
function prepare(spec) {
|
|
202
|
+
const basis = /* @__PURE__ */ new Map([
|
|
203
|
+
[SETTINGS, fingerprint(join3(spec.root, SETTINGS))]
|
|
204
|
+
]);
|
|
205
|
+
const lock = readLock(spec.root);
|
|
206
|
+
const ownedTargets = new Map(
|
|
207
|
+
lock.filter((entry) => entry.kind === "link" && entry.target !== void 0).map((entry) => [entry.path, entry.target])
|
|
208
|
+
);
|
|
209
|
+
const outputs = plan(spec, ownedTargets);
|
|
210
|
+
const owned = new Set(lock.map((entry) => entry.path));
|
|
211
|
+
const planned = new Set(outputs.map((output) => output.path));
|
|
212
|
+
const stale = lock.filter((entry) => !planned.has(entry.path));
|
|
213
|
+
readNativeJson(spec.root, outputs, stale);
|
|
214
|
+
return { outputs, owned, stale, basis };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/project/apply/present.ts
|
|
218
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
219
|
+
import { join as join4 } from "path";
|
|
220
|
+
function present(root, output) {
|
|
221
|
+
const abs = join4(root, "file" in output ? output.file : output.path);
|
|
222
|
+
switch (output.kind) {
|
|
223
|
+
case "link":
|
|
224
|
+
return linkOf(abs) === output.target;
|
|
225
|
+
case "file":
|
|
226
|
+
return existsSync3(abs) && linkOf(abs) === null && readFileSync3(abs, "utf8") === output.content;
|
|
227
|
+
case "json":
|
|
228
|
+
if (output.managed && Array.isArray(output.value) && output.value.length === 0) {
|
|
229
|
+
return getKey(readJson(abs), output.key) === void 0;
|
|
230
|
+
}
|
|
231
|
+
return same(getKey(readJson(abs), output.key), output.value);
|
|
232
|
+
case "block":
|
|
233
|
+
return existsSync3(abs) && readFileSync3(abs, "utf8").includes(block(output.content));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/project/apply/check.ts
|
|
238
|
+
function checkProblems(spec, outputs, stale) {
|
|
239
|
+
return [
|
|
240
|
+
...outputs.filter((o) => !isPermissionPath(o.path) && !present(spec.root, o)).map((o) => `drift: ${o.path}`),
|
|
241
|
+
...permissionProblems(spec),
|
|
242
|
+
...stale.map((e) => `stale: ${e.path}`),
|
|
243
|
+
...undeclared(spec, outputs).map((p) => `undeclared: ${p}`),
|
|
244
|
+
...deadGlobs(spec.root, outputs).map((p) => `dead glob: ${p}`),
|
|
245
|
+
...[lockVersionProblem(spec.root)].filter((p) => p !== null)
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/project/apply/check-project.ts
|
|
250
|
+
function checkProject(spec) {
|
|
251
|
+
const { outputs, stale } = prepare(spec);
|
|
252
|
+
const problems = [
|
|
253
|
+
...checkProblems(spec, outputs, stale),
|
|
254
|
+
...guardVersionProblems(spec)
|
|
255
|
+
];
|
|
256
|
+
const warnings = [...permissionWarnings(spec), ...spec.deprecations ?? []];
|
|
257
|
+
return {
|
|
258
|
+
code: problems.length > 0 ? 2 : 0,
|
|
259
|
+
problems,
|
|
260
|
+
...warnings.length > 0 ? { warnings } : {},
|
|
261
|
+
outputs: outputs.length,
|
|
262
|
+
pruned: 0
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export {
|
|
267
|
+
guardVersionProblems,
|
|
268
|
+
deadGlobs,
|
|
269
|
+
present,
|
|
270
|
+
writeNative,
|
|
271
|
+
prepare,
|
|
272
|
+
checkProject
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=chunk-DJZPPCJP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSkillServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z4Q6RYJH.js";
|
|
4
4
|
import {
|
|
5
5
|
attachMailbox
|
|
6
6
|
} from "./chunk-JZKAJUVT.js";
|
|
@@ -84,4 +84,4 @@ export {
|
|
|
84
84
|
serveWithMailbox,
|
|
85
85
|
main
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-G6JXCUSK.js.map
|
|
@@ -20,6 +20,11 @@ var gitSpec = {
|
|
|
20
20
|
name: "during-pause",
|
|
21
21
|
describe: "Deliver although the sessions are paused",
|
|
22
22
|
boolean: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "no-push",
|
|
26
|
+
describe: "Replay and gate, then stop without pushing",
|
|
27
|
+
boolean: true
|
|
23
28
|
}
|
|
24
29
|
]
|
|
25
30
|
};
|
|
@@ -27,4 +32,4 @@ var gitSpec = {
|
|
|
27
32
|
export {
|
|
28
33
|
gitSpec
|
|
29
34
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-GFOQDLPL.js.map
|
|
@@ -7,20 +7,20 @@ import {
|
|
|
7
7
|
observeSession,
|
|
8
8
|
openGroup,
|
|
9
9
|
runOperation
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YLITJLTR.js";
|
|
11
11
|
import {
|
|
12
12
|
nativeHostTools
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-POTI2RJ6.js";
|
|
14
14
|
import {
|
|
15
15
|
locateExecutable
|
|
16
16
|
} from "./chunk-R2GPCZUX.js";
|
|
17
17
|
import {
|
|
18
18
|
artifact,
|
|
19
19
|
stateDirectory
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-33KGCJB2.js";
|
|
21
21
|
import {
|
|
22
22
|
ptyBinary
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DEY23WTH.js";
|
|
24
24
|
import {
|
|
25
25
|
GroupStore,
|
|
26
26
|
privateJson
|
|
@@ -249,4 +249,4 @@ async function invoke(operation) {
|
|
|
249
249
|
export {
|
|
250
250
|
invoke
|
|
251
251
|
};
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
252
|
+
//# sourceMappingURL=chunk-GQP4GWU4.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claudeSocket
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NHUMPEPV.js";
|
|
4
4
|
import {
|
|
5
5
|
opencodeUrl
|
|
6
6
|
} from "./chunk-TIA4SPU2.js";
|
|
7
7
|
import {
|
|
8
8
|
ptyReachable,
|
|
9
9
|
ptyRef
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OFJIMBTL.js";
|
|
11
11
|
|
|
12
12
|
// src/sessions/wake/probe.ts
|
|
13
13
|
function wakeableBy(record, context) {
|
|
@@ -22,4 +22,4 @@ function wakeableBy(record, context) {
|
|
|
22
22
|
export {
|
|
23
23
|
wakeableBy
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-JQVSDPFL.js.map
|
|
@@ -30,10 +30,25 @@ var initSpec = {
|
|
|
30
30
|
var hooksSpec = {
|
|
31
31
|
name: "hooks",
|
|
32
32
|
describe: "List compiled policies or simulate a native hook without a runtime",
|
|
33
|
-
usage: "pmcp hooks list | test --runtime claude|codex --event <event> [--command <text> | --path <path> | --tool <name>] [--session-state <file>] [--json]",
|
|
33
|
+
usage: "pmcp hooks list | test --runtime claude|codex --event <event> [--command <text> | --path <path> | --tool <name>] [--session-state <file>] [--json] | test --fixtures <file> [--json] | report [--since <when>] [--switch-check <guard>] [--json]",
|
|
34
34
|
options: [
|
|
35
35
|
configOption,
|
|
36
36
|
jsonOption,
|
|
37
|
+
{
|
|
38
|
+
name: "fixtures",
|
|
39
|
+
describe: "Run these cases through the projected hook entry for every wired runtime.",
|
|
40
|
+
placeholder: "<file>"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "since",
|
|
44
|
+
describe: "Report only log lines from this long ago (10m, 2h, 3d) or this ISO time.",
|
|
45
|
+
placeholder: "<when>"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "switch-check",
|
|
49
|
+
describe: "List the calls this guard found something in but let through.",
|
|
50
|
+
placeholder: "<guard>"
|
|
51
|
+
},
|
|
37
52
|
{
|
|
38
53
|
name: "runtime",
|
|
39
54
|
describe: "Native runtime to inspect.",
|
|
@@ -72,4 +87,4 @@ export {
|
|
|
72
87
|
initSpec,
|
|
73
88
|
hooksSpec
|
|
74
89
|
};
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-KEHB4FZP.js.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
git,
|
|
3
|
+
gitText
|
|
4
|
+
} from "./chunk-G7JONWL4.js";
|
|
5
|
+
|
|
6
|
+
// src/git/superseded.ts
|
|
7
|
+
import { existsSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var GITLINK = /^:160000 160000 [0-9a-f]{40} ([0-9a-f]{40}) M$/u;
|
|
10
|
+
function submoduleRepo(cwd, path) {
|
|
11
|
+
const checkout = join(cwd, path);
|
|
12
|
+
if (existsSync(join(checkout, ".git"))) return checkout;
|
|
13
|
+
const common = gitText(cwd, [
|
|
14
|
+
"rev-parse",
|
|
15
|
+
"--path-format=absolute",
|
|
16
|
+
"--git-common-dir"
|
|
17
|
+
]);
|
|
18
|
+
const kept = common ? join(common, "modules", path) : "";
|
|
19
|
+
return kept && existsSync(kept) ? kept : null;
|
|
20
|
+
}
|
|
21
|
+
function pinsSuperseded(cwd, upstream, sha) {
|
|
22
|
+
const parents = gitText(cwd, ["rev-list", "--parents", "-n", "1", sha]);
|
|
23
|
+
if (parents.split(" ").length !== 2) return false;
|
|
24
|
+
const diff = git(cwd, [
|
|
25
|
+
"diff-tree",
|
|
26
|
+
"--raw",
|
|
27
|
+
"--no-commit-id",
|
|
28
|
+
"--no-renames",
|
|
29
|
+
"--abbrev=40",
|
|
30
|
+
"-z",
|
|
31
|
+
"-r",
|
|
32
|
+
`${sha}^`,
|
|
33
|
+
sha
|
|
34
|
+
]);
|
|
35
|
+
const fields = diff.stdout.split("\0").slice(0, -1);
|
|
36
|
+
if (diff.status !== 0 || fields.length === 0 || fields.length % 2 !== 0)
|
|
37
|
+
return false;
|
|
38
|
+
for (let index = 0; index < fields.length; index += 2) {
|
|
39
|
+
const pin = GITLINK.exec(fields[index] ?? "")?.[1];
|
|
40
|
+
const path = fields[index + 1];
|
|
41
|
+
if (pin === void 0 || !path) return false;
|
|
42
|
+
const listed = gitText(cwd, ["ls-tree", upstream, "--", path]);
|
|
43
|
+
const theirs = /^160000 commit ([0-9a-f]{40})\t/u.exec(listed)?.[1];
|
|
44
|
+
if (theirs === void 0) return false;
|
|
45
|
+
if (theirs === pin) continue;
|
|
46
|
+
const repo = submoduleRepo(cwd, path);
|
|
47
|
+
if (repo === null) return false;
|
|
48
|
+
if (git(repo, ["merge-base", "--is-ancestor", pin, theirs]).status !== 0)
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/git/landed.ts
|
|
55
|
+
function cherry(cwd, upstream, head = "HEAD") {
|
|
56
|
+
const listed = git(cwd, ["cherry", "-v", upstream, head]).stdout;
|
|
57
|
+
const carried = [];
|
|
58
|
+
const missing = [];
|
|
59
|
+
for (const line of listed.split("\n")) {
|
|
60
|
+
if (line.startsWith("- ")) carried.push(line.slice(2));
|
|
61
|
+
if (!line.startsWith("+ ")) continue;
|
|
62
|
+
const sha = line.slice(2).split(" ")[0] ?? "";
|
|
63
|
+
if (pinsSuperseded(cwd, upstream, sha)) carried.push(line.slice(2));
|
|
64
|
+
else missing.push(line.slice(2));
|
|
65
|
+
}
|
|
66
|
+
return { carried, missing };
|
|
67
|
+
}
|
|
68
|
+
function undelivered(cwd, upstream, named) {
|
|
69
|
+
if (named.length === 0)
|
|
70
|
+
return cherry(cwd, upstream).missing.map(
|
|
71
|
+
(line) => line.split(" ")[0] ?? ""
|
|
72
|
+
);
|
|
73
|
+
const shas = [];
|
|
74
|
+
for (const ref of named) {
|
|
75
|
+
const sha = gitText(cwd, [
|
|
76
|
+
"rev-parse",
|
|
77
|
+
"--verify",
|
|
78
|
+
"-q",
|
|
79
|
+
`${ref}^{commit}`
|
|
80
|
+
]);
|
|
81
|
+
if (!sha) throw new Error(`${ref} is not a commit`);
|
|
82
|
+
const listed = git(cwd, ["cherry", upstream, sha, `${sha}^`]).stdout;
|
|
83
|
+
if (listed.startsWith("+ ") && !pinsSuperseded(cwd, upstream, sha))
|
|
84
|
+
shas.push(sha);
|
|
85
|
+
}
|
|
86
|
+
return shas;
|
|
87
|
+
}
|
|
88
|
+
function touchedPaths(cwd, commits) {
|
|
89
|
+
const paths = /* @__PURE__ */ new Set();
|
|
90
|
+
for (const sha of commits) {
|
|
91
|
+
const listed = gitText(cwd, [
|
|
92
|
+
"diff-tree",
|
|
93
|
+
"--no-commit-id",
|
|
94
|
+
"--name-only",
|
|
95
|
+
"-r",
|
|
96
|
+
sha
|
|
97
|
+
]);
|
|
98
|
+
for (const path of listed.split("\n")) {
|
|
99
|
+
if (path) paths.add(path);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return paths;
|
|
103
|
+
}
|
|
104
|
+
function isAncestor(cwd, ancestor, of) {
|
|
105
|
+
return git(cwd, ["merge-base", "--is-ancestor", ancestor, of]).status === 0;
|
|
106
|
+
}
|
|
107
|
+
function distance(cwd, upstream) {
|
|
108
|
+
const counted = gitText(cwd, [
|
|
109
|
+
"rev-list",
|
|
110
|
+
"--left-right",
|
|
111
|
+
"--count",
|
|
112
|
+
`${upstream}...HEAD`
|
|
113
|
+
]);
|
|
114
|
+
if (!counted) return null;
|
|
115
|
+
const [behind = 0, ahead = 0] = counted.split(/\s+/u).map(Number);
|
|
116
|
+
return { behind, ahead };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
cherry,
|
|
121
|
+
undelivered,
|
|
122
|
+
touchedPaths,
|
|
123
|
+
isAncestor,
|
|
124
|
+
distance
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=chunk-KUBHGVTD.js.map
|