Skip to main content

CLI utilities for csrd service generation and feature augmentation

Project description

csrd-utils

CLI and runtime helpers for generating csrd services and augmenting existing services with optional features.

Install

pip install "csrd-utils @ git+https://github.com/csrd-api/fastapi-common.git#subdirectory=packages/utils"

CLI

csrd --help
csrd --version
csrd new workspace                                # create workspace, then choose none/service/cluster
csrd new service                                  # requires workspace; prompts to create one if missing
csrd new service --interactive --name items       # pre-fills name prompt with 'items'
csrd new service --name inventory --no-interactive --output ./my-workspace
csrd new service --name pricing --output ./my-workspace --no-interactive
csrd new cluster --spec ./cluster.yaml --output ./my-workspace
csrd new cluster                                  # requires workspace; interactive mode can offer to create one
csrd feature list
csrd feature plan workers --service .
csrd feature plan workers --service . --json
csrd feature add workers --service .
csrd doctor --service .
csrd audit                                          # if cwd is workspace, audits all services
csrd audit --service .                              # explicitly audit one service path
csrd completion bash                                # print bash completion script

feature plan --json is useful for CI or tooling wrappers.

Bash tab completion

Enable command/subcommand completion in bash:

source <(csrd completion bash)

Then examples like csrd ne<TAB> and csrd new wor<TAB> complete to new and workspace.

Workspace extraction command

Service extraction into a sibling workspace is supported:

csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --mode copy
csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --mode move
csrd workspace extract-service --service ./source-ws/src/pricing --target-workspace ../pricing-ws --dry-run --json

Use extraction when service ownership diverges, release cadence becomes independent, or workspace orchestration starts coupling unrelated deployments.

Manual fallback remains available if needed:

csrd new workspace --name pricing-ws --output .. --generate none
cp -a ./source-ws/src/pricing ../pricing-ws/src/pricing
cd ../pricing-ws
csrd new cluster --spec ./.csrd/cluster.yaml --output . --force

Interactive generation behavior

  • csrd new service and csrd new cluster are workspace-first commands.
  • If a workspace marker is missing in the selected output path, interactive flows ask to create one and continue.
  • Non-interactive generation errors when no workspace marker is present.
  • Workspace cluster source of truth is persisted at .csrd/cluster.yaml.
  • If .csrd/cluster.yaml already exists, csrd new service appends the generated service and refreshes scaffold files (docker-compose.yml, .env.example, README.md, smoke.sh). Service source directories and running containers are never touched.
  • If .csrd/cluster.yaml is missing, csrd new service bootstraps .csrd/cluster.yaml and writes initial cluster scaffold files.
  • csrd new service runs a compact interactive flow by default (core prompts 1-6), then asks whether to show advanced options.
  • csrd new workspace creates a workspace directory and prompts whether to generate none, service, or cluster immediately.
  • In compact mode, advanced options are hidden by default.
  • csrd new service --interactive runs the full verbose interactive flow.
  • Passing --name <value> in interactive mode uses that value as the name prompt default.
  • You can still overwrite the default by entering a different value at the prompt.
  • Use --no-interactive for fully flag-driven generation.
  • Database default is none.
  • All yes/no prompts default to No (y/N).

Typical workflow

# 0) Create a workspace and generate a service inside it
csrd new workspace --name local-dev --output . --generate none
csrd new service --name inventory --output ./local-dev --database postgres --workers

# 1) Verify service compatibility
csrd doctor --service ./local-dev/src/inventory

# 1b) Audit for weak/insecure defaults
csrd audit --service ./local-dev/src/inventory

# 2) Inspect available bundled features
csrd feature list

# 3) Dry-run a feature
csrd feature plan workers --service ./local-dev/src/inventory

# 4) Apply feature files/merges
csrd feature add workers --service ./local-dev/src/inventory

# 5) Add a second service — workspace auto-upgrades to cluster
csrd new service --name pricing --output ./local-dev --database postgres

Bundled assets

  • features/workers/ feature manifests and fragments
  • templates/cookiecutter-service/ template starter

Python API

from pathlib import Path
from csrd_utils import ServiceAugmentor
from csrd_utils.resources import features_path

with features_path() as feature_lib:
    augmentor = ServiceAugmentor(Path("."), feature_lib)
    ok, changes = augmentor.add_feature("workers", plan=True)

Documentation

  • docs/CLI_REFERENCE.md - full command/flag reference
  • docs/FEATURES.md - bundled feature catalog and behavior
  • docs/FUTURE_WORK.md - remaining provider-specific CI wiring work (Phase 5B)
  • docs/AGENT_SMOKE_TESTS.md - copy/paste validation flow for clean workspaces
  • docs/COMMAND_MATRIX.yaml - machine-readable command matrix for automation
  • AGENTS.md - package-local rules for autonomous agents

CLI-only agent mode

If an agent can only see the installed CLI (not source files), use this exploration sequence:

csrd --help
csrd new --help
csrd new workspace --help
csrd new service --help
csrd new cluster --help
csrd feature --help
csrd doctor --help
csrd audit --help
csrd feature list

Then run a clean smoke flow:

mkdir -p /tmp/csrd-smoke
csrd new workspace --name ws --output /tmp/csrd-smoke --generate none
csrd new service --name demo-svc --output /tmp/csrd-smoke/ws --no-interactive
csrd doctor --service /tmp/csrd-smoke/ws/src/demo-svc
csrd audit --service /tmp/csrd-smoke/ws/src/demo-svc
csrd feature plan workers --service /tmp/csrd-smoke/ws/src/demo-svc
csrd feature add workers --service /tmp/csrd-smoke/ws/src/demo-svc

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csrd_utils-0.3.81.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csrd_utils-0.3.81-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

Details for the file csrd_utils-0.3.81.tar.gz.

File metadata

  • Download URL: csrd_utils-0.3.81.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for csrd_utils-0.3.81.tar.gz
Algorithm Hash digest
SHA256 9cfab2eaae5f05141a61b190db67fc11270c7de5d19d4cf9c526adf80f60454b
MD5 a1bae622626c98e088efb439b706f946
BLAKE2b-256 47b8fe09deeba5ee7552e1c62985378928f7233e35d484f694dba7bc618f058c

See more details on using hashes here.

Provenance

The following attestation bundles were made for csrd_utils-0.3.81.tar.gz:

Publisher: release.yml on csrd-api/fastapi-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file csrd_utils-0.3.81-py3-none-any.whl.

File metadata

  • Download URL: csrd_utils-0.3.81-py3-none-any.whl
  • Upload date:
  • Size: 113.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for csrd_utils-0.3.81-py3-none-any.whl
Algorithm Hash digest
SHA256 e4cddb15dc98c98a4dac500f89b1629d9c4ef35757c2c5a88cea42da7f8d8c3c
MD5 cc9b900aee97ebc5593082dbd6bd0f61
BLAKE2b-256 1bbc8f909aac25d1d6c43f1c48188305da8a776ca0803f1f7f3904d61bbbec8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for csrd_utils-0.3.81-py3-none-any.whl:

Publisher: release.yml on csrd-api/fastapi-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page