跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    shihyuho

    Command Inject

    v1.3.1工具与命令
    opencode-command-inject

    Auto-inject project commands into OpenCode. Finds Makefile targets, package.json scripts, and discovered local skills at startup.

    GitHub 星标

    4

    近 30 天 +1

    月装机量

    644

    近 7 天 91

    综合评分SCORE

    45.0

    生态多维模型

    最近提交

    1 天前

    2026-08-19

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-command-inject@1.3.1"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    Version

    Auto-inject project commands into OpenCode. Finds Makefile targets, package.json scripts, and local skills at startup.

    Prerequisites

    • OpenCode CLI installed
    • A project with Makefile, package.json, or local skills

    Installation

    Add the plugin to your OpenCode config (~/.config/opencode/opencode.json):

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-command-inject@latest"]
    }
    

    Usage

    The plugin scans your project at startup and injects commands from multiple sources. Type / in OpenCode to see and run them.

    Commands are loaded from pluggable sources (command-sources). Each source reads a specific file format and transforms it into OpenCode commands with consistent naming and templates.

    By default, generated names stay the same. You only change naming when you add command_name_prefix config.

    Makefile

    Reads Makefile targets and exposes them as make:<target> commands.

    Supports target: ## description syntax for descriptions. Without description, uses the target name.

    Example:

    build: ## Build the project
    	bun run build
    

    → command: /make:build with description "Build the project"

    NPM Scripts

    Reads scripts from package.json and exposes them as <runner>:<script> commands.

    Runner is auto-detected: checks packageManager field first, then lockfiles (pnpm-lock.yaml, yarn.lock, bun.lockb, bun.lock, package-lock.json), falls back to npm.

    Example: in a pnpm project:

    {
      "scripts": {
        "dev": "vite"
      }
    }
    

    → command: /pnpm:dev

    Skills

    Discovers local skills from these directories (first match wins):

    1. .opencode/skills
    2. ~/.config/opencode/skills
    3. .claude/skills
    4. .agents/skills
    5. ~/.claude/skills
    6. ~/.agents/skills

    Skills are exposed as skill:<name> commands. Each skill expects SKILL.md in <skill-dir>/<skill-name>/.

    Example: .agents/skills/review/SKILL.md → command: /skill:review

    Configuration

    You can customize each source via configuration file. See docs/configuration.md for detailed documentation.

    Quick examples:

    {
      "$schema": "https://unpkg.com/opencode-command-inject/opencode-command-inject.schema.json",
      "command_name_prefix": {
        "disable": true
      },
      "sources": {
        "skill": {
          "command_name_prefix": {
            "disable": false,
            "value": "coach"
          }
        },
        "makefile": {
          "command_name_prefix": {
            "disable": false,
            "value": "maker"
          }
        }
      }
    }
    

    Top-level command_name_prefix.disable: true turns off generated prefixes globally. A source can force prefixes back on and optionally rename them with sources.<source>.command_name_prefix.value.

    If a custom prefix creates a collision, the plugin falls back to the canonical source-prefixed name and logs a warning.

    Development

    git clone https://github.com/shihyuho/opencode-command-inject.git
    cd opencode-command-inject
    bun install
    

    Link locally in your OpenCode config:

    {
      "plugin": ["file:///path/to/opencode-command-inject"]
    }
    

    License

    MIT