diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f03f9c7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: CI + +on: + push: + branches: [develop, main] + pull_request: + +defaults: + run: + shell: bash + +jobs: + unit: + name: unit (${{ matrix.os }}, python ${{ matrix.python || 'default' }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + python: "3.9" + - os: ubuntu-latest + python: "3.x" + - os: macos-latest # its default python3, no setup-python + steps: + - uses: actions/checkout@v4 + - if: matrix.python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - run: python3 --version + - name: Clone vendors at the locked commits (installs nothing) + run: ./sync.sh --dry-run + - name: Tests + run: python3 -m unittest + env: + DEVFLOW_REQUIRE_VENDORS: "1" + + fresh-install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Dry run + run: ./sync.sh --dry-run + - name: Sync + run: ./sync.sh + - name: Every manifest skill is installed and managed + run: | + python3 - <<'PY' + import json, os, sys + man = json.load(open("manifest.json")) + root = os.path.expanduser("~/.claude/skills") + missing = [s["name"] for s in man["skills"] + if not os.path.isfile(os.path.join(root, s["name"], man["marker"]))] + if missing: + sys.exit("not installed with a %s marker in %s: %s" % (man["marker"], root, ", ".join(missing))) + print("%d managed skills in %s" % (len(man["skills"]), root)) + PY + - name: Re-sync and dry run report no change + # Every status that changes something (or would) starts its line with one of these words. + run: | + for args in "" "--dry-run"; do + out=$(./sync.sh $args) + echo "$out" + if grep -E '^[[:space:]]*(installed|updated|removed|added|would|FAIL|WARN|SKIP)([[:space:]]|$)' <<<"$out"; then + echo "::error::./sync.sh $args reported a change after a full sync" + exit 1 + fi + done + - name: Tests + run: python3 -m unittest + env: + DEVFLOW_REQUIRE_VENDORS: "1" diff --git a/.gitignore b/.gitignore index 2250dc0..39ab943 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ -vendor/ +# vendor clones, as a folder or a symlink, at any depth +vendor .patch-work/ __pycache__/ devflow.local.json +# per-tool instructions files: AGENTS.md is the shared one +/CLAUDE.md +/CLAUDE.local.md +/GEMINI.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..0760ef3 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,20 @@ +# Contributor instructions + +For agents working on the devflow repo itself, or on a fork of it. This file is never installed anywhere: what users get is the devflow section, `global/claude-md-section.md`. + +## Rules + +- **Tests:** run `python3 -m unittest` before calling a change done. Without the vendor clones most sync tests skip; `./sync.sh --dry-run` clones them without installing anything. +- **Patches:** change them only through `./sync.sh edit ` (edit `.patch-work//b/`), then `./sync.sh save ` and `./sync.sh`. Never hand-edit a `patches/*.patch`. +- **Never edit an installed skill** (`//`). It's generated, and the next sync overwrites it. Change `owned/`, `patches/` or `manifest.json` here, then sync. +- **`vendor/`** holds the git-ignored upstream clones. Never edit or commit them. +- **Smoke driver exception:** when the user asks for an unattended smoke run, you may send devflow slash commands, and the answers to their pauses, as the user message of a headless child agent session in the throwaway smoke repo. Never in any other repo, and never in your own session. This is the one exception to the devflow section's "never start a slash-only skill yourself". The smoke kit is in `smoke/`; start with its README. + +## Per-tool setup + +Codex and Cursor read `AGENTS.md` natively. For the others: + +- **Claude Code** reads `AGENTS.md` only when the repo has no `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md`. If you keep one, put `@AGENTS.md` in it. +- **Gemini CLI:** add `AGENTS.md` to `context.fileName` in your settings, e.g. `"context": {"fileName": ["AGENTS.md", "GEMINI.md"]}`. + +`CLAUDE.md`, `CLAUDE.local.md` and `GEMINI.md` are git-ignored here: keep your per-tool notes in them. Only `AGENTS.md` is shared. diff --git a/DESIGN.md b/DESIGN.md index 86684e2..735b306 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -57,13 +57,13 @@ Why devflow is built the way it is. [SKILLS.md](SKILLS.md) says what is installe ## 9. SDD skips its own final review for devflow callers - **Decision:** when `/dev-single --rigor` or `run-lanes` calls SDD, it skips its whole-branch Final Review and returns its deferred minor findings along with its Rulings. -- **Why:** the caller's final review (`spec-review` over the whole feature, with one fix pass; see 15) covers the same ground. In the smoke test, three reviews of one branch reached the same verdict. Per-task reviews still gate every task. +- **Why:** the caller's final review (`spec-review` over the whole feature, with one fix pass; see 15) covers the same ground. In a [smoke run](smoke/README.md), three reviews of one branch reached the same verdict. Per-task reviews still gate every task. - **Rejected:** keeping SDD's final review and dropping `spec-review` in rigor mode. ## 10. Footprints stay per module; splits for parallelism are raised - **Decision:** `to-tickets` lists each ticket's footprint as modules. If tickets can only run in parallel after a module is split, the proposal says so and asks: split or serialize. -- **Why:** in the smoke test, a one-file module was quietly turned into a package just so tickets could run in parallel, and review then flagged that as speculative generality. Asking keeps that architecture choice yours. +- **Why:** in a smoke run, a one-file module was quietly turned into a package just so tickets could run in parallel, and review then flagged that as speculative generality. Asking keeps that architecture choice yours. - **Rejected:** per-function footprints for fast tickets that only add new functions. ## 11. `--auto` uses a stand-in agent and ends at the PR @@ -101,3 +101,10 @@ Why devflow is built the way it is. [SKILLS.md](SKILLS.md) says what is installe - **Why:** skill folders are read by several tools (as of 2026-10: Codex, Gemini CLI and Copilot CLI read `~/.agents/skills`; Cursor reads `~/.agents`, `~/.cursor`, `~/.claude` and `~/.codex` skills and honors `disable-model-invocation`; Claude Code reads only `~/.claude/skills`), so one build can serve all of them. A local choice keeps the repo free of per-machine state. - **Cost accepted:** Cursor with Claude or Codex also selected reads both folders, so duplicates can appear. Codex needs `multi_agent = true` for subagents. - **Rejected:** a per-tool mapping file for each tool (obra/superpowers), plugin packaging, and rewording skill bodies per tool. devflow follows mattpocock/skills' lighter approach, keeping "Call the Skill tool" prose and adding one translation sentence to the global section. + +## 16. Contributor rules live outside the devflow section; the smoke kit runs any agent + +- **Decision:** rules for developing devflow itself (the suite, patch editing, the smoke-driver exception) live in the contributor instructions: the tracked `AGENTS.md`. Per-tool files (`CLAUDE.md`, `CLAUDE.local.md`, `GEMINI.md`) are git-ignored, and `AGENTS.md` says how each tool reads it. The devflow section carries only what every user needs. The smoke kit in `smoke/` is one Python driver over a per-agent command table (`agents.json`), with the agent under test and the stand-in chosen separately. Results stay out of the repo; findings become GitHub issues. +- **Why:** the devflow section loads into every session of every user, so a rule only contributors need is pure context cost (see 14). `AGENTS.md` is the one file most tools read. A table makes adding an agent one entry, so a smoke run can test any provider (see 15), and a Claude stand-in can answer for Codex under test. +- **Cost accepted:** a smoke run makes live agent calls and creates a real GitHub repo. The codex entry is unverified until it has been smoke-run. +- **Rejected:** keeping the rule in the devflow section; a local section-override mechanism (sync machinery for one rule); the old Claude-only bash scripts kept outside the repo (stale and personal); tracking results in the repo (an issue is the lasting record). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b087925 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Maceo Richards + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 10e37fe..28aa912 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,26 @@ # devflow -My agent skills and workflows, for Claude Code, Codex, Gemini CLI or Cursor. **[SKILLS.md](SKILLS.md) is the current overview** of every skill, the workflow mechanics and the naming conventions. Handpicked skills from [obra/superpowers](https://github.com/obra/superpowers) and [mattpocock/skills](https://github.com/mattpocock/skills), plus my patches and my own skills, built into the skills folders of the providers you pick (Claude Code by default) so every project sees them. [DESIGN.md](DESIGN.md) records why it's built this way. +An opinionated set of agent skills and workflows for Claude Code, Codex, Gemini CLI or Cursor: handpicked skills from [obra/superpowers](https://github.com/obra/superpowers) and [mattpocock/skills](https://github.com/mattpocock/skills), patches to some of them, and devflow's own skills, built into the skills folders of the providers you pick (Claude Code by default) so every project sees them. **[SKILLS.md](SKILLS.md) is the current overview** of every skill, the workflow mechanics and the naming conventions. [DESIGN.md](DESIGN.md) records why it's built this way. + +Use it as is, or fork it to choose your own skills: edit `manifest.json`, then run `./sync.sh`. + +## Quickstart + +**Prerequisites:** Python 3.9+, git, the GitHub CLI `gh` signed in (`gh auth login`), and one supported provider (see [Providers](#providers)). GitHub is the only tracker the workflows support. + +```bash +git clone https://github.com/maceorichards/devflow.git +cd devflow +./sync.sh --dry-run +./sync.sh +``` + +The dry run clones the upstream skill repos into `vendor/` at the locked commits and shows what would change, writing nothing outside the clone. The second command builds and installs for Claude Code; to pick other providers, run `./sync.sh providers ` instead. Then, in each project, run `/setup-devflow-skills` once (see [Workflows](#workflows)). + +What the sync edits outside the clone: +- Each selected provider's skills folder (e.g. `~/.claude/skills`): only folders it marks with `.managed-by-devflow`. A folder of the same name without the marker is skipped. +- The devflow section of each provider's instructions file (e.g. `~/.claude/CLAUDE.md`), between `devflow` markers. The rest of the file is left alone. +- The git ignore file git reads, to which it appends the lines in `global/git-ignore-lines` (`.devflow/`, `.worktrees/`, …): the global `core.excludesFile`, else `$XDG_CONFIG_HOME/git/ignore`, else `~/.config/git/ignore`. A system-level `core.excludesFile` is not consulted. ## Workflows @@ -59,7 +79,7 @@ The building blocks can't be slash-only: `disable-model-invocation` also stops o | `devflow.local.json` | Which providers this machine installs to (git-ignored; written by `./sync.sh providers`) | | `vendor.lock` | The upstream commits the patches were last applied against (written by `sync.sh`) | | `patches/` | Diffs against upstream skills | -| `owned/` | My skills. Never synced from upstream. `tdd` was forked once from Matt's (see `owned/tdd/ORIGIN.md`). | +| `owned/` | devflow's own skills. Never synced from upstream. `tdd` was forked once from Matt Pocock's (see `owned/tdd/ORIGIN.md`). | | `global/` | The devflow section for providers' instructions files (between `devflow` markers) and the global git ignore lines | | `tests/` | The `python3 -m unittest` suite for `sync.sh` and the docs | | `vendor/` | Git-ignored upstream clones | @@ -84,3 +104,7 @@ python3 -m unittest # run the test suite **Adding a skill:** add an entry to `manifest.json`, then run `./sync.sh`. **Removing one:** delete its entry; `./sync.sh` removes the installed copy. **Never edit an installed `//` directly.** It's generated, and the next sync overwrites it. + +## Contributing + +Agents (and people) working on devflow itself, or on a fork, follow [AGENTS.md](AGENTS.md): the test command, the patch edit/save flow and the rules for the repo. To check the workflows end to end, use the smoke kit: [smoke/README.md](smoke/README.md). diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..b175cce --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,65 @@ +# Third-party notices + +devflow builds its managed skills from two MIT-licensed upstreams, cloned into `vendor/` at the commits in `vendor.lock`: + +- [obra/superpowers](https://github.com/obra/superpowers), by Jesse Vincent. +- [mattpocock/skills](https://github.com/mattpocock/skills), by Matt Pocock. + +What in this repo derives from them: + +- `patches/`: diffs against upstream skills from both repos, carrying their text. +- `owned/tdd`: forked once from Matt Pocock's `tdd` skill (see `owned/tdd/ORIGIN.md`). + +The upstream skills themselves aren't in this repo: each user's sync builds them from clones it pulls itself. + +## obra/superpowers + +``` +MIT License + +Copyright (c) 2025 Jesse Vincent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## mattpocock/skills + +``` +MIT License + +Copyright (c) 2026 Matt Pocock + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/docs/GLOSSARY.md b/docs/GLOSSARY.md index 69c4a33..50f7fc2 100644 --- a/docs/GLOSSARY.md +++ b/docs/GLOSSARY.md @@ -1,6 +1,6 @@ # devflow -A personal set of agent skills and workflows, built from upstream skill repos plus patches and owned skills, and installed for one or more agent tools. +An opinionated set of agent skills and workflows, built from upstream skill repos plus patches and owned skills, and installed for one or more agent tools. Use it as is, or fork it to choose your own skills. ## Language @@ -11,3 +11,15 @@ _Avoid_: Target, harness, model provider **Agent docs**: The git-ignored working material agents write in a project's main checkout (specs, plans, run state and per-repo conventions), kept in `.devflow/`. _Avoid_: Agent files, working docs + +**Devflow section**: +The managed block that devflow writes into each provider's global instructions file, between `devflow` markers. It is for everyone who uses devflow, so nothing about developing devflow itself belongs in it. +_Avoid_: Global rules, managed block + +**Contributor instructions**: +The tracked `AGENTS.md` at the root of the devflow repo, read by agents working on devflow itself (and on forks of it). Never installed anywhere. +_Avoid_: Project rules, dev rules + +**Smoke run**: +An unattended end-to-end run of a devflow workflow in a throwaway repo, with a stand-in agent answering the workflow's pauses, used to find defects in the skills. +_Avoid_: Smoke test, e2e test diff --git a/global/claude-md-section.md b/global/claude-md-section.md index d13fca8..6518520 100644 --- a/global/claude-md-section.md +++ b/global/claude-md-section.md @@ -1,4 +1,4 @@ - + ## devflow skills and workflows - `/dev-single [--fast | --rigor] [--auto]`: one-ticket feature. Worktree → grill-with-docs → to-spec → your review → implement (or, with `--rigor`, plan + subagent-driven-development) → final review → PR. @@ -10,7 +10,6 @@ Rules: - **Tool wording:** "Call the Skill tool with X": follow X. "Dispatch a subagent": use your subagents. `/name`: the user invokes `name`. Cannot dispatch subagents? Stop and say so; never fake a dispatch. - **Never start a slash-only skill yourself:** `dev-single`, `dev-multi`, `grill-me`, `prototype`, `setup-devflow-skills`, `systematic-debugging`. `--auto` is the user's permission for that one run's pauses, nothing more: it never lets you start one of these. -- **Smoke driver exception:** when the user asks for an unattended smoke run, you may send these commands, and the answers to their pauses, as the user message of a child `claude -p` session in the throwaway smoke repo. Never in any other repo, and never in your own session. - **Devflow building blocks run only when a workflow or another skill calls for them, or when the user asks:** align, grill-with-docs, grilling, domain-modeling, to-spec, to-tickets, implement, implement-spec, run-lanes, writing-plans, subagent-driven-development, requesting-code-review, using-git-worktrees, finishing-a-development-branch, spec-review, codebase-design, tdd. - **Agent docs** live in the main checkout's git-ignored `.devflow/`: - specs: `specs/iss-N-.md` diff --git a/lib/sync.py b/lib/sync.py index 5896619..65dcf4d 100644 --- a/lib/sync.py +++ b/lib/sync.py @@ -26,7 +26,6 @@ MANIFEST = os.path.join(ROOT, "manifest.json") LOCK = os.path.join(ROOT, "vendor.lock") LOCAL = os.path.join(ROOT, "devflow.local.json") -GIT_IGNORE = os.path.expanduser("~/.config/git/ignore") MD_START = "" @@ -268,6 +267,44 @@ def cleanup(man, tilde_dir, install_ids, dry, failures): # --------------------------------------------------------------------- global config +def tilde(path): + """`~/...` for a path under HOME (or `~` itself), the path unchanged otherwise.""" + home = os.path.expanduser("~").rstrip(os.sep) + if home and (path == home or path.startswith(home + os.sep)): + return "~" + path[len(home):] + return path + + +def clone_path(): + """This clone's root as the section header and ignore comment name it.""" + return tilde(ROOT) + + +def git_ignore_target(): + """The file git reads global excludes from (#37): `core.excludesFile` from the global git + config, else `$XDG_CONFIG_HOME/git/ignore`, else `~/.config/git/ignore`. ValueError (with + the reason) when the config can't be read or the value is relative (#37: warn, never break). + `--includes` because naming a scope turns [include]/includeIf off, and git itself follows them (#34).""" + try: + r = subprocess.run(["git", "config", "--global", "--includes", "--type=path", "--get", + "core.excludesFile"], + capture_output=True, text=True) + except OSError as e: + raise ValueError(f"could not read core.excludesFile ({e})") + if r.returncode not in (0, 1): + lines = r.stderr.strip().splitlines() + raise ValueError(f"could not read core.excludesFile ({lines[0] if lines else 'git exited ' + str(r.returncode)})") + value = r.stdout.strip() if r.returncode == 0 else "" + if value: + if not os.path.isabs(value): + raise ValueError(f"core.excludesFile is relative ({value})") + return value + xdg = os.environ.get("XDG_CONFIG_HOME") + if xdg: + return os.path.join(xdg, "git", "ignore") + return os.path.expanduser("~/.config/git/ignore") + + def section_bounds(cur): """(a, b) for exactly one well-ordered section, None for no markers; ValueError otherwise.""" starts, ends = cur.count(MD_START), cur.count(MD_END) @@ -289,7 +326,7 @@ def unreadable_skip(tilde_path): def sync_instructions(tilde_path, dry): path = os.path.expanduser(tilde_path) with open(os.path.join(ROOT, "global", "claude-md-section.md")) as f: - section = f.read().strip() + "\n" + section = f.read().replace("{{clone}}", clone_path()).strip() + "\n" cur = "" if os.path.exists(path): try: @@ -344,20 +381,34 @@ def remove_instructions(tilde_path, dry): def sync_git_ignore(dry): with open(os.path.join(ROOT, "global", "git-ignore-lines")) as f: want = [l.strip() for l in f if l.strip() and not l.startswith("#")] - cur = open(GIT_IGNORE).read() if os.path.exists(GIT_IGNORE) else "" - have = {l.strip() for l in cur.splitlines()} - missing = [l for l in want if l not in have] - if not missing: - return "git ignore lines present" - if not dry: - os.makedirs(os.path.dirname(GIT_IGNORE), exist_ok=True) - with open(GIT_IGNORE, "a") as f: - if cur and not cur.endswith("\n"): - f.write("\n") - if "# devflow" not in cur: - f.write("# devflow (managed by ~/Documents/CUSTOM-SKILLS/devflow)\n") - f.write("\n".join(missing) + "\n") - return f"{'would add' if dry else 'added'} to ~/.config/git/ignore: {', '.join(missing)}" + manual = "add these lines yourself: " + ", ".join(want) + try: + target = git_ignore_target() + except ValueError as e: + return f"WARN git ignore: {e}; {manual}" + shown = tilde(target) + missing = want # nothing is known to be present until the file has been read + action = "read" + try: + cur = open(target).read() if os.path.exists(target) else "" + have = {l.strip() for l in cur.splitlines()} + missing = [l for l in want if l not in have] + if not missing: + return f"git ignore lines present in {shown}" + if not dry: + action = "write" + os.makedirs(os.path.dirname(target), exist_ok=True) + with open(target, "a") as f: + if cur and not cur.endswith("\n"): + f.write("\n") + if "# devflow" not in cur: + f.write(f"# devflow (managed by {clone_path()})\n") + f.write("\n".join(missing) + "\n") + except (OSError, UnicodeDecodeError) as e: # undecodable target: warn, never crash (#34) + why = e.strerror if isinstance(e, OSError) and e.strerror else e + return (f"WARN git ignore: could not {action} {shown} ({why}); " + f"add these lines yourself: {', '.join(missing)}") + return f"{'would add' if dry else 'added'} to git ignore {shown}: {', '.join(missing)}" # --------------------------------------------------------------------- commands @@ -453,7 +504,8 @@ def apply_all(man, lock, dry=False, only_sources=None, selected=None): status = remove_instructions(f, dry) if status: print(" " + status) - print(" " + sync_git_ignore(dry)) + status = sync_git_ignore(dry) + print(status if status.startswith("WARN") else " " + status) # #37: a WARN starts its line for p in man["providers"]: if p["name"] in selected and not p["instructions"]: print(f"note: {p['name']} reads no instructions file: paste global/claude-md-section.md " diff --git a/smoke/.gitignore b/smoke/.gitignore new file mode 100644 index 0000000..333c1e9 --- /dev/null +++ b/smoke/.gitignore @@ -0,0 +1 @@ +logs/ diff --git a/smoke/CHECKLIST.md b/smoke/CHECKLIST.md new file mode 100644 index 0000000..9509258 --- /dev/null +++ b/smoke/CHECKLIST.md @@ -0,0 +1,76 @@ +# devflow smoke checklist + +What each scenario of a [smoke run](README.md) should show. Re-run after changing workflows or patches, in a fresh repo from `drive.py init`, and use a new label per scenario. Tick items from the logs, the smoke repo's files and commits, and its issues and PRs. + +## 0. Setup: `/setup-devflow-skills` +- [ ] Asks for the tracker; for GitHub, asks which base branch features start from and fills the `Base branch:` line in `.devflow/agents/issue-tracker.md` +- [ ] Writes the conventions to `.devflow/agents/` (`issue-tracker.md`, `domain.md`); writes no instructions file and no `## Agent skills` block; no root `docs/agents/`; commits nothing +- [ ] Domain docs single-context: `docs/GLOSSARY.md` and `docs/adr/` +- [ ] `.devflow/x` and `.worktrees/x` are ignored (`git check-ignore -q`) +- [ ] Tracker doc has "Sub-issues and blocking", no `/wayfinder` or `/triage` +- [ ] First workflow run passes `align` preflight with nothing pushed beyond the initial commit + +## 1. `/dev-single` (fast) +- [ ] Mode line comes first +- [ ] Base is `main`, read from the `Base branch:` line (stated in the first grilling round only when that line is missing) +- [ ] Worktree `.worktrees/feat-` cut from `origin/main`; the session stays in the main checkout +- [ ] Branch renamed `feat/` → `feat/iss-N-` after to-spec; folder name kept +- [ ] Issue #N with `ready-for-agent`; `.devflow/specs/iss-N-.md` exists with its `" +# The marker line the template carried before #34 (global/claude-md-section.md, line 1). +OLD_HEADER = ("") + + +def read(path): + with open(path) as f: + return f.read() + + +def write(path, text): + os.makedirs(os.path.dirname(path), exist_ok=True) + with open(path, "w") as f: + f.write(text) + + +def start_lines(text): + return [l for l in text.splitlines() if l.startswith(START)] + + +def names(path): + """Regex matching `path` as a whole path (a following `/` is allowed, e.g. `/global/...`).""" + return re.escape(path) + r"(?![\w.-])" + + +class RealpathSandbox: + """SyncSandbox run through real paths. On macOS the temp folder sits behind the + /var -> /private/var symlink; running sync.sh by its real path with a real HOME + leaves exactly one right answer for "the clone's root", whichever way the sync + resolves it.""" + + def __init__(self, home_is_repo_parent): + self.sb = SyncSandbox() + self.repo = os.path.realpath(self.sb.repo) + tmp = os.path.realpath(self.sb.tmp) + # HOME = the repo's parent gives `~/repo`; the default sandbox home is a sibling, + # so the repo is outside HOME and the path stays absolute. + self.home = tmp if home_is_repo_parent else os.path.realpath(self.sb.home) + + def run(self, *args): + env = os.environ.copy() + env["HOME"] = self.home + # Keep the ignore file at today's default whatever the runner's environment (#37 + # resolves XDG_CONFIG_HOME and core.excludesFile; not under test here). + env.pop("XDG_CONFIG_HOME", None) + for k in list(env): + if k.startswith("GIT_CONFIG"): + del env[k] + return subprocess.run([os.path.join(self.repo, "sync.sh")] + list(args), + cwd=self.repo, env=env, capture_output=True, text=True) + + def path(self, tilde): + return os.path.join(self.home, tilde[2:]) + + def close(self): + self.sb.close() + + +class RenderedClonePathTest(unittest.TestCase): + """#34 user stories 3 and 4: the header and the ignore comment name the user's clone.""" + + def sandbox(self, home_is_repo_parent): + sb = RealpathSandbox(home_is_repo_parent) + self.addCleanup(sb.close) + r = sb.run() + self.assertEqual(r.returncode, 0, r.stdout + r.stderr) + return sb + + def header(self, sb): + lines = start_lines(read(sb.path("~/.claude/CLAUDE.md"))) + self.assertEqual(len(lines), 1, lines) + return lines[0] + + def ignore_comment(self, sb): + lines = [l for l in read(sb.path("~/.config/git/ignore")).splitlines() + if l.startswith("# devflow")] + self.assertEqual(len(lines), 1, lines) + return lines[0] + + def test_header_names_clone_with_tilde_when_under_home(self): + sb = self.sandbox(home_is_repo_parent=True) + self.assertRegex(self.header(sb), names("~/repo")) + + def test_header_names_clone_absolute_when_outside_home(self): + sb = self.sandbox(home_is_repo_parent=False) + self.assertRegex(self.header(sb), names(sb.repo)) + + def test_header_has_no_author_path(self): + sb = self.sandbox(home_is_repo_parent=False) + self.assertNotIn("CUSTOM-SKILLS", self.header(sb)) + + def test_ignore_comment_names_clone_with_tilde_when_under_home(self): + sb = self.sandbox(home_is_repo_parent=True) + self.assertRegex(self.ignore_comment(sb), names("~/repo")) + + def test_ignore_comment_names_clone_absolute_when_outside_home(self): + sb = self.sandbox(home_is_repo_parent=False) + self.assertRegex(self.ignore_comment(sb), names(sb.repo)) + + def test_ignore_comment_has_no_author_path(self): + sb = self.sandbox(home_is_repo_parent=False) + self.assertNotIn("CUSTOM-SKILLS", self.ignore_comment(sb)) + + +class OldHeaderMigrationTest(unittest.TestCase): + """#34 user story 5: an install with the old header is rewritten once, user text kept.""" + + BEFORE = "# my rules\nkeep me before\n\n" + AFTER = "\n# more of mine\nkeep me after\n" + + @classmethod + def setUpClass(cls): + cls.sb = RealpathSandbox(home_is_repo_parent=False) + cls.md = cls.sb.path("~/.claude/CLAUDE.md") + write(cls.md, cls.BEFORE + OLD_HEADER + "\n## devflow skills and workflows\nold body\n" + + END + cls.AFTER) + cls.result = cls.sb.run() + cls.out = read(cls.md) + + @classmethod + def tearDownClass(cls): + cls.sb.close() + + # characterization: an old header never made the sync fail + def test_sync_succeeds(self): + self.assertEqual(self.result.returncode, 0, self.result.stdout + self.result.stderr) + + # characterization: marker detection already matches the `