@imdeadpool/guardex 8.4.15 → 8.4.16
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 +2 -33
- package/README.md +7 -174
- package/SECURITY.md +1 -1
- package/package.json +6 -39
- package/scripts/prepublish-bump-version.js +11 -1
- package/src/agents/start.js +1 -1
- package/src/cli/commands/branch.js +7 -7
- package/src/cli/commands/claude.js +6 -13
- package/src/cli/commands/pr.js +2 -2
- package/src/cli/commands/release.js +7 -1
- package/src/cli/commands/review.js +2 -2
- package/src/cli/commands/worktree-copy-ignored.js +1 -1
- package/src/cli/commands/worktree-estimate.js +2 -2
- package/src/cli/commands/worktree-hooks.js +1 -1
- package/src/cli/commands/worktree-navigation.js +3 -3
- package/src/cli/shared-locks.js +1 -1
- package/src/context.js +8 -1
- package/src/finish/index.js +1 -1
- package/src/finish/post-branch-finish-cleanup.js +2 -2
- package/src/finish/review-gate.js +3 -3
- package/src/finish/review-receipt.js +5 -5
- package/src/{github-api.js → github/api.js} +2 -2
- package/src/mcp/collect.js +2 -2
- package/src/pr-review.js +2 -1178
- package/src/pr-value.js +2 -111
- package/src/provider-binary.js +2 -122
- package/src/{pr.js → pull-request/index.js} +5 -5
- package/src/{pr-lens-publish.js → pull-request/lens-publish.js} +2 -2
- package/src/{pr-lens.js → pull-request/lens.js} +2 -2
- package/src/{pr-respond.js → pull-request/respond.js} +8 -8
- package/src/pull-request/value.js +111 -0
- package/src/{review-fix.js → review/fix.js} +2 -2
- package/src/review/provider-binary.js +122 -0
- package/src/review/pull-request.js +1178 -0
- package/src/{worktree-copy-ignored.js → worktree/copy-ignored.js} +3 -3
- package/src/{worktree-hook-worker.js → worktree/hook-worker.js} +1 -1
- package/src/{worktree-hooks.js → worktree/hooks.js} +5 -5
- package/src/{worktree-navigation.js → worktree/navigation.js} +2 -2
- package/src/{worktree-picker.js → worktree/picker.js} +1 -1
- package/src/{worktree-quota.js → worktree/quota.js} +1 -1
- package/src/{worktree-start.js → worktree/start.js} +4 -4
- package/src/{worktree-tasks.js → worktree/tasks.js} +6 -6
- /package/src/{shared-git-state.js → git/shared-state.js} +0 -0
- /package/src/{pr-checks.js → pull-request/checks.js} +0 -0
- /package/src/{review-diff-context.js → review/diff-context.js} +0 -0
- /package/src/{review-diff.js → review/diff.js} +0 -0
package/CONTRIBUTING.md
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Development setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm ci
|
|
9
|
-
npm test
|
|
10
|
-
node --check bin/multiagent-safety.js
|
|
11
|
-
npm pack --dry-run
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Pull request checklist
|
|
15
|
-
|
|
16
|
-
- Keep changes small and focused
|
|
17
|
-
- Add or update tests for behavior changes
|
|
18
|
-
- Keep README and CLI help text aligned
|
|
19
|
-
- Ensure `npm test` passes locally
|
|
20
|
-
|
|
21
|
-
## Release hygiene
|
|
22
|
-
|
|
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.
|
|
3
|
+
See the [GitGuardex contribution guide](https://github.com/opencue/gitguardex/blob/main/CONTRIBUTING.md)
|
|
4
|
+
for the repository layout, development checks, and release process.
|
package/README.md
CHANGED
|
@@ -1,184 +1,17 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img alt="GitGuardex logo" src="./logo.png" width="180">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
1
|
# GitGuardex
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/@imdeadpool/guardex)
|
|
10
|
-
[](https://github.com/opencue/gitguardex/actions/workflows/ci.yml)
|
|
11
|
-
[License](./LICENSE)
|
|
12
|
-
|
|
13
|
-
[Quick start](#install) · [AI code review](#code-assist-review-gate) · [Impact Assist](#impact-assist) · [How it compares](#how-it-compares)
|
|
14
|
-
|
|
15
|
-
## Install
|
|
16
|
-
|
|
17
|
-
Requires Node.js 18+, Git, and an authenticated GitHub CLI (`gh`) for the PR flow. Use Linux or macOS; on Windows, use WSL.
|
|
3
|
+
GitGuardex coordinates isolated agent worktrees, file ownership, verification
|
|
4
|
+
and PR-only merges.
|
|
18
5
|
|
|
19
6
|
```sh
|
|
20
7
|
npm install -g @imdeadpool/guardex
|
|
21
|
-
|
|
22
|
-
gx setup
|
|
23
|
-
gx branch start "Add checkout validation" "codex" --no-transfer
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Enter the worktree printed by `gx branch start`. Claim the files you intend to edit:
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
gx locks claim --branch "$(git branch --show-current)" src/checkout.ts
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Make the change and run your project's tests. Then ship the PR:
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
gx branch finish --via-pr --wait-for-merge --cleanup
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Finish can commit and open the PR, run the selected gates, then squash-merge and clean up the finished lane. It does not override GitHub branch protection.
|
|
39
|
-
|
|
40
|
-
## Code-assist review gate
|
|
41
|
-
|
|
42
|
-
For AI code review, install and authenticate the Codex or Claude Code CLI.
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
gx pr-review --pr 123 --post
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Review an existing PR using your local Codex CLI. GitGuardex falls back to Claude Code if Codex cannot launch; pin either with `--provider` (or `--review-provider` when finishing). The review posts severity, file and line, and the reason a finding matters. **Posting a review does not merge the PR.**
|
|
49
|
-
|
|
50
|
-
With `--gate-review`, high and critical findings block the finish. Add `--gate-autofix` to attempt fixes and review the new head before merging. A green CI run is not a substitute for a clean review, or vice versa.
|
|
51
|
-
|
|
52
|
-
```sh
|
|
53
|
-
gx branch finish --via-pr --wait-for-merge --cleanup --gate-review --gate-autofix
|
|
8
|
+
gx --help
|
|
54
9
|
```
|
|
55
10
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<summary>See a real review on GitHub</summary>
|
|
60
|
-
|
|
61
|
-

|
|
62
|
-
|
|
63
|
-
[Open the example PR](https://github.com/projects-kssk/Wireless_KFB_Project/pull/165) · [Full-size screenshot](https://raw.githubusercontent.com/recodeee/gitguardex/main/docs/images/code-assist-review-gate.png)
|
|
64
|
-
|
|
65
|
-
</details>
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## Impact Assist
|
|
70
|
-
|
|
71
|
-
**Code review asks what could break. Impact Assist asks what the repository gains or gives up by merging.** The review renders this as a **PR impact** section: benefits, trade-offs, links to supporting diff lines, and suggested next steps when available.
|
|
72
|
-
|
|
73
|
-
For example, a material benefit (**+25**) and a notable trade-off (**−10**) yield **65/100** from a neutral baseline of **50**. That is a diff-based estimate, not a benchmark or a merge verdict. If the diff is incomplete or the estimate has no valid supporting evidence, the section reports it as unavailable.
|
|
74
|
-
|
|
75
|
-
[See Impact Assist on a real GitGuardex PR](https://github.com/opencue/gitguardex/pull/897#pullrequestreview-6070455129).
|
|
76
|
-
|
|
77
|
-
## How it compares
|
|
78
|
-
|
|
79
|
-
| If you use… | It handles… | What GitGuardex adds |
|
|
80
|
-
| --- | --- | --- |
|
|
81
|
-
| Plain `git worktree` | Separate checkouts | Task identity, shared file claims, and cleanup that preserves work it cannot safely remove |
|
|
82
|
-
| A standalone AI reviewer | Findings on a diff | Optional blocking review and autofix tied to the PR finish, plus a separate impact estimate |
|
|
83
|
-
| GitHub Actions and branch protection | Required checks and merge rules | Local preflight, worktree ownership, and a single workflow from task start to cleanup |
|
|
84
|
-
|
|
85
|
-
GitGuardex works with Git, GitHub, and your existing agent CLI. It does not replace them.
|
|
86
|
-
|
|
87
|
-
<details>
|
|
88
|
-
<summary>See the problem and capability diagrams</summary>
|
|
89
|
-
|
|
90
|
-
## The problem
|
|
91
|
-
|
|
92
|
-

|
|
93
|
-
|
|
94
|
-
### What GitGuardex can do
|
|
95
|
-
|
|
96
|
-
<p align="center">
|
|
97
|
-
<img alt="GitGuardex capability map: isolated lanes, evidence-driven shipping, and safe cleanup" src="https://raw.githubusercontent.com/opencue/gitguardex/main/docs/images/capabilities-dark.svg" width="900">
|
|
98
|
-
</p>
|
|
99
|
-
|
|
100
|
-
</details>
|
|
101
|
-
|
|
102
|
-
## More workflows
|
|
103
|
-
|
|
104
|
-
- **See what other agents own:** `gx status`, `gx context path/to/file`, or the [agent cockpit](./docs/agents-cockpit.md).
|
|
105
|
-
- **Inspect local agent usage:** `gx usage` reads local logs through [ccusage](https://github.com/ccusage/ccusage); it does not install the backend.
|
|
106
|
-
- **Preview cleanup and storage:** `gx cleanup --dry-run` and the [worktree storage guide](./docs/worktree-storage.md).
|
|
107
|
-
- **Configure verification:** [local preflight](./docs/preflight.md), [OpenSpec (opt-in)](./docs/openspec-getting-started.md), or `gx --help`.
|
|
108
|
-
- **Advanced worktrees:** [provisioning, navigation, and lifecycle hooks](https://github.com/opencue/gitguardex/blob/f748d7e02c853b29826bb1e1005127468de407e8/README.md#worktree-provisioning) and [VS Code setup](https://github.com/opencue/gitguardex/blob/f748d7e02c853b29826bb1e1005127468de407e8/README.md#see-every-lane-in-vs-code).
|
|
109
|
-
- **Launch with a Cue profile:** [preview, start, and resume GitGuardex tasks](https://github.com/opencue/cuecards/blob/main/docs/gitguardex-workflows.md).
|
|
110
|
-
|
|
111
|
-
<details>
|
|
112
|
-
<summary>Agent skills and maintainer releases</summary>
|
|
113
|
-
|
|
114
|
-
```sh
|
|
115
|
-
npx skills add recodee/gitguardex
|
|
116
|
-
gx release # create/update the current GitHub release from README notes
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
`gx setup` does not auto-run `npx skills add ...`. If the picker does not show a separate `guardex` skill, that is expected; use the `gitguardex` skill.
|
|
120
|
-
|
|
121
|
-
`gx release` is the maintainer path for package releases. It reads `README.md`, finds the last published GitHub release, and writes one grouped GitHub release body.
|
|
122
|
-
|
|
123
|
-
</details>
|
|
124
|
-
|
|
125
|
-
[Contributing](./CONTRIBUTING.md) · [Security](./SECURITY.md) · [Issues](https://github.com/opencue/gitguardex/issues) · [Third-party notices](./THIRD-PARTY-NOTICES.md)
|
|
126
|
-
|
|
127
|
-
GitGuardex is independent and is not affiliated with OpenAI or Anthropic.
|
|
11
|
+
See the [project README](https://github.com/opencue/gitguardex#readme) for setup
|
|
12
|
+
and workflows, and the [repository](https://github.com/opencue/gitguardex)
|
|
13
|
+
for source and contributing information.
|
|
128
14
|
|
|
129
15
|
## Release notes
|
|
130
16
|
|
|
131
|
-
|
|
132
|
-
<summary><strong>v8.x</strong></summary>
|
|
133
|
-
|
|
134
|
-
### v8.4.0
|
|
135
|
-
- Added authenticated agent messaging that delivers live when safe and queues
|
|
136
|
-
durably when Nodeterm or tmux delivery is unavailable.
|
|
137
|
-
- Added worktree-shared CLI and MCP inbox operations for reading and
|
|
138
|
-
acknowledging queued agent messages.
|
|
139
|
-
- Improved stale Codex worktree recovery and VS Code visibility for managed
|
|
140
|
-
worktrees.
|
|
141
|
-
|
|
142
|
-
### v8.3.0
|
|
143
|
-
- Added adaptive direct-main agent work and branch-targeted `gx sync`.
|
|
144
|
-
- Made worktree cleanup safer by preserving active or locked lanes while pruning
|
|
145
|
-
only eligible merged or opted-in clean lanes.
|
|
146
|
-
- Persisted and validated explicit finish bases, recognized SHA-256 null object
|
|
147
|
-
IDs, and prevented stale VS Code worktree providers.
|
|
148
|
-
|
|
149
|
-
### v8.2.0
|
|
150
|
-
- Reduced agent preflight and finish token overhead.
|
|
151
|
-
- Preserved dirty worktrees during stale-worktree cleanup and exposed
|
|
152
|
-
command-specific cleanup help.
|
|
153
|
-
- Added the owning tmux pane and worktree to file-lock conflict output.
|
|
154
|
-
|
|
155
|
-
### v8.1.1
|
|
156
|
-
- Prevented `gx doctor` from pruning dirty detached or managed worktrees during
|
|
157
|
-
stale-worktree repair.
|
|
158
|
-
|
|
159
|
-
### v8.1.0
|
|
160
|
-
- Added shared Git lock state so independent clones coordinate file ownership.
|
|
161
|
-
- Aligned npm repository metadata with `opencue/gitguardex` for trusted OIDC
|
|
162
|
-
publishing.
|
|
163
|
-
|
|
164
|
-
### v8.0.0
|
|
165
|
-
- Added `gx branch finish --fast` for small tasks that should use the PR +
|
|
166
|
-
squash-merge path without repeating local preflight or opt-in AI review.
|
|
167
|
-
- Removed the legacy `cr.yml` AI-review workflow; repository policy and explicit
|
|
168
|
-
Guardex review gates now control merge readiness.
|
|
169
|
-
|
|
170
|
-
</details>
|
|
171
|
-
|
|
172
|
-
<details>
|
|
173
|
-
<summary><strong>v7.x</strong></summary>
|
|
174
|
-
|
|
175
|
-
### v7.1.1
|
|
176
|
-
- Bumped `@imdeadpool/guardex` from `7.1.0` to `7.1.1` so the current
|
|
177
|
-
`main` payload can publish under a fresh npm version after `7.1.0` reached
|
|
178
|
-
the registry.
|
|
179
|
-
- Direct maintainer `npm publish` now checks npm during `prepublishOnly` and
|
|
180
|
-
bumps package release metadata to the next unpublished patch version when the
|
|
181
|
-
committed version is already published. GitHub Actions release publishes keep
|
|
182
|
-
the committed metadata so packed and signed assets stay aligned.
|
|
183
|
-
|
|
184
|
-
</details>
|
|
17
|
+
See the [GitHub releases](https://github.com/opencue/gitguardex/releases).
|
package/SECURITY.md
CHANGED
|
@@ -8,7 +8,7 @@ Only the latest published GitGuardex CLI build is supported for security fixes.
|
|
|
8
8
|
|
|
9
9
|
Please report security issues privately by opening a GitHub security advisory:
|
|
10
10
|
|
|
11
|
-
- https://github.com/
|
|
11
|
+
- https://github.com/opencue/gitguardex/security/advisories/new
|
|
12
12
|
|
|
13
13
|
If advisories are unavailable, open a private report via GitHub issue contact details and avoid posting exploit details publicly.
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imdeadpool/guardex",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.16",
|
|
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,
|
|
@@ -10,39 +10,6 @@
|
|
|
10
10
|
"gx": "bin/multiagent-safety.js",
|
|
11
11
|
"multiagent-safety": "bin/multiagent-safety.js"
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "node --test test/*.test.js",
|
|
15
|
-
"test:coverage": "node scripts/run-coverage-gate.js",
|
|
16
|
-
"lint": "biome lint bin src scripts test",
|
|
17
|
-
"format": "biome format --write bin src scripts test",
|
|
18
|
-
"format:check": "biome format bin src scripts test",
|
|
19
|
-
"format:check:changed": "node scripts/check-changed-format.js",
|
|
20
|
-
"package:check": "node --check bin/multiagent-safety.js && bash scripts/check-script-symlinks.sh && npm pack --dry-run",
|
|
21
|
-
"verify": "npm run format:check:changed && npm run lint && npm test && npm run package:check",
|
|
22
|
-
"prepublishOnly": "node scripts/prepublish-bump-version.js",
|
|
23
|
-
"postinstall": "node -e \"require('./src/heavy').installReport()\"",
|
|
24
|
-
"agent:codex": "bash ./scripts/codex-agent.sh",
|
|
25
|
-
"agent:branch:start": "bash ./scripts/agent-branch-start.sh",
|
|
26
|
-
"agent:branch:finish": "bash ./scripts/agent-branch-finish.sh",
|
|
27
|
-
"agent:branch:merge": "bash ./scripts/agent-branch-merge.sh",
|
|
28
|
-
"agent:cleanup": "gx cleanup",
|
|
29
|
-
"agent:hooks:install": "bash ./scripts/install-agent-git-hooks.sh",
|
|
30
|
-
"guardex:install-global": "bash ./scripts/install-global-hooks.sh",
|
|
31
|
-
"agent:locks:claim": "python3 ./scripts/agent-file-locks.py claim",
|
|
32
|
-
"agent:locks:allow-delete": "python3 ./scripts/agent-file-locks.py allow-delete",
|
|
33
|
-
"agent:locks:release": "python3 ./scripts/agent-file-locks.py release",
|
|
34
|
-
"agent:locks:status": "python3 ./scripts/agent-file-locks.py status",
|
|
35
|
-
"agent:plan:init": "bash ./scripts/openspec/init-plan-workspace.sh",
|
|
36
|
-
"agent:protect:list": "gx protect list",
|
|
37
|
-
"agent:branch:sync": "gx sync",
|
|
38
|
-
"agent:branch:sync:check": "gx sync --check",
|
|
39
|
-
"agent:safety:setup": "gx setup",
|
|
40
|
-
"agent:safety:scan": "gx status --strict",
|
|
41
|
-
"agent:safety:fix": "gx setup --repair",
|
|
42
|
-
"agent:safety:doctor": "gx doctor",
|
|
43
|
-
"agent:review:watch": "bash ./scripts/review-bot-watch.sh",
|
|
44
|
-
"agent:finish": "gx finish --all"
|
|
45
|
-
},
|
|
46
13
|
"engines": {
|
|
47
14
|
"node": ">=18"
|
|
48
15
|
},
|
|
@@ -90,13 +57,13 @@
|
|
|
90
57
|
"publishConfig": {
|
|
91
58
|
"access": "public"
|
|
92
59
|
},
|
|
93
|
-
"devDependencies": {
|
|
94
|
-
"@biomejs/biome": "1.9.4",
|
|
95
|
-
"fast-check": "3.23.2"
|
|
96
|
-
},
|
|
97
60
|
"dependencies": {
|
|
98
61
|
"jsonc-parser": "3.3.1",
|
|
99
62
|
"semver": "7.7.4"
|
|
100
63
|
},
|
|
101
|
-
"
|
|
64
|
+
"scripts": {
|
|
65
|
+
"prepublishOnly": "node scripts/prepublish-bump-version.js",
|
|
66
|
+
"postinstall": "node -e \"require('./src/heavy').installReport()\""
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "43fb1dc08dedd0753077cc987321abe0aba4d8f6"
|
|
102
69
|
}
|
|
@@ -81,7 +81,17 @@ function findPublishableVersion({ name, version, npmView, maxAttempts = 100 }) {
|
|
|
81
81
|
function updatePackageLock(repoRoot, name, version) {
|
|
82
82
|
const lockPath = path.join(repoRoot, 'package-lock.json');
|
|
83
83
|
if (!fs.existsSync(lockPath)) {
|
|
84
|
-
|
|
84
|
+
const workspaceRoot = path.resolve(repoRoot, '../..');
|
|
85
|
+
const workspaceLockPath = path.join(workspaceRoot, 'package-lock.json');
|
|
86
|
+
if (!fs.existsSync(workspaceLockPath)) return false;
|
|
87
|
+
|
|
88
|
+
const workspaceLock = readJson(workspaceLockPath);
|
|
89
|
+
const entry = workspaceLock.packages?.[path.relative(workspaceRoot, repoRoot).split(path.sep).join('/')];
|
|
90
|
+
if (entry?.name !== name) return false;
|
|
91
|
+
|
|
92
|
+
entry.version = version;
|
|
93
|
+
writeJson(workspaceLockPath, workspaceLock);
|
|
94
|
+
return true;
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
const lockfile = readJson(lockPath);
|
package/src/agents/start.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
const { runPackageAsset } = require('../core/runtime');
|
|
7
7
|
const { currentBranchName } = require('../git');
|
|
8
8
|
const { buildAgentLaunchCommand } = require('./launch');
|
|
9
|
-
const { runTaskStart } = require('../worktree
|
|
9
|
+
const { runTaskStart } = require('../worktree/start');
|
|
10
10
|
const { resolveAgent } = require('./registry');
|
|
11
11
|
const {
|
|
12
12
|
applyAgentSelectionKey,
|
|
@@ -241,11 +241,11 @@ function branch(rawArgs) {
|
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
if (rest.length !== 1 || rest[0] !== '--json') throw new Error('Usage: gx branch tasks --json');
|
|
244
|
-
require('../../worktree
|
|
244
|
+
require('../../worktree/tasks').listTasks(resolveRepoRoot(activeCwd));
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
if (subcommand === 'run-task') {
|
|
248
|
-
require('../../worktree
|
|
248
|
+
require('../../worktree/tasks').runTask(resolveRepoRoot(activeCwd), rest);
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
251
|
if (subcommand === 'start') {
|
|
@@ -257,7 +257,7 @@ function branch(rawArgs) {
|
|
|
257
257
|
if (json && (readOnly || jsonIndices.length !== 1 ||
|
|
258
258
|
branchStartOptionIndices(passthrough, '--task-id').length !== 1))
|
|
259
259
|
throw new Error('--json requires a normal branch start with --task-id');
|
|
260
|
-
const quota = readOnly ? {} : require('../../worktree
|
|
260
|
+
const quota = readOnly ? {} : require('../../worktree/quota').readWorktreeQuota(repoRoot);
|
|
261
261
|
if (!readOnly) {
|
|
262
262
|
const modeIndex = passthrough.indexOf('--provision-mode');
|
|
263
263
|
if (modeIndex >= 0 && !passthrough[modeIndex + 1]) throw new Error('--provision-mode requires a value');
|
|
@@ -268,12 +268,12 @@ function branch(rawArgs) {
|
|
|
268
268
|
if (passthrough.includes('--task-id')) {
|
|
269
269
|
if (passthrough.filter((arg) => arg === '--task-id').length !== 1)
|
|
270
270
|
throw new Error('--task-id must appear once');
|
|
271
|
-
require('../../worktree
|
|
271
|
+
require('../../worktree/start').validateTaskId(
|
|
272
272
|
passthrough[passthrough.indexOf('--task-id') + 1]
|
|
273
273
|
);
|
|
274
274
|
}
|
|
275
275
|
if (json) {
|
|
276
|
-
require('../../worktree
|
|
276
|
+
require('../../worktree/start').invokeTaskStart(repoRoot,
|
|
277
277
|
passthrough.filter((_, index) => index !== jsonIndices[0]), true);
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
@@ -284,7 +284,7 @@ function branch(rawArgs) {
|
|
|
284
284
|
recoverStaleManagedWorktrees(repoRoot);
|
|
285
285
|
}
|
|
286
286
|
if ((passthrough.includes('--task-id') || Object.keys(quota).length) && !isReadOnlyBranchStart(passthrough)) {
|
|
287
|
-
require('../../worktree
|
|
287
|
+
require('../../worktree/start').invokeTaskStart(repoRoot, passthrough);
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
invokePackageAsset('branchStart', passthrough, { cwd: repoRoot });
|
|
@@ -468,7 +468,7 @@ function pivot(rawArgs) {
|
|
|
468
468
|
}
|
|
469
469
|
const result = isReadOnlyBranchStart(passthrough)
|
|
470
470
|
? runPackageAsset('branchStart', passthrough, { cwd: repoRoot })
|
|
471
|
-
: require('../../worktree
|
|
471
|
+
: require('../../worktree/start').runTaskStart(repoRoot, passthrough);
|
|
472
472
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
473
473
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
474
474
|
if (result.status !== 0) {
|
|
@@ -15,7 +15,7 @@ const cp = require('child_process');
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
const { isDeepStrictEqual } = require('util');
|
|
18
|
-
const { TOOL_NAME, SHORT_TOOL_NAME } = require('../../context');
|
|
18
|
+
const { TOOL_NAME, SHORT_TOOL_NAME, CHECKOUT_ROOT, PACKAGE_ROOT } = require('../../context');
|
|
19
19
|
const { gitRun, resolveRepoRoot } = require('../../git');
|
|
20
20
|
const { requireValue } = require('../args');
|
|
21
21
|
|
|
@@ -43,8 +43,8 @@ const ABIDE_COMPILE_TIMEOUT_MS = 15 * 60_000;
|
|
|
43
43
|
const ABIDE_CALIBRATE_TIMEOUT_MS = 10 * 60_000;
|
|
44
44
|
|
|
45
45
|
const MANAGED_AGENT_SKILLS = [
|
|
46
|
-
{ name: 'gitguardex', source: ['.claude', 'skills', 'gitguardex'] },
|
|
47
|
-
{ name: 'opensrc', source: ['templates', 'codex', 'skills', 'opensrc'] },
|
|
46
|
+
{ name: 'gitguardex', source: [CHECKOUT_ROOT, '.claude', 'skills', 'gitguardex'] },
|
|
47
|
+
{ name: 'opensrc', source: [PACKAGE_ROOT, 'templates', 'codex', 'skills', 'opensrc'] },
|
|
48
48
|
];
|
|
49
49
|
|
|
50
50
|
const MANAGED_HOOK_FILES = [
|
|
@@ -222,10 +222,6 @@ function mergeSettings(existing, template) {
|
|
|
222
222
|
return base;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
function findPackageRoot() {
|
|
226
|
-
return path.resolve(__dirname, '..', '..', '..');
|
|
227
|
-
}
|
|
228
|
-
|
|
229
225
|
function copyFileIfDifferent(srcPath, destPath, { dryRun }) {
|
|
230
226
|
if (!fs.existsSync(srcPath)) {
|
|
231
227
|
return { status: 'source-missing', dest: destPath };
|
|
@@ -247,10 +243,9 @@ function copyFileIfDifferent(srcPath, destPath, { dryRun }) {
|
|
|
247
243
|
}
|
|
248
244
|
|
|
249
245
|
function installHooks(repoRoot, { dryRun }) {
|
|
250
|
-
const packageRoot = findPackageRoot();
|
|
251
246
|
const results = [];
|
|
252
247
|
for (const hookFile of MANAGED_HOOK_FILES) {
|
|
253
|
-
const src = path.join(
|
|
248
|
+
const src = path.join(CHECKOUT_ROOT, HOOKS_REL, hookFile);
|
|
254
249
|
const dest = path.join(repoRoot, HOOKS_REL, hookFile);
|
|
255
250
|
const result = copyFileIfDifferent(src, dest, { dryRun });
|
|
256
251
|
if (result.status === 'source-missing') continue;
|
|
@@ -267,10 +262,9 @@ function installHooks(repoRoot, { dryRun }) {
|
|
|
267
262
|
}
|
|
268
263
|
|
|
269
264
|
function installSlashCommands(repoRoot, { dryRun }) {
|
|
270
|
-
const packageRoot = findPackageRoot();
|
|
271
265
|
const results = [];
|
|
272
266
|
for (const filename of MANAGED_SLASH_COMMANDS) {
|
|
273
|
-
const src = path.join(
|
|
267
|
+
const src = path.join(CHECKOUT_ROOT, COMMANDS_REL, filename);
|
|
274
268
|
const dest = path.join(repoRoot, COMMANDS_REL, filename);
|
|
275
269
|
const result = copyFileIfDifferent(src, dest, { dryRun });
|
|
276
270
|
if (result.status === 'source-missing') continue;
|
|
@@ -280,10 +274,9 @@ function installSlashCommands(repoRoot, { dryRun }) {
|
|
|
280
274
|
}
|
|
281
275
|
|
|
282
276
|
function installAgentSkills(repoRoot, { dryRun }) {
|
|
283
|
-
const packageRoot = findPackageRoot();
|
|
284
277
|
const results = [];
|
|
285
278
|
for (const skill of MANAGED_AGENT_SKILLS) {
|
|
286
|
-
const srcDir = path.join(
|
|
279
|
+
const srcDir = path.join(...skill.source);
|
|
287
280
|
if (!fs.existsSync(srcDir)) {
|
|
288
281
|
results.push({ skill: skill.name, status: 'source-missing' });
|
|
289
282
|
continue;
|
package/src/cli/commands/pr.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// This is the thin glue layer; logic lives in src/pr.js.
|
|
15
15
|
|
|
16
16
|
const { TOOL_NAME, SHORT_TOOL_NAME } = require('../../context');
|
|
17
|
-
const prModule = require('../../
|
|
17
|
+
const prModule = require('../../pull-request/index');
|
|
18
18
|
const { prReview } = require('./review');
|
|
19
19
|
|
|
20
20
|
function logInfo(message) {
|
|
@@ -432,7 +432,7 @@ function cmdRespond(rawArgs) {
|
|
|
432
432
|
return;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
const { prRespond } = require('../../
|
|
435
|
+
const { prRespond } = require('../../pull-request/respond');
|
|
436
436
|
const result = prRespond({
|
|
437
437
|
pr: opts.pr,
|
|
438
438
|
target: opts.target,
|
|
@@ -47,7 +47,10 @@ function ensureCleanWorkingTree(repoRoot) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function readReleaseRepoPackageJson(repoRoot) {
|
|
50
|
-
const
|
|
50
|
+
const workspaceManifest = path.join(repoRoot, 'package', 'gitguardex', 'package.json');
|
|
51
|
+
const manifestPath = fs.existsSync(workspaceManifest)
|
|
52
|
+
? workspaceManifest
|
|
53
|
+
: path.join(repoRoot, 'package.json');
|
|
51
54
|
if (!fs.existsSync(manifestPath)) {
|
|
52
55
|
throw new Error(`Release blocked: package.json missing in ${repoRoot}`);
|
|
53
56
|
}
|
|
@@ -243,6 +246,9 @@ function release(rawArgs) {
|
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
const releasePackageJson = readReleaseRepoPackageJson(repoRoot);
|
|
249
|
+
if (typeof releasePackageJson.version !== 'string' || !releasePackageJson.version.trim()) {
|
|
250
|
+
throw new Error('Release blocked: the package manifest has no version');
|
|
251
|
+
}
|
|
246
252
|
const repoSlug = resolveReleaseGithubRepo(repoRoot);
|
|
247
253
|
const currentTag = `v${releasePackageJson.version}`;
|
|
248
254
|
const previousTag = resolvePreviousPublishedReleaseTag(repoSlug, currentTag);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// src/cli/main.js.
|
|
3
3
|
const { resolveRepoRoot } = require('../../git');
|
|
4
4
|
const { runReviewBotCommand } = require('../../core/runtime');
|
|
5
|
-
const prReviewModule = require('../../
|
|
6
|
-
const reviewFixModule = require('../../review
|
|
5
|
+
const prReviewModule = require('../../review/pull-request');
|
|
6
|
+
const reviewFixModule = require('../../review/fix');
|
|
7
7
|
const { parseReviewArgs, parsePrReviewArgs } = require('../args');
|
|
8
8
|
const { isSpawnFailure } = require('../shared/sandbox');
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { resolveRepoRoot } = require('../../git');
|
|
2
2
|
const { extractTargetedArgs, run } = require('../../core/runtime');
|
|
3
|
-
const { estimateCheckout } = require('../../worktree
|
|
3
|
+
const { estimateCheckout } = require('../../worktree/start');
|
|
4
4
|
|
|
5
5
|
function worktreeEstimate(args) {
|
|
6
6
|
if (args.length === 1 && ['--help', '-h'].includes(args[0])) {
|
|
@@ -45,7 +45,7 @@ function worktreeEstimate(args) {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
const report = estimateCheckout(repoRoot, ref, exclusions);
|
|
48
|
-
report.quota = require('../../worktree
|
|
48
|
+
report.quota = require('../../worktree/quota').inspectWorktreeQuota(repoRoot, report.checkoutBytes, destination);
|
|
49
49
|
if (checkQuota && report.quota?.violations.length) {
|
|
50
50
|
throw new Error(report.quota.violations.join(', ') + ': reuse an existing task or inspect safe cleanup before creating another worktree. No new checkout was created.');
|
|
51
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { resolveRepoRoot } = require('../../git');
|
|
4
|
-
const hooks = require('../../worktree
|
|
4
|
+
const hooks = require('../../worktree/hooks');
|
|
5
5
|
|
|
6
6
|
async function runWorktreeHooksCommand(args, deps = {}) {
|
|
7
7
|
if (args.includes('--help') || args.includes('-h')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { resolveRepoRoot } = require('../../git');
|
|
2
|
-
const { resolveWorktree, shellIntegration } = require('../../worktree
|
|
3
|
-
const { pickWorktree } = require('../../worktree
|
|
2
|
+
const { resolveWorktree, shellIntegration } = require('../../worktree/navigation');
|
|
3
|
+
const { pickWorktree } = require('../../worktree/picker');
|
|
4
4
|
|
|
5
5
|
async function switchWorktree(args = [], deps = {}) {
|
|
6
6
|
const options = { cwd: process.cwd() };
|
|
@@ -36,7 +36,7 @@ async function switchWorktree(args = [], deps = {}) {
|
|
|
36
36
|
if (!entry) return null;
|
|
37
37
|
if (/[\x00-\x1f\x7f]/.test(entry.path))
|
|
38
38
|
throw new Error('Navigation path contains unsupported control characters');
|
|
39
|
-
const hook = deps.runLifecycleHook || require('../../worktree
|
|
39
|
+
const hook = deps.runLifecycleHook || require('../../worktree/hooks').runLifecycleHook;
|
|
40
40
|
const context = {
|
|
41
41
|
worktreePath: entry.path,
|
|
42
42
|
branch: entry.branch,
|
package/src/cli/shared-locks.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { TOOL_NAME } = require('../context');
|
|
4
4
|
const { resolveRepoRoot } = require('../git');
|
|
5
5
|
const { run, extractTargetedArgs, runPackageAsset } = require('../core/runtime');
|
|
6
|
-
const sharedGitState = require('../shared-
|
|
6
|
+
const sharedGitState = require('../git/shared-state');
|
|
7
7
|
|
|
8
8
|
function writeCommandResult(result) {
|
|
9
9
|
if (result.stdout) process.stdout.write(result.stdout);
|
package/src/context.js
CHANGED
|
@@ -4,6 +4,12 @@ const path = require('node:path');
|
|
|
4
4
|
const cp = require('node:child_process');
|
|
5
5
|
|
|
6
6
|
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
7
|
+
const workspaceRoot = path.resolve(PACKAGE_ROOT, '../..');
|
|
8
|
+
const CHECKOUT_ROOT =
|
|
9
|
+
path.join(workspaceRoot, 'package', 'gitguardex') === PACKAGE_ROOT &&
|
|
10
|
+
fs.existsSync(path.join(workspaceRoot, '.git'))
|
|
11
|
+
? workspaceRoot
|
|
12
|
+
: PACKAGE_ROOT;
|
|
7
13
|
const CLI_ENTRY_PATH = path.join(PACKAGE_ROOT, 'bin', 'multiagent-safety.js');
|
|
8
14
|
const packageJsonPath = path.join(PACKAGE_ROOT, 'package.json');
|
|
9
15
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
@@ -91,7 +97,7 @@ const RTK_BIN = process.env.GUARDEX_RTK_BIN || 'rtk';
|
|
|
91
97
|
let _ghBin;
|
|
92
98
|
let _requiredSystemTools;
|
|
93
99
|
const MAINTAINER_RELEASE_REPO = path.resolve(
|
|
94
|
-
process.env.GUARDEX_RELEASE_REPO ||
|
|
100
|
+
process.env.GUARDEX_RELEASE_REPO || CHECKOUT_ROOT,
|
|
95
101
|
);
|
|
96
102
|
const NPM_BIN = process.env.GUARDEX_NPM_BIN || 'npm';
|
|
97
103
|
const OPENSPEC_BIN = process.env.GUARDEX_OPENSPEC_BIN || 'openspec';
|
|
@@ -1286,6 +1292,7 @@ module.exports = {
|
|
|
1286
1292
|
cp,
|
|
1287
1293
|
cachedSpawn,
|
|
1288
1294
|
PACKAGE_ROOT,
|
|
1295
|
+
CHECKOUT_ROOT,
|
|
1289
1296
|
CLI_ENTRY_PATH,
|
|
1290
1297
|
packageJsonPath,
|
|
1291
1298
|
packageJson,
|
package/src/finish/index.js
CHANGED
|
@@ -167,7 +167,7 @@ function autoCommitWorktreeForFinish(repoRoot, worktreePath, branch, options) {
|
|
|
167
167
|
return { changed: true, committed: false, dryRun: true };
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const { runLifecycleHookSync } = require('../worktree
|
|
170
|
+
const { runLifecycleHookSync } = require('../worktree/hooks');
|
|
171
171
|
runLifecycleHookSync(repoRoot, 'pre-commit', { worktreePath, branch });
|
|
172
172
|
// Hooks may generate files; claim through GX before staging.
|
|
173
173
|
claimLocksForAutoCommit(repoRoot, worktreePath, branch);
|
|
@@ -437,7 +437,7 @@ function cleanupFinishedDetachedWorktree(input) {
|
|
|
437
437
|
if (!worktreeIdentityMatches(plan) || probeWorktreeOwnership(plan.worktreePath).active)
|
|
438
438
|
return false;
|
|
439
439
|
try {
|
|
440
|
-
require('../worktree
|
|
440
|
+
require('../worktree/hooks').runLifecycleHookSync(plan.repoRoot, 'pre-remove', {
|
|
441
441
|
worktreePath: plan.worktreePath,
|
|
442
442
|
branch: plan.branch
|
|
443
443
|
});
|
|
@@ -463,7 +463,7 @@ function cleanupFinishedDetachedWorktree(input) {
|
|
|
463
463
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
464
464
|
retireCleanupJob(plan);
|
|
465
465
|
try {
|
|
466
|
-
require('../worktree
|
|
466
|
+
require('../worktree/hooks').runLifecycleHookSync(plan.repoRoot, 'post-remove', {
|
|
467
467
|
worktreePath: plan.worktreePath,
|
|
468
468
|
branch: plan.branch
|
|
469
469
|
});
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
const { run } = require('../core/runtime');
|
|
11
11
|
const { TOOL_NAME } = require('../context');
|
|
12
|
-
const pr = require('../
|
|
13
|
-
const prReview = require('../
|
|
14
|
-
const reviewFix = require('../review
|
|
12
|
+
const pr = require('../pull-request/index');
|
|
13
|
+
const prReview = require('../review/pull-request');
|
|
14
|
+
const reviewFix = require('../review/fix');
|
|
15
15
|
const { reviewReceipt } = require('./review-receipt');
|
|
16
16
|
const { mapWorktreePathsByBranch } = require('../git');
|
|
17
17
|
|