### Example: using skills.Engine to list, install, and uninstall skills Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/cmd-skills.md Shows how to use the headless skills engine to list skills, install one with options, and handle uninstall errors. Requires importing the skills package. ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/skills" eng := skills.NewEngine("/path/to/project") views, err := eng.List() // []skills.SkillView (cloud rows + local install state) // views[i].State: "review" | "ready" | "installed" report, err := eng.Install("some-skill", skills.InstallOptions{ Global: true, // or false for project scope Agents: []string{"claude-code", "codex"}, // empty = all detected }) // report.CanonicalPath, report.Agents, report.Skipped, report.CloudSyncError ur, err := eng.Uninstall("some-skill") if err != nil && ur.CloudSyncError != "" { // installed locally but cloud state flip failed } ``` -------------------------------- ### Example usage of skills engine Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/skills.md Shows how to create a skills engine, list available skills, approve and install them, check status, and enumerate agents. The Install call may return a CloudSyncError if cloud state is not updated, but the skill is still installed on disk. ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/skills" eng := skills.NewEngine("/home/user/project") // browse + install views, err := eng.List() for _, v := range views { switch v.State { case "review": if err := eng.Approve(v); err != nil { /* ... */ } case "ready": report, err := eng.Install(v.Name, skills.InstallOptions{Global: false}) if report.CloudSyncError != "" { // installed on disk; cloud state not updated } } } // status without a login installed, err := eng.Status() for _, s := range installed { fmt.Println(s.Name, s.Scope, s.Agents) } // which agents can be targeted? for _, a := range eng.Agents() { fmt.Println(a.Name, "detected:", a.Detected) } ``` -------------------------------- ### Get help for SpecStory CLI Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Use `specstory help` to display general help, or `specstory help ` for command-specific help. The example shows `specstory help run`. ```zsh specstory help ``` ```zsh specstory help # e.g. specstory help run ``` -------------------------------- ### Install gotestsum test helper Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Install the gotestsum test helper using Go's install command. ```zsh go install gotest.tools/gotestsum@latest ``` -------------------------------- ### Initialize telemetry and process session with tracing Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/analytics-telemetry.md Use this Go example to set up telemetry in a custom service, mirroring the CLI root's setup. It initializes telemetry with a service name, endpoint, and enabled flag, then creates a session trace, starts a span, computes session stats, sets span attributes, processes exchange spans, ends the span, and records session metrics. The initialization warns but does not fail on error, and shutdown is deferred. ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/telemetry" // identical to the CLI root's setup: if err := telemetry.Init(context.Background(), telemetry.Options{ ServiceName: "my-service", Endpoint: "localhost:4317", Enabled: true, }); err != nil { // warn, don't fail } defer telemetry.Shutdown(ctx) ctx = telemetry.ContextWithSessionTrace(ctx, sessionID) ctx, span := telemetry.Tracer("specstory").Start(ctx, "process_session") stats := telemetry.ComputeSessionStats("Claude Code", session) telemetry.SetSessionSpanAttributes(span, stats) telemetry.ProcessExchangeSpans(ctx, stats, session.SessionData.Exchanges, true /* no prompts */) span.End() telemetry.RecordSessionMetrics(ctx, stats, time.Since(start)) ``` -------------------------------- ### Example: Get provider and enumerate all Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/spi-factory.md Shows how to resolve a provider by ID (case-insensitive) and iterate over all registered providers for a multi-provider sweep. The Get method returns an error for unknown IDs, and the example includes a comment showing the error message format. ```go registry := factory.GetRegistry() // resolve a provider provider, err := registry.Get("Claude") // case-insensitive if err != nil { return err // "provider 'Claude' not found" } // enumerate everything for a multi-provider sweep for _, id := range registry.ListIDs() { p, _ := registry.Get(id) if p.DetectAgent(projectPath, false) { sessions, err := p.GetAgentChatSessions(projectPath, false, nil) // ... } } ``` -------------------------------- ### Install Go and golangci-lint with Homebrew Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Install the required development tools on macOS using Homebrew. Requires Go 1.27.3 or later and the latest golangci-lint. ```zsh brew install go golangci-lint ``` -------------------------------- ### Provenance engine usage example Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/provenance.md Shows how to start the provenance engine, watch a filesystem path, process agent session events, and query attribution records. The engine is equivalent to the --provenance flag; ProcessEvents is a no-op when engine is nil. ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/provenance" engine, cleanup, err := provenance.StartEngine(true) // --provenance equivalent if err != nil { return err } defer cleanup() fsStop, err := provenance.StartFSWatcher(ctx, engine, "/home/user/project") if err != nil { return err } defer fsStop() // after each agent session update: provenance.ProcessEvents(ctx, engine, session) // nop when engine is nil // query attribution for a file records, err := engine.QueryRecords(ctx) for _, r := range records { fmt.Printf("%s modified %s via %s exchange %s\n", r.ActorUsername, r.FilePath, r.AgentType, r.ExchangeID) } ``` -------------------------------- ### Complete TOML configuration example Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/configuration.md Full example configuration file in TOML format covering local and cloud sync, logging, version check, analytics, telemetry, redaction, resume, skills, and provider settings. Includes commented-out optional keys for Cursor API key and mirror directory. ```toml [local_sync] enabled = true output_dir = "~/.specstory/history" local_time_zone = false [cloud_sync] enabled = true [logging] log = false debug = false debug_dir = "~/.specstory/debug" console = false silent = false [version_check] enabled = true [analytics] enabled = true [telemetry] endpoint = "localhost:4317" service_name = "specstory-cli" prompts = true [redaction] enabled = true [resume] view_mode = "dense" # last_agent = "claude" # written automatically [skills] view_mode = "dense" default_location = "global" [providers] claude_cmd = "claude" codex_cmd = "codex" cursor_cmd = "cursor-agent" # cursor_api_key = "crsr_..." # cursorcloud_mirror_dir = "~/.specstory/cursorcloud" ``` -------------------------------- ### Development setup: clone, symlink, and test Source: https://github.com/specstoryai/getspecstory/blob/dev/lore/CONTRIBUTING.md Sets up the Lore development environment by cloning the repository, symlinking it into the agents skills directory, and running tests. Requires Node >= 22.5 and no install step since there are no dependencies. The symlink makes every edit live immediately. ```zsh git clone git@github.com:specstoryai/getspecstory.git ~/getspecstory mkdir -p ~/.agents/skills && ln -sfn ~/getspecstory/lore ~/.agents/skills/lore # fan out into the harnesses you use (symlink, never copy) for h in ~/.claude/skills ~/.codex/skills; do [ -d "$h" ] && ln -sfn ~/.agents/skills/lore "$h/lore" done npm test # Node >= 22.5; no install step - there are no dependencies ``` -------------------------------- ### provenance.FSWatcher.Start Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/types.md Starts the filesystem watcher with the given context. ```APIDOC ## `Start(ctx)` ### Description Starts the filesystem watcher. ### Parameters - `ctx` (context.Context) - Required - The context. ### Returns - (none) ``` -------------------------------- ### OpenCode configuration with schema Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/opencode/examples/tool-exercise.md Use this JSONC snippet to start an OpenCode configuration file. It includes the published schema URL for editor validation and autocomplete. Keep the schema URL in configuration examples. ```jsonc { "$schema": "https://opencode.ai/config.json", } ``` -------------------------------- ### Install SpecStory CLI via Homebrew Source: https://github.com/specstoryai/getspecstory/blob/dev/README.md Install the SpecStory CLI using Homebrew. Required for terminal coding agents and Agent Skills. ```bash brew tap specstoryai/tap brew install specstory ``` -------------------------------- ### Check installed agents and launch with session auto-save Source: https://github.com/specstoryai/getspecstory/blob/dev/README.md Use the SpecStory CLI to check which agents are installed, launch your preferred agent with automatic session saving, and render prior sessions as markdown. All sessions save to `.specstory/history/`. ```bash # Check which agents are installed specstory check # Launch your preferred agent with session auto-save specstory run claude # Launch Claude Code specstory run cursor # Launch Cursor CLI specstory run cursorcloud # Start a Cursor Cloud Agent on this repo and save its sessions specstory run codex # Launch Codex CLI specstory run droid # Launch Droid CLI specstory run deepseek # Launch DeepSeek TUI specstory run antigravity # Launch Antigravity CLI specstory run grok # Launch Grok Build specstory run muse # Launch Muse Code specstory run opencode # Launch OpenCode specstory run qwen # Launch Qwen Code specstory run pi # Launch Pi specstory run # Launch the default agent (Claude Code) # Render all prior agent coding sessions in the project as markdown specstory sync ``` -------------------------------- ### Specify non-default IDE install locations with `--user-data-dir` Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Use the repeatable `--user-data-dir` flag to point an IDE provider at a non-default install location, useful for portable installs or reading a Windows-side install from WSL. Takes a `provider_id:path` pair where path is the IDE's user-data-dir (parent of `User`). Supported provider IDs: `cursoride`, `cursorcloud`, `copilotide`, `copilotide-insiders`, `copilotide-vscodium`, `copilotide-vscodium-insiders`. If the path doesn't exist, warns and falls back to standard location; `cursorcloud` path is created on first sync. ```zsh specstory sync --user-data-dir cursoride:/opt/cursor/data --user-data-dir copilotide:/opt/vscode/data ``` -------------------------------- ### Install Workthreads Skill Source: https://github.com/specstoryai/getspecstory/blob/dev/workthreads/docs/2026-06-24-WORKTHREADS-AS-BUILT.md Run this command from the workthreads directory to install the skill. It bundles the engine and SKILL.md into ~/.agents/skills/workthreads and symlinks it into ~/.claude/skills/workthreads, making /workthreads available in any Claude Code session. Re-run to update. ```zsh cd workthreads && ./install.sh ``` -------------------------------- ### Install Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/skills.md Installs a skill by name with specified options. Returns a report that may contain a cloud sync error if the cloud state was not updated. ```APIDOC ## Install ### Description Installs a skill by name with specified options. Returns a report that may contain a cloud sync error if the cloud state was not updated. ### Method Method ### Endpoint `eng.Install(name string, opts InstallOptions) (InstallReport, error)` ### Parameters - **name** (string) - Required - The name of the skill to install. - **opts** (InstallOptions) - Required - Installation options, e.g., `InstallOptions{Global: false}`. ### Request Example ```go report, err := eng.Install(v.Name, skills.InstallOptions{Global: false}) ``` ### Response Returns an `InstallReport` with a `CloudSyncError` field that is non-empty if the cloud state was not updated. ``` -------------------------------- ### Engine.Install Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/skills.md Downloads and installs a skill. Returns an InstallReport. Errors if the skill is still awaiting review, has no content to install, or if recording/removing files fails. ```APIDOC ## Engine.Install ### Description Downloads and installs a skill. Returns an InstallReport. Errors if the skill is still awaiting review, has no content to install, or if recording/removing files fails. ### Signature ```go func (e *Engine) Install(name string, opts InstallOptions) (InstallReport, error) ``` ### Parameters - **name** (string) - Required - The skill name. - **opts** (InstallOptions) - Required - Installation options. ### Returns - **InstallReport** - The installation report. - **error** - Error if any; possible errors: `%q is still awaiting review — approve it before installing`, `%q has no content to install`, `recording installed skill: %w`, `removing skill files: %w`. ``` -------------------------------- ### Test provider factory scripts under isolated home directory Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/NEW-PROVIDER-GUIDE.md Run the factory scripts the way CI does, with an isolated HOME and no credentials. The first command checks latest-version; the second captures its output and runs install; the loop runs list-tools twice and diffs the sorted readings. Requires GNU timeout (install via Homebrew on macOS). ```zsh env -i HOME="$(mktemp -d)" PATH="$PATH" timeout 120 bash pkg/providers//factory/latest-version H=$(mktemp -d); V=$(env -i HOME="$(mktemp -d)" PATH="$PATH" bash pkg/providers//factory/latest-version | head -1) env -i HOME="$H" PATH="$PATH" bash pkg/providers//factory/install "$V" for n in 1 2; do ( cd "$(mktemp -d)" && env -i HOME="$H" PATH="$PATH" ="${:-}" bash pkg/providers//factory/list-tools > "/tmp/reading-$n" ); done diff <(sort -u /tmp/reading-1) <(sort -u /tmp/reading-2) && echo "readings agree" ``` -------------------------------- ### SetInstallState Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/cloud.md Sets the install state of a skill. ```APIDOC ## SetInstallState ### Description Sets the install state of a skill. ### Method Function ### Signature ```go func SetInstallState(name, state string) error ``` ### Parameters - **name** (string) - Required - The skill name. - **state** (string) - Required - The install state. Possible values: "available", "installed". ### Returns - **error** - Error if any. ``` -------------------------------- ### Run CLI in interactive auto-save mode Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/CLAUDE.md Starts the CLI in interactive auto-save mode. ```zsh # Interactive interactive auto-save mode ./specstory run ``` -------------------------------- ### Prompt agent to list all tools into ./tools.txt Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/NEW-PROVIDER-GUIDE.md Run the agent directly in a scratch directory and ask it to write all tool names to ./tools.txt. Use this when no harness tool declaration is available. ```text Hello , tell me all the tools you have access to. Write all the tool names to the file ./tools.txt. ``` -------------------------------- ### Example provider implementation (Go) Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/spi-provider.md Shows the full SPI provider interface implementation for a custom agent. Includes all required methods: Name, Check, DetectAgent, GetAgentChatSession, GetAgentChatSessions, ListAgentChatSessions, ExecAgentAndWatch, WatchAgent, ReconstructSession, NativeSessionPath, SupportsReconstruction, and ListAllAgentChatSessions. ReconstructSession and NativeSessionPath return spi.ErrReconstructionUnsupported when reconstruction is not supported. Register the provider in pkg/spi/factory/registry.go's registerAll() — the only place new providers are wired. ```go package myagent import ( "context" "github.com/specstoryai/getspecstory/specstory-cli/pkg/spi" "github.com/specstoryai/getspecstory/specstory-cli/pkg/spi/schema" ) type Provider struct{} func NewProvider() *Provider { return &Provider{} } func (p *Provider) Name() string { return "My Agent" } func (p *Provider) Check(customCommand string) spi.CheckResult { /* probe binary */ } func (p *Provider) DetectAgent(projectPath string, helpOutput bool) bool { /* storage exists? */ } func (p *Provider) GetAgentChatSession(projectPath, sessionID string, debugRaw bool) (*spi.AgentChatSession, error) { /* parse one */ } func (p *Provider) GetAgentChatSessions(projectPath string, debugRaw bool, progress spi.ProgressCallback) ([]spi.AgentChatSession, error) { /* parse all */ } func (p *Provider) ListAgentChatSessions(projectPath string) ([]spi.SessionMetadata, error) { /* metadata only */ } func (p *Provider) ExecAgentAndWatch(projectPath, customCommand, resumeSessionID string, debugRaw bool, sessionCallback func(*spi.AgentChatSession)) error { /* exec + watch */ } func (p *Provider) WatchAgent(ctx context.Context, projectPath string, debugRaw bool, sessionCallback func(*spi.AgentChatSession)) error { /* watch only */ } func (p *Provider) ReconstructSession(data *schema.SessionData, opts spi.ReconstructOptions) (*spi.ReconstructedSession, error) { return nil, spi.ErrReconstructionUnsupported } func (p *Provider) NativeSessionPath(projectPath, filename string) (string, error) { return "", spi.ErrReconstructionUnsupported } func (p *Provider) SupportsReconstruction() bool { return false } func (p *Provider) ListAllAgentChatSessions() ([]spi.GlobalSessionRef, error) { /* enumerate */ } ``` -------------------------------- ### GET /api/v1/lore/skills/library Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/endpoints.md Returns the unified skills library containing review, ready, and installed skills. Each skill includes its SKILL.md content inline. ```APIDOC ## GET /api/v1/lore/skills/library ### Description Returns the unified skills library containing review, ready, and installed skills. Each skill includes its SKILL.md content inline. ### Method GET ### Endpoint /api/v1/lore/skills/library ### Response #### Success Response (200) - **skills** (array of SkillRow) - List of skills. - Each skill includes SKILL.md content inline. #### Response Example { "skills": [ { "name": "string", "state": "string", "content": "string" } ] } ``` -------------------------------- ### Run interactive auto-save mode Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Start interactive auto-save mode with `specstory run `. Defaults to Claude Code if no provider is specified. Example shows `specstory run codex`. ```zsh # Defaults to Claude Code if no provider is specified. specstory run # e.g. specstory run codex ``` -------------------------------- ### Build SpecStory CLI from source Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Clone the repository, navigate to the CLI directory, and build the project. The resulting executable is named 'specstory'. ```zsh # Clone the repository git clone https://github.com/specstoryai/getspecstory.git # Navigate to the CLI directory cd getspecstory/specstory-cli # Build the project go build -o specstory ``` -------------------------------- ### RedactContent usage example Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/redact.md Shows how to call redact.RedactContent to replace detected secrets with placeholders like [REDACTED:openai-api-key] and get the count of distinct secrets replaced. The example content includes an API key and a GitHub token; the count is 2. Use the returned count to treat content as sensitive when it is greater than zero. ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/redact" content := `api_key = "sk-1234567890abcdef" token: ghp_abcdefghijklmnopqrstuvwxyz1234567890` redacted, count := redact.RedactContent(content) // redacted: api_key = "[REDACTED:openai-api-key]" (example rule id) // token: [REDACTED:github-token] (example rule id) // count: 2 distinct secrets replaced if count > 0 { // content contained credentials — treat it as sensitive anyway } ``` -------------------------------- ### Prompt agent to exercise each tool in ./tools.txt Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/NEW-PROVIDER-GUIDE.md After obtaining the tool inventory, run the agent directly in the scratch directory and prompt it to use each available tool one-by-one, identifying any it cannot exercise. ```text Please use each of the tools in ./tools.txt that is available in this environment, one-by-one, to show me how they work. Identify any tools you cannot exercise and explain why. ``` -------------------------------- ### WatchProviders usage example Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/cmd-watch.md Starts watchers for all providers and processes session updates. Uses signal.NotifyContext for clean Ctrl+C exit. The callback receives each session update; here it processes the session with ProcessSingleSession and logs errors. ```go ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() registry := factory.GetRegistry() providers := registry.GetAll() // or a subset map[string]spi.Provider err := utils.WatchProviders(ctx, projectPath, providers, false /* debugRaw */, func(providerID string, session *spi.AgentChatSession) { // session is an update for providerID — save markdown yourself or use // cmdpkg.NewAutosaveCallback(deps) _, err := sessionpkg.ProcessSingleSession(ctx, providerID, session, outputConfig, sessionpkg.ProcessingOptions{IsAutosave: true, RedactSecrets: true}) if err != nil { slog.Error("autosave failed", "err", err) } }) ``` -------------------------------- ### Example Configuration (TOML) Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/README.md Full commented TOML configuration for SpecStory CLI, covering local sync, cloud sync, logging, version check, analytics, telemetry, redaction, and provider commands. All options are commented out by default; uncomment and edit to change behavior. Equivalent CLI flags are noted for each option. ```toml # SpecStory CLI Configuration # # Uncomment (remove the #) the line and edit any setting below to change the default behavior. # For more information, see: https://docs.specstory.com/integrations/terminal-coding-agents/usage [local_sync] # Write markdown files locally. (default: true) # enabled = false # equivalent to --only-cloud-sync # Custom output directory for markdown files. # Default: ./.specstory/history (relative to the project directory) # output_dir = "~/.specstory/history" # equivalent to --output-dir "~/.specstory/history" # Use local timezone for file name and content timestamps (default: false, UTC) # local_time_zone = true # equivalent to --local-time-zone [cloud_sync] # Sync session data to SpecStory Cloud. (default: true, when logged in to SpecStory Cloud) # enabled = false # equivalent to --no-cloud-sync [logging] # Write logs to .specstory/debug/debug.log (default: false) # log = true # equivalent to --log # Debug-level output, requires console or log (default: false) # debug = true # equivalent to --debug # Custom output directory for debug data. # Default: ./.specstory/debug (relative to the project directory) # debug_dir = "~/.specstory/debug" # equivalent to --debug-dir "~/.specstory/debug" # Error/warn/info output to stdout (default: false) # console = true # equivalent to --console # Suppress all non-error output (default: false) # silent = true # equivalent to --silent [version_check] # Check for new versions of the CLI on startup. # Default: true # enabled = false # equivalent to --no-version-check [analytics] # Send anonymous product usage analytics to help improve SpecStory. # Default: true # enabled = false # equivalent to --no-usage-analytics [telemetry] # OTLP gRPC collector endpoint (e.g., "localhost:4317" or "http://localhost:4317") # endpoint = "localhost:4317" # Override the default service name (default: "specstory-cli") # service_name = "my-service-name" # Include user prompt text in telemetry spans (default: true) # prompts = false [redaction] # Redact secrets and API keys from saved markdown history and cloud-synced # session data. (default: true) # Detection uses the betterleaks ruleset, covering API keys, tokens, private # keys, and other credentials for many providers. # enabled = false # equivalent to --no-redact-secrets [providers] # Agent execution commands by provider (used by specstory run) # Pass custom flags (e.g. claude_cmd = "claude --allow-dangerously-skip-permissions") # Use of these is equivalent to -c "custom command" # Claude Code command # claude_cmd = "claude" # Codex CLI command # codex_cmd = "codex" # Copilot IDE commands (used by specstory run copilotide[-variant] to open the IDE) # copilotide_cmd = "code" # copilotide_insiders_cmd = "code-insiders" # copilotide_vscodium_cmd = "codium" # copilotide_vscodium_insiders_cmd = "codium-insiders" # Cursor CLI command # cursor_cmd = "cursor-agent" # Cursor IDE command (used by specstory run cursoride to open the IDE) # cursoride_cmd = "cursor" # Cursor Cloud Agent: command used by specstory run cursorcloud to open the new # agent's page on cursor.com. The default is the system URL opener for your OS, # shown below; set it to open a specific browser instead. # cursorcloud_cmd = "open" # macOS default # cursorcloud_cmd = "xdg-open" # Linux default # cursorcloud_cmd = "rundll32 url.dll,FileProtocolHandler" # Windows default # Cursor API key for reading cloud agents (create one at https://cursor.com/dashboard/api). # The CURSOR_API_KEY environment variable takes precedence. Prefer it, or your user # config (~/.specstory/cli/config.toml): a key in a project config is readable by # anyone who can read the project, and is committed unless .specstory/cli/ is ignored. # cursor_api_key = "crsr_..." # Where raw cloud agent transcripts are mirrored (default: .specstory/cursorcloud in the project) # cursorcloud_mirror_dir = "~/.specstory/cursorcloud" # DeepSeek TUI command # deepseek_cmd = "deepseek" # Droid CLI command # droid_cmd = "droid" # Gemini CLI command # gemini_cmd = "gemini" # Antigravity CLI command # antigravity_cmd = "agy" # Grok Build command # grok_cmd = "grok" # Muse Code command # muse_cmd = "muse" # OpenCode command # opencode_cmd = "opencode" # Pi command # pi_cmd = "pi" # Qwen Code command # qwen_cmd = "qwen" ``` -------------------------------- ### Process a single session with sessionpkg.ProcessSingleSession Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/session.md Shows how to process a single session using the session package. It sets up output configuration, processes the session with options like redacting secrets and using UTC, then prints the size of the generated markdown. Also demonstrates computing and flushing session statistics. ```go import ( "context" sessionpkg "github.com/specstoryai/getspecstory/specstory-cli/pkg/session" "github.com/specstoryai/getspecstory/specstory-cli/pkg/utils" ) cfg, err := utils.SetupOutputConfig("", "") // defaults to ./.specstory if err != nil { return err } size, err := sessionpkg.ProcessSingleSession(context.Background(), "claude", agentSession, cfg, sessionpkg.ProcessingOptions{ OnlyCloudSync: false, ShowOutput: true, IsAutosave: false, // manual sync semantics (HEAD-checked cloud sync) UseUTC: true, RedactSecrets: true, // redact API keys/tokens before writing }) if err != nil { // nil SessionData -> "session or session data is nil" // markdown render failure -> "failed to generate markdown: …" // disk failure -> "error writing markdown file: …" return err } fmt.Printf("wrote %d bytes of markdown\n", size) // statistics stats := sessionpkg.ComputeSessionStatistics(agentSession.SessionData, markdown, "claude") collector := sessionpkg.SharedStatisticsCollector(cfg.GetStatisticsPath()) collector.AddSessionStats(agentSession.SessionID, stats) if err := collector.Flush(); err != nil { return err } ``` -------------------------------- ### SetupOutputConfig and ProjectIdentity usage example Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/utils.md Shows how to configure output and project identity using utils. SetupOutputConfig defaults to {cwd}/.specstory and returns a ValidationError for invalid/not-a-dir/not-writable output dirs. EnsureProjectIdentity and GetProjectID return the project ID (git_id or workspace_id). ```go import "github.com/specstoryai/getspecstory/specstory-cli/pkg/utils" // output config cfg, err := utils.SetupOutputConfig("", "") // {cwd}/.specstory defaults if err != nil { return err // utils.ValidationError (invalid/not-a-dir/not-writable output dir) } fmt.Println(cfg.GetHistoryDir()) // {cwd}/.specstory/history fmt.Println(cfg.GetStatisticsPath()) // {cwd}/.specstory/statistics.json // identity mgr := utils.NewProjectIdentityManagerWithOverrides(cwd, cfg.GetSpecstoryDir(), "", "") if _, err := mgr.EnsureProjectIdentity(); err != nil { return err } projectID, err := mgr.GetProjectID() // "abcd-1234-efgh-5678" (git_id or workspace_id) ``` -------------------------------- ### Install Lore as a Claude Code Plugin Source: https://github.com/specstoryai/getspecstory/blob/dev/lore/README.md Alternative installation method for Claude Code. Adds the marketplace and installs the Lore plugin. Plugin installs update via `/plugin update lore`. ```text /plugin marketplace add specstoryai/getspecstory /plugin install lore@specstory ``` -------------------------------- ### PATCH /api/v1/lore/skills/{name} Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/endpoints.md Updates the install state of a skill in the cloud. The state can be set to 'installed' or 'available'. ```APIDOC ## PATCH /api/v1/lore/skills/{name} ### Description Updates the install state of a skill in the cloud. The state can be set to 'installed' or 'available'. ### Method PATCH ### Endpoint /api/v1/lore/skills/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the skill. #### Request Body - **install_state** (string) - Required - Either "installed" or "available". ### Request Example { "install_state": "installed" } ### Response #### Success Response (200) - **success** (boolean) - Whether the operation succeeded. #### Response Example { "success": true } ``` -------------------------------- ### Build and vet for Windows (GOOS=windows GOARCH=amd64) Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/NEW-PROVIDER-GUIDE.md Run before opening a PR to verify the CLI compiles and passes vet for Windows. The environment prefix must be applied to both commands. ```shell GOOS=windows GOARCH=amd64 go build ./... ``` ```shell GOOS=windows GOARCH=amd64 go vet ./... ``` -------------------------------- ### Webfetch with format parameter Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/opencode/examples/optional-params.md Fetches https://example.com using the webfetch tool with the format parameter set to 'html'. The result is the HTML content of the page. ```html Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

``` -------------------------------- ### Skill state and run status constants Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/cloud.md Constants for skill states (review, ready, installed) and install states (available, installed). Helper functions RunTerminal and RunInProgress check run status. ```go const ( SkillStateReview = "review" SkillStateReady = "ready" SkillStateInstalled = "installed" InstallStateAvailable = "available" InstallStateInstalled = "installed" ) func RunTerminal(status string) bool func RunInProgress(status string) bool ``` -------------------------------- ### Web search for example.com Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/grokbuild/examples/session-1.0.34/session.md Initiates a web search for the query 'example.com'. The search status is reported as in progress. ```text query: `example.com` Status: `in_progress` ``` -------------------------------- ### Install Lore Agent Skill via npx Source: https://github.com/specstoryai/getspecstory/blob/dev/README.md Install the Lore Agent Skill using npx. Requires Node 22.5+. ```bash npx skills add specstoryai/getspecstory --skill lore ``` -------------------------------- ### How It Works diagram Source: https://github.com/specstoryai/getspecstory/blob/dev/README.md ASCII diagram showing the flow from AI coding tools through local-first storage to the cloud platform. ```text AI Coding Tools Local First Cloud Platform ───────────────── ───────────── ───────────────── (Login Required) Cursor IDE ┐ Copilot IDE │ Claude Code CLI │ Cursor CLI │ Cursor Cloud Agent │ Codex CLI ├──────► .specstory/history/ ──────► cloud.specstory.com Droid CLI │ (Auto-Saved Locally) (Search, Ask & Share) DeepSeek TUI │ Antigravity CLI │ Grok Build │ Muse Code │ OpenCode │ Pi │ Qwen Code ┘ ``` -------------------------------- ### PROV-JSON synthetic example Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/docs/git-provenance/standards/w3c-prov.md Synthetic example in PROV-JSON style showing entities, activities, agents, and relations. ```json { "entity": { "e1": { "prov:label": "src/app.ts" } }, "activity": { "a1": { "prov:label": "code-edit", "prov:startTime": "2026-01-23T14:00:00Z", "prov:endTime": "2026-01-23T14:05:00Z" } }, "agent": { "ag1": { "prov:type": "prov:Person", "prov:label": "Developer" }, "ag2": { "prov:type": "prov:SoftwareAgent", "prov:label": "AI Agent" } }, "wasGeneratedBy": { "g1": { "prov:entity": "e1", "prov:activity": "a1" } }, "wasAssociatedWith": { "w1": { "prov:activity": "a1", "prov:agent": "ag2" } } } ``` -------------------------------- ### Create canonical skill and symlink into harnesses Source: https://github.com/specstoryai/getspecstory/blob/dev/lore/SKILL.md Creates a canonical skill package in ~/.agents/skills//SKILL.md and symlinks it into each existing harness skills directory (~/.claude/skills, ~/.codex/skills). Symlinks avoid frozen-copy drift. Project-scoped skills go to /.claude/skills/ instead. ```zsh # canonical home (the cross-harness neutral location; Codex and Gemini CLI read it natively) ~/.agents/skills//SKILL.md # fan out into every harness skills dir that exists (symlink, never copy - avoids frozen-copy drift) for h in ~/.claude/skills ~/.codex/skills; do [ -d "$h" ] && ln -sfn ~/.agents/skills/ "$h/" done ``` -------------------------------- ### SetupOutputConfig Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/utils.md Sets up the output configuration with default paths. Returns a validation error if the output directory is invalid, not a directory, or not writable. ```APIDOC ## SetupOutputConfig ### Description Sets up the output configuration with default paths. Returns a validation error if the output directory is invalid, not a directory, or not writable. ### Function Signature ```go func SetupOutputConfig(cwd string, outputDir string) (*OutputConfig, error) ``` ### Parameters - **cwd** (string) - Required - The current working directory. - **outputDir** (string) - Required - The output directory; empty string uses default `{cwd}/.specstory`. ### Return Value - **cfg** (*OutputConfig) - The output configuration. - **err** (error) - Returns `utils.ValidationError` if the output directory is invalid, not a directory, or not writable. ``` -------------------------------- ### Verify Homebrew installation Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/docs/CLI-RELEASE.md After release, verifies the Homebrew tap and upgrades the specstory CLI. Run these commands to confirm the installed version works. ```zsh brew tap specstoryai/homebrew-tap brew update brew upgrade specstory specstory version ``` -------------------------------- ### Start finite monitor with DONE command Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/grokbuild/examples/session-1.0.34/session.md Launches a short-lived monitor that runs a command printing 'DONE' and exits. The monitor is non-persistent with a 15-second timeout, and events are delivered asynchronously without polling. ```bash printf 'DONE\n' ``` -------------------------------- ### Full Session Example JSON Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/docs/SPI-SESSION-DATA-SCHEMA.md Complete session example with two exchanges, including user messages, agent text, tool use, and tool output. ```json { "schemaVersion": "1.0", "provider": { "id": "claude", "name": "Claude Code", "version": "1.0.0" }, "sessionId": "sess-1234", "createdAt": "2025-11-13T10:00:00Z", "updatedAt": "2025-11-13T10:05:00Z", "slug": "create-go-hello-world", "workspaceRoot": "/home/alice/project", "exchanges": [ { "exchangeId": "ex_001", "startTime": "2025-11-13T10:00:00Z", "endTime": "2025-11-13T10:00:15Z", "messages": [ { "id": "u1", "timestamp": "2025-11-13T10:00:00Z", "role": "user", "content": [{ "type": "text", "text": "Create src/main.go with Hello World" }] }, { "id": "a1", "timestamp": "2025-11-13T10:00:10Z", "role": "agent", "model": "claude-3-5-sonnet-20241022", "content": [{ "type": "text", "text": "Creating the file now." }], "tool": { "name": "Write", "type": "write", "useId": "tool_001", "input": { "file_path": "src/main.go" } }, "pathHints": ["src/main.go"] } ] }, { "exchangeId": "ex_002", "startTime": "2025-11-13T10:01:00Z", "endTime": "2025-11-13T10:01:20Z", "messages": [ { "id": "u2", "timestamp": "2025-11-13T10:01:00Z", "role": "user", "content": [{ "type": "text", "text": "Run the program" }] }, { "id": "t2", "timestamp": "2025-11-13T10:01:10Z", "role": "agent", "model": "claude-3-5-sonnet-20241022", "tool": { "name": "Bash", "type": "shell", "useId": "tool_002", "input": { "command": "go run src/main.go" }, "output": { "stdout": "Hello World\n", "exit_code": 0 } } }, { "id": "a2", "timestamp": "2025-11-13T10:01:20Z", "role": "agent", "model": "claude-3-5-sonnet-20241022", "content": [{ "type": "text", "text": "The program ran successfully and printed 'Hello World'." }] } ] } ] } ``` -------------------------------- ### Package-global watcher state and init Source: https://github.com/specstoryai/getspecstory/blob/dev/PLAN.md Defines package-global watcher state and initializes the context in init(). Required for the shared watcher used by WatchAgent and run. ```go var ( watcherCtx context.Context; watcherCancel context.CancelFunc; watcherWg sync.WaitGroup; watcherCallback func(*spi.AgentChatSession); watcherDebugRaw bool; watcherMutex sync.RWMutex ) func init() { watcherCtx, watcherCancel = context.WithCancel(context.Background()) } ``` -------------------------------- ### Grep with include and path parameters Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/opencode/examples/optional-params.md Uses the grep tool with pattern 'magic', path 'sub', and include '*.txt' to search for matches. The result shows one match in data.txt at line 2. ```text Found 1 matches /Users/dev/oc-tools/sub/data.txt: Line 2: beta magic ``` -------------------------------- ### Webfetch https://example.com Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/pkg/providers/opencode/examples/tool-exercise.md Fetches the content of https://example.com using the webfetch tool. The result is a markdown representation of the example domain page. ```markdown # Example Domain This domain is for use in documentation examples without needing permission. Avoid use in operations. [Learn more](https://iana.org/domains/example) ``` -------------------------------- ### Engine.Uninstall Source: https://github.com/specstoryai/getspecstory/blob/dev/_autodocs/api-reference/skills.md Removes files, symlinks, lock entry, and clears cloud install state for a skill. Returns an error if the skill is not installed from SpecStory Cloud. ```APIDOC ## Engine.Uninstall ### Description Removes files, symlinks, lock entry, and clears cloud install state for a skill. Returns an error if the skill is not installed from SpecStory Cloud. ### Signature ```go func (e *Engine) Uninstall(name string) (UninstallReport, error) ``` ### Parameters - **name** (string) - Required - The skill name. ### Returns - **UninstallReport** - The uninstall report. - **error** - Error if any; error message: `%q is not installed from SpecStory Cloud`. ``` -------------------------------- ### Exchange Record JSON example Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/docs/git-provenance/RECOMMENDATIONS.md Session/prompt/tool context keyed by exchange_id. Provides rich explainability context including contributor, prompt, summary, tools, and VCS revision. ```json { "version": "1.0.0", "exchanges": [ { "exchange_id": "ex_0042", "session_id": "sess_7c3a", "timestamp": "2026-02-20T16:04:12Z", "contributor": { "type": "ai", "tool": "claude-code", "model": "claude-sonnet-4-20250514" }, "user_prompt": "Add strict callback host validation.", "assistant_summary": "Added allowlist validation and URL parsing guards.", "tools": [ { "name": "Edit", "file": "pkg/auth/callback.go" }, { "name": "Edit", "file": "pkg/auth/callback_test.go" } ], "vcs": { "type": "git", "revision": "9f4a2c3d" } } ] } ``` -------------------------------- ### GET /v0/agents Source: https://github.com/specstoryai/getspecstory/blob/dev/specstory-cli/docs/CURSOR-CLOUD-AGENTS.md Lists agents (legacy). ```APIDOC ## GET /v0/agents ### Description Lists agents (legacy). ### Method GET ### Endpoint /v0/agents ### Response #### Success Response (200) - **agents** (array) - List of agents. - **status** (string) - Agent status. - **source** (object) - Source information. - **repository** (string) - Repository URL. - **ref** (string) - Reference. - **target** (object) - Target information. - **branchName** (string) - Branch name. - **url** (string) - URL. - **prUrl** (string) - Pull request URL. - **linesAdded** (integer) - Lines added. - **filesChanged** (integer) - Files changed. #### Response Example { "agents": [ { "status": "string", "source": { "repository": "string", "ref": "string" }, "target": { "branchName": "string", "url": "string", "prUrl": "string" }, "linesAdded": 0, "filesChanged": 0 } ] } ```