Skip to content

feat: add ct init scaffolding and process workspaces - #139

Merged
2000game merged 7 commits into
eqrm:mainfrom
bwl21:feat/131-init
Aug 25, 2026
Merged

2000game merged 7 commits into
eqrm:mainfrom
bwl21:feat/131-init

Conversation

@bwl21

@bwl21 bwl21 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add ct init [directory] to scaffold a minimal config repository
  • generate ct.config.ts, ct.envs.json, .gitignore, config/, and blueprints/
  • collect the ChurchTools host, first environment, and optional Git initialization interactively
  • support reproducible non-interactive initialization with --host, --env, --git/--no-git, and --yes
  • refuse to overwrite existing scaffold files through a preflight check
  • optionally verify and store an existing login token through a hidden prompt on macOS
  • add an opt-in --template process quickstart for portable, instance-aware process workspaces

Process quickstart

The existing standard template remains the default. A reusable process inside an existing repository can be initialized explicitly:

ct init processes/example-process \
  --template process \
  --host https://example.church.tools \
  --env prod \
  --protected \
  --no-git \
  --yes

This creates:

<process>/
├── ct.config.ts
├── ct.envs.json
├── .gitignore
├── README.md
├── blueprint/
├── configs/
└── instances/
    └── example.church.tools/
        ├── ct-state.example.church.tools.json
        ├── backups/
        ├── reference/
        └── reports/

The root ct.config.ts is the normal entry point. ct.envs.json binds the environment to the normalized host, hostname-derived state path and protection status. The empty host-bound state is written immediately; the process template never creates a generic ct-state.json.

Portable definitions stay outside instances/. The generated README uses explicit ct plan -e <env> / ct apply -e <env> commands and reserves configs/ for exceptional -c entry points. Reports, backups and captured reference output remain under the matching instance and are ignored by default. No credentials or live ChurchTools IDs are generated.

Boundaries

Validation

  • npm test — 823 passed, 5 skipped
  • focused init/CLI tests — 18 passed
  • npm run typecheck
  • npm run lint
  • npm run build
  • documentation staleness check — all pages current
  • Prettier check for every changed file
  • git diff --check

The repository-wide Prettier command additionally sees unrelated local generated files under reference/ and reports/; those files were not modified or included in this PR.

Fixes #131

@bwl21
bwl21 marked this pull request as ready for review August 22, 2026 17:53
@bwl21 bwl21 changed the title [codex] add ct init scaffolding and secure token login feat: add ct init scaffolding and secure token setup Aug 23, 2026
@bwl21
bwl21 marked this pull request as draft August 24, 2026 16:35
@bwl21 bwl21 changed the title feat: add ct init scaffolding and secure token setup feat: add ct init scaffolding and process workspaces Aug 24, 2026
# Conflicts:
#	src/index.ts
#	tests/cli.test.ts
# Conflicts:
#	src/auth/login.ts
#	src/auth/tokenStore.ts
#	src/commands/auth.ts
@bwl21
bwl21 marked this pull request as ready for review August 24, 2026 20:46
Review follow-ups on eqrm#131:

- `ct init` no longer exits 1 when the guided login fails after the
  scaffold is written. The failure is reported and the command falls
  through to the `ct auth login` hint, as `ct auth login` does; a
  re-run would otherwise only hit "refusing to overwrite".
- The standard .gitignore now ignores `backups/`. `ct apply` writes
  backups next to the state file, which the standard scaffold puts at
  the repository root, so every apply left a dump of the live instance
  staged for the next `git add .`. The process template already did.
- `validateHost` rejects a URL carrying a query or fragment. A URL
  copied out of the browser address bar was accepted verbatim and
  every request became `.../#/churchdb/api/...`. A path is left alone:
  it is how a sub-path installation is addressed.
- The "Initialize a Git repository?" question is skipped in a
  directory that already is one, instead of collecting an answer that
  was then silently dropped.
- `askHidden` delegates to `askSecret`, leaving one no-echo code path
  instead of two divergent ones, only one of which was covered.

Claude-Session: https://claude.ai/code/session_01SaAzHDgDPSvLnfkKcnDj37
@2000game
2000game merged commit 4e01c03 into eqrm:main Aug 25, 2026
3 checks passed
@bwl21
bwl21 deleted the feat/131-init branch August 26, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add ct init for new config repositories

2 participants