@modootoday/pmcp 0.17.4 → 0.18.2

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.
Files changed (272) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.mcp.json +1 -1
  5. package/CHANGELOG.md +152 -0
  6. package/CONTRIBUTING.md +71 -0
  7. package/README.md +98 -201
  8. package/SECURITY.md +17 -1
  9. package/dist/apply-JUTGS5WZ.js +242 -0
  10. package/dist/{attachment-tU5FZrgZ.d.ts → attachment-D84OGI6n.d.ts} +1 -1
  11. package/dist/available-DBSIVVJ6.js +73 -0
  12. package/dist/broadcast-CBMVOV3G.js +18 -0
  13. package/dist/chunk-26WLNWDG.js +93 -0
  14. package/dist/chunk-2FIV63WC.js +252 -0
  15. package/dist/chunk-2P4Z2NUX.js +28 -0
  16. package/dist/chunk-34DECPVC.js +22 -0
  17. package/dist/chunk-3FCFAQDG.js +42 -0
  18. package/dist/chunk-3IDXEV5E.js +1934 -0
  19. package/dist/chunk-3PW4FI7U.js +32 -0
  20. package/dist/chunk-3Y3HDMHA.js +108 -0
  21. package/dist/chunk-47O3X4VS.js +113 -0
  22. package/dist/chunk-4NDEP7HU.js +26 -0
  23. package/dist/chunk-5OMOPUE6.js +39 -0
  24. package/dist/chunk-5QQWS4US.js +53 -0
  25. package/dist/chunk-5ZABTVSW.js +48 -0
  26. package/dist/chunk-65KAQSJP.js +7 -0
  27. package/dist/chunk-6STKGOCW.js +27 -0
  28. package/dist/chunk-6WXMJOMI.js +9 -0
  29. package/dist/chunk-73AKO4UL.js +24 -0
  30. package/dist/chunk-7DLZC73N.js +29 -0
  31. package/dist/chunk-7GBYECSK.js +72 -0
  32. package/dist/chunk-7HFIGCSL.js +419 -0
  33. package/dist/chunk-7TD53M7L.js +13 -0
  34. package/dist/chunk-7UCZAN4J.js +778 -0
  35. package/dist/chunk-A4PKLESO.js +112 -0
  36. package/dist/chunk-A7VF7A35.js +1025 -0
  37. package/dist/chunk-ABTJQ4QV.js +74 -0
  38. package/dist/chunk-AJ4VXM2U.js +349 -0
  39. package/dist/chunk-BBTBJCFA.js +380 -0
  40. package/dist/chunk-BU65MNVU.js +13 -0
  41. package/dist/chunk-C4NHQGHL.js +142 -0
  42. package/dist/chunk-CJTKR6K6.js +1213 -0
  43. package/dist/chunk-D77IRGHO.js +1246 -0
  44. package/dist/chunk-DCU2EXQV.js +78 -0
  45. package/dist/chunk-DMZHQZ7P.js +104 -0
  46. package/dist/chunk-DZ2MRTYT.js +135 -0
  47. package/dist/chunk-E2YOZ2FF.js +207 -0
  48. package/dist/chunk-E3DQB5LS.js +48 -0
  49. package/dist/chunk-EATCUWGG.js +66 -0
  50. package/dist/chunk-EAWPJHJ7.js +155 -0
  51. package/dist/chunk-EIDIVIAD.js +33 -0
  52. package/dist/chunk-F5QYZK7E.js +396 -0
  53. package/dist/chunk-F5XMGOOX.js +28 -0
  54. package/dist/chunk-FENOGX3U.js +31 -0
  55. package/dist/chunk-GZHHEHKY.js +44 -0
  56. package/dist/chunk-HDMBVLCZ.js +53 -0
  57. package/dist/chunk-HQOB7OQS.js +81 -0
  58. package/dist/chunk-I2ZP2PSA.js +211 -0
  59. package/dist/chunk-IG33DXLT.js +151 -0
  60. package/dist/chunk-IJBSOWHK.js +86 -0
  61. package/dist/chunk-INT7QLEU.js +114 -0
  62. package/dist/chunk-J7UYNJCR.js +9 -0
  63. package/dist/chunk-JEL35P7S.js +53 -0
  64. package/dist/chunk-JGJ4INEN.js +32 -0
  65. package/dist/chunk-JS5RTH4I.js +84 -0
  66. package/dist/chunk-JWRZDYB5.js +59 -0
  67. package/dist/chunk-KMXRRSKT.js +660 -0
  68. package/dist/chunk-LBXO4VPG.js +73 -0
  69. package/dist/chunk-LLBPVZXM.js +67 -0
  70. package/dist/chunk-LLT5FQBE.js +57 -0
  71. package/dist/chunk-LMT3PPXJ.js +17 -0
  72. package/dist/chunk-LMUBBIE2.js +83 -0
  73. package/dist/chunk-LTZH5E3G.js +479 -0
  74. package/dist/chunk-LW4TG7EL.js +39 -0
  75. package/dist/chunk-MPSQXSC6.js +346 -0
  76. package/dist/chunk-MVFH26QT.js +97 -0
  77. package/dist/chunk-NLEXKE7U.js +67 -0
  78. package/dist/chunk-NQPURJT5.js +44 -0
  79. package/dist/chunk-NRBQK6UX.js +105 -0
  80. package/dist/chunk-OEH47H6A.js +48 -0
  81. package/dist/chunk-OG7QR2DP.js +75 -0
  82. package/dist/chunk-OPYFEHKG.js +52 -0
  83. package/dist/chunk-P4N7DBD5.js +83 -0
  84. package/dist/chunk-PAX3QXX2.js +140 -0
  85. package/dist/chunk-PKODFR5F.js +102 -0
  86. package/dist/chunk-PMJG2CXF.js +122 -0
  87. package/dist/chunk-Q5H3L6Y4.js +23 -0
  88. package/dist/chunk-QEF7EK3T.js +28 -0
  89. package/dist/chunk-QEW4J3IZ.js +74 -0
  90. package/dist/chunk-QPL7E2HW.js +464 -0
  91. package/dist/chunk-R2GPCZUX.js +22 -0
  92. package/dist/chunk-R5MT42JS.js +284 -0
  93. package/dist/chunk-RMATE45Z.js +197 -0
  94. package/dist/chunk-RPQOBHVU.js +87 -0
  95. package/dist/chunk-S3PIAMXV.js +230 -0
  96. package/dist/chunk-T3LKX23M.js +168 -0
  97. package/dist/chunk-T6GOWHK6.js +30 -0
  98. package/dist/chunk-TIA4SPU2.js +10 -0
  99. package/dist/chunk-TNCZ6444.js +57 -0
  100. package/dist/chunk-TVL5RTE6.js +269 -0
  101. package/dist/chunk-TXQ7L33K.js +45 -0
  102. package/dist/chunk-UPQTAHUK.js +189 -0
  103. package/dist/chunk-V4NPDK6X.js +14 -0
  104. package/dist/chunk-VJFEN6DJ.js +38 -0
  105. package/dist/chunk-VMHUEOT5.js +643 -0
  106. package/dist/chunk-VRPMYPZU.js +4985 -0
  107. package/dist/chunk-WIW772I3.js +25 -0
  108. package/dist/chunk-XELAZAIM.js +136 -0
  109. package/dist/chunk-XNML2KIC.js +23 -0
  110. package/dist/chunk-XP2U3LO3.js +30 -0
  111. package/dist/chunk-YGOWIJPE.js +51 -0
  112. package/dist/chunk-YIXDHQYE.js +11 -0
  113. package/dist/chunk-YSAWTGNA.js +117 -0
  114. package/dist/claude-U2JC2DNQ.js +77 -0
  115. package/dist/cli-MI4ZCAZ3.js +41 -0
  116. package/dist/cli-ZN7ZVDEZ.js +46 -0
  117. package/dist/cli.js +144 -16197
  118. package/dist/completion-ILSRB3LW.js +142 -0
  119. package/dist/config-DnpLL2kT.d.ts +46 -0
  120. package/dist/{service-qpCsOXkQ.d.ts → core-C1LPjxK6.d.ts} +2 -6
  121. package/dist/diagnostics-XKXVVQWH.js +93 -0
  122. package/dist/doctor-O2E63YGO.js +538 -0
  123. package/dist/entry-X6CSYQRQ.js +305 -0
  124. package/dist/exec-mcp-2PMWBPD7.js +365 -0
  125. package/dist/harness-L2KSI2ZB.js +177 -0
  126. package/dist/harness-egress-bridge.js +4 -4
  127. package/dist/harness-launch-gate.js +47 -940
  128. package/dist/harness-pane-runner.js +13 -80
  129. package/dist/harness-worker.js +21 -2703
  130. package/dist/hook-body.js +5222 -0
  131. package/dist/hook-spec-C5fWTSCH.d.ts +100 -0
  132. package/dist/hook.js +26 -0
  133. package/dist/hooks-BHTA44X7.js +21 -0
  134. package/dist/host-UIZAXXQH.js +22 -0
  135. package/dist/host-UWK754BW.js +210 -0
  136. package/dist/host-run-BI2OTZDZ.js +307 -0
  137. package/dist/http.d.ts +5 -42
  138. package/dist/http.js +21 -2234
  139. package/dist/import-mcp-GPKJI7DI.js +400 -0
  140. package/dist/index.d.ts +146 -168
  141. package/dist/index.js +133 -4948
  142. package/dist/init-3C2Y7BNJ.js +14 -0
  143. package/dist/install-GG7HHZK2.js +796 -0
  144. package/dist/invoke-44CJRVMK.js +23 -0
  145. package/dist/list-MCP2FXUF.js +68 -0
  146. package/dist/list-WL6L4J5H.js +65 -0
  147. package/dist/load-BEUBABtB.d.ts +21 -0
  148. package/dist/logout-F5EJ5MOU.js +44 -0
  149. package/dist/logs-TBUA4UWU.js +107 -0
  150. package/dist/mailbox/index.d.ts +10 -5
  151. package/dist/mailbox/index.js +53 -1572
  152. package/dist/mailbox-BMTZOSZ7.js +285 -0
  153. package/dist/mailbox-GDJ7BWQN.js +189 -0
  154. package/dist/mainline-KAD2ERLP.js +639 -0
  155. package/dist/marketplace-G4VQET5W.js +191 -0
  156. package/dist/mcp-235QZN2A.js +15 -0
  157. package/dist/mcp-FJ2UQ4RH.js +193 -0
  158. package/dist/models-ISU4DCMA.js +32 -0
  159. package/dist/opencode-CN7JLQYO.js +60 -0
  160. package/dist/pause-7LILUVGL.js +18 -0
  161. package/dist/preview-DT7DWG5F.js +91 -0
  162. package/dist/project/hook-adapter.d.ts +5 -2
  163. package/dist/project/hook-adapter.js +41 -27
  164. package/dist/project-5YV5CUEG.js +70 -0
  165. package/dist/pty-XTJ4MIWK.js +94 -0
  166. package/dist/recovery-U6QB3PMT.js +100 -0
  167. package/dist/reindex-Y27QJFDB.js +22 -0
  168. package/dist/resume-26VFAAMH.js +18 -0
  169. package/dist/run-3AXTZSR7.js +126 -0
  170. package/dist/run-3SOVRQIA.js +19 -0
  171. package/dist/serve-DQMKTFIV.js +104 -0
  172. package/dist/session-XM2CR425.js +159 -0
  173. package/dist/setup-DTKZLZUT.js +18 -0
  174. package/dist/start-login-YTZV6KMF.js +416 -0
  175. package/dist/status-A2OUTNGK.js +9 -0
  176. package/dist/status-H2VAHIDV.js +10 -0
  177. package/dist/status-MROQ7WR7.js +43 -0
  178. package/dist/status-RO55QPKV.js +55 -0
  179. package/dist/status-UME2L33L.js +286 -0
  180. package/dist/stdio.d.ts +3 -13
  181. package/dist/stdio.js +16 -3186
  182. package/dist/sweep-35LGQTTO.js +18 -0
  183. package/dist/test-AGZOJLRZ.js +561 -0
  184. package/dist/tools-gpHNq9Dh.d.ts +328 -0
  185. package/dist/tui-G5LLWCSV.js +153 -0
  186. package/dist/unbroadcast-5QNGAJR2.js +18 -0
  187. package/dist/validate-IU52H2IC.js +46 -0
  188. package/dist/worker-QZ5T6LJD.js +80 -0
  189. package/dist/worktree-create-PZSRB7PH.js +89 -0
  190. package/dist/worktree-list-JYB6VXLW.js +51 -0
  191. package/dist/worktree-sync-UF5CXPWV.js +30 -0
  192. package/docs/authoring.md +82 -0
  193. package/docs/browser-and-desktop.md +46 -0
  194. package/docs/commands.md +325 -0
  195. package/docs/compare.md +35 -0
  196. package/docs/compatibility.md +55 -0
  197. package/docs/embeddings.md +1 -1
  198. package/docs/getting-started.md +105 -0
  199. package/docs/git-workflow.md +60 -0
  200. package/docs/glossary.md +31 -0
  201. package/docs/hooks/capabilities/antigravity.json +199 -0
  202. package/docs/hooks/capabilities/claude.json +179 -0
  203. package/docs/hooks/capabilities/codex.json +179 -0
  204. package/docs/hooks/capabilities/gemini.json +196 -0
  205. package/docs/hooks/capabilities/grok.json +192 -0
  206. package/docs/hooks/capabilities/opencode.json +184 -0
  207. package/docs/hooks.md +264 -0
  208. package/docs/install.md +72 -0
  209. package/docs/library-skills.md +132 -0
  210. package/docs/mailbox.md +16 -5
  211. package/docs/project-configuration.md +540 -58
  212. package/docs/sessions.md +64 -0
  213. package/docs/skills.md +4 -45
  214. package/docs/terminal-harness.md +92 -44
  215. package/docs/terminal-workspace.md +81 -169
  216. package/gemini-extension.json +2 -2
  217. package/mcp.json +1 -1
  218. package/package.json +16 -2
  219. package/plugin.json +2 -2
  220. package/plugins/pmcp/.claude-plugin/plugin.json +4 -2
  221. package/plugins/pmcp/.mcp.json +1 -1
  222. package/plugins/pmcp/gemini-extension.json +2 -2
  223. package/plugins/pmcp/mcp.json +1 -1
  224. package/plugins/pmcp/mod/commands.ts +72 -0
  225. package/plugins/pmcp/mod/contract.d.ts +39 -0
  226. package/plugins/pmcp/mod/draw.tsx +216 -0
  227. package/plugins/pmcp/mod/guard.ts +42 -0
  228. package/plugins/pmcp/mod/hooks.json +4 -0
  229. package/plugins/pmcp/mod/host.ts +46 -0
  230. package/plugins/pmcp/mod/model.ts +144 -0
  231. package/plugins/pmcp/mod/reader/index.ts +18 -0
  232. package/plugins/pmcp/mod/reader/read.ts +76 -0
  233. package/plugins/pmcp/mod/reader/settings.ts +54 -0
  234. package/plugins/pmcp/mod/reader/types.ts +38 -0
  235. package/plugins/pmcp/mod/register.tsx +73 -0
  236. package/plugins/pmcp/mod/sessions/format.ts +91 -0
  237. package/plugins/pmcp/mod/sessions/types.ts +162 -0
  238. package/plugins/pmcp/mod/snapshot.ts +75 -0
  239. package/plugins/pmcp/mod/spinner.tsx +30 -0
  240. package/plugins/pmcp/mod/state.ts +28 -0
  241. package/plugins/pmcp/plugin.json +2 -2
  242. package/plugins/pmcp/skills/agent-assets-migrate/SKILL.md +96 -0
  243. package/plugins/pmcp/skills/headless-agents-ci-scaffold/SKILL.md +101 -0
  244. package/plugins/pmcp/skills/marketplace-plugin-scaffold/SKILL.md +87 -0
  245. package/plugins/pmcp/skills/package-skill-catalog/SKILL.md +51 -15
  246. package/plugins/pmcp/skills/pmcp-browser/SKILL.md +27 -0
  247. package/plugins/pmcp/skills/pmcp-desktop/SKILL.md +25 -0
  248. package/plugins/pmcp/skills/pmcp-project-init/SKILL.md +153 -0
  249. package/plugins/pmcp/skills/pmcp-sessions-and-git/SKILL.md +96 -0
  250. package/plugins/pmcp/skills/skill-package-scaffold/SKILL.md +89 -0
  251. package/schema/catalog-v1.json +187 -0
  252. package/schema/library.json +196 -0
  253. package/schema/marketplace-manifest.json +144 -0
  254. package/schema/plugin-manifest.json +59 -0
  255. package/schema/skill-frontmatter.json +170 -0
  256. package/schema/skill-metadata-core.json +131 -0
  257. package/skills/agent-assets-migrate/SKILL.md +96 -0
  258. package/skills/headless-agents-ci-scaffold/SKILL.md +101 -0
  259. package/skills/marketplace-plugin-scaffold/SKILL.md +87 -0
  260. package/skills/package-skill-catalog/SKILL.md +51 -15
  261. package/skills/pmcp-browser/SKILL.md +27 -0
  262. package/skills/pmcp-desktop/SKILL.md +25 -0
  263. package/skills/pmcp-project-init/SKILL.md +153 -0
  264. package/skills/pmcp-sessions-and-git/SKILL.md +96 -0
  265. package/skills/skill-package-scaffold/SKILL.md +89 -0
  266. package/dist/config-BkSpjUG6.d.ts +0 -50
  267. package/dist/embed-DRROSD3F.d.ts +0 -53
  268. package/dist/hook-spec-CSJJySsH.d.ts +0 -11
  269. package/dist/server-VWSY3Shw.d.ts +0 -543
  270. package/dist/tui-worker.js +0 -6549
  271. package/docs/manual-library-skills.md +0 -74
  272. /package/dist/{tui-worker.d.ts → hook.d.ts} +0 -0
@@ -0,0 +1,216 @@
1
+ /* @jsxRuntime classic */
2
+ /* @jsx h */
3
+ /* @jsxFrag Fragment */
4
+
5
+ import { runCommand } from "./commands";
6
+ import {
7
+ ageOf,
8
+ bandMark,
9
+ blocking,
10
+ detailOf,
11
+ headline,
12
+ holderOf,
13
+ kindOf,
14
+ labelOf,
15
+ LOOK,
16
+ marksOf,
17
+ nameOf,
18
+ placeOf,
19
+ stuck,
20
+ summaryOf,
21
+ TONE,
22
+ toneOf,
23
+ waitingOf,
24
+ } from "./model";
25
+ import { state } from "./state";
26
+
27
+ const MARKS = 6;
28
+
29
+ export async function drawPane($: any, e: any): Promise<any> {
30
+ const { Box, Text, Button, Client } = await $.ui.resolve(e);
31
+ const { pause, lease, records, broadcast } = state.snapshot;
32
+ const tone = TONE[toneOf(state.snapshot)];
33
+ const columns = Math.max(20, Number(e.props?.bodyColumns ?? 80));
34
+ const now = state.now;
35
+ const nameWidth = Math.max(4, ...records.map((r) => labelOf(r).length));
36
+ const placeWidth = Math.max(5, ...records.map((r) => placeOf(r).length));
37
+ const fixed = 2 + nameWidth + 1 + 8 + placeWidth + 1 + MARKS + 5;
38
+ const actionWidth = Math.max(0, columns - fixed);
39
+ const mark = bandMark(state.snapshot);
40
+ return (
41
+ <Box flexDirection="column">
42
+ <Box flexDirection="row" backgroundColor={tone.background}>
43
+ {mark.spin ? (
44
+ <Client
45
+ key="spin"
46
+ module="./spinner.tsx"
47
+ props={{ color: tone.color, background: tone.background }}
48
+ width={2}
49
+ />
50
+ ) : (
51
+ <Text key="spin" color={tone.color} backgroundColor={tone.background}>
52
+ {mark.glyph}{" "}
53
+ </Text>
54
+ )}
55
+ {pause ? (
56
+ <Text color="error" bold backgroundColor={tone.background}>
57
+ PAUSED
58
+ </Text>
59
+ ) : (
60
+ <Text color={tone.color} bold backgroundColor={tone.background}>
61
+ sessions
62
+ </Text>
63
+ )}
64
+ <Text backgroundColor={tone.background}>
65
+ {" "}
66
+ {pause
67
+ ? `${pause.reason} · ${ageOf(pause.since, now)} ago`
68
+ : headline(state.snapshot)}
69
+ </Text>
70
+ </Box>
71
+ {lease ? (
72
+ <Text wrap="truncate-end">
73
+ <Text color="warning">◷ lease for {ageOf(lease.since, now)} </Text>
74
+ <Text>by {holderOf(lease, records)} </Text>
75
+ <Text dimColor>{lease.subject}</Text>
76
+ </Text>
77
+ ) : null}
78
+ {broadcast ? (
79
+ <Text wrap="truncate-end">
80
+ <Text color="suggestion">» broadcast </Text>
81
+ <Text>{broadcast.text}</Text>
82
+ </Text>
83
+ ) : null}
84
+ <Text> </Text>
85
+ {records.length === 0 ? <Text dimColor>No live sessions.</Text> : null}
86
+ {records.map((record) => {
87
+ const look = LOOK[kindOf(record)];
88
+ return (
89
+ <Box key={record.session}>
90
+ <Text wrap="truncate-end">
91
+ <Text color={look.color}>{look.glyph} </Text>
92
+ <Text bold={record.session === state.self}>
93
+ {labelOf(record).padEnd(nameWidth)}{" "}
94
+ </Text>
95
+ <Text color={look.color}>{look.word.padEnd(8)}</Text>
96
+ <Text dimColor>{placeOf(record).padEnd(placeWidth)} </Text>
97
+ <Text color="warning">{marksOf(record).padEnd(MARKS)}</Text>
98
+ <Text dimColor>
99
+ {ageOf(record.updatedAt, now).padStart(4)}{" "}
100
+ {detailOf(record).slice(0, actionWidth)}
101
+ </Text>
102
+ </Text>
103
+ </Box>
104
+ );
105
+ })}
106
+ <Text> </Text>
107
+ {pause ? (
108
+ <Button
109
+ key="resume"
110
+ label="Resume sessions"
111
+ onPress={() => runCommand($, "resume")}
112
+ />
113
+ ) : (
114
+ <Text dimColor>
115
+ /pmcp pause &lt;reason&gt; · /pmcp broadcast &lt;text&gt;
116
+ </Text>
117
+ )}
118
+ </Box>
119
+ );
120
+ }
121
+
122
+ function row(key: string, Box: any, Text: any, children: any): any {
123
+ return (
124
+ <Box key={key}>
125
+ <Text wrap="truncate-end">{children}</Text>
126
+ </Box>
127
+ );
128
+ }
129
+
130
+ export async function drawBand($: any, e: any, next: any): Promise<any> {
131
+ if (e.props?.hasSurvey) return next(e);
132
+ const { pause, lease, records } = state.snapshot;
133
+ const waiting = blocking(records);
134
+ const heard = state.snapshot.broadcast;
135
+ const broadcast = heard?.by === state.self ? null : heard;
136
+ const held = lease && stuck(lease) ? lease : null;
137
+ const { Box, Text, Client } = await $.ui.resolve(e);
138
+ const tone = TONE[toneOf(state.snapshot)];
139
+ const mark = bandMark(state.snapshot);
140
+ const rows = [];
141
+ const summary = (
142
+ <Box key="summary" flexDirection="row" backgroundColor={tone.background}>
143
+ {mark.spin ? (
144
+ <Client
145
+ key="spin"
146
+ module="./spinner.tsx"
147
+ props={{ color: tone.color, background: tone.background }}
148
+ width={2}
149
+ />
150
+ ) : (
151
+ <Text key="spin" color={tone.color} backgroundColor={tone.background}>
152
+ {mark.glyph}{" "}
153
+ </Text>
154
+ )}
155
+ <Text wrap="truncate-end" backgroundColor={tone.background}>
156
+ <Text bold color={tone.color}>
157
+ pmcp{" "}
158
+ </Text>
159
+ <Text>{summaryOf(state.snapshot)}</Text>
160
+ <Text dimColor> · /pmcp </Text>
161
+ </Text>
162
+ </Box>
163
+ );
164
+ if (pause) {
165
+ rows.push(
166
+ row("pause", Box, Text, [
167
+ <Text key="mark" color="error" bold>
168
+ ■ paused{" "}
169
+ </Text>,
170
+ <Text key="reason">{pause.reason}</Text>,
171
+ <Text key="hint" dimColor>
172
+ {" "}
173
+ · /pmcp resume
174
+ </Text>,
175
+ ]),
176
+ );
177
+ }
178
+ if (waiting.length > 0) {
179
+ const names = waiting.map((r) => `${nameOf(r)} (${waitingOf(r)})`);
180
+ rows.push(
181
+ row("asking", Box, Text, [
182
+ <Text key="mark" color="permission" bold>
183
+ ◆ asking{" "}
184
+ </Text>,
185
+ <Text key="names">{names.join(", ")}</Text>,
186
+ ]),
187
+ );
188
+ }
189
+ if (held) {
190
+ rows.push(
191
+ row("lease", Box, Text, [
192
+ <Text key="mark" color="warning">
193
+ ◷ lease held for {ageOf(held.since, state.now)}{" "}
194
+ </Text>,
195
+ <Text key="holder">by {holderOf(held, records)} </Text>,
196
+ <Text key="subject" dimColor>
197
+ {held.subject}
198
+ </Text>,
199
+ ]),
200
+ );
201
+ }
202
+ if (broadcast) {
203
+ rows.push(
204
+ row("broadcast", Box, Text, [
205
+ <Text key="mark" color="suggestion">
206
+ » broadcast{" "}
207
+ </Text>,
208
+ <Text key="text">{broadcast.text}</Text>,
209
+ ]),
210
+ );
211
+ }
212
+ // Prioritize actionable states because narrow status bands cannot display every summary.
213
+ const room = Math.max(1, Number(e.props?.maxRows ?? rows.length + 1));
214
+ const shown = room > rows.length ? [summary, ...rows] : rows.slice(0, room);
215
+ return <Box flexDirection="column">{shown}</Box>;
216
+ }
@@ -0,0 +1,42 @@
1
+ // Leave foreign-edit decisions to the person because the mod must not enforce independent policy.
2
+ import { nameOf } from "./model";
3
+ import type { SessionRecord } from "./reader/index";
4
+ import { state } from "./state";
5
+
6
+ function checkoutOf(target: string, records: readonly SessionRecord[]): string {
7
+ let best = "";
8
+ for (const record of records) {
9
+ const root = record.worktree ?? "";
10
+ if (root && target.startsWith(`${root}/`) && root.length > best.length) {
11
+ best = root;
12
+ }
13
+ }
14
+ const desk = /^(.*\/\.claude\/worktrees\/[^/]+)\//.exec(target)?.[1] ?? "";
15
+ return desk.length > best.length ? desk : best;
16
+ }
17
+
18
+ export async function holdForeignEdit($: any, e: any, next: any): Promise<any> {
19
+ const target = String(e.file_path ?? e.notebook_path ?? "");
20
+ const records = state.snapshot.records;
21
+ const mine = records.find((r) => r.session === state.self)?.worktree;
22
+ const checkout = checkoutOf(target, records);
23
+ // Choose the innermost checkout because linked worktrees may be nested under the main checkout.
24
+ const owner = records.find(
25
+ (r) =>
26
+ r.session !== state.self && r.worktree === checkout && checkout !== mine,
27
+ );
28
+ if (!owner) return next(e);
29
+ try {
30
+ const answer = await $.ui.ask(
31
+ `${nameOf(owner)} works in ${owner.worktree}. Edit ${target} anyway?`,
32
+ ["Edit", "Cancel"],
33
+ );
34
+ if (answer === "Edit") return next(e);
35
+ } catch {
36
+ // Leave noninteractive warnings to hooks because no person is available for a mod prompt.
37
+ return next(e);
38
+ }
39
+ return {
40
+ deny: `${nameOf(owner)} works in ${owner.worktree}; the person declined this edit.`,
41
+ };
42
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "pmcp sessions: the /pmcp pane, the band above the prompt, toasts, /pmcp pause, resume and broadcast, and a hold-and-ask on edits in another live session's checkout.",
3
+ "modules": ["./register.tsx"]
4
+ }
@@ -0,0 +1,46 @@
1
+ import { parseUiSettings, UI_SETTINGS_FILE } from "./reader/index";
2
+ import type { StateFiles, UiSettings } from "./reader/index";
3
+
4
+ export function hostFiles($: any): StateFiles {
5
+ return {
6
+ exists: async (path) => Boolean(await $.fs.exists(path)),
7
+ read: async (path) => String(await $.fs.read(path)),
8
+ list: async (directory) => {
9
+ const entries = (await $.fs.list(directory).catch(() => [])) as any[];
10
+ return entries.map((entry) => String(entry.name));
11
+ },
12
+ };
13
+ }
14
+
15
+ // Ask the projected hook for state location so mod and hook readers cannot diverge.
16
+ export async function resolveStateDir(
17
+ $: any,
18
+ root: string,
19
+ settings: UiSettings,
20
+ ): Promise<string> {
21
+ if (settings.stateDir) return settings.stateDir;
22
+ const hook = `${root}/.agents/pmcp-hooks/hook.mjs`;
23
+ if (!(await $.fs.exists(hook))) return "";
24
+ const run = await $.process
25
+ .run(["node", hook, "--state-dir"])
26
+ .catch(() => null);
27
+ if (!run || run.exitCode !== 0) return "";
28
+ return String(run.stdout).trim();
29
+ }
30
+
31
+ export async function findSettings(
32
+ $: any,
33
+ cwd: string,
34
+ ): Promise<{ root: string; settings: UiSettings } | null> {
35
+ let directory = cwd.replace(/\/+$/, "");
36
+ while (directory) {
37
+ const path = `${directory}/${UI_SETTINGS_FILE}`;
38
+ if (await $.fs.exists(path)) {
39
+ const source = String(await $.fs.read(path).catch(() => ""));
40
+ const settings = parseUiSettings(source, directory);
41
+ return settings ? { root: directory, settings } : null;
42
+ }
43
+ directory = directory.replace(/\/[^/]*$/, "");
44
+ }
45
+ return null;
46
+ }
@@ -0,0 +1,144 @@
1
+ import type { Lease, SessionRecord, SessionSnapshot } from "./reader/index";
2
+ import { LEASE_STUCK_MS, state } from "./state";
3
+
4
+ export type Kind = "asking" | "working" | "idle";
5
+
6
+ export const LOOK: {
7
+ [K in Kind]: { glyph: string; word: string; color: string };
8
+ } = {
9
+ asking: { glyph: "◆", word: "asking", color: "permission" },
10
+ working: { glyph: "●", word: "working", color: "claude" },
11
+ idle: { glyph: "○", word: "idle", color: "inactive" },
12
+ };
13
+
14
+ const ORDER: Kind[] = ["asking", "working", "idle"];
15
+
16
+ const WAITING: { [key: string]: string } = {
17
+ permission_prompt: "permission",
18
+ agent_needs_input: "question",
19
+ idle_prompt: "done",
20
+ };
21
+
22
+ export function nameOf(record: SessionRecord): string {
23
+ return record.alias || record.session.slice(0, 8);
24
+ }
25
+
26
+ export function kindOf(record: SessionRecord): Kind {
27
+ if (record.status === "waiting" && record.waiting !== "idle_prompt")
28
+ return "asking";
29
+ if (record.status === "working") return "working";
30
+ return "idle";
31
+ }
32
+
33
+ export function blocking(records: readonly SessionRecord[]): SessionRecord[] {
34
+ return records.filter(
35
+ (r) => kindOf(r) === "asking" && r.session !== state.self,
36
+ );
37
+ }
38
+
39
+ export function stuck(lease: Lease): boolean {
40
+ return state.now - Date.parse(lease.since ?? "") > LEASE_STUCK_MS;
41
+ }
42
+
43
+ // An empty reason is still a question; older records carry no notification type.
44
+ export function waitingOf(record: SessionRecord): string {
45
+ return WAITING[record.waiting ?? ""] ?? (record.waiting || "input");
46
+ }
47
+
48
+ // Name the session whose runtime holds the lease, else the one session working in its cwd.
49
+ export function holderOf(
50
+ lease: Lease,
51
+ records: readonly SessionRecord[],
52
+ ): string {
53
+ const byPid = records.find((r) => r.pid === lease.pid);
54
+ if (byPid) return nameOf(byPid);
55
+ const here = records.filter((r) => lease.cwd && r.worktree === lease.cwd);
56
+ if (here.length === 1) return nameOf(here[0]!);
57
+ return `pid ${lease.pid}`;
58
+ }
59
+
60
+ export function labelOf(record: SessionRecord): string {
61
+ if (record.session === state.self) return `${nameOf(record)} (you)`;
62
+ return nameOf(record);
63
+ }
64
+
65
+ export function byKind(a: SessionRecord, b: SessionRecord): number {
66
+ const order = ORDER.indexOf(kindOf(a)) - ORDER.indexOf(kindOf(b));
67
+ if (order !== 0) return order;
68
+ return labelOf(a).localeCompare(labelOf(b));
69
+ }
70
+
71
+ // A desk is named by its directory: detached linked worktrees have no branch to show.
72
+ export function placeOf(record: SessionRecord): string {
73
+ const worktree = record.worktree ?? "";
74
+ const desk = /\/\.claude\/worktrees\/([^/]+)\/?$/u.exec(worktree)?.[1];
75
+ if (desk) return desk;
76
+ if (record.branch) return record.branch;
77
+ return worktree.replace(/\/+$/u, "").split("/").pop() || "-";
78
+ }
79
+
80
+ export function detailOf(record: SessionRecord): string {
81
+ if (kindOf(record) === "asking") return waitingOf(record);
82
+ return record.lastAction ?? "";
83
+ }
84
+
85
+ export function marksOf(record: SessionRecord): string {
86
+ return record.behind ? `↓${record.behind}` : "";
87
+ }
88
+
89
+ // The band animates only while a session works, the same signal the pane's working rows use.
90
+ export function bandMark(snapshot: SessionSnapshot): {
91
+ spin: boolean;
92
+ glyph: string;
93
+ } {
94
+ const spin = snapshot.records.some((r) => kindOf(r) === "working");
95
+ return { spin, glyph: spin ? LOOK.working.glyph : LOOK.idle.glyph };
96
+ }
97
+
98
+ export type Tone = "paused" | "asking" | "leased" | "working" | "idle";
99
+
100
+ export function toneOf(snapshot: SessionSnapshot): Tone {
101
+ if (snapshot.pause) return "paused";
102
+ if (blocking(snapshot.records).length > 0) return "asking";
103
+ if (snapshot.lease) return "leased";
104
+ if (snapshot.records.some((r) => kindOf(r) === "working")) return "working";
105
+ return "idle";
106
+ }
107
+
108
+ export const TONE: { [T in Tone]: { color: string; background: string } } = {
109
+ paused: { color: "error", background: "#3a1d22" },
110
+ asking: { color: "permission", background: "#2e2640" },
111
+ leased: { color: "warning", background: "#332b17" },
112
+ working: { color: "claude", background: "#2b2420" },
113
+ idle: { color: "inactive", background: "#22252b" },
114
+ };
115
+
116
+ export function ageOf(stamp: string | undefined, now: number): string {
117
+ const seconds = Math.max(
118
+ 0,
119
+ Math.round((now - Date.parse(stamp ?? "")) / 1000),
120
+ );
121
+ if (!Number.isFinite(seconds)) return "";
122
+ if (seconds < 60) return `${seconds}s`;
123
+ if (seconds < 3600) return `${Math.floor(seconds / 60)}m`;
124
+ return `${Math.floor(seconds / 3600)}h`;
125
+ }
126
+
127
+ export function headline(snapshot: SessionSnapshot): string {
128
+ const { records } = snapshot;
129
+ const asking = records.filter((r) => kindOf(r) === "asking").length;
130
+ const working = records.filter((r) => kindOf(r) === "working").length;
131
+ const parts = [`${records.length} session${records.length === 1 ? "" : "s"}`];
132
+ if (asking > 0) parts.push(`${asking} asking`);
133
+ if (working > 0) parts.push(`${working} working`);
134
+ return parts.join(" · ");
135
+ }
136
+
137
+ export function summaryOf(snapshot: SessionSnapshot): string {
138
+ const parts = [headline(snapshot)];
139
+ const behind = snapshot.records.filter((r) => (r.behind ?? 0) > 0).length;
140
+ if (behind > 0) parts.push(`${behind} behind`);
141
+ if (snapshot.lease) parts.push(`lease: ${snapshot.lease.subject}`);
142
+ if (snapshot.broadcast) parts.push("broadcast");
143
+ return parts.join(" · ");
144
+ }
@@ -0,0 +1,18 @@
1
+ export {
2
+ isAlive,
3
+ readRecords,
4
+ readSessionState,
5
+ STALE_MS,
6
+ STATE_PATHS,
7
+ } from "./read";
8
+ export { parseUiSettings, UI_SETTINGS_FILE } from "./settings";
9
+ export type {
10
+ Broadcast,
11
+ Lease,
12
+ Pause,
13
+ ReadOptions,
14
+ SessionRecord,
15
+ SessionSnapshot,
16
+ StateFiles,
17
+ UiSettings,
18
+ } from "./types";
@@ -0,0 +1,76 @@
1
+ import {
2
+ asBroadcast,
3
+ asLease,
4
+ asPause,
5
+ asRecord,
6
+ leaseFile,
7
+ recordLive,
8
+ STATE_FILES,
9
+ } from "../sessions/format";
10
+ import type {
11
+ ReadOptions,
12
+ SessionRecord,
13
+ SessionSnapshot,
14
+ StateFiles,
15
+ } from "./types";
16
+
17
+ export { STALE_MS } from "../sessions/format";
18
+
19
+ export const STATE_PATHS = {
20
+ records: STATE_FILES.records,
21
+ pause: STATE_FILES.pause,
22
+ lease: leaseFile("lockfile"),
23
+ broadcast: STATE_FILES.broadcast,
24
+ } as const;
25
+
26
+ function parse(text: string): unknown {
27
+ try {
28
+ return JSON.parse(text);
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ async function readJson(files: StateFiles, path: string): Promise<unknown> {
35
+ if (!(await files.exists(path))) return null;
36
+ return parse(await files.read(path).catch(() => ""));
37
+ }
38
+
39
+ export async function isAlive(
40
+ files: StateFiles,
41
+ pid: unknown,
42
+ ): Promise<boolean> {
43
+ const value = Number(pid);
44
+ if (!Number.isInteger(value) || value <= 0) return false;
45
+ return files.exists(`/proc/${value}`);
46
+ }
47
+
48
+ export async function readRecords(
49
+ files: StateFiles,
50
+ options: ReadOptions,
51
+ ): Promise<SessionRecord[]> {
52
+ const directory = `${options.stateDir}/${STATE_PATHS.records}`;
53
+ const names = await files.list(directory).catch(() => [] as string[]);
54
+ const records: SessionRecord[] = [];
55
+ for (const name of names.filter((item) => item.endsWith(".json")).sort()) {
56
+ const record = asRecord(await readJson(files, `${directory}/${name}`));
57
+ if (!record) continue;
58
+ const pidAlive = await isAlive(files, record.pid);
59
+ if (recordLive(record, options.now, pidAlive)) records.push(record);
60
+ }
61
+ return records;
62
+ }
63
+
64
+ export async function readSessionState(
65
+ files: StateFiles,
66
+ options: ReadOptions,
67
+ ): Promise<SessionSnapshot> {
68
+ const at = (name: string) => `${options.stateDir}/${name}`;
69
+ const lease = asLease(await readJson(files, at(STATE_PATHS.lease)));
70
+ return {
71
+ records: await readRecords(files, options),
72
+ pause: asPause(await readJson(files, at(STATE_PATHS.pause))),
73
+ lease: lease && (await isAlive(files, lease.pid)) ? lease : null,
74
+ broadcast: asBroadcast(await readJson(files, at(STATE_PATHS.broadcast))),
75
+ };
76
+ }
@@ -0,0 +1,54 @@
1
+ import type { UiSettings } from "./types";
2
+
3
+ export const UI_SETTINGS_FILE = ".agents/pmcp-hooks/ui-claude.json";
4
+
5
+ const SWITCHES = [
6
+ "sessionsPane",
7
+ "statusBand",
8
+ "commands",
9
+ "holdForeignEdits",
10
+ ] as const;
11
+
12
+ function within(root: string, path: string): string {
13
+ if (path.startsWith("/")) return path;
14
+ const parts = root.split("/");
15
+ for (const part of path.split("/")) {
16
+ if (part === "" || part === ".") continue;
17
+ if (part === "..") {
18
+ parts.pop();
19
+ continue;
20
+ }
21
+ parts.push(part);
22
+ }
23
+ return parts.join("/");
24
+ }
25
+
26
+ // Disable the mod on unreadable settings so partial configuration cannot activate a broken UI.
27
+ export function parseUiSettings(
28
+ source: string,
29
+ projectRoot: string,
30
+ ): UiSettings | null {
31
+ let value: unknown;
32
+ try {
33
+ value = JSON.parse(source);
34
+ } catch {
35
+ return null;
36
+ }
37
+ if (value === null || typeof value !== "object" || Array.isArray(value))
38
+ return null;
39
+ const raw = value as Record<string, unknown>;
40
+ const declared = raw.stateDir;
41
+ if (
42
+ declared !== undefined &&
43
+ (typeof declared !== "string" || declared === "")
44
+ )
45
+ return null;
46
+ if (SWITCHES.some((key) => typeof raw[key] !== "boolean")) return null;
47
+ return {
48
+ ...(declared ? { stateDir: within(projectRoot, declared) } : {}),
49
+ sessionsPane: raw.sessionsPane === true,
50
+ statusBand: raw.statusBand === true,
51
+ commands: raw.commands === true,
52
+ holdForeignEdits: raw.holdForeignEdits === true,
53
+ };
54
+ }
@@ -0,0 +1,38 @@
1
+ import type {
2
+ Broadcast,
3
+ Lease,
4
+ Pause,
5
+ SessionRecord as StoredRecord,
6
+ } from "../sessions/types";
7
+
8
+ export type { Broadcast, Lease, Pause } from "../sessions/types";
9
+
10
+ export interface SessionRecord extends StoredRecord {
11
+ readonly behind?: number;
12
+ }
13
+
14
+ export interface SessionSnapshot {
15
+ readonly records: readonly SessionRecord[];
16
+ readonly pause: Pause | null;
17
+ readonly lease: Lease | null;
18
+ readonly broadcast: Broadcast | null;
19
+ }
20
+
21
+ export interface StateFiles {
22
+ exists(path: string): Promise<boolean>;
23
+ read(path: string): Promise<string>;
24
+ list(directory: string): Promise<string[]>;
25
+ }
26
+
27
+ export interface ReadOptions {
28
+ readonly stateDir: string;
29
+ readonly now: number;
30
+ }
31
+
32
+ export interface UiSettings {
33
+ readonly stateDir?: string;
34
+ readonly sessionsPane: boolean;
35
+ readonly statusBand: boolean;
36
+ readonly commands: boolean;
37
+ readonly holdForeignEdits: boolean;
38
+ }