library: a plugin hook that reads CLAUDE_PLUGIN_ROOT itself gets the folder
@AXmake110 on X: with the Claude Code plugin ponytail installed for an
agent, every start of the agent printed a red error. ponytail's hooks
read the folder in Node, not through the shell:
node -e "require(require('path').join(process.env.CLAUDE_PLUGIN_ROOT.split(String.fromCharCode(92)).join('/'), 'hooks/ponytail-activate.js'))"
magpie replaced only ${CLAUDE_PLUGIN_ROOT} and $CLAUDE_PLUGIN_ROOT, so
the command went into Claude Code's settings.json (and, for the
UserPromptSubmit hook, Codex's hooks.json) as written. Outside Claude
Code's plugin runtime nothing sets the variable, and Node threw
"Cannot read properties of undefined (reading 'split')".
Fixed for the class (plugin_env.go):
- a hook program's own read of CLAUDE_PLUGIN_ROOT or CLAUDE_PLUGIN_DATA
becomes a quoted string literal of the folder, with forward slashes:
process.env.X, process.env['X'], Bun.env, Deno.env.get, Python's
os.environ[...]/.get/os.getenv, Ruby's ENV[...]/ENV.fetch. The quote
is chosen so it doesn't end the sh quoting around it. PowerShell's
$env:X / ${env:X} and cmd's %X% become the folder.
- a plugin's command MCP server gets both variables in its env, as
Claude Code gives them, unless the plugin set them.
- ${CLAUDE_PLUGIN_ROOT}/DATA in a subagent's prompt and in a copied
SKILL.md are resolved, as Claude Code resolves them in Markdown.
- every agent gets the same text: the parts are library items, so
Claude Code, Codex, Gemini, Cursor and Grok are all written from them.
- existing installs: load() heals the hooks, servers and subagent
prompts of an installed plugin that still name the variables, and the
next sync (the app's startup sync) writes them out again; the old
entry is replaced, not duplicated. A SKILL.md copied before is fixed
by the plugin's Update or a reinstall.
Not carried yet, filed as #6682: exec-form hooks (command + args, whose
args are dropped today) and CLAUDE_PLUGIN_OPTION_<KEY>.
The fixture is ponytail's published hooks files, byte for byte
(DietrichGebert/ponytail 96608e07, testdata/ponytail/README.md).
Run (mote; full suite at 901b56c80 on origin/main 221c91fae, then
rebased on 411769e9c and internal/library + internal/tui run again: ok):
- go test ./internal/library -run TestPlugin: ok.
- New tests: TestPluginHookReadsRootFromItsProgram (installs ponytail for
Claude and Codex, then runs the SessionStart command under sh with
node and no CLAUDE_PLUGIN_ROOT), TestPluginHookWrittenBeforeIsResolved
(old library.json + settings.json, then Sync), TestPluginEnvRefsEachSpelling,
TestPluginPartsGetItsFolders.
- Broken by hand: with the hook rewrite and the heal off, the first two
go red and node prints the reporter's TypeError; with only the heal
off, TestPluginHookWrittenBeforeIsResolved alone goes red; with the
server env, prompt and skill changes off, TestPluginPartsGetItsFolders
goes red (the written .claude/agents/helper.md too).
- Real use in a sandbox HOME: installed the real ponytail 5.3.3 from
github.com/DietrichGebert/ponytail for Claude Code and Codex; the
three hooks landed with the folder as a literal, and each ran under
sh with node and printed ponytail's context, no error.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean.
- Windows (xiaomi-gpu): go test ./internal/library -run TestPlugin ok
(the node run is skipped there).
- Full suite (go test -tags nogui -count=1 -timeout 45m ./...): 98
packages ok; every red is already on main and none is in the library:
TestNoEagerPackageRegexps (chatpage.go, #6689), cli's
TestEveryRouteHasACommandOrIsNamed (#6677), gateway's
TestKeySlotEveryRoute and TestLazyCatManifestListsTheClientRoutes
(#6688), and a doneHold panic in a gateway test helper (#6690). The
tui red (TestEveryWordHasZh) is fixed in the next commit.
Not tried: a real Claude Code or Codex session starting with the hooks
(the commands were run as they run them, with sh -c); a hook run
on Windows.
This commit is contained in:
@@ -37,7 +37,7 @@ Pi's extensions and packages.
|
||||
| Variables | An `EnvVar` (paopao_baobao on X) is a name, a value and the agents ticked for it (`internal/library/env.go`). Claude Code gets it in `settings.json`'s `env`, Codex in `config.toml`'s `[shell_environment_policy.set]` (`envFile`, `writeEnv`); an agent with no such setting is greyed on the tab, saying why. `syncEnv` records what it wrote in `Applied.Env` and never overrides the user: a name the file already sets to another value is left as it is and reported as a problem on the row (`env:<name>`), and a recorded value the user changed in the file is theirs from then on (the record is dropped, a removal or a turn-off leaves it). Turning an agent off or removing the variable takes out only the recorded, unchanged value. Codex's spelling is respected: a `set` sub-table or an inline `set = {…}` is edited, a dotted spelling is refused with `left as it is`. An unreadable or wrongly typed file is an error, never empty, and nothing is written. Names are `[A-Za-z_][A-Za-z0-9_]*`, at most 128, values at most 8192 bytes. Variables are carried with the library (see below). Tests: `TestEnvWrittenAndTakenOut`, `TestEnvNeverOverridesTheUsers`, `TestEnvValueChanged`, `TestEnvCodexInlineSet`, `TestEnvUnreadableFileLeftAlone`, `TestEnvChecked`, `library-env.test.cjs`. |
|
||||
| Subagents | A `Subagent` (#2283) is a name (lowercase letters, digits and -), a one-line description, a prompt, and the library's skills and MCP servers it uses, given to the agents ticked for it. `syncSubagents` writes it as a file of its own in each agent's user-level folder, in that agent's format (`subagentSpecOf`): Markdown with YAML front matter in `~/.claude/agents` (with `skills` and `mcpServers`), `~/.factory/droids` (with `mcpServers`), `~/.config/opencode/agents` (`mode: subagent`), `~/.gemini/agents`, `~/.qwen/agents`, `~/.grok/agents`, `~/.cursor/agents` and `~/.copilot/agents` (`<name>.agent.md`); a TOML role (`name`, `description`, `model` when set, `developer_instructions`) in `$CODEX_HOME/agents`. Skills and servers are named only where the agent's file can name them, and only those the library has. A subagent's optional `Model` (a model or routing group of Codex's list, `subagentModels` in `/api/library`) is written only into Codex's role (luckymanjc on Discord): the role file is a config layer, and Codex lays its `model` over the one its lead names in spawn_agent (`apply_spawn_agent_role` after `apply_requested_spawn_agent_model_overrides` in codex-rs `core/src/agent/child_config.rs`), so the subagent's requests carry it and the gateway routes them as any other. Codex's subagent model on the Agents page (`CodexSubagentModel`), when set, still rewrites every subagent's request, and the editor says so. Without one, a Codex subagent runs on the model its lead names, else the lead's own. The page lists, per agent, whether it binds skills, servers and a model (`SubagentAgentView`), names the agents that run a subagent on their own pick, and greys out an agent that takes none. | [`subagents.go`](../../internal/library/subagents.go) |
|
||||
| Subagents from a repository | The Subagents tab's find line (CHENGJIAHEGOXIS on X: msitarzewski/agency-agents) takes what the skill installer does, owner/repo, a GitHub or GitLab link to the repository, a folder or a file in it, any git address, or a folder here, and fetches it the same way (`fetchSourceRoot`, shared with `resolvePluginRoot`; `tooBig` refuses a whole repository too big to download and asks for its folder's link). `ProbeSubagents` lists each Markdown file with front matter that has a description (`readSubagentAt`): its name is the slug of `name` (`subagentName`), else the file's own name when it sits in an `agents` or `droids` folder; its description is folded to one line of at most 1000 characters; the body is the prompt. Every other key (`color`, `emoji`, `vibe`, `tools`, `author`, `model`, …) is dropped, a Codex TOML role is not read, and a skill's folder (one with a SKILL.md) and `.git`, `.github`, `node_modules` are skipped. Of two files with one name the shallower is taken and the other is listed in `Left` with why, as is one `Subagent.check` refuses (a reserved name). `ImportSubagents` (`POST /api/library/subagents/probe`, then `subagents/import` with `source`, `paths`, `agents`) adds the picked ones for the agents ticked, recording where each came from (`From`, a `Source` with the file's path) and the hash of its description and prompt as imported (`FromHash`). Imported again, from the repository's link or a folder's or a file's, a subagent from the same file is `have` when it is the same, `update` when upstream changed and the library's still matches `FromHash` (its description and prompt are replaced, its agents, skills, servers and model kept), and `edited` when the user changed it here (`SaveSubagent` keeps `From`; it is left as it is). A name the library has for another subagent is never written over: the import takes the next free `name-N`. A carried library carries `From`. The page lists what was found to pick from, with Select all, a filter past eight, a tag for each state and the files left out (`TestSubagentsFromAgencyAgents`, `TestSubagentImportLeavesTheUsersOwn`, `TestSubagentImportAgainUpdates`, `TestSubagentsFromAFolder`, `library-subagents-import.test.cjs`; the fixture is agency-agents' own files in `testdata/agency-agents`). | [`subagent_import.go`](../../internal/library/subagent_import.go), [`plugin.go`](../../internal/library/plugin.go), [`plugins/library/client.js`](../../internal/gui/assets/plugins/library/client.js) |
|
||||
| Claude plugins | A `Plugin` (FakeshadowzZ on X) is a Claude Code plugin kept as one item: `.claude-plugin/plugin.json`, `skills/<name>/SKILL.md`, `agents/*.md`, `hooks/hooks.json` and `.mcp.json`, from a folder, a git address or a marketplace.json (`ProbePlugins`, `InstallPlugins`; a marketplace entry with a relative path, or a github/url/git source, is fetched when installed). Its files are copied to `<library>/plugins/<name>`; `${CLAUDE_PLUGIN_ROOT}` is that folder and `${CLAUDE_PLUGIN_DATA}` is `<library>/plugin-data/<name>`, which an update keeps. Its parts are ordinary library skills, MCP servers, hooks and subagents, each tagged `Bundle: <plugin>`, so every agent gets them through the code of its kind and the old tabs go on working; the plugin holds the names, its agents and `Off`. `PluginAgents` sets every part's agents, `PluginOn` clears them (kept in `Agents` for turning it on again) or gives them back, `RemovePlugin` removes the parts, and `UpdatePlugin` reads the source again. A hook whose Claude event and matcher have a portable event becomes it (Stop turn-end, PostToolUse after-tool, PreToolUse before-tool, UserPromptSubmit prompt, SessionStart session-start; Bash is shell, Edit/Write/MultiEdit is edit); any other event is `claude:<Event>`, for Claude Code only. Subagents go to the agents in `SubagentAgents`. A part whose name the library has gets the prefix `<plugin>-`: the user's own item is never written over or removed. Slash commands, LSP servers and hooks that aren't a command are listed in `Left` and shown, not carried. A backup file carries the parts but not the plugin record or its folder, so on another computer they are ordinary items whose `${CLAUDE_PLUGIN_ROOT}` paths don't exist (`TestPluginImportCarryOnOffRemove`, `TestPluginNameClashKeepsTheUsersOwn`, `TestPluginMarketplaceAndUpdate`, `TestPluginRefusesWhatIsNone`, `library-plugins.test.cjs`). | [`plugin.go`](../../internal/library/plugin.go), [`plugins/library/client.js`](../../internal/gui/assets/plugins/library/client.js) |
|
||||
| Claude plugins | A `Plugin` (FakeshadowzZ on X) is a Claude Code plugin kept as one item: `.claude-plugin/plugin.json`, `skills/<name>/SKILL.md`, `agents/*.md`, `hooks/hooks.json` and `.mcp.json`, from a folder, a git address or a marketplace.json (`ProbePlugins`, `InstallPlugins`; a marketplace entry with a relative path, or a github/url/git source, is fetched when installed). Its files are copied to `<library>/plugins/<name>`; `${CLAUDE_PLUGIN_ROOT}` is that folder and `${CLAUDE_PLUGIN_DATA}` is `<library>/plugin-data/<name>`, which an update keeps. No agent sets either variable outside Claude Code's plugin runtime, so every reference is resolved before a part is written out ([`plugin_env.go`](../../internal/library/plugin_env.go)): `${NAME}`/`$NAME` in a hook command, a server's command, args and env, a subagent's prompt and a copied SKILL.md become the folder; a hook program's own read (`process.env.NAME`, `Bun.env`, `Deno.env.get`, Python's `os.environ`/`os.getenv`, Ruby's `ENV`) becomes a quoted string literal of the folder with forward slashes, and PowerShell's `$env:NAME` and cmd's `%NAME%` the folder (ponytail's hooks threw at every start without it, @AXmake110 on X); a command server is given both variables in its env, as Claude Code gives them. Parts a magpie before this wrote with the variables in them are resolved at load (`healPluginRefs`) and written out again at the next sync; a SKILL.md copied before is fixed by Update or a reinstall. Exec-form hooks (`args`) and `CLAUDE_PLUGIN_OPTION_<KEY>` are not carried yet (#6682). Its parts are ordinary library skills, MCP servers, hooks and subagents, each tagged `Bundle: <plugin>`, so every agent gets them through the code of its kind and the old tabs go on working; the plugin holds the names, its agents and `Off`. `PluginAgents` sets every part's agents, `PluginOn` clears them (kept in `Agents` for turning it on again) or gives them back, `RemovePlugin` removes the parts, and `UpdatePlugin` reads the source again. A hook whose Claude event and matcher have a portable event becomes it (Stop turn-end, PostToolUse after-tool, PreToolUse before-tool, UserPromptSubmit prompt, SessionStart session-start; Bash is shell, Edit/Write/MultiEdit is edit); any other event is `claude:<Event>`, for Claude Code only. Subagents go to the agents in `SubagentAgents`. A part whose name the library has gets the prefix `<plugin>-`: the user's own item is never written over or removed. Slash commands, LSP servers and hooks that aren't a command are listed in `Left` and shown, not carried. A backup file carries the parts but not the plugin record or its folder, so on another computer they are ordinary items whose `${CLAUDE_PLUGIN_ROOT}` paths don't exist (`TestPluginImportCarryOnOffRemove`, `TestPluginHookReadsRootFromItsProgram`, `TestPluginHookWrittenBeforeIsResolved`, `TestPluginPartsGetItsFolders`, `TestPluginNameClashKeepsTheUsersOwn`, `TestPluginMarketplaceAndUpdate`, `TestPluginRefusesWhatIsNone`, `library-plugins.test.cjs`). | [`plugin.go`](../../internal/library/plugin.go), [`plugins/library/client.js`](../../internal/gui/assets/plugins/library/client.js) |
|
||||
| Backups | Before a change first writes an agent file, `backups` copies it to `BackupDir`, one folder per change. The last `keepBackups` (30) changes are kept. The Backups button at the top of every tab, beside Library folder, opens that folder (`libHead`; Dade on Discord found it at the foot of a long page). | [`backup.go`](../../internal/library/backup.go) |
|
||||
| RTK | `SetRTK` runs rtk's own installer (`rtk init -g …`) for an agent being switched on. For one being switched off, it removes exactly what the installer wrote, using magpie's own code, which works even with rtk gone. An rtk.exe in one of winget's folders that winget has no record of (`winget list` says so, or its records name another folder; netube99 on X, 0x8A150014) is upgraded from rtk's own Windows release over the file a `WinGet\Links` link points to, not by `winget upgrade`. `ReadRTK` reads each agent's files to say which have the hook. An agent gone for its CLI (`CLIMissing`, #2254) isn't offered rtk, but one that still has the hook is listed so it can be taken out. `rtkSpec.blocked` stops the installer where it would break an agent. `rtkSpec.env` tells the installer the agent's folder where rtk would pick another: Hermes Agent's is `appdir.HermesHome` (`%LOCALAPPDATA%\hermes` on Windows), which rtk is given as `HERMES_HOME`, since rtk 0.51 knows only `$HERMES_HOME` and `~/.hermes`. Antigravity CLI (`agy`, #2202) gets rtk 0.51's own plugin for Antigravity, `plugins/rtk` in its global customization folder `~/.gemini/config` (`plugin.json`, `hooks.json` with `PreToolUse` → `rtk hook antigravity`, `rules/AGENTS.md`), which `agy plugin list` lists; switching it off takes that one folder out. rtk 0.50 knows Antigravity only per project and fails `rtk init -g --agent antigravity`, so an older rtk is `blocked` (`agyBlocked`) and the row says to update RTK. OpenCode 2 loads only the plugin rtk 0.52 on writes (one default object with `id` and `setup()`, rtk-ai/rtk#4187); an older rtk's plugin is for OpenCode 1 and OpenCode 2 refuses it, so with an OpenCode 2 here an older rtk is `blocked` (`openCodeBlocked`) and the row says to update RTK (#2295). Under OpenCode 2, an old plugin left from before an rtk update counts as off once the rtk here can write the new one (`openCodeHas`), so switching it on writes the new one over it; with an older rtk it counts as on, so it can be switched off. Factory's Droid (lml0664 on Discord) gets rtk's own `rtk init -g --agent droid`, given Droid's folder as `FACTORY_HOME_OVERRIDE`; rtk puts its `Execute` group (`rtk hook droid`) in the root `hooks.json`, or in `settings.json`'s `hooks.PreToolUse` where Droid's hooks already are, so `droidHookFiles` reads and switches off all three places rtk 1.1.0 may use (`hooks.json`, `hooks/hooks.json`, `settings.json`), leaving the user's own hooks. rtk before 0.44 has no Droid agent, so it is `blocked` (`droidBlocked`). A detected agent RTK has no hook for at all is still listed, from `rtkNoHook`, with the reason and a switch that can't be turned on (dsh: its hooks can allow or deny a command but not rewrite it, and `rtk init` has no `--agent dsh`; Grok Build and Grok App: `rtk init` has no Grok or Grok App agent, so both are listed with the switch off; Qoder and Qoder CN: rtk 1.1.0 has no Qoder agent; Cline and Kimi Code: `rtk init --agent cline|kimi` writes only one project's `.clinerules` or `AGENTS.md`, instructions with no hook, and Kimi's refuses `-g`). RTK 1.1.0's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent. The page's No RTK hook tag gives each agent's own reason and rtk-ai/rtk issue (`rtkNoHookWhy` in plugins/library/client.js: dsh #3847, Grok Build and Grok App #2136, Qoder and Qoder CN #1327, Cline #3841), and an agent with no entry gets no link; `TestRTKNoHookIssuesAreEachAgents` fails when the page and `rtkNoHook` cite different issues, or two agents cite the same ones without a reason in `sharedRTKIssues`. | [`rtk.go`](../../internal/library/rtk.go) |
|
||||
| RTK in WSL | An agent in a WSL distro (`claude@wsl:Ubuntu`) is listed by its kind (`rtkKind`), and its hook runs in the distro, where Windows' rtk.exe is no command, so it gets the distro's own rtk (lex on Discord). `rtkDistroOf` asks the distro with `wsl.exe -d <distro> -e sh -lc` where rtk is (a login or interactive shell's PATH; else `~/.local/bin` or `~/.cargo/bin`, `offPath`), kept 15s; `ReadRTK` lists one `RTKDistro` for each distro its agents are in. Install RTK in WSL `<distro>` (`InstallRTKIn`, `POST /api/library/rtk/install` with `distro`, `magpie library rtk install <distro>`) runs RTK's own Linux installer in the distro (`curl -fsSL …/install.sh \| sh`, wget where there's no curl). Switching an agent on runs the distro's rtk there (`rtkInstallWSL`: `rtk init -g …` with its folder on PATH, Claude Code pointed at a folder of its own for the OpenCode and Cursor installers), and reads and edits its files under the distro's home as magpie opens it (`rtkClaudeDir`, `rtkCodexDir`, `rtkHome`). A distro that isn't running is never started (#3896): `rtkWSLLive` and `rtkDistroOf` check `agent.WSLRunning` first, its agents are listed `asleep` with the switch off, and switching or installing says to start it (`TestRTKWSLAsleep`). The page gives each distro a card (`rtkDistroCard` in plugins/library/client.js; library-rtk-wsl.test.cjs). | [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) |
|
||||
|
||||
@@ -219,8 +219,9 @@ func load() (*Library, error) {
|
||||
if l.Applied == nil {
|
||||
l.Applied = map[string]*Applied{}
|
||||
}
|
||||
l.heal() // magpie's own servers run this computer's magpie (self_here.go)
|
||||
l.carryTwin() // Claude Magpie keeps what it was given as Claude Desktop (desktop_twin.go)
|
||||
l.heal() // magpie's own servers run this computer's magpie (self_here.go)
|
||||
l.carryTwin() // Claude Magpie keeps what it was given as Claude Desktop (desktop_twin.go)
|
||||
l.healPluginRefs() // a plugin's parts that still name its variables (plugin_env.go)
|
||||
return l, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,12 @@ import (
|
||||
// agent here can take (slash commands, LSP servers, hooks that aren't a
|
||||
// command) are listed in Left, never silently dropped.
|
||||
//
|
||||
// ${CLAUDE_PLUGIN_ROOT} in a command, argument, header or value is the
|
||||
// bundle's folder; ${CLAUDE_PLUGIN_DATA} a folder of its own that stays
|
||||
// across updates.
|
||||
// ${CLAUDE_PLUGIN_ROOT} in a command, argument, header or value, a skill's
|
||||
// SKILL.md or a subagent's prompt is the bundle's folder;
|
||||
// ${CLAUDE_PLUGIN_DATA} a folder of its own that stays across updates. A
|
||||
// hook's program that reads either from its environment is given the
|
||||
// folder as a literal, and a command server both in its env
|
||||
// (plugin_env.go).
|
||||
|
||||
// Plugin is a plugin the library keeps.
|
||||
type Plugin struct {
|
||||
@@ -208,11 +211,7 @@ func readPlugin(dir, hint string, over map[string]any) (*plLoaded, error) {
|
||||
return nil, errors.New("the plugin has no name")
|
||||
}
|
||||
p := &plLoaded{name: name, description: strings.Join(strings.Fields(plStr(man["description"])), " "), version: plStr(man["version"])}
|
||||
root, data := pluginDir(name), pluginData(name)
|
||||
sub := func(s string) string {
|
||||
return strings.NewReplacer("${CLAUDE_PLUGIN_ROOT}", root, "$CLAUDE_PLUGIN_ROOT", root,
|
||||
"${CLAUDE_PLUGIN_DATA}", data, "$CLAUDE_PLUGIN_DATA", data).Replace(s)
|
||||
}
|
||||
root, sub := pluginDir(name), pluginSub(name)
|
||||
leave := func(what, why string) { p.left = append(p.left, PluginLeft{What: what, Why: why}) }
|
||||
|
||||
// skills
|
||||
@@ -277,6 +276,7 @@ func readPlugin(dir, hint string, over map[string]any) (*plLoaded, error) {
|
||||
leave("agent "+strings.TrimSuffix(filepath.Base(f), filepath.Ext(f)), err.Error())
|
||||
continue
|
||||
}
|
||||
s.Prompt = sub(s.Prompt)
|
||||
p.agents = append(p.agents, s)
|
||||
}
|
||||
|
||||
@@ -303,6 +303,9 @@ func readPlugin(dir, hint string, over map[string]any) (*plLoaded, error) {
|
||||
}
|
||||
for _, doc := range mcpDocs {
|
||||
servers, left := serversOf(doc, sub)
|
||||
for _, s := range servers {
|
||||
pluginServerEnv(s, name)
|
||||
}
|
||||
p.servers = append(p.servers, servers...)
|
||||
p.left = append(p.left, left...)
|
||||
}
|
||||
@@ -557,7 +560,7 @@ func plHooksOf(doc map[string]any, bundle, root string, sub func(string) string,
|
||||
left = append(left, PluginLeft{What: ev + " hook", Why: "a hook of type " + t + " isn't a command: agents take commands only"})
|
||||
continue
|
||||
}
|
||||
cmd := sub(quoteRoot(plStr(hm["command"]), root))
|
||||
cmd := sub(quoteRoot(pluginEnvRefs(plStr(hm["command"]), bundle), root))
|
||||
if cmd == "" {
|
||||
continue
|
||||
}
|
||||
@@ -1057,6 +1060,11 @@ func installPlugin(l *Library, pl *plLoaded, dir, input, pick string, agents []s
|
||||
skip("skill "+s.name, err.Error())
|
||||
continue
|
||||
}
|
||||
if err := pluginSkillText(skillDir(n), pl.name); err != nil {
|
||||
os.RemoveAll(skillDir(n))
|
||||
skip("skill "+s.name, err.Error())
|
||||
continue
|
||||
}
|
||||
l.Skills = append(l.Skills, &Skill{Name: n, Agents: []string{}, Bundle: pl.name})
|
||||
b.Skills = append(b.Skills, n)
|
||||
skillNames[s.name] = n
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/yetone/magpie/internal/lazyre"
|
||||
)
|
||||
|
||||
// Claude Code runs a plugin's hooks and MCP servers with CLAUDE_PLUGIN_ROOT
|
||||
// and CLAUDE_PLUGIN_DATA in their environment, and resolves ${NAME} in their
|
||||
// commands, arguments and env, and in skill and agent Markdown (its plugins
|
||||
// reference, "Where each variable resolves"). A part the library carries
|
||||
// runs as an ordinary hook, server, skill or subagent of each agent, where
|
||||
// neither is set, so magpie resolves every reference to them it can find
|
||||
// before writing the part out.
|
||||
//
|
||||
// A hook's command can also read the variable itself, in the language it
|
||||
// runs: ponytail's SessionStart hook is
|
||||
//
|
||||
// node -e "require(require('path').join(process.env.CLAUDE_PLUGIN_ROOT.split(...).join('/'), 'hooks/ponytail-activate.js'))"
|
||||
//
|
||||
// which, given as written, threw at every start of the agent
|
||||
// (@AXmake110 on X). Such a read becomes a string literal of the folder.
|
||||
// A hook has no env of its own in any agent's file, so the command is the
|
||||
// only place to put it; an MCP server has one, and is given both
|
||||
// variables there, as Claude Code gives them.
|
||||
|
||||
var pluginEnvNames = []string{"CLAUDE_PLUGIN_ROOT", "CLAUDE_PLUGIN_DATA"}
|
||||
|
||||
const plVar = `(CLAUDE_PLUGIN_(?:ROOT|DATA))`
|
||||
|
||||
// pluginEnvReads are a program's reads of the variable that a string
|
||||
// literal stands in for: JavaScript (Node, Bun, Deno), Python and Ruby.
|
||||
var pluginEnvReads = lazyre.New(strings.Join([]string{
|
||||
`(?:process|Bun)\.env\.` + plVar + `\b`,
|
||||
`(?:process|Bun)\.env\[\s*['"` + "`" + `]` + plVar + `['"` + "`" + `]\s*\]`,
|
||||
`Deno\.env\.get\(\s*['"]` + plVar + `['"]\s*\)`,
|
||||
`os\.environ\[\s*['"]` + plVar + `['"]\s*\]`,
|
||||
`os\.(?:environ\.get|getenv)\(\s*['"]` + plVar + `['"]\s*(?:,[^()]*)?\)`,
|
||||
`\bENV\[\s*['"]` + plVar + `['"]\s*\]`,
|
||||
`\bENV\.fetch\(\s*['"]` + plVar + `['"]\s*(?:,[^()]*)?\)`,
|
||||
}, "|"))
|
||||
|
||||
// pluginEnvShell are the shells' own spellings other than sh's ${NAME} and
|
||||
// $NAME (which pluginSub replaces): PowerShell's $env:NAME and
|
||||
// ${env:NAME}, and cmd's %NAME%. The folder goes in as written, as it
|
||||
// does for sh's.
|
||||
var pluginEnvShell = lazyre.New(`(?i:\$env:)` + plVar + `\b|\$\{(?i:env:)` + plVar + `\}|%` + plVar + `%`)
|
||||
|
||||
// pluginSub replaces ${NAME} and $NAME with the plugin's folders.
|
||||
func pluginSub(name string) func(string) string {
|
||||
root, data := pluginDir(name), pluginData(name)
|
||||
return strings.NewReplacer("${CLAUDE_PLUGIN_ROOT}", root, "$CLAUDE_PLUGIN_ROOT", root,
|
||||
"${CLAUDE_PLUGIN_DATA}", data, "$CLAUDE_PLUGIN_DATA", data).Replace
|
||||
}
|
||||
|
||||
// pluginEnvRefs resolves a hook command's reads of the plugin's variables:
|
||||
// a program's read becomes a string literal, quoted so it doesn't end the
|
||||
// shell's quoting around it, and a shell's own spelling the folder.
|
||||
// ${NAME} and $NAME are left to pluginSub.
|
||||
func pluginEnvRefs(cmd, name string) string {
|
||||
if !strings.Contains(cmd, "CLAUDE_PLUGIN_") {
|
||||
return cmd
|
||||
}
|
||||
folder := func(v string) string {
|
||||
if v == "CLAUDE_PLUGIN_DATA" {
|
||||
return pluginData(name)
|
||||
}
|
||||
return pluginDir(name)
|
||||
}
|
||||
var b strings.Builder
|
||||
last := 0
|
||||
for _, m := range pluginEnvReads.FindAllStringSubmatchIndex(cmd, -1) {
|
||||
v := ""
|
||||
for g := 2; g+1 < len(m); g += 2 {
|
||||
if m[g] >= 0 {
|
||||
v = cmd[m[g]:m[g+1]]
|
||||
break
|
||||
}
|
||||
}
|
||||
b.WriteString(cmd[last:m[0]])
|
||||
// forward slashes: every runtime here takes them on Windows too,
|
||||
// and a backslash would be an escape in the literal
|
||||
p := filepath.ToSlash(folder(v))
|
||||
q := "'"
|
||||
if shellQuoteAt(cmd, m[0]) == '\'' {
|
||||
q = `"`
|
||||
}
|
||||
b.WriteString(q + strings.NewReplacer(`\`, `\\`, q, `\`+q).Replace(p) + q)
|
||||
last = m[1]
|
||||
}
|
||||
b.WriteString(cmd[last:])
|
||||
return pluginEnvShell.ReplaceAllStringFunc(b.String(), func(s string) string {
|
||||
if strings.Contains(s, "DATA") {
|
||||
return pluginData(name)
|
||||
}
|
||||
return pluginDir(name)
|
||||
})
|
||||
}
|
||||
|
||||
// shellQuoteAt is the sh quote open at byte i of s: ', " or 0.
|
||||
func shellQuoteAt(s string, i int) byte {
|
||||
var q byte
|
||||
for j := 0; j < i && j < len(s); j++ {
|
||||
c := s[j]
|
||||
switch {
|
||||
case q == '\'':
|
||||
if c == '\'' {
|
||||
q = 0
|
||||
}
|
||||
case c == '\\':
|
||||
j++
|
||||
case q == '"':
|
||||
if c == '"' {
|
||||
q = 0
|
||||
}
|
||||
case c == '\'' || c == '"':
|
||||
q = c
|
||||
}
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
// pluginServerEnv gives a plugin's command server the variables Claude
|
||||
// Code gives it, unless the plugin set them itself.
|
||||
func pluginServerEnv(s *Server, name string) {
|
||||
if s.Transport != "stdio" && s.Transport != "" {
|
||||
return
|
||||
}
|
||||
for _, v := range pluginEnvNames {
|
||||
if _, ok := s.Env[v]; ok {
|
||||
continue
|
||||
}
|
||||
if s.Env == nil {
|
||||
s.Env = map[string]string{}
|
||||
}
|
||||
if v == "CLAUDE_PLUGIN_DATA" {
|
||||
s.Env[v] = pluginData(name)
|
||||
} else {
|
||||
s.Env[v] = pluginDir(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pluginSkillText resolves ${NAME} in a skill's SKILL.md copied out of a
|
||||
// plugin, as Claude Code does when it loads a plugin's skill.
|
||||
func pluginSkillText(dir, name string) error {
|
||||
f := filepath.Join(dir, "SKILL.md")
|
||||
b, err := os.ReadFile(f)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
s := string(b)
|
||||
if !strings.Contains(s, "CLAUDE_PLUGIN_") {
|
||||
return nil
|
||||
}
|
||||
fi, err := os.Stat(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(f, []byte(pluginSub(name)(s)), fi.Mode().Perm())
|
||||
}
|
||||
|
||||
// healPluginRefs resolves the plugin variables still in the parts of an
|
||||
// installed plugin, written by a magpie that left them as they were: a
|
||||
// hook's program read, a server that reads them, a subagent's prompt.
|
||||
// Such a reference never works outside Claude Code's plugin runtime, so
|
||||
// resolving it changes nothing that worked; the next sync writes the
|
||||
// part out again.
|
||||
func (l *Library) healPluginRefs() {
|
||||
if len(l.Plugins) == 0 {
|
||||
return
|
||||
}
|
||||
ours := func(b string) bool { return b != "" && l.plugin(b) != nil }
|
||||
for _, h := range l.Hooks {
|
||||
if h != nil && ours(h.Bundle) && strings.Contains(h.Command, "CLAUDE_PLUGIN_") {
|
||||
h.Command = pluginSub(h.Bundle)(pluginEnvRefs(h.Command, h.Bundle))
|
||||
}
|
||||
}
|
||||
for _, s := range l.MCP {
|
||||
if s == nil || !ours(s.Bundle) {
|
||||
continue
|
||||
}
|
||||
reads := strings.Contains(s.Command, "CLAUDE_PLUGIN_")
|
||||
for _, a := range s.Args {
|
||||
reads = reads || strings.Contains(a, "CLAUDE_PLUGIN_")
|
||||
}
|
||||
for _, v := range s.Env {
|
||||
reads = reads || strings.Contains(v, "CLAUDE_PLUGIN_")
|
||||
}
|
||||
if reads {
|
||||
pluginServerEnv(s, s.Bundle)
|
||||
}
|
||||
}
|
||||
for _, s := range l.Subagents {
|
||||
if s != nil && ours(s.Bundle) && strings.Contains(s.Prompt, "CLAUDE_PLUGIN_") {
|
||||
s.Prompt = pluginSub(s.Bundle)(s.Prompt)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// copyTree copies testdata's plugin into a folder of the test's own.
|
||||
func copyTree(t *testing.T, from string) string {
|
||||
t.Helper()
|
||||
to := filepath.Join(t.TempDir(), filepath.Base(from))
|
||||
err := filepath.WalkDir(from, func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, _ := filepath.Rel(from, p)
|
||||
if d.IsDir() {
|
||||
return os.MkdirAll(filepath.Join(to, r), 0o755)
|
||||
}
|
||||
b, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(filepath.Join(to, r), b, 0o644)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return to
|
||||
}
|
||||
|
||||
// ponytail's hooks read CLAUDE_PLUGIN_ROOT from Node's process.env, which
|
||||
// only Claude Code's plugin runtime sets: given as written, each start of
|
||||
// the agent printed Node's TypeError (@AXmake110 on X). Its hooks.json is
|
||||
// the published file's bytes.
|
||||
func TestPluginHookReadsRootFromItsProgram(t *testing.T) {
|
||||
node, _ := exec.LookPath("node")
|
||||
sh, _ := exec.LookPath("sh")
|
||||
h := sandbox(t)
|
||||
pluginAgents(t, h)
|
||||
src := copyTree(t, filepath.Join("testdata", "ponytail"))
|
||||
|
||||
res := ok(t)(InstallPlugins(src, nil, []string{"claude", "codex"}))
|
||||
if len(res.Installed) != 1 || res.Installed[0] != "ponytail" {
|
||||
t.Fatalf("installed: %+v", res)
|
||||
}
|
||||
root := filepath.Join(Dir(), "plugins", "ponytail")
|
||||
lit := "'" + filepath.ToSlash(root) + "'"
|
||||
|
||||
var settings struct {
|
||||
Hooks map[string][]struct {
|
||||
Matcher string `json:"matcher"`
|
||||
Hooks []struct {
|
||||
Command string `json:"command"`
|
||||
} `json:"hooks"`
|
||||
} `json:"hooks"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(read(t, filepath.Join(h, ".claude/settings.json"))), &settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var start string
|
||||
for _, ev := range []string{"SessionStart", "SubagentStart", "UserPromptSubmit"} {
|
||||
gs := settings.Hooks[ev]
|
||||
if len(gs) != 1 || len(gs[0].Hooks) != 1 {
|
||||
t.Fatalf("claude %s: %+v", ev, gs)
|
||||
}
|
||||
c := gs[0].Hooks[0].Command
|
||||
if strings.Contains(c, "CLAUDE_PLUGIN_ROOT") || !strings.Contains(c, "require('path').join("+lit+".split(") {
|
||||
t.Errorf("claude %s still reads the variable: %s", ev, c)
|
||||
}
|
||||
if ev == "SessionStart" {
|
||||
start = c
|
||||
if gs[0].Matcher != "startup|resume|clear|compact" {
|
||||
t.Errorf("matcher: %q", gs[0].Matcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
// the prompt hook is portable: Codex runs the same command
|
||||
if c := read(t, filepath.Join(h, ".codex/hooks.json")); strings.Contains(c, "CLAUDE_PLUGIN_ROOT") || !strings.Contains(c, "ponytail-mode-tracker.js") {
|
||||
t.Errorf("codex hooks:\n%s", c)
|
||||
}
|
||||
|
||||
// and it runs, with no CLAUDE_PLUGIN_ROOT in its environment
|
||||
if node == "" || sh == "" || runtime.GOOS == "windows" {
|
||||
t.Log("no node or sh here: the command isn't run")
|
||||
return
|
||||
}
|
||||
write(t, filepath.Join(root, "hooks", "ponytail-activate.js"), "console.log('ponytail on')\n")
|
||||
cmd := exec.Command(sh, "-c", start)
|
||||
cmd.Env = []string{"PATH=" + filepath.Dir(node), "HOME=" + h}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil || strings.TrimSpace(string(out)) != "ponytail on" {
|
||||
t.Fatalf("the hook as written: %v\n%s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
// What a magpie before this wrote, process.env.CLAUDE_PLUGIN_ROOT as it was,
|
||||
// is resolved at the next sync, with nothing installed again.
|
||||
func TestPluginHookWrittenBeforeIsResolved(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
pluginAgents(t, h)
|
||||
src := copyTree(t, filepath.Join("testdata", "ponytail"))
|
||||
ok(t)(InstallPlugins(src, nil, []string{"claude"}))
|
||||
root := filepath.Join(Dir(), "plugins", "ponytail")
|
||||
lit := "'" + filepath.ToSlash(root) + "'"
|
||||
|
||||
// as the old magpie left library.json and Claude Code's settings
|
||||
for _, f := range []string{path(), filepath.Join(h, ".claude/settings.json")} {
|
||||
s := read(t, f)
|
||||
if !strings.Contains(s, lit) {
|
||||
t.Fatalf("%s lacks %s:\n%s", f, lit, s)
|
||||
}
|
||||
write(t, f, strings.ReplaceAll(s, lit, "process.env.CLAUDE_PLUGIN_ROOT"))
|
||||
}
|
||||
ok(t)(Sync())
|
||||
s := read(t, filepath.Join(h, ".claude/settings.json"))
|
||||
if strings.Contains(s, "CLAUDE_PLUGIN_ROOT") || strings.Count(s, "ponytail-activate.js") != 1 || !strings.Contains(s, lit) {
|
||||
t.Errorf("settings after the sync:\n%s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginEnvRefsEachSpelling(t *testing.T) {
|
||||
sandbox(t)
|
||||
root, data := filepath.ToSlash(pluginDir("p")), filepath.ToSlash(pluginData("p"))
|
||||
nr, nd := pluginDir("p"), pluginData("p")
|
||||
for _, c := range []struct{ in, want string }{
|
||||
{`node -e "require(process.env.CLAUDE_PLUGIN_ROOT + '/a.js')"`, `node -e "require('` + root + `' + '/a.js')"`},
|
||||
{`node -e 'require(process.env.CLAUDE_PLUGIN_ROOT + "/a.js")'`, `node -e 'require("` + root + `" + "/a.js")'`},
|
||||
{`node -e "x(process.env['CLAUDE_PLUGIN_DATA'])"`, `node -e "x('` + data + `')"`},
|
||||
{`bun -e "x(Bun.env.CLAUDE_PLUGIN_ROOT)"`, `bun -e "x('` + root + `')"`},
|
||||
{`deno eval "x(Deno.env.get('CLAUDE_PLUGIN_ROOT'))"`, `deno eval "x('` + root + `')"`},
|
||||
{`python3 -c "import os; x(os.environ['CLAUDE_PLUGIN_ROOT'])"`, `python3 -c "import os; x('` + root + `')"`},
|
||||
{`python3 -c "import os; x(os.environ.get('CLAUDE_PLUGIN_DATA', '/tmp'))"`, `python3 -c "import os; x('` + data + `')"`},
|
||||
{`python3 -c 'import os; x(os.getenv("CLAUDE_PLUGIN_ROOT"))'`, `python3 -c 'import os; x("` + root + `")'`},
|
||||
{`ruby -e "x(ENV['CLAUDE_PLUGIN_ROOT'])"`, `ruby -e "x('` + root + `')"`},
|
||||
{`& "$env:CLAUDE_PLUGIN_ROOT\a.ps1"`, `& "` + nr + `\a.ps1"`},
|
||||
{`& "${env:CLAUDE_PLUGIN_DATA}\a.ps1"`, `& "` + nd + `\a.ps1"`},
|
||||
{`"%CLAUDE_PLUGIN_ROOT%\a.cmd"`, `"` + nr + `\a.cmd"`},
|
||||
// sh's own spellings are pluginSub's, and a longer name isn't one
|
||||
{`"${CLAUDE_PLUGIN_ROOT}"/a.sh $CLAUDE_PLUGIN_DATA`, `"${CLAUDE_PLUGIN_ROOT}"/a.sh $CLAUDE_PLUGIN_DATA`},
|
||||
{`node -e "x(process.env.CLAUDE_PLUGIN_ROOTS)"`, `node -e "x(process.env.CLAUDE_PLUGIN_ROOTS)"`},
|
||||
} {
|
||||
if got := pluginEnvRefs(c.in, "p"); got != c.want {
|
||||
t.Errorf("%s\n got %s\nwant %s", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A command server is given both variables, as Claude Code gives them; a
|
||||
// subagent's prompt and a skill's SKILL.md have ${CLAUDE_PLUGIN_ROOT}
|
||||
// resolved, as Claude Code resolves it in their Markdown.
|
||||
func TestPluginPartsGetItsFolders(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
pluginAgents(t, h)
|
||||
src := filepath.Join(t.TempDir(), "kit")
|
||||
write(t, filepath.Join(src, ".claude-plugin/plugin.json"), `{"name":"kit"}`)
|
||||
write(t, filepath.Join(src, ".mcp.json"), `{"mcpServers":{"kit-db":{"command":"node","args":["-e","require(process.env.CLAUDE_PLUGIN_ROOT+'/db.js')"]},"kit-web":{"url":"https://example.com/mcp"}}}`)
|
||||
write(t, filepath.Join(src, "agents/helper.md"), "---\nname: helper\ndescription: Helps\n---\nRun ${CLAUDE_PLUGIN_ROOT}/bin/help.\n")
|
||||
write(t, filepath.Join(src, "skills/use/SKILL.md"), "---\nname: use\ndescription: Use it\n---\nRun `${CLAUDE_PLUGIN_ROOT}/bin/use`.\n")
|
||||
ok(t)(InstallPlugins(src, nil, []string{"claude"}))
|
||||
root, data := pluginDir("kit"), pluginData("kit")
|
||||
|
||||
l, err := load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db, web := l.server("kit-db"), l.server("kit-web")
|
||||
if db == nil || db.Env["CLAUDE_PLUGIN_ROOT"] != root || db.Env["CLAUDE_PLUGIN_DATA"] != data {
|
||||
t.Errorf("command server: %+v", db)
|
||||
}
|
||||
if web == nil || len(web.Env) != 0 {
|
||||
t.Errorf("a URL server has no process: %+v", web)
|
||||
}
|
||||
if s := l.subagent("helper"); s == nil || s.Prompt != "Run "+root+"/bin/help." {
|
||||
t.Errorf("subagent: %+v", s)
|
||||
}
|
||||
if s := read(t, filepath.Join(h, ".claude/agents/helper.md")); !strings.Contains(s, "Run "+root+"/bin/help.") {
|
||||
t.Errorf("claude's subagent:\n%s", s)
|
||||
}
|
||||
if s := read(t, filepath.Join(skillDir("use"), "SKILL.md")); !strings.Contains(s, "Run `"+root+"/bin/use`.") {
|
||||
t.Errorf("skill:\n%s", s)
|
||||
}
|
||||
inJSON := func(s string) string { b, _ := json.Marshal(s); return string(b[1 : len(b)-1]) }
|
||||
if cj := read(t, filepath.Join(h, ".claude.json")); !strings.Contains(cj, `"CLAUDE_PLUGIN_ROOT": "`+inJSON(root)+`"`) && !strings.Contains(cj, `"CLAUDE_PLUGIN_ROOT":"`+inJSON(root)+`"`) {
|
||||
t.Errorf("claude's server env:\n%s", cj)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "ponytail",
|
||||
"version": "5.3.3",
|
||||
"description": "Lazy senior dev mode. Forces the simplest, shortest solution that actually works: YAGNI, stdlib first, no unrequested abstractions.",
|
||||
"author": {
|
||||
"name": "Dietrich Gebert",
|
||||
"url": "https://github.com/DietrichGebert"
|
||||
},
|
||||
"hooks": [
|
||||
"./hooks/claude-codex-hooks.json",
|
||||
"./hooks/claude-band.json"
|
||||
],
|
||||
"types": "./hooks/band/types.d.ts",
|
||||
"userConfig": {
|
||||
"ledger": {
|
||||
"type": "boolean",
|
||||
"title": "Task board",
|
||||
"description": "After every turn, write this task's row (cost, turns, agent time, tokens, reuse, tests) to ~/.config/ponytail/band/<project>.csv for the board.",
|
||||
"default": true
|
||||
},
|
||||
"webhookUrl": {
|
||||
"type": "string",
|
||||
"title": "Webhook URL",
|
||||
"description": "Optional: an https address that gets this task's row as JSON after every turn (a team board, n8n, a sheet script). Empty: nothing leaves this machine.",
|
||||
"default": ""
|
||||
},
|
||||
"webhookToken": {
|
||||
"type": "string",
|
||||
"title": "Webhook token",
|
||||
"sensitive": true,
|
||||
"description": "Optional: sent to the webhook as a Bearer token. Kept in the system keychain, never in a settings file or a repo."
|
||||
},
|
||||
"sendNames": {
|
||||
"type": "boolean",
|
||||
"title": "Send task names",
|
||||
"default": true,
|
||||
"description": "Send each task's name (its name in the Claude Code sidebar, or its first prompt) to the webhook. Off: the board shows the task without a name."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
The hook files of DietrichGebert/ponytail 5.3.3 as published, byte for
|
||||
byte, at commit 96608e078b2d5ea607c5c3b8b5a54d1c1fba6846:
|
||||
.claude-plugin/plugin.json, hooks/claude-codex-hooks.json and
|
||||
hooks/claude-band.json. Its scripts are left out; the test writes a stand-in
|
||||
hooks/ponytail-activate.js into the installed copy.
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"hooks": {},
|
||||
"modules": [
|
||||
"./band/register.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"matcher": "startup|resume|clear|compact",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "node -e \"require(require('path').join(process.env.CLAUDE_PLUGIN_ROOT.split(String.fromCharCode(92)).join('/'), 'hooks/ponytail-activate.js'))\"",
|
||||
"timeout": 15,
|
||||
"statusMessage": "Loading ponytail mode..."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"SubagentStart": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "node -e \"require(require('path').join(process.env.CLAUDE_PLUGIN_ROOT.split(String.fromCharCode(92)).join('/'), 'hooks/ponytail-subagent.js'))\"",
|
||||
"timeout": 15,
|
||||
"statusMessage": "Loading ponytail mode..."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"UserPromptSubmit": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "node -e \"require(require('path').join(process.env.CLAUDE_PLUGIN_ROOT.split(String.fromCharCode(92)).join('/'), 'hooks/ponytail-mode-tracker.js'))\"",
|
||||
"timeout": 15,
|
||||
"statusMessage": "Tracking ponytail mode..."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user