deeplyzer 0.1.0 → 0.2.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/LICENSE CHANGED
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ ![Deeplyzer Logo](img/logo.png)
1
2
  # Deeplyzer
2
3
 
3
4
  ### Deep analysis of software beyond static code analysis.
@@ -64,7 +65,7 @@ Deeplyzer goes further. It understands how the application works, investigates t
64
65
 
65
66
  ## How Deeplyzer Works
66
67
 
67
- ![Deeplyzer Workflow](img/a_clean_infographic_on_white_background_a_horizon.png)
68
+ ![Deeplyzer Workflow](img/workflow.png)
68
69
 
69
70
  ## Installation
70
71
 
@@ -81,13 +82,15 @@ Create a configuration file (e.g. `deeplyzer.json`) in your project root.
81
82
  ```json
82
83
  {
83
84
  "sources": [],
84
- "source-exclusions": [],
85
+ "source_exclusions": [],
85
86
  "llm": {
86
- "provider": "openai",
87
+ "provider": "openai | gemini | claude",
87
88
  "model": "gpt-6.1-sol",
88
89
  "apiKey": "<API key goes here>"
89
90
  },
91
+ "log_path": "C:\\deeplyzer\\.logs",
90
92
  "build_graph": false,
93
+ "deep_analysis": true,
91
94
  "static_analysis": false,
92
95
  "batch_size": 10
93
96
  }
@@ -98,16 +101,23 @@ Create a configuration file (e.g. `deeplyzer.json`) in your project root.
98
101
  | Option | Required | Default | Description |
99
102
  |---|---|---|---|
100
103
  | `sources` | Yes | `[]` | Source files or directories to analyze. |
101
- | `source-exclusions` | No | `[]` | Files or directories to exclude from analysis. |
104
+ | `source_exclusions` | No | `[]` | Files or directories to exclude from analysis. |
102
105
  | `llm.provider` | Yes | - | LLM provider (`openai`, `claude`, `gemini`). |
103
106
  | `llm.model` | Yes | - | Model to use for analysis. |
104
107
  | `llm.apiKey` | Yes | - | API key for the selected LLM provider. |
105
108
  | `build_graph` | No | `true` | Build semantic code graphs. |
109
+ | `deep_analysis` | No | true | Enable deep LLM-based analysis. |
106
110
  | `static_analysis` | No | `true` | Enable static code analysis. |
107
111
  | `batch_size` | No | `10` | Number of sources processed in each batch. |
112
+ | `log_path` | No | - | Directory where analysis logs are written. |
108
113
 
109
114
  **Note:** `build_graph`, `static_analysis`, and `batch_size` are optional. If omitted, their default values are used.
110
115
 
116
+ ## Links
117
+
118
+ - **GitHub Repository:** [github.com/areteqa/deeplyzer](https://github.com/areteqa/deeplyzer)
119
+ - **NPM Package:** [npmjs.com/package/deeplyzer](https://www.npmjs.com/package/deeplyzer)
120
+
111
121
  ## License
112
122
 
113
123
  Deeplyzer is open-source software licensed under the [MIT License](LICENSE).
package/index.js CHANGED
@@ -1,13 +1,29 @@
1
-
2
1
  const Engine = require("./engine");
2
+ const SessionManager = require("./session/sessionManager");
3
+ const Logger = require('./utils/logger');
4
+ const globals = require("./globals");
3
5
  const fs = require("fs");
4
6
  const path = require("path");
5
7
 
6
8
  (async () => {
7
- try {
8
- const config = _loadConfig();
9
+ try {
10
+ const argument = process.argv[2];
11
+
12
+ // Handle commands
13
+ if (argument === "clear-session") {
14
+ SessionManager.clearSession();
15
+ console.log("[INFO] Session cleared successfully.");
16
+ return;
17
+ }
18
+
19
+ // Normal execution
20
+ SessionManager.loadSession();
21
+
22
+ globals.config = _loadConfig(argument);
23
+
24
+ Logger.init();
9
25
 
10
- const engine = new Engine(config);
26
+ const engine = new Engine();
11
27
 
12
28
  await engine.run();
13
29
 
@@ -17,11 +33,15 @@ const path = require("path");
17
33
  }
18
34
  })();
19
35
 
20
- function _loadConfig() {
21
- const configPath = process.argv[2];
36
+ function _loadConfig(configPath) {
22
37
 
23
38
  if (!configPath) {
24
- throw new Error("Configuration file path is required.\nUsage: node index.js <config.json>");
39
+ throw new Error(
40
+ "Configuration file path or command is required.\n" +
41
+ "Usage:\n" +
42
+ " node index.js <config.json>\n" +
43
+ " node index.js clear-session"
44
+ );
25
45
  }
26
46
 
27
47
  const resolvedPath = path.resolve(configPath);
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "deeplyzer",
3
- "version": "0.1.0",
3
+ "version": "0.2.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",
7
7
  "scripts": {
8
8
  "start": "node index.js"
9
9
  },
10
+ "files": [
11
+ "!packages/**"
12
+ ],
10
13
  "keywords": [
11
14
  "ai",
12
15
  "autonomous-testing",
@@ -1,17 +0,0 @@
1
- const LLM = require('../../llm/llm');
2
- const FileUtil = require('../../utils/fileUtil');
3
-
4
- class BuildCode {
5
- constructor(config){
6
- this.llm = new LLM(config.llm);
7
- this.fileUtil = new FileUtil();
8
- }
9
-
10
- async build(prompt, id) {
11
- const response = await this.llm.generate({ prompt: prompt, json: true });
12
-
13
- this.fileUtil.saveCodeFiles(response, id);
14
- }
15
- }
16
-
17
- module.exports = BuildCode;
@@ -1,65 +0,0 @@
1
-
2
- const path = require("path");
3
- const { exec } = require("child_process");
4
- const util = require("util");
5
- const fs = require("fs");
6
-
7
- class ExecCommand {
8
- constructor() {
9
- this.baseDir = path.join(process.cwd(), ".deeplyzer");
10
- this.execAsync = util.promisify(exec);
11
-
12
- this.platform = process.platform;
13
- this.shell = this.getShell();
14
- }
15
-
16
- getShell() {
17
- switch (this.platform) {
18
- case "win32":
19
- return "powershell.exe";
20
-
21
- case "darwin":
22
- return "/bin/zsh";
23
-
24
- case "linux":
25
- return "/bin/bash";
26
-
27
- default:
28
- throw new Error(
29
- `Unsupported operating system: ${this.platform}`
30
- );
31
- }
32
- }
33
-
34
- async exec(command, id) {
35
- const cwd = path.join(this.baseDir, "src", id);
36
-
37
- fs.mkdirSync(cwd, { recursive: true });
38
-
39
- try {
40
- const { stdout, stderr } = await this.execAsync(command, {
41
- cwd,
42
- shell: this.shell,
43
- windowsHide: true,
44
- maxBuffer: 10 * 1024 * 1024
45
- });
46
-
47
- if (stdout) process.stdout.write(stdout);
48
- if (stderr) process.stderr.write(stderr);
49
-
50
- return { success: true, stdout, stderr };
51
-
52
- } catch (error) {
53
- console.error(`[COMMAND ERROR] ${error.message}`);
54
-
55
- return {
56
- success: false,
57
- stdout: error.stdout || "",
58
- stderr: error.stderr || "",
59
- error: error.message
60
- };
61
- }
62
- }
63
- }
64
-
65
- module.exports = ExecCommand;
@@ -1,34 +0,0 @@
1
- const BuildCode = require('./buildCode');
2
- const ExecCommand = require('./execCommand');
3
- const IdUtil = require('../../utils/idUtil');
4
-
5
- class PlanExecutor {
6
- constructor(config) {
7
- this.buildCode = new BuildCode(config);
8
- this.execCommand = new ExecCommand();
9
- }
10
-
11
- async exec(plan) {
12
- let responses = [];
13
-
14
- for (const planItem of plan) {
15
- const id = IdUtil.generate();
16
-
17
- if (planItem.prompt && planItem.prompt != "") {
18
- await this.buildCode.build(planItem.prompt, id);
19
- }
20
-
21
- if (planItem.commands && planItem.commands.length > 0) {
22
- for(const command of planItem.commands) {
23
- const response = await this.execCommand.exec(command, id);
24
-
25
- responses.push(response);
26
- }
27
- }
28
- }
29
-
30
- return responses;
31
- }
32
- }
33
-
34
- module.exports = PlanExecutor;
@@ -1,43 +0,0 @@
1
- const WorkflowAnalysisPlanner = require('./plan/workflowAnalysisPlanner');
2
- const PlanExecutor = require('./exec/planExecutor');
3
- const InfraAnalysisPlanner = require('./plan/infraAnalysisPlanner');
4
-
5
- class DeepAnalysisOrchestrator {
6
- constructor(config) {
7
- this.config = config;
8
- this.planExecutor = new PlanExecutor(config);
9
- }
10
-
11
- async analyzeWorkflows(workflows) {
12
- if(!workflows) return;
13
-
14
- const planner = new WorkflowAnalysisPlanner();
15
- for(const workflow of workflows) {
16
- const plan = planner.plan(workflow);
17
-
18
- await this.planExecutor.exec(plan);
19
- }
20
- }
21
-
22
- async analyzeInfra(graphs) {
23
- const planner = new InfraAnalysisPlanner(graphs, this.config);
24
- planner.graphs = graphs;
25
-
26
- let exit = false, count = 0, plan, responses;
27
- while(!exit) {
28
- console.log("Generating infra validation plan");
29
- plan = await planner.plan(plan, responses);
30
-
31
- console.log("Executing infra validations");
32
- responses = await this.planExecutor.exec(plan);
33
-
34
- console.log("Checking infra validation exit");
35
- exit = planner.checkExit(plan, responses);
36
-
37
- count = count + 1;
38
- if(count > 3) break;
39
- }
40
- }
41
- }
42
-
43
- module.exports = DeepAnalysisOrchestrator;
@@ -1,45 +0,0 @@
1
- const PromptsUtil = require('../../utils/promptsUtil');
2
- const LLM = require('../../llm/llm');
3
-
4
- class InfraAnalysisPlanner {
5
- constructor(graphs, config) {
6
- this.graphs = graphs;
7
-
8
- this.llm = new LLM(config.llm);
9
- }
10
-
11
- async plan(existingPlan, existingResponses) {
12
- let infraInstructions = [];
13
- for(const graph of this.graphs) {
14
- if(graph.file.is_infra) {
15
- infraInstructions.push(graph.file.content);
16
- }
17
- }
18
-
19
- if(infraInstructions.length == 0) return null;
20
-
21
- let prompt = PromptsUtil.read("infra_plan");
22
-
23
- prompt = prompt.replaceAll("***INSTRUCTIONS***", infraInstructions.join("\n"));
24
- prompt = prompt.replaceAll("***EXISTING_PLAN***", JSON.stringify(existingPlan ?? {}));
25
- prompt = prompt.replaceAll("***EXISTING_RESPONSES***", JSON.stringify(existingResponses ?? {}));
26
-
27
- const response = await this.llm.generate({ prompt: prompt });
28
-
29
- return response;
30
- }
31
-
32
- async checkExit(responses) {
33
- let prompt = PromptsUtil.read("check_exit");
34
-
35
- prompt = prompt.replaceAll("***RESPONSES***", JSON.stringify(responses));
36
-
37
- const response = await this.llm.generate({ prompt: prompt, text: true });
38
-
39
- const exit = response?.trim().toUpperCase() === "TRUE";
40
-
41
- return exit;
42
- }
43
- }
44
-
45
- module.exports = InfraAnalysisPlanner;
@@ -1,7 +0,0 @@
1
- class WorkflowAnalysisPlanner {
2
- async plan(workflow) {
3
-
4
- }
5
- }
6
-
7
- module.exports = WorkflowAnalysisPlanner;
package/engine.js DELETED
@@ -1,50 +0,0 @@
1
- const GraphService = require('./services/graphService');
2
- const WorkflowService = require('./services/workflowService');
3
- const StaticAnalyzerService = require('./services/staticAnalyzerService');
4
-
5
- const DeepAnalysisOrchestrator = require('./deepAnalysis/orchestrator');
6
-
7
- class Engine {
8
- constructor(config = {}) {
9
- this.config = config;
10
- }
11
-
12
- async run() {
13
- try {
14
- console.log("[ENGINE] Starting Deeplyzer...");
15
- console.log("[ENGINE] Configuration loaded.");
16
-
17
- // step 1: build graph
18
- let graphs;
19
- const graphService = new GraphService(this.config);
20
- if (this.config.build_graph ?? true) {
21
- graphs = await graphService.buildGraphs();
22
- } else {
23
- graphs = await graphService.loadGraphs();
24
- }
25
-
26
-
27
- // step 2: build workflows
28
- const workflowService = new WorkflowService();
29
- const workflows = workflowService.build(graphs);
30
-
31
- // step 3: perform static code analysis
32
- if (this.config.static_analysis ?? true) {
33
- const staticAnalyzerService = new StaticAnalyzerService(this.config);
34
- await staticAnalyzerService.analyze(graphs, workflows);
35
- }
36
-
37
- console.log("[ENGINE] Starting deep analysis...");
38
- const orchestrator = new DeepAnalysisOrchestrator(this.config);
39
- //await orchestrator.analyzeWorkflows(null);
40
- await orchestrator.analyzeInfra(graphs);
41
-
42
- console.log("[ENGINE] Execution completed.");
43
- } catch (error) {
44
- console.error("[ENGINE ERROR]", error);
45
- throw error;
46
- }
47
- }
48
- }
49
-
50
- module.exports = Engine;
package/llm/llm.js DELETED
@@ -1,58 +0,0 @@
1
-
2
- const OpenAIProvider = require("./providers/openai");
3
- const ClaudeProvider = require("./providers/claude");
4
- const GeminiProvider = require("./providers/gemini");
5
-
6
- class LLM {
7
- constructor(llmConfig = {}) {
8
- const providers = {
9
- openai: OpenAIProvider,
10
- claude: ClaudeProvider,
11
- gemini: GeminiProvider
12
- };
13
-
14
- const Provider = providers[llmConfig.provider];
15
-
16
- if (!Provider) {
17
- throw new Error(`Unsupported LLM provider: ${llmConfig.provider}`);
18
- }
19
-
20
- if (!llmConfig.model || !llmConfig.apiKey) {
21
- throw new Error("LLM model and API key are required.");
22
- }
23
-
24
- this.llmConfig = llmConfig;
25
- this.provider = new Provider(llmConfig);
26
- }
27
-
28
- async generate(options = {}) {
29
- if (!options.prompt) {
30
- throw new Error("Prompt is required.");
31
- }
32
-
33
- try {
34
- const response = await this.provider.generate(options);
35
-
36
- if(options.text) return response.text;
37
-
38
- return this._parseJSON(response.text);
39
-
40
- } catch (error) {
41
- throw new Error(
42
- `[${this.llmConfig.provider}] ${error.message}`
43
- );
44
- }
45
- }
46
-
47
- _parseJSON(text) {
48
- return JSON.parse(
49
- text
50
- .replace(/^```json\s*/i, "")
51
- .replace(/^```\s*/i, "")
52
- .replace(/\s*```$/, "")
53
- .trim()
54
- );
55
- }
56
- }
57
-
58
- module.exports = LLM;
@@ -1,65 +0,0 @@
1
-
2
- const axios = require("axios");
3
-
4
- class ClaudeProvider {
5
- constructor(llmConfig) {
6
- this.llmConfig = llmConfig;
7
-
8
- this.client = axios.create({
9
- baseURL: "https://api.anthropic.com/v1",
10
- headers: {
11
- "x-api-key": llmConfig.apiKey,
12
- "anthropic-version": "2023-06-01",
13
- "Content-Type": "application/json"
14
- }
15
- });
16
- }
17
-
18
- async generate(options) {
19
- const payload = {
20
- model: this.llmConfig.model,
21
- messages: [
22
- {
23
- role: "user",
24
- content: options.prompt
25
- }
26
- ]
27
- };
28
-
29
- if (options.system) {
30
- payload.system = options.system;
31
- }
32
-
33
- if (options.temperature !== undefined) {
34
- payload.temperature = options.temperature;
35
- }
36
-
37
- if (options.json) {
38
- payload.system = [
39
- payload.system || "",
40
- "Return only valid JSON. No markdown code fences."
41
- ].join("\n");
42
- }
43
-
44
- const { data } = await this.client.post("/messages", payload);
45
-
46
- return {
47
- text: data.content
48
- .filter(item => item.type === "text")
49
- .map(item => item.text)
50
- .join("\n"),
51
- model: data.model,
52
- provider: "claude",
53
- usage: {
54
- inputTokens: data.usage?.input_tokens || 0,
55
- outputTokens: data.usage?.output_tokens || 0,
56
- totalTokens:
57
- (data.usage?.input_tokens || 0) +
58
- (data.usage?.output_tokens || 0)
59
- },
60
- raw: data
61
- };
62
- }
63
- }
64
-
65
- module.exports = ClaudeProvider;
@@ -1,66 +0,0 @@
1
-
2
- const axios = require("axios");
3
-
4
- class GeminiProvider {
5
- constructor(llmConfig) {
6
- this.llmConfig = llmConfig;
7
-
8
- this.client = axios.create({
9
- baseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
10
- headers: {
11
- Authorization: `Bearer ${llmConfig.apiKey}`,
12
- "Content-Type": "application/json"
13
- }
14
- });
15
- }
16
-
17
- async generate(options) {
18
- const messages = [];
19
-
20
- if (options.system) {
21
- messages.push({
22
- role: "system",
23
- content: options.system
24
- });
25
- }
26
-
27
- messages.push({
28
- role: "user",
29
- content: options.prompt
30
- });
31
-
32
- const payload = {
33
- model: this.llmConfig.model,
34
- messages
35
- };
36
-
37
- if (options.temperature !== undefined) {
38
- payload.temperature = options.temperature;
39
- }
40
-
41
- if (options.json) {
42
- payload.response_format = {
43
- type: "json_object"
44
- };
45
- }
46
-
47
- const { data } = await this.client.post(
48
- "/chat/completions",
49
- payload
50
- );
51
-
52
- return {
53
- text: data.choices?.[0]?.message?.content || "",
54
- model: data.model,
55
- provider: "gemini",
56
- usage: {
57
- inputTokens: data.usage?.prompt_tokens || 0,
58
- outputTokens: data.usage?.completion_tokens || 0,
59
- totalTokens: data.usage?.total_tokens || 0
60
- },
61
- raw: data
62
- };
63
- }
64
- }
65
-
66
- module.exports = GeminiProvider;
@@ -1,91 +0,0 @@
1
-
2
- const axios = require("axios");
3
-
4
- class OpenAIProvider {
5
- constructor(llmConfig) {
6
- this.llmConfig = llmConfig;
7
-
8
- this.client = axios.create({
9
- baseURL: "https://api.openai.com/v1",
10
- headers: {
11
- Authorization: `Bearer ${llmConfig.apiKey}`,
12
- "Content-Type": "application/json"
13
- },
14
- timeout: 300000
15
- });
16
- }
17
-
18
- async generate(options) {
19
- const messages = [];
20
-
21
- if (options.system) {
22
- messages.push({
23
- role: "system",
24
- content: options.system
25
- });
26
- }
27
-
28
- messages.push({
29
- role: "user",
30
- content: options.json
31
- ? `${options.prompt}\n\nReturn the response as valid JSON. Do not include markdown code fences.`
32
- : options.prompt
33
- });
34
-
35
- const payload = {
36
- model: this.llmConfig.model,
37
- messages
38
- };
39
-
40
- if (options.temperature !== undefined) {
41
- payload.temperature = options.temperature;
42
- }
43
-
44
- if (options.maxTokens !== undefined) {
45
- payload.max_tokens = options.maxTokens;
46
- }
47
-
48
- if (options.json) {
49
- payload.response_format = {
50
- type: "json_object"
51
- };
52
- }
53
-
54
- if (options.responseFormat) {
55
- payload.response_format = options.responseFormat;
56
- }
57
-
58
- try {
59
- const { data } = await this.client.post(
60
- "/chat/completions",
61
- payload
62
- );
63
-
64
- const choice = data.choices?.[0];
65
-
66
- return {
67
- text: choice?.message?.content || "",
68
- model: data.model,
69
- provider: "openai",
70
- finishReason: choice?.finish_reason,
71
- usage: {
72
- inputTokens: data.usage?.prompt_tokens || 0,
73
- outputTokens: data.usage?.completion_tokens || 0,
74
- totalTokens: data.usage?.total_tokens || 0
75
- },
76
- raw: data
77
- };
78
-
79
- } catch (error) {
80
- throw new Error(
81
- `[OpenAI] ${error.response?.status || "ERROR"}: ${
82
- JSON.stringify(
83
- error.response?.data || error.message
84
- )
85
- }`
86
- );
87
- }
88
- }
89
- }
90
-
91
- module.exports = OpenAIProvider;