@shareai-lab/kode 1.1.14 → 1.1.16-dev.1

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 (289) hide show
  1. package/cli.js +77 -82
  2. package/dist/entrypoints/cli.js +59 -38
  3. package/dist/entrypoints/cli.js.map +3 -3
  4. package/dist/index.js +5 -26
  5. package/dist/package.json +4 -1
  6. package/package.json +11 -104
  7. package/dist/test/testAdapters.js +0 -88
  8. package/dist/test/testAdapters.js.map +0 -1
  9. package/src/ProjectOnboarding.tsx +0 -198
  10. package/src/Tool.ts +0 -83
  11. package/src/commands/agents.tsx +0 -3416
  12. package/src/commands/approvedTools.ts +0 -53
  13. package/src/commands/bug.tsx +0 -20
  14. package/src/commands/clear.ts +0 -43
  15. package/src/commands/compact.ts +0 -120
  16. package/src/commands/config.tsx +0 -19
  17. package/src/commands/cost.ts +0 -18
  18. package/src/commands/ctx_viz.ts +0 -209
  19. package/src/commands/doctor.ts +0 -24
  20. package/src/commands/help.tsx +0 -19
  21. package/src/commands/init.ts +0 -37
  22. package/src/commands/listen.ts +0 -42
  23. package/src/commands/login.tsx +0 -51
  24. package/src/commands/logout.tsx +0 -40
  25. package/src/commands/mcp.ts +0 -41
  26. package/src/commands/model.tsx +0 -40
  27. package/src/commands/modelstatus.tsx +0 -20
  28. package/src/commands/onboarding.tsx +0 -34
  29. package/src/commands/pr_comments.ts +0 -59
  30. package/src/commands/refreshCommands.ts +0 -54
  31. package/src/commands/release-notes.ts +0 -34
  32. package/src/commands/resume.tsx +0 -31
  33. package/src/commands/review.ts +0 -49
  34. package/src/commands/terminalSetup.ts +0 -221
  35. package/src/commands.ts +0 -139
  36. package/src/components/ApproveApiKey.tsx +0 -93
  37. package/src/components/AsciiLogo.tsx +0 -13
  38. package/src/components/AutoUpdater.tsx +0 -148
  39. package/src/components/Bug.tsx +0 -367
  40. package/src/components/Config.tsx +0 -293
  41. package/src/components/ConsoleOAuthFlow.tsx +0 -327
  42. package/src/components/Cost.tsx +0 -23
  43. package/src/components/CostThresholdDialog.tsx +0 -46
  44. package/src/components/CustomSelect/option-map.ts +0 -42
  45. package/src/components/CustomSelect/select-option.tsx +0 -78
  46. package/src/components/CustomSelect/select.tsx +0 -152
  47. package/src/components/CustomSelect/theme.ts +0 -45
  48. package/src/components/CustomSelect/use-select-state.ts +0 -414
  49. package/src/components/CustomSelect/use-select.ts +0 -35
  50. package/src/components/FallbackToolUseRejectedMessage.tsx +0 -15
  51. package/src/components/FileEditToolUpdatedMessage.tsx +0 -66
  52. package/src/components/Help.tsx +0 -215
  53. package/src/components/HighlightedCode.tsx +0 -33
  54. package/src/components/InvalidConfigDialog.tsx +0 -113
  55. package/src/components/Link.tsx +0 -32
  56. package/src/components/LogSelector.tsx +0 -86
  57. package/src/components/Logo.tsx +0 -170
  58. package/src/components/MCPServerApprovalDialog.tsx +0 -100
  59. package/src/components/MCPServerDialogCopy.tsx +0 -25
  60. package/src/components/MCPServerMultiselectDialog.tsx +0 -109
  61. package/src/components/Message.tsx +0 -221
  62. package/src/components/MessageResponse.tsx +0 -15
  63. package/src/components/MessageSelector.tsx +0 -211
  64. package/src/components/ModeIndicator.tsx +0 -88
  65. package/src/components/ModelConfig.tsx +0 -301
  66. package/src/components/ModelListManager.tsx +0 -227
  67. package/src/components/ModelSelector.tsx +0 -3387
  68. package/src/components/ModelStatusDisplay.tsx +0 -230
  69. package/src/components/Onboarding.tsx +0 -274
  70. package/src/components/PressEnterToContinue.tsx +0 -11
  71. package/src/components/PromptInput.tsx +0 -760
  72. package/src/components/SentryErrorBoundary.ts +0 -39
  73. package/src/components/Spinner.tsx +0 -129
  74. package/src/components/StickerRequestForm.tsx +0 -16
  75. package/src/components/StructuredDiff.tsx +0 -191
  76. package/src/components/TextInput.tsx +0 -259
  77. package/src/components/TodoItem.tsx +0 -47
  78. package/src/components/TokenWarning.tsx +0 -31
  79. package/src/components/ToolUseLoader.tsx +0 -40
  80. package/src/components/TrustDialog.tsx +0 -106
  81. package/src/components/binary-feedback/BinaryFeedback.tsx +0 -63
  82. package/src/components/binary-feedback/BinaryFeedbackOption.tsx +0 -111
  83. package/src/components/binary-feedback/BinaryFeedbackView.tsx +0 -172
  84. package/src/components/binary-feedback/utils.ts +0 -220
  85. package/src/components/messages/AssistantBashOutputMessage.tsx +0 -22
  86. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +0 -49
  87. package/src/components/messages/AssistantRedactedThinkingMessage.tsx +0 -19
  88. package/src/components/messages/AssistantTextMessage.tsx +0 -144
  89. package/src/components/messages/AssistantThinkingMessage.tsx +0 -40
  90. package/src/components/messages/AssistantToolUseMessage.tsx +0 -132
  91. package/src/components/messages/TaskProgressMessage.tsx +0 -32
  92. package/src/components/messages/TaskToolMessage.tsx +0 -58
  93. package/src/components/messages/UserBashInputMessage.tsx +0 -28
  94. package/src/components/messages/UserCommandMessage.tsx +0 -30
  95. package/src/components/messages/UserKodingInputMessage.tsx +0 -28
  96. package/src/components/messages/UserPromptMessage.tsx +0 -35
  97. package/src/components/messages/UserTextMessage.tsx +0 -39
  98. package/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.tsx +0 -12
  99. package/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx +0 -36
  100. package/src/components/messages/UserToolResultMessage/UserToolRejectMessage.tsx +0 -31
  101. package/src/components/messages/UserToolResultMessage/UserToolResultMessage.tsx +0 -57
  102. package/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx +0 -35
  103. package/src/components/messages/UserToolResultMessage/utils.tsx +0 -56
  104. package/src/components/permissions/BashPermissionRequest/BashPermissionRequest.tsx +0 -121
  105. package/src/components/permissions/FallbackPermissionRequest.tsx +0 -153
  106. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +0 -182
  107. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +0 -77
  108. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +0 -164
  109. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +0 -83
  110. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +0 -240
  111. package/src/components/permissions/PermissionRequest.tsx +0 -101
  112. package/src/components/permissions/PermissionRequestTitle.tsx +0 -69
  113. package/src/components/permissions/hooks.ts +0 -44
  114. package/src/components/permissions/toolUseOptions.ts +0 -59
  115. package/src/components/permissions/utils.ts +0 -23
  116. package/src/constants/betas.ts +0 -5
  117. package/src/constants/claude-asterisk-ascii-art.tsx +0 -238
  118. package/src/constants/figures.ts +0 -4
  119. package/src/constants/keys.ts +0 -3
  120. package/src/constants/macros.ts +0 -11
  121. package/src/constants/modelCapabilities.ts +0 -179
  122. package/src/constants/models.ts +0 -1025
  123. package/src/constants/oauth.ts +0 -18
  124. package/src/constants/product.ts +0 -17
  125. package/src/constants/prompts.ts +0 -168
  126. package/src/constants/releaseNotes.ts +0 -7
  127. package/src/context/PermissionContext.tsx +0 -149
  128. package/src/context.ts +0 -278
  129. package/src/cost-tracker.ts +0 -84
  130. package/src/entrypoints/cli.tsx +0 -1561
  131. package/src/entrypoints/mcp.ts +0 -175
  132. package/src/history.ts +0 -25
  133. package/src/hooks/useApiKeyVerification.ts +0 -59
  134. package/src/hooks/useArrowKeyHistory.ts +0 -55
  135. package/src/hooks/useCanUseTool.ts +0 -138
  136. package/src/hooks/useCancelRequest.ts +0 -39
  137. package/src/hooks/useDoublePress.ts +0 -41
  138. package/src/hooks/useExitOnCtrlCD.ts +0 -31
  139. package/src/hooks/useInterval.ts +0 -25
  140. package/src/hooks/useLogMessages.ts +0 -16
  141. package/src/hooks/useLogStartupTime.ts +0 -12
  142. package/src/hooks/useNotifyAfterTimeout.ts +0 -65
  143. package/src/hooks/usePermissionRequestLogging.ts +0 -44
  144. package/src/hooks/useTerminalSize.ts +0 -49
  145. package/src/hooks/useTextInput.ts +0 -317
  146. package/src/hooks/useUnifiedCompletion.ts +0 -1405
  147. package/src/index.ts +0 -34
  148. package/src/messages.ts +0 -38
  149. package/src/permissions.ts +0 -268
  150. package/src/query.ts +0 -720
  151. package/src/screens/ConfigureNpmPrefix.tsx +0 -197
  152. package/src/screens/Doctor.tsx +0 -219
  153. package/src/screens/LogList.tsx +0 -68
  154. package/src/screens/REPL.tsx +0 -813
  155. package/src/screens/ResumeConversation.tsx +0 -68
  156. package/src/services/adapters/base.ts +0 -38
  157. package/src/services/adapters/chatCompletions.ts +0 -90
  158. package/src/services/adapters/responsesAPI.ts +0 -170
  159. package/src/services/browserMocks.ts +0 -66
  160. package/src/services/claude.ts +0 -2197
  161. package/src/services/customCommands.ts +0 -704
  162. package/src/services/fileFreshness.ts +0 -377
  163. package/src/services/gpt5ConnectionTest.ts +0 -340
  164. package/src/services/mcpClient.ts +0 -564
  165. package/src/services/mcpServerApproval.tsx +0 -50
  166. package/src/services/mentionProcessor.ts +0 -273
  167. package/src/services/modelAdapterFactory.ts +0 -69
  168. package/src/services/notifier.ts +0 -40
  169. package/src/services/oauth.ts +0 -357
  170. package/src/services/openai.ts +0 -1359
  171. package/src/services/responseStateManager.ts +0 -90
  172. package/src/services/sentry.ts +0 -3
  173. package/src/services/statsig.ts +0 -172
  174. package/src/services/statsigStorage.ts +0 -86
  175. package/src/services/systemReminder.ts +0 -507
  176. package/src/services/vcr.ts +0 -161
  177. package/src/test/testAdapters.ts +0 -96
  178. package/src/tools/ArchitectTool/ArchitectTool.tsx +0 -135
  179. package/src/tools/ArchitectTool/prompt.ts +0 -15
  180. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +0 -576
  181. package/src/tools/BashTool/BashTool.tsx +0 -243
  182. package/src/tools/BashTool/BashToolResultMessage.tsx +0 -38
  183. package/src/tools/BashTool/OutputLine.tsx +0 -49
  184. package/src/tools/BashTool/prompt.ts +0 -174
  185. package/src/tools/BashTool/utils.ts +0 -56
  186. package/src/tools/FileEditTool/FileEditTool.tsx +0 -319
  187. package/src/tools/FileEditTool/prompt.ts +0 -51
  188. package/src/tools/FileEditTool/utils.ts +0 -58
  189. package/src/tools/FileReadTool/FileReadTool.tsx +0 -404
  190. package/src/tools/FileReadTool/prompt.ts +0 -7
  191. package/src/tools/FileWriteTool/FileWriteTool.tsx +0 -301
  192. package/src/tools/FileWriteTool/prompt.ts +0 -10
  193. package/src/tools/GlobTool/GlobTool.tsx +0 -119
  194. package/src/tools/GlobTool/prompt.ts +0 -8
  195. package/src/tools/GrepTool/GrepTool.tsx +0 -147
  196. package/src/tools/GrepTool/prompt.ts +0 -11
  197. package/src/tools/MCPTool/MCPTool.tsx +0 -107
  198. package/src/tools/MCPTool/prompt.ts +0 -3
  199. package/src/tools/MemoryReadTool/MemoryReadTool.tsx +0 -127
  200. package/src/tools/MemoryReadTool/prompt.ts +0 -3
  201. package/src/tools/MemoryWriteTool/MemoryWriteTool.tsx +0 -89
  202. package/src/tools/MemoryWriteTool/prompt.ts +0 -3
  203. package/src/tools/MultiEditTool/MultiEditTool.tsx +0 -388
  204. package/src/tools/MultiEditTool/prompt.ts +0 -45
  205. package/src/tools/NotebookEditTool/NotebookEditTool.tsx +0 -298
  206. package/src/tools/NotebookEditTool/prompt.ts +0 -3
  207. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +0 -258
  208. package/src/tools/NotebookReadTool/prompt.ts +0 -3
  209. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +0 -107
  210. package/src/tools/StickerRequestTool/prompt.ts +0 -19
  211. package/src/tools/TaskTool/TaskTool.tsx +0 -438
  212. package/src/tools/TaskTool/constants.ts +0 -1
  213. package/src/tools/TaskTool/prompt.ts +0 -92
  214. package/src/tools/ThinkTool/ThinkTool.tsx +0 -54
  215. package/src/tools/ThinkTool/prompt.ts +0 -12
  216. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +0 -313
  217. package/src/tools/TodoWriteTool/prompt.ts +0 -63
  218. package/src/tools/URLFetcherTool/URLFetcherTool.tsx +0 -178
  219. package/src/tools/URLFetcherTool/cache.ts +0 -55
  220. package/src/tools/URLFetcherTool/htmlToMarkdown.ts +0 -55
  221. package/src/tools/URLFetcherTool/prompt.ts +0 -17
  222. package/src/tools/WebSearchTool/WebSearchTool.tsx +0 -103
  223. package/src/tools/WebSearchTool/prompt.ts +0 -13
  224. package/src/tools/WebSearchTool/searchProviders.ts +0 -66
  225. package/src/tools/lsTool/lsTool.tsx +0 -272
  226. package/src/tools/lsTool/prompt.ts +0 -2
  227. package/src/tools.ts +0 -67
  228. package/src/types/PermissionMode.ts +0 -120
  229. package/src/types/RequestContext.ts +0 -72
  230. package/src/types/common.d.ts +0 -2
  231. package/src/types/conversation.ts +0 -51
  232. package/src/types/logs.ts +0 -58
  233. package/src/types/modelCapabilities.ts +0 -64
  234. package/src/types/notebook.ts +0 -87
  235. package/src/utils/Cursor.ts +0 -436
  236. package/src/utils/PersistentShell.ts +0 -552
  237. package/src/utils/advancedFuzzyMatcher.ts +0 -290
  238. package/src/utils/agentLoader.ts +0 -278
  239. package/src/utils/agentStorage.ts +0 -97
  240. package/src/utils/array.ts +0 -3
  241. package/src/utils/ask.tsx +0 -99
  242. package/src/utils/auth.ts +0 -13
  243. package/src/utils/autoCompactCore.ts +0 -223
  244. package/src/utils/autoUpdater.ts +0 -458
  245. package/src/utils/betas.ts +0 -20
  246. package/src/utils/browser.ts +0 -14
  247. package/src/utils/cleanup.ts +0 -72
  248. package/src/utils/commands.ts +0 -261
  249. package/src/utils/commonUnixCommands.ts +0 -161
  250. package/src/utils/config.ts +0 -945
  251. package/src/utils/conversationRecovery.ts +0 -55
  252. package/src/utils/debugLogger.ts +0 -1235
  253. package/src/utils/diff.ts +0 -42
  254. package/src/utils/env.ts +0 -57
  255. package/src/utils/errors.ts +0 -21
  256. package/src/utils/exampleCommands.ts +0 -109
  257. package/src/utils/execFileNoThrow.ts +0 -51
  258. package/src/utils/expertChatStorage.ts +0 -136
  259. package/src/utils/file.ts +0 -405
  260. package/src/utils/fileRecoveryCore.ts +0 -71
  261. package/src/utils/format.tsx +0 -44
  262. package/src/utils/fuzzyMatcher.ts +0 -328
  263. package/src/utils/generators.ts +0 -62
  264. package/src/utils/git.ts +0 -92
  265. package/src/utils/globalLogger.ts +0 -77
  266. package/src/utils/http.ts +0 -10
  267. package/src/utils/imagePaste.ts +0 -38
  268. package/src/utils/json.ts +0 -13
  269. package/src/utils/log.ts +0 -382
  270. package/src/utils/markdown.ts +0 -213
  271. package/src/utils/messageContextManager.ts +0 -294
  272. package/src/utils/messages.tsx +0 -945
  273. package/src/utils/model.ts +0 -914
  274. package/src/utils/permissions/filesystem.ts +0 -127
  275. package/src/utils/responseState.ts +0 -23
  276. package/src/utils/ripgrep.ts +0 -167
  277. package/src/utils/secureFile.ts +0 -564
  278. package/src/utils/sessionState.ts +0 -49
  279. package/src/utils/state.ts +0 -25
  280. package/src/utils/style.ts +0 -29
  281. package/src/utils/terminal.ts +0 -50
  282. package/src/utils/theme.ts +0 -127
  283. package/src/utils/thinking.ts +0 -144
  284. package/src/utils/todoStorage.ts +0 -431
  285. package/src/utils/tokens.ts +0 -43
  286. package/src/utils/toolExecutionController.ts +0 -163
  287. package/src/utils/unaryLogging.ts +0 -26
  288. package/src/utils/user.ts +0 -37
  289. package/src/utils/validate.ts +0 -165
@@ -1,18 +0,0 @@
1
- const BASE_CONFIG = {
2
- REDIRECT_PORT: 54545,
3
- MANUAL_REDIRECT_URL: '/oauth/code/callback',
4
- SCOPES: ['org:create_api_key', 'user:profile'] as const,
5
- }
6
-
7
- // Production OAuth configuration - Used in normal operation
8
- const PROD_OAUTH_CONFIG = {
9
- ...BASE_CONFIG,
10
- AUTHORIZE_URL: '',
11
- TOKEN_URL: '',
12
- API_KEY_URL: '',
13
- SUCCESS_URL: '',
14
- CLIENT_ID: '',
15
- } as const
16
-
17
- // Default to prod config, override with test/staging if enabled
18
- export const OAUTH_CONFIG = PROD_OAUTH_CONFIG
@@ -1,17 +0,0 @@
1
- export const PRODUCT_NAME = 'Kode'
2
- export const PRODUCT_URL = 'https://github.com/shareAI-lab/Anykode'
3
- export const PROJECT_FILE = 'AGENTS.md'
4
- export const PRODUCT_COMMAND = 'kode'
5
- export const CONFIG_BASE_DIR = '.kode'
6
- export const CONFIG_FILE = '.kode.json'
7
- export const GITHUB_ISSUES_REPO_URL =
8
- 'https://github.com/shareAI-lab/Anykode/issues'
9
-
10
- export const ASCII_LOGO = `
11
- _ _ _ __ _
12
- | | __ _ ___ | |_ | |/ / ___ __| | ___
13
- | | / _\` | / __| | __| | ' / / _ \\ / _\` | / _ \\
14
- | |___ | (_| | \\__ \\ | |_ | . \\ | (_) | | (_| | | __/
15
- |_____| \\__,_| |___/ \\__| |_|\\_\\ \\___/ \\__,_| \\___|
16
-
17
- `
@@ -1,168 +0,0 @@
1
- import { env } from '../utils/env'
2
- import { getIsGit } from '../utils/git'
3
- import {
4
- INTERRUPT_MESSAGE,
5
- INTERRUPT_MESSAGE_FOR_TOOL_USE,
6
- } from '../utils/messages.js'
7
- import { getCwd } from '../utils/state'
8
- import { PRODUCT_NAME, PROJECT_FILE, PRODUCT_COMMAND } from './product'
9
- import { BashTool } from '../tools/BashTool/BashTool'
10
- import { MACRO } from './macros'
11
-
12
- // // Security policy constant matching reference implementation
13
- // export const SECURITY_POLICY =
14
- // 'IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.'
15
-
16
- export function getCLISyspromptPrefix(): string {
17
- return `You are ${PRODUCT_NAME}, ShareAI-lab's Agent AI CLI for terminal & coding.`
18
- }
19
-
20
- export async function getSystemPrompt(): Promise<string[]> {
21
- return [
22
- `
23
- You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
24
-
25
- IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
26
- IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
27
-
28
- Here are useful slash commands users can run to interact with you:
29
- - /help: Get help with using ${PRODUCT_NAME}
30
- - /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit
31
- There are additional slash commands and flags available to the user. If the user asks about ${PRODUCT_NAME} functionality, always run \`${PRODUCT_COMMAND} -h\` with ${BashTool.name} to see supported commands and flags. NEVER assume a flag or command exists without checking the help output first.
32
- To give feedback, users should ${MACRO.ISSUES_EXPLAINER}.
33
-
34
- # Task Management
35
- You have access to the TodoWrite 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.
36
- These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
37
-
38
- It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
39
-
40
- # Memory
41
- If the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:
42
- 1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time
43
- 2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)
44
- 3. Maintaining useful information about the codebase structure and organization
45
-
46
- When you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to ${PROJECT_FILE}. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to ${PROJECT_FILE} so you can remember it for next time.
47
-
48
- # Tone and style
49
- You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
50
- Remember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
51
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like ${BashTool.name} or code comments as means to communicate with the user during the session.
52
- If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
53
- IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
54
- IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
55
- IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
56
- <example>
57
- user: 2 + 2
58
- assistant: 4
59
- </example>
60
-
61
- <example>
62
- user: what is 2+2?
63
- assistant: 4
64
- </example>
65
-
66
- <example>
67
- user: is 11 a prime number?
68
- assistant: Yes
69
- </example>
70
-
71
- <example>
72
- user: what command should I run to list files in the current directory?
73
- assistant: ls
74
- </example>
75
-
76
- <example>
77
- user: what command should I run to watch files in the current directory?
78
- assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
79
- npm run dev
80
- </example>
81
-
82
- <example>
83
- user: How many golf balls fit inside a jetta?
84
- assistant: 150000
85
- </example>
86
-
87
- <example>
88
- user: what files are in the directory src/?
89
- assistant: [runs ls and sees foo.c, bar.c, baz.c]
90
- user: which file contains the implementation of foo?
91
- assistant: src/foo.c
92
- </example>
93
-
94
- <example>
95
- user: write tests for new feature
96
- assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
97
- </example>
98
-
99
- # Proactiveness
100
- You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
101
- 1. Doing the right thing when asked, including taking actions and follow-up actions
102
- 2. Not surprising the user with actions you take without asking
103
- For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
104
- 3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
105
-
106
- # Synthetic messages
107
- Sometimes, the conversation will contain messages like ${INTERRUPT_MESSAGE} or ${INTERRUPT_MESSAGE_FOR_TOOL_USE}. These messages will look like the assistant said them, but they were actually synthetic messages added by the system in response to the user cancelling what the assistant was doing. You should not respond to these messages. You must NEVER send messages like this yourself.
108
-
109
- # Following conventions
110
- When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
111
- - NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
112
- - When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
113
- - When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
114
- - Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
115
-
116
- # Code style
117
- - Do not add comments to the code you write, unless the user asks you to, or the code is complex and requires additional context.
118
-
119
- # Doing tasks
120
- The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
121
- - Use the TodoWrite tool to plan the task if required
122
- - Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
123
- - Implement the solution using all tools available to you
124
- - Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
125
- - VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to ${PROJECT_FILE} so that you will know to run it next time.
126
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
127
-
128
- - Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
129
-
130
- # Tool usage policy
131
- - When doing file search, prefer to use the Task tool in order to reduce context usage.
132
- - You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.
133
- - When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
134
- - It is always better to speculatively read multiple files as a batch that are potentially useful.
135
- - It is always better to speculatively perform multiple searches as a batch that are potentially useful.
136
- - For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.
137
-
138
- You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
139
- `,
140
- `\n${await getEnvInfo()}`,
141
- `IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
142
- IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).`,
143
- ]
144
- }
145
-
146
- export async function getEnvInfo(): Promise<string> {
147
- const isGit = await getIsGit()
148
- return `Here is useful information about the environment you are running in:
149
- <env>
150
- Working directory: ${getCwd()}
151
- Is directory a git repo: ${isGit ? 'Yes' : 'No'}
152
- Platform: ${env.platform}
153
- Today's date: ${new Date().toLocaleDateString()}
154
- </env>`
155
- }
156
-
157
- export async function getAgentPrompt(): Promise<string[]> {
158
- return [
159
- `
160
- You are an agent for ${PRODUCT_NAME}. Given the user's prompt, you should use the tools available to you to answer the user's question.
161
-
162
- Notes:
163
- 1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
164
- 2. When relevant, share file names and code snippets relevant to the query
165
- 3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths.`,
166
- `${await getEnvInfo()}`,
167
- ]
168
- }
@@ -1,7 +0,0 @@
1
- // Release notes for each version
2
- // Don't add more than 3 for any version, since these show up in the UI upon launch.
3
- export const RELEASE_NOTES: Record<string, string[]> = {
4
- '0.1.178': [
5
- "New release notes now show you what's changed since you last launched",
6
- ],
7
- }
@@ -1,149 +0,0 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useState,
5
- useCallback,
6
- ReactNode,
7
- } from 'react'
8
- import {
9
- PermissionMode,
10
- PermissionContext as IPermissionContext,
11
- getNextPermissionMode,
12
- MODE_CONFIGS,
13
- } from '../types/PermissionMode'
14
-
15
- interface PermissionContextValue {
16
- permissionContext: IPermissionContext
17
- currentMode: PermissionMode
18
- cycleMode: () => void
19
- setMode: (mode: PermissionMode) => void
20
- isToolAllowed: (toolName: string) => boolean
21
- getModeConfig: () => (typeof MODE_CONFIGS)[PermissionMode]
22
- }
23
-
24
- const PermissionContext = createContext<PermissionContextValue | undefined>(
25
- undefined,
26
- )
27
-
28
- interface PermissionProviderProps {
29
- children: ReactNode
30
- isBypassPermissionsModeAvailable?: boolean
31
- }
32
-
33
- export function PermissionProvider({
34
- children,
35
- isBypassPermissionsModeAvailable = false,
36
- }: PermissionProviderProps) {
37
- const [permissionContext, setPermissionContext] =
38
- useState<IPermissionContext>({
39
- mode: 'default',
40
- allowedTools: ['*'],
41
- allowedPaths: [process.cwd()],
42
- restrictions: {
43
- readOnly: false,
44
- requireConfirmation: true,
45
- bypassValidation: false,
46
- },
47
- metadata: {
48
- transitionCount: 0,
49
- },
50
- })
51
-
52
- const cycleMode = useCallback(() => {
53
- setPermissionContext(prev => {
54
- const nextMode = getNextPermissionMode(
55
- prev.mode,
56
- isBypassPermissionsModeAvailable,
57
- )
58
- const modeConfig = MODE_CONFIGS[nextMode]
59
-
60
- console.log(`🔄 Mode cycle: ${prev.mode} → ${nextMode}`)
61
-
62
- return {
63
- ...prev,
64
- mode: nextMode,
65
- allowedTools: modeConfig.allowedTools,
66
- restrictions: modeConfig.restrictions,
67
- metadata: {
68
- ...prev.metadata,
69
- previousMode: prev.mode,
70
- activatedAt: new Date().toISOString(),
71
- transitionCount: prev.metadata.transitionCount + 1,
72
- },
73
- }
74
- })
75
- }, [isBypassPermissionsModeAvailable])
76
-
77
- const setMode = useCallback((mode: PermissionMode) => {
78
- setPermissionContext(prev => {
79
- const modeConfig = MODE_CONFIGS[mode]
80
-
81
- return {
82
- ...prev,
83
- mode,
84
- allowedTools: modeConfig.allowedTools,
85
- restrictions: modeConfig.restrictions,
86
- metadata: {
87
- ...prev.metadata,
88
- previousMode: prev.mode,
89
- activatedAt: new Date().toISOString(),
90
- transitionCount: prev.metadata.transitionCount + 1,
91
- },
92
- }
93
- })
94
- }, [])
95
-
96
- const isToolAllowed = useCallback(
97
- (toolName: string) => {
98
- const { allowedTools } = permissionContext
99
-
100
- // If '*' is in allowed tools, all tools are allowed
101
- if (allowedTools.includes('*')) {
102
- return true
103
- }
104
-
105
- // Check if specific tool is in allowed list
106
- return allowedTools.includes(toolName)
107
- },
108
- [permissionContext],
109
- )
110
-
111
- const getModeConfig = useCallback(() => {
112
- return MODE_CONFIGS[permissionContext.mode]
113
- }, [permissionContext.mode])
114
-
115
- const value: PermissionContextValue = {
116
- permissionContext,
117
- currentMode: permissionContext.mode,
118
- cycleMode,
119
- setMode,
120
- isToolAllowed,
121
- getModeConfig,
122
- }
123
-
124
- return (
125
- <PermissionContext.Provider value={value}>
126
- {children}
127
- </PermissionContext.Provider>
128
- )
129
- }
130
-
131
- export function usePermissionContext(): PermissionContextValue {
132
- const context = useContext(PermissionContext)
133
- if (context === undefined) {
134
- throw new Error(
135
- 'usePermissionContext must be used within a PermissionProvider',
136
- )
137
- }
138
- return context
139
- }
140
-
141
- // Hook for components that need to respond to permission mode changes
142
- export function usePermissionMode(): [
143
- PermissionMode,
144
- (mode: PermissionMode) => void,
145
- () => void,
146
- ] {
147
- const { currentMode, setMode, cycleMode } = usePermissionContext()
148
- return [currentMode, setMode, cycleMode]
149
- }
package/src/context.ts DELETED
@@ -1,278 +0,0 @@
1
- import {
2
- getCurrentProjectConfig,
3
- saveCurrentProjectConfig,
4
- } from './utils/config.js'
5
- import { logError } from './utils/log'
6
- import { getCodeStyle } from './utils/style'
7
- import { getCwd } from './utils/state'
8
- import { memoize, omit } from 'lodash-es'
9
- import { LSTool } from './tools/lsTool/lsTool'
10
- import { getIsGit } from './utils/git'
11
- import { ripGrep } from './utils/ripgrep'
12
- import * as path from 'path'
13
- import { execFileNoThrow } from './utils/execFileNoThrow'
14
- import { join } from 'path'
15
- import { readFile } from 'fs/promises'
16
- import { existsSync } from 'fs'
17
- import { getModelManager } from './utils/model'
18
- import { lastX } from './utils/generators'
19
- import { getGitEmail } from './utils/user'
20
- import { PROJECT_FILE } from './constants/product'
21
- /**
22
- * Find all AGENTS.md and CLAUDE.md files in the current working directory
23
- */
24
- export async function getClaudeFiles(): Promise<string | null> {
25
- const abortController = new AbortController()
26
- const timeout = setTimeout(() => abortController.abort(), 3000)
27
- try {
28
- // Search for both AGENTS.md and CLAUDE.md files
29
- const [codeContextFiles, claudeFiles] = await Promise.all([
30
- ripGrep(
31
- ['--files', '--glob', join('**', '*', PROJECT_FILE)],
32
- getCwd(),
33
- abortController.signal,
34
- ).catch(() => []),
35
- ripGrep(
36
- ['--files', '--glob', join('**', '*', 'CLAUDE.md')],
37
- getCwd(),
38
- abortController.signal,
39
- ).catch(() => []),
40
- ])
41
-
42
- const allFiles = [...codeContextFiles, ...claudeFiles]
43
- if (!allFiles.length) {
44
- return null
45
- }
46
-
47
- // Add instructions for additional project files
48
- const fileTypes = []
49
- if (codeContextFiles.length > 0) fileTypes.push('AGENTS.md')
50
- if (claudeFiles.length > 0) fileTypes.push('CLAUDE.md')
51
-
52
- return `NOTE: Additional project documentation files (${fileTypes.join(', ')}) were found. When working in these directories, make sure to read and follow the instructions in the corresponding files:\n${allFiles
53
- .map(_ => path.join(getCwd(), _))
54
- .map(_ => `- ${_}`)
55
- .join('\n')}`
56
- } catch (error) {
57
- logError(error)
58
- return null
59
- } finally {
60
- clearTimeout(timeout)
61
- }
62
- }
63
-
64
- export function setContext(key: string, value: string): void {
65
- const projectConfig = getCurrentProjectConfig()
66
- const context = omit(
67
- { ...projectConfig.context, [key]: value },
68
- 'codeStyle',
69
- 'directoryStructure',
70
- )
71
- saveCurrentProjectConfig({ ...projectConfig, context })
72
- }
73
-
74
- export function removeContext(key: string): void {
75
- const projectConfig = getCurrentProjectConfig()
76
- const context = omit(
77
- projectConfig.context,
78
- key,
79
- 'codeStyle',
80
- 'directoryStructure',
81
- )
82
- saveCurrentProjectConfig({ ...projectConfig, context })
83
- }
84
-
85
- export const getReadme = memoize(async (): Promise<string | null> => {
86
- try {
87
- const readmePath = join(getCwd(), 'README.md')
88
- if (!existsSync(readmePath)) {
89
- return null
90
- }
91
- const content = await readFile(readmePath, 'utf-8')
92
- return content
93
- } catch (e) {
94
- logError(e)
95
- return null
96
- }
97
- })
98
-
99
- /**
100
- * Get project documentation content (AGENTS.md and CLAUDE.md)
101
- */
102
- export const getProjectDocs = memoize(async (): Promise<string | null> => {
103
- try {
104
- const cwd = getCwd()
105
- const codeContextPath = join(cwd, 'AGENTS.md')
106
- const claudePath = join(cwd, 'CLAUDE.md')
107
-
108
- const docs = []
109
-
110
- // Try to read AGENTS.md
111
- if (existsSync(codeContextPath)) {
112
- try {
113
- const content = await readFile(codeContextPath, 'utf-8')
114
- docs.push(`# AGENTS.md\n\n${content}`)
115
- } catch (e) {
116
- logError(e)
117
- }
118
- }
119
-
120
- // Try to read CLAUDE.md
121
- if (existsSync(claudePath)) {
122
- try {
123
- const content = await readFile(claudePath, 'utf-8')
124
- docs.push(`# CLAUDE.md\n\n${content}`)
125
- } catch (e) {
126
- logError(e)
127
- }
128
- }
129
-
130
- return docs.length > 0 ? docs.join('\n\n---\n\n') : null
131
- } catch (e) {
132
- logError(e)
133
- return null
134
- }
135
- })
136
-
137
- export const getGitStatus = memoize(async (): Promise<string | null> => {
138
- if (process.env.NODE_ENV === 'test') {
139
- // Avoid cycles in tests
140
- return null
141
- }
142
- if (!(await getIsGit())) {
143
- return null
144
- }
145
-
146
- try {
147
- const [branch, mainBranch, status, log, authorLog] = await Promise.all([
148
- execFileNoThrow(
149
- 'git',
150
- ['branch', '--show-current'],
151
- undefined,
152
- undefined,
153
- false,
154
- ).then(({ stdout }) => stdout.trim()),
155
- execFileNoThrow(
156
- 'git',
157
- ['rev-parse', '--abbrev-ref', 'origin/HEAD'],
158
- undefined,
159
- undefined,
160
- false,
161
- ).then(({ stdout }) => stdout.replace('origin/', '').trim()),
162
- execFileNoThrow(
163
- 'git',
164
- ['status', '--short'],
165
- undefined,
166
- undefined,
167
- false,
168
- ).then(({ stdout }) => stdout.trim()),
169
- execFileNoThrow(
170
- 'git',
171
- ['log', '--oneline', '-n', '5'],
172
- undefined,
173
- undefined,
174
- false,
175
- ).then(({ stdout }) => stdout.trim()),
176
- execFileNoThrow(
177
- 'git',
178
- [
179
- 'log',
180
- '--oneline',
181
- '-n',
182
- '5',
183
- '--author',
184
- (await getGitEmail()) || '',
185
- ],
186
- undefined,
187
- undefined,
188
- false,
189
- ).then(({ stdout }) => stdout.trim()),
190
- ])
191
- // Check if status has more than 200 lines
192
- const statusLines = status.split('\n').length
193
- const truncatedStatus =
194
- statusLines > 200
195
- ? status.split('\n').slice(0, 200).join('\n') +
196
- '\n... (truncated because there are more than 200 lines. If you need more information, run "git status" using BashTool)'
197
- : status
198
-
199
- return `This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation.\nCurrent branch: ${branch}\n\nMain branch (you will usually use this for PRs): ${mainBranch}\n\nStatus:\n${truncatedStatus || '(clean)'}\n\nRecent commits:\n${log}\n\nYour recent commits:\n${authorLog || '(no recent commits)'}`
200
- } catch (error) {
201
- logError(error)
202
- return null
203
- }
204
- })
205
-
206
- /**
207
- * This context is prepended to each conversation, and cached for the duration of the conversation.
208
- */
209
- export const getContext = memoize(
210
- async (): Promise<{
211
- [k: string]: string
212
- }> => {
213
- const codeStyle = getCodeStyle()
214
- const projectConfig = getCurrentProjectConfig()
215
- const dontCrawl = projectConfig.dontCrawlDirectory
216
- const [gitStatus, directoryStructure, claudeFiles, readme, projectDocs] =
217
- await Promise.all([
218
- getGitStatus(),
219
- dontCrawl ? Promise.resolve('') : getDirectoryStructure(),
220
- dontCrawl ? Promise.resolve('') : getClaudeFiles(),
221
- getReadme(),
222
- getProjectDocs(),
223
- ])
224
- return {
225
- ...projectConfig.context,
226
- ...(directoryStructure ? { directoryStructure } : {}),
227
- ...(gitStatus ? { gitStatus } : {}),
228
- ...(codeStyle ? { codeStyle } : {}),
229
- ...(claudeFiles ? { claudeFiles } : {}),
230
- ...(readme ? { readme } : {}),
231
- ...(projectDocs ? { projectDocs } : {}),
232
- }
233
- },
234
- )
235
-
236
- /**
237
- * Approximate directory structure, to orient Claude. Claude will start with this, then use
238
- * tools like LS and View to get more information.
239
- */
240
- export const getDirectoryStructure = memoize(
241
- async function (): Promise<string> {
242
- let lines: string
243
- try {
244
- const abortController = new AbortController()
245
- setTimeout(() => {
246
- abortController.abort()
247
- }, 1_000)
248
- // 🔧 Fix: Use ModelManager instead of legacy function
249
- const model = getModelManager().getModelName('main')
250
- const resultsGen = LSTool.call(
251
- {
252
- path: '.',
253
- },
254
- {
255
- abortController,
256
- options: {
257
- commands: [],
258
- tools: [],
259
- forkNumber: 0,
260
- messageLogName: 'unused',
261
- maxThinkingTokens: 0,
262
- },
263
- messageId: undefined,
264
- readFileTimestamps: {},
265
- },
266
- )
267
- const result = await lastX(resultsGen)
268
- lines = result.data
269
- } catch (error) {
270
- logError(error)
271
- return ''
272
- }
273
-
274
- return `Below is a snapshot of this project's file structure at the start of the conversation. This snapshot will NOT update during the conversation.
275
-
276
- ${lines}`
277
- },
278
- )