sdd_auth_plan.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. """Setup helper for the explicit-skill-request and mid-conversation
  2. skill-invocation drill scenarios.
  3. Both scenarios have the user say something like "the plan at
  4. docs/superpowers/plans/auth-system.md is ready — subagent-driven-
  5. development, please." So the helper drops a plan file at the same
  6. path the bash test family used (no date prefix).
  7. The plan content is intentionally trivial. These scenarios measure
  8. whether the skill *fires* when explicitly invoked — they don't run
  9. the full plan to completion.
  10. """
  11. from __future__ import annotations
  12. from pathlib import Path
  13. from setup_helpers.base import _git
  14. PLAN_BODY = """\
  15. # Auth System Implementation Plan
  16. A short stub plan used by the explicit-skill-request and
  17. mid-conversation-skill-invocation drill scenarios.
  18. ## Task 1: Add User model
  19. **File:** `src/models/User.js`
  20. Export a `User` class with an `email` field and a `passwordHash` field.
  21. Add a one-line test in `test/models/User.test.js` asserting the class is
  22. constructable with `{ email, passwordHash }`.
  23. ## Task 2: Add register/login routes
  24. **File:** `src/routes/auth.js`
  25. Export Express-style handlers `register(req, res)` and `login(req, res)`.
  26. Stubs are fine — return JSON `{ ok: true }` from each.
  27. ## Task 3: Add JWT middleware
  28. **File:** `src/middleware/jwt.js`
  29. Export `requireJWT(req, res, next)`. If no `Authorization` header,
  30. respond `401`. Otherwise call `next()`.
  31. ## Task 4: Wire it up
  32. **File:** `src/index.js`
  33. Import the routes and middleware. Wire the routes to `/auth/*` paths
  34. and apply `requireJWT` to a placeholder `/protected` route.
  35. The plan is intentionally tiny; the scenarios only measure whether the
  36. SDD skill loads and starts dispatching subagents in response to the
  37. user's request, not whether the implementation completes.
  38. """
  39. def add_sdd_auth_plan(workdir: Path) -> None:
  40. workdir = Path(workdir)
  41. plans_dir = workdir / "docs" / "superpowers" / "plans"
  42. plans_dir.mkdir(parents=True, exist_ok=True)
  43. (plans_dir / "auth-system.md").write_text(PLAN_BODY)
  44. _git(["git", "add", "docs"], cwd=workdir)
  45. _git(["git", "commit", "-m", "draft auth-system plan"], cwd=workdir)