claude-runtime-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.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/bin/crs.js +87 -0
- package/examples/.claude-codex-sync.example.json +15 -0
- package/package.json +46 -0
- package/src/claude-runtime-sync.js +924 -0
- package/src/codex-plugin-bridge.js +427 -0
- package/src/install-codex-zsh-hook.js +196 -0
- package/src/sync-claude-all-to-codex.js +997 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 stringzhao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# claude-runtime-sync
|
|
2
|
+
|
|
3
|
+
Use Claude config (`~/.claude` + `<repo>/.claude`) as the **single source of truth**, and sync reusable runtime capabilities into Codex.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Sync skills from Claude to Codex
|
|
8
|
+
- Sync MCP servers into managed block of `~/.codex/config.toml`
|
|
9
|
+
- Mirror project `.mcp.json` into `~/.claude/mcp.json`
|
|
10
|
+
- Sync Claude plugins and hooks metadata into Codex runtime area
|
|
11
|
+
- Generate bridge manifest for Codex event -> Claude hooks mapping
|
|
12
|
+
- Keep `agents.md` / `gemini.md` aligned with `CLAUDE.md` (symlink-first)
|
|
13
|
+
- Install zsh startup hook for auto-check + auto-sync before each `codex` launch
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i -g claude-runtime-sync
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## CLI
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
crs sync
|
|
25
|
+
crs check
|
|
26
|
+
crs bridge --watch
|
|
27
|
+
crs hook install
|
|
28
|
+
crs hook remove
|
|
29
|
+
crs sync-base
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Common flags
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
--project-root=/path/to/repo
|
|
36
|
+
--claude-home=/path/to/.claude
|
|
37
|
+
--codex-home=/path/to/.codex
|
|
38
|
+
--no-home
|
|
39
|
+
--no-project
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Recommended bootstrap
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 1) one-time hook install
|
|
46
|
+
crs hook install
|
|
47
|
+
|
|
48
|
+
# 2) verify drift state
|
|
49
|
+
crs check
|
|
50
|
+
|
|
51
|
+
# 3) apply sync if needed
|
|
52
|
+
crs sync
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Local development
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run check
|
|
59
|
+
npm run smoke
|
|
60
|
+
npm run pack:dry-run
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## GitHub Actions
|
|
64
|
+
|
|
65
|
+
This repo includes:
|
|
66
|
+
|
|
67
|
+
- `.github/workflows/ci.yml`: syntax check + CLI smoke + pack dry run
|
|
68
|
+
- `.github/workflows/publish.yml`: publish to npm on `v*` tag or manual dispatch
|
|
69
|
+
|
|
70
|
+
Required repository secret:
|
|
71
|
+
|
|
72
|
+
- `NPM_TOKEN`: npm automation token with publish permission
|
|
73
|
+
|
|
74
|
+
## Publish flow
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# bump version first
|
|
78
|
+
npm version patch
|
|
79
|
+
|
|
80
|
+
# publish from local (optional)
|
|
81
|
+
npm publish --access public
|
|
82
|
+
|
|
83
|
+
# or publish via CI
|
|
84
|
+
# git push --follow-tags
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Notes
|
|
88
|
+
|
|
89
|
+
- Event bridge uses structured Codex session events and maps them to Claude-style hook events.
|
|
90
|
+
- If you only need base sync (skills + mcp), run `crs sync-base`.
|
|
91
|
+
- Example project config: `examples/.claude-codex-sync.example.json`.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|
package/bin/crs.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
function printHelp() {
|
|
7
|
+
console.log(`claude-runtime-sync CLI
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
crs sync [flags] Sync Claude source-of-truth into Codex
|
|
11
|
+
crs check [flags] Check drift only (exit code 1 when drift exists)
|
|
12
|
+
crs bridge [flags] Run Codex plugin bridge
|
|
13
|
+
crs hook install [zshrc] Install zsh codex auto-sync hook
|
|
14
|
+
crs hook remove [zshrc] Remove zsh codex auto-sync hook
|
|
15
|
+
crs sync-base [flags] Run base sync (skills+mcp)
|
|
16
|
+
crs --help
|
|
17
|
+
|
|
18
|
+
Common flags:
|
|
19
|
+
--codex-home=PATH
|
|
20
|
+
--claude-home=PATH
|
|
21
|
+
--project-root=PATH
|
|
22
|
+
--no-home
|
|
23
|
+
--no-project
|
|
24
|
+
`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function runNodeScript(scriptPath, args) {
|
|
28
|
+
const result = spawnSync(process.execPath, [scriptPath, ...args], {
|
|
29
|
+
stdio: 'inherit',
|
|
30
|
+
env: process.env
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (result.error) {
|
|
34
|
+
throw result.error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof result.status === 'number') {
|
|
38
|
+
process.exit(result.status);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const argv = process.argv.slice(2);
|
|
45
|
+
if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help' || argv[0] === 'help') {
|
|
46
|
+
printHelp();
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const command = argv[0];
|
|
51
|
+
const rest = argv.slice(1);
|
|
52
|
+
|
|
53
|
+
const srcRoot = path.join(__dirname, '..', 'src');
|
|
54
|
+
const runtimeSyncScript = path.join(srcRoot, 'claude-runtime-sync.js');
|
|
55
|
+
const bridgeScript = path.join(srcRoot, 'codex-plugin-bridge.js');
|
|
56
|
+
const hookScript = path.join(srcRoot, 'install-codex-zsh-hook.js');
|
|
57
|
+
const baseSyncScript = path.join(srcRoot, 'sync-claude-all-to-codex.js');
|
|
58
|
+
|
|
59
|
+
if (command === 'sync') {
|
|
60
|
+
runNodeScript(runtimeSyncScript, rest);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (command === 'check') {
|
|
64
|
+
runNodeScript(runtimeSyncScript, ['--check', ...rest]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (command === 'bridge') {
|
|
68
|
+
runNodeScript(bridgeScript, rest);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (command === 'sync-base') {
|
|
72
|
+
runNodeScript(baseSyncScript, rest);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (command === 'hook') {
|
|
76
|
+
const mode = rest[0];
|
|
77
|
+
if (mode !== 'install' && mode !== 'remove') {
|
|
78
|
+
console.error('hook 子命令仅支持 install/remove');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
runNodeScript(hookScript, rest);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.error(`未知命令: ${command}`);
|
|
86
|
+
printHelp();
|
|
87
|
+
process.exit(1);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ignoreSkills": ["example-skill-to-ignore"],
|
|
3
|
+
"skillNameMap": {
|
|
4
|
+
"source-skill-name": "target-skill-name"
|
|
5
|
+
},
|
|
6
|
+
"ignorePlugins": ["example-plugin-to-ignore"],
|
|
7
|
+
"pluginNameMap": {
|
|
8
|
+
"task-notifier": "task-notifier"
|
|
9
|
+
},
|
|
10
|
+
"ignoreHookSources": ["home"],
|
|
11
|
+
"ignoreMcpServers": ["Example MCP To Ignore"],
|
|
12
|
+
"mcpNameMap": {
|
|
13
|
+
"Chrome DevTools MCP": "chrome-devtools-mcp"
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-runtime-sync",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Use Claude config as the single source of truth and sync reusable capabilities into Codex runtime.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"crs": "./bin/crs.js",
|
|
9
|
+
"claude-runtime-sync": "./bin/crs.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"src",
|
|
14
|
+
"examples",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"claude",
|
|
23
|
+
"codex",
|
|
24
|
+
"mcp",
|
|
25
|
+
"skills",
|
|
26
|
+
"hooks",
|
|
27
|
+
"plugins",
|
|
28
|
+
"sync"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/strzhao/claude-runtime-sync.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/strzhao/claude-runtime-sync",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/strzhao/claude-runtime-sync/issues"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"check": "node -c bin/crs.js && node -c src/claude-runtime-sync.js && node -c src/sync-claude-all-to-codex.js && node -c src/codex-plugin-bridge.js && node -c src/install-codex-zsh-hook.js",
|
|
40
|
+
"smoke": "node bin/crs.js --help",
|
|
41
|
+
"pack:dry-run": "npm pack --dry-run"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|