opencode-add-dir 1.7.1 → 1.7.2

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 (2) hide show
  1. package/README.md +26 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ When you need an agent to read, edit, or search files outside the current projec
10
10
  opencode plugin opencode-add-dir -g
11
11
  ```
12
12
 
13
- Restart OpenCode. Done.
13
+ Restart OpenCode. The plugin auto-registers itself in your `tui.json` — no manual config needed.
14
14
 
15
15
  <details>
16
16
  <summary>Alternative: local development</summary>
@@ -49,7 +49,14 @@ The plugin has two parts: a **TUI plugin** for the interactive dialogs and a **s
49
49
 
50
50
  ### TUI Plugin
51
51
 
52
- Handles all three slash commands via dialogs. Writes persisted directories to `~/.local/share/opencode/add-dir/directories.json` and grants session permissions via the SDK.
52
+ Handles all three slash commands via dialogs. Directories are stored in two files under `~/.local/share/opencode/add-dir/`:
53
+
54
+ - **`directories.json`** — Persisted dirs, survive restarts.
55
+ - **`session-dirs.json`** — Session-only dirs, cleared automatically on startup.
56
+
57
+ Which file gets written depends on the "Remember across sessions" toggle in `/add-dir`.
58
+
59
+ > Respects `XDG_DATA_HOME` if set.
53
60
 
54
61
  ### Server Plugin
55
62
 
@@ -57,10 +64,22 @@ Runs in the background — no commands, only hooks:
57
64
 
58
65
  | Hook | What it does |
59
66
  |------|-------------|
60
- | `config` | Injects `external_directory: "allow"` permission rules for persisted dirs at startup |
61
- | `tool.execute.before` | Auto-grants permissions when subagents access added directories |
62
- | `event` | Auto-approves any remaining permission popups for added directories |
63
- | `system.transform` | Injects added directory paths into the system prompt so the LLM knows about them |
67
+ | `config` | Injects `external_directory: "allow"` permission rules for all added dirs at startup |
68
+ | `tool.execute.before` | Pre-authorizes sessions when file tools (`read`, `write`, `edit`, `bash`, `glob`, `grep`, `list`, `apply_patch`, `multiedit`) target an added directory |
69
+ | `event` | Listens for `permission.asked` events and auto-approves when the path matches an added directory |
70
+ | `experimental.chat.system.transform` | Injects added directory paths into the system prompt so the LLM knows about them |
71
+
72
+ These three permission layers work together: `config` handles startup rules, `tool.execute.before` handles proactive grants during tool calls, and `event` catches any runtime permission requests that still come through.
73
+
74
+ ### Context Injection
75
+
76
+ By default the system prompt only gets the list of added directories. If you set:
77
+
78
+ ```bash
79
+ export OPENCODE_ADDDIR_INJECT_CONTEXT=1
80
+ ```
81
+
82
+ The plugin will also read and inject `AGENTS.md`, `CLAUDE.md`, and `.agents/AGENTS.md` from each added directory into the system prompt — useful when working across projects that have their own agent instructions.
64
83
 
65
84
  ## Development
66
85
 
@@ -79,7 +98,7 @@ src/
79
98
  ├── index.ts # Server plugin entry
80
99
  ├── plugin.ts # Server hooks (permissions, context injection)
81
100
  ├── tui-plugin.tsx # TUI plugin (dialogs for add/list/remove)
82
- ├── state.ts # Persistence, path utils, tui.json auto-config
101
+ ├── state.ts # Persistence, caching, path utils, tui.json auto-config
83
102
  ├── permissions.ts # Session grants + auto-approve
84
103
  ├── context.ts # System prompt injection
85
104
  └── types.ts # Shared type definitions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-add-dir",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Add working directories to your OpenCode session with auto-approved permissions",
5
5
  "author": "Cristian Fonseca <cfonsecacomas@gmail.com>",
6
6
  "type": "module",