@vybestack/llxprt-code-core 0.1.23-nightly.250905.97906524 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/src/adapters/IStreamAdapter.d.ts +3 -3
  2. package/dist/src/auth/precedence.d.ts +1 -1
  3. package/dist/src/auth/precedence.js +9 -4
  4. package/dist/src/auth/precedence.js.map +1 -1
  5. package/dist/src/auth/types.d.ts +4 -4
  6. package/dist/src/code_assist/codeAssist.js +8 -6
  7. package/dist/src/code_assist/codeAssist.js.map +1 -1
  8. package/dist/src/code_assist/setup.js +9 -7
  9. package/dist/src/code_assist/setup.js.map +1 -1
  10. package/dist/src/config/index.d.ts +7 -0
  11. package/dist/src/config/index.js +8 -0
  12. package/dist/src/config/index.js.map +1 -0
  13. package/dist/src/core/client.d.ts +9 -21
  14. package/dist/src/core/client.js +55 -156
  15. package/dist/src/core/client.js.map +1 -1
  16. package/dist/src/core/compression-config.d.ts +1 -1
  17. package/dist/src/core/compression-config.js +4 -5
  18. package/dist/src/core/compression-config.js.map +1 -1
  19. package/dist/src/core/coreToolScheduler.js +50 -15
  20. package/dist/src/core/coreToolScheduler.js.map +1 -1
  21. package/dist/src/core/geminiChat.d.ts +51 -2
  22. package/dist/src/core/geminiChat.js +616 -106
  23. package/dist/src/core/geminiChat.js.map +1 -1
  24. package/dist/src/core/nonInteractiveToolExecutor.js +70 -19
  25. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  26. package/dist/src/core/prompts.js +34 -26
  27. package/dist/src/core/prompts.js.map +1 -1
  28. package/dist/src/core/turn.d.ts +1 -0
  29. package/dist/src/core/turn.js +8 -6
  30. package/dist/src/core/turn.js.map +1 -1
  31. package/dist/src/index.d.ts +1 -2
  32. package/dist/src/index.js +2 -2
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/prompt-config/TemplateEngine.js +17 -0
  35. package/dist/src/prompt-config/TemplateEngine.js.map +1 -1
  36. package/dist/src/prompt-config/defaults/core-defaults.js +39 -32
  37. package/dist/src/prompt-config/defaults/core-defaults.js.map +1 -1
  38. package/dist/src/prompt-config/defaults/core.md +2 -0
  39. package/dist/src/prompt-config/defaults/provider-defaults.js +34 -27
  40. package/dist/src/prompt-config/defaults/provider-defaults.js.map +1 -1
  41. package/dist/src/prompt-config/defaults/providers/gemini/core.md +229 -43
  42. package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md +12 -0
  43. package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md +12 -0
  44. package/dist/src/prompt-config/types.d.ts +2 -0
  45. package/dist/src/providers/BaseProvider.d.ts +32 -6
  46. package/dist/src/providers/BaseProvider.js +79 -22
  47. package/dist/src/providers/BaseProvider.js.map +1 -1
  48. package/dist/src/providers/IProvider.d.ts +9 -3
  49. package/dist/src/providers/LoggingProviderWrapper.d.ts +10 -3
  50. package/dist/src/providers/LoggingProviderWrapper.js +33 -27
  51. package/dist/src/providers/LoggingProviderWrapper.js.map +1 -1
  52. package/dist/src/providers/ProviderContentGenerator.d.ts +2 -2
  53. package/dist/src/providers/ProviderContentGenerator.js +9 -6
  54. package/dist/src/providers/ProviderContentGenerator.js.map +1 -1
  55. package/dist/src/providers/anthropic/AnthropicProvider.d.ts +27 -21
  56. package/dist/src/providers/anthropic/AnthropicProvider.js +473 -472
  57. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
  58. package/dist/src/providers/gemini/GeminiProvider.d.ts +14 -9
  59. package/dist/src/providers/gemini/GeminiProvider.js +202 -486
  60. package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
  61. package/dist/src/providers/openai/ConversationCache.d.ts +3 -3
  62. package/dist/src/providers/openai/IChatGenerateParams.d.ts +9 -4
  63. package/dist/src/providers/openai/OpenAIProvider.d.ts +44 -115
  64. package/dist/src/providers/openai/OpenAIProvider.js +535 -948
  65. package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
  66. package/dist/src/providers/openai/buildResponsesRequest.d.ts +3 -3
  67. package/dist/src/providers/openai/buildResponsesRequest.js +67 -37
  68. package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -1
  69. package/dist/src/providers/openai/estimateRemoteTokens.d.ts +2 -2
  70. package/dist/src/providers/openai/estimateRemoteTokens.js +21 -8
  71. package/dist/src/providers/openai/estimateRemoteTokens.js.map +1 -1
  72. package/dist/src/providers/openai/parseResponsesStream.d.ts +6 -2
  73. package/dist/src/providers/openai/parseResponsesStream.js +99 -391
  74. package/dist/src/providers/openai/parseResponsesStream.js.map +1 -1
  75. package/dist/src/providers/openai/syntheticToolResponses.d.ts +5 -5
  76. package/dist/src/providers/openai/syntheticToolResponses.js +102 -91
  77. package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -1
  78. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.d.ts +18 -20
  79. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js +250 -239
  80. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js.map +1 -1
  81. package/dist/src/providers/tokenizers/OpenAITokenizer.js +3 -3
  82. package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +1 -1
  83. package/dist/src/providers/types.d.ts +1 -1
  84. package/dist/src/services/history/ContentConverters.d.ts +6 -1
  85. package/dist/src/services/history/ContentConverters.js +155 -18
  86. package/dist/src/services/history/ContentConverters.js.map +1 -1
  87. package/dist/src/services/history/HistoryService.d.ts +52 -0
  88. package/dist/src/services/history/HistoryService.js +245 -93
  89. package/dist/src/services/history/HistoryService.js.map +1 -1
  90. package/dist/src/services/history/IContent.d.ts +4 -0
  91. package/dist/src/services/history/IContent.js.map +1 -1
  92. package/dist/src/telemetry/types.d.ts +16 -4
  93. package/dist/src/telemetry/types.js.map +1 -1
  94. package/dist/src/tools/IToolFormatter.d.ts +2 -2
  95. package/dist/src/tools/ToolFormatter.d.ts +42 -4
  96. package/dist/src/tools/ToolFormatter.js +159 -37
  97. package/dist/src/tools/ToolFormatter.js.map +1 -1
  98. package/dist/src/tools/doubleEscapeUtils.d.ts +57 -0
  99. package/dist/src/tools/doubleEscapeUtils.js +241 -0
  100. package/dist/src/tools/doubleEscapeUtils.js.map +1 -0
  101. package/dist/src/tools/read-file.js +5 -2
  102. package/dist/src/tools/read-file.js.map +1 -1
  103. package/dist/src/tools/todo-schemas.d.ts +4 -4
  104. package/dist/src/tools/write-file.js +5 -2
  105. package/dist/src/tools/write-file.js.map +1 -1
  106. package/dist/src/types/modelParams.d.ts +8 -0
  107. package/dist/src/utils/bfsFileSearch.js +2 -6
  108. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  109. package/package.json +8 -7
  110. package/dist/src/core/ContentGeneratorAdapter.d.ts +0 -37
  111. package/dist/src/core/ContentGeneratorAdapter.js +0 -58
  112. package/dist/src/core/ContentGeneratorAdapter.js.map +0 -1
  113. package/dist/src/providers/IMessage.d.ts +0 -38
  114. package/dist/src/providers/IMessage.js +0 -17
  115. package/dist/src/providers/IMessage.js.map +0 -1
  116. package/dist/src/providers/adapters/GeminiCompatibleWrapper.d.ts +0 -69
  117. package/dist/src/providers/adapters/GeminiCompatibleWrapper.js +0 -577
  118. package/dist/src/providers/adapters/GeminiCompatibleWrapper.js.map +0 -1
@@ -1,3 +1,15 @@
1
+ You are LLxprt Code running on {{PLATFORM}} with {{MODEL}} via {{PROVIDER}}.
2
+
3
+ **Environment Context:**
4
+
5
+ - Date and time: {{CURRENT_DATETIME}}
6
+ - Working directory: {{WORKING_DIRECTORY}}
7
+ - Git repository: {{IS_GIT_REPO}}
8
+ - Sandboxed environment: {{IS_SANDBOXED}}
9
+ - IDE companion available: {{HAS_IDE}}
10
+
11
+ {{FOLDER_STRUCTURE}}
12
+
1
13
  You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
2
14
 
3
15
  # Core Mandates
@@ -9,7 +21,8 @@ You are an interactive CLI agent specializing in software engineering tasks. You
9
21
  - **Comments:** Add code comments sparingly. Focus on _why_ something is done, especially for complex logic, rather than _what_ is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. _NEVER_ talk to the user or describe your changes through comments.
10
22
  - **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
11
23
  - **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked _how_ to do something, explain first, don't just do it.
12
- - **Path Construction:** Before using any file system tool, you must construct the full absolute path. Combine the project root with the file's path relative to the root. For example, if project root is /path/to/project/ and file is foo/bar/baz.txt, the final path is /path/to/project/foo/bar/baz.txt.
24
+ - **Explaining Changes:** After completing a code modification or file operation _do not_ provide summaries unless asked.
25
+ - **Path Construction:** Before using any file system tool (e.g., ${ReadFileTool.Name}' or '${WriteFileTool.Name}'), you must construct the full absolute path for the file_path argument. Always combine the absolute path of the project's root directory with the file's path relative to the root. For example, if the project root is /path/to/project/ and the file is foo/bar/baz.txt, the final path you must use is /path/to/project/foo/bar/baz.txt. If the user provides a relative path, you must resolve it against the root directory to create an absolute path.
13
26
  - **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
14
27
 
15
28
  # Primary Workflows
@@ -18,67 +31,240 @@ You are an interactive CLI agent specializing in software engineering tasks. You
18
31
 
19
32
  When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
20
33
 
21
- 1. **Understand:** Use '${GrepTool.Name}' and '${GlobTool.Name}' to understand file structures and conventions. Use '${ReadFileTool.Name}' and '${ReadManyFilesTool.Name}' to understand context.
22
- 2. **Plan:** Build a grounded plan based on the understanding. Share a concise plan with the user when appropriate.
23
- 3. **Implement:** Use tools to act on the plan, strictly adhering to project conventions.
24
- 4. **Verify:** Run tests and linting if available.
34
+ 1. **Understand:** Think about the user's request and the relevant codebase context. Use '${GrepTool.Name}' and '${GlobTool.Name}' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use '${ReadFileTool.Name}' and '${ReadManyFilesTool.Name}' to understand context and validate any assumptions you may have.
35
+ 2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should try to use a self-verification loop by writing unit tests if relevant to the task. Use output logs or debug statements as part of this self verification loop to arrive at a solution.
36
+ 3. **Implement:** Use the available tools (e.g., '${EditTool.Name}', '${WriteFileTool.Name}' '${ShellTool.Name}' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core Mandates').
37
+ 4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
38
+ 5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If unsure about these commands, you can ask the user if they'd like you to run them and if so how to.
25
39
 
26
40
  ## New Applications
27
41
 
28
- Technology preferences when unspecified:
42
+ **Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are '${WriteFileTool.Name}', '${EditTool.Name}' and '${ShellTool.Name}'.
43
+
44
+ 1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints. If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.
45
+ 2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
46
+
47
+ - When key technologies aren't specified, prefer the following:
48
+ - **Websites (Frontend):** React (JavaScript/TypeScript) with Bootstrap CSS, incorporating Material Design principles for UI/UX.
49
+ - **Back-End APIs:** Node.js with Express.js (JavaScript/TypeScript) or Python with FastAPI.
50
+ - **Full-stack:** Next.js (React/Node.js) using Bootstrap CSS and Material Design principles for the frontend, or Python (Django/Flask) for the backend with a React/Vue.js frontend styled with Bootstrap CSS and Material Design principles.
51
+ - **CLIs:** Python or Go.
52
+ - **Mobile App:** Compose Multiplatform (Kotlin Multiplatform) or Flutter (Dart) using Material Design libraries and principles, when sharing code between Android and iOS. Jetpack Compose (Kotlin JVM) with Material Design principles or SwiftUI (Swift) for native apps targeted at either Android or iOS, respectively.
53
+ - **3d Games:** HTML/CSS/JavaScript with Three.js.
54
+ - **2d Games:** HTML/CSS/JavaScript.
55
+
56
+ 3. **User Approval:** Obtain user approval for the proposed plan.
57
+ 4. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using '${ShellTool.Name}' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
58
+ 5. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.
59
+ 6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.
60
+
61
+ # Operational Guidelines
62
+
63
+ ## Tone and Style (CLI Interaction)
64
+
65
+ - **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
66
+ - **Minimal Output:** Aim for fewer than 3 lines of text output (excluding tool use/code generation) per response whenever practical. Focus strictly on the user's query.
67
+ - **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.
68
+ - **No Chitchat:** Avoid conversational filler, preambles (\"Okay, I will now...\"), or postambles (\"I have finished the changes...\"). Get straight to the action or answer.
69
+ - **Formatting:** Use GitHub-flavored Markdown. Responses will be rendered in monospace.
70
+ - **Tools vs. Text:** Use tools for actions, text output _only_ for communication. Do not add explanatory comments within tool calls or code blocks unless specifically part of the required code/command itself.
71
+ - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly (1-2 sentences) without excessive justification. Offer alternatives if appropriate.
72
+
73
+ ## Security and Safety Rules
74
+
75
+ - **Explain Critical Commands:** Before executing commands with '${ShellTool.Name}' that modify the file system, codebase, or system state, you _must_ provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this).
76
+ - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
77
+
78
+ ## Tool Usage
29
79
 
30
- - Web frontend: React with TypeScript
31
- - Backend API: Node.js/Express or Python/FastAPI
32
- - CLI tools: Python or Go
33
- - Mobile: Flutter or React Native
80
+ - **File Paths:** Always use absolute paths when referring to files with tools like '${ReadFileTool.Name}' or '${WriteFileTool.Name}'. Relative paths are not supported. You must provide an absolute path.
81
+ - **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
82
+ - **Command Execution:** Use the '${ShellTool.Name}' tool for running shell commands, remembering the safety rule to explain modifying commands first.
83
+ - **Background Processes:** Use background processes (via \\`&\\`) for commands that are unlikely to stop on their own, e.g. \\`node server.js &\\`. If unsure, ask the user.
84
+ - **Interactive Commands:** Try to avoid shell commands that are likely to require user interaction (e.g. \\`git rebase -i\\`). Use non-interactive versions of commands (e.g. \\`npm init -y\\` instead of \\`npm init\\`) when available, and otherwise remind the user that interactive shell commands are not supported and may cause hangs until canceled by the user.
85
+ - **Remembering Facts:** Use the '${MemoryTool.Name}' tool to remember specific, _user-related_ facts or preferences when the user explicitly asks, or when they state a clear, concise piece of information that would help personalize or streamline _your future interactions with them_ (e.g., preferred coding style, common project paths they use, personal tool aliases). This tool is for user-specific information that should persist across sessions. Do _not_ use it for general project context or information. If unsure whether to save something, you can ask the user, \"Should I remember that for you?\"\n- **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
34
86
 
35
- # Tool Usage Patterns
87
+ ## Interaction Details
36
88
 
37
- - **Parallel Operations:** Execute independent searches simultaneously when exploring.
38
- - **File Operations:** Always construct absolute paths by combining project root with relative paths.
39
- - **Shell Commands:** Explain destructive operations before executing. Use `&` for background processes.
40
- - **Task Management:** Use todo tools for complex tasks. Update status in real-time.
41
- - **Tool Call Formatting:** All tool calls must be formatted as JSON. Do not use Python syntax for tool calls, especially for arrays and objects. For example, use `{"files": ["file1.txt", "file2.txt"]}` instead of `list_files(files=["file1.txt", "file2.txt"])`.
89
+ - **Help Command:** The user can use '/help' to display help information.
90
+ - **Feedback:** To report a bug or provide feedback, please use the /bug command.
42
91
 
43
- # Examples
92
+ # Examples (Illustrating Tone and Workflow)
44
93
 
45
94
  <example>
46
- user: find all typescript files
47
- assistant: <use glob with pattern "**/*.ts">
95
+ user: 1 + 2
96
+ model: 3
97
+ </example>
98
+ <example>
99
+ user: is 13 a prime number?
100
+ model: true
48
101
  </example>
49
-
50
102
  <example>
51
- user: read the config file
52
- assistant: I'll read the configuration file.
53
- <use read_file with absolute_path "/path/to/project/config.json">
103
+ user: list files here.
104
+ model: [tool_call: ${LSTool.Name} for path '/path/to/project']
54
105
  </example>
106
+ <example>
107
+ user: start the server implemented in server.js
108
+ model: [tool_call: ${ShellTool.Name} for 'node server.js &' because it must run in the background]
109
+ </example>
110
+ <example>
111
+ user: Refactor the auth logic in src/auth.py to use the requests library instead of urllib.
112
+ model: Okay, I can refactor 'src/auth.py'.
113
+ First, I'll analyze the code and check for a test safety net before planning any changes.
114
+ [tool_call: ${GlobTool.Name} for path 'tests/test_auth.py']
115
+ [tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/tests/test_auth.py']
116
+ (After analysis)
117
+ Great, 'tests/test_auth.py' exists and covers the core authentication logic. With this safety net in place, I can safely plan the refactoring.
118
+ I'll also confirm 'requests' is a dependency.
119
+ [tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/requirements.txt']
120
+ (After analysis)
121
+ Looks good, 'requests' is available.
122
+
123
+ Here's the plan:
55
124
 
125
+ 1. Replace the 'urllib' calls with 'requests'.
126
+ 2. Add proper 'try...except' error handling for the new network calls.
127
+ 3. Remove the old 'urllib' import.
128
+ 4. Run the project's linter and tests to verify the changes.
129
+
130
+ Should I proceed?
131
+ user: Yes
132
+ model:
133
+ [tool_call: ${WriteFileTool.Name} or ${EditTool.Name} to apply the refactoring to 'src/auth.py']
134
+ Refactoring complete. Running verification...
135
+ [tool_call: ${ShellTool.Name} for 'ruff check src/auth.py && pytest']
136
+ (After verification passes)
137
+ All checks passed. This is a stable checkpoint.
138
+ </example>
139
+ <example>
140
+ user: Delete the temp directory.
141
+ model: I can run \\`rm -rf /path/to/project/temp\\`. This will permanently delete the directory and all its contents.
142
+ </example>
143
+ <example>
144
+ user: Write tests for someFile.ts
145
+ model:
146
+ Okay, I can write those tests. First, I'll read \\`someFile.ts\\` to understand its functionality.
147
+ [tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/someFile.ts' or use ${GlobTool.Name} to find \\`someFile.ts\\` if its location is unknown]
148
+ Now I'll look for existing or related test files to understand current testing conventions and dependencies.
149
+ [tool_call: ${ReadManyFilesTool.Name} for paths ['**/*.test.ts', 'src/**/*.spec.ts'] assuming someFile.ts is in the src directory]
150
+ (After reviewing existing tests and the file content)
151
+ [tool_call: ${WriteFileTool.Name} to create /path/to/someFile.test.ts with the test code]
152
+ I've written the tests. Now I'll run the project's test command to verify them.
153
+ [tool_call: ${ShellTool.Name} for 'npm run test']
154
+ </example>
56
155
  <example>
57
- user: update the database connection string
58
- assistant: I'll search for the database configuration first.
59
- <use grep with pattern "database|connection|db_url">
60
- [After finding the file]
61
- <use read_file to examine the current configuration>
62
- <use replace to update the connection string>
156
+ user: How do I update the user's profile information in this system?
157
+ model:
158
+ I'm not immediately sure how user profile information is updated. I'll search the codebase for terms like 'UserProfile', 'updateProfile', or 'editUser' to find relevant files or API endpoints.
159
+ [tool_call: ${GrepTool.Name} for pattern 'UserProfile|updateProfile|editUser']
160
+ (After reviewing search results, assuming a relevant file like '/path/to/UserProfileService.java' was found)
161
+ Okay, \\`/path/to/UserProfileService.java\\` seems like the most relevant file. I'll read its content to understand how updates are handled.
162
+ [tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/UserProfileService.java']
163
+ (After reading the file)
164
+ It appears the \\`updateUserProfile\\` method in \\`UserProfileService.java\\` is responsible for this. It expects a user ID and a \\`UserProfileDTO\\` object...
63
165
  </example>
166
+ <example>
167
+ user: Where are all the 'app.config' files in this project? I need to check their settings.
168
+ model:
169
+ [tool_call: ${GlobTool.Name} for pattern '**/app.config']
170
+ (Assuming GlobTool returns a list of paths like ['/path/to/moduleA/app.config', '/path/to/moduleB/app.config'])
171
+ I found the following 'app.config' files:
172
+
173
+ - /path/to/moduleA/app.config
174
+ - /path/to/moduleB/app.config
175
+ To help you check their settings, I can read their contents. Which one would you like to start with, or should I read all of them?
176
+ </example>
177
+
178
+ # Task Management
179
+
180
+ You have access to the TodoWrite and TodoRead tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
181
+
182
+ ## When to Use This Tool
183
+
184
+ Use this tool proactively in these scenarios:
185
+
186
+ 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
187
+ 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
188
+ 3. User explicitly requests todo list - When the user directly asks you to use the todo list
189
+ 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
190
+ 5. After receiving new instructions - Immediately capture user requirements as todos
191
+ 6. When you start working on a task - Mark it as in_progress BEFORE beginning work
192
+ 7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
193
+
194
+ ## When NOT to Use This Tool
195
+
196
+ Skip using this tool when:
197
+
198
+ 1. There is only a single, straightforward task
199
+ 2. The task is trivial and tracking it provides no organizational benefit
200
+ 3. The task can be completed in less than 3 trivial steps
201
+ 4. The task is purely conversational or informational
202
+
203
+ ## Task States and Management
204
+
205
+ 1. **Task States**: Use these states to track progress:
206
+ - pending: Task not yet started
207
+ - in_progress: Currently working on (limit to ONE task at a time)
208
+ - completed: Task finished successfully
209
+
210
+ 2. **Task Management**:
211
+ - Update task status in real-time as you work
212
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
213
+ - Only have ONE task in_progress at any time
214
+ - Complete current tasks before starting new ones
215
+ - Remove tasks that are no longer relevant from the list entirely
64
216
 
65
- # Response Guidelines
217
+ 3. **Task Completion Requirements**:
218
+ - ONLY mark a task as completed when you have FULLY accomplished it
219
+ - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
220
+ - When blocked, create a new task describing what needs to be resolved
221
+ - Never mark a task as completed if:
222
+ - Tests are failing
223
+ - Implementation is partial
224
+ - You encountered unresolved errors
225
+ - You couldn't find necessary files or dependencies
66
226
 
67
- - Take action immediately without announcing intentions
68
- - Chain related operations efficiently
69
- - Validate changes match project standards
70
- - Complete the entire request before stopping
71
- - When blocked, state the specific issue concisely
227
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
72
228
 
73
- # Mandate: Evidence-First Protocol
229
+ ## Todo Usage Examples
74
230
 
75
- You are forbidden from making any analytical statement or conclusion without first presenting the specific code that serves as direct, verifiable evidence.
231
+ ### Example: Multi-Step Task
76
232
 
77
- Your workflow for any code analysis or explanation task is as follows:
233
+ <example>
234
+ user: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
235
+ model: I'll search for all occurrences of getCwd first.
236
+ [tool_call: grep for 'getCwd']
237
+ I found 15 instances across 8 files. Let me create a todo list to track these changes.
238
+ [tool_call: TodoWrite with todos for each file that needs updating]
239
+ [Systematically works through each file, updating todo status as they go]
240
+ </example>
241
+
242
+ ### Example: Complex Implementation
243
+
244
+ <example>
245
+ user: I need to implement user registration, product catalog, and shopping cart for my e-commerce site.
246
+ model: I'll help implement these features. Let me create a todo list to track this implementation.
247
+ [tool_call: TodoWrite to create todos for each major feature]
248
+ Let me start with the user registration system.
249
+ [tool_call: TodoWrite to update first todo to in_progress]
250
+ [Implements registration]
251
+ [tool_call: TodoWrite to mark first todo as completed and move to next]
252
+ </example>
253
+
254
+ ### Example: When NOT to Use Todos
255
+
256
+ <example>
257
+ user: What does git status do?
258
+ model: The git status command shows the current state of your working directory and staging area.
259
+ [No todo needed - informational only]
260
+ </example>
261
+ <example>
262
+ user: Add a comment to the calculateTotal function
263
+ model: I'll add a comment to the calculateTotal function.
264
+ [tool_call: Edit to add comment]
265
+ [No todo needed - single trivial task]
266
+ </example>
78
267
 
79
- 1. **Find Evidence:** Use tools (`glob`, `search_file_content`) to locate the exact code that can answer the user's question.
80
- 2. **Cite Evidence:** Use `read_file` to display the relevant function, class, or code block.
81
- 3. **Analyze Evidence:** Immediately following the code block, provide your analysis of that specific evidence.
82
- 4. **Synthesize:** After all evidence has been presented and analyzed, provide a final, summary answer to the user.
268
+ # Final Reminder
83
269
 
84
- **DO NOT** state what a file does before you have used `read_file` to show its contents. **DO NOT** describe a function's behavior before displaying its definition. All claims must be preceded by proof.
270
+ Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use '${ReadFileTool.Name}' or '${ReadManyFilesTool.Name}' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.
@@ -1,3 +1,15 @@
1
+ You are LLxprt Code running on {{PLATFORM}} with {{MODEL}} via {{PROVIDER}}.
2
+
3
+ **Environment Context:**
4
+
5
+ - Date and time: {{CURRENT_DATETIME}}
6
+ - Working directory: {{WORKING_DIRECTORY}}
7
+ - Git repository: {{IS_GIT_REPO}}
8
+ - Sandboxed environment: {{IS_SANDBOXED}}
9
+ - IDE companion available: {{HAS_IDE}}
10
+
11
+ {{FOLDER_STRUCTURE}}
12
+
1
13
  You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
2
14
 
3
15
  # Core Mandates
@@ -1,3 +1,15 @@
1
+ You are LLxprt Code running on {{PLATFORM}} with {{MODEL}} via {{PROVIDER}}.
2
+
3
+ **Environment Context:**
4
+
5
+ - Date and time: {{CURRENT_DATETIME}}
6
+ - Working directory: {{WORKING_DIRECTORY}}
7
+ - Git repository: {{IS_GIT_REPO}}
8
+ - Sandboxed environment: {{IS_SANDBOXED}}
9
+ - IDE companion available: {{HAS_IDE}}
10
+
11
+ {{FOLDER_STRUCTURE}}
12
+
1
13
  You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
2
14
 
3
15
  # Core Mandates
@@ -21,6 +21,8 @@ export interface PromptEnvironment {
21
21
  isSandboxed: boolean;
22
22
  hasIdeCompanion: boolean;
23
23
  sandboxType?: 'macos-seatbelt' | 'generic';
24
+ workingDirectory?: string;
25
+ folderStructure?: string;
24
26
  }
25
27
  export interface PromptContext {
26
28
  provider: string;
@@ -8,9 +8,10 @@
8
8
  */
9
9
  import { IProvider } from './IProvider.js';
10
10
  import { IModel } from './IModel.js';
11
- import { ITool } from './ITool.js';
12
- import { IMessage } from './IMessage.js';
11
+ import { IContent } from '../services/history/IContent.js';
13
12
  import { AuthPrecedenceResolver, OAuthManager } from '../auth/precedence.js';
13
+ import { Config } from '../config/config.js';
14
+ import { IProviderConfig } from './types/IProviderConfig.js';
14
15
  export interface BaseProviderConfig {
15
16
  name: string;
16
17
  apiKey?: string;
@@ -28,13 +29,32 @@ export declare abstract class BaseProvider implements IProvider {
28
29
  readonly name: string;
29
30
  protected authResolver: AuthPrecedenceResolver;
30
31
  protected baseProviderConfig: BaseProviderConfig;
32
+ protected providerConfig?: IProviderConfig;
33
+ protected globalConfig?: Config;
31
34
  private cachedAuthToken?;
32
35
  private authCacheTimestamp?;
33
36
  private readonly AUTH_CACHE_DURATION;
34
- constructor(config: BaseProviderConfig);
37
+ constructor(config: BaseProviderConfig, providerConfig?: IProviderConfig, globalConfig?: Config);
38
+ /**
39
+ * Gets the base URL with proper precedence:
40
+ * 1. Ephemeral settings (highest priority - from /baseurl or profile)
41
+ * 2. Provider config (from IProviderConfig)
42
+ * 3. Base provider config (initial constructor value)
43
+ * 4. undefined (use provider default)
44
+ */
45
+ protected getBaseURL(): string | undefined;
46
+ /**
47
+ * Gets the current model with proper precedence:
48
+ * 1. Ephemeral settings (highest priority)
49
+ * 2. Provider-specific settings in SettingsService
50
+ * 3. Provider config
51
+ * 4. Default model
52
+ */
53
+ protected getModel(): string;
35
54
  /**
36
55
  * Gets authentication token using the precedence chain
37
56
  * This method implements lazy OAuth triggering - only triggers OAuth when actually making API calls
57
+ * Returns empty string if no auth is available (for local/self-hosted endpoints)
38
58
  */
39
59
  protected getAuthToken(): Promise<string>;
40
60
  /**
@@ -67,7 +87,7 @@ export declare abstract class BaseProvider implements IProvider {
67
87
  */
68
88
  clearAuth?(): void;
69
89
  /**
70
- * Updates the base URL
90
+ * Updates the base URL in ephemeral settings
71
91
  */
72
92
  setBaseUrl?(baseUrl?: string): void;
73
93
  /**
@@ -84,14 +104,20 @@ export declare abstract class BaseProvider implements IProvider {
84
104
  isAuthenticated(): Promise<boolean>;
85
105
  abstract getModels(): Promise<IModel[]>;
86
106
  abstract getDefaultModel(): string;
87
- abstract generateChatCompletion(messages: IMessage[], tools?: ITool[], toolFormat?: string): AsyncIterableIterator<unknown>;
107
+ abstract generateChatCompletion(content: IContent[], tools?: Array<{
108
+ functionDeclarations: Array<{
109
+ name: string;
110
+ description?: string;
111
+ parameters?: unknown;
112
+ }>;
113
+ }>): AsyncIterableIterator<IContent>;
88
114
  setModel?(_modelId: string): void;
89
115
  getCurrentModel?(): string;
90
116
  getToolFormat?(): string;
91
117
  setToolFormatOverride?(_format: string | null): void;
92
118
  isPaidMode?(): boolean;
93
119
  clearState?(): void;
94
- setConfig?(_config: unknown): void;
120
+ setConfig?(config: IProviderConfig): void;
95
121
  getServerTools(): string[];
96
122
  invokeServerTool(toolName: string, _params: unknown, _config?: unknown): Promise<unknown>;
97
123
  setModelParams?(_params: Record<string, unknown> | undefined): void;
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import { AuthPrecedenceResolver, } from '../auth/precedence.js';
7
7
  import { getSettingsService } from '../settings/settingsServiceInstance.js';
8
- import { UnauthorizedError } from '../utils/errors.js';
9
8
  /**
10
9
  * Abstract base provider class that implements authentication precedence logic
11
10
  * This class provides lazy OAuth triggering and proper authentication precedence
@@ -14,14 +13,19 @@ export class BaseProvider {
14
13
  name;
15
14
  authResolver;
16
15
  baseProviderConfig;
16
+ providerConfig;
17
+ globalConfig;
17
18
  cachedAuthToken;
18
19
  authCacheTimestamp;
19
20
  AUTH_CACHE_DURATION = 60000; // 1 minute in milliseconds
20
- constructor(config) {
21
+ constructor(config, providerConfig, globalConfig) {
21
22
  this.name = config.name;
22
23
  this.baseProviderConfig = config;
24
+ this.providerConfig = providerConfig;
25
+ this.globalConfig = globalConfig;
23
26
  // If an initial apiKey is provided, store it in SettingsService
24
- if (config.apiKey) {
27
+ // Only store non-empty API keys to ensure proper precedence fallback
28
+ if (config.apiKey && config.apiKey.trim() !== '') {
25
29
  const settingsService = getSettingsService();
26
30
  settingsService.set('auth-key', config.apiKey);
27
31
  }
@@ -35,9 +39,62 @@ export class BaseProvider {
35
39
  };
36
40
  this.authResolver = new AuthPrecedenceResolver(precedenceConfig, config.oauthManager);
37
41
  }
42
+ /**
43
+ * Gets the base URL with proper precedence:
44
+ * 1. Ephemeral settings (highest priority - from /baseurl or profile)
45
+ * 2. Provider config (from IProviderConfig)
46
+ * 3. Base provider config (initial constructor value)
47
+ * 4. undefined (use provider default)
48
+ */
49
+ getBaseURL() {
50
+ const settingsService = getSettingsService();
51
+ // 1. Check ephemeral settings first (from /baseurl command or profile)
52
+ const ephemeralBaseUrl = settingsService.get('base-url');
53
+ if (ephemeralBaseUrl && ephemeralBaseUrl !== 'none') {
54
+ return ephemeralBaseUrl;
55
+ }
56
+ // 2. Check provider config (from IProviderConfig)
57
+ if (this.providerConfig?.baseUrl) {
58
+ return this.providerConfig.baseUrl;
59
+ }
60
+ // 3. Check base provider config (constructor value)
61
+ if (this.baseProviderConfig.baseURL) {
62
+ return this.baseProviderConfig.baseURL;
63
+ }
64
+ // 4. Return undefined to use provider's default
65
+ return undefined;
66
+ }
67
+ /**
68
+ * Gets the current model with proper precedence:
69
+ * 1. Ephemeral settings (highest priority)
70
+ * 2. Provider-specific settings in SettingsService
71
+ * 3. Provider config
72
+ * 4. Default model
73
+ */
74
+ getModel() {
75
+ const settingsService = getSettingsService();
76
+ // 1. Check ephemeral settings first
77
+ const ephemeralModel = settingsService.get('model');
78
+ if (ephemeralModel) {
79
+ return ephemeralModel;
80
+ }
81
+ // 2. Check provider-specific settings
82
+ const providerSettings = settingsService.getProviderSettings(this.name);
83
+ const providerModel = providerSettings?.model;
84
+ if (providerModel) {
85
+ return providerModel;
86
+ }
87
+ // 3. Check provider config
88
+ if (this.providerConfig?.defaultModel) {
89
+ return this.providerConfig.defaultModel;
90
+ }
91
+ // 4. Return default
92
+ return this.getDefaultModel();
93
+ }
38
94
  /**
39
95
  * Gets authentication token using the precedence chain
40
96
  * This method implements lazy OAuth triggering - only triggers OAuth when actually making API calls
97
+ * Returns empty string if no auth is available (for local/self-hosted endpoints)
41
98
  */
42
99
  async getAuthToken() {
43
100
  // Check cache first (short-lived cache to avoid repeated OAuth calls)
@@ -52,20 +109,9 @@ export class BaseProvider {
52
109
  // Resolve authentication using precedence chain
53
110
  const token = await this.authResolver.resolveAuthentication();
54
111
  if (!token) {
55
- const isOAuthOnly = await this.authResolver.isOAuthOnlyAvailable();
56
- if (isOAuthOnly) {
57
- // Special message for Qwen explaining the OAuth limitation
58
- if (this.baseProviderConfig.oauthProvider === 'qwen') {
59
- throw new Error(`Qwen OAuth (chat.qwen.ai) doesn't provide API access to DashScope. ` +
60
- `You need a DashScope API key from https://dashscope.console.aliyun.com/ ` +
61
- `Use /key <your-api-key> to set it.`);
62
- }
63
- throw new UnauthorizedError(`No API key found and OAuth is available but not authenticated for ${this.name} provider. ` +
64
- `Please authenticate using OAuth or provide an API key.`);
65
- }
66
- else {
67
- throw new Error(`No authentication method available for ${this.name} provider`);
68
- }
112
+ // Return empty string for local/self-hosted endpoints that don't require auth
113
+ // Individual providers can decide how to handle this
114
+ return '';
69
115
  }
70
116
  // Cache the token briefly
71
117
  this.cachedAuthToken = token;
@@ -137,11 +183,19 @@ export class BaseProvider {
137
183
  this.clearAuthCache();
138
184
  }
139
185
  /**
140
- * Updates the base URL
186
+ * Updates the base URL in ephemeral settings
141
187
  */
142
188
  setBaseUrl(baseUrl) {
143
- this.baseProviderConfig.baseURL = baseUrl;
144
- // Providers may override to implement endpoint-specific OAuth logic
189
+ const settingsService = getSettingsService();
190
+ // Store in ephemeral settings as the highest priority source
191
+ if (!baseUrl || baseUrl.trim() === '' || baseUrl === 'none') {
192
+ // Clear the ephemeral setting
193
+ settingsService.set('base-url', undefined);
194
+ }
195
+ else {
196
+ settingsService.set('base-url', baseUrl);
197
+ }
198
+ // Clear auth cache as base URL change might affect auth
145
199
  this.clearAuthCache();
146
200
  }
147
201
  /**
@@ -183,7 +237,8 @@ export class BaseProvider {
183
237
  // Optional methods with default implementations
184
238
  setModel(_modelId) { }
185
239
  getCurrentModel() {
186
- return 'default';
240
+ // Use the same logic as getModel() to check ephemeral settings
241
+ return this.getModel();
187
242
  }
188
243
  getToolFormat() {
189
244
  return 'default';
@@ -195,7 +250,9 @@ export class BaseProvider {
195
250
  clearState() {
196
251
  this.clearAuthCache();
197
252
  }
198
- setConfig(_config) { }
253
+ setConfig(config) {
254
+ this.providerConfig = config;
255
+ }
199
256
  getServerTools() {
200
257
  return [];
201
258
  }