Problem
The MCP init_run tool (packages/mcp/src/tools/init-run.ts:67) hardcodes the artifact base directory as join(projectRoot, '.ai', ...), which places run artifacts at <projectDir>/.ai/ instead of the documented default ~/.ai/.
The artifact conventions (artifact-conventions.md) specify a preference cascade for resolving the base directory:
artifacts.base_dir from <projectRoot>/.agents/preferences.yaml
artifacts.base_dir from ~/.agents/preferences.yaml
- Default:
~/.ai
All non-MCP skills (save-artifact, save-plan, review-change) and the orchestrate skill's fallback path correctly follow this cascade. The MCP init_run tool is the only code path that ignores it.
Proposed solution
Implement the preference cascade directly in the MCP server so that init_run resolves the artifact base directory from preferences files automatically. Add an optional baseDir parameter as an explicit override for testing and advanced callers.
Key changes:
- Add
js-yaml dependency to the MCP package
- Create
resolve-base-dir.ts utility implementing the preference cascade
- Update
init_run to call the resolver instead of hardcoding the path
- Add
baseDir to the MCP tool schema
- Update tests, orchestrate skill docs, and artifact conventions
Acceptance criteria
Problem
The MCP
init_runtool (packages/mcp/src/tools/init-run.ts:67) hardcodes the artifact base directory asjoin(projectRoot, '.ai', ...), which places run artifacts at<projectDir>/.ai/instead of the documented default~/.ai/.The artifact conventions (
artifact-conventions.md) specify a preference cascade for resolving the base directory:artifacts.base_dirfrom<projectRoot>/.agents/preferences.yamlartifacts.base_dirfrom~/.agents/preferences.yaml~/.aiAll non-MCP skills (save-artifact, save-plan, review-change) and the orchestrate skill's fallback path correctly follow this cascade. The MCP
init_runtool is the only code path that ignores it.Proposed solution
Implement the preference cascade directly in the MCP server so that
init_runresolves the artifact base directory from preferences files automatically. Add an optionalbaseDirparameter as an explicit override for testing and advanced callers.Key changes:
js-yamldependency to the MCP packageresolve-base-dir.tsutility implementing the preference cascadeinit_runto call the resolver instead of hardcoding the pathbaseDirto the MCP tool schemaAcceptance criteria
init_rundefaults to~/.aiwhen no preferences are set and nobaseDiris passedinit_runreadsartifacts.base_dirfrom project-level.agents/preferences.yamlinit_runfalls back to global~/.agents/preferences.yamlwhen project-level is absentbase_dirvalues are resolved fromprojectRootbaseDirparameter overrides the preference cascadebaseDirfor self-containment)resolve-base-dirtests cover the full cascadepnpm run checkpasses at root