@unifocl/codex-plugin 0.0.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/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # unifocl Codex Plugin
2
+
3
+ This folder defines the Codex-side equivalent of `@unifocl/claude-plugin`.
4
+
5
+ ## What the Codex plugin should do
6
+
7
+ Unlike Claude Code's npm plugin format, Codex integration is primarily:
8
+
9
+ 1. MCP server registration (`unifocl --mcp-server`)
10
+ 2. Reusable workflow guidance (Codex skill/playbook)
11
+
12
+ So the Codex plugin is a **distribution bundle** made of:
13
+
14
+ - MCP setup automation
15
+ - Codex skill files for `/init`, `/status`, `/context`, `/mutate`, `/workflow`-equivalent flows
16
+
17
+ ## Functional Scope
18
+
19
+ The Codex plugin must provide the same workflow guarantees as the Claude plugin:
20
+
21
+ - `/init` equivalent: project bridge setup + post-checks
22
+ - `/status` equivalent: daemon/mode/project/editor/session checks
23
+ - `/context` equivalent: hierarchy + project + inspector hydration
24
+ - `/mutate` equivalent: schema -> validate -> dry-run -> execute -> verify sequence
25
+ - `/workflow` equivalent: canonical multi-step agent workflow
26
+
27
+ The low-level behavior continues to live in:
28
+
29
+ - `unifocl --mcp-server`
30
+ - `unifocl exec "..."`
31
+
32
+ No mutation logic is duplicated in this package.
33
+
34
+ ## Distribution Strategy (No source checkout required)
35
+
36
+ Not all users clone this repository, so distribution should be release-based:
37
+
38
+ 1. **Primary channel: npm package**
39
+ - Publish: `@unifocl/codex-plugin`
40
+ - Contains:
41
+ - install script that runs Codex MCP registration
42
+ - bundled skill templates/playbooks
43
+ - One-liner install target:
44
+ - `npm install -g @unifocl/codex-plugin`
45
+ - then run `unifocl-codex-plugin install`
46
+
47
+ 2. **Binary channel: built-in CLI command (recommended follow-up)**
48
+ - Add command to `unifocl` binary:
49
+ - `unifocl agent install codex`
50
+ - This command:
51
+ - detects Codex config location
52
+ - registers `mcpServers.unifocl`
53
+ - installs/updates unifocl skill files under `$CODEX_HOME/skills/unifocl`
54
+ - Benefit: works for Homebrew/winget/release-binary users with no Node.js requirement.
55
+
56
+ 3. **GitHub release asset fallback**
57
+ - Ship a small cross-platform installer script in release assets:
58
+ - `install-codex-plugin.sh`
59
+ - `install-codex-plugin.ps1`
60
+ - Users download from release page and run once.
61
+
62
+ ## Versioning & Compatibility
63
+
64
+ - Keep plugin version aligned with unifocl CLI minor version.
65
+ - On protocol-affecting changes, include migration guidance (for example: rerun `/init`).
66
+ - Installer should be idempotent and safe to rerun.
67
+
68
+ ## File Layout
69
+
70
+ ```text
71
+ src/unifocl.codex-plugin/
72
+ README.md
73
+ package.json
74
+ bin/unifocl-codex-plugin.js
75
+ skills/unifocl/SKILL.md
76
+ skills/unifocl/references/init.md
77
+ skills/unifocl/references/status.md
78
+ skills/unifocl/references/context.md
79
+ skills/unifocl/references/mutate.md
80
+ skills/unifocl/references/workflow.md
81
+ ```
82
+
83
+ ## Minimal install behavior
84
+
85
+ Installer should execute equivalent of:
86
+
87
+ ```bash
88
+ scripts/setup-mcp-agents.sh --workspace <detected-or-provided-workspace> --codex
89
+ ```
90
+
91
+ Then copy bundled skill files to:
92
+
93
+ ```text
94
+ $CODEX_HOME/skills/unifocl/
95
+ ```
96
+
97
+ and print verification steps:
98
+
99
+ 1. Restart Codex session.
100
+ 2. Confirm MCP tools include `ListCommands` and `LookupCommand`.
101
+ 3. Run a smoke check with `unifocl exec "/status" --agentic --format json`.
102
+
103
+ ## Publish From CLI
104
+
105
+ From this directory:
106
+
107
+ ```bash
108
+ cd src/unifocl.codex-plugin
109
+ npm publish --access public
110
+ ```
111
+
112
+ If this is your first publish for the scope:
113
+
114
+ ```bash
115
+ npm login
116
+ npm publish --access public
117
+ ```
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const os = require("node:os");
7
+ const cp = require("node:child_process");
8
+
9
+ function printUsage() {
10
+ console.log(`Usage:
11
+ unifocl-codex-plugin install [--server-name <name>] [--config-root <path>] [--skills-dir <path>]
12
+ unifocl-codex-plugin doctor
13
+ unifocl-codex-plugin help
14
+ `);
15
+ }
16
+
17
+ function fail(message) {
18
+ console.error(`error: ${message}`);
19
+ process.exit(1);
20
+ }
21
+
22
+ function run(command, args, options = {}) {
23
+ const result = cp.spawnSync(command, args, {
24
+ stdio: "pipe",
25
+ encoding: "utf8",
26
+ ...options
27
+ });
28
+ return result;
29
+ }
30
+
31
+ function ensureCommandExists(command) {
32
+ const checker = process.platform === "win32" ? "where" : "which";
33
+ const result = run(checker, [command]);
34
+ if (result.status !== 0) {
35
+ fail(`required command not found on PATH: ${command}`);
36
+ }
37
+ }
38
+
39
+ function parseArgs(argv) {
40
+ const positional = [];
41
+ const options = {
42
+ serverName: "unifocl",
43
+ configRoot: "",
44
+ skillsDir: ""
45
+ };
46
+
47
+ for (let i = 0; i < argv.length; i += 1) {
48
+ const token = argv[i];
49
+ if (token === "--server-name") {
50
+ options.serverName = argv[++i] || "";
51
+ continue;
52
+ }
53
+ if (token === "--config-root") {
54
+ options.configRoot = argv[++i] || "";
55
+ continue;
56
+ }
57
+ if (token === "--skills-dir") {
58
+ options.skillsDir = argv[++i] || "";
59
+ continue;
60
+ }
61
+ positional.push(token);
62
+ }
63
+
64
+ return { positional, options };
65
+ }
66
+
67
+ function resolveCodexHome() {
68
+ if (process.env.CODEX_HOME && process.env.CODEX_HOME.trim() !== "") {
69
+ return path.resolve(process.env.CODEX_HOME);
70
+ }
71
+ return path.join(os.homedir(), ".codex");
72
+ }
73
+
74
+ function copyDirRecursive(srcDir, dstDir) {
75
+ fs.mkdirSync(dstDir, { recursive: true });
76
+ const entries = fs.readdirSync(srcDir, { withFileTypes: true });
77
+ for (const entry of entries) {
78
+ const srcPath = path.join(srcDir, entry.name);
79
+ const dstPath = path.join(dstDir, entry.name);
80
+ if (entry.isDirectory()) {
81
+ copyDirRecursive(srcPath, dstPath);
82
+ } else {
83
+ fs.copyFileSync(srcPath, dstPath);
84
+ }
85
+ }
86
+ }
87
+
88
+ function install(options) {
89
+ ensureCommandExists("codex");
90
+ ensureCommandExists("unifocl");
91
+
92
+ const serverName = options.serverName || "unifocl";
93
+ const codexHome = resolveCodexHome();
94
+ const configRoot = options.configRoot && options.configRoot.trim() !== ""
95
+ ? path.resolve(options.configRoot)
96
+ : path.join(codexHome, "unifocl-config");
97
+ const skillsTarget = options.skillsDir && options.skillsDir.trim() !== ""
98
+ ? path.resolve(options.skillsDir)
99
+ : path.join(codexHome, "skills", "unifocl");
100
+
101
+ fs.mkdirSync(configRoot, { recursive: true });
102
+ fs.mkdirSync(path.dirname(skillsTarget), { recursive: true });
103
+
104
+ const packageRoot = path.resolve(__dirname, "..");
105
+ const bundledSkills = path.join(packageRoot, "skills", "unifocl");
106
+ if (!fs.existsSync(bundledSkills)) {
107
+ fail(`bundled skills not found: ${bundledSkills}`);
108
+ }
109
+
110
+ run("codex", ["mcp", "remove", serverName], { stdio: "ignore" });
111
+ const addResult = run("codex", [
112
+ "mcp",
113
+ "add",
114
+ serverName,
115
+ "--env",
116
+ `UNIFOCL_CONFIG_ROOT=${configRoot}`,
117
+ "--",
118
+ "unifocl",
119
+ "--mcp-server"
120
+ ]);
121
+
122
+ if (addResult.status !== 0) {
123
+ const stderr = (addResult.stderr || "").trim();
124
+ const stdout = (addResult.stdout || "").trim();
125
+ fail(`failed to register MCP server in Codex.\n${stderr || stdout}`);
126
+ }
127
+
128
+ copyDirRecursive(bundledSkills, skillsTarget);
129
+
130
+ console.log("installed: unifocl codex plugin");
131
+ console.log(`- mcp server: ${serverName} -> unifocl --mcp-server`);
132
+ console.log(`- config root: ${configRoot}`);
133
+ console.log(`- skills path: ${skillsTarget}`);
134
+ console.log("next: restart Codex session and verify MCP tools are available.");
135
+ }
136
+
137
+ function doctor() {
138
+ const codexHome = resolveCodexHome();
139
+ const skillsPath = path.join(codexHome, "skills", "unifocl");
140
+ console.log(`codex home: ${codexHome}`);
141
+ console.log(`skills path: ${skillsPath}`);
142
+ console.log(`skills installed: ${fs.existsSync(skillsPath) ? "yes" : "no"}`);
143
+ }
144
+
145
+ function main() {
146
+ const { positional, options } = parseArgs(process.argv.slice(2));
147
+ const command = positional[0] || "help";
148
+
149
+ if (command === "help" || command === "--help" || command === "-h") {
150
+ printUsage();
151
+ return;
152
+ }
153
+ if (command === "install") {
154
+ install(options);
155
+ return;
156
+ }
157
+ if (command === "doctor") {
158
+ doctor();
159
+ return;
160
+ }
161
+
162
+ fail(`unknown command: ${command}`);
163
+ }
164
+
165
+ main();
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@unifocl/codex-plugin",
3
+ "version": "0.0.0",
4
+ "description": "Codex plugin bundle for unifocl: installs MCP server config and unifocl workflow skills.",
5
+ "keywords": [
6
+ "unifocl",
7
+ "codex",
8
+ "mcp",
9
+ "unity",
10
+ "plugin"
11
+ ],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/Kiankinakomochi/unifocl.git",
16
+ "directory": "src/unifocl.codex-plugin"
17
+ },
18
+ "bin": {
19
+ "unifocl-codex-plugin": "./bin/unifocl-codex-plugin.js"
20
+ },
21
+ "files": [
22
+ "bin/",
23
+ "skills/",
24
+ "README.md",
25
+ "package.json"
26
+ ]
27
+ }
@@ -0,0 +1,42 @@
1
+ # unifocl Codex Skill
2
+
3
+ Use this skill when working with Unity projects through `unifocl` in Codex.
4
+
5
+ ## Purpose
6
+
7
+ Provide a low-token workflow that mirrors the Claude plugin prompts:
8
+
9
+ - init
10
+ - status
11
+ - context
12
+ - mutate
13
+ - workflow
14
+
15
+ ## MCP Prerequisite
16
+
17
+ This skill assumes Codex MCP is configured:
18
+
19
+ - server name: `unifocl`
20
+ - command: `unifocl --mcp-server`
21
+
22
+ If not configured, run:
23
+
24
+ ```bash
25
+ unifocl-codex-plugin install
26
+ ```
27
+
28
+ ## Workflow Shortcuts
29
+
30
+ Read these references and follow them strictly:
31
+
32
+ - `references/init.md`
33
+ - `references/status.md`
34
+ - `references/context.md`
35
+ - `references/mutate.md`
36
+ - `references/workflow.md`
37
+
38
+ ## Guardrails
39
+
40
+ - Always prefer `GetAgentWorkflowGuide` over stale docs.
41
+ - Always run mutation validation + dry-run before execution.
42
+ - Use stable `--session-seed` values across multi-step flows.
@@ -0,0 +1,22 @@
1
+ Hydrate full scene context from the active unifocl project for agent reasoning.
2
+
3
+ Arguments (optional — pass any combination): $ARGUMENTS
4
+ --project <path> explicit project path
5
+ --depth <n> hierarchy/asset traversal depth
6
+ --limit <n> max objects to return
7
+ --compact omit null/default fields
8
+
9
+ Steps:
10
+
11
+ 1. Dump scene hierarchy:
12
+ `unifocl exec "/dump hierarchy --format json --depth 6 --limit 2000 $ARGUMENTS" --agentic --format json`
13
+
14
+ 2. Dump project asset structure:
15
+ `unifocl exec "/dump project --format json --depth 4 --limit 1000 $ARGUMENTS" --agentic --format json`
16
+
17
+ 3. For inspector detail on a specific object:
18
+ `unifocl exec "/inspect <path>" --agentic --format json $ARGUMENTS`
19
+ then:
20
+ `unifocl exec "/dump inspector --format json $ARGUMENTS" --agentic --format json`
21
+
22
+ Use this context before planning any mutation operation.
@@ -0,0 +1,23 @@
1
+ Initialize the unifocl bridge in a Unity project.
2
+
3
+ Project path (optional — defaults to current working directory if omitted): $ARGUMENTS
4
+
5
+ Steps:
6
+
7
+ 1. Run the init command to install the editor-side bridge package:
8
+ `unifocl exec "/init $ARGUMENTS" --agentic --format json`
9
+
10
+ 2. If `ok` is false, inspect the `message` field and surface the error. Common causes:
11
+ - Path does not contain `ProjectSettings/ProjectVersion.txt` (not a Unity project root)
12
+ - Unity Editor is not installed or not detected
13
+ - Write permission denied on `Packages/` directory
14
+
15
+ 3. After a successful `/init`, confirm the bridge is ready:
16
+ `unifocl exec "/status" --agentic --format json --project "$ARGUMENTS"`
17
+ Check that `data.mode` is `bridge` (Unity Editor connected) or `host` (headless/batch).
18
+
19
+ 4. If `protocolMismatch` appears in the response, the editor package is outdated — re-run step 1 to redeploy the updated version.
20
+
21
+ Next steps after a successful init:
22
+ - Use context workflow to hydrate scene state before any mutations.
23
+ - Use mutate workflow for guided scene mutations with dry-run validation.
@@ -0,0 +1,31 @@
1
+ Guided scene mutation with mandatory dry-run validation first.
2
+
3
+ Describe what to mutate: $ARGUMENTS
4
+
5
+ Follow this order exactly.
6
+
7
+ Step 1 — Plan
8
+ - Determine the `/mutate` op array.
9
+ - Call `GetMutateSchema` via MCP to verify supported ops and fields.
10
+
11
+ Step 2 — Validate
12
+ - Call `ValidateMutateBatch` via MCP with the planned JSON array.
13
+ - Fix all validation errors.
14
+
15
+ Step 3 — Dry-run
16
+ - `unifocl exec "/mutate --dry-run <json-array>" --agentic --format json`
17
+ - Review returned diff and paths.
18
+ - Do not proceed if `data.allOk` is false.
19
+
20
+ Step 4 — Execute
21
+ - `unifocl exec "/mutate <json-array>" --agentic --format json`
22
+ - Confirm `data.allOk: true`.
23
+
24
+ Step 5 — Verify
25
+ - Re-run context workflow or targeted dumps to confirm state.
26
+
27
+ Path rules:
28
+ - Root: `/`
29
+ - Top-level: `/ObjectName`
30
+ - Nested: `/Parent/Child`
31
+ - Case-sensitive names.
@@ -0,0 +1,23 @@
1
+ Check unifocl daemon and project status.
2
+
3
+ Optional project path or flags: $ARGUMENTS
4
+
5
+ Steps:
6
+
7
+ 1. Get current status:
8
+ `unifocl exec "/status" --agentic --format json $ARGUMENTS`
9
+
10
+ 2. Report from the response:
11
+ - `data.daemon` — running port and uptime
12
+ - `data.mode` — `bridge` (Unity Editor connected) or `host` (headless/batch)
13
+ - `data.project` — loaded project path and name
14
+ - `data.editor` — Unity Editor version in use
15
+ - `data.session` — active session seed if set
16
+
17
+ 3. If daemon is not running:
18
+ `unifocl exec "/daemon ps" --agentic --format json`
19
+
20
+ 4. If no project is open, run init workflow first.
21
+
22
+ 5. If environment issues are suspected:
23
+ `unifocl exec "/doctor" --agentic --format json`
@@ -0,0 +1,27 @@
1
+ Full agentic workflow guide for unifocl Unity operations.
2
+
3
+ Task or workflow to plan: $ARGUMENTS
4
+
5
+ Start by calling `GetAgentWorkflowGuide` via the unifocl MCP server.
6
+
7
+ Standard session pattern:
8
+
9
+ 1. Setup
10
+ - Ensure `unifocl` is installed.
11
+ - Install Codex integration: `unifocl-codex-plugin install`
12
+
13
+ 2. Open project
14
+ - `unifocl exec "/open <project-path>" --agentic --format json`
15
+ - Wait for `data.ok: true`
16
+
17
+ 3. Hydrate context
18
+ - Follow context workflow before planning mutations.
19
+
20
+ 4. Discover commands
21
+ - Use `ListCommands(scope="all")` and `LookupCommand(command="...")`.
22
+
23
+ 5. Mutate safely
24
+ - Follow mutate workflow (validate + dry-run first).
25
+
26
+ 6. Session efficiency
27
+ - Reuse stable `--session-seed <id>` across related exec calls.