Skip to content

Commit edc9301

Browse files
committed
Migrate webpack configuration to esbuild loader and introduce diff placeholders
- make builds faster - it's been reported that changes made to files like pnpm-lock.yaml are attached in files section of commit message prompt, these are very very heavy - no need to use code block for texts like "File modified" - define [Pasted text] in a single place ├── apps │ ├── browser │ │ ├── package.json │ │ └── webpack.config.ts │ └── editor │ ├── package.json │ ├── src │ │ ├── commands │ │ │ ├── apply-response-command │ │ │ │ └── utils │ │ │ │ └── preview │ │ │ │ ├── index.ts │ │ │ │ └── vscode-ui.ts │ │ │ ├── code-at-cursor-command │ │ │ │ └── utils │ │ │ │ └── perform-code-at-cursor.ts │ │ │ ├── copy-markdown-command.ts │ │ │ └── generate-commit-message-commands │ │ │ ├── actions │ │ │ │ ├── get-prompt-data.ts │ │ │ │ └── run-generate-action.ts │ │ │ ├── generate-commit-message-commands.ts │ │ │ ├── index.ts │ │ │ └── utils │ │ │ ├── build-commit-message-prompt.ts │ │ │ ├── generate-commit-message-with-api.ts │ │ │ ├── get-commit-message-config.ts │ │ │ └── strip-wrapping-quotes.ts │ │ ├── constants │ │ │ ├── edit-format-instructions.ts │ │ │ ├── ignored-lock-files.ts │ │ │ ├── instructions.ts │ │ │ ├── providers.ts │ │ │ ├── secret-storage-keys.ts │ │ │ ├── state-keys.ts │ │ │ └── values.ts │ │ ├── context │ │ │ ├── context-initialization.ts │ │ │ ├── helpers │ │ │ │ ├── get-all-workspace-files.ts │ │ │ │ └── get-selected-files.ts │ │ │ ├── providers │ │ │ │ ├── open-editors │ │ │ │ │ └── open-editors-provider.ts │ │ │ │ ├── selected-files │ │ │ │ │ └── selected-files-provider.ts │ │ │ │ └── workspace │ │ │ │ ├── modules │ │ │ │ │ ├── index.ts │ │ │ │ │ └── token-calculator.ts │ │ │ │ └── workspace-provider.ts │ │ │ ├── shared-context-state.ts │ │ │ └── utils │ │ │ └── shrink-file │ │ │ ├── index.ts │ │ │ ├── languages │ │ │ │ ├── c-style.ts │ │ │ │ ├── css.ts │ │ │ │ ├── html.ts │ │ │ │ ├── jsx.ts │ │ │ │ ├── python.ts │ │ │ │ ├── ruby.ts │ │ │ │ └── sql.ts │ │ │ ├── shrink-file.spec.ts │ │ │ ├── shrink-file.ts │ │ │ └── test-cases │ │ │ ├── c-style │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── css │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── html │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── jsx │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── python │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── ruby │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ ├── scss │ │ │ │ ├── input.txt │ │ │ │ └── output.txt │ │ │ └── sql │ │ │ ├── input.txt │ │ │ └── output.txt │ │ ├── extension.ts │ │ ├── features │ │ │ └── checkpoints │ │ │ └── actions │ │ │ ├── create-checkpoint.ts │ │ │ └── index.ts │ │ ├── i18n │ │ │ └── index.ts │ │ ├── services │ │ │ ├── providers-manager.ts │ │ │ └── websocket-manager.ts │ │ ├── utils │ │ │ ├── apply-reasoning-effort.ts │ │ │ ├── ascii-tree │ │ │ │ ├── ascii-tree.ts │ │ │ │ └── index.ts │ │ │ ├── commit-message-details.ts │ │ │ ├── files-collector.ts │ │ │ ├── git-repository-utils.ts │ │ │ ├── normalize-path.ts │ │ │ ├── prompt-builder.ts │ │ │ ├── send-llm-message.ts │ │ │ ├── show-configurations-quick-pick.ts │ │ │ ├── show-missing-configuration-notification.ts │ │ │ └── web-configuration-format-converters.ts │ │ └── views │ │ └── prompt │ │ └── backend │ │ ├── message-handlers │ │ │ ├── handle-autofill.ts │ │ │ ├── handle-copy-prompt.ts │ │ │ ├── handle-make-api-call.ts │ │ │ ├── handle-preview-prompt.ts │ │ │ └── handle-preview-web-configuration.ts │ │ └── prompt-view-provider.ts │ └── webpack.config.ts └── packages └── shared └── src └── utils ├── display-token-count.ts └── logger.ts
1 parent 7e0be1a commit edc9301

7 files changed

Lines changed: 3719 additions & 9593 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,10 +1210,6 @@
12101210
}
12111211
},
12121212
"devDependencies": {
1213-
"@babel/core": "^7.29.7",
1214-
"@babel/preset-env": "^7.27.2",
1215-
"@babel/preset-react": "^7.27.1",
1216-
"@babel/preset-typescript": "^7.27.1",
12171213
"@types/dompurify": "^3.0.5",
12181214
"@types/he": "^1.2.3",
12191215
"@types/jsdom": "^21.1.7",
@@ -1225,12 +1221,12 @@
12251221
"@types/turndown": "^5.0.5",
12261222
"@typescript-eslint/eslint-plugin": "^7.18.0",
12271223
"@typescript-eslint/parser": "^7.18.0",
1228-
"babel-loader": "^9.2.1",
12291224
"clean-webpack-plugin": "^4.0.0",
12301225
"copy-webpack-plugin": "^12.0.2",
12311226
"css-loader": "^6.5.1",
12321227
"eslint": "^8.57.1",
12331228
"eslint-config-prettier": "^10.1.5",
1229+
"esbuild-loader": "^4.2.2",
12341230
"eslint-plugin-react": "^7.37.5",
12351231
"fork-ts-checker-webpack-plugin": "^9.0.2",
12361232
"mini-css-extract-plugin": "^2.9.2",

‎apps/editor/src/commands/generate-commit-message-commands/utils/build-commit-message-prompt.ts‎

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as vscode from 'vscode'
22
import { commit_message_format } from '@/constants/instructions'
33
import type { GitRepository } from '@/utils/git-repository-utils'
4-
import { MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE } from '@/constants/values'
4+
import {
5+
MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE,
6+
DIFF_PLACEHOLDERS
7+
} from '@/constants/values'
58
import { PromptBuilder } from '@/utils/prompt-builder'
69
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
710

@@ -84,10 +87,35 @@ export const build_commit_message_prompt = async (
8487
}
8588
}
8689

90+
let is_ignored = false
91+
92+
if (file_path && workspace_provider) {
93+
const absolute_path = vscode.Uri.joinPath(
94+
repository.rootUri,
95+
file_path
96+
).fsPath
97+
if (
98+
workspace_provider.is_ignored_by_patterns(absolute_path) ||
99+
workspace_provider.is_excluded(file_path)
100+
) {
101+
is_ignored = true
102+
}
103+
}
104+
87105
if (is_binary) {
88-
if (status == 'created') final_diff_content = 'Binary file created'
89-
else if (status == 'deleted') final_diff_content = 'Binary file deleted'
90-
else final_diff_content = 'Binary file modified'
106+
if (status == 'created')
107+
final_diff_content = DIFF_PLACEHOLDERS.BINARY_FILE_CREATED
108+
else if (status == 'deleted')
109+
final_diff_content = DIFF_PLACEHOLDERS.BINARY_FILE_DELETED
110+
else final_diff_content = DIFF_PLACEHOLDERS.BINARY_FILE_MODIFIED
111+
} else if (is_ignored) {
112+
if (status == 'created')
113+
final_diff_content = DIFF_PLACEHOLDERS.FILE_CREATED
114+
else if (status == 'deleted')
115+
final_diff_content = DIFF_PLACEHOLDERS.FILE_DELETED
116+
else if (status == 'renamed')
117+
final_diff_content = DIFF_PLACEHOLDERS.FILE_RENAMED
118+
else final_diff_content = DIFF_PLACEHOLDERS.FILE_MODIFIED
91119
} else {
92120
const hunk_start_index = final_diff_content.indexOf('\n@@ ')
93121
if (hunk_start_index != -1) {
@@ -99,22 +127,7 @@ export const build_commit_message_prompt = async (
99127
}
100128
}
101129

102-
let should_include_full_content = true
103-
104-
if (!is_deleted && file_path && !is_binary) {
105-
if (workspace_provider) {
106-
const absolute_path = vscode.Uri.joinPath(
107-
repository.rootUri,
108-
file_path
109-
).fsPath
110-
if (
111-
workspace_provider.is_ignored_by_patterns(absolute_path) ||
112-
workspace_provider.is_excluded(file_path)
113-
) {
114-
should_include_full_content = false
115-
}
116-
}
117-
}
130+
const should_include_full_content = !is_ignored
118131

119132
if (
120133
!is_deleted &&

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@ export const MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE = 20000
33
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
6+
7+
export const DIFF_PLACEHOLDERS = {
8+
FILE_CREATED: 'File created',
9+
FILE_DELETED: 'File deleted',
10+
FILE_RENAMED: 'File renamed',
11+
FILE_MODIFIED: 'File modified',
12+
BINARY_FILE_CREATED: 'Binary file created',
13+
BINARY_FILE_DELETED: 'Binary file deleted',
14+
BINARY_FILE_MODIFIED: 'Binary file modified',
15+
BINARY_FILE_ADDED: 'Binary file added'
16+
}

‎apps/editor/src/utils/git-repository-utils.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import * as vscode from 'vscode'
22
import { execSync } from 'child_process'
33
import * as path from 'path'
44
import { t } from '@/i18n'
5-
import { MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE } from '@/constants/values'
5+
import {
6+
MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE,
7+
DIFF_PLACEHOLDERS
8+
} from '@/constants/values'
69
import { PromptBuilder } from './prompt-builder'
710
import { display_token_count } from '@shared/utils/display-token-count'
811
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
@@ -251,7 +254,7 @@ export const prepare_staged_changes = async (params: {
251254
status = 'created'
252255
const content = await vscode.workspace.fs.readFile(change.uri)
253256
if (content.includes(0)) {
254-
final_diff_content = 'Binary file added'
257+
final_diff_content = DIFF_PLACEHOLDERS.BINARY_FILE_ADDED
255258
} else {
256259
full_content = Buffer.from(content).toString('utf8')
257260
const lines = full_content.split('\n')
@@ -282,7 +285,7 @@ export const prepare_staged_changes = async (params: {
282285
raw_diff.includes('\nBinary files ') ||
283286
raw_diff.startsWith('Binary files ')
284287
) {
285-
final_diff_content = 'Binary file modified'
288+
final_diff_content = DIFF_PLACEHOLDERS.BINARY_FILE_MODIFIED
286289
} else {
287290
const hunk_start_index = raw_diff.indexOf('\n@@ ')
288291
if (hunk_start_index !== -1) {

‎apps/editor/src/utils/prompt-builder.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { normalize_path } from './normalize-path'
2+
import { DIFF_PLACEHOLDERS } from '@/constants/values'
23

34
export namespace PromptBuilder {
45
export const build_file_context = (params: {
@@ -37,8 +38,16 @@ export namespace PromptBuilder {
3738

3839
if (params.diff_content?.trimEnd()) {
3940
const diff_content = params.diff_content.trimEnd()
40-
const backticks = diff_content.includes('```') ? '````' : '```'
41-
result += `${backticks}diff\n${diff_content}\n${backticks}\n\n`
41+
42+
const is_placeholder =
43+
Object.values(DIFF_PLACEHOLDERS).includes(diff_content)
44+
45+
if (is_placeholder) {
46+
result += `${diff_content}\n\n`
47+
} else {
48+
const backticks = diff_content.includes('```') ? '````' : '```'
49+
result += `${backticks}diff\n${diff_content}\n${backticks}\n\n`
50+
}
4251
}
4352

4453
if (params.full_content?.trimEnd()) {

‎apps/editor/webpack.config.ts‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
4848
exclude: /node_modules/,
4949
use: [
5050
{
51-
loader: 'babel-loader',
51+
loader: 'esbuild-loader',
5252
options: {
53-
presets: ['@babel/preset-env', '@babel/preset-typescript']
53+
loader: 'ts',
54+
target: 'es2022'
5455
}
5556
}
5657
]
@@ -189,18 +190,11 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
189190
exclude: /node_modules/,
190191
use: [
191192
{
192-
loader: 'babel-loader',
193+
loader: 'esbuild-loader',
193194
options: {
194-
presets: [
195-
'@babel/preset-env',
196-
[
197-
'@babel/preset-react',
198-
{
199-
runtime: 'automatic'
200-
}
201-
],
202-
'@babel/preset-typescript'
203-
]
195+
loader: 'tsx',
196+
target: 'es2022',
197+
jsx: 'automatic'
204198
}
205199
}
206200
]

0 commit comments

Comments
 (0)