ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 jl-cmd-projects

subagent-models

打开或关闭子代理模型和代理类型,并设置子代理运行时使用的工作强度;这些设置既可作为 /config 中的默认值,也可通过 /subagent-models 仅应用于当前会话。

jl-cmd-projects@jl-cmd-projects

jl-cmd-projects/claude-dev-env/tree/main/packages/subagent-models

已翻译

关于这个 mod

subagent-models

这是一个 Claude Code mod,用来决定子代理可以使用哪些模型和代理类型,以及它们运行时使用的工作强度。

功能

  • 指定已关闭模型的 spawn 会改用默认模型运行。将 offAction 设为 deny 时,spawn 会被拒绝,并显示应使用的模型。
  • 完整模型 id 按所属系列计数。claude-fable-5-1 属于 fable。
  • 已关闭的代理类型仍会出现在模型的代理列表中,但指定该类型的 spawn 会被拒绝。
  • 已关闭的技能仍会出现在模型的技能列表中。模型或你运行它时,技能文本会被替换为表示已关闭的说明,因此模型会跳过它。像 tdd 这样的短名称也会匹配 pstack:tdd。
  • 默认模型始终允许使用,因此已关闭的模型总有可迁移到的目标。
  • 子代理发出的每个请求都会使用你设置的工作强度运行。主对话继续使用自己的模型和工作强度。
  • 开启 applyToRunning 后,工作强度的更改会在运行中的子代理下次请求时生效。关闭后,每个子代理会保持启动时的工作强度,直到 apply 或提示列的 apply now 按钮将它们全部迁移。
  • 如果子代理的模型来自其代理定义,它会在第一次请求时被捕获,并以相同方式迁移。
  • fork 会继承父级并原样传递。不指定模型的 spawn 也是如此。
  • 页脚胶囊显示默认模型和工作强度,例如 opus/medium。* 表示该会话与默认值不同。点击它可打开或关闭提示列。

设置

/config 保存每个新会话开始时使用的默认值:

| 设置 | 选项 | 默认值 | |---|---|---| | Opus 子代理 | on, off | on | | Fable 子代理 | on, off | off | | Sonnet 子代理 | on, off | off | | Haiku 子代理 | on, off | on | | 默认子代理模型 | opus, sonnet, haiku, fable | opus | | 子代理工作强度 | inherit, low, medium, high, xhigh, max | medium | | spawn 指定已关闭模型时 | move, deny | move | | 工作强度更改传递给运行中的子代理 | on, off | on | | 已关闭的代理类型 | 逗号分隔的代理类型,例如 Explore, Plan | none | | 已关闭的技能 | 逗号分隔的技能,例如 pstack:tdd, simplify | none | | 技能计为未使用前的天数 | 一个整数,是 unused after 菜单的起始截止值 | 14 |

该命令拒绝关闭默认模型,也拒绝将已关闭的模型设为默认模型。

仅当前会话

/subagent-models 会从下一次 spawn 开始更改当前会话,并让其他会话保持不变。

  • /subagent-models 打印当前生效的值,并标记本会话改过的值。
  • /subagent-models fable on 为本会话设置一个值。任何设置名称都可以,但必须使用其选项之一。
  • /subagent-models agents 列出本会话目前提供的代理类型,并显示各自的开关。
  • /subagent-models agent Explore off 为本会话关闭一个代理类型。on 会重新开启它。
  • /subagent-models skills 列出本会话拥有的技能,并显示各自的开关。/subagent-models skill pstack:tdd off 会为本会话关闭一个技能。
  • 提示上方的框线提示列以四列等宽网格容纳所有设置。标题行包含标题、类似 opus · medium · 2 of 4 models on 的摘要,以及 minimize 按钮。下面是一条由四个彩色区段组成的条带,显示哪些模型已开启;再下面是四个模型条目,每项都有圆点、名称和 on 或 off 按钮。下一行包含默认模型、工作强度、关闭操作和运行中子代理的下拉菜单。最后一行包含 agents 和 skills 按钮、apply to running,以及用于保存或重置的 more 菜单。页脚中的胶囊 ◈ opus/medium ▴ 可一键打开或关闭提示列。
  • agents 和 skills 按钮会打开一个面板,其中有 enable all、disable all,以及每种代理类型或技能对应的一行:圆点、名称和右侧的 on 或 off 按钮。每一行都放在与最长名称等宽的单元格中,因此各行会按列对齐。超过 44 个字符的名称会保留末尾并删去中间部分。行会按命名空间显示在小型大写标题下方,例如 PSTACK 或 BRAND-VOICE,标题带有数量。按下标题可折叠或展开分组。超过 16 项的分组默认折叠,并通过 show more 按钮每次展开 40 行。超过 16 项的列表会在转录旁的侧边面板中打开,按面板宽度排成尽可能多的等宽列。按钮在侧边面板时显示 ▸,在线性面板时显示 ▴。面板会在选择项目后保持打开,直到再次按下其按钮或关闭面板。选择会立即生效,并弹出提示说明发生了什么变化。
  • mod 会在自己的存储中记录每次技能运行的时间,因此 skills 列表和面板可以显示某项技能上次使用的时间。技能面板有 sort: recent,会按最近 N 天使用、已闲置 N+ 天和从未使用分组,并在每个芯片上显示时长,最新的排在前面。unused after 菜单从 14、28 或 56 天中选择截止值,初始使用 staleDays 设置;turn off unused Nd+ (count) 会关闭记录日期早于该截止值的技能。没有记录日期的技能不会被该按钮关闭。
  • /subagent-models bar 将提示列最小化或展开。
  • /subagent-models seed <file> 将上次使用日期从回填文件加载到 mod 自己的存储中。存储位于运行命令的账户对应的 Claude 配置文件夹,因此每个账户都要运行一次。
  • /subagent-models apply 立即将所有运行中的子代理迁移到当前工作强度。
  • /subagent-models save 将本会话的值写入 /config 默认值。
  • /subagent-models reset 丢弃本会话的值,使默认值再次生效。

回填上次使用日期

mod 只会记录加载当天开始的运行。scripts/backfill-last-used.mjs 会读取机器上每个 Claude 账户保存的转录,并为模型运行过的技能和你输入的斜杠命令写入各自最新的运行日期:

node packages/subagent-models/scripts/backfill-last-used.mjs --out dates.json

它会扫描每个 ~/.claude* 文件夹,以及包含 projects 文件夹的每个 ~/.claude-profiles/* 文件夹;如果某个文件夹是已扫描文件夹的链接,则跳过。它会为每个文件夹打印转录和技能运行计数。添加 --root <config dir> 可只扫描指定的文件夹,添加 --exclude <text> 可跳过路径包含该文本的文件夹。然后在每个账户中运行 /subagent-models seed dates.json。使用 node --test packages/subagent-models/scripts/backfill-last-used.test.mjs 运行该脚本的测试。

安装

完整的 npx claude-dev-env 安装会添加 claude-dev-env 市集,并以用户范围安装此 mod,因此该配置文件夹下的每个 Claude Code 会话都会加载它。--no-subagent-models 或 CDE_INSTALL_SUBAGENT_MODELS=0 会跳过这一步。

安装程序每次运行都会移除并重新安装插件。Claude Code 卸载插件时会丢弃该插件保存的 /config 值,因此安装程序运行后会再次应用设置表中的默认值。

手动安装:

claude plugin marketplace add jl-cmd/claude-dev-env
claude plugin install subagent-models@claude-dev-env

或者从克隆目录加载,仅用于一个会话:

claude --plugin-dir packages/subagent-models

测试

claude plugin validate .
claude plugin test .

在 Claude Code 2.1.288 上构建并测试。mod API 处于早期访问阶段,可能会在不同版本之间发生变化。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add jl-cmd-projects/claude-dev-env
claude plugin install subagent-models
原文 / README

subagent-models

A Claude Code mod that decides which models and agent types subagents may run as, and the effort they run at.

What it does

  • A spawn that names a turned-off model runs on the default model instead. With offAction set to deny, the spawn is refused with a message that names the model to use.
  • A full model id counts by its family. claude-fable-5-1 is fable.
  • A turned-off agent type leaves the model's agent listing, and a spawn that names it is refused.
  • A turned-off skill still appears in the model's skill listing. When the model or you run it, the skill's text is replaced with a note that says it is off, so the model skips it. A short name such as tdd also matches pstack:tdd.
  • The default model is always allowed, so a turned-off model always has somewhere to move.
  • Every request a subagent makes runs at the effort you set. The main conversation keeps its own model and effort.
  • With applyToRunning on, an effort change reaches running subagents on their next request. With it off, each subagent keeps the effort it started with until apply, or the bar's apply now button, moves them all.
  • A subagent whose model comes from its agent definition is caught on its first request and moved the same way.
  • A fork inherits its parent and passes untouched. So does a spawn that names no model.
  • The footer pill shows the default model and effort, as opus/medium. A * marks a session that differs from the defaults. Clicking it opens or closes the bar.

Settings

/config holds the defaults every new session starts with:

| Setting | Options | Default | |---|---|---| | Opus subagents | on, off | on | | Fable subagents | on, off | off | | Sonnet subagents | on, off | off | | Haiku subagents | on, off | on | | Default subagent model | opus, sonnet, haiku, fable | opus | | Subagent effort | inherit, low, medium, high, xhigh, max | medium | | When a spawn names a turned-off model | move, deny | move | | Effort changes reach running subagents | on, off | on | | Turned-off agent types | comma-separated agent types, such as Explore, Plan | none | | Turned-off skills | comma-separated skills, such as pstack:tdd, simplify | none | | Days before a skill counts as unused | a whole number of days, the starting cutoff of the unused after menu | 14 |

The command refuses to turn off the default model, and refuses a default model that is turned off.

This session only

/subagent-models changes the current session from its next spawn, and leaves other sessions alone.

  • /subagent-models prints the values in force and marks the ones this session changed.
  • /subagent-models fable on sets one value for this session. Any setting name works, with one of its options.
  • /subagent-models agents lists the agent types offered so far in this session, each with its switch.
  • /subagent-models agent Explore off turns one agent type off for this session. on turns it back on.
  • /subagent-models skills lists the skills the session has, each with its switch. /subagent-models skill pstack:tdd off turns one skill off for this session.
  • A framed bar above the prompt holds every setting in a grid of four equal columns. The header row has the title, a summary such as opus · medium · 2 of 4 models on, and a minimize button. Under it a strip of four colored segments shows which models are on, and a row of four model entries below it has a dot, the name and an on or off button each. The next row has dropdowns for the default model, effort, the turned-off action, and running subagents. The last row has the agents and skills buttons, apply to running, and a more menu that saves or resets. A pill in the footer, ◈ opus/medium ▴, opens and closes the bar with one click.
  • The agents and skills buttons open a panel with enable all, disable all, and one row per agent type or skill: a dot, the name, and an on or off button at the right edge. Every row sits in a cell as wide as the longest name, so the rows line up in columns. A name longer than 44 characters keeps its tail and loses its middle. The rows sit under a small-caps heading per namespace, such as PSTACK or BRAND-VOICE, with a count. Press a heading to fold or open its group. A group of more than 16 starts folded, and opens 40 rows at a time with a show more button. A list of more than 16 opens in a side pane beside the transcript, laid out in as many equal columns as the pane is wide. The button shows ▸ for a side pane and ▴ for an inline panel. A panel stays open across picks until you press its button again or close the pane. A pick applies at once and a toast says what changed.
  • The mod records the time of each skill run in its own store, so the skills listing and panel can show when a skill was last used. The skills panel has sort: recent, which groups the chips as used in the last N days, unused N+ days, and never seen, newest first, with the age on each chip. The unused after menu picks the cutoff from 14, 28 or 56 days, starting at the staleDays setting, and turn off unused Nd+ (count) turns off the skills with a recorded date older than that cutoff. A skill with no recorded date is never turned off by that button.
  • /subagent-models bar minimizes the bar or expands it.
  • /subagent-models seed <file> loads last-used dates from a backfill file into the mod's own store. The store lives in the Claude config folder of the account that runs the command, so run it once in each account.
  • /subagent-models apply moves every running subagent to the current effort now.
  • /subagent-models save writes this session's values to the /config defaults.
  • /subagent-models reset drops this session's values, so the defaults apply again.

Backfill last-used dates

The mod only records runs from the day it loads. scripts/backfill-last-used.mjs reads the saved transcripts of every Claude account on the machine and writes the newest date of each skill run, for skills the model ran and slash commands you typed:

node packages/subagent-models/scripts/backfill-last-used.mjs --out dates.json

It scans every ~/.claude* folder and every ~/.claude-profiles/* folder that holds a projects folder, skips a folder that is a link to one it already scanned, and prints the transcript and skill-run count for each. Add --root <config dir> to scan only the folders you name, or --exclude <text> to skip a folder whose path contains the text. Then run /subagent-models seed dates.json in each account. Run the script's tests with node --test packages/subagent-models/scripts/backfill-last-used.test.mjs.

Install

A full npx claude-dev-env install adds the claude-dev-env marketplace and installs the mod at user scope, so every Claude Code session under that config folder loads it. --no-subagent-models or CDE_INSTALL_SUBAGENT_MODELS=0 skips that step.

The installer removes and reinstalls the plugin on each run. Claude Code drops a plugin's saved /config values when it uninstalls the plugin, so after an installer run the defaults in the Settings table apply again.

To install it by hand:

claude plugin marketplace add jl-cmd/claude-dev-env
claude plugin install subagent-models@claude-dev-env

Or load it from a clone for one session:

claude --plugin-dir packages/subagent-models

Test

claude plugin validate .
claude plugin test .

Built and tested on Claude Code 2.1.288. The mod API is in early access and can change between releases.

更多类似作品