@imdeadpool/guardex 7.0.41 → 7.1.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.
Files changed (118) hide show
  1. package/README.md +94 -13
  2. package/package.json +3 -1
  3. package/skills/gitguardex/SKILL.md +13 -0
  4. package/skills/guardex-merge-skills-to-dev/SKILL.md +59 -0
  5. package/skills/gx-act/SKILL.md +82 -0
  6. package/src/agents/cleanup-sessions.js +126 -0
  7. package/src/agents/finish.js +172 -0
  8. package/src/agents/inspect.js +202 -0
  9. package/src/agents/launch.js +249 -0
  10. package/src/agents/registry.js +133 -0
  11. package/src/agents/selection-panel.js +571 -0
  12. package/src/agents/sessions.js +151 -0
  13. package/src/agents/start.js +591 -0
  14. package/src/agents/status.js +146 -0
  15. package/src/agents/terminal.js +152 -0
  16. package/src/budget/index.js +344 -0
  17. package/src/ci-init/index.js +265 -0
  18. package/src/cli/args.js +357 -3
  19. package/src/cli/commands/agents.js +364 -0
  20. package/src/cli/commands/bootstrap.js +92 -0
  21. package/src/cli/commands/branch.js +127 -0
  22. package/src/cli/commands/claude.js +674 -0
  23. package/src/cli/commands/doctor.js +268 -0
  24. package/src/cli/commands/finish.js +26 -0
  25. package/src/cli/commands/mcp.js +122 -0
  26. package/src/cli/commands/misc.js +304 -0
  27. package/src/cli/commands/pr.js +439 -0
  28. package/src/cli/commands/prompt.js +92 -0
  29. package/src/cli/commands/release.js +305 -0
  30. package/src/cli/commands/report.js +244 -0
  31. package/src/cli/commands/review.js +32 -0
  32. package/src/cli/commands/setup.js +242 -0
  33. package/src/cli/commands/status.js +338 -0
  34. package/src/cli/commands/watch.js +234 -0
  35. package/src/cli/main.js +85 -3613
  36. package/src/cli/shared/repo-env.js +161 -0
  37. package/src/cli/shared/sandbox.js +417 -0
  38. package/src/cli/shared/scaffolding.js +535 -0
  39. package/src/cli/shared/toolchain-shims.js +420 -0
  40. package/src/cockpit/action-runner.js +3 -0
  41. package/src/cockpit/actions.js +80 -0
  42. package/src/cockpit/control.js +1121 -0
  43. package/src/cockpit/index.js +426 -0
  44. package/src/cockpit/kitty-layout.js +549 -0
  45. package/src/cockpit/kitty-tree.js +144 -0
  46. package/src/cockpit/logs-reader.js +182 -0
  47. package/src/cockpit/menu.js +204 -0
  48. package/src/cockpit/pane-actions.js +597 -0
  49. package/src/cockpit/pane-menu.js +387 -0
  50. package/src/cockpit/projects-finder.js +178 -0
  51. package/src/cockpit/render.js +215 -0
  52. package/src/cockpit/settings-render.js +128 -0
  53. package/src/cockpit/settings.js +124 -0
  54. package/src/cockpit/shortcuts.js +24 -0
  55. package/src/cockpit/sidebar.js +311 -0
  56. package/src/cockpit/state.js +72 -0
  57. package/src/cockpit/theme.js +128 -0
  58. package/src/cockpit/welcome.js +266 -0
  59. package/src/context.js +304 -43
  60. package/src/core/runtime.js +6 -1
  61. package/src/doctor/index.js +45 -15
  62. package/src/finish/index.js +186 -7
  63. package/src/finish/preflight.js +177 -0
  64. package/src/finish/review-gate.js +182 -0
  65. package/src/git/index.js +511 -4
  66. package/src/hooks/index.js +0 -64
  67. package/src/kitty/command.js +101 -0
  68. package/src/kitty/runtime.js +250 -0
  69. package/src/mcp/collect.js +370 -0
  70. package/src/mcp/server.js +157 -0
  71. package/src/output/index.js +68 -2
  72. package/src/pr-review.js +264 -0
  73. package/src/pr.js +381 -0
  74. package/src/sandbox/index.js +13 -2
  75. package/src/scaffold/agent-worktree-prep.js +213 -0
  76. package/src/scaffold/index.js +127 -10
  77. package/src/speckit/index.js +226 -0
  78. package/src/submodule/index.js +288 -0
  79. package/src/terminal/index.js +45 -0
  80. package/src/terminal/kitty.js +622 -0
  81. package/src/terminal/tmux.js +125 -0
  82. package/src/tmux/command.js +27 -0
  83. package/src/tmux/session.js +89 -0
  84. package/src/toolchain/index.js +20 -0
  85. package/templates/AGENTS.monorepo-apps.md +26 -0
  86. package/templates/AGENTS.multiagent-safety.md +63 -323
  87. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  88. package/templates/codex/skills/gitguardex/SKILL.md +2 -0
  89. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  90. package/templates/githooks/pre-commit +44 -20
  91. package/templates/github/workflows/README.md +87 -0
  92. package/templates/github/workflows/ci-full.yml +55 -0
  93. package/templates/github/workflows/ci.yml +56 -0
  94. package/templates/github/workflows/cr.yml +20 -1
  95. package/templates/scripts/agent-branch-finish.sh +519 -23
  96. package/templates/scripts/agent-branch-merge.sh +4 -1
  97. package/templates/scripts/agent-branch-start.sh +176 -24
  98. package/templates/scripts/agent-preflight.sh +115 -0
  99. package/templates/scripts/agent-worktree-prune.sh +96 -5
  100. package/templates/scripts/codex-agent.sh +41 -97
  101. package/templates/scripts/openspec/init-plan-workspace.sh +43 -0
  102. package/templates/scripts/review-bot-watch.sh +31 -2
  103. package/templates/scripts/agent-session-state.js +0 -171
  104. package/templates/scripts/install-vscode-active-agents-extension.js +0 -135
  105. package/templates/vscode/guardex-active-agents/README.md +0 -34
  106. package/templates/vscode/guardex-active-agents/extension.js +0 -3782
  107. package/templates/vscode/guardex-active-agents/fileicons/gitguardex-fileicons.json +0 -54
  108. package/templates/vscode/guardex-active-agents/fileicons/icons/agent.svg +0 -5
  109. package/templates/vscode/guardex-active-agents/fileicons/icons/branch.svg +0 -7
  110. package/templates/vscode/guardex-active-agents/fileicons/icons/config.svg +0 -4
  111. package/templates/vscode/guardex-active-agents/fileicons/icons/hook.svg +0 -4
  112. package/templates/vscode/guardex-active-agents/fileicons/icons/openspec.svg +0 -5
  113. package/templates/vscode/guardex-active-agents/fileicons/icons/plan.svg +0 -4
  114. package/templates/vscode/guardex-active-agents/fileicons/icons/spec.svg +0 -5
  115. package/templates/vscode/guardex-active-agents/icon.png +0 -0
  116. package/templates/vscode/guardex-active-agents/media/active-agents-hivemind.svg +0 -14
  117. package/templates/vscode/guardex-active-agents/package.json +0 -169
  118. package/templates/vscode/guardex-active-agents/session-schema.js +0 -1348
@@ -108,6 +108,18 @@ case "$codex_require_agent_branch" in
108
108
  *) should_require_codex_agent_branch=1 ;;
109
109
  esac
110
110
 
111
+ # General lockdown knob (applies to ALL agent sessions, not just Codex).
112
+ # Default OFF: any branch that is not a protected base is an acceptable agent
113
+ # branch, so `vendor/x`, `feat/y`, or any ad-hoc name commits without ceremony.
114
+ # Set GUARDEX_REQUIRE_AGENT_BRANCH=1 (or `git config multiagent.requireAgentBranch
115
+ # true`) to force agent commits back onto the agent/* namespace.
116
+ require_agent_branch_raw="${GUARDEX_REQUIRE_AGENT_BRANCH:-$(git config --get multiagent.requireAgentBranch || true)}"
117
+ require_agent_branch="$(printf '%s' "$require_agent_branch_raw" | tr '[:upper:]' '[:lower:]')"
118
+ should_require_agent_branch=0
119
+ case "$require_agent_branch" in
120
+ 1|true|yes|on) should_require_agent_branch=1 ;;
121
+ esac
122
+
111
123
  is_codex_managed_only_commit_on_protected=0
112
124
  if [[ "$is_codex_session" == "1" && "$is_protected_branch" == "1" ]]; then
113
125
  deleted_paths="$(git diff --cached --name-only --diff-filter=D)"
@@ -138,8 +150,6 @@ if [[ "$should_require_codex_agent_branch" == "1" && "${GUARDEX_ALLOW_CODEX_ON_N
138
150
  GitGuardex requires Codex work to run from an isolated agent/* branch.
139
151
  Start the sub-branch/worktree with:
140
152
  gx branch start "<task-or-plan>" "<agent-name>"
141
- Or manually:
142
- gx branch start "<task-or-plan>" "<agent-name>"
143
153
  Then commit from the created agent/* branch.
144
154
 
145
155
  Temporary bypass (not recommended):
@@ -147,19 +157,10 @@ Temporary bypass (not recommended):
147
157
  MSG
148
158
  exit 1
149
159
  fi
150
-
151
- cat >&2 <<'MSG'
152
- [codex-branch-guard] Codex agent commit blocked on non-agent branch.
153
- Use isolated branch/worktree first:
154
- gx branch start "<task-or-plan>" "<agent-name>"
155
- Then commit from the created agent/* branch.
156
-
157
- Temporary bypass (not recommended):
158
- GUARDEX_ALLOW_CODEX_ON_NON_AGENT=1 git commit ...
159
- Disable this rule for a repo (not recommended):
160
- git config multiagent.codexRequireAgentBranch false
161
- MSG
162
- exit 1
160
+ # Non-protected branches (vendor/, feat/, any ad-hoc name) are fine for
161
+ # Codex too — being OFF a protected base is the only load-bearing rule.
162
+ # Re-impose the agent/* requirement with GUARDEX_REQUIRE_AGENT_BRANCH=1
163
+ # (handled by the general lockdown gate below).
163
164
  fi
164
165
  fi
165
166
 
@@ -192,26 +193,49 @@ MSG
192
193
  exit 1
193
194
  fi
194
195
 
195
- if [[ "$is_agent_session" == "1" && "$branch" != agent/* ]]; then
196
+ if [[ "$is_agent_session" == "1" && "$branch" != agent/* && "$should_require_agent_branch" == "1" ]]; then
196
197
  cat >&2 <<'MSG'
197
- [agent-branch-guard] Agent commits must run on dedicated agent/* branches.
198
+ [agent-branch-guard] Lockdown mode: agent commits must run on dedicated agent/* branches.
199
+ GUARDEX_REQUIRE_AGENT_BRANCH (or multiagent.requireAgentBranch) is enabled.
198
200
  Start an agent branch first:
199
201
  gx branch start "<task-or-plan>" "<agent-name>"
200
202
  Then commit on that branch.
201
203
 
202
- Temporary bypass (not recommended):
203
- ALLOW_COMMIT_ON_PROTECTED_BRANCH=1 git commit ...
204
+ Relax (any non-protected branch is normally fine):
205
+ unset GUARDEX_REQUIRE_AGENT_BRANCH
206
+ # or: git config multiagent.requireAgentBranch false
204
207
  MSG
205
208
  exit 1
206
209
  fi
207
210
 
208
211
  if [[ "$branch" == agent/* ]]; then
209
212
  if [[ "${GUARDEX_AUTOCLAIM_STAGED_LOCKS:-1}" == "1" ]]; then
213
+ # Auto-claim non-deletion staged paths. Deletions need an explicit
214
+ # `--allow-delete` flag below so `locks validate --staged` doesn't
215
+ # reject the commit on the same trip the user staged the delete.
210
216
  while IFS= read -r staged_file; do
211
217
  [[ -z "$staged_file" ]] && continue
212
218
  [[ "$staged_file" == ".omx/state/agent-file-locks.json" ]] && continue
213
219
  run_guardex_cli locks claim --branch "$branch" "$staged_file" >/dev/null 2>&1 || true
214
- done < <(git diff --cached --name-only --diff-filter=ACMRDTUXB)
220
+ done < <(git diff --cached --name-only --diff-filter=ACMRTUXB)
221
+
222
+ # Auto-approve deletions for the same branch (gated separately so
223
+ # operators can disable this single behavior without disabling the
224
+ # broader auto-claim). Defaults to enabled — matches the auto-claim
225
+ # default and removes the "first commit fails, then `gx locks
226
+ # allow-delete`, then commit again" loop.
227
+ if [[ "${GUARDEX_AUTOCLAIM_STAGED_DELETES:-1}" == "1" ]]; then
228
+ _staged_deletes=()
229
+ while IFS= read -r staged_delete; do
230
+ [[ -z "$staged_delete" ]] && continue
231
+ [[ "$staged_delete" == ".omx/state/agent-file-locks.json" ]] && continue
232
+ _staged_deletes+=("$staged_delete")
233
+ done < <(git diff --cached --name-only --diff-filter=D)
234
+ if (( ${#_staged_deletes[@]} > 0 )); then
235
+ run_guardex_cli locks claim --branch "$branch" --allow-delete \
236
+ "${_staged_deletes[@]}" >/dev/null 2>&1 || true
237
+ fi
238
+ fi
215
239
  fi
216
240
 
217
241
  if ! run_guardex_cli locks validate --branch "$branch" --staged; then
@@ -0,0 +1,87 @@
1
+ # `templates/github/workflows/` — budget-friendly CI defaults
2
+
3
+ Workflow files in this directory are copied into a gitguardex-managed
4
+ project's `.github/workflows/` directory when bootstrapping. They are
5
+ the **default** budget posture for projects that use `gx branch start`
6
+ to drive agent iterations.
7
+
8
+ Agent flows land a high volume of PRs per month. Without these trims,
9
+ every PR + every post-merge push fans out across CI, CodeQL, Scorecard,
10
+ and Code Review — which dominates the GitHub Actions bill for any
11
+ multi-agent repo. The trims below cut that cost without giving up
12
+ correctness coverage.
13
+
14
+ ## What's trimmed and why
15
+
16
+ 1. **`concurrency: cancel-in-progress: true`** scoped per workflow + ref
17
+ so rapid pushes to the same agent branch cancel the prior run
18
+ instead of letting both finish on Actions minutes.
19
+
20
+ 2. **`if: github.event.pull_request.draft == false`** on every job that
21
+ shouldn't run on a draft PR, paired with
22
+ `pull_request.types: [..., ready_for_review]` in the trigger list so
23
+ CI fires the moment the PR is promoted out of draft.
24
+
25
+ 3. **`if: !startsWith(head.ref, 'agent/')`** on the Code Review job
26
+ (`cr.yml`) — skip AI review on automated agent-lane PRs. AI review
27
+ on hundreds of agent PRs per month burns both Actions minutes and
28
+ OpenAI tokens without adding signal; human-authored PRs (any non-
29
+ `agent/*` head branch) still get reviewed.
30
+
31
+ 4. **No `push: main` trigger** in `ci.yml` — branch protection on
32
+ `main` forces all changes through a PR, so PR-time CI is sufficient
33
+ and post-merge CI on `main` was pure duplication. Use
34
+ `workflow_dispatch` for ad-hoc full runs.
35
+
36
+ 5. **`paths-ignore`** for docs / openspec / template-only changes — skip
37
+ CI on changes that don't affect runtime behavior.
38
+
39
+ ## Customizing
40
+
41
+ - Replace `placeholder` steps in `ci.yml` with your build/test/lint
42
+ commands.
43
+ - Keep the `concurrency:`, `if:`, and `paths-ignore:` patterns. They
44
+ are the load-bearing part of the budget posture; removing them undoes
45
+ the win.
46
+
47
+ ## When to skip the draft-skip pattern
48
+
49
+ If your CI is fast (≤ 2 min) and you want continuous validation as
50
+ agents iterate, drop the `if: pull_request.draft == false` job guard.
51
+ The concurrency cancel alone still prevents minute pile-up.
52
+
53
+ ## When to re-enable AI code review on agent PRs
54
+
55
+ If your team relies on AI review as a true gating signal (not just
56
+ advisory), remove the `!startsWith(head.ref, 'agent/')` guard in
57
+ `cr.yml`. Expect the OpenAI bill to scale linearly with merge volume.
58
+
59
+ ## Per-PR label opt-in
60
+
61
+ Both `cr.yml` and `ci-full.yml` honor PR labels so the occasional
62
+ agent PR that actually needs the heavier check can opt in without
63
+ flipping a global toggle:
64
+
65
+ | Label | Effect |
66
+ | --- | --- |
67
+ | `needs-review` | Run AI code review on this PR even though it's `agent/*`. Useful for security-sensitive changes or public-API redesigns. |
68
+ | `needs-ci-full` | Run the full cross-runtime matrix from `ci-full.yml` on this PR instead of waiting for the weekly schedule. Useful before a release branch lands. |
69
+
70
+ To enable: open the PR, then `gh pr edit <num> --add-label needs-review`
71
+ (or click the labels picker in the GitHub UI). The label-trigger fires
72
+ the workflow immediately; you don't need to re-push.
73
+
74
+ Add label definitions to your repo with `gh label create needs-review
75
+ --description "Run AI code review on this PR"` and similar for
76
+ `needs-ci-full`, or define them in `.github/labels.yml` if you use a
77
+ label-sync workflow.
78
+
79
+ ## What about CodeQL / Scorecard?
80
+
81
+ The gitguardex repo itself runs CodeQL and Scorecard on the **weekly
82
+ schedule + `workflow_dispatch`** only — not on per-PR / per-push
83
+ triggers. Those workflows are long-running (5–10 min for CodeQL) and
84
+ were the largest single line item on the monthly Actions bill before
85
+ this change. If your project needs per-PR CodeQL gating for compliance
86
+ reasons, re-add the `pull_request` trigger and accept the cost; for
87
+ most repos, weekly + on-demand is the right default.
@@ -0,0 +1,55 @@
1
+ # Optional companion to `ci.yml`. Drop in alongside it when your
2
+ # project supports multiple runtimes / OS combinations and you want
3
+ # coverage across all of them without paying per-PR.
4
+ #
5
+ # Strategy: PR-time `ci.yml` runs the primary runtime only (cheap).
6
+ # This workflow runs the full matrix on the weekly schedule, and
7
+ # on-demand via `workflow_dispatch` before a release. Per-PR opt-in
8
+ # is available by applying the `needs-ci-full` label to a PR.
9
+ #
10
+ # Customize the matrix rows below to match your supported runtimes.
11
+
12
+ name: CI (full matrix)
13
+
14
+ on:
15
+ schedule:
16
+ - cron: '15 4 * * 1'
17
+ workflow_dispatch:
18
+ pull_request:
19
+ types: [labeled, synchronize]
20
+
21
+ permissions:
22
+ contents: read
23
+
24
+ concurrency:
25
+ group: ci-full-${{ github.workflow }}-${{ github.ref }}
26
+ cancel-in-progress: true
27
+
28
+ jobs:
29
+ test:
30
+ name: test (node ${{ matrix.node }})
31
+ # PR runs only fire when the `needs-ci-full` label is present.
32
+ # Schedule and workflow_dispatch always run.
33
+ if: >-
34
+ github.event_name != 'pull_request' ||
35
+ contains(github.event.pull_request.labels.*.name, 'needs-ci-full') ||
36
+ (github.event.action == 'labeled' && github.event.label.name == 'needs-ci-full')
37
+ runs-on: ubuntu-latest
38
+ strategy:
39
+ fail-fast: false
40
+ matrix:
41
+ node: [18, 22]
42
+
43
+ steps:
44
+ - name: Checkout
45
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46
+
47
+ - name: Setup Node
48
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
49
+ with:
50
+ node-version: ${{ matrix.node }}
51
+
52
+ # Replace below with your build/test/lint steps. Keep them parallel
53
+ # to `ci.yml` so the weekly matrix matches what runs per-PR.
54
+ - name: Project verification placeholder
55
+ run: echo "Replace this step with your build/test/lint commands."
@@ -0,0 +1,56 @@
1
+ # Budget-friendly CI default for gitguardex-managed projects.
2
+ #
3
+ # Four trims keep Actions minutes low while agent branches iterate:
4
+ # 1. `concurrency: cancel-in-progress` — rapid pushes to the same ref
5
+ # kill the prior run instead of letting both finish.
6
+ # 2. Job-level `if: pull_request.draft == false` plus the
7
+ # `ready_for_review` PR trigger — draft PRs skip CI, and CI fires
8
+ # automatically the moment the PR is promoted out of draft.
9
+ # 3. `paths-ignore` for docs / openspec / template-only changes —
10
+ # skip CI on changes that don't affect runtime behavior.
11
+ # 4. No `push: main` trigger — branch-protection-required PR runs
12
+ # already cover correctness, and post-merge CI on main is pure
13
+ # duplication. Use `workflow_dispatch` for ad-hoc full runs.
14
+ #
15
+ # Copy this file to `.github/workflows/ci.yml` in your project and
16
+ # replace the placeholder `steps:` block with your build/test/lint
17
+ # commands.
18
+
19
+ name: CI
20
+
21
+ on:
22
+ pull_request:
23
+ branches:
24
+ - main
25
+ types: [opened, reopened, synchronize, ready_for_review]
26
+ paths-ignore:
27
+ - '**/*.md'
28
+ - 'docs/**'
29
+ - 'openspec/**'
30
+ - '.github/ISSUE_TEMPLATE/**'
31
+ - '.github/PULL_REQUEST_TEMPLATE.md'
32
+ - '.changeset/**'
33
+ workflow_dispatch:
34
+
35
+ permissions:
36
+ contents: read
37
+
38
+ concurrency:
39
+ group: ci-${{ github.workflow }}-${{ github.ref }}
40
+ cancel-in-progress: true
41
+
42
+ jobs:
43
+ build:
44
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49
+
50
+ # Replace below with your build/test/lint steps. Examples:
51
+ # - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
52
+ # with: { node-version: '20' }
53
+ # - run: npm ci
54
+ # - run: npm test
55
+ - name: Project verification placeholder
56
+ run: echo "Replace this step with your build/test/lint commands."
@@ -2,14 +2,33 @@ name: Code Review
2
2
 
3
3
  on:
4
4
  pull_request:
5
- types: [opened, reopened, synchronize]
5
+ types: [opened, reopened, synchronize, ready_for_review, labeled]
6
6
 
7
7
  permissions:
8
8
  contents: read
9
9
  pull-requests: write
10
10
 
11
+ # Budget-friendly default for gitguardex-managed projects: cancel
12
+ # superseded runs on the same PR so rapid agent pushes don't fan-out
13
+ # the OpenAI bill.
14
+ concurrency:
15
+ group: cr-${{ github.workflow }}-${{ github.event.pull_request.number }}
16
+ cancel-in-progress: true
17
+
11
18
  jobs:
12
19
  review:
20
+ # Skip on draft PRs and on `agent/*` head branches by default.
21
+ # Agent PRs can opt-in by applying the `needs-review` label —
22
+ # useful for the occasional agent PR that genuinely needs AI
23
+ # eyes (security-sensitive change, public-API redesign, etc.).
24
+ # Human-authored PRs (any non-`agent/*` head branch) always run.
25
+ if: >-
26
+ github.event.pull_request.draft == false &&
27
+ (
28
+ !startsWith(github.event.pull_request.head.ref, 'agent/') ||
29
+ contains(github.event.pull_request.labels.*.name, 'needs-review') ||
30
+ (github.event.action == 'labeled' && github.event.label.name == 'needs-review')
31
+ )
13
32
  runs-on: ubuntu-latest
14
33
  env:
15
34
  OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}