Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
aec5882c
Unverified
提交
aec5882c
authored
4月 28, 2025
作者:
Will Chen
提交者:
GitHub
4月 28, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in extract codebase that artificially limited to 30 files (#32)
上级
e65b80bc
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
4 行增加
和
65 行删除
+4
-65
app_handlers.ts
src/ipc/handlers/app_handlers.ts
+0
-25
ipc_client.ts
src/ipc/ipc_client.ts
+0
-14
codebase.ts
src/utils/codebase.ts
+4
-26
没有找到文件。
src/ipc/handlers/app_handlers.ts
浏览文件 @
aec5882c
...
@@ -619,31 +619,6 @@ export function registerAppHandlers() {
...
@@ -619,31 +619,6 @@ export function registerAppHandlers() {
}
}
);
);
// Extract codebase information
ipcMain
.
handle
(
"extract-codebase"
,
async
(
_
,
{
appId
,
maxFiles
}:
{
appId
:
number
;
maxFiles
?:
number
})
=>
{
const
app
=
await
db
.
query
.
apps
.
findFirst
({
where
:
eq
(
apps
.
id
,
appId
),
});
if
(
!
app
)
{
throw
new
Error
(
"App not found"
);
}
const
appPath
=
getDyadAppPath
(
app
.
path
);
try
{
return
await
extractCodebase
(
appPath
,
maxFiles
);
}
catch
(
error
)
{
logger
.
error
(
`Error extracting codebase for app
${
appId
}
:`
,
error
);
throw
new
Error
(
`Failed to extract codebase:
${(
error
as
any
).
message
}
`
);
}
}
);
ipcMain
.
handle
(
ipcMain
.
handle
(
"edit-app-file"
,
"edit-app-file"
,
async
(
async
(
...
...
src/ipc/ipc_client.ts
浏览文件 @
aec5882c
...
@@ -431,20 +431,6 @@ export class IpcClient {
...
@@ -431,20 +431,6 @@ export class IpcClient {
}
}
}
}
// Extract codebase information for a given app
public
async
extractCodebase
(
appId
:
number
,
maxFiles
=
30
):
Promise
<
string
>
{
try
{
const
codebaseInfo
=
await
this
.
ipcRenderer
.
invoke
(
"extract-codebase"
,
{
appId
,
maxFiles
,
});
return
codebaseInfo
as
string
;
}
catch
(
error
)
{
showError
(
error
);
throw
error
;
}
}
// Delete an app and all its files
// Delete an app and all its files
public
async
deleteApp
(
appId
:
number
):
Promise
<
{
success
:
boolean
}
>
{
public
async
deleteApp
(
appId
:
number
):
Promise
<
{
success
:
boolean
}
>
{
try
{
try
{
...
...
src/utils/codebase.ts
浏览文件 @
aec5882c
...
@@ -33,18 +33,9 @@ async function isGitIgnored(
...
@@ -33,18 +33,9 @@ async function isGitIgnored(
/**
/**
* Recursively walk a directory and collect all relevant files
* Recursively walk a directory and collect all relevant files
*/
*/
async
function
collectFiles
(
async
function
collectFiles
(
dir
:
string
,
baseDir
:
string
):
Promise
<
string
[]
>
{
dir
:
string
,
baseDir
:
string
,
maxFiles
=
100
):
Promise
<
string
[]
>
{
const
files
:
string
[]
=
[];
const
files
:
string
[]
=
[];
// Stop if we've reached the file limit
if
(
files
.
length
>=
maxFiles
)
{
return
files
;
}
// Check if directory exists
// Check if directory exists
if
(
!
fs
.
existsSync
(
dir
))
{
if
(
!
fs
.
existsSync
(
dir
))
{
return
files
;
return
files
;
...
@@ -55,11 +46,6 @@ async function collectFiles(
...
@@ -55,11 +46,6 @@ async function collectFiles(
const
entries
=
fs
.
readdirSync
(
dir
,
{
withFileTypes
:
true
});
const
entries
=
fs
.
readdirSync
(
dir
,
{
withFileTypes
:
true
});
for
(
const
entry
of
entries
)
{
for
(
const
entry
of
entries
)
{
// Stop if we've reached the file limit
if
(
files
.
length
>=
maxFiles
)
{
break
;
}
const
fullPath
=
path
.
join
(
dir
,
entry
.
name
);
const
fullPath
=
path
.
join
(
dir
,
entry
.
name
);
// Skip excluded directories
// Skip excluded directories
...
@@ -74,11 +60,7 @@ async function collectFiles(
...
@@ -74,11 +60,7 @@ async function collectFiles(
if
(
entry
.
isDirectory
())
{
if
(
entry
.
isDirectory
())
{
// Recursively process subdirectories
// Recursively process subdirectories
const
subDirFiles
=
await
collectFiles
(
const
subDirFiles
=
await
collectFiles
(
fullPath
,
baseDir
);
fullPath
,
baseDir
,
maxFiles
-
files
.
length
);
files
.
push
(...
subDirFiles
);
files
.
push
(...
subDirFiles
);
}
else
if
(
entry
.
isFile
())
{
}
else
if
(
entry
.
isFile
())
{
// Check file extension and filename
// Check file extension and filename
...
@@ -152,19 +134,15 @@ ${content}
...
@@ -152,19 +134,15 @@ ${content}
/**
/**
* Extract and format codebase files as a string to be included in prompts
* Extract and format codebase files as a string to be included in prompts
* @param appPath - Path to the codebase to extract
* @param appPath - Path to the codebase to extract
* @param maxFiles - Maximum number of files to include (default: 30)
* @returns A string containing formatted file contents
* @returns A string containing formatted file contents
*/
*/
export
async
function
extractCodebase
(
export
async
function
extractCodebase
(
appPath
:
string
):
Promise
<
string
>
{
appPath
:
string
,
maxFiles
=
30
):
Promise
<
string
>
{
if
(
!
fs
.
existsSync
(
appPath
))
{
if
(
!
fs
.
existsSync
(
appPath
))
{
return
`# Error: Directory
${
appPath
}
does not exist`
;
return
`# Error: Directory
${
appPath
}
does not exist`
;
}
}
// Collect all relevant files
// Collect all relevant files
const
files
=
await
collectFiles
(
appPath
,
appPath
,
maxFiles
);
const
files
=
await
collectFiles
(
appPath
,
appPath
);
// Sort files to prioritize important files
// Sort files to prioritize important files
const
sortedFiles
=
sortFilesByImportance
(
files
,
appPath
);
const
sortedFiles
=
sortFilesByImportance
(
files
,
appPath
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论