Skip to content

fix(kimaki): point opencode.json plugin paths at persistent kimaki-config dir on local#124

Merged
chubes4 merged 1 commit intomainfrom
fix/local-plugin-path-persistent
May 6, 2026
Merged

fix(kimaki): point opencode.json plugin paths at persistent kimaki-config dir on local#124
chubes4 merged 1 commit intomainfrom
fix/local-plugin-path-persistent

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 6, 2026

Summary

  • Point local OpenCode plugin entries at $KIMAKI_DATA_DIR/kimaki-config/plugins instead of npm package-local kimaki/plugins paths.
  • Stop local Kimaki sync/post-upgrade from relying on npm-dir plugin restoration; post-upgrade now validates the persistent plugin target while retaining skill restoration.
  • Rewrite stale managed plugin entries during opencode.json repair so existing installs migrate on the next upgrade run.

Problem

npm update -g kimaki wipes $(npm root -g)/kimaki/plugins/, and macOS local installs have no launchd ExecStartPre hook to restore it. When dm-context-filter.ts disappears, Kimaki bridge content such as --worktree, --cwd, scheduled sends, and worktree creation instructions leaks into agent system prompts unfiltered.

Reproducer

Observed ENOENT failures in kimaki.error.log on May 2 and May 5 while OpenCode tried to load npm-dir plugin paths:

path=file:///Users/chubes/.nvm/versions/node/v24.13.1/lib/node_modules/kimaki/plugins/dm-context-filter.ts ... ENOENT

Root cause

Local installs had a plugin path mismatch:

  • Persistent source: $KIMAKI_DATA_DIR/kimaki-config/plugins/, which survives npm update -g kimaki.
  • OpenCode-loaded path: $(npm root -g)/kimaki/plugins/, which is package-local and gets wiped by npm updates.

Fix

  • Generate local opencode.json entries directly against $KIMAKI_DATA_DIR/kimaki-config/plugins/<plugin>.ts.
  • Remove the local npm-dir plugin mirror from bridge_sync_config.
  • Make post-upgrade.sh validate persistent plugin files by default instead of restoring them into npm package-local paths.
  • Teach additive/full opencode.json repair to rewrite managed plugin entries whose basename is dm-context-filter.ts or dm-agent-sync.ts when they point outside the persistent plugin directory.
  • Run opencode.json drift/repair during --kimaki-only upgrades so the documented repair command actually exercises the migration.

VPS impact

None expected. VPS installs already use /opt/kimaki-config/plugins as the durable OpenCode plugin target, so the persistent source and loaded plugin path remain the same.

Tests added

  • Added tests/opencode-local-plugin-path.sh for local-mode opencode.json plugin generation.
  • Extended tests/repair-opencode-json.sh to verify additive repair rewrites stale npm-dir managed plugin paths.
  • Updated tests/post-upgrade-restore.sh for the new persistent-plugin validation behavior.
  • Refreshed effective-prompt snapshots for the current Kimaki prompt text; filtered leak count remains zero.

Test status

  • bash upgrade.sh --kimaki-only --dry-run --wp-path /Users/chubes/Studio/intelligence-chubes4
  • bash upgrade.sh --kimaki-only --repair-opencode-json --dry-run --wp-path /Users/chubes/Studio/intelligence-chubes4
  • for test_script in tests/*.sh; do bash "$test_script"; done
  • node tests/effective-prompt/run.mjs
  • homeboy test

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (GPT-5.5)
  • Used for: Implementing the patch, writing focused regression tests, running dry-run/test validation, and drafting this PR summary. Chris remains responsible for review and merge.

Local installs wrote durable plugin copies under kimaki-config but kept loading OpenCode plugins from npm's package directory, so npm update -g kimaki could erase the loaded files. Load and repair managed plugin paths against the persistent config directory instead, and keep post-upgrade focused on skills plus plugin validation.
@chubes4 chubes4 merged commit ef8a8b5 into main May 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant