5-phase-workflow 3.1.0 → 3.1.2

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 CHANGED
@@ -25,7 +25,6 @@ Then configure the project once:
25
25
 
26
26
  ```bash
27
27
  /5:configure
28
- /5:implement CONFIGURE
29
28
  ```
30
29
 
31
30
  This adds the foifi rules to `AGENTS.md` as one marked block, links your existing standards from it, and makes `CLAUDE.md` include it. Nothing else in your files or settings changes.
package/bin/install.js CHANGED
@@ -1254,8 +1254,9 @@ function removePlanningActiveMarker(dataDir) {
1254
1254
  // is shared, so performUpdate() and performCodexUpdate() both run this.
1255
1255
  function movePlansToPlanningDir(dataDir) {
1256
1256
  const featuresDir = path.join(dataDir, 'features');
1257
- if (!fs.existsSync(featuresDir)) return;
1257
+ if (!fs.existsSync(featuresDir)) return 0;
1258
1258
  const planningDir = path.join(dataDir, 'planning');
1259
+ let moved = 0;
1259
1260
  try {
1260
1261
  for (const feature of fs.readdirSync(featuresDir)) {
1261
1262
  const planFile = path.join(featuresDir, feature, 'plan.md');
@@ -1263,9 +1264,53 @@ function movePlansToPlanningDir(dataDir) {
1263
1264
  if (!fs.existsSync(planFile) || fs.existsSync(target)) continue;
1264
1265
  fs.mkdirSync(planningDir, { recursive: true });
1265
1266
  fs.renameSync(planFile, target);
1267
+ moved++;
1266
1268
  log.info(`Moved plan: features/${feature}/plan.md → planning/${feature}.md`);
1267
1269
  }
1268
1270
  } catch (e) {}
1271
+ return moved;
1272
+ }
1273
+
1274
+ // Before .5/planning/ existed, plans lived in .5/features/, so a project that git-ignored
1275
+ // .5/features/ also ignored its plans. Carry that choice over to .5/planning/, but only for
1276
+ // projects that come from that layout: plans moved by this upgrade, or an install that was
1277
+ // upgraded into 3.1.0 (whose migration moved them without this). A project configured on 3.1
1278
+ // may have chosen "Only .5/features/" on purpose; /5:configure now marks that with
1279
+ // `!.5/planning/`, and any .5/planning rule or plan tracked in git (checked before the move) is left alone.
1280
+ // Shared .5/ data, so both update paths run this.
1281
+ // True when git tracks any plan, in the old or the new location. Call it before plans move:
1282
+ // afterwards the index still lists them only under .5/features/.
1283
+ function hasTrackedPlans(dataDir) {
1284
+ try {
1285
+ return require('child_process')
1286
+ .execFileSync('git', ['ls-files', '--', '.5/features/*/plan.md', '.5/planning'],
1287
+ { cwd: path.dirname(dataDir), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
1288
+ .trim() !== '';
1289
+ } catch (e) {
1290
+ return false; // not a git checkout: nothing is tracked
1291
+ }
1292
+ }
1293
+
1294
+ function ignorePlanningLikeFeatures(dataDir, movedPlans, previousVersion, plansTracked) {
1295
+ const projectRoot = path.dirname(dataDir);
1296
+ const gitignorePath = path.join(projectRoot, '.gitignore');
1297
+ if (!fs.existsSync(gitignorePath)) return;
1298
+ try {
1299
+ if (!movedPlans) {
1300
+ if (previousVersion !== '3.1.0') return;
1301
+ // A fresh 3.1.0 install has installedAt === lastUpdated; an upgraded one does not
1302
+ const versionData = JSON.parse(fs.readFileSync(path.join(dataDir, 'version.json'), 'utf8'));
1303
+ if (!versionData.installedAt || versionData.installedAt === versionData.lastUpdated) return;
1304
+ }
1305
+ if (plansTracked) return;
1306
+ const content = fs.readFileSync(gitignorePath, 'utf8');
1307
+ const rules = content.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#'));
1308
+ const ignoresFeatures = rules.some(l => /^\/?\.5\/features\/?(\*\*?)?$/.test(l));
1309
+ const hasPlanningRule = rules.some(l => /^!?\/?\.5\/planning\/?(\*\*?)?$/.test(l));
1310
+ if (!ignoresFeatures || hasPlanningRule) return;
1311
+ fs.writeFileSync(gitignorePath, content.trimEnd() + '\n.5/planning/\n');
1312
+ log.info('Added .5/planning/ to .gitignore (plans were ignored under .5/features/)');
1313
+ } catch (e) {}
1269
1314
  }
1270
1315
 
1271
1316
  // Perform update (preserves user-created files, updates .5/ data directory)
@@ -1294,7 +1339,8 @@ function performUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
1294
1339
  removePlanningActiveMarker(dataDir);
1295
1340
 
1296
1341
  // Plans moved from .5/features/{name}/plan.md to .5/planning/{name}.md
1297
- movePlansToPlanningDir(dataDir);
1342
+ const plansTracked = hasTrackedPlans(dataDir);
1343
+ ignorePlanningLikeFeatures(dataDir, movePlansToPlanningDir(dataDir), versionInfo.installed, plansTracked);
1298
1344
 
1299
1345
  // Flag v1 → v2 major upgrade so statusline can prompt for reconfigure
1300
1346
  const prevMajor = versionInfo.installed ? parseInt(versionInfo.installed.split('.')[0], 10) : 0;
@@ -1490,7 +1536,8 @@ function performCodexUpdate(targetPath, sourcePath, isGlobal, versionInfo) {
1490
1536
  removePlanningActiveMarker(dataDir);
1491
1537
 
1492
1538
  // Plans moved from .5/features/{name}/plan.md to .5/planning/{name}.md
1493
- movePlansToPlanningDir(dataDir);
1539
+ const plansTracked = hasTrackedPlans(dataDir);
1540
+ ignorePlanningLikeFeatures(dataDir, movePlansToPlanningDir(dataDir), versionInfo.installed, plansTracked);
1494
1541
 
1495
1542
  // Flag v1 → v2 major upgrade so skills can prompt for reconfigure
1496
1543
  const prevMajor = versionInfo.installed ? parseInt(versionInfo.installed.split('.')[0], 10) : 0;
@@ -90,10 +90,9 @@ First-time setup:
90
90
 
91
91
  ```text
92
92
  /5:configure
93
- /5:implement CONFIGURE
94
93
  ```
95
94
 
96
- `/5:configure` writes `.5/config.json`, sets `plansDirectory` to `.5/planning` in `.claude/settings.json`, and writes the CONFIGURE plan. `/5:implement CONFIGURE` adds the workflow rules to AGENTS.md as one marked block that links the repository's own standards, appends `@AGENTS.md` to CLAUDE.md when it lacks that line, and generates scoped rules. Nothing outside the block changes.
95
+ `/5:configure` writes `.5/config.json`, sets `plansDirectory` to `.5/planning` in `.claude/settings.json`, writes the CONFIGURE plan, and then runs `/5:implement CONFIGURE` itself, which adds the workflow rules to AGENTS.md as one marked block that links the repository's own standards, appends `@AGENTS.md` to CLAUDE.md when it lacks that line, and generates scoped rules. Nothing outside the block changes.
97
96
 
98
97
  Refresh the AGENTS.md block and the rules later with:
99
98
 
@@ -135,5 +134,5 @@ v2.0.0 removes old commands during upgrade:
135
134
  | `/5:review` | Review changes for correctness and standards |
136
135
  | `/5:address-review-findings` | Fix clear findings, ask about real decisions |
137
136
  | `/5:analyze-feature` | Document a feature with mermaid diagrams |
138
- | `/5:configure` | Create project config and CONFIGURE plan |
137
+ | `/5:configure` | Create project config and CONFIGURE plan, then implement it |
139
138
  | `/5:reconfigure` | Refresh the AGENTS.md block and rules |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5-phase-workflow",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "A dev-workflow for Claude Code and Codex",
5
5
  "bin": {
6
6
  "foifi": "bin/install.js"
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: 5:configure
3
- description: Configures the project. Analyzes project, gathers preferences, writes config.json, points Claude Code plan mode at .5/planning/, and creates .5/planning/CONFIGURE.md. Follow up with /5:implement CONFIGURE.
4
- allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion
3
+ description: Configures the project. Analyzes project, gathers preferences, writes config.json, points Claude Code plan mode at .5/planning/, creates .5/planning/CONFIGURE.md, then runs /5:implement CONFIGURE itself.
4
+ allowed-tools: Agent, Read, Write, Edit, Glob, Grep, Bash, Workflow, Skill, AskUserQuestion
5
5
  user-invocable: true
6
6
  ---
7
7
 
8
8
  <role>
9
9
  You are a Project Configurator. You analyze a project, gather preferences, and write config.json plus a unified plan.
10
- You do NOT write AGENTS.md, CLAUDE.md, or rules directly — those are /5:implement's job.
10
+ You do NOT write AGENTS.md, CLAUDE.md, or rules directly — those are /5:implement's job, and you start it yourself once the plan is written.
11
11
  You write ONLY to: .5/config.json, .5/version.json, .5/planning/CONFIGURE.md, .gitignore, and the `plansDirectory` key of .claude/settings.json (Claude Code only).
12
- After writing config.json and the unified plan, you are DONE. Exit immediately.
12
+ After writing config.json and the unified plan, you hand off to `/5:implement CONFIGURE`.
13
13
  </role>
14
14
 
15
15
  # Configure (Project Setup Plan)
@@ -18,16 +18,11 @@ Current commit: !`git rev-parse --short HEAD 2>/dev/null || echo "none"`
18
18
 
19
19
  ## Overview
20
20
 
21
- This command prepares project configuration. It analyzes the project, asks preference questions, writes `.5/config.json`, points Claude Code plan mode at `.5/planning/`, and writes a plan at `.5/planning/CONFIGURE.md`.
22
-
23
- After running this command, proceed through the standard phases:
24
- 1. **`/5:configure`** (this command) - Create config and CONFIGURE plan
25
- 2. `/5:implement CONFIGURE` - Execute configuration (uses `configure-agents-md` and `configure-rules`)
26
- 3. `/5:review` - Review generated files if desired
21
+ This command prepares project configuration. It analyzes the project, asks preference questions, writes `.5/config.json`, points Claude Code plan mode at `.5/planning/`, writes a plan at `.5/planning/CONFIGURE.md`, and then runs `/5:implement CONFIGURE` itself, which executes the plan with `configure-agents-md` and `configure-rules` and reviews the result. The user runs only this one command.
27
22
 
28
23
  ## ⚠️ CRITICAL SCOPE CONSTRAINT
29
24
 
30
- **THIS COMMAND WRITES config.json AND CREATES THE CONFIGURE PLAN. NOTHING ELSE.**
25
+ **THIS COMMAND WRITES config.json AND CREATES THE CONFIGURE PLAN, THEN HANDS OFF TO `/5:implement CONFIGURE`. NOTHING ELSE.**
31
26
 
32
27
  Your job in this command:
33
28
  ✅ Analyze project (detect type, build commands, etc.)
@@ -35,7 +30,7 @@ Your job in this command:
35
30
  ✅ Write `.5/config.json` directly
36
31
  ✅ Set `plansDirectory` in `.claude/settings.json` (Claude Code only)
37
32
  ✅ Create the plan at `.5/planning/CONFIGURE.md` for remaining work
38
- ✅ Tell user to run /5:implement CONFIGURE
33
+ ✅ Run `/5:implement CONFIGURE` right after the plan is written
39
34
 
40
35
  Your job is NOT:
41
36
  ❌ Write AGENTS.md or CLAUDE.md directly (/5:implement does this)
@@ -43,9 +38,9 @@ Your job is NOT:
43
38
  ❌ Skip user interaction
44
39
  ❌ Assume project structure
45
40
 
46
- **After writing config.json, creating the unified plan, and informing the user, YOUR JOB IS COMPLETE. EXIT IMMEDIATELY.**
41
+ **After writing config.json and the unified plan, run `/5:implement CONFIGURE`. The rest is its job.**
47
42
 
48
- **If you find yourself writing AGENTS.md, CLAUDE.md, or rules, STOP IMMEDIATELY. You should only be writing config.json, the settings key, and the plan.**
43
+ **If you find yourself writing AGENTS.md, CLAUDE.md, or rules before `/5:implement CONFIGURE` runs, STOP IMMEDIATELY. You should only be writing config.json, the settings key, and the plan.**
49
44
 
50
45
  ## Configuration Process
51
46
 
@@ -173,6 +168,7 @@ Context7 provides up-to-date, version-specific documentation and code examples d
173
168
  - "Generate `.claude/rules/` files? These are scoped instruction files that automatically load when the agent works with matching file types (e.g., testing rules load only when editing test files, code-style rules load only for source files)."
174
169
  - Options: "Yes (recommended)", "Skip"
175
170
  - Note: Rules complement AGENTS.md — they provide focused, file-type-scoped directives derived from your project's actual conventions.
171
+ - On Codex, the rules live in the foifi block of `AGENTS.md`. When the user skipped AGENTS.md in step 2j, do not ask: set `rules.generate` to `false`.
176
172
 
177
173
  **2l. Git-ignore workflow folders:**
178
174
  - "`.5/planning/` will hold your plans. `.5/features/` will hold implementation state and review findings. Which should git ignore?"
@@ -216,7 +212,8 @@ Native plan mode must save its plans in `.5/planning/`, where `/5:implement` fin
216
212
  For each folder the user chose to ignore in step 2l (`.5/planning/`, `.5/features/`):
217
213
  1. Check if `.gitignore` exists in the project root — create it if not
218
214
  2. Check if the folder is already listed — if not, append it on a new line
219
- 3. Inform the user which folders were added to `.gitignore`
215
+ 3. When the user chose "Only `.5/features/`", also append `!.5/planning/`, so upgrades know the plans are shared on purpose and do not ignore them
216
+ 4. Inform the user which folders were added to `.gitignore`
220
217
 
221
218
  **Always gitignore `.5/.reconfig-reminder`:**
222
219
 
@@ -226,7 +223,9 @@ Ensure `.5/.reconfig-reminder` is gitignored (it's a transient runtime flag that
226
223
 
227
224
  ### Step 3: Create Configuration Plan
228
225
 
229
- Write `.5/planning/CONFIGURE.md` containing all gathered data:
226
+ If the user skipped both AGENTS.md (step 2j) and rules (step 2j2), there is nothing to implement: delete `.5/planning/CONFIGURE.md` if an earlier run left it, so no later `/5:implement` applies what the user just declined. Then skip Steps 3 and 4, tell the user "Configuration saved to `.5/config.json`", and stop.
227
+
228
+ Otherwise write `.5/planning/CONFIGURE.md` containing all gathered data. When the user skipped AGENTS.md in step 2j, leave out everything about AGENTS.md and CLAUDE.md: the `configure agents md` component, Requirement 1, its acceptance criteria and Module Impact row, and the "After configure agents md" ordering. The plan then generates only the rules, and nothing touches `AGENTS.md` or `CLAUDE.md`. The template below shows the plan with both selected:
230
229
 
231
230
  ```markdown
232
231
  ---
@@ -323,21 +322,16 @@ Only generate rules for patterns that were actually detected:
323
322
 
324
323
  ## Next Steps
325
324
 
326
- 1. Run `/5:implement CONFIGURE`.
325
+ 1. `/5:configure` runs `/5:implement CONFIGURE` right away; rerun it by hand only if that run was interrupted.
327
326
  ```
328
327
 
329
328
  **Important:** Use `mkdir -p .5/planning` before writing the plan.
330
329
 
331
- ### Step 4: Guide User to Next Phase
330
+ ### Step 4: Run the Plan
332
331
 
333
- Tell the user:
332
+ Tell the user in one line: "Configuration saved to `.5/config.json`, plan written to `.5/planning/CONFIGURE.md` — implementing it now."
334
333
 
335
- 1. "Configuration saved to `.5/config.json`"
336
- 2. "Configuration plan written to `.5/planning/CONFIGURE.md`"
337
- 3. "Next steps:"
338
- - "Run `/clear` to reset context"
339
- - "Then run `/5:implement CONFIGURE`"
340
- 4. "After that: Run `/5:review` if you want a review of generated files"
334
+ Then run `/5:implement CONFIGURE` right away, without asking: the user already chose what to generate in Step 2. It writes the AGENTS.md block and the rules, verifies them, and runs `/5:review` on the result.
341
335
 
342
336
  ## Related Documentation
343
337
  - [configure-agents-md skill](../../skills/configure-agents-md/SKILL.md)