How to set up, run, test, and publish ccal locally.
- Node 20+
- pnpm (the package manager this repo uses)
- The
claudeCLI installed and logged in — ccal spawns it as a subprocess, so you need it to exercise/v1/chat/completionsend to end. Install from https://docs.claude.com/claude-code and runclaudeonce to sign in.
git clone https://github.com/rousan/ccal.git
cd ccal
pnpm install| Script | What it does |
|---|---|
pnpm dev |
Run the server directly from src/ with tsx (no build step). Equivalent to tsx src/cli.ts serve. |
pnpm typecheck |
tsc --noEmit — type-check without emitting. |
pnpm build |
tsc — compile src/ to dist/ (this is what prepublishOnly runs). |
pnpm start |
Run the compiled server: node dist/cli.js serve. |
During development, pnpm dev is usually all you need. Pass flags after the
script, e.g.:
pnpm dev -- --port 8788Start the server (source or compiled):
pnpm dev -- --port 8787
# or, after pnpm build:
node dist/cli.js serve --port 8787Health probe:
curl http://127.0.0.1:8787/health
# {"ok":true}Model list:
curl http://127.0.0.1:8787/v1/models
# {"object":"list","data":[{"id":"sonnet",...},{"id":"opus",...},{"id":"haiku",...}]}Chat completion (non-streaming):
curl http://127.0.0.1:8787/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "sonnet",
"messages": [{ "role": "user", "content": "Say hello in one word." }]
}'Chat completion (streaming):
curl -N http://127.0.0.1:8787/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "sonnet",
"stream": true,
"messages": [{ "role": "user", "content": "Say hello in one word." }]
}'You should see data: {...} SSE frames followed by data: [DONE].
The
/v1/modelsand/healthendpoints work without theclaudeCLI. The chat endpoint needsclaudeinstalled and logged in; if it can't be found you get a502with a clear message.
Vanilla mode: start the server with --vanilla and a request that would
otherwise use a tool should instead get a plain-English answer with no tool
activity:
node dist/cli.js serve --port 8787 --vanilla
curl http://127.0.0.1:8787/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "sonnet",
"messages": [{ "role": "user", "content": "List the files in the current directory." }]
}'Compare against the same request without --vanilla: the agentic server
actually runs a tool and returns real file names (plus a *↳ Bash: ...* note);
the vanilla server says it can't do that and asks you to run the command
yourself. That contrast is the whole point of the flag — see the README
section for what
changes and why.
If auto-detection doesn't find your binary, set the override:
CCAL_CLAUDE_PATH=/path/to/claude pnpm devSee architecture.md for the full request lifecycle and
../CLAUDE.md for the src/ module map and conventions. In short:
cli.ts (entry) → server.ts (routes) → prompt.ts (flatten) →
claude-binary.ts (resolve) → claude.ts (spawn) → stream.ts (translate).
ccal is published as the scoped, public package @rousan/ccal.
-
Make sure you're logged in to npm and have publish rights to the
@rousanscope:npm whoami npm login # if needed -
Bump the version and update the changelog:
- Update
versioninpackage.json(follow SemVer). - Move the relevant notes from
Unreleasedto a new version section in ../CHANGELOG.md.
- Update
-
Build and publish.
prepublishOnlyrunspnpm buildautomatically, sodist/is always freshly compiled:pnpm build npm publish --access public
--access publicis also set viapublishConfiginpackage.json, so scoped publishes default to public rather than private. -
Verify the published bin works end to end:
npx @rousan/ccal serve --port 8787
Releases are automated by .github/workflows/release.yml, which runs on every
push to main. Bump version in package.json on a PR to main and merge it;
CI then reads the version and, if the tag v<version> does not already exist,
publishes @rousan/ccal to npm, creates the git tag, and cuts a GitHub Release
with generated notes. Pushes that don't change the version skip (the tag already
exists), so nothing is re-released by accident.
This needs a repository secret NPM_TOKEN — an npm automation token with
publish rights to the @rousan scope. The manual npm publish above is only a
fallback for local one-off publishes.
The files field in package.json limits the published tarball to dist,
README.md, and LICENSE, so source and dev files are not shipped.