Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/plan-followup-refine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kilocode/cli": patch
"kilo-code": patch
---

Show an interactive Implement / Keep refining panel when Plan mode is ready instead of asking users to type a numbered choice.
2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/ar.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/br.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/bs.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/da.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export const dict = {
"plan.followup.answer.newSession.description": "In einer neuen Sitzung mit leerem Kontext umsetzen",
"plan.followup.answer.continue": "Hier fortfahren",
"plan.followup.answer.continue.description": "Den Plan in dieser Sitzung umsetzen",
"plan.followup.answer.keepRefining": "Weiter verfeinern",
"plan.followup.answer.keepRefining.description": "Weiter planen, ohne jetzt zu implementieren",

// Slow-repo snapshot prompt
"snapshot.slowRepo.header": "Snapshot ist langsam",
Expand Down
2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export const dict = {
"plan.followup.answer.newSession.description": "Implement in a fresh session with a clean context",
"plan.followup.answer.continue": "Continue here",
"plan.followup.answer.continue.description": "Implement the plan in this session",
"plan.followup.answer.keepRefining": "Keep refining",
"plan.followup.answer.keepRefining.description": "Keep planning without implementing yet",

// Slow-repo snapshot prompt. The English strings here are the canonical
// labels sent by the backend and must stay in sync with
Expand Down
2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/es.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/fr.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/it.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/ja.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/ko.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/nl.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/no.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/pl.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/ru.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/th.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/tr.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/uk.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/zh.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilo-i18n/src/zht.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/kilo-telemetry/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export namespace Telemetry {
track(TelemetryEvent.AGENT_USED, { agent, sessionId })
}

export function trackPlanFollowup(sessionId: string, choice: "new_session" | "continue" | "custom" | "dismissed") {
export function trackPlanFollowup(
sessionId: string,
choice: "new_session" | "continue" | "keep_refining" | "custom" | "dismissed",
) {
track(TelemetryEvent.PLAN_FOLLOWUP, { sessionId, choice })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const keys = [
"plan.followup.answer.newSession.description",
"plan.followup.answer.continue",
"plan.followup.answer.continue.description",
"plan.followup.answer.keepRefining",
"plan.followup.answer.keepRefining.description",
]

describe("plan follow-up i18n keys", () => {
Expand Down
20 changes: 20 additions & 0 deletions packages/opencode/src/kilocode/plan-followup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export namespace PlanFollowup {
export const PLAN_PREFIX = "Implement the following plan:"
export const ANSWER_NEW_SESSION = "Start new session"
export const ANSWER_CONTINUE = "Continue here"
export const ANSWER_KEEP_REFINING = "Keep refining"

export function abort(sessionID: SessionID) {
const ctl = pending.get(sessionID)
Expand Down Expand Up @@ -320,6 +321,13 @@ export namespace PlanFollowup {
descriptionKey: "plan.followup.answer.continue.description",
mode: "code",
},
{
label: ANSWER_KEEP_REFINING,
labelKey: "plan.followup.answer.keepRefining",
description: "Keep planning without implementing yet",
descriptionKey: "plan.followup.answer.keepRefining.description",
mode: "plan",
},
],
},
],
Expand Down Expand Up @@ -540,6 +548,18 @@ export namespace PlanFollowup {
return "continue"
}

if (answer === ANSWER_KEEP_REFINING) {
Telemetry.trackPlanFollowup(input.sessionID, "keep_refining")
const msg = await inject({
sessionID: input.sessionID,
agent: "plan",
model: user.model,
text: "Continue refining the plan. Do not implement yet.",
})
KiloSessionPromptQueue.retarget(input.sessionID, msg.id)
return "continue"
}

Telemetry.trackPlanFollowup(input.sessionID, "custom")
const msg = await inject({
sessionID: input.sessionID,
Expand Down
13 changes: 4 additions & 9 deletions packages/opencode/src/kilocode/session/native-plan-prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Your job is to gather context, challenge assumptions, resolve design questions,
- Follow the latest Plan File reminder for the target plan location.
- If no exact plan file path is provided, follow the latest Plan File reminder for the directory and generated filename pattern.
- Use repo-root `plans/`, `.plans/`, or `.opencode/plans/` only when requested or required by the repo/client and your permissions allow it.
- Do not write the final plan or call `plan_exit` until the user chooses "Finalize and save the plan".
- After final approval, write the final plan to the chosen plan file, then call `plan_exit` with the saved plan path.
- When the plan is implementation-ready, write the final plan to the chosen plan file, then call `plan_exit` with the saved plan path.
- Do not edit source files or non-plan documentation files.
- Do not run mutating commands.
- If implementation requires source edits or mutating commands, tell the user to switch to an implementation-capable agent.
Expand All @@ -34,13 +33,9 @@ Your job is to gather context, challenge assumptions, resolve design questions,

- Keep planning until the important design decisions are resolved or explicitly marked out of scope.
- If material uncertainty remains, keep the plan open: summarize the current state, identify the most important unresolved decision, and ask exactly one next question with your recommended answer.
- If the plan is implementation-ready but not saved, do not print the full plan in chat. Give a concise draft-ready summary, then ask exactly one question with these choices:
1. Finalize and save the plan
2. Continue refining
- Recommend "Finalize and save the plan" only when the goal, constraints, affected boundaries, data flow, failure modes, rollout or migration path, and validation plan are addressed or explicitly out of scope.
- If the user chooses "Finalize and save the plan", write the complete finalized Markdown plan to the chosen plan file, then call `plan_exit` as described above.
- If the user chooses "Continue refining", keep planning and do not write the final plan or call `plan_exit`.
- After `plan_exit`, rely on the client follow-up to ask whether the user wants to implement the saved plan in a new session.
- If the plan is implementation-ready, write the complete finalized Markdown plan to the chosen plan file, then call `plan_exit` as described above.
- Call `plan_exit` only when the goal, constraints, affected boundaries, data flow, failure modes, rollout or migration path, and validation plan are addressed or explicitly out of scope.
- Follow the latest Plan File reminder for whether to confirm with the user before finalizing, and for what happens after `plan_exit`.
- Do not implement source or documentation changes as this agent.

Saved plans should be concise and actionable. Prefer a clear ordered task list over a lengthy design document. Include only the context, decisions, risks, validation steps, and open questions another implementation-capable agent needs to execute safely.
Expand Down
10 changes: 8 additions & 2 deletions packages/opencode/src/kilocode/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ export namespace KiloSessionPrompt {
return id === "architect" || name === "plan" || name === "architect"
}

function supportsPlanFollowup() {
return ["cli", "vscode", "jetbrains"].includes(Flag.KILO_CLIENT)
}

/**
* Determines whether the plan follow-up prompt should be shown.
* Checks if the plan_exit tool was called in the last assistant turn.
* Exported so tests can verify the logic independently.
*/
export function shouldAskPlanFollowup(input: { messages: MessageV2.WithParts[]; abort: AbortSignal }) {
if (input.abort.aborted) return false
if (!["cli", "vscode", "jetbrains"].includes(Flag.KILO_CLIENT)) return false
if (!supportsPlanFollowup()) return false
const idx = input.messages.findLastIndex((m) => m.info.role === "user")
return input.messages
.slice(idx + 1)
Expand Down Expand Up @@ -299,7 +303,9 @@ export namespace KiloSessionPrompt {
info,
"Use the chosen plan path as the main plan file. Do not write or edit other files unless the user explicitly asks and your permissions allow it.",
"Project/user instructions about plan location (for example plans/ or .plans/) are authorized when permissions allow them; they do not conflict with this reminder. When finalizing, call plan_exit with the path of the plan file you wrote.",
'Before creating or updating the plan file, or calling plan_exit, ask the user to choose exactly one of: "Finalize and save the plan" or "Continue refining". If the user chooses to finalize, write the main plan file, then call plan_exit.',
supportsPlanFollowup()
? "When the plan is implementation-ready, write the main plan file and call plan_exit. Do not ask the user to choose between finalizing and refining in chat; the client follow-up after plan_exit asks whether to implement the saved plan or keep refining."
: 'Before creating or updating the plan file, or calling plan_exit, ask the user to choose exactly one of: "Finalize and save the plan" or "Continue refining". If the user chooses to finalize, write the main plan file, then call plan_exit.',
].join("\n")
add(`<system-reminder>\n${body}\n</system-reminder>`)
}
Expand Down
Loading
Loading