dsh-uitest 2.3.0 → 2.4.0
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 +76 -11
- package/bin/uitest.mjs +189 -11
- package/client.js +222 -25
- package/host/agent-bridge.mjs +9 -2
- package/host/agent-test.mjs +1 -1
- package/host/context-budget.mjs +1 -1
- package/index.js +14 -2
- package/lib/agent-session.mjs +81 -3
- package/lib/agent-tasks.mjs +212 -0
- package/lib/batch.mjs +204 -13
- package/lib/browser-ab.mjs +21 -6
- package/lib/browser.mjs +5 -5
- package/lib/config.mjs +1 -0
- package/lib/convert.mjs +178 -40
- package/lib/doc-structure.mjs +316 -0
- package/lib/flow.mjs +49 -14
- package/lib/knowledge-central-episodes.mjs +120 -0
- package/lib/knowledge-central-import.mjs +16 -1
- package/lib/knowledge-central.mjs +176 -25
- package/lib/knowledge-clean.mjs +749 -0
- package/lib/knowledge-consolidate.mjs +1271 -0
- package/lib/knowledge-coverage.mjs +150 -0
- package/lib/knowledge-docs.mjs +3 -3
- package/lib/knowledge-effect.mjs +148 -0
- package/lib/knowledge-facts.mjs +1008 -0
- package/lib/knowledge-maintain.mjs +185 -0
- package/lib/knowledge-permission.mjs +447 -0
- package/lib/knowledge-query.mjs +304 -26
- package/lib/knowledge-store.mjs +169 -14
- package/lib/knowledge-summarize.mjs +332 -0
- package/lib/knowledge.mjs +944 -47
- package/lib/learn-run.mjs +157 -51
- package/lib/run-learn.mjs +34 -0
- package/lib/run-observe.mjs +95 -27
- package/lib/run-stats.mjs +71 -0
- package/package.json +12 -2
- package/scripts/knowledge-central-purge.mjs +248 -0
- package/scripts/knowledge-central-sync.mjs +102 -20
- package/scripts/knowledge-consolidate.mjs +158 -0
- package/scripts/knowledge-coverage.mjs +94 -0
- package/scripts/knowledge-effect.mjs +82 -0
- package/scripts/knowledge-permission-probe.mjs +196 -0
- package/scripts/knowledge-permission-report.mjs +140 -0
- package/scripts/knowledge-report.mjs +492 -0
- package/scripts/knowledge-summarize.mjs +200 -0
- package/skills/uitest/SKILL.md +4 -2
- package/skills/uitest/references/convert-knowledge.md +66 -13
- package/studio/host.mjs +143 -6
- package/studio/knowledge.mjs +279 -42
- package/studio/snapshot.mjs +6 -1
package/lib/flow.mjs
CHANGED
|
@@ -23,12 +23,20 @@ import {
|
|
|
23
23
|
import * as pwDriver from './browser.mjs';
|
|
24
24
|
import * as abDriver from './browser-ab.mjs';
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/** 显式配置 > 环境变量 > agent-browser;batch/studio/agent-session 都用同一个默认。 */
|
|
27
|
+
export function resolveDriverName(config = {}, env = process.env) {
|
|
28
|
+
return String((config.browser && config.browser.driver) || env.UITEST_DRIVER || 'agent-browser').toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const driverFor = (config) => (resolveDriverName(config) === 'playwright' ? pwDriver : abDriver);
|
|
27
32
|
|
|
28
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* agent 判断步骤:有宿主判断器时由它给 ok/note。
|
|
35
|
+
* CLI 没有判断器时标记 skipped,保留位置和说明,不把"没验证"伪造成通过。
|
|
36
|
+
*/
|
|
29
37
|
async function runAgentStep(actionCtx, step) {
|
|
30
38
|
if (typeof actionCtx.agentStep !== 'function') {
|
|
31
|
-
|
|
39
|
+
return { skipped: true, reason: 'agent 判断步骤没有宿主判断器,本次未验证' };
|
|
32
40
|
}
|
|
33
41
|
const result = await actionCtx.agentStep(step, actionCtx);
|
|
34
42
|
if (!result || typeof result !== 'object') {
|
|
@@ -45,7 +53,7 @@ async function runAgentStep(actionCtx, step) {
|
|
|
45
53
|
import { createLiveView } from './live-view.mjs';
|
|
46
54
|
import { validatePreconditionFlow } from './preconditions.mjs';
|
|
47
55
|
import { createPageObserver } from './run-observe.mjs';
|
|
48
|
-
import {
|
|
56
|
+
import { learnRun } from './run-learn.mjs';
|
|
49
57
|
|
|
50
58
|
/* ------------------------------------------------------------------ */
|
|
51
59
|
/* flow 定位与校验 */
|
|
@@ -458,6 +466,7 @@ export async function runFlow(options = {}) {
|
|
|
458
466
|
|
|
459
467
|
const steps = [];
|
|
460
468
|
const failedSteps = [];
|
|
469
|
+
const skippedSteps = [];
|
|
461
470
|
let aborted = false;
|
|
462
471
|
let loginReused = null;
|
|
463
472
|
let session = providedSession || null;
|
|
@@ -671,12 +680,17 @@ export async function runFlow(options = {}) {
|
|
|
671
680
|
const data = step.action === 'agent'
|
|
672
681
|
? await runAgentStep(actionCtx, step)
|
|
673
682
|
: await driver.performAction(session.page, step, actionCtx);
|
|
683
|
+
if (data && typeof data === 'object' && data.skipped === true) {
|
|
684
|
+
status = 'skipped';
|
|
685
|
+
skippedSteps.push({ id: stepId, action: stepAction, reason: String(data.reason || '') });
|
|
686
|
+
log.warn(`步骤 ${stepId} 跳过:${data.reason}`);
|
|
687
|
+
}
|
|
674
688
|
if (step.action === 'login' && data && typeof data.reused === 'boolean') {
|
|
675
689
|
loginReused = data.reused;
|
|
676
690
|
stepLoginReused = data.reused;
|
|
677
691
|
log.info(data.reused ? '复用已有登录态(storageState 有效)' : '已执行登录并更新 storageState');
|
|
678
692
|
}
|
|
679
|
-
if (step.store) {
|
|
693
|
+
if (step.store && !(data && typeof data === 'object' && data.skipped === true)) {
|
|
680
694
|
storedValue = pickStoredValue(data);
|
|
681
695
|
vars[step.store] = storedValue;
|
|
682
696
|
}
|
|
@@ -718,6 +732,7 @@ export async function runFlow(options = {}) {
|
|
|
718
732
|
action: stepAction,
|
|
719
733
|
message: truncate(lastError.message, 600),
|
|
720
734
|
screenshot: failedRel,
|
|
735
|
+
soft: Boolean(step.continueOnFail),
|
|
721
736
|
...(lastError.detail ? { detail: lastError.detail } : {}),
|
|
722
737
|
});
|
|
723
738
|
detail = safeDetail({
|
|
@@ -737,6 +752,7 @@ export async function runFlow(options = {}) {
|
|
|
737
752
|
durationMs: Date.now() - startMs,
|
|
738
753
|
detail,
|
|
739
754
|
screenshot,
|
|
755
|
+
...(step.continueOnFail ? { continueOnFail: true } : {}),
|
|
740
756
|
...(failureScreenshot ? { failureScreenshot } : {}),
|
|
741
757
|
vars: safeVarSnapshot(vars),
|
|
742
758
|
...(step.shot || stepAction === 'screenshot' || step.key || rawStep.key ? { keyShot: true } : {}),
|
|
@@ -779,7 +795,10 @@ export async function runFlow(options = {}) {
|
|
|
779
795
|
const endedAt = new Date();
|
|
780
796
|
const endedAtIso = nowIso(endedAt);
|
|
781
797
|
const failedCount = failedSteps.length;
|
|
782
|
-
|
|
798
|
+
// continueOnFail 的断言只记警告,不改变运行结论;硬失败才判定 failed。
|
|
799
|
+
const softFailedCount = failedSteps.filter((step) => step.soft).length;
|
|
800
|
+
const hardFailedCount = failedCount - softFailedCount;
|
|
801
|
+
const runStatus = hardFailedCount === 0 && !setupError ? 'passed' : 'failed';
|
|
783
802
|
const finalRecord = {
|
|
784
803
|
...runRecord,
|
|
785
804
|
flow: flow.name || runLabel,
|
|
@@ -810,6 +829,10 @@ export async function runFlow(options = {}) {
|
|
|
810
829
|
executed: steps.length,
|
|
811
830
|
passed: steps.filter((step) => step.status === 'passed').length,
|
|
812
831
|
failed: failedCount,
|
|
832
|
+
hardFailed: hardFailedCount,
|
|
833
|
+
softFailed: softFailedCount,
|
|
834
|
+
skipped: skippedSteps.length,
|
|
835
|
+
assertions: flow.steps.filter((step) => step.action === 'expect' || step.action === 'assert').length,
|
|
813
836
|
aborted,
|
|
814
837
|
},
|
|
815
838
|
};
|
|
@@ -819,25 +842,34 @@ export async function runFlow(options = {}) {
|
|
|
819
842
|
}
|
|
820
843
|
writeRunRecord(runJsonPath, finalRecord);
|
|
821
844
|
|
|
822
|
-
//
|
|
845
|
+
// 运行结束后自动沉淀页面观察、等待、失败建议与耗时;失败只写 learnError + warning,不阻塞/不改变运行结果
|
|
823
846
|
let learnResult = null;
|
|
824
847
|
let learnError = null;
|
|
825
848
|
if (learnAfterRun) {
|
|
826
849
|
try {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
runDir:
|
|
830
|
-
pagesAdded:
|
|
831
|
-
pagesMerged:
|
|
832
|
-
actionsAdded:
|
|
833
|
-
observations:
|
|
850
|
+
const learned = learnRun(config, { runDir, logger: log });
|
|
851
|
+
learnResult = {
|
|
852
|
+
runDir: learned.observations?.runDir || learned.timing?.runDir || runDir,
|
|
853
|
+
pagesAdded: learned.observations?.pagesAdded || 0,
|
|
854
|
+
pagesMerged: learned.observations?.pagesMerged || 0,
|
|
855
|
+
actionsAdded: learned.observations?.actionsAdded || 0,
|
|
856
|
+
observations: learned.observations?.observations || 0,
|
|
857
|
+
waitsUpdated: learned.timing?.updatedPages?.length || 0,
|
|
858
|
+
suggestions: learned.timing?.suggestions?.length || 0,
|
|
859
|
+
learnings: learned.timing?.learnings?.length || 0,
|
|
834
860
|
at: nowIso(),
|
|
835
861
|
};
|
|
862
|
+
if (learned.errors.length) {
|
|
863
|
+
learnError = learned.errors.map((item) => `${item.stage}: ${item.message}`).join(';');
|
|
864
|
+
finalRecord.learnError = learnError;
|
|
865
|
+
log.warn(`自动学习部分失败(不影响运行结果):${learnError}`);
|
|
866
|
+
}
|
|
836
867
|
} catch (err) {
|
|
837
868
|
learnError = truncate(err.message, 500);
|
|
838
869
|
finalRecord.learnError = learnError;
|
|
839
870
|
log.warn(`自动学习失败(不影响运行结果):${learnError}`);
|
|
840
871
|
}
|
|
872
|
+
if (learnResult) finalRecord.learn = learnResult;
|
|
841
873
|
writeRunRecord(runJsonPath, finalRecord);
|
|
842
874
|
}
|
|
843
875
|
|
|
@@ -852,6 +884,8 @@ export async function runFlow(options = {}) {
|
|
|
852
884
|
runDir,
|
|
853
885
|
runJsonPath,
|
|
854
886
|
failedSteps,
|
|
887
|
+
skippedSteps,
|
|
888
|
+
skipped: skippedSteps.length,
|
|
855
889
|
live: finalRecord.live,
|
|
856
890
|
setup: finalRecord.setup || [],
|
|
857
891
|
setupFailed,
|
|
@@ -860,6 +894,7 @@ export async function runFlow(options = {}) {
|
|
|
860
894
|
vars,
|
|
861
895
|
loginReused,
|
|
862
896
|
pages: run.pages,
|
|
897
|
+
assertions: finalRecord.summary.assertions,
|
|
863
898
|
learn: finalRecord.learn || null,
|
|
864
899
|
learnError,
|
|
865
900
|
flow: run.flow,
|
|
@@ -4,6 +4,18 @@ import { categorySourceTag } from './knowledge-categories.mjs';
|
|
|
4
4
|
|
|
5
5
|
export const PAGE_EPISODE_SOURCE = 'uitest page knowledge · ' + categorySourceTag('page');
|
|
6
6
|
export const PROCESS_EPISODE_SOURCE = 'uitest process knowledge · ' + categorySourceTag('operation');
|
|
7
|
+
export const FLOW_EPISODE_SOURCE = 'uitest flow knowledge · ' + categorySourceTag('business-flow');
|
|
8
|
+
export const DOCUMENT_EPISODE_SOURCE = 'uitest document knowledge';
|
|
9
|
+
export const SYSTEM_EPISODE_SOURCE = 'uitest system knowledge · ' + categorySourceTag('business-flow');
|
|
10
|
+
export const EXPERIENCE_EPISODE_SOURCE = 'uitest experience evidence · ' + categorySourceTag('operation');
|
|
11
|
+
export const FACT_EPISODE_SOURCE = 'uitest canonical fact · ' + categorySourceTag('business-flow');
|
|
12
|
+
export const PERMISSION_FACT_EPISODE_SOURCE = 'uitest permission fact · ' + categorySourceTag('business-flow');
|
|
13
|
+
|
|
14
|
+
/** 文档结构 Episode 的来源描述:有状态/流转时归单据流转,否则归业务流程。 */
|
|
15
|
+
export function documentEpisodeSource(document) {
|
|
16
|
+
const category = (document?.statuses || []).length || (document?.transitions || []).length ? 'document-flow' : 'business-flow';
|
|
17
|
+
return DOCUMENT_EPISODE_SOURCE + ' · ' + categorySourceTag(category);
|
|
18
|
+
}
|
|
7
19
|
|
|
8
20
|
export function pageEpisodeBody(page) {
|
|
9
21
|
return {
|
|
@@ -11,6 +23,7 @@ export function pageEpisodeBody(page) {
|
|
|
11
23
|
category: 'page',
|
|
12
24
|
id: page?.id || '',
|
|
13
25
|
title: page?.title || '',
|
|
26
|
+
summary: page?.summary || '',
|
|
14
27
|
urlName: page?.urlName || '',
|
|
15
28
|
url: page?.url || '',
|
|
16
29
|
tableHeaders: (page?.table?.headers || []).slice(0, 30),
|
|
@@ -34,9 +47,116 @@ export function processEpisodeBody(process) {
|
|
|
34
47
|
id: process?.id || '',
|
|
35
48
|
caseId: process?.caseId || '',
|
|
36
49
|
name: process?.name || '',
|
|
50
|
+
summary: process?.summary || '',
|
|
37
51
|
steps: (process?.steps || []).slice(0, 40),
|
|
38
52
|
notes: (process?.notes || []).slice(-20),
|
|
39
53
|
corrections: (process?.corrections || []).slice(-20),
|
|
40
54
|
reviews: (process?.reviews || []).slice(-10),
|
|
41
55
|
};
|
|
42
56
|
}
|
|
57
|
+
|
|
58
|
+
/** 系统级知识:菜单、URL、角色、权限、术语,一页承载整个系统的稳定事实。 */
|
|
59
|
+
export function systemEpisodeBody(system) {
|
|
60
|
+
return {
|
|
61
|
+
type: 'system',
|
|
62
|
+
category: 'business-flow',
|
|
63
|
+
name: system?.system || system?.name || '系统',
|
|
64
|
+
summary: system?.summary || '',
|
|
65
|
+
baseUrl: system?.baseUrl || '',
|
|
66
|
+
menus: system?.menus || {},
|
|
67
|
+
urls: system?.urls || {},
|
|
68
|
+
notes: (system?.notes || []).slice(-20),
|
|
69
|
+
roles: (system?.roles || []).slice(0, 80),
|
|
70
|
+
permissions: (system?.permissions || []).slice(0, 120),
|
|
71
|
+
glossary: (system?.glossary || []).slice(0, 200),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 执行经验:页面备注/人工反馈/用例过程,只进证据组,供同用例/同页面查询。 */
|
|
76
|
+
export function experienceEpisodeBody(experience) {
|
|
77
|
+
return {
|
|
78
|
+
type: 'experience',
|
|
79
|
+
category: 'operation',
|
|
80
|
+
id: experience?.id || '',
|
|
81
|
+
kind: experience?.kind || '',
|
|
82
|
+
caseId: experience?.caseId || '',
|
|
83
|
+
batchId: experience?.batchId || '',
|
|
84
|
+
pageId: experience?.pageId || '',
|
|
85
|
+
name: experience?.name || experience?.title || '',
|
|
86
|
+
steps: (experience?.steps || []).slice(0, 40),
|
|
87
|
+
notes: (experience?.notes || []).slice(-20),
|
|
88
|
+
corrections: (experience?.corrections || []).slice(-20),
|
|
89
|
+
reviews: (experience?.reviews || []).slice(-10),
|
|
90
|
+
feedbacks: (experience?.feedbacks || []).slice(-20),
|
|
91
|
+
sources: (experience?.sources || []).slice(-20),
|
|
92
|
+
observations: (experience?.observations || []).slice(-20),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 正典业务流程:只含可复用步骤,不带 caseId/纠错/复盘。 */
|
|
97
|
+
export function flowEpisodeBody(process) {
|
|
98
|
+
return {
|
|
99
|
+
type: 'flow',
|
|
100
|
+
category: 'business-flow',
|
|
101
|
+
id: process?.id || '',
|
|
102
|
+
name: process?.name || '',
|
|
103
|
+
summary: process?.summary || '',
|
|
104
|
+
keywords: (process?.keywords || []).slice(0, 20),
|
|
105
|
+
steps: (process?.steps || []).slice(0, 40),
|
|
106
|
+
notes: (process?.notes || []).slice(-20),
|
|
107
|
+
confidence: process?.confidence ?? null,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 正典事实:状态/证据计数/冲突值随 Episode 一起同步,供中心按实体检索。 */
|
|
112
|
+
export function factEpisodeBody(fact) {
|
|
113
|
+
const conflicts = (fact?.conflicts || []).slice(0, 10).map((conflict) => ({
|
|
114
|
+
value: conflict?.value,
|
|
115
|
+
confidence: conflict?.confidence ?? null,
|
|
116
|
+
evidence: (conflict?.evidence || []).slice(0, 5),
|
|
117
|
+
}));
|
|
118
|
+
return {
|
|
119
|
+
type: 'fact',
|
|
120
|
+
category: 'business-flow',
|
|
121
|
+
id: fact?.id || '',
|
|
122
|
+
kind: fact?.kind || '',
|
|
123
|
+
subject: fact?.subject || '',
|
|
124
|
+
predicate: fact?.predicate || '',
|
|
125
|
+
value: fact?.value,
|
|
126
|
+
scope: fact?.scope || {},
|
|
127
|
+
status: fact?.status || '',
|
|
128
|
+
confidence: fact?.confidence ?? null,
|
|
129
|
+
revision: fact?.revision ?? 1,
|
|
130
|
+
validFrom: fact?.validFrom || '',
|
|
131
|
+
validTo: fact?.validTo || '',
|
|
132
|
+
deprecationReason: fact?.deprecationReason || '',
|
|
133
|
+
conflicts,
|
|
134
|
+
evidence: (fact?.evidence || []).slice(0, 20).map((item) => ({
|
|
135
|
+
type: item?.type || '',
|
|
136
|
+
ref: item?.ref || '',
|
|
137
|
+
at: item?.at || '',
|
|
138
|
+
note: item?.note || '',
|
|
139
|
+
})),
|
|
140
|
+
notes: (fact?.notes || []).slice(-10),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 文档结构:单据字段/状态/流转/角色/权限/术语,不发送全文。 */
|
|
145
|
+
export function documentEpisodeBody(document) {
|
|
146
|
+
const statuses = (document?.statuses || []).slice(0, 40);
|
|
147
|
+
const transitions = (document?.transitions || []).slice(0, 60);
|
|
148
|
+
return {
|
|
149
|
+
type: 'document',
|
|
150
|
+
category: statuses.length || transitions.length ? 'document-flow' : 'business-flow',
|
|
151
|
+
id: document?.id || '',
|
|
152
|
+
title: document?.title || '',
|
|
153
|
+
summary: document?.summary || '',
|
|
154
|
+
kind: document?.kind || '',
|
|
155
|
+
fields: (document?.fields || []).slice(0, 200),
|
|
156
|
+
statuses,
|
|
157
|
+
transitions,
|
|
158
|
+
roles: (document?.roles || []).slice(0, 60),
|
|
159
|
+
permissions: (document?.permissions || []).slice(0, 120),
|
|
160
|
+
glossary: (document?.glossary || []).slice(0, 120),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -5,6 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import { centralConfig, centralIngest, centralIngestFast } from './knowledge-central.mjs';
|
|
6
6
|
import { listLocallyEditedDocumentNames } from './knowledge-docs.mjs';
|
|
7
7
|
import { categorySourceTag, inferKnowledgeCategory, isKnowledgeCategory, UNCATEGORIZED } from './knowledge-categories.mjs';
|
|
8
|
+
import { classifyDocumentKind, isLearnableDocument } from './knowledge-clean.mjs';
|
|
8
9
|
import { nowIso, slug } from './util.mjs';
|
|
9
10
|
|
|
10
11
|
export const KNOWLEDGE_SOURCE_EXTS = ['.md', '.markdown', '.txt', '.json'];
|
|
@@ -176,6 +177,7 @@ export function buildDocumentEpisodes(files = [], { maxFileBytes = SCAN_DEFAULTS
|
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
const resolvedCategory = fixedCategory || inferKnowledgeCategory(rel + '\n' + text.slice(0, 4000));
|
|
180
|
+
const documentKind = classifyDocumentKind({ title: rel, content: text });
|
|
179
181
|
episodes.push({
|
|
180
182
|
key: 'doc:' + slug(rel),
|
|
181
183
|
name: rel,
|
|
@@ -187,6 +189,8 @@ export function buildDocumentEpisodes(files = [], { maxFileBytes = SCAN_DEFAULTS
|
|
|
187
189
|
path: absPath,
|
|
188
190
|
format: ext.replace(/^\./, ''),
|
|
189
191
|
size: stat.size,
|
|
192
|
+
documentKind,
|
|
193
|
+
learnable: isLearnableDocument(documentKind),
|
|
190
194
|
});
|
|
191
195
|
}
|
|
192
196
|
return episodes;
|
|
@@ -210,6 +214,8 @@ function documentOf(file, episode) {
|
|
|
210
214
|
format: episode.format,
|
|
211
215
|
size: episode.size,
|
|
212
216
|
category: episode.category || UNCATEGORIZED,
|
|
217
|
+
kind: episode.documentKind || '',
|
|
218
|
+
learnable: episode.learnable !== false,
|
|
213
219
|
status: 'imported',
|
|
214
220
|
};
|
|
215
221
|
}
|
|
@@ -256,13 +262,21 @@ export async function importKnowledgeToCentral(config, { paths = [], files = [],
|
|
|
256
262
|
for (const episode of episodes) episode.source_description = episode.source_description + ' · ' + String(title).slice(0, 120);
|
|
257
263
|
}
|
|
258
264
|
// 本地编辑过的文档不能重新发送源文件:新版 /ingest 会先写后删同名 Episode,会把编辑版一起替换掉。
|
|
265
|
+
// 测试报告/会议纪要只作证据,不进知识组,避免实例数据被中心抽取成正典。
|
|
259
266
|
const editedNames = listLocallyEditedDocumentNames(config);
|
|
260
|
-
const
|
|
267
|
+
const evidenceSkipped = episodes.filter((episode) => episode.learnable === false).length;
|
|
268
|
+
const sendEpisodes = episodes.filter((episode) => episode.learnable !== false && !editedNames.has(episode.name));
|
|
261
269
|
const episodeByPath = new Map(episodes.map((episode) => [episode.path, episode]));
|
|
262
270
|
const documents = [];
|
|
263
271
|
for (const file of scan.files) {
|
|
264
272
|
const doc = documentOf(file, episodeByPath.get(file.path));
|
|
265
273
|
const episode = episodeByPath.get(file.path);
|
|
274
|
+
if (episode && episode.learnable === false) {
|
|
275
|
+
doc.status = 'skipped';
|
|
276
|
+
doc.error = '按文档类型仅作证据,不进入知识组:' + episode.documentKind;
|
|
277
|
+
documents.push(doc);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
266
280
|
if (episode && editedNames.has(episode.name)) {
|
|
267
281
|
doc.status = 'skipped';
|
|
268
282
|
doc.error = '本地已编辑,保留本地版本;如需用源文件覆盖,请先删除本地文档';
|
|
@@ -274,6 +288,7 @@ export async function importKnowledgeToCentral(config, { paths = [], files = [],
|
|
|
274
288
|
const totals = {
|
|
275
289
|
files: scan.files.length,
|
|
276
290
|
episodes: episodes.length,
|
|
291
|
+
evidenceSkipped,
|
|
277
292
|
ingested: 0,
|
|
278
293
|
skipped: documents.filter((item) => item.status === 'skipped').length,
|
|
279
294
|
failed: 0,
|