py-opencode-wrapper 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
@@ -81,7 +81,12 @@ def build_argv(
81
81
  return cmd
82
82
 
83
83
 
84
- def build_env(run_cfg: RunConfig, base: Mapping[str, str] | None = None) -> dict[str, str]:
84
+ def build_env(
85
+ run_cfg: RunConfig,
86
+ base: Mapping[str, str] | None = None,
87
+ *,
88
+ cwd: str | Path | None = None,
89
+ ) -> dict[str, str]:
85
90
  env = dict(base if base is not None else os.environ)
86
91
  if run_cfg.extra_env:
87
92
  env.update(dict(run_cfg.extra_env))
@@ -90,6 +95,14 @@ def build_env(run_cfg: RunConfig, base: Mapping[str, str] | None = None) -> dict
90
95
  env["OPENCODE_CONFIG_CONTENT"] = content
91
96
  if run_cfg.disable_autoupdate:
92
97
  env["OPENCODE_DISABLE_AUTOUPDATE"] = "1"
98
+ # opencode's `run` cmd resolves the project root as
99
+ # `process.env.PWD ?? process.cwd()` (run.ts:276), and the bash builtin
100
+ # `pwd` reads $PWD too. asyncio.create_subprocess_exec(cwd=...) only
101
+ # chdirs the child; it leaves PWD inherited from the parent shell, which
102
+ # makes opencode operate against the wrong directory. Pin PWD to the
103
+ # resolved workspace so the child sees a consistent cwd.
104
+ if cwd is not None:
105
+ env["PWD"] = str(cwd)
93
106
  return env
94
107
 
95
108
 
@@ -380,8 +393,8 @@ class AsyncOpenCodeClient:
380
393
  validate_config_for_run(run_cfg)
381
394
  bin_path = self.resolved_binary()
382
395
  argv = build_argv(bin_path, prompt, run_cfg)
383
- env = build_env(run_cfg)
384
396
  cwd = str(Path(workspace).expanduser().resolve())
397
+ env = build_env(run_cfg, cwd=cwd)
385
398
 
386
399
  events_acc: list[dict[str, Any]] = []
387
400
  raw_acc: list[str] = []
@@ -436,8 +449,8 @@ class AsyncOpenCodeClient:
436
449
  validate_config_for_run(run_cfg)
437
450
  bin_path = self.resolved_binary()
438
451
  argv = build_argv(bin_path, prompt, run_cfg)
439
- env = build_env(run_cfg)
440
452
  cwd = str(Path(workspace).expanduser().resolve())
453
+ env = build_env(run_cfg, cwd=cwd)
441
454
 
442
455
  events_acc: list[dict[str, Any]] = []
443
456
  raw_acc: list[str] = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: py-opencode-wrapper
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Async Python wrapper for OpenCode CLI (opencode run --format json)
5
5
  Project-URL: Homepage, https://github.com/idailylife/oc_py_wrapper
6
6
  Project-URL: Repository, https://github.com/idailylife/oc_py_wrapper
@@ -104,11 +104,29 @@ Per-call JSON is merged and passed as `OPENCODE_CONFIG_CONTENT` (see [OpenCode c
104
104
  | `permission` | `permission` map (`allow` / `deny`, patterns) |
105
105
  | `mcp` | MCP server definitions |
106
106
  | `tools` | Enable/disable tools (including MCP globs) |
107
+ | `instructions` | Instruction file paths / glob patterns to inject |
107
108
  | `config_overrides` | Any extra top-level config keys to deep-merge |
108
109
 
109
110
  Optional env tuning: `disable_autoupdate=True` sets `OPENCODE_DISABLE_AUTOUPDATE=1`.
110
111
  Note: `ask` is intentionally rejected in subprocess mode (no interactive terminal); use `allow` or `deny`.
111
112
 
113
+ ### User config isolation
114
+
115
+ By default, `RunConfig.inherit_user_config=False` makes each child `opencode`
116
+ process see a sanitized copy of the host's global OpenCode config. The wrapper
117
+ keeps only provider-selection keys (`$schema`, `provider`,
118
+ `disabled_providers`, `enabled_providers`) and drops capability/configuration
119
+ keys such as `mcp`, `agent`, `command`, `tools`, `plugin`, `skills`,
120
+ `instructions`, `permission`, and `model`.
121
+
122
+ This keeps benchmark and orchestration runs reproducible while still allowing
123
+ provider configuration and `opencode auth` credentials to work. Project-level
124
+ config discovered from the workspace is not suppressed.
125
+
126
+ Set `inherit_user_config=True` to restore the legacy behavior of inheriting the
127
+ host OpenCode config as-is. For reproducible runs, pass `model`, `permission`,
128
+ `mcp`, `tools`, and `instructions` explicitly through `RunConfig`.
129
+
112
130
  ## CLI arguments
113
131
 
114
132
  `RunConfig` maps to flags such as `--agent`, `-m`, `-f`, `--attach`, `--title`, etc. Prompt text is appended as the final `opencode run` message argument.
@@ -1,9 +1,9 @@
1
1
  opencode_wrapper/__init__.py,sha256=iCkMcrh7P35jHFq8gH-GKjaKqwnvmOkGCLRfgnb0moE,1013
2
- opencode_wrapper/client.py,sha256=TDDCHCRb2WGk4Pipb2nJLLhWt2nz43wYsreKvSYl9EQ,19003
2
+ opencode_wrapper/client.py,sha256=Ny4pDBV6cToIOn2W7BgCFL1w12KdlVQVCInhddf_Df4,19546
3
3
  opencode_wrapper/config.py,sha256=JraBPkX95GXFoOvn181BRv_8YPvsUDXiZMN1hZWhSf0,7823
4
4
  opencode_wrapper/errors.py,sha256=zaXzzFb6ObdrNlm-PJE_7tbgvMEhoZcbeQVWNHNTkUQ,1168
5
5
  opencode_wrapper/events.py,sha256=PHz04DcB0K0JfIRxgV8GQ3psl7VjQXZ25gIrDCOgAHQ,6478
6
- py_opencode_wrapper-0.2.0.dist-info/METADATA,sha256=Tw2pl9daegsqTvvx0RIciN2idvIhYzVPQIHORVmWoEI,5940
7
- py_opencode_wrapper-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
- py_opencode_wrapper-0.2.0.dist-info/top_level.txt,sha256=8LETj5bPgl1YnB83iOiueuQvGryj3RzaeEQecPVS9Q8,17
9
- py_opencode_wrapper-0.2.0.dist-info/RECORD,,
6
+ py_opencode_wrapper-0.2.1.dist-info/METADATA,sha256=W56IyS4yoBlsSFIIrtsPx0-Ck6AoCCuhmdHiZslRgnE,6884
7
+ py_opencode_wrapper-0.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
+ py_opencode_wrapper-0.2.1.dist-info/top_level.txt,sha256=8LETj5bPgl1YnB83iOiueuQvGryj3RzaeEQecPVS9Q8,17
9
+ py_opencode_wrapper-0.2.1.dist-info/RECORD,,