buildwright 0.0.5 → 0.0.7

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.
Files changed (41) hide show
  1. package/package.json +1 -1
  2. package/templates/.buildwright/agents/README.md +53 -0
  3. package/templates/.buildwright/agents/architect.md +143 -0
  4. package/templates/.buildwright/agents/security-engineer.md +193 -0
  5. package/templates/.buildwright/agents/staff-engineer.md +134 -0
  6. package/templates/.buildwright/claws/README.md +89 -0
  7. package/templates/.buildwright/claws/TEMPLATE.md +71 -0
  8. package/templates/.buildwright/claws/backend.md +114 -0
  9. package/templates/.buildwright/claws/database.md +120 -0
  10. package/templates/.buildwright/claws/devops.md +175 -0
  11. package/templates/.buildwright/claws/frontend.md +111 -0
  12. package/templates/.buildwright/commands/bw-analyse.md +86 -0
  13. package/templates/.buildwright/commands/bw-claw.md +332 -0
  14. package/templates/.buildwright/commands/bw-help.md +85 -0
  15. package/templates/.buildwright/commands/bw-new-feature.md +504 -0
  16. package/templates/.buildwright/commands/bw-quick.md +323 -0
  17. package/templates/.buildwright/commands/bw-ship.md +288 -0
  18. package/templates/.buildwright/commands/bw-verify.md +108 -0
  19. package/templates/.buildwright/steering/naming-conventions.md +40 -0
  20. package/templates/.buildwright/steering/product.md +16 -0
  21. package/templates/.buildwright/steering/quality-gates.md +35 -0
  22. package/templates/.buildwright/steering/tech.md +27 -0
  23. package/templates/.buildwright/tasks/TEMPLATE.md +79 -0
  24. package/templates/.env.example +11 -1
  25. package/templates/.github/workflows/quality-gates.yml +150 -0
  26. package/templates/BUILDWRIGHT.md +99 -1
  27. package/templates/CLAUDE.md +150 -1
  28. package/templates/Makefile +86 -1
  29. package/templates/docs/requirements/TEMPLATE.md +33 -0
  30. package/templates/scripts/bump-version.sh +33 -0
  31. package/templates/scripts/hooks/post-checkout +24 -0
  32. package/templates/scripts/hooks/post-merge +14 -0
  33. package/templates/scripts/hooks/pre-commit +14 -0
  34. package/templates/scripts/install-hooks.sh +35 -0
  35. package/templates/scripts/release.sh +38 -0
  36. package/templates/scripts/sync-agents.sh +294 -0
  37. package/templates/scripts/validate-skill.sh +156 -0
  38. package/templates/.buildwright +0 -1
  39. package/templates/.github +0 -1
  40. package/templates/docs +0 -1
  41. package/templates/scripts +0 -1
@@ -1 +1,150 @@
1
- ../../CLAUDE.md
1
+ # Buildwright Development
2
+
3
+ ## Mission
4
+ Agent-first autonomous development. Humans approve specs; agents implement, test, and ship.
5
+
6
+ ## Steering Documents
7
+
8
+ At the start of every session, read **all** `.md` files in `.buildwright/steering/`.
9
+ Also read all `.md` files in `.buildwright/codebase/` if that directory exists — these
10
+ are codebase analysis docs (stack, architecture, conventions, concerns) generated by
11
+ /bw-analyse. Do not assume a fixed set of files; discover what is there.
12
+
13
+ ## Agents & Claws
14
+ - Agent personas in `.buildwright/agents/` — Architect, Staff Engineer, Security Engineer
15
+ - Domain-specialist claws in `.buildwright/claws/` — Frontend, Backend, Database (+ TEMPLATE for custom)
16
+ - Use `/bw-claw` for cross-domain features that need the Claw Architecture
17
+ - For multi-claw work: use the best available model for Architect and Security review; lighter models suffice for Database and API claws.
18
+
19
+ ## Project Structure
20
+
21
+ `.buildwright/` is the canonical configuration directory (committed to git). Tool-specific directories are generated from it and gitignored:
22
+
23
+ ```
24
+ .buildwright/ ← Canonical source (committed)
25
+ agents/ ← Architect, Staff Engineer, Security Engineer
26
+ claws/ ← Frontend, Backend, Database, TEMPLATE
27
+ codebase/ ← Generated by /bw-analyse (stack, architecture, conventions, concerns)
28
+ commands/ ← bw-new-feature, bw-claw, bw-quick, bw-ship, bw-verify, bw-help
29
+ steering/ ← product.md, tech.md, quality-gates.md, naming-conventions.md
30
+ tasks/
31
+
32
+ .claude/ ← Generated by `make sync` (gitignored, except settings.json)
33
+ .opencode/ ← Generated by `make sync` (gitignored)
34
+ .cursor/rules/ ← Generated by `make sync` (gitignored)
35
+ AGENTS.md ← Generated by `make sync` (gitignored)
36
+ ```
37
+
38
+ After cloning or editing `.buildwright/`, run `make sync` to regenerate tool-specific configs.
39
+
40
+ ## Operating Mode
41
+
42
+ ### Default Behavior
43
+ - AUTONOMOUS mode: Execute fully without asking for confirmation
44
+ - Verify your own work through tests and checks
45
+ - Commit when verification passes
46
+ - Only stop if genuinely blocked (missing info, failing tests after retries)
47
+ - **Autonomous failure handling**: When `BUILDWRIGHT_AUTO_APPROVE=true` (default) and any step fails after retries, commit completed work, push, create PR with failure details, and exit(1). In interactive mode (`BUILDWRIGHT_AUTO_APPROVE=false`), STOP and report blocker as before.
48
+
49
+ ### Workflow Priority
50
+ 1. **New features (single domain)**: /bw-new-feature → Research → Spec → Approval → Implement → Ship
51
+ 2. **Cross-domain features**: /bw-claw → Architect decomposes → Claws execute per domain → Integrate → Ship
52
+ 3. **Small tasks/bugs**: /bw-quick → Quick research → Implement → Verify → Commit
53
+ 4. **Refactors**: /bw-new-feature (if scope unclear) or /bw-quick (if scope clear)
54
+ 5. **Ship existing work**: /bw-ship → Verify → Security → Review → Push → PR
55
+ 6. **Quick quality check**: /bw-verify → typecheck, lint, test, build
56
+ 7. **Show commands**: /bw-help
57
+ 8. **Analyse existing codebase**: /bw-analyse → reads codebase → writes structured docs to .buildwright/codebase/ → updates tech.md. Run first on any brownfield project.
58
+
59
+ ## Command Discovery
60
+
61
+ Run once per session. Cache the result — do not re-detect on every step.
62
+
63
+ 1. Read `.buildwright/steering/tech.md`. If "Project Commands" has real commands (not template placeholders) → use them. STOP.
64
+ 2. Auto-detect from project files in priority order: `package.json` → Node.js (check lock files: `pnpm-lock.yaml`→pnpm, `yarn.lock`→yarn, `bun.lockb`→bun, else→npm) | `Cargo.toml` → cargo | `go.mod` → go | `pyproject.toml` → check `poetry.lock`→poetry, `uv.lock`→uv, else→pip/hatch | `setup.py` → pip | `requirements.txt` → pip | `Makefile` → read targets.
65
+ 3. Derive four commands — typecheck, lint, test, build. If a stack has no equivalent for an operation, mark it SKIP (not a failure). Python has no build step; that's fine.
66
+ 4. Write discovered commands to tech.md so future runs use step 1.
67
+ 5. If still ambiguous: in a greenfield context go to the Greenfield Path (see bw-new-feature). Otherwise ask: "What commands run your tests, linter, and build?"
68
+
69
+ ## Credentials & Environment Variables
70
+
71
+ | Variable | Default | Required | Purpose |
72
+ |----------|---------|----------|---------|
73
+ | `GITHUB_TOKEN` | — | Yes | Push branches and open PRs via `gh`. Needs `repo` scope. |
74
+ | `BUILDWRIGHT_AUTO_APPROVE` | `true` | No | Autonomous mode — skip human approval, fail gracefully on errors |
75
+ | `BUILDWRIGHT_AGENT_RETRIES` | `2` | No | Number of verify retries before giving up |
76
+
77
+ `GITHUB_TOKEN` is the only credential. Use a fine-grained personal access token scoped to a single repository with "Contents: Read and write" and "Pull requests: Read and write" permissions. `BUILDWRIGHT_AUTO_APPROVE` is a configuration flag, not a secret.
78
+
79
+ ## Verification Loop (CRITICAL)
80
+
81
+ Before EVERY commit, discover commands first (see Command Discovery above), then run:
82
+
83
+ 1. **Type check** — run DISCOVERED_TYPECHECK (SKIP gracefully if this stack has none)
84
+ 2. **Lint** — run DISCOVERED_LINT (SKIP gracefully if this stack has none)
85
+ 3. **Test** — run DISCOVERED_TEST
86
+ 4. **Build** — run DISCOVERED_BUILD (SKIP gracefully if this stack has no build step, e.g. Python)
87
+
88
+ If ANY required step fails: fix and retry (max 2 attempts). If same error repeats or still failing: STOP and report blocker.
89
+
90
+ ## Git Rules
91
+ - Atomic commits: only commit files you changed
92
+ - Conventional commits: feat:, fix:, refactor:, test:, docs:, chore:
93
+ - List each file explicitly in commit message
94
+ - Never edit .env files
95
+ - Never run destructive git operations without explicit instruction
96
+ - Multi-agent safety: NEVER use git stash (other agents may be working)
97
+ - Only `.buildwright/` is committed — never commit `.claude/` or `.opencode/` content files
98
+ - After editing any file in `.buildwright/`, run `make sync` before committing
99
+ - Before committing, update README.md, docs/, or CHANGELOG.md if the change affects user-facing behavior
100
+
101
+ ## Cross-Domain Features (Claw Architecture)
102
+ When a feature touches multiple domains (e.g., DB + API + UI):
103
+ 1. `/bw-claw` triggers the Architect persona (`.buildwright/agents/architect.md`)
104
+ 2. Architect registers new fields in `.buildwright/steering/naming-conventions.md` BEFORE spawning claws
105
+ 3. Each claw (`.buildwright/claws/*.md`) executes its domain task using TDD
106
+ 4. Claws derive naming from the conventions registry — they never invent their own
107
+ 5. Architect integrates and runs quality gates
108
+
109
+ ## Design Principles (ALWAYS APPLY)
110
+
111
+ 1. **KISS (Keep It Simple, Stupid)**
112
+ - Prefer simple solutions over clever ones
113
+ - If it feels complex, step back and simplify
114
+ - Code should be readable by a junior developer
115
+
116
+ 2. **YAGNI (You Aren't Gonna Need It)**
117
+ - Build only what's required NOW
118
+ - No speculative features "for later"
119
+ - Avoid abstractions until they're proven needed
120
+
121
+ 3. **No Premature Optimization**
122
+ - Make it work first, then make it fast (if needed)
123
+ - Optimize only with profiling data
124
+ - Readability > micro-optimizations
125
+
126
+ 4. **Boring Technology**
127
+ - Prefer proven, well-documented solutions
128
+ - New tech only when it solves a real problem
129
+ - Consider maintenance burden
130
+
131
+ 5. **Fail Fast, Fail Loud**
132
+ - Validate inputs at boundaries
133
+ - Throw errors early with clear messages
134
+ - No silent failures
135
+
136
+ ## Code Standards
137
+ - Follow existing patterns in the codebase exactly
138
+ - Keep files under 500 lines; split proactively
139
+ - Write tests for all new functionality (TDD preferred)
140
+ - Avoid type system escape hatches (`any` in TypeScript, untyped `interface{}` in Go, `Any` in Python) — use proper types
141
+ - Use Decimal/BigDecimal for financial calculations, NEVER floating point
142
+ - All user inputs must be validated
143
+
144
+ ## Self-Improvement
145
+ When you discover a pattern, gotcha, or better approach:
146
+ - Add it below under "Learned Patterns"
147
+ - Keep entries concise (one line each)
148
+
149
+ ## Learned Patterns
150
+ <!-- Agent adds entries here as it learns -->
@@ -1 +1,86 @@
1
- ../../Makefile
1
+ .PHONY: dist clean sync sync-check cursor opencode openclaw validate install-hooks uninstall-hooks bump release test-cli
2
+
3
+ # ============================================================================
4
+ # Sync — Generate .claude/, .opencode/, .cursor/rules/ from .buildwright/ (canonical)
5
+ # Source of truth: .buildwright/ → .claude/ + .opencode/ + .cursor/rules/ + AGENTS.md + dist/
6
+ # ============================================================================
7
+
8
+ sync:
9
+ @chmod +x scripts/sync-agents.sh
10
+ @scripts/sync-agents.sh
11
+
12
+ sync-check:
13
+ @chmod +x scripts/sync-agents.sh
14
+ @scripts/sync-agents.sh --check
15
+
16
+ # ============================================================================
17
+ # Package for distribution
18
+ # ============================================================================
19
+
20
+ # ClawHub — upload dist/buildwright/ folder to https://clawhub.ai/upload
21
+ dist: sync
22
+ @echo "dist/buildwright/ ready — upload this folder to ClawHub"
23
+
24
+ # Cursor — print setup instructions (rules generated by make sync)
25
+ cursor: sync
26
+ @echo "Cursor rules generated at .cursor/rules/"
27
+ @echo "Open this project in Cursor — rules are applied automatically."
28
+ @echo "Settings > Rules shows steering rules as 'Always' and commands/agents/claws as 'Intelligent'."
29
+
30
+ # OpenCode — install skill to user global config
31
+ opencode: sync
32
+ @mkdir -p ~/.config/opencode/skills/buildwright
33
+ @cp SKILL.md ~/.config/opencode/skills/buildwright/SKILL.md
34
+ @echo "Installed to ~/.config/opencode/skills/buildwright/"
35
+
36
+ # OpenClaw — install skill to user skills directory
37
+ openclaw: sync
38
+ @mkdir -p ~/.openclaw/skills/buildwright
39
+ @cp SKILL.md ~/.openclaw/skills/buildwright/SKILL.md
40
+ @echo "Installed to ~/.openclaw/skills/buildwright/"
41
+
42
+ # ============================================================================
43
+ # Validate SKILL.md against Agent Skills spec (agentskills.io)
44
+ # ============================================================================
45
+
46
+ validate:
47
+ @chmod +x scripts/validate-skill.sh
48
+ @scripts/validate-skill.sh SKILL.md
49
+
50
+ # ============================================================================
51
+ # Git Hooks — keep .buildwright/ ↔ generated files in sync automatically
52
+ # ============================================================================
53
+
54
+ install-hooks:
55
+ @chmod +x scripts/install-hooks.sh
56
+ @scripts/install-hooks.sh
57
+
58
+ uninstall-hooks:
59
+ @rm -f .git/hooks/pre-commit .git/hooks/post-merge .git/hooks/post-checkout
60
+ @echo "Buildwright hooks removed."
61
+
62
+ # ============================================================================
63
+ # Clean
64
+ # ============================================================================
65
+
66
+ bump: ## Bump version files only (no git ops): make bump [BUMP=patch|minor|major]
67
+ @chmod +x scripts/bump-version.sh
68
+ @scripts/bump-version.sh $(or $(BUMP),patch)
69
+
70
+ release: ## Full release: bump, commit, tag, push, GitHub release, npm publish: make release [BUMP=patch|minor|major]
71
+ @chmod +x scripts/release.sh
72
+ @scripts/release.sh $(or $(BUMP),patch)
73
+
74
+ test-cli: ## Pack and install CLI globally for local testing
75
+ @echo "Packing cli/..."
76
+ @cd cli && npm pack
77
+ @TARBALL=$$(ls cli/buildwright-*.tgz | tail -1) && \
78
+ npm install -g "./$$TARBALL" && \
79
+ rm -f "$$TARBALL"
80
+ @echo ""
81
+ @echo "✓ buildwright installed globally from local pack"
82
+ @echo " Test it: cd /tmp && mkdir test-bw && cd test-bw && buildwright init"
83
+ @echo " Uninstall: npm uninstall -g buildwright"
84
+
85
+ clean:
86
+ rm -rf dist/
@@ -0,0 +1,33 @@
1
+ # Feature: [Name]
2
+
3
+ ## Problem Statement
4
+ [What problem are we solving? Who has this problem?]
5
+
6
+ ## Success Metrics
7
+ - [Metric]: [Target]
8
+
9
+ ## User Stories
10
+ As a [role], I want [capability] so that [benefit].
11
+
12
+ ## Functional Requirements
13
+
14
+ ### Must Have (MVP)
15
+ 1. [Requirement]
16
+ - Acceptance: [Criteria]
17
+
18
+ ### Should Have
19
+ 1. [Requirement]
20
+
21
+ ### Out of Scope
22
+ - [What NOT to build]
23
+
24
+ ## Constraints
25
+ - Timeline: [Deadline]
26
+ - Technical: [Integrations, platforms]
27
+ - Regulatory: [Compliance]
28
+
29
+ ## Examples / Edge Cases
30
+ 1. [Scenario]: [Expected behavior]
31
+
32
+ ## Open Questions
33
+ [Questions needing answers]
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # npm versions that are reserved/broken and must never be published
5
+ BLOCKED_VERSIONS=("1.0.0" "1.0.1" "1.0.2")
6
+
7
+ BUMP="${1:-patch}" # patch | minor | major
8
+
9
+ # 1. Bump cli/package.json (no git tag yet)
10
+ cd cli
11
+ npm version "$BUMP" --no-git-tag-version
12
+ NEW_VERSION=$(node -p "require('./package.json').version")
13
+
14
+ # 2. Check if new version is blocked — if so, keep patching until clear
15
+ while printf '%s\n' "${BLOCKED_VERSIONS[@]}" | grep -qx "$NEW_VERSION"; do
16
+ echo "⚠️ Version $NEW_VERSION is reserved on npm — skipping to next patch..."
17
+ npm version patch --no-git-tag-version
18
+ NEW_VERSION=$(node -p "require('./package.json').version")
19
+ done
20
+ cd ..
21
+
22
+ # 3. Update SKILL.md frontmatter
23
+ sed -i.bak "s/^ version: \".*\"/ version: \"$NEW_VERSION\"/" SKILL.md
24
+ rm -f SKILL.md.bak
25
+
26
+ # 4. Sync dist/
27
+ make sync
28
+
29
+ echo ""
30
+ echo "✓ Bumped to v$NEW_VERSION"
31
+ echo ""
32
+ echo "Files updated: cli/package.json SKILL.md"
33
+ echo "Run 'make release' to commit, tag, push, create GitHub release, and npm publish."
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+ # Buildwright post-checkout hook
3
+ # Runs after git checkout.
4
+ # $1 = previous HEAD, $2 = new HEAD, $3 = 1 (branch switch) or 0 (file checkout)
5
+ # Only acts on branch switches ($3 == 1) where .buildwright/ content differs.
6
+
7
+ set -e
8
+
9
+ PREV_HEAD="$1"
10
+ NEW_HEAD="$2"
11
+ BRANCH_SWITCH="$3"
12
+
13
+ # Skip file-level checkouts
14
+ if [ "$BRANCH_SWITCH" != "1" ]; then
15
+ exit 0
16
+ fi
17
+
18
+ if git diff --name-only "$PREV_HEAD" "$NEW_HEAD" 2>/dev/null | grep -q '^\.buildwright/'; then
19
+ echo "Buildwright: .buildwright/ differs between branches — running make sync..."
20
+ make sync
21
+ echo "Buildwright: sync complete."
22
+ fi
23
+
24
+ exit 0
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ # Buildwright post-merge hook
3
+ # Runs after git pull / git merge.
4
+ # If any file under .buildwright/ changed in the merge, run make sync automatically.
5
+
6
+ set -e
7
+
8
+ if git diff --name-only ORIG_HEAD HEAD 2>/dev/null | grep -q '^\.buildwright/'; then
9
+ echo "Buildwright: .buildwright/ changed in merge — running make sync..."
10
+ make sync
11
+ echo "Buildwright: sync complete."
12
+ fi
13
+
14
+ exit 0
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ # Buildwright pre-commit hook
3
+ # If any staged file is under .buildwright/, run make sync before committing.
4
+ # Never blocks the commit — sync is a convenience to keep generated files current.
5
+
6
+ set -e
7
+
8
+ if git diff --cached --name-only | grep -q '^\.buildwright/'; then
9
+ echo "Buildwright: .buildwright/ changes detected — running make sync..."
10
+ make sync
11
+ echo "Buildwright: sync complete."
12
+ fi
13
+
14
+ exit 0
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ # Buildwright hook installer
3
+ # Copies scripts/hooks/* to .git/hooks/ and makes them executable.
4
+ # Idempotent — safe to run multiple times.
5
+
6
+ set -e
7
+
8
+ if ! git rev-parse --show-toplevel >/dev/null 2>&1; then
9
+ echo "Not inside a git repository — skipping hook installation."
10
+ echo "Run 'git init && make install-hooks' to enable auto-sync hooks."
11
+ exit 0
12
+ fi
13
+
14
+ HOOKS_SRC="$(cd "$(dirname "$0")/hooks" && pwd)"
15
+ HOOKS_DEST="$(git rev-parse --show-toplevel)/.git/hooks"
16
+
17
+ if [ ! -d "$HOOKS_SRC" ]; then
18
+ echo "Error: hooks source directory not found at $HOOKS_SRC" >&2
19
+ exit 1
20
+ fi
21
+
22
+ if [ ! -d "$HOOKS_DEST" ]; then
23
+ echo "Error: .git/hooks directory not found. Are you inside a git repo?" >&2
24
+ exit 1
25
+ fi
26
+
27
+ for hook in "$HOOKS_SRC"/*; do
28
+ name="$(basename "$hook")"
29
+ dest="$HOOKS_DEST/$name"
30
+ cp "$hook" "$dest"
31
+ chmod +x "$dest"
32
+ echo " Installed: .git/hooks/$name"
33
+ done
34
+
35
+ echo "Buildwright hooks installed successfully."
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ BUMP="${1:-patch}"
5
+
6
+ # Guard: working tree must be clean before we start
7
+ if ! git diff --quiet || ! git diff --cached --quiet; then
8
+ echo "Error: working tree has uncommitted changes. Commit or stash before releasing."
9
+ exit 1
10
+ fi
11
+
12
+ # Step 1: bump version files (cli/package.json + SKILL.md + make sync)
13
+ make bump BUMP="$BUMP"
14
+
15
+ # Read new version from the bumped package.json
16
+ NEW_VERSION=$(node -p "require('./cli/package.json').version")
17
+
18
+ # Step 2: commit version files
19
+ git add cli/package.json cli/package-lock.json SKILL.md
20
+ git commit -m "chore: bump version to v$NEW_VERSION"
21
+
22
+ # Step 3: annotated tag
23
+ git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
24
+
25
+ # Step 4: push commit + tag
26
+ git push
27
+ git push origin "v$NEW_VERSION"
28
+
29
+ # Step 5: GitHub release with auto-generated notes
30
+ gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --generate-notes
31
+
32
+ # Step 6: publish to npm
33
+ cd cli && npm publish
34
+
35
+ echo ""
36
+ echo "✓ Released v$NEW_VERSION"
37
+ echo " GitHub: https://github.com/$(gh repo view --json nameWithOwner -q .nameWithOwner)/releases/tag/v$NEW_VERSION"
38
+ echo " npm: https://www.npmjs.com/package/buildwright/v/$NEW_VERSION"