codex-attachment-manager
Context Attachment Manager for Claude Code: earlier images go out as short placeholders instead of being sent again with every message, and the model fetches the original back by its ID.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 15 Nov 2026.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/chipfighter/context-attachment-manager with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/chipfighter/context-attachment-manager'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/chipfighter--context-attachment-manager)HTML
<a href="/listings/chipfighter--context-attachment-manager"><img src="/api/listings/chipfighter--context-attachment-manager/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.
Send this to your agent. It identifies its platform and installs the right setup:
Install Context Attachment Manager for me, following https://github.com/chipfighter/context-attachment-manager/blob/main/INSTALL.md
Then restart the agent (in Claude Desktop, start a new Code session). See [supported agents](#works-with) and [installation, updates and uninstall](INSTALL.md).
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.
.claude-plugin/marketplace.json · Manifest · 14 lines
- {
- "name": "codex-attachment-manager",
- "owner": {
- "name": "chipfighter"
- },
- "description": "Context Attachment Manager for Claude Code: earlier images go out as short placeholders instead of being sent again with every message, and the model fetches the original back by its ID.",
- "plugins": [
- {
- "name": "codex-attachment-manager",
- "source": "./",
- "description": "In Claude Code sessions with many images, earlier images go out as short placeholders instead of being sent again with every message; the model fetches the original back by its ID, also after compaction, and the prompt cache keeps working."
- }
- ]
- }
README.md · README · 131 lines
- <p align="center">
- <img src="plugin/assets/logo.png" width="96" height="96" alt="">
- </p>
- <h1 align="center">Context Attachment Manager</h1>
- <p align="center"><b>A local plugin for image-heavy chats in Codex, Claude Code and other agents.</b><br>Earlier images stop going out with every message. The model fetches the one it needs by its ID, also after the chat is compacted.</p>
- <p align="center">
- <a href="https://github.com/chipfighter/context-attachment-manager/releases"><img src="https://img.shields.io/github/v/release/chipfighter/context-attachment-manager?include_prereleases" alt="Release"></a>
- <img src="https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey" alt="Platform: Windows, macOS, Linux">
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License: MIT"></a>
- </p>
- <p align="center"><b>English</b> · <a href="README_CN.md">简体中文</a> · <a href="README_JA.md">日本語</a> · <a href="README_KO.md">한국어</a> · <a href="README_ES.md">Español</a> · <a href="README_PT_BR.md">Português (Brasil)</a> · <a href="README_FR.md">Français</a> · <a href="README_DE.md">Deutsch</a></p>
- <p align="center">
- <img src="docs/images/loop.gif" alt="The panel on a task with fifteen keyframes. With auto-select on, earlier images turn grey and the next request drops from 7.5 MB to 1.7 MB." width="100%">
- </p>
- ## What it does
- An agent normally sends every earlier image again with each message, so a long chat with many images gets slow and can stop going through. This plugin numbers each image (`IMG-001`, `IMG-002`, …) and sends earlier ones as short placeholders instead:
- - **The model fetches what it needs**: when it has to look at an earlier image again, it gets the original back by its ID.
- - **It can tell images apart**: the model notes one line on what each image shows, plus your comments on it. These stay in the placeholders, also after the chat is compacted.
- - **The cache keeps working**: a placeholder is written once and then stays the same, so the earlier chat is still read from the model's prompt cache. See [the design](#design-keep-the-cache-working).
- - **Nothing is deleted**: your original images and chat history stay as they are.
- It is on by default; you do not need to open the panel. Typical uses: image and video creation, scanned documents, computer and browser use.
- ## Install
- Send this to your agent. It identifies its platform and installs the right setup:
- ```text
- Install Context Attachment Manager for me, following https://github.com/chipfighter/context-attachment-manager/blob/main/INSTALL.md
- ```
- Then restart the agent (in Claude Desktop, start a new Code session). See [supported agents](#works-with) and [installation, updates and uninstall](INSTALL.md).
- ## The panel, when you want control
- <p align="center">
- <img src="docs/images/hero.png" alt="The panel: automatically manage earlier images, search by what you remember, and preview an image." width="100%">
- </p>
- - **Find an image** by a detail or a comment you remember, like "rainy night" or "best face".
- - **Keep a reference in view**: open an image and check **Send every turn**.
- - **Choose images yourself**: turn off **Auto-select** and pick what goes with your next message.
- In **Codex**, open **Context Assets** in the task's side panel. In **Claude Desktop's Code tab**, the panel opens automatically when there are images; type `/cam` to bring it back.
- ## Privacy
- The plugin runs locally. Your original images and chat history stay on your computer; requests go to the service your agent already uses.
- ## How we tested
- In Codex, a chat with nine keyframes grew to 42.4 MB and could not be sent after a restart or a compaction; with the plugin the same requests were 0.12 MB. See the [Codex comparison](eval/README.md) and [Claude Code long-task comparison](eval/long-task/README.md) for the results and reproduction steps.
- ## Design: keep the cache working
- Model services cache the start of a chat. When a request begins exactly like the one before, that part is read from the cache, which is faster and much cheaper. When something early in the chat changes, everything after the change is processed again.
- Any way of making a long chat smaller has to change something. The plugin makes its change as late in the chat as it can:
- <p align="center">
- <img src="docs/images/cache-compare.svg" alt="Four ways to handle a long chat with images, each drawn as the next request. Sending everything keeps the cache but sends every image again. Shrinking the images or dropping early history makes nearly the whole chat be processed again. With the plugin's placeholders, only the rest of the previous turn is processed again." width="100%">
- </p>
- - **A placeholder is written once**: an image becomes a placeholder in the turn after it appeared, so only the rest of that one turn is processed again. After that the placeholder stays the same from request to request.
- - **Fetching changes nothing earlier**: the original is added at the end of the current turn, and its placeholder stays where it is. Whichever image the model picks, and however many the chat holds, everything before the current turn is still read from the cache.
- - **The model gets the original back**: not a smaller copy, and not a summary of it.
- <p align="center">
- <img src="docs/images/cache-fetch.svg" alt="When the model fetches IMG-001, the original is attached at the end of the current turn and the placeholder in turn 1 stays as it is, so every earlier turn is read from the cache. In the next turn the fetched copy becomes a one-line note, and only what came after it is processed again." width="100%">
- </p>
- This is not free. After a turn with images, the rest of that turn is processed again once, and the model writes a short line for each new image. Changing an old image in the panel (unchecking it, checking it again, **Send every turn**) changes the chat at that image, so what follows it is processed again once. In our [long-task comparison in Claude Code](eval/long-task/README.md), 87% of the input was read from the cache with the plugin and 91% without it.
- The third row of the first figure is also what an agent's own compaction does, and what clearing old tool results on the API side does (Anthropic's context editing, for example): early content is removed, and what follows is processed again.
- ## Works with
- Codex and Claude Code are tested, and Codex and Claude Desktop also have the panel. The other agents below are supported through adapters written from their code and docs, but we have not tested them live yet. If you use one of them, please [tell us how it went](https://github.com/chipfighter/context-attachment-manager/issues), whether it worked or not.
- | Agent | What it is | Support |
- |---|---|---|
- | [Codex](https://github.com/openai/codex) | OpenAI's coding agent, desktop and CLI | Auto-select + panel, tested |
- | [Claude Code](https://github.com/anthropics/claude-code) | Anthropic's coding agent, desktop and CLI | Auto-select + panel (desktop), tested |
- | [WorkBuddy](https://www.workbuddy.cn) | Tencent's desktop AI work assistant, with CodeBuddy inside | Auto-select, not tested yet |
- | [OpenCode](https://github.com/anomalyco/opencode) | Open-source terminal coding agent for any model provider | Auto-select, not tested yet |
- | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google's open-source terminal agent | Auto-select, not tested yet |
- | [pi](https://github.com/earendil-works/pi) | Minimal, extensible terminal coding agent | Auto-select (pi extension), not tested yet |
- | [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) | DeepSeek's agent harness where everything is a plugin | Auto-select (dsh plugin), not tested yet |
- | [Qwen Code](https://github.com/QwenLM/qwen-code) | Qwen's open-source terminal agent | Auto-select, not tested yet |
- | [Cline](https://github.com/cline/cline) | Open-source coding agent for VS Code, JetBrains and the terminal | Auto-select, not tested yet |
- | [Kilo Code](https://github.com/Kilo-Org/kilocode) | Open-source coding agent for VS Code, JetBrains and the terminal | Auto-select, not tested yet |
- | [goose](https://github.com/aaif-goose/goose) | Open-source agent for desktop and terminal, extended with MCP | Auto-select, not tested yet |
- | [Cherry Studio](https://github.com/CherryHQ/cherry-studio) | Open-source desktop chat client for many models | Auto-select, not tested yet |
- Setup for these agents: [INSTALL.md](INSTALL.md#other-agents). To connect another agent, see [ADAPTERS.md](ADAPTERS.md).
- ## FAQ
- ### Why do Codex and Claude Code get slow in a long chat with many images?
- The agent sends every earlier image again with each message, so a long chat with many images gets slow and can stop going through. In Codex, a chat with nine keyframes grew to 42.4 MB and could not be sent after a restart or a compaction; with Context Attachment Manager the same requests were 0.12 MB.
- ### Does Context Attachment Manager break the prompt cache?
- Only a little. A placeholder is written once and then stays the same, and a fetched image is added at the end of the current turn, so earlier turns are still read from the cache. After a turn with images, the rest of that turn is processed again once. In our long-task comparison in Claude Code, 87% of the input was read from the cache with the plugin and 91% without it.
- ### How is it different from compaction, or from shrinking the images?
- Compaction and dropping early history remove the early part of the chat, and shrinking the images changes it. Either way nearly the whole chat is processed again, and the model is left with a summary or a smaller copy. With Context Attachment Manager, only the rest of the previous turn is processed again, and the model gets the original image back by its ID.
- ### Can the model still see an earlier image?
- Yes. Every image has an ID such as `IMG-001`, and the model fetches the original when it needs to look at it again, also after the chat is compacted.
- ### Are my images deleted, or sent anywhere else?
- No. The plugin runs on your computer. Your original images and chat history stay as they are, and requests go to the service your agent already uses.
- ### Which agents does it work with, and is it free?
- Codex and Claude Code are tested. WorkBuddy, OpenCode, Gemini CLI, pi, DeepSeek Harness, Qwen Code, Cline, Kilo Code, goose and Cherry Studio are supported through adapters that we have not tested live yet. It is free and open source under the MIT license.
- <p align="center"><sub><a href="CHANGELOG.md">Changelog</a> · <a href="CONTRIBUTING.md">Contributing</a> · <a href="LICENSE">MIT License</a></sub></p>
scripts/install.ps1 · Bundled script · 77 lines · 1 finding marked
- # Purpose: v0.1-5 - install the Codex attachment manager on Windows in one line, without opening GitHub:
- # irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.ps1 | iex
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 2 on GitHub
- # Codex's own command line adds this repository as a plugin marketplace and installs the plugin; the installed plugin
- # then points Codex at its local engine (cam setup) and starts it. Running it again upgrades. Restart Codex afterwards.
- # Input: CAM_REF (a tag or branch; a release sets its own tag), CAM_SOURCE (a local checkout, for tests),
- # CODEX_CLI_PATH, CODEX_HOME. Output: Codex's plugin cache, config.toml (backed up first) and, when needed, .env.
- # ASCII only: Windows PowerShell 5.1 decodes a downloaded script as Latin-1. The body runs in its own scope, so the
- # user's session keeps its own settings.
- & {
- $ErrorActionPreference = 'Stop'
- $repo = 'chipfighter/context-attachment-manager'
- $name = 'codex-attachment-manager'
- $plugin = "$name@$name"
- function Find-Codex {
- if ($env:CODEX_CLI_PATH -and (Test-Path -LiteralPath $env:CODEX_CLI_PATH)) { return $env:CODEX_CLI_PATH }
- # The desktop app keeps one folder per build; the newest belongs to the app that runs now.
- $bin = Join-Path $env:LOCALAPPDATA 'OpenAI\Codex\bin'
- if (Test-Path -LiteralPath $bin) {
- $newest = Get-ChildItem -LiteralPath $bin -Directory | ForEach-Object { Join-Path $_.FullName 'codex.exe' } |
- Where-Object { Test-Path -LiteralPath $_ } | Sort-Object { (Get-Item -LiteralPath $_).LastWriteTime } -Descending | Select-Object -First 1
- if ($newest) { return $newest }
- }
- $onPath = Get-Command codex -All -ErrorAction SilentlyContinue | Where-Object { $_.Source -match '\.(exe|cmd)$' } | Select-Object -First 1
- if ($onPath) { return $onPath.Source }
- throw 'Codex command line not found. Install the Codex desktop app and open it once, or set CODEX_CLI_PATH to codex.exe.'
- }
- # Codex prints warnings on stderr; they are not failures.
- function Invoke-Codex([string[]]$CodexArgs, [switch]$AllowFailure, [switch]$PassThru) {
- $ErrorActionPreference = 'Continue'
- $stderrFile = [IO.Path]::GetTempFileName()
- $output = (& $codex @CodexArgs 2>$stderrFile | ForEach-Object { "$_" }) -join "`n"
- if ($LASTEXITCODE -ne 0 -and -not $AllowFailure) { throw "codex $($CodexArgs -join ' ') failed: $output $(Get-Content -LiteralPath $stderrFile -Raw)" }
- if ($PassThru) { return $output }
- }
- $codex = Find-Codex
- $codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME '.codex' }
- # A release replaces the placeholder with its own tag; a copy from the repository follows the default branch.
- $ref = if ($env:CAM_REF) { $env:CAM_REF } elseif ('__CAM_REF__' -notlike '__*') { '__CAM_REF__' } else { $null }
- $source = if ($env:CAM_SOURCE) { $env:CAM_SOURCE } else { $repo }
- Write-Host "Installing the plugin with $codex ..."
- $root = Join-Path $codexHome "plugins\cache\$name\$name"
- # Codex may clean old cache files even when Windows keeps a running plugin's directory locked.
- $cached = @(Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^\d+\.\d+\.\d+([-+][\w.-]+)?$' })
- $cacheBackup = Join-Path ([IO.Path]::GetTempPath()) ("cam-runtime-backup-" + [guid]::NewGuid().ToString('N'))
- New-Item -ItemType Directory -Path $cacheBackup | Out-Null
- foreach ($entry in $cached) { Copy-Item -LiteralPath $entry.FullName -Destination $cacheBackup -Recurse -Force }
- $installed = $null
- try {
- # Refresh marketplace metadata without deleting the working plugin first.
- Invoke-Codex @('plugin', 'marketplace', 'remove', $name) -AllowFailure
- $add = @('plugin', 'marketplace', 'add', $source)
- if ($ref -and -not $env:CAM_SOURCE) { $add += @('--ref', $ref) }
- Invoke-Codex $add
- $result = Invoke-Codex @('plugin', 'add', '--json', $plugin) -PassThru | ConvertFrom-Json
- if ($result.version -notmatch '^\d+\.\d+\.\d+([-+][\w.-]+)?$') { throw 'Invalid installed plugin version.' }
- $installed = Get-Item -LiteralPath (Join-Path $root $result.version)
- if (-not (Test-Path -LiteralPath (Join-Path $installed.FullName 'src\cam.ts'))) { $installed = $null; throw 'The new plugin runtime is incomplete.' }
- } finally {
- foreach ($entry in $cached) {
- if ($installed -and $entry.Name -eq $installed.Name) { continue }
- $target = Join-Path $root $entry.Name
- New-Item -ItemType Directory -Path $target -Force | Out-Null
- Get-ChildItem -LiteralPath (Join-Path $cacheBackup $entry.Name) -Force | ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination $target -Recurse -Force }
- }
- }
- # The installed plugin writes the proxy settings itself (checking for conflicts first) and starts its engine.
- Write-Host 'Pointing Codex at the local engine ...'
- & cmd.exe /d /s /c call "$($installed.FullName)\scripts\launch.cmd" "$($installed.FullName)\src\cam.ts" setup
- if ($LASTEXITCODE -ne 0) { throw 'The proxy settings were not written (see above); Codex still connects directly.' }
- Write-Host ''
- Write-Host 'Done. Restart Codex, then open the panel from the side panel: New tab > Plugins and MCP.'
- }
scripts/install.sh · Bundled script · 79 lines · 1 finding marked
- #!/bin/sh
- # Purpose: v0.1-5 - install the Codex attachment manager on macOS or Linux in one line, without opening GitHub:
- # curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/install.sh | sh
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 3 on GitHub
- # Codex's own command line adds this repository as a plugin marketplace and installs the plugin; the installed plugin
- # then points Codex at its local engine (cam setup) and starts it. Running it again upgrades. Restart Codex afterwards.
- # Input: CAM_REF (a tag or branch; a release sets its own tag), CAM_SOURCE (a local checkout, for tests),
- # CODEX_CLI_PATH, CODEX_HOME. Output: Codex's plugin cache, config.toml (backed up first) and, when needed, .env.
- set -eu
- repo=chipfighter/context-attachment-manager
- name=codex-attachment-manager
- plugin="$name@$name"
- find_codex() {
- if [ -n "${CODEX_CLI_PATH:-}" ] && [ -x "$CODEX_CLI_PATH" ]; then printf '%s\n' "$CODEX_CLI_PATH"; return 0; fi
- # The desktop app ships one; Codex's own installer puts it in ~/.local/bin.
- for candidate in \
- /Applications/ChatGPT.app/Contents/Resources/codex \
- /Applications/Codex.app/Contents/Resources/codex \
- "$HOME/Applications/ChatGPT.app/Contents/Resources/codex" \
- "$HOME/Applications/Codex.app/Contents/Resources/codex" \
- "$HOME/.local/bin/codex"
- do
- if [ -x "$candidate" ]; then printf '%s\n' "$candidate"; return 0; fi
- done
- command -v codex
- }
- codex=$(find_codex) || {
- printf '%s\n' 'Codex command line not found. Install Codex (the desktop app, or the command line), or set CODEX_CLI_PATH.' >&2
- exit 1
- }
- codex_home=${CODEX_HOME:-$HOME/.codex}
- # A release replaces the placeholder with its own tag; a copy from the repository follows the default branch.
- ref=${CAM_REF:-__CAM_REF__}
- case "$ref" in __*) ref= ;; esac
- source=${CAM_SOURCE:-$repo}
- printf 'Installing the plugin with %s ...\n' "$codex"
- # Keep older runtimes usable if Codex's cache cleanup meets files still in use.
- cache_root="$codex_home/plugins/cache/$name/$name"
- cache_backup=$(mktemp -d "${TMPDIR:-/tmp}/cam-runtime-backup-XXXXXXXX")
- if [ -d "$cache_root" ]; then cp -R "$cache_root/." "$cache_backup/"; fi
- installed_version=
- restore_caches() {
- for saved in "$cache_backup"/*; do
- [ -d "$saved" ] || continue
- saved_version=${saved##*/}
- [ "$saved_version" != "$installed_version" ] || continue
- mkdir -p "$cache_root/$saved_version"
- cp -R "$saved/." "$cache_root/$saved_version/"
- done
- }
- trap restore_caches 0
- # Refresh marketplace metadata without deleting the working plugin first.
- "$codex" plugin marketplace remove "$name" >/dev/null 2>&1 || true
- if [ -n "${CAM_SOURCE:-}" ] || [ -z "$ref" ]; then
- "$codex" plugin marketplace add "$source"
- else
- "$codex" plugin marketplace add "$source" --ref "$ref"
- fi
- "$codex" plugin add --json "$plugin" > "$cache_backup/install-result.json"
- version=$(sed -n 's/^[[:space:]]*"version":[[:space:]]*"\([^"]*\)".*/\1/p' "$cache_backup/install-result.json")
- case "$version" in ''|*[!0-9A-Za-z.+-]*) printf '%s\n' 'Invalid installed plugin version.' >&2; exit 1 ;; esac
- installed="$cache_root/$version"
- if [ ! -f "$installed/src/cam.ts" ]; then
- printf 'The plugin did not arrive in %s.\n' "$installed" >&2
- exit 1
- fi
- installed_version=$version
- restore_caches
- trap - 0
- # The installed plugin writes the proxy settings itself (checking for conflicts first) and starts its engine.
- printf '%s\n' 'Pointing Codex at the local engine ...'
- if ! "$installed/scripts/launch" "$installed/src/cam.ts" setup; then
- printf '%s\n' 'The proxy settings were not written (see above); Codex still connects directly.' >&2
- exit 1
- fi
- printf '\n%s\n' 'Done. Restart Codex, then open the panel from the side panel: New tab > Plugins and MCP.'
scripts/uninstall.ps1 · Bundled script · 94 lines · 1 finding marked
- # Purpose: v0.1-5 - remove the Codex attachment manager on Windows in one line; also the way back when Codex cannot
- # connect because the plugin was removed without turning it off in the panel first:
- # irm https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.ps1 | iex
- Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
- Line 3 on GitHub
- # Takes out only the marked blocks this tool wrote to config.toml and .env (config.toml is backed up first), then removes
- # the plugin and its marketplace with Codex's own command line. Needs neither Node nor any of the plugin's files.
- # Input: CODEX_HOME, CAM_DATA_DIR, CODEX_CLI_PATH. Output: config.toml, .env, Codex's plugin cache.
- # ASCII only, and in its own scope (see install.ps1).
- & {
- $ErrorActionPreference = 'Stop'
- $name = 'codex-attachment-manager'
- $plugin = "$name@$name"
- $beginMarkers = @(
- '# >>> codex-attachment-manager: managed proxy setting, remove it with the tool >>>',
- '# >>> codex-attachment-manager: managed MCP server, remove it with the tool >>>'
- )
- $endMarker = '# <<< codex-attachment-manager <<<'
- # The rule the plugin itself uses (codexconfig.ts): drop every marked block; a block at the very top takes the blank
- # line after it along. BOM and line endings stay as they were. Returns $null when there is nothing to remove.
- function Remove-ManagedBlocks([string]$Path) {
- if (-not (Test-Path -LiteralPath $Path)) { return $null }
- $bytes = [IO.File]::ReadAllBytes($Path)
- $bom = $bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF
- $skip = if ($bom) { 3 } else { 0 }
- $body = [Text.Encoding]::UTF8.GetString($bytes, $skip, $bytes.Length - $skip)
- $eol = if ($body.Contains("`r`n")) { "`r`n" } else { "`n" }
- $lines = $body.Split([string[]]@($eol), [StringSplitOptions]::None)
- $kept = New-Object System.Collections.Generic.List[string]
- $changed = $false
- for ($i = 0; $i -lt $lines.Length; $i++) {
- if ($beginMarkers -notcontains $lines[$i].Trim()) { $kept.Add($lines[$i]); continue }
- $stop = $i + 1
- while ($stop -lt $lines.Length -and $lines[$stop].Trim() -ne $endMarker) { $stop++ }
- if ($stop -ge $lines.Length) { throw "A marked block in $Path has no end marker; the file was left as it is." }
- $atTop = $kept.Count -eq 0
- $i = $stop
- if ($atTop -and $i + 1 -lt $lines.Length -and $lines[$i + 1] -eq '') { $i++ }
- $changed = $true
- }
- if (-not $changed) { return $null }
- return [pscustomobject]@{ Bom = $bom; Text = [string]::Join($eol, $kept.ToArray()) }
- }
- function Save-Text([string]$Path, $Result) {
- $out = [Text.Encoding]::UTF8.GetBytes($Result.Text)
- if ($Result.Bom) { $out = [byte[]]((0xEF, 0xBB, 0xBF) + $out) }
- [IO.File]::WriteAllBytes($Path, $out)
- }
- $codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME '.codex' }
- $dataDir = if ($env:CAM_DATA_DIR) { $env:CAM_DATA_DIR } else { Join-Path $env:USERPROFILE ('.' + $name) }
- $config = Join-Path $codexHome 'config.toml'
- $dotenv = Join-Path $codexHome '.env'
- $result = Remove-ManagedBlocks $config
- if ($result) {
- $backups = Join-Path $dataDir 'config-backup'
- New-Item -ItemType Directory -Force -Path $backups | Out-Null
- Copy-Item -LiteralPath $config -Destination (Join-Path $backups ('config.toml.' + (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH-mm-ss.fffZ')))
- Save-Text $config $result
- Write-Host 'Codex connects directly again: the proxy settings were taken out of config.toml.'
- } else {
- Write-Host 'config.toml holds no proxy settings of this tool.'
- }
- $result = Remove-ManagedBlocks $dotenv
- if ($result) {
- # A .env that held nothing but this block is deleted rather than left empty.
- if ($result.Text.Trim() -eq '') { Remove-Item -LiteralPath $dotenv } else { Save-Text $dotenv $result }
- Write-Host 'The NO_PROXY block was taken out of .env.'
- }
- $codex = $null
- if ($env:CODEX_CLI_PATH -and (Test-Path -LiteralPath $env:CODEX_CLI_PATH)) { $codex = $env:CODEX_CLI_PATH }
- if (-not $codex) {
- $bin = Join-Path $env:LOCALAPPDATA 'OpenAI\Codex\bin'
- if (Test-Path -LiteralPath $bin) {
- $codex = Get-ChildItem -LiteralPath $bin -Directory | ForEach-Object { Join-Path $_.FullName 'codex.exe' } |
- Where-Object { Test-Path -LiteralPath $_ } | Sort-Object { (Get-Item -LiteralPath $_).LastWriteTime } -Descending | Select-Object -First 1
- }
- }
- if (-not $codex) { $codex = (Get-Command codex -All -ErrorAction SilentlyContinue | Where-Object { $_.Source -match '\.(exe|cmd)$' } | Select-Object -First 1).Source }
- if ($codex) {
- $ErrorActionPreference = 'Continue'
- & $codex plugin remove $plugin 2>&1 | Out-Null
- & $codex plugin marketplace remove $name 2>&1 | Out-Null
- $ErrorActionPreference = 'Stop'
- Write-Host 'The plugin and its marketplace were removed from Codex.'
- } else {
- Write-Host 'Codex command line not found: remove the plugin on the Plugins page in Codex.'
- }
- Write-Host ''
- Write-Host "Done. Restart Codex. Selections and logs stay in $dataDir; delete that folder if you do not need them."
- }
scripts/uninstall.sh · Bundled script · 101 lines · 1 finding marked
- #!/bin/sh
- # Purpose: v0.1-5 - remove the Codex attachment manager on macOS or Linux in one line; also the way back when Codex
- # cannot connect because the plugin was removed without turning it off in the panel first:
- # curl -fsSL https://github.com/chipfighter/context-attachment-manager/releases/latest/download/uninstall.sh | sh
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 4 on GitHub
- # Takes out only the marked blocks this tool wrote to config.toml and .env (config.toml is backed up first), then removes
- # the plugin and its marketplace with Codex's own command line. Needs neither Node nor any of the plugin's files.
- # Input: CODEX_HOME, CAM_DATA_DIR, XDG_DATA_HOME, CODEX_CLI_PATH. Output: config.toml, .env, Codex's plugin cache.
- set -eu
- name=codex-attachment-manager
- plugin="$name@$name"
- codex_home=${CODEX_HOME:-$HOME/.codex}
- if [ -n "${CAM_DATA_DIR:-}" ]; then data_dir=$CAM_DATA_DIR
- elif [ "$(uname -s)" = Darwin ]; then data_dir="$HOME/Library/Application Support/$name"
- else data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/$name"
- fi
- # The rule the plugin itself uses (codexconfig.ts): drop every marked block; a block at the very top takes the blank
- # line after it along. A BOM and CRLF line endings stay as they were. Writes the result to $2; exit status 1 when
- # there was nothing to remove, 2 when a block has no end marker.
- strip_blocks() {
- awk '
- function trim(s) { sub(/^[ \t\r]+/, "", s); sub(/[ \t\r]+$/, "", s); return s }
- { line[NR] = $0 }
- END {
- bom = "\357\273\277"
- proxy = "# >>> codex-attachment-manager: managed proxy setting, remove it with the tool >>>"
- mcp = "# >>> codex-attachment-manager: managed MCP server, remove it with the tool >>>"
- stop = "# <<< codex-attachment-manager <<<"
- if (NR > 0 && substr(line[1], 1, 3) == bom) { hadbom = 1; line[1] = substr(line[1], 4) }
- kept = 0; changed = 0
- for (i = 1; i <= NR; i++) {
- t = trim(line[i])
- if (t != proxy && t != mcp) { out[++kept] = line[i]; continue }
- j = i + 1
- while (j <= NR && trim(line[j]) != stop) j++
- if (j > NR) exit 2
- top = (kept == 0)
- i = j
- if (top && i < NR && (line[i + 1] == "" || line[i + 1] == "\r")) i++
- changed = 1
- }
- if (!changed) exit 1
- for (k = 1; k <= kept; k++) printf "%s%s\n", (k == 1 && hadbom ? bom : ""), out[k]
- }' "$1" > "$2"
- }
- # Only replaces the file when something was removed; the new text goes in place in one step.
- clean() {
- file=$1
- [ -f "$file" ] || return 1
- status=0
- strip_blocks "$file" "$file.cam-tmp" || status=$?
- if [ "$status" -ne 0 ]; then
- rm -f "$file.cam-tmp"
- if [ "$status" -eq 2 ]; then printf 'A marked block in %s has no end marker; the file was left as it is.\n' "$file" >&2; exit 1; fi
- return 1
- fi
- return 0
- }
- config="$codex_home/config.toml"
- if clean "$config"; then
- mkdir -p "$data_dir/config-backup"
- cp "$config" "$data_dir/config-backup/config.toml.$(date -u +%Y-%m-%dT%H-%M-%S.000Z)"
- mv "$config.cam-tmp" "$config"
- printf '%s\n' 'Codex connects directly again: the proxy settings were taken out of config.toml.'
- else
- printf '%s\n' 'config.toml holds no proxy settings of this tool.'
- fi
- dotenv="$codex_home/.env"
- if clean "$dotenv"; then
- # A .env that held nothing but this block is deleted rather than left empty.
- if awk 'NR == 1 { sub(/^\357\273\277/, "") } /[^ \t\r]/ { found = 1 } END { exit found ? 1 : 0 }' "$dotenv.cam-tmp"; then
- rm -f "$dotenv" "$dotenv.cam-tmp"
- else
- mv "$dotenv.cam-tmp" "$dotenv"
- fi
- printf '%s\n' 'The NO_PROXY block was taken out of .env.'
- fi
- codex=
- if [ -n "${CODEX_CLI_PATH:-}" ] && [ -x "$CODEX_CLI_PATH" ]; then codex=$CODEX_CLI_PATH; fi
- for candidate in \
- /Applications/ChatGPT.app/Contents/Resources/codex \
- /Applications/Codex.app/Contents/Resources/codex \
- "$HOME/Applications/ChatGPT.app/Contents/Resources/codex" \
- "$HOME/Applications/Codex.app/Contents/Resources/codex" \
- "$HOME/.local/bin/codex"
- do
- if [ -z "$codex" ] && [ -x "$candidate" ]; then codex=$candidate; fi
- done
- if [ -z "$codex" ]; then codex=$(command -v codex || true); fi
- if [ -n "$codex" ]; then
- "$codex" plugin remove "$plugin" >/dev/null 2>&1 || true
- "$codex" plugin marketplace remove "$name" >/dev/null 2>&1 || true
- printf '%s\n' 'The plugin and its marketplace were removed from Codex.'
- else
- printf '%s\n' 'Codex command line not found: remove the plugin on the Plugins page in Codex.'
- fi
- printf '\nDone. Restart Codex. Selections and logs stay in %s; delete that folder if you do not need them.\n' "$data_dir"
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.