deeplyzer 0.9.0 → 0.11.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 +1 -19
- package/analysis/deep/orchestratorAgent.js +19 -8
- package/analysis/deep/runner/runnerAgent.js +72 -27
- package/engine.js +15 -37
- package/index.js +27 -36
- package/package.json +2 -1
- package/prompts/deep.runner.command +230 -37
- package/prompts/deep.runner.identify.runtime +365 -0
- package/prompts/deep.runner.runtime +137 -44
- package/prompts/graph.build_nodes +32 -48
- package/prompts/graph.source_exclusions +2 -0
- package/services/graphService.js +144 -99
- package/services/workflowService.js +103 -36
- package/utils/execUtil.js +115 -13
- package/utils/fileUtil.js +14 -17
- package/utils/hashUtil.js +34 -0
- package/session/sessionManager.js +0 -130
package/README.md
CHANGED
|
@@ -93,20 +93,6 @@ deeplyzer <configfile>
|
|
|
93
93
|
|
|
94
94
|
This creates graphs and workflows, then runs static and deep analysis.
|
|
95
95
|
|
|
96
|
-
- **Clear the session**
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
deeplyzer clear-session
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
- **Reset the analysis session**
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
deeplyzer reset-analysis-session
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
This resets the session and performs only static and deep analysis.
|
|
109
|
-
|
|
110
96
|
## Configuration
|
|
111
97
|
|
|
112
98
|
Create a configuration file (e.g. `deeplyzer.json`) in your project root.
|
|
@@ -121,9 +107,7 @@ Create a configuration file (e.g. `deeplyzer.json`) in your project root.
|
|
|
121
107
|
"apiKey": "<API key goes here>"
|
|
122
108
|
},
|
|
123
109
|
"log_path": "C:\\<local path>\\.logs",
|
|
124
|
-
"build_graph": false,
|
|
125
110
|
"deep_analysis": true,
|
|
126
|
-
"static_analysis": false,
|
|
127
111
|
"batch_size": 10
|
|
128
112
|
}
|
|
129
113
|
```
|
|
@@ -150,13 +134,11 @@ Create a configuration file (e.g. `deeplyzer.json`) in your project root.
|
|
|
150
134
|
| `llm.provider` | Yes | - | LLM provider (`openai`, `claude`, `gemini`). |
|
|
151
135
|
| `llm.model` | Yes | - | Model to use for analysis. |
|
|
152
136
|
| `llm.apiKey` | Yes | - | API key for the selected LLM provider. |
|
|
153
|
-
| `build_graph` | No | `true` | Build semantic code graphs. |
|
|
154
137
|
| `deep_analysis` | No | true | Enable deep LLM-based analysis. |
|
|
155
|
-
| `static_analysis` | No | `true` | Enable static code analysis. |
|
|
156
138
|
| `batch_size` | No | `10` | Number of sources processed in each batch. |
|
|
157
139
|
| `log_path` | No | - | Windows or platform-specific directory where logs are written (example: `C:\\deeplyzer\\.logs`). |
|
|
158
140
|
|
|
159
|
-
**Note:** `
|
|
141
|
+
**Note:** `batch_size` is optional. If omitted, its default value is used.
|
|
160
142
|
|
|
161
143
|
## Links
|
|
162
144
|
|
|
@@ -25,7 +25,7 @@ class OrchestratorAgent {
|
|
|
25
25
|
if(runner.workflowRunner == "dynamic") {
|
|
26
26
|
await this._runDynamicWorkflow(workflow);
|
|
27
27
|
} else {
|
|
28
|
-
await this._runOpenPackageWorkflow(workflow);
|
|
28
|
+
await this._runOpenPackageWorkflow(workflow, runner);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -38,7 +38,7 @@ class OrchestratorAgent {
|
|
|
38
38
|
// GENERATE
|
|
39
39
|
const generateResult = await this.generateAgent.generate(workflow.src, id);
|
|
40
40
|
|
|
41
|
-
const setup = await this.runnerAgent.setupRuntime(generateResult);
|
|
41
|
+
const setup = await this.runnerAgent.setupRuntime(generateResult.runtimeCommands);
|
|
42
42
|
if (!setup.complete) {
|
|
43
43
|
Logger.error(`Setup of runtime for workflow: ${workflow.id} failed.`);
|
|
44
44
|
return;
|
|
@@ -58,15 +58,26 @@ class OrchestratorAgent {
|
|
|
58
58
|
return assessments;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async _runOpenPackageWorkflow(workflow,
|
|
62
|
-
// run
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
async _runOpenPackageWorkflow(workflow, runner) {
|
|
62
|
+
// Step 1: setup runtime, run servers
|
|
63
|
+
const commands = await this.runnerAgent.identifyRuntime(runner);
|
|
64
|
+
const setup = await this.runnerAgent.setupRuntime(commands.runtimeCommands);
|
|
65
|
+
if (!setup.complete) {
|
|
66
|
+
Logger.error(`Setup of runtime for workflow: ${workflow.id} failed.`);
|
|
67
|
+
return;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
if (commands.execCommands.length > 0) {
|
|
71
|
+
for (const command of commands.execCommands) {
|
|
72
|
+
const result = await this.runnerAgent.execCommand(command, "", commands.execCommands);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Step 2: open package installation, execution
|
|
77
|
+
const workflowRunnerPackage = globals.openPackages.find(item => item.name === runner.workflowRunner);
|
|
69
78
|
if (workflowRunnerPackage) {
|
|
79
|
+
await this.setupOpenPackage(workflowRunnerPackage.name, workflowRunnerPackage.installations);
|
|
80
|
+
|
|
70
81
|
const result = await execUtil.createInstance(workflowRunnerPackage.name, workflowRunnerPackage.initClass);
|
|
71
82
|
const instance = result.instance;
|
|
72
83
|
|
|
@@ -3,6 +3,7 @@ const PromptsUtil = require('../../../utils/promptsUtil');
|
|
|
3
3
|
const Logger = require('../../../utils/logger');
|
|
4
4
|
const globals = require('../../../globals');
|
|
5
5
|
const execUtil = require('../../../utils/execUtil');
|
|
6
|
+
const os = require("os");
|
|
6
7
|
|
|
7
8
|
class RunnerAgent {
|
|
8
9
|
constructor() {
|
|
@@ -35,29 +36,38 @@ class RunnerAgent {
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
async
|
|
39
|
+
async identifyRuntime(runner) {
|
|
40
|
+
const files = this._getWorkflowFilePaths(runner.files);
|
|
41
|
+
|
|
42
|
+
let prompt = PromptsUtil.read("deep.runner.identify.runtime");
|
|
43
|
+
prompt = prompt.replaceAll("***FILES***", JSON.stringify(files));
|
|
44
|
+
prompt = prompt.replaceAll("***SHELL***", this._detectShell());
|
|
45
|
+
Logger.detailed("Identify runtime details: " + prompt);
|
|
46
|
+
|
|
47
|
+
const response = await this.llm.generate({ prompt: prompt, json: true });
|
|
48
|
+
Logger.detailed("Commands Generated: " + JSON.stringify(response));
|
|
49
|
+
|
|
50
|
+
return response.commands;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async setupRuntime(runtimeCommands) {
|
|
39
54
|
// install runtime
|
|
40
55
|
let results = [], complete = false;
|
|
41
56
|
|
|
42
57
|
for (let attempts = 0; attempts < 3; attempts++) {
|
|
43
|
-
results = await this._setupRuntime(
|
|
44
|
-
const assessment = await this._assessSetupRuntimeResults(
|
|
58
|
+
results = await this._setupRuntime(runtimeCommands, results);
|
|
59
|
+
const assessment = await this._assessSetupRuntimeResults(runtimeCommands, results);
|
|
45
60
|
|
|
46
61
|
if (assessment) { complete = true; break; }
|
|
47
62
|
}
|
|
48
63
|
|
|
49
|
-
/*// install open package if required for the runner
|
|
50
|
-
const workflowRunnerPackage = globals.openPackages.find(item => item.name === runner.workflowRunner);
|
|
51
|
-
if (workflowRunnerPackage) {
|
|
52
|
-
results = await this._setupOpenPackage(workflowRunnerPackage.name, workflowRunnerPackage.installations);
|
|
53
|
-
}*/
|
|
54
|
-
|
|
55
64
|
return { complete: complete }
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
async execCommand(command, id) {
|
|
67
|
+
async execCommand(command, id, allCommands) {
|
|
59
68
|
let result = null, results = [], complete = false;
|
|
60
|
-
let cmd = command;
|
|
69
|
+
let cmd = typeof command === "string" ? { detached: false, cmd: command } : command;
|
|
70
|
+
let cmds = [cmd];
|
|
61
71
|
|
|
62
72
|
Logger.detailed("Initiating command execution: " + command);
|
|
63
73
|
|
|
@@ -65,30 +75,32 @@ class RunnerAgent {
|
|
|
65
75
|
if (results.length > 0) {
|
|
66
76
|
let prompt = PromptsUtil.read("deep.runner.command");
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
let executionHistory = results.map((item, index) => {
|
|
79
|
+
return `COMMAND ${index + 1}: ${
|
|
80
|
+
typeof item.command === "object" && item.command !== null
|
|
81
|
+
? JSON.stringify(item.command) : item.command ?? "NOT_AVAILABLE"
|
|
82
|
+
}
|
|
83
|
+
RESULT ${index + 1}: ${JSON.stringify(item.result)}`;}).join("\n\n");
|
|
73
84
|
|
|
74
|
-
prompt = prompt.replaceAll("***
|
|
85
|
+
prompt = prompt.replaceAll("***INITIAL_COMMANDS***", allCommands == null ? "NOT_AVAILABLE" : JSON.stringify(allCommands));
|
|
86
|
+
prompt = prompt.replaceAll("***COMMAND***", JSON.stringify(cmds));
|
|
75
87
|
prompt = prompt.replaceAll("***OS***", process.platform);
|
|
88
|
+
prompt = prompt.replaceAll("***SHELL***", this._detectShell());
|
|
76
89
|
prompt = prompt.replaceAll("***RESULT***", executionHistory);
|
|
77
90
|
Logger.detailed("Exec command details: " + prompt);
|
|
78
91
|
|
|
79
92
|
const response = await this.llm.generate({ prompt: prompt, json: true });
|
|
80
93
|
Logger.detailed("Command Generated: " + JSON.stringify(response));
|
|
81
94
|
|
|
82
|
-
|
|
95
|
+
cmds = response.commands;
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
command: cmd,
|
|
88
|
-
|
|
89
|
-
});
|
|
98
|
+
for(const cmd of cmds) {
|
|
99
|
+
result = await execUtil.exec(cmd.cmd, id, cmd.detached);
|
|
100
|
+
results.push({ command: cmd, result: result });
|
|
101
|
+
}
|
|
90
102
|
|
|
91
|
-
const assessment = await this._assessExecCommandResults(
|
|
103
|
+
const assessment = await this._assessExecCommandResults(cmds, result);
|
|
92
104
|
|
|
93
105
|
if (assessment) { complete = true; break; }
|
|
94
106
|
}
|
|
@@ -96,7 +108,7 @@ class RunnerAgent {
|
|
|
96
108
|
return { complete: complete }
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
async
|
|
111
|
+
async setupOpenPackage(packageName, installations) {
|
|
100
112
|
const results = [];
|
|
101
113
|
|
|
102
114
|
const installResult = await execUtil.installPackage(packageName);
|
|
@@ -123,6 +135,7 @@ class RunnerAgent {
|
|
|
123
135
|
let prompt = PromptsUtil.read("deep.runner.runtime");
|
|
124
136
|
prompt = prompt.replaceAll("***RUNTIME_DETAILS***", JSON.stringify(runtimeCommands));
|
|
125
137
|
prompt = prompt.replaceAll("***OS***", process.platform);
|
|
138
|
+
prompt = prompt.replaceAll("***SHELL***", this._detectShell());
|
|
126
139
|
prompt = prompt.replaceAll("***RESULTS***", JSON.stringify(existingResults ?? "NONE"));
|
|
127
140
|
Logger.detailed("Setup runtime details: " + prompt);
|
|
128
141
|
|
|
@@ -154,9 +167,9 @@ class RunnerAgent {
|
|
|
154
167
|
return String(response || "").trim().toUpperCase() === "TRUE";
|
|
155
168
|
}
|
|
156
169
|
|
|
157
|
-
async _assessExecCommandResults(
|
|
170
|
+
async _assessExecCommandResults(commands, results) {
|
|
158
171
|
let prompt = PromptsUtil.read("deep.runner.assess.command");
|
|
159
|
-
prompt = prompt.replaceAll("***COMMAND***",
|
|
172
|
+
prompt = prompt.replaceAll("***COMMAND***", JSON.stringify(commands));
|
|
160
173
|
prompt = prompt.replaceAll("***RESULTS***", JSON.stringify(results ?? "NONE"));
|
|
161
174
|
Logger.detailed("Assess run command details: " + prompt);
|
|
162
175
|
|
|
@@ -165,6 +178,38 @@ class RunnerAgent {
|
|
|
165
178
|
|
|
166
179
|
return String(response || "").trim().toUpperCase() === "TRUE";
|
|
167
180
|
}
|
|
181
|
+
|
|
182
|
+
_getWorkflowFilePaths(files) {
|
|
183
|
+
const fileNames = new Set(files);
|
|
184
|
+
|
|
185
|
+
const sourcePaths = new Set();
|
|
186
|
+
|
|
187
|
+
for (const graph of globals.graphs || []) {
|
|
188
|
+
if (fileNames.has(graph.file?.file) && graph.file?.path) {
|
|
189
|
+
sourcePaths.add(graph.file.path);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return [...sourcePaths];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_detectShell() {
|
|
197
|
+
if (process.platform !== "win32") {
|
|
198
|
+
return process.env.SHELL || "bash";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// PowerShell sets this environment variable
|
|
202
|
+
if (process.env.PSModulePath) {
|
|
203
|
+
return "powershell";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// CMD normally exposes ComSpec pointing to cmd.exe
|
|
207
|
+
if (process.env.ComSpec?.toLowerCase().endsWith("\\cmd.exe")) {
|
|
208
|
+
return "cmd";
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return "unknown";
|
|
212
|
+
}
|
|
168
213
|
}
|
|
169
214
|
|
|
170
215
|
module.exports = RunnerAgent;
|
package/engine.js
CHANGED
|
@@ -6,7 +6,6 @@ const OrchestratorAgent = require('./analysis/deep/orchestratorAgent');
|
|
|
6
6
|
|
|
7
7
|
const Logger = require('./utils/logger');
|
|
8
8
|
const globals = require("./globals");
|
|
9
|
-
const SessionManager = require("./session/sessionManager");
|
|
10
9
|
|
|
11
10
|
class Engine {
|
|
12
11
|
constructor() {
|
|
@@ -21,61 +20,40 @@ class Engine {
|
|
|
21
20
|
async run() {
|
|
22
21
|
try {
|
|
23
22
|
Logger.essential("[ENGINE] Starting Deeplyzer...");
|
|
24
|
-
SessionManager.updateState("in_progress");
|
|
25
23
|
|
|
26
24
|
// step 1: build graph
|
|
27
|
-
|
|
28
|
-
globals.graphs = await this.graphService.buildGraphs();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if(!globals.graphs || globals.graphs.length == 0) {
|
|
32
|
-
globals.graphs = await this.graphService.loadGraphs();
|
|
33
|
-
}
|
|
25
|
+
await this.graphService.buildGraphs();
|
|
34
26
|
|
|
35
|
-
// step 2: build workflows
|
|
36
|
-
if(
|
|
27
|
+
// step 2: build / load workflows
|
|
28
|
+
if(this.graphService.hasUpdates()) {
|
|
37
29
|
globals.workflows = this.workflowService.build();
|
|
38
|
-
|
|
39
|
-
SessionManager.updateStage("build_workflows");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if(!globals.workflows) {
|
|
30
|
+
} else {
|
|
43
31
|
globals.workflows = this.workflowService.loadWorkflows();
|
|
44
32
|
}
|
|
45
33
|
|
|
46
34
|
this.workflowService.fillSources();
|
|
47
35
|
|
|
48
36
|
// step 3: identify runners
|
|
49
|
-
if(
|
|
37
|
+
if(this.graphService.hasUpdates()) {
|
|
50
38
|
globals.runners = await this.runnerIdentificationService.identify();
|
|
51
|
-
|
|
52
|
-
SessionManager.updateStage("identify_runners");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if(!globals.runners) {
|
|
39
|
+
} else {
|
|
56
40
|
globals.runners = this.runnerIdentificationService.loadRunners();
|
|
57
41
|
}
|
|
58
42
|
|
|
43
|
+
const staticAnalysisEnabled = globals.config.static_analysis ?? true;
|
|
44
|
+
const deepAnalysisEnabled = globals.config.deep_analysis ?? true;
|
|
45
|
+
|
|
59
46
|
// step 4: perform static code analysis
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
SessionManager.updateStage("static_analysis");
|
|
65
|
-
}
|
|
66
|
-
}*/
|
|
47
|
+
if (staticAnalysisEnabled || deepAnalysisEnabled) {
|
|
48
|
+
// await this.staticAnalyzer.analyze(graphs, workflows);
|
|
49
|
+
}
|
|
67
50
|
|
|
68
51
|
// step 4: perform deep code analysis
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await this.orchestratorAgent.start(globals.workflows);
|
|
73
|
-
|
|
74
|
-
SessionManager.updateStage("deep_analysis");
|
|
75
|
-
}
|
|
52
|
+
if (deepAnalysisEnabled) {
|
|
53
|
+
Logger.essential("[ENGINE] Starting deep analysis...");
|
|
54
|
+
await this.orchestratorAgent.start(globals.workflows);
|
|
76
55
|
}
|
|
77
56
|
|
|
78
|
-
SessionManager.updateState("completed");
|
|
79
57
|
Logger.essential("[ENGINE] Execution completed.");
|
|
80
58
|
} catch (error) {
|
|
81
59
|
Logger.error("[ENGINE ERROR]", error);
|
package/index.js
CHANGED
|
@@ -1,55 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const Engine = require("./engine");
|
|
4
|
-
const SessionManager = require("./session/sessionManager");
|
|
5
4
|
const Logger = require('./utils/logger');
|
|
5
|
+
const FileUtil = require('./utils/fileUtil');
|
|
6
6
|
const globals = require("./globals");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log("[INFO] Session cleared successfully.");
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (argument === "reset-analysis-session") {
|
|
22
|
-
SessionManager.resetAnalysisSession();
|
|
23
|
-
console.log("[INFO] Session reset successfully.");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Normal execution
|
|
28
|
-
SessionManager.loadSession();
|
|
10
|
+
async function run(configPath) {
|
|
11
|
+
// Handle commands
|
|
12
|
+
if (configPath === "clear-graphs") {
|
|
13
|
+
const fileUtil = new FileUtil();
|
|
14
|
+
fileUtil.removeFiles("graph");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
globals.config = _loadConfig(configPath);
|
|
31
19
|
|
|
32
|
-
|
|
20
|
+
Logger.init();
|
|
33
21
|
|
|
34
|
-
|
|
22
|
+
const engine = new Engine();
|
|
23
|
+
await engine.run();
|
|
24
|
+
}
|
|
35
25
|
|
|
36
|
-
|
|
26
|
+
// Export for require()
|
|
27
|
+
module.exports = run;
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
// Console execution
|
|
30
|
+
if (require.main === module) {
|
|
31
|
+
(async () => {
|
|
32
|
+
try {
|
|
33
|
+
await run(process.argv[2]);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(`[ERROR] ${error.message}`);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
43
40
|
|
|
44
41
|
function _loadConfig(configPath) {
|
|
45
|
-
|
|
46
42
|
if (!configPath) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
"Configuration file path or command is required.\n" +
|
|
49
|
-
"Usage:\n" +
|
|
50
|
-
" node index.js <config.json>\n" +
|
|
51
|
-
" node index.js clear-session"
|
|
52
|
-
);
|
|
43
|
+
throw new Error("Configuration file path or command is required.");
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
const resolvedPath = path.resolve(configPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deeplyzer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Go beyond static code analysis. End-to-end intelligence across code, execution flows, databases, and cloud infrastructure.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"axios": "^1.21.1",
|
|
30
|
+
"cli-progress": "^3.12.0",
|
|
30
31
|
"playwright": "^1.65.1"
|
|
31
32
|
}
|
|
32
33
|
}
|