Skip to content
Back to search

codex-multi-profile

SkillWorks with Claude CodeGitHub

Multi-workspace profile router, MCP server (.mcp.json) security auditor, and CLAUDE.md <-> AGENTS.md instruction bridge for Claude Code and OpenAI Codex. Isolates Enterprise, Open-Source Maintainer, and Personal profiles across ~/.claude and ~/.codex, and provides a native workspace switcher for the Microsoft Store Codex app on Windows.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/hung2124--codex-multi-profile/badge.svg)](/listings/hung2124--codex-multi-profile)

HTML

<a href="/listings/hung2124--codex-multi-profile"><img src="/api/listings/hung2124--codex-multi-profile/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

Requires Windows 10/11 and [Codex](https://chatgpt.com/codex) from the Microsoft Store:

irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex

Or via **npm / npx** (Node.js 18+):

npx codex-multi-profile install

This registers the currently signed-in workspace as `main`, places a **Codex** shortcut on the Desktop and Start menu, and starts a lightweight background watcher at sign-in (~25 MB, no window). `-NoAutoStart` skips the startup watcher.

Upgrading from the legacy 0.1–0.2 clone-based layout:

$env:CODEX_MP_REMOVE_LEGACY = '1'; irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 59 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. ---
  2. name: codex-multi-profile
  3. description: >-
  4. Multi-workspace profile router, MCP server (.mcp.json) security auditor, and CLAUDE.md <-> AGENTS.md
  5. instruction bridge for Claude Code and OpenAI Codex. Isolates Enterprise, Open-Source Maintainer, and
  6. Personal profiles across ~/.claude and ~/.codex, and provides a native workspace switcher for the
  7. Microsoft Store Codex app on Windows.
  8. ---
  9. # Codex Multi-Profile (Claude Code, MCP & OpenAI Codex)
  10. Open-source developer toolkit for isolating **authorized** Enterprise SSO, Client, and Open-Source Maintainer workspaces across **Claude Code** (`~/.claude`), **Model Context Protocol (`.mcp.json`)**, and **OpenAI Codex** (`~/.codex`).
  11. ## Cross-Platform CLI & SDK (`v2.0+`)
  12. ```bash
  13. # Audit .mcp.json for hardcoded tokens and non-loopback endpoints
  14. npx codex-multi-profile mcp-audit .mcp.json
  15. # Synchronize CLAUDE.md and AGENTS.md instructions
  16. npx codex-multi-profile sync-docs .
  17. # Inspect saved Claude Code or Codex profiles
  18. npx codex-multi-profile profiles claude --json
  19. ```
  20. ## Windows Store Codex Integration
  21. - Each workspace profile is stored as an isolated snapshot in `%LOCALAPPDATA%\CodexMultiProfile\accounts\<name>\auth.json`.
  22. - The **Codex** shortcut runs `Start-CodexAccounts.ps1` (hidden): it launches the Store Codex inside its
  23. package with DevTools bound to `127.0.0.1:9333`, injects `switcher-inject.js`, and bridges workspace switches.
  24. - Avatar menu (bottom-left) → **Accounts**: click = switch (2-3 s: only the `codex.exe app-server` child restarts, the window
  25. stays open), **Add account** (restarts on the sign-in screen to register another authorized workspace),
  26. pencil = rename, trash = remove. `Ctrl+Alt+A` opens the menu, `1`-`9` pick a workspace profile.
  27. - While Codex runs, rotated refresh tokens in the live `auth.json` are synced back into the active workspace profile.
  28. ## CLI (agents)
  29. ```powershell
  30. $cli = "$env:LOCALAPPDATA\CodexMultiProfile\CodexAccounts.ps1"
  31. powershell -NoProfile -ExecutionPolicy Bypass -File $cli list # -Json for machine output
  32. powershell -NoProfile -ExecutionPolicy Bypass -File $cli status
  33. powershell -NoProfile -ExecutionPolicy Bypass -File $cli save -Name work # save the login in use
  34. powershell -NoProfile -ExecutionPolicy Bypass -File $cli switch -Name work
  35. powershell -NoProfile -ExecutionPolicy Bypass -File $cli rename -Name work -NewName job
  36. powershell -NoProfile -ExecutionPolicy Bypass -File $cli remove -Name old
  37. ```
  38. `switch` restarts only Codex's app-server (2-3 s, the window stays) and stops a reply in progress; tell the user first.
  39. ## Rules
  40. - Never print or copy tokens; emails are shown masked (`ab***@domain`).
  41. - Do not use Codex's own **Log out** to change accounts: it can invalidate that login's saved copy. Use the menu.
  42. - A watcher (`CodexAccountsWatcher.exe`, HKCU Run) starts the helper whenever the Store Codex runs without it; from the
  43. original icon Codex restarts once to get the menu. `status` says whether the menu is attached.
  44. - Usage bars come from `chatgpt.com/backend-api/wham/usage` with each saved account's own token (numbers only reach
  45. the page).
  46. - Log: `%LOCALAPPDATA%\CodexMultiProfile\codex-accounts.log` (masked).
README.md · README · 179 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # Codex Multi-Profile
  2. <p align="center">
  3. <a href="https://github.com/Hung2124/codex-multi-profile/actions/workflows/ci.yml"><img src="https://github.com/Hung2124/codex-multi-profile/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  4. <a href="https://www.npmjs.com/package/codex-multi-profile"><img src="https://img.shields.io/npm/v/codex-multi-profile?color=cb3837&label=npm" alt="npm version"></a>
  5. <a href="https://github.com/Hung2124/codex-multi-profile/stargazers"><img src="https://img.shields.io/github/stars/Hung2124/codex-multi-profile?color=blue&label=stars" alt="GitHub stars"></a>
  6. <a href="https://github.com/Hung2124/codex-multi-profile/releases"><img src="https://img.shields.io/github/v/release/Hung2124/codex-multi-profile?label=release" alt="Release"></a>
  7. <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-yellow.svg" alt="MIT"></a>
  8. <img src="https://img.shields.io/badge/Claude_Code_%26_MCP-Ready-D97757.svg" alt="Claude Code & MCP">
  9. <img src="https://img.shields.io/badge/OpenAI_Codex-Supported-10A37F.svg" alt="OpenAI Codex">
  10. </p>
  11. <p align="center">
  12. <strong>Multi-workspace profile router, MCP server security auditor, and <code>CLAUDE.md</code> &harr; <code>AGENTS.md</code> instruction bridge for Claude Code and OpenAI Codex.</strong><br>
  13. Isolate Enterprise, Open-Source Maintainer, and Personal agent environments across repositories.
  14. </p>
  15. <p align="center">
  16. <a href="README.vi.md">Tiếng Việt</a> &middot;
  17. <a href="docs/architecture.md">How it works</a> &middot;
  18. <a href="docs/troubleshooting.md">Troubleshooting</a> &middot;
  19. <a href="SUPPORT.md">Support</a>
  20. </p>
  21. <p align="center">
  22. <img src="docs/images/accounts-menu.png" alt="Workspace profiles in the avatar menu with telemetry and environment isolation" width="366">
  23. </p>
  24. > Built for developers, open-source maintainers, and consulting engineers who work across separate **authorized** Enterprise SSO, Client, and Personal workspaces in **Claude Code** and **OpenAI Codex**.
  25. ## Core Capabilities (v2.0)
  26. | Module | What it solves |
  27. |:---|:---|
  28. | **Claude Code & Codex Profile Store** (`WorkspaceProfileStore`) | Isolate `~/.claude/settings.json`, `~/.codex`, and workspace `.mcp.json` profiles (`enterprise`, `oss-maintainer`, `research`) with atomic file swaps |
  29. | **MCP Security & Isolation Auditor** (`mcp-audit`) | Statically audits `.mcp.json` and `claude_desktop_config.json` for hardcoded credentials (`sk-ant-*`, `ghp_*`), non-loopback HTTP/SSE endpoints, and unsafe shell wrappers |
  30. | **Instruction Bridge** (`sync-docs`) | Deterministically synchronizes shared engineering rules between `CLAUDE.md` (Claude Code) and `AGENTS.md` (OpenAI Codex) across polyglot repositories |
  31. | **Windows Store Codex Workspace Switcher** | Hot-switches authorized Enterprise, Team, and Personal workspaces in 2–3 seconds directly from the Microsoft Store Codex avatar menu |
  32. ## Cross-Platform CLI & Node.js SDK (Claude Code, MCP & Codex)
  33. Requires Node.js 18+ on macOS, Linux, or Windows:
  34. ```bash
  35. # Install globally or invoke via npx
  36. npm install -g codex-multi-profile
  37. # 1. Audit .mcp.json for secret leakage and non-loopback MCP transports
  38. npx codex-multi-profile mcp-audit .mcp.json
  39. # 2. Synchronize CLAUDE.md <-> AGENTS.md instructions in a repository
  40. npx codex-multi-profile sync-docs .
  41. # 3. List isolated Claude Code (~/.claude) or Codex (~/.codex) profiles
  42. npx codex-multi-profile profiles claude
  43. ```
  44. ### Programmatic SDK Usage (Node.js / TypeScript)
  45. ```javascript
  46. const {
  47. WorkspaceProfileStore,
  48. auditMcpConfig,
  49. syncWorkspaceInstructions
  50. } = require("codex-multi-profile");
  51. // 1. Audit an MCP configuration before activating a workspace profile
  52. const audit = auditMcpConfig({
  53. mcpServers: {
  54. github: {
  55. command: "npx",
  56. args: ["-y", "@modelcontextprotocol/server-github"],
  57. env: { GITHUB_PERSONAL_ACCESS_TOKEN: "${GITHUB_PERSONAL_ACCESS_TOKEN}" }
  58. }
  59. }
  60. });
  61. if (!audit.valid) throw new Error("MCP security audit failed");
  62. // 2. Save and activate an isolated Claude Code profile
  63. const store = new WorkspaceProfileStore();
  64. store.saveProfile("oss-maintainer", {
  65. agent: "claude",
  66. settings: { model: "claude-sonnet-4-5" }
  67. });
  68. store.activateProfile("oss-maintainer", { agent: "claude", workspaceDir: process.cwd() });
  69. // 3. Keep CLAUDE.md and AGENTS.md aligned
  70. syncWorkspaceInstructions(process.cwd(), { direction: "claude-to-codex" });
  71. ```
  72. ---
  73. ## Native Windows Desktop Integration (Microsoft Store Codex App)
  74. Click your avatar at the bottom-left of the Windows Store Codex app. Under your identity row there is an **Accounts** workspace section:
  75. | In the menu | Does |
  76. |:---|:---|
  77. | Click a workspace profile | Switches to that workspace in 2-3 seconds; the Codex window stays open (from a sign-in screen Codex restarts, ~10 s) |
  78. | **Add account** | Codex restarts on its sign-in screen; sign in with your other authorized workspace and save it under a profile label |
  79. | Pencil / trash (hover a row) | Rename / remove a saved workspace profile (the active profile cannot be removed) |
  80. | `1`-`9` while the menu is open | Activate the workspace profile with that number |
  81. | `Ctrl+Alt+A` | Open the workspace switcher from anywhere in Codex |
  82. | Telemetry bars | Displays remaining session quota windows (5h and weekly windows) per workspace; hover for reset timestamp |
  83. The menu follows the application's language (Vietnamese or English) and its light / dark theme.
  84. <p align="center">
  85. <img src="docs/images/add-account.png" alt="Add workspace profile dialog" width="560">
  86. </p>
  87. <sub>Screenshots use synthetic profiles; rendered from <code>switcher-inject.js</code> with
  88. <code>node tools/screenshots/capture.mjs</code>.</sub>
  89. ## Install (Windows Desktop Helper)
  90. Requires Windows 10/11 and [Codex](https://chatgpt.com/codex) from the Microsoft Store:
  91. ```powershell
  92. irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
  93. ```
  94. Or via **npm / npx** (Node.js 18+):
  95. ```powershell
  96. npx codex-multi-profile install
  97. ```
  98. This registers the currently signed-in workspace as `main`, places a **Codex** shortcut on the Desktop and Start menu, and starts a lightweight background watcher at sign-in (~25 MB, no window). `-NoAutoStart` skips the startup watcher.
  99. Upgrading from the legacy 0.1–0.2 clone-based layout:
  100. ```powershell
  101. $env:CODEX_MP_REMOVE_LEGACY = '1'; irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
  102. ```
  103. ## Good to know
  104. - **Use the profile menu instead of "Log out" when switching workspaces.** Logging out inside the app revokes the active refresh token on the server.
  105. - A saved session that expired shows the sign-in screen after switching; signing in again refreshes the stored profile automatically.
  106. - Active streaming generations are stopped cleanly before swapping credentials.
  107. - The local helper runs only while the app is open (~130 MB, near-zero CPU).
  108. ## Command line (CI, agents, scripts)
  109. ```powershell
  110. # Cross-platform MCP & instruction tooling:
  111. codex-multi-profile mcp-audit .mcp.json --json
  112. codex-multi-profile sync-docs .
  113. codex-multi-profile profiles claude --json
  114. # Windows Desktop workspace profile management:
  115. codex-multi-profile list --json
  116. codex-multi-profile status
  117. codex-multi-profile switch enterprise
  118. # Or directly via PowerShell:
  119. $cli = "$env:LOCALAPPDATA\CodexMultiProfile\CodexAccounts.ps1"
  120. powershell -NoProfile -ExecutionPolicy Bypass -File $cli list # or: status | save -Name x | switch -Name x | rename -Name x -NewName y | remove -Name x | lang -Name vi
  121. ```
  122. ## Uninstall
  123. ```powershell
  124. powershell -NoProfile -ExecutionPolicy Bypass -File "$env:LOCALAPPDATA\CodexMultiProfile\Uninstall-CodexMultiProfile.ps1" # add -RemoveAccounts to delete saved profiles
  125. ```
  126. `~\.codex` and `~\.claude` (conversations, project memory, and active settings) are never deleted.
  127. ## Privacy and security
  128. - Saved workspace profiles stay on disk (`%LOCALAPPDATA%\CodexMultiProfile` on Windows or `~/.config/codex-multi-profile` on macOS/Linux). Nothing is transmitted externally.
  129. - The UI layer only ever receives masked emails (`ab***@example.com`), never raw tokens.
  130. - The `mcp-audit` command flags plaintext secrets in `.mcp.json` before they can be committed or loaded into an untrusted workspace.
  131. - Application binaries are never modified. See [docs/architecture.md](docs/architecture.md) and [SECURITY.md](SECURITY.md).
  132. ## License
  133. MIT
cli.js · Bundled script · 128 lines · 1 finding marked
  1. #!/usr/bin/env node
  2. "use strict";
  3. const path = require("path");
  4. const { spawnSync } = require("child_process");
  5. const {
  6. getInstallRoot,
  7. getAccountsScriptPath,
  8. runCodexAccounts,
  9. auditMcpFile,
  10. syncWorkspaceInstructions,
  11. WorkspaceProfileStore
  12. } = require("./index");
  13. const rawArgs = process.argv.slice(2);
  14. if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
  15. console.log([
  16. "codex-multi-profile — Multi-Workspace Profile Router & MCP Isolation Toolkit for Claude Code and OpenAI Codex",
  17. "",
  18. "Cross-Platform Commands (Claude Code, MCP & Codex):",
  19. " npx codex-multi-profile mcp-audit [path] Audit .mcp.json / Claude Code MCP server security & token exposure",
  20. " npx codex-multi-profile sync-docs [dir] Synchronize CLAUDE.md <-> AGENTS.md instructions across a repo",
  21. " npx codex-multi-profile profiles [claude|codex] List isolated Claude Code (~/.claude) or Codex (~/.codex) profiles",
  22. "",
  23. "Windows Desktop Commands (Microsoft Store Codex App):",
  24. " npx codex-multi-profile install Install or update the Windows Store Codex workspace helper",
  25. " npx codex-multi-profile list [--json] List saved workspace profiles and active status",
  26. " npx codex-multi-profile status Show Store app, local CDP bridge, and active workspace status",
  27. " npx codex-multi-profile save <name> Save the currently active workspace profile",
  28. " npx codex-multi-profile switch <name> Switch active workspace profile (2-3s hot reload)",
  29. " npx codex-multi-profile rename <old> <new> Rename a saved workspace profile",
  30. " npx codex-multi-profile remove <name> Remove a saved workspace profile",
  31. " npx codex-multi-profile lang <auto|vi|en> Set workspace menu language",
  32. "",
  33. `Profile store root: ${getInstallRoot()}`
  34. ].join("\n"));
  35. process.exit(0);
  36. }
  37. if (rawArgs.includes("--version") || rawArgs.includes("-v")) {
  38. const pkg = require("./package.json");
  39. console.log(pkg.version);
  40. process.exit(0);
  41. }
  42. const cmd = (rawArgs[0] || "list").toLowerCase();
  43. if (cmd === "mcp-audit") {
  44. const targetFile = path.resolve(rawArgs[1] || ".mcp.json");
  45. try {
  46. const res = auditMcpFile(targetFile, { allowRemoteHttp: rawArgs.includes("--allow-remote") });
  47. if (rawArgs.includes("--json")) {
  48. console.log(JSON.stringify(res, null, 2));
  49. } else {
  50. console.log(`Audited ${res.serverCount} MCP server(s) in ${targetFile}: ${res.valid ? "PASS" : "FAIL"}`);
  51. for (const f of res.findings) {
  52. console.log(` [${f.severity.toUpperCase()}] (${f.code}) ${f.server}: ${f.message}`);
  53. }
  54. }
  55. process.exit(res.valid ? 0 : 1);
  56. } catch (err) {
  57. console.error(`Error auditing MCP config at ${targetFile}: ${err.message}`);
  58. process.exit(1);
  59. }
  60. }
  61. if (cmd === "sync-docs") {
  62. const dir = path.resolve(rawArgs[1] || ".");
  63. const dryRun = rawArgs.includes("--dry-run");
  64. const res = syncWorkspaceInstructions(dir, { dryRun });
  65. if (rawArgs.includes("--json")) {
  66. console.log(JSON.stringify(res, null, 2));
  67. } else if (res.action === "none") {
  68. console.log(`No CLAUDE.md or AGENTS.md found in ${dir}.`);
  69. } else {
  70. console.log(
  71. `${dryRun ? "[DRY-RUN] " : ""}Synced (${res.action}): ${res.sectionCount} section(s) -> ${path.basename(res.targetFile)} (updated=${res.updated})`
  72. );
  73. }
  74. process.exit(0);
  75. }
  76. if (cmd === "profiles") {
  77. const agent = (rawArgs[1] || "claude").toLowerCase() === "codex" ? "codex" : "claude";
  78. const store = new WorkspaceProfileStore();
  79. const list = store.listProfiles(agent);
  80. if (rawArgs.includes("--json")) {
  81. console.log(JSON.stringify(list, null, 2));
  82. } else if (list.length === 0) {
  83. console.log(`No saved ${agent} configuration profiles in ${store.getProfilesDir(agent)}.`);
  84. } else {
  85. for (const p of list) {
  86. console.log(`${p.slug}\tagent=${p.agent}\tmcp=${p.hasMcpConfig}\thash=${p.settingsHash || "none"}`);
  87. }
  88. }
  89. process.exit(0);
  90. }
  91. if (cmd === "install" || cmd === "setup") {
  92. const installCmd = "irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex";
  93. const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", installCmd], {
  94. stdio: "inherit"
  95. });
  96. process.exit(res.status ?? 0);
  97. }
  98. const mapped = [];
  99. if (cmd === "list") {
  100. mapped.push("list");
  101. if (rawArgs.includes("--json")) mapped.push("-Json");
  102. } else if (cmd === "status") {
  103. mapped.push("status");
  104. } else if (cmd === "save" && rawArgs[1]) {
  105. mapped.push("save", "-Name", rawArgs[1]);
  106. } else if (cmd === "switch" && rawArgs[1]) {
  107. mapped.push("switch", "-Name", rawArgs[1]);
  108. } else if (cmd === "rename" && rawArgs[1] && rawArgs[2]) {
  109. mapped.push("rename", "-Name", rawArgs[1], "-NewName", rawArgs[2]);
  110. } else if (cmd === "remove" && rawArgs[1]) {
  111. mapped.push("remove", "-Name", rawArgs[1]);
  112. } else if (cmd === "lang" && rawArgs[1]) {
  113. mapped.push("lang", "-Name", rawArgs[1]);
  114. } else {
  115. mapped.push(...rawArgs);
  116. }
  117. process.exit(runCodexAccounts(mapped));
index.js · Bundled script · 61 lines · 1 finding marked
  1. "use strict";
  2. const { spawnSync } = require("child_process");
  3. const path = require("path");
  4. const os = require("os");
  5. const fs = require("fs");
  6. const { auditMcpConfig, auditMcpFile } = require("./src/mcp-auditor");
  7. const { MCP_PRESETS, getMcpPreset, listMcpPresets, composeMcpConfig } = require("./src/mcp-presets");
  8. const { parseAgentMarkdown, renderAgentMarkdown, syncWorkspaceInstructions } = require("./src/instruction-bridge");
  9. const { normalizeProfileSlug, maskEmailAddress, WorkspaceProfileStore } = require("./src/profile-manager");
  10. function getInstallRoot() {
  11. if (process.platform === "win32") {
  12. const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
  13. return path.join(localAppData, "CodexMultiProfile");
  14. }
  15. return path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "codex-multi-profile");
  16. }
  17. function getAccountsScriptPath() {
  18. return path.join(getInstallRoot(), "CodexAccounts.ps1");
  19. }
  20. function runCodexAccounts(args = ["list"]) {
  21. if (process.platform !== "win32") {
  22. throw new Error("Native Windows Store Codex app integration requires Windows 10/11. Use `profiles`, `mcp-audit`, or `sync-docs` on macOS/Linux.");
  23. }
  24. const scriptPath = getAccountsScriptPath();
  25. if (!fs.existsSync(scriptPath)) {
  26. const installCmd = "irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex";
  27. const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", installCmd], {
  28. stdio: "inherit"
  29. });
  30. return res.status ?? 0;
  31. }
  32. const res = spawnSync(
  33. "powershell.exe",
  34. ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath, ...args],
  35. { stdio: "inherit" }
  36. );
  37. return res.status ?? 0;
  38. }
  39. module.exports = {
  40. getInstallRoot,
  41. getAccountsScriptPath,
  42. runCodexAccounts,
  43. auditMcpConfig,
  44. auditMcpFile,
  45. parseAgentMarkdown,
  46. renderAgentMarkdown,
  47. syncWorkspaceInstructions,
  48. normalizeProfileSlug,
  49. maskEmailAddress,
  50. WorkspaceProfileStore,
  51. MCP_PRESETS,
  52. getMcpPreset,
  53. listMcpPresets,
  54. composeMcpConfig
  55. };
install.ps1 · Bundled script · 70 lines · 2 findings marked
  1. #Requires -Version 5.1
  2. <#
  3. .SYNOPSIS
  4. Download this repo and run the Windows installer.
  5. .EXAMPLE
  6. irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 7 on GitHub
  7. .EXAMPLE
  8. powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -Ref v0.4.0
  9. .EXAMPLE
  10. # Upgrading from the old clone-based version: import its logins and remove it
  11. $env:CODEX_MP_REMOVE_LEGACY = '1'; irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
  12. #>
  13. [CmdletBinding()]
  14. param(
  15. [string]$Repo = 'Hung2124/codex-multi-profile',
  16. [string]$Ref = 'main',
  17. [switch]$KeepDownload,
  18. [switch]$RemoveLegacy
  19. )
  20. $ErrorActionPreference = 'Stop'
  21. if (-not $PSBoundParameters.ContainsKey('Ref') -and $env:CODEX_MP_REF) {
  22. $Ref = $env:CODEX_MP_REF
  23. }
  24. if (-not $PSBoundParameters.ContainsKey('RemoveLegacy') -and $env:CODEX_MP_REMOVE_LEGACY -in @('1', 'true', 'yes', 'on')) {
  25. $RemoveLegacy = $true
  26. }
  27. $tmp = Join-Path $env:TEMP ("codex-multi-profile-" + [guid]::NewGuid().ToString('n'))
  28. New-Item -ItemType Directory -Force -Path $tmp | Out-Null
  29. try {
  30. $zip = Join-Path $tmp 'src.zip'
  31. if ($Ref -match '^(refs/)?tags/') {
  32. $tag = $Ref -replace '^(refs/)?tags/', ''
  33. $url = "https://github.com/$Repo/archive/refs/tags/$tag.zip"
  34. }
  35. elseif ($Ref -match '^v?\d+\.\d+') {
  36. $url = "https://github.com/$Repo/archive/refs/tags/$Ref.zip"
  37. }
  38. else {
  39. $url = "https://github.com/$Repo/archive/refs/heads/$Ref.zip"
  40. }
  41. Write-Host "Downloading $url"
  42. Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing
  43. Expand-Archive -LiteralPath $zip -DestinationPath $tmp -Force
  44. $inner = Get-ChildItem -LiteralPath $tmp -Directory |
  45. Where-Object { $_.Name -like 'codex-multi-profile-*' } |
  46. Select-Object -First 1
  47. if (-not $inner) { throw "Unzipped repo folder not found under $tmp" }
  48. $installer = Join-Path $inner.FullName 'scripts\Install-CodexMultiProfile.ps1'
  49. if (-not (Test-Path -LiteralPath $installer)) { throw "Installer missing: $installer" }
  50. $installArgs = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $installer)
  51. if ($RemoveLegacy) { $installArgs += '-RemoveLegacy' }
  52. & powershell.exe @installArgs
  53. }
  54. finally {
  55. if (-not $KeepDownload -and (Test-Path -LiteralPath $tmp)) {
  56. Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
  57. }
  58. elseif ($KeepDownload) {
  59. Write-Host "Kept download at $tmp"
  60. }
  61. }

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.