codex-multi-profile
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.
Badge for your README
Markdown
[](/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
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.
- ---
- name: codex-multi-profile
- description: >-
- 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.
- ---
- # Codex Multi-Profile (Claude Code, MCP & OpenAI Codex)
- 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`).
- ## Cross-Platform CLI & SDK (`v2.0+`)
- ```bash
- # Audit .mcp.json for hardcoded tokens and non-loopback endpoints
- npx codex-multi-profile mcp-audit .mcp.json
- # Synchronize CLAUDE.md and AGENTS.md instructions
- npx codex-multi-profile sync-docs .
- # Inspect saved Claude Code or Codex profiles
- npx codex-multi-profile profiles claude --json
- ```
- ## Windows Store Codex Integration
- - Each workspace profile is stored as an isolated snapshot in `%LOCALAPPDATA%\CodexMultiProfile\accounts\<name>\auth.json`.
- - The **Codex** shortcut runs `Start-CodexAccounts.ps1` (hidden): it launches the Store Codex inside its
- package with DevTools bound to `127.0.0.1:9333`, injects `switcher-inject.js`, and bridges workspace switches.
- - Avatar menu (bottom-left) → **Accounts**: click = switch (2-3 s: only the `codex.exe app-server` child restarts, the window
- stays open), **Add account** (restarts on the sign-in screen to register another authorized workspace),
- pencil = rename, trash = remove. `Ctrl+Alt+A` opens the menu, `1`-`9` pick a workspace profile.
- - While Codex runs, rotated refresh tokens in the live `auth.json` are synced back into the active workspace profile.
- ## CLI (agents)
- ```powershell
- $cli = "$env:LOCALAPPDATA\CodexMultiProfile\CodexAccounts.ps1"
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli list # -Json for machine output
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli status
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli save -Name work # save the login in use
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli switch -Name work
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli rename -Name work -NewName job
- powershell -NoProfile -ExecutionPolicy Bypass -File $cli remove -Name old
- ```
- `switch` restarts only Codex's app-server (2-3 s, the window stays) and stops a reply in progress; tell the user first.
- ## Rules
- - Never print or copy tokens; emails are shown masked (`ab***@domain`).
- - Do not use Codex's own **Log out** to change accounts: it can invalidate that login's saved copy. Use the menu.
- - A watcher (`CodexAccountsWatcher.exe`, HKCU Run) starts the helper whenever the Store Codex runs without it; from the
- original icon Codex restarts once to get the menu. `status` says whether the menu is attached.
- - Usage bars come from `chatgpt.com/backend-api/wham/usage` with each saved account's own token (numbers only reach
- the page).
- - 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.
- # Codex Multi-Profile
- <p align="center">
- <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>
- <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>
- <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>
- <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>
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-yellow.svg" alt="MIT"></a>
- <img src="https://img.shields.io/badge/Claude_Code_%26_MCP-Ready-D97757.svg" alt="Claude Code & MCP">
- <img src="https://img.shields.io/badge/OpenAI_Codex-Supported-10A37F.svg" alt="OpenAI Codex">
- </p>
- <p align="center">
- <strong>Multi-workspace profile router, MCP server security auditor, and <code>CLAUDE.md</code> ↔ <code>AGENTS.md</code> instruction bridge for Claude Code and OpenAI Codex.</strong><br>
- Isolate Enterprise, Open-Source Maintainer, and Personal agent environments across repositories.
- </p>
- <p align="center">
- <a href="README.vi.md">Tiếng Việt</a> ·
- <a href="docs/architecture.md">How it works</a> ·
- <a href="docs/troubleshooting.md">Troubleshooting</a> ·
- <a href="SUPPORT.md">Support</a>
- </p>
- <p align="center">
- <img src="docs/images/accounts-menu.png" alt="Workspace profiles in the avatar menu with telemetry and environment isolation" width="366">
- </p>
- > 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**.
- ## Core Capabilities (v2.0)
- | Module | What it solves |
- |:---|:---|
- | **Claude Code & Codex Profile Store** (`WorkspaceProfileStore`) | Isolate `~/.claude/settings.json`, `~/.codex`, and workspace `.mcp.json` profiles (`enterprise`, `oss-maintainer`, `research`) with atomic file swaps |
- | **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 |
- | **Instruction Bridge** (`sync-docs`) | Deterministically synchronizes shared engineering rules between `CLAUDE.md` (Claude Code) and `AGENTS.md` (OpenAI Codex) across polyglot repositories |
- | **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 |
- ## Cross-Platform CLI & Node.js SDK (Claude Code, MCP & Codex)
- Requires Node.js 18+ on macOS, Linux, or Windows:
- ```bash
- # Install globally or invoke via npx
- npm install -g codex-multi-profile
- # 1. Audit .mcp.json for secret leakage and non-loopback MCP transports
- npx codex-multi-profile mcp-audit .mcp.json
- # 2. Synchronize CLAUDE.md <-> AGENTS.md instructions in a repository
- npx codex-multi-profile sync-docs .
- # 3. List isolated Claude Code (~/.claude) or Codex (~/.codex) profiles
- npx codex-multi-profile profiles claude
- ```
- ### Programmatic SDK Usage (Node.js / TypeScript)
- ```javascript
- const {
- WorkspaceProfileStore,
- auditMcpConfig,
- syncWorkspaceInstructions
- } = require("codex-multi-profile");
- // 1. Audit an MCP configuration before activating a workspace profile
- const audit = auditMcpConfig({
- mcpServers: {
- github: {
- command: "npx",
- args: ["-y", "@modelcontextprotocol/server-github"],
- env: { GITHUB_PERSONAL_ACCESS_TOKEN: "${GITHUB_PERSONAL_ACCESS_TOKEN}" }
- }
- }
- });
- if (!audit.valid) throw new Error("MCP security audit failed");
- // 2. Save and activate an isolated Claude Code profile
- const store = new WorkspaceProfileStore();
- store.saveProfile("oss-maintainer", {
- agent: "claude",
- settings: { model: "claude-sonnet-4-5" }
- });
- store.activateProfile("oss-maintainer", { agent: "claude", workspaceDir: process.cwd() });
- // 3. Keep CLAUDE.md and AGENTS.md aligned
- syncWorkspaceInstructions(process.cwd(), { direction: "claude-to-codex" });
- ```
- ---
- ## Native Windows Desktop Integration (Microsoft Store Codex App)
- Click your avatar at the bottom-left of the Windows Store Codex app. Under your identity row there is an **Accounts** workspace section:
- | In the menu | Does |
- |:---|:---|
- | 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) |
- | **Add account** | Codex restarts on its sign-in screen; sign in with your other authorized workspace and save it under a profile label |
- | Pencil / trash (hover a row) | Rename / remove a saved workspace profile (the active profile cannot be removed) |
- | `1`-`9` while the menu is open | Activate the workspace profile with that number |
- | `Ctrl+Alt+A` | Open the workspace switcher from anywhere in Codex |
- | Telemetry bars | Displays remaining session quota windows (5h and weekly windows) per workspace; hover for reset timestamp |
- The menu follows the application's language (Vietnamese or English) and its light / dark theme.
- <p align="center">
- <img src="docs/images/add-account.png" alt="Add workspace profile dialog" width="560">
- </p>
- <sub>Screenshots use synthetic profiles; rendered from <code>switcher-inject.js</code> with
- <code>node tools/screenshots/capture.mjs</code>.</sub>
- ## Install (Windows Desktop Helper)
- Requires Windows 10/11 and [Codex](https://chatgpt.com/codex) from the Microsoft Store:
- ```powershell
- irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
- ```
- Or via **npm / npx** (Node.js 18+):
- ```powershell
- 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:
- ```powershell
- $env:CODEX_MP_REMOVE_LEGACY = '1'; irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
- ```
- ## Good to know
- - **Use the profile menu instead of "Log out" when switching workspaces.** Logging out inside the app revokes the active refresh token on the server.
- - A saved session that expired shows the sign-in screen after switching; signing in again refreshes the stored profile automatically.
- - Active streaming generations are stopped cleanly before swapping credentials.
- - The local helper runs only while the app is open (~130 MB, near-zero CPU).
- ## Command line (CI, agents, scripts)
- ```powershell
- # Cross-platform MCP & instruction tooling:
- codex-multi-profile mcp-audit .mcp.json --json
- codex-multi-profile sync-docs .
- codex-multi-profile profiles claude --json
- # Windows Desktop workspace profile management:
- codex-multi-profile list --json
- codex-multi-profile status
- codex-multi-profile switch enterprise
- # Or directly via PowerShell:
- $cli = "$env:LOCALAPPDATA\CodexMultiProfile\CodexAccounts.ps1"
- 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
- ```
- ## Uninstall
- ```powershell
- powershell -NoProfile -ExecutionPolicy Bypass -File "$env:LOCALAPPDATA\CodexMultiProfile\Uninstall-CodexMultiProfile.ps1" # add -RemoveAccounts to delete saved profiles
- ```
- `~\.codex` and `~\.claude` (conversations, project memory, and active settings) are never deleted.
- ## Privacy and security
- - Saved workspace profiles stay on disk (`%LOCALAPPDATA%\CodexMultiProfile` on Windows or `~/.config/codex-multi-profile` on macOS/Linux). Nothing is transmitted externally.
- - The UI layer only ever receives masked emails (`ab***@example.com`), never raw tokens.
- - The `mcp-audit` command flags plaintext secrets in `.mcp.json` before they can be committed or loaded into an untrusted workspace.
- - Application binaries are never modified. See [docs/architecture.md](docs/architecture.md) and [SECURITY.md](SECURITY.md).
- ## License
- MIT
cli.js · Bundled script · 128 lines · 1 finding marked
- #!/usr/bin/env node
- "use strict";
- const path = require("path");
- const { spawnSync } = require("child_process");
- const {
- getInstallRoot,
- getAccountsScriptPath,
- runCodexAccounts,
- auditMcpFile,
- syncWorkspaceInstructions,
- WorkspaceProfileStore
- } = require("./index");
- const rawArgs = process.argv.slice(2);
- if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
- console.log([
- "codex-multi-profile — Multi-Workspace Profile Router & MCP Isolation Toolkit for Claude Code and OpenAI Codex",
- "",
- "Cross-Platform Commands (Claude Code, MCP & Codex):",
- " npx codex-multi-profile mcp-audit [path] Audit .mcp.json / Claude Code MCP server security & token exposure",
- " npx codex-multi-profile sync-docs [dir] Synchronize CLAUDE.md <-> AGENTS.md instructions across a repo",
- " npx codex-multi-profile profiles [claude|codex] List isolated Claude Code (~/.claude) or Codex (~/.codex) profiles",
- "",
- "Windows Desktop Commands (Microsoft Store Codex App):",
- " npx codex-multi-profile install Install or update the Windows Store Codex workspace helper",
- " npx codex-multi-profile list [--json] List saved workspace profiles and active status",
- " npx codex-multi-profile status Show Store app, local CDP bridge, and active workspace status",
- " npx codex-multi-profile save <name> Save the currently active workspace profile",
- " npx codex-multi-profile switch <name> Switch active workspace profile (2-3s hot reload)",
- " npx codex-multi-profile rename <old> <new> Rename a saved workspace profile",
- " npx codex-multi-profile remove <name> Remove a saved workspace profile",
- " npx codex-multi-profile lang <auto|vi|en> Set workspace menu language",
- "",
- `Profile store root: ${getInstallRoot()}`
- ].join("\n"));
- process.exit(0);
- }
- if (rawArgs.includes("--version") || rawArgs.includes("-v")) {
- const pkg = require("./package.json");
- console.log(pkg.version);
- process.exit(0);
- }
- const cmd = (rawArgs[0] || "list").toLowerCase();
- if (cmd === "mcp-audit") {
- const targetFile = path.resolve(rawArgs[1] || ".mcp.json");
- try {
- const res = auditMcpFile(targetFile, { allowRemoteHttp: rawArgs.includes("--allow-remote") });
- if (rawArgs.includes("--json")) {
- console.log(JSON.stringify(res, null, 2));
- } else {
- console.log(`Audited ${res.serverCount} MCP server(s) in ${targetFile}: ${res.valid ? "PASS" : "FAIL"}`);
- for (const f of res.findings) {
- console.log(` [${f.severity.toUpperCase()}] (${f.code}) ${f.server}: ${f.message}`);
- }
- }
- process.exit(res.valid ? 0 : 1);
- } catch (err) {
- console.error(`Error auditing MCP config at ${targetFile}: ${err.message}`);
- process.exit(1);
- }
- }
- if (cmd === "sync-docs") {
- const dir = path.resolve(rawArgs[1] || ".");
- const dryRun = rawArgs.includes("--dry-run");
- const res = syncWorkspaceInstructions(dir, { dryRun });
- if (rawArgs.includes("--json")) {
- console.log(JSON.stringify(res, null, 2));
- } else if (res.action === "none") {
- console.log(`No CLAUDE.md or AGENTS.md found in ${dir}.`);
- } else {
- console.log(
- `${dryRun ? "[DRY-RUN] " : ""}Synced (${res.action}): ${res.sectionCount} section(s) -> ${path.basename(res.targetFile)} (updated=${res.updated})`
- );
- }
- process.exit(0);
- }
- if (cmd === "profiles") {
- const agent = (rawArgs[1] || "claude").toLowerCase() === "codex" ? "codex" : "claude";
- const store = new WorkspaceProfileStore();
- const list = store.listProfiles(agent);
- if (rawArgs.includes("--json")) {
- console.log(JSON.stringify(list, null, 2));
- } else if (list.length === 0) {
- console.log(`No saved ${agent} configuration profiles in ${store.getProfilesDir(agent)}.`);
- } else {
- for (const p of list) {
- console.log(`${p.slug}\tagent=${p.agent}\tmcp=${p.hasMcpConfig}\thash=${p.settingsHash || "none"}`);
- }
- }
- process.exit(0);
- }
- if (cmd === "install" || cmd === "setup") {
- const installCmd = "irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex";
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 101 on GitHub
- const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", installCmd], {
- stdio: "inherit"
- });
- process.exit(res.status ?? 0);
- }
- const mapped = [];
- if (cmd === "list") {
- mapped.push("list");
- if (rawArgs.includes("--json")) mapped.push("-Json");
- } else if (cmd === "status") {
- mapped.push("status");
- } else if (cmd === "save" && rawArgs[1]) {
- mapped.push("save", "-Name", rawArgs[1]);
- } else if (cmd === "switch" && rawArgs[1]) {
- mapped.push("switch", "-Name", rawArgs[1]);
- } else if (cmd === "rename" && rawArgs[1] && rawArgs[2]) {
- mapped.push("rename", "-Name", rawArgs[1], "-NewName", rawArgs[2]);
- } else if (cmd === "remove" && rawArgs[1]) {
- mapped.push("remove", "-Name", rawArgs[1]);
- } else if (cmd === "lang" && rawArgs[1]) {
- mapped.push("lang", "-Name", rawArgs[1]);
- } else {
- mapped.push(...rawArgs);
- }
- process.exit(runCodexAccounts(mapped));
index.js · Bundled script · 61 lines · 1 finding marked
- "use strict";
- const { spawnSync } = require("child_process");
- const path = require("path");
- const os = require("os");
- const fs = require("fs");
- const { auditMcpConfig, auditMcpFile } = require("./src/mcp-auditor");
- const { MCP_PRESETS, getMcpPreset, listMcpPresets, composeMcpConfig } = require("./src/mcp-presets");
- const { parseAgentMarkdown, renderAgentMarkdown, syncWorkspaceInstructions } = require("./src/instruction-bridge");
- const { normalizeProfileSlug, maskEmailAddress, WorkspaceProfileStore } = require("./src/profile-manager");
- function getInstallRoot() {
- if (process.platform === "win32") {
- const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
- return path.join(localAppData, "CodexMultiProfile");
- }
- return path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "codex-multi-profile");
- }
- function getAccountsScriptPath() {
- return path.join(getInstallRoot(), "CodexAccounts.ps1");
- }
- function runCodexAccounts(args = ["list"]) {
- if (process.platform !== "win32") {
- throw new Error("Native Windows Store Codex app integration requires Windows 10/11. Use `profiles`, `mcp-audit`, or `sync-docs` on macOS/Linux.");
- }
- const scriptPath = getAccountsScriptPath();
- if (!fs.existsSync(scriptPath)) {
- const installCmd = "irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex";
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 31 on GitHub
- const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", installCmd], {
- stdio: "inherit"
- });
- return res.status ?? 0;
- }
- const res = spawnSync(
- "powershell.exe",
- ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath, ...args],
- { stdio: "inherit" }
- );
- return res.status ?? 0;
- }
- module.exports = {
- getInstallRoot,
- getAccountsScriptPath,
- runCodexAccounts,
- auditMcpConfig,
- auditMcpFile,
- parseAgentMarkdown,
- renderAgentMarkdown,
- syncWorkspaceInstructions,
- normalizeProfileSlug,
- maskEmailAddress,
- WorkspaceProfileStore,
- MCP_PRESETS,
- getMcpPreset,
- listMcpPresets,
- composeMcpConfig
- };
install.ps1 · Bundled script · 70 lines · 2 findings marked
- #Requires -Version 5.1
- <#
- .SYNOPSIS
- Download this repo and run the Windows installer.
- .EXAMPLE
- 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
- .EXAMPLE
- powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -Ref v0.4.0
- .EXAMPLE
- # Upgrading from the old clone-based version: import its logins and remove it
- $env:CODEX_MP_REMOVE_LEGACY = '1'; irm https://raw.githubusercontent.com/Hung2124/codex-multi-profile/main/install.ps1 | iex
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 14 on GitHub
- #>
- [CmdletBinding()]
- param(
- [string]$Repo = 'Hung2124/codex-multi-profile',
- [string]$Ref = 'main',
- [switch]$KeepDownload,
- [switch]$RemoveLegacy
- )
- $ErrorActionPreference = 'Stop'
- if (-not $PSBoundParameters.ContainsKey('Ref') -and $env:CODEX_MP_REF) {
- $Ref = $env:CODEX_MP_REF
- }
- if (-not $PSBoundParameters.ContainsKey('RemoveLegacy') -and $env:CODEX_MP_REMOVE_LEGACY -in @('1', 'true', 'yes', 'on')) {
- $RemoveLegacy = $true
- }
- $tmp = Join-Path $env:TEMP ("codex-multi-profile-" + [guid]::NewGuid().ToString('n'))
- New-Item -ItemType Directory -Force -Path $tmp | Out-Null
- try {
- $zip = Join-Path $tmp 'src.zip'
- if ($Ref -match '^(refs/)?tags/') {
- $tag = $Ref -replace '^(refs/)?tags/', ''
- $url = "https://github.com/$Repo/archive/refs/tags/$tag.zip"
- }
- elseif ($Ref -match '^v?\d+\.\d+') {
- $url = "https://github.com/$Repo/archive/refs/tags/$Ref.zip"
- }
- else {
- $url = "https://github.com/$Repo/archive/refs/heads/$Ref.zip"
- }
- Write-Host "Downloading $url"
- Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing
- Expand-Archive -LiteralPath $zip -DestinationPath $tmp -Force
- $inner = Get-ChildItem -LiteralPath $tmp -Directory |
- Where-Object { $_.Name -like 'codex-multi-profile-*' } |
- Select-Object -First 1
- if (-not $inner) { throw "Unzipped repo folder not found under $tmp" }
- $installer = Join-Path $inner.FullName 'scripts\Install-CodexMultiProfile.ps1'
- if (-not (Test-Path -LiteralPath $installer)) { throw "Installer missing: $installer" }
- $installArgs = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $installer)
- if ($RemoveLegacy) { $installArgs += '-RemoveLegacy' }
- & powershell.exe @installArgs
- }
- finally {
- if (-not $KeepDownload -and (Test-Path -LiteralPath $tmp)) {
- Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
- }
- elseif ($KeepDownload) {
- Write-Host "Kept download at $tmp"
- }
- }
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.