@imdeadpool/guardex 7.1.1 → 8.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.
- package/README.md +115 -324
- package/package.json +23 -5
- package/skills/gitguardex/SKILL.md +83 -3
- package/src/agents/finish.js +15 -0
- package/src/ci-init/index.js +0 -1
- package/src/cli/args.js +137 -3
- package/src/cli/commands/branch.js +267 -14
- package/src/cli/commands/claude.js +15 -0
- package/src/cli/commands/doctor.js +26 -0
- package/src/cli/commands/onboard.js +293 -0
- package/src/cli/commands/prompt.js +15 -3
- package/src/cli/commands/review.js +18 -0
- package/src/cli/commands/setup.js +8 -6
- package/src/cli/commands/status.js +12 -0
- package/src/cli/main.js +2 -0
- package/src/cli/shared-locks.js +304 -0
- package/src/context.js +21 -3
- package/src/core/runtime.js +33 -1
- package/src/doctor/index.js +58 -5
- package/src/finish/heartbeat.js +169 -0
- package/src/finish/index.js +106 -4
- package/src/finish/progress.js +262 -0
- package/src/finish/review-gate.js +453 -32
- package/src/github-api.js +59 -0
- package/src/mcp/collect.js +87 -12
- package/src/output/index.js +210 -0
- package/src/pr-checks.js +121 -0
- package/src/pr-review.js +581 -51
- package/src/pr.js +143 -21
- package/src/provider-binary.js +101 -0
- package/src/review-diff.js +116 -0
- package/src/review-fix.js +229 -0
- package/src/sandbox/index.js +11 -5
- package/src/scaffold/index.js +4 -16
- package/src/shared-git-state.js +566 -0
- package/templates/AGENTS.multiagent-safety.md +63 -11
- package/templates/AGENTS.multiagent-safety.min.md +1 -0
- package/templates/codex/skills/gitguardex/SKILL.md +83 -3
- package/templates/githooks/post-checkout +4 -9
- package/templates/githooks/pre-commit +17 -1
- package/templates/github/workflows/README.md +30 -23
- package/templates/scripts/agent-autofinish-watch.sh +280 -0
- package/templates/scripts/agent-branch-finish.sh +354 -23
- package/templates/scripts/agent-branch-start.sh +49 -22
- package/templates/scripts/agent-claude-stop-finish.sh +194 -0
- package/templates/scripts/agent-file-locks.py +167 -24
- package/templates/scripts/agent-preflight.sh +14 -2
- package/templates/scripts/agent-stalled-report.sh +40 -0
- package/templates/scripts/codex-agent.sh +10 -63
- package/templates/github/workflows/cr.yml +0 -46
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Quiet wrapper around scripts/agent-autofinish-watch.sh that surfaces stalled
|
|
3
|
+
# agent/* worktrees. Prints nothing when everything's clean; prints a one-line
|
|
4
|
+
# summary per stalled worktree + a finish hint when there's work to recover.
|
|
5
|
+
#
|
|
6
|
+
# Designed to be wired as a SessionStart hook so Claude Code (and the user)
|
|
7
|
+
# learn about half-finished codex/claude agent runs at the top of each session.
|
|
8
|
+
#
|
|
9
|
+
# Exit codes:
|
|
10
|
+
# 0 — no stalled worktrees (or watcher missing — soft fail)
|
|
11
|
+
# 0 — even when stalled worktrees ARE detected (this is informational, not a hard error)
|
|
12
|
+
|
|
13
|
+
set -euo pipefail
|
|
14
|
+
|
|
15
|
+
repo_root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
16
|
+
watcher="${repo_root}/scripts/agent-autofinish-watch.sh"
|
|
17
|
+
|
|
18
|
+
if [[ ! -x "$watcher" ]]; then
|
|
19
|
+
exit 0
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
raw_output="$(bash "$watcher" --once --dry-run 2>&1 || true)"
|
|
23
|
+
|
|
24
|
+
# Filter to per-worktree status lines only ("[agent-autofinish-watch] agent/<branch>: ...").
|
|
25
|
+
stalled_lines="$(printf '%s\n' "$raw_output" | grep -E '^\[agent-autofinish-watch\] agent/' || true)"
|
|
26
|
+
|
|
27
|
+
if [[ -z "$stalled_lines" ]]; then
|
|
28
|
+
exit 0
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
stalled_count="$(printf '%s\n' "$stalled_lines" | wc -l | tr -d ' ')"
|
|
32
|
+
|
|
33
|
+
printf '⚠ Stalled agent worktrees detected (%s):\n' "$stalled_count"
|
|
34
|
+
printf '%s\n' "$stalled_lines" | sed 's/^\[agent-autofinish-watch\] / • /'
|
|
35
|
+
printf '\nResolve options:\n'
|
|
36
|
+
printf ' • Inspect: bash scripts/agent-autofinish-watch.sh --once --dry-run\n'
|
|
37
|
+
printf ' • Auto-finish: bash scripts/agent-autofinish-watch.sh --once --auto-merge\n'
|
|
38
|
+
printf ' • Run daemon: bash scripts/agent-autofinish-watch.sh --daemon --auto-merge\n'
|
|
39
|
+
|
|
40
|
+
exit 0
|
|
@@ -58,7 +58,7 @@ normalize_bool() {
|
|
|
58
58
|
|
|
59
59
|
normalize_tier() {
|
|
60
60
|
local raw="${1:-}"
|
|
61
|
-
local fallback="${2:-
|
|
61
|
+
local fallback="${2:-T1}"
|
|
62
62
|
local upper
|
|
63
63
|
upper="$(printf '%s' "$raw" | tr '[:lower:]' '[:upper:]')"
|
|
64
64
|
case "$upper" in
|
|
@@ -91,36 +91,6 @@ build_codex_launch_args() {
|
|
|
91
91
|
CODEX_LAUNCH_ARGS+=("$@")
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
string_contains_any() {
|
|
95
|
-
local haystack="$1"
|
|
96
|
-
shift
|
|
97
|
-
local needle
|
|
98
|
-
for needle in "$@"; do
|
|
99
|
-
if [[ "$haystack" == *"$needle"* ]]; then
|
|
100
|
-
return 0
|
|
101
|
-
fi
|
|
102
|
-
done
|
|
103
|
-
return 1
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
string_has_lightweight_prefix() {
|
|
107
|
-
local text="$1"
|
|
108
|
-
local prefix
|
|
109
|
-
for prefix in "quick:" "simple:" "tiny:" "minor:" "small:" "just:" "only:"; do
|
|
110
|
-
if [[ "$text" == "$prefix"* ]]; then
|
|
111
|
-
return 0
|
|
112
|
-
fi
|
|
113
|
-
done
|
|
114
|
-
return 1
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
task_requires_full_change_workspace() {
|
|
118
|
-
local text="$1"
|
|
119
|
-
string_contains_any "$text" \
|
|
120
|
-
"cleanup evidence" "merged cleanup" "merged state" "pr url" \
|
|
121
|
-
"cleanup pipeline" "finish pipeline" "sandbox cleanup" "tasks.md"
|
|
122
|
-
}
|
|
123
|
-
|
|
124
94
|
derive_task_mode_from_tier() {
|
|
125
95
|
case "$1" in
|
|
126
96
|
T0|T1) printf 'caveman' ;;
|
|
@@ -139,8 +109,8 @@ apply_openspec_tier() {
|
|
|
139
109
|
OPENSPEC_SKIP_PLAN=1
|
|
140
110
|
;;
|
|
141
111
|
T1)
|
|
112
|
+
OPENSPEC_SKIP_CHANGE=1
|
|
142
113
|
OPENSPEC_SKIP_PLAN=1
|
|
143
|
-
OPENSPEC_MINIMAL=1
|
|
144
114
|
;;
|
|
145
115
|
T2)
|
|
146
116
|
OPENSPEC_SKIP_PLAN=1
|
|
@@ -149,40 +119,15 @@ apply_openspec_tier() {
|
|
|
149
119
|
}
|
|
150
120
|
|
|
151
121
|
decide_task_routing() {
|
|
152
|
-
local task_lower
|
|
153
|
-
task_lower="$(printf '%s' "$TASK_NAME" | tr '[:upper:]' '[:lower:]')"
|
|
154
|
-
|
|
155
122
|
if [[ -n "$OPENSPEC_TIER_RAW" ]]; then
|
|
156
|
-
if ! OPENSPEC_TIER="$(normalize_tier "$OPENSPEC_TIER_RAW" "
|
|
123
|
+
if ! OPENSPEC_TIER="$(normalize_tier "$OPENSPEC_TIER_RAW" "T1")"; then
|
|
157
124
|
echo "[codex-agent] Unsupported OpenSpec tier: ${OPENSPEC_TIER_RAW}" >&2
|
|
158
125
|
return 1
|
|
159
126
|
fi
|
|
160
127
|
TASK_ROUTING_REASON="explicit tier override"
|
|
161
|
-
elif string_has_lightweight_prefix "$task_lower"; then
|
|
162
|
-
if task_requires_full_change_workspace "$task_lower"; then
|
|
163
|
-
OPENSPEC_TIER="T2"
|
|
164
|
-
TASK_ROUTING_REASON="cleanup-evidence artifact wording overrides lightweight prefix"
|
|
165
|
-
else
|
|
166
|
-
OPENSPEC_TIER="T1"
|
|
167
|
-
TASK_ROUTING_REASON="explicit lightweight prefix"
|
|
168
|
-
fi
|
|
169
|
-
elif string_contains_any "$task_lower" \
|
|
170
|
-
"ralph" "autopilot" "ultrawork" "ultraqa" "ralplan" "deep interview" "ouroboros" \
|
|
171
|
-
"migration" "refactor" "architecture" "re-architect" "cross-cutting" "multi-agent" \
|
|
172
|
-
"multiagent" "parallel" "orchestr" "release" "zero-copy" "install surface" "workflow"
|
|
173
|
-
then
|
|
174
|
-
OPENSPEC_TIER="T3"
|
|
175
|
-
TASK_ROUTING_REASON="plan-heavy or orchestration-heavy task wording"
|
|
176
|
-
elif string_contains_any "$task_lower" \
|
|
177
|
-
"typo" "spelling" "comment-only" "comment only" "format-only" "format only" \
|
|
178
|
-
"whitespace" "one-liner" "one liner" "version bump" "bump version" \
|
|
179
|
-
"single-file" "single file"
|
|
180
|
-
then
|
|
181
|
-
OPENSPEC_TIER="T1"
|
|
182
|
-
TASK_ROUTING_REASON="small bounded maintenance wording"
|
|
183
128
|
else
|
|
184
|
-
OPENSPEC_TIER="
|
|
185
|
-
TASK_ROUTING_REASON="default
|
|
129
|
+
OPENSPEC_TIER="T1"
|
|
130
|
+
TASK_ROUTING_REASON="default direct-execution route; OpenSpec requires --tier T2 or T3"
|
|
186
131
|
fi
|
|
187
132
|
|
|
188
133
|
if ! TASK_MODE="$(derive_task_mode_from_tier "$OPENSPEC_TIER")"; then
|
|
@@ -195,7 +140,7 @@ decide_task_routing() {
|
|
|
195
140
|
describe_task_routing() {
|
|
196
141
|
case "$OPENSPEC_TIER" in
|
|
197
142
|
T0) printf 'caveman / T0 (no OpenSpec scaffold)' ;;
|
|
198
|
-
T1) printf 'caveman / T1 (
|
|
143
|
+
T1) printf 'caveman / T1 (no OpenSpec scaffold)' ;;
|
|
199
144
|
T2) printf 'omx / T2 (change workspace only)' ;;
|
|
200
145
|
T3) printf 'omx / T3 (change plus plan workspace)' ;;
|
|
201
146
|
*) printf 'unknown / %s' "${OPENSPEC_TIER:-unset}" ;;
|
|
@@ -681,7 +626,7 @@ print_takeover_prompt() {
|
|
|
681
626
|
change_artifact="openspec/changes/${change_slug}/notes.md"
|
|
682
627
|
fi
|
|
683
628
|
if [[ ! -f "${wt}/${change_artifact}" ]]; then
|
|
684
|
-
change_artifact="
|
|
629
|
+
change_artifact=""
|
|
685
630
|
fi
|
|
686
631
|
|
|
687
632
|
finish_cmd="gx branch finish --branch \"${branch}\" --base ${base_branch} --via-pr --wait-for-merge --cleanup"
|
|
@@ -690,7 +635,9 @@ print_takeover_prompt() {
|
|
|
690
635
|
echo " change: ${change_slug}"
|
|
691
636
|
echo " branch: ${branch}"
|
|
692
637
|
echo " worktree: ${wt}"
|
|
693
|
-
|
|
638
|
+
if [[ -n "$change_artifact" ]]; then
|
|
639
|
+
echo " spec: ${change_artifact}"
|
|
640
|
+
fi
|
|
694
641
|
echo " routing: $(describe_task_routing) (${TASK_ROUTING_REASON})"
|
|
695
642
|
echo " rule: continue current state; do not create a new sandbox"
|
|
696
643
|
echo " finish: ${finish_cmd}"
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
name: Code Review
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, reopened, synchronize, ready_for_review, labeled]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
pull-requests: write
|
|
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
|
-
|
|
18
|
-
jobs:
|
|
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
|
-
)
|
|
32
|
-
runs-on: ubuntu-latest
|
|
33
|
-
env:
|
|
34
|
-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
35
|
-
steps:
|
|
36
|
-
- name: Skip when OPENAI_API_KEY is missing
|
|
37
|
-
if: ${{ env.OPENAI_API_KEY == '' }}
|
|
38
|
-
run: echo "OPENAI_API_KEY is not configured; skipping Code Review workflow."
|
|
39
|
-
|
|
40
|
-
- uses: anc95/ChatGPT-CodeReview@1e3df152c1b85c12da580b206c91ad343460c584 # v1.0.23
|
|
41
|
-
if: ${{ env.OPENAI_API_KEY != '' }}
|
|
42
|
-
env:
|
|
43
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
44
|
-
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
|
|
45
|
-
OPENAI_API_ENDPOINT: https://api.openai.com/v1
|
|
46
|
-
MODEL: gpt-4o-mini
|