cwtools-shared 0.2.9 → 0.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/dist/debug/zz.d.ts +1 -0
- package/dist/debug/zz.js +12 -0
- package/dist/generated/mcpTools.d.ts +49 -4
- package/dist/generated/mcpTools.js +94 -49
- package/dist/generated/workshopDetection.d.ts +22 -0
- package/dist/generated/workshopDetection.js +50 -0
- package/dist/generated/workspaceDetectionProfiles.d.ts +2 -0
- package/dist/generated/workspaceDetectionProfiles.js +84 -0
- package/dist/generated/workspaceGameDetection.d.ts +39 -0
- package/dist/generated/workspaceGameDetection.js +424 -0
- package/dist/host/capabilities.d.ts +39 -0
- package/dist/host/capabilities.js +128 -0
- package/dist/host/diagnostics.d.ts +8 -1
- package/dist/host/filesystem.d.ts +2 -0
- package/dist/host/hostServices.d.ts +47 -0
- package/dist/host/indexing.d.ts +3 -0
- package/dist/host/lsp.d.ts +9 -0
- package/dist/host/lsp.js +27 -0
- package/dist/host/readiness.js +10 -0
- package/dist/host/vanillaCache.js +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +22 -1
- package/dist/knowledge/interfaceKnowledge.d.ts +8 -0
- package/dist/knowledge/interfaceKnowledge.js +222 -0
- package/dist/project/descriptor.d.ts +12 -0
- package/dist/project/descriptor.js +69 -0
- package/dist/project/init.d.ts +11 -0
- package/dist/project/init.js +356 -0
- package/dist/project/knowledge.d.ts +6 -0
- package/dist/project/knowledge.js +20 -8
- package/dist/project/profile.d.ts +62 -7
- package/dist/project/profile.js +4 -3
- package/dist/project/profileBuilder.d.ts +31 -0
- package/dist/project/profileBuilder.js +989 -0
- package/dist/tools/archetypeArtifacts.d.ts +29 -0
- package/dist/tools/archetypeArtifacts.js +136 -0
- package/dist/tools/archetypeSlots.d.ts +32 -0
- package/dist/tools/archetypeSlots.js +257 -0
- package/dist/tools/archetypeTools.d.ts +4 -0
- package/dist/tools/archetypeTools.js +118 -0
- package/dist/tools/callHandler.d.ts +10 -0
- package/dist/tools/callHandler.js +76 -0
- package/dist/tools/catalog.d.ts +4094 -0
- package/dist/tools/catalog.js +5031 -0
- package/dist/tools/domainTools.d.ts +8 -0
- package/dist/tools/domainTools.js +222 -0
- package/dist/tools/mcpSchema.d.ts +20 -3
- package/dist/tools/mcpSchema.js +55 -7
- package/dist/tools/mediaWrites.d.ts +52 -0
- package/dist/tools/mediaWrites.js +322 -0
- package/dist/tools/names.d.ts +4 -4
- package/dist/tools/names.js +14 -1
- package/dist/tools/pdxWriteCore.d.ts +51 -0
- package/dist/tools/pdxWriteCore.js +628 -0
- package/dist/tools/pdxWrites.d.ts +88 -0
- package/dist/tools/pdxWrites.js +629 -0
- package/dist/tools/registry.d.ts +1 -0
- package/dist/tools/scopeBridge.d.ts +36 -0
- package/dist/tools/scopeBridge.js +173 -0
- package/dist/tools/symbols.js +22 -2
- package/dist/tools/targetingWeights.d.ts +206 -0
- package/dist/tools/targetingWeights.js +350 -0
- package/dist/tools/toolHandlers.d.ts +5 -1
- package/dist/tools/toolHandlers.js +146 -33
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_SCOPE_BRIDGE_CANDIDATES = exports.MAX_SCOPE_BRIDGE_HOPS = void 0;
|
|
4
|
+
exports.solveScopeBridge = solveScopeBridge;
|
|
5
|
+
exports.MAX_SCOPE_BRIDGE_HOPS = 4;
|
|
6
|
+
exports.MAX_SCOPE_BRIDGE_CANDIDATES = 200;
|
|
7
|
+
const REJECTED_SCOPES = new Set(['', 'unknown', 'unresolved', 'none', 'null', 'undefined']);
|
|
8
|
+
const MAX_RETURNED_PATHS = 200;
|
|
9
|
+
/**
|
|
10
|
+
* Finds evidence-backed scope transitions without consulting a registry or any
|
|
11
|
+
* process state. Inputs are normalized so output is independent of candidate
|
|
12
|
+
* order and spelling case.
|
|
13
|
+
*/
|
|
14
|
+
function solveScopeBridge(input) {
|
|
15
|
+
if (!input || typeof input !== 'object' || !Array.isArray(input.candidates) || input.candidates.length > exports.MAX_SCOPE_BRIDGE_CANDIDATES)
|
|
16
|
+
return emptyResult();
|
|
17
|
+
const fromScopes = parseScopes(input.fromScope);
|
|
18
|
+
const toScopes = parseScopes(input.toScope);
|
|
19
|
+
if (fromScopes.length === 0 || toScopes.length === 0 || !Array.isArray(input.candidates)) {
|
|
20
|
+
return emptyResult();
|
|
21
|
+
}
|
|
22
|
+
if (scopesMatch(fromScopes, toScopes)) {
|
|
23
|
+
const path = { rank: 1, steps: [], confidence: 1, evidence: [] };
|
|
24
|
+
return { paths: [path], confidence: path.confidence, evidence: [] };
|
|
25
|
+
}
|
|
26
|
+
const candidates = input.candidates
|
|
27
|
+
.map(normalizeCandidate)
|
|
28
|
+
.filter((candidate) => candidate !== undefined)
|
|
29
|
+
.sort(compareCandidates)
|
|
30
|
+
.slice(0, exports.MAX_SCOPE_BRIDGE_CANDIDATES);
|
|
31
|
+
let frontier = [{
|
|
32
|
+
scopes: fromScopes,
|
|
33
|
+
steps: [],
|
|
34
|
+
usedCandidates: new Set(),
|
|
35
|
+
usedUnion: fromScopes.length > 1,
|
|
36
|
+
usedAny: fromScopes.includes('any'),
|
|
37
|
+
}];
|
|
38
|
+
const found = [];
|
|
39
|
+
for (let depth = 0; depth < exports.MAX_SCOPE_BRIDGE_HOPS && frontier.length > 0; depth += 1) {
|
|
40
|
+
const next = [];
|
|
41
|
+
for (const node of frontier) {
|
|
42
|
+
for (const candidate of candidates) {
|
|
43
|
+
const candidateKey = candidateIdentity(candidate);
|
|
44
|
+
if (node.usedCandidates.has(candidateKey)
|
|
45
|
+
|| !scopesMatch(node.scopes, candidate.supportedScopes))
|
|
46
|
+
continue;
|
|
47
|
+
const step = {
|
|
48
|
+
name: candidate.name,
|
|
49
|
+
fromScopes: [...node.scopes],
|
|
50
|
+
toScopes: [...candidate.pushScopes],
|
|
51
|
+
evidence: [...candidate.evidence],
|
|
52
|
+
};
|
|
53
|
+
const usedCandidates = new Set(node.usedCandidates);
|
|
54
|
+
usedCandidates.add(candidateKey);
|
|
55
|
+
const child = {
|
|
56
|
+
scopes: candidate.pushScopes,
|
|
57
|
+
steps: [...node.steps, step],
|
|
58
|
+
usedCandidates,
|
|
59
|
+
usedUnion: node.usedUnion
|
|
60
|
+
|| candidate.supportedScopes.length > 1
|
|
61
|
+
|| candidate.pushScopes.length > 1,
|
|
62
|
+
usedAny: node.usedAny
|
|
63
|
+
|| candidate.supportedScopes.includes('any')
|
|
64
|
+
|| candidate.pushScopes.includes('any'),
|
|
65
|
+
};
|
|
66
|
+
if (scopesMatch(child.scopes, toScopes)) {
|
|
67
|
+
found.push(child);
|
|
68
|
+
}
|
|
69
|
+
else if (found.length < MAX_RETURNED_PATHS) {
|
|
70
|
+
next.push(child);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (found.length > 0)
|
|
75
|
+
break; // BFS: longer paths cannot outrank shortest paths.
|
|
76
|
+
frontier = deduplicateNodes(next).slice(0, MAX_RETURNED_PATHS);
|
|
77
|
+
}
|
|
78
|
+
const paths = found
|
|
79
|
+
.map(nodeToPath)
|
|
80
|
+
.sort(comparePaths)
|
|
81
|
+
.slice(0, MAX_RETURNED_PATHS)
|
|
82
|
+
.map((path, index) => ({ ...path, rank: index + 1 }));
|
|
83
|
+
const best = paths[0];
|
|
84
|
+
return best
|
|
85
|
+
? { paths, confidence: best.confidence, evidence: [...best.evidence] }
|
|
86
|
+
: emptyResult();
|
|
87
|
+
}
|
|
88
|
+
function normalizeCandidate(candidate) {
|
|
89
|
+
if (!candidate || typeof candidate.name !== 'string' || !Array.isArray(candidate.supportedScopes))
|
|
90
|
+
return undefined;
|
|
91
|
+
const name = candidate.name.trim();
|
|
92
|
+
const parsedSupportedScopes = candidate.supportedScopes.map(parseScopes);
|
|
93
|
+
if (parsedSupportedScopes.some(scopes => scopes.length === 0))
|
|
94
|
+
return undefined;
|
|
95
|
+
const supportedScopes = uniqueSorted(parsedSupportedScopes.flat());
|
|
96
|
+
const pushScopes = parseScopes(candidate.pushScope ?? '');
|
|
97
|
+
const evidence = normalizeEvidence(candidate.evidence);
|
|
98
|
+
if (!name || supportedScopes.length === 0 || pushScopes.length === 0 || evidence.length === 0)
|
|
99
|
+
return undefined;
|
|
100
|
+
return { name, supportedScopes, pushScopes, evidence };
|
|
101
|
+
}
|
|
102
|
+
function parseScopes(value) {
|
|
103
|
+
if (typeof value !== 'string')
|
|
104
|
+
return [];
|
|
105
|
+
const normalized = value.trim().toLowerCase().replace(/^union\s*[:(]\s*/, '').replace(/\)$/, '');
|
|
106
|
+
const scopes = normalized
|
|
107
|
+
.split(/\s*(?:\||,|\/)\s*/)
|
|
108
|
+
.map(scope => scope.trim());
|
|
109
|
+
if (scopes.some(scope => REJECTED_SCOPES.has(scope)))
|
|
110
|
+
return [];
|
|
111
|
+
return uniqueSorted(scopes);
|
|
112
|
+
}
|
|
113
|
+
function normalizeEvidence(value) {
|
|
114
|
+
const entries = typeof value === 'string' ? [value] : Array.isArray(value) ? value : [];
|
|
115
|
+
return uniqueSorted(entries
|
|
116
|
+
.filter((item) => typeof item === 'string')
|
|
117
|
+
.map(item => item.trim())
|
|
118
|
+
.filter(Boolean));
|
|
119
|
+
}
|
|
120
|
+
function uniqueSorted(values) {
|
|
121
|
+
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
122
|
+
}
|
|
123
|
+
function scopesMatch(left, right) {
|
|
124
|
+
return left.includes('any') || right.includes('any') || left.some(scope => right.includes(scope));
|
|
125
|
+
}
|
|
126
|
+
function candidateIdentity(candidate) {
|
|
127
|
+
return [candidate.name.toLowerCase(), candidate.supportedScopes.join('|'), candidate.pushScopes.join('|'), candidate.evidence.join('|')].join('\u0000');
|
|
128
|
+
}
|
|
129
|
+
function compareCandidates(left, right) {
|
|
130
|
+
return candidateIdentity(left).localeCompare(candidateIdentity(right));
|
|
131
|
+
}
|
|
132
|
+
function deduplicateNodes(nodes) {
|
|
133
|
+
const sorted = [...nodes].sort((left, right) => nodeIdentity(left).localeCompare(nodeIdentity(right)));
|
|
134
|
+
const seen = new Set();
|
|
135
|
+
return sorted.filter(node => {
|
|
136
|
+
const key = nodeIdentity(node);
|
|
137
|
+
if (seen.has(key))
|
|
138
|
+
return false;
|
|
139
|
+
seen.add(key);
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function nodeIdentity(node) {
|
|
144
|
+
return node.steps.map(step => [step.name.toLowerCase(), step.toScopes.join('|'), step.evidence.join('|')].join(':')).join('>');
|
|
145
|
+
}
|
|
146
|
+
function nodeToPath(node) {
|
|
147
|
+
const hopPenalty = Math.max(0, node.steps.length - 1) * 0.1;
|
|
148
|
+
const unionPenalty = node.usedUnion ? 0.05 : 0;
|
|
149
|
+
const anyPenalty = node.usedAny ? 0.15 : 0;
|
|
150
|
+
const confidence = Math.max(0, Number((1 - hopPenalty - unionPenalty - anyPenalty).toFixed(2)));
|
|
151
|
+
return {
|
|
152
|
+
rank: 0,
|
|
153
|
+
steps: node.steps.map(step => ({
|
|
154
|
+
...step,
|
|
155
|
+
fromScopes: [...step.fromScopes],
|
|
156
|
+
toScopes: [...step.toScopes],
|
|
157
|
+
evidence: [...step.evidence],
|
|
158
|
+
})),
|
|
159
|
+
confidence,
|
|
160
|
+
evidence: uniqueSorted(node.steps.flatMap(step => step.evidence)),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function comparePaths(left, right) {
|
|
164
|
+
return right.confidence - left.confidence
|
|
165
|
+
|| left.steps.length - right.steps.length
|
|
166
|
+
|| pathIdentity(left).localeCompare(pathIdentity(right));
|
|
167
|
+
}
|
|
168
|
+
function pathIdentity(path) {
|
|
169
|
+
return path.steps.map(step => step.name.toLowerCase()).join('>');
|
|
170
|
+
}
|
|
171
|
+
function emptyResult() {
|
|
172
|
+
return { paths: [], confidence: 0, evidence: [] };
|
|
173
|
+
}
|
package/dist/tools/symbols.js
CHANGED
|
@@ -244,6 +244,23 @@ async function queryDefinitionByNameWithHost(host, args) {
|
|
|
244
244
|
return (0, schema_1.toolDenied)('invalid_arguments', 'go_to_definition requires symbolName or a file position.');
|
|
245
245
|
const commandResult = await host.lsp.executeCommand('cwtools.ai.queryDefinitionByName', [symbolName], { timeoutMs: 10000 });
|
|
246
246
|
if (!isUnavailable(commandResult)) {
|
|
247
|
+
// The command reports a miss as `{ ok: false, error }`; returning that inside
|
|
248
|
+
// `ok: true` made "symbol not found" look like a successful definition lookup.
|
|
249
|
+
const record = commandResult && typeof commandResult === 'object' && !Array.isArray(commandResult)
|
|
250
|
+
? commandResult
|
|
251
|
+
: {};
|
|
252
|
+
if (record.ok === false) {
|
|
253
|
+
const message = typeof record.error === 'string' && record.error.trim()
|
|
254
|
+
? record.error
|
|
255
|
+
: `Symbol '${symbolName}' was not found.`;
|
|
256
|
+
return {
|
|
257
|
+
ok: false,
|
|
258
|
+
status: 'error',
|
|
259
|
+
source: 'cwtools-lsp-definition',
|
|
260
|
+
data: commandResult,
|
|
261
|
+
error: { code: 'definition_not_found', message },
|
|
262
|
+
};
|
|
263
|
+
}
|
|
247
264
|
return {
|
|
248
265
|
ok: true,
|
|
249
266
|
status: 'ready',
|
|
@@ -318,15 +335,18 @@ async function queryReferencesWithHost(host, args) {
|
|
|
318
335
|
}
|
|
319
336
|
}
|
|
320
337
|
const references = await textSearchReferences(host, identifier, args.file, limit);
|
|
338
|
+
// Lexical hits are partial evidence: they include comments and strings, so the
|
|
339
|
+
// result must not claim the readiness of semantic reference resolution.
|
|
321
340
|
return {
|
|
322
341
|
ok: true,
|
|
323
|
-
status: '
|
|
342
|
+
status: 'partial',
|
|
324
343
|
source: 'cwtools-text-references',
|
|
344
|
+
warnings: ['Fallback text references are lexical evidence, not semantic CWTools reference resolution.'],
|
|
325
345
|
data: {
|
|
326
346
|
identifier,
|
|
327
347
|
references,
|
|
328
348
|
total: references.length,
|
|
329
|
-
|
|
349
|
+
evidence: 'lexical',
|
|
330
350
|
},
|
|
331
351
|
};
|
|
332
352
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellaris 4.5.2 战斗索敌权重计算(纯计算,无副作用)。
|
|
3
|
+
*
|
|
4
|
+
* 实现 docs/stellaris-targeting-weight-4.5.2.md §2(舰船层乘法链 W1..W6 与整目标否决)
|
|
5
|
+
* 与 §3(武器层 p / ΣD 三层分摊 / S0..S + wk 加法项)的**归一化形式**:把引擎内部的
|
|
6
|
+
* 定点数 F = 100000 当作实数 1.0,除法按 C 风格向零截断的误差忽略不计。
|
|
7
|
+
*
|
|
8
|
+
* 两层互不相乘,各自 argmax(CShipTargeting::CalcBestTarget 与
|
|
9
|
+
* CWeaponComponentTargeting::CalcBestTarget);武器模板写 use_ship_main_target = yes 时
|
|
10
|
+
* 武器直接沿用舰船主目标,武器层分数不参与(误区 8)。
|
|
11
|
+
*
|
|
12
|
+
* 本模块刻意不 import vscode / fs / path,供后续 webview 面板(P3-1)直接复用。
|
|
13
|
+
*/
|
|
14
|
+
/** 索敌相关 define 的语义化视图,字段名对应 vanilla 00_defines.txt 里的 define。 */
|
|
15
|
+
export interface TargetingDefines {
|
|
16
|
+
/** COMBAT_SHIP_TARGETING_SIZE_MULT */
|
|
17
|
+
sizeSlope: number;
|
|
18
|
+
/** COMBAT_SHIP_TARGETING_SIZE_MAX */
|
|
19
|
+
sizeMax: number;
|
|
20
|
+
/** COMBAT_SHIP_TARGETING_TRACKING_MULT */
|
|
21
|
+
trackingMult: number;
|
|
22
|
+
/** COMBAT_SHIP_EVASION_TARGETING_WEIGHT */
|
|
23
|
+
evasionWeight: number;
|
|
24
|
+
/** COMBAT_SHIP_LOW_HEALTH_THRESHOLD */
|
|
25
|
+
lowHealthThreshold: number;
|
|
26
|
+
/** COMBAT_SHIP_LOW_HEALTH_TARGETING_WEIGHT */
|
|
27
|
+
lowHealthWeight: number;
|
|
28
|
+
/** COMBAT_SHIP_DISTANCE_TARGETING_WEIGHT */
|
|
29
|
+
distanceWeight: number;
|
|
30
|
+
/** COMBAT_SHIP_DISTANCE_TARGETING_WEIGHT_MIN */
|
|
31
|
+
distanceWeightMin: number;
|
|
32
|
+
/** COMBAT_SHIP_UNARMED_TARGETING_WEIGHT */
|
|
33
|
+
unarmedWeight: number;
|
|
34
|
+
/** COMBAT_SHIP_STARBASE_TARGETING_WEIGHT */
|
|
35
|
+
starbaseWeight: number;
|
|
36
|
+
/** COMBAT_SHIP_EVASION_AVOID_MIN_SHIP_SIZE */
|
|
37
|
+
avoidMinShipSize: number;
|
|
38
|
+
/** COMBAT_SHIP_EVASION_AVOID_THRESHOLD */
|
|
39
|
+
avoidThreshold: number;
|
|
40
|
+
/** RANDOM_TARGETING_WEIGHT */
|
|
41
|
+
randomWeight: number;
|
|
42
|
+
/** SHIP_CURRENT_TARGET_MULTIPLIER */
|
|
43
|
+
currentTargetMultiplier: number;
|
|
44
|
+
/** SHIP_RECENT_TARGET_PENALIZER */
|
|
45
|
+
recentTargetPenalizer: number;
|
|
46
|
+
}
|
|
47
|
+
/** vanilla 取值(Stellaris 4.5.2 common/defines/00_defines.txt, NCombat / NShip)。 */
|
|
48
|
+
export declare const VANILLA_TARGETING_DEFINES: TargetingDefines;
|
|
49
|
+
export interface TargetingAttackerInput {
|
|
50
|
+
/** 攻击方舰船追踪(0..1,引擎要求)。 */
|
|
51
|
+
tracking: number;
|
|
52
|
+
/** 攻击方 combat_size_multiplier。 */
|
|
53
|
+
sizeMultiplier: number;
|
|
54
|
+
}
|
|
55
|
+
export interface TargetingWeaponInput {
|
|
56
|
+
minDamage: number;
|
|
57
|
+
maxDamage: number;
|
|
58
|
+
/** accuracy(0..1)。 */
|
|
59
|
+
accuracy: number;
|
|
60
|
+
/** tracking(0..1),武器模板追踪率,不乘 κtrk。 */
|
|
61
|
+
tracking: number;
|
|
62
|
+
/** shield_damage (ms)。 */
|
|
63
|
+
shieldDamage: number;
|
|
64
|
+
/** armor_damage (ma)。 */
|
|
65
|
+
armorDamage: number;
|
|
66
|
+
/** hull_damage (mh)。 */
|
|
67
|
+
hullDamage: number;
|
|
68
|
+
shieldPenetration?: number;
|
|
69
|
+
armorPenetration?: number;
|
|
70
|
+
sizeDamageFactor?: number;
|
|
71
|
+
/** target_weights 表:键为 ship_size id,值为**加法项** wk。 */
|
|
72
|
+
targetWeights?: Record<string, number>;
|
|
73
|
+
}
|
|
74
|
+
export interface TargetingTargetInput {
|
|
75
|
+
/** ship_size id,用于查 weapon.targetWeights。 */
|
|
76
|
+
shipSizeId?: string;
|
|
77
|
+
/** 候选船 combat_size_multiplier (σ)。 */
|
|
78
|
+
sizeMultiplier: number;
|
|
79
|
+
/** 候选闪避 (ε),引擎上限 SHIP_MAX_EVASION = 0.9。 */
|
|
80
|
+
evasion: number;
|
|
81
|
+
/** 候选距离(引擎单位)。 */
|
|
82
|
+
distance: number;
|
|
83
|
+
/** 当前船体 (Vtgt),也是斩杀判据的右端。 */
|
|
84
|
+
hull: number;
|
|
85
|
+
/** 船体上限;缺省时不做残血判定。 */
|
|
86
|
+
maxHull?: number;
|
|
87
|
+
shield: number;
|
|
88
|
+
armor: number;
|
|
89
|
+
shieldHardening?: number;
|
|
90
|
+
armorHardening?: number;
|
|
91
|
+
/** 面板 DPD > 0(有能力还手);两层的无武装降权都用它。 */
|
|
92
|
+
armed: boolean;
|
|
93
|
+
isStarbase?: boolean;
|
|
94
|
+
isCurrentMainTarget?: boolean;
|
|
95
|
+
/** 在"最近目标记忆"中且非最新一项。 */
|
|
96
|
+
isRecentNonLatest?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface TargetingChainInput {
|
|
99
|
+
attacker: TargetingAttackerInput;
|
|
100
|
+
weapon: TargetingWeaponInput;
|
|
101
|
+
target: TargetingTargetInput;
|
|
102
|
+
/** 覆盖任意 define;未给出的项用 vanilla 值。 */
|
|
103
|
+
defines?: Partial<TargetingDefines>;
|
|
104
|
+
/** 开战随机量 ρ ∈ [0, 1),每场战斗每艘船各掷一次,整场不变。 */
|
|
105
|
+
rho?: number;
|
|
106
|
+
/** ship_target_weight_mult 修正值(如光环组件的 +0.5)。 */
|
|
107
|
+
targetWeightMultModifier?: number;
|
|
108
|
+
/** 随机扰动 r ∈ [0, 1),仅在 useRandom 为 true 时生效。 */
|
|
109
|
+
randomRoll?: number;
|
|
110
|
+
/** CalcBestTarget 的 useRandom;默认关闭以便复现确定性结果。 */
|
|
111
|
+
useRandom?: boolean;
|
|
112
|
+
/** 目标舰队里是否存在至少一艘"可命中"的船;否决判据的第四项。 */
|
|
113
|
+
fleetHasHittable?: boolean;
|
|
114
|
+
/** true = 武器组件 target_focus = spread(引擎 targetFocus = 1):Mcur 不施加。 */
|
|
115
|
+
targetFocus?: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface TargetingShipChain {
|
|
118
|
+
/** true = 整目标被剔除(return 0),不参与 argmax,不是"排最后"。 */
|
|
119
|
+
veto: boolean;
|
|
120
|
+
/** 否决判据逐项取值,便于诊断是哪一项没过。 */
|
|
121
|
+
vetoCheck: {
|
|
122
|
+
/** Δ = ε − τ > 0 */
|
|
123
|
+
evasionDeltaPositive: boolean;
|
|
124
|
+
/** σatt >= σavoidmin */
|
|
125
|
+
attackerSizeLargeEnough: boolean;
|
|
126
|
+
/** Δ >= Tavoid */
|
|
127
|
+
deltaAboveThreshold: boolean;
|
|
128
|
+
/** 目标舰队存在可命中目标 */
|
|
129
|
+
fleetHasHittable: boolean;
|
|
130
|
+
};
|
|
131
|
+
/** min(σ, σmax) */
|
|
132
|
+
sizeCapped: number;
|
|
133
|
+
W1: number;
|
|
134
|
+
/** τ = atrk · κtrk */
|
|
135
|
+
shipTracking: number;
|
|
136
|
+
/** Δ = ε − τ */
|
|
137
|
+
evasionDelta: number;
|
|
138
|
+
/** 1/(1 + Δ·κev);Δ <= 0 时为 1(无惩罚)。 */
|
|
139
|
+
evasionFactor: number;
|
|
140
|
+
W2: number;
|
|
141
|
+
distanceFactor: number;
|
|
142
|
+
W3: number;
|
|
143
|
+
/** ŵtgt = 1 + ρ + ship_target_weight_mult */
|
|
144
|
+
targetWeight: number;
|
|
145
|
+
W4: number;
|
|
146
|
+
lowHealthFactor: number;
|
|
147
|
+
unarmedFactor: number;
|
|
148
|
+
starbaseFactor: number;
|
|
149
|
+
W5: number;
|
|
150
|
+
randomFactor: number;
|
|
151
|
+
W6: number;
|
|
152
|
+
/** 舰船层最终权重 W(ship),被否决时为 0。 */
|
|
153
|
+
weight: number;
|
|
154
|
+
}
|
|
155
|
+
export interface TargetingWeaponLayer {
|
|
156
|
+
/** 命中率 p。 */
|
|
157
|
+
p: number;
|
|
158
|
+
/** 区间中点(索敌路径 useRandom = false)。 */
|
|
159
|
+
baseDamage: number;
|
|
160
|
+
damageSplit: {
|
|
161
|
+
/** 盾分量 ms·Cs */
|
|
162
|
+
Ds: number;
|
|
163
|
+
/** 甲分量 ma·Ca */
|
|
164
|
+
Da: number;
|
|
165
|
+
/** 船体分量 mh·剩余伤害;斩杀判据用的是它。 */
|
|
166
|
+
Dh: number;
|
|
167
|
+
};
|
|
168
|
+
/** ΣD = Ds + Da + Dh */
|
|
169
|
+
sumD: number;
|
|
170
|
+
S0: number;
|
|
171
|
+
/** 斩杀加成倍率(1.5 或 1)。 */
|
|
172
|
+
killBonus: number;
|
|
173
|
+
S1: number;
|
|
174
|
+
/** 无武装降权倍率(κun 或 1)。 */
|
|
175
|
+
unarmedPenalty: number;
|
|
176
|
+
S2: number;
|
|
177
|
+
/** target_weights 加法项;未命中为 0。 */
|
|
178
|
+
wk: number;
|
|
179
|
+
/** S = S2 + wk */
|
|
180
|
+
score: number;
|
|
181
|
+
/** 当前主目标粘性倍率(Mcur 或 1)。 */
|
|
182
|
+
currentTargetMultiplier: number;
|
|
183
|
+
/** 近期记忆惩罚倍率(Mrec 或 1)。 */
|
|
184
|
+
recentTargetPenalizer: number;
|
|
185
|
+
/** S(weapon) 最终比较值 = score × Mcur × Mrec。 */
|
|
186
|
+
final: number;
|
|
187
|
+
}
|
|
188
|
+
export interface TargetingChainResult {
|
|
189
|
+
veto: boolean;
|
|
190
|
+
shipChain: TargetingShipChain;
|
|
191
|
+
weapon: TargetingWeaponLayer;
|
|
192
|
+
/** 本次实际生效的 define 值(vanilla + 覆盖),便于核对"改了 define 会怎样"。 */
|
|
193
|
+
defines: TargetingDefines;
|
|
194
|
+
notes: string[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 计算单个候选目标的完整索敌权重链。纯函数:不读文件、不依赖 vscode。
|
|
198
|
+
*/
|
|
199
|
+
export declare function computeTargetingChain(input: TargetingChainInput): TargetingChainResult;
|
|
200
|
+
/** 工具调用入口:校验并收窄不可信的工具参数,失败时返回结构化错误而不是抛出。 */
|
|
201
|
+
export declare function executeTargetingWeightQuery(args: unknown): Record<string, unknown>;
|
|
202
|
+
/**
|
|
203
|
+
* 把工具参数(不可信输入)收窄为 TargetingChainInput。
|
|
204
|
+
* 未知字段一律忽略并按缺省处理;类型错误立即抛出带字段路径的消息。
|
|
205
|
+
*/
|
|
206
|
+
export declare function parseTargetingChainInput(args: unknown): TargetingChainInput;
|