@imdeadpool/guardex 8.4.0 → 8.4.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.
- package/CONTRIBUTING.md +13 -4
- package/README.md +223 -1
- package/THIRD-PARTY-NOTICES.md +29 -0
- package/bin/multiagent-safety.js +9 -12
- package/package.json +4 -2
- package/skills/gitguardex/SKILL.md +28 -0
- package/skills/pr-lens/SKILL.md +87 -0
- package/src/abide.js +534 -0
- package/src/agents/activity.js +23 -4
- package/src/agents/inspect.js +15 -6
- package/src/agents/launch.js +6 -1
- package/src/agents/process-lease.js +84 -0
- package/src/agents/sessions.js +96 -16
- package/src/agents/start.js +18 -9
- package/src/agents/status.js +35 -14
- package/src/agents/supervise.js +87 -0
- package/src/budget/index.js +6 -1
- package/src/cli/args.js +71 -77
- package/src/cli/commands/agents.js +38 -10
- package/src/cli/commands/branch.js +116 -103
- package/src/cli/commands/claude.js +604 -50
- package/src/cli/commands/codex.js +359 -0
- package/src/cli/commands/context.js +52 -0
- package/src/cli/commands/mcp.js +5 -1
- package/src/cli/commands/pr.js +138 -3
- package/src/cli/commands/review.js +3 -1
- package/src/cli/commands/setup.js +25 -0
- package/src/cli/commands/status.js +128 -60
- package/src/cli/commands/storage.js +24 -0
- package/src/cli/commands/usage.js +48 -0
- package/src/cli/commands/watch.js +157 -47
- package/src/cli/commands/worktree-copy-ignored.js +38 -0
- package/src/cli/commands/worktree-estimate.js +69 -0
- package/src/cli/commands/worktree-hooks.js +62 -0
- package/src/cli/commands/worktree-navigation.js +71 -0
- package/src/cli/commands/worktree-provision.js +92 -0
- package/src/cli/main.js +229 -110
- package/src/cli/shared/gate-flags.js +131 -0
- package/src/cli/shared/scaffolding.js +31 -3
- package/src/cli/shared-locks.js +3 -1
- package/src/cockpit/pane-actions.js +43 -7
- package/src/context.js +373 -17
- package/src/doctor/index.js +29 -35
- package/src/finish/events.js +254 -0
- package/src/finish/index.js +322 -62
- package/src/finish/post-branch-finish-cleanup.js +316 -22
- package/src/finish/preflight.js +44 -1
- package/src/finish/progress.js +36 -0
- package/src/finish/review-gate.js +317 -127
- package/src/finish/review-receipt.js +156 -0
- package/src/finish/with-claims-lock.py +29 -0
- package/src/git/index.js +179 -42
- package/src/hooks/index.js +68 -3
- package/src/mcp/collect.js +61 -5
- package/src/mcp/server.js +4 -0
- package/src/output/index.js +167 -1
- package/src/pr-lens-publish.js +93 -0
- package/src/pr-lens.js +184 -0
- package/src/pr-respond.js +860 -0
- package/src/pr-review.js +519 -159
- package/src/pr.js +73 -14
- package/src/provider-binary.js +21 -0
- package/src/review-diff-context.js +90 -0
- package/src/review-fix.js +23 -17
- package/src/scaffold/agent-worktree-prep.js +14 -12
- package/src/scaffold/dependency-store.js +234 -0
- package/src/scaffold/index.js +13 -1
- package/src/scaffold/provision-approvals.js +83 -0
- package/src/scaffold/provision-config.js +169 -40
- package/src/shared-git-state.js +11 -1
- package/src/speckit/index.js +12 -1
- package/src/storage/run-artifacts.js +185 -0
- package/src/toolchain/index.js +322 -2
- package/src/worktree-copy-ignored.js +200 -0
- package/src/worktree-hook-worker.js +29 -0
- package/src/worktree-hooks.js +333 -0
- package/src/worktree-navigation.js +248 -0
- package/src/worktree-picker.js +89 -0
- package/src/worktree-quota.js +100 -0
- package/src/worktree-start.js +100 -0
- package/templates/AGENTS.multiagent-safety.md +8 -0
- package/templates/AGENTS.multiagent-safety.min.md +3 -1
- package/templates/codex/skills/gitguardex/SKILL.md +28 -0
- package/templates/codex/skills/opensrc/SKILL.md +24 -0
- package/templates/githooks/post-merge +16 -2
- package/templates/scripts/agent-autofinish-watch.sh +17 -18
- package/templates/scripts/agent-branch-finish.sh +180 -19
- package/templates/scripts/agent-branch-merge.sh +7 -32
- package/templates/scripts/agent-branch-start.sh +202 -43
- package/templates/scripts/agent-claude-stop-finish.sh +4 -27
- package/templates/scripts/agent-file-locks.py +257 -29
- package/templates/scripts/agent-preflight.sh +3 -0
- package/templates/scripts/agent-worktree-prune.sh +975 -63
- package/templates/scripts/codex-agent.sh +55 -5
- package/templates/scripts/lib/guardex-base-branch.sh +207 -0
- package/templates/scripts/openspec/init-change-workspace.sh +10 -18
- package/templates/scripts/review-bot-watch.sh +171 -4
package/CONTRIBUTING.md
CHANGED
|
@@ -20,7 +20,16 @@ npm pack --dry-run
|
|
|
20
20
|
|
|
21
21
|
## Release hygiene
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
23
|
+
- Every push to `main` queues the npm release workflow. It runs verification and
|
|
24
|
+
the dependency audit before releasing the current commit; superseded runs
|
|
25
|
+
skip publishing.
|
|
26
|
+
- By default the workflow releases the next free patch after npm `latest`. For
|
|
27
|
+
a deliberate minor or major release, raise `package.json` and its lockfile and
|
|
28
|
+
add the version to the `README.md` release notes in the same PR.
|
|
29
|
+
- The npm Trusted Publisher is `opencue/gitguardex`, workflow `release.yml`,
|
|
30
|
+
environment `npm`, with `npm publish` allowed. No npm token is needed.
|
|
31
|
+
- The workflow publishes with provenance and attaches the published tarball,
|
|
32
|
+
SHA-256 checksum, and Sigstore bundle to the GitHub release. Rerun a failed
|
|
33
|
+
release on the same commit before the next merge to recover without publishing
|
|
34
|
+
a second version. A manually published stable tag matching the package version
|
|
35
|
+
on `main` still uses the same workflow.
|
package/README.md
CHANGED
|
@@ -74,7 +74,14 @@ Parallel agents can edit the same files, overwrite tests, or commit directly to
|
|
|
74
74
|
<summary><strong>Implementation evidence and shipped hardening</strong></summary>
|
|
75
75
|
|
|
76
76
|
- **Correct base targeting** — persist and validate each lane's base so an
|
|
77
|
-
unattended finish cannot use another checkout's target.
|
|
77
|
+
unattended finish cannot use another checkout's target. When
|
|
78
|
+
`branch.<b>.guardexBase` is absent (e.g., a worktree created with raw
|
|
79
|
+
`git worktree add`), the finish and stop hooks infer the base from git
|
|
80
|
+
history: the oldest reflog "Created from <name>" entry wins; if absent,
|
|
81
|
+
ancestry distance (commits ahead of each candidate's merge-base) selects the
|
|
82
|
+
closest; ties prefer `multiagent.baseBranch`, then protected branches, then
|
|
83
|
+
lexical order; and the result is persisted as `branch.<b>.guardexBase` for
|
|
84
|
+
every subsequent gate. ([#745](https://github.com/opencue/gitguardex/pull/745), [#750](https://github.com/opencue/gitguardex/pull/750), [#751](https://github.com/opencue/gitguardex/pull/751))
|
|
78
85
|
- **Billing-aware CI fallback** — waive only named checks that GitHub could not
|
|
79
86
|
start because of billing, while keeping repository preflight mandatory.
|
|
80
87
|
([#743](https://github.com/opencue/gitguardex/pull/743))
|
|
@@ -129,6 +136,57 @@ npm test
|
|
|
129
136
|
gx branch finish --via-pr --wait-for-merge --cleanup
|
|
130
137
|
```
|
|
131
138
|
|
|
139
|
+
### Agent token usage
|
|
140
|
+
|
|
141
|
+
`gx usage` delegates to [ccusage](https://github.com/ccusage/ccusage), reading the
|
|
142
|
+
token usage already recorded by supported coding-agent CLIs. Install ccusage
|
|
143
|
+
once with `npm install -g ccusage`; GX never silently downloads it.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
gx usage # daily totals across detected agents
|
|
147
|
+
gx usage codex session --json --offline # Codex sessions, machine-readable
|
|
148
|
+
gx usage claude daily --since 20260921 # Claude Code date filter
|
|
149
|
+
gx usage codex session --help # ccusage's report-specific options
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Reports cover ccusage's configured local log roots, **not just the current GX
|
|
153
|
+
repository**. `CODEX_HOME` and other ccusage environment/config settings pass
|
|
154
|
+
through unchanged. Use `GUARDEX_CCUSAGE_BIN` to select an executable or JS entry
|
|
155
|
+
point. GX preserves the backend output and exit status, without recounting
|
|
156
|
+
tokens or treating missing ccusage as a successful empty report.
|
|
157
|
+
|
|
158
|
+
Costs are API-equivalent estimates, not invoices or subscription balances.
|
|
159
|
+
Pricing may require network access; `--offline` uses ccusage's offline pricing.
|
|
160
|
+
Missing logs cannot be measured, and Codex log support is experimental.
|
|
161
|
+
For A/B comparisons, use separate sessions with the same tasks/model and check
|
|
162
|
+
task success before comparing input, output, cached tokens and elapsed time.
|
|
163
|
+
This command reports usage; it does not itself run an A/B experiment.
|
|
164
|
+
|
|
165
|
+
### One-call agent context
|
|
166
|
+
|
|
167
|
+
`gx context` exposes the existing MCP context collector as compact JSON, scoped
|
|
168
|
+
to the current repository. Read the current lane, peer agents, and ownership of
|
|
169
|
+
multiple files without separate per-file calls:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
gx context src/auth.ts test/auth.test.ts
|
|
173
|
+
gx context --target /path/to/worktree --max-bytes 20000 --json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
PR lookup is opt-in with `--include-prs`. The default limit is 20,000 UTF-8 bytes
|
|
177
|
+
of JSON, excluding the trailing newline; this is a byte budget, not a token
|
|
178
|
+
count. Up to 200 file paths are accepted. Use `--` before dash-prefixed filenames.
|
|
179
|
+
Only optional peer summaries may be omitted, with `complete: false` and an
|
|
180
|
+
omission count. Required safety data, including ownership conflicts, is never
|
|
181
|
+
truncated: an insufficient budget fails. Raise `--max-bytes` (up to 1 MiB) or
|
|
182
|
+
split the file batch. This read-only snapshot does not claim files or grant edit
|
|
183
|
+
permission; existing locks, approvals and merge gates still apply.
|
|
184
|
+
|
|
185
|
+
Run `node scripts/benchmark-context-cli.js` for a repeated local comparison of
|
|
186
|
+
separate MCP requests, the already-available batched MCP call, and this CLI.
|
|
187
|
+
It checks equivalent safety facts and reports timings and output bytes, not
|
|
188
|
+
provider-token counts or universal performance savings.
|
|
189
|
+
|
|
132
190
|
For a small change that you already verified locally, use the explicit fast
|
|
133
191
|
profile:
|
|
134
192
|
|
|
@@ -147,6 +205,138 @@ security-sensitive, migration, dependency, or broad refactor changes.
|
|
|
147
205
|
|
|
148
206
|
---
|
|
149
207
|
|
|
208
|
+
## Worktree provisioning
|
|
209
|
+
|
|
210
|
+
Opt into isolated dependency copies in `.guardex.json` (JSONC is supported):
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"provision": {
|
|
215
|
+
"files": { "copy": ["node_modules", ".env"], "symlink": [] },
|
|
216
|
+
"postCreate": ["npm run build"]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
New `gx branch start` worktrees apply this configuration. `copy` supports files
|
|
222
|
+
and directories, attempts native copy-on-write, and falls back to regular copying.
|
|
223
|
+
Unlike shared symlinks, modifying a copied dependency does not modify the source.
|
|
224
|
+
Existing targets are left untouched. Internal symlinks are relocated inside the
|
|
225
|
+
copy; dangling links, links outside the selected directory, and special files
|
|
226
|
+
fail the directory copy without installing a partial target. An explicit copy
|
|
227
|
+
never falls back to a shared symlink. Without an explicit copy policy, legacy
|
|
228
|
+
dependency sharing remains available; choose copies for writable dependencies.
|
|
229
|
+
|
|
230
|
+
**Migration:** `postCreate` now skips commands until their exact ordered list has
|
|
231
|
+
been approved locally for that repository. In a human terminal, run:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
gx worktree approve-hooks --target /path/to/source-repo
|
|
235
|
+
gx worktree provision --source /path/to/source-repo --target /path/to/agent-worktree
|
|
236
|
+
# Revoke approval without running hooks:
|
|
237
|
+
gx worktree approve-hooks --target /path/to/source-repo --revoke
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Approval is stored outside the repo under the Guardex user's
|
|
241
|
+
`.config/gitguardex/provision-approvals/`. Changed command lists require fresh
|
|
242
|
+
consent; noninteractive runs and `--yes` cannot grant it. Approved hooks can run
|
|
243
|
+
arbitrary shell code, including subsequently changed scripts: approval is not a
|
|
244
|
+
sandbox or a review of those scripts. `GUARDEX_PROVISION_HOOKS=0` disables even
|
|
245
|
+
approved hooks. `provision --with-defaults` also applies legacy dependency links
|
|
246
|
+
where they do not overlap an explicit copy policy (used by branch creation).
|
|
247
|
+
|
|
248
|
+
`gx agents status` prints its header before Git probes and then each completed
|
|
249
|
+
session row on a terminal. Redirected text and `--json` retain their prior format.
|
|
250
|
+
This is progressive display, not a claim that Git collection is faster.
|
|
251
|
+
|
|
252
|
+
These adaptations were inspired by [Worktrunk](https://github.com/max-sixty/worktrunk),
|
|
253
|
+
not implemented by adding a second worktree manager. Reproduce the local copy
|
|
254
|
+
comparison with `node scripts/benchmark-provision.js`; it reports repeated-run
|
|
255
|
+
timings and allocation accounting, not universal performance or storage savings.
|
|
256
|
+
|
|
257
|
+
### Native worktree navigation
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
eval "$(gx shell-init bash)" # zsh supported too; fish: gx shell-init fish | source
|
|
261
|
+
gx switch agent/bot/my-task # registered branch, worktree path, or "-" for previous
|
|
262
|
+
gx switch pr:123 --create # GitHub PR (requires gh); creation uses GX safety gates
|
|
263
|
+
gx switch # terminal picker with diff-stat and PR preview
|
|
264
|
+
gx switch agent/bot/my-task --json
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Without shell integration, `gx switch` prints the destination; it cannot change
|
|
268
|
+
the parent shell's directory. `--print` is path-only and `--json` is structured
|
|
269
|
+
output. Navigation does not change the primary checkout. `--create` provisions
|
|
270
|
+
a GX agent lane from an existing branch or PR head, retaining quotas and claims,
|
|
271
|
+
not a second worktree manager. PR URLs must match this repository; fork PR heads
|
|
272
|
+
are fetched through the origin repository's numbered PR ref and verified by SHA.
|
|
273
|
+
|
|
274
|
+
### Approved lifecycle hooks
|
|
275
|
+
|
|
276
|
+
Alongside the existing `provision.postCreate`, configure named lifecycle events:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"hooks": {
|
|
281
|
+
"pre-start": ["npm ci", { "build": "npm run build", "lint": "npm run lint" }],
|
|
282
|
+
"pre-merge": "npm test",
|
|
283
|
+
"post-start": "echo Ready"
|
|
284
|
+
},
|
|
285
|
+
"hookTimeoutMs": 600000
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
An array is an ordered pipeline; commands in a named object run concurrently,
|
|
290
|
+
and the next stage waits for all of them to succeed. Pre hooks block; post hooks
|
|
291
|
+
run in the background with per-run output and status files.
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
gx worktree hook approve pre-start --source /path/to/repo
|
|
295
|
+
gx worktree hook approve pre-merge --source /path/to/repo
|
|
296
|
+
gx worktree hook approve post-start --source /path/to/repo
|
|
297
|
+
gx worktree hook pre-start --source /path/to/repo --worktree /path/to/lane --dry-run
|
|
298
|
+
gx worktree hook logs --source /path/to/repo --json
|
|
299
|
+
gx worktree hook approve pre-start --source /path/to/repo --revoke
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Consent is interactive and local, bound to the repository, event, exact ordered
|
|
303
|
+
commands and timeout. Changes require approval again. These approvals are separate
|
|
304
|
+
from legacy `postCreate`; `--yes` cannot approve shell execution. State lives under
|
|
305
|
+
the Guardex user's `.config/gitguardex/lifecycle-hooks/`, outside the repository.
|
|
306
|
+
Approved commands are arbitrary shell code, not sandboxed; invoked scripts can
|
|
307
|
+
change independently of the approved command text.
|
|
308
|
+
|
|
309
|
+
Events are `pre-*` and `post-*` for `start`, `switch`, `commit`, `merge`,
|
|
310
|
+
and `remove`. Start hooks run after provisioning but before readiness, then
|
|
311
|
+
after successful initialization; reduced provisioning modes skip them. Switch
|
|
312
|
+
hooks surround destination selection, before the shell consumes its path.
|
|
313
|
+
Commit hooks surround GX finish's auto-commit (not unrelated manual Git commits).
|
|
314
|
+
Merge hooks supplement, never replace, existing PR/merge gates: a pre-merge hook
|
|
315
|
+
that changes the source revision or leaves changes aborts the merge.
|
|
316
|
+
Removal hooks apply to guarded prune and deferred finish cleanup, not internal
|
|
317
|
+
temporary integration/probe trees. A failed pre-remove preserves the worktree;
|
|
318
|
+
post-remove runs from the surviving repository, with `GUARDEX_WORKTREE` retaining
|
|
319
|
+
the removed path. Hooks also receive `GUARDEX_REPO_ROOT`, `GUARDEX_BRANCH` and
|
|
320
|
+
`GUARDEX_HOOK_EVENT`. `GUARDEX_PROVISION_HOOKS=0` disables hooks explicitly.
|
|
321
|
+
|
|
322
|
+
### Explicit ignored-file copy
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
gx worktree copy-ignored --source /path/to/repo --target /path/to/lane --dry-run --json
|
|
326
|
+
gx worktree copy-ignored --source /path/to/repo --target /path/to/lane
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Only ignored files are eligible. Optional source `.worktreeinclude` narrows the
|
|
330
|
+
selection using Git's ignore-pattern syntax, for example `node_modules/**`
|
|
331
|
+
followed by `!node_modules/private/`. Existing or tracked target files are never
|
|
332
|
+
overwritten, and symlink escapes and nested repositories are rejected. This
|
|
333
|
+
explicit command does not broaden the normal branch-start copy policy.
|
|
334
|
+
GX runtime/ownership directories are excluded, including aliases pointing into
|
|
335
|
+
them. Foreign file claims and malformed lock registries block copying. Shared
|
|
336
|
+
remote-lock mode currently refuses this command rather than bypassing remote
|
|
337
|
+
ownership or fetching state during a read-only dry-run.
|
|
338
|
+
See [third-party attribution](THIRD-PARTY-NOTICES.md).
|
|
339
|
+
|
|
150
340
|
## Code-assist review gate
|
|
151
341
|
|
|
152
342
|
Add `--gate-review` to review the PR before merge. Add `--gate-autofix` to let
|
|
@@ -159,6 +349,38 @@ gx branch finish --via-pr --wait-for-merge --cleanup \
|
|
|
159
349
|
|
|
160
350
|
High and critical findings block the merge. The review is posted directly on
|
|
161
351
|
the PR as a readable severity, location, and finding table.
|
|
352
|
+
If the PR diff exceeds the review size limit, the merge gate stops before
|
|
353
|
+
launching the reviewer. Split the PR into smaller changes and rerun the gate.
|
|
354
|
+
A standalone `gx pr-review` can still produce an advisory report marked partial.
|
|
355
|
+
Both `gx pr-review` and the finish gate use Codex first. If the Codex CLI cannot
|
|
356
|
+
launch, they try Claude. Timeouts, failed or invalid reviews, and findings do not
|
|
357
|
+
trigger a switch. Use `--provider` or `--review-provider` to pin one provider.
|
|
358
|
+
|
|
359
|
+
After a clean review, normal gated finishes run the repository preflight while
|
|
360
|
+
GitHub CI runs. The final publish still requires both and checks the exact head
|
|
361
|
+
and base. After an interruption, rerun the same finish command: an unchanged
|
|
362
|
+
review policy and revision can reuse a recent Codex verdict if it is still the
|
|
363
|
+
latest, unchanged review on GitHub. A mandatory trusted-base CI fallback
|
|
364
|
+
preflight is never replaced by the regular preflight receipt.
|
|
365
|
+
|
|
366
|
+
Set `GUARDEX_REVIEW_COMPACT_DIFF=1` to try a smaller review prompt for large npm
|
|
367
|
+
lockfile patches. Only unchanged generated context is compacted; changed lines
|
|
368
|
+
and their coordinates are kept. The original diff is still used for coverage,
|
|
369
|
+
anchors and Abide. This opt-in does not apply to PR Lens.
|
|
370
|
+
|
|
371
|
+
For a repository that intentionally disables its GitHub Actions workflows,
|
|
372
|
+
enable the local CI fallback from that checkout:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
git config --local multiagent.ciFallbackWhenDisabled true
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
After the normal CI registration grace period, the gate accepts zero check
|
|
379
|
+
runs only if GitHub confirms a nonempty workflow list with every workflow
|
|
380
|
+
manually disabled and reports the reviewed PR as mergeable. A clean review
|
|
381
|
+
and a successful target-aware preflight from the trusted base are still
|
|
382
|
+
required. Missing or unverified workflow state, pending or failed checks,
|
|
383
|
+
and GitHub branch protection are not bypassed.
|
|
162
384
|
|
|
163
385
|
<p align="center">
|
|
164
386
|
<a href="https://github.com/projects-kssk/Wireless_KFB_Project/pull/165">
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Worktrunk inspiration
|
|
2
|
+
|
|
3
|
+
Native GX navigation, lifecycle hooks and ignored-file selection are informed by
|
|
4
|
+
[Worktrunk](https://github.com/max-sixty/worktrunk). They do not install or invoke
|
|
5
|
+
Worktrunk, and GitGuardex remains the worktree manager. The implementations are
|
|
6
|
+
JavaScript adaptations of behavior, not a vendored Rust package.
|
|
7
|
+
|
|
8
|
+
Worktrunk offers MIT OR Apache-2.0 licensing. The MIT notice is reproduced below
|
|
9
|
+
to retain attribution for the source consulted during this adaptation.
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2025 Maximilian Roos
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
package/bin/multiagent-safety.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { runFromBin } = require('../src/cli/main');
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const finishCleanup = prepareBranchFinishCleanup(process.argv.slice(2), process.cwd());
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const cleanup =
|
|
6
|
+
args[0] === 'branch' && args[1] === 'finish'
|
|
7
|
+
? require('../src/finish/post-branch-finish-cleanup')
|
|
8
|
+
: null;
|
|
9
|
+
const finishCleanup = cleanup?.prepareBranchFinishCleanup(args, process.cwd());
|
|
12
10
|
|
|
13
11
|
void runFromBin().then(() => {
|
|
14
12
|
if (!process.exitCode && finishCleanup) {
|
|
15
13
|
process.chdir(finishCleanup.repoRoot);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cleanupFinishedDetachedWorktree(finishCleanup);
|
|
14
|
+
const pending = cleanup.persistFinishedCleanup(finishCleanup);
|
|
15
|
+
if (pending && !cleanup.cleanupFinishedDetachedWorktree(pending)) {
|
|
16
|
+
cleanup.scheduleFinishedDetachedWorktreeCleanup(pending);
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imdeadpool/guardex",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "Guardian T-Rex for your multi-agent repo. Isolated worktrees, file locks, and PR-only merges stop parallel Codex & Claude agents from overwriting each other's work. Auto-wires Oh My Codex, Oh My Claude, OpenSpec, and Caveman.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"skills",
|
|
53
53
|
"templates",
|
|
54
54
|
"README.md",
|
|
55
|
+
"THIRD-PARTY-NOTICES.md",
|
|
55
56
|
"LICENSE",
|
|
56
57
|
"SECURITY.md",
|
|
57
58
|
"CONTRIBUTING.md"
|
|
@@ -95,5 +96,6 @@
|
|
|
95
96
|
"dependencies": {
|
|
96
97
|
"jsonc-parser": "3.3.1",
|
|
97
98
|
"semver": "7.7.4"
|
|
98
|
-
}
|
|
99
|
+
},
|
|
100
|
+
"gitHead": "3bf9656768d002719dc9498f17d317a3b2bf39cf"
|
|
99
101
|
}
|
|
@@ -112,6 +112,34 @@ Treat `🏁 Cleanup` as finished-but-best-effort, not as unconditional success:
|
|
|
112
112
|
|
|
113
113
|
Structured phase events are persisted privately under `.omx/state/finish-runs/*.jsonl` (`0700` directory, `0600` files). Prefer that JSONL stream over parsing narrative logs when exact state is needed; the visual output prints the active event-file path.
|
|
114
114
|
|
|
115
|
+
For agent transcripts, opt into `gx branch finish --agent-quiet` (or `gx finish --agent-quiet`)
|
|
116
|
+
alongside the same required finish flags and gates. It prints one run ID/event-file pointer,
|
|
117
|
+
retains warnings and blockers, and ends with a bounded summary; it does not skip verification.
|
|
118
|
+
Read only new observations with `gx finish events --run <run-id> --wait-ms 30000`, then
|
|
119
|
+
pass the returned `--cursor <cursor>` on the next read. Use the same repository target as
|
|
120
|
+
the finish invocation. Let this bounded CLI wait do the polling instead of repeatedly
|
|
121
|
+
asking the model to reread the whole log. Events are observations, never merge authority.
|
|
122
|
+
|
|
123
|
+
Opt-in bounded observations (defaults remain unchanged):
|
|
124
|
+
- MCP `my_context`: pass `max_bytes` to bound UTF-8 JSON tool text. Ownership,
|
|
125
|
+
conflicts and safety fields are mandatory; `budget-too-small` requires a larger
|
|
126
|
+
budget or smaller file batch. Check `complete`/`omitted`; fetch full peers only
|
|
127
|
+
when needed. This budgets bytes, not model tokens.
|
|
128
|
+
- `gx watch --pr-cache-ms 5000` shares PR probes with a short in-process TTL keyed
|
|
129
|
+
by repository, remote, branch and HEAD. Observation age is shown; dirty state
|
|
130
|
+
stays fresh. The cache is never used by merge gates.
|
|
131
|
+
- `gx finish events --run <id> --view state`: merge `stages` patches by stage,
|
|
132
|
+
retain every `alerts` record, and resume with the opaque cursor. Paginated
|
|
133
|
+
snapshots are incomplete until `snapshotComplete: true`. Raw view remains the
|
|
134
|
+
default; reset explicitly on invalid/replaced/truncated cursors.
|
|
135
|
+
- `gx agents set-status --activity working --dedupe-surface`: skip identical
|
|
136
|
+
successful pane-label writes, but still renew session activity on every call.
|
|
137
|
+
Changed targets and failed writes retry. This never infers agent completion.
|
|
138
|
+
|
|
139
|
+
For setup guidance, use `gx prompt --list-parts` then `gx prompt --part <name>` for the
|
|
140
|
+
needed slice; use `--exec --part <name>` only for command-capable slices. Do not repeatedly
|
|
141
|
+
load the full setup prompt or remove the mandatory safety contract to save tokens.
|
|
142
|
+
|
|
115
143
|
When inspecting or verifying, prefer `rtk` compact wrappers if available (`rtk git status`, `rtk grep`, `rtk test <cmd>`, and noisy gx reads like `rtk gx status` / `rtk gx doctor`). Do not wrap commands whose stdout is parsed by scripts (`--json`, `--porcelain`, exact stdout contracts) or shell-ready output (`gx prompt --exec`).
|
|
116
144
|
|
|
117
145
|
To shrink gx's own large narrative output (e.g. `gx prompt`, `gx prompt --snippet`) before it lands in your context, set `GUARDEX_COMPRESS_CMD="<stdin->stdout filter>"`; gx routes that output through the filter (terse/non-TTY mode, fail-open, JSON skipped). Unset = byte-for-byte unchanged. Confirm it is wired with `gx status` or `gx doctor` — both print a `Token compression` line and flag a configured-but-missing binary (doctor's warning is advisory and never changes its safe/unsafe exit code).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-lens
|
|
3
|
+
description: Generate local PR Lens architecture and data-flow diagrams alongside a GitGuardex Codex or Claude PR review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Lens code review
|
|
7
|
+
|
|
8
|
+
Install the optional renderer once (requires Node >=20.11):
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @coldtea/pr-lens-cli@0.6.1
|
|
12
|
+
gx pr-review --pr 123 --provider codex --pr-lens
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`gx pr review` accepts the same flags. `--provider claude` uses Claude instead.
|
|
16
|
+
No additional model API key is needed: the existing tool-free review call
|
|
17
|
+
returns findings and a PR Lens graph together. PR Lens validates the graph
|
|
18
|
+
and renders light/dark SVGs locally. A valid graph needs no second model call.
|
|
19
|
+
|
|
20
|
+
Set `GUARDEX_PR_LENS_BIN` to an installed CLI path if it is not on PATH.
|
|
21
|
+
Set `GUARDEX_REVIEW_PR_LENS=1` to include diagrams in `gx branch finish
|
|
22
|
+
--gate-review` too. `--no-pr-lens` overrides the environment for a direct review.
|
|
23
|
+
The default remains off, so Node 18 review users do not acquire a new requirement.
|
|
24
|
+
|
|
25
|
+
The printed manifest names the SVGs; graph and diagrams live in the durable
|
|
26
|
+
Git common-directory artifact store, surviving worktree cleanup. `--artifact`
|
|
27
|
+
changes the findings Markdown path, not the diagram store. `--post` posts the
|
|
28
|
+
normal findings only: diagrams remain local. No canvas upload, public asset
|
|
29
|
+
publication, auto-install, `.gitignore` edit, or checkout config loading occurs.
|
|
30
|
+
|
|
31
|
+
The diagram is limited to the supplied diff, not a whole-repository map.
|
|
32
|
+
PR metadata and line counts come from GitHub, never from the model. A moving
|
|
33
|
+
PR, truncated diff, missing graph/CLI, or validation/render failure fails the
|
|
34
|
+
requested review rather than silently reporting success. Existing finding
|
|
35
|
+
severity rules and merge gates are unchanged.
|
|
36
|
+
|
|
37
|
+
Findings are saved before validation/rendering, including when `--post` was
|
|
38
|
+
requested. Diagram failures report the saved Markdown path and a separate failed
|
|
39
|
+
status; they still throw and prevent posting or a successful merge verdict.
|
|
40
|
+
|
|
41
|
+
A schema-validation failure gets at most one graph-only repair using the same
|
|
42
|
+
provider/model and tool-free sandbox. The repair cannot replace the original
|
|
43
|
+
findings or trusted PR metadata. It receives the diff, graph and validator errors;
|
|
44
|
+
it has a separate timeout of at most 60 seconds (or the lower review timeout),
|
|
45
|
+
a 64,000-character graph input limit, 8,000-character error limit and
|
|
46
|
+
256,000-byte process output cap. These bound retries/input/output, not billed
|
|
47
|
+
tokens. CLI installation, I/O, renderer and timeout failures do not trigger repair.
|
|
48
|
+
Failed repair remains an error. The PR head is checked again after repair.
|
|
49
|
+
|
|
50
|
+
The `PR Lens contract` workflow installs CLI 0.6.1 outside the checkout and
|
|
51
|
+
always enables the real renderer tests; the tests use fixture model responses,
|
|
52
|
+
not paid model calls. To run the same tests locally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
GUARDEX_TEST_PR_LENS_BIN=/absolute/path/to/pr-lens node --test test/pr-lens*.test.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Optional PR artifact link
|
|
59
|
+
|
|
60
|
+
After an explicitly configured GitHub Actions workflow has uploaded the diagram
|
|
61
|
+
directory (graph, manifest and SVGs), publish its artifact URL:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gx pr-review --pr 123 --post --pr-lens-publish \
|
|
65
|
+
https://github.com/OWNER/REPO/actions/runs/RUN_ID/artifacts/ARTIFACT_ID
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This is a **publish-only** operation: it does not run another review/model,
|
|
69
|
+
render, upload files or produce a merge verdict. Do not combine it with
|
|
70
|
+
`--fix`, `--pr-lens`, `--no-pr-lens` or `--artifact`. The existing `--post`
|
|
71
|
+
review behavior still leaves diagrams local.
|
|
72
|
+
|
|
73
|
+
Only HTTPS artifact URLs on the same GitHub host and repository are accepted.
|
|
74
|
+
GitHub must confirm an unexpired artifact for that run and the current PR head
|
|
75
|
+
SHA; a merge-commit artifact is not accepted as a head-commit artifact. The
|
|
76
|
+
uploader is responsible for the archive contents: this command verifies metadata,
|
|
77
|
+
not the contents of the archive. It refuses public canvas/external hosting URLs.
|
|
78
|
+
|
|
79
|
+
The link keeps GitHub's repository access controls and artifact retention; it is
|
|
80
|
+
a download link, not an inline image. A matching comment is updated only if it
|
|
81
|
+
belongs to the authenticated user, otherwise a new comment is created. Serialize
|
|
82
|
+
publication jobs to avoid concurrent creates. Use a user token with Actions read
|
|
83
|
+
and issue-comment write access; tokens unable to resolve `gh api user` fail
|
|
84
|
+
closed (including installation-only tokens). No publication is enabled by default.
|
|
85
|
+
|
|
86
|
+
Upstream: https://github.com/coldteadotai/pr-lens (MIT), CLI 0.6.1,
|
|
87
|
+
graph schema 0.2.0; inspected at `0f55772ecffd9d1fd7f39378d6f183fad1596015`.
|