Skip to content

feat: ai-friendly root-cms client CLI commands and agent skill#1299

Merged
stevenle merged 3 commits into
mainfrom
feat/root-cms-ai-cli
Jul 12, 2026
Merged

feat: ai-friendly root-cms client CLI commands and agent skill#1299
stevenle merged 3 commits into
mainfrom
feat/root-cms-ai-cli

Conversation

@stevenle

Copy link
Copy Markdown
Member

Summary

Exposes the RootCMSClient to AI coding agents (and scripts) through the root-cms CLI, plus a downloadable skill that teaches agents how to use it.

New commands

  • root-cms client.call <method> [jsonArgs] — invokes any public method on RootCMSClient. Args are a JSON array of positional arguments matching the method's TypeScript signature. Output is a single-line JSON envelope on stdout:

    {"ok": true, "result": <value>}      # exit 0
    {"ok": false, "error": "<message>"}  # exit 1
    
    • Omit jsonArgs for zero-arg methods; pass - to read args from stdin (stdin is only read when explicitly requested, so no hangs).
    • Firestore Timestamp / GeoPoint / DocumentReference round-trip as {_seconds,_nanoseconds} / {_latitude,_longitude} / {_referencePath} in both args and results.
  • root-cms client.methods [--json] [--types] — lists all public methods with their TS signatures and JSDoc descriptions for discovery; --types also emits the referenced interface/type definitions.

  • root-cms skill.install [dir] — installs the bundled root-cms-cli agent skill into a local skills directory (default .claude/skills). Supports a custom dir and --force.

How it works

The method/type catalog is parsed from the generated dist/core/client.d.ts, so it always matches the real API. Private methods are excluded. The decorative CLI banner is suppressed for client.* commands to keep stdout as clean JSON.

Also refactors the duplicated convertFirestoreTypes helper into cli/utils.ts.

Downloadable skill

skills/root-cms-cli/SKILL.md teaches the discover-then-call workflow, arg encoding, the result envelope, and write-safety guidance. It ships with the npm package (skills/**/* added to files) and installs via root-cms skill.install.

Testing

  • pnpm build:core succeeds; .d.ts generation passes.
  • 23 tests pass, including 6 new parser tests in cli/client-reflect.test.ts (private exclusion, multi-line signatures, zero-arg methods, type extraction).
  • Lint clean.
  • Manually verified client.methods (text + --json --types), client.call error/exit-code paths, and all skill.install scenarios (default, custom dir, duplicate error, --force).

Not exercised: a successful client.call requires a real Root.js project (root.config.ts) + Firebase credentials, which the repo root lacks — plumbing was verified up to config load.

🤖 Generated with Claude Code

stevenle and others added 2 commits July 10, 2026 17:15
Adds CLI commands designed for AI coding agents to interact with the
RootCMSClient programmatically:

- `root-cms client.call <method> [jsonArgs]` invokes any public method
  with a JSON array of positional args and prints a JSON result envelope
  ({"ok":true,"result":...} / {"ok":false,"error":...}). Firestore
  Timestamp/GeoPoint/DocumentReference values round-trip as plain JSON.
- `root-cms client.methods [--json] [--types]` lists every public method
  with its TypeScript signature and description (plus referenced type
  defs) for API discovery.
- `root-cms skill.install [dir]` installs the bundled `root-cms-cli`
  agent skill into a local skills dir (default `.claude/skills`).

The method/type catalog is parsed from the generated client.d.ts so it
always matches the real API; private methods are excluded. The decorative
CLI banner is suppressed for `client.*` so stdout stays clean JSON.

Also refactors the duplicated convertFirestoreTypes helper into utils.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydw

Copy link
Copy Markdown
Member

Nice; looks good. Regarding the local skills directory maybe we could try to have it detect the right dir; for example VS Code uses .agents (https://agentskills.io/skill-creation/quickstart#prerequisites, https://docs.github.com/en/copilot/concepts/agents/about-agent-skills#about-agent-skills). So it could try to identify where the project stores the skills and install it there.

@stevenle

Copy link
Copy Markdown
Member Author

@jeremydw how do you propose the "detect" mechanism would work? i.e. the agent checks to see if certain folders already exists?

Instead of defaulting to `.claude/skills`, `root-cms skill.install` now
stays agnostic of any particular AI provider:

- Detects any existing `.<provider>/skills` directory in the project
  (e.g. `.claude/skills`, `.agent/skills`, `.cursor/skills`) and installs
  into all of them.
- Otherwise seeds `skills/` under a known agent config dir that exists
  (`.claude`, `.agent`).
- Otherwise falls back to a neutral `.agent/skills`.

An explicit `[dir]` argument still overrides detection. Already-installed
targets are skipped (unless `--force`) instead of erroring, so multi-dir
installs don't abort partway.

Adds detectSkillsDirs() unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydw

Copy link
Copy Markdown
Member

@jeremydw how do you propose the "detect" mechanism would work? i.e. the agent checks to see if certain folders already exists?

Yup - the latest commit has what I was thinking!

@stevenle stevenle merged commit 479feb7 into main Jul 12, 2026
1 check passed
@stevenle stevenle deleted the feat/root-cms-ai-cli branch July 12, 2026 22:22
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.

2 participants