opencode.env 0.0.0 → 0.0.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.
- package/README.md +39 -55
- package/dist/index.mjs +19 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
# opencode
|
|
1
|
+
# opencode.env
|
|
2
2
|
|
|
3
|
-
OpenCode plugin that
|
|
4
|
-
|
|
5
|
-
to every bash invocation.
|
|
3
|
+
OpenCode plugin that loads `.env` files and direnv environment variables into
|
|
4
|
+
every shell invocation.
|
|
6
5
|
|
|
7
6
|
## Usage
|
|
8
7
|
|
|
@@ -10,7 +9,7 @@ Add to your OpenCode config (`opencode.json`):
|
|
|
10
9
|
|
|
11
10
|
```json
|
|
12
11
|
{
|
|
13
|
-
"plugin": ["opencode
|
|
12
|
+
"plugin": ["opencode.env"]
|
|
14
13
|
}
|
|
15
14
|
```
|
|
16
15
|
|
|
@@ -19,72 +18,57 @@ Add to your OpenCode config (`opencode.json`):
|
|
|
19
18
|
Create a config file in any of these locations. Layers are merged in this order
|
|
20
19
|
(later wins and merged instead of replacing):
|
|
21
20
|
|
|
22
|
-
1. `~/.opencode
|
|
23
|
-
2. `./.opencode
|
|
24
|
-
3. `./.opencode/
|
|
21
|
+
1. `~/.opencode.env.json` — global
|
|
22
|
+
2. `./.opencode.env.json` — project root
|
|
23
|
+
3. `./.opencode/env.json` — project root
|
|
25
24
|
|
|
26
25
|
```json
|
|
27
26
|
{
|
|
28
|
-
"$schema": "https://github.com/NazmusSayad/opencode
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"commands": ["custom-pattern"],
|
|
34
|
-
"disableDefaults": false,
|
|
35
|
-
"disableGlobal": false
|
|
36
|
-
},
|
|
37
|
-
"whitelist": {
|
|
38
|
-
"commands": ["vitest"],
|
|
39
|
-
"disableDefaults": false,
|
|
40
|
-
"disableGlobal": false
|
|
41
|
-
}
|
|
27
|
+
"$schema": "https://github.com/NazmusSayad/opencode.env/raw/refs/heads/schema/schema.json",
|
|
28
|
+
"files": [".env", ".env.local"],
|
|
29
|
+
"define": {
|
|
30
|
+
"NODE_ENV": "development",
|
|
31
|
+
"MY_VAR": "value"
|
|
42
32
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"disableGlobal": false,
|
|
48
|
-
"disableCwd": false
|
|
49
|
-
},
|
|
50
|
-
"command": {
|
|
51
|
-
"before": { "command": "set -e", "comment": "Fail fast" },
|
|
52
|
-
"after": { "command": "echo done", "comment": "Notify" }
|
|
53
|
-
}
|
|
33
|
+
"disableDirenv": false,
|
|
34
|
+
"disableGlobal": false,
|
|
35
|
+
"disableCwdEnv": false,
|
|
36
|
+
"disableCwdDirenv": false
|
|
54
37
|
}
|
|
55
38
|
```
|
|
56
39
|
|
|
57
|
-
### `
|
|
40
|
+
### `files`
|
|
41
|
+
|
|
42
|
+
Array of `.env`-style file paths to load (resolved relative to the project root,
|
|
43
|
+
or `~/` for home directory). Variables are merged in order — later files
|
|
44
|
+
override earlier ones.
|
|
45
|
+
|
|
46
|
+
### `define`
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
whitespace-normalized.
|
|
48
|
+
Inline `KEY: "value"` map of environment variables merged over file-based vars.
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
- `blacklist` / `whitelist` — `commands` are substring patterns. `disableDefaults` skips the built-in list; `disableGlobal` skips the global config's list.
|
|
64
|
-
- `message` — custom block error. Placeholders: `{{COMMAND}}`, `{{PATTERN}}`.
|
|
50
|
+
### `disableGlobal`
|
|
65
51
|
|
|
66
|
-
|
|
67
|
-
`yarn start`, `npx vite`, `npx next`, `npx nodemon`, `npx tsx watch`,
|
|
68
|
-
`node --watch`, `pm2 start`. `npx next lint` is allowed by default.
|
|
52
|
+
Set to `true` to ignore the global config's `files` and `define` settings.
|
|
69
53
|
|
|
70
|
-
### `
|
|
54
|
+
### `disableCwdEnv`
|
|
71
55
|
|
|
72
|
-
|
|
56
|
+
By default, `.env` files from the current working directory are also loaded
|
|
57
|
+
(if different from the project root). Set to `true` to load only from the
|
|
58
|
+
project root.
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
- `files` — additional `.env`-style files to load (resolved relative to project root, or `~/` for home).
|
|
76
|
-
- `disableDefaults` — skip the built-in `.env` file list.
|
|
77
|
-
- `disableGlobal` — skip the global config's `define` and `files`.
|
|
78
|
-
- `disableCwd` — by default, `.env` files from the current working directory are also loaded. Set to `true` to load only from the project root.
|
|
60
|
+
### `disableDirenv`
|
|
79
61
|
|
|
80
|
-
|
|
62
|
+
Set to `true` to skip loading environment variables from [direnv](https://direnv.net/).
|
|
81
63
|
|
|
82
|
-
|
|
83
|
-
command already starts/ends with the injected string.
|
|
64
|
+
### `disableCwdDirenv`
|
|
84
65
|
|
|
85
|
-
|
|
66
|
+
By default, direnv is evaluated in the current working directory (if different
|
|
67
|
+
from the project root). Set to `true` to evaluate direnv only in the project
|
|
68
|
+
root.
|
|
86
69
|
|
|
87
70
|
## Debugging
|
|
88
71
|
|
|
89
|
-
Set `
|
|
90
|
-
`os.tmpdir()/.opencode-
|
|
72
|
+
Set `OPENCODE_ENV_LOG_ENABLED=true` to write logs to
|
|
73
|
+
`os.tmpdir()/.opencode.env-logs/`. Use `OPENCODE_ENV_LOG_PATH` to specify a
|
|
74
|
+
custom log directory.
|