pactkit-codex 5.0.0__tar.gz → 5.1.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 (18) hide show
  1. {pactkit_codex-5.0.0/src/pactkit_codex.egg-info → pactkit_codex-5.1.0}/PKG-INFO +3 -3
  2. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/README.md +1 -1
  3. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/pyproject.toml +6 -6
  4. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex/deployer.py +144 -40
  5. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0/src/pactkit_codex.egg-info}/PKG-INFO +3 -3
  6. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex.egg-info/requires.txt +1 -1
  7. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/LICENSE +0 -0
  8. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/setup.cfg +0 -0
  9. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex/__init__.py +0 -0
  10. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex/declarations.py +0 -0
  11. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex/enforcement.py +0 -0
  12. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex.egg-info/SOURCES.txt +0 -0
  13. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex.egg-info/dependency_links.txt +0 -0
  14. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex.egg-info/entry_points.txt +0 -0
  15. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/src/pactkit_codex.egg-info/top_level.txt +0 -0
  16. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/tests/test_capability_contract.py +0 -0
  17. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/tests/test_host_body_snapshot.py +0 -0
  18. {pactkit_codex-5.0.0 → pactkit_codex-5.1.0}/tests/test_profile_contract.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-codex
3
- Version: 5.0.0
3
+ Version: 5.1.0
4
4
  Summary: PactKit adapter for OpenAI Codex CLI
5
5
  Author: Slim
6
6
  License: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
21
21
  Requires-Python: >=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: pactkit<5.1.0,>=5.0.0
24
+ Requires-Dist: pactkit<5.2.0,>=5.1.0
25
25
  Requires-Dist: tomli>=1.1.0; python_version < "3.11"
26
26
  Dynamic: license-file
27
27
 
@@ -37,7 +37,7 @@ Dynamic: license-file
37
37
 
38
38
  **pactkit-codex** brings the [PactKit](https://github.com/pactkit/pactkit) spec-driven development workflow to OpenAI's Codex CLI. It deploys:
39
39
 
40
- - **AGENTS.md** — Global constitution with agent roles and PDCA routing
40
+ - **AGENTS.md** — Managed runtime instructions and opt-in workflow skills; no bundled roles
41
41
  - **Command Skills** — PDCA workflow entries (`$project-plan`, `$project-act`, etc.)
42
42
  - **Skills** — Standalone Python scripts (visualize, board, scaffold)
43
43
  - **Rules** — Modular governance rules loaded on-demand per command
@@ -10,7 +10,7 @@
10
10
 
11
11
  **pactkit-codex** brings the [PactKit](https://github.com/pactkit/pactkit) spec-driven development workflow to OpenAI's Codex CLI. It deploys:
12
12
 
13
- - **AGENTS.md** — Global constitution with agent roles and PDCA routing
13
+ - **AGENTS.md** — Managed runtime instructions and opt-in workflow skills; no bundled roles
14
14
  - **Command Skills** — PDCA workflow entries (`$project-plan`, `$project-act`, etc.)
15
15
  - **Skills** — Standalone Python scripts (visualize, board, scaffold)
16
16
  - **Rules** — Modular governance rules loaded on-demand per command
@@ -4,17 +4,17 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pactkit-codex"
7
- version = "5.0.0"
7
+ version = "5.1.0"
8
8
  description = "PactKit adapter for OpenAI Codex CLI"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
11
11
  requires-python = ">=3.10"
12
12
  dependencies = [
13
- # 2026-10-14: the project-level AGENTS.md write goes through
14
- # `pactkit.managed_docs.upsert_managed_block`, which first ships in
15
- # core 4.1.3. The previous floor (>=4.1.0) allowed a released-core
16
- # combination whose deploy raises ImportError.
17
- "pactkit>=5.0.0,<5.1.0",
13
+ # 2026-11-26 (review round4 #4): project integration imports
14
+ # `pactkit.config.resolve_integration_config`, which first ships in core
15
+ # 5.0.2. The previous floor (>=5.0.0) allowed released core 5.0.0/5.0.1,
16
+ # whose deploy raises ImportError. The floor matches the API's first version.
17
+ "pactkit>=5.1.0,<5.2.0",
18
18
  "tomli>=1.1.0; python_version < '3.11'",
19
19
  ]
20
20
 
@@ -174,17 +174,41 @@ class CodexDeployer(DeployerBase):
174
174
  """
175
175
  if global_only and project_only:
176
176
  raise ValueError("global_only and project_only are mutually exclusive")
177
+ # Protect direct calls and forced installs before any target changes.
178
+ try:
179
+ from pactkit.deploy_manifest import restrict_legacy_role_ownership as _role_ownership # noqa: F401
180
+ except ImportError as exc:
181
+ raise RuntimeError("PactKit Core 5.0.4 or newer is required by the codex adapter") from exc
177
182
  codex_root = Path(target) if target else Path.home() / ".codex"
178
183
  project_root = Path(project_root) if project_root is not None else Path.cwd()
179
184
 
180
185
  print("🚀 PactKit Codex CLI Deployment")
181
186
 
187
+ # round18 #1: terminate before ANY global write (command Skills, references,
188
+ # post-processing) if a component dir or nested entry escapes into a project.
189
+ if not project_only:
190
+ from pactkit.deploy_shared import assert_global_component_boundary
191
+
192
+ assert_global_component_boundary(codex_root)
193
+
182
194
  from pactkit.config import find_pactkit_yaml
183
195
 
184
- project_yaml = None if global_only else find_pactkit_yaml(project_root)
196
+ if global_only:
197
+ project_yaml = None
198
+ elif project_only:
199
+ # Review A#1: integration is scoped to the target project — never walk
200
+ # up to an outer project's YAML. Imported here (not at module top) so a
201
+ # global-only deploy never needs the integration API (round4 #4).
202
+ from pactkit.config import resolve_integration_config
203
+
204
+ _scoped_cfg, project_yaml = resolve_integration_config(project_root, format="codex")
205
+ if config is None:
206
+ config = _scoped_cfg
207
+ else:
208
+ project_yaml = find_pactkit_yaml(project_root)
185
209
  if config is not None:
186
210
  cfg = config
187
- elif project_yaml is not None:
211
+ elif project_yaml is not None and project_yaml.is_file():
188
212
  auto_added = auto_merge_config_file(project_yaml)
189
213
  for item in auto_added:
190
214
  print(f" -> Auto-added: {item}")
@@ -201,7 +225,7 @@ class CodexDeployer(DeployerBase):
201
225
  # A global-only deployment never touches the project, so the rollback
202
226
  # scope must not include project paths either.
203
227
  transaction_root = project_root if (target is None and not global_only) else None
204
- with rollback_paths(self._transaction_paths(codex_root, transaction_root)):
228
+ with rollback_paths(self._transaction_paths(codex_root, transaction_root, project_only=project_only)):
205
229
  # Project-only integration writes NO machine-global Codex components
206
230
  # (R3): integrating a project must not re-select what other projects
207
231
  # load. Only the default mixed path deploys global components.
@@ -262,8 +286,21 @@ class CodexDeployer(DeployerBase):
262
286
  )
263
287
 
264
288
  @staticmethod
265
- def _transaction_paths(codex_root, project_root=None):
266
- """Return the exact Codex paths a deployment may mutate."""
289
+ def _transaction_paths(codex_root, project_root=None, project_only=False):
290
+ """Return the exact Codex paths a deployment may mutate.
291
+
292
+ Review #2: a project-only integration must NOT include machine-global
293
+ Codex paths in its rollback scope — a failed project write would otherwise
294
+ delete/restore ~/.codex files shared by every other project.
295
+ """
296
+ if project_only:
297
+ if project_root is None:
298
+ return ()
299
+ return (
300
+ project_root / "AGENTS.md",
301
+ project_root / ".codex" / "AGENTS.local.md",
302
+ project_root / ".codex" / "pactkit.yaml",
303
+ )
267
304
  from pactkit.portable_methods import get_portable_methods
268
305
  from pactkit.prompts.skills import get_skill_manifest
269
306
 
@@ -297,10 +334,15 @@ class CodexDeployer(DeployerBase):
297
334
  / "phases" / f"{phase}.md"
298
335
  for phase in ("plan", "act", "check", "done")
299
336
  )
337
+ # round26 #4: the shared preserve writer now generates .pactkit-new
338
+ # candidates for plain skills, command SKILL.md and scripts too — not
339
+ # only references/. Snapshot every candidate path so a failed deploy
340
+ # removes newly-created candidates and restores pre-existing ones;
341
+ # residue would otherwise read as a conflict marker and skew later
342
+ # ownership reads (load_previous_hashes excludes candidate-marked paths).
300
343
  skill_files.extend(
301
344
  path.with_suffix(path.suffix + ".pactkit-new")
302
345
  for path in tuple(skill_files)
303
- if "references" in path.parts
304
346
  )
305
347
  skill_files.extend(
306
348
  codex_root / "skills" / "_rules" / "guides" / filename
@@ -750,7 +792,7 @@ class CodexDeployer(DeployerBase):
750
792
  content_bytes = raw_content.encode("utf-8")
751
793
  if len(content_bytes) > MAX_SIZE:
752
794
  import warnings
753
- warnings.warn(f"AGENTS.md exceeds 10KB ({len(content_bytes)} bytes), truncating agent details")
795
+ warnings.warn(f"PactKit-managed AGENTS.md exceeds 10KB ({len(content_bytes)} bytes), truncating instructions")
754
796
  raw_content = _truncate_agents_md(raw_content, MAX_SIZE)
755
797
 
756
798
  _enforce_deploy_integrity(raw_content, profile, "AGENTS.md")
@@ -782,16 +824,12 @@ class CodexDeployer(DeployerBase):
782
824
  if (normalized := normalize_rule_id(rule_id)) is not None
783
825
  }
784
826
  codex_root = skills_dir.parent
785
- previous_hashes = {}
786
- deployment_manifest = codex_root / ".pactkit-deployed.json"
787
- if deployment_manifest.is_file():
788
- try:
789
- payload = json.loads(deployment_manifest.read_text(encoding="utf-8"))
790
- files = payload.get("files", {})
791
- if isinstance(files, dict):
792
- previous_hashes = files
793
- except (OSError, ValueError, TypeError):
794
- pass
827
+ # round25 #2 / round24 #1: conflict-aware ownership read (excludes records
828
+ # beside a .pactkit-new candidate) instead of a raw json read, so a stale
829
+ # old-manifest claim cannot authorize overwriting a preserved original.
830
+ from pactkit.deploy_manifest import load_previous_hashes, preserve_or_write
831
+
832
+ previous_hashes = load_previous_hashes(codex_root)
795
833
  # STORY-slim-20260903a24e1ece0d7f: merged ownership view — the deploy
796
834
  # check previously read only .pactkit-deployed.json (which never carries
797
835
  # reference paths), so every content change produced a .pactkit-new
@@ -952,7 +990,13 @@ class CodexDeployer(DeployerBase):
952
990
  for cmd_name, skill_content in rendered.items():
953
991
  skill_path = skills_dir / cmd_name / "SKILL.md"
954
992
  snapshots[skill_path] = skill_path.read_bytes() if skill_path.is_file() else None
955
- atomic_write(skill_path, skill_content)
993
+ # round25 #2: ownership judgment before overwrite (shared writer).
994
+ # A user-edited command SKILL.md is preserved + candidate, not
995
+ # clobbered; the preview classifies this path as preserve-writer.
996
+ skill_written = preserve_or_write(
997
+ codex_root, skill_path, skill_content,
998
+ ownership_proofs, f"command_skill:{cmd_name}",
999
+ )
956
1000
  for relative, reference_content in references_by_command[cmd_name].items():
957
1001
  reference = skill_path.parent / "references" / relative
958
1002
  snapshots[reference] = (
@@ -1004,13 +1048,28 @@ class CodexDeployer(DeployerBase):
1004
1048
  _enforce_deploy_integrity(
1005
1049
  capsule, profile, f"sprint_phase:{phase}",
1006
1050
  )
1007
- atomic_write(reference, capsule)
1008
- record_deployed_reference(
1009
- manifest_references,
1010
- reference.relative_to(codex_root).as_posix(),
1011
- reference,
1051
+ # round26 #2: phase references go through the same shared
1052
+ # ownership writer as the main SKILL.md. A user-edited
1053
+ # phase file is preserved + candidate, not clobbered in the
1054
+ # same update that preserves the main skill. Only a
1055
+ # confirmed write is recorded in the reference ledger.
1056
+ phase_written = preserve_or_write(
1057
+ codex_root, reference, capsule,
1058
+ ownership_proofs, f"sprint_phase:{phase}",
1012
1059
  )
1013
- record_deployed_command(manifest, cmd_name, skill_path)
1060
+ if phase_written:
1061
+ record_deployed_reference(
1062
+ manifest_references,
1063
+ reference.relative_to(codex_root).as_posix(),
1064
+ reference,
1065
+ )
1066
+ # round25 #2: only a confirmed write may claim ownership. A
1067
+ # preserved user original must not be recorded in the command
1068
+ # ledger — that would authorize the next deploy to overwrite it.
1069
+ if skill_written:
1070
+ record_deployed_command(manifest, cmd_name, skill_path)
1071
+ else:
1072
+ manifest.pop(cmd_name, None)
1014
1073
  deployed += 1
1015
1074
  write_command_manifest(skills_dir, manifest, references=manifest_references)
1016
1075
  except Exception:
@@ -1073,6 +1132,17 @@ class CodexDeployer(DeployerBase):
1073
1132
  if project_root.resolve() == Path.home().resolve():
1074
1133
  return
1075
1134
 
1135
+ # Review round4 #1: refuse an escaping .codex/ symlink before the first
1136
+ # write — AGENTS.md, the local copy, backups and the config YAML must stay
1137
+ # inside the project. Same predicate Core uses for the hook channel.
1138
+ from pactkit.deploy_shared import validate_project_write_boundary
1139
+
1140
+ validate_project_write_boundary(
1141
+ project_root,
1142
+ [".codex", "AGENTS.md", ".codex/AGENTS.local.md", ".codex/pactkit.yaml",
1143
+ ".codex/.pactkit-backups"],
1144
+ )
1145
+
1076
1146
  stack = _detect_stack(project_root)
1077
1147
  project_name = project_root.name
1078
1148
  codex_dir = project_root / ".codex"
@@ -1103,6 +1173,32 @@ class CodexDeployer(DeployerBase):
1103
1173
  # a value Core's own validator rejects — see the classification row.
1104
1174
  generate_config_if_missing(format="codex", project_root=project_root)
1105
1175
 
1176
+ def preserve_writer_paths(self, deploy_root, config=None):
1177
+ """round27 #2: the sprint phase capsules go through the shared
1178
+ preserve_or_write writer (deploy_codex_command_skills), so a directory
1179
+ occupying one is preserved and the deploy continues — not a failure.
1180
+ Core's component enumeration does not know these Host-specific reference
1181
+ paths; the preview must take them from this actual write plan."""
1182
+ paths = super().preserve_writer_paths(deploy_root, config)
1183
+ for phase in ("plan", "act", "check", "done"):
1184
+ paths.add(f"skills/project-sprint/references/phases/{phase}.md")
1185
+ return paths
1186
+
1187
+ def ownership_hashes(self, deploy_root):
1188
+ """round28 #2: the same merged ownership view execution uses
1189
+ (deploy_codex_command_skills): the conflict-aware deployment manifest
1190
+ plus the command-manifest reference table. The preview must judge a
1191
+ phase file's overwrite by this merged proof, not the global manifest
1192
+ alone."""
1193
+ from pactkit.deploy_manifest import load_previous_hashes
1194
+ from pactkit.generators.command_ownership import read_command_references
1195
+
1196
+ deploy_root = Path(deploy_root)
1197
+ return {
1198
+ **load_previous_hashes(deploy_root),
1199
+ **read_command_references(deploy_root / "skills"),
1200
+ }
1201
+
1106
1202
  @staticmethod
1107
1203
  def deploy_codex_skills(skills_dir, enabled_skills, profile):
1108
1204
  """Deploy skills with Codex-specific path replacement in scripts."""
@@ -1111,30 +1207,47 @@ class CodexDeployer(DeployerBase):
1111
1207
  # STORY-slim-139 R4: consume the core SKILL_MANIFEST — no local
1112
1208
  # hardcoded skill list (the old 10-item snapshot silently dropped
1113
1209
  # garden/audit/report when core added them).
1210
+ from pactkit.deploy_manifest import load_previous_hashes, preserve_or_write
1211
+ from pactkit.generators.deployer import _mkdir_within
1114
1212
  from pactkit.prompts.skills import get_skill_manifest
1115
1213
 
1116
1214
  enabled_set = set(enabled_skills)
1117
1215
  deployed = 0
1216
+ deploy_root = skills_dir.parent
1217
+ # round25 #2: ownership judgment BEFORE overwrite — the same shared
1218
+ # writer Core/OpenCode use. A user-edited SKILL.md/script is preserved
1219
+ # with a .pactkit-new candidate instead of clobbered by atomic_write,
1220
+ # which also makes the preview's preserve-writer classification truthful.
1221
+ previous_hashes = load_previous_hashes(deploy_root)
1118
1222
 
1119
1223
  for sd in get_skill_manifest():
1120
1224
  if sd["name"] not in enabled_set:
1121
1225
  continue
1122
1226
  skill_dir = skills_dir / sd["name"]
1123
- skill_dir.mkdir(parents=True, exist_ok=True)
1227
+ # round17 #1: terminate on an escaping nested component dir, before
1228
+ # any create/write (a skills/<name>/ symlink into a project).
1229
+ _mkdir_within(deploy_root, skill_dir)
1124
1230
 
1125
1231
  skill_md = render_skill_md(sd, profile, _prefix)
1126
1232
  skill_md = _replace_cli_with_scripts(skill_md)
1127
1233
  skill_md = CodexDeployer.strip_model_references(skill_md)
1128
1234
  _enforce_deploy_integrity(skill_md, profile, f"skill:{sd['name']}")
1129
- atomic_write(skill_dir / "SKILL.md", skill_md)
1235
+ written = preserve_or_write(
1236
+ deploy_root, skill_dir / "SKILL.md", skill_md,
1237
+ previous_hashes, f"skill:{sd['name']}",
1238
+ )
1130
1239
  if sd["script_name"]:
1131
1240
  scripts_dir = skill_dir / "scripts"
1132
- scripts_dir.mkdir(exist_ok=True)
1241
+ _mkdir_within(deploy_root, scripts_dir)
1133
1242
  script_content = sd["script_source"]
1134
1243
  script_content = script_content.replace("~/.claude/", f"{profile.global_config_dir}/")
1135
1244
  script_content = script_content.replace("~/.config/opencode/", f"{profile.global_config_dir}/")
1136
- atomic_write(scripts_dir / sd["script_name"], script_content)
1137
- deployed += 1
1245
+ preserve_or_write(
1246
+ deploy_root, scripts_dir / sd["script_name"], script_content,
1247
+ previous_hashes, f"skill:{sd['name']} script",
1248
+ )
1249
+ if written:
1250
+ deployed += 1
1138
1251
 
1139
1252
  return deployed
1140
1253
 
@@ -1236,17 +1349,8 @@ def _extract_goal_from_prompt(prompt):
1236
1349
 
1237
1350
 
1238
1351
  def _truncate_agents_md(content, max_bytes):
1239
- """Truncate AGENTS.md to fit within size budget by removing agent details."""
1240
- parts = content.split("## Agent Roles")
1241
- if len(parts) < 2:
1242
- return content[:max_bytes]
1243
- before = parts[0]
1244
- after_parts = parts[1].split("## PDCA Routing Table")
1245
- if len(after_parts) < 2:
1246
- return content[:max_bytes]
1247
- minimal_agents = "\n## Agent Roles\n\nSee agent definitions in skill files.\n\n"
1248
- result = before + minimal_agents + "## PDCA Routing Table" + after_parts[1]
1249
- return result
1352
+ """Trim only the generated block, respecting the host's UTF-8 byte budget."""
1353
+ return content.encode("utf-8")[:max_bytes].decode("utf-8", errors="ignore")
1250
1354
 
1251
1355
 
1252
1356
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pactkit-codex
3
- Version: 5.0.0
3
+ Version: 5.1.0
4
4
  Summary: PactKit adapter for OpenAI Codex CLI
5
5
  Author: Slim
6
6
  License: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
21
21
  Requires-Python: >=3.10
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: pactkit<5.1.0,>=5.0.0
24
+ Requires-Dist: pactkit<5.2.0,>=5.1.0
25
25
  Requires-Dist: tomli>=1.1.0; python_version < "3.11"
26
26
  Dynamic: license-file
27
27
 
@@ -37,7 +37,7 @@ Dynamic: license-file
37
37
 
38
38
  **pactkit-codex** brings the [PactKit](https://github.com/pactkit/pactkit) spec-driven development workflow to OpenAI's Codex CLI. It deploys:
39
39
 
40
- - **AGENTS.md** — Global constitution with agent roles and PDCA routing
40
+ - **AGENTS.md** — Managed runtime instructions and opt-in workflow skills; no bundled roles
41
41
  - **Command Skills** — PDCA workflow entries (`$project-plan`, `$project-act`, etc.)
42
42
  - **Skills** — Standalone Python scripts (visualize, board, scaffold)
43
43
  - **Rules** — Modular governance rules loaded on-demand per command
@@ -1,4 +1,4 @@
1
- pactkit<5.1.0,>=5.0.0
1
+ pactkit<5.2.0,>=5.1.0
2
2
 
3
3
  [:python_version < "3.11"]
4
4
  tomli>=1.1.0
File without changes
File without changes