ReviewOS

also looking at this

stacks/buddy

fix(agent): stop handing an agent text a stranger wrote as its instructions

#1414
Merged glennmichael123 wants to merge feat/plan-mode into main
9 files +425 -5
bin/cli.tsmodified+27-4
Changes to bin/cli.ts
@@ -1472,6 +1472,10 @@ cli
14721472 const { runFixCi } = await import('../src/ci')
14731473 return await runFixCi({ config, provider, prNumber, analysisOnly: true, logger })
14741474 },
1475 plan: async (number, isPullRequest, request) => {
1476 const { runPlan } = await import('../src/agent')
1477 return await runPlan({ config, provider, number, isPullRequest, request, logger })
1478 },
14751479 remember: async (text, context) => {
14761480 const { addLearning, createLearning, loadLearnings, serializeLearnings, DEFAULT_LEARNINGS_FILE }
14771481 = await import('../src/ai')
@@ -2967,17 +2971,36 @@ cli
29672971 await provider.updateIssue(issueNumber, { body: clearQuickSelection(issue.body) })
29682972
29692973 for (const action of selection.actions) {
2970 const { getFinishingTouch, runAgent } = await import('../src/agent')
2971 const touch = getFinishingTouch(action === 'build' ? 'autofix' : 'plan')
2974 // The issue title and body belong to whoever opened it, which on a
2975 // public repository is anyone. They used to be concatenated into the
2976 // task string — the half of the context the model is told to trust —
2977 // and for a ticked "build" that task drives an agent holding write,
2978 // shell and git tools. Both paths now read the issue through a tool,
2979 // so the runner frames it as third-party data.
2980 if (action === 'plan') {
2981 const { runPlan } = await import('../src/agent')
2982 const plan = await runPlan({ config, provider, number: issueNumber, isPullRequest: false, logger })
2983
2984 await provider.createComment(issueNumber, plan)
2985 logger.success('✅ Ran plan')
2986 continue
2987 }
2988
2989 const { BUILTIN_TOOLS, createReadIssueTool, getFinishingTouch, runAgent } = await import('../src/agent')
2990 const touch = getFinishingTouch('autofix')
29722991
29732992 const result = await runAgent(ai, {
29742993 mode: touch.mode,
2975 task: `${touch.buildTask({ summary: issue.title, files: [] })}\n\nIssue:\n${issue.body}`,
2994 task: `${touch.buildTask({ files: [] })}\n\nCall \`read_issue\` to see what was asked for.`,
2995 tools: [...BUILTIN_TOOLS, createReadIssueTool(provider, issueNumber, false)],
29762996 context: { workspace: process.cwd(), baseBranch: config.repository?.baseBranch ?? 'main' },
29772997 logger,
29782998 })
29792999
2980 await provider.createComment(issueNumber, result.output)
3000 await provider.createComment(
3001 issueNumber,
3002 result.output || `I could not finish that (${result.stopReason}).`,
3003 )
29813004 logger.success(`✅ Ran ${action}`)
29823005 }
29833006