cacli 0.2.2__tar.gz → 0.2.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 (54) hide show
  1. {cacli-0.2.2/src/cacli.egg-info → cacli-0.2.3}/PKG-INFO +1 -1
  2. {cacli-0.2.2 → cacli-0.2.3}/pyproject.toml +1 -1
  3. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/cli.py +18 -0
  4. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/SKILL.md +4 -1
  5. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/engine.py +14 -0
  6. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/host.py +16 -0
  7. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/pi.py +11 -3
  8. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/runner.py +28 -0
  9. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/spawn.py +2 -0
  10. {cacli-0.2.2 → cacli-0.2.3/src/cacli.egg-info}/PKG-INFO +1 -1
  11. {cacli-0.2.2 → cacli-0.2.3}/tests/test_flow.py +41 -0
  12. {cacli-0.2.2 → cacli-0.2.3}/tests/test_launch.py +65 -2
  13. {cacli-0.2.2 → cacli-0.2.3}/tests/test_pi_provider.py +42 -0
  14. {cacli-0.2.2 → cacli-0.2.3}/LICENSE +0 -0
  15. {cacli-0.2.2 → cacli-0.2.3}/README.md +0 -0
  16. {cacli-0.2.2 → cacli-0.2.3}/setup.cfg +0 -0
  17. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/__init__.py +0 -0
  18. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/devin_stream.py +0 -0
  19. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/__init__.py +0 -0
  20. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/aexec.py +0 -0
  21. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/cli.py +0 -0
  22. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/costs.py +0 -0
  23. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/journal.py +0 -0
  24. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/runs.py +0 -0
  25. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/sandbox.py +0 -0
  26. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/schema.py +0 -0
  27. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/flow/shim.py +0 -0
  28. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/__init__.py +0 -0
  29. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/base.py +0 -0
  30. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/claude.py +0 -0
  31. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/codex.py +0 -0
  32. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/cursor.py +0 -0
  33. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/devin.py +0 -0
  34. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/harnesses/opencode.py +0 -0
  35. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/inference.py +0 -0
  36. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/server.py +0 -0
  37. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/sessions.py +0 -0
  38. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/status.py +0 -0
  39. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/transcript_apply.py +0 -0
  40. {cacli-0.2.2 → cacli-0.2.3}/src/cacli/types.py +0 -0
  41. {cacli-0.2.2 → cacli-0.2.3}/src/cacli.egg-info/SOURCES.txt +0 -0
  42. {cacli-0.2.2 → cacli-0.2.3}/src/cacli.egg-info/dependency_links.txt +0 -0
  43. {cacli-0.2.2 → cacli-0.2.3}/src/cacli.egg-info/entry_points.txt +0 -0
  44. {cacli-0.2.2 → cacli-0.2.3}/src/cacli.egg-info/requires.txt +0 -0
  45. {cacli-0.2.2 → cacli-0.2.3}/src/cacli.egg-info/top_level.txt +0 -0
  46. {cacli-0.2.2 → cacli-0.2.3}/tests/test_claude_provider.py +0 -0
  47. {cacli-0.2.2 → cacli-0.2.3}/tests/test_codex_provider.py +0 -0
  48. {cacli-0.2.2 → cacli-0.2.3}/tests/test_cursor_provider.py +0 -0
  49. {cacli-0.2.2 → cacli-0.2.3}/tests/test_devin_provider.py +0 -0
  50. {cacli-0.2.2 → cacli-0.2.3}/tests/test_devin_stream.py +0 -0
  51. {cacli-0.2.2 → cacli-0.2.3}/tests/test_flow_resume.py +0 -0
  52. {cacli-0.2.2 → cacli-0.2.3}/tests/test_flow_schema.py +0 -0
  53. {cacli-0.2.2 → cacli-0.2.3}/tests/test_opencode_provider.py +0 -0
  54. {cacli-0.2.2 → cacli-0.2.3}/tests/test_transcript_apply.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cacli
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Harness and provider CLI for running coding agents
5
5
  Author: Benjamin Anderson
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cacli"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Harness and provider CLI for running coding agents"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -105,6 +105,20 @@ def _add_common_args(parser: argparse.ArgumentParser) -> None:
105
105
  "restores unsandboxed execution."
106
106
  ),
107
107
  )
108
+ parser.add_argument(
109
+ "--extension",
110
+ dest="extensions",
111
+ action="append",
112
+ default=[],
113
+ help="Pi extension path, passed as -e (repeatable; pi only)",
114
+ )
115
+ parser.add_argument(
116
+ "--no-trust-project",
117
+ dest="trust_project",
118
+ action="store_false",
119
+ default=True,
120
+ help="Ignore project-local Pi settings and extensions (--no-approve; pi only)",
121
+ )
108
122
  parser.add_argument("--cwd", default=".", help="Working directory")
109
123
  parser.add_argument(
110
124
  "--timeout", "-t", type=int, default=3600, help="Timeout in seconds"
@@ -123,6 +137,8 @@ def _run_command(args) -> None:
123
137
  web_search=args.web_search,
124
138
  settings=args.settings,
125
139
  sandbox=args.sandbox,
140
+ extensions=args.extensions,
141
+ trust_project=args.trust_project,
126
142
  )
127
143
  if args.command_only:
128
144
  print(launch.command)
@@ -142,6 +158,8 @@ def _run_command(args) -> None:
142
158
  sandbox=args.sandbox,
143
159
  cwd=args.cwd,
144
160
  timeout=args.timeout,
161
+ extensions=args.extensions,
162
+ trust_project=args.trust_project,
145
163
  )
146
164
 
147
165
  if args.raw:
@@ -108,6 +108,8 @@ All arguments after `prompt` are keyword-only.
108
108
  | `sandbox` | None | `True` = force OS sandbox, `False` = force off, `None` = harness default (codex/devin default sandboxed; claude/cursor use their own CLI defaults) |
109
109
  | `web_search` | True | allow the agent to search the web |
110
110
  | `env` | None | extra env vars (dict of str→str) |
111
+ | `extensions` | None | pi only: list of extension paths, each passed as `-e` |
112
+ | `trust_project` | True | pi only: `False` passes `--no-approve`, ignoring project-local `.pi/` settings and extensions |
111
113
 
112
114
  **Returns `None` on terminal failure** (after retries) — never raises for
113
115
  agent failure. Fan-outs degrade instead of exploding; filter with
@@ -207,7 +209,8 @@ the previous run's journal (instant, no re-execution — though replayed costs
207
209
  still count against the resumed run's budget), then goes live at the first
208
210
  call whose identity differs. Identity includes prompt/harness/provider/model/effort/
209
211
  schema/cwd plus the execution options `web_search`, `settings`, `sandbox`,
210
- `env`, `retries`, `schema_retries`, `timeout`, and `stall_timeout`. `label` and
212
+ `env`, `retries`, `schema_retries`, `timeout`, and `stall_timeout` (and pi's
213
+ `extensions`/`trust_project` when set). `label` and
211
214
  `phase` are display-only and deliberately excluded from resume identity.
212
215
  Resuming with an edited script or different `--args` is the intended
213
216
  iteration workflow: fix a later stage, keep earlier results cached. Cached
@@ -210,6 +210,8 @@ class FlowEngine:
210
210
  settings: str | None,
211
211
  sandbox: bool | None,
212
212
  env: dict[str, str] | None,
213
+ extensions: tuple[str, ...] = (),
214
+ trust_project: bool = True,
213
215
  ) -> Any | None:
214
216
  if self.cancel_event.is_set():
215
217
  raise RuntimeError("FlowCancelled: workflow cancelled")
@@ -219,14 +221,24 @@ class FlowEngine:
219
221
  provider=provider_name,
220
222
  model=model,
221
223
  params=provider_params(env),
224
+ extensions=extensions,
225
+ trust_project=trust_project,
222
226
  )
223
227
  adapter = get_harness(harness_name)
224
228
  if self.exec_fn is aexec:
225
229
  check_credentials(launch, env)
226
230
  provider_name = launch.provider
227
231
  resolved_model = launch.model
232
+ # Pi-only options join the identity only when set, so resume keys of
233
+ # runs recorded before these options existed stay valid.
234
+ pi_options: dict[str, Any] = {}
235
+ if extensions:
236
+ pi_options["extensions"] = list(extensions)
237
+ if not trust_project:
238
+ pi_options["trust_project"] = False
228
239
  index, key, cached, respawning = await self._assign_call(
229
240
  {
241
+ **pi_options,
230
242
  "prompt": prompt,
231
243
  "harness": harness_name,
232
244
  "provider": provider_name,
@@ -377,6 +389,8 @@ class FlowEngine:
377
389
  settings=settings,
378
390
  sandbox=sandbox,
379
391
  output_schema=output_schema,
392
+ extensions=extensions,
393
+ trust_project=trust_project,
380
394
  )
381
395
  exec_result = await self.exec_fn(
382
396
  attempt_launch.command,
@@ -120,6 +120,8 @@ class FlowHost:
120
120
  settings: Any = None,
121
121
  sandbox: Any = None,
122
122
  env: Any = None,
123
+ extensions: Any = None,
124
+ trust_project: Any = True,
123
125
  ) -> Any | None:
124
126
  if self.engine.cancel_event.is_set():
125
127
  raise RuntimeError("FlowCancelled: workflow cancelled")
@@ -184,6 +186,18 @@ class FlowHost:
184
186
  raise TypeError("web_search must be a boolean")
185
187
  if sandbox is not None and not isinstance(sandbox, bool):
186
188
  raise TypeError("sandbox must be a boolean or null")
189
+ if extensions is None:
190
+ extensions = []
191
+ if not isinstance(extensions, list) or not all(
192
+ isinstance(extension, str) and extension for extension in extensions
193
+ ):
194
+ raise TypeError("extensions must be a list of non-empty strings")
195
+ if len(extensions) > 20 or any(
196
+ len(extension) > 4096 for extension in extensions
197
+ ):
198
+ raise ValueError("extensions has too many or too long entries")
199
+ if not isinstance(trust_project, bool):
200
+ raise TypeError("trust_project must be a boolean")
187
201
  if env is not None:
188
202
  if not isinstance(env, dict) or not all(
189
203
  isinstance(key, str) and isinstance(value, str)
@@ -222,4 +236,6 @@ class FlowHost:
222
236
  settings=settings,
223
237
  sandbox=sandbox,
224
238
  env=env,
239
+ extensions=tuple(extensions),
240
+ trust_project=trust_project,
225
241
  )
@@ -70,6 +70,8 @@ class PiHarness(BaseHarness):
70
70
  sandbox: bool | None = None,
71
71
  output_schema: dict | Path | None = None,
72
72
  exec_prefix: Sequence[str] = (),
73
+ extensions: Sequence[str] = (),
74
+ trust_project: bool = True,
73
75
  ) -> str:
74
76
  if sandbox:
75
77
  raise NotImplementedError(
@@ -79,8 +81,6 @@ class PiHarness(BaseHarness):
79
81
  if settings is not None:
80
82
  raise ValueError("harness 'pi' does not support a settings argument")
81
83
 
82
- # cacli runs Pi in externally isolated environments. Trust the project
83
- # so Pi loads repository-local instructions, settings, and resources.
84
84
  parts = [
85
85
  *exec_prefix,
86
86
  "pi",
@@ -88,8 +88,12 @@ class PiHarness(BaseHarness):
88
88
  "json",
89
89
  "--print",
90
90
  "--no-session",
91
- "--approve",
92
91
  ]
92
+ # cacli runs Pi in externally isolated environments, so by default it
93
+ # trusts the project and loads repository-local settings and resources.
94
+ parts.append("--approve" if trust_project else "--no-approve")
95
+ for extension in extensions:
96
+ parts.extend(["-e", extension])
93
97
  if model:
94
98
  parts.extend(["--model", model])
95
99
  if reasoning_effort and reasoning_effort != "auto":
@@ -158,6 +162,8 @@ class PiHarness(BaseHarness):
158
162
  settings: str | None = None,
159
163
  sandbox: bool | None = None,
160
164
  exec_prefix: Sequence[str] = (),
165
+ extensions: Sequence[str] = (),
166
+ trust_project: bool = True,
161
167
  ) -> str:
162
168
  return self.build_command(
163
169
  prompt=prompt,
@@ -165,6 +171,8 @@ class PiHarness(BaseHarness):
165
171
  settings=settings,
166
172
  sandbox=sandbox,
167
173
  exec_prefix=exec_prefix,
174
+ extensions=extensions,
175
+ trust_project=trust_project,
168
176
  )
169
177
 
170
178
  def extract_result_from_json(self, raw_output: str) -> str:
@@ -3,8 +3,10 @@
3
3
  import os
4
4
  from dataclasses import dataclass
5
5
  from pathlib import Path
6
+ from typing import Sequence
6
7
 
7
8
  from cacli.harnesses import get_harness
9
+ from cacli.harnesses.pi import PiHarness
8
10
  from cacli.inference import Credential, PROVIDERS
9
11
  from cacli.types import AgentRunResult, ExecResult, ShellExecFn
10
12
 
@@ -33,8 +35,14 @@ def _build_launch(
33
35
  sandbox: bool | None = None,
34
36
  output_schema: dict | Path | None = None,
35
37
  pr_description: bool = False,
38
+ extensions: Sequence[str] = (),
39
+ trust_project: bool = True,
36
40
  ) -> LaunchSpec:
37
41
  adapter = get_harness(harness)
42
+ if not isinstance(adapter, PiHarness) and (extensions or not trust_project):
43
+ raise ValueError(
44
+ "extensions and trust_project options are supported only by the 'pi' harness"
45
+ )
38
46
  pair = adapter.pairing(provider)
39
47
  catalog = PROVIDERS[pair.provider]
40
48
  supplied = dict(params or {})
@@ -60,6 +68,12 @@ def _build_launch(
60
68
  prefix_parts.extend(["-u", key])
61
69
  prefix_parts.extend(f"{key}={value}" for key, value in env.items())
62
70
  exec_prefix = prefix_parts if len(prefix_parts) > 1 else []
71
+ # Only Pi takes extension and project-trust options; others were rejected above.
72
+ pi_options = (
73
+ {"extensions": extensions, "trust_project": trust_project}
74
+ if isinstance(adapter, PiHarness)
75
+ else {}
76
+ )
63
77
  if pr_description:
64
78
  command = adapter.build_pr_description_command(
65
79
  prompt,
@@ -67,6 +81,7 @@ def _build_launch(
67
81
  settings=settings,
68
82
  sandbox=sandbox,
69
83
  exec_prefix=exec_prefix,
84
+ **pi_options,
70
85
  )
71
86
  else:
72
87
  command = adapter.build_command(
@@ -78,6 +93,7 @@ def _build_launch(
78
93
  sandbox=sandbox,
79
94
  output_schema=output_schema,
80
95
  exec_prefix=exec_prefix,
96
+ **pi_options,
81
97
  )
82
98
  command = adapter.configure_command(pair, command, supplied)
83
99
  credentials = tuple(
@@ -108,6 +124,8 @@ def build_launch(
108
124
  settings: str | None = None,
109
125
  sandbox: bool | None = None,
110
126
  output_schema: dict | Path | None = None,
127
+ extensions: Sequence[str] = (),
128
+ trust_project: bool = True,
111
129
  ) -> LaunchSpec:
112
130
  return _build_launch(
113
131
  harness,
@@ -120,6 +138,8 @@ def build_launch(
120
138
  settings=settings,
121
139
  sandbox=sandbox,
122
140
  output_schema=output_schema,
141
+ extensions=extensions,
142
+ trust_project=trust_project,
123
143
  )
124
144
 
125
145
 
@@ -132,6 +152,8 @@ def build_pr_description_command(
132
152
  params: dict[str, str] | None = None,
133
153
  settings: str | None = None,
134
154
  sandbox: bool | None = None,
155
+ extensions: Sequence[str] = (),
156
+ trust_project: bool = True,
135
157
  ) -> str:
136
158
  """Build a PR description invocation with the same provider selection."""
137
159
  launch = _build_launch(
@@ -142,6 +164,8 @@ def build_pr_description_command(
142
164
  params=params,
143
165
  settings=settings,
144
166
  sandbox=sandbox,
167
+ extensions=extensions,
168
+ trust_project=trust_project,
145
169
  pr_description=True,
146
170
  )
147
171
  return launch.command
@@ -184,6 +208,8 @@ def run_agent(
184
208
  cwd: str = ".",
185
209
  timeout: int = 3600,
186
210
  env: dict[str, str] | None = None,
211
+ extensions: Sequence[str] = (),
212
+ trust_project: bool = True,
187
213
  ) -> AgentRunResult:
188
214
  launch = build_launch(
189
215
  harness,
@@ -196,6 +222,8 @@ def run_agent(
196
222
  settings=settings,
197
223
  sandbox=sandbox,
198
224
  output_schema=output_schema,
225
+ extensions=extensions,
226
+ trust_project=trust_project,
199
227
  )
200
228
  exec_result: ExecResult = exec_fn(launch.command, cwd, timeout, env)
201
229
  result = get_harness(harness).parse_output(exec_result.stdout)
@@ -47,6 +47,8 @@ def spawn_agent(args) -> None:
47
47
  web_search=getattr(args, "web_search", True),
48
48
  settings=getattr(args, "settings", None),
49
49
  sandbox=getattr(args, "sandbox", None),
50
+ extensions=getattr(args, "extensions", ()),
51
+ trust_project=getattr(args, "trust_project", True),
50
52
  )
51
53
 
52
54
  check_credentials(launch)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cacli
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Harness and provider CLI for running coding agents
5
5
  Author: Benjamin Anderson
6
6
  License-Expression: MIT
@@ -690,3 +690,44 @@ def test_flow_journal_records_harness_and_provider(tmp_path, fake_provider):
690
690
  entry["harness"] == "fake" and entry["provider"] == "openai-api"
691
691
  for entry in entries
692
692
  )
693
+
694
+
695
+ def test_pi_flow_agent_passes_extensions_and_project_trust(tmp_path):
696
+ commands = []
697
+
698
+ async def pi_exec(command, *args, **kwargs):
699
+ commands.append(command)
700
+ message = {
701
+ "role": "assistant",
702
+ "content": [{"type": "text", "text": "done"}],
703
+ "stopReason": "stop",
704
+ }
705
+ return AsyncExecResult(
706
+ 0, json.dumps({"type": "message_end", "message": message})
707
+ )
708
+
709
+ source = (
710
+ "async def main():\n"
711
+ ' return await agent("test", harness="pi", provider="claude-api",\n'
712
+ ' extensions=["/opt/guardian.ts"], trust_project=False)\n'
713
+ )
714
+ outcome = run(
715
+ run_flow(
716
+ write_flow(tmp_path, source),
717
+ runs_root=tmp_path / "runs",
718
+ engine_options={"exec_fn": pi_exec},
719
+ )
720
+ )
721
+ assert outcome.result == "done"
722
+ parts = shlex.split(commands[0])
723
+ assert "--no-approve" in parts and "--approve" not in parts
724
+ assert parts[parts.index("-e") + 1] == "/opt/guardian.ts"
725
+
726
+
727
+ def test_flow_agent_rejects_invalid_extensions(tmp_path):
728
+ source = (
729
+ "async def main():\n"
730
+ ' return await agent("test", harness="pi", extensions="/opt/guardian.ts")\n'
731
+ )
732
+ with pytest.raises(Exception, match="extensions must be a list"):
733
+ run(run_flow(write_flow(tmp_path, source), runs_root=tmp_path / "runs"))
@@ -1,12 +1,13 @@
1
1
  """Harness/provider pairings and non-secret launch plans."""
2
2
 
3
3
  import shlex
4
+ import sys
4
5
  from dataclasses import asdict
5
6
 
6
7
  import pytest
7
8
 
8
- from cacli import build_launch, get_harness, list_harnesses
9
- from cacli.cli import check_credentials
9
+ from cacli import ExecResult, build_launch, get_harness, list_harnesses, run_agent
10
+ from cacli.cli import check_credentials, main
10
11
  from cacli.inference import PROVIDERS, provider_params
11
12
 
12
13
 
@@ -153,6 +154,24 @@ def test_pr_description_uses_pairing_and_env_prefix():
153
154
  assert "model_providers.openai_api.wire_api=responses" in codex
154
155
 
155
156
 
157
+ def test_pi_launch_options_and_non_pi_rejection():
158
+ from cacli import build_launch
159
+
160
+ launch = build_launch(
161
+ "pi",
162
+ "hello",
163
+ params={"account_id": "account"},
164
+ extensions=("/tmp/guardian extension.ts", "/tmp/extra.ts"),
165
+ trust_project=False,
166
+ )
167
+ assert "--no-approve -e '" in launch.command
168
+ assert "-e '/tmp/guardian extension.ts' -e /tmp/extra.ts" in launch.command
169
+ with pytest.raises(ValueError, match="supported only by the 'pi' harness"):
170
+ build_launch("codex", "hello", extensions=("extension.ts",))
171
+ with pytest.raises(ValueError, match="supported only by the 'pi' harness"):
172
+ build_launch("codex", "hello", trust_project=False)
173
+
174
+
156
175
  def test_cli_rejects_missing_credential_without_printing_value(monkeypatch, capsys):
157
176
  import sys
158
177
  from cacli.cli import main
@@ -282,3 +301,47 @@ def test_provider_params_reads_every_param(monkeypatch):
282
301
  "account_id": "",
283
302
  "azure_host": "https://res.openai.azure.com/",
284
303
  }
304
+
305
+
306
+ def test_cli_and_run_agent_pass_pi_launch_options(monkeypatch, capsys):
307
+ monkeypatch.setenv("CLOUDFLARE_ACCOUNT_ID", "account")
308
+ monkeypatch.setattr(
309
+ sys,
310
+ "argv",
311
+ [
312
+ "cacli",
313
+ "run",
314
+ "hello",
315
+ "--harness",
316
+ "pi",
317
+ "--extension",
318
+ "/opt/a.ts",
319
+ "--extension",
320
+ "/opt/b.ts",
321
+ "--no-trust-project",
322
+ "--command-only",
323
+ ],
324
+ )
325
+ main()
326
+ parts = shlex.split(capsys.readouterr().out)
327
+ assert "--no-approve" in parts and "--approve" not in parts
328
+ assert [parts[i + 1] for i, part in enumerate(parts) if part == "-e"] == [
329
+ "/opt/a.ts",
330
+ "/opt/b.ts",
331
+ ]
332
+
333
+ seen = []
334
+
335
+ def fake_exec(command, cwd, timeout, env):
336
+ seen.append(command)
337
+ return ExecResult(0, "", "")
338
+
339
+ run_agent(
340
+ "pi",
341
+ "hello",
342
+ fake_exec,
343
+ params={"account_id": "account"},
344
+ extensions=("/opt/a.ts",),
345
+ trust_project=False,
346
+ )
347
+ assert "--no-approve -e /opt/a.ts" in seen[0]
@@ -78,6 +78,48 @@ def test_build_command_omits_optional_model_and_auto_thinking():
78
78
  assert "--thinking" not in parts
79
79
 
80
80
 
81
+ def test_build_command_loads_extensions_in_order_and_can_disable_project_trust():
82
+ command = PiHarness().build_command(
83
+ "hello",
84
+ extensions=("/tmp/first extension.ts", "/tmp/second.ts"),
85
+ trust_project=False,
86
+ )
87
+ parts = shlex.split(command)
88
+
89
+ assert parts[parts.index("--no-approve")] == "--no-approve"
90
+ assert "--approve" not in parts
91
+ assert parts[parts.index("--no-approve") + 1 :] == [
92
+ "-e",
93
+ "/tmp/first extension.ts",
94
+ "-e",
95
+ "/tmp/second.ts",
96
+ ]
97
+
98
+
99
+ def test_build_command_defaults_match_approved_command():
100
+ assert PiHarness().build_command("hello") == (
101
+ "printf '%s' hello | pi --mode json --print --no-session --approve"
102
+ )
103
+
104
+
105
+ def test_pr_description_command_honors_extensions_and_project_trust():
106
+ from cacli import build_pr_description_command
107
+
108
+ command = build_pr_description_command(
109
+ "pi",
110
+ "hello",
111
+ params={"account_id": "account"},
112
+ extensions=("/tmp/guardian extension.ts", "/tmp/other.ts"),
113
+ trust_project=False,
114
+ )
115
+ parts = shlex.split(command)
116
+
117
+ assert "--no-approve" in parts
118
+ assert "--approve" not in parts
119
+ assert parts[parts.index("-e") + 1] == "/tmp/guardian extension.ts"
120
+ assert parts[parts.index("-e", parts.index("-e") + 1) + 1] == "/tmp/other.ts"
121
+
122
+
81
123
  def test_build_command_rejects_internal_sandbox_and_settings():
82
124
  provider = PiHarness()
83
125
 
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