Repository navigation
Description
Problem
engine/ ships the ports for named agent definitions and progressive-disclosure skills — tool.AgentSource (engine/tool/agentsource.go), tool.SkillSource (engine/tool/skillsource.go), and the sourceconformance suite that proves an implementation correct — but no implementation of either. Every filesystem-backed discovery adapter lives in the root module:
internal/adapter/agents(~2,060 LoC) —ProjectDirClaude = ".claude/agents"(resolve.go:16), the frontmatter def parser, theFSSource, the precedence-orderedMultiSource, the registry.internal/adapter/skills(~4,340 LoC total; ~1,180 in the read-only core) —ProjectDirClaude = ".claude/skills"(resolve.go:16), theSKILL.mddiscovery/parse, theFSSource, theSkilltool body itself (tool.go:15,ToolName = "Skill"), the activator.
Neither is importable. github.com/stacklok/mecatl root is explicitly outside the compatibility boundary (engine/COMPATIBILITY.md: "The entire root module — internal/, cmd/, contracts/, perf/ … carry no external compatibility promise"), and MVS-wise importing it reintroduces exactly the adapter dep-cone #113 removed.
Net effect for an engine importer: an embedded loop has no Skill tool at all, and its Subagent(agent=…) parameter is permanently inert — the model sees an affordance the harness cannot satisfy. The consumer's only options are to reimplement ~3,000 LoC of discovery + frontmatter parsing + trust tiering, or to depend on the root module. This is the same shape as #269 (FS tool bodies): the correctness-heavy code exists, tested, and is walled off from the people who need it.
Concrete consumer
jerm-dro/fogburn embeds engine/agent and vendors only github.com/stacklok/mecatl/engine. Its .claude/skills/{migration-audit,pr-test-audit}/SKILL.md and any .claude/agents/*.md are unreachable from a fogburn-driven session; the repo's Subagent tool advertises an agent argument that can never resolve. Same gap Atrium hits from the other direction.
Scope: the two discovery adapters + the Skill tool body
Follow the #269 pattern exactly — move the engine-clean code, carry only the helpers it needs, leave the OS-coupled parts to the consumer.
In scope
engine/adapter/agentfs— the whole ofinternal/adapter/agents. Its entire non-stdlib import set today isengine/tool+ two helper packages (toolkit.SplitFrontmatter,xdgconfig.{OSEnv,ResolveEnv,UserConfigDir}). It reads the filesystem with plainos.ReadDir/os.ReadFile(discover.go:277-297) — noosfs, nogitenv, no secret-scrub cone. This is the cheaper half; do it first.engine/adapter/skillfs— the READ-ONLY skills core:resolve.go,source.go,fssource.go,skill.go,tool.go,activator.go,discover.go,sanitize.go(~1,180 LoC). Non-stdlib closure isengine/{session,tool}+toolkit.{SplitFrontmatter,MaxOutputBytes,ParseArgs,Schema,Truncate,TruncateRunes}+xdgconfig+ one call toosfs.ResolveRoot(fssource.go:268, for read-root canonicalisation).- Carry the helpers, don't move them. Inline the six
toolkitfunctions and the threexdgconfigfunctions, as Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 did forfstools(engine/adapter/fstools/fstools.go:82re-declaresMaxOutputByteswith a comment pinning it to thetoolkitoriginal).toolkitis a grab-bag used acrossmcp/memory/skills/agents; moving it wholesale ripples for no benefit here. - Break the one
osfsedge.fssource.go:268callsosfs.ResolveRoot(abs +EvalSymlinks) to canonicalise skill read-roots to match theosfsenforcement layer. That is ~2 lines of stdlib; inline it, or take an injected canonicaliser func. Do NOT dragosfsin — it is the ~900-line hardened Workspace Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 deliberately left out. .golangci.yml+engine/arch/layering_test.goentries. Copy an existing block. Note these two needosallowed (unlike every currentengine/adapter/*block, which denies it) — discovery is inherently filesystem-walking. Say so in the block'sdesc, and consider a narrower deny (os/exec, network) instead.- Root-module aliases. Add
internal/adapter/{agents,skills}/alias.gore-exporting the graduated types, exactly asinternal/adapter/tools/alias.godoes forfstoolsafter Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 — sointernal/app,cmd/mecated,cmd/mecatuikeep compiling untouched and there is no second copy to drift. engine/COMPATIBILITY.md— list both under the existingengine/adapter/*"excluded, may change without notice" clause.
Out of scope (deliberately)
- The writable
SkillDrafthalf —drafter.go,drafttool.go,novelty.go,promote.go,assetcache.go(~830 LoC). The quarantine directory, similarity threshold, and promote CLI are an operator workflow, not a discovery primitive;assetcache.goexists to serve the remote gRPC driver branch. A consumer wanting model-authored skills is a separate issue. osfsitself, and theWithReadRootscarve-out plumbing. The graduatedFSSourceshould return the read-roots it needs (it already does —fssource.go:236-268); wiring them into a concrete Workspace stays the consumer's job. (fogburn's Workspace explicitly drops this carve-out today,cli/internal/tools/workspace.go:35.)- The
grpcdriverremote sources — heavy contracts/grpc closure,internal/by right. - The trust-gate policy decision. Graduate the mechanism (
ResolveOptions.IncludeProjectTieris already a plain bool the caller sets); the default stays the composition root's call. Note for the PR: today both binaries defaultTrustProject=false(cmd/mecatui/config_test.go:41-42), so project-tier defs/skills are withheld on an untrusted checkout — the graduated package must keep that gate a caller input, never a hardcoded default.
What a consumer still owns
- a
tool.Workspace(and, if it wants activated-skill file reads, the read-root carve-out), - the trust decision feeding
IncludeProjectTier, - registering the
Skilltool and wiringAgentSourceinto itsSubagentconstruction.
Acceptance
- A fresh module importing
engine/adapter/{agentfs,skillfs}resolves.claude/agents/*.mdand.claude/skills/*/SKILL.mdfrom a workspace root, withengine/adapter/sourceconformancepassing against both. - No new non-stdlib module in
engine/go.mod. - Root module builds unchanged via aliases;
internal/adapter/{agents,skills}contain no second copy of the moved bodies. task api:check/ CHANGELOG per COMPATIBILITY.md.
Payoff
An engine importer gets working named specialists and skills — the two "what should the agent know here" primitives — by importing them. Without this, Subagent(agent=…) is a documented affordance that no external consumer can honour.
Sibling of #269 (same graduation pattern, same rationale). Related: #194 (the toolkit-consumer guide would document these).
Activity
test(e2e): live coverage for Subagent(agent=…) via a workspace agent …
refactor(discovery): graduate agent-def + skills discovery into engin…