Skip to content

feat(cli): implement 'cougr add <piece>' component/system importer #245

Description

@salazarsebas

Part of #238

Background

Once a project exists (via cougr new or otherwise), adding a specific capability, session-based auth, a hidden-information mechanic, a standards-layer guard, currently means manually reading an example and copy-pasting the relevant component/system code. This mirrors the distribution model shadcn/ui uses for UI components (copy owned source into your project via a CLI, not an opaque dependency), applied to Cougr's existing example catalog.

Objective

Implement cougr add <piece>, which copies a named, self-contained component/system pair (or standards-layer module) from the example catalog into the current project as editable source, with its mod wiring updated automatically.

References

  • Product spec: docs/strategy/06-product-strategy.md (shadcn distribution pattern discussion)
  • examples/README.md (existing catalog, the data source this command reads from)
  • Candidate first pieces: session-auth (from examples/session_arena), hidden-hand (from examples/hidden_hand), standards/pausable, standards/access-control (from src/standards/ usage in examples/guild_arena)
  • shadcn/ui CLI, for the distribution pattern this issue adapts: https://ui.shadcn.com/docs/cli

In scope

  1. A catalog manifest (e.g. pieces.toml, embedded in the CLI binary like the new templates) mapping a piece name to its source files, target paths, and any Cargo.toml dependency lines it requires (e.g. adding the testutils feature if the piece includes a harness-based test).
  2. cougr add <piece> copies the piece's files into the current project's src/, appends the necessary mod declarations to lib.rs (or the relevant parent module) without clobbering existing code, and prints what was added.
  3. Conflict handling: if a target file already exists, the command refuses to overwrite and tells the user exactly what would have been written, rather than silently merging or destroying local changes.
  4. cougr add --list prints all available pieces with a one-line description, sourced from the same manifest.
  5. At least 3 pieces implemented end-to-end for v1: session-auth, hidden-hand, standards/pausable.

Out of scope

  • A remote/community piece registry (Tier 3 in docs/strategy/05-ecosystem-vision.md); all pieces ship embedded in the binary for v1.
  • Automatic dependency-version resolution beyond appending a known-good cougr-core feature/version line.

Definition of done

  • cougr add --list shows at least 3 pieces.
  • cougr add session-auth on a fresh cougr new project results in a project that still builds and passes cargo test after the addition.
  • Running cougr add twice for the same piece does not silently overwrite modified files.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programadvancedRequires deep Cougr knowledgeclicougr-cli toolingenhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions