openyida 2026.11.2 → 2026.11.3
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/README.md +11 -9
- package/bin/yida.js +2 -1
- package/lib/app/application-entry-urls.js +35 -1
- package/lib/app/check-prd-completeness.js +27 -6
- package/lib/app/create-app.js +17 -9
- package/lib/app/fast-build.js +151 -0
- package/lib/app/fast-theme.js +83 -0
- package/lib/app/form-data-contract.js +162 -0
- package/lib/app/services/canvas-page-schema-builder.js +10 -0
- package/lib/asset/ai-image.js +8 -5
- package/lib/asset/asset-cmd.js +24 -4
- package/lib/asset/asset-execution.js +25 -4
- package/lib/asset/asset-plan.js +4 -2
- package/lib/asset/asset-resolve.js +21 -7
- package/lib/auth/oauth-loopback.js +1 -1
- package/lib/auth/org.js +2 -0
- package/lib/auth/token-auth.js +1 -0
- package/lib/core/agent-capabilities.js +30 -9
- package/lib/core/batch.js +71 -122
- package/lib/core/command-manifest.js +71 -38
- package/lib/core/locales/en.js +20 -4
- package/lib/core/locales/zh.js +19 -3
- package/lib/core/permission-guidance.js +10 -10
- package/lib/core/query-data.js +67 -10
- package/lib/core/sample.js +73 -0
- package/lib/core/task-concurrency.js +96 -0
- package/lib/corp-efficiency/corp-efficiency.js +15 -8
- package/lib/design/fast-document.js +118 -0
- package/lib/design-plan/design-plan.js +3 -3
- package/lib/design-plan/init.js +90 -5
- package/lib/design-plan/materialize.js +2 -2
- package/lib/design-plan/validate.js +64 -9
- package/lib/flash-note/build-flash-note-prompt.js +1 -1
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +135 -0
- package/lib/samples/openyida-scaffold/canvas-file-upload.jsx +106 -0
- package/lib/samples/openyida-scaffold/file-upload-client.jsx +160 -0
- package/lib/samples/yida-app/fast-app.json +64 -0
- package/lib/samples/yida-design/fast-design.json +38 -0
- package/package.json +3 -3
- package/scripts/postinstall.js +6 -6
- package/yida-skills/SKILL.md +10 -9
- package/yida-skills/references/official-example-schema-patterns.md +3 -3
- package/yida-skills/references/qwenwork-link-presentation.md +11 -16
- package/yida-skills/references/user-facing-summary.md +1 -1
- package/yida-skills/skills/yida-app/SKILL.md +23 -12
- package/yida-skills/skills/yida-app/references/fast-context.md +7 -0
- package/yida-skills/skills/yida-app/workflow/fast-build.md +65 -0
- package/yida-skills/skills/yida-app/workflow/parallel-work.md +15 -5
- package/yida-skills/skills/yida-app/workflow/plan/workflow.md +5 -1
- package/yida-skills/skills/yida-app/workflow/step-2-design.md +13 -6
- package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +7 -2
- package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +5 -2
- package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +7 -2
- package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +14 -4
- package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +2 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/file-upload.md +75 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/native-components-bridge.md +4 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +1 -1
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +23 -82
- package/yida-skills/skills/yida-corp-efficiency/SKILL.md +3 -3
- package/yida-skills/skills/yida-create-app/SKILL.md +9 -5
- package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +13 -17
- package/yida-skills/skills/yida-custom-page/SKILL.md +2 -0
- package/yida-skills/skills/yida-custom-page/references/attachment-upload-guide.md +4 -0
- package/yida-skills/skills/yida-data-management/SKILL.md +2 -0
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +9 -0
- package/yida-skills/skills/yida-design/SKILL.md +7 -2
- package/yida-skills/skills/yida-design/references/application-theme-consistency.md +4 -4
- package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +2 -2
- package/yida-skills/skills/yida-design/references/design-mode.md +4 -2
- package/yida-skills/skills/yida-design/references/fast-design-spec.md +32 -0
- package/yida-skills/skills/yida-design/references/native-form-styles.md +2 -2
- package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +4 -4
- package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +4 -4
- package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-4-wireframe-interaction.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
- package/yida-skills/skills/yida-dingtalk-openapi/references/api-contract.md +1 -1
- package/yida-skills/skills/yida-flash-note-to-prd/references/flash-note-prompt.md +1 -1
- package/yida-skills/skills/yida-image-assets/SKILL.md +11 -5
- package/yida-skills/skills/yida-login/SKILL.md +6 -0
- package/yida-skills/skills/yida-ppt-slider/references/examples.md +3 -3
- package/yida-skills/skills/yida-prd/SKILL.md +5 -1
- package/yida-skills/skills/yida-publish-page/SKILL.md +3 -0
- package/yida-skills/skills/yida-requirement-analysis/SKILL.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -0
- package/yida-skills/skills-index.json +2 -2
|
@@ -8,7 +8,9 @@ const { t } = require('./i18n');
|
|
|
8
8
|
const { buildCommandManifest, buildEntryDeliveryPolicy } = require('./command-manifest');
|
|
9
9
|
const { buildEnvironmentSnapshot } = require('./env');
|
|
10
10
|
const coreUtils = require('./utils');
|
|
11
|
+
const { buildTaskExecutionPolicy } = require('./task-concurrency');
|
|
11
12
|
const { buildHostAssetCapabilities } = require('../asset/host-capabilities');
|
|
13
|
+
const { preferredLinkPresentationTool, buildLinkPresentationCompletionGate } = require('../app/application-entry-urls');
|
|
12
14
|
const { buildQwenWorkLoginInvocation, isQwenWorkWebRuntime } = require('./qwenwork-login-guidance');
|
|
13
15
|
const { findProjectRoot, getAuthStatus } = coreUtils;
|
|
14
16
|
|
|
@@ -139,21 +141,35 @@ function buildLinkPresentationPolicy(runtime = {}) {
|
|
|
139
141
|
}
|
|
140
142
|
return {
|
|
141
143
|
mode: 'host_show_link',
|
|
142
|
-
applies_to: '
|
|
144
|
+
applies_to: 'current_yida_entry_at_end_of_each_turn',
|
|
143
145
|
timing: 'before_final_reply',
|
|
144
146
|
max_calls_per_turn: 1,
|
|
145
|
-
target: '
|
|
146
|
-
|
|
147
|
+
target: 'single_updated_page_workbench_entry_otherwise_adminUrl',
|
|
148
|
+
target_selection: {
|
|
149
|
+
single_page_update: {
|
|
150
|
+
condition: 'Only one existing page was successfully modified in this turn, with no other resource or application changes.',
|
|
151
|
+
count_by: 'distinct_appType_and_formUuid_in_this_turn',
|
|
152
|
+
repeated_updates: 'count_same_page_once',
|
|
153
|
+
read_only_operations: 'do_not_count',
|
|
154
|
+
target: 'modified_page_confirmed_workbench_entry',
|
|
155
|
+
target_path: '/workbench/{formUuid}',
|
|
156
|
+
},
|
|
157
|
+
otherwise: {
|
|
158
|
+
target: 'current_application_confirmed_adminUrl',
|
|
159
|
+
target_path: '/admin',
|
|
160
|
+
includes: 'New applications or pages, multiple modified pages, other resource or application changes, no page modification, or unconfirmed single-page scope or workbenchUrl.',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
147
163
|
other_links: 'preserve_existing_delivery_and_workflow',
|
|
148
164
|
requires_host_tool_inventory_check: true,
|
|
149
165
|
tool_availability: 'unknown_until_declared_by_host',
|
|
150
|
-
preferred_tool: runtime
|
|
151
|
-
|
|
166
|
+
preferred_tool: preferredLinkPresentationTool(runtime),
|
|
167
|
+
completion_gate: buildLinkPresentationCompletionGate(),
|
|
152
168
|
tool_selection: 'In QwenWork cloud, prefer show_link; on desktop, prefer artifact_show_link. Otherwise use an available link presentation tool and its declared parameters and supported resources.',
|
|
153
|
-
input: '
|
|
154
|
-
required_action: 'Keep the existing YiDA workflow and ordinary link delivery.
|
|
155
|
-
scope: '
|
|
156
|
-
fallback: 'If the
|
|
169
|
+
input: 'For a single-page update, use the modified page confirmed workbench entry from a successful result or targeted readback, preferring workbenchUrl; formUrl or url is also eligible when its path is /{appType}/workbench/{formUuid} for that verified page. Otherwise use the current application confirmed adminUrl from create-app or app-list. Preserve the selected URL unchanged; do not substitute a standalone /custom/ URL or hard-code example resources.',
|
|
170
|
+
required_action: 'Keep the existing YiDA workflow and ordinary link delivery. Before the final reply of each turn, select the single updated page workbenchUrl or otherwise the application adminUrl according to target_selection, and call the available link presentation tool once. Repeat once in each new turn, not for every link. Respect explicit user exclusions.',
|
|
171
|
+
scope: 'The single updated existing page entry when eligible; otherwise the current YiDA application developer administration entry.',
|
|
172
|
+
fallback: 'If the single-page scope or its workbenchUrl is unconfirmed, use the confirmed application adminUrl. If no eligible URL is confirmed, do not guess or create resources. If the tool is unavailable or fails, keep the completed work and selected clickable link without repeated calls or business writes.',
|
|
157
173
|
user_facing_guidance: 'Explain only the business result, what the link opens and any action the user needs to take. Do not describe tool names, parameters or background processing unless the user asks for technical details.',
|
|
158
174
|
success_means: 'presentation_request_accepted_only_not_registration_or_rendering',
|
|
159
175
|
cli_urls: 'preserve_original_fields',
|
|
@@ -206,6 +222,7 @@ function commandBriefs(manifest, commandIds) {
|
|
|
206
222
|
examples: entry.examples || [],
|
|
207
223
|
args: entry.args || [],
|
|
208
224
|
canonical: entry.canonical || null,
|
|
225
|
+
task_concurrency: entry.task_concurrency || null,
|
|
209
226
|
notes: entry.notes || [],
|
|
210
227
|
}));
|
|
211
228
|
}
|
|
@@ -586,6 +603,7 @@ function buildFullAppArtifactRoute(manifest) {
|
|
|
586
603
|
orchestrator_skill_id: workflow.orchestrator_skill_id,
|
|
587
604
|
requirement_analysis_skill_id: workflow.requirement_analysis_skill_id,
|
|
588
605
|
requirement_brief_path: workflow.requirement_brief_path,
|
|
606
|
+
fast_build: workflow.fast_build,
|
|
589
607
|
visual_decision_policy: workflow.visual_decision_policy,
|
|
590
608
|
user_visible_expression_policy: workflow.user_visible_expression_policy,
|
|
591
609
|
optional_asset_branch: workflow.optional_asset_branch,
|
|
@@ -670,6 +688,7 @@ function buildCommandManifestDigest(manifest) {
|
|
|
670
688
|
permission_effect: entry.permission && entry.permission.effect,
|
|
671
689
|
args: entry.args || [],
|
|
672
690
|
canonical: entry.canonical || null,
|
|
691
|
+
task_concurrency: entry.task_concurrency || null,
|
|
673
692
|
notes: entry.notes || [],
|
|
674
693
|
})),
|
|
675
694
|
};
|
|
@@ -744,6 +763,7 @@ function buildAgentCapabilitiesSummary() {
|
|
|
744
763
|
link_presentation_policy: buildLinkPresentationPolicy(runtime),
|
|
745
764
|
runtime,
|
|
746
765
|
asset_capabilities: assetCapabilities,
|
|
766
|
+
task_execution: buildTaskExecutionPolicy(),
|
|
747
767
|
builder_path: builderPath,
|
|
748
768
|
};
|
|
749
769
|
}
|
|
@@ -781,6 +801,7 @@ function buildAgentCapabilities() {
|
|
|
781
801
|
active: envSnapshot.active,
|
|
782
802
|
runtime,
|
|
783
803
|
asset_capabilities: assetCapabilities,
|
|
804
|
+
task_execution: buildTaskExecutionPolicy(),
|
|
784
805
|
login: loginStatus,
|
|
785
806
|
application_entry_policy: applicationEntryPolicy,
|
|
786
807
|
link_presentation_policy: buildLinkPresentationPolicy(runtime),
|
package/lib/core/batch.js
CHANGED
|
@@ -7,23 +7,28 @@
|
|
|
7
7
|
* openyida batch --commands "cmd1" "cmd2" "cmd3" # 内联模式,多参数
|
|
8
8
|
*
|
|
9
9
|
* 可选:
|
|
10
|
-
* --
|
|
11
|
-
* --
|
|
10
|
+
* --concurrency N 独立就绪任务的并发上限 1..4(默认 1)
|
|
11
|
+
* --stop-on-error 失败后停止排队任务,等待运行中的任务完成
|
|
12
|
+
* --json 最终只输出 JSON 汇总到 stdout
|
|
12
13
|
* --quiet 自动注入到每条子命令(batch 本身也静默)
|
|
13
14
|
*
|
|
14
15
|
* 设计要点:
|
|
15
16
|
* - 零侵入:不修改任何已有命令的 run() 函数
|
|
16
|
-
* - 每条子命令通过 child_process.
|
|
17
|
+
* - 每条子命令通过 child_process.execFile 调用 bin/yida.js,
|
|
17
18
|
* token 文件已在磁盘上,各命令读取时直接命中缓存(零登录开销)
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
19
|
+
* - 静默模式为子命令注入 --quiet,逐项保存输出和耗时,结果按输入顺序汇总
|
|
20
|
+
* - 需要登录的任务启动前预检登录态;纯本地检查/编译不触发登录
|
|
21
|
+
* - 仅 manifest 已核实的独立操作并发;资源冲突等待,其他命令串行隔离
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
'use strict';
|
|
23
25
|
|
|
24
26
|
const fs = require('fs');
|
|
25
27
|
const path = require('path');
|
|
26
|
-
const {
|
|
28
|
+
const { execFile } = require('child_process');
|
|
29
|
+
const { CliError } = require('./cli-error');
|
|
30
|
+
const { t } = require('./i18n');
|
|
31
|
+
const { describeTask, runTaskWave } = require('./task-concurrency');
|
|
27
32
|
const { loadAuthData, triggerLogin } = require('./utils');
|
|
28
33
|
const { banner, step, success, fail, info, warn, result, label } = require('./chalk');
|
|
29
34
|
|
|
@@ -36,11 +41,18 @@ function parseArgs(args) {
|
|
|
36
41
|
stopOnError: false,
|
|
37
42
|
json: false,
|
|
38
43
|
quiet: false,
|
|
44
|
+
concurrency: 1,
|
|
39
45
|
};
|
|
40
46
|
|
|
41
47
|
for (let i = 0; i < args.length; i++) {
|
|
42
48
|
const arg = args[i];
|
|
43
|
-
if (arg === '--
|
|
49
|
+
if (arg === '--concurrency') {
|
|
50
|
+
const value = args[++i];
|
|
51
|
+
if (!/^[1-4]$/.test(value || '')) {
|
|
52
|
+
throw new CliError(t('batch.invalid_concurrency'), { code: 'BATCH_INVALID_CONCURRENCY' });
|
|
53
|
+
}
|
|
54
|
+
parsed.concurrency = Number(value);
|
|
55
|
+
} else if (arg === '--stop-on-error') {
|
|
44
56
|
parsed.stopOnError = true;
|
|
45
57
|
} else if (arg === '--json') {
|
|
46
58
|
parsed.json = true;
|
|
@@ -110,74 +122,44 @@ function parseCommandLine(commandLine) {
|
|
|
110
122
|
return tokens;
|
|
111
123
|
}
|
|
112
124
|
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
function parseOutput(value) {
|
|
126
|
+
const text = String(value || '').trim();
|
|
127
|
+
if (!text) { return null; }
|
|
128
|
+
for (const candidate of [text, text.slice(text.lastIndexOf('\n{') + 1), ...text.split('\n').reverse()]) {
|
|
129
|
+
try { return JSON.parse(candidate); } catch { /* Try the next complete JSON value. */ }
|
|
118
130
|
}
|
|
131
|
+
return text;
|
|
132
|
+
}
|
|
119
133
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
function executeCommand(commandTokens, quiet) {
|
|
135
|
+
const finalTokens = [...commandTokens];
|
|
136
|
+
if (quiet && !finalTokens.includes('--quiet')) { finalTokens.push('--quiet'); }
|
|
137
|
+
const started = Date.now();
|
|
138
|
+
return new Promise(resolve => {
|
|
139
|
+
execFile(process.execPath, [YIDA_BIN, ...finalTokens], {
|
|
140
|
+
encoding: 'utf-8', timeout: 120000, maxBuffer: 10 * 1024 * 1024,
|
|
141
|
+
env: { ...process.env, YIDA_QUIET: quiet ? '1' : (process.env.YIDA_QUIET || '') },
|
|
142
|
+
}, (error, stdout, stderr) => {
|
|
143
|
+
const primary = parseOutput(stdout), diagnostic = error ? parseOutput(stderr) : null;
|
|
144
|
+
const output = primary && typeof primary === 'object' ? primary
|
|
145
|
+
: diagnostic && typeof diagnostic === 'object' ? diagnostic : primary ?? diagnostic;
|
|
146
|
+
const failed = !!error || output?.success === false || output?.ok === false;
|
|
147
|
+
resolve({ command: commandTokens.join(' '), success: !failed,
|
|
148
|
+
exitCode: failed ? (Number.isInteger(error?.code) && error.code !== 0 ? error.code : 1) : 0,
|
|
149
|
+
elapsed: Date.now() - started, startedAt: new Date(started).toISOString(), endedAt: new Date().toISOString(),
|
|
150
|
+
output, ...(failed ? { error: output?.errorMsg || output?.message || output?.error || String(stderr || error?.message || '').trim() } : {}),
|
|
151
|
+
});
|
|
130
152
|
});
|
|
131
|
-
|
|
132
|
-
const elapsed = Date.now() - startTime;
|
|
133
|
-
|
|
134
|
-
// 尝试解析 stdout 中的 JSON
|
|
135
|
-
const output = stdout.trim();
|
|
136
|
-
let parsedOutput = null;
|
|
137
|
-
if (output) {
|
|
138
|
-
// 取最后一行非空内容(多行时前面可能有 stderr 漏到 stdout 的情况)
|
|
139
|
-
const lines = output.split('\n').filter(Boolean);
|
|
140
|
-
const lastLine = lines[lines.length - 1];
|
|
141
|
-
try {
|
|
142
|
-
parsedOutput = JSON.parse(lastLine);
|
|
143
|
-
} catch (_parseError) {
|
|
144
|
-
parsedOutput = output;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
command: commandTokens.join(' '),
|
|
150
|
-
success: true,
|
|
151
|
-
exitCode: 0,
|
|
152
|
-
elapsed,
|
|
153
|
-
output: parsedOutput,
|
|
154
|
-
};
|
|
155
|
-
} catch (execError) {
|
|
156
|
-
const elapsed = Date.now() - startTime;
|
|
157
|
-
let output = null;
|
|
158
|
-
if (execError.stdout) {
|
|
159
|
-
const lines = execError.stdout.toString().trim().split('\n').filter(Boolean);
|
|
160
|
-
if (lines.length > 0) {
|
|
161
|
-
try {
|
|
162
|
-
output = JSON.parse(lines[lines.length - 1]);
|
|
163
|
-
} catch (_parseError) {
|
|
164
|
-
output = lines[lines.length - 1] || null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
command: commandTokens.join(' '),
|
|
171
|
-
success: false,
|
|
172
|
-
exitCode: execError.status || 1,
|
|
173
|
-
elapsed,
|
|
174
|
-
output,
|
|
175
|
-
error: execError.stderr ? execError.stderr.toString().trim().split('\n').filter(Boolean).pop() : execError.message,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
153
|
+
});
|
|
178
154
|
}
|
|
179
155
|
|
|
180
156
|
async function run(args) {
|
|
157
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
158
|
+
const entry = require('./command-manifest').flattenCommandManifest().find(item => item.id === 'batch');
|
|
159
|
+
console.log('openyida ' + entry.usage);
|
|
160
|
+
entry.notes.forEach(note => console.log(note));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
181
163
|
const parsed = parseArgs(args);
|
|
182
164
|
const quiet = parsed.quiet || parsed.json;
|
|
183
165
|
|
|
@@ -202,6 +184,12 @@ async function run(args) {
|
|
|
202
184
|
return;
|
|
203
185
|
}
|
|
204
186
|
|
|
187
|
+
const tasks = commands.map(command => {
|
|
188
|
+
const tokens = parseCommandLine(command);
|
|
189
|
+
if (tokens[0] === 'openyida') { tokens.shift(); }
|
|
190
|
+
return { tokens, policy: describeTask(tokens) };
|
|
191
|
+
}).filter(task => task.tokens.length);
|
|
192
|
+
|
|
205
193
|
// 预检登录态
|
|
206
194
|
if (!quiet) {
|
|
207
195
|
banner('Batch 批量执行');
|
|
@@ -211,10 +199,10 @@ async function run(args) {
|
|
|
211
199
|
step(1, '检查登录态');
|
|
212
200
|
}
|
|
213
201
|
|
|
214
|
-
let authData = loadAuthData();
|
|
202
|
+
let authData = tasks.some(task => task.policy.requiresLogin) ? loadAuthData() : {};
|
|
215
203
|
if (!authData) {
|
|
216
204
|
if (!quiet) { info('未找到登录缓存,触发登录...'); }
|
|
217
|
-
authData = triggerLogin();
|
|
205
|
+
authData = await triggerLogin();
|
|
218
206
|
}
|
|
219
207
|
if (!authData) {
|
|
220
208
|
fail('登录失败,无法执行批量命令');
|
|
@@ -223,56 +211,16 @@ async function run(args) {
|
|
|
223
211
|
}
|
|
224
212
|
if (!quiet) { success('登录态可用'); }
|
|
225
213
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const tokens = parseCommandLine(commandLine);
|
|
237
|
-
|
|
238
|
-
// 跳过 'openyida' 前缀(用户可能写了完整命令)
|
|
239
|
-
if (tokens[0] === 'openyida') {
|
|
240
|
-
tokens.shift();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (tokens.length === 0) { continue; }
|
|
244
|
-
|
|
245
|
-
if (!quiet) {
|
|
246
|
-
info('[' + (i + 1) + '/' + commands.length + '] ' + commandLine);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const commandResult = executeCommand(tokens, quiet);
|
|
250
|
-
results.push(commandResult);
|
|
251
|
-
|
|
252
|
-
if (commandResult.success) {
|
|
253
|
-
successCount++;
|
|
254
|
-
if (!quiet) { success(' ✓ ' + commandResult.elapsed + 'ms'); }
|
|
255
|
-
} else {
|
|
256
|
-
failedCount++;
|
|
257
|
-
if (!quiet) { fail(' ✗ exit=' + commandResult.exitCode + ' ' + (commandResult.error || '')); }
|
|
258
|
-
if (parsed.stopOnError) {
|
|
259
|
-
if (!quiet) { warn('--stop-on-error 触发,跳过剩余 ' + (commands.length - i - 1) + ' 条命令'); }
|
|
260
|
-
stopped = true;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// 输出结果
|
|
267
|
-
const summary = {
|
|
268
|
-
success: failedCount === 0,
|
|
269
|
-
total: commands.length,
|
|
270
|
-
executed: results.length,
|
|
271
|
-
successCount,
|
|
272
|
-
failedCount,
|
|
273
|
-
stopped,
|
|
274
|
-
results,
|
|
275
|
-
};
|
|
214
|
+
if (!quiet) { step(2, t('batch.executing', String(parsed.concurrency))); }
|
|
215
|
+
const wave = await runTaskWave(tasks, parsed, async (task, index) => {
|
|
216
|
+
if (!quiet) { info('[' + (index + 1) + '/' + tasks.length + '] ' + task.tokens.join(' ')); }
|
|
217
|
+
return executeCommand(task.tokens, quiet);
|
|
218
|
+
});
|
|
219
|
+
const results = wave.results;
|
|
220
|
+
const successCount = results.filter(item => item.success).length;
|
|
221
|
+
const failedCount = results.length - successCount;
|
|
222
|
+
const summary = { success: failedCount === 0, total: tasks.length, executed: results.length,
|
|
223
|
+
successCount, failedCount, ...wave };
|
|
276
224
|
|
|
277
225
|
if (!quiet) {
|
|
278
226
|
result(failedCount === 0, 'Batch 完成: ' + successCount + ' 成功, ' + failedCount + ' 失败', [
|
|
@@ -288,6 +236,7 @@ async function run(args) {
|
|
|
288
236
|
} else {
|
|
289
237
|
console.log(JSON.stringify(summary, null, 2));
|
|
290
238
|
}
|
|
239
|
+
return summary;
|
|
291
240
|
}
|
|
292
241
|
|
|
293
|
-
module.exports = { parseArgs, parseCommandLine, loadCommandsFromFile, run };
|
|
242
|
+
module.exports = { parseArgs, parseCommandLine, loadCommandsFromFile, parseOutput, executeCommand, run };
|