windows-exe-decompiler-mcp-server 0.1.0 → 0.1.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/CLAUDE_INSTALLATION.md +129 -0
- package/CODEX_INSTALLATION.md +25 -1
- package/COPILOT_INSTALLATION.md +29 -1
- package/LICENSE +21 -21
- package/README.md +232 -110
- package/dist/analysis-provenance.d.ts +50 -2
- package/dist/analysis-provenance.js +1 -0
- package/dist/analysis-task-runner.js +92 -0
- package/dist/config.d.ts +35 -16
- package/dist/config.js +37 -3
- package/dist/database.js +115 -115
- package/dist/decompiler-worker.d.ts +10 -5
- package/dist/decompiler-worker.js +240 -58
- package/dist/dynamic-trace.d.ts +6 -0
- package/dist/dynamic-trace.js +52 -1
- package/dist/ghidra-config.js +17 -1
- package/dist/index.js +38 -8
- package/dist/pe-runtime-functions.d.ts +90 -0
- package/dist/pe-runtime-functions.js +452 -0
- package/dist/prompts/module-reconstruction-review.d.ts +5 -0
- package/dist/prompts/module-reconstruction-review.js +65 -0
- package/dist/runtime-correlation.d.ts +5 -0
- package/dist/runtime-correlation.js +179 -2
- package/dist/sample-workspace.d.ts +28 -0
- package/dist/sample-workspace.js +186 -0
- package/dist/semantic-name-suggestion-artifacts.d.ts +56 -0
- package/dist/semantic-name-suggestion-artifacts.js +87 -0
- package/dist/server.js +1 -1
- package/dist/setup-guidance.d.ts +73 -0
- package/dist/setup-guidance.js +211 -0
- package/dist/tools/artifact-read.d.ts +10 -10
- package/dist/tools/artifacts-diff.d.ts +8 -8
- package/dist/tools/artifacts-list.d.ts +16 -16
- package/dist/tools/attack-map.d.ts +8 -8
- package/dist/tools/binary-role-profile.d.ts +1197 -0
- package/dist/tools/binary-role-profile.js +575 -0
- package/dist/tools/code-function-explain-apply.d.ts +12 -12
- package/dist/tools/code-function-explain-prepare.d.ts +12 -12
- package/dist/tools/code-function-explain-review.d.ts +58 -58
- package/dist/tools/code-function-rename-apply.d.ts +12 -12
- package/dist/tools/code-function-rename-prepare.d.ts +14 -14
- package/dist/tools/code-function-rename-review.d.ts +66 -66
- package/dist/tools/code-functions-define.d.ts +337 -0
- package/dist/tools/code-functions-define.js +337 -0
- package/dist/tools/code-functions-list.js +1 -1
- package/dist/tools/code-functions-rank.js +1 -1
- package/dist/tools/code-functions-reconstruct.d.ts +368 -58
- package/dist/tools/code-functions-reconstruct.js +130 -10
- package/dist/tools/code-functions-smart-recover.d.ts +352 -0
- package/dist/tools/code-functions-smart-recover.js +190 -0
- package/dist/tools/code-module-review-apply.d.ts +233 -0
- package/dist/tools/code-module-review-apply.js +209 -0
- package/dist/tools/code-module-review-prepare.d.ts +756 -0
- package/dist/tools/code-module-review-prepare.js +343 -0
- package/dist/tools/code-module-review.d.ts +474 -0
- package/dist/tools/code-module-review.js +566 -0
- package/dist/tools/code-reconstruct-export.d.ts +193 -21
- package/dist/tools/code-reconstruct-export.js +578 -21
- package/dist/tools/code-reconstruct-plan.d.ts +20 -20
- package/dist/tools/com-role-profile.d.ts +353 -0
- package/dist/tools/com-role-profile.js +186 -0
- package/dist/tools/dll-export-profile.d.ts +625 -0
- package/dist/tools/dll-export-profile.js +230 -0
- package/dist/tools/dotnet-metadata-extract.d.ts +122 -122
- package/dist/tools/dotnet-reconstruct-export.d.ts +49 -49
- package/dist/tools/dotnet-types-list.d.ts +66 -66
- package/dist/tools/dynamic-dependencies.d.ts +144 -8
- package/dist/tools/dynamic-dependencies.js +20 -1
- package/dist/tools/dynamic-memory-import.js +105 -2
- package/dist/tools/ghidra-analyze.d.ts +20 -0
- package/dist/tools/ghidra-analyze.js +10 -2
- package/dist/tools/ghidra-health.d.ts +177 -0
- package/dist/tools/ghidra-health.js +28 -0
- package/dist/tools/ioc-export.d.ts +8 -8
- package/dist/tools/packer-detect.d.ts +14 -14
- package/dist/tools/packer-detect.js +6 -9
- package/dist/tools/pe-exports-extract.d.ts +8 -8
- package/dist/tools/pe-exports-extract.js +6 -9
- package/dist/tools/pe-fingerprint.d.ts +36 -36
- package/dist/tools/pe-imports-extract.d.ts +8 -8
- package/dist/tools/pe-imports-extract.js +6 -9
- package/dist/tools/pe-pdata-extract.d.ts +448 -0
- package/dist/tools/pe-pdata-extract.js +219 -0
- package/dist/tools/pe-symbols-recover.d.ts +227 -0
- package/dist/tools/pe-symbols-recover.js +316 -0
- package/dist/tools/report-generate.d.ts +15 -1
- package/dist/tools/report-generate.js +139 -16
- package/dist/tools/report-summarize.d.ts +2242 -8
- package/dist/tools/report-summarize.js +246 -10
- package/dist/tools/runtime-detect.d.ts +8 -8
- package/dist/tools/runtime-detect.js +2 -12
- package/dist/tools/rust-binary-analyze.d.ts +2047 -0
- package/dist/tools/rust-binary-analyze.js +443 -0
- package/dist/tools/sample-profile-get.d.ts +135 -16
- package/dist/tools/sample-profile-get.js +35 -32
- package/dist/tools/sandbox-execute.d.ts +10 -10
- package/dist/tools/strings-extract.d.ts +8 -8
- package/dist/tools/strings-extract.js +2 -12
- package/dist/tools/strings-floss-decode.d.ts +8 -8
- package/dist/tools/system-health.d.ts +172 -36
- package/dist/tools/system-health.js +14 -0
- package/dist/tools/system-setup-guide.d.ts +179 -0
- package/dist/tools/system-setup-guide.js +62 -0
- package/dist/tools/tool-help.d.ts +16 -16
- package/dist/tools/tool-help.js +172 -0
- package/dist/tools/yara-scan.d.ts +8 -8
- package/dist/types.d.ts +2 -0
- package/dist/workflows/function-explanation-review.d.ts +3034 -76
- package/dist/workflows/function-explanation-review.js +172 -42
- package/dist/workflows/function-index-recover.d.ts +333 -0
- package/dist/workflows/function-index-recover.js +291 -0
- package/dist/workflows/module-reconstruction-review.d.ts +3537 -0
- package/dist/workflows/module-reconstruction-review.js +354 -0
- package/dist/workflows/reconstruct.d.ts +2182 -223
- package/dist/workflows/reconstruct.js +575 -32
- package/dist/workflows/semantic-name-review.d.ts +1436 -85
- package/dist/workflows/semantic-name-review.js +150 -58
- package/dist/workflows/triage.d.ts +8 -8
- package/ghidra_scripts/DecompileFunction.java +487 -487
- package/ghidra_scripts/ExtractCFG.java +256 -256
- package/ghidra_scripts/ExtractFunctions.java +442 -442
- package/ghidra_scripts/README.md +112 -112
- package/ghidra_scripts/SearchFunctionReferences.java +380 -380
- package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -9
- package/helpers/DotNetMetadataProbe/Program.cs +566 -566
- package/install-to-claude.ps1 +432 -0
- package/install-to-codex.ps1 +256 -178
- package/install-to-copilot.ps1 +389 -303
- package/package.json +4 -2
- package/requirements.txt +9 -9
- package/workers/requirements-dynamic.txt +11 -11
- package/workers/requirements.txt +8 -8
- package/workers/speakeasy_compat.py +175 -175
- package/workers/static_worker.py +3474 -3474
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCodeReconstructExportHandler } from './code-reconstruct-export.js';
|
|
3
|
+
import { persistSemanticModuleReviewPrepareBundleArtifact, SEMANTIC_MODULE_REVIEW_PREPARE_BUNDLE_ARTIFACT_TYPE, } from '../semantic-name-suggestion-artifacts.js';
|
|
4
|
+
import { buildModuleReconstructionReviewPromptText } from '../prompts/module-reconstruction-review.js';
|
|
5
|
+
const TOOL_NAME = 'code.module.review.prepare';
|
|
6
|
+
const PreparedModuleFunctionSchema = z.object({
|
|
7
|
+
function: z.string(),
|
|
8
|
+
address: z.string(),
|
|
9
|
+
confidence: z.number().min(0).max(1),
|
|
10
|
+
validated_name: z.string().nullable().optional(),
|
|
11
|
+
resolution_source: z.string().nullable().optional(),
|
|
12
|
+
explanation_summary: z.string().nullable().optional(),
|
|
13
|
+
explanation_behavior: z.string().nullable().optional(),
|
|
14
|
+
explanation_confidence: z.number().min(0).max(1).nullable().optional(),
|
|
15
|
+
});
|
|
16
|
+
const PreparedModuleSchema = z.object({
|
|
17
|
+
module_name: z.string(),
|
|
18
|
+
role_hint: z.string().nullable().optional(),
|
|
19
|
+
focus_matches: z.array(z.string()).optional(),
|
|
20
|
+
confidence: z.number().min(0).max(1),
|
|
21
|
+
function_count: z.number().int().nonnegative(),
|
|
22
|
+
import_hints: z.array(z.string()),
|
|
23
|
+
string_hints: z.array(z.string()),
|
|
24
|
+
runtime_apis: z.array(z.string()),
|
|
25
|
+
runtime_stages: z.array(z.string()),
|
|
26
|
+
functions: z.array(PreparedModuleFunctionSchema),
|
|
27
|
+
rewrite_path: z.string(),
|
|
28
|
+
pseudocode_path: z.string(),
|
|
29
|
+
interface_path: z.string(),
|
|
30
|
+
});
|
|
31
|
+
const PreparedModuleReviewBundleSchema = z.object({
|
|
32
|
+
schema_version: z.literal(1),
|
|
33
|
+
sample_id: z.string(),
|
|
34
|
+
analysis_goal: z.string(),
|
|
35
|
+
generated_at: z.string(),
|
|
36
|
+
selection: z.object({
|
|
37
|
+
topk: z.number().int().positive(),
|
|
38
|
+
module_limit: z.number().int().positive(),
|
|
39
|
+
min_module_size: z.number().int().positive(),
|
|
40
|
+
include_imports: z.boolean(),
|
|
41
|
+
include_strings: z.boolean(),
|
|
42
|
+
evidence_scope: z.enum(['all', 'latest', 'session']),
|
|
43
|
+
evidence_session_tag: z.string().nullable(),
|
|
44
|
+
semantic_scope: z.enum(['all', 'latest', 'session']),
|
|
45
|
+
semantic_session_tag: z.string().nullable(),
|
|
46
|
+
role_target: z.string().nullable(),
|
|
47
|
+
role_focus_areas: z.array(z.string()),
|
|
48
|
+
role_priority_order: z.array(z.string()),
|
|
49
|
+
}),
|
|
50
|
+
output_contract: z.object({
|
|
51
|
+
output_root: z.literal('reviews'),
|
|
52
|
+
required_fields: z.array(z.string()),
|
|
53
|
+
}),
|
|
54
|
+
binary_profile: z.any().nullable(),
|
|
55
|
+
runtime_evidence: z.any().nullable(),
|
|
56
|
+
provenance: z.any().optional(),
|
|
57
|
+
modules: z.array(PreparedModuleSchema),
|
|
58
|
+
});
|
|
59
|
+
export const codeModuleReviewPrepareInputSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
|
|
62
|
+
topk: z
|
|
63
|
+
.number()
|
|
64
|
+
.int()
|
|
65
|
+
.min(1)
|
|
66
|
+
.max(40)
|
|
67
|
+
.default(12)
|
|
68
|
+
.describe('Top-K high-value functions forwarded to code.reconstruct.export'),
|
|
69
|
+
module_limit: z
|
|
70
|
+
.number()
|
|
71
|
+
.int()
|
|
72
|
+
.min(1)
|
|
73
|
+
.max(12)
|
|
74
|
+
.default(6)
|
|
75
|
+
.describe('Maximum module count in the prepared reconstruction bundle'),
|
|
76
|
+
min_module_size: z
|
|
77
|
+
.number()
|
|
78
|
+
.int()
|
|
79
|
+
.min(1)
|
|
80
|
+
.max(20)
|
|
81
|
+
.default(2)
|
|
82
|
+
.describe('Modules with fewer functions than this threshold are merged into core'),
|
|
83
|
+
include_imports: z
|
|
84
|
+
.boolean()
|
|
85
|
+
.default(true)
|
|
86
|
+
.describe('Use import features for module hints'),
|
|
87
|
+
include_strings: z
|
|
88
|
+
.boolean()
|
|
89
|
+
.default(true)
|
|
90
|
+
.describe('Use high-value string clusters for module hints'),
|
|
91
|
+
analysis_goal: z
|
|
92
|
+
.string()
|
|
93
|
+
.min(1)
|
|
94
|
+
.max(400)
|
|
95
|
+
.default('Review reconstructed modules, refine their role labels, and propose evidence-grounded rewrite guidance.')
|
|
96
|
+
.describe('Human-readable analysis goal injected into the prompt contract for any external LLM'),
|
|
97
|
+
persist_artifact: z
|
|
98
|
+
.boolean()
|
|
99
|
+
.default(true)
|
|
100
|
+
.describe('Persist the prepared module review bundle as a JSON artifact for later review and provenance'),
|
|
101
|
+
session_tag: z
|
|
102
|
+
.string()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe('Optional semantic module review session tag used for artifact grouping'),
|
|
105
|
+
evidence_scope: z
|
|
106
|
+
.enum(['all', 'latest', 'session'])
|
|
107
|
+
.default('all')
|
|
108
|
+
.describe('Runtime evidence scope forwarded to code.reconstruct.export for module review preparation'),
|
|
109
|
+
evidence_session_tag: z
|
|
110
|
+
.string()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('Optional runtime evidence session selector used when evidence_scope=session or to narrow all/latest results'),
|
|
113
|
+
semantic_scope: z
|
|
114
|
+
.enum(['all', 'latest', 'session'])
|
|
115
|
+
.default('all')
|
|
116
|
+
.describe('Semantic artifact scope forwarded to code.reconstruct.export for module review preparation'),
|
|
117
|
+
semantic_session_tag: z
|
|
118
|
+
.string()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe('Optional semantic artifact session selector used when semantic_scope=session or to narrow all/latest results'),
|
|
121
|
+
role_target: z
|
|
122
|
+
.string()
|
|
123
|
+
.min(1)
|
|
124
|
+
.max(64)
|
|
125
|
+
.optional()
|
|
126
|
+
.describe('Optional high-level binary role hint such as native_rust_executable, dll_library, or com_server'),
|
|
127
|
+
role_focus_areas: z
|
|
128
|
+
.array(z.string().min(1).max(96))
|
|
129
|
+
.max(16)
|
|
130
|
+
.default([])
|
|
131
|
+
.describe('Optional role-aware focus areas forwarded to code.reconstruct.export'),
|
|
132
|
+
role_priority_order: z
|
|
133
|
+
.array(z.string().min(1).max(96))
|
|
134
|
+
.max(24)
|
|
135
|
+
.default([])
|
|
136
|
+
.describe('Optional role-aware priority-order hints forwarded to code.reconstruct.export'),
|
|
137
|
+
})
|
|
138
|
+
.refine((value) => value.evidence_scope !== 'session' || Boolean(value.evidence_session_tag?.trim()), {
|
|
139
|
+
message: 'evidence_session_tag is required when evidence_scope=session',
|
|
140
|
+
path: ['evidence_session_tag'],
|
|
141
|
+
})
|
|
142
|
+
.refine((value) => value.semantic_scope !== 'session' || Boolean(value.semantic_session_tag?.trim()), {
|
|
143
|
+
message: 'semantic_session_tag is required when semantic_scope=session',
|
|
144
|
+
path: ['semantic_session_tag'],
|
|
145
|
+
});
|
|
146
|
+
export const codeModuleReviewPrepareOutputSchema = z.object({
|
|
147
|
+
ok: z.boolean(),
|
|
148
|
+
data: z
|
|
149
|
+
.object({
|
|
150
|
+
sample_id: z.string(),
|
|
151
|
+
analysis_goal: z.string(),
|
|
152
|
+
prepared_count: z.number().int().nonnegative(),
|
|
153
|
+
prompt_name: z.literal('reverse.module_reconstruction_review'),
|
|
154
|
+
prompt_arguments: z.object({
|
|
155
|
+
analysis_goal: z.string(),
|
|
156
|
+
prepared_bundle_json: z.string(),
|
|
157
|
+
}),
|
|
158
|
+
task_prompt: z.string(),
|
|
159
|
+
prepared_bundle: PreparedModuleReviewBundleSchema,
|
|
160
|
+
export: z.object({
|
|
161
|
+
export_root: z.string(),
|
|
162
|
+
manifest_path: z.string(),
|
|
163
|
+
module_count: z.number().int().nonnegative(),
|
|
164
|
+
}),
|
|
165
|
+
artifact: z
|
|
166
|
+
.object({
|
|
167
|
+
id: z.string(),
|
|
168
|
+
type: z.literal(SEMANTIC_MODULE_REVIEW_PREPARE_BUNDLE_ARTIFACT_TYPE),
|
|
169
|
+
path: z.string(),
|
|
170
|
+
sha256: z.string(),
|
|
171
|
+
mime: z.string().optional(),
|
|
172
|
+
})
|
|
173
|
+
.optional(),
|
|
174
|
+
})
|
|
175
|
+
.optional(),
|
|
176
|
+
warnings: z.array(z.string()).optional(),
|
|
177
|
+
errors: z.array(z.string()).optional(),
|
|
178
|
+
artifacts: z.array(z.any()).optional(),
|
|
179
|
+
metrics: z
|
|
180
|
+
.object({
|
|
181
|
+
elapsed_ms: z.number(),
|
|
182
|
+
tool: z.string(),
|
|
183
|
+
})
|
|
184
|
+
.optional(),
|
|
185
|
+
});
|
|
186
|
+
export const codeModuleReviewPrepareToolDefinition = {
|
|
187
|
+
name: TOOL_NAME,
|
|
188
|
+
description: 'Prepare a structured module-level reconstruction bundle and MCP prompt contract so any tool-calling LLM can review grouped modules and refine rewrite guidance.',
|
|
189
|
+
inputSchema: codeModuleReviewPrepareInputSchema,
|
|
190
|
+
outputSchema: codeModuleReviewPrepareOutputSchema,
|
|
191
|
+
};
|
|
192
|
+
export function createCodeModuleReviewPrepareHandler(workspaceManager, database, cacheManager, dependencies) {
|
|
193
|
+
const exportHandler = dependencies?.exportHandler ||
|
|
194
|
+
createCodeReconstructExportHandler(workspaceManager, database, cacheManager);
|
|
195
|
+
return async (args) => {
|
|
196
|
+
const startTime = Date.now();
|
|
197
|
+
try {
|
|
198
|
+
const input = codeModuleReviewPrepareInputSchema.parse(args);
|
|
199
|
+
const exportResult = await exportHandler({
|
|
200
|
+
sample_id: input.sample_id,
|
|
201
|
+
topk: input.topk,
|
|
202
|
+
module_limit: input.module_limit,
|
|
203
|
+
min_module_size: input.min_module_size,
|
|
204
|
+
include_imports: input.include_imports,
|
|
205
|
+
include_strings: input.include_strings,
|
|
206
|
+
validate_build: false,
|
|
207
|
+
run_harness: false,
|
|
208
|
+
evidence_scope: input.evidence_scope,
|
|
209
|
+
evidence_session_tag: input.evidence_session_tag,
|
|
210
|
+
semantic_scope: input.semantic_scope,
|
|
211
|
+
semantic_session_tag: input.semantic_session_tag,
|
|
212
|
+
role_target: input.role_target,
|
|
213
|
+
role_focus_areas: input.role_focus_areas,
|
|
214
|
+
role_priority_order: input.role_priority_order,
|
|
215
|
+
reuse_cached: true,
|
|
216
|
+
});
|
|
217
|
+
if (!exportResult.ok) {
|
|
218
|
+
return {
|
|
219
|
+
ok: false,
|
|
220
|
+
errors: exportResult.errors || ['code.reconstruct.export failed'],
|
|
221
|
+
warnings: exportResult.warnings,
|
|
222
|
+
artifacts: exportResult.artifacts,
|
|
223
|
+
metrics: {
|
|
224
|
+
elapsed_ms: Date.now() - startTime,
|
|
225
|
+
tool: TOOL_NAME,
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const exportData = (exportResult.data || {});
|
|
230
|
+
const preparedBundle = {
|
|
231
|
+
schema_version: 1,
|
|
232
|
+
sample_id: input.sample_id,
|
|
233
|
+
analysis_goal: input.analysis_goal,
|
|
234
|
+
generated_at: new Date().toISOString(),
|
|
235
|
+
selection: {
|
|
236
|
+
topk: input.topk,
|
|
237
|
+
module_limit: input.module_limit,
|
|
238
|
+
min_module_size: input.min_module_size,
|
|
239
|
+
include_imports: input.include_imports,
|
|
240
|
+
include_strings: input.include_strings,
|
|
241
|
+
evidence_scope: input.evidence_scope,
|
|
242
|
+
evidence_session_tag: input.evidence_session_tag || null,
|
|
243
|
+
semantic_scope: input.semantic_scope,
|
|
244
|
+
semantic_session_tag: input.semantic_session_tag || null,
|
|
245
|
+
role_target: input.role_target || null,
|
|
246
|
+
role_focus_areas: input.role_focus_areas,
|
|
247
|
+
role_priority_order: input.role_priority_order,
|
|
248
|
+
},
|
|
249
|
+
output_contract: {
|
|
250
|
+
output_root: 'reviews',
|
|
251
|
+
required_fields: [
|
|
252
|
+
'module_name',
|
|
253
|
+
'summary',
|
|
254
|
+
'role_hint',
|
|
255
|
+
'confidence',
|
|
256
|
+
'assumptions',
|
|
257
|
+
'evidence_used',
|
|
258
|
+
'rewrite_guidance',
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
binary_profile: exportData.binary_profile || null,
|
|
262
|
+
runtime_evidence: exportData.runtime_evidence || null,
|
|
263
|
+
provenance: exportData.provenance || null,
|
|
264
|
+
modules: Array.isArray(exportData.modules)
|
|
265
|
+
? exportData.modules.map((module) => ({
|
|
266
|
+
module_name: module.name,
|
|
267
|
+
role_hint: module.role_hint || null,
|
|
268
|
+
focus_matches: Array.isArray(module.focus_matches) ? module.focus_matches : [],
|
|
269
|
+
confidence: Number(module.confidence || 0),
|
|
270
|
+
function_count: Number(module.function_count || 0),
|
|
271
|
+
import_hints: Array.isArray(module.import_hints) ? module.import_hints : [],
|
|
272
|
+
string_hints: Array.isArray(module.string_hints) ? module.string_hints : [],
|
|
273
|
+
runtime_apis: Array.isArray(module.runtime_apis) ? module.runtime_apis : [],
|
|
274
|
+
runtime_stages: Array.isArray(module.runtime_stages) ? module.runtime_stages : [],
|
|
275
|
+
functions: Array.isArray(module.functions)
|
|
276
|
+
? module.functions.map((func) => ({
|
|
277
|
+
function: func.function,
|
|
278
|
+
address: func.address,
|
|
279
|
+
confidence: Number(func.confidence || 0),
|
|
280
|
+
validated_name: func.validated_name || null,
|
|
281
|
+
resolution_source: func.name_resolution_source || null,
|
|
282
|
+
explanation_summary: func.explanation_summary || null,
|
|
283
|
+
explanation_behavior: func.explanation_behavior || null,
|
|
284
|
+
explanation_confidence: typeof func.explanation_confidence === 'number'
|
|
285
|
+
? func.explanation_confidence
|
|
286
|
+
: null,
|
|
287
|
+
}))
|
|
288
|
+
: [],
|
|
289
|
+
rewrite_path: module.rewrite_path,
|
|
290
|
+
pseudocode_path: module.pseudocode_path,
|
|
291
|
+
interface_path: module.interface_path,
|
|
292
|
+
}))
|
|
293
|
+
: [],
|
|
294
|
+
};
|
|
295
|
+
const promptArguments = {
|
|
296
|
+
analysis_goal: input.analysis_goal,
|
|
297
|
+
prepared_bundle_json: JSON.stringify(preparedBundle, null, 2),
|
|
298
|
+
};
|
|
299
|
+
const taskPrompt = buildModuleReconstructionReviewPromptText(promptArguments.prepared_bundle_json, input.analysis_goal);
|
|
300
|
+
let artifact;
|
|
301
|
+
const artifacts = [...(exportResult.artifacts || [])];
|
|
302
|
+
if (input.persist_artifact) {
|
|
303
|
+
artifact = await persistSemanticModuleReviewPrepareBundleArtifact(workspaceManager, database, input.sample_id, preparedBundle, input.session_tag || null);
|
|
304
|
+
artifacts.push(artifact);
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
ok: true,
|
|
308
|
+
data: {
|
|
309
|
+
sample_id: input.sample_id,
|
|
310
|
+
analysis_goal: input.analysis_goal,
|
|
311
|
+
prepared_count: preparedBundle.modules.length,
|
|
312
|
+
prompt_name: 'reverse.module_reconstruction_review',
|
|
313
|
+
prompt_arguments: promptArguments,
|
|
314
|
+
task_prompt: taskPrompt,
|
|
315
|
+
prepared_bundle: preparedBundle,
|
|
316
|
+
export: {
|
|
317
|
+
export_root: exportData.export_root,
|
|
318
|
+
manifest_path: exportData.manifest_path,
|
|
319
|
+
module_count: preparedBundle.modules.length,
|
|
320
|
+
},
|
|
321
|
+
artifact,
|
|
322
|
+
},
|
|
323
|
+
warnings: exportResult.warnings,
|
|
324
|
+
artifacts,
|
|
325
|
+
metrics: {
|
|
326
|
+
elapsed_ms: Date.now() - startTime,
|
|
327
|
+
tool: TOOL_NAME,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
return {
|
|
333
|
+
ok: false,
|
|
334
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
335
|
+
metrics: {
|
|
336
|
+
elapsed_ms: Date.now() - startTime,
|
|
337
|
+
tool: TOOL_NAME,
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=code-module-review-prepare.js.map
|