Repository navigation
S19: agentDir ⇄ spec v2 round trip - #861
Merged
Merged
Conversation
specToAgentDir(spec) renders a v2 spec as agent-directory files (agent.yaml, instructions.md, instructions/<family>.md, skills/<name>/SKILL.md, subagents/<name>/) plus a dropped list of every field a directory cannot hold; agentDirToSpec(dir) reads a data-config directory back into a validated v2 spec without importing any of its code, reporting directory content a spec cannot hold (memory/*, schedules/*, channels/*, auth/approve files and the approve, store, toolConcurrency, projectInstructions, provider, engine, output config keys). Code configs throw LOUSHO_SPEC_UNSUPPORTED; a config with no model throws LOUSHO_SPEC_INVALID. The yaml-inline fixture gains a 'model' line so it can be read as a spec. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
src/agentDir/spec.ts— two new exports:specToAgentDir(spec): { files, dropped }renders a validated AgentSpec v2 as agent-directory files (paths relative,/separators):agent.yamlwith keys in a fixed order,instructions.md,instructions/<family>.md,skills/<name>/SKILL.md(inline skills only) and recursivesubagents/<name>/. Every spec field a directory cannot hold is reported indropped({ field, reason }) — mcpServers, guardrails, handoffs, memory, triggers, output, reasoning, fallbackModels, rateLimit, promptCaching, toolSearch, codeMode, askQuestion, subagentOptions, maxSubagentDepth, maxHandoffs, abortListeners, flow, evals, promptRef, instructions file refs, non-file tools, extra/inline hooks, non-inline sub-agents, skill dir/registry refs and tool-file paths outsidetools/.agentDirToSpec(dir): Promise<{ spec, dropped }>reads a data-config directory (agent.json / agent.yaml / agent.yml, or none) back into a spec, validated withagentSpecV2Schema. It never imports a file: onlyfsreads,yaml,JSON.parseandloadSkills(markdown). A code config (agent.ts,agent.js, ...) throwsLOUSHO_SPEC_UNSUPPORTED; a config with nomodelthrowsLOUSHO_SPEC_INVALID. Directory content a spec cannot hold is reported asdropped:memory/*,schedules/*,channels/*, rootauth.*/approve.*files and theapprove,store,toolConcurrency,projectInstructions,provider,engine,outputconfig keys.SpecToAgentDirResult/AgentDirToSpecResultare named interfaces (the anonymous return types' members tripped the typedoc ratchet).For specs that use only directory-expressible keys the round trip is the identity (permission ids regenerate as
p1…, hooks ash1).Also:
src/agentDir/__fixtures__/yaml-inline/agent.yamlgains amodelline so the fixture can be read as a spec (v2 requires one); the only consumer (loadAgentDir.test.ts) does not assert on model and still passes.Tested
npx vitest run src/agentDir/spec.test.ts— 10 tests, all pass: minimal and rich round-trip identity, dropped lists for non-directory keys, code-config / missing-model errors, no-import spy onimportModule(0 calls),registry/inbox-triagedropped list, skill-folder-with-extras →{ dir }.npx tsc --noEmit,npm run typecheck:tests,npm run lint— clean.npm run test:coverage— 7184 passed; 11 failures in 3 files, all environmental and unrelated:packages/create-lousho/*needs the workspace's owndist/(never built here) andsrc/spec/v2/templates.test.tsfails on CRLF line endings in template READMEs from the Windows checkout.npm run fallow,npm run docs:ratchet,npm run api:check,npm run docs:llms:check,npm run size-check— all pass.Acceptance criteria
specToAgentDir(spec).fileswritten to a temp dir round-trips throughagentDirToSpecas{ spec, dropped: [] }(minimal and rich fixtures)guardrails,mcpServersand a{ builtin }tool lists exactly those three indroppedagentDirToSpec(src/agentDir/__fixtures__/yaml-inline)succeeds without importing anything (spy onimportModule, 0 calls)agent.tsthrowsLOUSHO_SPEC_UNSUPPORTEDregistry/inbox-triagereads withdroppednaming itsmemory/,schedules/,channels/files andapproveGenerated with Devin