Skip to content

Commit e2df659

Browse files
author
Matthew
committed
Merge branch 'docs/story-11-2-devrail-init' into 'main'
docs(standards): update stories 11.1 (done) and 11.2 (review) See merge request orgdocs/development-standards!32
2 parents 8cca800 + a738d6d commit e2df659

File tree

2 files changed

+77
-34
lines changed

2 files changed

+77
-34
lines changed
Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Story 11.2: Implement `devrail init` Core Script
22

3-
Status: backlog
3+
Status: review
44

55
## Story
66

@@ -20,51 +20,94 @@ so that my project is DevRail-compliant with a single command.
2020

2121
## Tasks / Subtasks
2222

23-
- [ ] Task 1: Implement core script (AC: 1, 2, 6)
24-
- [ ] 1.1 Create script following design from Story 11.1
25-
- [ ] 1.2 Implement `.devrail.yml` parsing
26-
- [ ] 1.3 Implement file generation for core files (Makefile, DEVELOPMENT.md, .editorconfig, .gitignore)
27-
- [ ] 1.4 Implement file generation for agent files (CLAUDE.md, AGENTS.md, .cursorrules)
28-
- [ ] 1.5 Implement file generation for pre-commit config (.pre-commit-config.yaml)
29-
- [ ] 1.6 Implement CI platform detection and generation (.github/workflows or .gitlab-ci.yml)
30-
31-
- [ ] Task 2: Implement interactive mode (AC: 3)
32-
- [ ] 2.1 Add interactive prompts for language selection
33-
- [ ] 2.2 Add interactive prompts for CI platform selection
34-
- [ ] 2.3 Generate `.devrail.yml` from interactive responses
35-
36-
- [ ] Task 3: Implement conflict resolution (AC: 4)
37-
- [ ] 3.1 Detect existing files before generation
38-
- [ ] 3.2 Implement prompt/skip/overwrite/merge strategies
39-
- [ ] 3.3 Default to prompt when files exist
40-
41-
- [ ] Task 4: Implement --dry-run (AC: 7)
42-
- [ ] 4.1 Add --dry-run flag that shows planned file operations without writing
43-
44-
- [ ] Task 5: Test and validate (AC: 5)
45-
- [ ] 5.1 Test against empty directory (greenfield)
46-
- [ ] 5.2 Test against existing project (retrofit)
47-
- [ ] 5.3 Test idempotency (re-run produces no changes)
48-
- [ ] 5.4 Verify generated files match template repos
23+
- [x] Task 1: Create script skeleton with option parsing (AC: 1, 7)
24+
- [x] 1.1 Create `devrail-init.sh` in dev-toolchain repo with POSIX-compatible shebang and usage/help
25+
- [x] 1.2 Parse CLI options: `--languages`, `--ci`, `--all`, `--agents-only`, `--yes`, `--force`, `--dry-run`, `--version`
26+
- [x] 1.3 Implement dry-run mode (track operations, print summary, write nothing)
27+
28+
- [x] Task 2: Implement Layer 1 — Agent instruction files (AC: 1, 5)
29+
- [x] 2.1 Embed CLAUDE.md, AGENTS.md, .cursorrules, .opencode/agents.yaml content as heredocs
30+
- [x] 2.2 Write scaffold function that creates files with conflict detection
31+
- [x] 2.3 Implement `--agents-only` shortcut
32+
33+
- [x] Task 3: Implement Layer 2 — Pre-commit hooks (AC: 1, 2, 5)
34+
- [x] 3.1 Embed .pre-commit-config.yaml template with language-conditional hook blocks
35+
- [x] 3.2 Generate language-aware config based on `.devrail.yml` languages list
36+
- [x] 3.3 Check for `pre-commit` installation and print instructions if missing
37+
38+
- [x] Task 4: Implement Layer 3 — Makefile + container (AC: 1, 2, 4, 5)
39+
- [x] 4.1 Embed Makefile, DEVELOPMENT.md, .editorconfig, .gitignore, .gitleaksignore content
40+
- [x] 4.2 Implement `.devrail.yml` creation from `--languages` flag or interactive prompt
41+
- [x] 4.3 Implement Makefile merge strategy (detect markers, backup+include for non-DevRail Makefiles)
42+
- [x] 4.4 Implement .gitignore append-with-marker pattern
43+
44+
- [x] Task 5: Implement Layer 4 — CI pipelines (AC: 1, 2, 5)
45+
- [x] 5.1 Embed GitHub Actions ci.yml, PR template, CODEOWNERS
46+
- [x] 5.2 Embed GitLab CI .gitlab-ci.yml, MR template, CODEOWNERS
47+
- [x] 5.3 Select platform from `--ci` flag or interactive prompt
48+
49+
- [x] Task 6: Implement interactive mode (AC: 3)
50+
- [x] 6.1 Add interactive prompts for language selection (multi-select from 8 ecosystems)
51+
- [x] 6.2 Add interactive prompts for CI platform selection (github/gitlab/none)
52+
- [x] 6.3 Add 4-layer adoption prompts per design doc
53+
- [x] 6.4 Generate `.devrail.yml` from interactive responses
54+
55+
- [x] Task 7: Implement conflict resolution (AC: 4, 6)
56+
- [x] 7.1 Detect existing files before each write
57+
- [x] 7.2 Interactive mode: prompt with [s]kip / [o]verwrite / [b]ackup+overwrite
58+
- [x] 7.3 `--yes` mode: skip existing files
59+
- [x] 7.4 `--force` mode: overwrite without prompting
60+
61+
- [x] Task 8: Test and validate (AC: 5, 6, 7)
62+
- [x] 8.1 Write bats tests for option parsing and scaffold functions
63+
- [x] 8.2 Test greenfield: empty directory, all layers
64+
- [x] 8.3 Test retrofit: existing project with Makefile, verify merge strategy
65+
- [x] 8.4 Test idempotency: re-run produces no changes
66+
- [x] 8.5 Test dry-run: verify no files written
67+
- [x] 8.6 Test --agents-only: verify only Layer 1 files created
68+
- [x] 8.7 Verify generated files match template repo content
4969

5070
## Dev Notes
5171

52-
- Blocked by Story 11.1 (design must be completed first)
53-
- Implementation language TBD (bash script vs Go CLI vs Python CLI) — decided in 11.1
54-
- Must follow DevRail critical rules (idempotent scripts, shared logging, etc.)
72+
- Design doc: `_bmad-output/planning-artifacts/devrail-init-design.md` (Story 11.1, done)
73+
- Implementation: single POSIX-compatible shell script with embedded heredocs
74+
- Lives in dev-toolchain repo at `scripts/devrail-init.sh`
75+
- File contents sourced from github-repo-template and gitlab-repo-template
76+
- Makefile and DEVELOPMENT.md downloaded from GitHub raw URLs (too large for heredoc embedding)
77+
- `make init` (container-side) remains separate — generates per-language tool configs (ruff.toml, etc.)
78+
- `devrail init` (host-side) generates project structure files (Makefile, CI, agent files, etc.)
5579

5680
### References
5781

58-
- [Source: Story 11.1 design document] — CLI specification
82+
- [Source: devrail-init-design.md] — CLI specification and design decisions
5983
- [Source: github-repo-template/] — reference files for generation
6084
- [Source: gitlab-repo-template/] — reference files for generation
6185

6286
## Dev Agent Record
6387

6488
### Agent Model Used
6589

90+
Claude Opus 4.6
91+
6692
### Debug Log References
6793

94+
- `make check` passed on dev-toolchain repo
95+
- 16/16 bats tests pass
96+
- Manual testing: greenfield (19 files), idempotency (all skipped), dry-run (no files), agents-only (4 files), GitLab CI, Makefile backup+merge
97+
6898
### Completion Notes List
6999

100+
- Script is 1082 lines of bash (after shfmt formatting)
101+
- Small files (agent instructions, .editorconfig, .gitleaksignore, CI workflows) embedded as heredocs
102+
- Large files (Makefile, DEVELOPMENT.md) downloaded from `raw.githubusercontent.com/devrail-dev/github-repo-template/main/`
103+
- Pre-commit config generated dynamically based on language list — only active hooks for declared languages
104+
- GitHub CI generates 6 separate workflow files (lint, format, test, security, scan, docs) matching template structure
105+
- Makefile merge: detects DevRail markers for in-place update, backs up non-DevRail Makefiles with include guidance
106+
- .gitignore: appends below `# --- DevRail ---` marker, skips if marker already present
107+
- Container version tag (`$DEVRAIL_VERSION`) flows through to all generated files
108+
- PR: https://github.com/devrail-dev/dev-toolchain/pull/11
109+
70110
### File List
111+
112+
- `dev-toolchain/scripts/devrail-init.sh` — new script (created)
113+
- `dev-toolchain/tests/test-devrail-init.sh` — new bats tests (created)

_bmad-output/implementation-artifacts/sprint-status.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ development_status:
117117
10-3-write-v160-release-blog-post: done
118118
epic-10-retrospective: optional
119119

120-
epic-11: backlog
121-
11-1-design-devrail-init-cli: ready-for-dev
122-
11-2-implement-devrail-init-core: backlog
120+
epic-11: in-progress
121+
11-1-design-devrail-init-cli: done
122+
11-2-implement-devrail-init-core: review
123123
11-3-distribute-and-document-devrail-init: backlog
124124
epic-11-retrospective: optional
125125

0 commit comments

Comments
 (0)