Path Instructions
OpenCode plugin that injects path-specific *.instructions.md files from .github/instructions and .opencode/instructions
7
近 30 天 +1
26
近 7 天 1
31.1
生态多维模型
4 个月前
2026-05-25
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@klocus/opencode-path-instructions@1.2.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@klocus/opencode-path-instructions@1.2.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @klocus/opencode-path-instructionsOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Mirror of GitHub Copilot's path-specific custom instructions for OpenCode. Automatically injects coding rules into the AI's context when it reads or edits files matching configured glob patterns.
Installation
Add to your opencode.json:
{
"plugin": ["@klocus/opencode-path-instructions"]
}
Options
Pass options as a tuple to enable agent filtering or control injection triggers:
{
"plugin": [
[
"@klocus/opencode-path-instructions",
{
"agents": { "mode": "blacklist", "list": ["explore"] },
"injectOn": ["edit", "write"]
}
]
]
}
agents—modeis"blacklist"(skip listed agents) or"whitelist"(only listed agents). The main session is identified as"main".injectOn— which operations trigger injection:"read","edit","write". Defaults to all three. OpenCode patch operations are treated as"edit"for updates/moves and"write"for new files. Deleting files does not trigger injection.
As a local plugin
cp src/path-instructions.ts /your-project/.opencode/plugins/path-instructions.ts
Usage
- Create
.opencode/instructions/(or.github/instructions/) in your project root. - Add
*.instructions.mdfiles with YAML frontmatter specifying which files they apply to:
---
applyTo: "src/app/**/*.ts, src/app/**/*.html"
---
- Use OnPush change detection strategy for all new components.
- Prefer signals over observables for local state.
Instructions are injected once per session when the AI touches a matching file, then not repeated.
Releasing
A helper script is included at scripts/release.sh to bump the package version, build, push commits and tags, and optionally publish to npm.
Usage examples:
Bump patch, build, push (and trigger CI publish):
./scripts/release.shExplicit version, build skipped, dry run:
./scripts/release.sh 1.2.3 --no-build --dry-run
Notes:
- By default the CI workflow will publish packages via Trusted Publisher (OIDC) when a
v*.*.*tag is pushed. Use--publishto perform a localnpm publishfrom your machine instead. - Ensure you have permissions to publish and that your npm login is configured if using
--publish.
同类生态推荐
Copilot Usage Detector
opencode-copilot-usage-detector
OpenCode plugin that tracks GitHub Copilot token usage, learns rate limits empirically, and proactively informs the user
Copilot Statusline
opencode-copilot-statusline
OpenCode TUI plugin: display GitHub Copilot quota (premium requests, with a chat fallback for Copilot Free) in the footer statusline. V2-native, zero-config, no cookies.
Copilot Delegate
opencode-copilot-delegate
OpenCode plugin that delegates tasks to GitHub Copilot CLI as background subprocesses