Skip to content

Commit 18c4ac1

Browse files
NagyViktNagyVikt
andauthored
Align downstream OpenSpec scaffolds with recodee bootstrap (#247)
Sync the setup-managed change and plan helpers to the richer recodee versions and lock the new scaffold shape with install regressions. Constraint: gx setup should install the same OpenSpec helper behavior already used in recodee Rejected: Update only templates | runtime/template drift would break parity guarantees Rejected: Copy the recodee plan scaffold verbatim without fixes | unescaped backticks corrupted generated cleanup text Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep scripts/openspec and templates/scripts/openspec in lockstep with frontend mirrors and install tests Tested: node --test --test-name-pattern OpenSpec test/install.test.js; node --test test/metadata.test.js; node --check bin/multiagent-safety.js; openspec validate agent-codex-sync-recodee-openspec-bootstrap-into-gx-2026-04-21-17-20 --type change --strict; openspec validate --specs; git diff --check Not-tested: Full npm test suite Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent f3c5707 commit 18c4ac1

11 files changed

Lines changed: 2025 additions & 280 deletions

File tree

frontend/scripts/openspec/init-change-workspace.sh

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

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"
77
exit 1
88
fi
99

1010
CHANGE_SLUG="$1"
1111
CAPABILITY_SLUG="${2:-$CHANGE_SLUG}"
12+
AGENT_BRANCH="${3:-agent/<your-name>/<branch-slug>}"
1213

1314
if [[ "$CHANGE_SLUG" =~ [^a-z0-9-] ]]; then
1415
echo "Error: change slug must be kebab-case (lowercase letters, numbers, hyphens)."
@@ -24,7 +25,17 @@ CHANGE_DIR="openspec/changes/${CHANGE_SLUG}"
2425
SPEC_DIR="${CHANGE_DIR}/specs/${CAPABILITY_SLUG}"
2526
TODAY="$(date -u +%Y-%m-%d)"
2627

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
2839

2940
if [[ ! -f "${CHANGE_DIR}/.openspec.yaml" ]]; then
3041
cat > "${CHANGE_DIR}/.openspec.yaml" <<YAMLEOF
@@ -33,6 +44,27 @@ created: ${TODAY}
3344
YAMLEOF
3445
fi
3546

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+
3668
if [[ ! -f "${CHANGE_DIR}/proposal.md" ]]; then
3769
cat > "${CHANGE_DIR}/proposal.md" <<PROPOSALEOF
3870
## Why
@@ -51,6 +83,14 @@ fi
5183

5284
if [[ ! -f "${CHANGE_DIR}/tasks.md" ]]; then
5385
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+
5494
## 1. Specification
5595
5696
- [ ] 1.1 Finalize proposal scope and acceptance criteria for \`${CHANGE_SLUG}\`.
@@ -67,11 +107,11 @@ if [[ ! -f "${CHANGE_DIR}/tasks.md" ]]; then
67107
- [ ] 3.2 Run \`openspec validate ${CHANGE_SLUG} --type change --strict\`.
68108
- [ ] 3.3 Run \`openspec validate --specs\`.
69109
70-
## 4. Cleanup
110+
## 4. Cleanup (mandatory; run before claiming completion)
71111
72-
- [ ] 4.1 Finish the agent branch via PR merge + cleanup (\`gx finish --via-pr --wait-for-merge --cleanup\` or \`bash scripts/agent-branch-finish.sh --branch <agent-branch> --base <base-branch> --via-pr --wait-for-merge --cleanup\`).
73-
- [ ] 4.2 Record PR URL + final \`MERGED\` state in the completion handoff.
74-
- [ ] 4.3 Confirm sandbox cleanup (\`git worktree list\`, \`git branch -a\`) or capture a \`BLOCKED:\` handoff if merge/cleanup is pending.
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).
75115
TASKSEOF
76116
fi
77117

@@ -89,5 +129,5 @@ The system SHALL enforce ${CAPABILITY_SLUG} behavior as defined by this change.
89129
SPECEOF
90130
fi
91131

92-
echo "[gitguardex] OpenSpec change workspace ready: ${CHANGE_DIR}"
93-
echo "[gitguardex] OpenSpec change spec scaffold: ${SPEC_DIR}/spec.md"
132+
echo "[guardex] OpenSpec change workspace ready: ${CHANGE_DIR}"
133+
echo "[guardex] OpenSpec change spec scaffold: ${SPEC_DIR}/spec.md"

0 commit comments

Comments
 (0)