Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
W
WebAgent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xuchentao
WebAgent
Commits
b542c952
Commit
b542c952
authored
Jul 24, 2026
by
xuchentao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
移除 Agent 修改规模限制
parent
bb9d04f4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
13 deletions
+27
-13
AGENTS.md
AGENTS.md
+7
-0
contracts.ts
backend/src/agent/contracts.ts
+0
-3
diff-validator.test.ts
backend/src/agent/diff-validator.test.ts
+17
-0
diff-validator.ts
backend/src/agent/diff-validator.ts
+1
-7
path-policy.ts
backend/src/security/path-policy.ts
+0
-1
agent-runtime.md
docs/agent-runtime.md
+1
-1
site-patch-schema.md
docs/site-patch-schema.md
+1
-1
No files found.
AGENTS.md
0 → 100644
View file @
b542c952
# 开发规范
## Node.js 运行时
-
执行安装、测试、类型检查、构建或启动等项目命令前,必须先运行
`nvm use 24`
。
-
在非交互式 Shell 中,先运行
`source /Users/mac/.nvm/nvm.sh`
,再运行
`nvm use 24`
和后续项目命令。
-
不使用系统自带 Node.js 或其他 Node.js 版本执行项目命令。
backend/src/agent/contracts.ts
View file @
b542c952
...
...
@@ -43,7 +43,4 @@ export const DEFAULT_AGENT_POLICY: AgentToolPolicy = {
export
const
AGENT_LIMITS
=
{
timeoutMs
:
600
_000
,
maxTurns
:
20
,
maxFiles
:
30
,
maxDiffBytes
:
1
_048_576
,
maxFileBytes
:
262
_144
,
}
as
const
;
backend/src/agent/diff-validator.test.ts
View file @
b542c952
...
...
@@ -41,3 +41,20 @@ test("AgentDiffValidator accepts source edits and rejects protected files", asyn
await
rm
(
root
,
{
recursive
:
true
,
force
:
true
});
}
});
test
(
"AgentDiffValidator does not limit changed file count, file size, or diff size"
,
async
()
=>
{
const
root
=
await
workspace
();
try
{
await
writeFile
(
path
.
join
(
root
,
"src"
,
"large.ts"
),
`export default
${
JSON
.
stringify
(
"x"
.
repeat
(
1
_100_000
))}
;\n`
);
await
Promise
.
all
(
Array
.
from
({
length
:
30
},
(
_
,
index
)
=>
(
writeFile
(
path
.
join
(
root
,
"src"
,
`extra-
${
index
}
.ts`
),
`export const value
${
index
}
=
${
index
}
;\n`
)
)));
const
result
=
await
new
AgentDiffValidator
().
validate
(
root
);
assert
.
equal
(
result
.
passed
,
true
);
assert
.
ok
(
result
.
files
.
length
>
30
);
assert
.
ok
(
result
.
totalBytes
>
1
_048_576
);
}
finally
{
await
rm
(
root
,
{
recursive
:
true
,
force
:
true
});
}
});
backend/src/agent/diff-validator.ts
View file @
b542c952
import
path
from
"node:path"
;
import
{
lstat
,
realpath
}
from
"node:fs/promises"
;
import
{
execa
}
from
"execa"
;
import
{
AGENT_LIMITS
}
from
"./contracts.js"
;
export
interface
AgentDiffValidation
{
passed
:
boolean
;
...
...
@@ -27,10 +26,8 @@ export class AgentDiffValidator {
return
raw
.
includes
(
" -> "
)
?
raw
.
split
(
" -> "
).
at
(
-
1
)
!
:
raw
;
}))].
sort
();
const
violations
:
string
[]
=
[];
let
fileBytes
=
0
;
const
root
=
await
realpath
(
workspace
);
if
(
!
files
.
length
)
violations
.
push
(
"Agent 没有产生文件修改"
);
if
(
files
.
length
>
AGENT_LIMITS
.
maxFiles
)
violations
.
push
(
`修改文件数
${
files
.
length
}
超过限制
${
AGENT_LIMITS
.
maxFiles
}
`
);
for
(
const
file
of
files
)
{
if
(
file
.
includes
(
".."
)
||
file
.
startsWith
(
"/"
)
||
file
.
includes
(
"
\
\"
)) {
violations.push(`不安全路径: ${file}`);
...
...
@@ -46,8 +43,6 @@ export class AgentDiffValidator {
if (info.isFile()) {
const resolved = await realpath(candidate);
if (!resolved.startsWith(root + path.sep)) violations.push(`文件解析到工作区外: ${file}`);
if (info.size > AGENT_LIMITS.maxFileBytes) violations.push(`文件超过 ${AGENT_LIMITS.maxFileBytes} 字节: ${file}`);
fileBytes += info.size;
}
} catch { /* deleted file */ }
}
...
...
@@ -58,7 +53,6 @@ export class AgentDiffValidator {
]);
if (checkResult.exitCode !== 0) violations.push("
git
diff
--
check
未通过
:
" + checkResult.stdout.slice(-1000));
const totalBytes = Buffer.byteLength(diffResult.stdout);
if (totalBytes > AGENT_LIMITS.maxDiffBytes) violations.push(`Diff 超过 ${AGENT_LIMITS.maxDiffBytes} 字节`);
return { passed: violations.length === 0, diff: diffResult.stdout, files, totalBytes: Math.max(totalBytes, fileBytes), violations };
return { passed: violations.length === 0, diff: diffResult.stdout, files, totalBytes, violations };
}
}
backend/src/security/path-policy.ts
View file @
b542c952
...
...
@@ -20,7 +20,6 @@ export async function validatePatch(patch: SitePatch, workspacePath: string): Pr
if (!allowedPatterns.some((pattern) => pattern.test(normalized))) throw new Error("
Patch
路径不在白名单中
:
" + normalized);
if (seen.has(normalized)) throw new Error("
Patch
中存在重复路径
:
" + normalized);
seen.add(normalized);
if (operation.type === "
write
" && Buffer.byteLength(operation.content, "
utf8
") > 256 * 1024) throw new Error("
单文件不能超过
256
KiB
");
const destination = path.resolve(workspacePath, normalized);
if (!destination.startsWith(path.resolve(workspacePath) + path.sep)) throw new Error("
Patch
路径越界
");
const existing = await lstat(destination).catch(() => null);
...
...
docs/agent-runtime.md
View file @
b542c952
...
...
@@ -27,7 +27,7 @@ Qwen Code 使用 `OPENAI_API_KEY`、`OPENAI_BASE_URL`、`OPENAI_MODEL` 的 OpenA
-
Agent 只能读取工作草稿,写入限制在
`src/**`
;shell 只允许三条只读 Git 自检命令。
-
禁止访问
`.env*`
、
`.git/**`
、依赖、构建产物、package/lockfile、网络和发布工具。
-
Provider 完成后,系统仍会独立检查路径、符号链接
、文件数、文件大小、diff 大小
和
`git diff --check`
。
-
Provider 完成后,系统仍会独立检查路径、符号链接和
`git diff --check`
。
-
系统独立执行网站构建;构建通过后只原子替换未保存草稿的测试预览,不创建 Git 提交。后续 Agent 任务继续使用同一草稿,因此多轮修改可以累积。
-
用户在左侧“版本”中填写说明并手动保存时,系统再次构建草稿,通过后才创建一个 Git 提交并将其设为当前保存版本。
-
用户可以放弃未保存草稿;系统会先确认当前保存版本可重新构建,再删除草稿,避免因构建异常丢失修改。
...
...
docs/site-patch-schema.md
View file @
b542c952
...
...
@@ -23,4 +23,4 @@
平台能力内核
`src/_platform/**`
、内容协议
`src/content.config.ts`
和外置文章映射
`src/content/articles/**`
由 WebAgent 维护,Agent 不得修改。页面、布局、组件和样式仍可自由调整。
禁止路径包括
`.git`
、
`node_modules`
、
`dist`
、
`.astro`
、依赖清单和 Astro 配置。单次最多 5 个操作
,单文件不超过 256 KiB
;不允许路径穿越、绝对路径、符号链接写入或模型生成 Shell。
禁止路径包括
`.git`
、
`node_modules`
、
`dist`
、
`.astro`
、依赖清单和 Astro 配置。单次最多 5 个操作;不允许路径穿越、绝对路径、符号链接写入或模型生成 Shell。
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment