Skip to content

Commit d0856bc

Browse files
fix: removed custom instructions from settings and added .hairules (#75)
1 parent 258c719 commit d0856bc

File tree

19 files changed

+129
-668
lines changed

19 files changed

+129
-668
lines changed

.changeset/plenty-llamas-rush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hai-build-code-generator": patch
3+
---
4+
5+
Removed custom instructions upload and added quick start for .hairules

src/core/Cline.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ import { arePathsEqual, getReadablePath } from "../utils/path"
5454
import { fixModelHtmlEscaping, removeInvalidChars } from "../utils/string"
5555
import { AssistantMessageContent, parseAssistantMessage, ToolParamName, ToolUseName } from "./assistant-message"
5656
import { constructNewFileContent } from "./assistant-message/diff"
57-
import { HaiBuildContextOptions, HaiInstructionFile } from "../shared/customApi"
57+
import { HaiBuildContextOptions } from "../shared/customApi"
5858
import { buildTreeString } from "../utils/customFs"
5959
import { FindFilesToEditAgent } from "../integrations/code-prep/FindFilesToEditAgent"
6060
import { CodeScanner } from "../integrations/security/code-scan"
6161
import { ToolUse } from "./assistant-message"
62-
import { readInstructionsFromFiles } from "../utils/instructions"
6362
import { isCommandIncludedInSecretScanning, isSecretFile } from "../integrations/secret-scanning"
6463
import { ClineIgnoreController, LOCK_TEXT_SYMBOL } from "./ignore/ClineIgnoreController"
6564
import { parseMentions } from "./mentions"
@@ -80,7 +79,6 @@ export class Cline {
8079
api: ApiHandler
8180
private terminalManager: TerminalManager
8281
private urlContentFetcher: UrlContentFetcher
83-
isCustomInstructionsEnabled: boolean
8482
browserSession: BrowserSession
8583
private didEditFile: boolean = false
8684
customInstructions?: string
@@ -126,7 +124,6 @@ export class Cline {
126124
private apiConfiguration: ApiConfiguration
127125
private embeddingConfiguration: EmbeddingConfiguration
128126
private filesEditedByAI: Set<string> = new Set([])
129-
fileInstructions: HaiInstructionFile[] | undefined
130127
private didAutomaticallyRetryFailedApiRequest = false
131128

132129
constructor(
@@ -137,11 +134,9 @@ export class Cline {
137134
chatSettings: ChatSettings,
138135
embeddingConfiguration: EmbeddingConfiguration,
139136
customInstructions?: string,
140-
fileInstructions?: HaiInstructionFile[],
141137
task?: string,
142138
images?: string[],
143139
historyItem?: HistoryItem,
144-
isCustomInstructionsEnabled: boolean = true,
145140
) {
146141
this.clineIgnoreController = new ClineIgnoreController(cwd)
147142
this.clineIgnoreController.initialize().catch((error) => {
@@ -154,8 +149,6 @@ export class Cline {
154149
this.browserSession = new BrowserSession(provider.context, browserSettings)
155150
this.diffViewProvider = new DiffViewProvider(cwd)
156151
this.customInstructions = customInstructions
157-
this.isCustomInstructionsEnabled = isCustomInstructionsEnabled
158-
this.fileInstructions = fileInstructions
159152
this.autoApprovalSettings = autoApprovalSettings
160153
this.browserSettings = browserSettings
161154
this.chatSettings = chatSettings
@@ -1289,10 +1282,7 @@ export class Cline {
12891282

12901283
const supportsCodeIndex = this.buildContextOptions?.useIndex ?? false
12911284
let systemPrompt = await SYSTEM_PROMPT(cwd, supportsComputerUse, supportsCodeIndex, mcpHub, this.browserSettings)
1292-
let isCustomInstructionsEnabled = (await this.providerRef.deref()?.customGetState("isCustomInstructionsEnabled")) as any
1293-
let settingsCustomInstructions = isCustomInstructionsEnabled ? this.customInstructions?.trim() : undefined
1294-
let instructionStates = (await this.providerRef.deref()?.customGetState("fileInstructions")) as any
1295-
let fileInstructions = await readInstructionsFromFiles(instructionStates)
1285+
let settingsCustomInstructions = this.customInstructions?.trim()
12961286

12971287
const clineRulesFilePath = path.resolve(cwd, GlobalFileNames.clineRules)
12981288
let clineRulesFileInstructions: string | undefined
@@ -1313,14 +1303,9 @@ export class Cline {
13131303
clineIgnoreInstructions = `# .haiignore\n\n(The following is provided by a root-level .haiignore file where the user has specified files and directories that should not be accessed. When using list_files, you'll notice a ${LOCK_TEXT_SYMBOL} next to files that are blocked. Attempting to access the file's contents e.g. through read_file will result in an error.)\n\n${clineIgnoreContent}\n.haiignore`
13141304
}
13151305

1316-
if (settingsCustomInstructions || clineRulesFileInstructions || fileInstructions) {
1306+
if (settingsCustomInstructions || clineRulesFileInstructions) {
13171307
// altering the system prompt mid-task will break the prompt cache, but in the grand scheme this will not change often so it's better to not pollute user messages with it the way we have to with <potentially relevant details>
1318-
systemPrompt += addUserInstructions(
1319-
settingsCustomInstructions,
1320-
clineRulesFileInstructions,
1321-
fileInstructions,
1322-
clineIgnoreInstructions,
1323-
)
1308+
systemPrompt += addUserInstructions(settingsCustomInstructions, clineRulesFileInstructions, clineIgnoreInstructions)
13241309
}
13251310

13261311
// If the previous API request's total token usage is close to the context window, truncate the conversation history to free up space for the new request

src/core/prompts/system.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ ${customObjectivePrompt(supportsCodeIndex)}`
991991
export function addUserInstructions(
992992
settingsCustomInstructions?: string,
993993
clineRulesFileInstructions?: string,
994-
fileInstructions?: string,
995994
clineIgnoreInstructions?: string,
996995
) {
997996
let customInstructions = ""
@@ -1001,9 +1000,6 @@ export function addUserInstructions(
10011000
if (clineRulesFileInstructions) {
10021001
customInstructions += clineRulesFileInstructions + "\n\n"
10031002
}
1004-
if (fileInstructions) {
1005-
customInstructions += fileInstructions + "\n\n"
1006-
}
10071003
if (clineIgnoreInstructions) {
10081004
customInstructions += clineIgnoreInstructions
10091005
}

0 commit comments

Comments
 (0)