jinpwng asked to carry one project's Library choices, with what they
need, to a new path (a new checkout, another machine) from the CLI.
- `magpie library project export <dir> [file|-]` writes ExportProject's
JSON (kind magpie-project, version 1): the project's skills, servers,
subagents, hooks and plugins by agent, its Claude Code plugins, Pi
packages, servers and skills turned off, and its instructions, plus
need: each hook's and subagent's definition, each skill's and plugin's
remote source; a plugin's own hooks and subagents go by their plugin.
No ownership record (Placed, HookRecs, AgentFiles, PiRecs, ClaudeWrote,
InstrFiles), key, sign-in or other project goes in; a server goes by
name only, since its settings can hold a key. The file is 0600.
- `apply <file|-> <dir>` (also `import`) makes the folder a project,
saves a hook or subagent the library here lacks from the export (for no
agent of its own), and gives each choice through the setters the page
uses: the agents the folder has for it kept, the export's added, so a
second apply changes nothing and the folder's own entries stay. A Claude
plugin or Pi package the folder has already is left as it is;
instructions only when it has none. What this library lacks (a skill,
server or plugin) is named with its source and exits 1; nothing is
fetched.
Run (mote): go test ./internal/library -run 'TestProjectExportApply'
-count=1: ok; the full suite is in the push record.
Real CLI (built binary, two sandbox HOMEs with stub claude and pi on
PATH): in A, project add, hook bark and subagent checker for claude, Pi
npm:pi-demo, export; A deleted; in B (its own "echo mine" Stop hook in
.claude/settings.local.json) apply saved bark and checker and printed
"has what the export has", a second import printed the same and added
nothing; B's settings.local.json held SessionStart "echo bark" beside
"echo mine", .claude/agents/checker.md was written and .pi/settings.json
listed npm:pi-demo.
Broken by hand: with the hook save in ApplyProject skipped,
TestProjectExportApply is red.
Not tried: the reporter's own projects; a Windows path in an export.