From d5f78b8687149b34dfc2b660472ce67888e612a1 Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:29:35 -0400 Subject: [PATCH 01/24] docs(iss-34): glossary Co-Authored-By: Claude Opus 5.5 --- docs/GLOSSARY.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 From cb11c95872b964b9da746ebdab7447338504f36a Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:52:25 -0400 Subject: [PATCH 02/24] test(iss-34-t35): acceptance tests Co-Authored-By: Claude Opus 5.5 --- tests/test_docs.py | 75 +++++++++++ tests/test_leftovers.py | 280 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 355 insertions(+) create mode 100644 tests/test_leftovers.py diff --git a/tests/test_docs.py b/tests/test_docs.py index b67f552..7bc64c9 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -60,3 +60,78 @@ def test_skills_md_matches_manifest_descriptions(self): skills = read("SKILLS.md") self.assertIn("three-axis", skills.lower()) self.assertNotIn("CLAUDE.local.md", skills) + + +def read_if_exists(name): + path = os.path.join(ROOT, name) + return read(name) if os.path.exists(path) else "" + + +class ContributorInstructionsTest(unittest.TestCase): + """#35 (#34 user stories 32-36): a tracked AGENTS.md carries the contributor rules.""" + + def agents(self): + return read_if_exists("AGENTS.md") + + def test_agents_md_exists(self): + self.assertTrue(os.path.isfile(os.path.join(ROOT, "AGENTS.md"))) + + def test_agents_md_has_smoke_driver_rule(self): + # #34 user story 34: generalized to a headless child agent session, only in the + # throwaway smoke repo, never in any other repo or the agent's own session + text = self.agents().lower() + for s in ("headless child agent session", "throwaway smoke repo", "other repo", "own session"): + with self.subTest(s=s): + self.assertIn(s, text) + + def test_agents_md_has_test_command(self): + # #34 user story 33 + self.assertIn("python3 -m unittest", self.agents()) + + def test_agents_md_has_patch_edit_save_flow(self): + # #34 user story 33: patches change through `sync.sh edit` / `save` + text = self.agents() + with self.subTest(step="edit"): + self.assertIn("sync.sh edit", text) + with self.subTest(step="save"): + self.assertRegex(text, r"sync\.sh save|`?edit`?\s*/\s*`?save") + + def test_agents_md_forbids_editing_installed_skills(self): + # #34 user story 33: "never edit an installed skill" (wording as in the README's rule) + self.assertRegex(self.agents(), r"(?i)(never|don't|do not)\s+edit[^.\n]*installed") + + def test_agents_md_has_claude_note(self): + # #34 user story 35 + self.assertIn("@AGENTS.md", self.agents()) + + def test_agents_md_has_gemini_note(self): + # #34 user story 36 + self.assertIn("context.fileName", self.agents()) + + +class LicenseTest(unittest.TestCase): + """#35 (#34 user stories 1 and 2): MIT license and upstream notices.""" + + def test_license_is_mit(self): + self.assertIn("MIT License", read_if_exists("LICENSE")) + + def test_license_copyright_line(self): + # #34 Implementation Decisions: "Copyright (c) 2026 Maceo Richards" + self.assertIn("Copyright (c) 2026 Maceo Richards", read_if_exists("LICENSE")) + + def test_notices_name_both_upstreams(self): + text = read_if_exists("THIRD_PARTY_NOTICES.md") + for s in ("obra/superpowers", "Jesse Vincent", "mattpocock/skills", "Matt Pocock"): + with self.subTest(s=s): + self.assertIn(s, text) + + def test_notices_carry_mit_permission_text(self): + self.assertIn("Permission is hereby granted, free of charge", + read_if_exists("THIRD_PARTY_NOTICES.md")) + + def test_notices_name_derived_parts(self): + # #34 Implementation Decisions: the patches, and `tdd`, forked from Matt's + text = read_if_exists("THIRD_PARTY_NOTICES.md") + for s in ("patches", "tdd"): + with self.subTest(s=s): + self.assertIn(s, text) diff --git a/tests/test_leftovers.py b/tests/test_leftovers.py new file mode 100644 index 0000000..d13c14f --- /dev/null +++ b/tests/test_leftovers.py @@ -0,0 +1,280 @@ +"""Acceptance tests for #35 (part of #34, group A): the clone path rendered at sync time, +the smoke-driver rule leaving the devflow section, and the repo's .gitignore rules.""" +import json +import os +import re +import shutil +import subprocess +import tempfile +import unittest + +from tests.harness import REAL_ROOT, SyncSandbox + +START = "" +# 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 ` + ## 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..b900869 100644 --- a/lib/sync.py +++ b/lib/sync.py @@ -268,6 +268,14 @@ def cleanup(man, tilde_dir, install_ids, dry, failures): # --------------------------------------------------------------------- global config +def clone_path(): + """This clone's root as the section header and ignore comment name it: `~/...` under HOME.""" + home = os.path.expanduser("~").rstrip(os.sep) + if home and (ROOT == home or ROOT.startswith(home + os.sep)): + return "~" + ROOT[len(home):] + return ROOT + + 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 +297,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: @@ -355,7 +363,7 @@ def sync_git_ignore(dry): 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(f"# devflow (managed by {clone_path()})\n") f.write("\n".join(missing) + "\n") return f"{'would add' if dry else 'added'} to ~/.config/git/ignore: {', '.join(missing)}" From 5b25dd68d65b32004a5c8a847e6190e7b6af597e Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:53:53 -0400 Subject: [PATCH 04/24] chore(iss-34-t35): ignore vendor at any depth and the per-tool instructions files Co-Authored-By: Claude Opus 5.5 --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 From 9eb2ad673b1e461a7ae355c14dae83703f05c047 Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:54:18 -0400 Subject: [PATCH 05/24] docs(iss-34-t35): MIT license and third-party notices for superpowers and mattpocock/skills Co-Authored-By: Claude Opus 5.5 --- LICENSE | 21 ++++++++++++++ THIRD_PARTY_NOTICES.md | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 LICENSE create mode 100644 THIRD_PARTY_NOTICES.md 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/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. +``` From b75fd779e2238e4850c5f24411b37c9ac6a918c6 Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:55:23 -0400 Subject: [PATCH 06/24] docs(iss-34-t35): AGENTS.md contributor instructions, with the generalized smoke-driver rule Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 AGENTS.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. From 07f0c663c99a2e59633fc31978adb834a13cb797 Mon Sep 17 00:00:00 2001 From: maceorichards Date: Mon, 26 Oct 2026 15:56:12 -0400 Subject: [PATCH 07/24] test(iss-34-t36): acceptance tests Co-Authored-By: Claude Opus 5.5 --- smoke/drive.py | 11 + .../fixtures/smoke/claude_error_subtype.json | 1 + tests/fixtures/smoke/claude_is_error.json | 1 + tests/fixtures/smoke/claude_ok.json | 1 + tests/fixtures/smoke/claude_pr.json | 1 + .../fixtures/smoke/claude_pr_other_repo.json | 1 + tests/fixtures/smoke/claude_standin.json | 1 + tests/fixtures/smoke/codex_error_event.jsonl | 5 + tests/fixtures/smoke/codex_ok.jsonl | 7 + tests/fixtures/smoke/codex_turn_failed.jsonl | 4 + tests/fixtures/smoke/cursor_create_chat.txt | 1 + tests/fixtures/smoke/cursor_ok.json | 1 + tests/fixtures/smoke/fake_cli.py | 71 ++ tests/test_smoke_driver.py | 721 ++++++++++++++++++ 14 files changed, 827 insertions(+) create mode 100644 smoke/drive.py create mode 100644 tests/fixtures/smoke/claude_error_subtype.json create mode 100644 tests/fixtures/smoke/claude_is_error.json create mode 100644 tests/fixtures/smoke/claude_ok.json create mode 100644 tests/fixtures/smoke/claude_pr.json create mode 100644 tests/fixtures/smoke/claude_pr_other_repo.json create mode 100644 tests/fixtures/smoke/claude_standin.json create mode 100644 tests/fixtures/smoke/codex_error_event.jsonl create mode 100644 tests/fixtures/smoke/codex_ok.jsonl create mode 100644 tests/fixtures/smoke/codex_turn_failed.jsonl create mode 100644 tests/fixtures/smoke/cursor_create_chat.txt create mode 100644 tests/fixtures/smoke/cursor_ok.json create mode 100644 tests/fixtures/smoke/fake_cli.py create mode 100644 tests/test_smoke_driver.py diff --git a/smoke/drive.py b/smoke/drive.py new file mode 100644 index 0000000..da78c39 --- /dev/null +++ b/smoke/drive.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +"""devflow smoke driver (#36). Stub: the acceptance tests pin its behavior.""" +import sys + + +def main(argv=None): + raise NotImplementedError("smoke driver (#36) not implemented yet") + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/fixtures/smoke/claude_error_subtype.json b/tests/fixtures/smoke/claude_error_subtype.json new file mode 100644 index 0000000..d1529ac --- /dev/null +++ b/tests/fixtures/smoke/claude_error_subtype.json @@ -0,0 +1 @@ +{"type":"result","subtype":"error_max_turns","is_error":false,"duration_ms":5000,"num_turns":30,"session_id":"{SESSION_ID}","total_cost_usd":0.2} diff --git a/tests/fixtures/smoke/claude_is_error.json b/tests/fixtures/smoke/claude_is_error.json new file mode 100644 index 0000000..a259163 --- /dev/null +++ b/tests/fixtures/smoke/claude_is_error.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":true,"duration_ms":300,"num_turns":1,"result":"API Error: overloaded","session_id":"{SESSION_ID}","total_cost_usd":0} diff --git a/tests/fixtures/smoke/claude_ok.json b/tests/fixtures/smoke/claude_ok.json new file mode 100644 index 0000000..0598d87 --- /dev/null +++ b/tests/fixtures/smoke/claude_ok.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":false,"duration_ms":1834,"num_turns":2,"result":"Claude says: spec drafted.","session_id":"{SESSION_ID}","total_cost_usd":0.0123} diff --git a/tests/fixtures/smoke/claude_pr.json b/tests/fixtures/smoke/claude_pr.json new file mode 100644 index 0000000..937fb00 --- /dev/null +++ b/tests/fixtures/smoke/claude_pr.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":false,"duration_ms":2210,"num_turns":5,"result":"Opened https://github.com/smoke-owner/smoke-repo/pull/7 for review.","session_id":"{SESSION_ID}","total_cost_usd":0.0311} diff --git a/tests/fixtures/smoke/claude_pr_other_repo.json b/tests/fixtures/smoke/claude_pr_other_repo.json new file mode 100644 index 0000000..f48b9e5 --- /dev/null +++ b/tests/fixtures/smoke/claude_pr_other_repo.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":false,"duration_ms":1500,"num_turns":1,"result":"This looks like https://github.com/someone-else/other-repo/pull/3 upstream.","session_id":"{SESSION_ID}","total_cost_usd":0.0052} diff --git a/tests/fixtures/smoke/claude_standin.json b/tests/fixtures/smoke/claude_standin.json new file mode 100644 index 0000000..7926593 --- /dev/null +++ b/tests/fixtures/smoke/claude_standin.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":false,"duration_ms":912,"num_turns":1,"result":"Yes, go with option A.","session_id":"{SESSION_ID}","total_cost_usd":0.0041} diff --git a/tests/fixtures/smoke/codex_error_event.jsonl b/tests/fixtures/smoke/codex_error_event.jsonl new file mode 100644 index 0000000..3277a88 --- /dev/null +++ b/tests/fixtures/smoke/codex_error_event.jsonl @@ -0,0 +1,5 @@ +{"type":"thread.started","thread_id":"0199a213-81c0-7800-8aa1-bbab2a035a53"} +{"type":"turn.started"} +{"type":"error","message":"Reconnecting... 1/5"} +{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"Done anyway."}} +{"type":"turn.completed","usage":{"input_tokens":10,"cached_input_tokens":0,"output_tokens":5}} diff --git a/tests/fixtures/smoke/codex_ok.jsonl b/tests/fixtures/smoke/codex_ok.jsonl new file mode 100644 index 0000000..68fac9c --- /dev/null +++ b/tests/fixtures/smoke/codex_ok.jsonl @@ -0,0 +1,7 @@ +{"type":"thread.started","thread_id":"0199a213-81c0-7800-8aa1-bbab2a035a53"} +{"type":"turn.started"} +{"type":"item.completed","item":{"id":"item_0","type":"reasoning","text":"Looking at the tests."}} +{"type":"item.completed","item":{"id":"item_1","type":"agent_message","text":"Running the tests now."}} +{"type":"item.completed","item":{"id":"item_2","type":"command_execution","command":"python3 -m unittest","aggregated_output":"OK","exit_code":0,"status":"completed"}} +{"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"Codex says: tests pass."}} +{"type":"turn.completed","usage":{"input_tokens":1200,"cached_input_tokens":0,"output_tokens":80}} diff --git a/tests/fixtures/smoke/codex_turn_failed.jsonl b/tests/fixtures/smoke/codex_turn_failed.jsonl new file mode 100644 index 0000000..a5e8893 --- /dev/null +++ b/tests/fixtures/smoke/codex_turn_failed.jsonl @@ -0,0 +1,4 @@ +{"type":"thread.started","thread_id":"0199a213-81c0-7800-8aa1-bbab2a035a53"} +{"type":"turn.started"} +{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"Starting."}} +{"type":"turn.failed","error":{"message":"stream disconnected before completion"}} diff --git a/tests/fixtures/smoke/cursor_create_chat.txt b/tests/fixtures/smoke/cursor_create_chat.txt new file mode 100644 index 0000000..f604425 --- /dev/null +++ b/tests/fixtures/smoke/cursor_create_chat.txt @@ -0,0 +1 @@ +c0ffee00-1234-4abc-8def-0123456789ab diff --git a/tests/fixtures/smoke/cursor_ok.json b/tests/fixtures/smoke/cursor_ok.json new file mode 100644 index 0000000..a2ee5da --- /dev/null +++ b/tests/fixtures/smoke/cursor_ok.json @@ -0,0 +1 @@ +{"type":"result","subtype":"success","is_error":false,"duration_ms":4120,"duration_api_ms":4120,"result":"Cursor says: done.","session_id":"{SESSION_ID}","request_id":"7d1c2b3a-0000-4000-8000-00000000c0de"} diff --git a/tests/fixtures/smoke/fake_cli.py b/tests/fixtures/smoke/fake_cli.py new file mode 100644 index 0000000..9e3b91d --- /dev/null +++ b/tests/fixtures/smoke/fake_cli.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Fake `claude`, `agent`, `codex` and `gh` for the smoke driver tests (#36). + +The test copies this file into a temporary bin folder under each tool's name. +Every call appends {"prog", "argv", "cwd"} as one JSON line to $FAKE_RECORD. + +- gh: `repo view ...` prints $FAKE_GH_SLUG; anything else (e.g. `repo create`) exits 0. +- agent create-chat: prints cursor_create_chat.txt from $FAKE_FIXTURES. +- any other call: takes the next response queued for this tool in $FAKE_QUEUE + ({"": [{"stdout": "", "exit": N, "stderr": "..."}]}). + The last queued response repeats once the queue is used up. In the fixture + text, {SESSION_ID} becomes the value after --session-id, --resume or resume + (a fixed id when there is none), the way the real tools echo the session. +""" +import json +import os +import sys + +DEFAULT_ID = "00000000-0000-4000-8000-000000000000" + + +def session_id(args): + for flag in ("--session-id", "--resume", "resume"): + if flag in args: + i = args.index(flag) + if i + 1 < len(args): + return args[i + 1] + return DEFAULT_ID + + +def main(): + prog = os.path.basename(sys.argv[0]) + args = sys.argv[1:] + with open(os.environ["FAKE_RECORD"], "a") as f: + f.write(json.dumps({"prog": prog, "argv": args, "cwd": os.getcwd()}) + "\n") + fixtures = os.environ["FAKE_FIXTURES"] + if prog == "gh": + if args[:2] == ["repo", "view"]: + sys.stdout.write(os.environ["FAKE_GH_SLUG"] + "\n") + return 0 + if prog == "agent" and args[:1] == ["create-chat"]: + with open(os.path.join(fixtures, "cursor_create_chat.txt")) as f: + sys.stdout.write(f.read()) + return 0 + queue_path = os.environ["FAKE_QUEUE"] + queue = [] + if os.path.exists(queue_path): + with open(queue_path) as f: + queue = json.load(f).get(prog, []) + if not queue: + sys.stderr.write("fake %s: no queued response\n" % prog) + return 97 + state_path = queue_path + ".state" + state = {} + if os.path.exists(state_path): + with open(state_path) as f: + state = json.load(f) + n = state.get(prog, 0) + state[prog] = n + 1 + with open(state_path, "w") as f: + json.dump(state, f) + item = queue[min(n, len(queue) - 1)] + with open(os.path.join(fixtures, item["stdout"])) as f: + text = f.read() + sys.stdout.write(text.replace("{SESSION_ID}", session_id(args))) + sys.stderr.write(item.get("stderr", "")) + return item.get("exit", 0) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_smoke_driver.py b/tests/test_smoke_driver.py new file mode 100644 index 0000000..eecddf9 --- /dev/null +++ b/tests/test_smoke_driver.py @@ -0,0 +1,721 @@ +"""Acceptance tests for #36 (#34 part D): the smoke driver `smoke/drive.py` (black-box). + +The seam: `python3 -I smoke/drive.py ...` run as a subprocess, with fake `claude`, +`agent`, `codex` and `gh` executables first on PATH (tests/fixtures/smoke/fake_cli.py). +The fakes record their argv and cwd and print recorded sample outputs. git is real. +No live agent, no network. + +Options are passed after the subcommand's positionals (`send