windows-exe-decompiler-mcp-server 0.1.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/CODEX_INSTALLATION.md +69 -0
- package/COPILOT_INSTALLATION.md +77 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/bin/windows-exe-decompiler-mcp-server.js +3 -0
- package/dist/analysis-provenance.d.ts +184 -0
- package/dist/analysis-provenance.js +74 -0
- package/dist/analysis-task-runner.d.ts +31 -0
- package/dist/analysis-task-runner.js +160 -0
- package/dist/artifact-inventory.d.ts +23 -0
- package/dist/artifact-inventory.js +175 -0
- package/dist/cache-manager.d.ts +128 -0
- package/dist/cache-manager.js +454 -0
- package/dist/confidence-semantics.d.ts +66 -0
- package/dist/confidence-semantics.js +122 -0
- package/dist/config.d.ts +335 -0
- package/dist/config.js +193 -0
- package/dist/database.d.ts +227 -0
- package/dist/database.js +601 -0
- package/dist/decompiler-worker.d.ts +441 -0
- package/dist/decompiler-worker.js +1962 -0
- package/dist/dynamic-trace.d.ts +95 -0
- package/dist/dynamic-trace.js +629 -0
- package/dist/env-validator.d.ts +15 -0
- package/dist/env-validator.js +249 -0
- package/dist/error-handler.d.ts +28 -0
- package/dist/error-handler.example.d.ts +22 -0
- package/dist/error-handler.example.js +141 -0
- package/dist/error-handler.js +139 -0
- package/dist/ghidra-analysis-status.d.ts +49 -0
- package/dist/ghidra-analysis-status.js +178 -0
- package/dist/ghidra-config.d.ts +134 -0
- package/dist/ghidra-config.js +464 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +200 -0
- package/dist/job-queue.d.ts +169 -0
- package/dist/job-queue.js +407 -0
- package/dist/logger.d.ts +106 -0
- package/dist/logger.js +176 -0
- package/dist/policy-guard.d.ts +115 -0
- package/dist/policy-guard.js +243 -0
- package/dist/process-output.d.ts +15 -0
- package/dist/process-output.js +90 -0
- package/dist/prompts/function-explanation-review.d.ts +5 -0
- package/dist/prompts/function-explanation-review.js +64 -0
- package/dist/prompts/semantic-name-review.d.ts +5 -0
- package/dist/prompts/semantic-name-review.js +63 -0
- package/dist/runtime-correlation.d.ts +34 -0
- package/dist/runtime-correlation.js +279 -0
- package/dist/runtime-paths.d.ts +3 -0
- package/dist/runtime-paths.js +11 -0
- package/dist/selection-diff.d.ts +667 -0
- package/dist/selection-diff.js +53 -0
- package/dist/semantic-name-suggestion-artifacts.d.ts +116 -0
- package/dist/semantic-name-suggestion-artifacts.js +314 -0
- package/dist/server.d.ts +129 -0
- package/dist/server.js +578 -0
- package/dist/tools/artifact-read.d.ts +235 -0
- package/dist/tools/artifact-read.js +317 -0
- package/dist/tools/artifacts-diff.d.ts +728 -0
- package/dist/tools/artifacts-diff.js +304 -0
- package/dist/tools/artifacts-list.d.ts +515 -0
- package/dist/tools/artifacts-list.js +389 -0
- package/dist/tools/attack-map.d.ts +290 -0
- package/dist/tools/attack-map.js +519 -0
- package/dist/tools/cache-observability.d.ts +4 -0
- package/dist/tools/cache-observability.js +36 -0
- package/dist/tools/code-function-cfg.d.ts +50 -0
- package/dist/tools/code-function-cfg.js +102 -0
- package/dist/tools/code-function-decompile.d.ts +55 -0
- package/dist/tools/code-function-decompile.js +103 -0
- package/dist/tools/code-function-disassemble.d.ts +43 -0
- package/dist/tools/code-function-disassemble.js +185 -0
- package/dist/tools/code-function-explain-apply.d.ts +255 -0
- package/dist/tools/code-function-explain-apply.js +225 -0
- package/dist/tools/code-function-explain-prepare.d.ts +535 -0
- package/dist/tools/code-function-explain-prepare.js +276 -0
- package/dist/tools/code-function-explain-review.d.ts +397 -0
- package/dist/tools/code-function-explain-review.js +589 -0
- package/dist/tools/code-function-rename-apply.d.ts +248 -0
- package/dist/tools/code-function-rename-apply.js +220 -0
- package/dist/tools/code-function-rename-prepare.d.ts +506 -0
- package/dist/tools/code-function-rename-prepare.js +279 -0
- package/dist/tools/code-function-rename-review.d.ts +574 -0
- package/dist/tools/code-function-rename-review.js +761 -0
- package/dist/tools/code-functions-list.d.ts +37 -0
- package/dist/tools/code-functions-list.js +91 -0
- package/dist/tools/code-functions-rank.d.ts +34 -0
- package/dist/tools/code-functions-rank.js +90 -0
- package/dist/tools/code-functions-reconstruct.d.ts +2725 -0
- package/dist/tools/code-functions-reconstruct.js +2807 -0
- package/dist/tools/code-functions-search.d.ts +39 -0
- package/dist/tools/code-functions-search.js +90 -0
- package/dist/tools/code-reconstruct-export.d.ts +1212 -0
- package/dist/tools/code-reconstruct-export.js +4002 -0
- package/dist/tools/code-reconstruct-plan.d.ts +274 -0
- package/dist/tools/code-reconstruct-plan.js +342 -0
- package/dist/tools/dotnet-metadata-extract.d.ts +541 -0
- package/dist/tools/dotnet-metadata-extract.js +355 -0
- package/dist/tools/dotnet-reconstruct-export.d.ts +567 -0
- package/dist/tools/dotnet-reconstruct-export.js +1151 -0
- package/dist/tools/dotnet-types-list.d.ts +325 -0
- package/dist/tools/dotnet-types-list.js +201 -0
- package/dist/tools/dynamic-dependencies.d.ts +115 -0
- package/dist/tools/dynamic-dependencies.js +213 -0
- package/dist/tools/dynamic-memory-import.d.ts +10 -0
- package/dist/tools/dynamic-memory-import.js +567 -0
- package/dist/tools/dynamic-trace-import.d.ts +10 -0
- package/dist/tools/dynamic-trace-import.js +235 -0
- package/dist/tools/entrypoint-fallback-disasm.d.ts +30 -0
- package/dist/tools/entrypoint-fallback-disasm.js +89 -0
- package/dist/tools/ghidra-analyze.d.ts +88 -0
- package/dist/tools/ghidra-analyze.js +208 -0
- package/dist/tools/ghidra-health.d.ts +37 -0
- package/dist/tools/ghidra-health.js +212 -0
- package/dist/tools/ioc-export.d.ts +209 -0
- package/dist/tools/ioc-export.js +542 -0
- package/dist/tools/packer-detect.d.ts +165 -0
- package/dist/tools/packer-detect.js +284 -0
- package/dist/tools/pe-exports-extract.d.ts +175 -0
- package/dist/tools/pe-exports-extract.js +253 -0
- package/dist/tools/pe-fingerprint.d.ts +234 -0
- package/dist/tools/pe-fingerprint.js +269 -0
- package/dist/tools/pe-imports-extract.d.ts +105 -0
- package/dist/tools/pe-imports-extract.js +245 -0
- package/dist/tools/report-generate.d.ts +157 -0
- package/dist/tools/report-generate.js +457 -0
- package/dist/tools/report-summarize.d.ts +2131 -0
- package/dist/tools/report-summarize.js +596 -0
- package/dist/tools/runtime-detect.d.ts +135 -0
- package/dist/tools/runtime-detect.js +247 -0
- package/dist/tools/sample-ingest.d.ts +94 -0
- package/dist/tools/sample-ingest.js +327 -0
- package/dist/tools/sample-profile-get.d.ts +183 -0
- package/dist/tools/sample-profile-get.js +121 -0
- package/dist/tools/sandbox-execute.d.ts +441 -0
- package/dist/tools/sandbox-execute.js +392 -0
- package/dist/tools/strings-extract.d.ts +375 -0
- package/dist/tools/strings-extract.js +314 -0
- package/dist/tools/strings-floss-decode.d.ts +143 -0
- package/dist/tools/strings-floss-decode.js +259 -0
- package/dist/tools/system-health.d.ts +434 -0
- package/dist/tools/system-health.js +446 -0
- package/dist/tools/task-cancel.d.ts +21 -0
- package/dist/tools/task-cancel.js +70 -0
- package/dist/tools/task-status.d.ts +27 -0
- package/dist/tools/task-status.js +106 -0
- package/dist/tools/task-sweep.d.ts +22 -0
- package/dist/tools/task-sweep.js +77 -0
- package/dist/tools/tool-help.d.ts +340 -0
- package/dist/tools/tool-help.js +261 -0
- package/dist/tools/yara-scan.d.ts +554 -0
- package/dist/tools/yara-scan.js +313 -0
- package/dist/types.d.ts +266 -0
- package/dist/types.js +41 -0
- package/dist/worker-pool.d.ts +204 -0
- package/dist/worker-pool.js +650 -0
- package/dist/workflows/deep-static.d.ts +104 -0
- package/dist/workflows/deep-static.js +276 -0
- package/dist/workflows/function-explanation-review.d.ts +655 -0
- package/dist/workflows/function-explanation-review.js +440 -0
- package/dist/workflows/reconstruct.d.ts +2053 -0
- package/dist/workflows/reconstruct.js +666 -0
- package/dist/workflows/semantic-name-review.d.ts +2418 -0
- package/dist/workflows/semantic-name-review.js +521 -0
- package/dist/workflows/triage.d.ts +659 -0
- package/dist/workflows/triage.js +1374 -0
- package/dist/workspace-manager.d.ts +150 -0
- package/dist/workspace-manager.js +411 -0
- package/ghidra_scripts/DecompileFunction.java +487 -0
- package/ghidra_scripts/DecompileFunction.py +150 -0
- package/ghidra_scripts/ExtractCFG.java +256 -0
- package/ghidra_scripts/ExtractCFG.py +233 -0
- package/ghidra_scripts/ExtractFunctions.java +442 -0
- package/ghidra_scripts/ExtractFunctions.py +101 -0
- package/ghidra_scripts/README.md +125 -0
- package/ghidra_scripts/SearchFunctionReferences.java +380 -0
- package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -0
- package/helpers/DotNetMetadataProbe/Program.cs +566 -0
- package/install-to-codex.ps1 +178 -0
- package/install-to-copilot.ps1 +303 -0
- package/package.json +101 -0
- package/requirements.txt +9 -0
- package/workers/requirements-dynamic.txt +11 -0
- package/workers/requirements.txt +8 -0
- package/workers/speakeasy_compat.py +175 -0
- package/workers/static_worker.py +5183 -0
- package/workers/yara_rules/default.yar +33 -0
- package/workers/yara_rules/malware_families.yar +93 -0
- package/workers/yara_rules/packers.yar +80 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCodeFunctionsReconstructHandler } from './code-functions-reconstruct.js';
|
|
3
|
+
import { persistSemanticNamePrepareBundleArtifact, SEMANTIC_NAME_PREPARE_BUNDLE_ARTIFACT_TYPE, } from '../semantic-name-suggestion-artifacts.js';
|
|
4
|
+
import { buildSemanticNameReviewPromptText } from '../prompts/semantic-name-review.js';
|
|
5
|
+
const TOOL_NAME = 'code.function.rename.prepare';
|
|
6
|
+
const PreparedFunctionSchema = z.object({
|
|
7
|
+
function: z.string(),
|
|
8
|
+
address: z.string(),
|
|
9
|
+
confidence: z.number().min(0).max(1),
|
|
10
|
+
suggested_name: z.string().nullable().optional(),
|
|
11
|
+
name_resolution: z.any().optional(),
|
|
12
|
+
semantic_evidence: z.any().optional(),
|
|
13
|
+
suggestion_required: z.boolean(),
|
|
14
|
+
});
|
|
15
|
+
const PreparedBundleSchema = z.object({
|
|
16
|
+
schema_version: z.literal(1),
|
|
17
|
+
sample_id: z.string(),
|
|
18
|
+
analysis_goal: z.string(),
|
|
19
|
+
generated_at: z.string(),
|
|
20
|
+
selection: z.object({
|
|
21
|
+
address: z.string().nullable(),
|
|
22
|
+
symbol: z.string().nullable(),
|
|
23
|
+
topk: z.number().int().positive(),
|
|
24
|
+
include_resolved: z.boolean(),
|
|
25
|
+
max_functions: z.number().int().positive(),
|
|
26
|
+
evidence_scope: z.enum(['all', 'latest', 'session']),
|
|
27
|
+
evidence_session_tag: z.string().nullable(),
|
|
28
|
+
semantic_scope: z.enum(['all', 'latest', 'session']),
|
|
29
|
+
semantic_session_tag: z.string().nullable(),
|
|
30
|
+
}),
|
|
31
|
+
suggestion_contract: z.object({
|
|
32
|
+
output_root: z.literal('suggestions'),
|
|
33
|
+
required_fields: z.array(z.string()),
|
|
34
|
+
}),
|
|
35
|
+
functions: z.array(PreparedFunctionSchema),
|
|
36
|
+
});
|
|
37
|
+
export const codeFunctionRenamePrepareInputSchema = z.object({
|
|
38
|
+
sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
|
|
39
|
+
address: z.string().optional().describe('Optional specific function address'),
|
|
40
|
+
symbol: z.string().optional().describe('Optional specific function symbol'),
|
|
41
|
+
topk: z
|
|
42
|
+
.number()
|
|
43
|
+
.int()
|
|
44
|
+
.min(1)
|
|
45
|
+
.max(20)
|
|
46
|
+
.default(6)
|
|
47
|
+
.describe('When address/symbol not provided, prepare up to top-K reconstructed functions'),
|
|
48
|
+
max_functions: z
|
|
49
|
+
.number()
|
|
50
|
+
.int()
|
|
51
|
+
.min(1)
|
|
52
|
+
.max(20)
|
|
53
|
+
.default(6)
|
|
54
|
+
.describe('Maximum number of functions included in the prepared bundle'),
|
|
55
|
+
include_resolved: z
|
|
56
|
+
.boolean()
|
|
57
|
+
.default(false)
|
|
58
|
+
.describe('Include functions that already have validated rule-based names'),
|
|
59
|
+
analysis_goal: z
|
|
60
|
+
.string()
|
|
61
|
+
.min(1)
|
|
62
|
+
.max(400)
|
|
63
|
+
.default('Reverse-engineer the prepared functions and propose precise human-readable semantic names.')
|
|
64
|
+
.describe('Human-readable analysis goal injected into the task prompt for any external LLM'),
|
|
65
|
+
persist_artifact: z
|
|
66
|
+
.boolean()
|
|
67
|
+
.default(true)
|
|
68
|
+
.describe('Persist the prepared evidence bundle as a JSON artifact for later review and provenance'),
|
|
69
|
+
session_tag: z
|
|
70
|
+
.string()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('Optional semantic naming session tag used for artifact grouping'),
|
|
73
|
+
evidence_scope: z
|
|
74
|
+
.enum(['all', 'latest', 'session'])
|
|
75
|
+
.default('all')
|
|
76
|
+
.describe('Runtime evidence scope forwarded to code.functions.reconstruct for semantic review preparation'),
|
|
77
|
+
evidence_session_tag: z
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Optional runtime evidence session selector used when evidence_scope=session or to narrow all/latest results'),
|
|
81
|
+
semantic_scope: z
|
|
82
|
+
.enum(['all', 'latest', 'session'])
|
|
83
|
+
.default('all')
|
|
84
|
+
.describe('Semantic naming artifact scope forwarded to code.functions.reconstruct for review preparation'),
|
|
85
|
+
semantic_session_tag: z
|
|
86
|
+
.string()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe('Optional semantic naming session selector used when semantic_scope=session or to narrow all/latest results'),
|
|
89
|
+
})
|
|
90
|
+
.refine((value) => value.evidence_scope !== 'session' || Boolean(value.evidence_session_tag?.trim()), {
|
|
91
|
+
message: 'evidence_session_tag is required when evidence_scope=session',
|
|
92
|
+
path: ['evidence_session_tag'],
|
|
93
|
+
})
|
|
94
|
+
.refine((value) => value.semantic_scope !== 'session' || Boolean(value.semantic_session_tag?.trim()), {
|
|
95
|
+
message: 'semantic_session_tag is required when semantic_scope=session',
|
|
96
|
+
path: ['semantic_session_tag'],
|
|
97
|
+
});
|
|
98
|
+
export const codeFunctionRenamePrepareOutputSchema = z.object({
|
|
99
|
+
ok: z.boolean(),
|
|
100
|
+
data: z
|
|
101
|
+
.object({
|
|
102
|
+
sample_id: z.string(),
|
|
103
|
+
analysis_goal: z.string(),
|
|
104
|
+
prepared_count: z.number().int().nonnegative(),
|
|
105
|
+
unresolved_count: z.number().int().nonnegative(),
|
|
106
|
+
prompt_name: z.literal('reverse.semantic_name_review'),
|
|
107
|
+
prompt_arguments: z.object({
|
|
108
|
+
analysis_goal: z.string(),
|
|
109
|
+
prepared_bundle_json: z.string(),
|
|
110
|
+
}),
|
|
111
|
+
task_prompt: z.string(),
|
|
112
|
+
prepared_bundle: PreparedBundleSchema,
|
|
113
|
+
artifact: z
|
|
114
|
+
.object({
|
|
115
|
+
id: z.string(),
|
|
116
|
+
type: z.literal(SEMANTIC_NAME_PREPARE_BUNDLE_ARTIFACT_TYPE),
|
|
117
|
+
path: z.string(),
|
|
118
|
+
sha256: z.string(),
|
|
119
|
+
mime: z.string().optional(),
|
|
120
|
+
})
|
|
121
|
+
.optional(),
|
|
122
|
+
})
|
|
123
|
+
.optional(),
|
|
124
|
+
warnings: z.array(z.string()).optional(),
|
|
125
|
+
errors: z.array(z.string()).optional(),
|
|
126
|
+
artifacts: z.array(z.any()).optional(),
|
|
127
|
+
metrics: z
|
|
128
|
+
.object({
|
|
129
|
+
elapsed_ms: z.number(),
|
|
130
|
+
tool: z.string(),
|
|
131
|
+
})
|
|
132
|
+
.optional(),
|
|
133
|
+
});
|
|
134
|
+
export const codeFunctionRenamePrepareToolDefinition = {
|
|
135
|
+
name: TOOL_NAME,
|
|
136
|
+
description: 'Prepare structured semantic-evidence bundles and a model-agnostic MCP prompt contract for external LLM function renaming review.',
|
|
137
|
+
inputSchema: codeFunctionRenamePrepareInputSchema,
|
|
138
|
+
outputSchema: codeFunctionRenamePrepareOutputSchema,
|
|
139
|
+
};
|
|
140
|
+
function shouldIncludePreparedFunction(func, includeResolved) {
|
|
141
|
+
if (includeResolved) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return !func?.name_resolution?.validated_name;
|
|
145
|
+
}
|
|
146
|
+
function dedupePreparedFunctions(functions) {
|
|
147
|
+
const seen = new Set();
|
|
148
|
+
const deduped = [];
|
|
149
|
+
for (const item of functions) {
|
|
150
|
+
const key = `${String(item?.address || 'unknown').toLowerCase()}::${String(item?.function || 'unknown').toLowerCase()}`;
|
|
151
|
+
if (seen.has(key)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
seen.add(key);
|
|
155
|
+
deduped.push(item);
|
|
156
|
+
}
|
|
157
|
+
return deduped;
|
|
158
|
+
}
|
|
159
|
+
export function createCodeFunctionRenamePrepareHandler(workspaceManager, database, cacheManager, dependencies) {
|
|
160
|
+
const reconstructHandler = dependencies?.reconstructHandler ||
|
|
161
|
+
createCodeFunctionsReconstructHandler(workspaceManager, database, cacheManager);
|
|
162
|
+
return async (args) => {
|
|
163
|
+
const startTime = Date.now();
|
|
164
|
+
try {
|
|
165
|
+
const input = codeFunctionRenamePrepareInputSchema.parse(args);
|
|
166
|
+
const reconstructResult = await reconstructHandler({
|
|
167
|
+
sample_id: input.sample_id,
|
|
168
|
+
address: input.address,
|
|
169
|
+
symbol: input.symbol,
|
|
170
|
+
topk: input.topk,
|
|
171
|
+
include_xrefs: true,
|
|
172
|
+
max_pseudocode_lines: 80,
|
|
173
|
+
max_assembly_lines: 60,
|
|
174
|
+
timeout: 45,
|
|
175
|
+
evidence_scope: input.evidence_scope,
|
|
176
|
+
evidence_session_tag: input.evidence_session_tag,
|
|
177
|
+
semantic_scope: input.semantic_scope,
|
|
178
|
+
semantic_session_tag: input.semantic_session_tag,
|
|
179
|
+
});
|
|
180
|
+
if (!reconstructResult.ok) {
|
|
181
|
+
return {
|
|
182
|
+
ok: false,
|
|
183
|
+
errors: reconstructResult.errors || ['code.functions.reconstruct failed'],
|
|
184
|
+
warnings: reconstructResult.warnings,
|
|
185
|
+
metrics: {
|
|
186
|
+
elapsed_ms: Date.now() - startTime,
|
|
187
|
+
tool: TOOL_NAME,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const functions = dedupePreparedFunctions((reconstructResult.data?.functions || []).filter((item) => shouldIncludePreparedFunction(item, input.include_resolved)))
|
|
192
|
+
.slice(0, input.max_functions)
|
|
193
|
+
.map((item) => ({
|
|
194
|
+
function: item.function,
|
|
195
|
+
address: item.address,
|
|
196
|
+
confidence: item.confidence,
|
|
197
|
+
suggested_name: item.suggested_name || null,
|
|
198
|
+
name_resolution: item.name_resolution,
|
|
199
|
+
semantic_evidence: item.semantic_evidence,
|
|
200
|
+
suggestion_required: !item?.name_resolution?.validated_name,
|
|
201
|
+
}));
|
|
202
|
+
const preparedBundle = {
|
|
203
|
+
schema_version: 1,
|
|
204
|
+
sample_id: input.sample_id,
|
|
205
|
+
analysis_goal: input.analysis_goal,
|
|
206
|
+
generated_at: new Date().toISOString(),
|
|
207
|
+
selection: {
|
|
208
|
+
address: input.address || null,
|
|
209
|
+
symbol: input.symbol || null,
|
|
210
|
+
topk: input.topk,
|
|
211
|
+
include_resolved: input.include_resolved,
|
|
212
|
+
max_functions: input.max_functions,
|
|
213
|
+
evidence_scope: input.evidence_scope,
|
|
214
|
+
evidence_session_tag: input.evidence_session_tag || null,
|
|
215
|
+
semantic_scope: input.semantic_scope,
|
|
216
|
+
semantic_session_tag: input.semantic_session_tag || null,
|
|
217
|
+
},
|
|
218
|
+
suggestion_contract: {
|
|
219
|
+
output_root: 'suggestions',
|
|
220
|
+
required_fields: [
|
|
221
|
+
'address_or_function',
|
|
222
|
+
'candidate_name',
|
|
223
|
+
'confidence',
|
|
224
|
+
'why',
|
|
225
|
+
'required_assumptions',
|
|
226
|
+
'evidence_used',
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
functions,
|
|
230
|
+
};
|
|
231
|
+
const preparedBundleJson = JSON.stringify(preparedBundle, null, 2);
|
|
232
|
+
const taskPrompt = buildSemanticNameReviewPromptText(preparedBundleJson, input.analysis_goal);
|
|
233
|
+
const warnings = [...(reconstructResult.warnings || [])];
|
|
234
|
+
const artifacts = [];
|
|
235
|
+
let artifact;
|
|
236
|
+
if (functions.length === 0) {
|
|
237
|
+
warnings.push('No functions matched the preparation filter. Consider include_resolved=true or a larger topk.');
|
|
238
|
+
}
|
|
239
|
+
if (input.persist_artifact) {
|
|
240
|
+
artifact = await persistSemanticNamePrepareBundleArtifact(workspaceManager, database, input.sample_id, preparedBundle, input.session_tag);
|
|
241
|
+
artifacts.push(artifact);
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
ok: true,
|
|
245
|
+
data: {
|
|
246
|
+
sample_id: input.sample_id,
|
|
247
|
+
analysis_goal: input.analysis_goal,
|
|
248
|
+
prepared_count: functions.length,
|
|
249
|
+
unresolved_count: functions.filter((item) => item.suggestion_required).length,
|
|
250
|
+
prompt_name: 'reverse.semantic_name_review',
|
|
251
|
+
prompt_arguments: {
|
|
252
|
+
analysis_goal: input.analysis_goal,
|
|
253
|
+
prepared_bundle_json: preparedBundleJson,
|
|
254
|
+
},
|
|
255
|
+
task_prompt: taskPrompt,
|
|
256
|
+
prepared_bundle: preparedBundle,
|
|
257
|
+
artifact,
|
|
258
|
+
},
|
|
259
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
260
|
+
artifacts: artifacts.length > 0 ? artifacts : undefined,
|
|
261
|
+
metrics: {
|
|
262
|
+
elapsed_ms: Date.now() - startTime,
|
|
263
|
+
tool: TOOL_NAME,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
return {
|
|
269
|
+
ok: false,
|
|
270
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
271
|
+
metrics: {
|
|
272
|
+
elapsed_ms: Date.now() - startTime,
|
|
273
|
+
tool: TOOL_NAME,
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=code-function-rename-prepare.js.map
|