Problem
Global DAG prompt lookup hardcodes ~/.config/opencode/dag-prompts, ignoring both OPENCODE_CONFIG_DIR and XDG_CONFIG_HOME. Other global DAG and memory assets consistently resolve through Flag.OPENCODE_CONFIG_DIR ?? Global.Path.config.
User Impact
Users with redirected config directories can successfully install/sync global prompt assets into the configured opencode directory, but prompt_template: { id } cannot resolve them and reports the misleading validation error prompt id ... does not resolve. This breaks every non-default XDG/config-dir setup.
Evidence
packages/opencode/src/dag/templates/resolve.ts:95: hardcoded path.join(os.homedir(), ".config", "opencode", "dag-prompts", ...).
packages/opencode/src/dag/workflows.ts:152, packages/opencode/src/dag/config.ts:116, and packages/opencode/src/memory/config.ts:167: sibling global assets use Flag.OPENCODE_CONFIG_DIR ?? Global.Path.config.
packages/core/src/plugin/command/dag-template-update.txt:16-24: the command contract explicitly requires OPENCODE_CONFIG_DIR and XDG support.
packages/opencode/src/dag/validation.ts:999-1000: unresolved prompt diagnostic.
packages/opencode/src/dag/templates/resolve.ts:42-44,97-102: safe-ID validation and project-first precedence that must remain unchanged.
Fix Requirements
- Resolve the global path with
path.join(Flag.OPENCODE_CONFIG_DIR ?? Global.Path.config, "dag-prompts", ${id}.md).
- Preserve
isSafeTemplateId, project-scoped precedence, interpolation, and diagnostics.
- Update the nearby comment describing the global directory.
- Add a focused
OPENCODE_CONFIG_DIR redirection test in packages/opencode/test/dag/dag-templates.test.ts.
Non-goals
- Do not add migration or symlink behavior.
- Do not change project-scoped lookup, sanitization, interpolation, or diagnostic wording.
Acceptance Criteria
- With
OPENCODE_CONFIG_DIR=/tmp/x and /tmp/x/dag-prompts/foo.md present, prompt id foo resolves that file.
- Default behavior remains unchanged when no override is set, including XDG resolution through
Global.Path.config.
os.homedir is no longer used by dag/templates/resolve.ts.
Likely Code Locations
packages/opencode/src/dag/templates/resolve.ts
packages/opencode/test/dag/dag-templates.test.ts
Verification
cd packages/opencode && bun test test/dag/dag-templates.test.ts && bun typecheck
git grep -n "os.homedir" -- packages/opencode/src/dag/templates/resolve.ts
Problem
Global DAG prompt lookup hardcodes
~/.config/opencode/dag-prompts, ignoring bothOPENCODE_CONFIG_DIRandXDG_CONFIG_HOME. Other global DAG and memory assets consistently resolve throughFlag.OPENCODE_CONFIG_DIR ?? Global.Path.config.User Impact
Users with redirected config directories can successfully install/sync global prompt assets into the configured opencode directory, but
prompt_template: { id }cannot resolve them and reports the misleading validation errorprompt id ... does not resolve. This breaks every non-default XDG/config-dir setup.Evidence
packages/opencode/src/dag/templates/resolve.ts:95: hardcodedpath.join(os.homedir(), ".config", "opencode", "dag-prompts", ...).packages/opencode/src/dag/workflows.ts:152,packages/opencode/src/dag/config.ts:116, andpackages/opencode/src/memory/config.ts:167: sibling global assets useFlag.OPENCODE_CONFIG_DIR ?? Global.Path.config.packages/core/src/plugin/command/dag-template-update.txt:16-24: the command contract explicitly requiresOPENCODE_CONFIG_DIRand XDG support.packages/opencode/src/dag/validation.ts:999-1000: unresolved prompt diagnostic.packages/opencode/src/dag/templates/resolve.ts:42-44,97-102: safe-ID validation and project-first precedence that must remain unchanged.Fix Requirements
path.join(Flag.OPENCODE_CONFIG_DIR ?? Global.Path.config, "dag-prompts",${id}.md).isSafeTemplateId, project-scoped precedence, interpolation, and diagnostics.OPENCODE_CONFIG_DIRredirection test inpackages/opencode/test/dag/dag-templates.test.ts.Non-goals
Acceptance Criteria
OPENCODE_CONFIG_DIR=/tmp/xand/tmp/x/dag-prompts/foo.mdpresent, prompt idfooresolves that file.Global.Path.config.os.homediris no longer used bydag/templates/resolve.ts.Likely Code Locations
packages/opencode/src/dag/templates/resolve.tspackages/opencode/test/dag/dag-templates.test.tsVerification