opencode-add-dir 1.7.0 → 1.7.1

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 +2 -21
  2. package/package.json +1 -5
  3. package/bin/setup.mjs +0 -58
package/README.md CHANGED
@@ -12,15 +12,6 @@ opencode plugin opencode-add-dir -g
12
12
 
13
13
  Restart OpenCode. Done.
14
14
 
15
- <details>
16
- <summary>Alternative: setup CLI</summary>
17
-
18
- ```bash
19
- npx opencode-add-dir-setup
20
- ```
21
-
22
- </details>
23
-
24
15
  <details>
25
16
  <summary>Alternative: local development</summary>
26
17
 
@@ -69,11 +60,7 @@ Runs in the background — no commands, only hooks:
69
60
  | `config` | Injects `external_directory: "allow"` permission rules for persisted dirs at startup |
70
61
  | `tool.execute.before` | Auto-grants permissions when subagents access added directories |
71
62
  | `event` | Auto-approves any remaining permission popups for added directories |
72
- | `system.transform` | Injects `AGENTS.md` / `CLAUDE.md` content from added directories into the system prompt |
73
-
74
- ### Context Injection
75
-
76
- If an added directory contains `AGENTS.md`, `CLAUDE.md`, or `.agents/AGENTS.md`, the content is automatically injected into the system prompt.
63
+ | `system.transform` | Injects added directory paths into the system prompt so the LLM knows about them |
77
64
 
78
65
  ## Development
79
66
 
@@ -93,17 +80,11 @@ src/
93
80
  ├── plugin.ts # Server hooks (permissions, context injection)
94
81
  ├── tui-plugin.tsx # TUI plugin (dialogs for add/list/remove)
95
82
  ├── state.ts # Persistence, path utils, tui.json auto-config
96
- ├── validate.ts # Directory validation
97
83
  ├── permissions.ts # Session grants + auto-approve
98
- ├── context.ts # AGENTS.md injection
84
+ ├── context.ts # System prompt injection
99
85
  └── types.ts # Shared type definitions
100
86
  ```
101
87
 
102
- ## Limitations
103
-
104
- - Directories added without "Remember" rely on session-level permissions. The first access by a subagent may briefly show a permission popup before auto-dismissing.
105
- - The `permission.ask` plugin hook is defined in the OpenCode SDK but [not invoked](https://github.com/sst/opencode/blob/main/packages/opencode/src/permission/index.ts) in the source — this plugin works around it using `tool.execute.before` and event-based auto-approval.
106
-
107
88
  ## License
108
89
 
109
90
  [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-add-dir",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
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",
@@ -22,12 +22,8 @@
22
22
  "server",
23
23
  "tui"
24
24
  ],
25
- "bin": {
26
- "opencode-add-dir-setup": "./bin/setup.mjs"
27
- },
28
25
  "files": [
29
26
  "dist/",
30
- "bin/setup.mjs",
31
27
  "README.md",
32
28
  "LICENSE"
33
29
  ],
package/bin/setup.mjs DELETED
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs"
3
- import { join } from "path"
4
- import { homedir } from "os"
5
-
6
- const PKG = "opencode-add-dir"
7
- const isRemove = process.argv.includes("--remove")
8
- const dir = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "opencode")
9
-
10
- function findFile(base) {
11
- for (const ext of [".jsonc", ".json"]) {
12
- const p = join(dir, base + ext)
13
- if (existsSync(p)) return p
14
- }
15
- return join(dir, base + ".json")
16
- }
17
-
18
- function readConfig(path) {
19
- if (!existsSync(path)) return {}
20
- return JSON.parse(readFileSync(path, "utf-8").replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, ""))
21
- }
22
-
23
- function hasPlugin(plugins) {
24
- return plugins.some((p) => {
25
- const n = Array.isArray(p) ? p[0] : p
26
- return n === PKG || n.startsWith(PKG + "@")
27
- })
28
- }
29
-
30
- function patch(path, schema) {
31
- const config = readConfig(path)
32
- config.plugin ??= []
33
-
34
- if (isRemove) {
35
- if (!hasPlugin(config.plugin)) return false
36
- config.plugin = config.plugin.filter((p) => {
37
- const n = Array.isArray(p) ? p[0] : p
38
- return n !== PKG && !n.startsWith(PKG + "@")
39
- })
40
- } else {
41
- if (hasPlugin(config.plugin)) return false
42
- config.plugin.push(PKG)
43
- if (schema && !config.$schema) config.$schema = schema
44
- }
45
-
46
- writeFileSync(path, JSON.stringify(config, null, 2) + "\n")
47
- return true
48
- }
49
-
50
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
51
-
52
- for (const [label, path, schema] of [
53
- ["server", findFile("opencode"), "https://opencode.ai/config.json"],
54
- ["tui", findFile("tui")],
55
- ]) {
56
- if (patch(path, schema)) console.log(`${isRemove ? "Removed from" : "Added to"} ${label}: ${path}`)
57
- else console.log(`${label}: already ${isRemove ? "absent" : "configured"}`)
58
- }