claudekit-codex-sync 0.1.0

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 (56) hide show
  1. package/AGENTS.md +45 -0
  2. package/README.md +131 -0
  3. package/bin/ck-codex-sync +12 -0
  4. package/bin/ck-codex-sync.js +9 -0
  5. package/docs/code-standards.md +62 -0
  6. package/docs/codebase-summary.md +83 -0
  7. package/docs/codex-vs-claude-agents.md +74 -0
  8. package/docs/installation-guide.md +64 -0
  9. package/docs/project-overview-pdr.md +44 -0
  10. package/docs/project-roadmap.md +51 -0
  11. package/docs/system-architecture.md +106 -0
  12. package/package.json +16 -0
  13. package/plans/260222-2051-claudekit-codex-community-sync/phase-01-productization.md +36 -0
  14. package/plans/260222-2051-claudekit-codex-community-sync/phase-02-core-refactor.md +32 -0
  15. package/plans/260222-2051-claudekit-codex-community-sync/phase-03-agent-transpiler.md +33 -0
  16. package/plans/260222-2051-claudekit-codex-community-sync/phase-04-parity-harness.md +43 -0
  17. package/plans/260222-2051-claudekit-codex-community-sync/phase-05-distribution-npm.md +35 -0
  18. package/plans/260222-2051-claudekit-codex-community-sync/phase-06-git-clone-docs.md +28 -0
  19. package/plans/260222-2051-claudekit-codex-community-sync/phase-07-qa-release.md +35 -0
  20. package/plans/260222-2051-claudekit-codex-community-sync/plan.md +99 -0
  21. package/plans/260223-0951-refactor-and-upgrade/phase-01-project-structure.md +79 -0
  22. package/plans/260223-0951-refactor-and-upgrade/phase-02-extract-templates.md +36 -0
  23. package/plans/260223-0951-refactor-and-upgrade/phase-03-modularize-python.md +107 -0
  24. package/plans/260223-0951-refactor-and-upgrade/phase-04-live-source-detection.md +76 -0
  25. package/plans/260223-0951-refactor-and-upgrade/phase-05-agent-toml-config.md +88 -0
  26. package/plans/260223-0951-refactor-and-upgrade/phase-06-backup-registry.md +58 -0
  27. package/plans/260223-0951-refactor-and-upgrade/phase-07-tests-docs-push.md +54 -0
  28. package/plans/260223-0951-refactor-and-upgrade/plan.md +72 -0
  29. package/reports/brainstorm-260222-2051-claudekit-codex-community-sync.md +113 -0
  30. package/scripts/bootstrap-claudekit-skill-scripts.sh +150 -0
  31. package/scripts/claudekit-sync-all.py +1150 -0
  32. package/scripts/export-claudekit-prompts.sh +221 -0
  33. package/scripts/normalize-claudekit-for-codex.sh +261 -0
  34. package/src/claudekit_codex_sync/__init__.py +0 -0
  35. package/src/claudekit_codex_sync/asset_sync_dir.py +125 -0
  36. package/src/claudekit_codex_sync/asset_sync_zip.py +140 -0
  37. package/src/claudekit_codex_sync/bridge_generator.py +33 -0
  38. package/src/claudekit_codex_sync/cli.py +199 -0
  39. package/src/claudekit_codex_sync/config_enforcer.py +140 -0
  40. package/src/claudekit_codex_sync/constants.py +104 -0
  41. package/src/claudekit_codex_sync/dep_bootstrapper.py +73 -0
  42. package/src/claudekit_codex_sync/path_normalizer.py +248 -0
  43. package/src/claudekit_codex_sync/prompt_exporter.py +89 -0
  44. package/src/claudekit_codex_sync/runtime_verifier.py +32 -0
  45. package/src/claudekit_codex_sync/source_resolver.py +78 -0
  46. package/src/claudekit_codex_sync/sync_registry.py +77 -0
  47. package/src/claudekit_codex_sync/utils.py +130 -0
  48. package/templates/agents-md.md +45 -0
  49. package/templates/bridge-docs-init.sh +25 -0
  50. package/templates/bridge-project-status.sh +49 -0
  51. package/templates/bridge-resolve-command.py +52 -0
  52. package/templates/bridge-skill.md +63 -0
  53. package/templates/command-map.md +44 -0
  54. package/tests/__init__.py +1 -0
  55. package/tests/test_config_enforcer.py +44 -0
  56. package/tests/test_path_normalizer.py +61 -0
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "claudekit-codex-sync",
3
+ "version": "0.1.0",
4
+ "description": "Sync ClaudeKit skills, agents, and config to Codex CLI",
5
+ "main": "bin/ck-codex-sync.js",
6
+ "bin": {
7
+ "ck-codex-sync": "bin/ck-codex-sync.js"
8
+ },
9
+ "scripts": {
10
+ "sync": "python3 src/claudekit_codex_sync/cli.py",
11
+ "test": "python3 -m pytest tests/",
12
+ "lint": "python3 -m py_compile src/claudekit_codex_sync/*.py"
13
+ },
14
+ "keywords": ["claudekit", "codex", "sync", "skills"],
15
+ "license": "MIT"
16
+ }
@@ -0,0 +1,36 @@
1
+ # Phase 01: Productization Baseline
2
+
3
+ ## Goal
4
+ Turn current private script set into a repository-grade project layout ready for public collaboration.
5
+
6
+ ## Tasks
7
+ 1. Define repository structure (`packages`, `scripts`, `docs`, `fixtures`, `tests`).
8
+ 2. Add base metadata:
9
+ - `README.md`
10
+ - `LICENSE`
11
+ - `CONTRIBUTING.md`
12
+ - `SECURITY.md`
13
+ - `CODE_OF_CONDUCT.md`
14
+ 3. Add configuration conventions:
15
+ - `.editorconfig`
16
+ - `.gitignore`
17
+ - formatting/lint standards
18
+ 4. Define support matrix doc:
19
+ - OS support
20
+ - Codex version compatibility
21
+ - Python/Node requirements
22
+
23
+ ## Deliverables
24
+ - Public repo skeleton with contribution standards.
25
+ - Clear scope and support boundaries.
26
+
27
+ ## Acceptance Criteria
28
+ - New contributor can clone repo and understand project purpose in <5 minutes.
29
+ - Required project policy files exist and are coherent.
30
+ - Basic local setup instructions are complete and tested once.
31
+
32
+ ## Risks
33
+ - Over-documentation before stable CLI behavior.
34
+
35
+ ## Mitigation
36
+ - Keep docs minimal for v1 and expand only after phase 5.
@@ -0,0 +1,32 @@
1
+ # Phase 02: Core Refactor
2
+
3
+ ## Goal
4
+ Refactor existing `claudekit-sync-all.py` into maintainable modules while preserving behavior.
5
+
6
+ ## Tasks
7
+ 1. Split monolithic script into modules:
8
+ - zip/source discovery
9
+ - asset sync
10
+ - skill sync
11
+ - normalization/patches
12
+ - prompt export
13
+ - verification
14
+ 2. Introduce typed config object and explicit defaults.
15
+ 3. Add stable machine-readable output mode (`--json`).
16
+ 4. Preserve existing flags and backward compatibility behavior.
17
+ 5. Add regression tests against current fixture zip.
18
+
19
+ ## Deliverables
20
+ - Modular core package with testable units.
21
+ - No functional regressions versus current script baseline.
22
+
23
+ ## Acceptance Criteria
24
+ - Existing command scenarios produce equivalent outputs (except intentional formatting changes).
25
+ - Unit tests cover critical branches (zip selection, exclusion rules, manifests, idempotency).
26
+ - Re-run idempotency verified on fixture workspace.
27
+
28
+ ## Risks
29
+ - Refactor introduces hidden behavior drift.
30
+
31
+ ## Mitigation
32
+ - Snapshot-based regression assertions before/after refactor.
@@ -0,0 +1,33 @@
1
+ # Phase 03: Agent Transpiler
2
+
3
+ ## Goal
4
+ Convert Claude agent definitions into Codex-compatible role config with predictable behavior.
5
+
6
+ ## Tasks
7
+ 1. Parse `~/.claude/agents/*.md` frontmatter + body.
8
+ 2. Build normalization pipeline:
9
+ - path remap (`.claude` -> `.codex` equivalents)
10
+ - remove/translate Claude-only tool semantics
11
+ - preserve behavioral intent in `developer_instructions`
12
+ 3. Generate Codex role artifacts:
13
+ - `[agents.<role>]` in config
14
+ - `~/.codex/agents/<role>.toml`
15
+ 4. Support modes:
16
+ - default prefixed roles (`ck-*`)
17
+ - optional built-in override mode
18
+ 5. Add dry-run diff report for generated roles.
19
+
20
+ ## Deliverables
21
+ - Deterministic agent transpilation command.
22
+ - Compatibility layer from Claude role semantics to Codex role semantics.
23
+
24
+ ## Acceptance Criteria
25
+ - Generated role files pass TOML parse and Codex config validation.
26
+ - Default mode does not override `default/worker/explorer` unexpectedly.
27
+ - At least 10 common Claude agents transpiled without fatal errors.
28
+
29
+ ## Risks
30
+ - Literal translation can create noisy or invalid instructions.
31
+
32
+ ## Mitigation
33
+ - Rule-based sanitizer + max-size bounds + warning report for unsupported directives.
@@ -0,0 +1,43 @@
1
+ # Phase 04: Parity Benchmark Harness
2
+
3
+ ## Goal
4
+ Provide objective evidence for "near-similar behavior" between Claude flow and Codex transpiled flow.
5
+
6
+ ## Tasks
7
+ 1. Define benchmark suite (20-30 scenarios):
8
+ - planning
9
+ - code review
10
+ - bug debug
11
+ - docs update
12
+ - research orchestration
13
+ 2. Define scoring rubric:
14
+ - task success
15
+ - artifact completeness
16
+ - policy compliance
17
+ - orchestration quality
18
+ - severity-weighted output quality
19
+ 3. Implement benchmark runner:
20
+ - fixture setup
21
+ - command execution
22
+ - result collection
23
+ - score aggregation
24
+ 4. Add report outputs:
25
+ - JSON raw results
26
+ - Markdown summary
27
+ - trend comparison across versions
28
+ 5. Add fail threshold gates for CI (`--min-parity`).
29
+
30
+ ## Deliverables
31
+ - Reproducible parity suite and scorer.
32
+ - Public benchmark report format.
33
+
34
+ ## Acceptance Criteria
35
+ - Single command runs full suite and outputs machine-readable report.
36
+ - Score reproducibility within acceptable variance window.
37
+ - Threshold gate blocks release when parity score is below target.
38
+
39
+ ## Risks
40
+ - Benchmark bias or non-determinism.
41
+
42
+ ## Mitigation
43
+ - Freeze fixtures, pin prompts, repeat-run averaging, and publish methodology.
@@ -0,0 +1,35 @@
1
+ # Phase 05: NPM Distribution
2
+
3
+ ## Goal
4
+ Ship a clean npm user experience without rewriting core logic.
5
+
6
+ ## Tasks
7
+ 1. Create Node CLI wrapper package:
8
+ - preflight checks (`python3`, `codex` availability)
9
+ - argument passthrough
10
+ - error mapping with actionable remediation
11
+ 2. Commands:
12
+ - `sync`
13
+ - `transpile-agents`
14
+ - `benchmark`
15
+ - `verify`
16
+ 3. Add npm metadata:
17
+ - bin entry
18
+ - semver strategy
19
+ - changelog generation
20
+ 4. Add smoke tests for `npx` path on Linux/macOS/WSL.
21
+
22
+ ## Deliverables
23
+ - Installable npm package runnable via `npx`.
24
+ - CLI docs with examples.
25
+
26
+ ## Acceptance Criteria
27
+ - `npx <package> sync --help` works on supported environments.
28
+ - Wrapper cleanly forwards exit codes from core engine.
29
+ - Common failure modes have clear remediation text.
30
+
31
+ ## Risks
32
+ - Python missing in user environment.
33
+
34
+ ## Mitigation
35
+ - Preflight + auto-detected install hints per OS.
@@ -0,0 +1,28 @@
1
+ # Phase 06: Git-Clone Workflow and Docs
2
+
3
+ ## Goal
4
+ Ensure users who prefer direct clone can run the toolkit with zero ambiguity.
5
+
6
+ ## Tasks
7
+ 1. Add `scripts/install.sh` and `scripts/install.ps1` for bootstrap.
8
+ 2. Add one-command usage examples for:
9
+ - latest zip auto-sync
10
+ - explicit zip path
11
+ - global vs workspace scope
12
+ - dry-run and rollback flow
13
+ 3. Add migration guide from private script path to community repo CLI.
14
+ 4. Add troubleshooting section for common environment issues.
15
+
16
+ ## Deliverables
17
+ - Git-clone installation path fully documented.
18
+ - Copy/paste-ready command docs for common workflows.
19
+
20
+ ## Acceptance Criteria
21
+ - Fresh machine can clone and run sync in <=10 minutes using docs only.
22
+ - Troubleshooting covers top 10 expected errors.
23
+
24
+ ## Risks
25
+ - Docs drift from implementation.
26
+
27
+ ## Mitigation
28
+ - Add docs validation checklist in release process.
@@ -0,0 +1,35 @@
1
+ # Phase 07: QA, CI, and Release
2
+
3
+ ## Goal
4
+ Ship safely with repeatable quality gates and predictable releases.
5
+
6
+ ## Tasks
7
+ 1. CI matrix:
8
+ - Ubuntu
9
+ - macOS
10
+ - WSL smoke runner (if available)
11
+ 2. Test pipeline:
12
+ - unit
13
+ - integration
14
+ - parity benchmark threshold gate
15
+ 3. Release pipeline:
16
+ - semantic versioning
17
+ - changelog generation
18
+ - npm publish
19
+ - git tag/release notes
20
+ 4. Add compatibility matrix and deprecation policy.
21
+
22
+ ## Deliverables
23
+ - Automated CI + release workflow.
24
+ - Stable release quality bars documented and enforced.
25
+
26
+ ## Acceptance Criteria
27
+ - Release candidate fails if parity below threshold.
28
+ - Tagged release publishes npm package and changelog.
29
+ - Rollback procedure validated once.
30
+
31
+ ## Risks
32
+ - Flaky parity tests block releases.
33
+
34
+ ## Mitigation
35
+ - Separate flaky detector and quarantine process; keep stable core gate strict.
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: "ClaudeKit Codex Community Toolkit"
3
+ description: "Productize sync scripts for npm + git clone and add parity proof between Claude and Codex workflows"
4
+ status: pending
5
+ priority: P1
6
+ effort: 5d
7
+ branch: local/home-vinhawk
8
+ tags: [feature, tooling, codex, claudekit, community]
9
+ created: 2026-02-22
10
+ ---
11
+
12
+ # ClaudeKit Codex Community Toolkit
13
+
14
+ ## Summary
15
+ Build a community-ready toolkit that syncs ClaudeKit -> Codex with full automation, supports npm and git-clone distribution, and includes measurable parity testing to support "near-similar behavior" claims.
16
+
17
+ ## Scope
18
+ ### In scope
19
+ - Productize current sync engine into reusable CLI package.
20
+ - Add Claude-agent -> Codex-agent role transpiler.
21
+ - Add parity benchmark harness with reproducible scoring.
22
+ - Publish via npm (`npx`) and git clone workflow.
23
+ - Add docs, CI, release process, compatibility matrix.
24
+
25
+ ### Out of scope (v1)
26
+ - Full TypeScript rewrite of existing Python core.
27
+ - MCP/hooks parity as default behavior.
28
+ - Proprietary cloud telemetry or hosted backend.
29
+
30
+ ## Key Decisions
31
+ 1. Keep Python core for v1 to reduce regression risk.
32
+ 2. Add Node wrapper for npm UX (`npx`).
33
+ 3. Use prefixed roles (`ck-*`) by default to avoid accidental built-in override.
34
+ 4. Prove parity with benchmark metrics, not subjective statements.
35
+ 5. Ship staged releases (`v1` -> `v1.1`) instead of big-bang rewrite.
36
+
37
+ ## Phases
38
+ | Phase | File | Goal | Effort |
39
+ |---|---|---|---|
40
+ | Phase 1 | [phase-01-productization.md](./phase-01-productization.md) | Repo/product baseline and public packaging structure | 0.5d |
41
+ | Phase 2 | [phase-02-core-refactor.md](./phase-02-core-refactor.md) | Refactor current script into maintainable core modules | 1d |
42
+ | Phase 3 | [phase-03-agent-transpiler.md](./phase-03-agent-transpiler.md) | Claude agent definitions -> Codex roles transpilation | 1d |
43
+ | Phase 4 | [phase-04-parity-harness.md](./phase-04-parity-harness.md) | Deterministic benchmark + scoring and reports | 1d |
44
+ | Phase 5 | [phase-05-distribution-npm.md](./phase-05-distribution-npm.md) | npm wrapper, npx flow, preflight checks | 0.75d |
45
+ | Phase 6 | [phase-06-git-clone-docs.md](./phase-06-git-clone-docs.md) | Git-clone install flow, docs, examples | 0.5d |
46
+ | Phase 7 | [phase-07-qa-release.md](./phase-07-qa-release.md) | CI matrix, release automation, quality gates | 0.25d |
47
+
48
+ ## Architecture Overview
49
+ ```
50
+ ┌───────────────────────────────────────────────────────────────────┐
51
+ │ community repo (public) │
52
+ │ ├─ packages/cli-node (npm wrapper, preflight, UX) │
53
+ │ ├─ packages/core-python (sync engine + transpiler + benchmark) │
54
+ │ ├─ fixtures/ (zip + ~/.claude snapshots for tests) │
55
+ │ ├─ docs/ (install, config, parity methodology) │
56
+ │ └─ .github/workflows/ (CI matrix + release) │
57
+ └───────────────────────────────────────────────────────────────────┘
58
+
59
+
60
+ user machine (Ubuntu/macOS/WSL)
61
+
62
+ ┌─────────────┴─────────────┐
63
+ │ │
64
+ ▼ ▼
65
+ npx claudekit-codex-sync git clone + ./scripts/install.sh
66
+ ```
67
+
68
+ ## Success Criteria
69
+ 1. Install and run success >=95% on Ubuntu/macOS/WSL.
70
+ 2. Sync + verify pass >=98% on supported fixtures.
71
+ 3. Parity benchmark >=85% before public parity claim.
72
+ 4. Re-run idempotency: second run produces no destructive drift.
73
+ 5. Clear rollback path documented and tested.
74
+
75
+ ## Risks & Mitigations
76
+ | Risk | Impact | Mitigation |
77
+ |---|---|---|
78
+ | Runtime semantics differ Claude vs Codex | False parity claims | Use outcome-based scoring + publish raw reports |
79
+ | npm wrapper fails due missing Python | Install friction | Preflight checks + one-line remediation |
80
+ | Agent transpiler overfits one kit version | Fragile updates | Schema validation + fixture regression tests |
81
+ | Codex feature drift (`multi_agent`) | Break role flows | Version matrix + compatibility checks |
82
+
83
+ ## Deliverables
84
+ - Public-ready repository structure.
85
+ - CLI commands for sync, transpile, benchmark, verify.
86
+ - Published npm package + tagged git release.
87
+ - Benchmark report template and reproducible results.
88
+ - Operational docs for users and contributors.
89
+
90
+ ## Implementation Notes
91
+ - Keep MCP/hooks opt-in flags intact.
92
+ - Preserve latest-zip selection behavior as default.
93
+ - Ensure `--dry-run` and `--json` output for automation consumers.
94
+ - Add "strict mode" for CI (non-zero exit on parity threshold miss).
95
+
96
+ ## Open Questions
97
+ 1. Final npm package name preference (`claudekit-codex-sync` vs alternatives)?
98
+ 2. License choice for community repo (MIT/Apache-2.0)?
99
+ 3. Initial support policy: LTS + latest Codex only, or broad version range?
@@ -0,0 +1,79 @@
1
+ # Phase 1: Project Structure
2
+
3
+ Status: pending
4
+ Priority: critical
5
+ Effort: 0.5d
6
+
7
+ ## Goal
8
+ Initialize npm project structure, .gitignore, and module directories.
9
+
10
+ ## Steps
11
+
12
+ ### 1.1 Initialize npm
13
+ ```bash
14
+ cd /home/vinhawk/claudekit-codex-sync
15
+ npm init -y
16
+ ```
17
+
18
+ Edit `package.json`:
19
+ ```json
20
+ {
21
+ "name": "claudekit-codex-sync",
22
+ "version": "0.1.0",
23
+ "description": "Sync ClaudeKit skills, agents, and config to Codex CLI",
24
+ "main": "bin/ck-codex-sync.js",
25
+ "bin": { "ck-codex-sync": "bin/ck-codex-sync.js" },
26
+ "scripts": {
27
+ "sync": "python3 src/claudekit_codex_sync/cli.py",
28
+ "test": "python3 -m pytest tests/",
29
+ "lint": "python3 -m py_compile src/claudekit_codex_sync/*.py"
30
+ },
31
+ "keywords": ["claudekit", "codex", "sync", "skills"],
32
+ "license": "MIT"
33
+ }
34
+ ```
35
+
36
+ ### 1.2 Create bin/ck-codex-sync.js
37
+ ```javascript
38
+ #!/usr/bin/env node
39
+ const { execSync } = require('child_process');
40
+ const path = require('path');
41
+ const script = path.join(__dirname, '..', 'src', 'claudekit_codex_sync', 'cli.py');
42
+ try {
43
+ execSync(`python3 "${script}" ${process.argv.slice(2).join(' ')}`, { stdio: 'inherit' });
44
+ } catch (e) {
45
+ process.exit(e.status || 1);
46
+ }
47
+ ```
48
+
49
+ ### 1.3 Create .gitignore
50
+ ```
51
+ node_modules/
52
+ __pycache__/
53
+ *.pyc
54
+ .venv/
55
+ dist/
56
+ build/
57
+ *.egg-info/
58
+ .pytest_cache/
59
+ ```
60
+
61
+ ### 1.4 Create directories
62
+ ```bash
63
+ mkdir -p src/claudekit_codex_sync templates tests docs
64
+ touch src/claudekit_codex_sync/__init__.py
65
+ ```
66
+
67
+ ### 1.5 Delete redundant bash scripts
68
+ ```bash
69
+ git rm scripts/normalize-claudekit-for-codex.sh
70
+ git rm scripts/export-claudekit-prompts.sh
71
+ git rm scripts/bootstrap-claudekit-skill-scripts.sh
72
+ ```
73
+
74
+ ## Todo
75
+ - [ ] npm init + package.json
76
+ - [ ] bin/ck-codex-sync.js
77
+ - [ ] .gitignore
78
+ - [ ] Create src/ templates/ tests/ docs/ dirs
79
+ - [ ] Delete redundant bash scripts
@@ -0,0 +1,36 @@
1
+ # Phase 2: Extract Templates
2
+
3
+ Status: pending
4
+ Priority: high
5
+ Effort: 0.25d
6
+
7
+ ## Goal
8
+ Move 295 lines of inline template strings from `claudekit-sync-all.py` to separate files in `templates/`.
9
+
10
+ ## Mapping
11
+
12
+ | Constant (in Python) | Target File | Lines |
13
+ |---|---|---|
14
+ | `AGENTS_TEMPLATE` (L57-102) | `templates/agents-md.md` | 45 |
15
+ | `COMMAND_MAP_TEMPLATE` (L105-149) | `templates/command-map.md` | 44 |
16
+ | `BRIDGE_SKILL_TEMPLATE` (L152-215) | `templates/bridge-skill.md` | 63 |
17
+ | `BRIDGE_RESOLVE_SCRIPT` (L218-270) | `templates/bridge-resolve-command.py` | 52 |
18
+ | `BRIDGE_DOCS_INIT_SCRIPT` (L273-298) | `templates/bridge-docs-init.sh` | 25 |
19
+ | `BRIDGE_STATUS_SCRIPT` (L301-350) | `templates/bridge-project-status.sh` | 49 |
20
+
21
+ ## Loading Pattern
22
+
23
+ In Python modules, use:
24
+ ```python
25
+ from pathlib import Path
26
+
27
+ TEMPLATES_DIR = Path(__file__).parent.parent.parent / "templates"
28
+
29
+ def load_template(name: str) -> str:
30
+ return (TEMPLATES_DIR / name).read_text(encoding="utf-8")
31
+ ```
32
+
33
+ ## Todo
34
+ - [ ] Create 6 template files from inline strings
35
+ - [ ] Remove inline strings from Python
36
+ - [ ] Add `load_template()` utility
@@ -0,0 +1,107 @@
1
+ # Phase 3: Modularize Python
2
+
3
+ Status: pending
4
+ Priority: critical
5
+ Effort: 1d
6
+
7
+ ## Goal
8
+ Split 1151-line `claudekit-sync-all.py` into 11 modules, each <200 lines.
9
+
10
+ ## Module Split
11
+
12
+ ### `src/claudekit_codex_sync/utils.py` (~90 lines)
13
+ From lines: 394-502
14
+ ```python
15
+ # Functions: SyncError, eprint, run_cmd, ensure_parent,
16
+ # write_bytes_if_changed, write_text_if_changed, zip_mode,
17
+ # find_latest_zip (→ moved to source_resolver), load_manifest,
18
+ # save_manifest, apply_replacements, is_excluded_path
19
+ ```
20
+
21
+ ### `src/claudekit_codex_sync/source_resolver.py` (~80 lines)
22
+ From lines: 453-591
23
+ ```python
24
+ # Functions: find_latest_zip, collect_skill_entries
25
+ # NEW: detect_claude_source, validate_claude_source
26
+ ```
27
+
28
+ ### `src/claudekit_codex_sync/asset_sync.py` (~160 lines)
29
+ From lines: 505-656
30
+ ```python
31
+ # Functions: sync_assets, sync_skills
32
+ # NEW: sync_assets_from_dir, sync_skills_from_dir
33
+ ```
34
+
35
+ ### `src/claudekit_codex_sync/path_normalizer.py` (~120 lines)
36
+ From lines: 353-391, 493-497, 659-772
37
+ ```python
38
+ # Constants: SKILL_MD_REPLACEMENTS, PROMPT_REPLACEMENTS
39
+ # NEW: AGENT_TOML_REPLACEMENTS
40
+ # Functions: apply_replacements, normalize_files, patch_copywriting_script
41
+ # NEW: normalize_agent_tomls
42
+ ```
43
+
44
+ ### `src/claudekit_codex_sync/config_enforcer.py` (~80 lines)
45
+ From lines: 795-846
46
+ ```python
47
+ # Functions: ensure_agents, enforce_config
48
+ # NEW: enforce_multi_agent_flag
49
+ ```
50
+
51
+ ### `src/claudekit_codex_sync/prompt_exporter.py` (~100 lines)
52
+ From lines: 849-937
53
+ ```python
54
+ # Functions: ensure_frontmatter, export_prompts
55
+ ```
56
+
57
+ ### `src/claudekit_codex_sync/dep_bootstrapper.py` (~60 lines)
58
+ From lines: 940-998
59
+ ```python
60
+ # Functions: bootstrap_deps
61
+ ```
62
+
63
+ ### `src/claudekit_codex_sync/runtime_verifier.py` (~30 lines)
64
+ From lines: 1001-1021
65
+ ```python
66
+ # Functions: verify_runtime
67
+ ```
68
+
69
+ ### `src/claudekit_codex_sync/bridge_generator.py` (~30 lines)
70
+ From lines: 775-792
71
+ ```python
72
+ # Functions: ensure_bridge_skill (reads templates from files)
73
+ ```
74
+
75
+ ### `src/claudekit_codex_sync/cli.py` (~100 lines)
76
+ From lines: 1028-1151
77
+ ```python
78
+ # Functions: parse_args, main, print_summary
79
+ # Imports all modules, orchestrates the sync
80
+ ```
81
+
82
+ ## Import Structure
83
+ ```
84
+ cli.py
85
+ ├── source_resolver.py
86
+ ├── asset_sync.py ── utils.py
87
+ ├── path_normalizer.py ── utils.py
88
+ ├── config_enforcer.py ── utils.py
89
+ ├── prompt_exporter.py ── utils.py, path_normalizer.py
90
+ ├── dep_bootstrapper.py ── utils.py
91
+ ├── runtime_verifier.py ── utils.py
92
+ └── bridge_generator.py ── utils.py
93
+ ```
94
+
95
+ ## Todo
96
+ - [ ] Create utils.py
97
+ - [ ] Create source_resolver.py
98
+ - [ ] Create asset_sync.py
99
+ - [ ] Create path_normalizer.py
100
+ - [ ] Create config_enforcer.py
101
+ - [ ] Create prompt_exporter.py
102
+ - [ ] Create dep_bootstrapper.py
103
+ - [ ] Create runtime_verifier.py
104
+ - [ ] Create bridge_generator.py
105
+ - [ ] Create cli.py (orchestrator)
106
+ - [ ] Delete old scripts/claudekit-sync-all.py
107
+ - [ ] Verify: each module <200 lines
@@ -0,0 +1,76 @@
1
+ # Phase 4: Live Source + Claude Dir Detection
2
+
3
+ Status: pending
4
+ Priority: critical
5
+ Effort: 0.5d
6
+
7
+ ## Goal
8
+ Add `--source-mode live` to read directly from `~/.claude/` instead of zip. Auto-detect Claude installation.
9
+
10
+ ## Changes to `source_resolver.py`
11
+
12
+ ```python
13
+ def detect_claude_source() -> Path:
14
+ """Auto-detect Claude Code installation."""
15
+ candidates = [
16
+ Path.home() / ".claude",
17
+ Path(os.environ.get("USERPROFILE", "")) / ".claude",
18
+ ]
19
+ for p in candidates:
20
+ if p.exists() and (p / "skills").is_dir():
21
+ return p
22
+ raise SyncError("Claude Code not found. Use --source-dir to specify.")
23
+
24
+ def validate_source(source: Path) -> dict:
25
+ return {
26
+ "skills": (source / "skills").is_dir(),
27
+ "agents": (source / "agents").is_dir(),
28
+ "commands": (source / "commands").is_dir(),
29
+ "rules": (source / "rules").is_dir(),
30
+ "claude_md": (source / "CLAUDE.md").is_file(),
31
+ }
32
+ ```
33
+
34
+ ## Changes to `cli.py`
35
+
36
+ Add args:
37
+ ```python
38
+ p.add_argument("--source-mode", choices=["auto", "live", "zip"], default="auto")
39
+ p.add_argument("--source-dir", type=Path, default=None)
40
+ ```
41
+
42
+ Route in main:
43
+ ```python
44
+ if source_mode == "live" or (source_mode == "auto" and source_dir):
45
+ source = source_dir or detect_claude_source()
46
+ sync_assets_from_dir(source, ...)
47
+ sync_skills_from_dir(source, ...)
48
+ else:
49
+ zip_path = find_latest_zip(args.zip_path)
50
+ with zipfile.ZipFile(zip_path) as zf:
51
+ sync_assets(zf, ...)
52
+ sync_skills(zf, ...)
53
+ ```
54
+
55
+ ## Changes to `asset_sync.py`
56
+
57
+ ```python
58
+ def sync_skills_from_dir(source: Path, *, codex_home: Path, ...) -> Dict[str, int]:
59
+ skills_src = source / "skills"
60
+ skills_dst = codex_home / "skills"
61
+ for skill_dir in sorted(skills_src.iterdir()):
62
+ if not skill_dir.is_dir() or skill_dir.name.startswith("."):
63
+ continue
64
+ # apply same exclusion logic as sync_skills
65
+ dst = skills_dst / skill_dir.name
66
+ if dst.exists():
67
+ shutil.rmtree(dst)
68
+ shutil.copytree(skill_dir, dst)
69
+ ```
70
+
71
+ ## Todo
72
+ - [ ] Add detect_claude_source() + validate
73
+ - [ ] Add --source-mode, --source-dir args
74
+ - [ ] Add sync_assets_from_dir()
75
+ - [ ] Add sync_skills_from_dir()
76
+ - [ ] Route in main()