@prestyj/cli 4.2.16 → 4.2.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +15 -7
- package/dist/cli.js +458 -238
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +66 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +22 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +184 -23
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agents.d.ts +0 -2
- package/dist/core/agents.d.ts.map +1 -1
- package/dist/core/agents.js +1 -5
- package/dist/core/agents.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +66 -17
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/auto-update.js +1 -1
- package/dist/core/auto-update.js.map +1 -1
- package/dist/core/compaction/compactor.d.ts +36 -5
- package/dist/core/compaction/compactor.d.ts.map +1 -1
- package/dist/core/compaction/compactor.js +222 -63
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/compactor.test.js +377 -32
- package/dist/core/compaction/compactor.test.js.map +1 -1
- package/dist/core/compaction/token-estimator.d.ts +5 -0
- package/dist/core/compaction/token-estimator.d.ts.map +1 -1
- package/dist/core/compaction/token-estimator.js +41 -2
- package/dist/core/compaction/token-estimator.js.map +1 -1
- package/dist/core/compaction/token-estimator.test.js +43 -21
- package/dist/core/compaction/token-estimator.test.js.map +1 -1
- package/dist/core/event-bus.d.ts +6 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js +7 -0
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/file-lock.d.ts +6 -0
- package/dist/core/file-lock.d.ts.map +1 -0
- package/dist/core/file-lock.js +76 -0
- package/dist/core/file-lock.js.map +1 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/mcp/client.d.ts +0 -26
- package/dist/core/mcp/client.d.ts.map +1 -1
- package/dist/core/mcp/client.js +34 -141
- package/dist/core/mcp/client.js.map +1 -1
- package/dist/core/mcp/defaults.d.ts.map +1 -1
- package/dist/core/mcp/defaults.js +4 -8
- package/dist/core/mcp/defaults.js.map +1 -1
- package/dist/core/mcp/types.d.ts +0 -2
- package/dist/core/mcp/types.d.ts.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +16 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/oauth/anthropic.d.ts.map +1 -1
- package/dist/core/oauth/anthropic.js +3 -3
- package/dist/core/oauth/anthropic.js.map +1 -1
- package/dist/core/prompt-commands.d.ts.map +1 -1
- package/dist/core/prompt-commands.js +21 -0
- package/dist/core/prompt-commands.js.map +1 -1
- package/dist/core/session-manager.d.ts +34 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +160 -54
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -2
- package/dist/core/skills.d.ts +2 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +8 -8
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +4 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +22 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/telegram.d.ts +94 -0
- package/dist/core/telegram.d.ts.map +1 -0
- package/dist/core/telegram.js +227 -0
- package/dist/core/telegram.js.map +1 -0
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +36 -5
- package/dist/interactive.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +1 -0
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/json-mode.d.ts.map +1 -1
- package/dist/modes/json-mode.js +2 -1
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc-mode.d.ts +28 -0
- package/dist/modes/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc-mode.js +146 -0
- package/dist/modes/rpc-mode.js.map +1 -0
- package/dist/modes/serve-mode.d.ts +21 -0
- package/dist/modes/serve-mode.d.ts.map +1 -0
- package/dist/modes/serve-mode.js +650 -0
- package/dist/modes/serve-mode.js.map +1 -0
- package/dist/system-prompt.d.ts +1 -1
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +45 -10
- package/dist/system-prompt.js.map +1 -1
- package/dist/tools/bash.d.ts +4 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +58 -5
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/edit.d.ts +4 -1
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +9 -5
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/enter-plan.d.ts +8 -0
- package/dist/tools/enter-plan.d.ts.map +1 -0
- package/dist/tools/enter-plan.js +28 -0
- package/dist/tools/enter-plan.js.map +1 -0
- package/dist/tools/exit-plan.d.ts +8 -0
- package/dist/tools/exit-plan.d.ts.map +1 -0
- package/dist/tools/exit-plan.js +35 -0
- package/dist/tools/exit-plan.js.map +1 -0
- package/dist/tools/grep.d.ts +2 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +7 -8
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/index.d.ts +17 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +26 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/ls.d.ts +2 -1
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +4 -4
- package/dist/tools/ls.js.map +1 -1
- package/dist/tools/operations.d.ts +39 -0
- package/dist/tools/operations.d.ts.map +1 -0
- package/dist/tools/operations.js +27 -0
- package/dist/tools/operations.js.map +1 -0
- package/dist/tools/path-utils.d.ts +5 -0
- package/dist/tools/path-utils.d.ts.map +1 -1
- package/dist/tools/path-utils.js +18 -0
- package/dist/tools/path-utils.js.map +1 -1
- package/dist/tools/plan-mode.test.d.ts +2 -0
- package/dist/tools/plan-mode.test.d.ts.map +1 -0
- package/dist/tools/plan-mode.test.js +214 -0
- package/dist/tools/plan-mode.test.js.map +1 -0
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +6 -5
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/skill.d.ts +10 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +36 -0
- package/dist/tools/skill.js.map +1 -0
- package/dist/tools/subagent.d.ts +3 -1
- package/dist/tools/subagent.d.ts.map +1 -1
- package/dist/tools/subagent.js +46 -4
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/tasks.d.ts +2 -2
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +47 -0
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/write.d.ts +4 -1
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +17 -6
- package/dist/tools/write.js.map +1 -1
- package/dist/ui/App.d.ts +35 -1
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +367 -91
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.d.ts +2 -1
- package/dist/ui/components/ActivityIndicator.d.ts.map +1 -1
- package/dist/ui/components/ActivityIndicator.js +25 -4
- package/dist/ui/components/ActivityIndicator.js.map +1 -1
- package/dist/ui/components/AnimationContext.d.ts +22 -0
- package/dist/ui/components/AnimationContext.d.ts.map +1 -0
- package/dist/ui/components/AnimationContext.js +35 -0
- package/dist/ui/components/AnimationContext.js.map +1 -0
- package/dist/ui/components/AssistantMessage.d.ts.map +1 -1
- package/dist/ui/components/AssistantMessage.js +6 -1
- package/dist/ui/components/AssistantMessage.js.map +1 -1
- package/dist/ui/components/Banner.d.ts.map +1 -1
- package/dist/ui/components/Banner.js +4 -7
- package/dist/ui/components/Banner.js.map +1 -1
- package/dist/ui/components/CompactionNotice.d.ts.map +1 -1
- package/dist/ui/components/CompactionNotice.js +4 -8
- package/dist/ui/components/CompactionNotice.js.map +1 -1
- package/dist/ui/components/Footer.d.ts +2 -1
- package/dist/ui/components/Footer.d.ts.map +1 -1
- package/dist/ui/components/Footer.js +8 -15
- package/dist/ui/components/Footer.js.map +1 -1
- package/dist/ui/components/InputArea.d.ts +3 -1
- package/dist/ui/components/InputArea.d.ts.map +1 -1
- package/dist/ui/components/InputArea.js +23 -25
- package/dist/ui/components/InputArea.js.map +1 -1
- package/dist/ui/components/PlanApproval.d.ts +8 -0
- package/dist/ui/components/PlanApproval.d.ts.map +1 -0
- package/dist/ui/components/PlanApproval.js +44 -0
- package/dist/ui/components/PlanApproval.js.map +1 -0
- package/dist/ui/components/PlanBanner.d.ts +6 -0
- package/dist/ui/components/PlanBanner.d.ts.map +1 -0
- package/dist/ui/components/PlanBanner.js +14 -0
- package/dist/ui/components/PlanBanner.js.map +1 -0
- package/dist/ui/components/PlanOverlay.d.ts +11 -0
- package/dist/ui/components/PlanOverlay.d.ts.map +1 -0
- package/dist/ui/components/PlanOverlay.js +263 -0
- package/dist/ui/components/PlanOverlay.js.map +1 -0
- package/dist/ui/components/ServerToolExecution.d.ts +1 -0
- package/dist/ui/components/ServerToolExecution.d.ts.map +1 -1
- package/dist/ui/components/ServerToolExecution.js +12 -3
- package/dist/ui/components/ServerToolExecution.js.map +1 -1
- package/dist/ui/components/SkillsOverlay.d.ts +7 -0
- package/dist/ui/components/SkillsOverlay.d.ts.map +1 -0
- package/dist/ui/components/SkillsOverlay.js +158 -0
- package/dist/ui/components/SkillsOverlay.js.map +1 -0
- package/dist/ui/components/Spinner.d.ts.map +1 -1
- package/dist/ui/components/Spinner.js +5 -9
- package/dist/ui/components/Spinner.js.map +1 -1
- package/dist/ui/components/StreamingArea.d.ts +2 -1
- package/dist/ui/components/StreamingArea.d.ts.map +1 -1
- package/dist/ui/components/StreamingArea.js +11 -4
- package/dist/ui/components/StreamingArea.js.map +1 -1
- package/dist/ui/components/SubAgentPanel.d.ts.map +1 -1
- package/dist/ui/components/SubAgentPanel.js +27 -29
- package/dist/ui/components/SubAgentPanel.js.map +1 -1
- package/dist/ui/components/TaskOverlay.d.ts.map +1 -1
- package/dist/ui/components/TaskOverlay.js +7 -3
- package/dist/ui/components/TaskOverlay.js.map +1 -1
- package/dist/ui/components/ThinkingBlock.d.ts.map +1 -1
- package/dist/ui/components/ThinkingBlock.js +4 -1
- package/dist/ui/components/ThinkingBlock.js.map +1 -1
- package/dist/ui/components/ThinkingIndicator.d.ts.map +1 -1
- package/dist/ui/components/ThinkingIndicator.js +8 -33
- package/dist/ui/components/ThinkingIndicator.js.map +1 -1
- package/dist/ui/components/ToolExecution.d.ts.map +1 -1
- package/dist/ui/components/ToolExecution.js +95 -41
- package/dist/ui/components/ToolExecution.js.map +1 -1
- package/dist/ui/components/ToolGroupExecution.d.ts +7 -0
- package/dist/ui/components/ToolGroupExecution.d.ts.map +1 -0
- package/dist/ui/components/ToolGroupExecution.js +115 -0
- package/dist/ui/components/ToolGroupExecution.js.map +1 -0
- package/dist/ui/components/UserMessage.js +1 -1
- package/dist/ui/components/UserMessage.js.map +1 -1
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.d.ts.map +1 -1
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/components/index.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.d.ts +8 -0
- package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentLoop.js +320 -220
- package/dist/ui/hooks/useAgentLoop.js.map +1 -1
- package/dist/ui/hooks/useTerminalSize.d.ts +21 -9
- package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -1
- package/dist/ui/hooks/useTerminalSize.js +33 -16
- package/dist/ui/hooks/useTerminalSize.js.map +1 -1
- package/dist/ui/hooks/useTerminalTitle.d.ts.map +1 -1
- package/dist/ui/hooks/useTerminalTitle.js +8 -16
- package/dist/ui/hooks/useTerminalTitle.js.map +1 -1
- package/dist/ui/live-item-flush.d.ts +11 -1
- package/dist/ui/live-item-flush.d.ts.map +1 -1
- package/dist/ui/live-item-flush.js +81 -2
- package/dist/ui/live-item-flush.js.map +1 -1
- package/dist/ui/login.d.ts +1 -1
- package/dist/ui/login.d.ts.map +1 -1
- package/dist/ui/login.js +30 -6
- package/dist/ui/login.js.map +1 -1
- package/dist/ui/render.d.ts +11 -0
- package/dist/ui/render.d.ts.map +1 -1
- package/dist/ui/render.js +24 -10
- package/dist/ui/render.js.map +1 -1
- package/dist/ui/sessions.d.ts +2 -0
- package/dist/ui/sessions.d.ts.map +1 -0
- package/dist/ui/sessions.js +208 -0
- package/dist/ui/sessions.js.map +1 -0
- package/dist/ui/theme/dark.json +3 -1
- package/dist/ui/theme/light.json +3 -1
- package/dist/ui/theme/theme.d.ts +2 -0
- package/dist/ui/theme/theme.d.ts.map +1 -1
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +17 -5
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/image.d.ts.map +1 -1
- package/dist/utils/image.js +60 -5
- package/dist/utils/image.js.map +1 -1
- package/package.json +8 -8
package/dist/tools/grep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"A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import { ProcessManager } from "../core/process-manager.js";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
3
4
|
import type { AgentDefinition } from "../core/agents.js";
|
|
5
|
+
import type { Skill } from "../core/skills.js";
|
|
4
6
|
export interface CreateToolsOptions {
|
|
5
7
|
agents?: AgentDefinition[];
|
|
8
|
+
skills?: Skill[];
|
|
6
9
|
provider?: string;
|
|
7
10
|
model?: string;
|
|
11
|
+
/** Custom I/O operations for remote execution (SSH, Docker, etc.). Defaults to local filesystem. */
|
|
12
|
+
operations?: ToolOperations;
|
|
13
|
+
/** Ref for checking plan mode state inside tool execute functions. */
|
|
14
|
+
planModeRef?: {
|
|
15
|
+
current: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Callback when the LLM enters plan mode. */
|
|
18
|
+
onEnterPlan?: (reason?: string) => void;
|
|
19
|
+
/** Callback when the LLM exits plan mode. Returns approval result string. */
|
|
20
|
+
onExitPlan?: (planPath: string) => Promise<string>;
|
|
8
21
|
}
|
|
9
22
|
export interface CreateToolsResult {
|
|
10
23
|
tools: AgentTool[];
|
|
@@ -22,5 +35,9 @@ export { createWebFetchTool } from "./web-fetch.js";
|
|
|
22
35
|
export { createTaskOutputTool } from "./task-output.js";
|
|
23
36
|
export { createTaskStopTool } from "./task-stop.js";
|
|
24
37
|
export { createTasksTool } from "./tasks.js";
|
|
38
|
+
export { createSkillTool } from "./skill.js";
|
|
39
|
+
export { createEnterPlanTool } from "./enter-plan.js";
|
|
40
|
+
export { createExitPlanTool } from "./exit-plan.js";
|
|
25
41
|
export { ProcessManager } from "../core/process-manager.js";
|
|
42
|
+
export { localOperations, type ToolOperations } from "./operations.js";
|
|
26
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA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AM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -11,24 +11,39 @@ import { createWebFetchTool } from "./web-fetch.js";
|
|
|
11
11
|
import { createTaskOutputTool } from "./task-output.js";
|
|
12
12
|
import { createTaskStopTool } from "./task-stop.js";
|
|
13
13
|
import { createTasksTool } from "./tasks.js";
|
|
14
|
+
import { createSkillTool } from "./skill.js";
|
|
15
|
+
import { createEnterPlanTool } from "./enter-plan.js";
|
|
16
|
+
import { createExitPlanTool } from "./exit-plan.js";
|
|
17
|
+
import { localOperations } from "./operations.js";
|
|
14
18
|
export function createTools(cwd, opts) {
|
|
15
19
|
const readFiles = new Set();
|
|
16
20
|
const processManager = new ProcessManager();
|
|
21
|
+
const ops = opts?.operations ?? localOperations;
|
|
22
|
+
const planModeRef = opts?.planModeRef;
|
|
17
23
|
const tools = [
|
|
18
|
-
createReadTool(cwd, readFiles),
|
|
19
|
-
createWriteTool(cwd, readFiles),
|
|
20
|
-
createEditTool(cwd, readFiles),
|
|
21
|
-
createBashTool(cwd, processManager),
|
|
24
|
+
createReadTool(cwd, readFiles, ops),
|
|
25
|
+
createWriteTool(cwd, readFiles, ops, planModeRef),
|
|
26
|
+
createEditTool(cwd, readFiles, ops, planModeRef),
|
|
27
|
+
createBashTool(cwd, processManager, ops, planModeRef),
|
|
22
28
|
createFindTool(cwd),
|
|
23
|
-
createGrepTool(cwd),
|
|
24
|
-
createLsTool(cwd),
|
|
29
|
+
createGrepTool(cwd, ops),
|
|
30
|
+
createLsTool(cwd, ops),
|
|
25
31
|
createWebFetchTool(),
|
|
26
32
|
createTaskOutputTool(processManager),
|
|
27
33
|
createTaskStopTool(processManager),
|
|
28
34
|
createTasksTool(cwd),
|
|
29
35
|
];
|
|
30
36
|
if (opts?.agents && opts.agents.length > 0 && opts.provider && opts.model) {
|
|
31
|
-
tools.push(createSubAgentTool(cwd, opts.agents, opts.provider, opts.model));
|
|
37
|
+
tools.push(createSubAgentTool(cwd, opts.agents, opts.provider, opts.model, planModeRef));
|
|
38
|
+
}
|
|
39
|
+
if (opts?.skills && opts.skills.length > 0) {
|
|
40
|
+
tools.push(createSkillTool(opts.skills));
|
|
41
|
+
}
|
|
42
|
+
if (opts?.onEnterPlan) {
|
|
43
|
+
tools.push(createEnterPlanTool(opts.onEnterPlan));
|
|
44
|
+
}
|
|
45
|
+
if (opts?.onExitPlan) {
|
|
46
|
+
tools.push(createExitPlanTool(cwd, opts.onExitPlan));
|
|
32
47
|
}
|
|
33
48
|
return { tools, processManager };
|
|
34
49
|
}
|
|
@@ -43,5 +58,9 @@ export { createWebFetchTool } from "./web-fetch.js";
|
|
|
43
58
|
export { createTaskOutputTool } from "./task-output.js";
|
|
44
59
|
export { createTaskStopTool } from "./task-stop.js";
|
|
45
60
|
export { createTasksTool } from "./tasks.js";
|
|
61
|
+
export { createSkillTool } from "./skill.js";
|
|
62
|
+
export { createEnterPlanTool } from "./enter-plan.js";
|
|
63
|
+
export { createExitPlanTool } from "./exit-plan.js";
|
|
46
64
|
export { ProcessManager } from "../core/process-manager.js";
|
|
65
|
+
export { localOperations } from "./operations.js";
|
|
47
66
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,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EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC"}
|
package/dist/tools/ls.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AgentTool } from "@prestyj/agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
3
4
|
declare const LsParams: z.ZodObject<{
|
|
4
5
|
path: z.ZodOptional<z.ZodString>;
|
|
5
6
|
all: z.ZodOptional<z.ZodBoolean>;
|
|
6
7
|
}, z.core.$strip>;
|
|
7
|
-
export declare function createLsTool(cwd: string): AgentTool<typeof LsParams>;
|
|
8
|
+
export declare function createLsTool(cwd: string, ops?: ToolOperations): AgentTool<typeof LsParams>;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=ls.d.ts.map
|
package/dist/tools/ls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,QAAA,MAAM,QAAQ;;;iBAGZ,CAAC;AAEH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,cAAgC,GACpC,SAAS,CAAC,OAAO,QAAQ,CAAC,CAyC5B"}
|
package/dist/tools/ls.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
1
|
import path from "node:path";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
import { resolvePath } from "./path-utils.js";
|
|
4
|
+
import { localOperations } from "./operations.js";
|
|
5
5
|
const LsParams = z.object({
|
|
6
6
|
path: z.string().optional().describe("Directory path (defaults to cwd)"),
|
|
7
7
|
all: z.boolean().optional().describe("Show hidden files (default: false)"),
|
|
8
8
|
});
|
|
9
|
-
export function createLsTool(cwd) {
|
|
9
|
+
export function createLsTool(cwd, ops = localOperations) {
|
|
10
10
|
return {
|
|
11
11
|
name: "ls",
|
|
12
12
|
description: "List directory contents with file types and sizes. Directories listed first.",
|
|
13
13
|
parameters: LsParams,
|
|
14
14
|
async execute({ path: dirPath, all }) {
|
|
15
15
|
const resolved = dirPath ? resolvePath(cwd, dirPath) : cwd;
|
|
16
|
-
const entries = await
|
|
16
|
+
const entries = await ops.readdir(resolved, { withFileTypes: true });
|
|
17
17
|
// Filter hidden files unless --all
|
|
18
18
|
const filtered = all ? entries : entries.filter((e) => !e.name.startsWith("."));
|
|
19
19
|
// Separate dirs and files, then sort each alphabetically
|
|
@@ -29,7 +29,7 @@ export function createLsTool(cwd) {
|
|
|
29
29
|
}
|
|
30
30
|
for (const file of files) {
|
|
31
31
|
try {
|
|
32
|
-
const stat = await
|
|
32
|
+
const stat = await ops.stat(path.join(resolved, file.name));
|
|
33
33
|
const size = formatSize(stat.size);
|
|
34
34
|
const type = file.isSymbolicLink() ? "l" : "f";
|
|
35
35
|
lines.push(`${type} ${size.padStart(8)} ${file.name}`);
|
package/dist/tools/ls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IACxE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAC3E,CAAC,CAAC;AAEH,MAAM,UAAU,YAAY,CAC1B,GAAW,EACX,MAAsB,eAAe;IAErC,OAAO;QACL,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,8EAA8E;QAC3F,UAAU,EAAE,QAAQ;QACpB,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;YAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAC3D,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,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C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;oBAC/C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3D,CAAC;gBAAC,MAAM,CAAC;oBACP,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;YAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,kBAAkB,CAAC;YAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAChE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAChF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { type ReadStream } from "node:fs";
|
|
3
|
+
import type { Dirent, Stats } from "node:fs";
|
|
4
|
+
/**
|
|
5
|
+
* Abstraction over filesystem and process operations.
|
|
6
|
+
* Default implementation uses local Node.js APIs.
|
|
7
|
+
* Replace with SSH/Docker/cloud implementations for remote execution.
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolOperations {
|
|
10
|
+
/** Read a file's contents as UTF-8 string. */
|
|
11
|
+
readFile(path: string): Promise<string>;
|
|
12
|
+
/** Write content to a file. Creates parent directories if needed. */
|
|
13
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
14
|
+
/** Get file/directory stats. */
|
|
15
|
+
stat(path: string): Promise<Stats>;
|
|
16
|
+
/** Check if a path is a symbolic link. */
|
|
17
|
+
lstat(path: string): Promise<Stats>;
|
|
18
|
+
/** Read directory contents with file type info. */
|
|
19
|
+
readdir(path: string, options: {
|
|
20
|
+
withFileTypes: true;
|
|
21
|
+
}): Promise<Dirent[]>;
|
|
22
|
+
/** Create a directory (recursive). */
|
|
23
|
+
mkdir(path: string): Promise<void>;
|
|
24
|
+
/** Create a readable stream for a file. */
|
|
25
|
+
createReadStream(path: string, encoding: BufferEncoding): ReadStream;
|
|
26
|
+
/** Spawn a child process. Returns the ChildProcess handle. */
|
|
27
|
+
spawn(command: string, args: string[], options: {
|
|
28
|
+
cwd: string;
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
detached?: boolean;
|
|
31
|
+
stdio?: Array<"pipe" | "ignore">;
|
|
32
|
+
}): ChildProcess;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default local filesystem + process operations.
|
|
36
|
+
* This is what tools use when running on the local machine.
|
|
37
|
+
*/
|
|
38
|
+
export declare const localOperations: ToolOperations;
|
|
39
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/tools/operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SA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
|
3
|
+
import { createReadStream } from "node:fs";
|
|
4
|
+
/**
|
|
5
|
+
* Default local filesystem + process operations.
|
|
6
|
+
* This is what tools use when running on the local machine.
|
|
7
|
+
*/
|
|
8
|
+
export const localOperations = {
|
|
9
|
+
readFile: (path) => fs.readFile(path, "utf-8"),
|
|
10
|
+
writeFile: async (path, content) => {
|
|
11
|
+
const { dirname } = await import("node:path");
|
|
12
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
|
13
|
+
await fs.writeFile(path, content, "utf-8");
|
|
14
|
+
},
|
|
15
|
+
stat: (path) => fs.stat(path),
|
|
16
|
+
lstat: (path) => fs.lstat(path),
|
|
17
|
+
readdir: (path, options) => fs.readdir(path, options),
|
|
18
|
+
mkdir: (path) => fs.mkdir(path, { recursive: true }).then(() => { }),
|
|
19
|
+
createReadStream: (path, encoding) => createReadStream(path, { encoding }),
|
|
20
|
+
spawn: (command, args, options) => spawn(command, args, {
|
|
21
|
+
cwd: options.cwd,
|
|
22
|
+
env: options.env,
|
|
23
|
+
detached: options.detached,
|
|
24
|
+
stdio: options.stdio,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/tools/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AA2C5D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAE9C,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QACjC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QAC9C,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;IAE7B,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;IAE/B,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAsB;IAE1E,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;IAEnE,gBAAgB,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;IAE1E,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAChC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;QACnB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAA2E;KAC3F,CAAC;CACL,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export declare function resolvePath(cwd: string, filePath: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Check if a path is a symlink. Used by file tools to prevent symlink-based
|
|
4
|
+
* attacks that could read/write sensitive files outside the working directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare function rejectSymlink(resolved: string): Promise<void>;
|
|
2
7
|
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnE"}
|
package/dist/tools/path-utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
export function resolvePath(cwd, filePath) {
|
|
@@ -6,4 +7,21 @@ export function resolvePath(cwd, filePath) {
|
|
|
6
7
|
}
|
|
7
8
|
return path.resolve(cwd, filePath);
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a path is a symlink. Used by file tools to prevent symlink-based
|
|
12
|
+
* attacks that could read/write sensitive files outside the working directory.
|
|
13
|
+
*/
|
|
14
|
+
export async function rejectSymlink(resolved) {
|
|
15
|
+
try {
|
|
16
|
+
const stat = await fs.lstat(resolved);
|
|
17
|
+
if (stat.isSymbolicLink()) {
|
|
18
|
+
throw new Error(`Refusing to follow symlink: ${resolved}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
// Re-throw our own error; swallow ENOENT (file doesn't exist yet, e.g. write/new file)
|
|
23
|
+
if (err instanceof Error && err.message.startsWith("Refusing to follow"))
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
9
27
|
//# sourceMappingURL=path-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAgB;IACvD,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC"}
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAgB;IACvD,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,uFAAuF;QACvF,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC;YAAE,MAAM,GAAG,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-mode.test.d.ts","sourceRoot":"","sources":["../../src/tools/plan-mode.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import { createEnterPlanTool } from "./enter-plan.js";
|
|
6
|
+
import { createExitPlanTool } from "./exit-plan.js";
|
|
7
|
+
import { createWriteTool } from "./write.js";
|
|
8
|
+
import { createEditTool } from "./edit.js";
|
|
9
|
+
import { createBashTool } from "./bash.js";
|
|
10
|
+
import { ProcessManager } from "../core/process-manager.js";
|
|
11
|
+
import { buildSystemPrompt } from "../system-prompt.js";
|
|
12
|
+
function resultToString(result) {
|
|
13
|
+
return typeof result === "string" ? result : result.content;
|
|
14
|
+
}
|
|
15
|
+
const mockContext = {
|
|
16
|
+
signal: new AbortController().signal,
|
|
17
|
+
toolCallId: "test-1",
|
|
18
|
+
};
|
|
19
|
+
// ── enter_plan tool ──────────────────────────────────────
|
|
20
|
+
describe("createEnterPlanTool", () => {
|
|
21
|
+
it("calls onEnterPlan callback and returns instructions", async () => {
|
|
22
|
+
let calledWith;
|
|
23
|
+
const tool = createEnterPlanTool((reason) => {
|
|
24
|
+
calledWith = reason;
|
|
25
|
+
});
|
|
26
|
+
const result = resultToString(await tool.execute({ reason: "complex task" }, mockContext));
|
|
27
|
+
expect(calledWith).toBe("complex task");
|
|
28
|
+
expect(result).toContain("Plan mode activated");
|
|
29
|
+
expect(result).toContain(".ezcoder/plans/");
|
|
30
|
+
expect(result).toContain("exit_plan");
|
|
31
|
+
});
|
|
32
|
+
it("works without a reason", async () => {
|
|
33
|
+
let called = false;
|
|
34
|
+
const tool = createEnterPlanTool(() => {
|
|
35
|
+
called = true;
|
|
36
|
+
});
|
|
37
|
+
await tool.execute({}, mockContext);
|
|
38
|
+
expect(called).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
// ── exit_plan tool ───────────────────────────────────────
|
|
42
|
+
describe("createExitPlanTool", () => {
|
|
43
|
+
let tmpDir;
|
|
44
|
+
beforeEach(async () => {
|
|
45
|
+
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "exit-plan-test-"));
|
|
46
|
+
await fs.mkdir(path.join(tmpDir, ".ezcoder", "plans"), { recursive: true });
|
|
47
|
+
});
|
|
48
|
+
afterEach(async () => {
|
|
49
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
50
|
+
});
|
|
51
|
+
it("rejects paths outside .ezcoder/plans/", async () => {
|
|
52
|
+
const tool = createExitPlanTool(tmpDir, async () => "ok");
|
|
53
|
+
const result = resultToString(await tool.execute({ plan_path: "src/hack.ts" }, mockContext));
|
|
54
|
+
expect(result).toContain("Error");
|
|
55
|
+
expect(result).toContain(".ezcoder/plans/");
|
|
56
|
+
});
|
|
57
|
+
it("rejects empty plan files", async () => {
|
|
58
|
+
const planPath = path.join(tmpDir, ".ezcoder", "plans", "empty.md");
|
|
59
|
+
await fs.writeFile(planPath, " \n \n");
|
|
60
|
+
const tool = createExitPlanTool(tmpDir, async () => "should not reach");
|
|
61
|
+
const result = resultToString(await tool.execute({ plan_path: ".ezcoder/plans/empty.md" }, mockContext));
|
|
62
|
+
expect(result).toContain("Error");
|
|
63
|
+
expect(result).toContain("empty");
|
|
64
|
+
});
|
|
65
|
+
it("rejects non-existent plan files", async () => {
|
|
66
|
+
const tool = createExitPlanTool(tmpDir, async () => "should not reach");
|
|
67
|
+
const result = resultToString(await tool.execute({ plan_path: ".ezcoder/plans/ghost.md" }, mockContext));
|
|
68
|
+
expect(result).toContain("Error");
|
|
69
|
+
expect(result).toContain("Could not read");
|
|
70
|
+
});
|
|
71
|
+
it("calls onExitPlan for valid plans and returns the result", async () => {
|
|
72
|
+
const planPath = path.join(tmpDir, ".ezcoder", "plans", "my-plan.md");
|
|
73
|
+
await fs.writeFile(planPath, "# Plan\n\n1. Step one\n2. Step two\n");
|
|
74
|
+
let receivedPath = "";
|
|
75
|
+
const tool = createExitPlanTool(tmpDir, async (p) => {
|
|
76
|
+
receivedPath = p;
|
|
77
|
+
return "Plan submitted.";
|
|
78
|
+
});
|
|
79
|
+
const result = resultToString(await tool.execute({ plan_path: ".ezcoder/plans/my-plan.md" }, mockContext));
|
|
80
|
+
expect(receivedPath).toBe(planPath);
|
|
81
|
+
expect(result).toBe("Plan submitted.");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
// ── Tool restrictions in plan mode ───────────────────────
|
|
85
|
+
describe("plan mode tool restrictions", () => {
|
|
86
|
+
let tmpDir;
|
|
87
|
+
const planModeRef = { current: false };
|
|
88
|
+
beforeEach(async () => {
|
|
89
|
+
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "plan-restrict-test-"));
|
|
90
|
+
planModeRef.current = false;
|
|
91
|
+
});
|
|
92
|
+
afterEach(async () => {
|
|
93
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
94
|
+
});
|
|
95
|
+
describe("bash", () => {
|
|
96
|
+
it("allows execution when plan mode is off", async () => {
|
|
97
|
+
const pm = new ProcessManager();
|
|
98
|
+
const tool = createBashTool(tmpDir, pm, undefined, planModeRef);
|
|
99
|
+
const result = resultToString(await tool.execute({ command: "echo hello" }, mockContext));
|
|
100
|
+
expect(result).toContain("Exit code: 0");
|
|
101
|
+
expect(result).toContain("hello");
|
|
102
|
+
pm.shutdownAll();
|
|
103
|
+
});
|
|
104
|
+
it("blocks execution when plan mode is on", async () => {
|
|
105
|
+
planModeRef.current = true;
|
|
106
|
+
const pm = new ProcessManager();
|
|
107
|
+
const tool = createBashTool(tmpDir, pm, undefined, planModeRef);
|
|
108
|
+
const result = resultToString(await tool.execute({ command: "echo hello" }, mockContext));
|
|
109
|
+
expect(result).toContain("Error");
|
|
110
|
+
expect(result).toContain("restricted in plan mode");
|
|
111
|
+
pm.shutdownAll();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe("edit", () => {
|
|
115
|
+
it("blocks execution when plan mode is on", async () => {
|
|
116
|
+
planModeRef.current = true;
|
|
117
|
+
const readFiles = new Set();
|
|
118
|
+
const tool = createEditTool(tmpDir, readFiles, undefined, planModeRef);
|
|
119
|
+
const result = resultToString(await tool.execute({ file_path: "test.ts", old_text: "foo", new_text: "bar" }, mockContext));
|
|
120
|
+
expect(result).toContain("Error");
|
|
121
|
+
expect(result).toContain("restricted in plan mode");
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe("write", () => {
|
|
125
|
+
it("blocks writing to non-plan paths when plan mode is on", async () => {
|
|
126
|
+
planModeRef.current = true;
|
|
127
|
+
const tool = createWriteTool(tmpDir, undefined, undefined, planModeRef);
|
|
128
|
+
const result = resultToString(await tool.execute({ file_path: "src/hack.ts", content: "malicious" }, mockContext));
|
|
129
|
+
expect(result).toContain("Error");
|
|
130
|
+
expect(result).toContain("restricted in plan mode");
|
|
131
|
+
expect(result).toContain(".ezcoder/plans/");
|
|
132
|
+
});
|
|
133
|
+
it("allows writing to .ezcoder/plans/ when plan mode is on", async () => {
|
|
134
|
+
planModeRef.current = true;
|
|
135
|
+
const tool = createWriteTool(tmpDir, undefined, undefined, planModeRef);
|
|
136
|
+
const result = resultToString(await tool.execute({ file_path: ".ezcoder/plans/my-plan.md", content: "# Plan\n\nDo stuff." }, mockContext));
|
|
137
|
+
expect(result).toContain("Wrote");
|
|
138
|
+
expect(result).toContain("bytes");
|
|
139
|
+
// Verify file was actually created
|
|
140
|
+
const written = await fs.readFile(path.join(tmpDir, ".ezcoder", "plans", "my-plan.md"), "utf-8");
|
|
141
|
+
expect(written).toBe("# Plan\n\nDo stuff.");
|
|
142
|
+
});
|
|
143
|
+
it("creates .ezcoder/plans/ directory if it doesn't exist", async () => {
|
|
144
|
+
planModeRef.current = true;
|
|
145
|
+
const tool = createWriteTool(tmpDir, undefined, undefined, planModeRef);
|
|
146
|
+
await tool.execute({ file_path: ".ezcoder/plans/auto-created.md", content: "# Plan" }, mockContext);
|
|
147
|
+
const stat = await fs.stat(path.join(tmpDir, ".ezcoder", "plans"));
|
|
148
|
+
expect(stat.isDirectory()).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
it("allows writing anywhere when plan mode is off", async () => {
|
|
151
|
+
planModeRef.current = false;
|
|
152
|
+
const tool = createWriteTool(tmpDir, undefined, undefined, planModeRef);
|
|
153
|
+
const result = resultToString(await tool.execute({ file_path: "src/normal.ts", content: "export const x = 1;" }, mockContext));
|
|
154
|
+
expect(result).toContain("Wrote");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
// ── System prompt generation ─────────────────────────────
|
|
159
|
+
describe("buildSystemPrompt with plan mode", () => {
|
|
160
|
+
let tmpDir;
|
|
161
|
+
beforeEach(async () => {
|
|
162
|
+
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "prompt-test-"));
|
|
163
|
+
});
|
|
164
|
+
afterEach(async () => {
|
|
165
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
166
|
+
});
|
|
167
|
+
it("includes plan mode section when planMode is true", async () => {
|
|
168
|
+
const prompt = await buildSystemPrompt(tmpDir, [], true);
|
|
169
|
+
expect(prompt).toContain("Plan Mode (ACTIVE)");
|
|
170
|
+
expect(prompt).toContain("read-only");
|
|
171
|
+
expect(prompt).toContain("exit_plan");
|
|
172
|
+
expect(prompt).toContain(".ezcoder/plans/");
|
|
173
|
+
});
|
|
174
|
+
it("does not include plan mode section when planMode is false", async () => {
|
|
175
|
+
const prompt = await buildSystemPrompt(tmpDir, [], false);
|
|
176
|
+
expect(prompt).not.toContain("Plan Mode (ACTIVE)");
|
|
177
|
+
});
|
|
178
|
+
it("includes enter_plan and exit_plan tool descriptions", async () => {
|
|
179
|
+
const prompt = await buildSystemPrompt(tmpDir, [], false);
|
|
180
|
+
expect(prompt).toContain("enter_plan");
|
|
181
|
+
expect(prompt).toContain("exit_plan");
|
|
182
|
+
});
|
|
183
|
+
it("includes approved plan when approvedPlanPath is set", async () => {
|
|
184
|
+
const plansDir = path.join(tmpDir, ".ezcoder", "plans");
|
|
185
|
+
await fs.mkdir(plansDir, { recursive: true });
|
|
186
|
+
const planPath = path.join(plansDir, "approved.md");
|
|
187
|
+
await fs.writeFile(planPath, "# My Plan\n\n1. Do this\n2. Do that\n");
|
|
188
|
+
const prompt = await buildSystemPrompt(tmpDir, [], false, planPath);
|
|
189
|
+
expect(prompt).toContain("Approved Plan");
|
|
190
|
+
expect(prompt).toContain("approved.md");
|
|
191
|
+
expect(prompt).toContain("# My Plan");
|
|
192
|
+
expect(prompt).toContain("Do this");
|
|
193
|
+
expect(prompt).toContain("Follow the plan");
|
|
194
|
+
});
|
|
195
|
+
it("does not include approved plan section when no path is set", async () => {
|
|
196
|
+
const prompt = await buildSystemPrompt(tmpDir, [], false);
|
|
197
|
+
expect(prompt).not.toContain("Approved Plan");
|
|
198
|
+
expect(prompt).not.toContain("<approved_plan>");
|
|
199
|
+
});
|
|
200
|
+
it("does not include approved plan when in plan mode (even if path is set)", async () => {
|
|
201
|
+
const planPath = path.join(tmpDir, "fake-plan.md");
|
|
202
|
+
const prompt = await buildSystemPrompt(tmpDir, [], true, planPath);
|
|
203
|
+
// Plan mode section should be present, but not the approved plan
|
|
204
|
+
expect(prompt).toContain("Plan Mode (ACTIVE)");
|
|
205
|
+
expect(prompt).not.toContain("Approved Plan");
|
|
206
|
+
});
|
|
207
|
+
it("gracefully handles missing approved plan file", async () => {
|
|
208
|
+
const prompt = await buildSystemPrompt(tmpDir, [], false, "/nonexistent/plan.md");
|
|
209
|
+
// Should not crash, and should not include the section
|
|
210
|
+
expect(prompt).not.toContain("Approved Plan");
|
|
211
|
+
expect(prompt).not.toContain("<approved_plan>");
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
//# sourceMappingURL=plan-mode.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-mode.test.js","sourceRoot":"","sources":["../../src/tools/plan-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,SAAS,cAAc,CAAC,MAAoC;IAC1D,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;IACpC,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,4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AC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;QACtF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEnE,iEAAiE;QACjE,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;QAElF,uDAAuD;QACvD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/tools/read.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AgentTool } from "@prestyj/agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
3
4
|
export declare const BINARY_EXTENSIONS: Set<string>;
|
|
4
5
|
declare const ReadParams: z.ZodObject<{
|
|
5
6
|
file_path: z.ZodString;
|
|
6
7
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
7
8
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
8
9
|
}, z.core.$strip>;
|
|
9
|
-
export declare function createReadTool(cwd: string, readFiles?: Set<string
|
|
10
|
+
export declare function createReadTool(cwd: string, readFiles?: Set<string>, ops?: ToolOperations): AgentTool<typeof ReadParams>;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=read.d.ts.map
|
package/dist/tools/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,eAAO,MAAM,iBAAiB,aAqD5B,CAAC;AAEH,QAAA,MAAM,UAAU;;;;iBASd,CAAC;AAEH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,GAAG,GAAE,cAAgC,GACpC,SAAS,CAAC,OAAO,UAAU,CAAC,CAmD9B"}
|