@orion-agents/orion-code 0.3.21 → 0.3.24
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.
- package/CHANGELOG.md +67 -6
- package/README.md +6 -6
- package/README.zh-CN.md +5 -5
- package/dist/harness/failure-attribution.d.ts +23 -0
- package/dist/harness/failure-attribution.js +103 -0
- package/dist/harness/verified-repair.d.ts +71 -0
- package/dist/harness/verified-repair.js +212 -0
- package/dist/product/paths.d.ts +20 -1
- package/dist/product/paths.js +293 -10
- package/dist/runtime/release-receipts.d.ts +3 -3
- package/dist/runtime/release-receipts.js +29 -0
- package/dist/runtime/tool-gateway.d.ts +6 -0
- package/dist/runtime/tool-gateway.js +37 -7
- package/dist/services/config-dir.d.ts +3 -2
- package/dist/services/config-dir.js +6 -29
- package/dist/services/repo-intelligence/index.d.ts +11 -0
- package/dist/services/repo-intelligence/index.js +20 -0
- package/dist/services/repo-intelligence/recall.d.ts +44 -0
- package/dist/services/repo-intelligence/recall.js +115 -0
- package/dist/services/repo-intelligence/symbol-index.d.ts +52 -0
- package/dist/services/repo-intelligence/symbol-index.js +258 -0
- package/dist/services/session-storage.d.ts +18 -2
- package/dist/services/session-storage.js +196 -60
- package/dist/web/protocol.d.ts +8 -0
- package/dist/web/workbench-controller.js +46 -2
- package/dist/web-client/assets/{FilesPanel-CKeXPofZ.js → FilesPanel-BjEDjE7l.js} +1 -1
- package/dist/web-client/assets/{GitPanel-DollPxv0.js → GitPanel-DvgAZDRA.js} +1 -1
- package/dist/web-client/assets/{ReviewPanel-CNADacIn.js → ReviewPanel-BMPaYKDY.js} +1 -1
- package/dist/web-client/assets/{TerminalPanel-Cyns4uJt.js → TerminalPanel-Da1ZEhGF.js} +1 -1
- package/dist/web-client/assets/index-DZOlUgt6.js +20 -0
- package/dist/web-client/assets/{useAutoNotice-BLADeFFj.js → useAutoNotice-Ylj5bfSH.js} +1 -1
- package/dist/web-client/index.html +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/services/auto-fix/autoFixConfig.d.ts +0 -30
- package/dist/services/auto-fix/autoFixConfig.js +0 -78
- package/dist/services/auto-fix/autoFixHook.d.ts +0 -27
- package/dist/services/auto-fix/autoFixHook.js +0 -99
- package/dist/services/auto-fix/autoFixRunner.d.ts +0 -60
- package/dist/services/auto-fix/autoFixRunner.js +0 -207
- package/dist/services/auto-fix/index.d.ts +0 -7
- package/dist/services/auto-fix/index.js +0 -17
- package/dist/web-client/assets/index-BhGhORAX.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,j as l,P as _,R as M,b as N,c as $,d as j}from"./index-
|
|
1
|
+
import{r as t,j as l,P as _,R as M,b as N,c as $,d as j}from"./index-DZOlUgt6.js";function y({panelId:i,navigatorWidthPx:o,onNavigatorWidthCommit:e,contentLabel:d,navigatorLabel:h,handleLabel:s,contentClassName:r="",navigatorClassName:n="",children:p}){const[x,W]=t.Children.toArray(p),u=t.useRef(null),[E,T]=t.useState(0),[A,m]=t.useState(null);t.useEffect(()=>{const c=u.current;if(!c)return;const w=new ResizeObserver(S=>{const v=S[0]?.contentRect.width;v&&T(v)});return w.observe(c),()=>w.disconnect()},[]);const a=j(E),f=Math.min($(A??o),a),b=c=>{m(null),e(Math.min(c,a))},g=`${i}-split-content`,R=`${i}-split-navigator`;return l.jsxs("div",{ref:u,className:"resource-split-layout",style:{"--resource-navigator-width":`${f}px`},children:[l.jsx("section",{id:g,className:`resource-split-content${r?` ${r}`:""}`,"aria-label":d,children:W}),l.jsx(_,{side:"right",className:"resource-split-handle",minWidth:N,maxWidth:Math.max(N,a),defaultWidth:M,label:s,width:f,controls:R,boundsRef:u,resizingScope:"resource-split",onPreview:m,onCommit:b}),l.jsx("section",{id:R,className:`resource-split-navigator${n?` ${n}`:""}`,"aria-label":h,children:x})]})}const I=4e3;function D(){const[i,o]=t.useState(null),e=t.useRef(null);return t.useEffect(()=>()=>{e.current!==null&&window.clearTimeout(e.current)},[]),{notice:i,showNotice:(s,r="info")=>{e.current!==null&&(window.clearTimeout(e.current),e.current=null),o({text:s,tone:r}),r!=="error"&&(e.current=window.setTimeout(()=>{e.current=null,o(n=>n?.text===s?null:n)},I))},clearNotice:()=>{e.current!==null&&(window.clearTimeout(e.current),e.current=null),o(null)}}}export{y as R,D as u};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<meta name="description" content="Orion Code local Web Workbench" />
|
|
9
9
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
10
10
|
<title>Orion Code</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DZOlUgt6.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-DCYKIeOj.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-agents/orion-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@orion-agents/orion-code",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.24",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@clack/prompts": "^0.7.0",
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* orion code - AutoFix 配置
|
|
3
|
-
*
|
|
4
|
-
* 定义 lint、test 命令和修复策略。
|
|
5
|
-
*/
|
|
6
|
-
export interface AutoFixConfig {
|
|
7
|
-
/** 是否启用 */
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
/** Lint 命令 */
|
|
10
|
-
lintCommand?: string;
|
|
11
|
-
/** Test 命令 */
|
|
12
|
-
testCommand?: string;
|
|
13
|
-
/** Build 命令 */
|
|
14
|
-
buildCommand?: string;
|
|
15
|
-
/** 超时时间(ms) */
|
|
16
|
-
timeout: number;
|
|
17
|
-
/** 最大修复尝试次数 */
|
|
18
|
-
maxFixAttempts: number;
|
|
19
|
-
/** 触发条件 */
|
|
20
|
-
triggers: AutoFixTrigger[];
|
|
21
|
-
}
|
|
22
|
-
export interface AutoFixTrigger {
|
|
23
|
-
/** 触发类型 */
|
|
24
|
-
type: 'file_edit' | 'file_write' | 'manual' | 'post_tool';
|
|
25
|
-
/** 文件模式(glob) */
|
|
26
|
-
filePattern?: string;
|
|
27
|
-
}
|
|
28
|
-
export declare const DEFAULT_AUTOFIX_CONFIG: AutoFixConfig;
|
|
29
|
-
export declare function detectAutoFixConfig(projectPath: string): AutoFixConfig;
|
|
30
|
-
//# sourceMappingURL=autoFixConfig.d.ts.map
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* orion code - AutoFix 配置
|
|
4
|
-
*
|
|
5
|
-
* 定义 lint、test 命令和修复策略。
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.DEFAULT_AUTOFIX_CONFIG = void 0;
|
|
9
|
-
exports.detectAutoFixConfig = detectAutoFixConfig;
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// 默认配置
|
|
12
|
-
// ============================================================================
|
|
13
|
-
exports.DEFAULT_AUTOFIX_CONFIG = {
|
|
14
|
-
enabled: true,
|
|
15
|
-
lintCommand: 'npm run lint',
|
|
16
|
-
testCommand: 'npm test',
|
|
17
|
-
buildCommand: 'npm run build',
|
|
18
|
-
timeout: 60000,
|
|
19
|
-
maxFixAttempts: 3,
|
|
20
|
-
triggers: [
|
|
21
|
-
{ type: 'file_edit', filePattern: '**/*.ts' },
|
|
22
|
-
{ type: 'file_write', filePattern: '**/*.ts' },
|
|
23
|
-
{ type: 'file_edit', filePattern: '**/*.js' },
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* 检测项目配置
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Deep-ish copy of the default config.
|
|
31
|
-
*
|
|
32
|
-
* A bare `{ ...DEFAULT_AUTOFIX_CONFIG }` shares the `triggers` array between
|
|
33
|
-
* every caller, and returning the singleton itself let `AutoFixRunner.setEnabled`
|
|
34
|
-
* mutate the module-level default process-wide (every Runner constructed
|
|
35
|
-
* afterwards inherited the disabled state).
|
|
36
|
-
*/
|
|
37
|
-
function cloneDefaultConfig() {
|
|
38
|
-
return {
|
|
39
|
-
...exports.DEFAULT_AUTOFIX_CONFIG,
|
|
40
|
-
triggers: exports.DEFAULT_AUTOFIX_CONFIG.triggers.map(trigger => ({ ...trigger })),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function detectAutoFixConfig(projectPath) {
|
|
44
|
-
// 尝试读取 package.json
|
|
45
|
-
try {
|
|
46
|
-
const pkgPath = (0, path_1.join)(projectPath, 'package.json');
|
|
47
|
-
const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
|
|
48
|
-
const config = cloneDefaultConfig();
|
|
49
|
-
// Detection must clear the command when the script is absent: the field is
|
|
50
|
-
// pre-populated from the defaults, so skipping the branch left
|
|
51
|
-
// `npm run lint` in place and the runner reported "Missing script: lint"
|
|
52
|
-
// as a lint failure for a linter the project does not have.
|
|
53
|
-
// 检测 lint 命令
|
|
54
|
-
if (pkg.scripts?.lint) {
|
|
55
|
-
config.lintCommand = 'npm run lint';
|
|
56
|
-
}
|
|
57
|
-
else if (pkg.scripts?.eslint) {
|
|
58
|
-
config.lintCommand = 'npm run eslint';
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
config.lintCommand = undefined;
|
|
62
|
-
}
|
|
63
|
-
// 检测 test 命令
|
|
64
|
-
config.testCommand = pkg.scripts?.test ? 'npm test' : undefined;
|
|
65
|
-
// 检测 build 命令
|
|
66
|
-
config.buildCommand = pkg.scripts?.build ? 'npm run build' : undefined;
|
|
67
|
-
return config;
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
return cloneDefaultConfig();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
// ============================================================================
|
|
74
|
-
// 导入辅助(放在末尾避免循环依赖)
|
|
75
|
-
// ============================================================================
|
|
76
|
-
const path_1 = require("path");
|
|
77
|
-
const fs_1 = require("fs");
|
|
78
|
-
//# sourceMappingURL=autoFixConfig.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* orion code - AutoFix Hook
|
|
3
|
-
*
|
|
4
|
-
* Post-sampling hook,在工具执行后触发 AutoFix。
|
|
5
|
-
*/
|
|
6
|
-
import type { QueryEvent } from '../../framework/query';
|
|
7
|
-
import type { AutoFixTrigger } from './autoFixConfig';
|
|
8
|
-
/**
|
|
9
|
-
* 检查工具调用是否触发 AutoFix
|
|
10
|
-
*/
|
|
11
|
-
export declare function shouldTriggerAutoFix(toolName: string, args: Record<string, unknown>, triggers: AutoFixTrigger[]): {
|
|
12
|
-
trigger: boolean;
|
|
13
|
-
files: string[];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* AutoFix Hook 处理器
|
|
17
|
-
*/
|
|
18
|
-
export declare function autoFixHook(event: QueryEvent, triggers: AutoFixTrigger[]): Promise<void>;
|
|
19
|
-
declare function matchesPattern(path: string, pattern?: string): boolean;
|
|
20
|
-
export { autoFixHook as postToolHook };
|
|
21
|
-
/**
|
|
22
|
-
* Internals exposed for unit tests only. Not part of the public API.
|
|
23
|
-
*/
|
|
24
|
-
export declare const __testables: {
|
|
25
|
-
matchesPattern: typeof matchesPattern;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=autoFixHook.d.ts.map
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* orion code - AutoFix Hook
|
|
4
|
-
*
|
|
5
|
-
* Post-sampling hook,在工具执行后触发 AutoFix。
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.__testables = void 0;
|
|
9
|
-
exports.shouldTriggerAutoFix = shouldTriggerAutoFix;
|
|
10
|
-
exports.autoFixHook = autoFixHook;
|
|
11
|
-
exports.postToolHook = autoFixHook;
|
|
12
|
-
const autoFixRunner_1 = require("./autoFixRunner");
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Hook 实现
|
|
15
|
-
// ============================================================================
|
|
16
|
-
/**
|
|
17
|
-
* 检查工具调用是否触发 AutoFix
|
|
18
|
-
*/
|
|
19
|
-
function shouldTriggerAutoFix(toolName, args, triggers) {
|
|
20
|
-
const result = { trigger: false, files: [] };
|
|
21
|
-
for (const trigger of triggers) {
|
|
22
|
-
if (trigger.type === 'file_edit' && toolName === 'edit_file') {
|
|
23
|
-
const path = args.path;
|
|
24
|
-
if (path && matchesPattern(path, trigger.filePattern)) {
|
|
25
|
-
result.trigger = true;
|
|
26
|
-
result.files.push(path);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (trigger.type === 'file_write' && toolName === 'write_file') {
|
|
30
|
-
const path = args.path;
|
|
31
|
-
if (path && matchesPattern(path, trigger.filePattern)) {
|
|
32
|
-
result.trigger = true;
|
|
33
|
-
result.files.push(path);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (trigger.type === 'post_tool' && toolName === trigger.filePattern) {
|
|
37
|
-
result.trigger = true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* AutoFix Hook 处理器
|
|
44
|
-
*/
|
|
45
|
-
async function autoFixHook(event, triggers) {
|
|
46
|
-
if (event.type !== 'tool_result') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
// 检查是否触发
|
|
50
|
-
const check = shouldTriggerAutoFix(event.name, event.args, triggers);
|
|
51
|
-
if (!check.trigger) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// 运行 AutoFix
|
|
55
|
-
const runner = (0, autoFixRunner_1.getAutoFixRunner)();
|
|
56
|
-
const context = {
|
|
57
|
-
projectPath: process.cwd(),
|
|
58
|
-
changedFiles: check.files,
|
|
59
|
-
trigger: triggers[0],
|
|
60
|
-
};
|
|
61
|
-
const result = await runner.run(context);
|
|
62
|
-
if (!result.success) {
|
|
63
|
-
console.log(`[AutoFix] ${result.errors.length} issues found after ${event.name}`);
|
|
64
|
-
for (const err of result.errors.slice(0, 5)) {
|
|
65
|
-
console.log(` - ${err.type}: ${err.message}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
console.log(`[AutoFix] All checks passed (${result.duration}ms)`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// ============================================================================
|
|
73
|
-
// 辅助函数
|
|
74
|
-
// ============================================================================
|
|
75
|
-
function matchesPattern(path, pattern) {
|
|
76
|
-
if (!pattern)
|
|
77
|
-
return true;
|
|
78
|
-
// 简化 glob 匹配
|
|
79
|
-
if (pattern.startsWith('**/*.')) {
|
|
80
|
-
// slice(4), not slice(5): keep the leading `.`. Without it the default
|
|
81
|
-
// trigger `**/*.ts` degraded into a suffix match, so writing an
|
|
82
|
-
// extensionless file such as `docs/requirements` kicked off the whole
|
|
83
|
-
// lint + build + test pipeline.
|
|
84
|
-
const ext = pattern.slice(4);
|
|
85
|
-
return path.endsWith(ext);
|
|
86
|
-
}
|
|
87
|
-
if (pattern.includes('*')) {
|
|
88
|
-
// Escape all regex special chars, then replace glob wildcard.
|
|
89
|
-
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
|
|
90
|
-
const regex = new RegExp(escaped.replace(/\*/g, '.*'));
|
|
91
|
-
return regex.test(path);
|
|
92
|
-
}
|
|
93
|
-
return path === pattern;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Internals exposed for unit tests only. Not part of the public API.
|
|
97
|
-
*/
|
|
98
|
-
exports.__testables = { matchesPattern };
|
|
99
|
-
//# sourceMappingURL=autoFixHook.js.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* orion code - AutoFix Runner
|
|
3
|
-
*
|
|
4
|
-
* 代码修改后自动运行 lint + test,检测并尝试修复错误。
|
|
5
|
-
*/
|
|
6
|
-
import type { AutoFixConfig, AutoFixTrigger } from './autoFixConfig';
|
|
7
|
-
export interface AutoFixResult {
|
|
8
|
-
success: boolean;
|
|
9
|
-
lintPassed: boolean;
|
|
10
|
-
testPassed: boolean;
|
|
11
|
-
buildPassed?: boolean;
|
|
12
|
-
errors: AutoFixError[];
|
|
13
|
-
fixAttempts: number;
|
|
14
|
-
duration: number;
|
|
15
|
-
}
|
|
16
|
-
export interface AutoFixError {
|
|
17
|
-
type: 'lint' | 'test' | 'build';
|
|
18
|
-
file?: string;
|
|
19
|
-
line?: number;
|
|
20
|
-
message: string;
|
|
21
|
-
fixable: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface AutoFixContext {
|
|
24
|
-
projectPath: string;
|
|
25
|
-
changedFiles: string[];
|
|
26
|
-
trigger: AutoFixTrigger;
|
|
27
|
-
}
|
|
28
|
-
export declare class AutoFixRunner {
|
|
29
|
-
private config;
|
|
30
|
-
private projectPath;
|
|
31
|
-
private fixAttempts;
|
|
32
|
-
private lastRunTime;
|
|
33
|
-
constructor(projectPath?: string, config?: AutoFixConfig);
|
|
34
|
-
/**
|
|
35
|
-
* 运行 AutoFix
|
|
36
|
-
*/
|
|
37
|
-
run(_context: AutoFixContext): Promise<AutoFixResult>;
|
|
38
|
-
/**
|
|
39
|
-
* 快速检查(仅 lint)
|
|
40
|
-
*/
|
|
41
|
-
quickCheck(_files: string[]): Promise<{
|
|
42
|
-
passed: boolean;
|
|
43
|
-
errors: AutoFixError[];
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* 获取配置
|
|
47
|
-
*/
|
|
48
|
-
getConfig(): AutoFixConfig;
|
|
49
|
-
/**
|
|
50
|
-
* 启用/禁用
|
|
51
|
-
*/
|
|
52
|
-
setEnabled(enabled: boolean): void;
|
|
53
|
-
private runCommand;
|
|
54
|
-
private parseLintErrors;
|
|
55
|
-
private parseBuildErrors;
|
|
56
|
-
private parseTestErrors;
|
|
57
|
-
}
|
|
58
|
-
export declare function getAutoFixRunner(projectPath?: string, config?: AutoFixConfig): AutoFixRunner;
|
|
59
|
-
export declare function resetAutoFixRunner(): void;
|
|
60
|
-
//# sourceMappingURL=autoFixRunner.d.ts.map
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* orion code - AutoFix Runner
|
|
4
|
-
*
|
|
5
|
-
* 代码修改后自动运行 lint + test,检测并尝试修复错误。
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.AutoFixRunner = void 0;
|
|
9
|
-
exports.getAutoFixRunner = getAutoFixRunner;
|
|
10
|
-
exports.resetAutoFixRunner = resetAutoFixRunner;
|
|
11
|
-
const child_process_1 = require("child_process");
|
|
12
|
-
const autoFixConfig_1 = require("./autoFixConfig");
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// AutoFix Runner
|
|
15
|
-
// ============================================================================
|
|
16
|
-
class AutoFixRunner {
|
|
17
|
-
constructor(projectPath, config) {
|
|
18
|
-
this.fixAttempts = 0;
|
|
19
|
-
this.lastRunTime = 0;
|
|
20
|
-
this.projectPath = projectPath || process.cwd();
|
|
21
|
-
this.config = config || (0, autoFixConfig_1.detectAutoFixConfig)(this.projectPath);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 运行 AutoFix
|
|
25
|
-
*/
|
|
26
|
-
async run(_context) {
|
|
27
|
-
if (!this.config.enabled) {
|
|
28
|
-
return {
|
|
29
|
-
success: true,
|
|
30
|
-
lintPassed: true,
|
|
31
|
-
testPassed: true,
|
|
32
|
-
errors: [],
|
|
33
|
-
fixAttempts: 0,
|
|
34
|
-
duration: 0,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const startTime = Date.now();
|
|
38
|
-
const errors = [];
|
|
39
|
-
let lintPassed = true;
|
|
40
|
-
let testPassed = true;
|
|
41
|
-
let buildPassed = true;
|
|
42
|
-
// 1. 运行 lint
|
|
43
|
-
if (this.config.lintCommand) {
|
|
44
|
-
const lintResult = await this.runCommand(this.config.lintCommand);
|
|
45
|
-
lintPassed = lintResult.success;
|
|
46
|
-
if (!lintResult.success) {
|
|
47
|
-
errors.push(...this.parseLintErrors(lintResult.output));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// 2. 运行 build(如果有)
|
|
51
|
-
if (this.config.buildCommand) {
|
|
52
|
-
const buildResult = await this.runCommand(this.config.buildCommand);
|
|
53
|
-
buildPassed = buildResult.success;
|
|
54
|
-
if (!buildResult.success) {
|
|
55
|
-
errors.push(...this.parseBuildErrors(buildResult.output));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// 3. 运行 test
|
|
59
|
-
if (this.config.testCommand) {
|
|
60
|
-
const testResult = await this.runCommand(this.config.testCommand);
|
|
61
|
-
testPassed = testResult.success;
|
|
62
|
-
if (!testResult.success) {
|
|
63
|
-
errors.push(...this.parseTestErrors(testResult.output));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const duration = Date.now() - startTime;
|
|
67
|
-
return {
|
|
68
|
-
success: lintPassed && testPassed && buildPassed,
|
|
69
|
-
lintPassed,
|
|
70
|
-
testPassed,
|
|
71
|
-
buildPassed,
|
|
72
|
-
errors,
|
|
73
|
-
fixAttempts: this.fixAttempts,
|
|
74
|
-
duration,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 快速检查(仅 lint)
|
|
79
|
-
*/
|
|
80
|
-
async quickCheck(_files) {
|
|
81
|
-
if (!this.config.lintCommand) {
|
|
82
|
-
return { passed: true, errors: [] };
|
|
83
|
-
}
|
|
84
|
-
const lintResult = await this.runCommand(this.config.lintCommand);
|
|
85
|
-
const errors = lintResult.success ? [] : this.parseLintErrors(lintResult.output);
|
|
86
|
-
return {
|
|
87
|
-
passed: lintResult.success,
|
|
88
|
-
errors,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 获取配置
|
|
93
|
-
*/
|
|
94
|
-
getConfig() {
|
|
95
|
-
return this.config;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 启用/禁用
|
|
99
|
-
*/
|
|
100
|
-
setEnabled(enabled) {
|
|
101
|
-
this.config.enabled = enabled;
|
|
102
|
-
}
|
|
103
|
-
// ============================================================================
|
|
104
|
-
// 内部方法
|
|
105
|
-
// ============================================================================
|
|
106
|
-
async runCommand(command) {
|
|
107
|
-
return new Promise(resolve => {
|
|
108
|
-
const [cmd, ...args] = command.split(' ');
|
|
109
|
-
(0, child_process_1.execFile)(cmd, args, {
|
|
110
|
-
cwd: this.projectPath,
|
|
111
|
-
timeout: this.config.timeout,
|
|
112
|
-
maxBuffer: 1024 * 1024,
|
|
113
|
-
}, (error, stdout, stderr) => {
|
|
114
|
-
const output = stdout.toString() + stderr.toString();
|
|
115
|
-
resolve({
|
|
116
|
-
success: !error,
|
|
117
|
-
output,
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
parseLintErrors(output) {
|
|
123
|
-
const errors = [];
|
|
124
|
-
const lines = output.split('\n');
|
|
125
|
-
for (const line of lines) {
|
|
126
|
-
// ESLint 格式: /path/to/file.ts:10:5: error message
|
|
127
|
-
const match = line.match(/^([^:]+):(\d+):(\d+):\s+(.+)$/);
|
|
128
|
-
if (match) {
|
|
129
|
-
errors.push({
|
|
130
|
-
type: 'lint',
|
|
131
|
-
file: match[1],
|
|
132
|
-
line: parseInt(match[2]),
|
|
133
|
-
message: match[4],
|
|
134
|
-
fixable: line.includes('--fix'),
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
// 简化格式: error: message at file:line
|
|
138
|
-
const simpleMatch = line.match(/error:\s+(.+)\s+at\s+([^:]+):(\d+)/);
|
|
139
|
-
if (simpleMatch) {
|
|
140
|
-
errors.push({
|
|
141
|
-
type: 'lint',
|
|
142
|
-
file: simpleMatch[2],
|
|
143
|
-
line: parseInt(simpleMatch[3]),
|
|
144
|
-
message: simpleMatch[1],
|
|
145
|
-
fixable: false,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return errors;
|
|
150
|
-
}
|
|
151
|
-
parseBuildErrors(output) {
|
|
152
|
-
const errors = [];
|
|
153
|
-
const lines = output.split('\n');
|
|
154
|
-
for (const line of lines) {
|
|
155
|
-
// TypeScript 格式: src/file.ts(10,5): error TS1234: message
|
|
156
|
-
const match = line.match(/^([^(]+)\((\d+),(\d+)\):\s+error\s+TS\d+:\s+(.+)$/);
|
|
157
|
-
if (match) {
|
|
158
|
-
errors.push({
|
|
159
|
-
type: 'build',
|
|
160
|
-
file: match[1],
|
|
161
|
-
line: parseInt(match[2]),
|
|
162
|
-
message: match[4],
|
|
163
|
-
fixable: false,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return errors;
|
|
168
|
-
}
|
|
169
|
-
parseTestErrors(output) {
|
|
170
|
-
const errors = [];
|
|
171
|
-
const lines = output.split('\n');
|
|
172
|
-
for (const line of lines) {
|
|
173
|
-
// Jest 格式: FAIL src/test.ts
|
|
174
|
-
if (line.includes('FAIL') || line.includes('Error:')) {
|
|
175
|
-
errors.push({
|
|
176
|
-
type: 'test',
|
|
177
|
-
message: line.trim(),
|
|
178
|
-
fixable: false,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
// Mocha 格式: AssertionError: ...
|
|
182
|
-
if (line.startsWith('AssertionError')) {
|
|
183
|
-
errors.push({
|
|
184
|
-
type: 'test',
|
|
185
|
-
message: line.trim(),
|
|
186
|
-
fixable: false,
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return errors.slice(0, 10); // 限制数量
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
exports.AutoFixRunner = AutoFixRunner;
|
|
194
|
-
// ============================================================================
|
|
195
|
-
// 单例
|
|
196
|
-
// ============================================================================
|
|
197
|
-
let autoFixRunner = null;
|
|
198
|
-
function getAutoFixRunner(projectPath, config) {
|
|
199
|
-
if (!autoFixRunner) {
|
|
200
|
-
autoFixRunner = new AutoFixRunner(projectPath, config);
|
|
201
|
-
}
|
|
202
|
-
return autoFixRunner;
|
|
203
|
-
}
|
|
204
|
-
function resetAutoFixRunner() {
|
|
205
|
-
autoFixRunner = null;
|
|
206
|
-
}
|
|
207
|
-
//# sourceMappingURL=autoFixRunner.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* orion code - AutoFix 服务入口
|
|
3
|
-
*/
|
|
4
|
-
export { AutoFixRunner, getAutoFixRunner, resetAutoFixRunner, type AutoFixResult, type AutoFixError, type AutoFixContext, } from './autoFixRunner';
|
|
5
|
-
export { DEFAULT_AUTOFIX_CONFIG, detectAutoFixConfig, type AutoFixConfig, type AutoFixTrigger, } from './autoFixConfig';
|
|
6
|
-
export { autoFixHook, shouldTriggerAutoFix } from './autoFixHook';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* orion code - AutoFix 服务入口
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.shouldTriggerAutoFix = exports.autoFixHook = exports.detectAutoFixConfig = exports.DEFAULT_AUTOFIX_CONFIG = exports.resetAutoFixRunner = exports.getAutoFixRunner = exports.AutoFixRunner = void 0;
|
|
7
|
-
var autoFixRunner_1 = require("./autoFixRunner");
|
|
8
|
-
Object.defineProperty(exports, "AutoFixRunner", { enumerable: true, get: function () { return autoFixRunner_1.AutoFixRunner; } });
|
|
9
|
-
Object.defineProperty(exports, "getAutoFixRunner", { enumerable: true, get: function () { return autoFixRunner_1.getAutoFixRunner; } });
|
|
10
|
-
Object.defineProperty(exports, "resetAutoFixRunner", { enumerable: true, get: function () { return autoFixRunner_1.resetAutoFixRunner; } });
|
|
11
|
-
var autoFixConfig_1 = require("./autoFixConfig");
|
|
12
|
-
Object.defineProperty(exports, "DEFAULT_AUTOFIX_CONFIG", { enumerable: true, get: function () { return autoFixConfig_1.DEFAULT_AUTOFIX_CONFIG; } });
|
|
13
|
-
Object.defineProperty(exports, "detectAutoFixConfig", { enumerable: true, get: function () { return autoFixConfig_1.detectAutoFixConfig; } });
|
|
14
|
-
var autoFixHook_1 = require("./autoFixHook");
|
|
15
|
-
Object.defineProperty(exports, "autoFixHook", { enumerable: true, get: function () { return autoFixHook_1.autoFixHook; } });
|
|
16
|
-
Object.defineProperty(exports, "shouldTriggerAutoFix", { enumerable: true, get: function () { return autoFixHook_1.shouldTriggerAutoFix; } });
|
|
17
|
-
//# sourceMappingURL=index.js.map
|