feat: agent-ready CLI and embedded MCP server - #1
Merged
Conversation
Make `fic` zero-shot drivable by coding agents (Phases 2+3 of the design):
- Structured JSON error envelope on stderr in json mode (the default):
{"error":{"code","message","hint"?,"fields"?,"totals"?}}; table mode keeps
plaintext. `code` is the error's canonical identity (fic.core.errors.error_code),
shared by the CLI envelope and the MCP tool-error surface. Exit codes 0-7 unchanged.
- `fic agent-docs`: self-describing manual (JSON / markdown) walking the live Typer
tree — every command, flag, exit code, and the error-envelope shape.
- `fic mcp serve`: embedded MCP stdio server (fic/mcp/) exposing 13 tools over
fic.core via per-resource dispatch adapters. Reads are free; the 6 write tools
take a required boolean `confirm` (fail-closed, checked before any network), and
errors carry the code prefixed into the tool-error message. The mcp SDK is an
optional extra, imported lazily so the base CLI never needs it.
- Console entry point `fic.cli.main:main` renders click usage errors (exit 2)
through the same envelope. Write-gate parity: `docs convert` and `einvoice send`
now require `--yes` (extracted to a shared `require_yes` helper); a bad/missing
document type now surfaces as a recoverable `validation` error (exit 4).
- Command descriptions and allowed `--type` values added so the CLI surface is
self-sufficient via agent-docs.
Tests: error-envelope contract, agent-docs structure, MCP dispatch/gate/inventory
(incl. the confirm gate driven through the real call_tool path), TTY guard. No
network in tests; core purity guard intact.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- README: "Use with an AI agent" section (agent-docs, MCP setup for Claude Code/Cursor, the 13 tools, the error envelope), `fic[mcp]` install, and the updated core/-adapter design note (MCP server now real, not hypothetical). - skills/fic/SKILL.md: bundled skill teaching the search->inspect->act loop, document type enums, the confirm/--yes write gate, exit codes, and traps. - AGENTS.md: dev contract (core purity, the agent-scripted public contract, one-renderer/one-exit, write gates, layout). - docs/superpowers/specs: the agent-readiness design spec + its adversarial design-review resolutions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
ficzero-shot drivable by coding agents — Phases 2+3 of the original design (CLI → Skill → MCP). Inspired by the positronick CLI's agent surface and thego-api-cliplaybook.What changed
Structured error contract
{"error":{"code","message","hint"?,"fields"?,"totals"?}};--output tablekeeps human plaintext. Exit codes 0–7 unchanged.codeis the error's canonical identity (fic.core.errors.error_code), shared by the CLI envelope and the MCP tool-error surface so they can't disagree.fic agent-docs— self-describing manual (JSON, or markdown via--output table) walking the live Typer tree: every command, flag, exit code, and the envelope shape. Command descriptions and the allowed--typevalues were added so the CLI surface is self-sufficient.fic mcp serve— embedded MCP stdio server (fic/mcp/) exposing 13 tools overfic.corevia per-resource dispatch adapters. Reads are free; the 6 write tools take a required booleanconfirm(fail-closed, checked before any network), and errors carry the code prefixed into the tool message ([not_found] …). ThemcpSDK is an optionalfic[mcp]extra, imported lazily so the base CLI never needs it. TTY guard prints client setup instead of hijacking the terminal.Write-gate parity —
docs convertandeinvoice sendnow require--yes(extracted to a sharedrequire_yes), matching the MCPconfirmgate; a bad/missing document type is now a recoverablevalidationerror (exit 4).Docs — README "Use with an AI agent" section,
skills/fic/SKILL.md,AGENTS.md, and the design spec (with its adversarial-review resolutions).How it was verified
fic_deletewithoutconfirmrefused as a tool error with no network call; missing/invalid type → recoverable validation error; MCP errors arrive as[not_found] …/[validation] ….--yesgate; the MCP error-code contract gap) that were fixed and re-verified.🤖 Generated with Claude Code