Skip to content

docs: add breakdown configuration guide#205

Open
Ev3lynx727 wants to merge 8 commits into
cortexkit:masterfrom
Ev3lynx727:docs/breakdown-configuration
Open

docs: add breakdown configuration guide#205
Ev3lynx727 wants to merge 8 commits into
cortexkit:masterfrom
Ev3lynx727:docs/breakdown-configuration

Conversation

@Ev3lynx727

@Ev3lynx727 Ev3lynx727 commented Jun 30, 2026

Copy link
Copy Markdown

Breakdown and configuration reference for Magic Context plugin installation, plugin schema, backend architecture, troubleshooting, and FAQ.

Covers:

  • Global vs local scope installation, cache locations
  • Plugin schema (opencode.jsonc entry, model binding, compaction)
  • Backend architecture (SQLite, ONNX model, RPC, context resolution)
  • Troubleshooting (small-pickle error, duplicate entries, missing package)
  • FAQ (5 common questions)

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Adds a breakdown and configuration guide for the Magic Context plugin to simplify install, setup, and troubleshooting. Clarifies canonical install paths and makes the duplicate-entry cleanup script safe and accurate.

  • Bug Fixes
    • Verify step now checks ~/.cache/opencode/packages/@cortexkit/ (no @latest) to match opencode plugin installs.
    • Cleanup script: filters out @cortexkit/opencode-magic-context, deletes the plugin key only if empty, fixes bash line continuation (single \), and chains the success echo with && after mv (removed trailing && :) so it only prints on success.
    • “Package Missing” guidance now uses opencode plugin @cortexkit/opencode-magic-context --global and warns against manual npm install to non-canonical ~/.cache/opencode/node_modules/.

Written for commit cc54df1. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR adds docs/breakdown-configuration.md, a new reference guide for the Magic Context plugin covering installation, plugin schema, backend architecture, troubleshooting, and FAQ. It also resolves all four issues flagged in the previous review round (wholesale file deletion, @latest verify path, jq filter-then-check logic, and unconditional echo).

  • Installation & verify: Documents global vs local scope, canonical cache paths (~/.cache/opencode/packages/), and corrects the verify snippet to list the @cortexkit/ directory without an @latest suffix.
  • Duplicate-entry cleanup: Replaces the destructive whole-file delete with a surgical jq pipeline that filters only the @cortexkit/opencode-magic-context entry, deletes the plugin key only when the filtered result is empty, and chains echo with && so it prints only on success.
  • Backend & FAQ: Explains SQLite session state, ONNX model origin, config.providers() vs models.json, and the opencode/small-pickle console warning.

Confidence Score: 5/5

Safe to merge — adds a documentation-only file with no runtime code changes; all previously flagged correctness issues in the bash cleanup snippet have been resolved.

The only changed file is a new markdown guide. The previous round's concerns (file clobbering, wrong @latest path, incorrect jq length condition, unconditional echo) are all addressed in this revision. The two remaining notes are minor robustness suggestions in a copy-paste troubleshooting snippet and do not affect any runtime behavior.

No files require special attention — the cleanup snippet in the Duplicate Plugin Entries section has two small hardening opportunities flagged as suggestions.

Important Files Changed

Filename Overview
docs/breakdown-configuration.md New documentation guide covering install paths, plugin schema, backend architecture, troubleshooting, and FAQ; addresses all previously flagged issues (file clobbering, @latest verify path, jq filter logic, echo chaining). Two minor style/robustness P2 notes remain in the cleanup snippet.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant OC as OpenCode (main)
    participant MC as Magic Context (child)
    participant SDK as config.providers() SDK
    participant DB as SQLite (context.db)
    participant ONNX as ONNX Model

    OC->>MC: spawn child process
    MC->>DB: open context.db (SQLite)
    MC->>MC: warm apiCache from last-known-good file
    MC->>SDK: config.providers()
    SDK-->>MC: merged models (live + compiled-in + auth caps)
    MC->>MC: bound result to [20k, 3M] range
    MC->>ONNX: load all-MiniLM-L6-v2
    MC-->>OC: RPC socket ready
    OC->>MC: context compaction request
    MC->>DB: read/write compacted history
    MC-->>OC: resolved context window
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant OC as OpenCode (main)
    participant MC as Magic Context (child)
    participant SDK as config.providers() SDK
    participant DB as SQLite (context.db)
    participant ONNX as ONNX Model

    OC->>MC: spawn child process
    MC->>DB: open context.db (SQLite)
    MC->>MC: warm apiCache from last-known-good file
    MC->>SDK: config.providers()
    SDK-->>MC: merged models (live + compiled-in + auth caps)
    MC->>MC: bound result to [20k, 3M] range
    MC->>ONNX: load all-MiniLM-L6-v2
    MC-->>OC: RPC socket ready
    OC->>MC: context compaction request
    MC->>DB: read/write compacted history
    MC-->>OC: resolved context window
Loading

Reviews (6): Last reviewed commit: "Fix: proper && chain for echo (remove st..." | Re-trigger Greptile

Comment thread docs/breakdown-configuration.md
Comment thread docs/breakdown-configuration.md

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread docs/breakdown-configuration.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread docs/breakdown-configuration.md Outdated
Comment thread docs/breakdown-configuration.md

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/breakdown-configuration.md">

<violation number="1" location="docs/breakdown-configuration.md:157">
P2: Duplicate-entry cleanup command only modifies `~/.opencode/opencode.json` even though the troubleshooting guidance directs users to check both `~/.opencode/opencode.json` and `~/.opencode/tui.json` for duplicate plugin entries. If the duplicate is in `tui.json`, the fix will silently fail to resolve the issue.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

```bash
# Targeted removal — removes just the magic-context entry from the plugin array,
# never deletes the entire file even if it contains other config.
if [ -f ~/.opencode/opencode.json ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Duplicate-entry cleanup command only modifies ~/.opencode/opencode.json even though the troubleshooting guidance directs users to check both ~/.opencode/opencode.json and ~/.opencode/tui.json for duplicate plugin entries. If the duplicate is in tui.json, the fix will silently fail to resolve the issue.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/breakdown-configuration.md, line 157:

<comment>Duplicate-entry cleanup command only modifies `~/.opencode/opencode.json` even though the troubleshooting guidance directs users to check both `~/.opencode/opencode.json` and `~/.opencode/tui.json` for duplicate plugin entries. If the duplicate is in `tui.json`, the fix will silently fail to resolve the issue.</comment>

<file context>
@@ -149,13 +149,14 @@ cat ~/.opencode/opencode.json 2>/dev/null
-  echo "Removed (only plugin entry)"
+# Targeted removal — removes just the magic-context entry from the plugin array,
+# never deletes the entire file even if it contains other config.
+if [ -f ~/.opencode/opencode.json ]; then
+  jq 'if (.plugin | length) == 1 then del(.plugin) else (.plugin |= map(select(. != "@cortexkit/opencode-magic-context"))) end'     ~/.opencode/opencode.json > /tmp/opencode_tmp.json && mv /tmp/opencode_tmp.json ~/.opencode/opencode.json
+  echo "Removed magic-context entry from plugin array"
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/breakdown-configuration.md">

<violation number="1" location="docs/breakdown-configuration.md:157">
P2: Duplicate-entry cleanup command only modifies `~/.opencode/opencode.json` even though the troubleshooting guidance directs users to check both `~/.opencode/opencode.json` and `~/.opencode/tui.json` for duplicate plugin entries. If the duplicate is in `tui.json`, the fix will silently fail to resolve the issue.</violation>

<violation number="2" location="docs/breakdown-configuration.md:159">
P1: Troubleshooting script uses a predictable /tmp file, creating symlink attack and concurrent access risks</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread docs/breakdown-configuration.md Outdated
# never deletes the entire file even if it contains other config.
if [ -f ~/.opencode/opencode.json ]; then
# Always filter first, then del only if nothing remains.
jq '(.plugin |= map(select(. != "@cortexkit/opencode-magic-context"))) | if (.plugin | length) == 0 then del(.plugin) else . end' \\

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Troubleshooting script uses a predictable /tmp file, creating symlink attack and concurrent access risks

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/breakdown-configuration.md, line 159:

<comment>Troubleshooting script uses a predictable /tmp file, creating symlink attack and concurrent access risks</comment>

<file context>
@@ -149,13 +149,16 @@ cat ~/.opencode/opencode.json 2>/dev/null
+# never deletes the entire file even if it contains other config.
+if [ -f ~/.opencode/opencode.json ]; then
+  # Always filter first, then del only if nothing remains.
+jq '(.plugin |= map(select(. != "@cortexkit/opencode-magic-context"))) | if (.plugin | length) == 0 then del(.plugin) else . end' \\
+  ~/.opencode/opencode.json > /tmp/opencode_tmp.json && mv /tmp/opencode_tmp.json ~/.opencode/opencode.json
+  echo "Removed magic-context entry from plugin array"
</file context>

Comment thread docs/breakdown-configuration.md Outdated
Comment thread docs/breakdown-configuration.md
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