ctx-agent 2.0.0__tar.gz → 2.0.2__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-2.0.0 → ctx_agent-2.0.2}/PKG-INFO +11 -14
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/README.md +10 -13
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/pyproject.toml +1 -1
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/brand.py +1 -1
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/headless.py +2 -1
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/update.py +10 -10
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_misc.py +1 -1
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_update.py +12 -5
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/.gitignore +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/CHANGELOG.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/commands.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/keybindings.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/permissions.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/skills.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/swarm.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/docs/tools.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/pet_demo.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/app.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/atpath.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/attachments.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/builtin_skills/meta/swarm/SKILL.md +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/cli.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/agents.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/auth.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/base.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/models.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/sessions.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/settings.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/commands/system.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/export.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/history.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/hook.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/jobs.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/notifications.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/permissions.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/pet.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/prefs.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/prompts.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/swarm/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/swarm/board.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/swarm/engine.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/swarm/mentions.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/titles.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/_tool_utils.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/apply_patch.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/ask_user.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/bash.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/read.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/search.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/skill.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/swarm.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/todo.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tools/web.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/base.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/diff.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/recap.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/tools.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/blocks/usage.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/footer.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/panels.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/sidebar.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/splash.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/styles.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/swarm.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/usage_stats.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/viewport.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/src/ctx/code/tui/width_policy.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/__init__.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_agent_inbox.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_agent_instances.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_agent_instances_factory.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_agent_pre_step.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_apply_patch.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_ask_user.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_atpath.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_attachments.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_bash.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_bash_actions.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_blocks.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_builtin_skills.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_compaction.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_context_length.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_finalize_compact.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_footer.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_headless.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_history.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_jobs.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_model_picker.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_panel.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_permission_guards.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_permissions.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_pet.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_prefs.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_prompts.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_provider_hooks.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_read.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_recap_digest.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_render_compat.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_sdk_transports.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_search_block.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_search_tool.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_search_ui.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_settings.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_sidebar.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_skill.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_sse_stream.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_step_compact_events.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_stream_patch.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_stream_recovery.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_swarm.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_swarm_board.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_titles.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_todo_tool.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_tool_pipeline_events.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_tool_utils.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_viewport.py +0 -0
- {ctx_agent-2.0.0 → ctx_agent-2.0.2}/tests/test_web.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: ctx-agent
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Minimal coding agent built on the ctx harness with its own terminal UI.
|
|
5
5
|
Author: OEvortex
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -11,26 +11,26 @@ Requires-Dist: ctx-sdk>=2.0.0
|
|
|
11
11
|
Requires-Dist: ctx-term>=2.0.0
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
|
|
14
|
-
#
|
|
14
|
+
# ctx-agent
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
The coding agent built on the [ctx](https://github.com/OEvortex/ctx-coding-agent) harness (`ctx-sdk`) and the `ctx-term` toolkit: keyboard-driven TUI, headless CLI, sessions, providers, tools, and permissions.
|
|
17
17
|
|
|
18
18
|
Requires Python 3.12+.
|
|
19
19
|
|
|
20
20
|
## Install and run
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
uv tool install
|
|
23
|
+
uv tool install ctx-agent # or: pipx install ctx-agent / pip install ctx-agent
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
ctx # terminal UI
|
|
26
|
+
ctx -p "fix the failing test" # headless: one prompt, one answer, exit
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Connect a model with `--provider`/`--model`, or export a provider key (`ANTHROPIC_API_KEY`, etc.) and start. Resume work with
|
|
29
|
+
Connect a model with `--provider`/`--model`, or export a provider key (`ANTHROPIC_API_KEY`, etc.) and start. Resume work with the session commands inside the TUI (`/session`, `/tree`, `/handoff`).
|
|
30
30
|
|
|
31
31
|
## Headless mode
|
|
32
32
|
|
|
33
|
-
`
|
|
33
|
+
`ctx -p <prompt>` (or `ctx -p` / `ctx -p -` to read the prompt from stdin) runs one turn without the alternate screen: the answer goes to stdout, diagnostics to stderr, so it pipes cleanly. `--verbose` prints each tool call to stderr.
|
|
34
34
|
|
|
35
35
|
Approvals cannot be answered headlessly — every tool approval is denied and agent questions get an empty response — so run with the permission mode you intend.
|
|
36
36
|
|
|
@@ -51,20 +51,17 @@ Exit codes:
|
|
|
51
51
|
| `VX_THEME` | Pin the TUI palette by name at startup |
|
|
52
52
|
| `VX_BOOT_TRACE` | Path to a file; each boot phase appends a timestamp for startup-latency measurement |
|
|
53
53
|
| `VX_DEBUG_FRAME` | Path to a file; every rendered frame is appended as JSON for debugging the TUI |
|
|
54
|
-
| `VX_AMBIGUOUS_WIDTH` | `wide`/`narrow`: how the terminal draws East-Asian-Ambiguous glyphs (`·`, `─`, `│`, `→`, `●`), which every rule and border
|
|
55
|
-
| `VX_UPDATE_USE_PIP` | Set to force `/update` down the `pip install --upgrade
|
|
54
|
+
| `VX_AMBIGUOUS_WIDTH` | `wide`/`narrow`: how the terminal draws East-Asian-Ambiguous glyphs (`·`, `─`, `│`, `→`, `●`), which every rule and border ctx prints is made of. Normally measured at startup by asking the terminal for its cursor position around one glyph, then remembered per terminal in `vx-prefs.json` (refreshed monthly), falling back to a CJK `LC_ALL`/`LC_CTYPE`/`LANG` signal. Set it to skip all of that |
|
|
55
|
+
| `VX_UPDATE_USE_PIP` | Set to force `/update` down the `pip install --upgrade ctx-agent` path |
|
|
56
56
|
|
|
57
57
|
`VTX_PET_SHEET` / `VTX_PETS_DIR` configure the animated-pet graphics prototype (`pet.py`, `pet_demo.py`); they are a development demo, not shipped UI surface.
|
|
58
58
|
|
|
59
59
|
## Demos
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
`pet_demo.py` is a standalone program that drives the graphics backends against a real terminal:
|
|
62
62
|
|
|
63
63
|
| Command | What it shows |
|
|
64
64
|
|---|---|
|
|
65
|
-
| `uv run python demo.py` | the swarm board (`ctx.code.tui.swarm`) with a simulated room: live tool calls, durations, a `needs you` approval |
|
|
66
|
-
| `uv run python html_demo.py` | the HTML/CSS renderer, page by page |
|
|
67
|
-
| `uv run python markdown_demo.py` | the markdown renderer over a long document |
|
|
68
65
|
| `uv run python pet_demo.py` | sprite-sheet animation across the cell and pixel graphics backends |
|
|
69
66
|
|
|
70
67
|
## Documentation
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ctx-agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The coding agent built on the [ctx](https://github.com/OEvortex/ctx-coding-agent) harness (`ctx-sdk`) and the `ctx-term` toolkit: keyboard-driven TUI, headless CLI, sessions, providers, tools, and permissions.
|
|
4
4
|
|
|
5
5
|
Requires Python 3.12+.
|
|
6
6
|
|
|
7
7
|
## Install and run
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
uv tool install
|
|
10
|
+
uv tool install ctx-agent # or: pipx install ctx-agent / pip install ctx-agent
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
ctx # terminal UI
|
|
13
|
+
ctx -p "fix the failing test" # headless: one prompt, one answer, exit
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Connect a model with `--provider`/`--model`, or export a provider key (`ANTHROPIC_API_KEY`, etc.) and start. Resume work with
|
|
16
|
+
Connect a model with `--provider`/`--model`, or export a provider key (`ANTHROPIC_API_KEY`, etc.) and start. Resume work with the session commands inside the TUI (`/session`, `/tree`, `/handoff`).
|
|
17
17
|
|
|
18
18
|
## Headless mode
|
|
19
19
|
|
|
20
|
-
`
|
|
20
|
+
`ctx -p <prompt>` (or `ctx -p` / `ctx -p -` to read the prompt from stdin) runs one turn without the alternate screen: the answer goes to stdout, diagnostics to stderr, so it pipes cleanly. `--verbose` prints each tool call to stderr.
|
|
21
21
|
|
|
22
22
|
Approvals cannot be answered headlessly — every tool approval is denied and agent questions get an empty response — so run with the permission mode you intend.
|
|
23
23
|
|
|
@@ -38,20 +38,17 @@ Exit codes:
|
|
|
38
38
|
| `VX_THEME` | Pin the TUI palette by name at startup |
|
|
39
39
|
| `VX_BOOT_TRACE` | Path to a file; each boot phase appends a timestamp for startup-latency measurement |
|
|
40
40
|
| `VX_DEBUG_FRAME` | Path to a file; every rendered frame is appended as JSON for debugging the TUI |
|
|
41
|
-
| `VX_AMBIGUOUS_WIDTH` | `wide`/`narrow`: how the terminal draws East-Asian-Ambiguous glyphs (`·`, `─`, `│`, `→`, `●`), which every rule and border
|
|
42
|
-
| `VX_UPDATE_USE_PIP` | Set to force `/update` down the `pip install --upgrade
|
|
41
|
+
| `VX_AMBIGUOUS_WIDTH` | `wide`/`narrow`: how the terminal draws East-Asian-Ambiguous glyphs (`·`, `─`, `│`, `→`, `●`), which every rule and border ctx prints is made of. Normally measured at startup by asking the terminal for its cursor position around one glyph, then remembered per terminal in `vx-prefs.json` (refreshed monthly), falling back to a CJK `LC_ALL`/`LC_CTYPE`/`LANG` signal. Set it to skip all of that |
|
|
42
|
+
| `VX_UPDATE_USE_PIP` | Set to force `/update` down the `pip install --upgrade ctx-agent` path |
|
|
43
43
|
|
|
44
44
|
`VTX_PET_SHEET` / `VTX_PETS_DIR` configure the animated-pet graphics prototype (`pet.py`, `pet_demo.py`); they are a development demo, not shipped UI surface.
|
|
45
45
|
|
|
46
46
|
## Demos
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
`pet_demo.py` is a standalone program that drives the graphics backends against a real terminal:
|
|
49
49
|
|
|
50
50
|
| Command | What it shows |
|
|
51
51
|
|---|---|
|
|
52
|
-
| `uv run python demo.py` | the swarm board (`ctx.code.tui.swarm`) with a simulated room: live tool calls, durations, a `needs you` approval |
|
|
53
|
-
| `uv run python html_demo.py` | the HTML/CSS renderer, page by page |
|
|
54
|
-
| `uv run python markdown_demo.py` | the markdown renderer over a long document |
|
|
55
52
|
| `uv run python pet_demo.py` | sprite-sheet animation across the cell and pixel graphics backends |
|
|
56
53
|
|
|
57
54
|
## Documentation
|
|
@@ -18,6 +18,7 @@ from typing import TYPE_CHECKING, TextIO
|
|
|
18
18
|
import ctx.code.tools
|
|
19
19
|
from ctx.code import prompts as vx_prompts
|
|
20
20
|
from ctx.core.config import config, get_config, get_last_selected
|
|
21
|
+
from ctx.core.paths import get_config_dir
|
|
21
22
|
from ctx.protocol.types import StopReason
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -191,7 +192,7 @@ async def run_headless(
|
|
|
191
192
|
hook_bridge = HookBridge(
|
|
192
193
|
bus=bus,
|
|
193
194
|
project_path=Path.cwd() / ".ctx" / "hooks.yml",
|
|
194
|
-
global_path=
|
|
195
|
+
global_path=get_config_dir() / "hooks.yml",
|
|
195
196
|
)
|
|
196
197
|
await hook_bridge.load()
|
|
197
198
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"""``/update`` for
|
|
1
|
+
"""``/update`` for ctx-agent itself.
|
|
2
2
|
|
|
3
|
-
Detects how this copy
|
|
3
|
+
Detects how this copy was installed and upgrades that one -- a source
|
|
4
4
|
checkout is fast-forwarded with git, a tool install goes through ``uv tool`` or
|
|
5
|
-
``pipx``, and anything else falls back to ``pip install --upgrade
|
|
6
|
-
package name
|
|
7
|
-
|
|
5
|
+
``pipx``, and anything else falls back to ``pip install --upgrade ctx-agent``.
|
|
6
|
+
The package name is pinned here so the command never upgrades another
|
|
7
|
+
product by accident.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
@@ -15,7 +15,7 @@ import sys
|
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
from typing import Literal
|
|
17
17
|
|
|
18
|
-
PACKAGE = "
|
|
18
|
+
PACKAGE = "ctx-agent"
|
|
19
19
|
|
|
20
20
|
#: Set to 1 to force the pip path (mirrors the ctx/ctx-code convention).
|
|
21
21
|
FORCE_PIP_ENV = "VX_UPDATE_USE_PIP"
|
|
@@ -62,10 +62,10 @@ def _is_pipx_tool(package: str) -> bool:
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
def _source_checkout() -> Path | None:
|
|
65
|
-
"""The git root of a
|
|
65
|
+
"""The git root of a ctx running from a working tree, if it is one."""
|
|
66
66
|
# .../packages/code/src/ctx/code/update.py -> the checkout that owns it.
|
|
67
67
|
for candidate in Path(__file__).resolve().parents:
|
|
68
|
-
if (candidate / ".git").exists() and (candidate / "packages" / "
|
|
68
|
+
if (candidate / ".git").exists() and (candidate / "packages" / "code").is_dir():
|
|
69
69
|
return candidate
|
|
70
70
|
return None
|
|
71
71
|
|
|
@@ -92,7 +92,7 @@ def self_update(package: str = PACKAGE) -> tuple[bool, str]:
|
|
|
92
92
|
if cmd is None:
|
|
93
93
|
root = _source_checkout()
|
|
94
94
|
if root is None:
|
|
95
|
-
return False, "
|
|
95
|
+
return False, "Running from source, but no git checkout was found."
|
|
96
96
|
try:
|
|
97
97
|
pull = _run(["git", "-C", str(root), "pull", "--ff-only"])
|
|
98
98
|
except FileNotFoundError:
|
|
@@ -104,7 +104,7 @@ def self_update(package: str = PACKAGE) -> tuple[bool, str]:
|
|
|
104
104
|
return False, f"git pull failed (exit {pull.returncode}): {detail}"
|
|
105
105
|
if "already up to date" in (pull.stdout or "").lower():
|
|
106
106
|
return True, f"Already up to date ({installer})."
|
|
107
|
-
return True, f"Updated via {installer}. Restart
|
|
107
|
+
return True, f"Updated via {installer}. Restart ctx to load the new code."
|
|
108
108
|
|
|
109
109
|
try:
|
|
110
110
|
result = _run(cmd)
|
|
@@ -20,7 +20,7 @@ class TestInstallChoice:
|
|
|
20
20
|
installer, cmd = update.install_choice()
|
|
21
21
|
assert installer == "pip"
|
|
22
22
|
assert cmd is not None
|
|
23
|
-
assert "pip" in cmd and "--upgrade" in cmd and "
|
|
23
|
+
assert "pip" in cmd and "--upgrade" in cmd and "ctx-agent" in cmd
|
|
24
24
|
|
|
25
25
|
def test_uv_tool_detected(self, monkeypatch, no_tools):
|
|
26
26
|
monkeypatch.setattr(update, "_find_executable", lambda name: name == "uv")
|
|
@@ -38,7 +38,7 @@ class TestInstallChoice:
|
|
|
38
38
|
|
|
39
39
|
def test_source_checkout_wins(self, monkeypatch, no_tools, tmp_path):
|
|
40
40
|
root = tmp_path / "checkout"
|
|
41
|
-
(root / "packages" / "
|
|
41
|
+
(root / "packages" / "code").mkdir(parents=True)
|
|
42
42
|
(root / ".git").mkdir()
|
|
43
43
|
monkeypatch.setattr(update, "_source_checkout", lambda: root)
|
|
44
44
|
installer, cmd = update.install_choice()
|
|
@@ -47,6 +47,7 @@ class TestInstallChoice:
|
|
|
47
47
|
|
|
48
48
|
def test_uv_fallback(self, monkeypatch, no_tools):
|
|
49
49
|
monkeypatch.setattr(update, "_find_executable", lambda name: name == "uv")
|
|
50
|
+
monkeypatch.setattr(update, "_is_uv_tool", lambda pkg: False)
|
|
50
51
|
installer, cmd = update.install_choice()
|
|
51
52
|
assert installer == "uv"
|
|
52
53
|
assert cmd is not None and cmd[:3] == ["uv", "pip", "install"]
|
|
@@ -60,7 +61,9 @@ class TestInstallChoice:
|
|
|
60
61
|
class TestSelfUpdate:
|
|
61
62
|
def test_success_message(self, monkeypatch):
|
|
62
63
|
monkeypatch.setattr(
|
|
63
|
-
update,
|
|
64
|
+
update,
|
|
65
|
+
"install_choice",
|
|
66
|
+
lambda pkg="ctx-agent": ("uv tool", ["uv", "tool", "upgrade", "ctx-agent"]),
|
|
64
67
|
)
|
|
65
68
|
monkeypatch.setattr(
|
|
66
69
|
update,
|
|
@@ -72,7 +75,9 @@ class TestSelfUpdate:
|
|
|
72
75
|
assert "uv tool" in msg
|
|
73
76
|
|
|
74
77
|
def test_already_up_to_date(self, monkeypatch):
|
|
75
|
-
monkeypatch.setattr(
|
|
78
|
+
monkeypatch.setattr(
|
|
79
|
+
update, "install_choice", lambda pkg="ctx-agent": ("pip", ["pip", "install"])
|
|
80
|
+
)
|
|
76
81
|
monkeypatch.setattr(
|
|
77
82
|
update,
|
|
78
83
|
"_run",
|
|
@@ -84,7 +89,9 @@ class TestSelfUpdate:
|
|
|
84
89
|
assert ok and "up to date" in msg
|
|
85
90
|
|
|
86
91
|
def test_failure_message(self, monkeypatch):
|
|
87
|
-
monkeypatch.setattr(
|
|
92
|
+
monkeypatch.setattr(
|
|
93
|
+
update, "install_choice", lambda pkg="ctx-agent": ("pip", ["pip", "install"])
|
|
94
|
+
)
|
|
88
95
|
monkeypatch.setattr(
|
|
89
96
|
update,
|
|
90
97
|
"_run",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|