Skip to content

Commit 1afa48a

Browse files
committed
Extract CLI prompt inlining character limits into named constants and reference them in build-cli-prompt
- extract 20000 1000 to `apps/editor/src/constants/values.ts`
1 parent 0283761 commit 1afa48a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/editor/src/constants/values.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export const MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE = 1000
44
export const GIT_LOG_SINCE_DURATION = '6 months ago'
55
export const SYMBOL_CACHE_DURATION = 5 * 60 * 1000
66

7+
export const MAX_CLI_PROMPT_TOTAL_INLINED_CHARS = 20000
8+
export const MAX_CLI_PROMPT_FILE_INLINED_CHARS = 1000
9+
710
export const DIFF_PLACEHOLDERS = {
811
FILE_CREATED: 'File created',
912
FILE_DELETED: 'File deleted',

‎apps/editor/src/views/prompt/backend/message-handlers/utils/build-cli-prompt.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
44
import { replace_symbols } from '@/views/prompt/backend/utils/symbols/replace-symbols'
55
import { cli_edit_ask_task_scope } from '@/constants/instructions'
66
import { LAST_SELECTED_WORKSPACE_IN_AGENTIC_CLI_STATE_KEY } from '@/constants/state-keys'
7+
import {
8+
MAX_CLI_PROMPT_TOTAL_INLINED_CHARS,
9+
MAX_CLI_PROMPT_FILE_INLINED_CHARS
10+
} from '@/constants/values'
711

812
export const build_cli_prompt = async (params: {
913
prompt_view_provider: PromptViewProvider
@@ -67,7 +71,7 @@ export const build_cli_prompt = async (params: {
6771
let are_all_files_preloaded = false
6872
let are_any_files_preloaded = false
6973

70-
if (total_content_length <= 20000) {
74+
if (total_content_length <= MAX_CLI_PROMPT_TOTAL_INLINED_CHARS) {
7175
are_all_files_preloaded = true
7276
are_any_files_preloaded = files_data.length > 0
7377
const file_blocks = files_data.map((data) =>
@@ -84,8 +88,8 @@ export const build_cli_prompt = async (params: {
8488
for (const data of files_data) {
8589
if (data.content !== undefined) {
8690
if (
87-
data.content.length <= 1000 &&
88-
total_inlined_characters + data.content.length <= 20000
91+
data.content.length <= MAX_CLI_PROMPT_FILE_INLINED_CHARS &&
92+
total_inlined_characters + data.content.length <= MAX_CLI_PROMPT_TOTAL_INLINED_CHARS
8993
) {
9094
total_inlined_characters += data.content.length
9195
file_blocks.push(

0 commit comments

Comments
 (0)