Rust workspace for the ctx context-capture tool.
- Default config is created at
$XDG_CONFIG_HOME/ctx/config.toml(or~/.config/ctx/config.toml), with data in$XDG_DATA_HOME/ctxand state in$XDG_STATE_HOME/ctx. - Config precedence (highest first): CLI flags, CLI
--config, environment variables (CTX__...), local./ctx.toml, global config file. - A commented example config lives in
examples/config.tomlwith a$schemareference (schema inexamples/config.schema.json). - Run
cargo run -p ctx-cli(binary name:ctx) to exercise the CLI; it emits structured JSON (metadata + system, displays, apps, windows, clipboard, screenshots, accessibility, actions) or a human summary (--jsonfor machine output). Use--saveto write the JSON into the configured capture directory. Clipboard and screenshots are captured when enabled; use--provider noopto disable host interactions. Usescripts/copy_config_schema.shto publish schema updates to the shared schemas repo. ctx current --jsonreturns the lightweight current-context state quickly from$XDG_STATE_HOME/ctx/current-context.json(oroutput.state_file). Event sources must announce complete active-context reports explicitly; ctx does not poll tmux or window managers automatically. Example:ctx current report --source shell --kind terminal --cwd "$PWD" --project my-repo --json. Each report replaces the previousactivecontext wholesale, so non-terminal reporters can omitcwd/projectwithout leaving stale shell state behind. JSON format v1:schema,version,updated_at,sequence, andactivewith optionalsource,kind,app,bundle_id,window,workspace,url,cwd,project,depthfields.- tmux users can install the example hooks in
examples/tmux-current-context.confto report active pane cwd, session, and window on focus changes. zellij and herdr users can run the polling reportersexamples/zellij-current-context.shandexamples/herdr-current-context.shinside their sessions. AeroSpace users can adaptexamples/aerospace-current-context.shto report workspace/window changes with--kind application. Browser extensions/native messaging hosts should report focused tabs with--kind browser --url <url>. ctx watchdetects new screenshots from screenshot directories (poll-based file watching with write-settling) and the clipboard, deduplicates them across sources by hashing decoded pixels, and emits one JSON line per detection event. Clipboard-only screenshots are spooled as PNGs into the data-dirinbox/; the seen-hash index persists in the state dir so restarts do not re-emit. Flags:--dir(repeatable, defaults to platform screenshot dirs),--no-clipboard,--interval-ms,--max-age-secs,--once.- Nested multiplexers (e.g. herdr inside tmux) are handled via
--depth: reporters declare their terminal nesting depth, and ctx drops a shallower report that arrives while a deeper report is still fresh (2s grace window), so the innermost multiplexer wins races on the same focus change while genuine outer focus changes still get through. The tmux example hooks additionally skip reporting when the focused pane runs a nested multiplexer. - Tooling commands are listed in AGENTS.md.