pactkit-opencode 4.4.2__py3-none-any.whl → 5.0.3__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.
- pactkit_opencode/deployer.py +142 -118
- {pactkit_opencode-4.4.2.dist-info → pactkit_opencode-5.0.3.dist-info}/METADATA +2 -2
- pactkit_opencode-5.0.3.dist-info/RECORD +9 -0
- pactkit_opencode-4.4.2.dist-info/RECORD +0 -9
- {pactkit_opencode-4.4.2.dist-info → pactkit_opencode-5.0.3.dist-info}/WHEEL +0 -0
- {pactkit_opencode-4.4.2.dist-info → pactkit_opencode-5.0.3.dist-info}/entry_points.txt +0 -0
- {pactkit_opencode-4.4.2.dist-info → pactkit_opencode-5.0.3.dist-info}/top_level.txt +0 -0
pactkit_opencode/deployer.py
CHANGED
|
@@ -29,8 +29,8 @@ from pactkit.generators.deployer import (
|
|
|
29
29
|
_deploy_skills,
|
|
30
30
|
)
|
|
31
31
|
from pactkit.generators.spi import generate_config_if_missing
|
|
32
|
-
from pactkit_opencode import declarations
|
|
33
32
|
from pactkit.utils import atomic_write
|
|
33
|
+
from pactkit_opencode import declarations
|
|
34
34
|
|
|
35
35
|
# All canonical commands deploy. Sprint has a sequential capability fallback.
|
|
36
36
|
OPENCODE_EXCLUDED_COMMANDS: frozenset[str] = frozenset()
|
|
@@ -133,49 +133,74 @@ 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.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
#
|
|
155
|
+
# round18 #1: terminate before ANY global write — including the script-path
|
|
156
|
+
# post-processing that rewrites command files — if a component dir or nested
|
|
157
|
+
# entry escapes into a project.
|
|
158
|
+
if not project_only:
|
|
159
|
+
from pactkit.deploy_shared import assert_global_component_boundary
|
|
160
|
+
from pactkit.generators.deployer import _mkdir_within
|
|
161
|
+
|
|
162
|
+
assert_global_component_boundary(opencode_root, extra_dirs=("plugins",))
|
|
163
|
+
|
|
164
|
+
# Prepare directories (global components only; project-only integration
|
|
165
|
+
# writes no machine-global OpenCode state).
|
|
156
166
|
agents_dir = opencode_root / "agents"
|
|
157
167
|
skills_dir = opencode_root / "skills"
|
|
158
168
|
commands_dir = opencode_root / "commands"
|
|
159
169
|
rules_dir = opencode_root / "rules"
|
|
160
170
|
|
|
161
|
-
|
|
162
|
-
d
|
|
171
|
+
if not project_only:
|
|
172
|
+
for d in [opencode_root, agents_dir, skills_dir, commands_dir, rules_dir]:
|
|
173
|
+
_mkdir_within(opencode_root, d)
|
|
163
174
|
|
|
164
|
-
# STORY-slim-008 R1+R2: Load config from project-level pactkit.yaml
|
|
175
|
+
# STORY-slim-008 R1+R2: Load config from project-level pactkit.yaml.
|
|
176
|
+
# A global-only deployment never reads the project (Core supplies cfg).
|
|
165
177
|
from pactkit.config import find_pactkit_yaml
|
|
166
178
|
|
|
167
|
-
|
|
179
|
+
if global_only:
|
|
180
|
+
project_yaml = None
|
|
181
|
+
elif project_only:
|
|
182
|
+
# Review A#1: integration is scoped to the target project — never walk
|
|
183
|
+
# up to an outer project's YAML. Imported here so a global-only deploy
|
|
184
|
+
# never needs the integration API (round4 #4).
|
|
185
|
+
from pactkit.config import resolve_integration_config
|
|
186
|
+
|
|
187
|
+
_scoped_cfg, project_yaml = resolve_integration_config(project_root, format="opencode")
|
|
188
|
+
if config is None:
|
|
189
|
+
config = _scoped_cfg
|
|
190
|
+
else:
|
|
191
|
+
project_yaml = find_pactkit_yaml(project_root)
|
|
168
192
|
|
|
169
193
|
if config is not None:
|
|
170
194
|
cfg = config
|
|
171
|
-
elif project_yaml is not None:
|
|
195
|
+
elif project_yaml is not None and project_yaml.is_file():
|
|
172
196
|
auto_added = auto_merge_config_file(project_yaml)
|
|
173
197
|
for item in auto_added:
|
|
174
198
|
print(f" -> Auto-added: {item}")
|
|
175
199
|
cfg = load_config(project_yaml)
|
|
176
200
|
else:
|
|
177
201
|
cfg = {}
|
|
178
|
-
|
|
202
|
+
if not global_only:
|
|
203
|
+
cfg = activate_pactkit_maintainer_overlay(cfg, project_root)
|
|
179
204
|
|
|
180
205
|
enabled_agents = cfg.get("agents", sorted(VALID_AGENTS))
|
|
181
206
|
enabled_skills = cfg.get("skills", sorted(VALID_SKILLS))
|
|
@@ -185,121 +210,108 @@ class OpenCodeDeployer(DeployerBase):
|
|
|
185
210
|
# Apply explicit format exclusions (currently none).
|
|
186
211
|
enabled_commands = [c for c in enabled_commands if c not in OPENCODE_EXCLUDED_COMMANDS]
|
|
187
212
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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(),
|
|
213
|
+
n_skills = n_commands = n_agents = n_plugins = 0
|
|
214
|
+
if not project_only:
|
|
215
|
+
# Deploy embedded skills (pactkit-board, pactkit-visualize, etc.)
|
|
216
|
+
# round21 #2: CLI-to-script conversion happens INSIDE _deploy_skills
|
|
217
|
+
# (content_transform) BEFORE the ownership check, so a user-edited skill
|
|
218
|
+
# is preserved against the final content — not rewritten by a post-pass.
|
|
219
|
+
n_skills = _deploy_skills(
|
|
220
|
+
skills_dir,
|
|
221
|
+
enabled_skills,
|
|
222
|
+
profile=self.profile,
|
|
223
|
+
content_transform=_replace_cli_with_scripts,
|
|
221
224
|
)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
225
|
+
_cleanup_legacy_portable_methods(skills_dir, self.profile)
|
|
226
|
+
_cleanup_legacy(skills_dir)
|
|
227
|
+
# Clean up legacy command skills from skills/ directory (migrated to commands/)
|
|
228
|
+
self._cleanup_command_skills(skills_dir)
|
|
229
|
+
|
|
230
|
+
# round22 #2: ownership is recorded ONLY at the final manifest commit
|
|
231
|
+
# (write_deploy_manifest below), never mid-deploy by directory/file name.
|
|
232
|
+
# An early record_deployed_file glob claimed the on-disk bytes of a
|
|
233
|
+
# user-edited SKILL.md that preserve_or_write had just PRESERVED (writing
|
|
234
|
+
# a .pactkit-new candidate). If the gate-plugin write then failed, the
|
|
235
|
+
# final manifest never ran to exclude it, so the poisoned record survived
|
|
236
|
+
# and the next retry overwrote the user's original. pactkit_owned_files
|
|
237
|
+
# already skips any artifact with a .pactkit-new sibling, so the single
|
|
238
|
+
# final commit records confirmed-written files only.
|
|
239
|
+
|
|
240
|
+
# Deploy commands to commands/ directory (OpenCode uses /command-name to invoke)
|
|
241
|
+
# round20 #2: the CLI-to-script conversion happens INSIDE _deploy_commands
|
|
242
|
+
# (content_transform) BEFORE the ownership check, so a user-edited command
|
|
243
|
+
# file is preserved against the final content — not rewritten by a post-pass.
|
|
244
|
+
n_commands = _deploy_commands(
|
|
245
|
+
commands_dir, enabled_commands, profile=self.profile, config=cfg,
|
|
246
|
+
content_transform=_replace_cli_with_scripts,
|
|
243
247
|
)
|
|
244
248
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
# R4 (2026-09-11 review): retire instruction refs BEFORE _deploy_rules
|
|
250
|
+
# deletes byte-identical legacy files — ref ownership is proven by the
|
|
251
|
+
# referenced file's content, so the files must still exist here.
|
|
252
|
+
providers = self._load_opencode_providers(opencode_root)
|
|
253
|
+
if not providers:
|
|
254
|
+
providers = self._load_opencode_providers(
|
|
255
|
+
Path(self.profile.global_config_dir).expanduser()
|
|
256
|
+
)
|
|
257
|
+
command_models = cfg.get("command_models", {})
|
|
258
|
+
if command_models:
|
|
259
|
+
# Honesty (STORY-slim-202611196170677f83b5): OpenCode requires
|
|
260
|
+
# model+template command entries; model-only routing is not written,
|
|
261
|
+
# so this config is ignored. Say so instead of silently dropping it.
|
|
262
|
+
print(
|
|
263
|
+
" ⚠️ command_models is set but OpenCode does not consume model-only "
|
|
264
|
+
"command routing (its command entries require model+template); "
|
|
265
|
+
"this configuration is not applied."
|
|
266
|
+
)
|
|
267
|
+
self._update_global_opencode_json(
|
|
268
|
+
opencode_root,
|
|
269
|
+
command_models=command_models,
|
|
270
|
+
providers=providers,
|
|
271
|
+
enabled_commands=enabled_commands,
|
|
262
272
|
)
|
|
263
|
-
self._update_global_opencode_json(
|
|
264
|
-
opencode_root,
|
|
265
|
-
command_models=command_models,
|
|
266
|
-
providers=providers,
|
|
267
|
-
enabled_commands=enabled_commands,
|
|
268
|
-
)
|
|
269
273
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
_deploy_rules(opencode_root, enabled_rules, profile=self.profile)
|
|
275
|
+
_deploy_guides(opencode_root, profile=self.profile)
|
|
276
|
+
self._deploy_agents_md_inline(opencode_root)
|
|
273
277
|
|
|
274
|
-
|
|
278
|
+
n_agents = _deploy_agents(agents_dir, enabled_agents, profile=self.profile)
|
|
275
279
|
|
|
276
280
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
if not global_only:
|
|
282
|
+
ci_config = cfg.get("ci", {})
|
|
283
|
+
ci_provider = ci_config.get("provider", "none") if isinstance(ci_config, dict) else "none"
|
|
284
|
+
_deploy_ci(ci_provider, project_root, cfg)
|
|
280
285
|
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
if not project_only:
|
|
287
|
+
import hashlib
|
|
283
288
|
|
|
284
|
-
|
|
289
|
+
from pactkit.deploy_manifest import write_deploy_manifest
|
|
285
290
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
# round13 #2: install the gate plugin BEFORE stamping the manifest
|
|
292
|
+
# complete. If the plugin write fails or is interrupted, the manifest
|
|
293
|
+
# is never stamped current, so `update --if-needed` repairs this Host
|
|
294
|
+
# instead of skipping it and leaving a missing/stale gate.
|
|
295
|
+
n_plugins = self._deploy_gate_plugin(opencode_root)
|
|
296
|
+
|
|
297
|
+
# round14 #2: the plugin ownership lands in the SAME manifest commit as
|
|
298
|
+
# the version + input digest (extra_files), so an interruption between
|
|
299
|
+
# two writes cannot leave the Host stamped current while the plugin is
|
|
300
|
+
# absent from the uninstall inventory.
|
|
301
|
+
extra_files = {}
|
|
302
|
+
if n_plugins:
|
|
303
|
+
plugin_rel = "plugins/pactkit-gate.js"
|
|
304
|
+
extra_files[plugin_rel] = hashlib.sha256(
|
|
305
|
+
(opencode_root / plugin_rel).read_bytes()
|
|
306
|
+
).hexdigest()
|
|
307
|
+
write_deploy_manifest(opencode_root, "opencode", cfg, extra_files=extra_files)
|
|
296
308
|
|
|
297
309
|
print(
|
|
298
310
|
f"\n✅ OpenCode: {n_agents} Agents, {n_skills} Skills, "
|
|
299
311
|
f"{n_commands} Commands, {n_plugins} Gate plugin → {opencode_root}"
|
|
300
312
|
)
|
|
301
313
|
|
|
302
|
-
if target is None:
|
|
314
|
+
if target is None and not global_only:
|
|
303
315
|
self._generate_project_agents_md(project_root)
|
|
304
316
|
self._generate_project_config(project_root)
|
|
305
317
|
|
|
@@ -316,14 +328,26 @@ class OpenCodeDeployer(DeployerBase):
|
|
|
316
328
|
Recorded in the deployment manifest, so `pactkit uninstall` removes it
|
|
317
329
|
with the rest of the owned files — no residue (R4).
|
|
318
330
|
"""
|
|
319
|
-
from pactkit.deploy_manifest import atomic_write
|
|
331
|
+
from pactkit.deploy_manifest import atomic_write
|
|
332
|
+
from pactkit.deploy_shared import project_write_target_or_none
|
|
320
333
|
from pactkit.generators.opencode_plugin import render_plugin_source
|
|
321
334
|
|
|
335
|
+
plugin_rel = "plugins/pactkit-gate.js"
|
|
336
|
+
# round14 #1: a plugins/ dir reached through an escaping symlink would land
|
|
337
|
+
# the global gate plugin inside a project (Story B global boundary). The
|
|
338
|
+
# atomic write only protects the final replace; the parent dir link still
|
|
339
|
+
# decides where the temp and final file land, so check the real path first.
|
|
340
|
+
if project_write_target_or_none(opencode_root, plugin_rel) is None:
|
|
341
|
+
raise ValueError(
|
|
342
|
+
f"{plugin_rel} resolves outside the deploy root {opencode_root} "
|
|
343
|
+
"(symlink escape); refusing to write a global asset into a project"
|
|
344
|
+
)
|
|
322
345
|
plugins_dir = opencode_root / "plugins"
|
|
323
346
|
plugins_dir.mkdir(parents=True, exist_ok=True)
|
|
324
347
|
plugin_path = plugins_dir / "pactkit-gate.js"
|
|
325
348
|
atomic_write(plugin_path, render_plugin_source())
|
|
326
|
-
|
|
349
|
+
# Ownership is recorded by write_deploy_manifest(extra_files=...) in the
|
|
350
|
+
# same commit as the version + digest (round14 #2), not a separate write.
|
|
327
351
|
return 1
|
|
328
352
|
|
|
329
353
|
@staticmethod
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pactkit_opencode/__init__.py,sha256=eUyhW1gUrXXAgcGgPjNm-eddx7rji35WuzncsAqiW5U,934
|
|
2
|
+
pactkit_opencode/declarations.py,sha256=UNPSQZWn9aeZv4cEvyzeT0mztgsMyft_hkoYGA25ceI,9257
|
|
3
|
+
pactkit_opencode/deployer.py,sha256=4nh0SDpcrIb_bMj95lDmRtG8DDejsyzoiz712gQZ5MA,27852
|
|
4
|
+
pactkit_opencode/enforcement.py,sha256=aOaNYU30rF67PfJNSLXubAwJJfw88UbkE1JDDb7XGec,2897
|
|
5
|
+
pactkit_opencode-5.0.3.dist-info/METADATA,sha256=nhrOoF8QGmmOWtv55twew0hX_VWdts_QoaX7vO38HCo,187
|
|
6
|
+
pactkit_opencode-5.0.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
pactkit_opencode-5.0.3.dist-info/entry_points.txt,sha256=By7lE89sPCfucVIOpDRWK2biKi_ZarkCltUidcCAo6Y,65
|
|
8
|
+
pactkit_opencode-5.0.3.dist-info/top_level.txt,sha256=kmFfcuDMNxmyylzdSsieob_DGbBJ43YN1_DOZMIrudA,17
|
|
9
|
+
pactkit_opencode-5.0.3.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pactkit_opencode/__init__.py,sha256=eUyhW1gUrXXAgcGgPjNm-eddx7rji35WuzncsAqiW5U,934
|
|
2
|
-
pactkit_opencode/declarations.py,sha256=UNPSQZWn9aeZv4cEvyzeT0mztgsMyft_hkoYGA25ceI,9257
|
|
3
|
-
pactkit_opencode/deployer.py,sha256=oF4tMbLwt4pQ4XPUzZtn1lQOcoCVVh9PRzqd_9QIj5E,25766
|
|
4
|
-
pactkit_opencode/enforcement.py,sha256=aOaNYU30rF67PfJNSLXubAwJJfw88UbkE1JDDb7XGec,2897
|
|
5
|
-
pactkit_opencode-4.4.2.dist-info/METADATA,sha256=JSBNjcwNw8xLhVJPu4p7S1Ykr2W1DrVCqTxPh3geOiQ,187
|
|
6
|
-
pactkit_opencode-4.4.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
-
pactkit_opencode-4.4.2.dist-info/entry_points.txt,sha256=By7lE89sPCfucVIOpDRWK2biKi_ZarkCltUidcCAo6Y,65
|
|
8
|
-
pactkit_opencode-4.4.2.dist-info/top_level.txt,sha256=kmFfcuDMNxmyylzdSsieob_DGbBJ43YN1_DOZMIrudA,17
|
|
9
|
-
pactkit_opencode-4.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|