@zenobius/opencode-skillful 1.1.0-next.3 → 1.1.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +214 -10
  2. package/dist/index.js +5317 -131
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -74,6 +74,103 @@ skill_find "testing -performance"
74
74
  - Natural query syntax with negation and quoted phrases
75
75
  - Skill ranking by relevance (name matches weighted higher)
76
76
  - Silent message insertion (noReply pattern)
77
+ - **Pluggable prompt rendering** with model-aware format selection (XML, JSON, Markdown)
78
+
79
+ ## Prompt Renderer Configuration
80
+
81
+ The plugin supports **multiple formats for prompt injection**, allowing you to optimize results for different LLM models and use cases.
82
+
83
+ > See the [Configuration](#configuration) section for complete configuration details, including bunfig setup and global/project-level overrides.
84
+
85
+ ### Supported Formats
86
+
87
+ Choose the format that works best for your LLM:
88
+
89
+ | Format | Best For | Characteristics |
90
+ | ----------------- | ---------------------- | ---------------------------------------------------------------------- |
91
+ | **XML** (default) | Claude models | Human-readable, structured, XML-optimized for Claude |
92
+ | **JSON** | GPT and strict parsers | Machine-readable, strict JSON structure, strong parsing support |
93
+ | **Markdown** | All models | Readable prose, heading-based structure, easy to read in conversations |
94
+
95
+ ### Configuration Syntax
96
+
97
+ Set your preferences in `.opencode-skillful.json`:
98
+
99
+ ```json
100
+ {
101
+ "promptRenderer": "xml",
102
+ "modelRenderers": {
103
+ "claude-3-5-sonnet": "xml",
104
+ "gpt-4": "json",
105
+ "gpt-4-turbo": "json"
106
+ }
107
+ }
108
+ ```
109
+
110
+ **How It Works:**
111
+
112
+ 1. Every tool execution checks the current active LLM model
113
+ 2. If `modelRenderers[modelID]` is configured, that format is used
114
+ 3. Otherwise, the global `promptRenderer` default is used
115
+ 4. Results are rendered in the selected format and injected into the prompt
116
+
117
+ ### Format Output Examples
118
+
119
+ #### XML Format (Claude Optimized)
120
+
121
+ ```xml
122
+ <Skill>
123
+ <name>git-commits</name>
124
+ <description>Guidelines for writing effective git commit messages</description>
125
+ <toolName>writing_git_commits</toolName>
126
+ </Skill>
127
+ ```
128
+
129
+ **Advantages:**
130
+
131
+ - Matches Claude's native instruction format
132
+ - Clear tag-based structure
133
+ - Excellent readability for complex nested data
134
+
135
+ #### JSON Format (GPT Optimized)
136
+
137
+ ```json
138
+ {
139
+ "name": "git-commits",
140
+ "description": "Guidelines for writing effective git commit messages",
141
+ "toolName": "writing_git_commits"
142
+ }
143
+ ```
144
+
145
+ **Advantages:**
146
+
147
+ - Strong parsing support across LLMs
148
+ - Strict, validated structure
149
+ - Familiar format for language models trained on JSON data
150
+
151
+ #### Markdown Format (Human Readable)
152
+
153
+ ```markdown
154
+ # Skill
155
+
156
+ ### name
157
+
158
+ - **name**: _git-commits_
159
+
160
+ ### description
161
+
162
+ - **description**: _Guidelines for writing effective git commit messages_
163
+
164
+ ### toolName
165
+
166
+ - **toolName**: _writing_git_commits_
167
+ ```
168
+
169
+ **Advantages:**
170
+
171
+ - Most readable in conversations
172
+ - Natural language-friendly
173
+ - Works well for exploratory workflows
77
174
 
78
175
  ## Skill Discovery Paths
79
176
 
@@ -354,26 +451,133 @@ Non-zero exit codes indicate script failures. Always check STDERR and the exit c
354
451
 
355
452
  ## Configuration
356
453
 
357
- The plugin reads configuration from the OpenCode config file (`~/.config/opencode/config.json`):
454
+ The plugin loads configuration from **bunfig**, supporting both project-local and global configuration files:
455
+
456
+ ### Configuration Files
457
+
458
+ Configuration is loaded in this priority order (highest priority last):
459
+
460
+ 1. **Global config** (standard platform locations):
461
+ - Linux/macOS: `~/.config/opencode-skillful/config.json`
462
+ - Windows: `%APPDATA%/opencode-skillful/config.json`
463
+
464
+ 2. **Project config** (in your project root):
465
+ - `.opencode-skillful.json`
466
+
467
+ Later configuration files override earlier ones. Use project-local `.opencode-skillful.json` to override global settings for specific projects.
468
+
469
+ ### Configuration Options
470
+
471
+ #### Plugin Installation
472
+
473
+ First, register the plugin in your OpenCode config (`~/.config/opencode/config.json`):
358
474
 
359
475
  ```json
360
476
  {
361
- "plugins": ["@zenobius/opencode-skillful"],
362
- "skillful": {
363
- "debug": false,
364
- "basePaths": ["~/.config/opencode/skills", ".opencode/skills"]
365
- }
477
+ "plugins": ["@zenobius/opencode-skillful"]
366
478
  }
367
479
  ```
368
480
 
369
- ### Configuration Options
481
+ #### Skill Discovery Configuration
482
+
483
+ Create `.opencode-skillful.json` in your project root or global config directory:
484
+
485
+ ```json
486
+ {
487
+ "debug": false,
488
+ "basePaths": ["~/.config/opencode/skills", ".opencode/skills"],
489
+ "promptRenderer": "xml",
490
+ "modelRenderers": {}
491
+ }
492
+ ```
493
+
494
+ **Configuration Fields:**
370
495
 
371
496
  - **debug** (boolean, default: `false`): Enable debug output showing skill discovery stats
372
- - When enabled, `skill_find` includes discovered, parsed, rejected, and duplicate counts
373
- - Useful for diagnosing skill loading issues
497
+ - When enabled, `skill_find` responses include discovered, parsed, rejected, and error counts
498
+ - Useful for diagnosing skill loading and parsing issues
499
+
374
500
  - **basePaths** (array, default: standard locations): Custom skill search directories
375
- - Paths are searched in order; later paths override earlier ones for duplicate skill names
501
+ - Paths are searched in priority order; later paths override earlier ones for duplicate skill names
502
+ - Default: `[~/.config/opencode/skills, .opencode/skills]`
376
503
  - Use project-local `.opencode/skills/` for project-specific skills
504
+ - Platform-aware paths: automatically resolves to XDG, macOS, or Windows standard locations
505
+
506
+ - **promptRenderer** (string, default: `'xml'`): Default format for prompt injection
507
+ - Options: `'xml'` | `'json'` | `'md'`
508
+ - XML (default): Claude-optimized, human-readable structured format
509
+ - JSON: GPT-optimized, strict JSON formatting for strong parsing models
510
+ - Markdown: Human-readable format with headings and nested lists
511
+ - Used when no model-specific renderer is configured
512
+
513
+ - **modelRenderers** (object, default: `{}`): Per-model format overrides
514
+ - Maps model IDs to preferred formats
515
+ - Overrides global `promptRenderer` for specific models
516
+ - Example: `{ "gpt-4": "json", "claude-3-5-sonnet": "xml" }`
517
+
518
+ ### How Renderer Selection Works
519
+
520
+ When any tool executes (`skill_find`, `skill_use`, `skill_resource`):
521
+
522
+ 1. The plugin queries the OpenCode session to determine the active LLM model
523
+ 2. Builds a list of model candidates to check, from most to least specific:
524
+ - Full model ID (e.g., `"anthropic-claude-3-5-sonnet"`)
525
+ - Generic model pattern (e.g., `"claude-3-5-sonnet"`)
526
+ 3. Checks if any candidate exists in `modelRenderers` configuration
527
+ - First match wins (most specific takes precedence)
528
+ - If found, uses that format
529
+ 4. If no match in `modelRenderers`, falls back to `promptRenderer` default
530
+ 5. Renders the results in the selected format and injects into the prompt
531
+
532
+ **Example**: If your config has `"claude-3-5-sonnet": "xml"` and the active model is `"anthropic-claude-3-5-sonnet"`, the plugin will:
533
+
534
+ - Try matching `"anthropic-claude-3-5-sonnet"` (no match)
535
+ - Try matching `"claude-3-5-sonnet"` (match found! Use XML)
536
+ - Return `"xml"` format
537
+
538
+ This allows different models to receive results in their preferred format without needing to specify every model variant. Configure the generic model name once and it works for all provider-prefixed variations.
539
+
540
+ ### Example Configurations
541
+
542
+ #### Global Configuration for Multi-Model Setup
543
+
544
+ `~/.config/opencode-skillful/config.json`:
545
+
546
+ ```json
547
+ {
548
+ "debug": false,
549
+ "promptRenderer": "xml",
550
+ "modelRenderers": {
551
+ "claude-3-5-sonnet": "xml",
552
+ "claude-3-opus": "xml",
553
+ "gpt-4": "json",
554
+ "gpt-4-turbo": "json",
555
+ "llama-2-70b": "md"
556
+ }
557
+ }
558
+ ```
559
+
560
+ #### Project-Specific Override
561
+
562
+ `.opencode-skillful.json` (project root):
563
+
564
+ ```json
565
+ {
566
+ "debug": true,
567
+ "basePaths": ["~/.config/opencode/skills", ".opencode/skills", "./vendor/skills"],
568
+ "promptRenderer": "xml",
569
+ "modelRenderers": {
570
+ "gpt-4": "json"
571
+ }
572
+ }
573
+ ```
574
+
575
+ This project-local config:
576
+
577
+ - Enables debug output for troubleshooting
578
+ - Adds a custom vendor skills directory
579
+ - Uses JSON format specifically for GPT-4 when it's the active model
580
+ - Falls back to XML for all other models
377
581
 
378
582
  ## Architecture
379
583