Expand description
Implementation of the seshat init command.
Implementation of the seshat init command.
Detects installed AI coding clients, locates their MCP configuration files, checks whether Seshat is already configured, and either auto-patches JSON configs (with backup + confirmation) or displays a copy-paste snippet for JSONC configs.
§Supported clients
| Client | Detection | Config key |
|---|---|---|
| Claude Code | claude in PATH | mcpServers |
| Claude Desktop | app dir exists (macOS) | mcpServers |
| OpenCode | opencode in PATH | mcp |
| Cursor | cursor in PATH | mcpServers |
§Scope selection (default: smart auto-detect)
Without flags, seshat init uses a smart scope:
- First checks whether a project-level config exists for each client in the current working directory (or nearest git root).
- If a project-level config is found, it targets that.
- If not, falls back to the global user config.
--project forces project-level configs only (no fallback).
--global forces global configs only.
§JSONC handling
OpenCode supports both .json and .jsonc config files. When a .jsonc
file is detected (or a .json file that fails JSON parsing), we only show
a snippet — we never auto-patch JSONC to avoid silently destroying comments.
Structs§
- Config
Target - A resolved config target for a specific client.
- Patch
Result - Result of patching a JSON config file.
Enums§
- Client
Kind - A supported AI coding client.
- Config
Format - Config file format.
- Scope
Request - Explicit scope requested by the user via CLI flags.
Functions§
- detect_
clients - Detect all installed AI coding clients and resolve their config targets.
- find_
opencode_ config_ in_ dir - Find the opencode config in a directory, preferring
.jsoncover.json. - is_
already_ configured - Check whether
seshatis already present in the target’s config. - merge_
seshat_ entry - Merge the
seshatentry into a parsed JSONValue. - patch_
json_ config - Patch a JSON config file: (backup if exists) → parse → merge → write.
- resolve_
single_ client - Resolve config target for a single explicitly-named non-ClaudeCode client.
- run_
init - Run the
seshat initcommand. - write_
backup - Write a timestamped backup of
pathnext to the original.