@imdeadpool/guardex 5.0.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.
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ Thanks for contributing to `GuardeX`.
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
+ - Keep `main` green (CI passing)
24
+ - Prefer trusted publishing (`npm publish --provenance`)
25
+ - Use a clean working tree and tag-based releases when possible
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 multiagent-safety contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,428 @@
1
+ # GuardeX — Guardian T-Rex for your repo
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40imdeadpool%2Fguardex?color=cb3837&logo=npm)](https://www.npmjs.com/package/@imdeadpool/guardex)
4
+ [![CI](https://github.com/recodeecom/multiagent-safety/actions/workflows/ci.yml/badge.svg)](https://github.com/recodeecom/multiagent-safety/actions/workflows/ci.yml)
5
+ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/recodeecom/multiagent-safety/badge)](https://securityscorecards.dev/viewer/?uri=github.com/recodeecom/multiagent-safety)
6
+
7
+ GuardeX is a short-command, hardened multi-agent safety setup for any git repo.
8
+
9
+ > [!WARNING]
10
+ > Not affiliated with OpenAI or Codex. Not an official tool.
11
+
12
+ ## Why this tool exists
13
+
14
+ If you run multiple agents at the same time, it is easy to get collisions:
15
+ two agents editing the same files, unsafe deletes, broken branch flow, or
16
+ confusing ownership.
17
+
18
+ `GuardeX` adds strict guardrails so parallel agent work stays safe and predictable.
19
+
20
+ ![Multi-agent dashboard example](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/dashboard-multi-agent.png)
21
+
22
+ The dashboard above is the exact kind of parallel workflow GuardeX is built for.
23
+
24
+ It also includes an OpenSpec planning scaffold script so plan-mode workspaces
25
+ can be bootstrapped consistently across repos.
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ npm i -g @imdeadpool/guardex
31
+ ```
32
+
33
+ Package page: https://www.npmjs.com/package/@imdeadpool/guardex
34
+
35
+
36
+ ## Command aliases
37
+
38
+ - Preferred short command: `gx`
39
+ - Full command: `guardex`
40
+ - Legacy aliases still supported: `musafety`, `multiagent-safety`
41
+
42
+ ## Security + maintenance posture
43
+
44
+ - CI matrix on Node 18/20/22 (`npm test`, `node --check`, `npm pack --dry-run`)
45
+ - trusted publishing workflow uses `npm publish --provenance` in GitHub Actions
46
+ - OpenSSF Scorecard workflow and weekly Dependabot for GitHub Actions
47
+ - Dedicated security disclosure policy in [`SECURITY.md`](./SECURITY.md)
48
+
49
+ Related tools:
50
+
51
+ - [oh-my-codex (OMX)](https://github.com/Yeachan-Heo/oh-my-codex)
52
+ - [OpenSpec](https://github.com/Fission-AI/OpenSpec)
53
+
54
+ ## Fast setup (recommended)
55
+
56
+ ```sh
57
+ # inside your repo
58
+ gx setup
59
+ ```
60
+
61
+ That one command runs:
62
+
63
+ 1. detects whether OMX/OpenSpec are already globally installed,
64
+ 2. asks strict Y/N approval only if something is missing,
65
+ 3. installs guardrail scripts/hooks,
66
+ 4. repairs common safety problems,
67
+ 5. installs local Codex + Claude gx helper skill files if missing,
68
+ 6. scans and reports final status.
69
+
70
+ ## Setup screenshot
71
+
72
+ ![gx setup success screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/setup-success.svg)
73
+
74
+ ## Status logs screenshot
75
+
76
+ ![gx service status screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/guardex-service-status.svg)
77
+
78
+ ## AI helper skills installed by setup/doctor
79
+
80
+ `gx setup` and `gx doctor` also ensure these local helper files exist:
81
+
82
+ - Codex skill: `.codex/skills/guardex/SKILL.md`
83
+ - Claude command: `.claude/commands/guardex.md` (use as `/guardex`)
84
+
85
+ ## Scorecard report generation
86
+
87
+ Create/update markdown reports from OpenSSF Scorecard JSON:
88
+
89
+ ```sh
90
+ gx report scorecard --repo github.com/recodeecom/multiagent-safety
91
+ ```
92
+
93
+ By default this writes:
94
+
95
+ - `docs/reports/openssf-scorecard-baseline-YYYY-MM-DD.md`
96
+ - `docs/reports/openssf-scorecard-remediation-plan-YYYY-MM-DD.md`
97
+
98
+ ## Workflow protocol screenshots
99
+
100
+ ### 1) Start isolated agent branch/worktree
101
+
102
+ ![gx branch start protocol screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/workflow-branch-start.svg)
103
+
104
+ ### 2) Lock claim + deletion guard protocol
105
+
106
+ ![gx lock and delete guard screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/workflow-lock-guard.svg)
107
+
108
+ ### 3) Multi-agent branch visibility (IDE/source control style)
109
+
110
+ ![gx source control multi-agent screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/workflow-source-control.svg)
111
+
112
+ #### Real VS Code Source Control example (after `gx setup`)
113
+
114
+ ![GuardeX real VS Code Source Control layout](./docs/images/workflow-vscode-guardex-real.png)
115
+
116
+ This is the exact layout you should expect in VS Code Source Control after setup
117
+ and a few `agent-branch-start` runs:
118
+
119
+ ```text
120
+ GuardeX (your preferred local branch: main/dev)
121
+ agent_codex_<timestamp>-<snapshot>-<task>
122
+ agent_bot_<timestamp>-<snapshot>-<task>
123
+ agent_bot_<timestamp>-<snapshot>-<task>
124
+ ```
125
+
126
+ That gives you one stable main repo view plus parallel agent worktrees in the
127
+ same VS Code window, so branch ownership and progress stay visible at once.
128
+
129
+ ## Companion tool: `codex-auth` account switcher
130
+
131
+ If you run multiple Codex identities, this workflow pairs well with
132
+ [`codex-auth`](https://github.com/recodeecom/codex-account-switcher-cli/tree/main),
133
+ a CLI that snapshots `~/.codex/auth.json` per account and lets you switch fast
134
+ without repeated login/logout loops.
135
+
136
+ > [!WARNING]
137
+ > Not affiliated with OpenAI or Codex. Not an official tool.
138
+
139
+ How `codex-auth` works:
140
+
141
+ - stores named snapshots in `~/.codex/accounts/*.json`
142
+ - switches by replacing active `~/.codex/auth.json`
143
+ - keeps lightweight per-terminal session memory (default key is shell PPID),
144
+ so older terminals can keep their original account context
145
+
146
+ Requirements: Node.js 18+
147
+
148
+ Install:
149
+
150
+ ```sh
151
+ npm i -g @imdeadpool/codex-account-switcher
152
+ ```
153
+
154
+ Common commands:
155
+
156
+ ```sh
157
+ codex-auth login [name]
158
+ codex-auth save <name>
159
+ codex-auth use <name>
160
+ codex-auth list --details
161
+ codex-auth current
162
+ codex-auth status
163
+ codex-auth self-update --check
164
+ ```
165
+
166
+ Optional shell-hook helpers:
167
+
168
+ ```sh
169
+ codex-auth setup-login-hook
170
+ codex-auth hook-status
171
+ codex-auth remove-login-hook
172
+ ```
173
+
174
+ ## Copy prompt for your AI (Codex / Claude)
175
+
176
+ ```sh
177
+ gx copy-prompt
178
+ ```
179
+
180
+ This prints a ready-to-paste prompt.
181
+
182
+ ### Prompt preview (SVG)
183
+
184
+ ![gx copy prompt screenshot](https://raw.githubusercontent.com/recodeecom/multiagent-safety/main/docs/images/copy-prompt-output.svg)
185
+
186
+ ### Commands-only copy mode
187
+
188
+ If you only want executable commands (without explanatory text):
189
+
190
+ ```sh
191
+ gx copy-commands
192
+ ```
193
+
194
+ Example output:
195
+
196
+ ```sh
197
+ npm i -g @imdeadpool/guardex
198
+ gx setup
199
+ gx doctor
200
+ bash scripts/codex-agent.sh "task" "agent-name"
201
+ bash scripts/agent-branch-start.sh "task" "agent-name"
202
+ python3 scripts/agent-file-locks.py claim --branch "$(git rev-parse --abbrev-ref HEAD)" <file...>
203
+ bash scripts/agent-branch-finish.sh --branch "$(git rev-parse --abbrev-ref HEAD)"
204
+ bash scripts/openspec/init-plan-workspace.sh "<plan-slug>"
205
+ gx protect add release staging
206
+ gx sync --check
207
+ gx sync
208
+ ```
209
+
210
+ Full checklist output:
211
+
212
+ ```text
213
+ Use this exact checklist to setup multi-agent safety in this repository for Codex or Claude.
214
+
215
+ 1) Install (if missing):
216
+ npm i -g @imdeadpool/guardex
217
+
218
+ 2) Bootstrap safety in this repo:
219
+ gx setup
220
+
221
+ - Setup detects global OMX/OpenSpec first.
222
+ - If one is missing and setup asks for approval, reply explicitly:
223
+ - y = run: npm i -g oh-my-codex @fission-ai/openspec (missing ones only)
224
+ - n = skip global installs
225
+
226
+ 3) If setup reports warnings/errors, repair + re-check:
227
+ gx doctor
228
+
229
+ 4) Confirm next safe agent workflow commands:
230
+ bash scripts/codex-agent.sh "task" "agent-name"
231
+ bash scripts/agent-branch-start.sh "task" "agent-name"
232
+ python3 scripts/agent-file-locks.py claim --branch "$(git rev-parse --abbrev-ref HEAD)" <file...>
233
+ bash scripts/agent-branch-finish.sh --branch "$(git rev-parse --abbrev-ref HEAD)"
234
+
235
+ 5) Optional: create OpenSpec planning workspace:
236
+ bash scripts/openspec/init-plan-workspace.sh "<plan-slug>"
237
+
238
+ 6) Optional: protect extra branches:
239
+ gx protect add release staging
240
+
241
+ 7) Optional: sync your current agent branch with latest base branch:
242
+ gx sync --check
243
+ gx sync
244
+
245
+ 8) Optional (GitHub remote cleanup): enable:
246
+ Settings -> General -> Pull Requests -> Automatically delete head branches
247
+ ```
248
+
249
+ ## Basic commands
250
+
251
+ ```sh
252
+ gx status [--target <path>] [--json]
253
+ gx setup [--target <path>] [--dry-run] [--yes-global-install|--no-global-install] [--no-gitignore]
254
+ gx doctor [--target <path>] [--dry-run] [--json] [--keep-stale-locks] [--no-gitignore]
255
+ gx copy-prompt
256
+ gx copy-commands
257
+ gx protect list [--target <path>]
258
+ gx protect add <branch...> [--target <path>]
259
+ gx protect remove <branch...> [--target <path>]
260
+ gx protect set <branch...> [--target <path>]
261
+ gx protect reset [--target <path>]
262
+ gx sync --check [--target <path>] [--base <branch>] [--json]
263
+ gx sync [--target <path>] [--base <branch>] [--strategy rebase|merge] [--ff-only]
264
+ gx report scorecard [--target <path>] [--repo github.com/<owner>/<repo>] [--scorecard-json <file>] [--output-dir <path>] [--date YYYY-MM-DD]
265
+ bash scripts/agent-worktree-prune.sh --base dev # manual stale worktree cleanup
266
+ bash scripts/openspec/init-plan-workspace.sh <plan-slug> # optional OpenSpec plan scaffold
267
+ ```
268
+
269
+ No command defaults to `gx status` (non-mutating health/status view).
270
+ `gx status` reports CLI/runtime info, global OMX/OpenSpec service status, and repo safety service state.
271
+ When run in an interactive terminal, default `GuardeX` checks npm for a newer version first
272
+ and asks `[y/N]` whether to update immediately (default is `N`).
273
+
274
+ - Interactive setup: prompts for Y/N approval before global OMX/OpenSpec install.
275
+ - Interactive prompt is strict (`[y/n]`) and waits for explicit answer.
276
+ - Non-interactive setup: skips global installs by default; use `--yes-global-install` to force.
277
+
278
+ ## Advanced commands
279
+
280
+ ```sh
281
+ gx install [--target <path>] [--force] [--skip-agents] [--skip-package-json] [--no-gitignore] [--dry-run]
282
+ gx fix [--target <path>] [--dry-run] [--keep-stale-locks] [--no-gitignore]
283
+ gx scan [--target <path>] [--json]
284
+ gx report help
285
+ ```
286
+
287
+ ## Keep agent branches synced with your base branch
288
+
289
+ Use sync checks before finishing agent branches:
290
+
291
+ ```sh
292
+ gx sync --check
293
+ gx sync
294
+ ```
295
+
296
+ Defaults:
297
+
298
+ - `gx sync` base branch: `dev` (or `multiagent.baseBranch`)
299
+ - strategy: `rebase` (or `multiagent.sync.strategy`)
300
+
301
+ `agent-branch-start.sh` and `agent-branch-finish.sh` resolve base branch in this order:
302
+
303
+ 1. explicit `--base`
304
+ 2. `multiagent.baseBranch`
305
+ 3. branch-linked base metadata / source upstream / current checked-out branch (context-dependent)
306
+ 4. fallback `dev`
307
+
308
+ Useful variants:
309
+
310
+ ```sh
311
+ gx sync --strategy merge
312
+ gx sync --all-agent-branches --check
313
+ ```
314
+
315
+ By default, `agent-branch-finish.sh` also blocks finishing when your branch is behind `origin/<base>` and points to `gx sync`.
316
+
317
+ Optional pre-commit behind-threshold gate (off by default):
318
+
319
+ ```sh
320
+ git config multiagent.sync.requireBeforeCommit true
321
+ git config multiagent.sync.maxBehindCommits 0
322
+ ```
323
+
324
+ With that enabled, agent-branch commits are blocked if the branch is behind `origin/<base>` by more than the configured threshold.
325
+
326
+ ## Configure protected branches
327
+
328
+ Default protected branches are:
329
+
330
+ - `dev`
331
+ - `main`
332
+ - `master`
333
+
334
+ You can manage additional protected branches via CLI:
335
+
336
+ ```sh
337
+ gx protect list
338
+ gx protect add release staging
339
+ gx protect remove dev
340
+ gx protect set main release hotfix
341
+ gx protect reset
342
+ ```
343
+
344
+ Configuration is stored in local git config key:
345
+
346
+ ```text
347
+ multiagent.protectedBranches
348
+ ```
349
+
350
+ ## What is protected
351
+
352
+ - direct commits to protected branches (defaults: `dev`, `main`, `master`; configurable via `gx protect ...`)
353
+ - protected-branch commits are blocked regardless of commit client (including VS Code Source Control)
354
+ - Codex-session commits on non-`agent/*` branches are blocked by default (`multiagent.codexRequireAgentBranch=true`)
355
+ - Codex commits attempted on protected branches trigger `guardex-preedit-guard` and require starting work via `scripts/codex-agent.sh`
356
+ - overlapping file ownership between agents
357
+ - unapproved deletions of claimed files
358
+ - risky stale/missing lock state
359
+ - accidental loss of critical guardrail files
360
+ - in-place branch bootstrap requires explicit opt-in (`--in-place --allow-in-place`)
361
+ - setup also writes a managed `.gitignore` block so generated gx scripts/hooks stay out of normal git status noise by default
362
+ - includes `oh-my-codex/` by default to keep local OMX source clones out of repo status
363
+ - pass `--no-gitignore` if you want to keep tracking these files in git
364
+
365
+ ## Files it installs
366
+
367
+ ```text
368
+ scripts/agent-branch-start.sh
369
+ scripts/agent-branch-finish.sh
370
+ scripts/codex-agent.sh
371
+ scripts/agent-worktree-prune.sh
372
+ scripts/agent-file-locks.py
373
+ scripts/install-agent-git-hooks.sh
374
+ scripts/openspec/init-plan-workspace.sh
375
+ .githooks/pre-commit
376
+ .codex/skills/guardex/SKILL.md
377
+ .claude/commands/guardex.md
378
+ .omx/state/agent-file-locks.json
379
+ ```
380
+
381
+ If `package.json` exists, it also adds helper scripts (`agent:*`).
382
+
383
+ ## Local development
384
+
385
+ ```sh
386
+ npm test
387
+ node --check bin/multiagent-safety.js
388
+ npm pack --dry-run
389
+ ```
390
+
391
+ ## Release notes
392
+
393
+ ### v0.4.6
394
+
395
+ - Added repository metadata (`repository`, `bugs`, `homepage`, `funding`) in package manifest.
396
+ - Added CI workflow for Node 18/20/22 with packaging and syntax verification.
397
+ - Added npm provenance-oriented release workflow, OpenSSF Scorecard workflow, and Dependabot for Actions.
398
+ - Added explicit `SECURITY.md` and `CONTRIBUTING.md`.
399
+
400
+ ### v0.4.5
401
+
402
+ - Added optional pre-commit behind-threshold sync gate (`multiagent.sync.requireBeforeCommit`, `multiagent.sync.maxBehindCommits`).
403
+ - Added `gx sync` workflow (`--check`, sync strategies, report mode).
404
+ - `agent-branch-finish.sh` now blocks finishing when source branch is behind `origin/<base>` (config-aware).
405
+
406
+ ### v0.4.4
407
+
408
+ - Added `scripts/agent-worktree-prune.sh` to templates/install.
409
+ - `agent-branch-finish.sh` now auto-runs prune after merge (best effort).
410
+ - Added npm helper script: `agent:cleanup`.
411
+
412
+ ### v0.4.2
413
+
414
+ - Setup now detects existing global OMX/OpenSpec installs first.
415
+ - If tools are already present, setup skips global install automatically.
416
+ - Interactive approval is now strict `[y/n]` (waits for explicit answer).
417
+ - Added setup screenshot to README.
418
+ - Added 3 additional workflow screenshots (branch start, lock/delete guard, source-control view).
419
+
420
+ ### v0.4.0
421
+
422
+ - Added setup-time Y/N approval prompt for optional global install of:
423
+ - `oh-my-codex`
424
+ - `@fission-ai/openspec`
425
+ - Added setup flags for automation:
426
+ - `--yes-global-install`
427
+ - `--no-global-install`
428
+ - Added official repo links for OMX and OpenSpec.
package/SECURITY.md ADDED
@@ -0,0 +1,28 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Only the latest published `guardex` version is supported for security fixes.
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ Please report security issues privately by opening a GitHub security advisory:
10
+
11
+ - https://github.com/recodeecom/multiagent-safety/security/advisories/new
12
+
13
+ If advisories are unavailable, open a private report via GitHub issue contact details and avoid posting exploit details publicly.
14
+
15
+ ## Response Targets
16
+
17
+ - Acknowledgement: within 72 hours
18
+ - Initial triage: within 7 days
19
+ - Remediation/release target: as fast as possible based on severity
20
+
21
+ ## Scope
22
+
23
+ Report issues related to:
24
+
25
+ - Hook bypasses or branch-protection bypasses
26
+ - Unsafe lock ownership behavior
27
+ - Command injection, path traversal, or privilege escalation in scripts
28
+ - Supply-chain integrity concerns in release/publish flow