codex-theme-installer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Install a Codex theme from CodexThemes

从CodexThemes安装Codex主题

Download a published theme's portable package from codexthemes.ai and unpack its source files into
~/.codexthemes/themes/<theme-id>/
. This skill is standalone: its TypeScript scripts own the download, validation, and local installation. It does not search the gallery (codex-theme-finder), create themes (codex-theme-creator), or submit them (codex-theme-submitter). Applying belongs to codex-theme-switcher — but a successful install chains directly into it (Step 4); installing files and stopping is not a finished job. The only required local tools are Node.js 20+ and
npx
.
Read
references/download-api.md
before diagnosing an unexpected API response or changing endpoint behavior. Run all commands from the installed skill directory.
从codexthemes.ai下载已发布主题的可移植包,并将其源文件解压到
~/.codexthemes/themes/<theme-id>/
中。此技能是独立的:其TypeScript脚本负责下载、验证和本地安装。它不搜索主题库(codex-theme-finder)、创建主题(codex-theme-creator)或提交主题(codex-theme-submitter)。主题应用属于codex-theme-switcher的功能——但安装成功后会直接进入该步骤(步骤4);仅安装文件并不代表任务完成。唯一需要的本地工具是Node.js 20+和
npx
在诊断意外API响应或更改端点行为之前,请阅读
references/download-api.md
。所有命令均需从已安装的技能目录运行。

Step 1: identify the theme

步骤1:确定主题

Resolve what to install to a theme id — the lowercase slug from codex-theme-finder results or from a
https://codexthemes.ai/themes/<theme-id>
URL. The script accepts either form. If the user only describes a style without naming a theme, find candidates with codex-theme-finder first instead of guessing ids.
确定要安装的主题对应的主题ID——即codex-theme-finder结果中的小写短名称,或
https://codexthemes.ai/themes/<theme-id>
URL中的部分。脚本接受这两种形式。如果用户仅描述了主题风格但未指定具体主题,请先使用codex-theme-finder查找候选主题,而非猜测ID。

Step 2: install

步骤2:安装

bash
npx tsx scripts/install-theme.ts <theme-id | codexthemes.ai theme URL> [--force]
Downloads work without any API key inside a free anonymous quota, so do not demand a key up front. When a key is already configured (
CODEXTHEMES_API_KEY
environment variable or
~/.codexthemes/credentials.json
), the script sends it automatically for higher limits.
The script validates the downloaded package (format, schema version, matching theme id, safe relative filenames, ≤30 MB) before writing anything, then unpacks
theme.json
, the stylesheet, the artwork, and the readme into
~/.codexthemes/themes/<theme-id>/
. It refuses to overwrite an existing non-empty theme directory; pass
--force
only after the user confirms replacing their local copy — the directory may hold their own edits.
Updating an installed theme: published themes are updated in place on codexthemes.ai, so when the user asks to update, upgrade, or re-download a theme they already installed, re-run the install with
--force
— the update request itself is the confirmation, unless the local copy holds edits the user made (then warn first). After the files land, continue into Step 4 so the running app actually switches to the new version; a hot swap of the same theme id re-injects the updated CSS.
bash
npx tsx scripts/install-theme.ts <theme-id | codexthemes.ai theme URL> [--force]
下载可在无API密钥的情况下使用免费匿名配额,因此不要一开始就要求用户提供密钥。如果已配置密钥(
CODEXTHEMES_API_KEY
环境变量或
~/.codexthemes/credentials.json
文件),脚本会自动发送密钥以获得更高限制。
脚本会先验证下载的包(格式、架构版本、主题ID匹配、安全的相对文件名、大小≤30 MB),然后再写入任何内容,接着将
theme.json
、样式表、图片和自述文件解压到
~/.codexthemes/themes/<theme-id>/
中。它会拒绝覆盖已存在的非空主题目录;仅在用户确认替换本地副本后再使用
--force
参数——该目录可能包含用户自己的编辑内容。
更新已安装的主题:已发布的主题会在codexthemes.ai上进行原地更新,因此当用户要求更新、升级或重新下载已安装的主题时,使用
--force
参数重新运行安装命令即可——更新请求本身即视为确认,除非本地副本包含用户自己的编辑内容(此时需先发出警告)。文件下载完成后,继续执行步骤4,以便运行中的应用实际切换到新版本;同一主题ID的热替换会重新注入更新后的CSS。

Step 3: handle quota and rate limits

步骤3:处理配额和速率限制

On HTTP
429
or
402
the free quota is exhausted; the script's error message includes any
Retry-After
value. Do not retry in a loop. Tell the user the free download quota is used up and guide them to configure a personal API key:
  1. Create a key at
    https://codexthemes.ai/settings/apikeys
    .
  2. Store it:
    printf '%s' "<api-key>" | npx tsx scripts/apikey.ts set
    (stdin keeps the key out of shell history;
    apikey.ts set <key>
    also works).
  3. Re-run the install.
Check the current key state with
npx tsx scripts/apikey.ts status
; remove a stored key with
npx tsx scripts/apikey.ts clear
. Never print a full key (scripts only show a masked form), never write it into a project file, and never commit it.
On
401
/
403
the configured key is invalid or revoked — guide the user to create a fresh key the same way. On
404
the theme id does not exist; re-check the id with codex-theme-finder.
当出现HTTP
429
402
状态码时,说明免费配额已用尽;脚本的错误消息会包含
Retry-After
值。不要循环重试。告知用户免费下载配额已用完,并指导他们配置个人API密钥:
  1. https://codexthemes.ai/settings/apikeys
    创建密钥。
  2. 存储密钥:
    printf '%s' "<api-key>" | npx tsx scripts/apikey.ts set
    (标准输入可避免密钥出现在shell历史中;
    apikey.ts set <key>
    同样有效)。
  3. 重新运行安装命令。
使用
npx tsx scripts/apikey.ts status
检查当前密钥状态;使用
npx tsx scripts/apikey.ts clear
删除已存储的密钥。切勿打印完整密钥(脚本仅显示掩码形式),切勿将其写入项目文件,也切勿提交到版本控制系统。
当出现
401
/
403
状态码时,说明配置的密钥无效或已被撤销——以同样方式指导用户创建新密钥。当出现
404
状态码时,说明主题ID不存在——使用codex-theme-finder重新检查ID。

Step 4: activate, or hand the user the exact next reply

步骤4:激活,或告知用户下一步的明确指令

An install request means the user wants to see the theme in Codex, not merely store its files. Report the installed path (
~/.codexthemes/themes/<theme-id>/
), the theme version, and the files written — then continue directly into activation with codex-theme-switcher. If codex-theme-switcher is not installed, bootstrap it the same way this skill was bootstrapped (
npx skills add codexthemes/skills --skill codex-theme-switcher -g -a codex
).
  • If Codex already exposes its debugging endpoint, hot-swap now with the switcher's
    switch-theme.ts apply <theme-id>
    and verify with
    switch-theme.ts status
    — a hot swap is reversible and needs no confirmation beyond the install request itself.
  • If activation requires restarting Codex, do not restart silently and do not stop at "installed". End by telling the user the exact reply that continues, for example: "Reply
    apply
    and I will restart Codex to activate
    <theme-id>
    ." When they reply, follow the switcher's
    --launch
    flow.
Never end the conversation with only "files installed, not applied" and no actionable next step, and never claim the theme is active until the switcher's
status
reports
active
.
安装请求意味着用户希望在Codex中看到该主题,而不仅仅是存储其文件。报告安装路径(
~/.codexthemes/themes/<theme-id>/
)、主题版本和已写入的文件——然后直接使用codex-theme-switcher进行激活。如果未安装codex-theme-switcher,按照此技能的引导方式进行安装(
npx skills add codexthemes/skills --skill codex-theme-switcher -g -a codex
)。
  • 如果Codex已暴露其调试端点,立即使用切换器的
    switch-theme.ts apply <theme-id>
    进行热替换,并使用
    switch-theme.ts status
    验证——热替换是可逆的,且除安装请求外无需额外确认。
  • 如果激活需要重启Codex,请勿静默重启,也不要停留在“已安装”状态。最后告知用户继续操作的明确指令,例如:“回复
    apply
    ,我将重启Codex以激活
    <theme-id>
    。”当用户回复后,按照切换器的
    --launch
    流程操作。
切勿仅以“文件已安装,未应用”结束对话而不提供可执行的下一步操作,且在切换器的
status
报告
active
之前,切勿声称主题已激活。