wave-agent-sdk 0.12.0 → 0.12.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 (68) hide show
  1. package/README.md +0 -13
  2. package/builtin/skills/settings/ENV.md +4 -0
  3. package/builtin/skills/settings/HOOKS.md +4 -0
  4. package/builtin/skills/settings/MODELS.md +4 -0
  5. package/builtin/skills/settings/SKILL.md +5 -1
  6. package/builtin/skills/settings/SKILLS.md +13 -0
  7. package/dist/agent.d.ts +2 -2
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +3 -2
  10. package/dist/managers/aiManager.d.ts.map +1 -1
  11. package/dist/managers/aiManager.js +0 -4
  12. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  13. package/dist/managers/backgroundTaskManager.js +9 -2
  14. package/dist/managers/cronManager.d.ts.map +1 -1
  15. package/dist/managers/cronManager.js +1 -0
  16. package/dist/managers/permissionManager.d.ts.map +1 -1
  17. package/dist/managers/permissionManager.js +9 -5
  18. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  19. package/dist/managers/slashCommandManager.js +2 -0
  20. package/dist/prompts/index.d.ts +11 -3
  21. package/dist/prompts/index.d.ts.map +1 -1
  22. package/dist/prompts/index.js +97 -11
  23. package/dist/services/configurationService.d.ts +1 -1
  24. package/dist/services/configurationService.d.ts.map +1 -1
  25. package/dist/services/configurationService.js +26 -15
  26. package/dist/services/fileWatcher.d.ts.map +1 -1
  27. package/dist/services/fileWatcher.js +12 -2
  28. package/dist/services/hook.d.ts.map +1 -1
  29. package/dist/services/hook.js +6 -1
  30. package/dist/services/session.d.ts.map +1 -1
  31. package/dist/services/session.js +2 -14
  32. package/dist/tools/bashTool.d.ts.map +1 -1
  33. package/dist/tools/bashTool.js +30 -19
  34. package/dist/tools/webFetchTool.d.ts.map +1 -1
  35. package/dist/tools/webFetchTool.js +1 -1
  36. package/dist/tools/writeTool.d.ts.map +1 -1
  37. package/dist/tools/writeTool.js +6 -0
  38. package/dist/types/core.d.ts +2 -0
  39. package/dist/types/core.d.ts.map +1 -1
  40. package/dist/types/core.js +2 -0
  41. package/dist/utils/bashParser.d.ts +4 -0
  42. package/dist/utils/bashParser.d.ts.map +1 -1
  43. package/dist/utils/bashParser.js +23 -0
  44. package/dist/utils/messageOperations.d.ts +10 -0
  45. package/dist/utils/messageOperations.d.ts.map +1 -1
  46. package/dist/utils/messageOperations.js +51 -0
  47. package/dist/utils/stringUtils.d.ts +4 -0
  48. package/dist/utils/stringUtils.d.ts.map +1 -1
  49. package/dist/utils/stringUtils.js +21 -0
  50. package/package.json +1 -1
  51. package/src/agent.ts +3 -2
  52. package/src/managers/aiManager.ts +0 -6
  53. package/src/managers/backgroundTaskManager.ts +9 -2
  54. package/src/managers/cronManager.ts +1 -0
  55. package/src/managers/permissionManager.ts +9 -4
  56. package/src/managers/slashCommandManager.ts +2 -0
  57. package/src/prompts/index.ts +111 -9
  58. package/src/services/configurationService.ts +34 -20
  59. package/src/services/fileWatcher.ts +13 -2
  60. package/src/services/hook.ts +4 -1
  61. package/src/services/session.ts +2 -21
  62. package/src/tools/bashTool.ts +32 -22
  63. package/src/tools/webFetchTool.ts +3 -2
  64. package/src/tools/writeTool.ts +10 -0
  65. package/src/types/core.ts +4 -0
  66. package/src/utils/bashParser.ts +24 -0
  67. package/src/utils/messageOperations.ts +57 -0
  68. package/src/utils/stringUtils.ts +20 -0
package/README.md CHANGED
@@ -14,19 +14,6 @@ npm install wave-agent-sdk
14
14
 
15
15
  See [examples](./examples) for usage examples.
16
16
 
17
- ## Development
18
-
19
- ```bash
20
- # Install dependencies
21
- pnpm install
22
-
23
- # Build
24
- pnpm build
25
-
26
- # Test
27
- pnpm test
28
- ```
29
-
30
17
  ## License
31
18
 
32
19
  MIT
@@ -57,6 +57,10 @@ Example:
57
57
  }
58
58
  ```
59
59
 
60
+ ## Live Reload
61
+
62
+ Environment variables configured in `settings.json` support **live reload**. When you modify the `env` field in any `settings.json` file (user, project, or local scope), the changes take effect immediately without requiring a Wave session restart.
63
+
60
64
  ## Best Practices
61
65
 
62
66
  - **Use Local Overrides for Secrets**: Never commit sensitive information like `WAVE_API_KEY` to `settings.json`. Use `settings.local.json` instead.
@@ -86,6 +86,10 @@ Hooks can communicate status and control Wave's behavior using exit codes:
86
86
  - `Stop`: Blocks the stop operation and provides `stderr` to the agent.
87
87
  - **Other Exits (e.g., Exit 1)**: Non-blocking error. Wave continues execution but shows `stderr` as a warning to the user.
88
88
 
89
+ ## Live Reload
90
+
91
+ Hook configurations support **live reload**. When you modify hooks in `settings.json`, the changes take effect immediately without restarting Wave.
92
+
89
93
  ## Best Practices
90
94
 
91
95
  - **Keep hooks fast**: Long-running hooks can slow down your workflow unless they are `async`.
@@ -65,3 +65,7 @@ You can also set the default models Wave uses via environment variables in `sett
65
65
  }
66
66
  }
67
67
  ```
68
+
69
+ ## Live Reload
70
+
71
+ Model configurations support **live reload**. When you modify the `models` field or model-related environment variables in `settings.json`, the changes take effect immediately without restarting Wave.
@@ -11,6 +11,10 @@ This skill helps you manage your Wave configuration and provides guidance on how
11
11
 
12
12
  `settings.json` is the central configuration file for Wave. It allows you to customize hooks, environment variables, tool permissions, and more.
13
13
 
14
+ ### Live Reload
15
+
16
+ Changes to `settings.json` take effect immediately without restarting Wave. When you modify any setting, the new configuration is applied to subsequent operations automatically.
17
+
14
18
  Wave looks for `settings.json` in three scopes:
15
19
  1. **User Scope**: Global settings for all projects. Located at `~/.wave/settings.json`.
16
20
  2. **Project Scope**: Settings specific to the current project. Located at `.wave/settings.json` in your project root.
@@ -35,7 +39,7 @@ For detailed environment variable configuration and available `WAVE_*` variables
35
39
  ```
36
40
 
37
41
  ### 3. Permissions
38
- Manage tool permissions and define the "Safe Zone".
42
+ Manage tool permissions and define the "Safe Zone". Changes to permissions take effect immediately with live reload.
39
43
  ```json
40
44
  {
41
45
  "permissions": {
@@ -57,8 +57,21 @@ Project skills take precedence over user skills with the same name.
57
57
  - **AI-Invoked**: The agent automatically discovers and uses skills based on their `description`.
58
58
  - **User-Invoked**: Use slash commands in the CLI (e.g., `/my-skill`).
59
59
 
60
+ ## Inline Bash Commands
61
+
62
+ You can embed bash commands in skill content using the `!`command`` syntax. The command will be executed and its output will be inserted inline.
63
+
64
+ ```markdown
65
+ # Example Skill
66
+
67
+ Current git status: !`git status --short`
68
+
69
+ The above command will be replaced with the actual output when the skill is invoked.
70
+ ```
71
+
60
72
  ## Best Practices
61
73
 
62
74
  - **Clear Descriptions**: Write descriptions that help the AI understand exactly when the skill is relevant.
63
75
  - **Modular Design**: Keep skills focused on a single task or capability.
64
76
  - **Use `${WAVE_SKILL_DIR}`**: Use this placeholder to reference files within the skill directory.
77
+ - **Inline Bash Commands**: Use `!`command`` to execute bash commands and insert their output inline.
package/dist/agent.d.ts CHANGED
@@ -150,8 +150,8 @@ export declare class Agent {
150
150
  */
151
151
  restoreSession(sessionId: string): Promise<void>;
152
152
  abortAIMessage(): void;
153
- /** Execute bash command */
154
- executeBashCommand(command: string): Promise<void>;
153
+ /** Execute bash command (bang command) */
154
+ bang(command: string): Promise<void>;
155
155
  clearMessages(): Promise<void>;
156
156
  /** Unified interrupt method, interrupts both AI messages and command execution */
157
157
  abortMessage(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAElB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,OAAO,EAEP,eAAe,EACf,aAAa,EACb,WAAW,EACX,KAAK,EACL,cAAc,EACd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAc1B,qBAAa,KAAK;IAChB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,SAAS,CAAY;IAE7B,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,qBAAqB,CAAwB;IACrD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,O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,EAAE,OAAO,wBAAwB,EAAE,qBAAqB,GAC9D,OAAO,CAAC,OAAO,wBAAwB,EAAE,kBAAkB,CAAC;IAI/D;;;OAGG;IACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D;;;;OAIG;IACI,mBAAmB,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,+BAA+B,EAAE,gBAAgB,GAAG,IAAI;IAIlE;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;CACF"}
package/dist/agent.js CHANGED
@@ -286,9 +286,10 @@ export class Agent {
286
286
  abortAIMessage() {
287
287
  this.aiManager.abortAIMessage();
288
288
  }
289
- /** Execute bash command */
290
- async executeBashCommand(command) {
289
+ /** Execute bash command (bang command) */
290
+ async bang(command) {
291
291
  await this.bangManager?.executeCommand(command);
292
+ await this.messageManager.saveSession();
292
293
  }
293
294
  async clearMessages() {
294
295
  await this.slashCommandManager.executeCommand("clear");
@@ -1 +1 @@
1
- {"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,MAAM,WAAW,kBAAkB;IACjC,wBAAwB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5D,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IA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.warn("AI response truncated due to length limit. Response headers:", result.response_headers);
367
367
  }
368
368
  }
369
- if (result.response_headers &&
370
- Object.keys(result.response_headers).length > 0) {
371
- logger?.debug("AI response headers:", result.response_headers);
372
- }
373
369
  if (result.additionalFields &&
374
370
  Object.keys(result.additionalFields).length > 0) {
375
371
  this.messageManager.mergeAssistantAdditionalFields(result.additionalFields);
@@ -1 +1 @@
1
- {"version":3,"file":"backgroundTaskManager.d.ts","sourceRoot":"","sources":["../../src/managers/backgroundTaskManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAIzD,OAAO,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAGxE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,WAAW,8BAA8B;IAC7C,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;CAC7D;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAqB;IAO9B,OAAO,CAAC,SAAS;IANnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,OAAO,CAAS;gBAGd,SAAS,EAAE,SAAS,EAC5B,OAAO,EAAE,4BAA4B;IAMvC,OAAO,CAAC,iBAAiB;IAIlB,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAKnC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI/C,WAAW,IAAI,cAAc,EAAE;IAI/B,UAAU,CACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EA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AO,CAAC,iBAAiB;IAIlB,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAKnC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI/C,WAAW,IAAI,cAAc,EAAE;IAI/B,UAAU,CACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE;IA2InD,YAAY,CACjB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,aAAa,GAAE,MAAW,EAC1B,aAAa,GAAE,MAAW,GACzB,MAAM;IAmGF,SAAS,CACd,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,MAAM,GACd;QACD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI;IAoCD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IA+B7B,OAAO,IAAI,IAAI;CAUvB"}
@@ -57,7 +57,7 @@ export class BackgroundTaskManager {
57
57
  logStream.end();
58
58
  if (child.pid) {
59
59
  process.kill(-child.pid, "SIGTERM");
60
- setTimeout(() => {
60
+ const forceKillTimer = setTimeout(() => {
61
61
  if (child.pid && !child.killed) {
62
62
  try {
63
63
  process.kill(-child.pid, "SIGKILL");
@@ -67,6 +67,7 @@ export class BackgroundTaskManager {
67
67
  }
68
68
  }
69
69
  }, 1000);
70
+ forceKillTimer.unref();
70
71
  }
71
72
  else {
72
73
  child.kill("SIGTERM");
@@ -84,6 +85,11 @@ export class BackgroundTaskManager {
84
85
  if (timeout && timeout > 0) {
85
86
  timeoutHandle = setTimeout(() => {
86
87
  if (shell.status === "running") {
88
+ const timeoutMsg = "\n\nCommand timed out";
89
+ shell.stderr += timeoutMsg;
90
+ if (logStream.writable) {
91
+ logStream.write(timeoutMsg);
92
+ }
87
93
  this.stopTask(id);
88
94
  }
89
95
  }, timeout);
@@ -179,7 +185,7 @@ export class BackgroundTaskManager {
179
185
  logStream.end();
180
186
  if (child.pid) {
181
187
  process.kill(-child.pid, "SIGTERM");
182
- setTimeout(() => {
188
+ const forceKillTimer = setTimeout(() => {
183
189
  if (child.pid && !child.killed) {
184
190
  try {
185
191
  process.kill(-child.pid, "SIGKILL");
@@ -189,6 +195,7 @@ export class BackgroundTaskManager {
189
195
  }
190
196
  }
191
197
  }, 1000);
198
+ forceKillTimer.unref();
192
199
  }
193
200
  else {
194
201
  child.kill("SIGTERM");
@@ -1 +1 @@
1
- {"version":3,"file":"cronManager.d.ts","sourceRoot":"","sources":["../../src/managers/cronManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,qBAAa,WAAW;IAIV,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAA+B;gBAE3B,SAAS,EAAE,SAAS;IAExC,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,KAAK,cAAc,GAEzB;IAEM,KAAK,IAAI,IAAI;IAKb,IAAI,IAAI,IAAI;IAOZ,SAAS,CACd,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC,GAC9D,OAAO;IAiCH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B,QAAQ,IAAI,OAAO,EAAE;IAI5B,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,sBAAsB;YAYhB,SAAS;CAuDxB"}
1
+ {"version":3,"file":"cronManager.d.ts","sourceRoot":"","sources":["../../src/managers/cronManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,qBAAa,WAAW;IAIV,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAA+B;gBAE3B,SAAS,EAAE,SAAS;IAExC,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,KAAK,cAAc,GAEzB;IAEM,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAOZ,SAAS,CACd,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC,GAC9D,OAAO;IAiCH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B,QAAQ,IAAI,OAAO,EAAE;IAI5B,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,sBAAsB;YAYhB,SAAS;CAuDxB"}
@@ -16,6 +16,7 @@ export class CronManager {
16
16
  if (this.interval)
17
17
  return;
18
18
  this.interval = setInterval(() => this.checkJobs(), 60000); // Check every minute
19
+ this.interval.unref();
19
20
  }
20
21
  stop() {
21
22
  if (this.interval) {
@@ -1 +1 @@
1
- {"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAiBhD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AA8DlD,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,wBAAw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AM,GACnB,qBAAqB;IAoFxB;;OAEG;IACH,OAAO,CAAC,WAAW;IA0EnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAmHvB;;;;;;;OAOG;IACI,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAgGjE;;;OAGG;IACU,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA4C5D"}
@@ -8,7 +8,7 @@
8
8
  import path from "node:path";
9
9
  import { minimatch } from "minimatch";
10
10
  import { RESTRICTED_TOOLS } from "../types/permissions.js";
11
- import { splitBashCommand, stripEnvVars, stripRedirections, hasWriteRedirections, isBashHeredocWrite, getSmartPrefix, DANGEROUS_COMMANDS, } from "../utils/bashParser.js";
11
+ import { splitBashCommand, stripEnvVars, stripRedirections, hasWriteRedirections, isBashHeredocWrite, getSmartPrefix, isDangerousFind, DANGEROUS_COMMANDS, } from "../utils/bashParser.js";
12
12
  import { isPathInside } from "../utils/pathSafety.js";
13
13
  import { BASH_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, READ_TOOL_NAME, } from "../constants/tools.js";
14
14
  const SAFE_COMMANDS = [
@@ -24,6 +24,7 @@ const SAFE_COMMANDS = [
24
24
  "tail",
25
25
  "wc",
26
26
  "sleep",
27
+ "find",
27
28
  ];
28
29
  const DEFAULT_ALLOWED_RULES = [
29
30
  "Bash(git status*)",
@@ -52,6 +53,7 @@ const DEFAULT_ALLOWED_RULES = [
52
53
  "Bash(git count-objects*)",
53
54
  "Bash(echo*)",
54
55
  "Bash(ls*)",
56
+ "Bash(find*)",
55
57
  "Bash(which*)",
56
58
  "Bash(type*)",
57
59
  "Bash(hostname*)",
@@ -658,7 +660,8 @@ export class PermissionManager {
658
660
  cmd === "head" ||
659
661
  cmd === "tail" ||
660
662
  cmd === "wc" ||
661
- cmd === "sleep") {
663
+ cmd === "sleep" ||
664
+ (cmd === "find" && !isDangerousFind(part))) {
662
665
  return true;
663
666
  }
664
667
  if (workdir) {
@@ -682,7 +685,7 @@ export class PermissionManager {
682
685
  }
683
686
  }
684
687
  // Check if this specific part is allowed by any rule
685
- if (hasWrite && isDefaultRules) {
688
+ if (isDefaultRules && (hasWrite || isDangerousFind(part))) {
686
689
  return false;
687
690
  }
688
691
  // We create a temporary context with just this part of the command
@@ -747,7 +750,8 @@ export class PermissionManager {
747
750
  cmd === "head" ||
748
751
  cmd === "tail" ||
749
752
  cmd === "wc" ||
750
- cmd === "sleep") {
753
+ cmd === "sleep" ||
754
+ (cmd === "find" && !isDangerousFind(part))) {
751
755
  isSafe = true;
752
756
  }
753
757
  else {
@@ -775,7 +779,7 @@ export class PermissionManager {
775
779
  if (commandMatch) {
776
780
  const cmd = commandMatch[1];
777
781
  const args = commandMatch[2]?.trim() || "";
778
- if (DANGEROUS_COMMANDS.includes(cmd)) {
782
+ if (DANGEROUS_COMMANDS.includes(cmd) || isDangerousFind(part)) {
779
783
  continue;
780
784
  }
781
785
  if (cmd === "cd") {
@@ -1 +1 @@
1
- {"version":3,"file":"slashCommandManager.d.ts","sourceRoot":"","sources":["../../src/managers/slashCommandManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAWlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,mBAAmB;IAQ5B,OAAO,CAAC,SAAS;IAPnB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,6BAA6B,CAAgC;gBAG3D,SAAS,EAAE,SAAS,EAC5B,OA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W,IAAI,YAAY,EAAE;IAIpC;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI9D;;OAEG;IACU,cAAc,CACzB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;IA2BnB;;;OAGG;IACI,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG;QAClD,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAeD;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI7C;;OAEG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI1E;;OAEG;IACI,iBAAiB,IAAI,kBAAkB,EAAE;IAIhD;;OAEG;YACW,+BAA+B;IAuD7C;;OAEG;IACI,mBAAmB,IAAI,IAAI;CAQnC"}
@@ -309,6 +309,8 @@ export class SlashCommandManager {
309
309
  }
310
310
  finally {
311
311
  this.currentCommandAbortController = null;
312
+ // FR-013: Ensure slash commands are persisted to the session file
313
+ await this.messageManager.saveSession();
312
314
  }
313
315
  }
314
316
  /**
@@ -1,10 +1,17 @@
1
1
  import { ToolPlugin } from "../tools/types.js";
2
2
  import { PermissionMode } from "../types/permissions.js";
3
3
  export declare const MAX_PARALLEL_TOOL_CALLS = 3;
4
- export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
5
- export declare const TOOL_POLICY = "\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- **Limit**: You MUST NOT call more than 3 tools in parallel in a single response.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
4
+ export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.";
5
+ export declare const DOING_TASKS_PROMPT = "# Doing tasks\n- The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change \"methodName\" to snake case, do not reply with just \"method_name\", instead find the method in the code and modify the code.\n- You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.\n- If you notice the user's request is based on a misconception, or spot a bug adjacent to what they asked about, say so. You're a collaborator, not just an executor\u2014users benefit from your judgment, not just your compliance.\n- In general, do not propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Do not create files unless they're absolutely necessary for achieving your goal. Generally prefer editing an existing file to creating a new one, as this prevents file bloat and builds on existing work more effectively.\n- If an approach fails, diagnose why before switching tactics\u2014read the error, check your assumptions, try a focused fix. Don't retry the identical action blindly, but don't abandon a viable approach after a single failure either. Escalate to the user with AskUserQuestion only when you're genuinely stuck after investigation, not as a first response to friction.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it. Prioritize writing safe, secure, and correct code.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is what the task actually requires\u2014no speculative abstractions, but no half-finished implementations either. Three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused _vars, re-exporting types, adding // removed comments for removed code, etc. If you are certain that something is unused, you can delete it completely.\n- Report outcomes faithfully: if tests fail, say so with the relevant output; if you did not run a verification step, say that rather than implying it succeeded. Never claim \"all tests pass\" when output shows failures, never suppress or simplify failing checks (tests, lints, type errors) to manufacture a green result, and never characterize incomplete or broken work as done. Equally, when a check did pass or a task is complete, state it plainly \u2014 do not hedge confirmed results with unnecessary disclaimers, downgrade finished work to \"partial,\" or re-verify things you already checked. The goal is an accurate report, not a defensive one.\n- Before reporting a task complete, verify it actually works: run the test, execute the script, check the output. Minimum complexity means no gold-plating, not skipping the finish line. If you can't verify (no test exists, can't run the code), say so explicitly rather than claiming success.";
6
+ export declare const EXECUTING_ACTIONS_PROMPT = "# Executing actions with care\n\nCarefully consider the reversibility and blast radius of actions. Generally you can freely take local, reversible actions like editing files or running tests. But for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding. The cost of pausing to confirm is low, while the cost of an unwanted action (lost work, unintended messages sent, deleted branches) can be very high. For actions like these, consider the context, the action, and user instructions, and by default transparently communicate the action and ask for confirmation before proceeding.\n\nExamples of the kind of risky actions that warrant user confirmation:\n- Destructive operations: deleting files/branches, dropping database tables, killing processes, rm -rf, overwriting uncommitted changes\n- Hard-to-reverse operations: force-pushing (can also overwrite upstream), git reset --hard, amending published commits, removing or downgrading packages/dependencies, modifying CI/CD pipelines\n- Actions visible to others or that affect shared state: pushing code, creating/closing/commenting on PRs or issues, sending messages (Slack, email, GitHub), posting to external services\n\nWhen you encounter an obstacle, do not use destructive actions as a shortcut to simply make it go away. For instance, try to identify root causes and fix underlying issues rather than bypassing safety checks (e.g. --no-verify). If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting, as it may represent the user's in-progress work. For example, typically resolve merge conflicts rather than discarding changes. In short: only take risky actions carefully, and when in doubt, ask before acting. Follow both the spirit and letter of these instructions - measure twice, cut once.";
7
+ export declare const TOOL_POLICY = "# Using your tools\n\n- Do NOT use the Bash to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:\n - To read files use Read instead of cat, head, tail, or sed\n - To edit files use Edit instead of sed or awk\n - To create files use Write instead of cat with heredoc or echo redirection\n - To search for files use Glob instead of find or ls\n - To search the content of files, use Grep instead of grep or rg\n - Reserve using the Bash exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the Bash tool for these if it is absolutely necessary.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- **Limit**: You MUST NOT call more than 3 tools in parallel in a single response.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
8
+ /**
9
+ * Reference: /home/liuyiqi/github/claude-code/src/constants/prompts.ts getOutputEfficiencySection
10
+ */
11
+ export declare const OUTPUT_EFFICIENCY_PROMPT = "# Output efficiency\n\nIMPORTANT: Go straight to the point. Try the simplest approach first without going in circles. Do not overdo it. Be extra concise.\n\nKeep your text output brief and direct. Lead with the answer or action, not the reasoning. Skip filler words, preamble, and unnecessary transitions. Do not restate what the user said \u2014 just do it. When explaining, include only what is necessary for the user to understand.\n\nFocus text output on:\n- Decisions that need the user's input\n- High-level status updates at natural milestones\n- Errors or blockers that change the plan\n\nIf you can say it in one sentence, don't use three. Prefer short, direct sentences over long explanations. This does not apply to code or tool calls.";
12
+ export declare const TONE_AND_STYLE_PROMPT = "# Tone and style\n\n- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n- Your responses should be short and concise.\n- When referencing specific functions or pieces of code include the pattern file_path:line_number to allow the user to easily navigate to the source code location.\n- When referencing GitHub issues or pull requests, use the owner/repo#123 format (e.g. anthropics/claude-code#100) so they render as clickable links.\n- Do not use a colon before tool calls. Your tool calls may not be shown directly in the output, so text like \"Let me read the file:\" followed by a read tool call should just be \"Let me read the file.\" with a period.";
6
13
  export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean, isSubagent?: boolean): string;
7
- export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
14
+ export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.";
8
15
  export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
9
16
  export declare const WEB_CONTENT_SYSTEM_PROMPT = "You are a helpful assistant that extracts information from web content. The content is provided in Markdown format.";
10
17
  export declare const BTW_SYSTEM_PROMPT = "You are a helpful assistant. Answer the user's side question based on the conversation history. \nDo NOT say things like \"Let me try...\", \"I'll now...\", \"Let me check...\", or promise to take any action. \nIf you don't know the answer, say so - do not offer to look it up or investigate. \nSimply answer the question with the information you have.";
@@ -23,4 +30,5 @@ export declare function buildSystemPrompt(basePrompt: string | undefined, tools:
23
30
  };
24
31
  permissionMode?: PermissionMode;
25
32
  }): string;
33
+ export declare function enhanceSystemPromptWithEnvDetails(existingSystemPrompt: string, workdir: string): string;
26
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAazD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,y0BAKqH,CAAC;AAE9I,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,g9DAAqB,CAAC;AAExD,eAAO,MAAM,+BAA+B,20CAsBG,CAAC;AAEhD,eAAO,MAAM,yBAAyB,wHAAwH,CAAC;AAC/J,eAAO,MAAM,iBAAiB,qWAG4B,CAAC;AAE3D,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE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nB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,CAAC,EAAE,cAAc,CAAC;CAC5B,GACL,MAAM,CA8DR;AAED,wBAAgB,iCAAiC,CAC/C,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,CAgCR"}
@@ -2,25 +2,69 @@ import * as os from "node:os";
2
2
  import { isGitRepository } from "../utils/gitUtils.js";
3
3
  import { buildAutoMemoryPrompt } from "./autoMemory.js";
4
4
  import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
5
- import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, } from "../constants/tools.js";
5
+ import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, BASH_TOOL_NAME, READ_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, } from "../constants/tools.js";
6
6
  export const MAX_PARALLEL_TOOL_CALLS = 3;
7
- export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
8
-
9
- # Doing tasks
10
- The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
11
- - NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.
12
- - Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.
7
+ export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.`;
8
+ export const DOING_TASKS_PROMPT = `# Doing tasks
9
+ - The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change "methodName" to snake case, do not reply with just "method_name", instead find the method in the code and modify the code.
10
+ - You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.
11
+ - If you notice the user's request is based on a misconception, or spot a bug adjacent to what they asked about, say so. You're a collaborator, not just an executor—users benefit from your judgment, not just your compliance.
12
+ - In general, do not propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.
13
+ - Do not create files unless they're absolutely necessary for achieving your goal. Generally prefer editing an existing file to creating a new one, as this prevents file bloat and builds on existing work more effectively.
14
+ - If an approach fails, diagnose why before switching tactics—read the error, check your assumptions, try a focused fix. Don't retry the identical action blindly, but don't abandon a viable approach after a single failure either. Escalate to the user with ${ASK_USER_QUESTION_TOOL_NAME} only when you're genuinely stuck after investigation, not as a first response to friction.
15
+ - Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it. Prioritize writing safe, secure, and correct code.
13
16
  - Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.
14
17
  - Don't add features, refactor code, or make "improvements" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.
15
18
  - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.
16
- - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task—three similar lines of code is better than a premature abstraction.
17
- - Avoid backwards-compatibility hacks like renaming unused \`_vars\`, re-exporting types, adding \`// removed\` comments for removed code, etc. If something is unused, delete it completely.`;
18
- export const TOOL_POLICY = `
19
- # Tool usage policy
19
+ - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is what the task actually requires—no speculative abstractions, but no half-finished implementations either. Three similar lines of code is better than a premature abstraction.
20
+ - Avoid backwards-compatibility hacks like renaming unused _vars, re-exporting types, adding // removed comments for removed code, etc. If you are certain that something is unused, you can delete it completely.
21
+ - Report outcomes faithfully: if tests fail, say so with the relevant output; if you did not run a verification step, say that rather than implying it succeeded. Never claim "all tests pass" when output shows failures, never suppress or simplify failing checks (tests, lints, type errors) to manufacture a green result, and never characterize incomplete or broken work as done. Equally, when a check did pass or a task is complete, state it plainly — do not hedge confirmed results with unnecessary disclaimers, downgrade finished work to "partial," or re-verify things you already checked. The goal is an accurate report, not a defensive one.
22
+ - Before reporting a task complete, verify it actually works: run the test, execute the script, check the output. Minimum complexity means no gold-plating, not skipping the finish line. If you can't verify (no test exists, can't run the code), say so explicitly rather than claiming success.`;
23
+ export const EXECUTING_ACTIONS_PROMPT = `# Executing actions with care
24
+
25
+ Carefully consider the reversibility and blast radius of actions. Generally you can freely take local, reversible actions like editing files or running tests. But for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding. The cost of pausing to confirm is low, while the cost of an unwanted action (lost work, unintended messages sent, deleted branches) can be very high. For actions like these, consider the context, the action, and user instructions, and by default transparently communicate the action and ask for confirmation before proceeding.
26
+
27
+ Examples of the kind of risky actions that warrant user confirmation:
28
+ - Destructive operations: deleting files/branches, dropping database tables, killing processes, rm -rf, overwriting uncommitted changes
29
+ - Hard-to-reverse operations: force-pushing (can also overwrite upstream), git reset --hard, amending published commits, removing or downgrading packages/dependencies, modifying CI/CD pipelines
30
+ - Actions visible to others or that affect shared state: pushing code, creating/closing/commenting on PRs or issues, sending messages (Slack, email, GitHub), posting to external services
31
+
32
+ When you encounter an obstacle, do not use destructive actions as a shortcut to simply make it go away. For instance, try to identify root causes and fix underlying issues rather than bypassing safety checks (e.g. --no-verify). If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting, as it may represent the user's in-progress work. For example, typically resolve merge conflicts rather than discarding changes. In short: only take risky actions carefully, and when in doubt, ask before acting. Follow both the spirit and letter of these instructions - measure twice, cut once.`;
33
+ export const TOOL_POLICY = `# Using your tools
34
+
35
+ - Do NOT use the ${BASH_TOOL_NAME} to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:
36
+ - To read files use ${READ_TOOL_NAME} instead of cat, head, tail, or sed
37
+ - To edit files use ${EDIT_TOOL_NAME} instead of sed or awk
38
+ - To create files use ${WRITE_TOOL_NAME} instead of cat with heredoc or echo redirection
39
+ - To search for files use ${GLOB_TOOL_NAME} instead of find or ls
40
+ - To search the content of files, use ${GREP_TOOL_NAME} instead of grep or rg
41
+ - Reserve using the ${BASH_TOOL_NAME} exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the ${BASH_TOOL_NAME} tool for these if it is absolutely necessary.
20
42
  - You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
21
43
  - **Limit**: You MUST NOT call more than ${MAX_PARALLEL_TOOL_CALLS} tools in parallel in a single response.
22
44
  - However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
23
45
  - If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
46
+ /**
47
+ * Reference: /home/liuyiqi/github/claude-code/src/constants/prompts.ts getOutputEfficiencySection
48
+ */
49
+ export const OUTPUT_EFFICIENCY_PROMPT = `# Output efficiency
50
+
51
+ IMPORTANT: Go straight to the point. Try the simplest approach first without going in circles. Do not overdo it. Be extra concise.
52
+
53
+ Keep your text output brief and direct. Lead with the answer or action, not the reasoning. Skip filler words, preamble, and unnecessary transitions. Do not restate what the user said — just do it. When explaining, include only what is necessary for the user to understand.
54
+
55
+ Focus text output on:
56
+ - Decisions that need the user's input
57
+ - High-level status updates at natural milestones
58
+ - Errors or blockers that change the plan
59
+
60
+ If you can say it in one sentence, don't use three. Prefer short, direct sentences over long explanations. This does not apply to code or tool calls.`;
61
+ export const TONE_AND_STYLE_PROMPT = `# Tone and style
62
+
63
+ - Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
64
+ - Your responses should be short and concise.
65
+ - When referencing specific functions or pieces of code include the pattern file_path:line_number to allow the user to easily navigate to the source code location.
66
+ - When referencing GitHub issues or pull requests, use the owner/repo#123 format (e.g. anthropics/claude-code#100) so they render as clickable links.
67
+ - Do not use a colon before tool calls. Your tool calls may not be shown directly in the output, so text like "Let me read the file:" followed by a read tool call should just be "Let me read the file." with a period.`;
24
68
  export function buildPlanModePrompt(planFilePath, planExists, isSubagent = false) {
25
69
  const planFileInfo = planExists
26
70
  ? `A plan file already exists at ${planFilePath}. You can read it and make incremental edits using the ${EDIT_TOOL_NAME} tool if you need to.`
@@ -134,9 +178,13 @@ If you don't know the answer, say so - do not offer to look it up or investigate
134
178
  Simply answer the question with the information you have.`;
135
179
  export function buildSystemPrompt(basePrompt, tools, options = {}) {
136
180
  let prompt = basePrompt || DEFAULT_SYSTEM_PROMPT;
181
+ prompt += `\n\n${DOING_TASKS_PROMPT}`;
182
+ prompt += `\n\n${EXECUTING_ACTIONS_PROMPT}`;
137
183
  if (tools.length > 0) {
138
184
  prompt += `\n\n${TOOL_POLICY}`;
139
185
  }
186
+ prompt += `\n\n${OUTPUT_EFFICIENCY_PROMPT}`;
187
+ prompt += `\n\n${TONE_AND_STYLE_PROMPT}`;
140
188
  if (options.permissionMode === "dontAsk") {
141
189
  prompt += `\n\n# Permission Mode\nThe user has selected the 'dontAsk' permission mode. In this mode, any restricted tool call that does not match a pre-approved rule in 'permissions.allow' or 'temporaryRules' will be automatically denied without prompting the user. You will receive a 'Permission denied' error for such calls. This is intended to prevent interruptions for untrusted tools while allowing pre-approved ones to run seamlessly.`;
142
190
  }
@@ -151,6 +199,12 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
151
199
  const platform = os.platform();
152
200
  const osVersion = `${os.type()} ${os.release()}`;
153
201
  const today = new Date().toISOString().split("T")[0];
202
+ const shell = process.env.SHELL || "unknown";
203
+ const shellName = shell.includes("zsh")
204
+ ? "zsh"
205
+ : shell.includes("bash")
206
+ ? "bash"
207
+ : shell;
154
208
  prompt += `
155
209
 
156
210
  Here is useful information about the environment you are running in:
@@ -158,6 +212,7 @@ Here is useful information about the environment you are running in:
158
212
  Working directory: ${options.workdir}
159
213
  Is directory a git repo: ${isGitRepo}
160
214
  Platform: ${platform}
215
+ Shell: ${shellName}
161
216
  OS Version: ${osVersion}
162
217
  Today's date: ${today}
163
218
  </env>
@@ -174,3 +229,34 @@ Today's date: ${today}
174
229
  }
175
230
  return prompt;
176
231
  }
232
+ export function enhanceSystemPromptWithEnvDetails(existingSystemPrompt, workdir) {
233
+ const isGitRepo = isGitRepository(workdir);
234
+ const platform = os.platform();
235
+ const osVersion = `${os.type()} ${os.release()}`;
236
+ const today = new Date().toISOString().split("T")[0];
237
+ const shell = process.env.SHELL || "unknown";
238
+ const shellName = shell.includes("zsh")
239
+ ? "zsh"
240
+ : shell.includes("bash")
241
+ ? "bash"
242
+ : shell;
243
+ const notes = `Notes:
244
+ - Agent threads always have their cwd reset between bash calls, as a result please only use absolute file paths.
245
+ - In your final response, share file paths (always absolute, never relative) that are relevant to the task. Include code snippets only when the exact text is load-bearing (e.g., a bug you found, a function signature the caller asked for) — do not recap code you merely read.
246
+ - For clear communication with the user the assistant MUST avoid using emojis.
247
+ - Do not use a colon before tool calls. Text like "Let me read the file:" followed by a read tool call should just be "Let me read the file." with a period.`;
248
+ return `${existingSystemPrompt}
249
+
250
+ ${notes}
251
+
252
+ Here is useful information about the environment you are running in:
253
+ <env>
254
+ Working directory: ${workdir}
255
+ Is directory a git repo: ${isGitRepo}
256
+ Platform: ${platform}
257
+ Shell: ${shellName}
258
+ OS Version: ${osVersion}
259
+ Today's date: ${today}
260
+ </env>
261
+ `;
262
+ }
@@ -97,7 +97,7 @@ export declare class ConfigurationService {
97
97
  */
98
98
  setModel(model: string): void;
99
99
  /**
100
- * Get all configured models from settings.json and defaults
100
+ * Get all configured models from settings.json and environment
101
101
  */
102
102
  getConfiguredModels(): string[];
103
103
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,OAAO,CAAoB;IAEnC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,I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;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAa1D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoClE;;OAEG;IACG,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAuChB;;OAEG;IACG,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAmChB;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKjE;;;OAGG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;CAGnE;AAKD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,2BAA2B,CAsD7B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC9C,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAoC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,iBAAiB,GAAG,IAAI,CA6B1B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAoJ1B"}
1
+ {"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;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