Files
magpie/docs
yetone 57c90f9f27 library: a project's claudePlugins and pi read in another build's shapes (#7282)
A library.json whose project had "pi": {"npm:example": ["pi"]} or
"claudePlugins": {"demo@local": true}, as another build of magpie wrote
them, failed the whole library's read ("cannot unmarshal array … pi …
type string"): `magpie library project --json` exited 1, /api/library
answered 400, and no change could be made (jinpwng, v0.1.4573).

- Project.UnmarshalJSON reads claudePlugins as a list or as a map of id
  to on: true is in the list, false is left out, since magpie only turns
  a plugin on and writes nothing for one off. pi is read as source to
  "on"/"off", or to the agents it is for (some: on, none: off), or to a
  boolean.
- A read changes nothing. The first write after such a read keeps the
  file's bytes as library.json.before-reshape (reshapedCopy, never over
  an existing copy; one that can't be made stops the write), then writes
  magpie's shape.
- Any other shape still fails the read, and nothing is written over it.

Run (mote): go test ./internal/library -run
'TestProjectReadsOtherShapes|TestProjectExportApply|TestProjectPi|TestProjectClaudePlugin'
-count=1: ok; the full suite is in the push record.
Broken by hand (mica): with UnmarshalJSON renamed away,
TestProjectReadsOtherShapes is red with the reporter's own error, "json:
cannot unmarshal array into Go struct field Project.projects.pi of type
string".
Not tried: the reporter's own r11 file; a preview of the conversion
before it is written (the kept copy is the way back).
2026-11-20 12:06:44 +08:00
..