Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(chatgpt): stage portable OpenAI plugin package

Rahman1a0a396d4887
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 0122d442..93645dcd 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -92,7 +92,7 @@ MSO uses several extension concepts because they own different authority. They a
| Term | What it owns | State / authority | Do not confuse with |
|---|---|---|---|
| **Skill** | Trusted reusable instructions and routing policy (`SKILL.md`, optional structured contract/resources). | Skill trust (`official / verified / local / untrusted`) controls whether instructions may be model-loaded. A skill does not grant credentials or tool permission. | MCP server, Integration, executable app. |
-| **OpenAI/Codex plugin package** | Distribution metadata for reviewed skills plus an optional registered-app mapping (`.codex-plugin/plugin.json` + `.app.json`). | Packaging only. Staging does not install/select the package in a ChatGPT client and does not authorize the live MSO MCP server. | MSO Project Plugin, registered app, MCP authorization. |
+| **OpenAI plugin package** | Owner-private portable Agent Plugins package generated from reviewed `claude-skills/`: root `plugin.json`, projected root `skills/`, private `.app.json`, plus a `.codex-plugin/plugin.json` compatibility fallback. | Packaging only. Staging does not install/refresh/select the package in a ChatGPT client and does not authorize the live MSO MCP server. | MSO Project Plugin, registered app, MCP authorization. |
| **Registered app** | External platform identity referenced by `.app.json` when an exact real app registration exists. | Platform-owned install/connection/permission state. MSO keeps the mapping empty until an exact registration exists. | Generic MSO Integration or Project Plugin. |
| **Project Plugin** | A reviewed portable capability package that can declare skills and an MCP binding for one exact project. | Catalog presence never means installed. `project_mcp_manage` installs/removes only the selected project or explicit `@host` target with revision guards; no inheritance. | Global plugin install, Skill Market entry, Integration credential. |
| **MCP** | Protocol/transport boundary for structured tools. This includes MSO's own `/mcp` and project-declared MCP servers. | Tool schemas are discovered from the selected server; OAuth/project policy and call-time guards remain authoritative. | Package identity or credential storage. |
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index fa93a67c..d955b71c 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `chatgpt` stage portable OpenAI plugin package
- `memory` keep large typed projections mutable
## 2026-09-19
diff --git a/docs/CHATGPT-PLUGIN.md b/docs/CHATGPT-PLUGIN.md
index 330a4f9e..60f82f59 100644
--- a/docs/CHATGPT-PLUGIN.md
+++ b/docs/CHATGPT-PLUGIN.md
@@ -76,23 +76,24 @@ Fresh 3 also advertises the bounded `io.modelcontextprotocol/skills` extension.
For the complete non-ChatGPT MSO catalog, scopes, limits, A2A, providers, Tool Forge and other generic capabilities, see [`MCP.md`](./MCP.md).
-## OpenAI/Codex plugin package
+## OpenAI plugin package
-The repository root also carries `.codex-plugin/plugin.json` as an OpenAI/Codex compatibility package for the reviewed skills plus an optional registered-app mapping. It points directly at `./claude-skills/`, so the same reviewed skill bundles are reusable without maintaining a second copy. The package deliberately does **not** declare `mcpServers`: the live web-capable MSO MCP connection remains the separately authorized custom app at `/mcp`, preserving its OAuth scopes, server-side credentials, dynamic project MCP seams and browser/mobile availability instead of coupling those capabilities to a local plugin executor. `.app.json` is an intentionally empty OpenAI scaffold (`apps: {}`) until an exact registered app ID is available; this matches the supported plugin-creator scaffold and does not grant MCP access by itself. When an existing OpenAI registration is intentionally packaged, link only its exact registered ID—never a placeholder—and keep OAuth authorization on the live MSO app. Use `bun run plugin:link-app -- asdk_app_...`, `connector_...`, or `templated_apps_...`; if a copied plugin URL exposes `plugin_asdk_app_...`, the helper accepts it only as input and writes the canonical `asdk_app_...` ID. `bun run plugin:link-app -- --clear` restores the empty scaffold.
+The portable OpenAI package is generated privately by `bun run plugin:stage-private`; the source repository remains operator-neutral. Staging projects the reviewed `claude-skills/` SSOT into the portable package's required root `skills/` directory, generates a root Agent Plugins `plugin.json` using the supported `https://agent-plugins.org/schemas/1.0.0/plugin.schema.json` schema, and writes the OpenAI-specific app/interface metadata under `extensions.com.openai`. A rewritten `.codex-plugin/plugin.json` is retained only as a compatibility fallback for older clients.
-The OpenAI-facing repository shape is therefore:
+The staged package deliberately does **not** declare a bundled `mcp.json`: the live web-capable MSO MCP connection remains the separately authorized registered app at `/mcp`, preserving OAuth scopes, server-side credentials, dynamic project MCP seams and browser/mobile availability. The repository `.app.json` stays empty (`apps: {}`) so a maintainer-specific registered App ID is never committed. Staging resolves the exact App ID from private MSO Integrations, writes it only into the owner-private staged package, and redacts it from command output. A registered-app reference does not install, refresh, select, or authorize the app in ChatGPT.
+
+The source and staged shapes are therefore intentionally different:
```text
-MSO repo
-├── .codex-plugin/plugin.json # OpenAI/Codex compatibility manifest
-├── .app.json # registered-app mapping; empty until linked
-├── claude-skills/<skill>/
-│ ├── SKILL.md
-│ ├── contract.yaml
-│ └── agents/openai.yaml
-└── /mcp + /oauth/* # live custom MCP app, separately authorized
+MSO source owner-private staged package
+├── .codex-plugin/plugin.json ├── plugin.json
+├── .app.json apps: {} ├── .app.json real id, private
+├── claude-skills/<skill>/ ├── skills/<skill>/
+└── /mcp + /oauth/* └── .codex-plugin/plugin.json
```
+Use `bun run plugin:stage-private` to regenerate the portable private package and `bun run plugin:doctor-private` to verify portable/compatibility manifests, skill projection, private modes and redacted app binding. Installation/refresh remains a ChatGPT client action; after a package/app update, reload or refresh the app as required and test native UI in a **new conversation launched with the registered app/plugin selected**.
+
## Dynamic project capabilities without global project tools
MSO is generic and must not publish another project's MCP tool names.
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 80b604ec..51c95d07 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,7 @@
+## 2026-09-20 — Stage MSO as a portable OpenAI Agent Plugin
+
+Native MCP App acceptance still returned structured data when the current ChatGPT conversation reached MSO through the generic orchestration wrapper. Server descriptors/resources were already correct, but the owner-private plugin package was legacy-only and staged rather than installed. Private staging now emits the current portable Agent Plugins layout: root `plugin.json` with `extensions.com.openai.apps`, the reviewed `claude-skills/` tree projected to root `skills/`, private redacted `.app.json`, and a rewritten `.codex-plugin/plugin.json` compatibility fallback. The doctor validates both manifests, the projected skill set, owner-only modes and registered-app binding without printing the App ID, and recognizes both portable and legacy cached installs. Repository `.app.json` remains empty and no MCP credential or maintainer-specific App ID is committed. This fixes the MSO-owned packaging gap; ChatGPT installation/refresh/selection remains host-owned and must be accepted from a new app-selected conversation.
+
## 2026-09-20 — Distinguish Resend send-only scope from invalid credentials
HR provider UAT exposed a verification-model bug: MSO's Resend doctor probed only `GET /domains`, so a legitimate Sending-only key could receive 401/403 and then be persisted as `invalid` even though that response only proved the key lacked Domains-read capability. The doctor now treats those Resend-specific scope denials as capability-unavailable with sending explicitly unverified, while preserving strict invalidation for providers/endpoints where 401/403 actually establishes invalid access. It does not claim a Sending-only key is valid, does not send a probe email, does not broaden permissions, and never exposes the credential. Regression coverage locks both Resend 401/403 handling and the connection-health classification.
diff --git a/scripts/openai-plugin-doctor.mjs b/scripts/openai-plugin-doctor.mjs
index 87f08a65..86a9b3d4 100644
--- a/scripts/openai-plugin-doctor.mjs
+++ b/scripts/openai-plugin-doctor.mjs
@@ -5,6 +5,7 @@ import path from "node:path";
const home = os.homedir();
const argv = process.argv.slice(2);
+const PORTABLE_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
function option(name) {
const index = argv.indexOf(name);
@@ -40,12 +41,37 @@ async function isSafePrivatePath(target, expectedMode) {
}
}
+async function countSkills(root) {
+ try {
+ const entries = await fs.readdir(root, { withFileTypes: true });
+ let count = 0;
+ for (const entry of entries) {
+ if (!entry.isDirectory()) continue;
+ try {
+ const st = await fs.stat(path.join(root, entry.name, "SKILL.md"));
+ if (st.isFile()) count += 1;
+ } catch {}
+ }
+ return count;
+ } catch (error) {
+ if (error?.code === "ENOENT") return 0;
+ throw error;
+ }
+}
+
async function marketplaceDeclaresMso() {
const state = await readJson(marketplace);
if (!state || !Array.isArray(state.plugins)) return false;
return state.plugins.some((plugin) => plugin?.name === "mso");
}
+async function installedManifest(pluginVersionDir) {
+ const portable = await readJson(path.join(pluginVersionDir, "plugin.json"));
+ if (portable?.name === "mso") return portable;
+ const compatibility = await readJson(path.join(pluginVersionDir, ".codex-plugin", "plugin.json"));
+ return compatibility?.name === "mso" ? compatibility : null;
+}
+
async function cachedMsoInstalls() {
let marketplaces;
try {
@@ -76,22 +102,39 @@ async function cachedMsoInstalls() {
}
for (const version of versions) {
if (!version.isDirectory()) continue;
- const manifest = await readJson(path.join(pluginDir, version.name, ".codex-plugin", "plugin.json"));
- if (manifest?.name === "mso") count += 1;
+ if (await installedManifest(path.join(pluginDir, version.name))) count += 1;
}
}
}
return count;
}
-const pluginManifest = await readJson(path.join(stage, ".codex-plugin", "plugin.json"));
+const portableManifest = await readJson(path.join(stage, "plugin.json"));
+const compatibilityManifest = await readJson(path.join(stage, ".codex-plugin", "plugin.json"));
const appManifest = await readJson(path.join(stage, ".app.json"));
const binding = appManifest?.apps?.mso;
+
+const portableValid = Boolean(
+ portableManifest?.$schema === PORTABLE_SCHEMA &&
+ portableManifest?.name === "mso" &&
+ portableManifest?.extensions?.["com.openai"]?.apps === "./.app.json" &&
+ portableManifest?.extensions?.["com.openai"]?.interface &&
+ typeof portableManifest.extensions["com.openai"].interface === "object",
+);
+const compatibilityValid = Boolean(
+ compatibilityManifest?.name === "mso" &&
+ compatibilityManifest?.skills === "./skills/" &&
+ compatibilityManifest?.apps === "./.app.json",
+);
const bindingValid = Boolean(binding && canonicalId(binding.id) && binding.required === true);
-const staged = Boolean(pluginManifest && appManifest);
+const staged = Boolean(portableManifest && compatibilityManifest && appManifest);
+const skillCount = await countSkills(path.join(stage, "skills"));
+const skillsValid = skillCount > 0;
+
const stageModeSafe = await isSafePrivatePath(stage, 0o700);
const appModeSafe = await isSafePrivatePath(path.join(stage, ".app.json"), 0o600);
-const manifestLinksApp = pluginManifest?.apps === "./.app.json";
+const portableModeSafe = await isSafePrivatePath(path.join(stage, "plugin.json"), 0o600);
+const compatibilityModeSafe = await isSafePrivatePath(path.join(stage, ".codex-plugin", "plugin.json"), 0o600);
const marketplaceDeclared = await marketplaceDeclaresMso();
const installedCacheCount = await cachedMsoInstalls();
@@ -99,7 +142,12 @@ const status = {
staged,
stageModeSafe,
appModeSafe,
- manifestLinksApp,
+ portableModeSafe,
+ compatibilityModeSafe,
+ portableValid,
+ compatibilityValid,
+ skillsValid,
+ skillCount,
bindingPresent: Boolean(binding),
bindingValid,
marketplaceDeclared,
@@ -109,23 +157,36 @@ const status = {
console.log(
[
"openai-app: staged=" + (status.staged ? "yes" : "no"),
- "private-modes=" + (status.stageModeSafe && status.appModeSafe ? "safe" : "check"),
- "manifest-link=" + (status.manifestLinksApp ? "ok" : "missing"),
+ "private-modes=" + (status.stageModeSafe && status.appModeSafe && status.portableModeSafe && status.compatibilityModeSafe ? "safe" : "check"),
+ "portable-manifest=" + (status.portableValid ? "ok" : "invalid"),
+ "compat-manifest=" + (status.compatibilityValid ? "ok" : "invalid"),
+ "manifest-link=" + (status.portableValid ? "ok" : "missing"),
+ "skills=" + status.skillCount,
"binding=" + (status.bindingValid ? "present(redacted)" : status.bindingPresent ? "invalid(redacted)" : "missing"),
"marketplace-declared=" + (status.marketplaceDeclared ? "yes" : "no"),
"installed-cache=" + status.installedCacheCount,
].join("; "),
);
-if (!status.staged || !status.manifestLinksApp || !status.bindingValid || !status.stageModeSafe || !status.appModeSafe) {
+if (
+ !status.staged ||
+ !status.portableValid ||
+ !status.compatibilityValid ||
+ !status.skillsValid ||
+ !status.bindingValid ||
+ !status.stageModeSafe ||
+ !status.appModeSafe ||
+ !status.portableModeSafe ||
+ !status.compatibilityModeSafe
+) {
console.error("openai-app: private package is not installation-ready; App ID remains redacted");
process.exitCode = 2;
} else if (!status.marketplaceDeclared || status.installedCacheCount === 0) {
console.log(
- "openai-app: package is staged only. Staging does not install or refresh ChatGPT. Native MCP Apps acceptance must run through the registered app/direct app context or an actually installed plugin package.",
+ "openai-app: portable package is installation-ready but staged only. Staging does not install or refresh ChatGPT. Native MCP Apps acceptance must run through the registered app/direct app context or an actually installed plugin package.",
);
} else {
console.log(
- "openai-app: a local marketplace declaration and cached MSO plugin install were detected on this machine; start a new client conversation before native MCP Apps acceptance.",
+ "openai-app: a local marketplace declaration and cached MSO plugin install were detected on this machine; reload the client and start a new conversation before native MCP Apps acceptance.",
);
}
diff --git a/scripts/openai-plugin-doctor.test.ts b/scripts/openai-plugin-doctor.test.ts
index d042895a..6b6e7c96 100644
--- a/scripts/openai-plugin-doctor.test.ts
+++ b/scripts/openai-plugin-doctor.test.ts
@@ -17,17 +17,37 @@ async function fixture() {
const cache = path.join(root, "cache");
const appId = "asdk_app_privatefixture_do_not_print";
await mkdir(path.join(stage, ".codex-plugin"), { recursive: true, mode: 0o700 });
+ await mkdir(path.join(stage, "skills", "mso"), { recursive: true, mode: 0o700 });
+ await writeFile(
+ path.join(stage, "plugin.json"),
+ JSON.stringify({
+ $schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ name: "mso",
+ version: "0.2.21",
+ description: "MSO fixture",
+ extensions: {
+ "com.openai": {
+ apps: "./.app.json",
+ interface: { displayName: "MSO", capabilities: ["Read", "Write"] },
+ },
+ },
+ }),
+ { mode: 0o600 },
+ );
await writeFile(
path.join(stage, ".codex-plugin", "plugin.json"),
- JSON.stringify({ name: "mso", version: "0.2.21", apps: "./.app.json" }),
+ JSON.stringify({ name: "mso", version: "0.2.21", skills: "./skills/", apps: "./.app.json" }),
{ mode: 0o600 },
);
+ await writeFile(path.join(stage, "skills", "mso", "SKILL.md"), "---\nname: mso\ndescription: fixture skill\n---\n# MSO\n");
await writeFile(
path.join(stage, ".app.json"),
JSON.stringify({ apps: { mso: { id: appId, required: true } } }),
{ mode: 0o600 },
);
await chmod(stage, 0o700);
+ await chmod(path.join(stage, "plugin.json"), 0o600);
+ await chmod(path.join(stage, ".codex-plugin", "plugin.json"), 0o600);
await chmod(path.join(stage, ".app.json"), 0o600);
return { root, stage, marketplace, cache, appId };
}
@@ -53,20 +73,23 @@ function runDoctor(stage: string, marketplace: string, cache: string) {
}
describe("openai-plugin-doctor", () => {
- it("reports staged-only state without exposing the private app id", async () => {
+ it("reports a portable staged-only package without exposing the private app id", async () => {
const { stage, marketplace, cache, appId } = await fixture();
const stdout = runDoctor(stage, marketplace, cache);
expect(stdout).toContain("staged=yes");
expect(stdout).toContain("private-modes=safe");
+ expect(stdout).toContain("portable-manifest=ok");
+ expect(stdout).toContain("compat-manifest=ok");
expect(stdout).toContain("manifest-link=ok");
+ expect(stdout).toContain("skills=1");
expect(stdout).toContain("binding=present(redacted)");
expect(stdout).toContain("marketplace-declared=no");
expect(stdout).toContain("installed-cache=0");
- expect(stdout).toContain("package is staged only");
+ expect(stdout).toContain("portable package is installation-ready but staged only");
expect(stdout).not.toContain(appId);
});
- it("detects a local marketplace declaration and cached install without printing the binding", async () => {
+ it("detects a local marketplace declaration and portable cached install without printing the binding", async () => {
const { stage, marketplace, cache, appId } = await fixture();
await mkdir(path.dirname(marketplace), { recursive: true });
await writeFile(
@@ -82,9 +105,16 @@ describe("openai-plugin-doctor", () => {
],
}),
);
- const installed = path.join(cache, "personal", "mso", "local", ".codex-plugin");
+ const installed = path.join(cache, "personal", "mso", "local");
await mkdir(installed, { recursive: true });
- await writeFile(path.join(installed, "plugin.json"), JSON.stringify({ name: "mso", version: "0.2.21" }));
+ await writeFile(
+ path.join(installed, "plugin.json"),
+ JSON.stringify({
+ $schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ name: "mso",
+ version: "0.2.21",
+ }),
+ );
const stdout = runDoctor(stage, marketplace, cache);
expect(stdout).toContain("marketplace-declared=yes");
@@ -92,4 +122,17 @@ describe("openai-plugin-doctor", () => {
expect(stdout).toContain("cached MSO plugin install");
expect(stdout).not.toContain(appId);
});
+
+ it("still recognizes a legacy cached install as compatibility fallback", async () => {
+ const { stage, marketplace, cache } = await fixture();
+ await mkdir(path.dirname(marketplace), { recursive: true });
+ await writeFile(marketplace, JSON.stringify({ plugins: [{ name: "mso" }] }));
+ const installed = path.join(cache, "personal", "mso", "legacy", ".codex-plugin");
+ await mkdir(installed, { recursive: true });
+ await writeFile(path.join(installed, "plugin.json"), JSON.stringify({ name: "mso", version: "0.2.21" }));
+
+ const stdout = runDoctor(stage, marketplace, cache);
+ expect(stdout).toContain("marketplace-declared=yes");
+ expect(stdout).toContain("installed-cache=1");
+ });
});
diff --git a/scripts/stage-openai-plugin.mjs b/scripts/stage-openai-plugin.mjs
index 549e84d4..c55914fb 100755
--- a/scripts/stage-openai-plugin.mjs
+++ b/scripts/stage-openai-plugin.mjs
@@ -7,11 +7,44 @@ import { spawnSync } from "node:child_process";
const repo=path.resolve(path.dirname(new URL(import.meta.url).pathname),"..");
const stage=path.resolve(process.env.MSO_OPENAI_PLUGIN_STAGE??path.join(os.homedir(),".mso","private","plugin-packages","mso"));
const temp=stage+".tmp-"+process.pid;
+const legacySource=path.join(repo,".codex-plugin","plugin.json");
+const portableSchema="https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
+
+const legacy=JSON.parse(await fs.readFile(legacySource,"utf8"));
+if(legacy?.name!=="mso"||typeof legacy?.version!=="string"||!legacy?.interface||typeof legacy.interface!=="object"){
+ throw new Error("openai-app: source compatibility manifest is invalid");
+}
+
+const portable={
+ $schema:portableSchema,
+ name:legacy.name,
+ version:legacy.version,
+ description:legacy.description,
+ ...(legacy.author?{author:legacy.author}:{}),
+ ...(legacy.homepage?{homepage:legacy.homepage}:{}),
+ extensions:{
+ "com.openai":{
+ apps:"./.app.json",
+ interface:legacy.interface,
+ },
+ },
+};
+
await fs.rm(temp,{recursive:true,force:true});
await fs.mkdir(temp,{recursive:true,mode:0o700});
-for(const entry of [".codex-plugin","claude-skills"]){
- await fs.cp(path.join(repo,entry),path.join(temp,entry),{recursive:true,errorOnExist:false,force:true});
-}
+
+// Portable Agent Plugins discover skills only from root skills/. Keep claude-skills/
+// authoritative in source, but project that reviewed tree into the staged package.
+await fs.cp(path.join(repo,"claude-skills"),path.join(temp,"skills"),{recursive:true,errorOnExist:false,force:true});
+
+await fs.writeFile(path.join(temp,"plugin.json"),JSON.stringify(portable,null,2)+"\n",{mode:0o600});
+
+// Preserve the OpenAI/Codex compatibility manifest for clients that still consume it.
+// Its staged skill path points at the portable root skills/ projection.
+const compatibility={...legacy,skills:"./skills/",apps:"./.app.json"};
+await fs.mkdir(path.join(temp,".codex-plugin"),{recursive:true,mode:0o700});
+await fs.writeFile(path.join(temp,".codex-plugin","plugin.json"),JSON.stringify(compatibility,null,2)+"\n",{mode:0o600});
+
const linker=spawnSync(process.execPath,[path.join(repo,"scripts","link-openai-app.mjs"),"--output",path.join(temp,".app.json")],{
cwd:repo,stdio:["ignore","pipe","pipe"],encoding:"utf8",env:process.env,
});
@@ -20,11 +53,12 @@ if(linker.status!==0){
process.stderr.write(linker.stderr||"openai-app: private plugin staging failed\n");
process.exit(linker.status??2);
}
+
await fs.rm(stage,{recursive:true,force:true});
await fs.mkdir(path.dirname(stage),{recursive:true,mode:0o700});
await fs.rename(temp,stage);
await fs.chmod(stage,0o700);
-console.log("openai-app: private plugin package staged at "+stage+"; App ID is redacted and the source repository was not modified");
+console.log("openai-app: portable private plugin package staged at "+stage+"; App ID is redacted and the source repository was not modified");
const doctor=spawnSync(process.execPath,[path.join(repo,"scripts","openai-plugin-doctor.mjs")],{
cwd:repo,
diff --git a/scripts/stage-openai-plugin.test.ts b/scripts/stage-openai-plugin.test.ts
new file mode 100644
index 00000000..723cc9bc
--- /dev/null
+++ b/scripts/stage-openai-plugin.test.ts
@@ -0,0 +1,70 @@
+import { afterEach, describe, expect, it } from "vitest";
+import { mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
+import { execFileSync } from "node:child_process";
+import os from "node:os";
+import path from "node:path";
+
+const roots: string[] = [];
+afterEach(async () => {
+ await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
+});
+
+describe("stage-openai-plugin", () => {
+ it("projects official skills into a portable private package and keeps the app id redacted", async () => {
+ const root = await mkdtemp(path.join(os.tmpdir(), "mso-openai-plugin-stage-"));
+ roots.push(root);
+ const stage = path.join(root, "stage");
+ const store = path.join(root, "infra-providers.json");
+ const appId = "asdk_app_privatefixture_do_not_print";
+ const sourceSkills = await readdir(path.resolve("claude-skills"), { withFileTypes: true });
+ const sourceSkillCount = sourceSkills.filter((entry) => entry.isDirectory()).length;
+ await writeFile(
+ store,
+ JSON.stringify({
+ version: 2,
+ defaultUser: "rahmanef",
+ users: {
+ rahmanef: {
+ defaults: { "openai-app": "chatgpt-personal" },
+ connections: {
+ "openai-app": {
+ "chatgpt-personal": { values: { appId } },
+ },
+ },
+ },
+ },
+ }),
+ { mode: 0o600 },
+ );
+
+ const stdout = execFileSync(process.execPath, [path.resolve("scripts/stage-openai-plugin.mjs")], {
+ cwd: path.resolve("."),
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ MSO_OPENAI_PLUGIN_STAGE: stage,
+ OS_INFRA_STORE: store,
+ MSO_OPENAI_APP_USER: "rahmanef",
+ MSO_OPENAI_APP_CONNECTION: "chatgpt-personal",
+ },
+ });
+
+ const portable = JSON.parse(await readFile(path.join(stage, "plugin.json"), "utf8"));
+ const compatibility = JSON.parse(await readFile(path.join(stage, ".codex-plugin", "plugin.json"), "utf8"));
+ const app = JSON.parse(await readFile(path.join(stage, ".app.json"), "utf8"));
+
+ expect(portable).toMatchObject({
+ $schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ name: "mso",
+ extensions: { "com.openai": { apps: "./.app.json" } },
+ });
+ expect(compatibility.skills).toBe("./skills/");
+ expect(compatibility.apps).toBe("./.app.json");
+ expect((await stat(path.join(stage, "skills", "mso-agent-bootstrap", "SKILL.md"))).isFile()).toBe(true);
+ expect(app.apps.mso).toMatchObject({ id: appId, required: true });
+ expect(stdout).toContain("portable-manifest=ok");
+ expect(stdout).toContain("skills=" + sourceSkillCount);
+ expect(stdout).toContain("binding=present(redacted)");
+ expect(stdout).not.toContain(appId);
+ });
+});