Skip to content

Commit e4722e4

Browse files
author
iammm0
committed
chore(ci): ESLint unix 格式化器、Node 20/22/24 矩阵与 Prettier 修复
Made-with: Cursor
1 parent c8feba9 commit e4722e4

8 files changed

Lines changed: 30 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: ['18', '20', '22']
18+
node-version: ['20', '22', '24']
1919

2020
steps:
2121
- uses: actions/checkout@v4

package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"start:latest": "node scripts/start_latest.js",
2828
"start:tui": "npm --prefix terminal-ui run tui",
2929
"typecheck": "tsc -p server/tsconfig.json --noEmit",
30-
"lint": "eslint server/src/",
31-
"lint:fix": "eslint server/src/ --fix",
30+
"lint": "eslint server/src/ -f unix",
31+
"lint:fix": "eslint server/src/ -f unix --fix",
3232
"format": "prettier --write \"server/src/**/*.ts\"",
3333
"format:check": "prettier --check \"server/src/**/*.ts\"",
3434
"test": "vitest run",
@@ -41,7 +41,7 @@
4141
"release:verify": "node scripts/verify_release_package.js"
4242
},
4343
"engines": {
44-
"node": ">=18"
44+
"node": ">=20"
4545
},
4646
"keywords": [
4747
"security",
@@ -77,6 +77,7 @@
7777
"@typescript-eslint/parser": "^8.58.0",
7878
"eslint": "^10.2.0",
7979
"eslint-config-prettier": "^10.1.8",
80+
"eslint-formatter-unix": "^9.0.1",
8081
"prettier": "^3.8.1",
8182
"tsx": "^4.20.6",
8283
"typescript": "^5.8.3",

server/src/modules/agents/core/security-react-agent.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import { LLMProvider, createLLM, LLMConfig } from '../../../common/llm';
66
import { TodoItem } from '../../../common/types';
77
import { validateToolInvocation } from './tool-action-validate';
88
import { formatExecuteCommandObservation } from './observation-format';
9-
import {
10-
type ClientShellPayload,
11-
formatClientShellContextBlock,
12-
} from './client-shell-context.js';
9+
import { type ClientShellPayload, formatClientShellContextBlock } from './client-shell-context.js';
1310

1411
interface ReActStep {
1512
type: 'thought' | 'action' | 'observation';

server/src/modules/agents/core/tool-action-validate.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
*/
44

55
/** 允许 params 为空对象或无非空字段的工具(无需显式参数即可工作) */
6-
export const TOOLS_ALLOW_EMPTY_PARAMS = new Set<string>([
7-
'system_info',
8-
'network_analyze',
9-
]);
6+
export const TOOLS_ALLOW_EMPTY_PARAMS = new Set<string>(['system_info', 'network_analyze']);
107

118
function countEffectiveKeys(params: Record<string, unknown>): number {
129
return Object.keys(params).filter((k) => {

server/src/modules/chat/chat.service.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ function buildStreamSummaryPayload(summary: InteractionSummary): {
5252
if (tail) parts.push(`## 总结\n${tail}`);
5353
let report = parts.join('\n\n');
5454
if (!report.trim()) {
55-
report = summary.rawReport?.trim() ? summary.rawReport.slice(0, 12_000) : '(未能生成摘要,请查看服务端日志。)';
55+
report = summary.rawReport?.trim()
56+
? summary.rawReport.slice(0, 12_000)
57+
: '(未能生成摘要,请查看服务端日志。)';
5658
}
5759
/** 短收尾:详细章节已在「安全报告」块中展示,避免 TUI 再打一屏重复摘要 */
5860
const response =
5961
tail ||
60-
(summary.keyFindings[0]?.trim()
61-
? `首要发现:${summary.keyFindings[0].trim()}`
62-
: '') ||
62+
(summary.keyFindings[0]?.trim() ? `首要发现:${summary.keyFindings[0].trim()}` : '') ||
6363
'详情见上方「安全报告」。';
6464
return { report, response };
6565
}
@@ -215,8 +215,7 @@ export class ChatService {
215215

216216
if (!adaptiveOff && firstRun.cancelledCount > 0) {
217217
emit('phase', { phase: 'planning', detail: '穿插规划:根据未成功子任务补充方案…' });
218-
const adaptivePrompt =
219-
`${message}\n\n【穿插规划】上一阶段有 ${firstRun.cancelledCount} 个子任务未成功。请仅输出需要补充执行的新子任务 JSON 数组(新 id 建议 followup-1、followup-2);若无须补充则输出 []。\n\n阶段摘要(节选):\n${firstRun.summary.slice(0, 4000)}`;
218+
const adaptivePrompt = `${message}\n\n【穿插规划】上一阶段有 ${firstRun.cancelledCount} 个子任务未成功。请仅输出需要补充执行的新子任务 JSON 数组(新 id 建议 followup-1、followup-2);若无须补充则输出 []。\n\n阶段摘要(节选):\n${firstRun.summary.slice(0, 4000)}`;
220219
const subPlan = await this.plannerAgent.plan(adaptivePrompt);
221220
if (subPlan.todos.length > 0 && !subPlan.directResponse) {
222221
emitPlanningSse(emit, subPlan.planSummary, subPlan.todos, 'adaptive');

server/src/modules/tools/control/shell-command-guard.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ export function executeCommandShellProfile(): ShellExecutionProfile {
3434
if (process.platform === 'win32') {
3535
return shellProfile('cmd', 'cmd.exe (/d /s /c)');
3636
}
37-
const sh =
38-
process.env.SHELL ?? (process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash');
37+
const sh = process.env.SHELL ?? (process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash');
3938
const base = sh.split(/[/\\]/).pop() ?? sh;
4039
return shellProfile('posix', `${base} (-lc)`);
4140
}
@@ -44,7 +43,9 @@ function looksLikePowerShellCommand(c: string): boolean {
4443
if (/^\s*(powershell|pwsh)\s/i.test(c)) return false;
4544
if (/\$env:[A-Za-z_]/i.test(c)) return true;
4645
if (/\bGet-[A-Za-z][A-Za-z0-9-]*\b/.test(c)) return true;
47-
if (/\b(Select-Object|Where-Object|ForEach-Object|Write-Host|Out-File|Invoke-Expression)\b/.test(c)) {
46+
if (
47+
/\b(Select-Object|Where-Object|ForEach-Object|Write-Host|Out-File|Invoke-Expression)\b/.test(c)
48+
) {
4849
return true;
4950
}
5051
return false;

server/src/modules/tools/control/terminal-session.tool.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ export class TerminalSessionTool extends BaseTool {
282282
session_id: sessionId,
283283
message,
284284
shell_profile: session.getShellProfile(),
285-
hint:
286-
'Use action=exec with this session_id; command syntax must match shell_profile.kind (cmd / powershell / posix).',
285+
hint: 'Use action=exec with this session_id; command syntax must match shell_profile.kind (cmd / powershell / posix).',
287286
read_only_for_user: true,
288287
},
289288
};
@@ -324,8 +323,7 @@ export class TerminalSessionTool extends BaseTool {
324323
message: `Opened a new external terminal window (${opened.shell_name}).`,
325324
initial_command: initialCommand || null,
326325
shell_profile: extShellProfile,
327-
hint:
328-
'外部窗口不由本工具注入 exec;若要在会话内自动执行请用 action=open。手写命令时请按 shell_profile 语法。',
326+
hint: '外部窗口不由本工具注入 exec;若要在会话内自动执行请用 action=open。手写命令时请按 shell_profile 语法。',
329327
},
330328
};
331329
}

0 commit comments

Comments
 (0)