Skip to content

Commit f77189b

Browse files
committed
Type cleanup
1 parent e3c11af commit f77189b

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

src/core/prompts/sections/__tests__/custom-instructions.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ describe("addCustomInstructions", () => {
505505
expect(result).toContain("Rules from .roorules-test-mode:\nmode specific rules")
506506
})
507507

508-
it("should load AGENTS.md when useAgentRules is true", async () => {
508+
it("should load AGENTS.md when settings.useAgentRules is true", async () => {
509509
// Simulate no .roo/rules-test-mode directory
510510
statMock.mockRejectedValueOnce({ code: "ENOENT" })
511511

@@ -522,15 +522,15 @@ describe("addCustomInstructions", () => {
522522
"global instructions",
523523
"/fake/path",
524524
"test-mode",
525-
{ useAgentRules: true },
525+
{ settings: { useAgentRules: true } },
526526
)
527527

528528
expect(result).toContain("# Agent Rules Standard (AGENTS.md):")
529529
expect(result).toContain("Agent rules from AGENTS.md file")
530530
expect(readFileMock).toHaveBeenCalledWith(expect.stringContaining("AGENTS.md"), "utf-8")
531531
})
532532

533-
it("should not load AGENTS.md when useAgentRules is false", async () => {
533+
it("should not load AGENTS.md when settings.useAgentRules is false", async () => {
534534
// Simulate no .roo/rules-test-mode directory
535535
statMock.mockRejectedValueOnce({ code: "ENOENT" })
536536

@@ -547,14 +547,14 @@ describe("addCustomInstructions", () => {
547547
"global instructions",
548548
"/fake/path",
549549
"test-mode",
550-
{ useAgentRules: false },
550+
{ settings: { useAgentRules: false } },
551551
)
552552

553553
expect(result).not.toContain("# Agent Rules Standard (AGENTS.md):")
554554
expect(result).not.toContain("Agent rules from AGENTS.md file")
555555
})
556556

557-
it("should load AGENTS.md by default when useAgentRules is undefined", async () => {
557+
it("should load AGENTS.md by default when settings.useAgentRules is undefined", async () => {
558558
// Simulate no .roo/rules-test-mode directory
559559
statMock.mockRejectedValueOnce({ code: "ENOENT" })
560560

@@ -571,7 +571,7 @@ describe("addCustomInstructions", () => {
571571
"global instructions",
572572
"/fake/path",
573573
"test-mode",
574-
{}, // No useAgentRules specified
574+
{}, // No settings.useAgentRules specified
575575
)
576576

577577
expect(result).toContain("# Agent Rules Standard (AGENTS.md):")
@@ -590,7 +590,7 @@ describe("addCustomInstructions", () => {
590590
"global instructions",
591591
"/fake/path",
592592
"test-mode",
593-
{ useAgentRules: true },
593+
{ settings: { useAgentRules: true } },
594594
)
595595

596596
expect(result).toContain("Global Instructions:\nglobal instructions")
@@ -618,7 +618,7 @@ describe("addCustomInstructions", () => {
618618
"global instructions",
619619
"/fake/path",
620620
"test-mode",
621-
{ useAgentRules: true },
621+
{ settings: { useAgentRules: true } },
622622
)
623623

624624
// Should contain both AGENTS.md and .roorules content

src/core/prompts/sections/custom-instructions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Dirent } from "fs"
55

66
import { isLanguage } from "@roo-code/types"
77

8+
import type { SystemPromptSettings } from "../types"
9+
810
import { LANGUAGES } from "../../../shared/language"
911
import { getRooDirectoriesForCwd, getGlobalRooDirectory } from "../../../services/roo-config"
1012

@@ -238,8 +240,7 @@ export async function addCustomInstructions(
238240
options: {
239241
language?: string
240242
rooIgnoreInstructions?: string
241-
useAgentRules?: boolean
242-
settings?: Record<string, any>
243+
settings?: SystemPromptSettings
243244
} = {},
244245
): Promise<string> {
245246
const sections = []
@@ -319,7 +320,7 @@ export async function addCustomInstructions(
319320
}
320321

321322
// Add AGENTS.md content if enabled (default: true)
322-
if (options.useAgentRules !== false) {
323+
if (options.settings?.useAgentRules !== false) {
323324
const agentRulesContent = await loadAgentRulesFile(cwd)
324325
if (agentRulesContent && agentRulesContent.trim()) {
325326
rules.push(agentRulesContent.trim())

src/core/prompts/system.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as os from "os"
33

44
import type { ModeConfig, PromptComponent, CustomModePrompts, TodoItem } from "@roo-code/types"
55

6+
import type { SystemPromptSettings } from "./types"
7+
68
import { Mode, modes, defaultModeSlug, getModeBySlug, getGroupName, getModeSelection } from "../../shared/modes"
79
import { DiffStrategy } from "../../shared/tools"
810
import { formatLanguage } from "../../shared/language"
@@ -57,7 +59,7 @@ async function generatePrompt(
5759
language?: string,
5860
rooIgnoreInstructions?: string,
5961
partialReadsEnabled?: boolean,
60-
settings?: Record<string, any>,
62+
settings?: SystemPromptSettings,
6163
todoList?: TodoItem[],
6264
): Promise<string> {
6365
if (!context) {
@@ -122,7 +124,6 @@ ${getObjectiveSection(codeIndexManager, experiments)}
122124
${await addCustomInstructions(baseInstructions, globalCustomInstructions || "", cwd, mode, {
123125
language: language ?? formatLanguage(vscode.env.language),
124126
rooIgnoreInstructions,
125-
useAgentRules: settings?.useAgentRules,
126127
settings,
127128
})}`
128129

@@ -146,7 +147,7 @@ export const SYSTEM_PROMPT = async (
146147
language?: string,
147148
rooIgnoreInstructions?: string,
148149
partialReadsEnabled?: boolean,
149-
settings?: Record<string, any>,
150+
settings?: SystemPromptSettings,
150151
todoList?: TodoItem[],
151152
): Promise<string> => {
152153
if (!context) {
@@ -185,7 +186,6 @@ export const SYSTEM_PROMPT = async (
185186
{
186187
language: language ?? formatLanguage(vscode.env.language),
187188
rooIgnoreInstructions,
188-
useAgentRules: settings?.useAgentRules,
189189
settings,
190190
},
191191
)

src/core/prompts/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Settings passed to system prompt generation functions
3+
*/
4+
export interface SystemPromptSettings {
5+
maxConcurrentFileReads?: number
6+
todoListEnabled?: boolean
7+
useAgentRules?: boolean
8+
}

0 commit comments

Comments
 (0)