From 99797e80ac1232a717431ce764ad873046b7969a Mon Sep 17 00:00:00 2001 From: "pre-shared-workflows-auth[bot]" <168739156+pre-shared-workflows-auth[bot]@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:17:18 +0000 Subject: [PATCH] chore: publish the plugin files --- .codex-plugin/plugin.json | 1 + .github/README.md | 17 +++++++ com.github.copilot/rules/unity.mdc | 5 +++ hooks/hooks.json | 15 +++++++ plugin.json | 27 +++++++++++ rules/AGENTS.md | 1 + scripts/build-codex-zip.mts | 44 ++++++++++++++---- scripts/plugin-metadata.json | 3 +- scripts/sync-manifests.mts | 72 +++++++++++++++++++++++++++++- 9 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 com.github.copilot/rules/unity.mdc create mode 100644 hooks/hooks.json create mode 100644 plugin.json create mode 100644 rules/AGENTS.md diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 0dd67c6..a3904c0 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -24,6 +24,7 @@ "shader-graph" ], "skills": "./skills/", + "hooks": {}, "requires_local_executor": true, "interface": { "displayName": "Unity", diff --git a/.github/README.md b/.github/README.md index 9affb3b..6307a52 100644 --- a/.github/README.md +++ b/.github/README.md @@ -175,6 +175,23 @@ For what each skill covers and how to prompt it, see [About Unity's plugin](https://docs.unity.com/en-us/ai/unity-plugin/about-unity-plugin), or browse the [skills](../skills/using-unity/references/). +## What the plugin adds to a session + +Besides the skill, the plugin adds one sentence at the start of each session. It tells your agent +to load `using-unity` first when you're working on a Unity project or starting a new game project, +so a request that doesn't mention Unity still reaches the right skill. The sentence is added in +every folder, not only in Unity projects. + +How it arrives depends on the agent: + +- **Claude Code**: a `SessionStart` hook in `hooks/hooks.json`. It runs one `echo` command that + prints the sentence, and nothing else. +- **GitHub Copilot CLI**: a plugin rule, `com.github.copilot/rules/unity.mdc`. + `copilot instruction list` shows it under "Plugin instructions". +- **Antigravity**: a plugin rule, `rules/AGENTS.md`. `agy plugin list` counts it in the plugin's + components. +- **Codex** and **Grok**: nothing is added. They find `using-unity` from the skill list. + ## Works best with the Unity CLI Many skills drive your open Unity Editor directly: they create GameObjects, change import settings, run C# in the Editor, and check the result, instead of hand-editing scene and asset files. They do this through the [Unity CLI](https://docs.unity.com/en-us/unity-cli), Unity's command-line tool, which also installs Editors, creates and opens projects, and runs builds and tests. diff --git a/com.github.copilot/rules/unity.mdc b/com.github.copilot/rules/unity.mdc new file mode 100644 index 0000000..bfd2ef3 --- /dev/null +++ b/com.github.copilot/rules/unity.mdc @@ -0,0 +1,5 @@ +--- +description: Unity skills +alwaysApply: true +--- +If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity. diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..9a507c6 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "SessionStart": [ + { + "matcher": "startup|clear|compact", + "hooks": [ + { + "type": "command", + "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"additionalContext\":\"If you\\u0027re working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn\\u0027t explicitly mention Unity.\"}}'" + } + ] + } + ] + } +} diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..9f6bba9 --- /dev/null +++ b/plugin.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", + "name": "unity", + "version": "0.1.10-beta", + "description": "Unity's official plugin for coding agents, with curated skills for game development, monetization, and performance optimization.", + "author": { + "name": "Unity Technologies", + "url": "https://unity.com" + }, + "homepage": "https://unity.com", + "repository": "https://github.com/Unity-Technologies/unity-agent-plugin", + "license": "LicenseRef-Unity-Companion-License", + "keywords": [ + "unity", + "gamedev", + "game-development", + "ui-toolkit", + "ugui", + "2d", + "tilemap", + "in-app-purchases", + "monetization", + "localization", + "multiplayer", + "shader-graph" + ] +} diff --git a/rules/AGENTS.md b/rules/AGENTS.md new file mode 100644 index 0000000..91c47f2 --- /dev/null +++ b/rules/AGENTS.md @@ -0,0 +1 @@ +If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity. diff --git a/scripts/build-codex-zip.mts b/scripts/build-codex-zip.mts index 4bc1aa3..0398f65 100644 --- a/scripts/build-codex-zip.mts +++ b/scripts/build-codex-zip.mts @@ -4,11 +4,26 @@ // node scripts/build-codex-zip.mts writes dist/unity-codex-.zip // // Run it on a clean checkout of merged main, after the version bump. The zip holds one folder, -// `unity`, with the skills (no evals/ or tests/), both manifests, the README, the license and -// the logos the manifests reference. It refuses to build if the manifests disagree on -// the version or drift from scripts/plugin-metadata.json. +// `unity`, with the skills (no evals/ or tests/), the root plugin.json, the Codex manifest, the +// README, the license and the logos the Codex manifest references. It refuses to build if the +// manifests disagree on the name or version, or drift from scripts/plugin-metadata.json. +// +// The directory takes the package's identity (name, version, description, author) from the root +// plugin.json and everything else from .codex-plugin/plugin.json, because the root manifest has +// no extensions.com.openai. Files for other clients stay out: .claude-plugin/, hooks/, rules/ +// and com.github.copilot/. import { execFileSync } from 'node:child_process'; -import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs'; +import { + cpSync, + existsSync, + mkdirSync, + mkdtempSync, + readdirSync, + readFileSync, + rmSync, + statSync, + writeFileSync, +} from 'node:fs'; import { tmpdir } from 'node:os'; import { basename, join, resolve } from 'node:path'; @@ -22,23 +37,25 @@ execFileSync(process.execPath, [join(root, 'scripts/sync-manifests.mts'), '--che cwd: root, stdio: 'inherit', }); -const manifests = ['.codex-plugin/plugin.json', '.claude-plugin/plugin.json']; +const manifests = ['plugin.json', '.codex-plugin/plugin.json']; +const names = new Set(); for (const file of manifests) { - const { version } = JSON.parse(readFileSync(join(root, file), 'utf8')) as { version: string }; + const { name, version } = JSON.parse(readFileSync(join(root, file), 'utf8')) as { name: string; version: string }; if (version !== meta.version) fail(`${file} is at ${version}, expected ${meta.version}`); + names.add(name); } +if (names.size !== 1) fail(`${manifests.join(' and ')} disagree on the name: ${[...names].join(', ')}`); // 2. Stage the package as /unity. const excluded = new Set(['evals', 'tests', '.DS_Store', 'Thumbs.db']); const contents = [ 'skills', + 'plugin.json', '.codex-plugin', - '.claude-plugin', 'README.md', 'LICENSE.md', 'assets/unity.svg', 'assets/unity-small.svg', - 'assets/unity-tile.svg', // the icon .claude-plugin/plugin.json points to ]; const stage = mkdtempSync(join(tmpdir(), 'unity-codex-')); const pkg = join(stage, 'unity'); @@ -52,6 +69,17 @@ try { }); } + // The Codex manifest sets "hooks": {} so that a git install never picks up hooks/hooks.json, + // which is Claude Code's. The zip has no hooks/ folder, so the key has nothing to switch off + // here, and the plugin directory takes no plugins with lifecycle hooks. Leave it out, so the + // uploaded manifest declares none. + const codexManifest = join(pkg, '.codex-plugin/plugin.json'); + const { hooks, ...packed } = JSON.parse(readFileSync(codexManifest, 'utf8')) as Record; + if (hooks !== undefined && JSON.stringify(hooks) !== '{}') { + fail('.codex-plugin/plugin.json declares hooks; the plugin directory takes no plugins with lifecycle hooks'); + } + writeFileSync(codexManifest, `${JSON.stringify(packed, null, 2)}\n`); + // 3. Check what was staged before zipping it. const skills = readdirSync(join(pkg, 'skills')).filter((d) => existsSync(join(pkg, 'skills', d, 'SKILL.md')), diff --git a/scripts/plugin-metadata.json b/scripts/plugin-metadata.json index 00b4c61..531e2af 100644 --- a/scripts/plugin-metadata.json +++ b/scripts/plugin-metadata.json @@ -21,5 +21,6 @@ "localization", "multiplayer", "shader-graph" - ] + ], + "nudge": "If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity." } diff --git a/scripts/sync-manifests.mts b/scripts/sync-manifests.mts index 41f961c..1dc694e 100644 --- a/scripts/sync-manifests.mts +++ b/scripts/sync-manifests.mts @@ -8,7 +8,11 @@ // To release, change "version" in plugin-metadata.json and run the script without --check. // Platform-only fields (descriptions, the Codex interface block, Antigravity prompts) stay in // each manifest and are not touched. -import { readFileSync, writeFileSync } from 'node:fs'; +// +// It also writes the session-start nudge ("nudge" in plugin-metadata.json) into the three files +// that deliver it, so they always carry the same sentence. See `nudgeFiles` below. +import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { dirname } from 'node:path'; type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; type JsonObject = { [key: string]: Json }; @@ -21,6 +25,7 @@ interface Metadata { license: string; category: string; keywords: string[]; + nudge: string; } interface Marketplace extends JsonObject { @@ -34,6 +39,14 @@ const shared = ['version', 'author', 'homepage', 'repository', 'license', 'keywo // Each target names a manifest and where each shared key lives in it. const targets: { file: string; set: (manifest: JsonObject) => void }[] = [ { file: '.claude-plugin/plugin.json', set: (m) => assign(m, shared) }, + { + // The Agent Plugins manifest at the plugin root. Copilot CLI reads com.github.copilot/ only + // when it exists, Grok reads it before .claude-plugin/plugin.json, and OpenAI's plugin + // directory takes the package's identity from it. It has no extensions.com.openai, so + // Codex and the directory still read their settings from .codex-plugin/plugin.json. + file: 'plugin.json', + set: (m) => assign(m, shared), + }, { file: '.codex-plugin/plugin.json', set: (m) => { @@ -107,6 +120,63 @@ for (const { file, set } of targets) { else writeFileSync(file, after); } +// The session-start nudge: one sentence telling the agent to open using-unity first, delivered +// in each client's own form. +// hooks/hooks.json Claude Code: a SessionStart hook prints it as additionalContext. +// The matcher leaves out resume, where the saved text is replayed. +// com.github.copilot/rules/unity.mdc Copilot CLI: an always-on plugin rule. +// rules/AGENTS.md Antigravity: an always-on plugin rule. +// Codex and Grok get none. A Codex plugin hook needs the user's approval again after every +// plugin update, so .codex-plugin/plugin.json sets "hooks": {} to keep Codex from picking up +// hooks/hooks.json. Grok runs hooks/hooks.json and ignores what a SessionStart hook prints. +const nudgeFiles: { file: string; content: string }[] = [ + { + file: 'hooks/hooks.json', + content: `${JSON.stringify( + { + hooks: { + SessionStart: [ + { matcher: 'startup|clear|compact', hooks: [{ type: 'command', command: nudgeCommand(meta.nudge) }] }, + ], + }, + }, + null, + 2, + )}\n`, + }, + { + // Copilot CLI lists the rule only with a description and alwaysApply: true, in a .mdc file. + file: 'com.github.copilot/rules/unity.mdc', + content: `---\ndescription: Unity skills\nalwaysApply: true\n---\n${meta.nudge}\n`, + }, + { file: 'rules/AGENTS.md', content: `${meta.nudge}\n` }, +]; + +// The hook command runs in sh, Git Bash or PowerShell, whichever the client picks on the +// user's machine, with no program or file it could depend on. A single-quoted `echo` is the +// one form all of them print unchanged. An apostrophe would end the quoting, so it is written +// as the JSON escape \u0027, which the client decodes. +function nudgeCommand(text: string): string { + if (/[\\"\r\n]/.test(text)) { + throw new Error( + '"nudge" in scripts/plugin-metadata.json has a backslash, a double quote or a line break. ' + + 'Shells disagree on how `echo` prints those, so the hook would break in some of them. Reword it.', + ); + } + const output = JSON.stringify({ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: text } }); + return `echo '${output.replaceAll("'", '\\u0027')}'`; +} + +for (const { file, content } of nudgeFiles) { + const before = existsSync(file) ? readFileSync(file, 'utf8').replace(/\r\n/g, '\n') : null; + if (before === content) continue; + if (check) drifted.push(file); + else { + mkdirSync(dirname(file), { recursive: true }); + writeFileSync(file, content); + } +} + // The sample `codex plugin list`, `agy plugin list` and `copilot plugin list` output in the // README shows the version. Only those three lines are matched, so other version numbers in // the README are left alone.