deeplyzer 0.1.0 → 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/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
 
@@ -74,6 +75,30 @@ Install Deeplyzer using npm:
74
75
  npm install deeplyzer
75
76
  ```
76
77
 
78
+ ## Command Line Usage
79
+
80
+ - **Supply a configuration file**
81
+
82
+ ```bash
83
+ deeplyzer configFile.json
84
+ ```
85
+
86
+ This creates graphs and workflows, then runs static and deep analysis.
87
+
88
+ - **Clear the session**
89
+
90
+ ```bash
91
+ deeplyzer clear-session
92
+ ```
93
+
94
+ - **Reset the analysis session**
95
+
96
+ ```bash
97
+ deeplyzer reset-analysis-session
98
+ ```
99
+
100
+ This resets the session and performs only static and deep analysis.
101
+
77
102
  ## Configuration
78
103
 
79
104
  Create a configuration file (e.g. `deeplyzer.json`) in your project root.
@@ -81,33 +106,59 @@ Create a configuration file (e.g. `deeplyzer.json`) in your project root.
81
106
  ```json
82
107
  {
83
108
  "sources": [],
84
- "source-exclusions": [],
109
+ "source_exclusions": [],
85
110
  "llm": {
86
- "provider": "openai",
111
+ "provider": "openai | gemini | claude",
87
112
  "model": "gpt-6.1-sol",
88
113
  "apiKey": "<API key goes here>"
89
114
  },
115
+ "log_path": "C:\\<local path>\\.logs",
90
116
  "build_graph": false,
117
+ "deep_analysis": true,
91
118
  "static_analysis": false,
92
119
  "batch_size": 10
93
120
  }
94
121
  ```
95
122
 
123
+ ### Minimum Configuration
124
+
125
+ ```json
126
+ {
127
+ "sources": ["C:\\<source folder>"],
128
+ "llm": {
129
+ "provider": "openai",
130
+ "model": "gpt-6.1-sol",
131
+ "apiKey": "<API key goes here>"
132
+ }
133
+ }
134
+ ```
135
+
96
136
  ### Configuration Options
97
137
 
98
138
  | Option | Required | Default | Description |
99
139
  |---|---|---|---|
100
140
  | `sources` | Yes | `[]` | Source files or directories to analyze. |
101
- | `source-exclusions` | No | `[]` | Files or directories to exclude from analysis. |
141
+ | `source_exclusions` | No | `[]` | Files or directories to exclude from analysis. |
102
142
  | `llm.provider` | Yes | - | LLM provider (`openai`, `claude`, `gemini`). |
103
143
  | `llm.model` | Yes | - | Model to use for analysis. |
104
144
  | `llm.apiKey` | Yes | - | API key for the selected LLM provider. |
105
145
  | `build_graph` | No | `true` | Build semantic code graphs. |
146
+ | `deep_analysis` | No | true | Enable deep LLM-based analysis. |
106
147
  | `static_analysis` | No | `true` | Enable static code analysis. |
107
148
  | `batch_size` | No | `10` | Number of sources processed in each batch. |
149
+ | `log_path` | No | - | Windows or platform-specific directory where logs are written (example: `C:\\deeplyzer\\.logs`). |
108
150
 
109
151
  **Note:** `build_graph`, `static_analysis`, and `batch_size` are optional. If omitted, their default values are used.
110
152
 
153
+ ## Links
154
+
155
+ - **GitHub Repository:** [github.com/areteqa/deeplyzer](https://github.com/areteqa/deeplyzer)
156
+ - **NPM Package:** [npmjs.com/package/deeplyzer](https://www.npmjs.com/package/deeplyzer)
157
+
158
+ ### Workflow Runners
159
+
160
+ - **deeplyzer-web-engine:** [npmjs.com/package/deeplyzer-web-engine](https://www.npmjs.com/package/deeplyzer-web-engine)
161
+
111
162
  ## License
112
163
 
113
164
  Deeplyzer is open-source software licensed under the [MIT License](LICENSE).
package/index.js CHANGED
@@ -1,13 +1,35 @@
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
+ if (argument === "reset-analysis-session") {
20
+ SessionManager.resetAnalysisSession();
21
+ console.log("[INFO] Session reset successfully.");
22
+ return;
23
+ }
24
+
25
+ // Normal execution
26
+ SessionManager.loadSession();
27
+
28
+ globals.config = _loadConfig(argument);
29
+
30
+ Logger.init();
9
31
 
10
- const engine = new Engine(config);
32
+ const engine = new Engine();
11
33
 
12
34
  await engine.run();
13
35
 
@@ -17,11 +39,15 @@ const path = require("path");
17
39
  }
18
40
  })();
19
41
 
20
- function _loadConfig() {
21
- const configPath = process.argv[2];
42
+ function _loadConfig(configPath) {
22
43
 
23
44
  if (!configPath) {
24
- throw new Error("Configuration file path is required.\nUsage: node index.js <config.json>");
45
+ throw new Error(
46
+ "Configuration file path or command is required.\n" +
47
+ "Usage:\n" +
48
+ " node index.js <config.json>\n" +
49
+ " node index.js clear-session"
50
+ );
25
51
  }
26
52
 
27
53
  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.4.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;