diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 511086f..cd24ab4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Run test suite - run: swift test --filter "SubtreeTests" + run: swift package clean && swift test --filter "SubtreeLibTests" --jobs 2 linux: name: Test on Linux @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full git history for git operations # - name: Set up Docker Buildx # uses: docker/setup-buildx-action@v3 @@ -30,4 +32,4 @@ jobs: - name: Run Linux test suite run: | docker run --rm -v "$(pwd):/workspace" -w /workspace swift:6.1 \ - bash -c "swift package resolve && swift test --filter 'SubtreeTests'" + bash -c 'git config --global --add safe.directory /workspace && swift package clean && swift test --filter "SubtreeLibTests" --jobs 2' \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25b3699..14604ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,15 +103,13 @@ jobs: - name: Prepare release binaries run: | - VERSION="${{ github.event.release.tag_name }}" - # Copy and rename binaries for release upload - cp downloaded_artifacts/subtree_macos/subtree "subtree_${VERSION}_macos" - cp downloaded_artifacts/subtree_linux/subtree_linux "subtree_${VERSION}_linux_x86_64" - cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "subtree_${VERSION}_linux_arm64" + cp downloaded_artifacts/subtree_macos/subtree "subtree_macos" + cp downloaded_artifacts/subtree_linux/subtree_linux "subtree_linux_x86_64" + cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "subtree_linux_arm64" # Make all binaries executable - chmod +x subtree_${VERSION}_* + chmod +x subtree_* - name: Build artifact bundle run: | @@ -169,9 +167,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - VERSION="${{ github.event.release.tag_name }}" - gh release upload "${VERSION}" \ - "subtree_${VERSION}_macos" \ - "subtree_${VERSION}_linux_x86_64" \ - "subtree_${VERSION}_linux_arm64" \ + gh release upload "${{ github.event.release.tag_name }}" \ + "subtree_macos" \ + "subtree_linux_x86_64" \ + "subtree_linux_arm64" \ "subtree.artifactbundle.zip" diff --git a/.specify/memory/constitution.md b/.specify/memory/constitution.md index 2fbbfe6..98c9501 100644 --- a/.specify/memory/constitution.md +++ b/.specify/memory/constitution.md @@ -1,94 +1,220 @@ -# Subtree Constitution +# Subtree CLI Constitution ## Core Principles -### I. CLI I/O Contract -Subtree is a non-interactive, pipeline-friendly CLI by default. -- Input: command-line args and STDIN; Output: STDOUT; Errors/warnings: STDERR. -- Default output is human-readable. When `--json` is provided, output MUST be valid JSON and stable across patch releases. -- Exit codes: `0` success, `1` general failure, `2` usage/argument error, `3` I/O/environment error. Additional codes MAY be defined per subcommand and documented in `--help`. -- No interactive prompts unless `--interactive` (or equivalent) is explicitly passed and TTY is detected. -- Color and TTY behavior: enable colors only when attached to a TTY; support `--no-color` to disable. -- Required flags across all binaries: `--help`, `--version`, `--json` (where applicable), and `--quiet` to suppress non-essential output. - -### II. Test-First & CI (NON-NEGOTIABLE) -Test-Driven Development is mandatory for all changes. -- Red-Green-Refactor: write failing tests before implementation; refactor only with tests green. -- CI MUST run `swift build` and `swift test` on all supported platforms/architectures where feasible. -- New flags/behavior MUST include tests for success, failure, and edge cases; JSON mode outputs MUST have schema assertions. -- No PR may merge with failing tests or without coverage of new behavior. - -### III. Versioning & Releases -We use Semantic Versioning for the public CLI surface and output schemas. -- Versioning: MAJOR.MINOR.PATCH. Breaking CLI or JSON changes require a MAJOR release. -- Tags: `vX.Y.Z`. Releases are published as GitHub Releases with asset checksums. -- Deliverables: prebuilt binaries for all supported OS/architectures; include SHA-256 checksums and a plaintext CHANGELOG entry. -- Deprecations MUST be announced one MINOR release before removal, when feasible. - -### IV. Cross-Platform Builds -Subtree MUST build and function on the defined matrix without code divergence. -- Targets: macOS (arm64, x86_64), Linux glibc (x86_64, arm64), Windows (arm64, x86_64). -- Source MUST avoid OS-specific assumptions (paths, encodings, newlines). Use Swift standard library and portability utilities. -- CI SHOULD produce artifacts for each target or validate via matrix builds where native toolchains exist. - -### V. Exit Codes & Error Handling -All commands MUST return deterministic exit codes and clear diagnostics. -- Human-readable errors go to STDERR; JSON mode emits `{ "error": { "code": , "message": , "details": } }` on STDERR. -- Verbosity controls: `--quiet` suppresses info-level logs; `--trace` may include stack traces for debugging. -- Never print secrets or tokens. Redact in logs and error messages. - -## Additional Constraints - -- Language/Runtime: Swift + Swift Package Manager (SPM). No alternate build systems. -- Baseline commands: `--help`, `--version`, `--json` (where applicable), `--quiet`. -- Distribution: GitHub Releases with prebuilt binaries; include SHA-256 checksums and a CHANGELOG entry. -- Dependency policy: all dependencies pinned via `Package.resolved`; reproducible builds required. -- Security: no network calls during execution unless explicitly required by a subcommand and documented. - -## Development Workflow & Quality Gates - -1) Tests First -- All new behavior lands with failing tests first, then implementation. -- JSON output schemas validated in tests. - -2) CI Matrix -- Build and test across the supported OS/arch matrix where toolchains are available. -- Release pipelines produce artifacts and checksums; verify signatures/checksums before publish. - -3) Review Gating -- PRs MUST assert compliance with all Core Principles in the description. -- Any deviation requires a documented justification and follow-up task to restore compliance. +### I. Spec-First Development (NON-NEGOTIABLE) + +Every behavior change or feature MUST begin with a `spec.md` file that defines: + +- User scenarios with acceptance criteria in Given-When-Then format +- Failing tests that encode the acceptance criteria +- Measurable success criteria +- Functional requirements (technology-agnostic) + +**Bootstrap Requirement**: The first spec (spec 000 or spec 001) MUST establish the test harness and CI infrastructure used by all subsequent specs. This bootstrap spec defines the testing framework, test organization, CI configuration, and quality gates that govern the project. + +**Spec Organization**: Each spec MUST be small, independent, and focused on a single feature or small subfeature. Specs are stored in `specs/###-feature-name/spec.md` with related design artifacts (plan.md, tasks.md, etc.). + +**Implementation Notes**: Specs MAY include an optional "Implementation Notes" section at the end for language-specific guidance (preferably Swift for this project). However, the main spec body MUST remain behavior-focused, test-driven, and technology-agnostic. + +**Rationale**: Spec-first development ensures clear requirements, prevents scope creep, enables independent testing, and creates executable documentation. The bootstrap spec prevents test infrastructure drift across features. + +### II. Test-Driven Development (NON-NEGOTIABLE) + +All implementation MUST follow strict TDD discipline: + +1. **Write tests first** based on spec.md acceptance criteria +2. **Verify tests fail** before any implementation +3. **Implement minimal code** to pass the tests +4. **Refactor** while keeping tests green +5. Tests MUST pass before merge + +**Test Organization**: Unit tests validate individual components, integration tests verify feature workflows, contract tests ensure API/CLI stability. + +**Rationale**: TDD forces clear design, prevents regression, documents behavior through tests, and ensures testability. Failing tests first proves tests actually validate the requirement. + +### III. Small, Independent Specs + +Each spec.md MUST represent: + +- A single feature or small subfeature +- An independently testable unit of work +- A deployable increment of value +- User stories prioritized by importance (P1, P2, P3) + +Specs MUST NOT: + +- Combine multiple unrelated features +- Create dependencies on incomplete specs +- Describe implementation details instead of behavior + +**Rationale**: Small specs enable parallel work, reduce risk, accelerate feedback cycles, and allow incremental delivery. Independent specs prevent cascading failures and enable selective rollback. + +### IV. CI & Quality Gates + +All code changes MUST pass automated quality gates defined in the bootstrap spec. Required gates include: + +**CI Matrix**: Tests MUST run across representative platforms (e.g., macOS, Linux, Swift versions as appropriate for the project). + +**Test Requirements**: +- Unit tests MUST pass (validate individual components) +- Integration tests MUST pass (validate feature workflows) +- Contract tests MUST pass (validate CLI/API stability) + +**Merge Policy**: CI MUST pass green before merge. No exceptions. + +**Rationale**: Automated gates prevent regressions, ensure cross-platform compatibility, maintain quality consistency, and reduce manual review burden. Representative platform coverage catches environment-specific issues early. + +### V. Agent Maintenance Rules + +The agent MUST maintain `.windsurf/rules` as a small, surgical file describing: + +- Agent expectations for the codebase +- Current project structure and conventions +- Update procedures for rules file + +**Mandatory Update Triggers**: The agent MUST update `.windsurf/rules` after successfully implementing any spec that introduces changes to: + +1. **Project dependencies** (new packages, version bumps, removals) +2. **Directory structure or module organization** (new directories, moved components) +3. **Architecture patterns** (new layers, communication patterns, design patterns) +4. **CI/CD pipeline or quality gates** (new workflows, test requirements, deployment steps) +5. **Major feature areas** (new commands, core functionality additions) + +**Rationale**: Living documentation prevents drift between code reality and agent expectations. Specific triggers ensure updates happen consistently without excessive maintenance burden. Surgical scope keeps rules actionable and focused. + +## CI & Quality Gates + +### Platform Coverage + +CI pipeline MUST test on: +- Primary target platforms (defined in bootstrap spec) +- Representative platform matrix (e.g., macOS latest, Ubuntu LTS) +- Relevant language/runtime versions + +### Required Checks + +Before merge, ALL of the following MUST pass: +- ✅ All unit tests across all platforms +- ✅ All integration tests across all platforms +- ✅ All contract tests (CLI interface stability) +- ✅ Linting and formatting checks +- ✅ Build success on all platforms + +### Failure Policy + +If any check fails: +- Merge is BLOCKED +- Developer MUST fix root cause +- Re-run full CI suite +- No bypassing checks (no force merge) + +## Agent Maintenance Rules + +### .windsurf/rules Lifecycle + +**Initial State**: Agent creates `.windsurf/rules` during or immediately after bootstrap spec implementation. + +**Maintenance**: Agent updates `.windsurf/rules` after each successful spec implementation that triggers one of the five mandatory categories (dependencies, structure, architecture, CI, major features). + +**Content**: Rules file MUST remain small and surgical: +- Current dependencies and their purpose +- Directory structure and module organization +- Established architectural patterns +- CI/CD pipeline overview +- Major feature areas and their locations +- Conventions (naming, organization, testing) + +**Update Procedure**: When triggered: +1. Agent reads current `.windsurf/rules` +2. Identifies what changed in the completed spec +3. Updates relevant sections surgically (add/modify/remove only affected parts) +4. Keeps file concise and actionable + +### Rules File Format + +```markdown +# Subtree CLI - Agent Rules + +Last Updated: [DATE] | Spec: [###-feature-name] + +## Dependencies +- [List current dependencies and purpose] + +## Structure +- [Current directory organization] + +## Architecture +- [Established patterns and conventions] + +## CI/CD +- [Pipeline overview and quality gates] + +## Features +- [Major feature areas and locations] + +## Conventions +- [Naming, testing, organization rules] +``` ## Governance - -This constitution supersedes conflicting practices. Compliance is required for all changes. +### Supremacy + +This constitution supersedes all other development practices, guidelines, and conventions. In case of conflict, constitution principles take precedence. + +### Compliance + +- All pull requests MUST verify compliance with constitutional principles +- Code reviews MUST check for spec-first discipline and test coverage +- CI gates enforce test and quality requirements automatically +- Complexity MUST be justified against constitutional simplicity principles + +### Amendments + +Constitution amendments require: +1. Clear documentation of the proposed change +2. Rationale for the amendment (why current principles insufficient) +3. Migration plan for existing code/specs if needed +4. Version bump following semantic versioning rules + +### Versioning Rules + +- **MAJOR**: Backward-incompatible governance changes, principle removals, or redefinitions +- **MINOR**: New principles added or material expansions to existing principles +- **PATCH**: Clarifications, wording improvements, typo fixes, non-semantic refinements + +### Living Document -- Amendments: via PR with impact analysis (CLI flags, JSON schema, exit codes). Bump version per SemVer rules. -- Breaking changes: require migration notes and clear release notes; deprecate before removal when feasible. -- Compliance Review: reviewers verify Core Principles checkboxes in PR description; CI enforces tests and matrix builds. -- Runtime Guidance: see `.specify/templates/plan-template.md`, `spec-template.md`, and `tasks-template.md` for process checkpoints that mirror these principles. +This constitution is a living document that evolves with the project. Agents and developers MUST keep it synchronized with project reality through the amendment process. -**Version**: 1.0.0 | **Ratified**: 2025-09-22 | **Last Amended**: 2025-09-22 \ No newline at end of file +**Version**: 1.0.0 | **Ratified**: 2025-10-25 | **Last Amended**: 2025-10-25 diff --git a/.specify/memory/roadmap.md b/.specify/memory/roadmap.md new file mode 100644 index 0000000..350fb55 --- /dev/null +++ b/.specify/memory/roadmap.md @@ -0,0 +1,346 @@ +# Product Roadmap: Subtree CLI + +**Version:** v1.4.0 +**Last Updated:** 2025-10-29 + +## Vision & Goals + +Simplify git subtree management through declarative YAML configuration with safe file extraction and validation capabilities. + +**Target Users:** +- Solo developers and small teams managing vendor dependencies +- Open source project maintainers integrating upstream libraries +- Developers building monorepo-style projects with shared code + +**Primary Outcomes:** +1. **Reduce complexity** - Replace complex git subtree commands with simple declarative configuration +2. **Improve safety** - Prevent accidental data loss through built-in validation and overwrite protection +3. **Enable automation** - Support CI/CD pipelines with reliable, scriptable subtree operations + +## Release Plan + +> Timing is flexible based on development velocity. Each phase delivers complete, production-ready functionality. + +### Phase 1 — Foundation (✅ COMPLETE) + +**Goal:** Establish project infrastructure and configuration management + +**Status:** All features delivered and tested across macOS 13+ and Ubuntu 20.04 LTS + +**Key Features:** + +1. **CLI Bootstrap** + - Purpose & user value: Provides command-line interface skeleton with discoverable help system, enabling users to explore available commands and understand tool capabilities without external documentation + - Success metrics: + - Command help accessible in <5 seconds via `subtree --help` + - All stub commands execute without crashing (exit code 0) + - CI pipeline runs tests on macOS + Ubuntu completing in <10 minutes + - Dependencies: None + - Notes: Includes test infrastructure (unit + integration test harness) and GitHub Actions CI + +2. **Configuration Schema & Validation** + - Purpose & user value: Defines `subtree.yaml` structure and validation rules, enabling users to manage subtree dependencies declaratively with clear error messages when configuration is invalid + - Success metrics: + - Valid configs parse successfully on first attempt when following docs + - Invalid configs produce clear, actionable error messages within 1 second + - 100% of format/constraint violations caught before git operations + - Dependencies: CLI Bootstrap + - Notes: Format-only validation (no network/git checks), supports glob patterns for extract mappings + +3. **Init Command** + - Purpose & user value: Creates initial `subtree.yaml` configuration file at git repository root, providing starting point for declarative subtree management with overwrite protection + - Success metrics: + - Initialization completes in <1 second + - Users successfully initialize on first attempt without documentation + - 100% of initialization attempts either succeed or fail with clear error + - Dependencies: Configuration Schema & Validation + - Notes: Works from any subdirectory, follows symlinks to find git root, atomic file operations for concurrent safety + +**Next:** `/speckit.specify "Feature: Add Command - Add configured subtrees to repository with atomic commit strategy"` + +--- + +### Phase 2 — Core Subtree Operations (✅ COMPLETE) + +**Goal:** Enable complete subtree lifecycle management with atomic commits + +**Status:** All core subtree operations delivered and tested across macOS 13+ and Ubuntu 20.04 LTS + +**Key Features:** + +1. **Add Command (CLI-First)** ✅ COMPLETE + - Purpose & user value: Adds subtrees to repository via CLI flags in single atomic commits, creating config entries automatically and ensuring configuration always reflects repository state + - Success metrics: + - Subtree addition completes in <10 seconds for typical repositories + - 100% of add operations produce single commit (subtree + config update) + - Users can add subtrees with minimal flags (only --remote required) + - Smart defaults reduce typing: name from URL, prefix from name, ref defaults to 'main' + - Dependencies: Init Command + - Notes: CLI-First workflow (flags create config entry), atomic commit-amend pattern, duplicate detection via config check (name OR prefix), squash enabled by default (--no-squash to disable) + - Delivered: All 5 user stories implemented (MVP with smart defaults, override defaults, no-squash mode, duplicate prevention, error handling), 150 tests passing + +2. **Update Command** ✅ COMPLETE + - Purpose & user value: Updates subtrees to latest versions with flexible commit strategies, enabling users to keep dependencies current with report-only mode for CI/CD safety checks + - Success metrics: + - Update check (report mode) completes in <5 seconds + - Users understand update status without applying changes (exit code 5 if updates available) + - 100% of applied updates tracked in config with correct commit hash + - Dependencies: Add Command + - Notes: Report mode (no changes), current branch commits only, single-commit squashing option (--squash/--no-squash) + - Delivered: All 5 user stories implemented (selective update with squash, bulk update --all, report mode for CI/CD, no-squash mode, error handling), tag-aware commit messages, atomic commit pattern + +3. **Remove Command** ✅ COMPLETE + - Purpose & user value: Safely removes subtrees and updates configuration atomically, ensuring clean repository state and preventing orphaned configuration entries with idempotent behavior + - Success metrics: + - Removal completes in <5 seconds + - 100% of remove operations produce single commit (removal + config update) + - Config entries removed atomically with subtree directory + - Idempotent: succeeds when directory already deleted (exit code 0) + - Dependencies: Add Command + - Notes: Single atomic commit for removal + config update, validates subtree exists before removal, smart detection for directory state with context-aware success messages + - Delivered: All 2 user stories implemented (clean removal, idempotent removal), 191 tests passing, comprehensive error handling with exit codes 0/1/2/3 + +**Next:** `/speckit.specify "Feature: Case-Insensitive Names - Portable config validation and flexible name matching"` + +--- + +### Phase 3 — Advanced Operations & Safety + +**Goal:** Enable portable configuration validation and selective file extraction with comprehensive safety features + +**Key Features:** + +0. **Case-Insensitive Names & Validation** + - Purpose & user value: Enables flexible name matching for all commands (add, remove, update) while preventing duplicate names/prefixes across case variations, ensuring configs work portably across macOS (case-insensitive) and Linux (case-sensitive) filesystems + - Success metrics: + - Users can remove/update subtrees without remembering exact case (e.g., `remove hello-world` matches `Hello-World`) + - 100% of case-variant duplicate names detected during add (e.g., reject adding `Hello-World` + `hello-world`) + - 100% of case-variant duplicate prefixes detected during add (e.g., reject `vendor/lib` + `vendor/Lib`) + - Configs portable across all platforms (no macOS/Windows path conflicts) + - Dependencies: Add Command, Remove Command, Update Command + - Notes: Case-insensitive lookup for name matching in commands, case-insensitive duplicate validation for names AND prefixes, stores original case in config (case-preserving), prevents portability issues + +1. **Extract Command (Complete)** + - Purpose & user value: Copies files from subtrees to project structure using glob patterns with smart overwrite protection, enabling selective integration of upstream files (docs, templates, configs) without manual copying + - Success metrics: + - Ad-hoc extraction completes in <3 seconds for typical file sets + - Glob patterns match expected files with 100% accuracy + - Git-tracked files protected unless `--force` explicitly used + - Dependencies: Add Command + - Notes: Unified feature covering basic (`--from/--to`) and advanced (glob patterns, `**` globstar, `--all` for declared mappings, `--match` for filtering), `--persist` for saving mappings, `--force` for overrides, directory structure preserved relative to glob match + +2. **Lint Command** + - Purpose & user value: Validates subtree integrity and synchronization state offline and with remote checks, enabling users to detect configuration drift, missing subtrees, or desync between config and repository state + - Success metrics: + - Offline validation completes in <2 seconds + - 100% of config/repository mismatches detected and reported clearly + - Repair mode fixes discrepancies without manual intervention + - Remote validation detects divergence from upstream within 10 seconds + - Dependencies: Add Command + - Notes: Renamed from "validate" for clarity, offline mode (commit hash checks), `--with-remote` for upstream comparison, `--repair` mode, `--name` and `--from` for targeted validation + +**Next:** `/speckit.specify "Feature: CI Packaging - Automated releases with platform-specific binaries"` + +--- + +### Phase 4 — Production Readiness + +**Goal:** Deliver production-grade packaging and polished user experience + +**Key Features:** + +1. **CI Packaging & Binary Releases** + - Purpose & user value: Automated release packaging with platform-specific binaries distributed via GitHub Releases, enabling users to install pre-built binaries without Swift toolchain + - Success metrics: + - Release artifacts generated automatically on version tags + - Binaries available for macOS (arm64/x86_64) and Linux (x86_64/arm64) + - Users can install via single download + chmod command + - Swift artifact bundles include checksums for SPM integration + - Dependencies: Lint Command (all commands complete) + - Notes: GitHub Actions release workflow, artifact bundles for SPM, SHA256 checksums, installation instructions in releases + +2. **Polish & UX Refinements** + - Purpose & user value: Comprehensive UX improvements including progress indicators, enhanced error messages, and documentation site, reducing friction for new users and improving troubleshooting experience + - Success metrics: + - Long-running operations show progress indicators (no silent hangs) + - Error messages include suggested fixes 100% of the time + - New users complete first subtree add within 5 minutes using only docs + - Documentation site covers all commands with runnable examples + - Dependencies: CI Packaging + - Notes: Progress bars for git operations, emoji-prefixed messages throughout, comprehensive CHANGELOG, documentation site (GitHub Pages or similar), example repositories + +**Next:** Post-1.0 enhancements (interactive mode, config migration tools, advanced remapping) + +--- + +### Future Phases / Backlog + +**Not Yet Scheduled:** + +- **Config-First Add Workflow** — Add subtrees by reading pre-configured entries from `subtree.yaml` (declarative workflow) + - Purpose: Enables declarative workflow where users edit config first, then run `subtree add --name ` to apply + - Success metrics: Users can define subtrees in config and apply them without repeating CLI flags + - Dependencies: Add Command (CLI-First) + +- **Batch Add (--all flag)** — Add all configured subtrees in one command + - Purpose: Initial repository setup and bulk operations (e.g., `git clone && subtree add --all`) + - Success metrics: Users can populate all subtrees without manual iteration + - Dependencies: Config-First Add Workflow + - Notes: Requires detection logic to skip already-added subtrees + +- **Interactive Init Mode** — Guided configuration setup with prompts and validation (TTY-only feature for improved onboarding) + - Purpose: Reduces new user friction by providing step-by-step subtree configuration + - Success metrics: Users complete interactive init without documentation in <3 minutes + - Dependencies: Init Command + +- **Config Migration Tools** — Import existing git subtrees into `subtree.yaml` by scanning repository history + - Purpose: Enables adoption by projects already using git subtrees manually + - Success metrics: 90% of existing subtrees detected and imported correctly + - Dependencies: Lint Command + +- **Advanced Extract Remapping** — Complex path transformations and multi-source merging for extract operations + - Purpose: Supports advanced monorepo scenarios with nested subtree structures + - Success metrics: Users can remap nested paths without manual post-processing + - Dependencies: Extract Command + +- **Extract Flatten Mode (`--flatten` flag)** — Flatten extracted files into destination directory without preserving subdirectory structure + - Purpose: Enables simplified file layouts when subdirectory structure is unnecessary (e.g., copying all config files to single directory) + - Success metrics: Users can extract files flat when needed without manual post-processing + - Dependencies: Extract Command + - Notes: Complements default behavior (preserve structure relative to glob match); handles filename conflicts with clear errors + +- **Extract Dry-Run Mode (`--dry-run` flag)** — Preview extraction results without actually copying files + - Purpose: Enables users to validate glob patterns and check for conflicts before executing extraction + - Success metrics: Users can verify extraction plan (files matched, conflicts detected) without modifying filesystem + - Dependencies: Extract Command + - Notes: Shows file list with status indicators (new/overwrite/blocked), conflict warnings for git-tracked files, summary statistics + +- **Extract Auto-Stage Mode (`--stage` flag)** — Automatically stage extracted files for git commit + - Purpose: Streamlines workflow by staging extracted files immediately, reducing manual git add steps + - Success metrics: Users can extract and stage files in single command when desired + - Dependencies: Extract Command + - Notes: Optional flag (default behavior is manual staging); runs `git add` on extracted files after successful copy + +- **Dry-Run Mode** — Simulate git operations without committing changes for Update command + - Purpose: Enables safe testing of update commands to preview changes before applying + - Success metrics: Users can validate update behavior (fetch, merge simulation) without repository modification + - Dependencies: Update Command + - Notes: Complements report mode (which only checks availability); dry-run performs full validation including conflict detection + +- **Network Retry with Exponential Backoff** — Automatic retry logic for transient network failures during git operations + - Purpose: Improves reliability in unstable network environments and CI/CD pipelines + - Success metrics: 95% of transient network errors recover without manual intervention + - Dependencies: Update Command (primary use case), applies to Add/Remove as well + - Notes: Configurable retry count and backoff strategy, distinguishes transient errors (timeout, 503) from permanent failures (auth, 404) + +## Feature Areas + +**Core Management:** +- Init, Add, Update, Remove commands +- Atomic commit strategies ensuring config/repository synchronization +- Supports configuration-driven workflows + +**Validation & Safety:** +- Lint command for integrity checks (offline + remote) +- Overwrite protection for tracked files +- Git repository validation (must be inside git repo) +- Path safety validation (no `..`, no absolute paths) +- Repair mode for automatic fix of discrepancies + +**File Operations:** +- Extract command with glob pattern support +- Selective file copying from subtrees +- Copy mappings in config for repeatable extractions +- Dry-run and force modes + +**Developer Experience:** +- Comprehensive help system (`--help` at all levels) +- Clear, emoji-prefixed error messages +- Progress indicators for long operations +- Consistent exit codes for scripting + +**Platform & CI:** +- Cross-platform support (macOS 13+, Ubuntu 20.04 LTS) +- CI/CD friendly (report modes, predictable exit codes) +- Automated release packaging +- Swift Package Manager integration + +## Dependencies & Sequencing + +**Implementation Order:** + +1. **Foundation First** (Phase 1): Bootstrap → Schema → Init + *Rationale: Establishes test infrastructure, config format, and entry point* + +2. **Core Operations** (Phase 2): Add → Update → Remove + *Rationale: Enables complete subtree lifecycle, each builds on Add's atomic commit pattern* + +3. **Advanced Features** (Phase 3): Extract (unified) → Lint + *Rationale: Extract depends on subtrees existing (Add), Lint validates all previous operations* + +4. **Production Polish** (Phase 4): Packaging → UX Refinements + *Rationale: Distribution and polish come after feature completeness* + +**Cross-Release Dependencies:** + +- All Phase 2 commands depend on Phase 1 (Init) for config access +- Phase 3 Extract requires Phase 2 Add (subtrees must exist to extract from) +- Phase 3 Lint validates Phase 2 operations (add/update/remove state) +- Phase 4 Packaging requires all commands complete (nothing to package otherwise) + +## Metrics & Success Criteria (product-level) + +**Adoption Metrics:** +- **Personal/Team Use**: Successfully manages subtrees in 3+ personal/team projects within 6 months of 1.0 release +- **Open Source Community**: Achieves 50+ GitHub stars and 5+ external contributors within 12 months +- **CI Integration**: Used in CI pipelines for 3+ open source projects within 6 months + +**Usage Metrics:** +- **Time Savings**: Reduces subtree setup time from 15+ minutes (manual git commands) to <5 minutes (declarative config) +- **Command Success Rate**: 95%+ of commands complete successfully without user intervention +- **Error Recovery**: Users resolve errors without external help 90%+ of the time (clear error messages) + +**Quality Metrics:** +- **Reliability**: Zero data loss incidents in production use (git repository integrity maintained) +- **Performance**: All operations complete within documented time limits (init <1s, add <10s, update check <5s, extract <3s, lint <2s) +- **Cross-Platform**: 100% test pass rate on macOS 13+ and Ubuntu 20.04 LTS + +**Developer Experience:** +- **Onboarding**: New users complete first successful subtree add within 10 minutes +- **Documentation Quality**: Users find answers in docs without filing issues 80%+ of the time +- **Support Volume**: <2 support questions per 100 users per month (clarity of errors and docs) + +## Risks & Assumptions + +**Assumptions:** + +- Users have basic git knowledge (understand commits, branches, remotes) +- Git subtree command is available in user environments (standard git distribution) +- Users prefer declarative YAML configuration over CLI flags for repeated operations +- Most subtrees use standard git URL formats (https://, git@, file://) +- Users run commands from within git working directories (not bare repos) + +**Risks & Mitigations:** + +- **Risk:** Git subtree command behavior varies across git versions + *Mitigation:* Target git 2.x+ minimum, document tested versions, integration tests catch breaking changes + +- **Risk:** Users attempt to manage too many subtrees (100+), causing performance issues + *Mitigation:* Document recommended limits, optimize config parsing, add progress indicators for batch operations + +- **Risk:** Glob pattern complexity leads to unexpected file matches + *Mitigation:* Dry-run mode shows exactly what would be extracted, clear pattern validation errors + +- **Risk:** Concurrent operations on same repository cause conflicts + *Mitigation:* Atomic file operations for config updates (write temp + rename), git handles subtree operation locking + +- **Risk:** Limited adoption due to niche use case (subtrees less popular than submodules) + *Mitigation:* Focus on quality over quantity, highlight subtree advantages (simpler history, no .gitmodules), target users frustrated with submodules + +## Change Log + +- v1.4.0 (2025-10-29): Phase 2 complete - Remove Command delivered with idempotent behavior (191 tests passing), added Case-Insensitive Names feature to Phase 3 roadmap (MINOR - Phase 2 complete, Phase 3 refined scope) +- v1.3.0 (2025-10-28): Phase 2 progress update - Add Command and Update Command marked complete with production-ready implementations (MINOR - significant feature completion milestone, 2 of 3 Phase 2 commands delivered) +- v1.2.0 (2025-10-28): Update Command scope clarified - removed dry-run mode and topic branch mode from Phase 2, moved dry-run to backlog (MINOR - scope refinement for focused MVP) +- v1.1.0 (2025-10-27): Refined Phase 2 Add Command scope - CLI-First workflow only, moved Config-First workflow and --all flag to backlog (MINOR - scope reduction for simpler MVP) +- v1.0.0 (2025-10-27): Initial Subtree CLI roadmap created - complete product scope from foundation through production readiness \ No newline at end of file diff --git a/.specify/scripts/bash/check-prerequisites.sh b/.specify/scripts/bash/check-prerequisites.sh index d8e7930..54f32ec 100755 --- a/.specify/scripts/bash/check-prerequisites.sh +++ b/.specify/scripts/bash/check-prerequisites.sh @@ -82,34 +82,40 @@ source "$SCRIPT_DIR/common.sh" eval $(get_feature_paths) check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1 -# If paths-only mode, output paths and exit +# If paths-only mode, output paths and exit (support JSON + paths-only combined) if $PATHS_ONLY; then - echo "REPO_ROOT: $REPO_ROOT" - echo "BRANCH: $CURRENT_BRANCH" - echo "FEATURE_DIR: $FEATURE_DIR" - echo "FEATURE_SPEC: $FEATURE_SPEC" - echo "IMPL_PLAN: $IMPL_PLAN" - echo "TASKS: $TASKS" + if $JSON_MODE; then + # Minimal JSON paths payload (no validation performed) + printf '{"REPO_ROOT":"%s","BRANCH":"%s","FEATURE_DIR":"%s","FEATURE_SPEC":"%s","IMPL_PLAN":"%s","TASKS":"%s"}\n' \ + "$REPO_ROOT" "$CURRENT_BRANCH" "$FEATURE_DIR" "$FEATURE_SPEC" "$IMPL_PLAN" "$TASKS" + else + echo "REPO_ROOT: $REPO_ROOT" + echo "BRANCH: $CURRENT_BRANCH" + echo "FEATURE_DIR: $FEATURE_DIR" + echo "FEATURE_SPEC: $FEATURE_SPEC" + echo "IMPL_PLAN: $IMPL_PLAN" + echo "TASKS: $TASKS" + fi exit 0 fi # Validate required directories and files if [[ ! -d "$FEATURE_DIR" ]]; then echo "ERROR: Feature directory not found: $FEATURE_DIR" >&2 - echo "Run /specify first to create the feature structure." >&2 + echo "Run /speckit.specify first to create the feature structure." >&2 exit 1 fi if [[ ! -f "$IMPL_PLAN" ]]; then echo "ERROR: plan.md not found in $FEATURE_DIR" >&2 - echo "Run /plan first to create the implementation plan." >&2 + echo "Run /speckit.plan first to create the implementation plan." >&2 exit 1 fi # Check for tasks.md if required if $REQUIRE_TASKS && [[ ! -f "$TASKS" ]]; then echo "ERROR: tasks.md not found in $FEATURE_DIR" >&2 - echo "Run /tasks first to create the task list." >&2 + echo "Run /speckit.tasks first to create the task list." >&2 exit 1 fi @@ -157,4 +163,4 @@ else if $INCLUDE_TASKS; then check_file "$TASKS" "tasks.md" fi -fi \ No newline at end of file +fi diff --git a/.specify/scripts/bash/common.sh b/.specify/scripts/bash/common.sh index 34e5d4b..6931ecc 100755 --- a/.specify/scripts/bash/common.sh +++ b/.specify/scripts/bash/common.sh @@ -19,21 +19,21 @@ get_current_branch() { echo "$SPECIFY_FEATURE" return fi - + # Then check git if available if git rev-parse --abbrev-ref HEAD >/dev/null 2>&1; then git rev-parse --abbrev-ref HEAD return fi - + # For non-git repos, try to find the latest feature directory local repo_root=$(get_repo_root) local specs_dir="$repo_root/specs" - + if [[ -d "$specs_dir" ]]; then local latest_feature="" local highest=0 - + for dir in "$specs_dir"/*; do if [[ -d "$dir" ]]; then local dirname=$(basename "$dir") @@ -47,13 +47,13 @@ get_current_branch() { fi fi done - + if [[ -n "$latest_feature" ]]; then echo "$latest_feature" return fi fi - + echo "main" # Final fallback } @@ -65,35 +65,77 @@ has_git() { check_feature_branch() { local branch="$1" local has_git_repo="$2" - + # For non-git repos, we can't enforce branch naming but still provide output if [[ "$has_git_repo" != "true" ]]; then echo "[specify] Warning: Git repository not detected; skipped branch validation" >&2 return 0 fi - + if [[ ! "$branch" =~ ^[0-9]{3}- ]]; then echo "ERROR: Not on a feature branch. Current branch: $branch" >&2 echo "Feature branches should be named like: 001-feature-name" >&2 return 1 fi - + return 0 } get_feature_dir() { echo "$1/specs/$2"; } +# Find feature directory by numeric prefix instead of exact branch match +# This allows multiple branches to work on the same spec (e.g., 004-fix-bug, 004-add-feature) +find_feature_dir_by_prefix() { + local repo_root="$1" + local branch_name="$2" + local specs_dir="$repo_root/specs" + + # Extract numeric prefix from branch (e.g., "004" from "004-whatever") + if [[ ! "$branch_name" =~ ^([0-9]{3})- ]]; then + # If branch doesn't have numeric prefix, fall back to exact match + echo "$specs_dir/$branch_name" + return + fi + + local prefix="${BASH_REMATCH[1]}" + + # Search for directories in specs/ that start with this prefix + local matches=() + if [[ -d "$specs_dir" ]]; then + for dir in "$specs_dir"/"$prefix"-*; do + if [[ -d "$dir" ]]; then + matches+=("$(basename "$dir")") + fi + done + fi + + # Handle results + if [[ ${#matches[@]} -eq 0 ]]; then + # No match found - return the branch name path (will fail later with clear error) + echo "$specs_dir/$branch_name" + elif [[ ${#matches[@]} -eq 1 ]]; then + # Exactly one match - perfect! + echo "$specs_dir/${matches[0]}" + else + # Multiple matches - this shouldn't happen with proper naming convention + echo "ERROR: Multiple spec directories found with prefix '$prefix': ${matches[*]}" >&2 + echo "Please ensure only one spec directory exists per numeric prefix." >&2 + echo "$specs_dir/$branch_name" # Return something to avoid breaking the script + fi +} + get_feature_paths() { local repo_root=$(get_repo_root) local current_branch=$(get_current_branch) local has_git_repo="false" - + if has_git; then has_git_repo="true" fi - - local feature_dir=$(get_feature_dir "$repo_root" "$current_branch") - + + # Use prefix-based lookup to support multiple branches per spec + local feature_dir=$(find_feature_dir_by_prefix "$repo_root" "$current_branch") + cat </dev/null) ]] && echo " ✓ $2" || echo " ✗ $2"; } + diff --git a/.specify/scripts/bash/create-new-feature.sh b/.specify/scripts/bash/create-new-feature.sh index 6670550..86d9ecf 100755 --- a/.specify/scripts/bash/create-new-feature.sh +++ b/.specify/scripts/bash/create-new-feature.sh @@ -3,18 +3,67 @@ set -e JSON_MODE=false +SHORT_NAME="" +BRANCH_NUMBER="" ARGS=() -for arg in "$@"; do +i=1 +while [ $i -le $# ]; do + arg="${!i}" case "$arg" in - --json) JSON_MODE=true ;; - --help|-h) echo "Usage: $0 [--json] "; exit 0 ;; - *) ARGS+=("$arg") ;; + --json) + JSON_MODE=true + ;; + --short-name) + if [ $((i + 1)) -gt $# ]; then + echo 'Error: --short-name requires a value' >&2 + exit 1 + fi + i=$((i + 1)) + next_arg="${!i}" + # Check if the next argument is another option (starts with --) + if [[ "$next_arg" == --* ]]; then + echo 'Error: --short-name requires a value' >&2 + exit 1 + fi + SHORT_NAME="$next_arg" + ;; + --number) + if [ $((i + 1)) -gt $# ]; then + echo 'Error: --number requires a value' >&2 + exit 1 + fi + i=$((i + 1)) + next_arg="${!i}" + if [[ "$next_arg" == --* ]]; then + echo 'Error: --number requires a value' >&2 + exit 1 + fi + BRANCH_NUMBER="$next_arg" + ;; + --help|-h) + echo "Usage: $0 [--json] [--short-name ] [--number N] " + echo "" + echo "Options:" + echo " --json Output in JSON format" + echo " --short-name Provide a custom short name (2-4 words) for the branch" + echo " --number N Specify branch number manually (overrides auto-detection)" + echo " --help, -h Show this help message" + echo "" + echo "Examples:" + echo " $0 'Add user authentication system' --short-name 'user-auth'" + echo " $0 'Implement OAuth2 integration for API' --number 5" + exit 0 + ;; + *) + ARGS+=("$arg") + ;; esac + i=$((i + 1)) done FEATURE_DESCRIPTION="${ARGS[*]}" if [ -z "$FEATURE_DESCRIPTION" ]; then - echo "Usage: $0 [--json] " >&2 + echo "Usage: $0 [--json] [--short-name ] [--number N] " >&2 exit 1 fi @@ -31,6 +80,37 @@ find_repo_root() { return 1 } +# Function to check existing branches (local and remote) and return next available number +check_existing_branches() { + local short_name="$1" + + # Fetch all remotes to get latest branch info (suppress errors if no remotes) + git fetch --all --prune 2>/dev/null || true + + # Find all branches matching the pattern using git ls-remote (more reliable) + local remote_branches=$(git ls-remote --heads origin 2>/dev/null | grep -E "refs/heads/[0-9]+-${short_name}$" | sed 's/.*\/\([0-9]*\)-.*/\1/' | sort -n) + + # Also check local branches + local local_branches=$(git branch 2>/dev/null | grep -E "^[* ]*[0-9]+-${short_name}$" | sed 's/^[* ]*//' | sed 's/-.*//' | sort -n) + + # Check specs directory as well + local spec_dirs="" + if [ -d "$SPECS_DIR" ]; then + spec_dirs=$(find "$SPECS_DIR" -maxdepth 1 -type d -name "[0-9]*-${short_name}" 2>/dev/null | xargs -n1 basename 2>/dev/null | sed 's/-.*//' | sort -n) + fi + + # Combine all sources and get the highest number + local max_num=0 + for num in $remote_branches $local_branches $spec_dirs; do + if [ "$num" -gt "$max_num" ]; then + max_num=$num + fi + done + + # Return next number + echo $((max_num + 1)) +} + # Resolve repository root. Prefer git information when available, but fall back # to searching for repository markers so the workflow still functions in repositories that # were initialised with --no-git. @@ -53,23 +133,106 @@ cd "$REPO_ROOT" SPECS_DIR="$REPO_ROOT/specs" mkdir -p "$SPECS_DIR" -HIGHEST=0 -if [ -d "$SPECS_DIR" ]; then - for dir in "$SPECS_DIR"/*; do - [ -d "$dir" ] || continue - dirname=$(basename "$dir") - number=$(echo "$dirname" | grep -o '^[0-9]\+' || echo "0") - number=$((10#$number)) - if [ "$number" -gt "$HIGHEST" ]; then HIGHEST=$number; fi +# Function to generate branch name with stop word filtering and length filtering +generate_branch_name() { + local description="$1" + + # Common stop words to filter out + local stop_words="^(i|a|an|the|to|for|of|in|on|at|by|with|from|is|are|was|were|be|been|being|have|has|had|do|does|did|will|would|should|could|can|may|might|must|shall|this|that|these|those|my|your|our|their|want|need|add|get|set)$" + + # Convert to lowercase and split into words + local clean_name=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/ /g') + + # Filter words: remove stop words and words shorter than 3 chars (unless they're uppercase acronyms in original) + local meaningful_words=() + for word in $clean_name; do + # Skip empty words + [ -z "$word" ] && continue + + # Keep words that are NOT stop words AND (length >= 3 OR are potential acronyms) + if ! echo "$word" | grep -qiE "$stop_words"; then + if [ ${#word} -ge 3 ]; then + meaningful_words+=("$word") + elif echo "$description" | grep -q "\b${word^^}\b"; then + # Keep short words if they appear as uppercase in original (likely acronyms) + meaningful_words+=("$word") + fi + fi done + + # If we have meaningful words, use first 3-4 of them + if [ ${#meaningful_words[@]} -gt 0 ]; then + local max_words=3 + if [ ${#meaningful_words[@]} -eq 4 ]; then max_words=4; fi + + local result="" + local count=0 + for word in "${meaningful_words[@]}"; do + if [ $count -ge $max_words ]; then break; fi + if [ -n "$result" ]; then result="$result-"; fi + result="$result$word" + count=$((count + 1)) + done + echo "$result" + else + # Fallback to original logic if no meaningful words found + echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//' | tr '-' '\n' | grep -v '^$' | head -3 | tr '\n' '-' | sed 's/-$//' + fi +} + +# Generate branch name +if [ -n "$SHORT_NAME" ]; then + # Use provided short name, just clean it up + BRANCH_SUFFIX=$(echo "$SHORT_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//') +else + # Generate from description with smart filtering + BRANCH_SUFFIX=$(generate_branch_name "$FEATURE_DESCRIPTION") fi -NEXT=$((HIGHEST + 1)) -FEATURE_NUM=$(printf "%03d" "$NEXT") +# Determine branch number +if [ -z "$BRANCH_NUMBER" ]; then + if [ "$HAS_GIT" = true ]; then + # Check existing branches on remotes + BRANCH_NUMBER=$(check_existing_branches "$BRANCH_SUFFIX") + else + # Fall back to local directory check + HIGHEST=0 + if [ -d "$SPECS_DIR" ]; then + for dir in "$SPECS_DIR"/*; do + [ -d "$dir" ] || continue + dirname=$(basename "$dir") + number=$(echo "$dirname" | grep -o '^[0-9]\+' || echo "0") + number=$((10#$number)) + if [ "$number" -gt "$HIGHEST" ]; then HIGHEST=$number; fi + done + fi + BRANCH_NUMBER=$((HIGHEST + 1)) + fi +fi + +FEATURE_NUM=$(printf "%03d" "$BRANCH_NUMBER") +BRANCH_NAME="${FEATURE_NUM}-${BRANCH_SUFFIX}" -BRANCH_NAME=$(echo "$FEATURE_DESCRIPTION" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//') -WORDS=$(echo "$BRANCH_NAME" | tr '-' '\n' | grep -v '^$' | head -3 | tr '\n' '-' | sed 's/-$//') -BRANCH_NAME="${FEATURE_NUM}-${WORDS}" +# GitHub enforces a 244-byte limit on branch names +# Validate and truncate if necessary +MAX_BRANCH_LENGTH=244 +if [ ${#BRANCH_NAME} -gt $MAX_BRANCH_LENGTH ]; then + # Calculate how much we need to trim from suffix + # Account for: feature number (3) + hyphen (1) = 4 chars + MAX_SUFFIX_LENGTH=$((MAX_BRANCH_LENGTH - 4)) + + # Truncate suffix at word boundary if possible + TRUNCATED_SUFFIX=$(echo "$BRANCH_SUFFIX" | cut -c1-$MAX_SUFFIX_LENGTH) + # Remove trailing hyphen if truncation created one + TRUNCATED_SUFFIX=$(echo "$TRUNCATED_SUFFIX" | sed 's/-$//') + + ORIGINAL_BRANCH_NAME="$BRANCH_NAME" + BRANCH_NAME="${FEATURE_NUM}-${TRUNCATED_SUFFIX}" + + >&2 echo "[specify] Warning: Branch name exceeded GitHub's 244-byte limit" + >&2 echo "[specify] Original: $ORIGINAL_BRANCH_NAME (${#ORIGINAL_BRANCH_NAME} bytes)" + >&2 echo "[specify] Truncated to: $BRANCH_NAME (${#BRANCH_NAME} bytes)" +fi if [ "$HAS_GIT" = true ]; then git checkout -b "$BRANCH_NAME" @@ -80,7 +243,7 @@ fi FEATURE_DIR="$SPECS_DIR/$BRANCH_NAME" mkdir -p "$FEATURE_DIR" -TEMPLATE="$REPO_ROOT/templates/spec-template.md" +TEMPLATE="$REPO_ROOT/.specify/templates/spec-template.md" SPEC_FILE="$FEATURE_DIR/spec.md" if [ -f "$TEMPLATE" ]; then cp "$TEMPLATE" "$SPEC_FILE"; else touch "$SPEC_FILE"; fi diff --git a/.specify/scripts/bash/setup-plan.sh b/.specify/scripts/bash/setup-plan.sh index 654ba50..740a143 100755 --- a/.specify/scripts/bash/setup-plan.sh +++ b/.specify/scripts/bash/setup-plan.sh @@ -58,3 +58,4 @@ else echo "BRANCH: $CURRENT_BRANCH" echo "HAS_GIT: $HAS_GIT" fi + diff --git a/.specify/scripts/bash/update-agent-context.sh b/.specify/scripts/bash/update-agent-context.sh index d3cc422..2a44c68 100755 --- a/.specify/scripts/bash/update-agent-context.sh +++ b/.specify/scripts/bash/update-agent-context.sh @@ -30,12 +30,12 @@ # # 5. Multi-Agent Support # - Handles agent-specific file paths and naming conventions -# - Supports: Claude, Gemini, Copilot, Cursor, Qwen, opencode, Codex, Windsurf +# - Supports: Claude, Gemini, Copilot, Cursor, Qwen, opencode, Codex, Windsurf, Kilo Code, Auggie CLI, Roo Code, CodeBuddy CLI, Amp, or Amazon Q Developer CLI # - Can update single agents or all existing agent files # - Creates default Claude file if no agent files exist # # Usage: ./update-agent-context.sh [agent_type] -# Agent types: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf +# Agent types: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|q # Leave empty to update all existing agent files set -e @@ -69,6 +69,9 @@ WINDSURF_FILE="$REPO_ROOT/.windsurf/rules/specify-rules.md" KILOCODE_FILE="$REPO_ROOT/.kilocode/rules/specify-rules.md" AUGGIE_FILE="$REPO_ROOT/.augment/rules/specify-rules.md" ROO_FILE="$REPO_ROOT/.roo/rules/specify-rules.md" +CODEBUDDY_FILE="$REPO_ROOT/CODEBUDDY.md" +AMP_FILE="$REPO_ROOT/AGENTS.md" +Q_FILE="$REPO_ROOT/AGENTS.md" # Template file TEMPLATE_FILE="$REPO_ROOT/.specify/templates/agent-file-template.md" @@ -248,7 +251,7 @@ get_commands_for_language() { echo "cargo test && cargo clippy" ;; *"JavaScript"*|*"TypeScript"*) - echo "npm test && npm run lint" + echo "npm test \\&\\& npm run lint" ;; *) echo "# Add commands for $lang" @@ -388,12 +391,25 @@ update_existing_agent_file() { new_change_entry="- $CURRENT_BRANCH: Added $NEW_DB" fi + # Check if sections exist in the file + local has_active_technologies=0 + local has_recent_changes=0 + + if grep -q "^## Active Technologies" "$target_file" 2>/dev/null; then + has_active_technologies=1 + fi + + if grep -q "^## Recent Changes" "$target_file" 2>/dev/null; then + has_recent_changes=1 + fi + # Process file line by line local in_tech_section=false local in_changes_section=false local tech_entries_added=false local changes_entries_added=false local existing_changes_count=0 + local file_ended=false while IFS= read -r line || [[ -n "$line" ]]; do # Handle Active Technologies section @@ -454,6 +470,22 @@ update_existing_agent_file() { # Post-loop check: if we're still in the Active Technologies section and haven't added new entries if [[ $in_tech_section == true ]] && [[ $tech_entries_added == false ]] && [[ ${#new_tech_entries[@]} -gt 0 ]]; then printf '%s\n' "${new_tech_entries[@]}" >> "$temp_file" + tech_entries_added=true + fi + + # If sections don't exist, add them at the end of the file + if [[ $has_active_technologies -eq 0 ]] && [[ ${#new_tech_entries[@]} -gt 0 ]]; then + echo "" >> "$temp_file" + echo "## Active Technologies" >> "$temp_file" + printf '%s\n' "${new_tech_entries[@]}" >> "$temp_file" + tech_entries_added=true + fi + + if [[ $has_recent_changes -eq 0 ]] && [[ -n "$new_change_entry" ]]; then + echo "" >> "$temp_file" + echo "## Recent Changes" >> "$temp_file" + echo "$new_change_entry" >> "$temp_file" + changes_entries_added=true fi # Move temp file to target atomically @@ -556,7 +588,7 @@ update_specific_agent() { copilot) update_agent_file "$COPILOT_FILE" "GitHub Copilot" ;; - cursor) + cursor-agent) update_agent_file "$CURSOR_FILE" "Cursor IDE" ;; qwen) @@ -580,9 +612,18 @@ update_specific_agent() { roo) update_agent_file "$ROO_FILE" "Roo Code" ;; + codebuddy) + update_agent_file "$CODEBUDDY_FILE" "CodeBuddy CLI" + ;; + amp) + update_agent_file "$AMP_FILE" "Amp" + ;; + q) + update_agent_file "$Q_FILE" "Amazon Q Developer CLI" + ;; *) log_error "Unknown agent type '$agent_type'" - log_error "Expected: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo" + log_error "Expected: claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|roo|amp|q" exit 1 ;; esac @@ -641,6 +682,16 @@ update_all_existing_agents() { update_agent_file "$ROO_FILE" "Roo Code" found_agent=true fi + + if [[ -f "$CODEBUDDY_FILE" ]]; then + update_agent_file "$CODEBUDDY_FILE" "CodeBuddy CLI" + found_agent=true + fi + + if [[ -f "$Q_FILE" ]]; then + update_agent_file "$Q_FILE" "Amazon Q Developer CLI" + found_agent=true + fi # If no agent files exist, create a default Claude file if [[ "$found_agent" == false ]]; then @@ -665,7 +716,8 @@ print_summary() { fi echo - log_info "Usage: $0 [claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo]" + + log_info "Usage: $0 [claude|gemini|copilot|cursor-agent|qwen|opencode|codex|windsurf|kilocode|auggie|codebuddy|q]" } #============================================================================== @@ -717,3 +769,4 @@ main() { if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then main "$@" fi + diff --git a/.specify/templates/agent-file-template.md b/.specify/templates/agent-file-template.md index 2301e0e..4cc7fd6 100644 --- a/.specify/templates/agent-file-template.md +++ b/.specify/templates/agent-file-template.md @@ -3,21 +3,26 @@ Auto-generated from all feature plans. Last updated: [DATE] ## Active Technologies + [EXTRACTED FROM ALL PLAN.MD FILES] ## Project Structure -``` + +```text [ACTUAL STRUCTURE FROM PLANS] ``` ## Commands + [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES] ## Code Style + [LANGUAGE-SPECIFIC, ONLY FOR LANGUAGES IN USE] ## Recent Changes + [LAST 3 FEATURES AND WHAT THEY ADDED] - \ No newline at end of file + diff --git a/.specify/templates/checklist-template.md b/.specify/templates/checklist-template.md new file mode 100644 index 0000000..806657d --- /dev/null +++ b/.specify/templates/checklist-template.md @@ -0,0 +1,40 @@ +# [CHECKLIST TYPE] Checklist: [FEATURE NAME] + +**Purpose**: [Brief description of what this checklist covers] +**Created**: [DATE] +**Feature**: [Link to spec.md or relevant documentation] + +**Note**: This checklist is generated by the `/speckit.checklist` command based on feature context and requirements. + + + +## [Category 1] + +- [ ] CHK001 First checklist item with clear action +- [ ] CHK002 Second checklist item +- [ ] CHK003 Third checklist item + +## [Category 2] + +- [ ] CHK004 Another category item +- [ ] CHK005 Item with specific criteria +- [ ] CHK006 Final item in this category + +## Notes + +- Check items off as completed: `[x]` +- Add comments or findings inline +- Link to relevant resources or documentation +- Items are numbered sequentially for easy reference diff --git a/.specify/templates/plan-template.md b/.specify/templates/plan-template.md index 9115d1a..6a8bfc6 100644 --- a/.specify/templates/plan-template.md +++ b/.specify/templates/plan-template.md @@ -1,39 +1,22 @@ - # Implementation Plan: [FEATURE] **Branch**: `[###-feature-name]` | **Date**: [DATE] | **Spec**: [link] **Input**: Feature specification from `/specs/[###-feature-name]/spec.md` -## Execution Flow (/plan command scope) -``` -1. Load feature spec from Input path - → If not found: ERROR "No feature spec at {path}" -2. Fill Technical Context (scan for NEEDS CLARIFICATION) - → Detect Project Type from context (web=frontend+backend, mobile=app+api) - → Set Structure Decision based on project type -3. Fill the Constitution Check section based on the content of the constitution document. -4. Evaluate Constitution Check section below - → If violations exist: Document in Complexity Tracking - → If no justification possible: ERROR "Simplify approach first" - → Update Progress Tracking: Initial Constitution Check -5. Execute Phase 0 → research.md - → If NEEDS CLARIFICATION remain: ERROR "Resolve unknowns" -6. Execute Phase 1 → contracts, data-model.md, quickstart.md, agent-specific template file (e.g., `CLAUDE.md` for Claude Code, `.github/copilot-instructions.md` for GitHub Copilot, `GEMINI.md` for Gemini CLI, `QWEN.md` for Qwen Code or `AGENTS.md` for opencode). -7. Re-evaluate Constitution Check section - → If new violations: Refactor design, return to Phase 1 - → Update Progress Tracking: Post-Design Constitution Check -8. Plan Phase 2 → Describe task generation approach (DO NOT create tasks.md) -9. STOP - Ready for /tasks command -``` - -**IMPORTANT**: The /plan command STOPS at step 7. Phases 2-4 are executed by other commands: -- Phase 2: /tasks command creates tasks.md -- Phase 3-4: Implementation execution (manual or via tools) +**Note**: This template is filled in by the `/speckit.plan` command. See `.specify/templates/commands/plan.md` for the execution workflow. ## Summary + [Extract from feature spec: primary requirement + technical approach from research] ## Technical Context + + + **Language/Version**: [e.g., Python 3.11, Swift 5.9, Rust 1.75 or NEEDS CLARIFICATION] **Primary Dependencies**: [e.g., FastAPI, UIKit, LLVM or NEEDS CLARIFICATION] **Storage**: [if applicable, e.g., PostgreSQL, CoreData, files or N/A] @@ -45,6 +28,7 @@ **Scale/Scope**: [domain-specific, e.g., 10k users, 1M LOC, 50 screens or NEEDS CLARIFICATION] ## Constitution Check + *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.* [Gates determined based on constitution file] @@ -52,19 +36,27 @@ ## Project Structure ### Documentation (this feature) -``` + +```text specs/[###-feature]/ -├── plan.md # This file (/plan command output) -├── research.md # Phase 0 output (/plan command) -├── data-model.md # Phase 1 output (/plan command) -├── quickstart.md # Phase 1 output (/plan command) -├── contracts/ # Phase 1 output (/plan command) -└── tasks.md # Phase 2 output (/tasks command - NOT created by /plan) +├── plan.md # This file (/speckit.plan command output) +├── research.md # Phase 0 output (/speckit.plan command) +├── data-model.md # Phase 1 output (/speckit.plan command) +├── quickstart.md # Phase 1 output (/speckit.plan command) +├── contracts/ # Phase 1 output (/speckit.plan command) +└── tasks.md # Phase 2 output (/speckit.tasks command - NOT created by /speckit.plan) ``` ### Source Code (repository root) -``` -# Option 1: Single project (DEFAULT) + + +```text +# [REMOVE IF UNUSED] Option 1: Single project (DEFAULT) src/ ├── models/ ├── services/ @@ -76,7 +68,7 @@ tests/ ├── integration/ └── unit/ -# Option 2: Web application (when "frontend" + "backend" detected) +# [REMOVE IF UNUSED] Option 2: Web application (when "frontend" + "backend" detected) backend/ ├── src/ │ ├── models/ @@ -91,122 +83,22 @@ frontend/ │ └── services/ └── tests/ -# Option 3: Mobile + API (when "iOS/Android" detected) +# [REMOVE IF UNUSED] Option 3: Mobile + API (when "iOS/Android" detected) api/ └── [same as backend above] ios/ or android/ -└── [platform-specific structure] +└── [platform-specific structure: feature modules, UI flows, platform tests] ``` -**Structure Decision**: [DEFAULT to Option 1 unless Technical Context indicates web/mobile app] - -## Phase 0: Outline & Research -1. **Extract unknowns from Technical Context** above: - - For each NEEDS CLARIFICATION → research task - - For each dependency → best practices task - - For each integration → patterns task - -2. **Generate and dispatch research agents**: - ``` - For each unknown in Technical Context: - Task: "Research {unknown} for {feature context}" - For each technology choice: - Task: "Find best practices for {tech} in {domain}" - ``` - -3. **Consolidate findings** in `research.md` using format: - - Decision: [what was chosen] - - Rationale: [why chosen] - - Alternatives considered: [what else evaluated] - -**Output**: research.md with all NEEDS CLARIFICATION resolved - -## Phase 1: Design & Contracts -*Prerequisites: research.md complete* - -1. **Extract entities from feature spec** → `data-model.md`: - - Entity name, fields, relationships - - Validation rules from requirements - - State transitions if applicable - -2. **Generate API contracts** from functional requirements: - - For each user action → endpoint - - Use standard REST/GraphQL patterns - - Output OpenAPI/GraphQL schema to `/contracts/` - -3. **Generate contract tests** from contracts: - - One test file per endpoint - - Assert request/response schemas - - Tests must fail (no implementation yet) - -4. **Extract test scenarios** from user stories: - - Each story → integration test scenario - - Quickstart test = story validation steps - -5. **Update agent file incrementally** (O(1) operation): - - Run `.specify/scripts/bash/update-agent-context.sh windsurf` - **IMPORTANT**: Execute it exactly as specified above. Do not add or remove any arguments. - - If exists: Add only NEW tech from current plan - - Preserve manual additions between markers - - Update recent changes (keep last 3) - - Keep under 150 lines for token efficiency - - Output to repository root - -**Output**: data-model.md, /contracts/*, failing tests, quickstart.md, agent-specific file - -## Phase 2: Task Planning Approach -*This section describes what the /tasks command will do - DO NOT execute during /plan* - -**Task Generation Strategy**: -- Load `.specify/templates/tasks-template.md` as base -- Generate tasks from Phase 1 design docs (contracts, data model, quickstart) -- Each contract → contract test task [P] -- Each entity → model creation task [P] -- Each user story → integration test task -- Implementation tasks to make tests pass - -**Ordering Strategy**: -- TDD order: Tests before implementation -- Dependency order: Models before services before UI -- Mark [P] for parallel execution (independent files) - -**Estimated Output**: 25-30 numbered, ordered tasks in tasks.md - -**IMPORTANT**: This phase is executed by the /tasks command, NOT by /plan - -## Phase 3+: Future Implementation -*These phases are beyond the scope of the /plan command* - -**Phase 3**: Task execution (/tasks command creates tasks.md) -**Phase 4**: Implementation (execute tasks.md following constitutional principles) -**Phase 5**: Validation (run tests, execute quickstart.md, performance validation) +**Structure Decision**: [Document the selected structure and reference the real +directories captured above] ## Complexity Tracking -*Fill ONLY if Constitution Check has violations that must be justified* + +> **Fill ONLY if Constitution Check has violations that must be justified** | Violation | Why Needed | Simpler Alternative Rejected Because | |-----------|------------|-------------------------------------| | [e.g., 4th project] | [current need] | [why 3 projects insufficient] | | [e.g., Repository pattern] | [specific problem] | [why direct DB access insufficient] | - - -## Progress Tracking -*This checklist is updated during execution flow* - -**Phase Status**: -- [ ] Phase 0: Research complete (/plan command) -- [ ] Phase 1: Design complete (/plan command) -- [ ] Phase 2: Task planning complete (/plan command - describe approach only) -- [ ] Phase 3: Tasks generated (/tasks command) -- [ ] Phase 4: Implementation complete -- [ ] Phase 5: Validation passed - -**Gate Status**: -- [ ] Initial Constitution Check: PASS -- [ ] Post-Design Constitution Check: PASS -- [ ] All NEEDS CLARIFICATION resolved -- [ ] Complexity deviations documented - ---- -*Based on Constitution v1.0.0 - See `.specify/memory/constitution.md`* diff --git a/.specify/templates/spec-template.md b/.specify/templates/spec-template.md index 7915e7d..c67d914 100644 --- a/.specify/templates/spec-template.md +++ b/.specify/templates/spec-template.md @@ -5,69 +5,85 @@ **Status**: Draft **Input**: User description: "$ARGUMENTS" -## Execution Flow (main) -``` -1. Parse user description from Input - → If empty: ERROR "No feature description provided" -2. Extract key concepts from description - → Identify: actors, actions, data, constraints -3. For each unclear aspect: - → Mark with [NEEDS CLARIFICATION: specific question] -4. Fill User Scenarios & Testing section - → If no clear user flow: ERROR "Cannot determine user scenarios" -5. Generate Functional Requirements - → Each requirement must be testable - → Mark ambiguous requirements -6. Identify Key Entities (if data involved) -7. Run Review Checklist - → If any [NEEDS CLARIFICATION]: WARN "Spec has uncertainties" - → If implementation details found: ERROR "Remove tech details" -8. Return: SUCCESS (spec ready for planning) -``` +## User Scenarios & Testing *(mandatory)* + + + +### User Story 1 - [Brief Title] (Priority: P1) + +[Describe this user journey in plain language] + +**Why this priority**: [Explain the value and why it has this priority level] + +**Independent Test**: [Describe how this can be tested independently - e.g., "Can be fully tested by [specific action] and delivers [specific value]"] + +**Acceptance Scenarios**: + +1. **Given** [initial state], **When** [action], **Then** [expected outcome] +2. **Given** [initial state], **When** [action], **Then** [expected outcome] --- -## ⚡ Quick Guidelines -- ✅ Focus on WHAT users need and WHY -- ❌ Avoid HOW to implement (no tech stack, APIs, code structure) -- 👥 Written for business stakeholders, not developers - -### Section Requirements -- **Mandatory sections**: Must be completed for every feature -- **Optional sections**: Include only when relevant to the feature -- When a section doesn't apply, remove it entirely (don't leave as "N/A") - -### For AI Generation -When creating this spec from a user prompt: -1. **Mark all ambiguities**: Use [NEEDS CLARIFICATION: specific question] for any assumption you'd need to make -2. **Don't guess**: If the prompt doesn't specify something (e.g., "login system" without auth method), mark it -3. **Think like a tester**: Every vague requirement should fail the "testable and unambiguous" checklist item -4. **Common underspecified areas**: - - User types and permissions - - Data retention/deletion policies - - Performance targets and scale - - Error handling behaviors - - Integration requirements - - Security/compliance needs +### User Story 2 - [Brief Title] (Priority: P2) + +[Describe this user journey in plain language] + +**Why this priority**: [Explain the value and why it has this priority level] + +**Independent Test**: [Describe how this can be tested independently] + +**Acceptance Scenarios**: + +1. **Given** [initial state], **When** [action], **Then** [expected outcome] --- -## User Scenarios & Testing *(mandatory)* +### User Story 3 - [Brief Title] (Priority: P3) + +[Describe this user journey in plain language] + +**Why this priority**: [Explain the value and why it has this priority level] -### Primary User Story -[Describe the main user journey in plain language] +**Independent Test**: [Describe how this can be tested independently] + +**Acceptance Scenarios**: -### Acceptance Scenarios 1. **Given** [initial state], **When** [action], **Then** [expected outcome] -2. **Given** [initial state], **When** [action], **Then** [expected outcome] + +--- + +[Add more user stories as needed, each with an assigned priority] ### Edge Cases + + + - What happens when [boundary condition]? - How does system handle [error scenario]? ## Requirements *(mandatory)* + + ### Functional Requirements + - **FR-001**: System MUST [specific capability, e.g., "allow users to create accounts"] - **FR-002**: System MUST [specific capability, e.g., "validate email addresses"] - **FR-003**: Users MUST be able to [key interaction, e.g., "reset their password"] @@ -75,42 +91,25 @@ When creating this spec from a user prompt: - **FR-005**: System MUST [behavior, e.g., "log all security events"] *Example of marking unclear requirements:* + - **FR-006**: System MUST authenticate users via [NEEDS CLARIFICATION: auth method not specified - email/password, SSO, OAuth?] - **FR-007**: System MUST retain user data for [NEEDS CLARIFICATION: retention period not specified] ### Key Entities *(include if feature involves data)* + - **[Entity 1]**: [What it represents, key attributes without implementation] - **[Entity 2]**: [What it represents, relationships to other entities] ---- +## Success Criteria *(mandatory)* -## Review & Acceptance Checklist -*GATE: Automated checks run during main() execution* + -### Content Quality -- [ ] No implementation details (languages, frameworks, APIs) -- [ ] Focused on user value and business needs -- [ ] Written for non-technical stakeholders -- [ ] All mandatory sections completed +### Measurable Outcomes -### Requirement Completeness -- [ ] No [NEEDS CLARIFICATION] markers remain -- [ ] Requirements are testable and unambiguous -- [ ] Success criteria are measurable -- [ ] Scope is clearly bounded -- [ ] Dependencies and assumptions identified - ---- - -## Execution Status -*Updated by main() during processing* - -- [ ] User description parsed -- [ ] Key concepts extracted -- [ ] Ambiguities marked -- [ ] User scenarios defined -- [ ] Requirements generated -- [ ] Entities identified -- [ ] Review checklist passed - ---- +- **SC-001**: [Measurable metric, e.g., "Users can complete account creation in under 2 minutes"] +- **SC-002**: [Measurable metric, e.g., "System handles 1000 concurrent users without degradation"] +- **SC-003**: [User satisfaction metric, e.g., "90% of users successfully complete primary task on first attempt"] +- **SC-004**: [Business metric, e.g., "Reduce support tickets related to [X] by 50%"] diff --git a/.specify/templates/tasks-template.md b/.specify/templates/tasks-template.md index b8a28fa..60f9be4 100644 --- a/.specify/templates/tasks-template.md +++ b/.specify/templates/tasks-template.md @@ -1,127 +1,251 @@ +--- + +description: "Task list template for feature implementation" +--- + # Tasks: [FEATURE NAME] **Input**: Design documents from `/specs/[###-feature-name]/` -**Prerequisites**: plan.md (required), research.md, data-model.md, contracts/ +**Prerequisites**: plan.md (required), spec.md (required for user stories), research.md, data-model.md, contracts/ -## Execution Flow (main) -``` -1. Load plan.md from feature directory - → If not found: ERROR "No implementation plan found" - → Extract: tech stack, libraries, structure -2. Load optional design documents: - → data-model.md: Extract entities → model tasks - → contracts/: Each file → contract test task - → research.md: Extract decisions → setup tasks -3. Generate tasks by category: - → Setup: project init, dependencies, linting - → Tests: contract tests, integration tests - → Core: models, services, CLI commands - → Integration: DB, middleware, logging - → Polish: unit tests, performance, docs -4. Apply task rules: - → Different files = mark [P] for parallel - → Same file = sequential (no [P]) - → Tests before implementation (TDD) -5. Number tasks sequentially (T001, T002...) -6. Generate dependency graph -7. Create parallel execution examples -8. Validate task completeness: - → All contracts have tests? - → All entities have models? - → All endpoints implemented? -9. Return: SUCCESS (tasks ready for execution) -``` +**Tests**: The examples below include test tasks. Tests are OPTIONAL - only include them if explicitly requested in the feature specification. + +**Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story. + +## Format: `[ID] [P?] [Story] Description` -## Format: `[ID] [P?] Description` - **[P]**: Can run in parallel (different files, no dependencies) +- **[Story]**: Which user story this task belongs to (e.g., US1, US2, US3) - Include exact file paths in descriptions ## Path Conventions + - **Single project**: `src/`, `tests/` at repository root - **Web app**: `backend/src/`, `frontend/src/` - **Mobile**: `api/src/`, `ios/src/` or `android/src/` - Paths shown below assume single project - adjust based on plan.md structure -## Phase 3.1: Setup + + +## Phase 1: Setup (Shared Infrastructure) + +**Purpose**: Project initialization and basic structure + - [ ] T001 Create project structure per implementation plan - [ ] T002 Initialize [language] project with [framework] dependencies - [ ] T003 [P] Configure linting and formatting tools -## Phase 3.2: Tests First (TDD) ⚠️ MUST COMPLETE BEFORE 3.3 -**CRITICAL: These tests MUST be written and MUST FAIL before ANY implementation** -- [ ] T004 [P] Contract test POST /api/users in tests/contract/test_users_post.py -- [ ] T005 [P] Contract test GET /api/users/{id} in tests/contract/test_users_get.py -- [ ] T006 [P] Integration test user registration in tests/integration/test_registration.py -- [ ] T007 [P] Integration test auth flow in tests/integration/test_auth.py - -## Phase 3.3: Core Implementation (ONLY after tests are failing) -- [ ] T008 [P] User model in src/models/user.py -- [ ] T009 [P] UserService CRUD in src/services/user_service.py -- [ ] T010 [P] CLI --create-user in src/cli/user_commands.py -- [ ] T011 POST /api/users endpoint -- [ ] T012 GET /api/users/{id} endpoint -- [ ] T013 Input validation -- [ ] T014 Error handling and logging - -## Phase 3.4: Integration -- [ ] T015 Connect UserService to DB -- [ ] T016 Auth middleware -- [ ] T017 Request/response logging -- [ ] T018 CORS and security headers - -## Phase 3.5: Polish -- [ ] T019 [P] Unit tests for validation in tests/unit/test_validation.py -- [ ] T020 Performance tests (<200ms) -- [ ] T021 [P] Update docs/api.md -- [ ] T022 Remove duplication -- [ ] T023 Run manual-testing.md - -## Dependencies -- Tests (T004-T007) before implementation (T008-T014) -- T008 blocks T009, T015 -- T016 blocks T018 -- Implementation before polish (T019-T023) - -## Parallel Example -``` -# Launch T004-T007 together: -Task: "Contract test POST /api/users in tests/contract/test_users_post.py" -Task: "Contract test GET /api/users/{id} in tests/contract/test_users_get.py" -Task: "Integration test registration in tests/integration/test_registration.py" -Task: "Integration test auth in tests/integration/test_auth.py" +--- + +## Phase 2: Foundational (Blocking Prerequisites) + +**Purpose**: Core infrastructure that MUST be complete before ANY user story can be implemented + +**⚠️ CRITICAL**: No user story work can begin until this phase is complete + +Examples of foundational tasks (adjust based on your project): + +- [ ] T004 Setup database schema and migrations framework +- [ ] T005 [P] Implement authentication/authorization framework +- [ ] T006 [P] Setup API routing and middleware structure +- [ ] T007 Create base models/entities that all stories depend on +- [ ] T008 Configure error handling and logging infrastructure +- [ ] T009 Setup environment configuration management + +**Checkpoint**: Foundation ready - user story implementation can now begin in parallel + +--- + +## Phase 3: User Story 1 - [Title] (Priority: P1) 🎯 MVP + +**Goal**: [Brief description of what this story delivers] + +**Independent Test**: [How to verify this story works on its own] + +### Tests for User Story 1 (OPTIONAL - only if tests requested) ⚠️ + +> **NOTE: Write these tests FIRST, ensure they FAIL before implementation** + +- [ ] T010 [P] [US1] Contract test for [endpoint] in tests/contract/test_[name].py +- [ ] T011 [P] [US1] Integration test for [user journey] in tests/integration/test_[name].py + +### Implementation for User Story 1 + +- [ ] T012 [P] [US1] Create [Entity1] model in src/models/[entity1].py +- [ ] T013 [P] [US1] Create [Entity2] model in src/models/[entity2].py +- [ ] T014 [US1] Implement [Service] in src/services/[service].py (depends on T012, T013) +- [ ] T015 [US1] Implement [endpoint/feature] in src/[location]/[file].py +- [ ] T016 [US1] Add validation and error handling +- [ ] T017 [US1] Add logging for user story 1 operations + +**Checkpoint**: At this point, User Story 1 should be fully functional and testable independently + +--- + +## Phase 4: User Story 2 - [Title] (Priority: P2) + +**Goal**: [Brief description of what this story delivers] + +**Independent Test**: [How to verify this story works on its own] + +### Tests for User Story 2 (OPTIONAL - only if tests requested) ⚠️ + +- [ ] T018 [P] [US2] Contract test for [endpoint] in tests/contract/test_[name].py +- [ ] T019 [P] [US2] Integration test for [user journey] in tests/integration/test_[name].py + +### Implementation for User Story 2 + +- [ ] T020 [P] [US2] Create [Entity] model in src/models/[entity].py +- [ ] T021 [US2] Implement [Service] in src/services/[service].py +- [ ] T022 [US2] Implement [endpoint/feature] in src/[location]/[file].py +- [ ] T023 [US2] Integrate with User Story 1 components (if needed) + +**Checkpoint**: At this point, User Stories 1 AND 2 should both work independently + +--- + +## Phase 5: User Story 3 - [Title] (Priority: P3) + +**Goal**: [Brief description of what this story delivers] + +**Independent Test**: [How to verify this story works on its own] + +### Tests for User Story 3 (OPTIONAL - only if tests requested) ⚠️ + +- [ ] T024 [P] [US3] Contract test for [endpoint] in tests/contract/test_[name].py +- [ ] T025 [P] [US3] Integration test for [user journey] in tests/integration/test_[name].py + +### Implementation for User Story 3 + +- [ ] T026 [P] [US3] Create [Entity] model in src/models/[entity].py +- [ ] T027 [US3] Implement [Service] in src/services/[service].py +- [ ] T028 [US3] Implement [endpoint/feature] in src/[location]/[file].py + +**Checkpoint**: All user stories should now be independently functional + +--- + +[Add more user story phases as needed, following the same pattern] + +--- + +## Phase N: Polish & Cross-Cutting Concerns + +**Purpose**: Improvements that affect multiple user stories + +- [ ] TXXX [P] Documentation updates in docs/ +- [ ] TXXX Code cleanup and refactoring +- [ ] TXXX Performance optimization across all stories +- [ ] TXXX [P] Additional unit tests (if requested) in tests/unit/ +- [ ] TXXX Security hardening +- [ ] TXXX Run quickstart.md validation + +--- + +## Dependencies & Execution Order + +### Phase Dependencies + +- **Setup (Phase 1)**: No dependencies - can start immediately +- **Foundational (Phase 2)**: Depends on Setup completion - BLOCKS all user stories +- **User Stories (Phase 3+)**: All depend on Foundational phase completion + - User stories can then proceed in parallel (if staffed) + - Or sequentially in priority order (P1 → P2 → P3) +- **Polish (Final Phase)**: Depends on all desired user stories being complete + +### User Story Dependencies + +- **User Story 1 (P1)**: Can start after Foundational (Phase 2) - No dependencies on other stories +- **User Story 2 (P2)**: Can start after Foundational (Phase 2) - May integrate with US1 but should be independently testable +- **User Story 3 (P3)**: Can start after Foundational (Phase 2) - May integrate with US1/US2 but should be independently testable + +### Within Each User Story + +- Tests (if included) MUST be written and FAIL before implementation +- Models before services +- Services before endpoints +- Core implementation before integration +- Story complete before moving to next priority + +### Parallel Opportunities + +- All Setup tasks marked [P] can run in parallel +- All Foundational tasks marked [P] can run in parallel (within Phase 2) +- Once Foundational phase completes, all user stories can start in parallel (if team capacity allows) +- All tests for a user story marked [P] can run in parallel +- Models within a story marked [P] can run in parallel +- Different user stories can be worked on in parallel by different team members + +--- + +## Parallel Example: User Story 1 + +```bash +# Launch all tests for User Story 1 together (if tests requested): +Task: "Contract test for [endpoint] in tests/contract/test_[name].py" +Task: "Integration test for [user journey] in tests/integration/test_[name].py" + +# Launch all models for User Story 1 together: +Task: "Create [Entity1] model in src/models/[entity1].py" +Task: "Create [Entity2] model in src/models/[entity2].py" ``` +--- + +## Implementation Strategy + +### MVP First (User Story 1 Only) + +1. Complete Phase 1: Setup +2. Complete Phase 2: Foundational (CRITICAL - blocks all stories) +3. Complete Phase 3: User Story 1 +4. **STOP and VALIDATE**: Test User Story 1 independently +5. Deploy/demo if ready + +### Incremental Delivery + +1. Complete Setup + Foundational → Foundation ready +2. Add User Story 1 → Test independently → Deploy/Demo (MVP!) +3. Add User Story 2 → Test independently → Deploy/Demo +4. Add User Story 3 → Test independently → Deploy/Demo +5. Each story adds value without breaking previous stories + +### Parallel Team Strategy + +With multiple developers: + +1. Team completes Setup + Foundational together +2. Once Foundational is done: + - Developer A: User Story 1 + - Developer B: User Story 2 + - Developer C: User Story 3 +3. Stories complete and integrate independently + +--- + ## Notes + - [P] tasks = different files, no dependencies +- [Story] label maps task to specific user story for traceability +- Each user story should be independently completable and testable - Verify tests fail before implementing -- Commit after each task -- Avoid: vague tasks, same file conflicts - -## Task Generation Rules -*Applied during main() execution* - -1. **From Contracts**: - - Each contract file → contract test task [P] - - Each endpoint → implementation task - -2. **From Data Model**: - - Each entity → model creation task [P] - - Relationships → service layer tasks - -3. **From User Stories**: - - Each story → integration test [P] - - Quickstart scenarios → validation tasks - -4. **Ordering**: - - Setup → Tests → Models → Services → Endpoints → Polish - - Dependencies block parallel execution - -## Validation Checklist -*GATE: Checked by main() before returning* - -- [ ] All contracts have corresponding tests -- [ ] All entities have model tasks -- [ ] All tests come before implementation -- [ ] Parallel tasks truly independent -- [ ] Each task specifies exact file path -- [ ] No task modifies same file as another [P] task \ No newline at end of file +- Commit after each task or logical group +- Stop at any checkpoint to validate story independently +- Avoid: vague tasks, same file conflicts, cross-story dependencies that break independence diff --git a/.windsurf/rules/architecture.md b/.windsurf/rules/architecture.md new file mode 100644 index 0000000..7eef89a --- /dev/null +++ b/.windsurf/rules/architecture.md @@ -0,0 +1,193 @@ +--- +trigger: always_on +--- + +# Subtree CLI - Architecture & Testing Patterns + +Last Updated: 2025-10-26 | Phase: 10 (Complete) | Context: Proven patterns from MVP + CI implementation + +## Architecture Pattern: Library + Executable + +**Pattern**: Swift community standard for CLI tools + +### Structure + +``` +Sources/ +├── SubtreeLib/ # Library module (all business logic) +│ ├── Commands/ # Command implementations +│ └── Utilities/ # Helper utilities +└── subtree/ # Executable module (thin wrapper) + └── EntryPoint.swift # Calls SubtreeCommand.main() +``` + +### Responsibilities + +**SubtreeLib (Library)**: +- Contains ALL business logic +- Fully unit-testable with `@testable import` +- Can be used programmatically by other Swift code +- Exports `SubtreeCommand` as public API + +**subtree (Executable)**: +- Thin wrapper (5 lines) +- Single responsibility: Call `SubtreeCommand.main()` +- No business logic +- Enables standalone CLI usage + +### Benefits + +✅ **Testability**: Unit tests import SubtreeLib directly +✅ **Reusability**: Library can be embedded in other tools +✅ **Separation**: CLI concerns separate from business logic +✅ **Standard**: Matches swift-argument-parser best practices + +## Command Pattern: ArgumentParser + +**Framework**: swift-argument-parser 1.6.1 + +### Key Conventions + +- **Public struct**: Conforming to `ParsableCommand` +- **Static configuration**: Defines command metadata +- **Subcommands array**: Lists available subcommands +- **Public init**: Required for library usage +- **Version string**: Displayed with `--version` + +### Automatic Features + +ArgumentParser provides for free: +- `--help` / `-h` flag +- `--version` flag +- Subcommand help (`subtree --help`) +- Error handling with usage display +- Bash completion support + +## Testing Pattern: Two-Layer Approach + +### Unit Tests (SubtreeLibTests/) + +**Purpose**: Test business logic directly + +**Characteristics**: +- Uses `@testable import` for internal access +- Tests configuration, logic, utilities +- Fast (no process execution) +- Built-in Swift Testing framework (Swift 6.1) + +### Integration Tests (IntegrationTests/) + +**Purpose**: Test CLI end-to-end + +**Characteristics**: +- Uses TestHarness to execute actual binary +- Captures stdout/stderr/exit code +- Tests real CLI behavior +- Async execution with swift-subprocess + +## TestHarness Pattern + +**Location**: `Tests/IntegrationTests/TestHarness.swift` + +### Purpose + +Execute CLI commands in tests and capture results. + +### Core API + +```swift +struct TestHarness { + func run(arguments: [String]) async throws -> CommandResult +} + +struct CommandResult { + let stdout: String + let stderr: String + let exitCode: Int +} +``` + +### Git Support + +**GitRepositoryFixture**: Creates temporary git repositories for testing +- UUID-based unique paths (parallel-safe) +- Async initialization with initial commit +- Helper methods: `getCurrentCommit()`, `getCommitCount()`, `fileExists()` +- Complete cleanup with `tearDown()` + +**TestHarness Git Helpers**: `runGit()`, `verifyCommitExists()`, `getGitConfig()`, `isGitRepository()` + +## Swift Testing Framework + +**Version**: Built into Swift 6.1 toolchain (no package dependency) + +### Key Features + +- **@Suite**: Groups related tests +- **@Test**: Marks individual test functions +- **#expect**: Assertion macro (replaces XCTest assertions) +- **async/await**: First-class async test support +- **Parallel execution**: Tests run concurrently by default + +## Conventions + +### Swift Naming + +- **Files**: PascalCase (SubtreeCommand.swift, ExitCode.swift) +- **Types**: PascalCase (SubtreeCommand, TestHarness) +- **Functions**: camelCase (run, verifyCommitExists) +- **Constants**: camelCase (executablePath, exitCode) + +### Testing Discipline + +- **TDD**: Write tests first, verify failure, implement, verify pass +- **Test naming**: Descriptive strings in @Test("description") +- **Async tests**: Use async/await, not callbacks +- **Test isolation**: Each test is independent, use fixtures for setup +- **Assertions**: Use #expect(), not traditional assert() + +### Code Organization + +- **Library first**: All logic in SubtreeLib +- **Public API**: Only expose what's needed externally +- **Documentation**: Use Swift doc comments (///) +- **Error handling**: Use Swift errors, not exit() in library code + +--- + +## MVP Validation Checkpoint + +Verify architecture matches implementation: + +```bash +# 1. Library + Executable Pattern +ls -la Sources/SubtreeLib/Commands/ +wc -l Sources/subtree/main.swift # Should be ~5 lines + +# 2. Test Structure +grep "@testable import SubtreeLib" Tests/SubtreeLibTests/*.swift +grep "let harness: TestHarness" Tests/IntegrationTests/*.swift + +# 3. Swift Testing (no package dependency) +! grep "swift-testing" Package.swift || echo "ERROR" + +# 4. All tests pass +swift test # Should show 25/25 tests passed +``` + +**Expected**: All checks pass, architecture is consistent + +--- + +## Update Triggers + +Update this file when: + +1. **Architecture patterns change** (new layers, different structure) +2. **Testing patterns evolve** (new test utilities, different approaches) +3. **Framework updates** (ArgumentParser API changes, Testing updates) +4. **New command patterns** (subcommands, shared utilities) + +--- + +**Lines**: ~195 (under 200-line limit) \ No newline at end of file diff --git a/.windsurf/rules/bootstrap.md b/.windsurf/rules/bootstrap.md new file mode 100644 index 0000000..2fce398 --- /dev/null +++ b/.windsurf/rules/bootstrap.md @@ -0,0 +1,120 @@ +--- +trigger: always_on +--- + +# Subtree CLI - Bootstrap Rules + +Last Updated: 2025-10-26 | Spec: 001-cli-bootstrap | Phase: 10 (Complete) + +## Dependencies + +**Purpose**: Swift 6.1 CLI tool for managing git subtrees with declarative configuration + +- **swift-argument-parser 1.6.1**: CLI argument parsing +- **Yams 6.1.0**: YAML configuration parsing +- **swift-subprocess 0.1.0+**: Process execution +- **swift-system 1.5.0**: File operations (Ubuntu 20.04 compatible) + +## Structure + +``` +Sources/SubtreeLib/ # Library (all business logic) +├── Commands/ # ArgumentParser commands +└── Utilities/ # Helpers (ExitCode, etc.) +Sources/subtree/ # Executable (calls SubtreeLib.main()) +Tests/SubtreeLibTests/ # Unit tests (@testable import) +Tests/IntegrationTests/ # Integration tests (run binary + git fixtures) +``` + +**Platforms**: macOS 13+, Ubuntu 20.04 LTS + +## Architecture + +**Library + Executable** (Swift standard pattern) +- SubtreeLib: All logic, fully testable +- subtree: Thin wrapper +- Rationale: Testability + future programmatic use + +## CI/CD + +**Status**: Complete (Phase 5: local act, Phase 9: GitHub Actions) +**Details**: See [ci-cd.md](./ci-cd.md) for workflows, platform matrix, and validation + +## Features (Complete) + +**CLI Skeleton**: +- 6 stub commands (init, add, update, remove, extract, validate) +- Help system (`subtree --help`) +- Exit codes (0=success, non-zero=error) + +**Test Infrastructure**: +- TestHarness (CLI execution with swift-subprocess) +- GitRepositoryFixture (temporary git repos with UUID-based paths) +- 25 tests total (2 command + 7 exit code + 16 integration) + +**CI Automation**: +- GitHub Actions (macOS-15 + Ubuntu 20.04) +- Local testing (nektos/act with ci-local.yml) +- Platform-specific Swift setup (DEVELOPER_DIR vs setup-swift) + +--- + +## Update Triggers + +Agent MUST update when changes occur to: +1. **Project dependencies** - Add/remove packages, version changes +2. **Directory structure** - New folders, renamed paths +3. **Architecture patterns** - New layers, different structure +4. **CI/CD pipeline** - Workflow changes, platform updates +5. **Major feature areas** - New commands, test utilities + +**Procedure**: Read current file → identify changes → update surgically → keep <200 lines + +--- + +## Rules Organization + +**Pattern**: Multiple specialized files (not monolithic) + +**Current Files**: +- `compliance-check.md`: Constitution checks (always-on) +- `bootstrap.md`: Bootstrap context (this file) +- `architecture.md`: Architecture & testing patterns +- `ci-cd.md`: CI/CD workflows & validation + +**Rationale**: Modular (<200 lines each), focused, scalable + +--- + +## agents.md Maintenance + +**File**: `/agents.md` (universal AI onboarding per https://agents.md/) + +**Purpose**: High-level context for ANY AI tool + +**Update**: After EVERY phase (sync with README.md) + +**Procedure**: +1. Update header (date, phase) +2. Update status (✅ exists, ⏳ doesn't) +3. Update next phase pointer + +**See**: [agents.md](../agents.md) for current state + +--- + +## Architecture & Testing Patterns + +**Detailed Documentation**: See [architecture.md](./architecture.md) + +**Quick Reference**: +- Library + Executable pattern (SubtreeLib + subtree) +- ArgumentParser for commands +- Two-layer testing (unit + integration) +- TestHarness for CLI execution +- Swift Testing (built into Swift 6.1) + +--- + +**Lines**: ~120 (well under 200-line limit) + diff --git a/.windsurf/rules/ci-cd.md b/.windsurf/rules/ci-cd.md new file mode 100644 index 0000000..82554c8 --- /dev/null +++ b/.windsurf/rules/ci-cd.md @@ -0,0 +1,115 @@ +--- +trigger: always_on +--- + +# Subtree CLI - CI/CD & Validation + +Last Updated: 2025-10-26 | Phase: 10 (Complete) | Context: Production CI pipeline + +## CI/CD Pipeline + +**Platform**: GitHub Actions with local testing via nektos/act + +### Workflow: ci.yml + +**Purpose**: Production CI for all pushes and pull requests + +**Platform Matrix**: +- macOS-15 (Xcode 16.4 = Swift 6.1) +- Ubuntu 20.04 LTS (Swift 6.1) + +**Swift Setup Strategy**: +- **macOS**: Native Xcode via `DEVELOPER_DIR=/Applications/Xcode_16.4.app/Contents/Developer` + - No download/setup needed + - Faster execution + - Pre-installed on GitHub runners +- **Ubuntu**: `swift-actions/setup-swift@v2` + - Downloads Swift 6.1 + - Required (no Swift on Ubuntu runners) + +**Steps**: +1. Checkout code (`actions/checkout@v4`) +2. Setup Swift (Ubuntu only, conditional) +3. Verify Swift version +4. Build (`swift build`) +5. Run tests (`swift test` with 10-minute timeout) + +**Triggers**: +- Push to `main` or `001-cli-bootstrap` branches +- Pull requests to `main` + +### Workflow: ci-local.yml + +**Purpose**: Local CI testing with nektos/act + +**Platform**: Ubuntu only (Docker container) + +**Container**: `swift:6.1` (Swift pre-installed) + +**Usage**: +```bash +# Run local CI validation +act workflow_dispatch -W .github/workflows/ci-local.yml +``` + +**When to Use**: +- Before committing changes +- Testing workflow modifications +- Verifying test coverage + +**Limitations**: +- Linux only (act can't run macOS containers) +- Uses Docker (requires Docker running) +- First run downloads ~1.5GB image + +## CI Complete Validation Checkpoint + +Run these checks to verify CI matches implementation: + +### 1. Verify Workflow Configuration + +```bash +# Check ci.yml has correct platform matrix +grep "macos-15" .github/workflows/ci.yml +grep "ubuntu-20.04" .github/workflows/ci.yml + +# Verify DEVELOPER_DIR for macOS +grep "DEVELOPER_DIR" .github/workflows/ci.yml + +# Check conditional setup-swift for Ubuntu +grep "if: matrix.os == 'ubuntu-20.04'" .github/workflows/ci.yml +``` + +### 2. Verify Local CI Works + +```bash +# Test with act (should pass) +act workflow_dispatch -W .github/workflows/ci-local.yml + +# All 25 tests should pass in container +``` + +### 3. Verify Test Coverage + +```bash +# Check all test suites run +swift test 2>&1 | grep "Suite" + +# Should show: +# - Command Tests (2 tests) +# - Exit Code Tests (7 tests) +# - Subtree Integration Tests (9 tests) +# - Git Fixture Tests (7 tests) +# Total: 25 tests +``` + +### 4. Verify CI Badge + +Check README.md contains CI badge linking to workflow. + +**Expected**: All checks pass, CI pipeline matches documentation + +--- + +**Lines**: ~100 (well under 200-line limit) + diff --git a/.windsurf/rules/compliance-check.md b/.windsurf/rules/compliance-check.md new file mode 100644 index 0000000..92a9105 --- /dev/null +++ b/.windsurf/rules/compliance-check.md @@ -0,0 +1,5 @@ +--- +trigger: always_on +--- + +Before starting any feature work or behavior change, read .specify/memory/constitution.md and verify your approach complies with all five core principles (spec-first, TDD, small independent specs, CI gates, agent maintenance). After completing feature work, verify final compliance and check if .windsurf/rules updates are needed per Principle V triggers. \ No newline at end of file diff --git a/.windsurf/workflows/analyze.md b/.windsurf/workflows/analyze.md deleted file mode 100644 index f4c1a7b..0000000 --- a/.windsurf/workflows/analyze.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -description: Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation. ---- - -The user input to you can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). - -User input: - -$ARGUMENTS - -Goal: Identify inconsistencies, duplications, ambiguities, and underspecified items across the three core artifacts (`spec.md`, `plan.md`, `tasks.md`) before implementation. This command MUST run only after `/tasks` has successfully produced a complete `tasks.md`. - -STRICTLY READ-ONLY: Do **not** modify any files. Output a structured analysis report. Offer an optional remediation plan (user must explicitly approve before any follow-up editing commands would be invoked manually). - -Constitution Authority: The project constitution (`.specify/memory/constitution.md`) is **non-negotiable** within this analysis scope. Constitution conflicts are automatically CRITICAL and require adjustment of the spec, plan, or tasks—not dilution, reinterpretation, or silent ignoring of the principle. If a principle itself needs to change, that must occur in a separate, explicit constitution update outside `/analyze`. - -Execution steps: - -1. Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS. Derive absolute paths: - - SPEC = FEATURE_DIR/spec.md - - PLAN = FEATURE_DIR/plan.md - - TASKS = FEATURE_DIR/tasks.md - Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command). - -2. Load artifacts: - - Parse spec.md sections: Overview/Context, Functional Requirements, Non-Functional Requirements, User Stories, Edge Cases (if present). - - Parse plan.md: Architecture/stack choices, Data Model references, Phases, Technical constraints. - - Parse tasks.md: Task IDs, descriptions, phase grouping, parallel markers [P], referenced file paths. - - Load constitution `.specify/memory/constitution.md` for principle validation. - -3. Build internal semantic models: - - Requirements inventory: Each functional + non-functional requirement with a stable key (derive slug based on imperative phrase; e.g., "User can upload file" -> `user-can-upload-file`). - - User story/action inventory. - - Task coverage mapping: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases). - - Constitution rule set: Extract principle names and any MUST/SHOULD normative statements. - -4. Detection passes: - A. Duplication detection: - - Identify near-duplicate requirements. Mark lower-quality phrasing for consolidation. - B. Ambiguity detection: - - Flag vague adjectives (fast, scalable, secure, intuitive, robust) lacking measurable criteria. - - Flag unresolved placeholders (TODO, TKTK, ???, , etc.). - C. Underspecification: - - Requirements with verbs but missing object or measurable outcome. - - User stories missing acceptance criteria alignment. - - Tasks referencing files or components not defined in spec/plan. - D. Constitution alignment: - - Any requirement or plan element conflicting with a MUST principle. - - Missing mandated sections or quality gates from constitution. - E. Coverage gaps: - - Requirements with zero associated tasks. - - Tasks with no mapped requirement/story. - - Non-functional requirements not reflected in tasks (e.g., performance, security). - F. Inconsistency: - - Terminology drift (same concept named differently across files). - - Data entities referenced in plan but absent in spec (or vice versa). - - Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note). - - Conflicting requirements (e.g., one requires to use Next.js while other says to use Vue as the framework). - -5. Severity assignment heuristic: - - CRITICAL: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality. - - HIGH: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion. - - MEDIUM: Terminology drift, missing non-functional task coverage, underspecified edge case. - - LOW: Style/wording improvements, minor redundancy not affecting execution order. - -6. Produce a Markdown report (no file writes) with sections: - - ### Specification Analysis Report - | ID | Category | Severity | Location(s) | Summary | Recommendation | - |----|----------|----------|-------------|---------|----------------| - | A1 | Duplication | HIGH | spec.md:L120-134 | Two similar requirements ... | Merge phrasing; keep clearer version | - (Add one row per finding; generate stable IDs prefixed by category initial.) - - Additional subsections: - - Coverage Summary Table: - | Requirement Key | Has Task? | Task IDs | Notes | - - Constitution Alignment Issues (if any) - - Unmapped Tasks (if any) - - Metrics: - * Total Requirements - * Total Tasks - * Coverage % (requirements with >=1 task) - * Ambiguity Count - * Duplication Count - * Critical Issues Count - -7. At end of report, output a concise Next Actions block: - - If CRITICAL issues exist: Recommend resolving before `/implement`. - - If only LOW/MEDIUM: User may proceed, but provide improvement suggestions. - - Provide explicit command suggestions: e.g., "Run /specify with refinement", "Run /plan to adjust architecture", "Manually edit tasks.md to add coverage for 'performance-metrics'". - -8. Ask the user: "Would you like me to suggest concrete remediation edits for the top N issues?" (Do NOT apply them automatically.) - -Behavior rules: -- NEVER modify files. -- NEVER hallucinate missing sections—if absent, report them. -- KEEP findings deterministic: if rerun without changes, produce consistent IDs and counts. -- LIMIT total findings in the main table to 50; aggregate remainder in a summarized overflow note. -- If zero issues found, emit a success report with coverage statistics and proceed recommendation. - -Context: $ARGUMENTS diff --git a/.windsurf/workflows/implement.md b/.windsurf/workflows/implement.md deleted file mode 100644 index 003dce9..0000000 --- a/.windsurf/workflows/implement.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -description: Execute the implementation plan by processing and executing all tasks defined in tasks.md ---- - -The user input can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). - -User input: - -$ARGUMENTS - -1. Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. - -2. Load and analyze the implementation context: - - **REQUIRED**: Read tasks.md for the complete task list and execution plan - - **REQUIRED**: Read plan.md for tech stack, architecture, and file structure - - **IF EXISTS**: Read data-model.md for entities and relationships - - **IF EXISTS**: Read contracts/ for API specifications and test requirements - - **IF EXISTS**: Read research.md for technical decisions and constraints - - **IF EXISTS**: Read quickstart.md for integration scenarios - -3. Parse tasks.md structure and extract: - - **Task phases**: Setup, Tests, Core, Integration, Polish - - **Task dependencies**: Sequential vs parallel execution rules - - **Task details**: ID, description, file paths, parallel markers [P] - - **Execution flow**: Order and dependency requirements - -4. Execute implementation following the task plan: - - **Phase-by-phase execution**: Complete each phase before moving to the next - - **Respect dependencies**: Run sequential tasks in order, parallel tasks [P] can run together - - **Follow TDD approach**: Execute test tasks before their corresponding implementation tasks - - **File-based coordination**: Tasks affecting the same files must run sequentially - - **Validation checkpoints**: Verify each phase completion before proceeding - -5. Implementation execution rules: - - **Setup first**: Initialize project structure, dependencies, configuration - - **Tests before code**: If you need to write tests for contracts, entities, and integration scenarios - - **Core development**: Implement models, services, CLI commands, endpoints - - **Integration work**: Database connections, middleware, logging, external services - - **Polish and validation**: Unit tests, performance optimization, documentation - -6. Progress tracking and error handling: - - Report progress after each completed task - - Halt execution if any non-parallel task fails - - For parallel tasks [P], continue with successful tasks, report failed ones - - Provide clear error messages with context for debugging - - Suggest next steps if implementation cannot proceed - - **IMPORTANT** For completed tasks, make sure to mark the task off as [X] in the tasks file. - -7. Completion validation: - - Verify all required tasks are completed - - Check that implemented features match the original specification - - Validate that tests pass and coverage meets requirements - - Confirm the implementation follows the technical plan - - Report final status with summary of completed work - -Note: This command assumes a complete task breakdown exists in tasks.md. If tasks are incomplete or missing, suggest running `/tasks` first to regenerate the task list. diff --git a/.windsurf/workflows/plan.md b/.windsurf/workflows/plan.md deleted file mode 100644 index 23c020a..0000000 --- a/.windsurf/workflows/plan.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -description: Execute the implementation planning workflow using the plan template to generate design artifacts. ---- - -The user input to you can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). - -User input: - -$ARGUMENTS - -Given the implementation details provided as an argument, do this: - -1. Run `.specify/scripts/bash/setup-plan.sh --json` from the repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, SPECS_DIR, BRANCH. All future file paths must be absolute. - - BEFORE proceeding, inspect FEATURE_SPEC for a `## Clarifications` section with at least one `Session` subheading. If missing or clearly ambiguous areas remain (vague adjectives, unresolved critical choices), PAUSE and instruct the user to run `/clarify` first to reduce rework. Only continue if: (a) Clarifications exist OR (b) an explicit user override is provided (e.g., "proceed without clarification"). Do not attempt to fabricate clarifications yourself. -2. Read and analyze the feature specification to understand: - - The feature requirements and user stories - - Functional and non-functional requirements - - Success criteria and acceptance criteria - - Any technical constraints or dependencies mentioned - -3. Read the constitution at `.specify/memory/constitution.md` to understand constitutional requirements. - -4. Execute the implementation plan template: - - Load `.specify/templates/plan-template.md` (already copied to IMPL_PLAN path) - - Set Input path to FEATURE_SPEC - - Run the Execution Flow (main) function steps 1-9 - - The template is self-contained and executable - - Follow error handling and gate checks as specified - - Let the template guide artifact generation in $SPECS_DIR: - * Phase 0 generates research.md - * Phase 1 generates data-model.md, contracts/, quickstart.md - * Phase 2 generates tasks.md - - Incorporate user-provided details from arguments into Technical Context: $ARGUMENTS - - Update Progress Tracking as you complete each phase - -5. Verify execution completed: - - Check Progress Tracking shows all phases complete - - Ensure all required artifacts were generated - - Confirm no ERROR states in execution - -6. Report results with branch name, file paths, and generated artifacts. - -Use absolute paths with the repository root for all file operations to avoid path issues. diff --git a/.windsurf/workflows/specify.md b/.windsurf/workflows/specify.md deleted file mode 100644 index 0f92105..0000000 --- a/.windsurf/workflows/specify.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -description: Create or update the feature specification from a natural language feature description. ---- - -The user input to you can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). - -User input: - -$ARGUMENTS - -The text the user typed after `/specify` in the triggering message **is** the feature description. Assume you always have it available in this conversation even if `$ARGUMENTS` appears literally below. Do not ask the user to repeat it unless they provided an empty command. - -Given that feature description, do this: - -1. Run the script `.specify/scripts/bash/create-new-feature.sh --json "$ARGUMENTS"` from repo root and parse its JSON output for BRANCH_NAME and SPEC_FILE. All file paths must be absolute. - **IMPORTANT** You must only ever run this script once. The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for. -2. Load `.specify/templates/spec-template.md` to understand required sections. -3. Write the specification to SPEC_FILE using the template structure, replacing placeholders with concrete details derived from the feature description (arguments) while preserving section order and headings. -4. Report completion with branch name, spec file path, and readiness for the next phase. - -Note: The script creates and checks out the new branch and initializes the spec file before writing. diff --git a/.windsurf/workflows/speckit.analyze.md b/.windsurf/workflows/speckit.analyze.md new file mode 100644 index 0000000..98b04b0 --- /dev/null +++ b/.windsurf/workflows/speckit.analyze.md @@ -0,0 +1,184 @@ +--- +description: Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation. +--- + +## User Input + +```text +$ARGUMENTS +``` + +You **MUST** consider the user input before proceeding (if not empty). + +## Goal + +Identify inconsistencies, duplications, ambiguities, and underspecified items across the three core artifacts (`spec.md`, `plan.md`, `tasks.md`) before implementation. This command MUST run only after `/speckit.tasks` has successfully produced a complete `tasks.md`. + +## Operating Constraints + +**STRICTLY READ-ONLY**: Do **not** modify any files. Output a structured analysis report. Offer an optional remediation plan (user must explicitly approve before any follow-up editing commands would be invoked manually). + +**Constitution Authority**: The project constitution (`.specify/memory/constitution.md`) is **non-negotiable** within this analysis scope. Constitution conflicts are automatically CRITICAL and require adjustment of the spec, plan, or tasks—not dilution, reinterpretation, or silent ignoring of the principle. If a principle itself needs to change, that must occur in a separate, explicit constitution update outside `/speckit.analyze`. + +## Execution Steps + +### 1. Initialize Analysis Context + +Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS. Derive absolute paths: + +- SPEC = FEATURE_DIR/spec.md +- PLAN = FEATURE_DIR/plan.md +- TASKS = FEATURE_DIR/tasks.md + +Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command). +For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot"). + +### 2. Load Artifacts (Progressive Disclosure) + +Load only the minimal necessary context from each artifact: + +**From spec.md:** + +- Overview/Context +- Functional Requirements +- Non-Functional Requirements +- User Stories +- Edge Cases (if present) + +**From plan.md:** + +- Architecture/stack choices +- Data Model references +- Phases +- Technical constraints + +**From tasks.md:** + +- Task IDs +- Descriptions +- Phase grouping +- Parallel markers [P] +- Referenced file paths + +**From constitution:** + +- Load `.specify/memory/constitution.md` for principle validation + +### 3. Build Semantic Models + +Create internal representations (do not include raw artifacts in output): + +- **Requirements inventory**: Each functional + non-functional requirement with a stable key (derive slug based on imperative phrase; e.g., "User can upload file" → `user-can-upload-file`) +- **User story/action inventory**: Discrete user actions with acceptance criteria +- **Task coverage mapping**: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases) +- **Constitution rule set**: Extract principle names and MUST/SHOULD normative statements + +### 4. Detection Passes (Token-Efficient Analysis) + +Focus on high-signal findings. Limit to 50 findings total; aggregate remainder in overflow summary. + +#### A. Duplication Detection + +- Identify near-duplicate requirements +- Mark lower-quality phrasing for consolidation + +#### B. Ambiguity Detection + +- Flag vague adjectives (fast, scalable, secure, intuitive, robust) lacking measurable criteria +- Flag unresolved placeholders (TODO, TKTK, ???, ``, etc.) + +#### C. Underspecification + +- Requirements with verbs but missing object or measurable outcome +- User stories missing acceptance criteria alignment +- Tasks referencing files or components not defined in spec/plan + +#### D. Constitution Alignment + +- Any requirement or plan element conflicting with a MUST principle +- Missing mandated sections or quality gates from constitution + +#### E. Coverage Gaps + +- Requirements with zero associated tasks +- Tasks with no mapped requirement/story +- Non-functional requirements not reflected in tasks (e.g., performance, security) + +#### F. Inconsistency + +- Terminology drift (same concept named differently across files) +- Data entities referenced in plan but absent in spec (or vice versa) +- Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note) +- Conflicting requirements (e.g., one requires Next.js while other specifies Vue) + +### 5. Severity Assignment + +Use this heuristic to prioritize findings: + +- **CRITICAL**: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality +- **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion +- **MEDIUM**: Terminology drift, missing non-functional task coverage, underspecified edge case +- **LOW**: Style/wording improvements, minor redundancy not affecting execution order + +### 6. Produce Compact Analysis Report + +Output a Markdown report (no file writes) with the following structure: + +## Specification Analysis Report + +| ID | Category | Severity | Location(s) | Summary | Recommendation | +|----|----------|----------|-------------|---------|----------------| +| A1 | Duplication | HIGH | spec.md:L120-134 | Two similar requirements ... | Merge phrasing; keep clearer version | + +(Add one row per finding; generate stable IDs prefixed by category initial.) + +**Coverage Summary Table:** + +| Requirement Key | Has Task? | Task IDs | Notes | +|-----------------|-----------|----------|-------| + +**Constitution Alignment Issues:** (if any) + +**Unmapped Tasks:** (if any) + +**Metrics:** + +- Total Requirements +- Total Tasks +- Coverage % (requirements with >=1 task) +- Ambiguity Count +- Duplication Count +- Critical Issues Count + +### 7. Provide Next Actions + +At end of report, output a concise Next Actions block: + +- If CRITICAL issues exist: Recommend resolving before `/speckit.implement` +- If only LOW/MEDIUM: User may proceed, but provide improvement suggestions +- Provide explicit command suggestions: e.g., "Run /speckit.specify with refinement", "Run /speckit.plan to adjust architecture", "Manually edit tasks.md to add coverage for 'performance-metrics'" + +### 8. Offer Remediation + +Ask the user: "Would you like me to suggest concrete remediation edits for the top N issues?" (Do NOT apply them automatically.) + +## Operating Principles + +### Context Efficiency + +- **Minimal high-signal tokens**: Focus on actionable findings, not exhaustive documentation +- **Progressive disclosure**: Load artifacts incrementally; don't dump all content into analysis +- **Token-efficient output**: Limit findings table to 50 rows; summarize overflow +- **Deterministic results**: Rerunning without changes should produce consistent IDs and counts + +### Analysis Guidelines + +- **NEVER modify files** (this is read-only analysis) +- **NEVER hallucinate missing sections** (if absent, report them accurately) +- **Prioritize constitution violations** (these are always CRITICAL) +- **Use examples over exhaustive rules** (cite specific instances, not generic patterns) +- **Report zero issues gracefully** (emit success report with coverage statistics) + +## Context + +$ARGUMENTS diff --git a/.windsurf/workflows/speckit.checklist.md b/.windsurf/workflows/speckit.checklist.md new file mode 100644 index 0000000..970e6c9 --- /dev/null +++ b/.windsurf/workflows/speckit.checklist.md @@ -0,0 +1,294 @@ +--- +description: Generate a custom checklist for the current feature based on user requirements. +--- + +## Checklist Purpose: "Unit Tests for English" + +**CRITICAL CONCEPT**: Checklists are **UNIT TESTS FOR REQUIREMENTS WRITING** - they validate the quality, clarity, and completeness of requirements in a given domain. + +**NOT for verification/testing**: + +- ❌ NOT "Verify the button clicks correctly" +- ❌ NOT "Test error handling works" +- ❌ NOT "Confirm the API returns 200" +- ❌ NOT checking if code/implementation matches the spec + +**FOR requirements quality validation**: + +- ✅ "Are visual hierarchy requirements defined for all card types?" (completeness) +- ✅ "Is 'prominent display' quantified with specific sizing/positioning?" (clarity) +- ✅ "Are hover state requirements consistent across all interactive elements?" (consistency) +- ✅ "Are accessibility requirements defined for keyboard navigation?" (coverage) +- ✅ "Does the spec define what happens when logo image fails to load?" (edge cases) + +**Metaphor**: If your spec is code written in English, the checklist is its unit test suite. You're testing whether the requirements are well-written, complete, unambiguous, and ready for implementation - NOT whether the implementation works. + +## User Input + +```text +$ARGUMENTS +``` + +You **MUST** consider the user input before proceeding (if not empty). + +## Execution Steps + +1. **Setup**: Run `.specify/scripts/bash/check-prerequisites.sh --json` from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS list. + - All file paths must be absolute. + - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot"). + +2. **Clarify intent (dynamic)**: Derive up to THREE initial contextual clarifying questions (no pre-baked catalog). They MUST: + - Be generated from the user's phrasing + extracted signals from spec/plan/tasks + - Only ask about information that materially changes checklist content + - Be skipped individually if already unambiguous in `$ARGUMENTS` + - Prefer precision over breadth + + Generation algorithm: + 1. Extract signals: feature domain keywords (e.g., auth, latency, UX, API), risk indicators ("critical", "must", "compliance"), stakeholder hints ("QA", "review", "security team"), and explicit deliverables ("a11y", "rollback", "contracts"). + 2. Cluster signals into candidate focus areas (max 4) ranked by relevance. + 3. Identify probable audience & timing (author, reviewer, QA, release) if not explicit. + 4. Detect missing dimensions: scope breadth, depth/rigor, risk emphasis, exclusion boundaries, measurable acceptance criteria. + 5. Formulate questions chosen from these archetypes: + - Scope refinement (e.g., "Should this include integration touchpoints with X and Y or stay limited to local module correctness?") + - Risk prioritization (e.g., "Which of these potential risk areas should receive mandatory gating checks?") + - Depth calibration (e.g., "Is this a lightweight pre-commit sanity list or a formal release gate?") + - Audience framing (e.g., "Will this be used by the author only or peers during PR review?") + - Boundary exclusion (e.g., "Should we explicitly exclude performance tuning items this round?") + - Scenario class gap (e.g., "No recovery flows detected—are rollback / partial failure paths in scope?") + + Question formatting rules: + - If presenting options, generate a compact table with columns: Option | Candidate | Why It Matters + - Limit to A–E options maximum; omit table if a free-form answer is clearer + - Never ask the user to restate what they already said + - Avoid speculative categories (no hallucination). If uncertain, ask explicitly: "Confirm whether X belongs in scope." + + Defaults when interaction impossible: + - Depth: Standard + - Audience: Reviewer (PR) if code-related; Author otherwise + - Focus: Top 2 relevance clusters + + Output the questions (label Q1/Q2/Q3). After answers: if ≥2 scenario classes (Alternate / Exception / Recovery / Non-Functional domain) remain unclear, you MAY ask up to TWO more targeted follow‑ups (Q4/Q5) with a one-line justification each (e.g., "Unresolved recovery path risk"). Do not exceed five total questions. Skip escalation if user explicitly declines more. + +3. **Understand user request**: Combine `$ARGUMENTS` + clarifying answers: + - Derive checklist theme (e.g., security, review, deploy, ux) + - Consolidate explicit must-have items mentioned by user + - Map focus selections to category scaffolding + - Infer any missing context from spec/plan/tasks (do NOT hallucinate) + +4. **Load feature context**: Read from FEATURE_DIR: + - spec.md: Feature requirements and scope + - plan.md (if exists): Technical details, dependencies + - tasks.md (if exists): Implementation tasks + + **Context Loading Strategy**: + - Load only necessary portions relevant to active focus areas (avoid full-file dumping) + - Prefer summarizing long sections into concise scenario/requirement bullets + - Use progressive disclosure: add follow-on retrieval only if gaps detected + - If source docs are large, generate interim summary items instead of embedding raw text + +5. **Generate checklist** - Create "Unit Tests for Requirements": + - Create `FEATURE_DIR/checklists/` directory if it doesn't exist + - Generate unique checklist filename: + - Use short, descriptive name based on domain (e.g., `ux.md`, `api.md`, `security.md`) + - Format: `[domain].md` + - If file exists, append to existing file + - Number items sequentially starting from CHK001 + - Each `/speckit.checklist` run creates a NEW file (never overwrites existing checklists) + + **CORE PRINCIPLE - Test the Requirements, Not the Implementation**: + Every checklist item MUST evaluate the REQUIREMENTS THEMSELVES for: + - **Completeness**: Are all necessary requirements present? + - **Clarity**: Are requirements unambiguous and specific? + - **Consistency**: Do requirements align with each other? + - **Measurability**: Can requirements be objectively verified? + - **Coverage**: Are all scenarios/edge cases addressed? + + **Category Structure** - Group items by requirement quality dimensions: + - **Requirement Completeness** (Are all necessary requirements documented?) + - **Requirement Clarity** (Are requirements specific and unambiguous?) + - **Requirement Consistency** (Do requirements align without conflicts?) + - **Acceptance Criteria Quality** (Are success criteria measurable?) + - **Scenario Coverage** (Are all flows/cases addressed?) + - **Edge Case Coverage** (Are boundary conditions defined?) + - **Non-Functional Requirements** (Performance, Security, Accessibility, etc. - are they specified?) + - **Dependencies & Assumptions** (Are they documented and validated?) + - **Ambiguities & Conflicts** (What needs clarification?) + + **HOW TO WRITE CHECKLIST ITEMS - "Unit Tests for English"**: + + ❌ **WRONG** (Testing implementation): + - "Verify landing page displays 3 episode cards" + - "Test hover states work on desktop" + - "Confirm logo click navigates home" + + ✅ **CORRECT** (Testing requirements quality): + - "Are the exact number and layout of featured episodes specified?" [Completeness] + - "Is 'prominent display' quantified with specific sizing/positioning?" [Clarity] + - "Are hover state requirements consistent across all interactive elements?" [Consistency] + - "Are keyboard navigation requirements defined for all interactive UI?" [Coverage] + - "Is the fallback behavior specified when logo image fails to load?" [Edge Cases] + - "Are loading states defined for asynchronous episode data?" [Completeness] + - "Does the spec define visual hierarchy for competing UI elements?" [Clarity] + + **ITEM STRUCTURE**: + Each item should follow this pattern: + - Question format asking about requirement quality + - Focus on what's WRITTEN (or not written) in the spec/plan + - Include quality dimension in brackets [Completeness/Clarity/Consistency/etc.] + - Reference spec section `[Spec §X.Y]` when checking existing requirements + - Use `[Gap]` marker when checking for missing requirements + + **EXAMPLES BY QUALITY DIMENSION**: + + Completeness: + - "Are error handling requirements defined for all API failure modes? [Gap]" + - "Are accessibility requirements specified for all interactive elements? [Completeness]" + - "Are mobile breakpoint requirements defined for responsive layouts? [Gap]" + + Clarity: + - "Is 'fast loading' quantified with specific timing thresholds? [Clarity, Spec §NFR-2]" + - "Are 'related episodes' selection criteria explicitly defined? [Clarity, Spec §FR-5]" + - "Is 'prominent' defined with measurable visual properties? [Ambiguity, Spec §FR-4]" + + Consistency: + - "Do navigation requirements align across all pages? [Consistency, Spec §FR-10]" + - "Are card component requirements consistent between landing and detail pages? [Consistency]" + + Coverage: + - "Are requirements defined for zero-state scenarios (no episodes)? [Coverage, Edge Case]" + - "Are concurrent user interaction scenarios addressed? [Coverage, Gap]" + - "Are requirements specified for partial data loading failures? [Coverage, Exception Flow]" + + Measurability: + - "Are visual hierarchy requirements measurable/testable? [Acceptance Criteria, Spec §FR-1]" + - "Can 'balanced visual weight' be objectively verified? [Measurability, Spec §FR-2]" + + **Scenario Classification & Coverage** (Requirements Quality Focus): + - Check if requirements exist for: Primary, Alternate, Exception/Error, Recovery, Non-Functional scenarios + - For each scenario class, ask: "Are [scenario type] requirements complete, clear, and consistent?" + - If scenario class missing: "Are [scenario type] requirements intentionally excluded or missing? [Gap]" + - Include resilience/rollback when state mutation occurs: "Are rollback requirements defined for migration failures? [Gap]" + + **Traceability Requirements**: + - MINIMUM: ≥80% of items MUST include at least one traceability reference + - Each item should reference: spec section `[Spec §X.Y]`, or use markers: `[Gap]`, `[Ambiguity]`, `[Conflict]`, `[Assumption]` + - If no ID system exists: "Is a requirement & acceptance criteria ID scheme established? [Traceability]" + + **Surface & Resolve Issues** (Requirements Quality Problems): + Ask questions about the requirements themselves: + - Ambiguities: "Is the term 'fast' quantified with specific metrics? [Ambiguity, Spec §NFR-1]" + - Conflicts: "Do navigation requirements conflict between §FR-10 and §FR-10a? [Conflict]" + - Assumptions: "Is the assumption of 'always available podcast API' validated? [Assumption]" + - Dependencies: "Are external podcast API requirements documented? [Dependency, Gap]" + - Missing definitions: "Is 'visual hierarchy' defined with measurable criteria? [Gap]" + + **Content Consolidation**: + - Soft cap: If raw candidate items > 40, prioritize by risk/impact + - Merge near-duplicates checking the same requirement aspect + - If >5 low-impact edge cases, create one item: "Are edge cases X, Y, Z addressed in requirements? [Coverage]" + + **🚫 ABSOLUTELY PROHIBITED** - These make it an implementation test, not a requirements test: + - ❌ Any item starting with "Verify", "Test", "Confirm", "Check" + implementation behavior + - ❌ References to code execution, user actions, system behavior + - ❌ "Displays correctly", "works properly", "functions as expected" + - ❌ "Click", "navigate", "render", "load", "execute" + - ❌ Test cases, test plans, QA procedures + - ❌ Implementation details (frameworks, APIs, algorithms) + + **✅ REQUIRED PATTERNS** - These test requirements quality: + - ✅ "Are [requirement type] defined/specified/documented for [scenario]?" + - ✅ "Is [vague term] quantified/clarified with specific criteria?" + - ✅ "Are requirements consistent between [section A] and [section B]?" + - ✅ "Can [requirement] be objectively measured/verified?" + - ✅ "Are [edge cases/scenarios] addressed in requirements?" + - ✅ "Does the spec define [missing aspect]?" + +6. **Structure Reference**: Generate the checklist following the canonical template in `.specify/templates/checklist-template.md` for title, meta section, category headings, and ID formatting. If template is unavailable, use: H1 title, purpose/created meta lines, `##` category sections containing `- [ ] CHK### ` lines with globally incrementing IDs starting at CHK001. + +7. **Report**: Output full path to created checklist, item count, and remind user that each run creates a new file. Summarize: + - Focus areas selected + - Depth level + - Actor/timing + - Any explicit user-specified must-have items incorporated + +**Important**: Each `/speckit.checklist` command invocation creates a checklist file using short, descriptive names unless file already exists. This allows: + +- Multiple checklists of different types (e.g., `ux.md`, `test.md`, `security.md`) +- Simple, memorable filenames that indicate checklist purpose +- Easy identification and navigation in the `checklists/` folder + +To avoid clutter, use descriptive types and clean up obsolete checklists when done. + +## Example Checklist Types & Sample Items + +**UX Requirements Quality:** `ux.md` + +Sample items (testing the requirements, NOT the implementation): + +- "Are visual hierarchy requirements defined with measurable criteria? [Clarity, Spec §FR-1]" +- "Is the number and positioning of UI elements explicitly specified? [Completeness, Spec §FR-1]" +- "Are interaction state requirements (hover, focus, active) consistently defined? [Consistency]" +- "Are accessibility requirements specified for all interactive elements? [Coverage, Gap]" +- "Is fallback behavior defined when images fail to load? [Edge Case, Gap]" +- "Can 'prominent display' be objectively measured? [Measurability, Spec §FR-4]" + +**API Requirements Quality:** `api.md` + +Sample items: + +- "Are error response formats specified for all failure scenarios? [Completeness]" +- "Are rate limiting requirements quantified with specific thresholds? [Clarity]" +- "Are authentication requirements consistent across all endpoints? [Consistency]" +- "Are retry/timeout requirements defined for external dependencies? [Coverage, Gap]" +- "Is versioning strategy documented in requirements? [Gap]" + +**Performance Requirements Quality:** `performance.md` + +Sample items: + +- "Are performance requirements quantified with specific metrics? [Clarity]" +- "Are performance targets defined for all critical user journeys? [Coverage]" +- "Are performance requirements under different load conditions specified? [Completeness]" +- "Can performance requirements be objectively measured? [Measurability]" +- "Are degradation requirements defined for high-load scenarios? [Edge Case, Gap]" + +**Security Requirements Quality:** `security.md` + +Sample items: + +- "Are authentication requirements specified for all protected resources? [Coverage]" +- "Are data protection requirements defined for sensitive information? [Completeness]" +- "Is the threat model documented and requirements aligned to it? [Traceability]" +- "Are security requirements consistent with compliance obligations? [Consistency]" +- "Are security failure/breach response requirements defined? [Gap, Exception Flow]" + +## Anti-Examples: What NOT To Do + +**❌ WRONG - These test implementation, not requirements:** + +```markdown +- [ ] CHK001 - Verify landing page displays 3 episode cards [Spec §FR-001] +- [ ] CHK002 - Test hover states work correctly on desktop [Spec §FR-003] +- [ ] CHK003 - Confirm logo click navigates to home page [Spec §FR-010] +- [ ] CHK004 - Check that related episodes section shows 3-5 items [Spec §FR-005] +``` + +**✅ CORRECT - These test requirements quality:** + +```markdown +- [ ] CHK001 - Are the number and layout of featured episodes explicitly specified? [Completeness, Spec §FR-001] +- [ ] CHK002 - Are hover state requirements consistently defined for all interactive elements? [Consistency, Spec §FR-003] +- [ ] CHK003 - Are navigation requirements clear for all clickable brand elements? [Clarity, Spec §FR-010] +- [ ] CHK004 - Is the selection criteria for related episodes documented? [Gap, Spec §FR-005] +- [ ] CHK005 - Are loading state requirements defined for asynchronous episode data? [Gap] +- [ ] CHK006 - Can "visual hierarchy" requirements be objectively measured? [Measurability, Spec §FR-001] +``` + +**Key Differences:** + +- Wrong: Tests if the system works correctly +- Correct: Tests if the requirements are written correctly +- Wrong: Verification of behavior +- Correct: Validation of requirement quality +- Wrong: "Does it do X?" +- Correct: "Is X clearly specified?" diff --git a/.windsurf/workflows/clarify.md b/.windsurf/workflows/speckit.clarify.md similarity index 61% rename from .windsurf/workflows/clarify.md rename to .windsurf/workflows/speckit.clarify.md index 26ff530..8ff62c3 100644 --- a/.windsurf/workflows/clarify.md +++ b/.windsurf/workflows/speckit.clarify.md @@ -2,15 +2,19 @@ description: Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec. --- -The user input to you can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). - -User input: +## User Input +```text $ARGUMENTS +``` + +You **MUST** consider the user input before proceeding (if not empty). + +## Outline Goal: Detect and reduce ambiguity or missing decision points in the active feature specification and record the clarifications directly in the spec file. -Note: This clarification workflow is expected to run (and be completed) BEFORE invoking `/plan`. If the user explicitly states they are skipping clarification (e.g., exploratory spike), you may proceed, but must warn that downstream rework risk increases. +Note: This clarification workflow is expected to run (and be completed) BEFORE invoking `/speckit.plan`. If the user explicitly states they are skipping clarification (e.g., exploratory spike), you may proceed, but must warn that downstream rework risk increases. Execution steps: @@ -18,7 +22,8 @@ Execution steps: - `FEATURE_DIR` - `FEATURE_SPEC` - (Optionally capture `IMPL_PLAN`, `TASKS` for future chained flows.) - - If JSON parsing fails, abort and instruct user to re-run `/specify` or verify feature branch environment. + - If JSON parsing fails, abort and instruct user to re-run `/speckit.specify` or verify feature branch environment. + - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot"). 2. Load the current spec file. Perform a structured ambiguity & coverage scan using this taxonomy. For each category, mark status: Clear / Partial / Missing. Produce an internal coverage map used for prioritization (do not output raw map unless no questions will be asked). @@ -77,52 +82,65 @@ Execution steps: - Information is better deferred to planning phase (note internally) 3. Generate (internally) a prioritized queue of candidate clarification questions (maximum 5). Do NOT output them all at once. Apply these constraints: - - Maximum of 5 total questions across the whole session. + - Maximum of 10 total questions across the whole session. - Each question must be answerable with EITHER: - * A short multiple‑choice selection (2–5 distinct, mutually exclusive options), OR - * A one-word / short‑phrase answer (explicitly constrain: "Answer in <=5 words"). - - Only include questions whose answers materially impact architecture, data modeling, task decomposition, test design, UX behavior, operational readiness, or compliance validation. - - Ensure category coverage balance: attempt to cover the highest impact unresolved categories first; avoid asking two low-impact questions when a single high-impact area (e.g., security posture) is unresolved. - - Exclude questions already answered, trivial stylistic preferences, or plan-level execution details (unless blocking correctness). - - Favor clarifications that reduce downstream rework risk or prevent misaligned acceptance tests. - - If more than 5 categories remain unresolved, select the top 5 by (Impact * Uncertainty) heuristic. + - A short multiple‑choice selection (2–5 distinct, mutually exclusive options), OR + - A one-word / short‑phrase answer (explicitly constrain: "Answer in <=5 words"). + - Only include questions whose answers materially impact architecture, data modeling, task decomposition, test design, UX behavior, operational readiness, or compliance validation. + - Ensure category coverage balance: attempt to cover the highest impact unresolved categories first; avoid asking two low-impact questions when a single high-impact area (e.g., security posture) is unresolved. + - Exclude questions already answered, trivial stylistic preferences, or plan-level execution details (unless blocking correctness). + - Favor clarifications that reduce downstream rework risk or prevent misaligned acceptance tests. + - If more than 5 categories remain unresolved, select the top 5 by (Impact * Uncertainty) heuristic. 4. Sequential questioning loop (interactive): - Present EXACTLY ONE question at a time. - - For multiple‑choice questions render options as a Markdown table: + - For multiple‑choice questions: + - **Analyze all options** and determine the **most suitable option** based on: + - Best practices for the project type + - Common patterns in similar implementations + - Risk reduction (security, performance, maintainability) + - Alignment with any explicit project goals or constraints visible in the spec + - Present your **recommended option prominently** at the top with clear reasoning (1-2 sentences explaining why this is the best choice). + - Format as: `**Recommended:** Option [X] - ` + - Then render all options as a Markdown table: | Option | Description | |--------|-------------| | A |