subagent-cli 0.1.2__tar.gz → 0.1.3__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.
Files changed (47) hide show
  1. subagent_cli-0.1.3/PKG-INFO +166 -0
  2. subagent_cli-0.1.3/README.md +123 -0
  3. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/pyproject.toml +1 -1
  4. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/__init__.py +1 -1
  5. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/cli.py +147 -6
  6. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/paths.py +14 -1
  7. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_cli_phase1.py +82 -1
  8. subagent_cli-0.1.2/PKG-INFO +0 -107
  9. subagent_cli-0.1.2/README.md +0 -64
  10. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/.github/workflows/publish-pypi.yml +0 -0
  11. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/.gitignore +0 -0
  12. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/.python-version +0 -0
  13. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/CONTRIBUTING.md +0 -0
  14. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/LICENSE +0 -0
  15. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/config.example.yaml +0 -0
  16. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/docs/ARCHITECTURE.md +0 -0
  17. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/docs/examples/checkpoint.json +0 -0
  18. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/docs/examples/handoff.md +0 -0
  19. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/docs/examples/normalized-event.ndjson +0 -0
  20. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/docs/examples/worker-continue-flow.md +0 -0
  21. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/acp_client.py +0 -0
  22. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/approval_utils.py +0 -0
  23. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/config.py +0 -0
  24. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/constants.py +0 -0
  25. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/controller_service.py +0 -0
  26. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/daemon.py +0 -0
  27. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/errors.py +0 -0
  28. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/handoff_service.py +0 -0
  29. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/hints.py +0 -0
  30. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/input_contract.py +0 -0
  31. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/launcher_service.py +0 -0
  32. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/output.py +0 -0
  33. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/prompt_service.py +0 -0
  34. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/runtime_service.py +0 -0
  35. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/simple_yaml.py +0 -0
  36. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/state.py +0 -0
  37. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/turn_service.py +0 -0
  38. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/worker_runtime.py +0 -0
  39. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/src/subagent/worker_service.py +0 -0
  40. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/fixtures/fake_acp_agent.py +0 -0
  41. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_acp_backend_integration.py +0 -0
  42. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_daemon_phase1.py +0 -0
  43. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_handoff_phase4.py +0 -0
  44. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_polish_phase5.py +0 -0
  45. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_turn_phase3.py +0 -0
  46. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/tests/test_worker_phase2.py +0 -0
  47. {subagent_cli-0.1.2 → subagent_cli-0.1.3}/uv.lock +0 -0
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: subagent-cli
3
+ Version: 0.1.3
4
+ Summary: Protocol-agnostic worker orchestration CLI
5
+ Author: niitsuma-t
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 niitsuma-t
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ License-File: LICENSE
28
+ Keywords: acp,agent,automation,cli,orchestration
29
+ Classifier: Development Status :: 3 - Alpha
30
+ Classifier: Environment :: Console
31
+ Classifier: Intended Audience :: Developers
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: Topic :: Software Development :: Build Tools
39
+ Classifier: Topic :: Utilities
40
+ Requires-Python: >=3.11
41
+ Requires-Dist: typer>=0.24.1
42
+ Description-Content-Type: text/markdown
43
+
44
+ # subagent-cli
45
+
46
+ [![PyPI version](https://img.shields.io/pypi/v/subagent-cli)](https://pypi.org/project/subagent-cli/)
47
+ [![Python versions](https://img.shields.io/pypi/pyversions/subagent-cli)](https://pypi.org/project/subagent-cli/)
48
+ [![License](https://img.shields.io/github/license/otakumesi/subagent-cli)](LICENSE)
49
+ [![Publish to PyPI](https://github.com/otakumesi/subagent-cli/actions/workflows/publish-pypi.yml/badge.svg)](https://github.com/otakumesi/subagent-cli/actions/workflows/publish-pypi.yml)
50
+ [![Status: Alpha](https://img.shields.io/badge/status-alpha-orange)](https://pypi.org/project/subagent-cli/)
51
+
52
+ Orchestrate worker agents from a parent controller, cleanly and safely.
53
+ `subagent-cli` gives manager agents (for example Codex or Claude Code) a practical control plane for starting workers, sending turns, handling approvals, and continuing handoffs. 🤖
54
+
55
+ The command interface is protocol-agnostic, and the current runtime backend is ACP-based (`acp-stdio`).
56
+
57
+ ## Why subagent-cli? 🚀
58
+ - Run multi-agent workflows from one place (`worker start` to `worker continue`).
59
+ - Keep control explicit with strict approval operations and structured event flow.
60
+ - Recover cleanly with runtime restart + session resume (`session/load`).
61
+ - Stay local-first and scriptable with a single CLI surface.
62
+
63
+ ## Current Scope 🧭
64
+ - Alpha (`v0.1.x`)
65
+ - Local single-host focused
66
+ - Python 3.11+
67
+
68
+ ## Features ✨
69
+ - Worker lifecycle: `start`, `list`, `show`, `inspect`, `stop`
70
+ - Turn operations: `send`, `watch`, `wait`, `approve`, `cancel`
71
+ - Handoff workflow: `worker handoff` and `worker continue`
72
+ - Strict approval flow with structured events
73
+ - ACP runtime integration (`acp-stdio`)
74
+
75
+ ## Install 📦
76
+ With `uv` (recommended):
77
+ ```bash
78
+ uv tool install subagent-cli
79
+ ```
80
+
81
+ From PyPI:
82
+ ```bash
83
+ pip install subagent-cli
84
+ ```
85
+
86
+ From local artifacts:
87
+ ```bash
88
+ pip install dist/subagent_cli-*.whl
89
+ ```
90
+
91
+ ## Quick Start ⚡
92
+ 1. Bootstrap your local config.
93
+ ```bash
94
+ subagent config init --scope user
95
+ ```
96
+
97
+ 2. Set launcher command/args/env in `~/.config/subagent/config.yaml`.
98
+
99
+ 3. Initialize a controller in your workspace.
100
+ ```bash
101
+ subagent controller init --cwd .
102
+ ```
103
+
104
+ 4. Render manager guidance.
105
+ ```bash
106
+ subagent prompt render --target manager
107
+ ```
108
+
109
+ 5. Hand off from here to your manager agent (Codex / Claude Code).
110
+ Use this instruction template:
111
+
112
+ ```text
113
+ Act as the project manager for this repository.
114
+ Use subagent-cli as the control plane and progress this task by delegating to worker agents.
115
+
116
+ Required workflow:
117
+ 1) Read and follow the output of `subagent prompt render --target manager`.
118
+ 2) Check command help before execution (for example `subagent worker --help`, `subagent send --help`, `subagent approve --help`).
119
+ 3) Break the task into small executable chunks.
120
+ 4) Start/coordinate workers with subagent-cli.
121
+ 5) Use send/watch/wait/approve to drive each turn.
122
+ 6) Use handoff/continue when context gets large.
123
+ 7) Verify results (tests or checks) before reporting completion.
124
+
125
+ Task to execute:
126
+ <your task here>
127
+ ```
128
+
129
+ After handoff, the manager agent is expected to run the normal CLI lifecycle:
130
+ `worker start` -> `send` -> `watch` -> `approve` -> `handoff` -> `continue`
131
+
132
+ For local simulation/testing without a real ACP launcher:
133
+ ```bash
134
+ subagent worker start --cwd . --debug-mode
135
+ ```
136
+
137
+ ## Troubleshooting 🛠️
138
+ - Ensure the runtime has the permissions required by your launcher (some launchers need outbound network access).
139
+ - Preflight launcher availability:
140
+ ```bash
141
+ subagent launcher probe <launcher-name> --json
142
+ ```
143
+ - If `worker start` fails with `BACKEND_UNAVAILABLE`, inspect runtime logs under `~/.local/share/subagent/runtimes/` (or `$SUBAGENT_STATE_DIR/runtimes/` when overridden).
144
+ - For cut-down local testing without backend connectivity:
145
+ ```bash
146
+ subagent worker start --cwd . --debug-mode
147
+ ```
148
+
149
+ ## Configuration ⚙️
150
+ - Resolution order: `--config` > `SUBAGENT_CONFIG` > nearest `<cwd-or-parent>/.subagent/config.yaml` > `~/.config/subagent/config.yaml`
151
+ - Generate user config: `subagent config init --scope user`
152
+ - Generate project config: `subagent config init --scope project --cwd .`
153
+ - Override config path: `SUBAGENT_CONFIG=/path/to/config.yaml`
154
+ - Example config: [config.example.yaml](config.example.yaml)
155
+
156
+ ## State 💾
157
+ - Default state DB: `~/.local/share/subagent/state.db`
158
+ - Project hint file: `<workspace>/.subagent/controller.json`
159
+
160
+ ## Documentation 📚
161
+ - Architecture note: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
162
+ - Examples: [docs/examples](docs/examples)
163
+ - Contributing and release process: [CONTRIBUTING.md](CONTRIBUTING.md)
164
+
165
+ ## License
166
+ MIT ([LICENSE](LICENSE))
@@ -0,0 +1,123 @@
1
+ # subagent-cli
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/subagent-cli)](https://pypi.org/project/subagent-cli/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/subagent-cli)](https://pypi.org/project/subagent-cli/)
5
+ [![License](https://img.shields.io/github/license/otakumesi/subagent-cli)](LICENSE)
6
+ [![Publish to PyPI](https://github.com/otakumesi/subagent-cli/actions/workflows/publish-pypi.yml/badge.svg)](https://github.com/otakumesi/subagent-cli/actions/workflows/publish-pypi.yml)
7
+ [![Status: Alpha](https://img.shields.io/badge/status-alpha-orange)](https://pypi.org/project/subagent-cli/)
8
+
9
+ Orchestrate worker agents from a parent controller, cleanly and safely.
10
+ `subagent-cli` gives manager agents (for example Codex or Claude Code) a practical control plane for starting workers, sending turns, handling approvals, and continuing handoffs. 🤖
11
+
12
+ The command interface is protocol-agnostic, and the current runtime backend is ACP-based (`acp-stdio`).
13
+
14
+ ## Why subagent-cli? 🚀
15
+ - Run multi-agent workflows from one place (`worker start` to `worker continue`).
16
+ - Keep control explicit with strict approval operations and structured event flow.
17
+ - Recover cleanly with runtime restart + session resume (`session/load`).
18
+ - Stay local-first and scriptable with a single CLI surface.
19
+
20
+ ## Current Scope 🧭
21
+ - Alpha (`v0.1.x`)
22
+ - Local single-host focused
23
+ - Python 3.11+
24
+
25
+ ## Features ✨
26
+ - Worker lifecycle: `start`, `list`, `show`, `inspect`, `stop`
27
+ - Turn operations: `send`, `watch`, `wait`, `approve`, `cancel`
28
+ - Handoff workflow: `worker handoff` and `worker continue`
29
+ - Strict approval flow with structured events
30
+ - ACP runtime integration (`acp-stdio`)
31
+
32
+ ## Install 📦
33
+ With `uv` (recommended):
34
+ ```bash
35
+ uv tool install subagent-cli
36
+ ```
37
+
38
+ From PyPI:
39
+ ```bash
40
+ pip install subagent-cli
41
+ ```
42
+
43
+ From local artifacts:
44
+ ```bash
45
+ pip install dist/subagent_cli-*.whl
46
+ ```
47
+
48
+ ## Quick Start ⚡
49
+ 1. Bootstrap your local config.
50
+ ```bash
51
+ subagent config init --scope user
52
+ ```
53
+
54
+ 2. Set launcher command/args/env in `~/.config/subagent/config.yaml`.
55
+
56
+ 3. Initialize a controller in your workspace.
57
+ ```bash
58
+ subagent controller init --cwd .
59
+ ```
60
+
61
+ 4. Render manager guidance.
62
+ ```bash
63
+ subagent prompt render --target manager
64
+ ```
65
+
66
+ 5. Hand off from here to your manager agent (Codex / Claude Code).
67
+ Use this instruction template:
68
+
69
+ ```text
70
+ Act as the project manager for this repository.
71
+ Use subagent-cli as the control plane and progress this task by delegating to worker agents.
72
+
73
+ Required workflow:
74
+ 1) Read and follow the output of `subagent prompt render --target manager`.
75
+ 2) Check command help before execution (for example `subagent worker --help`, `subagent send --help`, `subagent approve --help`).
76
+ 3) Break the task into small executable chunks.
77
+ 4) Start/coordinate workers with subagent-cli.
78
+ 5) Use send/watch/wait/approve to drive each turn.
79
+ 6) Use handoff/continue when context gets large.
80
+ 7) Verify results (tests or checks) before reporting completion.
81
+
82
+ Task to execute:
83
+ <your task here>
84
+ ```
85
+
86
+ After handoff, the manager agent is expected to run the normal CLI lifecycle:
87
+ `worker start` -> `send` -> `watch` -> `approve` -> `handoff` -> `continue`
88
+
89
+ For local simulation/testing without a real ACP launcher:
90
+ ```bash
91
+ subagent worker start --cwd . --debug-mode
92
+ ```
93
+
94
+ ## Troubleshooting 🛠️
95
+ - Ensure the runtime has the permissions required by your launcher (some launchers need outbound network access).
96
+ - Preflight launcher availability:
97
+ ```bash
98
+ subagent launcher probe <launcher-name> --json
99
+ ```
100
+ - If `worker start` fails with `BACKEND_UNAVAILABLE`, inspect runtime logs under `~/.local/share/subagent/runtimes/` (or `$SUBAGENT_STATE_DIR/runtimes/` when overridden).
101
+ - For cut-down local testing without backend connectivity:
102
+ ```bash
103
+ subagent worker start --cwd . --debug-mode
104
+ ```
105
+
106
+ ## Configuration ⚙️
107
+ - Resolution order: `--config` > `SUBAGENT_CONFIG` > nearest `<cwd-or-parent>/.subagent/config.yaml` > `~/.config/subagent/config.yaml`
108
+ - Generate user config: `subagent config init --scope user`
109
+ - Generate project config: `subagent config init --scope project --cwd .`
110
+ - Override config path: `SUBAGENT_CONFIG=/path/to/config.yaml`
111
+ - Example config: [config.example.yaml](config.example.yaml)
112
+
113
+ ## State 💾
114
+ - Default state DB: `~/.local/share/subagent/state.db`
115
+ - Project hint file: `<workspace>/.subagent/controller.json`
116
+
117
+ ## Documentation 📚
118
+ - Architecture note: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
119
+ - Examples: [docs/examples](docs/examples)
120
+ - Contributing and release process: [CONTRIBUTING.md](CONTRIBUTING.md)
121
+
122
+ ## License
123
+ MIT ([LICENSE](LICENSE))
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "subagent-cli"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  description = "Protocol-agnostic worker orchestration CLI"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -2,6 +2,6 @@
2
2
 
3
3
  from .constants import SCHEMA_VERSION
4
4
 
5
- __version__ = "0.1.2"
5
+ __version__ = "0.1.3"
6
6
 
7
7
  __all__ = ["SCHEMA_VERSION", "__version__"]
@@ -10,6 +10,7 @@ import click
10
10
  import typer
11
11
 
12
12
  from .config import SubagentConfig, load_config
13
+ from .constants import PROJECT_HINT_DIRNAME
13
14
  from .controller_service import (
14
15
  attach_controller,
15
16
  init_controller,
@@ -31,7 +32,7 @@ from .input_contract import (
31
32
  )
32
33
  from .launcher_service import probe_launcher
33
34
  from .output import emit_error_and_exit, emit_json, ok_envelope
34
- from .paths import resolve_workspace_path
35
+ from .paths import resolve_config_path, resolve_workspace_path
35
36
  from .prompt_service import render_prompt
36
37
  from .state import StateStore
37
38
  from .turn_service import approve_request, cancel_turn, send_message, wait_for_event, watch_events
@@ -40,12 +41,17 @@ from .worker_service import inspect_worker, list_workers, show_worker, start_wor
40
41
  app = typer.Typer(
41
42
  help=(
42
43
  "subagent: protocol-agnostic worker orchestration CLI\n"
43
- "If you are a manager agent, start with: `subagent prompt render --target manager`"
44
+ "If you were instructed to use this tool as a manager agent, "
45
+ "start with: `subagent prompt render --target manager`\n"
46
+ "Tip: `subagent worker start`, `subagent send`, `subagent wait`, and "
47
+ "`subagent watch` may require running outside your sandbox "
48
+ "or with elevated permissions, depending on launcher/runtime policy."
44
49
  )
45
50
  )
46
51
  launcher_app = typer.Typer(help="Manage launcher registry from config")
47
52
  profile_app = typer.Typer(help="Manage profile registry from config")
48
53
  pack_app = typer.Typer(help="Manage pack registry from config")
54
+ config_app = typer.Typer(help="Manage config files")
49
55
  prompt_app = typer.Typer(help="Render manager/worker prompts")
50
56
  controller_app = typer.Typer(help="Manage controller ownership")
51
57
  worker_app = typer.Typer(help="Manage worker lifecycle")
@@ -53,6 +59,7 @@ worker_app = typer.Typer(help="Manage worker lifecycle")
53
59
  app.add_typer(launcher_app, name="launcher")
54
60
  app.add_typer(profile_app, name="profile")
55
61
  app.add_typer(pack_app, name="pack")
62
+ app.add_typer(config_app, name="config")
56
63
  app.add_typer(prompt_app, name="prompt")
57
64
  app.add_typer(controller_app, name="controller")
58
65
  app.add_typer(worker_app, name="worker")
@@ -65,6 +72,121 @@ def _load_config_or_exit(config_path: Path | None, *, json_output: bool) -> Suba
65
72
  emit_error_and_exit(error, json_output=json_output)
66
73
 
67
74
 
75
+ _DEFAULT_CONFIG_TEMPLATE = """launchers:
76
+ codex:
77
+ backend:
78
+ kind: acp-stdio
79
+ command: codex-acp
80
+ args: []
81
+ env: {}
82
+
83
+ claude-code:
84
+ backend:
85
+ kind: acp-stdio
86
+ command: claude-code-acp
87
+ args: []
88
+ env: {}
89
+
90
+ profiles:
91
+ worker-default:
92
+ promptLanguage: en
93
+ responseLanguage: same_as_manager
94
+ autoHandoff: turn_end
95
+ policyPreset: safe-default
96
+ defaultPacks:
97
+ - repo-conventions
98
+ bootstrap: |
99
+ You are a worker subagent.
100
+ Use STATUS:, ASK:, BLOCKED:, and DONE: prefixes when helpful.
101
+ Keep messages concise and actionable.
102
+
103
+ packs:
104
+ repo-conventions:
105
+ description: Follow repository coding conventions and keep diffs small.
106
+ prompt: |
107
+ Read existing conventions before editing.
108
+ Prefer minimal, explicit changes.
109
+
110
+ python-test-fix:
111
+ description: Fix flaky Python tests with minimal change scope.
112
+ prompt: |
113
+ Reproduce failing tests first.
114
+ Add regression coverage where practical.
115
+
116
+ policyPresets:
117
+ safe-default:
118
+ filesystem: workspace-write
119
+ network: ask
120
+ dangerousCommands: deny
121
+
122
+ defaults:
123
+ launcher: codex
124
+ profile: worker-default
125
+ packs:
126
+ - repo-conventions
127
+ """
128
+
129
+
130
+ def _default_project_config_path(cwd: Path) -> Path:
131
+ return resolve_workspace_path(cwd) / PROJECT_HINT_DIRNAME / "config.yaml"
132
+
133
+
134
+ @config_app.command("init")
135
+ def config_init(
136
+ scope: str = typer.Option(
137
+ "user",
138
+ "--scope",
139
+ help="Config target scope: user or project.",
140
+ ),
141
+ cwd: Path = typer.Option(Path("."), "--cwd", help="Workspace root for project scope"),
142
+ path: Path | None = typer.Option(None, "--path", help="Explicit output path override"),
143
+ force: bool = typer.Option(False, "--force", help="Overwrite existing file"),
144
+ json_output: bool = typer.Option(False, "--json", help="Emit JSON envelope."),
145
+ ) -> None:
146
+ normalized_scope = scope.strip().lower()
147
+ if normalized_scope not in {"user", "project"}:
148
+ emit_error_and_exit(
149
+ SubagentError(
150
+ code="INVALID_ARGUMENT",
151
+ message="`--scope` must be one of: user, project",
152
+ details={"scope": scope},
153
+ ),
154
+ json_output=json_output,
155
+ )
156
+
157
+ if path is not None:
158
+ target_path = path.expanduser().resolve()
159
+ elif normalized_scope == "project":
160
+ target_path = _default_project_config_path(cwd)
161
+ else:
162
+ target_path = resolve_config_path(prefer_project=False)
163
+
164
+ existed = target_path.exists()
165
+ if existed and not force:
166
+ emit_error_and_exit(
167
+ SubagentError(
168
+ code="CONFIG_ALREADY_EXISTS",
169
+ message=f"Config already exists: {target_path}",
170
+ details={"path": str(target_path)},
171
+ ),
172
+ json_output=json_output,
173
+ )
174
+
175
+ target_path.parent.mkdir(parents=True, exist_ok=True)
176
+ target_path.write_text(_DEFAULT_CONFIG_TEMPLATE, encoding="utf-8")
177
+
178
+ payload = {
179
+ "path": str(target_path),
180
+ "scope": normalized_scope,
181
+ "overwritten": existed,
182
+ }
183
+ if json_output:
184
+ emit_json(ok_envelope("config.initialized", payload))
185
+ else:
186
+ typer.echo(f"configPath: {target_path}")
187
+ typer.echo(f"scope: {normalized_scope}")
188
+
189
+
68
190
  def _store() -> StateStore:
69
191
  store = StateStore()
70
192
  store.bootstrap()
@@ -550,7 +672,13 @@ def controller_release(
550
672
  typer.echo(f"released: {payload['released']}")
551
673
 
552
674
 
553
- @app.command("send")
675
+ @app.command(
676
+ "send",
677
+ help=(
678
+ "Send a turn to a worker. "
679
+ "In sandboxed manager environments, this may need outside-sandbox execution."
680
+ ),
681
+ )
554
682
  def send(
555
683
  ctx: typer.Context,
556
684
  worker_id: str | None = typer.Option(None, "--worker", help="Worker ID"),
@@ -637,7 +765,13 @@ def send(
637
765
  typer.echo(f"state: {payload['state']}")
638
766
 
639
767
 
640
- @app.command("watch")
768
+ @app.command(
769
+ "watch",
770
+ help=(
771
+ "Watch worker events. "
772
+ "In sandboxed manager environments, this may need outside-sandbox execution."
773
+ ),
774
+ )
641
775
  def watch(
642
776
  worker_id: str = typer.Option(..., "--worker", help="Worker ID"),
643
777
  from_event_id: str | None = typer.Option(None, "--from-event-id", help="Cursor event ID"),
@@ -693,7 +827,13 @@ def watch(
693
827
  return
694
828
 
695
829
 
696
- @app.command("wait")
830
+ @app.command(
831
+ "wait",
832
+ help=(
833
+ "Wait for a worker event. "
834
+ "In sandboxed manager environments, this may need outside-sandbox execution."
835
+ ),
836
+ )
697
837
  def wait(
698
838
  ctx: typer.Context,
699
839
  worker_id: str | None = typer.Option(None, "--worker", help="Worker ID"),
@@ -869,7 +1009,8 @@ def cancel(
869
1009
  help=(
870
1010
  "Start a worker runtime. "
871
1011
  "Tip: run `subagent launcher probe <launcher-name> --json` first and ensure "
872
- "launcher-required permissions (including network access) are available."
1012
+ "launcher-required permissions (including network access) are available. "
1013
+ "In sandboxed manager environments, this may need outside-sandbox execution."
873
1014
  ),
874
1015
  )
875
1016
  def worker_start(
@@ -21,12 +21,25 @@ def resolve_workspace_path(cwd: Path | None = None) -> Path:
21
21
  return (cwd or Path.cwd()).expanduser().resolve()
22
22
 
23
23
 
24
- def resolve_config_path(config_path: Path | None = None) -> Path:
24
+ def _discover_project_config_path(cwd: Path | None = None) -> Path | None:
25
+ start = resolve_workspace_path(cwd)
26
+ for current in [start, *start.parents]:
27
+ candidate = current / PROJECT_HINT_DIRNAME / "config.yaml"
28
+ if candidate.exists():
29
+ return candidate
30
+ return None
31
+
32
+
33
+ def resolve_config_path(config_path: Path | None = None, *, prefer_project: bool = True) -> Path:
25
34
  if config_path is not None:
26
35
  return config_path.expanduser().resolve()
27
36
  env_value = os.environ.get(ENV_CONFIG_PATH)
28
37
  if env_value:
29
38
  return Path(env_value).expanduser().resolve()
39
+ if prefer_project:
40
+ discovered = _discover_project_config_path()
41
+ if discovered is not None:
42
+ return discovered
30
43
  return DEFAULT_CONFIG_PATH
31
44
 
32
45
 
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import os
4
5
  import tempfile
5
6
  import unittest
6
7
  from pathlib import Path
@@ -89,10 +90,90 @@ class CLIPhase1Tests(unittest.TestCase):
89
90
  self.assertEqual(pack_payload["type"], "pack.listed")
90
91
  self.assertEqual(pack_payload["data"]["count"], 1)
91
92
 
93
+ def test_config_init_creates_file_and_requires_force_to_overwrite(self) -> None:
94
+ config_out = self.root / "generated" / "config.yaml"
95
+
96
+ first = self.invoke(
97
+ ["config", "init", "--path", str(config_out), "--json"],
98
+ )
99
+ self.assertEqual(first.exit_code, 0)
100
+ first_payload = json.loads(first.stdout)
101
+ self.assertEqual(first_payload["type"], "config.initialized")
102
+ self.assertEqual(Path(first_payload["data"]["path"]).resolve(), config_out.resolve())
103
+ self.assertEqual(first_payload["data"]["scope"], "user")
104
+ self.assertFalse(first_payload["data"]["overwritten"])
105
+ self.assertTrue(config_out.exists())
106
+ generated = config_out.read_text(encoding="utf-8")
107
+ self.assertIn("launchers:", generated)
108
+ self.assertIn("profiles:", generated)
109
+ self.assertIn("defaults:", generated)
110
+
111
+ second = self.invoke(
112
+ ["config", "init", "--path", str(config_out), "--json"],
113
+ )
114
+ self.assertEqual(second.exit_code, 1)
115
+ second_payload = json.loads(second.stdout)
116
+ self.assertEqual(second_payload["error"]["code"], "CONFIG_ALREADY_EXISTS")
117
+
118
+ third = self.invoke(
119
+ ["config", "init", "--path", str(config_out), "--force", "--json"],
120
+ )
121
+ self.assertEqual(third.exit_code, 0)
122
+ third_payload = json.loads(third.stdout)
123
+ self.assertTrue(third_payload["data"]["overwritten"])
124
+
125
+ def test_config_init_project_scope_writes_under_workspace(self) -> None:
126
+ result = self.invoke(
127
+ ["config", "init", "--scope", "project", "--cwd", str(self.workspace), "--json"],
128
+ )
129
+ self.assertEqual(result.exit_code, 0)
130
+ payload = json.loads(result.stdout)
131
+ self.assertEqual(payload["type"], "config.initialized")
132
+ expected = self.workspace / ".subagent" / "config.yaml"
133
+ self.assertEqual(Path(payload["data"]["path"]).resolve(), expected.resolve())
134
+ self.assertEqual(payload["data"]["scope"], "project")
135
+ self.assertTrue(expected.exists())
136
+
92
137
  def test_root_help_mentions_manager_prompt_bootstrap(self) -> None:
93
138
  result = self.invoke(["--help"])
94
139
  self.assertEqual(result.exit_code, 0)
95
- self.assertIn("prompt render --target manager", result.stdout)
140
+ self.assertIn("instructed to", result.stdout)
141
+ self.assertIn("use this tool as a manager agent", result.stdout)
142
+ self.assertIn("subagent prompt render --target", result.stdout)
143
+ self.assertIn("outside your sandbox", result.stdout)
144
+ self.assertIn("or with elevated", result.stdout)
145
+ self.assertIn("permissions, depending on launcher/runtime policy", result.stdout)
146
+
147
+ def test_worker_start_help_mentions_sandbox_permissions(self) -> None:
148
+ result = self.invoke(["worker", "start", "--help"])
149
+ self.assertEqual(result.exit_code, 0)
150
+ self.assertIn("outside-sandbox execution", result.stdout)
151
+
152
+ def test_send_wait_watch_help_mentions_sandbox_permissions(self) -> None:
153
+ for args in (["send", "--help"], ["wait", "--help"], ["watch", "--help"]):
154
+ result = self.invoke(args)
155
+ self.assertEqual(result.exit_code, 0)
156
+ self.assertIn("outside-sandbox execution", result.stdout)
157
+
158
+ def test_project_config_is_auto_discovered_from_workspace(self) -> None:
159
+ project_config = self.workspace / ".subagent" / "config.yaml"
160
+ project_config.parent.mkdir(parents=True, exist_ok=True)
161
+ project_config.write_text(
162
+ SAMPLE_CONFIG.replace("codex-acp", "project-codex-acp").strip() + "\n",
163
+ encoding="utf-8",
164
+ )
165
+
166
+ original_cwd = Path.cwd()
167
+ os.chdir(self.workspace)
168
+ try:
169
+ result = self.invoke(["launcher", "show", "codex", "--json"], env={"SUBAGENT_CONFIG": ""})
170
+ finally:
171
+ os.chdir(original_cwd)
172
+
173
+ self.assertEqual(result.exit_code, 0)
174
+ payload = json.loads(result.stdout)
175
+ self.assertEqual(payload["type"], "launcher.shown")
176
+ self.assertEqual(payload["data"]["command"], "project-codex-acp")
96
177
 
97
178
  def test_controller_init_and_status_with_valid_env_handle(self) -> None:
98
179
  init_result = self.invoke(
@@ -1,107 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: subagent-cli
3
- Version: 0.1.2
4
- Summary: Protocol-agnostic worker orchestration CLI
5
- Author: niitsuma-t
6
- License: MIT License
7
-
8
- Copyright (c) 2026 niitsuma-t
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- License-File: LICENSE
28
- Keywords: acp,agent,automation,cli,orchestration
29
- Classifier: Development Status :: 3 - Alpha
30
- Classifier: Environment :: Console
31
- Classifier: Intended Audience :: Developers
32
- Classifier: License :: OSI Approved :: MIT License
33
- Classifier: Operating System :: OS Independent
34
- Classifier: Programming Language :: Python :: 3
35
- Classifier: Programming Language :: Python :: 3.11
36
- Classifier: Programming Language :: Python :: 3.12
37
- Classifier: Programming Language :: Python :: 3.13
38
- Classifier: Topic :: Software Development :: Build Tools
39
- Classifier: Topic :: Utilities
40
- Requires-Python: >=3.11
41
- Requires-Dist: typer>=0.24.1
42
- Description-Content-Type: text/markdown
43
-
44
- # subagent-cli
45
-
46
- `subagent-cli` is a protocol-agnostic CLI for orchestrating worker agents from a parent controller.
47
- In practice, it is a control-plane CLI that a manager agent (for example Codex or Claude Code) can use to launch and coordinate other worker agents.
48
- The CLI surface is protocol-agnostic, while the current runtime implementation is ACP-based (`acp-stdio`).
49
-
50
- ## Status
51
- - Alpha (`v0.1.x`)
52
- - Local single-host focused
53
- - Python 3.11+
54
-
55
- ## Features
56
- - Worker lifecycle: start, list, show, inspect, stop
57
- - Turn operations: send, watch, wait, approve, cancel
58
- - Handoff workflow: `worker handoff` and `worker continue`
59
- - Strict approval flow with structured events
60
- - ACP runtime integration (`acp-stdio`) with runtime restart + session resume (`session/load`)
61
-
62
- ## Install
63
- - From PyPI:
64
- `pip install subagent-cli`
65
- - From local artifacts:
66
- `pip install dist/subagent_cli-*.whl`
67
-
68
- ## Quick Start
69
- 1. Prepare config:
70
- `mkdir -p ~/.config/subagent && cp config.example.yaml ~/.config/subagent/config.yaml`
71
- 2. Initialize a controller in your workspace:
72
- `subagent controller init --cwd .`
73
- 3. Start a worker:
74
- `subagent worker start --cwd .`
75
- 4. Send an instruction:
76
- `subagent send --worker <worker-id> --text "Investigate failing tests"`
77
- 5. Watch events:
78
- `subagent watch --worker <worker-id> --ndjson`
79
-
80
- For local simulation/testing without a real ACP launcher:
81
- `subagent worker start --cwd . --debug-mode`
82
-
83
- ## Troubleshooting
84
- - Ensure the runtime has the permissions required by your launcher. Some launchers need outbound network access.
85
- - Preflight launcher availability:
86
- `subagent launcher probe <launcher-name> --json`
87
- - If `worker start` fails with `BACKEND_UNAVAILABLE`, inspect runtime logs under:
88
- `~/.local/share/subagent/runtimes/` (or `$SUBAGENT_STATE_DIR/runtimes/` when overridden)
89
- - For local cut-down testing without backend connectivity, use:
90
- `subagent worker start --cwd . --debug-mode`
91
-
92
- ## Configuration
93
- - Default config path: `~/.config/subagent/config.yaml`
94
- - Override config path: `SUBAGENT_CONFIG=/path/to/config.yaml`
95
- - Example config: [config.example.yaml](config.example.yaml)
96
-
97
- ## State
98
- - Default state DB: `~/.local/share/subagent/state.db`
99
- - Project hint file: `<workspace>/.subagent/controller.json`
100
-
101
- ## Documentation
102
- - Architecture note: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
103
- - Examples: [docs/examples](docs/examples)
104
- - Contributing and release process: [CONTRIBUTING.md](CONTRIBUTING.md)
105
-
106
- ## License
107
- MIT ([LICENSE](LICENSE))
@@ -1,64 +0,0 @@
1
- # subagent-cli
2
-
3
- `subagent-cli` is a protocol-agnostic CLI for orchestrating worker agents from a parent controller.
4
- In practice, it is a control-plane CLI that a manager agent (for example Codex or Claude Code) can use to launch and coordinate other worker agents.
5
- The CLI surface is protocol-agnostic, while the current runtime implementation is ACP-based (`acp-stdio`).
6
-
7
- ## Status
8
- - Alpha (`v0.1.x`)
9
- - Local single-host focused
10
- - Python 3.11+
11
-
12
- ## Features
13
- - Worker lifecycle: start, list, show, inspect, stop
14
- - Turn operations: send, watch, wait, approve, cancel
15
- - Handoff workflow: `worker handoff` and `worker continue`
16
- - Strict approval flow with structured events
17
- - ACP runtime integration (`acp-stdio`) with runtime restart + session resume (`session/load`)
18
-
19
- ## Install
20
- - From PyPI:
21
- `pip install subagent-cli`
22
- - From local artifacts:
23
- `pip install dist/subagent_cli-*.whl`
24
-
25
- ## Quick Start
26
- 1. Prepare config:
27
- `mkdir -p ~/.config/subagent && cp config.example.yaml ~/.config/subagent/config.yaml`
28
- 2. Initialize a controller in your workspace:
29
- `subagent controller init --cwd .`
30
- 3. Start a worker:
31
- `subagent worker start --cwd .`
32
- 4. Send an instruction:
33
- `subagent send --worker <worker-id> --text "Investigate failing tests"`
34
- 5. Watch events:
35
- `subagent watch --worker <worker-id> --ndjson`
36
-
37
- For local simulation/testing without a real ACP launcher:
38
- `subagent worker start --cwd . --debug-mode`
39
-
40
- ## Troubleshooting
41
- - Ensure the runtime has the permissions required by your launcher. Some launchers need outbound network access.
42
- - Preflight launcher availability:
43
- `subagent launcher probe <launcher-name> --json`
44
- - If `worker start` fails with `BACKEND_UNAVAILABLE`, inspect runtime logs under:
45
- `~/.local/share/subagent/runtimes/` (or `$SUBAGENT_STATE_DIR/runtimes/` when overridden)
46
- - For local cut-down testing without backend connectivity, use:
47
- `subagent worker start --cwd . --debug-mode`
48
-
49
- ## Configuration
50
- - Default config path: `~/.config/subagent/config.yaml`
51
- - Override config path: `SUBAGENT_CONFIG=/path/to/config.yaml`
52
- - Example config: [config.example.yaml](config.example.yaml)
53
-
54
- ## State
55
- - Default state DB: `~/.local/share/subagent/state.db`
56
- - Project hint file: `<workspace>/.subagent/controller.json`
57
-
58
- ## Documentation
59
- - Architecture note: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
60
- - Examples: [docs/examples](docs/examples)
61
- - Contributing and release process: [CONTRIBUTING.md](CONTRIBUTING.md)
62
-
63
- ## License
64
- MIT ([LICENSE](LICENSE))
File without changes
File without changes
File without changes