2.home-manager/tests/modules/programs/opencode/mixed-content.nix
Bob van der Linden 9bc3ca1230 opencode: skill -> skills
The skills option was creating files under ~/.config/opencode/skill/
(singular) but OpenCode documentation only mentions
~/.config/opencode/skills/ (plural). Both work, but using an
undocumented directory can be confusing.

Fixes: https://github.com/nix-community/home-manager/issues/8907
2026-03-19 21:32:45 +01:00

102 lines
3 KiB
Nix

{
programs.opencode = {
enable = true;
commands = {
inline-command = ''
# Inline Command
This command is defined inline.
'';
path-command = ./test-command.md;
};
agents = {
inline-agent = ''
# Inline Agent
This agent is defined inline.
'';
path-agent = ./test-agent.md;
};
tools = {
inline-tool = ''
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "Inline tool definition",
args: {
input: tool.schema.string().describe("Test input"),
},
async execute(args) {
return `Processed: ''${args.input}`
},
})
'';
path-tool = ./test-tool.ts;
};
skills = {
inline-skill = ''
---
name: inline-skill
description: An inline skill definition
---
## What I do
This skill is defined inline.
'';
path-skill = ./git-release-SKILL.md;
dir-skill = ./skill-dir/data-analysis;
};
themes = {
inline-theme = {
name = "inline-theme";
colors = {
primary = "#000000";
secondary = "#ffffff";
};
};
path-theme = ./my-theme.json;
};
};
nmt.script = ''
# Commands
assertFileExists home-files/.config/opencode/command/inline-command.md
assertFileExists home-files/.config/opencode/command/path-command.md
assertFileContent home-files/.config/opencode/command/path-command.md \
${./test-command.md}
# Agents
assertFileExists home-files/.config/opencode/agent/inline-agent.md
assertFileExists home-files/.config/opencode/agent/path-agent.md
assertFileContent home-files/.config/opencode/agent/path-agent.md \
${./test-agent.md}
# Tools
assertFileExists home-files/.config/opencode/tool/inline-tool.ts
assertFileExists home-files/.config/opencode/tool/path-tool.ts
assertFileContent home-files/.config/opencode/tool/path-tool.ts \
${./test-tool.ts}
# Skills
assertFileExists home-files/.config/opencode/skills/inline-skill/SKILL.md
assertFileExists home-files/.config/opencode/skills/path-skill/SKILL.md
assertFileExists home-files/.config/opencode/skills/dir-skill/SKILL.md
assertFileExists home-files/.config/opencode/skills/dir-skill/notes.txt
assertFileContent home-files/.config/opencode/skills/path-skill/SKILL.md \
${./git-release-SKILL.md}
assertFileContent home-files/.config/opencode/skills/dir-skill/SKILL.md \
${./skill-dir/data-analysis/SKILL.md}
# Themes
assertFileExists home-files/.config/opencode/themes/inline-theme.json
assertFileExists home-files/.config/opencode/themes/path-theme.json
assertFileContent home-files/.config/opencode/themes/path-theme.json \
${./my-theme.json}
# Verify inline-theme has the schema
assertFileContains home-files/.config/opencode/themes/inline-theme.json \
'"$schema": "https://opencode.ai/theme.json"'
'';
}