openyida 2026.4.2-beta.2 → 2026.4.2-beta.4
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/lib/core/doctor.js +59 -14
- package/package.json +1 -1
- package/yida-skills/SKILL.md +1 -1
package/lib/core/doctor.js
CHANGED
|
@@ -195,15 +195,9 @@ class EnvironmentChecker {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
checkPlaywrightInstalled() {
|
|
198
|
+
// 1. 检查 playwright npm 包是否安装
|
|
198
199
|
try {
|
|
199
200
|
require.resolve('playwright');
|
|
200
|
-
return {
|
|
201
|
-
id: 'env-playwright',
|
|
202
|
-
label: 'Playwright 已安装',
|
|
203
|
-
passed: true,
|
|
204
|
-
severity: Severity.INFO,
|
|
205
|
-
fixType: null,
|
|
206
|
-
};
|
|
207
201
|
} catch {
|
|
208
202
|
return {
|
|
209
203
|
id: 'env-playwright',
|
|
@@ -215,6 +209,39 @@ class EnvironmentChecker {
|
|
|
215
209
|
fixCommand: 'npm install playwright && npx playwright install chromium',
|
|
216
210
|
};
|
|
217
211
|
}
|
|
212
|
+
|
|
213
|
+
// 2. 检查 Chromium 二进制是否存在于用户目录(postinstall 已自动安装)
|
|
214
|
+
try {
|
|
215
|
+
const { chromium } = require('playwright');
|
|
216
|
+
const chromiumPath = chromium.executablePath();
|
|
217
|
+
if (chromiumPath && fs.existsSync(chromiumPath)) {
|
|
218
|
+
return {
|
|
219
|
+
id: 'env-playwright',
|
|
220
|
+
label: `Playwright + Chromium 已就绪`,
|
|
221
|
+
passed: true,
|
|
222
|
+
severity: Severity.INFO,
|
|
223
|
+
fixType: null,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
id: 'env-playwright',
|
|
228
|
+
label: 'Chromium 浏览器检测',
|
|
229
|
+
passed: false,
|
|
230
|
+
severity: Severity.ERROR,
|
|
231
|
+
message: `Chromium 未安装(期望路径:${chromiumPath || '未知'})`,
|
|
232
|
+
fixType: FixType.COMMAND,
|
|
233
|
+
fixCommand: 'npx playwright install chromium',
|
|
234
|
+
};
|
|
235
|
+
} catch {
|
|
236
|
+
// playwright API 不可用,降级为仅检查包安装
|
|
237
|
+
return {
|
|
238
|
+
id: 'env-playwright',
|
|
239
|
+
label: 'Playwright 已安装',
|
|
240
|
+
passed: true,
|
|
241
|
+
severity: Severity.INFO,
|
|
242
|
+
fixType: null,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
218
245
|
}
|
|
219
246
|
|
|
220
247
|
checkConfig() {
|
|
@@ -439,10 +466,10 @@ class ProjectInitChecker {
|
|
|
439
466
|
id: 'project-init',
|
|
440
467
|
label: passed ? 'project/ 工作目录已初始化' : 'project/ 工作目录检测',
|
|
441
468
|
passed,
|
|
442
|
-
severity: passed ? Severity.INFO : Severity.
|
|
443
|
-
message: passed ? null : 'project/
|
|
444
|
-
fixType: passed ? null : FixType.
|
|
445
|
-
|
|
469
|
+
severity: passed ? Severity.INFO : Severity.ERROR,
|
|
470
|
+
message: passed ? null : 'project/ 目录未初始化,将自动初始化',
|
|
471
|
+
fixType: passed ? null : FixType.AUTO,
|
|
472
|
+
fixAction: passed ? null : 'init-project',
|
|
446
473
|
}];
|
|
447
474
|
}
|
|
448
475
|
}
|
|
@@ -662,7 +689,7 @@ class FixEngine {
|
|
|
662
689
|
|
|
663
690
|
for (const issue of issues) {
|
|
664
691
|
if (issue.fixType === FixType.AUTO) {
|
|
665
|
-
const result = this.applyAutoFix(issue);
|
|
692
|
+
const result = await this.applyAutoFix(issue);
|
|
666
693
|
this.fixResults.push(result);
|
|
667
694
|
} else if (issue.fixType === FixType.COMMAND) {
|
|
668
695
|
this.fixResults.push({
|
|
@@ -685,9 +712,9 @@ class FixEngine {
|
|
|
685
712
|
/**
|
|
686
713
|
* 执行自动修复动作。
|
|
687
714
|
* @param {object} issue
|
|
688
|
-
* @returns {object}
|
|
715
|
+
* @returns {Promise<object>}
|
|
689
716
|
*/
|
|
690
|
-
applyAutoFix(issue) {
|
|
717
|
+
async applyAutoFix(issue) {
|
|
691
718
|
switch (issue.fixAction) {
|
|
692
719
|
case 'create-config': {
|
|
693
720
|
const configPath = path.join(this.projectRoot, 'config.json');
|
|
@@ -715,6 +742,24 @@ class FixEngine {
|
|
|
715
742
|
};
|
|
716
743
|
}
|
|
717
744
|
|
|
745
|
+
case 'init-project': {
|
|
746
|
+
try {
|
|
747
|
+
const copy = require('./copy');
|
|
748
|
+
await copy([]);
|
|
749
|
+
return {
|
|
750
|
+
id: issue.id,
|
|
751
|
+
fixed: true,
|
|
752
|
+
message: '已自动初始化 project/ 工作目录',
|
|
753
|
+
};
|
|
754
|
+
} catch (error) {
|
|
755
|
+
return {
|
|
756
|
+
id: issue.id,
|
|
757
|
+
fixed: false,
|
|
758
|
+
message: `project/ 初始化失败,请手动运行:openyida copy(${error.message})`,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
718
763
|
default:
|
|
719
764
|
return {
|
|
720
765
|
id: issue.id,
|
package/package.json
CHANGED
package/yida-skills/SKILL.md
CHANGED