helixmind 0.1.0 → 0.1.2

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.
Files changed (75) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +207 -207
  3. package/dist/cli/agent/autonomous.js +65 -65
  4. package/dist/cli/agent/loop.d.ts.map +1 -1
  5. package/dist/cli/agent/loop.js +7 -0
  6. package/dist/cli/agent/loop.js.map +1 -1
  7. package/dist/cli/agent/permissions.d.ts.map +1 -1
  8. package/dist/cli/agent/permissions.js +3 -0
  9. package/dist/cli/agent/permissions.js.map +1 -1
  10. package/dist/cli/agent/sandbox.js +2 -2
  11. package/dist/cli/agent/sandbox.js.map +1 -1
  12. package/dist/cli/agent/tools/bug-list.d.ts +2 -0
  13. package/dist/cli/agent/tools/bug-list.d.ts.map +1 -0
  14. package/dist/cli/agent/tools/bug-list.js +82 -0
  15. package/dist/cli/agent/tools/bug-list.js.map +1 -0
  16. package/dist/cli/agent/tools/bug-report.d.ts +2 -0
  17. package/dist/cli/agent/tools/bug-report.d.ts.map +1 -0
  18. package/dist/cli/agent/tools/bug-report.js +130 -0
  19. package/dist/cli/agent/tools/bug-report.js.map +1 -0
  20. package/dist/cli/agent/tools/registry.d.ts +2 -0
  21. package/dist/cli/agent/tools/registry.d.ts.map +1 -1
  22. package/dist/cli/agent/tools/registry.js +2 -0
  23. package/dist/cli/agent/tools/registry.js.map +1 -1
  24. package/dist/cli/agent/tools/write-file.js +6 -11
  25. package/dist/cli/agent/tools/write-file.js.map +1 -1
  26. package/dist/cli/auth/callback-server.js +64 -64
  27. package/dist/cli/bench/prompt.js +59 -59
  28. package/dist/cli/brain/template.js +2067 -2067
  29. package/dist/cli/bugs/detector.d.ts +14 -0
  30. package/dist/cli/bugs/detector.d.ts.map +1 -0
  31. package/dist/cli/bugs/detector.js +108 -0
  32. package/dist/cli/bugs/detector.js.map +1 -0
  33. package/dist/cli/bugs/journal.d.ts +36 -0
  34. package/dist/cli/bugs/journal.d.ts.map +1 -0
  35. package/dist/cli/bugs/journal.js +179 -0
  36. package/dist/cli/bugs/journal.js.map +1 -0
  37. package/dist/cli/bugs/types.d.ts +27 -0
  38. package/dist/cli/bugs/types.d.ts.map +1 -0
  39. package/dist/cli/bugs/types.js +2 -0
  40. package/dist/cli/bugs/types.js.map +1 -0
  41. package/dist/cli/checkpoints/store.d.ts.map +1 -1
  42. package/dist/cli/checkpoints/store.js +2 -0
  43. package/dist/cli/checkpoints/store.js.map +1 -1
  44. package/dist/cli/commands/chat.d.ts.map +1 -1
  45. package/dist/cli/commands/chat.js +200 -82
  46. package/dist/cli/commands/chat.js.map +1 -1
  47. package/dist/cli/commands/helix-menu.js +27 -27
  48. package/dist/cli/commands/init.js +10 -10
  49. package/dist/cli/context/assembler.d.ts +1 -1
  50. package/dist/cli/context/assembler.d.ts.map +1 -1
  51. package/dist/cli/context/assembler.js +51 -47
  52. package/dist/cli/context/assembler.js.map +1 -1
  53. package/dist/cli/context/session-buffer.d.ts.map +1 -1
  54. package/dist/cli/context/session-buffer.js +2 -0
  55. package/dist/cli/context/session-buffer.js.map +1 -1
  56. package/dist/cli/providers/anthropic.d.ts +1 -0
  57. package/dist/cli/providers/anthropic.d.ts.map +1 -1
  58. package/dist/cli/providers/anthropic.js +3 -0
  59. package/dist/cli/providers/anthropic.js.map +1 -1
  60. package/dist/cli/providers/model-limits.d.ts +12 -0
  61. package/dist/cli/providers/model-limits.d.ts.map +1 -0
  62. package/dist/cli/providers/model-limits.js +63 -0
  63. package/dist/cli/providers/model-limits.js.map +1 -0
  64. package/dist/cli/providers/openai.d.ts +1 -0
  65. package/dist/cli/providers/openai.d.ts.map +1 -1
  66. package/dist/cli/providers/openai.js +10 -3
  67. package/dist/cli/providers/openai.js.map +1 -1
  68. package/dist/cli/providers/types.d.ts +2 -0
  69. package/dist/cli/providers/types.d.ts.map +1 -1
  70. package/dist/cli/validation/dynamic-checks.js +20 -20
  71. package/dist/storage/database.js +68 -68
  72. package/dist/storage/edges.js +3 -3
  73. package/dist/storage/nodes.js +3 -3
  74. package/dist/storage/vectors.js +16 -16
  75. package/package.json +90 -90
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- GNU AFFERO GENERAL PUBLIC LICENSE
2
- Version 3, 19 November 2007
3
-
4
- Copyright (C) 2025 HelixMind
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Affero General Public License as published
8
- by the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Affero General Public License for more details.
15
-
16
- You should have received a copy of the GNU Affero General Public License
17
- along with this program. If not, see <https://www.gnu.org/licenses/>.
18
-
19
- For the full license text, see:
20
- https://www.gnu.org/licenses/agpl-3.0.txt
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2025 HelixMind
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+
19
+ For the full license text, see:
20
+ https://www.gnu.org/licenses/agpl-3.0.txt
package/README.md CHANGED
@@ -1,207 +1,207 @@
1
- <div align="center">
2
-
3
- # 🧠 HelixMind
4
-
5
- **AI Coding Assistant with Persistent Spiral Memory**
6
-
7
- [![npm version](https://img.shields.io/npm/v/helixmind?color=blue&logo=npm)](https://www.npmjs.com/package/helixmind)
8
- [![License](https://img.shields.io/badge/License-AGPL_3.0-blue?logo=gnu)](LICENSE)
9
- [![Node](https://img.shields.io/badge/Node-18%2B-green?logo=node.js)](https://nodejs.org)
10
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue?logo=typescript)](https://www.typescriptlang.org/)
11
-
12
- *Remembers context across sessions. Learns from every interaction.*
13
-
14
- [Installation](#-installation) • [Features](#-features) • [Quick Start](#-quick-start) • [Documentation](#-documentation)
15
-
16
- </div>
17
-
18
- ---
19
-
20
- ## ✨ Features
21
-
22
- <table>
23
- <tr>
24
- <td width="50%">
25
-
26
- ### 🔄 Spiral Memory
27
- **5-level hierarchical memory** that persists across sessions. Context flows between levels based on relevance and recency.
28
-
29
- </td>
30
- <td width="50%">
31
-
32
- ### 🤖 Multi-Provider
33
- **Claude, GPT-4, Ollama** and more. Switch seamlessly between AI providers.
34
-
35
- </td>
36
- </tr>
37
- <tr>
38
- <td width="50%">
39
-
40
- ### ⚡ Autonomous Mode
41
- AI can **edit files, run commands, and commit changes** — fully autonomous when needed.
42
-
43
- </td>
44
- <td width="50%">
45
-
46
- ### 🎯 Smart Context
47
- **Auto-assembles relevant code** from your project. Understands dependencies and patterns.
48
-
49
- </td>
50
- </tr>
51
- </table>
52
-
53
- ---
54
-
55
- ## 🚀 Installation
56
-
57
- ```bash
58
- # Run directly (no install needed)
59
- npx helixmind
60
-
61
- # Or install globally
62
- npm install -g helixmind
63
- helixmind
64
- ```
65
-
66
- ---
67
-
68
- ## 🎮 Quick Start
69
-
70
- ```bash
71
- # Start interactive chat
72
- npx helixmind
73
-
74
- # Initialize in current project
75
- npx helixmind init
76
-
77
- # Run autonomous task
78
- npx helixmind "fix all lint errors in src/"
79
-
80
- # Continue last session
81
- npx helixmind --continue
82
-
83
- # Use specific model
84
- npx helixmind --model claude-sonnet-4-20250514
85
- ```
86
-
87
- ---
88
-
89
- ## 📋 Commands
90
-
91
- | Command | Description |
92
- |:--------|:------------|
93
- | `helixmind` | 🎯 Start interactive chat |
94
- | `helixmind init` | ⚙️ Initialize HelixMind in project |
95
- | `helixmind --continue` | ▶️ Resume last session |
96
- | `helixmind --model <name>` | 🤖 Use specific model |
97
- | `helixmind --help` | ❓ Show all options |
98
-
99
- ### ⌨️ Keyboard Shortcuts
100
-
101
- | Key | Action |
102
- |:----|:-------|
103
- | `Ctrl+C` | 🛑 Exit |
104
- | `Ctrl+L` | 🧹 Clear screen |
105
- | `Ctrl+D` | 🐛 Toggle debug mode |
106
- | `Tab` | ✨ Autocomplete command |
107
-
108
- ---
109
-
110
- ## 🧠 Memory Architecture
111
-
112
- ```
113
- ┌─────────────────────────────────────────────────────┐
114
- │ Level 1 — 🔍 Focus │
115
- │ Most relevant, recent context │
116
- ├─────────────────────────────────────────────────────┤
117
- │ Level 2 — ⚡ Active │
118
- │ Related files, dependencies │
119
- ├─────────────────────────────────────────────────────┤
120
- │ Level 3 — 📚 Reference │
121
- │ Decisions, patterns, code structure │
122
- ├─────────────────────────────────────────────────────┤
123
- │ Level 4 — 📦 Archive │
124
- │ Compressed summaries, old sessions │
125
- ├─────────────────────────────────────────────────────┤
126
- │ Level 5 — 🗄️ Deep Archive │
127
- │ Long-term knowledge, project history │
128
- └─────────────────────────────────────────────────────┘
129
- ```
130
-
131
- Context automatically flows between levels based on relevance and recency.
132
-
133
- ---
134
-
135
- ## ⚙️ Configuration
136
-
137
- Create `.helixmind/config.json` in your project:
138
-
139
- ```json
140
- {
141
- "provider": "anthropic",
142
- "model": "claude-sonnet-4-20250514",
143
- "brainEnabled": true,
144
- "permissions": {
145
- "writeFiles": true,
146
- "runCommands": true,
147
- "gitCommit": true
148
- }
149
- }
150
- ```
151
-
152
- ### 🔑 Environment Variables
153
-
154
- ```bash
155
- ANTHROPIC_API_KEY=sk-ant-... # For Claude
156
- OPENAI_API_KEY=sk-... # For OpenAI/GPT
157
- ```
158
-
159
- ---
160
-
161
- ## 🛠️ Tech Stack
162
-
163
- | Category | Technology |
164
- |:---------|:-----------|
165
- | Language | ![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue) |
166
- | AI SDKs | ![Anthropic](https://img.shields.io/badge/Anthropic-SDK-orange) ![OpenAI](https://img.shields.io/badge/OpenAI-SDK-green) |
167
- | Database | ![SQLite](https://img.shields.io/badge/SQLite-better--sqlite3-lightgrey) |
168
- | Embeddings | ![Transformers](https://img.shields.io/badge/HuggingFace-Transformers-yellow) |
169
- | Testing | ![Vitest](https://img.shields.io/badge/Vitest-testing-yellowgreen) |
170
-
171
- ---
172
-
173
- ## 🏗️ Development
174
-
175
- ```bash
176
- # Clone repo
177
- git clone https://github.com/DancingTedDanson011/HelixMind.git
178
- cd HelixMind
179
-
180
- # Install dependencies
181
- npm install
182
-
183
- # Build
184
- npm run build
185
-
186
- # Run in dev mode
187
- npm run dev
188
-
189
- # Run tests
190
- npm test
191
- ```
192
-
193
- ---
194
-
195
- ## 📄 License
196
-
197
- [AGPL-3.0](LICENSE) — Free for open-source use. Commercial licenses available.
198
-
199
- ---
200
-
201
- <div align="center">
202
-
203
- **Made with ❤️ by [HelixMind](https://github.com/DancingTedDanson011)**
204
-
205
- [⬆ Back to Top](#-helixmind)
206
-
207
- </div>
1
+ <div align="center">
2
+
3
+ # 🧠 HelixMind
4
+
5
+ **AI Coding Assistant with Persistent Spiral Memory**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/helixmind?color=blue&logo=npm)](https://www.npmjs.com/package/helixmind)
8
+ [![License](https://img.shields.io/badge/License-AGPL_3.0-blue?logo=gnu)](LICENSE)
9
+ [![Node](https://img.shields.io/badge/Node-18%2B-green?logo=node.js)](https://nodejs.org)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue?logo=typescript)](https://www.typescriptlang.org/)
11
+
12
+ *Remembers context across sessions. Learns from every interaction.*
13
+
14
+ [Installation](#-installation) • [Features](#-features) • [Quick Start](#-quick-start) • [Documentation](#-documentation)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✨ Features
21
+
22
+ <table>
23
+ <tr>
24
+ <td width="50%">
25
+
26
+ ### 🔄 Spiral Memory
27
+ **5-level hierarchical memory** that persists across sessions. Context flows between levels based on relevance and recency.
28
+
29
+ </td>
30
+ <td width="50%">
31
+
32
+ ### 🤖 Multi-Provider
33
+ **Claude, GPT-4, Ollama** and more. Switch seamlessly between AI providers.
34
+
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td width="50%">
39
+
40
+ ### ⚡ Autonomous Mode
41
+ AI can **edit files, run commands, and commit changes** — fully autonomous when needed.
42
+
43
+ </td>
44
+ <td width="50%">
45
+
46
+ ### 🎯 Smart Context
47
+ **Auto-assembles relevant code** from your project. Understands dependencies and patterns.
48
+
49
+ </td>
50
+ </tr>
51
+ </table>
52
+
53
+ ---
54
+
55
+ ## 🚀 Installation
56
+
57
+ ```bash
58
+ # Run directly (no install needed)
59
+ npx helixmind
60
+
61
+ # Or install globally
62
+ npm install -g helixmind
63
+ helixmind
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 🎮 Quick Start
69
+
70
+ ```bash
71
+ # Start interactive chat
72
+ npx helixmind
73
+
74
+ # Initialize in current project
75
+ npx helixmind init
76
+
77
+ # Run autonomous task
78
+ npx helixmind "fix all lint errors in src/"
79
+
80
+ # Continue last session
81
+ npx helixmind --continue
82
+
83
+ # Use specific model
84
+ npx helixmind --model claude-sonnet-4-20250514
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 📋 Commands
90
+
91
+ | Command | Description |
92
+ |:--------|:------------|
93
+ | `helixmind` | 🎯 Start interactive chat |
94
+ | `helixmind init` | ⚙️ Initialize HelixMind in project |
95
+ | `helixmind --continue` | ▶️ Resume last session |
96
+ | `helixmind --model <name>` | 🤖 Use specific model |
97
+ | `helixmind --help` | ❓ Show all options |
98
+
99
+ ### ⌨️ Keyboard Shortcuts
100
+
101
+ | Key | Action |
102
+ |:----|:-------|
103
+ | `Ctrl+C` | 🛑 Exit |
104
+ | `Ctrl+L` | 🧹 Clear screen |
105
+ | `Ctrl+D` | 🐛 Toggle debug mode |
106
+ | `Tab` | ✨ Autocomplete command |
107
+
108
+ ---
109
+
110
+ ## 🧠 Memory Architecture
111
+
112
+ ```
113
+ ┌─────────────────────────────────────────────────────┐
114
+ │ Level 1 — 🔍 Focus │
115
+ │ Most relevant, recent context │
116
+ ├─────────────────────────────────────────────────────┤
117
+ │ Level 2 — ⚡ Active │
118
+ │ Related files, dependencies │
119
+ ├─────────────────────────────────────────────────────┤
120
+ │ Level 3 — 📚 Reference │
121
+ │ Decisions, patterns, code structure │
122
+ ├─────────────────────────────────────────────────────┤
123
+ │ Level 4 — 📦 Archive │
124
+ │ Compressed summaries, old sessions │
125
+ ├─────────────────────────────────────────────────────┤
126
+ │ Level 5 — 🗄️ Deep Archive │
127
+ │ Long-term knowledge, project history │
128
+ └─────────────────────────────────────────────────────┘
129
+ ```
130
+
131
+ Context automatically flows between levels based on relevance and recency.
132
+
133
+ ---
134
+
135
+ ## ⚙️ Configuration
136
+
137
+ Create `.helixmind/config.json` in your project:
138
+
139
+ ```json
140
+ {
141
+ "provider": "anthropic",
142
+ "model": "claude-sonnet-4-20250514",
143
+ "brainEnabled": true,
144
+ "permissions": {
145
+ "writeFiles": true,
146
+ "runCommands": true,
147
+ "gitCommit": true
148
+ }
149
+ }
150
+ ```
151
+
152
+ ### 🔑 Environment Variables
153
+
154
+ ```bash
155
+ ANTHROPIC_API_KEY=sk-ant-... # For Claude
156
+ OPENAI_API_KEY=sk-... # For OpenAI/GPT
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🛠️ Tech Stack
162
+
163
+ | Category | Technology |
164
+ |:---------|:-----------|
165
+ | Language | ![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue) |
166
+ | AI SDKs | ![Anthropic](https://img.shields.io/badge/Anthropic-SDK-orange) ![OpenAI](https://img.shields.io/badge/OpenAI-SDK-green) |
167
+ | Database | ![SQLite](https://img.shields.io/badge/SQLite-better--sqlite3-lightgrey) |
168
+ | Embeddings | ![Transformers](https://img.shields.io/badge/HuggingFace-Transformers-yellow) |
169
+ | Testing | ![Vitest](https://img.shields.io/badge/Vitest-testing-yellowgreen) |
170
+
171
+ ---
172
+
173
+ ## 🏗️ Development
174
+
175
+ ```bash
176
+ # Clone repo
177
+ git clone https://github.com/DancingTedDanson011/HelixMind.git
178
+ cd HelixMind
179
+
180
+ # Install dependencies
181
+ npm install
182
+
183
+ # Build
184
+ npm run build
185
+
186
+ # Run in dev mode
187
+ npm run dev
188
+
189
+ # Run tests
190
+ npm test
191
+ ```
192
+
193
+ ---
194
+
195
+ ## 📄 License
196
+
197
+ [AGPL-3.0](LICENSE) — Free for open-source use. Commercial licenses available.
198
+
199
+ ---
200
+
201
+ <div align="center">
202
+
203
+ **Made with ❤️ by [HelixMind](https://github.com/DancingTedDanson011)**
204
+
205
+ [⬆ Back to Top](#-helixmind)
206
+
207
+ </div>
@@ -4,80 +4,80 @@
4
4
  */
5
5
  import chalk from 'chalk';
6
6
  import { renderInfo } from '../ui/chat-view.js';
7
- const SCAN_PROMPT = `You are in AUTONOMOUS MODE. Scan this repository thoroughly for the most impactful issue to fix.
8
-
9
- Priority order:
10
- 1. CRITICAL bugs or logic errors that cause crashes or wrong behavior
11
- 2. Security vulnerabilities (injection, path traversal, hardcoded secrets)
12
- 3. Missing error handling that could cause unhandled exceptions
13
- 4. Broken or missing tests for important functionality
14
- 5. Performance bottlenecks
15
- 6. Dead code, unused imports, inconsistent patterns
16
- 7. Code quality improvements
17
-
18
- RULES:
19
- - Pick ONE issue — the most impactful one
20
- - Fix it completely (code + test if applicable)
21
- - End with a single-line summary starting with "DONE:" describing what you fixed
7
+ const SCAN_PROMPT = `You are in AUTONOMOUS MODE. Scan this repository thoroughly for the most impactful issue to fix.
8
+
9
+ Priority order:
10
+ 1. CRITICAL bugs or logic errors that cause crashes or wrong behavior
11
+ 2. Security vulnerabilities (injection, path traversal, hardcoded secrets)
12
+ 3. Missing error handling that could cause unhandled exceptions
13
+ 4. Broken or missing tests for important functionality
14
+ 5. Performance bottlenecks
15
+ 6. Dead code, unused imports, inconsistent patterns
16
+ 7. Code quality improvements
17
+
18
+ RULES:
19
+ - Pick ONE issue — the most impactful one
20
+ - Fix it completely (code + test if applicable)
21
+ - End with a single-line summary starting with "DONE:" describing what you fixed
22
22
  - If you genuinely cannot find ANY issue worth fixing, respond with exactly: ALL_TASKS_COMPLETE`;
23
23
  function continuePrompt(completed) {
24
- return `You are in AUTONOMOUS MODE (round ${completed.length + 1}).
25
-
26
- Already completed:
27
- ${completed.map((t, i) => ` ${i + 1}. ${t}`).join('\n')}
28
-
29
- Continue scanning for MORE issues in DIFFERENT areas of the codebase.
30
- Pick the next most impactful issue and fix it completely.
31
-
32
- End with a single-line summary starting with "DONE:" describing what you fixed.
24
+ return `You are in AUTONOMOUS MODE (round ${completed.length + 1}).
25
+
26
+ Already completed:
27
+ ${completed.map((t, i) => ` ${i + 1}. ${t}`).join('\n')}
28
+
29
+ Continue scanning for MORE issues in DIFFERENT areas of the codebase.
30
+ Pick the next most impactful issue and fix it completely.
31
+
32
+ End with a single-line summary starting with "DONE:" describing what you fixed.
33
33
  If you genuinely cannot find anything more to improve: ALL_TASKS_COMPLETE`;
34
34
  }
35
- export const SECURITY_PROMPT = `Perform a comprehensive SECURITY AUDIT of this codebase.
36
-
37
- Check every file systematically for:
38
- 1. **Command Injection** — user input passed to shell commands without sanitization
39
- 2. **Path Traversal** — user-controlled paths that could escape the project root
40
- 3. **XSS / Injection** — unsanitized output in HTML/templates
41
- 4. **Hardcoded Secrets** — API keys, passwords, tokens in source code
42
- 5. **Insecure Dependencies** — check package.json for known vulnerable packages
43
- 6. **Missing Input Validation** — unvalidated user input at boundaries
44
- 7. **Unsafe File Operations** — writing to arbitrary paths, following symlinks
45
- 8. **Information Disclosure** — verbose error messages, debug endpoints
46
- 9. **Authentication Issues** — missing auth checks, weak token generation
47
- 10. **Race Conditions** — TOCTOU, concurrent access without locks
48
-
49
- For EACH finding, report:
50
- - **Severity**: CRITICAL / HIGH / MEDIUM / LOW
51
- - **File**: exact file path and line number
52
- - **Issue**: what's wrong and why it's dangerous
53
- - **Fix**: specific code change needed
54
-
35
+ export const SECURITY_PROMPT = `Perform a comprehensive SECURITY AUDIT of this codebase.
36
+
37
+ Check every file systematically for:
38
+ 1. **Command Injection** — user input passed to shell commands without sanitization
39
+ 2. **Path Traversal** — user-controlled paths that could escape the project root
40
+ 3. **XSS / Injection** — unsanitized output in HTML/templates
41
+ 4. **Hardcoded Secrets** — API keys, passwords, tokens in source code
42
+ 5. **Insecure Dependencies** — check package.json for known vulnerable packages
43
+ 6. **Missing Input Validation** — unvalidated user input at boundaries
44
+ 7. **Unsafe File Operations** — writing to arbitrary paths, following symlinks
45
+ 8. **Information Disclosure** — verbose error messages, debug endpoints
46
+ 9. **Authentication Issues** — missing auth checks, weak token generation
47
+ 10. **Race Conditions** — TOCTOU, concurrent access without locks
48
+
49
+ For EACH finding, report:
50
+ - **Severity**: CRITICAL / HIGH / MEDIUM / LOW
51
+ - **File**: exact file path and line number
52
+ - **Issue**: what's wrong and why it's dangerous
53
+ - **Fix**: specific code change needed
54
+
55
55
  After the report, automatically fix all CRITICAL and HIGH severity issues.`;
56
56
  function goalPrompt(goal) {
57
- return `You are in AUTONOMOUS MODE with a specific goal.
58
-
59
- GOAL: ${goal}
60
-
61
- Work on this goal step by step. Break it down into subtasks if needed.
62
- Fix, implement, or change whatever is necessary to achieve the goal.
63
-
64
- RULES:
65
- - Focus exclusively on the given goal
66
- - Work methodically — one subtask at a time
67
- - End each round with a single-line summary starting with "DONE:" describing what you accomplished
57
+ return `You are in AUTONOMOUS MODE with a specific goal.
58
+
59
+ GOAL: ${goal}
60
+
61
+ Work on this goal step by step. Break it down into subtasks if needed.
62
+ Fix, implement, or change whatever is necessary to achieve the goal.
63
+
64
+ RULES:
65
+ - Focus exclusively on the given goal
66
+ - Work methodically — one subtask at a time
67
+ - End each round with a single-line summary starting with "DONE:" describing what you accomplished
68
68
  - When the goal is fully achieved, respond with exactly: ALL_TASKS_COMPLETE`;
69
69
  }
70
70
  function continueGoalPrompt(goal, completed) {
71
- return `You are in AUTONOMOUS MODE (round ${completed.length + 1}).
72
-
73
- GOAL: ${goal}
74
-
75
- Already completed:
76
- ${completed.map((t, i) => ` ${i + 1}. ${t}`).join('\n')}
77
-
78
- Continue working towards the goal. Pick the next subtask and complete it.
79
-
80
- End with a single-line summary starting with "DONE:" describing what you accomplished.
71
+ return `You are in AUTONOMOUS MODE (round ${completed.length + 1}).
72
+
73
+ GOAL: ${goal}
74
+
75
+ Already completed:
76
+ ${completed.map((t, i) => ` ${i + 1}. ${t}`).join('\n')}
77
+
78
+ Continue working towards the goal. Pick the next subtask and complete it.
79
+
80
+ End with a single-line summary starting with "DONE:" describing what you accomplished.
81
81
  When the goal is fully achieved: ALL_TASKS_COMPLETE`;
82
82
  }
83
83
  export async function runAutonomousLoop(callbacks, initialGoal) {
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/cli/agent/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAIZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,GAAE,MAAwB;CAI9C;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,CAAC,EA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,CAEvB;IAED,iEAAiE;IACjE,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IASd;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IAUP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC,kEAAkE;IAClE,KAAK,IAAI,IAAI;CAMd"}
@@ -3,6 +3,7 @@ import { renderToolCall, renderToolResult, renderToolDenied, resetToolCounter, r
3
3
  import { renderAssistantEnd } from '../ui/chat-view.js';
4
4
  import { captureFileSnapshots, fillSnapshotAfter } from '../checkpoints/revert.js';
5
5
  import { isRateLimitError, handleRateLimitError, detectCreditsExhausted } from '../providers/rate-limiter.js';
6
+ import { trimConversation, estimateTokens } from '../context/trimmer.js';
6
7
  export class AgentAbortError extends Error {
7
8
  constructor(message = 'Agent aborted') {
8
9
  super(message);
@@ -41,6 +42,10 @@ export async function runAgentLoop(userMessage, conversationHistory, options, co
41
42
  }
42
43
  // Signal activity indicator: we're about to call the LLM
43
44
  onThinking?.();
45
+ // Auto-trim before each LLM call to prevent context overflow
46
+ const systemTokens = estimateTokens([{ role: 'user', content: systemPrompt }]);
47
+ const availableBudget = Math.floor(provider.maxContextLength * 0.85) - systemTokens;
48
+ trimConversation(messages, availableBudget, sessionBuffer);
44
49
  // Call the LLM with tools — pass abort signal for hard cancellation
45
50
  let response;
46
51
  try {
@@ -255,6 +260,8 @@ function summarizeToolForStep(name, input) {
255
260
  case 'git_log': return 'git log';
256
261
  case 'spiral_query': return 'querying spiral';
257
262
  case 'spiral_store': return 'storing in spiral';
263
+ case 'bug_report': return `bug ${input.action || 'update'}`;
264
+ case 'bug_list': return 'listing bugs';
258
265
  default: return name;
259
266
  }
260
267
  }