Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .changeset/remove-experimental-plan-mode-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Always include the saved plan file hint when switching from Plan to Code, and remove the vestigial `KILO_EXPERIMENTAL_PLAN_MODE` flag.
2 changes: 0 additions & 2 deletions packages/core/src/flag/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ export const Flag = {

KILO_EXPERIMENTAL_LSP_TOOL: KILO_EXPERIMENTAL || truthy("KILO_EXPERIMENTAL_LSP_TOOL"), // kilocode_change

KILO_EXPERIMENTAL_PLAN_MODE: KILO_EXPERIMENTAL || truthy("KILO_EXPERIMENTAL_PLAN_MODE"), // kilocode_change

KILO_EXPERIMENTAL_SCOUT: KILO_EXPERIMENTAL || truthy("KILO_EXPERIMENTAL_SCOUT"), // kilocode_change

KILO_EXPERIMENTAL_MARKDOWN: !falsy("KILO_EXPERIMENTAL_MARKDOWN"), // kilocode_change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Priority:** P1
**Issue:** [#6143](https://github.com/Kilo-Org/kilocode/issues/6143)

An experimental plan mode prompt exists (`Flag.KILO_EXPERIMENTAL_PLAN_MODE`) that is verbose. Agent still tends to ask "Should I implement this?" repeatedly.
The plan mode prompt is verbose. The agent still tends to ask "Should I implement this?" repeatedly.

## Remaining Work

Expand Down
1 change: 0 additions & 1 deletion packages/opencode/src/effect/runtime-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class Service extends ConfigService.Service<Service>()("@opencode/Runtime
experimentalLspTy: bool("KILO_EXPERIMENTAL_LSP_TY"),
experimentalLspTool: enabledByExperimental("KILO_EXPERIMENTAL_LSP_TOOL"),
experimentalOxfmt: enabledByExperimental("KILO_EXPERIMENTAL_OXFMT"),
experimentalPlanMode: enabledByExperimental("KILO_EXPERIMENTAL_PLAN_MODE"),
experimentalCodeMode: enabledByExperimental("KILO_EXPERIMENTAL_CODE_MODE"),
experimentalEventSystem: enabledByExperimental("KILO_EXPERIMENTAL_EVENT_SYSTEM"),
experimentalSessionSwitcher: enabledByExperimental("KILO_EXPERIMENTAL_SESSION_SWITCHER"), // kilocode_change
Expand Down
24 changes: 0 additions & 24 deletions packages/opencode/src/session/reminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import { KiloSessionPrompt } from "@/kilocode/session/prompt" // kilocode_change
import { Agent } from "@/agent/agent"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { InstanceState } from "@/effect/instance-state"
import { RuntimeFlags } from "@/effect/runtime-flags"
import { PartID } from "./schema"
import { MessageV2 } from "./message-v2"
import { Session } from "./session"
import { SessionV1 } from "@opencode-ai/core/v1/session"
import CODE_SWITCH from "./prompt/code-switch.txt" // kilocode_change
import ASK_CODE_SWITCH from "@/kilocode/session/ask-code-switch.txt" // kilocode_change

export const apply = Effect.fn("SessionReminders.apply")(function* (input: {
messages: SessionV1.WithParts[]
agent: Agent.Info
session: Session.Info
}) {
const flags = yield* RuntimeFlags.Service
const fsys = yield* FSUtil.Service
const sessions = yield* Session.Service
const userMessage = input.messages.findLast((msg) => msg.info.role === "user")
Expand All @@ -40,26 +36,6 @@ export const apply = Effect.fn("SessionReminders.apply")(function* (input: {
if (switched) userMessage.parts.push(yield* sessions.updatePart(switched))
// kilocode_change end

if (!flags.experimentalPlanMode) {
const wasPlan = input.messages.some((msg) => msg.info.role === "assistant" && msg.info.agent === "plan")
if (
wasPlan &&
input.agent.name === "code" &&
!userMessage.parts.some((part) => part.type === "text" && part.text === ASK_CODE_SWITCH)
) {
// kilocode_change - renamed from "build" to "code"
userMessage.parts.push({
id: PartID.ascending(),
messageID: userMessage.info.id,
sessionID: userMessage.info.sessionID,
type: "text",
text: `\n\n${CODE_SWITCH}`, // kilocode_change - separated from user content
synthetic: true,
})
}
return input.messages
}

const assistantMessage = input.messages.findLast((msg) => msg.info.role === "assistant")
if (input.agent.name !== "plan" && assistantMessage?.info.agent === "plan") {
Comment thread
marius-kilocode marked this conversation as resolved.
Resolved
const ctx = yield* InstanceState.context
Expand Down
1 change: 0 additions & 1 deletion packages/opencode/test/effect/runtime-flags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ describe("RuntimeFlags", () => {
expect(flags.experimentalLspTy).toBe(false)
expect(flags.experimentalLspTool).toBe(true)
expect(flags.experimentalOxfmt).toBe(true)
expect(flags.experimentalPlanMode).toBe(true)
expect(flags.experimentalEventSystem).toBe(true)
expect(flags.experimentalWorkspaces).toBe(true)
expect(flags.experimentalIconDiscovery).toBe(true)
Expand Down
69 changes: 52 additions & 17 deletions packages/opencode/test/kilocode/reminders-separator.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { describe, expect, test } from "bun:test"
import { Effect, Layer } from "effect"
import fs from "fs/promises"
import path from "path"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { ProviderV2 } from "@opencode-ai/core/provider"
import { ModelV2 } from "@opencode-ai/core/model"
import { Agent } from "../../src/agent/agent"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { InstanceRef } from "../../src/effect/instance-ref"
import type { InstanceContext } from "../../src/project/instance-context"
import { Session } from "../../src/session/session"
import { SessionReminders } from "../../src/session/reminders"
import { MessageV2 } from "../../src/session/message-v2"
import { SessionID, MessageID, PartID } from "../../src/session/schema"
import { provideTestInstance, tmpdir } from "../fixture/fixture"

const sessionID = SessionID.make("ses_reminders")
const model = { providerID: ProviderV2.ID.make("openai"), modelID: ModelV2.ID.make("gpt-4") }
Expand Down Expand Up @@ -57,36 +61,67 @@ function assistantPlan(): MessageV2.WithParts {
} as unknown as MessageV2.WithParts
}

const apply = (messages: MessageV2.WithParts[]) =>
Effect.runPromise(
const session = { slug: "ses_reminders", time: { created: 0 } } as unknown as Session.Info

function apply(ctx: InstanceContext, messages: MessageV2.WithParts[]) {
return Effect.runPromise(
SessionReminders.apply({
messages,
agent: { name: "code" } as unknown as Agent.Info,
session: {} as unknown as Session.Info,
session,
}).pipe(
Effect.provideService(InstanceRef, ctx),
Effect.provide(
Layer.mergeAll(
RuntimeFlags.layer({ experimentalPlanMode: false }),
Layer.mock(Session.Service, {}),
Layer.mock(Session.Service, {
updatePart: <T extends MessageV2.Part>(part: T) => Effect.succeed(part),
}),
FSUtil.defaultLayer,
),
),
),
)
}

describe("SessionReminders plan-to-code switch", () => {
test("separates the code switch reminder from user text with blank lines", async () => {
const user = userMsg("write this to a file:")
const messages = [assistantPlan(), user]
const result = await apply(messages)
await using tmp = await tmpdir({ git: true })
await provideTestInstance({
directory: tmp.path,
fn: async (ctx) => {
const user = userMsg("write this to a file:")
const messages = [assistantPlan(), user]
const result = await apply(ctx, messages)

expect(result).toBe(messages)
expect(user.parts).toHaveLength(2)
const userText = user.parts[0] as MessageV2.TextPart
const reminder = user.parts[1] as MessageV2.TextPart
expect(userText.text).toBe("write this to a file:")
expect(reminder.type).toBe("text")
expect(reminder.synthetic).toBe(true)
expect(reminder.text.startsWith("\n\n<system-reminder>")).toBe(true)
},
})
})

test("appends the plan file hint without any experimental flag", async () => {
await using tmp = await tmpdir({ git: true })
await provideTestInstance({
directory: tmp.path,
fn: async (ctx) => {
const file = Session.plan(session, ctx)
await fs.mkdir(path.dirname(file), { recursive: true })
await Bun.write(file, "step 1")

expect(result).toBe(messages)
expect(user.parts).toHaveLength(2)
const userText = user.parts[0] as MessageV2.TextPart
const reminder = user.parts[1] as MessageV2.TextPart
expect(userText.text).toBe("write this to a file:")
expect(reminder.type).toBe("text")
expect(reminder.synthetic).toBe(true)
expect(reminder.text.startsWith("\n\n<system-reminder>")).toBe(true)
const user = userMsg("implement the plan:")
const messages = [assistantPlan(), user]
const result = await apply(ctx, messages)

expect(result).toBe(messages)
const reminder = user.parts.at(-1) as MessageV2.TextPart
expect(reminder.text).toContain(`A plan file exists at ${file}`)
},
})
})
})
Loading