Skip to content

Commit eef218f

Browse files
committed
fix: add {SCRIPT} invocation to levelup commands for proper script execution
- Add Phase 0 (Environment Setup) to spec, clarify, skills, and implement commands - Each command now properly invokes {SCRIPT} to get paths from setup-levelup.sh - Remove obsolete levelup scripts from main scripts/ folder (now in extension) - Use CDR_FILE, TEAM_DIRECTIVES, SKILLS_DRAFTS from script JSON output - Extension is now fully self-contained with working script references
1 parent 4d81adf commit eef218f

9 files changed

Lines changed: 238 additions & 1089 deletions

File tree

extensions/levelup/commands/clarify.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,32 @@ You are acting as a **Context Validator** reviewing discovered patterns. Your ro
6767

6868
## Execution Steps
6969

70+
### Phase 0: Environment Setup
71+
72+
**Objective**: Initialize CDR infrastructure and resolve paths
73+
74+
Run `{SCRIPT}` from repository root and parse JSON output:
75+
76+
```json
77+
{
78+
"REPO_ROOT": "/path/to/project",
79+
"CDR_FILE": "/path/to/project/.specify/memory/cdr.md",
80+
"TEAM_DIRECTIVES": "/path/to/team-ai-directives",
81+
"TEAM_DIRECTIVES_EXISTS": true,
82+
"SKILLS_DRAFTS": "/path/to/project/.specify/drafts/skills",
83+
"BRANCH": "current-branch"
84+
}
85+
```
86+
87+
**IMPORTANT**: Run this script only ONCE. Use the JSON output to get all paths.
88+
7089
### Phase 1: Load Current State
7190

7291
**Objective**: Load CDRs and team-ai-directives for validation
7392

7493
#### Step 1: Load CDRs
7594

76-
Read `.specify/memory/cdr.md` and parse all CDRs.
95+
Read CDR_FILE (from script output) and parse all CDRs.
7796

7897
Filter CDRs by status:
7998
- **Primary**: Status = "Discovered" or "Proposed"
@@ -83,7 +102,7 @@ If user specified specific CDR IDs, filter to those.
83102

84103
#### Step 2: Load Team Directives
85104

86-
Load existing team-ai-directives for comparison:
105+
If TEAM_DIRECTIVES_EXISTS is true, load existing team-ai-directives for comparison:
87106
- `context_modules/constitution.md`
88107
- `context_modules/rules/**/*.md`
89108
- `context_modules/personas/*.md`
@@ -219,7 +238,7 @@ If content needs revision:
219238

220239
#### Step 1: Update CDR File
221240

222-
For each clarified CDR:
241+
Update CDR_FILE (from script output) for each clarified CDR:
223242

224243
1. Update status
225244
2. Update content if revised

extensions/levelup/commands/implement.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,45 @@ Before running:
6060

6161
## Execution Steps
6262

63+
### Phase 0: Environment Setup
64+
65+
**Objective**: Initialize CDR infrastructure and resolve paths
66+
67+
Run `{SCRIPT}` from repository root and parse JSON output:
68+
69+
```json
70+
{
71+
"REPO_ROOT": "/path/to/project",
72+
"CDR_FILE": "/path/to/project/.specify/memory/cdr.md",
73+
"TEAM_DIRECTIVES": "/path/to/team-ai-directives",
74+
"TEAM_DIRECTIVES_EXISTS": true,
75+
"SKILLS_DRAFTS": "/path/to/project/.specify/drafts/skills",
76+
"BRANCH": "current-branch"
77+
}
78+
```
79+
80+
**IMPORTANT**: Run this script only ONCE. Use the JSON output to get all paths.
81+
6382
### Phase 1: Validate Environment
6483

6584
**Objective**: Ensure prerequisites are met
6685

67-
#### Step 1: Resolve Team Directives Path
86+
#### Step 1: Verify Team Directives
6887

69-
```bash
70-
TEAM_DIRECTIVES="${SPECIFY_TEAM_DIRECTIVES:-}"
71-
if [[ -z "$TEAM_DIRECTIVES" ]]; then
72-
if [[ -d ".specify/team-ai-directives" ]]; then
73-
TEAM_DIRECTIVES=".specify/team-ai-directives"
74-
elif [[ -d ".specify/memory/team-ai-directives" ]]; then
75-
TEAM_DIRECTIVES=".specify/memory/team-ai-directives"
76-
fi
77-
fi
78-
```
88+
Check TEAM_DIRECTIVES_EXISTS from script output.
7989

80-
If not found, **STOP**:
90+
If false, **STOP**:
8191
```
8292
Team AI directives repository not found.
8393
Run: specify init --team-ai-directives <path-or-url>
8494
```
8595

8696
#### Step 2: Check Working Tree
8797

98+
Use TEAM_DIRECTIVES from script output:
99+
88100
```bash
89-
cd "$TEAM_DIRECTIVES"
101+
cd "{TEAM_DIRECTIVES}"
90102
git status --porcelain
91103
```
92104

@@ -98,7 +110,7 @@ Please commit or stash changes before running /levelup.implement.
98110

99111
#### Step 3: Load Accepted CDRs
100112

101-
Read `.specify/memory/cdr.md` and filter:
113+
Read CDR_FILE (from script output) and filter:
102114
- Status = "Accepted"
103115

104116
If no accepted CDRs, **STOP**:
@@ -181,13 +193,13 @@ CDR: {CDR-ID}
181193

182194
#### Step 4: Process Draft Skills
183195

184-
If `.specify/drafts/skills/` contains skills (and not `--skip-skills`):
196+
If SKILLS_DRAFTS (from script output) contains skills (and not `--skip-skills`):
185197

186198
1. Copy skill directory to `{TEAM_DIRECTIVES}/skills/`
187199
2. Read `.skills-entry.json` and merge into `.skills.json`
188200

189201
```bash
190-
cp -r .specify/drafts/skills/{skill-name} "$TEAM_DIRECTIVES/skills/"
202+
cp -r {SKILLS_DRAFTS}/{skill-name} "{TEAM_DIRECTIVES}/skills/"
191203
```
192204

193205
Update `.skills.json`:
@@ -316,7 +328,7 @@ MCP tools not available. Create PR manually:
316328

317329
**Objective**: Mark CDRs as implemented
318330

319-
Update `.specify/memory/cdr.md`:
331+
Update CDR_FILE (from script output):
320332

321333
For each implemented CDR:
322334
- Change status: "Accepted" → "Implemented"

extensions/levelup/commands/skills.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,27 @@ Skills follow the team-ai-directives format:
8585

8686
## Execution Steps
8787

88+
### Phase 0: Environment Setup
89+
90+
**Objective**: Initialize CDR infrastructure and resolve paths
91+
92+
Run `{SCRIPT}` from repository root and parse JSON output:
93+
94+
```json
95+
{
96+
"REPO_ROOT": "/path/to/project",
97+
"CDR_FILE": "/path/to/project/.specify/memory/cdr.md",
98+
"TEAM_DIRECTIVES": "/path/to/team-ai-directives",
99+
"TEAM_DIRECTIVES_EXISTS": true,
100+
"SKILLS_DRAFTS": "/path/to/project/.specify/drafts/skills",
101+
"BRANCH": "current-branch"
102+
}
103+
```
104+
105+
**IMPORTANT**: Run this script only ONCE. Use the JSON output to get all paths.
106+
107+
Skills will be created in SKILLS_DRAFTS directory.
108+
88109
### Phase 1: Parse User Input
89110

90111
**Objective**: Determine which skill to build
@@ -105,7 +126,7 @@ If input is ambiguous, ask for clarification.
105126

106127
#### Step 1: Load CDRs
107128

108-
Read `.specify/memory/cdr.md` and filter:
129+
Read CDR_FILE (from script output) and filter:
109130
- Status = "Accepted"
110131
- Context Type = "Skill" (primary) or related types
111132

@@ -139,8 +160,10 @@ Proceed with these CDRs? (Y/N or specify different CDRs)
139160

140161
#### Step 1: Create Directory
141162

163+
Use SKILLS_DRAFTS from script output:
164+
142165
```bash
143-
mkdir -p .specify/drafts/skills/{skill-name}/references
166+
mkdir -p {SKILLS_DRAFTS}/{skill-name}/references
144167
```
145168

146169
#### Step 2: Generate SKILL.md

extensions/levelup/commands/spec.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,34 @@ If no feature context available, the command will note this and provide limited
6060

6161
## Execution Steps
6262

63+
### Phase 0: Environment Setup
64+
65+
**Objective**: Initialize CDR infrastructure and resolve paths
66+
67+
Run `{SCRIPT}` from repository root and parse JSON output:
68+
69+
```json
70+
{
71+
"REPO_ROOT": "/path/to/project",
72+
"CDR_FILE": "/path/to/project/.specify/memory/cdr.md",
73+
"TEAM_DIRECTIVES": "/path/to/team-ai-directives",
74+
"TEAM_DIRECTIVES_EXISTS": true,
75+
"SKILLS_DRAFTS": "/path/to/project/.specify/drafts/skills",
76+
"BRANCH": "feature/001-user-auth"
77+
}
78+
```
79+
80+
**IMPORTANT**: Run this script only ONCE. Use the JSON output to get all paths.
81+
82+
If `TEAM_DIRECTIVES_EXISTS` is false, warn user but continue (CDR enrichment still works).
83+
6384
### Phase 1: Load Feature Context
6485

6586
**Objective**: Load current feature artifacts
6687

6788
#### Step 1: Detect Feature Branch
6889

69-
Detect current feature from:
90+
Use BRANCH from script output, or detect from:
7091
1. Git branch name (e.g., `feature/001-user-auth`)
7192
2. `SPECIFY_FEATURE` environment variable
7293
3. User-provided feature name
@@ -89,7 +110,7 @@ If artifacts are missing, note which are unavailable.
89110

90111
**Objective**: Load CDRs to refine
91112

92-
Read `.specify/memory/cdr.md` and filter:
113+
Read CDR_FILE (from script output) and filter:
93114
- Status = "Discovered" or "Proposed"
94115
- Match user-specified CDR IDs if provided
95116

@@ -162,7 +183,7 @@ Append evidence to CDR:
162183

163184
**Objective**: Write enriched CDRs to file
164185

165-
Update `.specify/memory/cdr.md` with:
186+
Update CDR_FILE (from script output) with:
166187
- Added evidence sections
167188
- Updated "Date" field
168189
- Note about enrichment source

0 commit comments

Comments
 (0)