@imdeadpool/guardex 6.0.0 → 6.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.
@@ -1,16 +1,39 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
+ soft=0
5
+ for arg in "$@"; do
6
+ case "$arg" in
7
+ --soft) soft=1 ;;
8
+ esac
9
+ done
10
+
11
+ soft_exit() {
12
+ if [[ "$soft" -eq 1 ]]; then
13
+ exit 0
14
+ fi
15
+ exit 1
16
+ }
17
+
4
18
  repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
5
19
  if [[ -z "$repo_root" ]]; then
6
- echo "[install-agent-git-hooks] Not inside a git repository." >&2
7
- exit 1
20
+ if [[ "$soft" -eq 0 ]]; then
21
+ echo "[install-agent-git-hooks] Not inside a git repository." >&2
22
+ fi
23
+ soft_exit
8
24
  fi
9
25
 
10
26
  hooks_dir="$repo_root/.githooks"
11
27
  if [[ ! -d "$hooks_dir" ]]; then
12
- echo "[install-agent-git-hooks] Missing hooks directory: $hooks_dir" >&2
13
- exit 1
28
+ if [[ "$soft" -eq 0 ]]; then
29
+ echo "[install-agent-git-hooks] Missing hooks directory: $hooks_dir" >&2
30
+ fi
31
+ soft_exit
32
+ fi
33
+
34
+ current_hooks_path="$(git -C "$repo_root" config --get core.hooksPath 2>/dev/null || true)"
35
+ if [[ "$soft" -eq 1 && "$current_hooks_path" == ".githooks" ]]; then
36
+ exit 0
14
37
  fi
15
38
 
16
39
  chmod +x "$hooks_dir"/* 2>/dev/null || true
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- if [[ $# -lt 1 || $# -gt 2 ]]; then
5
- echo "Usage: $0 <change-slug> [capability-slug]"
6
- echo "Example: $0 add-dashboard-live-usage runtime-migration"
4
+ if [[ $# -lt 1 || $# -gt 3 ]]; then
5
+ echo "Usage: $0 <change-slug> [capability-slug] [agent-branch]"
6
+ echo "Example: $0 add-dashboard-live-usage runtime-migration agent/claude-odin/add-dashboard-live-usage-123456"
7
7
  exit 1
8
8
  fi
9
9
 
10
10
  CHANGE_SLUG="$1"
11
11
  CAPABILITY_SLUG="${2:-$CHANGE_SLUG}"
12
+ AGENT_BRANCH="${3:-agent/<your-name>/<branch-slug>}"
12
13
 
13
14
  if [[ "$CHANGE_SLUG" =~ [^a-z0-9-] ]]; then
14
15
  echo "Error: change slug must be kebab-case (lowercase letters, numbers, hyphens)."
@@ -24,7 +25,17 @@ CHANGE_DIR="openspec/changes/${CHANGE_SLUG}"
24
25
  SPEC_DIR="${CHANGE_DIR}/specs/${CAPABILITY_SLUG}"
25
26
  TODAY="$(date -u +%Y-%m-%d)"
26
27
 
27
- mkdir -p "$SPEC_DIR"
28
+ MINIMAL_RAW="${GUARDEX_OPENSPEC_MINIMAL:-0}"
29
+ case "$(printf '%s' "$MINIMAL_RAW" | tr '[:upper:]' '[:lower:]')" in
30
+ 1|true|yes|on) MINIMAL=1 ;;
31
+ *) MINIMAL=0 ;;
32
+ esac
33
+
34
+ if [[ "$MINIMAL" -eq 1 ]]; then
35
+ mkdir -p "$CHANGE_DIR"
36
+ else
37
+ mkdir -p "$SPEC_DIR"
38
+ fi
28
39
 
29
40
  if [[ ! -f "${CHANGE_DIR}/.openspec.yaml" ]]; then
30
41
  cat > "${CHANGE_DIR}/.openspec.yaml" <<YAMLEOF
@@ -33,6 +44,27 @@ created: ${TODAY}
33
44
  YAMLEOF
34
45
  fi
35
46
 
47
+ if [[ "$MINIMAL" -eq 1 ]]; then
48
+ if [[ ! -f "${CHANGE_DIR}/notes.md" ]]; then
49
+ cat > "${CHANGE_DIR}/notes.md" <<NOTESEOF
50
+ # ${CHANGE_SLUG} (minimal / T1)
51
+
52
+ Branch: \`${AGENT_BRANCH}\`
53
+
54
+ Describe the change in a sentence or two. Commit message is the spec of record.
55
+
56
+ ## Cleanup
57
+
58
+ - [ ] Run: \`bash scripts/agent-branch-finish.sh --branch ${AGENT_BRANCH} --base dev --via-pr --wait-for-merge --cleanup\`
59
+ - [ ] Record PR URL + \`MERGED\` state in the completion handoff.
60
+ - [ ] Confirm sandbox worktree is gone (\`git worktree list\`, \`git branch -a\`).
61
+ NOTESEOF
62
+ fi
63
+ echo "[guardex] OpenSpec change workspace (minimal) ready: ${CHANGE_DIR}"
64
+ echo "[guardex] Notes-only scaffold: ${CHANGE_DIR}/notes.md"
65
+ exit 0
66
+ fi
67
+
36
68
  if [[ ! -f "${CHANGE_DIR}/proposal.md" ]]; then
37
69
  cat > "${CHANGE_DIR}/proposal.md" <<PROPOSALEOF
38
70
  ## Why
@@ -51,6 +83,14 @@ fi
51
83
 
52
84
  if [[ ! -f "${CHANGE_DIR}/tasks.md" ]]; then
53
85
  cat > "${CHANGE_DIR}/tasks.md" <<TASKSEOF
86
+ ## Definition of Done
87
+
88
+ This change is complete only when **all** of the following are true:
89
+
90
+ - Every checkbox below is checked.
91
+ - The agent branch reaches \`MERGED\` state on \`origin\` and the PR URL + state are recorded in the completion handoff.
92
+ - If any step blocks (test failure, conflict, ambiguous result), append a \`BLOCKED:\` line under section 4 explaining the blocker and **STOP**. Do not tick remaining cleanup boxes; do not silently skip the cleanup pipeline.
93
+
54
94
  ## 1. Specification
55
95
 
56
96
  - [ ] 1.1 Finalize proposal scope and acceptance criteria for \`${CHANGE_SLUG}\`.
@@ -66,6 +106,12 @@ if [[ ! -f "${CHANGE_DIR}/tasks.md" ]]; then
66
106
  - [ ] 3.1 Run targeted project verification commands.
67
107
  - [ ] 3.2 Run \`openspec validate ${CHANGE_SLUG} --type change --strict\`.
68
108
  - [ ] 3.3 Run \`openspec validate --specs\`.
109
+
110
+ ## 4. Cleanup (mandatory; run before claiming completion)
111
+
112
+ - [ ] 4.1 Run the cleanup pipeline: \`bash scripts/agent-branch-finish.sh --branch ${AGENT_BRANCH} --base dev --via-pr --wait-for-merge --cleanup\`. This handles commit -> push -> PR create -> merge wait -> worktree prune in one invocation.
113
+ - [ ] 4.2 Record the PR URL and final merge state (\`MERGED\`) in the completion handoff.
114
+ - [ ] 4.3 Confirm the sandbox worktree is gone (\`git worktree list\` no longer shows the agent path; \`git branch -a\` shows no surviving local/remote refs for the branch).
69
115
  TASKSEOF
70
116
  fi
71
117