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
- 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).
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.
- 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.
cougr add --list prints all available pieces with a one-line description, sourced from the same manifest.
- 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
Part of #238
Background
Once a project exists (via
cougr newor 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 itsmodwiring updated automatically.References
docs/strategy/06-product-strategy.md(shadcn distribution pattern discussion)examples/README.md(existing catalog, the data source this command reads from)session-auth(fromexamples/session_arena),hidden-hand(fromexamples/hidden_hand),standards/pausable,standards/access-control(fromsrc/standards/usage inexamples/guild_arena)In scope
pieces.toml, embedded in the CLI binary like thenewtemplates) mapping a piece name to its source files, target paths, and anyCargo.tomldependency lines it requires (e.g. adding thetestutilsfeature if the piece includes a harness-based test).cougr add <piece>copies the piece's files into the current project'ssrc/, appends the necessarymoddeclarations tolib.rs(or the relevant parent module) without clobbering existing code, and prints what was added.cougr add --listprints all available pieces with a one-line description, sourced from the same manifest.session-auth,hidden-hand,standards/pausable.Out of scope
docs/strategy/05-ecosystem-vision.md); all pieces ship embedded in the binary for v1.cougr-corefeature/version line.Definition of done
cougr add --listshows at least 3 pieces.cougr add session-authon a freshcougr newproject results in a project that still builds and passescargo testafter the addition.cougr addtwice for the same piece does not silently overwrite modified files.