pactkit-opencode 4.4.2__tar.gz → 5.0.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.
Files changed (36) hide show
  1. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/PKG-INFO +2 -2
  2. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/pyproject.toml +2 -2
  3. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode/deployer.py +122 -114
  4. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode.egg-info/PKG-INFO +2 -2
  5. pactkit_opencode-5.0.0/src/pactkit_opencode.egg-info/requires.txt +1 -0
  6. pactkit_opencode-4.4.2/src/pactkit_opencode.egg-info/requires.txt +0 -1
  7. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/README.md +0 -0
  8. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/setup.cfg +0 -0
  9. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode/__init__.py +0 -0
  10. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode/declarations.py +0 -0
  11. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode/enforcement.py +0 -0
  12. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode.egg-info/SOURCES.txt +0 -0
  13. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode.egg-info/dependency_links.txt +0 -0
  14. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode.egg-info/entry_points.txt +0 -0
  15. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/src/pactkit_opencode.egg-info/top_level.txt +0 -0
  16. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_a1_config_recovery.py +0 -0
  17. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_a2_mcp_retired.py +0 -0
  18. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_bug035_opencode_dual_layer.py +0 -0
  19. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_capability_contract.py +0 -0
  20. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_command_models_honesty.py +0 -0
  21. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_deploy_opencode_parity.py +0 -0
  22. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_gate_plugin_deploy.py +0 -0
  23. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_global_agents_ownership.py +0 -0
  24. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_host_body_snapshot.py +0 -0
  25. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_legacy_agents_migration.py +0 -0
  26. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_opencode_enforcement_channel.py +0 -0
  27. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_profile_contract.py +0 -0
  28. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_step6_self_sufficiency.py +0 -0
  29. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_step8_declaration_search_producer.py +0 -0
  30. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_story069_opencode_format.py +0 -0
  31. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_story070_opencode_compliance.py +0 -0
  32. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_story071_opencode_config_parity.py +0 -0
  33. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_story073_command_model_routing.py +0 -0
  34. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_story_work_units.py +0 -0
  35. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_user_command_scope.py +0 -0
  36. {pactkit_opencode-4.4.2 → pactkit_opencode-5.0.0}/tests/test_wire_format_contract.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-opencode
3
- Version: 4.4.2
3
+ Version: 5.0.0
4
4
  Summary: PactKit adapter for OpenCode IDE
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
7
- Requires-Dist: pactkit<4.5.0,>=4.4.2
7
+ Requires-Dist: pactkit<5.1.0,>=5.0.0
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pactkit-opencode"
7
- version = "4.4.2"
7
+ version = "5.0.0"
8
8
  description = "PactKit adapter for OpenCode IDE"
9
9
  requires-python = ">=3.10"
10
10
  license = "MIT"
11
11
  dependencies = [
12
- "pactkit>=4.4.2,<4.5.0",
12
+ "pactkit>=5.0.0,<5.1.0",
13
13
  ]
14
14
 
15
15
  [project.entry-points."pactkit.deployers"]
@@ -133,38 +133,41 @@ class OpenCodeDeployer(DeployerBase):
133
133
  deployment_claim = declarations.DEPLOYMENT_CLAIM
134
134
  input_translation = declarations.INPUT_TRANSLATION
135
135
 
136
- def deploy(self, config=None, target=None, project_root=None, no_redetect=False):
136
+ def deploy(self, config=None, target=None, project_root=None, no_redetect=False,
137
+ global_only=False, project_only=False):
137
138
  """Deploy PactKit configuration for OpenCode.
138
139
 
139
140
  ``project_root`` is **not** the deploy root: OpenCode installs globally
140
- under ``~/.config/opencode``, and the two MUST NOT be confused. It
141
- names the project whose config, overlay and CI file are read/written —
142
- those used to resolve from the caller's cwd, so ``pactkit -C
143
- <other-project>`` read the wrong project's policy.
144
-
145
- ``no_redetect`` is accepted because the Core dispatcher passes it
146
- alongside ``project_root``; it is a no-op here — this deployer's
147
- stack probe only reads the filesystem and never writes the stack
148
- back into the config.
141
+ under ``~/.config/opencode``, and the two MUST NOT be confused.
142
+
143
+ ``global_only`` (STORY-slim-20261125f4db76f08fc5): a global Host
144
+ deployment must not read or write any project file. ``project_only``
145
+ (R3, ``pactkit integrate``) is the inverse: write only project artifacts,
146
+ never re-deploy the machine-global OpenCode components other projects load.
149
147
  """
148
+ if global_only and project_only:
149
+ raise ValueError("global_only and project_only are mutually exclusive")
150
150
  opencode_root = Path(target) if target else Path.home() / ".config" / "opencode"
151
151
  project_root = Path(project_root) if project_root is not None else Path.cwd()
152
152
 
153
153
  print("🚀 PactKit OpenCode Deployment")
154
154
 
155
- # Prepare directories
155
+ # Prepare directories (global components only; project-only integration
156
+ # writes no machine-global OpenCode state).
156
157
  agents_dir = opencode_root / "agents"
157
158
  skills_dir = opencode_root / "skills"
158
159
  commands_dir = opencode_root / "commands"
159
160
  rules_dir = opencode_root / "rules"
160
161
 
161
- for d in [opencode_root, agents_dir, skills_dir, commands_dir, rules_dir]:
162
- d.mkdir(parents=True, exist_ok=True)
162
+ if not project_only:
163
+ for d in [opencode_root, agents_dir, skills_dir, commands_dir, rules_dir]:
164
+ d.mkdir(parents=True, exist_ok=True)
163
165
 
164
- # STORY-slim-008 R1+R2: Load config from project-level pactkit.yaml
166
+ # STORY-slim-008 R1+R2: Load config from project-level pactkit.yaml.
167
+ # A global-only deployment never reads the project (Core supplies cfg).
165
168
  from pactkit.config import find_pactkit_yaml
166
169
 
167
- project_yaml = find_pactkit_yaml(project_root)
170
+ project_yaml = None if global_only else find_pactkit_yaml(project_root)
168
171
 
169
172
  if config is not None:
170
173
  cfg = config
@@ -175,7 +178,8 @@ class OpenCodeDeployer(DeployerBase):
175
178
  cfg = load_config(project_yaml)
176
179
  else:
177
180
  cfg = {}
178
- cfg = activate_pactkit_maintainer_overlay(cfg, project_root)
181
+ if not global_only:
182
+ cfg = activate_pactkit_maintainer_overlay(cfg, project_root)
179
183
 
180
184
  enabled_agents = cfg.get("agents", sorted(VALID_AGENTS))
181
185
  enabled_skills = cfg.get("skills", sorted(VALID_SKILLS))
@@ -185,121 +189,125 @@ class OpenCodeDeployer(DeployerBase):
185
189
  # Apply explicit format exclusions (currently none).
186
190
  enabled_commands = [c for c in enabled_commands if c not in OPENCODE_EXCLUDED_COMMANDS]
187
191
 
188
- # Deploy embedded skills (pactkit-board, pactkit-visualize, etc.)
189
- n_skills = _deploy_skills(
190
- skills_dir,
191
- enabled_skills,
192
- profile=self.profile,
193
- )
194
- _cleanup_legacy_portable_methods(skills_dir, self.profile)
195
- _cleanup_legacy(skills_dir)
196
- # Clean up legacy command skills from skills/ directory (migrated to commands/)
197
- self._cleanup_command_skills(skills_dir)
198
-
199
- # Apply CLI-to-script replacement ONLY to PactKit-managed skill files
200
- # (STORY-slim-202611239641dc45a9fc): user-created skills stay untouched.
201
- from pactkit.prompts.skills import get_skill_manifest
202
- _skill_names = {s["name"] for s in get_skill_manifest()}
203
- for skill_md in skills_dir.glob("*/SKILL.md"):
204
- if skill_md.parent.name not in _skill_names:
205
- continue
206
- content = skill_md.read_text(encoding="utf-8")
207
- replaced = _replace_cli_with_scripts(content)
208
- if replaced != content:
209
- atomic_write(skill_md, replaced)
210
-
211
- # HOTFIX-slim-20260903d464746b1909: post-pass rewrites deployed bytes in
212
- # place; record the FINAL (transformed) digests or the next deploy cannot
213
- # prove ownership and re-produces .pactkit-new candidates.
214
- from pactkit.deploy_manifest import record_deployed_file
215
-
216
- for skill_md in skills_dir.glob("*/SKILL.md"):
217
- if skill_md.parent.name not in _skill_names:
218
- continue
219
- record_deployed_file(
220
- opencode_root, skill_md.relative_to(opencode_root).as_posix(),
192
+ n_skills = n_commands = n_agents = n_plugins = 0
193
+ if not project_only:
194
+ # Deploy embedded skills (pactkit-board, pactkit-visualize, etc.)
195
+ n_skills = _deploy_skills(
196
+ skills_dir,
197
+ enabled_skills,
198
+ profile=self.profile,
221
199
  )
200
+ _cleanup_legacy_portable_methods(skills_dir, self.profile)
201
+ _cleanup_legacy(skills_dir)
202
+ # Clean up legacy command skills from skills/ directory (migrated to commands/)
203
+ self._cleanup_command_skills(skills_dir)
204
+
205
+ # Apply CLI-to-script replacement ONLY to PactKit-managed skill files
206
+ # (STORY-slim-202611239641dc45a9fc): user-created skills stay untouched.
207
+ from pactkit.prompts.skills import get_skill_manifest
208
+ _skill_names = {s["name"] for s in get_skill_manifest()}
209
+ for skill_md in skills_dir.glob("*/SKILL.md"):
210
+ if skill_md.parent.name not in _skill_names:
211
+ continue
212
+ content = skill_md.read_text(encoding="utf-8")
213
+ replaced = _replace_cli_with_scripts(content)
214
+ if replaced != content:
215
+ atomic_write(skill_md, replaced)
216
+
217
+ # HOTFIX-slim-20260903d464746b1909: post-pass rewrites deployed bytes in
218
+ # place; record the FINAL (transformed) digests or the next deploy cannot
219
+ # prove ownership and re-produces .pactkit-new candidates.
220
+ from pactkit.deploy_manifest import record_deployed_file
221
+
222
+ for skill_md in skills_dir.glob("*/SKILL.md"):
223
+ if skill_md.parent.name not in _skill_names:
224
+ continue
225
+ record_deployed_file(
226
+ opencode_root, skill_md.relative_to(opencode_root).as_posix(),
227
+ )
222
228
 
223
- # Deploy commands to commands/ directory (OpenCode uses /command-name to invoke)
224
- n_commands = _deploy_commands(commands_dir, enabled_commands, profile=self.profile, config=cfg)
225
-
226
- # Apply CLI-to-script replacement ONLY to PactKit-managed command files
227
- # (STORY-slim-202611239641dc45a9fc): user-created commands stay untouched.
228
- from pactkit.prompts.commands import get_deployable_commands
229
- _cmd_catalog = set(get_deployable_commands())
230
- for cmd_md in commands_dir.glob("*.md"):
231
- if cmd_md.name not in _cmd_catalog:
232
- continue
233
- content = cmd_md.read_text(encoding="utf-8")
234
- replaced = _replace_cli_with_scripts(content)
235
- if replaced != content:
236
- atomic_write(cmd_md, replaced)
237
-
238
- for cmd_md in commands_dir.glob("*.md"):
239
- if cmd_md.name not in _cmd_catalog:
240
- continue
241
- record_deployed_file(
242
- opencode_root, cmd_md.relative_to(opencode_root).as_posix(),
243
- )
229
+ # Deploy commands to commands/ directory (OpenCode uses /command-name to invoke)
230
+ n_commands = _deploy_commands(commands_dir, enabled_commands, profile=self.profile, config=cfg)
231
+
232
+ # Apply CLI-to-script replacement ONLY to PactKit-managed command files
233
+ # (STORY-slim-202611239641dc45a9fc): user-created commands stay untouched.
234
+ from pactkit.prompts.commands import get_deployable_commands
235
+ _cmd_catalog = set(get_deployable_commands())
236
+ for cmd_md in commands_dir.glob("*.md"):
237
+ if cmd_md.name not in _cmd_catalog:
238
+ continue
239
+ content = cmd_md.read_text(encoding="utf-8")
240
+ replaced = _replace_cli_with_scripts(content)
241
+ if replaced != content:
242
+ atomic_write(cmd_md, replaced)
243
+
244
+ for cmd_md in commands_dir.glob("*.md"):
245
+ if cmd_md.name not in _cmd_catalog:
246
+ continue
247
+ record_deployed_file(
248
+ opencode_root, cmd_md.relative_to(opencode_root).as_posix(),
249
+ )
244
250
 
245
- # R4 (2026-09-11 review): retire instruction refs BEFORE _deploy_rules
246
- # deletes byte-identical legacy files — ref ownership is proven by the
247
- # referenced file's content, so the files must still exist here.
248
- providers = self._load_opencode_providers(opencode_root)
249
- if not providers:
250
- providers = self._load_opencode_providers(
251
- Path(self.profile.global_config_dir).expanduser()
252
- )
253
- command_models = cfg.get("command_models", {})
254
- if command_models:
255
- # Honesty (STORY-slim-202611196170677f83b5): OpenCode requires
256
- # model+template command entries; model-only routing is not written,
257
- # so this config is ignored. Say so instead of silently dropping it.
258
- print(
259
- " ⚠️ command_models is set but OpenCode does not consume model-only "
260
- "command routing (its command entries require model+template); "
261
- "this configuration is not applied."
251
+ # R4 (2026-09-11 review): retire instruction refs BEFORE _deploy_rules
252
+ # deletes byte-identical legacy files — ref ownership is proven by the
253
+ # referenced file's content, so the files must still exist here.
254
+ providers = self._load_opencode_providers(opencode_root)
255
+ if not providers:
256
+ providers = self._load_opencode_providers(
257
+ Path(self.profile.global_config_dir).expanduser()
258
+ )
259
+ command_models = cfg.get("command_models", {})
260
+ if command_models:
261
+ # Honesty (STORY-slim-202611196170677f83b5): OpenCode requires
262
+ # model+template command entries; model-only routing is not written,
263
+ # so this config is ignored. Say so instead of silently dropping it.
264
+ print(
265
+ " ⚠️ command_models is set but OpenCode does not consume model-only "
266
+ "command routing (its command entries require model+template); "
267
+ "this configuration is not applied."
268
+ )
269
+ self._update_global_opencode_json(
270
+ opencode_root,
271
+ command_models=command_models,
272
+ providers=providers,
273
+ enabled_commands=enabled_commands,
262
274
  )
263
- self._update_global_opencode_json(
264
- opencode_root,
265
- command_models=command_models,
266
- providers=providers,
267
- enabled_commands=enabled_commands,
268
- )
269
275
 
270
- _deploy_rules(opencode_root, enabled_rules, profile=self.profile)
271
- _deploy_guides(opencode_root, profile=self.profile)
272
- self._deploy_agents_md_inline(opencode_root)
276
+ _deploy_rules(opencode_root, enabled_rules, profile=self.profile)
277
+ _deploy_guides(opencode_root, profile=self.profile)
278
+ self._deploy_agents_md_inline(opencode_root)
273
279
 
274
- n_agents = _deploy_agents(agents_dir, enabled_agents, profile=self.profile)
280
+ n_agents = _deploy_agents(agents_dir, enabled_agents, profile=self.profile)
275
281
 
276
282
 
277
- ci_config = cfg.get("ci", {})
278
- ci_provider = ci_config.get("provider", "none") if isinstance(ci_config, dict) else "none"
279
- _deploy_ci(ci_provider, project_root, cfg)
283
+ if not global_only:
284
+ ci_config = cfg.get("ci", {})
285
+ ci_provider = ci_config.get("provider", "none") if isinstance(ci_config, dict) else "none"
286
+ _deploy_ci(ci_provider, project_root, cfg)
280
287
 
281
- # STORY-slim-139 R2: machine-readable deployment manifest
282
- from pactkit.deploy_manifest import write_deploy_manifest
288
+ if not project_only:
289
+ # STORY-slim-139 R2: machine-readable deployment manifest
290
+ from pactkit.deploy_manifest import write_deploy_manifest
283
291
 
284
- write_deploy_manifest(opencode_root, "opencode", cfg)
292
+ write_deploy_manifest(opencode_root, "opencode", cfg)
285
293
 
286
- # STORY-slim-20260918dda35a04d01d: the pre-tool gate channel. Deployed
287
- # GLOBALLY (like every other OpenCode asset here), so the plugin sees
288
- # every project on the machine — it activates per project via the
289
- # markers baked into its source, and is inert elsewhere.
290
- #
291
- # MUST run AFTER write_deploy_manifest: that function REBUILDS the
292
- # manifest's `files` map from the declared components, and `plugins/`
293
- # is not one — recording earlier gets silently overwritten, and then
294
- # `pactkit uninstall` leaves the plugin behind as residue (R4).
295
- n_plugins = self._deploy_gate_plugin(opencode_root)
294
+ # STORY-slim-20260918dda35a04d01d: the pre-tool gate channel. Deployed
295
+ # GLOBALLY (like every other OpenCode asset here), so the plugin sees
296
+ # every project on the machine — it activates per project via the
297
+ # markers baked into its source, and is inert elsewhere.
298
+ #
299
+ # MUST run AFTER write_deploy_manifest: that function REBUILDS the
300
+ # manifest's `files` map from the declared components, and `plugins/`
301
+ # is not one — recording earlier gets silently overwritten, and then
302
+ # `pactkit uninstall` leaves the plugin behind as residue (R4).
303
+ n_plugins = self._deploy_gate_plugin(opencode_root)
296
304
 
297
305
  print(
298
306
  f"\n✅ OpenCode: {n_agents} Agents, {n_skills} Skills, "
299
307
  f"{n_commands} Commands, {n_plugins} Gate plugin → {opencode_root}"
300
308
  )
301
309
 
302
- if target is None:
310
+ if target is None and not global_only:
303
311
  self._generate_project_agents_md(project_root)
304
312
  self._generate_project_config(project_root)
305
313
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-opencode
3
- Version: 4.4.2
3
+ Version: 5.0.0
4
4
  Summary: PactKit adapter for OpenCode IDE
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.10
7
- Requires-Dist: pactkit<4.5.0,>=4.4.2
7
+ Requires-Dist: pactkit<5.1.0,>=5.0.0
@@ -0,0 +1 @@
1
+ pactkit<5.1.0,>=5.0.0
@@ -1 +0,0 @@
1
- pactkit<4.5.0,>=4.4.2