envshed 0.18.0 → 0.20.0

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 (258) hide show
  1. package/README.md +1 -0
  2. package/bin/envshed.js +1 -1
  3. package/dist/agent/claude-code-hook.d.ts +9 -0
  4. package/dist/agent/claude-code-hook.d.ts.map +1 -0
  5. package/dist/agent/claude-code-hook.js +55 -0
  6. package/dist/agent/claude-code-hook.js.map +1 -0
  7. package/dist/agent/claude-code-hook.test.d.ts +2 -0
  8. package/dist/agent/claude-code-hook.test.d.ts.map +1 -0
  9. package/dist/agent/claude-code-hook.test.js +200 -0
  10. package/dist/agent/claude-code-hook.test.js.map +1 -0
  11. package/dist/agent/claude-code.d.ts +3 -0
  12. package/dist/agent/claude-code.d.ts.map +1 -0
  13. package/dist/agent/claude-code.js +206 -0
  14. package/dist/agent/claude-code.js.map +1 -0
  15. package/dist/agent/claude-code.test.d.ts +2 -0
  16. package/dist/agent/claude-code.test.d.ts.map +1 -0
  17. package/dist/agent/claude-code.test.js +302 -0
  18. package/dist/agent/claude-code.test.js.map +1 -0
  19. package/dist/agent/guard.d.ts +8 -0
  20. package/dist/agent/guard.d.ts.map +1 -0
  21. package/dist/agent/guard.js +361 -0
  22. package/dist/agent/guard.js.map +1 -0
  23. package/dist/agent/guard.test.d.ts +2 -0
  24. package/dist/agent/guard.test.d.ts.map +1 -0
  25. package/dist/agent/guard.test.js +271 -0
  26. package/dist/agent/guard.test.js.map +1 -0
  27. package/dist/agent/hook-main.d.ts +8 -0
  28. package/dist/agent/hook-main.d.ts.map +1 -0
  29. package/dist/agent/hook-main.js +45 -0
  30. package/dist/agent/hook-main.js.map +1 -0
  31. package/dist/agent/hook-messages.d.ts +7 -0
  32. package/dist/agent/hook-messages.d.ts.map +1 -0
  33. package/dist/agent/hook-messages.js +18 -0
  34. package/dist/agent/hook-messages.js.map +1 -0
  35. package/dist/agent/registry.d.ts +5 -0
  36. package/dist/agent/registry.d.ts.map +1 -0
  37. package/dist/agent/registry.js +6 -0
  38. package/dist/agent/registry.js.map +1 -0
  39. package/dist/agent/skill-content.d.ts +6 -0
  40. package/dist/agent/skill-content.d.ts.map +1 -0
  41. package/dist/agent/skill-content.js +62 -0
  42. package/dist/agent/skill-content.js.map +1 -0
  43. package/dist/agent/skill-content.test.d.ts +2 -0
  44. package/dist/agent/skill-content.test.d.ts.map +1 -0
  45. package/dist/agent/skill-content.test.js +15 -0
  46. package/dist/agent/skill-content.test.js.map +1 -0
  47. package/dist/agent/types.d.ts +35 -0
  48. package/dist/agent/types.d.ts.map +1 -0
  49. package/dist/agent/types.js +9 -0
  50. package/dist/agent/types.js.map +1 -0
  51. package/dist/commands/agent-session.d.ts +11 -0
  52. package/dist/commands/agent-session.d.ts.map +1 -0
  53. package/dist/commands/agent-session.js +300 -0
  54. package/dist/commands/agent-session.js.map +1 -0
  55. package/dist/commands/agent-session.test.d.ts +2 -0
  56. package/dist/commands/agent-session.test.d.ts.map +1 -0
  57. package/dist/commands/agent-session.test.js +381 -0
  58. package/dist/commands/agent-session.test.js.map +1 -0
  59. package/dist/commands/agent.d.ts +15 -0
  60. package/dist/commands/agent.d.ts.map +1 -0
  61. package/dist/commands/agent.js +114 -0
  62. package/dist/commands/agent.js.map +1 -0
  63. package/dist/commands/agent.test.d.ts +2 -0
  64. package/dist/commands/agent.test.d.ts.map +1 -0
  65. package/dist/commands/agent.test.js +132 -0
  66. package/dist/commands/agent.test.js.map +1 -0
  67. package/dist/commands/completions.d.ts.map +1 -1
  68. package/dist/commands/completions.js +37 -3
  69. package/dist/commands/completions.js.map +1 -1
  70. package/dist/commands/login.d.ts.map +1 -1
  71. package/dist/commands/login.js +42 -4
  72. package/dist/commands/login.js.map +1 -1
  73. package/dist/commands/login.test.js +55 -5
  74. package/dist/commands/login.test.js.map +1 -1
  75. package/dist/commands/pull.d.ts.map +1 -1
  76. package/dist/commands/pull.js +2 -1
  77. package/dist/commands/pull.js.map +1 -1
  78. package/dist/commands/request.d.ts +25 -0
  79. package/dist/commands/request.d.ts.map +1 -0
  80. package/dist/commands/request.js +157 -0
  81. package/dist/commands/request.js.map +1 -0
  82. package/dist/commands/request.test.d.ts +2 -0
  83. package/dist/commands/request.test.d.ts.map +1 -0
  84. package/dist/commands/request.test.js +177 -0
  85. package/dist/commands/request.test.js.map +1 -0
  86. package/dist/commands/run-redact.test.d.ts +2 -0
  87. package/dist/commands/run-redact.test.d.ts.map +1 -0
  88. package/dist/commands/run-redact.test.js +520 -0
  89. package/dist/commands/run-redact.test.js.map +1 -0
  90. package/dist/commands/run.d.ts +7 -1
  91. package/dist/commands/run.d.ts.map +1 -1
  92. package/dist/commands/run.js +167 -32
  93. package/dist/commands/run.js.map +1 -1
  94. package/dist/commands/run.test.js +227 -2
  95. package/dist/commands/run.test.js.map +1 -1
  96. package/dist/commands/scan.d.ts +9 -0
  97. package/dist/commands/scan.d.ts.map +1 -0
  98. package/dist/commands/scan.js +324 -0
  99. package/dist/commands/scan.js.map +1 -0
  100. package/dist/commands/scan.test.d.ts +2 -0
  101. package/dist/commands/scan.test.d.ts.map +1 -0
  102. package/dist/commands/scan.test.js +334 -0
  103. package/dist/commands/scan.test.js.map +1 -0
  104. package/dist/commands/token.d.ts.map +1 -1
  105. package/dist/commands/token.js +28 -11
  106. package/dist/commands/token.js.map +1 -1
  107. package/dist/commands/token.test.js +41 -7
  108. package/dist/commands/token.test.js.map +1 -1
  109. package/dist/commands/whoami.d.ts.map +1 -1
  110. package/dist/commands/whoami.js +8 -1
  111. package/dist/commands/whoami.js.map +1 -1
  112. package/dist/commands/whoami.test.js +16 -0
  113. package/dist/commands/whoami.test.js.map +1 -1
  114. package/dist/config-token.test.d.ts +2 -0
  115. package/dist/config-token.test.d.ts.map +1 -0
  116. package/dist/config-token.test.js +134 -0
  117. package/dist/config-token.test.js.map +1 -0
  118. package/dist/config.d.ts +16 -0
  119. package/dist/config.d.ts.map +1 -1
  120. package/dist/config.js +65 -3
  121. package/dist/config.js.map +1 -1
  122. package/dist/entry.d.ts +3 -0
  123. package/dist/entry.d.ts.map +1 -0
  124. package/dist/entry.js +15 -0
  125. package/dist/entry.js.map +1 -0
  126. package/dist/i18n.d.ts.map +1 -1
  127. package/dist/i18n.js +4 -16
  128. package/dist/i18n.js.map +1 -1
  129. package/dist/index.js +6 -0
  130. package/dist/index.js.map +1 -1
  131. package/dist/lib/agent-mode.d.ts +16 -0
  132. package/dist/lib/agent-mode.d.ts.map +1 -0
  133. package/dist/lib/agent-mode.js +24 -0
  134. package/dist/lib/agent-mode.js.map +1 -0
  135. package/dist/lib/agent-mode.test.d.ts +2 -0
  136. package/dist/lib/agent-mode.test.d.ts.map +1 -0
  137. package/dist/lib/agent-mode.test.js +35 -0
  138. package/dist/lib/agent-mode.test.js.map +1 -0
  139. package/dist/lib/agent-sessions.d.ts +37 -0
  140. package/dist/lib/agent-sessions.d.ts.map +1 -0
  141. package/dist/lib/agent-sessions.js +64 -0
  142. package/dist/lib/agent-sessions.js.map +1 -0
  143. package/dist/lib/allow-file.d.ts +21 -0
  144. package/dist/lib/allow-file.d.ts.map +1 -0
  145. package/dist/lib/allow-file.js +63 -0
  146. package/dist/lib/allow-file.js.map +1 -0
  147. package/dist/lib/allow-file.test.d.ts +2 -0
  148. package/dist/lib/allow-file.test.d.ts.map +1 -0
  149. package/dist/lib/allow-file.test.js +58 -0
  150. package/dist/lib/allow-file.test.js.map +1 -0
  151. package/dist/lib/command-spawn.d.ts +35 -0
  152. package/dist/lib/command-spawn.d.ts.map +1 -0
  153. package/dist/lib/command-spawn.js +67 -0
  154. package/dist/lib/command-spawn.js.map +1 -0
  155. package/dist/lib/command-spawn.process.test.d.ts +2 -0
  156. package/dist/lib/command-spawn.process.test.d.ts.map +1 -0
  157. package/dist/lib/command-spawn.process.test.js +43 -0
  158. package/dist/lib/command-spawn.process.test.js.map +1 -0
  159. package/dist/lib/command-spawn.test.d.ts +2 -0
  160. package/dist/lib/command-spawn.test.d.ts.map +1 -0
  161. package/dist/lib/command-spawn.test.js +80 -0
  162. package/dist/lib/command-spawn.test.js.map +1 -0
  163. package/dist/lib/duration.d.ts +3 -0
  164. package/dist/lib/duration.d.ts.map +1 -0
  165. package/dist/lib/duration.js +10 -0
  166. package/dist/lib/duration.js.map +1 -0
  167. package/dist/lib/duration.test.d.ts +2 -0
  168. package/dist/lib/duration.test.d.ts.map +1 -0
  169. package/dist/lib/duration.test.js +17 -0
  170. package/dist/lib/duration.test.js.map +1 -0
  171. package/dist/lib/env-format.d.ts +3 -0
  172. package/dist/lib/env-format.d.ts.map +1 -0
  173. package/dist/lib/env-format.js +20 -0
  174. package/dist/lib/env-format.js.map +1 -0
  175. package/dist/lib/history-clean.d.ts +42 -0
  176. package/dist/lib/history-clean.d.ts.map +1 -0
  177. package/dist/lib/history-clean.js +507 -0
  178. package/dist/lib/history-clean.js.map +1 -0
  179. package/dist/lib/history-clean.test.d.ts +2 -0
  180. package/dist/lib/history-clean.test.d.ts.map +1 -0
  181. package/dist/lib/history-clean.test.js +451 -0
  182. package/dist/lib/history-clean.test.js.map +1 -0
  183. package/dist/lib/history-scan.d.ts +108 -0
  184. package/dist/lib/history-scan.d.ts.map +1 -0
  185. package/dist/lib/history-scan.js +318 -0
  186. package/dist/lib/history-scan.js.map +1 -0
  187. package/dist/lib/history-scan.test.d.ts +2 -0
  188. package/dist/lib/history-scan.test.d.ts.map +1 -0
  189. package/dist/lib/history-scan.test.js +160 -0
  190. package/dist/lib/history-scan.test.js.map +1 -0
  191. package/dist/lib/keychain.d.ts +28 -0
  192. package/dist/lib/keychain.d.ts.map +1 -0
  193. package/dist/lib/keychain.js +87 -0
  194. package/dist/lib/keychain.js.map +1 -0
  195. package/dist/lib/keychain.test.d.ts +2 -0
  196. package/dist/lib/keychain.test.d.ts.map +1 -0
  197. package/dist/lib/keychain.test.js +128 -0
  198. package/dist/lib/keychain.test.js.map +1 -0
  199. package/dist/lib/locale-env.d.ts +3 -0
  200. package/dist/lib/locale-env.d.ts.map +1 -0
  201. package/dist/lib/locale-env.js +21 -0
  202. package/dist/lib/locale-env.js.map +1 -0
  203. package/dist/lib/oidc.d.ts +22 -0
  204. package/dist/lib/oidc.d.ts.map +1 -0
  205. package/dist/lib/oidc.js +84 -0
  206. package/dist/lib/oidc.js.map +1 -0
  207. package/dist/lib/oidc.test.d.ts +2 -0
  208. package/dist/lib/oidc.test.d.ts.map +1 -0
  209. package/dist/lib/oidc.test.js +107 -0
  210. package/dist/lib/oidc.test.js.map +1 -0
  211. package/dist/lib/redact.d.ts +60 -0
  212. package/dist/lib/redact.d.ts.map +1 -0
  213. package/dist/lib/redact.js +222 -0
  214. package/dist/lib/redact.js.map +1 -0
  215. package/dist/lib/redact.test.d.ts +2 -0
  216. package/dist/lib/redact.test.d.ts.map +1 -0
  217. package/dist/lib/redact.test.js +259 -0
  218. package/dist/lib/redact.test.js.map +1 -0
  219. package/dist/lib/redacted-output.d.ts +35 -0
  220. package/dist/lib/redacted-output.d.ts.map +1 -0
  221. package/dist/lib/redacted-output.js +155 -0
  222. package/dist/lib/redacted-output.js.map +1 -0
  223. package/dist/lib/secret-detector.d.ts +26 -0
  224. package/dist/lib/secret-detector.d.ts.map +1 -0
  225. package/dist/lib/secret-detector.js +332 -0
  226. package/dist/lib/secret-detector.js.map +1 -0
  227. package/dist/lib/secret-detector.test.d.ts +2 -0
  228. package/dist/lib/secret-detector.test.d.ts.map +1 -0
  229. package/dist/lib/secret-detector.test.js +207 -0
  230. package/dist/lib/secret-detector.test.js.map +1 -0
  231. package/dist/lib/shell-parse.d.ts +17 -0
  232. package/dist/lib/shell-parse.d.ts.map +1 -0
  233. package/dist/lib/shell-parse.js +191 -0
  234. package/dist/lib/shell-parse.js.map +1 -0
  235. package/dist/lib/shell-parse.test.d.ts +2 -0
  236. package/dist/lib/shell-parse.test.d.ts.map +1 -0
  237. package/dist/lib/shell-parse.test.js +41 -0
  238. package/dist/lib/shell-parse.test.js.map +1 -0
  239. package/dist/lib/token-input.d.ts +6 -0
  240. package/dist/lib/token-input.d.ts.map +1 -0
  241. package/dist/lib/token-input.js +42 -0
  242. package/dist/lib/token-input.js.map +1 -0
  243. package/dist/lib/token-input.test.d.ts +2 -0
  244. package/dist/lib/token-input.test.d.ts.map +1 -0
  245. package/dist/lib/token-input.test.js +38 -0
  246. package/dist/lib/token-input.test.js.map +1 -0
  247. package/dist/locales/en.json +222 -6
  248. package/dist/locales/es.json +219 -3
  249. package/dist/locales/pt-BR.json +219 -3
  250. package/dist/utils.d.ts +1 -1
  251. package/dist/utils.d.ts.map +1 -1
  252. package/dist/utils.js +5 -24
  253. package/dist/utils.js.map +1 -1
  254. package/dist/utils.test.js +14 -0
  255. package/dist/utils.test.js.map +1 -1
  256. package/package.json +7 -3
  257. package/dist/bin/envshed-linux-x64 +0 -4
  258. package/dist/bundle.cjs +0 -48909
@@ -0,0 +1,271 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { parseAllowFile } from "../lib/allow-file.js";
3
+ import { evaluateToolUse, isEnvFileName } from "./guard.js";
4
+ const none = parseAllowFile("");
5
+ const bash = (command, allow = none) => evaluateToolUse("Bash", { command }, allow);
6
+ describe("PreToolUse guard: envshed commands", () => {
7
+ it.each([
8
+ ["envshed secret get API_KEY", "secret-get"],
9
+ ["envshed secret get API_KEY -e prod --output json", "secret-get"],
10
+ ["npx envshed secret get API_KEY", "secret-get"],
11
+ ["npx -y envshed@latest secret get API_KEY", "secret-get"],
12
+ ["pnpm exec envshed secret get API_KEY", "secret-get"],
13
+ ["bin/envshed-dev secret get API_KEY", "secret-get"],
14
+ ["node apps/cli/bin/envshed.js secret get API_KEY", "secret-get"],
15
+ ["envshed --locale es secret get API_KEY", "secret-get"],
16
+ ["cd apps/web && envshed secret get API_KEY", "secret-get"],
17
+ ["FOO=1 envshed secret get API_KEY", "secret-get"],
18
+ ["sudo envshed secret get API_KEY", "secret-get"],
19
+ ["bash -c 'envshed secret get API_KEY'", "secret-get"],
20
+ ["echo $(envshed secret get API_KEY)", "secret-get"],
21
+ ['echo "$(envshed secret get API_KEY)"', "secret-get"],
22
+ ["envshed pull --stdout", "pull-stdout"],
23
+ ["envshed pull -e prod --stdout --format json", "pull-stdout"],
24
+ ["envshed diff dev prod --show-values", "diff-show-values"],
25
+ ["envshed share open https://example.com/s/abc", "share-open"],
26
+ ])("blocks %s", (command, rule) => {
27
+ expect(bash(command)).toBe(rule);
28
+ });
29
+ it.each([
30
+ "envshed pull",
31
+ "envshed pull -e dev --force",
32
+ "envshed push",
33
+ "envshed diff dev prod",
34
+ "envshed share open https://example.com/s/abc --file ./out.env",
35
+ "envshed secret set API_KEY",
36
+ "envshed secret delete API_KEY -y",
37
+ 'envshed request GITHUB_PAT --reason "configure runner" --no-wait',
38
+ "envshed whoami",
39
+ "envshed token show",
40
+ 'git commit -m "docs: never run envshed secret get"',
41
+ 'echo "envshed pull --stdout is blocked"',
42
+ ])("allows %s", (command) => {
43
+ expect(bash(command)).toBeNull();
44
+ });
45
+ });
46
+ describe("PreToolUse guard: envshed run", () => {
47
+ it.each([
48
+ "envshed run -- printenv",
49
+ "envshed run -- printenv API_KEY",
50
+ "envshed run -- env",
51
+ "envshed run -e prod -- env",
52
+ "envshed run --watch --interval 5 -- env",
53
+ "envshed run -- env FOO=1",
54
+ "envshed run printenv",
55
+ "npx envshed run -- printenv",
56
+ "envshed run -- sh -c 'printenv'",
57
+ "envshed run -- bash -lc 'env'",
58
+ "envshed run -- sh -c 'echo $API_KEY'",
59
+ "envshed run -- sh -c 'set'",
60
+ "envshed run -- sh -c 'export'",
61
+ "envshed run -- sh -c 'export -p'",
62
+ "envshed run -- bash -c 'declare -x'",
63
+ "envshed run -- sudo printenv",
64
+ `envshed run -- node -p "process.env"`,
65
+ `envshed run -- node -e "console.log(process.env.API_KEY)"`,
66
+ `envshed run -- python3 -c "import os; print(os.environ)"`,
67
+ `envshed run -- ruby -e "puts ENV.to_h"`,
68
+ "envshed run -- npm run env",
69
+ "envshed run -- cat /proc/self/environ",
70
+ // A single argument is a shell line.
71
+ "envshed run -- 'echo $API_KEY'",
72
+ `envshed run -- "printenv"`,
73
+ "envshed run -- 'env | grep KEY'",
74
+ `envshed run -- 'node -e "console.log(process.env)"'`,
75
+ "envshed run -- 'export -p'",
76
+ "envshed run -- 'npm test && printenv'",
77
+ ])("blocks %s", (command) => {
78
+ expect(bash(command)).toBe("run-dump-env");
79
+ });
80
+ it("blocks a nested read inside run", () => {
81
+ expect(bash("envshed run -- cat .env")).toBe("env-file");
82
+ expect(bash("envshed run -- envshed secret get X")).toBe("secret-get");
83
+ });
84
+ it.each([
85
+ "envshed run -- npm test",
86
+ "envshed run -e development -- npm test",
87
+ "envshed run -e prod -- pnpm build",
88
+ "envshed run -- node server.js",
89
+ "envshed run -- 'npm test && npm run build'",
90
+ "envshed run -- node --env-file=.env server.js",
91
+ "envshed run -- sh -c 'set -e; npm test'",
92
+ "envshed run -- sh -c 'export FOO=1; npm test'",
93
+ "envshed run -- sh -c 'echo starting && npm test'",
94
+ "envshed run -- sh -c 'echo $HOME'",
95
+ `envshed run -- node -e "startServer(process.env.PORT)"`,
96
+ "envshed run -- env FOO=1 npm test",
97
+ "envshed run -- docker compose up",
98
+ ])("allows %s", (command) => {
99
+ expect(bash(command)).toBeNull();
100
+ });
101
+ it("does not block printing the environment outside envshed run", () => {
102
+ expect(bash("printenv PATH")).toBeNull();
103
+ expect(bash("env")).toBeNull();
104
+ expect(bash("echo $HOME")).toBeNull();
105
+ });
106
+ });
107
+ describe("PreToolUse guard: .env files in shell commands", () => {
108
+ it.each([
109
+ "cat .env",
110
+ "cat ./.env",
111
+ "cat apps/web/.env.local",
112
+ 'cat "$HOME/project/.env"',
113
+ "cat .env.production",
114
+ "cat .e'n'v",
115
+ "cat .e\\nv",
116
+ "head -n 5 .env",
117
+ "tail -f .env",
118
+ "less .env",
119
+ "bat .env",
120
+ "grep API_KEY .env",
121
+ "grep -n API_KEY .env.local",
122
+ "grep -e API_KEY .env",
123
+ "rg API_KEY .env",
124
+ "grep -r TOKEN --include=.env .",
125
+ "rg TOKEN -g '.env*'",
126
+ "sed -n 1,5p .env",
127
+ "sed 's/a/b/' .env",
128
+ "awk -F= '{print $1}' .env",
129
+ "source .env",
130
+ ". .env",
131
+ "source .env && npm test",
132
+ "export $(cat .env | xargs)",
133
+ "set -a; . ./.env; set +a",
134
+ "cat .env*",
135
+ "cat .env.*",
136
+ "cat prod.env",
137
+ "cat .envrc",
138
+ "base64 .env",
139
+ "xxd .env",
140
+ "sort .env",
141
+ "cut -d= -f2 .env",
142
+ "diff .env .env.example",
143
+ "grep x < .env",
144
+ "while read l; do echo $l; done < .env",
145
+ "echo $(cat .env)",
146
+ 'echo "$(cat .env)"',
147
+ "bash -c 'cat .env'",
148
+ "sudo cat .env",
149
+ "xargs cat .env",
150
+ "find . -name .env -exec cat {} +",
151
+ "find . -name '.env*' -exec grep KEY {} \\;",
152
+ "git show HEAD:.env",
153
+ "git diff .env",
154
+ "dd if=.env",
155
+ `python3 -c "print(open('.env').read())"`,
156
+ `node -e "console.log(require('fs').readFileSync('.env','utf8'))"`,
157
+ "Get-Content .env",
158
+ "cd apps/web; cat .env",
159
+ ])("blocks %s", (command) => {
160
+ expect(bash(command)).toBe("env-file");
161
+ });
162
+ it.each([
163
+ "cat .env.example",
164
+ "cat apps/web/.env.example",
165
+ "cat .env.sample",
166
+ "cat .env.template",
167
+ "cat .env.local.example",
168
+ "cat .envshed.json",
169
+ "cat .envshed-allow",
170
+ "cat README.md",
171
+ "grep -r process.env src",
172
+ 'grep -rn "process.env" apps/web',
173
+ 'grep ".env" README.md',
174
+ "grep -e .env README.md",
175
+ "rg '\\.env' docs",
176
+ "grep -r TOKEN --exclude=.env .",
177
+ "grep -r TOKEN --exclude .env .",
178
+ "rg TOKEN -g '!.env'",
179
+ "sed 's/.env/.env.local/' README.md",
180
+ "cp .env.example .env",
181
+ "touch .env",
182
+ "ls -la .env",
183
+ "test -f .env",
184
+ "[ -f .env ] && echo yes",
185
+ "echo FOO=1 >> .env",
186
+ "echo .env >> .gitignore",
187
+ "rm .env",
188
+ "chmod 600 .env",
189
+ "find . -name .env",
190
+ "git status .env",
191
+ "git add .env.example",
192
+ "git check-ignore .env",
193
+ "docker compose --env-file .env up",
194
+ "source .venv/bin/activate",
195
+ "source .env/bin/activate",
196
+ "cat > notes.md <<EOF\ncat .env\nEOF",
197
+ 'git commit -m "stop running cat .env"',
198
+ 'echo "do not run cat .env"',
199
+ "# cat .env",
200
+ "npm test",
201
+ ])("allows %s", (command) => {
202
+ expect(bash(command)).toBeNull();
203
+ });
204
+ it("blocks the CLI config file, which holds the token", () => {
205
+ expect(bash("cat ~/.envshed/config.json")).toBe("cli-config");
206
+ expect(evaluateToolUse("Read", { file_path: "/Users/a/.envshed/config.json" }, none)).toBe("cli-config");
207
+ expect(bash("cat .envshed.json")).toBeNull();
208
+ });
209
+ it.each([
210
+ "cat ~/.envshed/sessions.json",
211
+ "security find-generic-password -s envshed -a cli-token -w",
212
+ "security dump-keychain -d",
213
+ "secret-tool lookup service envshed account cli-token",
214
+ "sudo security find-generic-password -s envshed -w",
215
+ ])("blocks reading the CLI's stored tokens with %s", (command) => {
216
+ expect(bash(command)).toBe("cli-config");
217
+ });
218
+ it("blocks the session file through the Read tool and leaves other keychain items alone", () => {
219
+ expect(evaluateToolUse("Read", { file_path: "/Users/a/.envshed/sessions.json" }, none)).toBe("cli-config");
220
+ expect(bash("security find-generic-password -s other-app -w")).toBeNull();
221
+ expect(bash("secret-tool lookup service other-app")).toBeNull();
222
+ expect(bash("security list-keychains")).toBeNull();
223
+ });
224
+ it("reads jq and yq arguments as a filter and then files", () => {
225
+ expect(bash("jq . .env")).toBe("env-file");
226
+ expect(bash("jq . package.json")).toBeNull();
227
+ expect(bash("jq .env package.json")).toBeNull();
228
+ });
229
+ it("honors path: patterns from the allow file, but never for the token file", () => {
230
+ const allow = parseAllowFile("path:fixtures/.env*\npath:.env.ci\npath:config.json\n");
231
+ expect(bash("cat fixtures/.env.test", allow)).toBeNull();
232
+ expect(bash("cat .env.ci", allow)).toBeNull();
233
+ expect(bash("cat .env", allow)).toBe("env-file");
234
+ expect(bash("cat ~/.envshed/config.json", allow)).toBe("cli-config");
235
+ });
236
+ });
237
+ describe("PreToolUse guard: file tools", () => {
238
+ it("blocks Read of .env files and not .env.example", () => {
239
+ expect(evaluateToolUse("Read", { file_path: "/repo/.env" }, none)).toBe("env-file");
240
+ expect(evaluateToolUse("Read", { file_path: "/repo/apps/web/.env.local" }, none)).toBe("env-file");
241
+ expect(evaluateToolUse("Read", { file_path: "/repo/.env.example" }, none)).toBeNull();
242
+ expect(evaluateToolUse("Read", { file_path: "/repo/src/env.ts" }, none)).toBeNull();
243
+ expect(evaluateToolUse("Read", { file_path: "/repo/.env/bin/activate" }, none)).toBeNull();
244
+ });
245
+ it("blocks Grep aimed at .env files", () => {
246
+ expect(evaluateToolUse("Grep", { pattern: "KEY", path: ".env" }, none)).toBe("env-file");
247
+ expect(evaluateToolUse("Grep", { pattern: "KEY", glob: ".env*" }, none)).toBe("env-file");
248
+ expect(evaluateToolUse("Grep", { pattern: ".env", path: "src" }, none)).toBeNull();
249
+ expect(evaluateToolUse("Grep", { pattern: "KEY", glob: "!.env" }, none)).toBeNull();
250
+ });
251
+ it("covers PowerShell and Monitor commands", () => {
252
+ expect(evaluateToolUse("PowerShell", { command: "Get-Content .env" }, none)).toBe("env-file");
253
+ expect(evaluateToolUse("Monitor", { command: "tail -f .env" }, none)).toBe("env-file");
254
+ });
255
+ it("passes unknown tools and malformed input", () => {
256
+ expect(evaluateToolUse("Write", { file_path: ".env", content: "x" }, none)).toBeNull();
257
+ expect(evaluateToolUse("Glob", { pattern: ".env*" }, none)).toBeNull();
258
+ expect(evaluateToolUse("Bash", null, none)).toBeNull();
259
+ expect(evaluateToolUse("Bash", { command: 7 }, none)).toBeNull();
260
+ expect(evaluateToolUse("Read", {}, none)).toBeNull();
261
+ });
262
+ });
263
+ describe("isEnvFileName", () => {
264
+ it.each([".env", ".env.local", ".env.production", ".env-prod", ".envrc", "prod.env", ".env*", ".env.*"])("%s is one", (name) => {
265
+ expect(isEnvFileName(name)).toBe(true);
266
+ });
267
+ it.each([".env.example", ".env.sample", ".env.template", ".env.dist", "example.env", ".envshed.json", ".envshed-allow", "env.ts", "process.env", "import.meta.env"])("%s is not", (name) => {
268
+ expect(isEnvFileName(name)).toBe(false);
269
+ });
270
+ });
271
+ //# sourceMappingURL=guard.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.test.js","sourceRoot":"","sources":["../../src/agent/guard.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,IAAI,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;AAChC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;AAE5F,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,IAAI,CAAC;QACN,CAAC,4BAA4B,EAAE,YAAY,CAAC;QAC5C,CAAC,kDAAkD,EAAE,YAAY,CAAC;QAClE,CAAC,gCAAgC,EAAE,YAAY,CAAC;QAChD,CAAC,0CAA0C,EAAE,YAAY,CAAC;QAC1D,CAAC,sCAAsC,EAAE,YAAY,CAAC;QACtD,CAAC,oCAAoC,EAAE,YAAY,CAAC;QACpD,CAAC,iDAAiD,EAAE,YAAY,CAAC;QACjE,CAAC,wCAAwC,EAAE,YAAY,CAAC;QACxD,CAAC,2CAA2C,EAAE,YAAY,CAAC;QAC3D,CAAC,kCAAkC,EAAE,YAAY,CAAC;QAClD,CAAC,iCAAiC,EAAE,YAAY,CA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7H,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC,CAClK,WAAW,EACX,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Entry point of `envshed agent hook <event>`. Any failure must not lock the user
3
+ * out of their agent, so it ends in exit 1 with one line on stderr: Claude Code
4
+ * treats that as a non-blocking error and shows the line. The error itself is
5
+ * never printed, because a JSON parse error can quote the prompt it failed on.
6
+ */
7
+ export declare function runHookCli(eventName: string | undefined): Promise<void>;
8
+ //# sourceMappingURL=hook-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-main.d.ts","sourceRoot":"","sources":["../../src/agent/hook-main.ts"],"names":[],"mappings":"AA2BA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7E"}
@@ -0,0 +1,45 @@
1
+ import { handleClaudeCodeHook } from "./claude-code-hook.js";
2
+ import { createHookTranslator } from "./hook-messages.js";
3
+ const STDIN_TIMEOUT_MS = 5_000;
4
+ function readStdin() {
5
+ return new Promise((resolve, reject) => {
6
+ const chunks = [];
7
+ const timer = setTimeout(() => reject(new Error("stdin timeout")), STDIN_TIMEOUT_MS);
8
+ timer.unref();
9
+ process.stdin.on("data", (chunk) => chunks.push(chunk));
10
+ process.stdin.on("end", () => {
11
+ clearTimeout(timer);
12
+ resolve(Buffer.concat(chunks).toString("utf-8"));
13
+ });
14
+ process.stdin.on("error", reject);
15
+ });
16
+ }
17
+ function failOpenNote() {
18
+ try {
19
+ return createHookTranslator()("failOpen");
20
+ }
21
+ catch {
22
+ return "envshed: agent hook failed; this action was not checked.";
23
+ }
24
+ }
25
+ /**
26
+ * Entry point of `envshed agent hook <event>`. Any failure must not lock the user
27
+ * out of their agent, so it ends in exit 1 with one line on stderr: Claude Code
28
+ * treats that as a non-blocking error and shows the line. The error itself is
29
+ * never printed, because a JSON parse error can quote the prompt it failed on.
30
+ */
31
+ export async function runHookCli(eventName) {
32
+ try {
33
+ const output = handleClaudeCodeHook(eventName, await readStdin());
34
+ if (output)
35
+ process.stdout.write(output);
36
+ process.exitCode = 0;
37
+ }
38
+ catch {
39
+ process.stderr.write(`${failOpenNote()}\n`);
40
+ process.exitCode = 1;
41
+ }
42
+ // A stdin that never closes would otherwise keep the process alive.
43
+ process.stdin.destroy();
44
+ }
45
+ //# sourceMappingURL=hook-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-main.js","sourceRoot":"","sources":["../../src/agent/hook-main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,SAAS,SAAS;IAChB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACrF,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAC3B,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,OAAO,oBAAoB,EAAE,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,0DAA0D,CAAC;IACpE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAA6B;IAC5D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,EAAE,MAAM,SAAS,EAAE,CAAC,CAAC;QAClE,IAAI,MAAM;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,CAAC;QAC5C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,oEAAoE;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Translations for the hook path. It skips i18n.ts on purpose: that module reads
3
+ * ~/.envshed/config.json, which holds the token, and hooks must not touch it.
4
+ * The locale therefore comes from LC_ALL or LANG only.
5
+ */
6
+ export declare function createHookTranslator(env?: NodeJS.ProcessEnv): (key: string, values?: Record<string, string>) => string;
7
+ //# sourceMappingURL=hook-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-messages.d.ts","sourceRoot":"","sources":["../../src/agent/hook-messages.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,IAI/D,KAAK,MAAM,EAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,YAEzD"}
@@ -0,0 +1,18 @@
1
+ import fs from "node:fs";
2
+ import { localeFromEnv } from "../lib/locale-env.js";
3
+ function loadMessages(locale) {
4
+ const url = new URL(`../locales/${locale}.json`, import.meta.url);
5
+ return JSON.parse(fs.readFileSync(url, "utf-8")).agentHook ?? {};
6
+ }
7
+ /**
8
+ * Translations for the hook path. It skips i18n.ts on purpose: that module reads
9
+ * ~/.envshed/config.json, which holds the token, and hooks must not touch it.
10
+ * The locale therefore comes from LC_ALL or LANG only.
11
+ */
12
+ export function createHookTranslator(env = process.env) {
13
+ const locale = localeFromEnv(env) ?? "en";
14
+ const english = loadMessages("en");
15
+ const messages = locale === "en" ? english : { ...english, ...loadMessages(locale) };
16
+ return (key, values = {}) => (messages[key] ?? key).replace(/\{\{(\w+)\}\}/g, (_, name) => values[name] ?? "");
17
+ }
18
+ //# sourceMappingURL=hook-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-messages.js","sourceRoot":"","sources":["../../src/agent/hook-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,MAAM,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IAC1C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IACrF,OAAO,CAAC,GAAW,EAAE,SAAiC,EAAE,EAAE,EAAE,CAC1D,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { AgentAdapter } from "./types.js";
2
+ export declare const DEFAULT_AGENT: string;
3
+ export declare const agentIds: () => string[];
4
+ export declare const findAgent: (id: string) => AgentAdapter | undefined;
5
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/agent/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,eAAO,MAAM,aAAa,QAAuB,CAAC;AAClD,eAAO,MAAM,QAAQ,gBAA8C,CAAC;AACpE,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,6BAAkD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { claudeCodeAdapter } from "./claude-code.js";
2
+ const ADAPTERS = [claudeCodeAdapter];
3
+ export const DEFAULT_AGENT = claudeCodeAdapter.id;
4
+ export const agentIds = () => ADAPTERS.map((adapter) => adapter.id);
5
+ export const findAgent = (id) => ADAPTERS.find((adapter) => adapter.id === id);
6
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/agent/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,QAAQ,GAAmB,CAAC,iBAAiB,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,EAAE,CAAC;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Lives apart from the general `envshed` skill, so installing never overwrites it. */
2
+ export declare const SKILL_NAME = "envshed-agent-safety";
3
+ /** Files without this marker are not ours: install and uninstall leave them alone. */
4
+ export declare const SKILL_MARKER = "<!-- managed by envshed agent install -->";
5
+ export declare const SKILL_CONTENT = "---\nname: envshed-agent-safety\ndescription: Rules for handling secrets in projects that use Envshed. Use whenever a task needs an API key, password, token or other credential, or touches environment variables or .env files.\n---\n\n<!-- managed by envshed agent install -->\n\n# Handling secrets with Envshed\n\nValues you see end up in the chat history and at the model provider. Work so that you never see them.\n\n## Rules\n\n- Never ask anyone to paste a secret into the chat. If one is missing, ask for it through Envshed, so a person enters the value in the dashboard.\n- Never print a secret value, and never put one in a command line, a tool argument, a file, a commit or your reply.\n- To use secrets at runtime, inject them: `envshed run -- <command>` in a shell, or the `@envshed/node` SDK inside your own tool, so the model sees only the result.\n- If a value reached the chat, tell the user at once. It needs rotating, which is their step.\n- A block or a refusal is not an obstacle to work around. Do what the message says, and if it looks wrong, tell the user.\n- Do not run `envshed secret get`, `envshed pull --stdout`, `envshed diff --show-values` or `envshed share open` without `--file`.\n- Do not read `.env` files or anything under `~/.envshed/`. `.env.example` is fine.\n- Do not run `envshed run -- printenv`, `envshed run -- env` or anything else that prints the injected environment.\n\n## Using a secret\n\nRun the program with the secrets injected. It gets the values and you do not:\n\n```bash\nenvshed run -e development -- npm test\n```\n\n## When a secret is missing\n\nAsk for it. If the key already exists, the command says so and changes nothing. Otherwise a person fills it in the dashboard, and the value never passes through this session:\n\n```bash\nenvshed request GITHUB_PAT --reason \"configure the runner\" -e development --no-wait\n```\n\nShell tools limit how long a command can run, so do not sit in a long wait:\n\n1. Run it with `--no-wait`, or in the background, so the tool does not time out.\n2. Tell the user who can fill it and give them the printed link.\n3. Run the same command again to check. An open request is reused, not duplicated.\n\nExit codes: `0` ready, `2` still pending, `3` declined, `4` timed out, `5` unusable, `1` error. Add `--output json` to read the status from a script. Do not retry after a decline: talk to the user.\n\n## When a secret may have leaked\n\nIf a value reached this chat, tell the user at once. It needs rotating, which is their step. `envshed scan` reports which keys appear in agent histories, by name only, and marks them as exposed. Do not run `envshed scan --clean` or `--undo` unless the user asks.\n\n## When a hook blocks you\n\nEnvshed hooks may stop a command or a prompt. Do not look for another way to reach the value. Do what the message says, usually `envshed run` or `envshed request`. If the block looks wrong, tell the user: exceptions in `.envshed-allow` are their decision, and that file holds patterns, never values.\n\nThese hooks prevent accidents. They are not a security boundary, and working around them is still a leak.\n";
6
+ //# sourceMappingURL=skill-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content.d.ts","sourceRoot":"","sources":["../../src/agent/skill-content.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,UAAU,yBAAyB,CAAC;AAEjD,sFAAsF;AACtF,eAAO,MAAM,YAAY,8CAA8C,CAAC;AAGxE,eAAO,MAAM,aAAa,ykGAuDzB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /** Lives apart from the general `envshed` skill, so installing never overwrites it. */
2
+ export const SKILL_NAME = "envshed-agent-safety";
3
+ /** Files without this marker are not ours: install and uninstall leave them alone. */
4
+ export const SKILL_MARKER = "<!-- managed by envshed agent install -->";
5
+ // Instructions for the agent itself, so they stay in English and are not translated.
6
+ export const SKILL_CONTENT = `---
7
+ name: ${SKILL_NAME}
8
+ description: Rules for handling secrets in projects that use Envshed. Use whenever a task needs an API key, password, token or other credential, or touches environment variables or .env files.
9
+ ---
10
+
11
+ ${SKILL_MARKER}
12
+
13
+ # Handling secrets with Envshed
14
+
15
+ Values you see end up in the chat history and at the model provider. Work so that you never see them.
16
+
17
+ ## Rules
18
+
19
+ - Never ask anyone to paste a secret into the chat. If one is missing, ask for it through Envshed, so a person enters the value in the dashboard.
20
+ - Never print a secret value, and never put one in a command line, a tool argument, a file, a commit or your reply.
21
+ - To use secrets at runtime, inject them: \`envshed run -- <command>\` in a shell, or the \`@envshed/node\` SDK inside your own tool, so the model sees only the result.
22
+ - If a value reached the chat, tell the user at once. It needs rotating, which is their step.
23
+ - A block or a refusal is not an obstacle to work around. Do what the message says, and if it looks wrong, tell the user.
24
+ - Do not run \`envshed secret get\`, \`envshed pull --stdout\`, \`envshed diff --show-values\` or \`envshed share open\` without \`--file\`.
25
+ - Do not read \`.env\` files or anything under \`~/.envshed/\`. \`.env.example\` is fine.
26
+ - Do not run \`envshed run -- printenv\`, \`envshed run -- env\` or anything else that prints the injected environment.
27
+
28
+ ## Using a secret
29
+
30
+ Run the program with the secrets injected. It gets the values and you do not:
31
+
32
+ \`\`\`bash
33
+ envshed run -e development -- npm test
34
+ \`\`\`
35
+
36
+ ## When a secret is missing
37
+
38
+ Ask for it. If the key already exists, the command says so and changes nothing. Otherwise a person fills it in the dashboard, and the value never passes through this session:
39
+
40
+ \`\`\`bash
41
+ envshed request GITHUB_PAT --reason "configure the runner" -e development --no-wait
42
+ \`\`\`
43
+
44
+ Shell tools limit how long a command can run, so do not sit in a long wait:
45
+
46
+ 1. Run it with \`--no-wait\`, or in the background, so the tool does not time out.
47
+ 2. Tell the user who can fill it and give them the printed link.
48
+ 3. Run the same command again to check. An open request is reused, not duplicated.
49
+
50
+ Exit codes: \`0\` ready, \`2\` still pending, \`3\` declined, \`4\` timed out, \`5\` unusable, \`1\` error. Add \`--output json\` to read the status from a script. Do not retry after a decline: talk to the user.
51
+
52
+ ## When a secret may have leaked
53
+
54
+ If a value reached this chat, tell the user at once. It needs rotating, which is their step. \`envshed scan\` reports which keys appear in agent histories, by name only, and marks them as exposed. Do not run \`envshed scan --clean\` or \`--undo\` unless the user asks.
55
+
56
+ ## When a hook blocks you
57
+
58
+ Envshed hooks may stop a command or a prompt. Do not look for another way to reach the value. Do what the message says, usually \`envshed run\` or \`envshed request\`. If the block looks wrong, tell the user: exceptions in \`.envshed-allow\` are their decision, and that file holds patterns, never values.
59
+
60
+ These hooks prevent accidents. They are not a security boundary, and working around them is still a leak.
61
+ `;
62
+ //# sourceMappingURL=skill-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content.js","sourceRoot":"","sources":["../../src/agent/skill-content.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAEjD,sFAAsF;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG,2CAA2C,CAAC;AAExE,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GAAG;QACrB,UAAU;;;;EAIhB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=skill-content.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content.test.d.ts","sourceRoot":"","sources":["../../src/agent/skill-content.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { describe, expect, it } from "vitest";
3
+ import { SKILL_CONTENT } from "./skill-content.js";
4
+ // The CLI does not depend on @envshed/shared, so this reads the source of the rules.
5
+ const source = readFileSync(new URL("../../../../packages/shared/src/agent-guidance.ts", import.meta.url), "utf-8");
6
+ const rules = [...source.matchAll(/^ {2}"(.+)",$/gm)].map((match) => match[1]);
7
+ describe("skill content", () => {
8
+ it("finds the shared rules", () => {
9
+ expect(rules.length).toBeGreaterThan(0);
10
+ });
11
+ it.each(rules)("carries the shared rule: %s", (rule) => {
12
+ expect(SKILL_CONTENT).toContain(`- ${rule}`);
13
+ });
14
+ });
15
+ //# sourceMappingURL=skill-content.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content.test.js","sourceRoot":"","sources":["../../src/agent/skill-content.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qFAAqF;AACrF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,mDAAmD,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACpH,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,6BAA6B,EAAE,CAAC,IAAI,EAAE,EAAE;QACrD,MAAM,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ export type AgentScope = "user" | "project";
2
+ export type ChangeStatus = "added" | "updated" | "unchanged" | "removed" | "absent" | "skipped-foreign";
3
+ export interface AgentContext {
4
+ scope: AgentScope;
5
+ /** Directory the project scope resolves against. */
6
+ cwd: string;
7
+ home: string;
8
+ env: NodeJS.ProcessEnv;
9
+ /** How hooks call this CLI, for example `envshed`. */
10
+ cliCommand: string;
11
+ }
12
+ export interface InstallReport {
13
+ settingsPath: string;
14
+ skillPath: string;
15
+ hooks: Array<{
16
+ event: string;
17
+ status: ChangeStatus;
18
+ }>;
19
+ skill: ChangeStatus;
20
+ }
21
+ /** One coding agent. Add a module implementing this and register it in `registry.ts`. */
22
+ export interface AgentAdapter {
23
+ id: string;
24
+ displayName: string;
25
+ install(context: AgentContext): InstallReport;
26
+ uninstall(context: AgentContext): InstallReport;
27
+ /** Where this agent keeps its local history, for `envshed scan`. */
28
+ historyRoots(context: Pick<AgentContext, "home" | "env">): string[];
29
+ }
30
+ /** The agent's settings file cannot be merged safely. It was left untouched. */
31
+ export declare class AgentSettingsError extends Error {
32
+ readonly settingsPath: string;
33
+ constructor(settingsPath: string);
34
+ }
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAExG,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;IACtD,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC;IAC9C,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAAC;IAChD,oEAAoE;IACpE,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC;CACrE;AAED,gFAAgF;AAChF,qBAAa,kBAAmB,SAAQ,KAAK;aACf,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAGjD"}
@@ -0,0 +1,9 @@
1
+ /** The agent's settings file cannot be merged safely. It was left untouched. */
2
+ export class AgentSettingsError extends Error {
3
+ settingsPath;
4
+ constructor(settingsPath) {
5
+ super(settingsPath);
6
+ this.settingsPath = settingsPath;
7
+ }
8
+ }
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AA+BA,gFAAgF;AAChF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACf;IAA5B,YAA4B,YAAoB;QAC9C,KAAK,CAAC,YAAY,CAAC,CAAC;QADM,iBAAY,GAAZ,YAAY,CAAQ;IAEhD,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Command } from "commander";
2
+ /** Agents branch on these, so they are part of the command's contract. Same style as `request`. */
3
+ export declare const AGENT_SESSION_EXIT: {
4
+ readonly active: 0;
5
+ readonly error: 1;
6
+ readonly pending: 2;
7
+ readonly declined: 3;
8
+ readonly timeout: 4;
9
+ };
10
+ export declare const agentSessionCommand: Command;
11
+ //# sourceMappingURL=agent-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../src/commands/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,mGAAmG;AACnG,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AA0IX,eAAO,MAAM,mBAAmB,SAiL5B,CAAC"}