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.
Files changed (3) hide show
  1. package/README.md +39 -55
  2. package/dist/index.mjs +19 -20
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # opencode-armor
1
+ # opencode.env
2
2
 
3
- OpenCode plugin that blocks bash commands for long-running dev servers, injects
4
- project `.env` variables into the shell, and prepends/appends arbitrary commands
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-armor"]
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-armor.json` — global
23
- 2. `./.opencode-armor.json` — project root
24
- 3. `./.opencode/armor.json` — project root
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-armor/raw/refs/heads/schema/schema.json",
29
- "armor": {
30
- "priority": "whitelist",
31
- "message": "Blocked: `{{COMMAND}}` (matched `{{PATTERN}}`)",
32
- "blacklist": {
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
- "dotenv": {
44
- "define": { "MY_VAR": "value" },
45
- "files": [".env"],
46
- "disableDefaults": false,
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
- ### `armor`
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
- Controls which bash commands are blocked. Patterns are case-insensitive and
60
- whitespace-normalized.
48
+ Inline `KEY: "value"` map of environment variables merged over file-based vars.
61
49
 
62
- - `priority` — `"whitelist"` (default) or `"blacklist"`.
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
- By default, dev servers and watchers are blocked e.g. `npm run dev`,
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
- ### `dotenv`
54
+ ### `disableCwdEnv`
71
55
 
72
- Injects environment variables into every shell via the `shell.env` hook.
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
- - `define` — inline `KEY: "value"` map merged over file-based vars.
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
- ### `command`
62
+ Set to `true` to skip loading environment variables from [direnv](https://direnv.net/).
81
63
 
82
- Inject a command at the start or end of every bash invocation. Skipped when the
83
- command already starts/ends with the injected string.
64
+ ### `disableCwdDirenv`
84
65
 
85
- - `before` / `after` `{ command, comment }`. `comment` is appended after `#`.
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 `OPENCODE_ARMOR_ENABLE_LOG=true` to write logs to
90
- `os.tmpdir()/.opencode-armor-logs/`.
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.