ctx-agent 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ctx_agent-0.1.0/.gitignore +38 -0
- ctx_agent-0.1.0/PKG-INFO +77 -0
- ctx_agent-0.1.0/README.md +64 -0
- ctx_agent-0.1.0/pyproject.toml +36 -0
- ctx_agent-0.1.0/src/ctx/code/README.md +148 -0
- ctx_agent-0.1.0/src/ctx/code/__init__.py +105 -0
- ctx_agent-0.1.0/src/ctx/code/acp.py +1364 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_rows.py +60 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/google-colab/SKILL.md +104 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/SKILL.md +217 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/api_reference.md +34 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/examples.md +426 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/functions.md +278 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/getting-started.md +94 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/gpu.md +163 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/images.md +250 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/resources.md +129 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/scaling.md +230 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/scheduled-jobs.md +299 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/secrets.md +193 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/volumes.md +300 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/cloud/modal/references/web-endpoints.md +340 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/code-review/review/SKILL.md +73 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/general/github/SKILL.md +139 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/SKILL.md +178 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/README.md +57 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/agents.md +574 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/cli.md +374 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/codemode.md +251 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/configuration.md +415 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/development.md +300 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/extensions.md +179 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/headless.md +173 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/how-ctx-works.md +179 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/keybindings.md +156 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/mcp.md +319 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/permissions.md +484 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/plugins.md +381 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/providers.md +368 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/quickstart.md +126 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/sdk.md +522 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/sessions.md +508 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/skills.md +179 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/slash-commands.md +185 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/storage-layout.md +157 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/theming.md +188 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs/tools.md +455 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/extensions.md +53 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/plugin-rows.md +232 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/ctx-self-extend/references/skill-authoring.md +68 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/meta/skill-builder/SKILL.md +133 -0
- ctx_agent-0.1.0/src/ctx/code/builtin_skills/setup/init/SKILL.md +74 -0
- ctx_agent-0.1.0/src/ctx/code/cli.py +420 -0
- ctx_agent-0.1.0/src/ctx/code/headless.py +323 -0
- ctx_agent-0.1.0/src/ctx/code/plugin_cmd.py +247 -0
- ctx_agent-0.1.0/src/ctx/code/prompts/__init__.py +65 -0
- ctx_agent-0.1.0/src/ctx/code/prompts/identity.py +137 -0
- ctx_agent-0.1.0/src/ctx/code/prompts/ponytail.py +191 -0
- ctx_agent-0.1.0/src/ctx/code/prompts/todo.py +45 -0
- ctx_agent-0.1.0/src/ctx/code/prompts_extras.py +29 -0
- ctx_agent-0.1.0/src/ctx/code/py.typed +0 -0
- ctx_agent-0.1.0/src/ctx/code/self_update.py +80 -0
- ctx_agent-0.1.0/src/ctx/code/tools/__init__.py +159 -0
- ctx_agent-0.1.0/src/ctx/code/tools/_tool_utils.py +77 -0
- ctx_agent-0.1.0/src/ctx/code/tools/apply_patch.py +472 -0
- ctx_agent-0.1.0/src/ctx/code/tools/ask_user.py +261 -0
- ctx_agent-0.1.0/src/ctx/code/tools/bash.py +517 -0
- ctx_agent-0.1.0/src/ctx/code/tools/codemode.py +683 -0
- ctx_agent-0.1.0/src/ctx/code/tools/find.py +150 -0
- ctx_agent-0.1.0/src/ctx/code/tools/flair.py +347 -0
- ctx_agent-0.1.0/src/ctx/code/tools/grep.py +241 -0
- ctx_agent-0.1.0/src/ctx/code/tools/read.py +305 -0
- ctx_agent-0.1.0/src/ctx/code/tools/skill.py +342 -0
- ctx_agent-0.1.0/src/ctx/code/tools/subagent.py +283 -0
- ctx_agent-0.1.0/src/ctx/code/tools/todo.py +363 -0
- ctx_agent-0.1.0/src/ctx/code/tools/tool_search.py +280 -0
- ctx_agent-0.1.0/src/ctx/code/tools/web.py +226 -0
- ctx_agent-0.1.0/src/ctx/code/update_check.py +49 -0
- ctx_agent-0.1.0/src/ctx/codemode/README.md +210 -0
- ctx_agent-0.1.0/src/ctx/codemode/__init__.py +131 -0
- ctx_agent-0.1.0/src/ctx/codemode/declarations.py +496 -0
- ctx_agent-0.1.0/src/ctx/codemode/errors.py +241 -0
- ctx_agent-0.1.0/src/ctx/codemode/governance.py +210 -0
- ctx_agent-0.1.0/src/ctx/codemode/host.py +1088 -0
- ctx_agent-0.1.0/src/ctx/codemode/integration.py +227 -0
- ctx_agent-0.1.0/src/ctx/codemode/jsonio.py +73 -0
- ctx_agent-0.1.0/src/ctx/codemode/plugin.py +14 -0
- ctx_agent-0.1.0/src/ctx/codemode/sandbox.py +1165 -0
- ctx_agent-0.1.0/src/ctx/codemode/source.py +171 -0
- ctx_agent-0.1.0/src/ctx/codemode/types.py +230 -0
- ctx_agent-0.1.0/src/ctx/mcp/README.md +244 -0
- ctx_agent-0.1.0/src/ctx/mcp/__init__.py +163 -0
- ctx_agent-0.1.0/src/ctx/mcp/auth.py +37 -0
- ctx_agent-0.1.0/src/ctx/mcp/client.py +742 -0
- ctx_agent-0.1.0/src/ctx/mcp/config.py +413 -0
- ctx_agent-0.1.0/src/ctx/mcp/content.py +86 -0
- ctx_agent-0.1.0/src/ctx/mcp/exposure.py +172 -0
- ctx_agent-0.1.0/src/ctx/mcp/jsonrpc.py +131 -0
- ctx_agent-0.1.0/src/ctx/mcp/manager.py +673 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/__init__.py +128 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/callback.py +237 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/discovery.py +296 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/errors.py +71 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/flow.py +539 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/provider.py +341 -0
- ctx_agent-0.1.0/src/ctx/mcp/oauth/types.py +329 -0
- ctx_agent-0.1.0/src/ctx/mcp/plugin.py +22 -0
- ctx_agent-0.1.0/src/ctx/mcp/resources.py +472 -0
- ctx_agent-0.1.0/src/ctx/mcp/tasks.py +56 -0
- ctx_agent-0.1.0/src/ctx/mcp/tool.py +494 -0
- ctx_agent-0.1.0/src/ctx/mcp/transport.py +125 -0
- ctx_agent-0.1.0/src/ctx/mcp/transports/__init__.py +27 -0
- ctx_agent-0.1.0/src/ctx/mcp/transports/in_memory.py +73 -0
- ctx_agent-0.1.0/src/ctx/mcp/transports/stdio.py +343 -0
- ctx_agent-0.1.0/src/ctx/mcp/transports/streamable_http.py +665 -0
- ctx_agent-0.1.0/src/ctx/mcp/types.py +228 -0
- ctx_agent-0.1.0/src/ctx/term/agent_runner.py +734 -0
- ctx_agent-0.1.0/src/ctx/term/agents_panel.py +530 -0
- ctx_agent-0.1.0/src/ctx/term/app.py +1219 -0
- ctx_agent-0.1.0/src/ctx/term/ask_user.py +356 -0
- ctx_agent-0.1.0/src/ctx/term/codemode_block.py +963 -0
- ctx_agent-0.1.0/src/ctx/term/commands/__init__.py +204 -0
- ctx_agent-0.1.0/src/ctx/term/commands/agents.py +161 -0
- ctx_agent-0.1.0/src/ctx/term/commands/auth.py +609 -0
- ctx_agent-0.1.0/src/ctx/term/commands/base.py +147 -0
- ctx_agent-0.1.0/src/ctx/term/commands/catalog.py +101 -0
- ctx_agent-0.1.0/src/ctx/term/commands/mcp.py +215 -0
- ctx_agent-0.1.0/src/ctx/term/commands/models.py +399 -0
- ctx_agent-0.1.0/src/ctx/term/commands/providers.py +71 -0
- ctx_agent-0.1.0/src/ctx/term/commands/reload.py +435 -0
- ctx_agent-0.1.0/src/ctx/term/commands/sessions.py +555 -0
- ctx_agent-0.1.0/src/ctx/term/commands/settings.py +395 -0
- ctx_agent-0.1.0/src/ctx/term/commands/switch.py +20 -0
- ctx_agent-0.1.0/src/ctx/term/commands/update.py +29 -0
- ctx_agent-0.1.0/src/ctx/term/completion_ui.py +363 -0
- ctx_agent-0.1.0/src/ctx/term/export.py +820 -0
- ctx_agent-0.1.0/src/ctx/term/launch.py +123 -0
- ctx_agent-0.1.0/src/ctx/term/plugin_ui.py +124 -0
- ctx_agent-0.1.0/src/ctx/term/queue_ui.py +142 -0
- ctx_agent-0.1.0/src/ctx/term/recap.py +218 -0
- ctx_agent-0.1.0/src/ctx/term/session_ui.py +248 -0
- ctx_agent-0.1.0/src/ctx/term/startup.py +200 -0
- ctx_agent-0.1.0/src/ctx/term/subagents.py +285 -0
- ctx_agent-0.1.0/src/ctx/term/task_ui.py +257 -0
- ctx_agent-0.1.0/src/ctx/term/todo_block.py +189 -0
- ctx_agent-0.1.0/src/ctx/term/todo_panel.py +133 -0
- ctx_agent-0.1.0/src/ctx/term/todo_ui.py +408 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/__init__.py +37 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/ask_user.py +420 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/base.py +39 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/bash.py +32 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/patch.py +149 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/read.py +114 -0
- ctx_agent-0.1.0/src/ctx/term/tool_blocks/subagent.py +279 -0
- ctx_agent-0.1.0/src/ctx/term/tool_output.py +34 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Vendored reference repos
|
|
2
|
+
ref/
|
|
3
|
+
reff/
|
|
4
|
+
|
|
5
|
+
# Python-generated files
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[oc]
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
wheels/
|
|
11
|
+
*.egg-info
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv
|
|
15
|
+
|
|
16
|
+
# macOS
|
|
17
|
+
.DS_Store
|
|
18
|
+
|
|
19
|
+
# Exported ctx sessions
|
|
20
|
+
ctx-session-*
|
|
21
|
+
|
|
22
|
+
# Local editor settings
|
|
23
|
+
.vscode/
|
|
24
|
+
.env
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
.coverage.*
|
|
29
|
+
htmlcov/
|
|
30
|
+
Site/
|
|
31
|
+
# One-off screenshots
|
|
32
|
+
image.png
|
|
33
|
+
model-merge/
|
|
34
|
+
benchmark_results.json
|
|
35
|
+
|
|
36
|
+
# Local configuration files
|
|
37
|
+
.ctx/
|
|
38
|
+
.vortexa/
|
ctx_agent-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ctx-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Coding agent product built on the ctx harness: Textual TUI, headless CLI, session management, and the ctx console script.
|
|
5
|
+
Author: OEvortex
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: cli,coding-agent,llm,tui
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: ctx-sdk>=0.1.0
|
|
10
|
+
Requires-Dist: ctx-term>=0.1.0
|
|
11
|
+
Requires-Dist: textual>=8.0.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# ctx-agent
|
|
15
|
+
|
|
16
|
+
**A coding agent that lives in your terminal.**
|
|
17
|
+
|
|
18
|
+
[](https://pypi.org/project/ctx-agent/)
|
|
19
|
+
[](https://pypi.org/project/ctx-agent/)
|
|
20
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
21
|
+
|
|
22
|
+
`ctx-agent` is the coding agent product built on the [ctx-sdk](https://pypi.org/project/ctx-sdk/) harness. It provides a keyboard-driven TUI, a headless CLI for scripts and CI, built-in tools, and the `ctx` console script.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install ctx-agent
|
|
28
|
+
|
|
29
|
+
ctx # terminal UI
|
|
30
|
+
ctx -p "add tests for ctx.git" # headless, one task, then exit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Python 3.12 or newer. The console script is `ctx`.
|
|
34
|
+
|
|
35
|
+
Connect a model with `--provider` and `--model`, or export a key and start:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
39
|
+
ctx --provider anthropic --model claude-sonnet-4-20250514
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Resume a session with `ctx -c`, or a specific one with `ctx -r <id>`.
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- **Interactive TUI** — keyboard-driven terminal interface with session management
|
|
47
|
+
- **Headless CLI** — run tasks non-interactively for scripts and CI pipelines
|
|
48
|
+
- **Built-in tools** — `read`, `apply_patch`, `bash`, `grep`, `skill`, `todo`, `web`, `ask_user`, `codemode`, `subagent`
|
|
49
|
+
- **65 LLM providers** — supports Anthropic, OpenAI, and 60+ more via provider catalog
|
|
50
|
+
- **Durable sessions** — resume, fork, and revert turns with snapshots
|
|
51
|
+
- **Plugin system** — every subsystem is replaceable via plugin composition
|
|
52
|
+
- **MCP client** — connect to Model Context Protocol servers
|
|
53
|
+
- **Self-extending** — ships a skill that teaches the model how to add new capabilities
|
|
54
|
+
|
|
55
|
+
## CLI commands
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
ctx # interactive TUI
|
|
59
|
+
ctx -p "explain this repo" # one prompt, then exit
|
|
60
|
+
ctx -p - < prompt.md # prompt from stdin
|
|
61
|
+
ctx --continue # resume the most recent session
|
|
62
|
+
ctx --resume 4f2a # resume a specific session
|
|
63
|
+
ctx acp # Agent Client Protocol server
|
|
64
|
+
ctx update # self-update to latest PyPI release
|
|
65
|
+
ctx auth status # check authentication status
|
|
66
|
+
ctx models list # list available models
|
|
67
|
+
ctx config list|get|set # manage configuration
|
|
68
|
+
ctx plugin ... # manage plugins
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
Full reference at [github.com/OEvortex/ctx-coding-agent](https://github.com/OEvortex/ctx-coding-agent).
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
[Apache License 2.0](LICENSE)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# ctx-agent
|
|
2
|
+
|
|
3
|
+
**A coding agent that lives in your terminal.**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/ctx-agent/)
|
|
6
|
+
[](https://pypi.org/project/ctx-agent/)
|
|
7
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
|
+
|
|
9
|
+
`ctx-agent` is the coding agent product built on the [ctx-sdk](https://pypi.org/project/ctx-sdk/) harness. It provides a keyboard-driven TUI, a headless CLI for scripts and CI, built-in tools, and the `ctx` console script.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install ctx-agent
|
|
15
|
+
|
|
16
|
+
ctx # terminal UI
|
|
17
|
+
ctx -p "add tests for ctx.git" # headless, one task, then exit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Python 3.12 or newer. The console script is `ctx`.
|
|
21
|
+
|
|
22
|
+
Connect a model with `--provider` and `--model`, or export a key and start:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
26
|
+
ctx --provider anthropic --model claude-sonnet-4-20250514
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Resume a session with `ctx -c`, or a specific one with `ctx -r <id>`.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Interactive TUI** — keyboard-driven terminal interface with session management
|
|
34
|
+
- **Headless CLI** — run tasks non-interactively for scripts and CI pipelines
|
|
35
|
+
- **Built-in tools** — `read`, `apply_patch`, `bash`, `grep`, `skill`, `todo`, `web`, `ask_user`, `codemode`, `subagent`
|
|
36
|
+
- **65 LLM providers** — supports Anthropic, OpenAI, and 60+ more via provider catalog
|
|
37
|
+
- **Durable sessions** — resume, fork, and revert turns with snapshots
|
|
38
|
+
- **Plugin system** — every subsystem is replaceable via plugin composition
|
|
39
|
+
- **MCP client** — connect to Model Context Protocol servers
|
|
40
|
+
- **Self-extending** — ships a skill that teaches the model how to add new capabilities
|
|
41
|
+
|
|
42
|
+
## CLI commands
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ctx # interactive TUI
|
|
46
|
+
ctx -p "explain this repo" # one prompt, then exit
|
|
47
|
+
ctx -p - < prompt.md # prompt from stdin
|
|
48
|
+
ctx --continue # resume the most recent session
|
|
49
|
+
ctx --resume 4f2a # resume a specific session
|
|
50
|
+
ctx acp # Agent Client Protocol server
|
|
51
|
+
ctx update # self-update to latest PyPI release
|
|
52
|
+
ctx auth status # check authentication status
|
|
53
|
+
ctx models list # list available models
|
|
54
|
+
ctx config list|get|set # manage configuration
|
|
55
|
+
ctx plugin ... # manage plugins
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
Full reference at [github.com/OEvortex/ctx-coding-agent](https://github.com/OEvortex/ctx-coding-agent).
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
[Apache License 2.0](LICENSE)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[tool.hatch.build.targets.wheel]
|
|
6
|
+
only-include = ["src/ctx"]
|
|
7
|
+
sources = ["src"]
|
|
8
|
+
exclude = [
|
|
9
|
+
"src/ctx/code/builtin_skills/meta/ctx-self-extend/references/docs",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[tool.hatch.build]
|
|
13
|
+
artifacts = []
|
|
14
|
+
|
|
15
|
+
[project]
|
|
16
|
+
name = "ctx-agent"
|
|
17
|
+
version = "0.1.0"
|
|
18
|
+
description = "Coding agent product built on the ctx harness: Textual TUI, headless CLI, session management, and the ctx console script."
|
|
19
|
+
requires-python = ">=3.12"
|
|
20
|
+
keywords = ["coding-agent", "tui", "cli", "llm"]
|
|
21
|
+
license = "Apache-2.0"
|
|
22
|
+
authors = [
|
|
23
|
+
{ name = "OEvortex" },
|
|
24
|
+
]
|
|
25
|
+
readme = "README.md"
|
|
26
|
+
homepage = "https://github.com/OEvortex/ctx-coding-agent"
|
|
27
|
+
repository = "https://github.com/OEvortex/ctx-coding-agent"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"ctx-sdk>=0.1.0",
|
|
30
|
+
"ctx-term>=0.1.0",
|
|
31
|
+
"textual>=8.0.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
ctx = "ctx.code.cli:main"
|
|
36
|
+
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# ctx.code
|
|
2
|
+
|
|
3
|
+
The product layer: the `ctx` console script, the headless runner, the concrete built-in tools and their default registry, the built-in skills package, and the handoff-agent loader. Use it to run the agent, or to embed its tools in something else. The Textual interface is `ctx.term`.
|
|
4
|
+
|
|
5
|
+
Everything here is wiring and choice. The engine it drives - the loop, the session store, the provider adapters - is `ctx.agent` and `ctx.ai`. Importing `ctx.code.tools` registers nothing by itself; each tool module exports a `PLUGIN` row that the plugin composition mounts.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
ctx.code CLI, headless runner, built-in tools, skills
|
|
9
|
+
|- ctx.term the Textual interface (app shell + primitives)
|
|
10
|
+
|- ctx.agent harness (loop, sessions, tools, hooks)
|
|
11
|
+
|- ctx.plugins plugin kernel; extensions are rows in it
|
|
12
|
+
|- ctx.ai providers and the model catalog
|
|
13
|
+
|- ctx.core config, permissions, events
|
|
14
|
+
|- ctx.git branch metadata
|
|
15
|
+
|- ctx.mcp MCP client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This package holds the wiring and the choices; the UI is `ctx.term`, documented in its own README. `cli.py:run_tui_command` is the only thing here that reaches for it.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
The tools are ordinary `BaseTool` instances, so anything that can drive a tool can drive these. Reach them through the registry:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import asyncio
|
|
26
|
+
|
|
27
|
+
from ctx.code.tools import get_tool
|
|
28
|
+
|
|
29
|
+
bash = get_tool("bash")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async def main() -> None:
|
|
33
|
+
result = await bash.execute(params=bash.params(command="echo hello", timeout=10))
|
|
34
|
+
print(result.success, result.result) # True hello
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
asyncio.run(main())
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`get_tool(name)` is the registry's default lookup and returns `None` for an unknown name. `tool.params` is the pydantic input model; `execute()` returns a `ToolResult` with `success`, `result`, `ui_summary`, and optional `images`, `file_changes`, and `structured` fields. Each tool also carries `description`, `needs_approval`, `mutating`, and the presentation hooks `format_call`, `format_preview`, and `ui_block`.
|
|
41
|
+
|
|
42
|
+
The same registry feeds the agent loop, so a tool added here is immediately available to the model.
|
|
43
|
+
|
|
44
|
+
## The console script
|
|
45
|
+
|
|
46
|
+
`pyproject.toml` declares `ctx = "ctx.code.cli:main"`, so `cli:main` is the entry point for both run surfaces:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ctx # interactive
|
|
50
|
+
ctx -p "explain this repo" # one prompt, then exit
|
|
51
|
+
ctx -p - < prompt.md # prompt from stdin
|
|
52
|
+
ctx --continue # resume the most recent session
|
|
53
|
+
ctx --resume 4f2a -m anthropic/claude-opus-5
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Subcommands are `ctx acp` (Agent Client Protocol server over stdio), `ctx update` (self-update to the latest stable PyPI release and exit), `ctx auth status`, `ctx models list`, `ctx config list|get|set`, and `ctx plugin ...` — `profiles`, `init NAME`, `path NAME`, `enable ROW`, `disable ROW`, `install SPEC`, `allow-version`, `revoke-version`, `version-exemptions` (see `plugin_cmd.py` and [docs/plugins.md](../../docs/plugins.md)).
|
|
57
|
+
|
|
58
|
+
Flags are `--model/-m`, `--provider`, `--api-key/-k`, `--base-url/-u`, `--prompt/-p`, `--openai-compat-auth` and `--anthropic-compat-auth` (`auto`/`required`/`none`), `--insecure-skip-verify`, `--continue/-c`, `--resume/-r`, `--extension/-e` (repeatable), `--no-extensions`, `--agent/-a`, `--agent-file` (repeatable), `--no-agents`, `--list-agents`, `--list-extensions`, `--profile`, `--patch`, `--dump-config`, and `--version`.
|
|
59
|
+
|
|
60
|
+
The CLI's first job is composition: it resolves `--profile` and `--patch`, calls `ctx.plugins.boot`, and only then builds a runtime. Extension files are discovered inside that boot and mounted as rows; `--list-extensions` prints the ones that mounted, with their tools, commands and handlers. See [docs/extensions.md](../../docs/extensions.md).
|
|
61
|
+
|
|
62
|
+
With `-p` the run goes to `headless.run_headless`; otherwise to `tui.launch.run_tui`. `--continue` and `--resume` are rejected together with `-p`.
|
|
63
|
+
|
|
64
|
+
## Headless
|
|
65
|
+
|
|
66
|
+
`headless.py` exports `resolve_prompt(prompt_arg, *, stdin)`, `render_run(events, *, out, err)`, and `run_headless(...)`. `run_headless` returns an exit code derived from the `StopReason`: `0` for a normal stop, `1` for an error or an unmapped reason, `3` for a length stop, and `2` for an empty prompt or a provider/agent-init failure. `render_run` is the piece to reuse if you want the event stream without the CLI.
|
|
67
|
+
|
|
68
|
+
Headless cannot show approval prompts, so it forces auto-approval for the run by writing the config file, running, and restoring it; the saved config is not mutated. A project's `.ctx/mcp.json` is read like any other, so its servers start with the run.
|
|
69
|
+
|
|
70
|
+
## Built-in tools
|
|
71
|
+
|
|
72
|
+
Registration goes through the plugin rows in `src/ctx/plugins/builtins/__init__.py`, not through this package's `__init__`: importing it builds nothing. `all_tools` (built lazily on first access) holds `ReadTool`, `ApplyPatchTool`, `BashTool`, `GrepTool`, `SkillTool`, `TodoTool`, plus `WebTool`, `WebSearchTool`, `AskUserTool`, `TaskTool`, `CodemodeTool`, and `ToolSearchTool` from `ctx.agent.tools` and the local `codemode`/`tool_search` modules. `DEFAULT_TOOLS` is `["read", "apply_patch", "bash", "skill", "todo", "web", "ask_user", "delegate_subagent"]`; `grep`, `web_search`, and `tool_search` are registered but not default-on, and `find` (`FindTool` in `tools/find.py`) ships a `PLUGIN` row that no shipped bundle mounts. `PARENT_ONLY_TOOLS` is `frozenset({"delegate_subagent"})` - not offered to a sub-agent.
|
|
73
|
+
|
|
74
|
+
Every mounted tool row calls `mount_tool(ctx, ..., is_default=..., parent_only=...)` from `ctx.plugins.builtins.tools._register`.
|
|
75
|
+
|
|
76
|
+
The filesystem tools are local to this package: `ReadTool`, `ApplyPatchTool`, `BashTool`, `GrepTool`, `SkillTool`, `TodoTool`, `FindTool`, `CodemodeTool`, `ToolSearchTool`. `WebTool`, `WebSearchTool`, `AskUserTool`, and `TaskTool` come from `ctx.agent.tools`.
|
|
77
|
+
|
|
78
|
+
Every tool points its `ui_block` at a Textual block in `ctx.term.tool_blocks`
|
|
79
|
+
(a sibling package under `ctx/term/`, alongside `todo_block.py` and
|
|
80
|
+
`codemode_block.py`). Those blocks own all tool-specific rendering: diff
|
|
81
|
+
previews, numbered reads, the questionnaire, sub-agent receipts, and shell
|
|
82
|
+
headers. The generic `ToolBlock` and the rest of the TUI framework live in
|
|
83
|
+
`term`; `ctx-code` only adds product behaviour on top.
|
|
84
|
+
|
|
85
|
+
The registry API is `get_tools(default_names)`, `get_tool(name)`, `get_tools_with_extensions(default_names, extension_tools=None)`, `tools_by_name`, and `get_tool_definitions`. `get_tools_with_extensions` replaces by name match, so an extension can override a built-in. The background-task re-exports (`BackgroundTaskManager`, `BackgroundTaskRecord`, `get_manager`, `set_manager`) are here too.
|
|
86
|
+
|
|
87
|
+
## Handoff agents and skills
|
|
88
|
+
|
|
89
|
+
`agents/` loads switchable agents from `.ctx/agent/<name>.py`: a bundle of system-prompt instructions, model/provider/thinking/max-turns overrides, a tool allow/deny list, agent-scoped tools and slash commands, and agent-scoped extensions. There are no built-in profiles. `load_all_agents(cwd=..., configured=...)` returns `(loaded, errors)` and collects errors rather than raising, so one bad agent file does not block the rest; `ctx --list-agents` prints that pair. An agent's `extensions` are mounted as rows of the running composition, scoped to that agent.
|
|
90
|
+
|
|
91
|
+
`builtin_skills/` is registered into the harness by `register_skills_package("ctx.code")` at package import. It ships `cloud/google-colab`, `cloud/modal`, `code-review/review`, `general/github`, `meta/skill-builder`, `meta/ctx-self-extend`, and `setup/init`.
|
|
92
|
+
|
|
93
|
+
`meta/ctx-self-extend` is the harness's own self-extension skill: it tells the model which surface to reach for when it needs a capability it does not have (a skill, a plugin row, or an extension), how a registered tool actually reaches the provider, and which paths are forbidden. It is bundled so that any agent composed on the ctx harness - the coding agent, the SDK runner, a sub-agent - inherits it without the project having to ship a copy.
|
|
94
|
+
|
|
95
|
+
## The interface: `ctx.term`
|
|
96
|
+
|
|
97
|
+
See `ctx/term/README.md`. `ctx.term.__all__` exports `Ctx`, `run_tui`, `ChatLog`, `InfoBar`, `StatusLine`, `QueueDisplay`, `format_path`, `TreeSelector`, `CommandsMixin`, and `export_session_html`, all lazily.
|
|
98
|
+
|
|
99
|
+
<details><summary>Module map</summary>
|
|
100
|
+
|
|
101
|
+
- `app.py` holds `Ctx`, the `App` subclass that composes the widget tree, wires the runtime, and routes input. It is also where `BINDINGS` lives.
|
|
102
|
+
- `launch.py` has `run_tui(args)` and the exit summary printed after the app closes; `startup.py` has the background chores - binary download, update check, file-path scan, git-branch refresh, launch warnings.
|
|
103
|
+
- `chat.py` is `ChatLog`, the scrollback that mounts the `ctx.term.blocks` widgets; `session_ui.py` renders persisted sessions into it.
|
|
104
|
+
- `widgets.py` has `InfoBar`, `StatusLine`, `QueueDisplay`, `FileChangesModal`, `format_path`, and `get_git_branch`; `status_lines.py` has the context-aware status-line text for model and agent lifecycle states, per-tool activity, and per-tool error lines.
|
|
105
|
+
- `tree.py` is `TreeSelector`, the session-tree navigator. `queue_ui.py` holds the pending and steer message queue state and its rendering. `agent_runner.py` drives agent runs, forwards agent events to the chat UI, and handles the `!` / `!!` shell commands.
|
|
106
|
+
- `completion_ui.py` handles the completion-list and selection-mode picker messages. Its `@on` handlers are re-bound in the `Ctx` class body, because Textual's metaclass only scans the namespace of classes it creates.
|
|
107
|
+
- `extension_ui.py` is `TextualExtensionUI`, implementing `ExtensionUIContext` over the app: confirm / select / input dialogs, chat notifications, and a persistent status/widget footer bar.
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
- `export.py` is `export_session_html`, a standalone exporter that parses session JSONL directly and takes the tool registry as its only ctx dependency. `recap.py` arms a 30s idle timer after a run and drafts a "where you left off" summary with a cheap one-off model call.
|
|
111
|
+
|
|
112
|
+
### Key bindings
|
|
113
|
+
|
|
114
|
+
From the `BINDINGS` table on `Ctx`:
|
|
115
|
+
|
|
116
|
+
- `ctrl+c` clear, `ctrl+d` delete session, `escape` interrupt the running agent
|
|
117
|
+
- `left` / `right` tree page up / down
|
|
118
|
+
- `ctrl+t` cycle thinking level, `ctrl+shift+t` toggle thinking
|
|
119
|
+
- `ctrl+o` toggle tool output
|
|
120
|
+
- `shift+tab` cycle handoff agent
|
|
121
|
+
- `alt+ctrl+p` cycle permission mode, `alt+ctrl+g` cycle tool group
|
|
122
|
+
|
|
123
|
+
The editor's own bindings live on `InputBox` in `ctx.term.input`.
|
|
124
|
+
|
|
125
|
+
### Slash commands
|
|
126
|
+
|
|
127
|
+
`commands/` splits handling by domain into `CommandsMixin`: `settings.py`, `models.py`, `sessions.py`, `auth.py`, `providers.py`, `agents.py`, `switch.py`, `update.py`, `reload.py`, and `mcp.py`.
|
|
128
|
+
|
|
129
|
+
Routing is two-stage. `Ctx` first tries `CommandsMixin._handle_command`, so a built-in always wins a name collision with a skill; anything the router does not know falls through to the skill system, Extension commands — whatever registered on `ctx.commands` — get the last swing, so an extension can shadow a built-in - and a handler that raises is reported in the chat log rather than crashing the app.
|
|
130
|
+
|
|
131
|
+
Routable commands are `help`, `quit`/`exit`/`q`, `clear`, `model`, `provider`, `new`, `settings`, `themes`, `permissions`, `thinking`, `effort`, `notifications`, `ponytail`, `handoff`, `resume`, `tree`, `undo`, `redo`, `session`, `login`, `logout`, `export`, `copy`, `compact`, `recap`, `agent`, `switch`, `update`, `reload`, and `mcp`.
|
|
132
|
+
|
|
133
|
+
`DEFAULT_COMMANDS` in `ctx.term.autocomplete` is the autocomplete list, and it is deliberately **not** the same set. `/effort` is a routable alias of `/thinking` - "effort" is what the wire calls it - and it is not advertised in autocomplete, because `/settings` is the discoverable entry point for the thinking and permissions sub-commands. `/switch` is handled but likewise not advertised.
|
|
134
|
+
|
|
135
|
+
### Thinking levels
|
|
136
|
+
|
|
137
|
+
`/thinking` and `ctrl+t` operate on `resolve_thinking_levels` in `ctx.ai.thinking`, the single source of truth also used by session restore and model switching. The offered set is what the models.dev catalog advertises for the model, intersected with what the transport's effort enum can send and what the API style has a wire spelling for.
|
|
138
|
+
|
|
139
|
+
One rough edge is worth stating plainly. `get_model` matches model ids exactly, so `space-bunny-alpha` misses the catalog entry `stealth/space-bunny-alpha` and the picker falls back to the provider's raw enum, which offers levels the model marks unsupported. `SettingsCommands._thinking_availability` reports this rather than hiding it, with `catalog entry not found, check the exact model id`. The model id format is not flexible; there is no prefix matching to rescue a near-miss.
|
|
140
|
+
|
|
141
|
+
## Tests
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uv run --no-sync python -m pytest -p no:cacheprovider tests/ui -q
|
|
145
|
+
uv run --no-sync python -m pytest -p no:cacheprovider tests/test_cli.py tests/test_headless.py tests/test_agent_profiles.py -q
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`tests/ui` holds the app, panel, picker, and widget tests; the CLI, headless runner, and agent loader are tested from `tests/` at the top level.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Coding-agent package surface.
|
|
2
|
+
|
|
3
|
+
Re-exports resolve lazily through :func:`__getattr__` so ``import
|
|
4
|
+
ctx.code.cli`` does not pay for ``headless``/provider graphs it may
|
|
5
|
+
never touch. ``register_skills_package`` stays eager — it is a side effect
|
|
6
|
+
other modules rely on at import time.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from ctx.agent.context.skills import register_skills_package
|
|
14
|
+
from ctx.code import prompts as _prompts # noqa: F401
|
|
15
|
+
from ctx.code.builtin_rows import register_builtin_tool_rows
|
|
16
|
+
|
|
17
|
+
# name -> owning module; the attribute name equals the export name.
|
|
18
|
+
_CONFIG_EXPORTS = {
|
|
19
|
+
"AVAILABLE_BINARIES",
|
|
20
|
+
"CONFIG_DIR_NAME",
|
|
21
|
+
"CURRENT_CONFIG_VERSION",
|
|
22
|
+
"Config",
|
|
23
|
+
"PermissionMode",
|
|
24
|
+
"add_recent_model",
|
|
25
|
+
"config",
|
|
26
|
+
"consume_config_warnings",
|
|
27
|
+
"get_agents_dir",
|
|
28
|
+
"get_config",
|
|
29
|
+
"get_config_dir",
|
|
30
|
+
"get_last_selected",
|
|
31
|
+
"get_recent_models",
|
|
32
|
+
"reload_config",
|
|
33
|
+
"reset_config",
|
|
34
|
+
"set_colored_tool_badge",
|
|
35
|
+
"set_config",
|
|
36
|
+
"set_git_context",
|
|
37
|
+
"set_last_selected",
|
|
38
|
+
"set_model_provider_filter",
|
|
39
|
+
"set_notifications_enabled",
|
|
40
|
+
"set_permissions_mode",
|
|
41
|
+
"set_show_welcome_shortcuts",
|
|
42
|
+
"set_theme",
|
|
43
|
+
"set_thinking_lines",
|
|
44
|
+
"update_available_binaries",
|
|
45
|
+
}
|
|
46
|
+
_VERSION_EXPORTS = {"PACKAGE_NAME", "VERSION", "format_version"}
|
|
47
|
+
_HEADLESS_EXPORTS = {"_exit_code", "render_run", "resolve_prompt", "run_headless"}
|
|
48
|
+
|
|
49
|
+
# Register coding agent skills package into harness, and contribute the
|
|
50
|
+
# coding toolset rows to the harness's BASE/MINIMAL bundles.
|
|
51
|
+
register_skills_package("ctx.code")
|
|
52
|
+
register_builtin_tool_rows()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def __getattr__(name: str) -> Any:
|
|
56
|
+
if name in _CONFIG_EXPORTS:
|
|
57
|
+
from ctx.core import config as module
|
|
58
|
+
|
|
59
|
+
return getattr(module, name)
|
|
60
|
+
if name in _VERSION_EXPORTS:
|
|
61
|
+
from ctx.core import version as module
|
|
62
|
+
|
|
63
|
+
return getattr(module, name)
|
|
64
|
+
if name in _HEADLESS_EXPORTS:
|
|
65
|
+
from ctx.code import headless as module
|
|
66
|
+
|
|
67
|
+
return getattr(module, name)
|
|
68
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
__all__ = [
|
|
72
|
+
"AVAILABLE_BINARIES",
|
|
73
|
+
"CONFIG_DIR_NAME",
|
|
74
|
+
"CURRENT_CONFIG_VERSION",
|
|
75
|
+
"PACKAGE_NAME",
|
|
76
|
+
"VERSION",
|
|
77
|
+
"Config",
|
|
78
|
+
"PermissionMode",
|
|
79
|
+
"_exit_code",
|
|
80
|
+
"add_recent_model",
|
|
81
|
+
"config",
|
|
82
|
+
"consume_config_warnings",
|
|
83
|
+
"format_version",
|
|
84
|
+
"get_agents_dir",
|
|
85
|
+
"get_config",
|
|
86
|
+
"get_config_dir",
|
|
87
|
+
"get_last_selected",
|
|
88
|
+
"get_recent_models",
|
|
89
|
+
"reload_config",
|
|
90
|
+
"render_run",
|
|
91
|
+
"reset_config",
|
|
92
|
+
"resolve_prompt",
|
|
93
|
+
"run_headless",
|
|
94
|
+
"set_colored_tool_badge",
|
|
95
|
+
"set_config",
|
|
96
|
+
"set_git_context",
|
|
97
|
+
"set_last_selected",
|
|
98
|
+
"set_model_provider_filter",
|
|
99
|
+
"set_notifications_enabled",
|
|
100
|
+
"set_permissions_mode",
|
|
101
|
+
"set_show_welcome_shortcuts",
|
|
102
|
+
"set_theme",
|
|
103
|
+
"set_thinking_lines",
|
|
104
|
+
"update_available_binaries",
|
|
105
|
+
]
|