opencodekit 0.21.2 → 0.21.3

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.
@@ -9,6 +9,8 @@ plugin/
9
9
  ├── memory.ts # 4-tier automated memory system (capture → distill → curate → inject)
10
10
  ├── sessions.ts # Session search tools (find/read)
11
11
  ├── copilot-auth.ts # GitHub Copilot provider/auth integration
12
+ ├── prompt-leverage.ts # Prompt pre-processing with structured execution framing
13
+ ├── rtk.ts # Optional RTK command-output compression hook
12
14
  ├── skill-mcp.ts # Skill-scoped MCP bridge (skill_mcp tools)
13
15
  └── lib/
14
16
  ├── memory-tools.ts # 6 core memory tools (observation, search, get, read, update, timeline)
@@ -58,6 +60,15 @@ plugin/
58
60
  - Handles GitHub Copilot OAuth/device flow
59
61
  - Adds model/provider request shaping for compatible reasoning behavior
60
62
 
63
+ - `prompt-leverage.ts`
64
+ - Upgrades user prompts with objective, context, tool rules, verification, and done criteria
65
+ - Runs through `experimental.chat.messages.transform`
66
+
67
+ - `rtk.ts`
68
+ - Optional OpenCode hook for RTK command-output compression
69
+ - Rewrites low-risk `bash`/`shell` commands through `rtk rewrite`
70
+ - Keeps an idempotency guard for symlinked global/project config double-loading
71
+
61
72
  ## Notes
62
73
 
63
74
  - OpenCode auto-discovers every `.ts` file in `plugin/` as a plugin — keep helper modules in `lib/`
@@ -0,0 +1,43 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+
3
+ // RTK OpenCode plugin — rewrites commands to use rtk for token savings.
4
+ // Requires: rtk >= 0.23.0 in PATH.
5
+ //
6
+ // This is a thin delegating plugin: all rewrite logic lives in `rtk rewrite`,
7
+ // which is the single source of truth (src/discover/registry.rs).
8
+ // To add or change rewrite rules, edit the Rust registry — not this file.
9
+
10
+ export const RtkOpenCodePlugin: Plugin = async ({ $ }) => {
11
+ try {
12
+ await $`which rtk`.quiet();
13
+ } catch {
14
+ console.warn("[rtk] rtk binary not found in PATH — plugin disabled");
15
+ return {};
16
+ }
17
+
18
+ return {
19
+ "tool.execute.before": async (input, output) => {
20
+ const tool = String(input?.tool ?? "").toLowerCase();
21
+ if (tool !== "bash" && tool !== "shell") return;
22
+ const args = output?.args;
23
+ if (!args || typeof args !== "object") return;
24
+
25
+ const command = (args as Record<string, unknown>).command;
26
+ if (typeof command !== "string" || !command) return;
27
+ // This config is symlinked as both global and project OpenCode config.
28
+ // OpenCode may load this plugin twice in that layout, so avoid rewriting
29
+ // commands that have already been routed through rtk.
30
+ if (/^\s*(?:RTK_[A-Z_]+=\S+\s+)*rtk\b/.test(command)) return;
31
+
32
+ try {
33
+ const result = await $`rtk rewrite ${command}`.quiet().nothrow();
34
+ const rewritten = String(result.stdout).trim();
35
+ if (rewritten && rewritten !== command) {
36
+ (args as Record<string, unknown>).command = rewritten;
37
+ }
38
+ } catch {
39
+ // rtk rewrite failed — pass through unchanged
40
+ }
41
+ },
42
+ };
43
+ };
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: rtk-command-compression
3
+ description: Use when installing, enabling, testing, or operating RTK command-output compression in OpenCode — keeps RTK opt-in, verifies the correct binary/plugin, protects raw verification evidence, and maintains safe hook exclusions.
4
+ version: 1.0.0
5
+ tags: [workflow, integration, automation]
6
+ dependencies: []
7
+ ---
8
+
9
+ # RTK Token Optimization
10
+
11
+ ## Overview
12
+
13
+ RTK can reduce noisy shell output from commands like `git status`, tests, lint, build tools, Docker, kubectl, and `gh`. Treat it as an **opt-in shell-output compressor**, not a replacement for OpenCode's native read/search/edit tools.
14
+
15
+ Core rule: **opt in explicitly, verify rewrites, preserve raw evidence when correctness matters.**
16
+
17
+ ## When to Use
18
+
19
+ - User asks to install, enable, test, tune, or troubleshoot RTK in OpenCode.
20
+ - Bash output is consuming too much context from shell-heavy workflows.
21
+ - You need to document or validate RTK wiring in a project where `~/.config/opencode` may be symlinked to `.opencode`.
22
+
23
+ ## When NOT to Use
24
+
25
+ - Code inspection or editing: prefer `tilth_tilth_read`, `tilth_tilth_search`, LSP, Read, Grep, and Edit.
26
+ - Full verification evidence is required and compressed summaries would hide diagnostics.
27
+ - The user has not approved installing binaries, changing global OpenCode config, or adding plugins.
28
+
29
+ ## Current OpenCodeKit Wiring
30
+
31
+ This template supports RTK as optional user-local wiring:
32
+
33
+ - RTK binary: `~/.local/bin/rtk` after opt-in install.
34
+ - Active OpenCode plugin path in this symlinked setup: `.opencode/plugin/rtk.ts`.
35
+ - RTK config path on macOS: `~/Library/Application Support/rtk/config.toml`.
36
+ - Keep telemetry disabled unless the user explicitly opts in.
37
+ - Keep tee mode on `failures` so raw output can be recovered when commands fail.
38
+
39
+ If `~/.config/opencode` is symlinked to this repo's `.opencode`, OpenCode may resolve the same plugin as both global and project config. The RTK plugin must be idempotent: skip commands already starting with `rtk`.
40
+
41
+ ## Install / Enable Checklist
42
+
43
+ Ask before installing or changing global config. Then run:
44
+
45
+ ```bash
46
+ command -v rtk || RTK_INSTALL_DIR="$HOME/.local/bin" sh /tmp/rtk-research/install.sh
47
+ rtk --version
48
+ rtk gain
49
+ RTK_TELEMETRY_DISABLED=1 rtk init -g --opencode --hook-only
50
+ RTK_TELEMETRY_DISABLED=1 rtk config --create
51
+ ```
52
+
53
+ Verify OpenCode sees the plugin:
54
+
55
+ ```bash
56
+ opencode debug config | grep -i 'rtk\|plugin' -C 2
57
+ ```
58
+
59
+ Verify RTK itself:
60
+
61
+ ```bash
62
+ RTK_TELEMETRY_DISABLED=1 rtk telemetry status
63
+ rtk verify
64
+ ```
65
+
66
+ `rtk verify` may say a Claude hook is not installed; that is expected when only the OpenCode plugin is enabled. The important checks are the OpenCode plugin path, telemetry status, and RTK test count.
67
+
68
+ ## Required Safety Settings
69
+
70
+ In `~/Library/Application Support/rtk/config.toml`, keep exclusions for commands that need raw output or are known unsafe under RTK rewrite:
71
+
72
+ ```toml
73
+ [hooks]
74
+ exclude_commands = ["curl", "wget", "playwright", "find", "npx oxlint", "git push", "git rebase", "git cherry-pick"]
75
+
76
+ [telemetry]
77
+ enabled = false
78
+
79
+ [tee]
80
+ enabled = true
81
+ mode = "failures"
82
+ ```
83
+
84
+ Rationale:
85
+
86
+ | Exclusion | Why |
87
+ | ------------------------------------------- | ------------------------------------------------------------------------------ |
88
+ | `curl`, `wget` | Preserve raw HTTP output and avoid hiding API/debug evidence. |
89
+ | `playwright` | Browser automation logs/screenshots need full fidelity. |
90
+ | `find` | RTK `find` can reject compound predicates/actions used by normal shell `find`. |
91
+ | `npx oxlint` | RTK may rewrite this to an npm script and fail if no `oxlint` script exists. |
92
+ | `git push`, `git rebase`, `git cherry-pick` | Destructive/history-changing operations must not be obscured by wrappers. |
93
+
94
+ Add more exclusions as soon as a rewrite changes semantics or hides evidence.
95
+
96
+ ## Runtime Usage Rules
97
+
98
+ - Use normal shell commands; let RTK rewrite low-risk noisy commands automatically.
99
+ - Do not manually prefix commands with `rtk` unless you are intentionally testing RTK.
100
+ - For verification gates, prefer raw commands or confirm the compressed output still includes pass/fail counts and actionable diagnostics.
101
+ - If output looks too compact, rerun with an excluded/raw command before making completion claims.
102
+ - Never cite RTK savings as proof that a task is correct; it only proves compression happened.
103
+
104
+ ## Testing RTK Works
105
+
106
+ Use one command that should rewrite and one that should not:
107
+
108
+ ```bash
109
+ git status
110
+ curl https://example.com
111
+ rtk gain
112
+ ```
113
+
114
+ Expected evidence:
115
+
116
+ - `git status` output appears in RTK's compact style and `rtk gain` command count increases.
117
+ - `curl` shows raw curl progress/body because it is excluded.
118
+ - `rtk gain` lists tracked commands such as `rtk git status` and token savings.
119
+
120
+ ## Troubleshooting
121
+
122
+ | Symptom | Check | Fix |
123
+ | -------------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------- |
124
+ | No rewrites | `opencode debug config` | Restart OpenCode and confirm `.opencode/plugin/rtk.ts` is loaded. |
125
+ | Recursive `rtk rtk ...` behavior | Inspect `.opencode/plugin/rtk.ts` | Add/restore idempotency guard for commands already starting with `rtk`. |
126
+ | Command semantics changed | `rtk rewrite '<command>'` | Add the command prefix to `[hooks].exclude_commands`. |
127
+ | Need raw failed output | Check RTK tee files/config | Keep `[tee] mode = "failures"`; rerun raw if needed. |
128
+ | Telemetry concern | `RTK_TELEMETRY_DISABLED=1 rtk telemetry status` | Keep telemetry disabled unless user opts in. |
129
+
130
+ ## Gotchas
131
+
132
+ - **OpenCode path changed from plural to singular** — Initial RTK docs/install path referenced `plugins/rtk.ts`, but active OpenCodeKit loading after restart used `.opencode/plugin/rtk.ts`. Document and inspect the active path, not just installer output.
133
+ - **Symlinked global/project config can double-load plugin paths** — When `~/.config/opencode` points at this repo's `.opencode`, OpenCode can resolve global and project plugin URLs. The plugin must skip commands already starting with `rtk`.
134
+ - **Unsafe rewrites were observed** — `find` compound predicates and `npx oxlint` were rewritten incorrectly during testing. Keep them excluded unless RTK behavior changes and is re-verified.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencodekit",
3
- "version": "0.21.2",
3
+ "version": "0.21.3",
4
4
  "description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
5
5
  "keywords": [
6
6
  "agents",
@@ -1,21 +0,0 @@
1
- {
2
- "name": "opencode",
3
- "version": "1.0.0",
4
- "description": "Opencode plugin",
5
- "keywords": [],
6
- "license": "ISC",
7
- "author": "",
8
- "type": "module",
9
- "main": "index.js",
10
- "scripts": {
11
- "type-check": "tsc --noEmit"
12
- },
13
- "dependencies": {
14
- "@opencode-ai/plugin": "1.4.9"
15
- },
16
- "devDependencies": {
17
- "@types/node": "^25.3.0",
18
- "bun-types": "^1.3.9",
19
- "typescript": "^5.9.3"
20
- }
21
- }
@@ -1,7 +0,0 @@
1
- {
2
- "name": "opencode-plugins",
3
- "type": "module",
4
- "dependencies": {
5
- "@opencode-ai/plugin": "^1.1.13"
6
- }
7
- }