[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76WWJX1FPSWYD1RB8JXNF3C":3,"skill-same:01M76WWJX1FPSWYD1RB8JXNF3C":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M76WWJX1FPSWYD1RB8JXNF3C","magus-sdk",null,"egladman\u002Fmagus","egladman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F8713153?v=4","01M75H42QB5A4X82APZF4H44GM","Eli Gladman","01M75H42R1K59Z7JWAP621J849",3,"GPL-3.0","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-sdk\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"# Consuming magus as a Go library\n\n{{if .Full}}This skill's reader has never run `magus` and does not know its subcommands. They\nfound `github.com\u002Fegladman\u002Fmagus` on pkg.go.dev or in an import line. They want to\ncall it from their own Go program. Ground every answer in the actual exported API,\nnever in what the CLI does, which this reader cannot see:{{else}}The reader has never run `magus`; they found `github.com\u002Fegladman\u002Fmagus` on\npkg.go.dev and want to call it from Go. Ground every answer in the exported API,\nnever the CLI:{{end}}\n\n- `magus.go`, `register.go`, `run.go`, `judge.go`, `knowledge.go`, `describe.go`\n- `types\u002Frepository.go`, `types\u002Fdescribe.go`\n- `project\u002Fimpact\u002Fimpact.go`\n\n## Before anything else: can they `go get` it?\n\nState what is verified, and claim no more. The root `go.mod` requires the nested\n`libs\u002Fgopherbuzz` and `libs\u002Fdiagnostics` modules at `v0.2.0`, and both tags are on\nthe origin (`git ls-remote --tags origin` lists `libs\u002Fgopherbuzz\u002Fv0.2.0` and\n`libs\u002Fdiagnostics\u002Fv0.2.0`){{if .Full}}. Its `replace` directives point at the working\ntree for in-repo builds only; a replace is never transitive, so a consumer resolves the\ntagged versions the requires name. An older root tag may still require them at `v0.0.0`\nand fail as `unknown revision libs\u002Fgopherbuzz\u002Fv0.0.0`{{end}}.\n\nSay `go get` succeeds only for a version you ran it against, and say how: a scratch\nmodule, `go get github.com\u002Fegladman\u002Fmagus@\u003Cversion>`, then `go build .\u002F...`{{if .Full}}. A worked\nexample that compiles for you inside the module but fails for them is worse than\nadmitting you did not check. `go install ...\u002Fcmd\u002Fmagus@\u003Cversion>` refuses the\nroot module at any version, since its `go.mod` carries replace directives{{end}}.\n\n## Entry points\n\n| Call | Returns | Cache | Use when |\n|---|---|---|---|\n| `magus.Open(ctx, root, opts...)` | `*magus.Magus` | builds one | the caller will `Run` targets or read cached results |\n| `magus.Inspect(ctx, root, opts...)` | `types.WorkspaceRepository` | none | pure introspection: list\u002Fdescribe\u002Fclassify, never execute |\n\n{{if .Full}}Both discover the root's projects and evaluate magusfiles the same way. `Open` calls\nthe same `load()` as `Inspect`, then also opens the on-disk cache. The only\ndifference is whether a cache is built, not what is discovered. `Inspect` returning the narrow\n`types.WorkspaceRepository` interface rather than the concrete `*Magus` is\nitself a hint: an introspection-only caller should code against the\ninterface, and a caller who later needs `Run` should switch to `Open` and get\nthe concrete type, not type-assert their way there.{{else}}A caller who later needs\n`Run` switches to `Open`, never type-asserts.{{end}}\n\nBoth require `magus.WithSpawnRule(magus.TierCeiling)` (it has no default), and\na workspace with a magusfile needs `import _ \"github.com\u002Fegladman\u002Fmagus\u002Fbuzzengine\"`.\n`magus.FindRoot(dir)` walks up from `dir` to the workspace root, the same walk the CLI\ndoes; an empty `dir` is an error, not the working directory.\n\n| Call | What it answers |\n|---|---|\n| `(*Magus).JudgeCommand(ctx, session, dir, cmd)`, `JudgeWrite(..., path)` | the guard's `types.GuardJudgment`: decision, `Rule`, `Reason`, `Next`; a deny is an answer, the error is a judgment that could not be made |\n| `(*Magus).Run(ctx, targets, magus.WithSession(id))` | judges each target first; a deny is a `*types.GuardDeniedError` and nothing runs |\n| `WithEnv`, `WithStderr`, `WithCommandLine` | the process state a workspace reads; without each it reads no environment, discards notices, records an empty command line |\n| `WithVCSDriver`, `WithCacheBackend` (Open), `WithObserver` (Run) | the three swappable parts, one option each |\n| `std.MagusPutJob`, `MagusQuery`, `MagusRefs`, `MagusTrailRead`, ... | the Buzz host modules' Go doors, with typed options (`types.JobPut`, `types.KnowledgeQueryOptions`, ...); `std` is in the Go API lock |\n\nThe lease a call acts under rides `ctx` (`types.WithJobLease`). The SDK never retries,\nre-grades or routes around a refusal.{{if .Full}} It has no agent loop: it answers what a loop asks\nand never decides what runs next.{{end}}\n\n## The interface hierarchy: depend on the narrowest role\n\n`types.WorkspaceRepository` embeds `WorkspaceReader + TargetExpander +\nAffectedComputer + Inspector`. `*Magus` (from `Open`) and the value `Inspect` returns\nboth satisfy all of it. Take the narrowest role a function uses{{if .Full}}.\n`types\u002Frepository.go` says so:\n\"Prefer the narrowest embedded role a consumer actually uses.\"{{end}}\n\n| Role | Methods | Answers |\n|---|---|---|\n| `WorkspaceReader` | `Root`, `All`, `Get`, `Graph`, `VCSOptions`, `Where` | what projects exist, and the project dependency graph |\n| `TargetExpander` | `ExpandPath`, `ExpandAffected` | which concrete `path:target` pairs a target pattern names |\n| `AffectedComputer` | `Affected`, `AffectedFromPaths` | which projects a VCS changeset touches |\n| `Inspector` | `List*`, `Evaluate*`, `ClassifyFiles`, `TargetGraph`, `Workspace` | see the axis below |\n\nA function that prints project names needs only `WorkspaceReader`{{if .Full}}. Widening its\nparameter to `WorkspaceRepository` because `Open` returns that is the over-coupling\nthis hierarchy prevents: every future caller must construct or stub the whole\nrepository for a signature that only reads `Root()` and `All()`{{else}}. Widening it to\n`WorkspaceRepository` makes every caller construct or stub the whole repository{{end}}.\n\n## The `List` \u002F `Evaluate` \u002F `Classify` axis\n\nThis is the SDK's organizing idea{{if .Full}}, stated in the `Inspector` doc comment in\n`types\u002Frepository.go`{{end}}:\n\n- `List*` enumerates a DECLARATION: cheap, no resolution.\n- `Evaluate*` RESOLVES one (spells bound, claims applied, charms patched in) and\n  costs more.\n- `ClassifyFiles` and `TargetGraph` are their own verbs; neither fits the split.\n\n| Method | Reads | Cost |\n|---|---|---|\n| `ListProjects` | declared project facts (project-relative globs) | cheap |\n| `ListTargets` | target name -> spell\u002Fproject vocabulary | cheap |\n| `ListCharms` | inverse charm index across every project | most expensive `Inspector` method (renders every charm x target x spell) |\n| `EvaluateProjects` | resolved spells, workspace-rooted globs | resolves every project |\n| `EvaluateTarget(ctx, t)` | full dispatch plan for one `path:target` | resolves one target |\n| `ClassifyFiles(ctx, paths)` | which project owns\u002Fdeclares each path | pure glob lookup, cheap even for a whole dirty tree |\n| `TargetGraph(ctx)` | the `ctx.needs` DAG, read statically from magusfile source | never executes a target body |\n\n`ProjectEntry.Sources` and `EvaluatedProject.Sources` share a FIELD NAME with\nDIFFERENT representations:\n\n- `ListProjects`: declared, project-relative globs.\n- `EvaluateProjects` (through its embedded `ProjectEntry`): resolved,\n  workspace-rooted globs, joined against the project path with magusfile globs\n  folded in.\n\n{{if .Full}}Reading one where the other was meant silently mismatches every glob it feeds. {{end}}The\nfield comment on `ProjectEntry.Sources` in `types\u002Fdescribe.go` is the one place this\nis documented. Read it before writing code that consumes both.\n\n## ctx and cancellation\n\nEvery `Inspector` method takes `ctx` first and returns `error` last, the read-only\n`List*` calls included. A cancelled walk returns an error, never a truncated slice.\n\n{{if .Full}}- `describeCancelled` in `describe.go` names the walk and how far it got\n  (`\"describe projects: cancelled after 2 of 8: context canceled\"`).\n{{end}}- The error wraps `ctx.Err()`, so `errors.Is(err, context.Canceled)` and\n  `errors.Is(err, context.DeadlineExceeded)` both hold.{{if .Full}}\n- VERIFIED: cancelling before `ListProjects` on a one-project workspace produces\n  exactly that message, and `errors.Is` returns true.{{end}}\n\nNever treat an empty or short `List*`\u002F`Evaluate*` result as \"the workspace has\nnothing\" without checking the error first.{{if .Full}} The reason is stated directly in\ndescribe.go: a partial inventory reporting `Count: 3` is indistinguishable from a\nworkspace that genuinely has three projects, so silently truncating would be a\nwrong answer wearing a right answer's shape.{{else}} A partial inventory is\nindistinguishable from a small one: a wrong answer wearing a right answer's shape.{{end}}\n\n## Two different graphs, easy to conflate\n\n- `WorkspaceReader.Graph()` returns `*types.Graph`: the PROJECT dependency graph\n  (project -> project, from `depends_on`).\n- `Inspector.TargetGraph(ctx)` returns `types.TargetGraphOutput`: the TARGET graph\n  (target -> target, from `ctx.needs`), within and across projects.{{if .Full}} It is read\n  statically from magusfile source and never runs a target body. It sees both arms\n  of a runtime branch and reports a dependency cycle if one exists.{{else}} It is read\n  statically, sees both arms of a branch, and reports cycles.{{end}}\n\nMatch the graph to the question's granularity{{if .Full}}. A caller doing scheduling or impact analysis usually holds both: `Graph()` for \"does\nproject A depend on project B\", `TargetGraph()` for \"does target `lint` in project A\ndepend on target `build` in project B\"{{end}}.\n\n## Sharp edges (verified, not folklore)\n\n**`types.Target` is dual-role.** Know which role it plays before reading any field:\n\n- As a work-unit, `Path`\u002F`Name`\u002F`Charms`\u002F`Files` identify which `path:target` to run.\n- As a policy bag (`Project.TargetPolicies` values, `EvaluatedTarget.Policy`), only\n  `SkipCache`\u002F`Slots`\u002F`Drift`\u002F`RetryOnVolatile` mean anything. Ignore the other 6 of\n  its 10 fields{{if .Full}}; they sit unset (see the type's own disclaimer at\n  `types\u002Ftarget.go:95-101`){{end}}.\n\n**The `Entry`\u002F`Output`\u002F`Report` suffix split needs the ~20-line comment at the top\nof `types\u002Fdescribe.go`.** Most of it is a naming CONVENTION, not vocabulary. Read the comment\nbefore you add a type{{if .Full}}; guess at the pattern instead and you misname it{{end}}.\n\n- `Entry` is added only when the bare name would collide with an existing type:\n  `ProjectEntry` because `types.Project` exists. `Charm` has no suffix because\n  nothing else claims that name.\n- `Output` means the `Inspector` method itself returns this shape\n  (`ProjectsOutput`, `TargetGraphOutput`).\n- `Report` means rebuilt at the render edge from a plain slice the method returned\n  (`FileReport`, `CharmReport`).\n- `ListProjects`\u002F`EvaluateProjects` are the deliberate exceptions: they return their\n  `*Output` type directly{{if .Full}}, because they carry a real `Workspace` field a\n  `{definition, count, items}` envelope cannot derive{{end}}.\n\n**Evaluating a magusfile needs the Buzz engine linked.** A program that loads\nmagusfiles blank-imports `github.com\u002Fegladman\u002Fmagus\u002Fbuzzengine`, as `cmd\u002Fmagus` does.\nWithout it, `Open` and `Inspect` fail with `*types.EngineNotLinkedError` (MGS1104) once\nany project has a magusfile, and never return a workspace missing its targets. A\nworkspace with no magusfile opens without the engine.{{if .Full}}\n\n`TargetGraph` reads magusfile source statically through the exported `libs\u002Fgopherbuzz`\nparser, with or without the engine.{{end}}\n\nThe other path builds the workspace in Go: the exported `Option`\u002F`ProjectOption`\u002F\n`BindingOption` wire API (`register.go`: `WithSpell`, `WithTarget`, `WithDependsOn`,\n...). A target named with `WithTarget` counts as declared, as an `export fun` does.\nBuilt-in spells (`go`, `ts`, `rust`, ...) are reachable this way{{if .Full}}: the\nexported `register.go` functions call `internal\u002Fspell` on the caller's behalf{{end}}.\n\n## Testing code that uses the SDK\n\nTest at the narrowest seam the code allows. Move to a real workspace only for what a\nfake cannot tell you.\n\n- Unit tests take the narrowest role (`types.WorkspaceReader` and so on). Fake it by\n  embedding the interface in a struct and overriding the one method the test calls. A\n  test that asserts on the call generates its own mock: magus's `types` mocks are internal.\n- Integration tests use `testkit.NewWorkspace(t)` (from `libs\u002Ftestkit`) with\n  `magus.Inspect`. Inspect opens no cache.\n- Call `testkit.Main(m)` from `TestMain`, or `testkit.Isolate(t)` in a serial test. The\n  `Output*` lookups and `PayloadByRef` read the session store and other checkouts on a\n  miss{{if .Full}}, so without isolation the result depends on the developer's machine{{end}}.\n- For `Run`, declare a one-method interface and fake that. `*magus.Magus` has too many\n  methods to fake whole.\n- Magusfile targets do not run outside this module, so a test that writes one and calls\n  `Run` proves nothing. Register a spell from Go with `WithSpell` instead.\n- Register a programmatic spell with `register.Spell(tb, name, opts ...spells.Option)`\n  (`libs\u002Ftestkit\u002Fregister`), passing `spells.WithTargets` and the like{{if .Full}}. The spell registry is process-global, so parallel\n  tests that register spells race{{end}}.\n\n## Audit mode\n\nAsked \"does the SDK actually give me X\", verify; never infer from naming:\n\n1. **Is the type exported?** `grep -n \"^type \u003CName>\" types\u002F*.go *.go` (or the package\n   the docs claim owns it). A type used only inside `internal\u002F` is unreachable,\n   whatever a doc comment implies.\n2. **Is the capability reachable without the CLI?** Trace the call from the exported\n   entry point (`Open`\u002F`Inspect`\u002Fa method on `*Magus`) down through its imports. The\n   capability stops where the trace crosses into an `internal\u002F` package nothing\n   exported re-wraps{{if .Full}}. `go-api-generate` fails on an exported signature that\n   names an `internal\u002F` type, so the locked packages cannot leak one{{end}}.\n3. **Is a boundary deliberate or accidental?** Read the package doc comment first\n   (`doc.go` or the top of the main file) before proposing a merge.\n   - Deliberate: `spells\u002Fdoc.go` documents that `spells` and `internal\u002Fspell` were\n     collapsed from three packages to two on purpose{{if .Full}}. `spells` is exported: the Buzz sources\n     plus `Op`\u002F`Driver`\u002F`Descriptor`; `internal\u002Fspell` is the unexported bytecode\n     decoder. It calls the\n     dependency direction load-bearing (`spells` imports nothing from `types`;\n     `types` imports `spells`) so the two cannot cycle. Merging `internal\u002Fspell`\n     into `spells` would put bytecode framing behind the public API{{end}}.\n   - Accidental: a package with no doc comment, one importer, and nothing it exports\n     that must stay exported after a merge{{if .Full}}. That shape (see the\n     {{skill \"architecture-review\"}} skill's table) is the accidental kind{{end}}.\n\nDo not paper over a genuine gap with a workaround the reader did not ask for. If a\ncapability is not reachable, say so plainly and name the exact package boundary\nthat stops it{{if .Full}}, as specific as the MGS1104 refusal above{{end}}.\n",{},"main","5f0df014d9eaf4aea1a930b0bd13c3338e2642de","internal\u002Fagent\u002Fskills\u002Fmagus-sdk",0,"https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus","http:\u002F\u002Feli.gladman.cc\u002Fmagus\u002F","https:\u002F\u002Fgithub.com\u002Fegladman","eli.gladman.cc","2026-11-14 12:23:44",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add egladman\u002Fmagus --skill magus-sdk",{"tool":37,"command":38},"bunx","bunx skills add egladman\u002Fmagus --skill magus-sdk",{"tool":40,"command":41},"pnpm","pnpm dlx skills add egladman\u002Fmagus --skill magus-sdk","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-sdk\u002FSKILL.md",true,[],[46,52,58,64,70,76],{"skillNo":47,"name":48,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M76WWZ75J70NCG0TR23XDDE6","magus-workspace-rules","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-workspace-rules\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M76WWX72SY78KG03AVYFE768","magus-vcs-hygiene","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-vcs-hygiene\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":18},"01M76WWTJYGRCKKXH948KN6RR3","magus-upstream-source","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-upstream-source\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M76WWRTBBAPNKM0PA2NG5Q3N","magus-upstream-docs","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-upstream-docs\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M76WWNTF03H9S5CN22QBX5ZK","magus-test-design","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-test-design\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M76WWGW39RTK0GRPX4QJXF9V","magus-run","https:\u002F\u002Fgithub.com\u002Fegladman\u002Fmagus\u002Fblob\u002Fmain\u002Finternal\u002Fagent\u002Fskills\u002Fmagus-run\u002FSKILL.md",[],[]]