@modootoday/pmcp 0.19.8 → 0.20.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-6OEABVQT.js → apply-QJ6MGLBX.js} +17 -17
- package/dist/{attachment-D84OGI6n.d.ts → attachment-ms6s8Aow.d.ts} +1 -1
- package/dist/{available-GFMTJW4E.js → available-HYSDAFYH.js} +4 -4
- package/dist/{broadcast-56NPEJWM.js → broadcast-LYOA6BEW.js} +5 -5
- package/dist/{chunk-44YE6B63.js → chunk-4VK5G3SV.js} +3 -3
- package/dist/{chunk-7B2KRL2H.js → chunk-5JPD6VIH.js} +74 -7
- package/dist/{chunk-42RFOVU3.js → chunk-66F3HLW4.js} +17 -5
- package/dist/{chunk-CVZEVTTX.js → chunk-7SDOSTW7.js} +3 -3
- package/dist/{chunk-6U623E6Y.js → chunk-AWZF72SH.js} +6 -6
- package/dist/{chunk-J5ZS7GLA.js → chunk-C3G75JH7.js} +2 -2
- package/dist/{chunk-PTDMSVKS.js → chunk-CQZYQAAV.js} +3 -3
- package/dist/{chunk-SRX2ONSZ.js → chunk-EKPMVEIA.js} +2 -2
- package/dist/{chunk-GXACIGVS.js → chunk-FD6VGFYZ.js} +5 -5
- package/dist/chunk-FGYFA6JY.js +7 -0
- package/dist/{chunk-RXKX33WU.js → chunk-FQAJSNNU.js} +3 -3
- package/dist/{chunk-QPL7E2HW.js → chunk-GJXOFDJT.js} +9 -2
- package/dist/{chunk-JZK7ZO7K.js → chunk-I4U2A6HP.js} +2 -2
- package/dist/{chunk-UGODVKBJ.js → chunk-IQD4W53M.js} +2 -2
- package/dist/{chunk-TFZLX66B.js → chunk-IZABPDAO.js} +2 -2
- package/dist/{chunk-VHTRCE5G.js → chunk-J6HNP6HA.js} +3 -3
- package/dist/{chunk-QXDD75DY.js → chunk-JBHGJKSL.js} +3 -3
- package/dist/{chunk-NWOV2E26.js → chunk-JZKAJUVT.js} +2 -2
- package/dist/{chunk-VUSA7POL.js → chunk-K2C3KFGB.js} +9 -9
- package/dist/{chunk-TLIOBOZ2.js → chunk-L4MFGGSI.js} +2 -2
- package/dist/{chunk-XP2U3LO3.js → chunk-M2RYXWX2.js} +2 -2
- package/dist/{chunk-LJL4L73I.js → chunk-MZEMLFFD.js} +3 -3
- package/dist/{chunk-6QM5OWGZ.js → chunk-O2JWF7ZM.js} +2 -2
- package/dist/{chunk-SHZPE6FD.js → chunk-OAIQ7A3R.js} +5 -5
- package/dist/{chunk-3PW4FI7U.js → chunk-ONP6JRFZ.js} +2 -2
- package/dist/{chunk-HEBCQTOD.js → chunk-PEMMV5YQ.js} +2 -2
- package/dist/{chunk-DHAPQUEF.js → chunk-PQTM27GU.js} +32 -15
- package/dist/{chunk-7B6IC3F7.js → chunk-PUIWESU3.js} +3 -3
- package/dist/{chunk-P4424VLT.js → chunk-QDY6BWE6.js} +2 -2
- package/dist/{chunk-3CYQWRGM.js → chunk-QOFSPFJ6.js} +351 -86
- package/dist/{chunk-C4NHQGHL.js → chunk-QSIADSMQ.js} +13 -2
- package/dist/{chunk-E4FJOLPJ.js → chunk-QYH2NR6G.js} +3 -3
- package/dist/{chunk-XLXDXJY2.js → chunk-RBNMNKNN.js} +5 -5
- package/dist/{chunk-ZYSALKKW.js → chunk-RMHZFWHF.js} +21 -21
- package/dist/{chunk-7DLZC73N.js → chunk-RPCIROW7.js} +2 -2
- package/dist/{chunk-CTA7255D.js → chunk-YDICIB2A.js} +2 -2
- package/dist/{chunk-HEWZ6INU.js → chunk-YOWIYFIV.js} +27 -41
- package/dist/{claude-U2JC2DNQ.js → claude-GT2BPXEL.js} +3 -3
- package/dist/{cli-UFCFDIVI.js → cli-6HTAJ54L.js} +5 -5
- package/dist/{cli-BTPTJWCC.js → cli-IV5DJCXU.js} +8 -8
- package/dist/cli.js +3 -3
- package/dist/{completion-UI4IOYXY.js → completion-PPM7MEI2.js} +2 -2
- package/dist/{config-DnpLL2kT.d.ts → config-DzHB75Jz.d.ts} +2 -0
- package/dist/{diagnostics-QSQDE2KO.js → diagnostics-EWU2ROTG.js} +7 -7
- package/dist/{doctor-EOBNGAAB.js → doctor-ZWZQMDKZ.js} +20 -20
- package/dist/{entry-HBROO3YP.js → entry-NDICBQ2F.js} +12 -12
- package/dist/{exec-mcp-DZU2DEPD.js → exec-mcp-AG4G7SG7.js} +13 -13
- package/dist/{harness-H4OKGO6F.js → harness-JABSZCAA.js} +3 -3
- package/dist/harness-launch-gate.js +5 -5
- package/dist/harness-worker.js +7 -7
- package/dist/hook-body.js +361 -81
- package/dist/{hooks-T5JAK3VQ.js → hooks-YVQSDQV3.js} +3 -3
- package/dist/{host-5JOCZURV.js → host-2SZRMHZX.js} +8 -8
- package/dist/{host-IRPBT5AL.js → host-BWZ5LA4Q.js} +16 -16
- package/dist/{host-run-KPH5ZNYU.js → host-run-SXLV4LHI.js} +21 -13
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/{import-mcp-24QRNZBJ.js → import-mcp-2M7SZRVQ.js} +11 -11
- package/dist/index.d.ts +6 -4
- package/dist/index.js +19 -19
- package/dist/{init-EPIJY23S.js → init-HOOIFBAD.js} +2 -2
- package/dist/{install-MQ7QSJQ7.js → install-HF6CROQP.js} +19 -9
- package/dist/{invoke-2SXY6G3P.js → invoke-JP4MILYY.js} +9 -9
- package/dist/{list-C3WEYY3N.js → list-UBSBUZKS.js} +13 -13
- package/dist/{list-FB6RNYYB.js → list-WK2IYUK7.js} +4 -4
- package/dist/{logout-J4SFSWMA.js → logout-OO3DERRK.js} +12 -12
- package/dist/{logs-H3RPKNTE.js → logs-K3QXKRD4.js} +6 -6
- package/dist/mailbox/index.d.ts +4 -4
- package/dist/mailbox/index.js +3 -3
- package/dist/{mailbox-UECKDZ3Q.js → mailbox-DAJV6VAI.js} +10 -10
- package/dist/{mailbox-5DWLH4W2.js → mailbox-YN6PG66A.js} +4 -4
- package/dist/{mainline-FPK4HWFF.js → mainline-6K5BA3WX.js} +55 -33
- package/dist/{mcp-W6OADCKB.js → mcp-JXNTKRJG.js} +2 -2
- package/dist/{pause-2HQ7CKMR.js → pause-GRVTSKOK.js} +5 -5
- package/dist/{project-TZAYGUHM.js → project-M672MKQH.js} +4 -4
- package/dist/{pty-XTJ4MIWK.js → pty-LHKJKY2E.js} +3 -3
- package/dist/{recovery-54KHNJX4.js → recovery-HB2YFQSQ.js} +3 -3
- package/dist/{reindex-ZULHSQWY.js → reindex-I7RYWCUR.js} +5 -5
- package/dist/{resume-ETFTR5V3.js → resume-6DMPGG3N.js} +5 -5
- package/dist/{run-QQB74HRI.js → run-5W566T3V.js} +14 -14
- package/dist/{run-XZ75CAFL.js → run-ORBIERI3.js} +4 -4
- package/dist/{serve-TILM4DH5.js → serve-73SRPAV4.js} +9 -9
- package/dist/{setup-63E3TVJK.js → setup-ULKDPF5B.js} +5 -6
- package/dist/{start-login-C2BWQNO5.js → start-login-BGFAMCZL.js} +12 -12
- package/dist/{status-3AU65SCN.js → status-73FEFQUQ.js} +12 -12
- package/dist/{status-JMXH6XG4.js → status-YCW6YJ3S.js} +23 -23
- package/dist/{status-CM753VKY.js → status-YHXEAJ7U.js} +8 -8
- package/dist/stdio.d.ts +2 -2
- package/dist/stdio.js +5 -5
- package/dist/{sweep-VY2TNOO5.js → sweep-XF2HG3EO.js} +5 -5
- package/dist/{test-MCM44GOL.js → test-IMNBXOYW.js} +15 -17
- package/dist/{tui-BL4OSDW4.js → tui-5GDA22TB.js} +6 -6
- package/dist/{unbroadcast-RKTBP57G.js → unbroadcast-XP3OCVN3.js} +5 -5
- package/dist/{validate-AVM2VHMM.js → validate-KFBCUFI4.js} +5 -5
- package/dist/{worker-GHQKC5XU.js → worker-RV6NGSXT.js} +10 -10
- package/dist/{worktree-list-NEIDD66X.js → worktree-list-4PLE7K6L.js} +4 -4
- package/docs/git-workflow.md +48 -12
- package/docs/hooks.md +23 -14
- package/docs/project-configuration.md +21 -12
- package/docs/upgrading.md +52 -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/draw.tsx +9 -2
- package/plugins/pmcp/mod/guard.ts +3 -3
- package/plugins/pmcp/mod/model.ts +15 -4
- package/plugins/pmcp/mod/reader/read.ts +33 -8
- package/plugins/pmcp/mod/reader/settings.ts +7 -0
- package/plugins/pmcp/mod/reader/types.ts +2 -0
- package/plugins/pmcp/mod/sessions/format.ts +25 -2
- package/plugins/pmcp/mod/sessions/types.ts +1 -1
- package/plugins/pmcp/plugin.json +1 -1
- package/schema/catalog-v1.json +4 -15
- package/schema/library.json +3 -8
- package/schema/marketplace-manifest.json +2 -6
- package/schema/skill-frontmatter.json +3 -8
- package/schema/skill-metadata-core.json +3 -8
- package/dist/chunk-DXJZ2ZCX.js +0 -56
- package/dist/chunk-QHH3TXOA.js +0 -7
- package/dist/{core-C1LPjxK6.d.ts → core-Sug_rZrx.d.ts} +1 -1
package/docs/git-workflow.md
CHANGED
|
@@ -18,8 +18,8 @@ repository that also has linked worktrees, tracks the files it edits there,
|
|
|
18
18
|
and names leftovers not yet delivered, because they block syncing the shared main for
|
|
19
19
|
everyone. Keys: `enabled` (`"auto"` default, following `[git] enabled`, or a
|
|
20
20
|
boolean), `warn_on_session`, `track_edits`, `warn_claimants` (booleans, default
|
|
21
|
-
`true`).
|
|
22
|
-
|
|
21
|
+
`true`). Like every feature it is opt-in: declare the table, even empty, to
|
|
22
|
+
turn it on.
|
|
23
23
|
|
|
24
24
|
`[git.worktrees]` configures the linked worktrees `pmcp git worktree` creates:
|
|
25
25
|
|
|
@@ -36,7 +36,9 @@ loses nothing: `on_session_start` (`"fetch_and_move"` default, `"move"`,
|
|
|
36
36
|
`"off"`), `between_prompts` (`"move_if_light"` default, `"off"`: move only when
|
|
37
37
|
no install is needed), `install_after_move` (`"off"` default, `"background"`,
|
|
38
38
|
`"foreground"`) and `notice_paths` (paths whose change is announced to the
|
|
39
|
-
session). Installs never block a session.
|
|
39
|
+
session). Installs never block a session. A worktree is not moved while the
|
|
40
|
+
workspace is paused or while any lease is held (every `[sessions.leases.<name>]`,
|
|
41
|
+
or the implicit `lockfile` lease), and the session is told which.
|
|
40
42
|
|
|
41
43
|
`[git.mainline.gate]`: `command` (argv; no gate when missing), `tree` (the
|
|
42
44
|
gate's worktree, default `<state dir>/gate/tree`; a relative path is relative to
|
|
@@ -52,7 +54,7 @@ fails without running the gate; once started, a gate is never retried.
|
|
|
52
54
|
|
|
53
55
|
One delivery gates at a time: pmcp takes an exclusive `flock` on the file `lock`
|
|
54
56
|
beside the gate tree (`<dir of tree>/lock`), so another tool that takes the same
|
|
55
|
-
file with `flock` (a
|
|
57
|
+
file with `flock` (a project's own landing script, say) and pmcp never gate together. With
|
|
56
58
|
`lock_env` set, pmcp sets that variable to `1` for the gate command and its
|
|
57
59
|
children, and a `pmcp git deliver` started with it already `1` runs under its
|
|
58
60
|
caller's lock instead of waiting for it. `tree_env` names a variable that, when
|
|
@@ -63,25 +65,43 @@ While a delivery holds the lock it keeps `holder.json` beside it,
|
|
|
63
65
|
can say whose gate it waits for; the file is removed on release.
|
|
64
66
|
|
|
65
67
|
A lease is `<state dir>/<name>-lease.json` unless `[sessions.leases.<name>] file`
|
|
66
|
-
places it elsewhere,
|
|
67
|
-
|
|
68
|
-
counts as free. With `events` set, each delivery that changed the leased paths
|
|
68
|
+
places it elsewhere, where any tool coordinating the same paths can read and
|
|
69
|
+
write it; a record whose process is gone counts as free. With `events` set, each delivery that changed the leased paths
|
|
69
70
|
appends one line there: `{at, subject, commit, hash, installed, lease}`, where
|
|
70
71
|
`commit` is the delivered upstream, `hash` the leased files' hash in the main
|
|
71
72
|
checkout after sync, and `installed` whether sync's install ran for that hash.
|
|
73
|
+
The fields of every shared file are listed under
|
|
74
|
+
[Shared file formats](#shared-file-formats).
|
|
72
75
|
|
|
73
76
|
`[git.mainline.deliver]` enables `pmcp git deliver`, which replays commits onto
|
|
74
77
|
the fetched mainline, runs the gate, and pushes one delivery at a time:
|
|
75
78
|
`attempts` (default `3`), `refuse_direct_push` (default `true`: a hook refuses
|
|
76
79
|
`git push` from any checkout of this repository, so the mainline moves only
|
|
77
80
|
through delivery), `during_pause` (`"refuse"` default or `"allow"`),
|
|
78
|
-
`lease_wait_seconds` (default `3600`)
|
|
79
|
-
delivery)
|
|
81
|
+
`lease_wait_seconds` (default `3600`), `notify` (argv run after a
|
|
82
|
+
delivery), `gate` and `push_env`.
|
|
83
|
+
|
|
84
|
+
The push of a delivery runs the repository's own hooks, so a pre-push hook that
|
|
85
|
+
gates as well needs one of two set-ups.
|
|
86
|
+
|
|
87
|
+
- `gate = "pre-push"` makes that hook the gate: pmcp takes the lock, replays and
|
|
88
|
+
retries, runs no `[git.mainline.gate] command` (declaring one is an error),
|
|
89
|
+
and pushes with `lock_env` set to `1`, so a hook that takes the same lock does
|
|
90
|
+
not wait on pmcp. The push output is the gate log, and a refused push is a
|
|
91
|
+
failed gate.
|
|
92
|
+
- `gate = "command"` (the default) keeps pmcp's command as the gate.
|
|
93
|
+
`push_env` (a table of variable names to strings, default `{}`) adds variables
|
|
94
|
+
to the push alone in either mode, so a hook can recognise a delivery that was
|
|
95
|
+
already gated and step aside.
|
|
96
|
+
|
|
97
|
+
Every delivery push also carries `PMCP_GIT_DELIVER=1`. In command mode the lock
|
|
98
|
+
variable reaches the push only if `push_env` names it.
|
|
80
99
|
|
|
81
100
|
`pmcp git deliver --json` prints one receipt on stdout when it ends, progress
|
|
82
101
|
staying on stderr: `{ok, code, delivered, upstream, attempts, gate, leases,
|
|
83
102
|
reason?}`, where `delivered` is the upstream commit it pushed (or `null`), `gate`
|
|
84
|
-
is `{exit, log}` for the last gate run (or `null
|
|
103
|
+
is `{exit, log, by}` for the last gate run (or `null`; `by` is `"command"` or
|
|
104
|
+
`"pre-push"`), `leases` the leases it took
|
|
85
105
|
and `reason` the last refusal or failure. Exit codes: `0` delivered or nothing
|
|
86
106
|
to deliver; `1` refused, a lease or the gate lock held too long, a replay
|
|
87
107
|
conflict, the gate failed, the push failed or it gave up after `attempts`; `2`
|
|
@@ -104,8 +124,8 @@ its name. Delivery events record the same hash and whether the stamp matches it.
|
|
|
104
124
|
`[git.submodules]`: `follow = "clean_pins"` (the default when the table is
|
|
105
125
|
present) moves submodules to the pinned commit when they are clean; `"off"`
|
|
106
126
|
leaves them. Without the table submodules are not followed.
|
|
107
|
-
`shared` lists submodules other sessions also edit in the main checkout (
|
|
108
|
-
|
|
127
|
+
`shared` lists submodules other sessions also edit in the main checkout (an
|
|
128
|
+
app kept in its own repository, for example): those move to the new pin even with uncommitted edits, as
|
|
109
129
|
long as no edited or untracked file is one the pin changes. When one is, the
|
|
110
130
|
submodule stays on the old pin and sync names the files; pmcp never restores,
|
|
111
131
|
stashes or discards them.
|
|
@@ -116,3 +136,19 @@ needs nothing. Otherwise exactly the pinned commit is pushed to the submodule's
|
|
|
116
136
|
branch (`branch` in `.gitmodules`, else `main`) as a fast-forward, never a later
|
|
117
137
|
commit; if that branch has moved past the pin's base, delivery stops before
|
|
118
138
|
anything else moves.
|
|
139
|
+
|
|
140
|
+
## Shared file formats
|
|
141
|
+
|
|
142
|
+
Delivery and sync coordinate through plain files, so any tool, a project's own
|
|
143
|
+
scripts included, can wait on, read or write the same state. These are pmcp's
|
|
144
|
+
formats: within a release line fields are only added, never renamed, retyped or
|
|
145
|
+
removed, and readers ignore fields they do not know. Times are UTC ISO 8601
|
|
146
|
+
strings, and JSON files are written whole through a rename.
|
|
147
|
+
|
|
148
|
+
| File | Where | Content |
|
|
149
|
+
| ------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
150
|
+
| `lock` | beside the gate tree | Empty; held with `flock -x` for the whole of one delivery's gate. |
|
|
151
|
+
| `holder.json` | beside `lock` | `{tip, subject, checkout, pid, startedAt}`: the commit being gated (full hash), its subject, the checkout delivering it, the holding process and when it took the lock. Removed by its writer before the lock is released, and only when `pid` is its own. |
|
|
152
|
+
| `<name>-lease.json` | the state directory, or `[sessions.leases.<name>] file` | `{pid, subject, since, cwd?}`. A lease whose `pid` is not alive is free; whoever takes it next replaces the file. |
|
|
153
|
+
| lease events | `[sessions.leases.<name>] events` | JSON Lines, one per delivery that changed the leased paths: `{at, subject, commit, hash, installed, lease}`, with `commit` the delivered upstream (10 characters), `hash` the leased files' hash in the main checkout after sync, and `installed` whether sync's install ran for that hash. |
|
|
154
|
+
| install stamp | `[git.mainline.sync] stamp`, else pmcp's state directory | One line: the hash last installed. With `stamp_hash = "plain"` it is the sha256 hex of the single `install_when_changed` file's bytes; with `"pmcp"`, a hash of every listed path and its name. |
|
package/docs/hooks.md
CHANGED
|
@@ -31,8 +31,7 @@ compile cache off.
|
|
|
31
31
|
|
|
32
32
|
Every feature is opt-in: a table that is missing turns its feature off, and a
|
|
33
33
|
declared table, even an empty one, turns it on. The exceptions are documented
|
|
34
|
-
where they apply: `[git]` features detect git (`enabled = "auto"`),
|
|
35
|
-
`[git.shared_checkout]` is on in any git checkout once the bundle exists, and
|
|
34
|
+
where they apply: declared `[git]` features detect git (`enabled = "auto"`), and
|
|
36
35
|
logging falls back to its defaults rather than to no logging. The bundle is
|
|
37
36
|
projected only when `[hooks]` declares guards or checks, a `[sessions.*]`
|
|
38
37
|
feature table is declared, `[git.shared_checkout]` or `[git.worktrees.sync]` is
|
|
@@ -60,18 +59,19 @@ call: `policy`, `session`, `verdict` (what the call got) and, under `data`, `raw
|
|
|
60
59
|
(what the guard found: `allow`, `ask` or `deny`), `mode`, `tool` (the tool kind) and
|
|
61
60
|
`native` (the runtime's tool name), never the command, the reason or the prompt.
|
|
62
61
|
|
|
63
|
-
| Table | Default mode | Modes | Refuses
|
|
64
|
-
| ------------------------------------------ | ------------ | ------------------------------------- |
|
|
65
|
-
| `[hooks.guards.shell.in_place_edit]` | deny | deny, ask, warn, observe, off | `sed -i`, `perl -i`, `awk -i inplace`: edits without a diff.
|
|
66
|
-
| `[hooks.guards.shell.heredoc]` | deny | deny, ask, warn, observe, off | Heredocs and here-strings, whose body the shell expands silently.
|
|
67
|
-
| `[hooks.guards.shell.stdin_interpreter]` | ask | deny, ask, warn, observe, off | An interpreter reading its program from stdin (`python3 -`, `cat x.py \| python3`).
|
|
68
|
-
| `[hooks.guards.shell.compose_teardown]` | deny | deny, ask, warn, observe, off | `docker compose down`, and `stop`, `rm` or `kill` with no service named: they hit every service.
|
|
69
|
-
| `[hooks.guards.shell.secret_exfiltration]` | graded | deny, ask, warn, observe, off, graded | Reading a credential asks; sending one over the network, or changing a live one, denies.
|
|
70
|
-
| `[hooks.guards.shell.host_approval]` | deny | deny, ask, warn, observe, off | `host approve`, and commands or edits touching the host approvals directory. On by itself when `[host]` is declared.
|
|
71
|
-
| `[hooks.guards.
|
|
72
|
-
| `[hooks.guards.git.
|
|
73
|
-
| `[hooks.guards.git.
|
|
74
|
-
| `[hooks.guards.git.
|
|
62
|
+
| Table | Default mode | Modes | Refuses |
|
|
63
|
+
| ------------------------------------------ | ------------ | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `[hooks.guards.shell.in_place_edit]` | deny | deny, ask, warn, observe, off | `sed -i`, `perl -i`, `awk -i inplace`: edits without a diff. |
|
|
65
|
+
| `[hooks.guards.shell.heredoc]` | deny | deny, ask, warn, observe, off | Heredocs and here-strings, whose body the shell expands silently. |
|
|
66
|
+
| `[hooks.guards.shell.stdin_interpreter]` | ask | deny, ask, warn, observe, off | An interpreter reading its program from stdin (`python3 -`, `cat x.py \| python3`). |
|
|
67
|
+
| `[hooks.guards.shell.compose_teardown]` | deny | deny, ask, warn, observe, off | `docker compose down`, and `stop`, `rm` or `kill` with no service named: they hit every service. |
|
|
68
|
+
| `[hooks.guards.shell.secret_exfiltration]` | graded | deny, ask, warn, observe, off, graded | Reading a credential asks; sending one over the network, or changing a live one, denies. |
|
|
69
|
+
| `[hooks.guards.shell.host_approval]` | deny | deny, ask, warn, observe, off | `host approve`, and commands or edits touching the host approvals directory. On by itself when `[host]` is declared. |
|
|
70
|
+
| `[hooks.guards.shell.runaway_regex]` | deny | deny, ask, warn, observe, off | A grep pattern that can hold a core for minutes: a repetition count over the threshold (`\{0,2500\}`, `{0,2500}` with `-E` or `-P`), or a `-P` group quantified inside a quantifier such as `(a+)+`. ripgrep (`rg`) matches in linear time and is never refused. |
|
|
71
|
+
| `[hooks.guards.git.push_without_verify]` | deny | deny, ask, warn, observe, off | `git push --no-verify`. |
|
|
72
|
+
| `[hooks.guards.git.forced_branch_move]` | deny | deny, ask, warn, observe, off | Forcing a branch that is checked out in another working tree. |
|
|
73
|
+
| `[hooks.guards.git.gate_bypass_env]` | deny | deny, ask, warn, observe, off | Setting a named gate-bypass variable where it takes effect, and optionally `--no-verify` on any git command. |
|
|
74
|
+
| `[hooks.guards.git.stage_all]` | deny | deny, ask, warn, observe, off | `git add -A`, `git add .`, `git commit -a` and similar; stage explicit paths. |
|
|
75
75
|
|
|
76
76
|
Options:
|
|
77
77
|
|
|
@@ -86,6 +86,15 @@ Options:
|
|
|
86
86
|
in `extra_secret_paths`. Only a file a command reads counts: a search
|
|
87
87
|
pattern, a sed or awk script, a jq filter or `-e` code that mentions `.env`
|
|
88
88
|
does not.
|
|
89
|
+
- `[hooks.guards.shell.runaway_regex]`: `threshold` (the largest repetition
|
|
90
|
+
count allowed, 1 to 32767, default `255`), `allow_timeout` (default `true`: a
|
|
91
|
+
grep run under `timeout <n>` is bounded and passes) and
|
|
92
|
+
`only_matching_wildcards` (default `false`: also refuse `-o` with more than
|
|
93
|
+
one `.*`, which is slow on long lines but often harmless). It reads `grep`,
|
|
94
|
+
`egrep`, `zgrep` and `git grep`; `fgrep` and `-F` patterns are literal. The
|
|
95
|
+
refusal suggests `grep -n` to find the line and `sed -n 'N,+K p'` to print
|
|
96
|
+
around it, `rg`, a smaller count, or `timeout 20`. A command the parser cannot
|
|
97
|
+
read passes.
|
|
89
98
|
- `[hooks.guards.git.gate_bypass_env]`: `names` (variable names, default `[]`)
|
|
90
99
|
and `no_verify` (boolean, default `true`).
|
|
91
100
|
|
|
@@ -33,12 +33,14 @@ specification. Without it, only the specification is checked.
|
|
|
33
33
|
[catalog.validation]
|
|
34
34
|
profile = "catalog-v1" # or "library"
|
|
35
35
|
deny_list = "private-terms.txt"
|
|
36
|
+
tiers = ["open", "free", "paid", "internal"]
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
| Key | Type | Default
|
|
39
|
-
| ----------- | ------ |
|
|
40
|
-
| `profile` | string | none
|
|
41
|
-
| `deny_list` | path | none
|
|
39
|
+
| Key | Type | Default | Meaning |
|
|
40
|
+
| ----------- | ------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
41
|
+
| `profile` | string | none | `catalog-v1`: general marketplace catalog rules (strict metadata, name equal to the directory, tier inheritance, ASCII descriptions, approval for scripts, locales); the marketplace's tier applies, else the skill's own `metadata.tier`, else `open`. `library`: the manual library skill metadata schema. |
|
|
42
|
+
| `deny_list` | path | none | A file of terms, one per line (`#` starts a comment), that no file of a skill may contain, compared without case. Relative to `pmcp.toml`. A finding names the list line, never the term. A missing file is an error. |
|
|
43
|
+
| `tiers` | list | `["open", "free", "paid", "internal"]` | The tier names this catalog uses, lowest first, in kebab case. `catalog-v1` reports a tier outside the list as `tier.unknown`; its tier-specific rules know only the four default names. The metadata schema itself takes any kebab-case name. |
|
|
42
44
|
|
|
43
45
|
Both apply to named skill directories and, with no directory named, to every
|
|
44
46
|
skill the catalog reaches.
|
|
@@ -164,6 +166,7 @@ the way to run sessions there.
|
|
|
164
166
|
[host]
|
|
165
167
|
roots = ["."] # every session cwd must be under one of these
|
|
166
168
|
mcp_write = false # pty_turn and pty_lease over pmcp harness mcp
|
|
169
|
+
memory_max = "4G" # MemoryMax of the host's systemd scope and printed unit (default 4G)
|
|
167
170
|
|
|
168
171
|
[[host.sessions]]
|
|
169
172
|
name = "lead" # lowercase, digits and -; unique
|
|
@@ -456,13 +459,13 @@ lives in one directory shared by every checkout of the repository.
|
|
|
456
459
|
|
|
457
460
|
`store` and `state_dir` alone enable nothing; each feature has its own table:
|
|
458
461
|
|
|
459
|
-
| Table | Keys
|
|
460
|
-
| -------------------------- |
|
|
461
|
-
| `[sessions.registry]` | `liveness` (`"pid_heartbeat"`, the only value), `stale_minutes` (default `30`)
|
|
462
|
-
| `[sessions.pause]` | `mode` (`deny` default, `ask`, `warn`, `off`), `refuses` (`"mutating"`), `scripts` (regular expressions, default `[]`: a `node` script matching one also counts as mutating, e.g. your own delivery or sync script)
|
|
463
|
-
| `[sessions.broadcast]` | `keep` (default `10`), `deliver_on` (default `["session_start", "prompt", "before_tool"]`; also `after_tool`, `stop`)
|
|
464
|
-
| `[sessions.leases.<name>]` | `path` (string, shown in the message and used by git delivery), `blocks` (required list of argv prefixes), `file` and `events` (optional paths: absolute, `~/…`, or `${gate_dir}/…` for the directory of the gate tree)
|
|
465
|
-
| `[sessions.roles.<name>]` | `agent_type` (default `<name>`, also matches `plugin:<name>`), `allow_edits` (default `false`), `allow_commands` (list of argv prefixes, default `[]`)
|
|
462
|
+
| Table | Keys | Effect |
|
|
463
|
+
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
464
|
+
| `[sessions.registry]` | `liveness` (`"pid_heartbeat"`, the only value), `stale_minutes` (default `30`) | Records each session with its process and heartbeat; `pmcp sessions status` lists them. |
|
|
465
|
+
| `[sessions.pause]` | `mode` (`deny` default, `ask`, `warn`, `off`), `refuses` (`"mutating"`), `scripts` (regular expressions, default `[]`: a `node` script matching one also counts as mutating, e.g. your own delivery or sync script), `commands` (argv prefixes that also count, replacing the default `docker` compose/build/push/run/rm/stop/restart and `wrangler` deploy/publish/secret), `script_names` (regular expressions for `bun`, `npm`, `pnpm` or `yarn run <name>`, default `["^git:", "^docker:", "^deploy", "^release", "^publish"]`); git commits, pushes and the like and package installs always count | While `pmcp sessions pause` is in effect, edits and mutating commands are refused for every session but the one that paused; reading continues. |
|
|
466
|
+
| `[sessions.broadcast]` | `keep` (default `10`), `deliver_on` (default `["session_start", "prompt", "before_tool"]`; also `after_tool`, `stop`) | Delivers `pmcp sessions broadcast` text once to each session, as context on the listed events. |
|
|
467
|
+
| `[sessions.leases.<name>]` | `path` (string, shown in the message and used by git delivery), `blocks` (required list of argv prefixes), `file` and `events` (optional paths: absolute, `~/…`, or `${gate_dir}/…` for the directory of the gate tree) | While another session holds lease `<name>`, commands starting with a listed prefix are denied until its delivery finishes. |
|
|
468
|
+
| `[sessions.roles.<name>]` | `agent_type` (default `<name>`, also matches `plugin:<name>`), `allow_edits` (default `false`), `allow_commands` (list of argv prefixes, default `[]`) | A subagent of that type may edit only if allowed and run only the listed commands. Claude only. |
|
|
466
469
|
|
|
467
470
|
These tables have no `mode`, except pause. Without `[sessions.registry]` no
|
|
468
471
|
session is recorded, and `[ui.claude]` refuses to project.
|
|
@@ -597,7 +600,8 @@ records them without raising the rest; see [Hooks](hooks.md#hooksguardsgroupname
|
|
|
597
600
|
`[ui.claude]` installs the session panes into Claude Code: `sessions_pane`,
|
|
598
601
|
`status_band`, `commands` and `hold_foreign_edits`, all booleans defaulting to
|
|
599
602
|
`true`. `hold_foreign_edits` asks before editing a file another live session
|
|
600
|
-
edited.
|
|
603
|
+
edited. The panes and the hold know linked worktrees by `[git.worktrees] root`
|
|
604
|
+
(default `.claude/worktrees`). It needs `[sessions.registry]`, and is written only when `claude` is
|
|
601
605
|
in `[targets] tools`. Without the table nothing is installed. `pmcp doctor`
|
|
602
606
|
shows the projected switches, or a failure until `pmcp project` writes them; it
|
|
603
607
|
cannot tell whether a running Claude Code loaded the session panes.
|
|
@@ -649,6 +653,9 @@ binary = "secrets-cli"
|
|
|
649
653
|
read = ["read", "env get"]
|
|
650
654
|
publish = ["deploy", "secret put", "secret delete"]
|
|
651
655
|
|
|
656
|
+
[hooks.guards.shell.runaway_regex]
|
|
657
|
+
threshold = 255
|
|
658
|
+
|
|
652
659
|
[hooks.guards.git.push_without_verify]
|
|
653
660
|
|
|
654
661
|
[hooks.guards.git.forced_branch_move]
|
|
@@ -693,6 +700,8 @@ allow_commands = [["pmcp", "git", "deliver"], ["git", "log"], ["git", "status"]]
|
|
|
693
700
|
[git]
|
|
694
701
|
remote = "origin"
|
|
695
702
|
|
|
703
|
+
[git.shared_checkout]
|
|
704
|
+
|
|
696
705
|
[git.mainline]
|
|
697
706
|
branch = "main"
|
|
698
707
|
|
package/docs/upgrading.md
CHANGED
|
@@ -5,6 +5,58 @@
|
|
|
5
5
|
What to do when a release changes something you rely on. Each release's notes on GitHub
|
|
6
6
|
Releases list its breaking changes and link here.
|
|
7
7
|
|
|
8
|
+
## From 0.19 to 0.20
|
|
9
|
+
|
|
10
|
+
0.20 removes defaults that suited one kind of project rather than pmcp's users in general.
|
|
11
|
+
Each one stays available as configuration; add the lines below to `pmcp.toml` to keep what
|
|
12
|
+
0.19 did, then run `pmcp project`.
|
|
13
|
+
|
|
14
|
+
**The shared-checkout notice is opt-in.** 0.19 turned `[git.shared_checkout]` on in any git
|
|
15
|
+
checkout once the hook bundle existed. Declare it to keep the notice:
|
|
16
|
+
|
|
17
|
+
```toml
|
|
18
|
+
[git.shared_checkout]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Dated `.bak` files are no longer secret paths by default.** 0.19 treated a file named like
|
|
22
|
+
`config.bak.20261027` as a credential. If yours hold credentials:
|
|
23
|
+
|
|
24
|
+
```toml
|
|
25
|
+
[hooks.guards.shell.secret_exfiltration]
|
|
26
|
+
extra_secret_paths = ['\.bak\.\d{8,}']
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`.env.<name>` directories (`.env.d/`, `.env.local/`) are still caught as `.env` variants.
|
|
30
|
+
|
|
31
|
+
**`bun run git:land` and `bun run git:sync` are no longer lockfile operations by name.** The
|
|
32
|
+
shell classifier had them built in. A project's own landing or sync script is data:
|
|
33
|
+
|
|
34
|
+
- a package script run with `bun`, `npm`, `pnpm` or `yarn run` is matched by
|
|
35
|
+
`[sessions.pause] script_names`, whose default `"^git:"` still covers `git:*` scripts;
|
|
36
|
+
- a script run with `node` is matched by `[sessions.pause] scripts`, for example
|
|
37
|
+
`scripts = ['tools/release/(land|sync)\.mjs$']`.
|
|
38
|
+
|
|
39
|
+
**`catalog-v1` validates general catalog rules only.** `pmcp validate` with
|
|
40
|
+
`[catalog.validation] profile = "catalog-v1"` no longer reports `description.trigger`,
|
|
41
|
+
`keywords.ascii`, `output-license.required`, `server-tools.forbidden`,
|
|
42
|
+
`server-tools.required` or `server-tools.order`. `metadata.server-tools` is an optional list of
|
|
43
|
+
any tool names. A catalog that relies on those rules runs its own check beside
|
|
44
|
+
`pmcp validate`.
|
|
45
|
+
|
|
46
|
+
**Session records move from `fleet/` to `sessions/` in the state directory.** 0.20 writes
|
|
47
|
+
every record to both `sessions/<session>.json` and the deprecated `fleet/<session>.json`, and
|
|
48
|
+
reads both, using the copy updated last, so an older pmcp sharing the state directory (a hook
|
|
49
|
+
bundle not yet projected again) is followed. A tool that reads `fleet/` keeps working through
|
|
50
|
+
0.20; move it to `sessions/` and run `pmcp project` everywhere before 0.21, which stops
|
|
51
|
+
writing `fleet/`. A mail
|
|
52
|
+
recipient's linked worktree is now `worktree` throughout; `desk:<path>` is still accepted as a
|
|
53
|
+
spelling of `worktree:<path>`.
|
|
54
|
+
|
|
55
|
+
**Deliveries can leave gating to the repository's pre-push hook.** This is new, not a
|
|
56
|
+
removal. `[git.mainline.deliver] gate = "pre-push"` and `push_env` are described in
|
|
57
|
+
[Git workflow](git-workflow.md). A delivery's push now always carries `PMCP_GIT_DELIVER=1`, and
|
|
58
|
+
the `--json` receipt's `gate` gains `by`.
|
|
59
|
+
|
|
8
60
|
## From 0.17 to 0.18
|
|
9
61
|
|
|
10
62
|
0.18 replaces tmux with pmcp's own terminal host, so it does not read tmux groups or views.
|
package/gemini-extension.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"mcpServers": {
|
|
5
5
|
"pmcp": {
|
|
6
6
|
"type": "stdio",
|
|
7
7
|
"command": "npx",
|
|
8
|
-
"args": ["-y", "@modootoday/pmcp@0.
|
|
8
|
+
"args": ["-y", "@modootoday/pmcp@0.20.0", "serve"]
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
package/mcp.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modootoday/pmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"author": "modootoday",
|
|
6
6
|
"description": "Use the skills your packages already ship, and keep your AI tools' project configuration in one place.",
|
|
@@ -136,9 +136,9 @@
|
|
|
136
136
|
"bun": ">=1.3.0"
|
|
137
137
|
},
|
|
138
138
|
"optionalDependencies": {
|
|
139
|
-
"@modootoday/pmcp-linux-x64": "0.
|
|
140
|
-
"@modootoday/pmcp-linux-arm64": "0.
|
|
141
|
-
"@modootoday/pmcp-darwin-x64": "0.
|
|
142
|
-
"@modootoday/pmcp-darwin-arm64": "0.
|
|
139
|
+
"@modootoday/pmcp-linux-x64": "0.20.0",
|
|
140
|
+
"@modootoday/pmcp-linux-arm64": "0.20.0",
|
|
141
|
+
"@modootoday/pmcp-darwin-x64": "0.20.0",
|
|
142
|
+
"@modootoday/pmcp-darwin-arm64": "0.20.0"
|
|
143
143
|
}
|
|
144
144
|
}
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "pmcp",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"description": "Find package skills and use native runtime project configuration.",
|
|
6
6
|
"author": { "name": "modootoday" },
|
|
7
7
|
"license": "Elastic-2.0",
|
package/plugins/pmcp/.mcp.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"mcpServers": {
|
|
5
5
|
"pmcp": {
|
|
6
6
|
"type": "stdio",
|
|
7
7
|
"command": "npx",
|
|
8
|
-
"args": ["-y", "@modootoday/pmcp@0.
|
|
8
|
+
"args": ["-y", "@modootoday/pmcp@0.20.0", "serve"]
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
package/plugins/pmcp/mcp.json
CHANGED
|
@@ -33,7 +33,10 @@ export async function drawPane($: any, e: any): Promise<any> {
|
|
|
33
33
|
const columns = Math.max(20, Number(e.props?.bodyColumns ?? 80));
|
|
34
34
|
const now = state.now;
|
|
35
35
|
const nameWidth = Math.max(4, ...records.map((r) => labelOf(r).length));
|
|
36
|
-
const placeWidth = Math.max(
|
|
36
|
+
const placeWidth = Math.max(
|
|
37
|
+
5,
|
|
38
|
+
...records.map((r) => placeOf(r, state.settings?.worktreeRoot).length),
|
|
39
|
+
);
|
|
37
40
|
const fixed = 2 + nameWidth + 1 + 8 + placeWidth + 1 + MARKS + 5;
|
|
38
41
|
const actionWidth = Math.max(0, columns - fixed);
|
|
39
42
|
const mark = bandMark(state.snapshot);
|
|
@@ -93,7 +96,11 @@ export async function drawPane($: any, e: any): Promise<any> {
|
|
|
93
96
|
{labelOf(record).padEnd(nameWidth)}{" "}
|
|
94
97
|
</Text>
|
|
95
98
|
<Text color={look.color}>{look.word.padEnd(8)}</Text>
|
|
96
|
-
<Text dimColor>
|
|
99
|
+
<Text dimColor>
|
|
100
|
+
{placeOf(record, state.settings?.worktreeRoot).padEnd(
|
|
101
|
+
placeWidth,
|
|
102
|
+
)}{" "}
|
|
103
|
+
</Text>
|
|
97
104
|
<Text color="warning">{marksOf(record).padEnd(MARKS)}</Text>
|
|
98
105
|
<Text dimColor>
|
|
99
106
|
{ageOf(record.updatedAt, now).padStart(4)}{" "}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Leave foreign-edit decisions to the person because the mod must not enforce independent policy.
|
|
2
|
-
import { nameOf } from "./model";
|
|
2
|
+
import { linkedWorktreeOf, nameOf } from "./model";
|
|
3
3
|
import type { SessionRecord } from "./reader/index";
|
|
4
4
|
import { state } from "./state";
|
|
5
5
|
|
|
@@ -11,8 +11,8 @@ function checkoutOf(target: string, records: readonly SessionRecord[]): string {
|
|
|
11
11
|
best = root;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
return
|
|
14
|
+
const linked = linkedWorktreeOf(target, state.settings?.worktreeRoot);
|
|
15
|
+
return linked.length > best.length && target !== linked ? linked : best;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export async function holdForeignEdit($: any, e: any, next: any): Promise<any> {
|
|
@@ -68,11 +68,22 @@ export function byKind(a: SessionRecord, b: SessionRecord): number {
|
|
|
68
68
|
return labelOf(a).localeCompare(labelOf(b));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
|
|
71
|
+
// The linked worktree directory directly under the worktree root that holds path, or "".
|
|
72
|
+
// Without a root (settings projected before it was written) the default root is matched.
|
|
73
|
+
export function linkedWorktreeOf(path: string, worktreeRoot?: string): string {
|
|
74
|
+
if (!worktreeRoot)
|
|
75
|
+
return /^(.*\/\.claude\/worktrees\/[^/]+)(?:\/|$)/u.exec(path)?.[1] ?? "";
|
|
76
|
+
const root = worktreeRoot.replace(/\/+$/u, "");
|
|
77
|
+
if (!path.startsWith(`${root}/`)) return "";
|
|
78
|
+
const name = path.slice(root.length + 1).split("/")[0];
|
|
79
|
+
return name ? `${root}/${name}` : "";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// A linked worktree is named by its directory: detached ones have no branch to show.
|
|
83
|
+
export function placeOf(record: SessionRecord, worktreeRoot?: string): string {
|
|
73
84
|
const worktree = record.worktree ?? "";
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
85
|
+
const linked = linkedWorktreeOf(worktree.replace(/\/+$/u, ""), worktreeRoot);
|
|
86
|
+
if (linked) return linked.split("/").pop()!;
|
|
76
87
|
if (record.branch) return record.branch;
|
|
77
88
|
return worktree.replace(/\/+$/u, "").split("/").pop() || "-";
|
|
78
89
|
}
|
|
@@ -3,11 +3,13 @@ import {
|
|
|
3
3
|
asLease,
|
|
4
4
|
asPause,
|
|
5
5
|
asRecord,
|
|
6
|
-
|
|
6
|
+
isLeaseFile,
|
|
7
|
+
latestRecord,
|
|
7
8
|
recordLive,
|
|
8
9
|
STATE_FILES,
|
|
9
10
|
} from "../sessions/format";
|
|
10
11
|
import type {
|
|
12
|
+
Lease,
|
|
11
13
|
ReadOptions,
|
|
12
14
|
SessionRecord,
|
|
13
15
|
SessionSnapshot,
|
|
@@ -19,7 +21,6 @@ export { STALE_MS } from "../sessions/format";
|
|
|
19
21
|
export const STATE_PATHS = {
|
|
20
22
|
records: STATE_FILES.records,
|
|
21
23
|
pause: STATE_FILES.pause,
|
|
22
|
-
lease: leaseFile("lockfile"),
|
|
23
24
|
broadcast: STATE_FILES.broadcast,
|
|
24
25
|
} as const;
|
|
25
26
|
|
|
@@ -49,11 +50,20 @@ export async function readRecords(
|
|
|
49
50
|
files: StateFiles,
|
|
50
51
|
options: ReadOptions,
|
|
51
52
|
): Promise<SessionRecord[]> {
|
|
52
|
-
|
|
53
|
-
const
|
|
53
|
+
// sessions/ and the deprecated fleet/: each session once, the copy updated last.
|
|
54
|
+
const found = new Map<string, (SessionRecord | null)[]>();
|
|
55
|
+
for (const folder of [STATE_PATHS.records, STATE_FILES.legacyRecords]) {
|
|
56
|
+
const directory = `${options.stateDir}/${folder}`;
|
|
57
|
+
const names = await files.list(directory).catch(() => [] as string[]);
|
|
58
|
+
for (const name of names.filter((item) => item.endsWith(".json")))
|
|
59
|
+
found.set(name, [
|
|
60
|
+
...(found.get(name) ?? []),
|
|
61
|
+
asRecord(await readJson(files, `${directory}/${name}`)),
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
54
64
|
const records: SessionRecord[] = [];
|
|
55
|
-
for (const name of
|
|
56
|
-
const record =
|
|
65
|
+
for (const name of [...found.keys()].sort()) {
|
|
66
|
+
const record = latestRecord(found.get(name)!);
|
|
57
67
|
if (!record) continue;
|
|
58
68
|
const pidAlive = await isAlive(files, record.pid);
|
|
59
69
|
if (recordLive(record, options.now, pidAlive)) records.push(record);
|
|
@@ -61,16 +71,31 @@ export async function readRecords(
|
|
|
61
71
|
return records;
|
|
62
72
|
}
|
|
63
73
|
|
|
74
|
+
// Every live lease in the state directory, whatever its name; the one held longest is shown.
|
|
75
|
+
export async function readLease(
|
|
76
|
+
files: StateFiles,
|
|
77
|
+
options: ReadOptions,
|
|
78
|
+
): Promise<Lease | null> {
|
|
79
|
+
const names = await files.list(options.stateDir).catch(() => [] as string[]);
|
|
80
|
+
let held: Lease | null = null;
|
|
81
|
+
for (const name of names.filter(isLeaseFile).sort()) {
|
|
82
|
+
const lease = asLease(await readJson(files, `${options.stateDir}/${name}`));
|
|
83
|
+
if (!lease || !(await isAlive(files, lease.pid))) continue;
|
|
84
|
+
if (!held || Date.parse(lease.since ?? "") < Date.parse(held.since ?? ""))
|
|
85
|
+
held = lease;
|
|
86
|
+
}
|
|
87
|
+
return held;
|
|
88
|
+
}
|
|
89
|
+
|
|
64
90
|
export async function readSessionState(
|
|
65
91
|
files: StateFiles,
|
|
66
92
|
options: ReadOptions,
|
|
67
93
|
): Promise<SessionSnapshot> {
|
|
68
94
|
const at = (name: string) => `${options.stateDir}/${name}`;
|
|
69
|
-
const lease = asLease(await readJson(files, at(STATE_PATHS.lease)));
|
|
70
95
|
return {
|
|
71
96
|
records: await readRecords(files, options),
|
|
72
97
|
pause: asPause(await readJson(files, at(STATE_PATHS.pause))),
|
|
73
|
-
lease:
|
|
98
|
+
lease: await readLease(files, options),
|
|
74
99
|
broadcast: asBroadcast(await readJson(files, at(STATE_PATHS.broadcast))),
|
|
75
100
|
};
|
|
76
101
|
}
|
|
@@ -44,11 +44,18 @@ export function parseUiSettings(
|
|
|
44
44
|
)
|
|
45
45
|
return null;
|
|
46
46
|
if (SWITCHES.some((key) => typeof raw[key] !== "boolean")) return null;
|
|
47
|
+
const worktrees = raw.worktreeRoot;
|
|
48
|
+
if (
|
|
49
|
+
worktrees !== undefined &&
|
|
50
|
+
(typeof worktrees !== "string" || worktrees === "")
|
|
51
|
+
)
|
|
52
|
+
return null;
|
|
47
53
|
return {
|
|
48
54
|
...(declared ? { stateDir: within(projectRoot, declared) } : {}),
|
|
49
55
|
sessionsPane: raw.sessionsPane === true,
|
|
50
56
|
statusBand: raw.statusBand === true,
|
|
51
57
|
commands: raw.commands === true,
|
|
52
58
|
holdForeignEdits: raw.holdForeignEdits === true,
|
|
59
|
+
...(worktrees ? { worktreeRoot: within(projectRoot, worktrees) } : {}),
|
|
53
60
|
};
|
|
54
61
|
}
|
|
@@ -35,4 +35,6 @@ export interface UiSettings {
|
|
|
35
35
|
readonly statusBand: boolean;
|
|
36
36
|
readonly commands: boolean;
|
|
37
37
|
readonly holdForeignEdits: boolean;
|
|
38
|
+
// [git.worktrees] root, absolute once parsed; absent in files projected before it was written.
|
|
39
|
+
readonly worktreeRoot?: string;
|
|
38
40
|
}
|