Skip to main content

Module init

Module init 

Source
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

ClientDetectionConfig key
Claude Codeclaude in PATHmcpServers
Claude Desktopapp dir exists (macOS)mcpServers
OpenCodeopencode in PATHmcp
Cursorcursor in PATHmcpServers

§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§

ConfigTarget
A resolved config target for a specific client.
PatchResult
Result of patching a JSON config file.

Enums§

ClientKind
A supported AI coding client.
ConfigFormat
Config file format.
ScopeRequest
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 .jsonc over .json.
is_already_configured
Check whether seshat is already present in the target’s config.
merge_seshat_entry
Merge the seshat entry into a parsed JSON Value.
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 init command.
write_backup
Write a timestamped backup of path next to the original.