@phren/agent 0.1.12 → 0.1.13

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.
@@ -16,8 +16,10 @@ export async function runTurn(userInput, session, config, hooks) {
16
16
  const spinner = createSpinner();
17
17
  const useStream = typeof provider.chatStream === "function";
18
18
  const status = hooks?.onStatus ?? ((msg) => process.stderr.write(msg));
19
- // Plan mode: modify system prompt for first turn
20
- let planPending = config.plan && session.turns === 0;
19
+ // Plan mode: inject plan-first prompt and strip tools so the LLM
20
+ // describes its plan before executing anything. Works on any turn,
21
+ // not just the first, so mid-session plan mode toggles also apply.
22
+ let planPending = !!config.plan;
21
23
  if (planPending) {
22
24
  systemPrompt = injectPlanPrompt(systemPrompt);
23
25
  }
@@ -106,7 +108,8 @@ export async function runTurn(userInput, session, config, hooks) {
106
108
  // Plan mode gate: after first response, ask for approval
107
109
  if (planPending) {
108
110
  planPending = false;
109
- const { approved, feedback } = await requestPlanApproval();
111
+ const approve = hooks?.onPlanApproval ?? requestPlanApproval;
112
+ const { approved, feedback } = await approve();
110
113
  if (!approved) {
111
114
  // Always restore original system prompt on rejection to prevent plan prompt leaking
112
115
  systemPrompt = config.systemPrompt;
@@ -106,22 +106,9 @@ export function checkPermission(config, toolName, input) {
106
106
  }
107
107
  return { verdict: "ask", reason: `Auto-confirm mode requires confirmation for "${toolName}".` };
108
108
  case "plan":
109
- // Plan mode: same as auto-confirm for permissions, but agent loop enables plan-first flow
110
- if (AUTO_CONFIRM_TOOLS.has(toolName)) {
111
- return { verdict: "allow", reason: `Plan mode allows "${toolName}".` };
112
- }
113
- if (toolName === "shell") {
114
- const cwd = input.cwd || config.projectRoot;
115
- const cwdResult = validatePath(cwd, config.projectRoot, config.allowedPaths);
116
- if (cwdResult.ok) {
117
- const cmd = input.command || "";
118
- const safety = checkShellSafety(cmd);
119
- if (safety.safe) {
120
- return { verdict: "allow", reason: "Safe shell command within sandbox (plan mode)." };
121
- }
122
- }
123
- }
124
- return { verdict: "ask", reason: `Plan mode requires confirmation for "${toolName}".` };
109
+ // Plan mode: require explicit approval for ALL tool calls so the user
110
+ // can review the full plan before anything executes.
111
+ return { verdict: "ask", reason: `Plan mode requires approval for "${toolName}".` };
125
112
  case "full-auto":
126
113
  // Full-auto: allow everything not denied or warned
127
114
  return { verdict: "allow", reason: "Full-auto mode." };
@@ -104,6 +104,7 @@ export async function startInkTui(config, spawner) {
104
104
  function handlePermissionCycle() {
105
105
  const next = nextPermissionMode(config.registry.permissionConfig.mode, yoloEnabled);
106
106
  config.registry.setPermissions({ ...config.registry.permissionConfig, mode: next });
107
+ config.plan = next === "plan";
107
108
  savePermissionMode(next);
108
109
  update();
109
110
  }
@@ -360,6 +361,10 @@ export async function startInkTui(config, spawner) {
360
361
  currentToolCalls.push({ name, input, output: cleanOutput, isError, durationMs: dur, diffRendered });
361
362
  update();
362
363
  },
364
+ // In the TUI, plan approval is handled by per-tool permission prompts
365
+ // rather than a blocking readline prompt. Auto-approve the plan gate
366
+ // and let the permission checker require approval on each tool call.
367
+ onPlanApproval: async () => ({ approved: true }),
363
368
  getSteeringInput: () => {
364
369
  const result = (() => {
365
370
  if (steerQueueBuf.length > 0 && inputMode === "steering") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/agent",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Coding agent with persistent memory — powered by phren",
5
5
  "type": "module",
6
6
  "bin": {