brainforge-ai 1.0.0 → 1.0.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.
- package/README.md +313 -147
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +131 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/serve.d.ts +2 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +162 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/core/templates.d.ts.map +1 -1
- package/dist/core/templates.js +98 -0
- package/dist/core/templates.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# ⚡ BrainForge
|
|
2
2
|
|
|
3
|
-
> Transform any idea into a structured, AI-assisted project — with agents, slash commands, a phase roadmap, persistent memory, and a live
|
|
3
|
+
> Transform any idea into a structured, AI-assisted project — with agents, slash commands, a phase roadmap, persistent memory, and a live dashboard.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/brainforge-ai)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
4
8
|
|
|
5
9
|
```bash
|
|
6
10
|
npx brainforge-ai init
|
|
@@ -10,72 +14,131 @@ npx brainforge-ai init
|
|
|
10
14
|
|
|
11
15
|
## What is BrainForge?
|
|
12
16
|
|
|
13
|
-
BrainForge is a CLI that installs a
|
|
14
|
-
|
|
15
|
-
It gives you:
|
|
17
|
+
BrainForge is a CLI that installs a **structured AI development system** into any project directory.
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
- **15 slash commands** (`/start-project`, `/create-roadmap`, `/execute-phase`, `/humanize-code`, `/professor-check`…)
|
|
19
|
-
- **Project memory** (architecture, coding style, known bugs, glossary, decisions)
|
|
20
|
-
- **Phase-based roadmap** with validation checklists
|
|
21
|
-
- **HTML dashboard** showing progress, commits, bugs, and decisions
|
|
22
|
-
- **Git checkpoints** (local only — never pushes)
|
|
23
|
-
- **Multi-AI compatibility** files (Claude Code, Codex, Gemini CLI, OpenCode, Cursor)
|
|
24
|
-
- **Code Level Engine** (beginner / intermediate / academic-realistic / professional)
|
|
19
|
+
Instead of vibing and hoping the AI does the right thing, BrainForge forces a clean workflow:
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
```
|
|
22
|
+
Idea → Plan → Research → Execute → Test → Review → Commit → Repeat
|
|
23
|
+
```
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
- Beginners doing vibe-coding
|
|
30
|
-
- Developers using Claude Code, Codex, Gemini CLI, Cursor, or Copilot
|
|
31
|
-
- Anyone who wants structure before they start coding
|
|
25
|
+
It works with any AI tool: **Claude Code**, **GitHub Copilot**, **Gemini CLI**, **Codex**, **Cursor**, **OpenCode**.
|
|
32
26
|
|
|
33
27
|
---
|
|
34
28
|
|
|
35
|
-
##
|
|
29
|
+
## Why use it?
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
→ repeat per phase
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**Rule:** The AI never codes without a plan. Always plan before executing.
|
|
31
|
+
| Without BrainForge | With BrainForge |
|
|
32
|
+
|--------------------|-----------------|
|
|
33
|
+
| AI codes everything at once | AI follows a phase plan |
|
|
34
|
+
| No memory between sessions | Persistent project memory |
|
|
35
|
+
| Hard to explain your code | `/explain-my-code` generates your defense speech |
|
|
36
|
+
| Code looks too AI-perfect | Code Level Engine adapts to your real level |
|
|
37
|
+
| No tests | `/write-tests` generates the right tests for your level |
|
|
38
|
+
| No version history | Automatic git checkpoints |
|
|
39
|
+
| Lost in files | Live dashboard with auto-reload |
|
|
50
40
|
|
|
51
41
|
---
|
|
52
42
|
|
|
53
|
-
## Installation
|
|
43
|
+
## Installation
|
|
54
44
|
|
|
55
|
-
###
|
|
45
|
+
### Run directly (no install needed)
|
|
56
46
|
|
|
57
47
|
```bash
|
|
58
48
|
npx brainforge-ai init
|
|
59
49
|
```
|
|
60
50
|
|
|
61
|
-
###
|
|
51
|
+
### Install globally
|
|
62
52
|
|
|
63
53
|
```bash
|
|
64
54
|
npm install -g brainforge-ai
|
|
65
55
|
brainforge init
|
|
66
56
|
```
|
|
67
57
|
|
|
68
|
-
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
### 1. Initialize BrainForge in your project
|
|
69
63
|
|
|
70
64
|
```bash
|
|
71
|
-
|
|
72
|
-
cd
|
|
73
|
-
|
|
74
|
-
npm run build
|
|
75
|
-
npm link
|
|
76
|
-
brainforge init
|
|
65
|
+
mkdir my-project
|
|
66
|
+
cd my-project
|
|
67
|
+
npx brainforge-ai init
|
|
77
68
|
```
|
|
78
69
|
|
|
70
|
+
Answer the questions:
|
|
71
|
+
- Project name and description
|
|
72
|
+
- Project type (web app, API, fullstack, mobile…)
|
|
73
|
+
- Stack (React, Node.js, PostgreSQL…)
|
|
74
|
+
- Your actual coding level
|
|
75
|
+
- Target code level
|
|
76
|
+
- Whether it's a school project
|
|
77
|
+
|
|
78
|
+
BrainForge generates the full structure and makes the first git commit automatically.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### 2. Open your AI tool and start working
|
|
83
|
+
|
|
84
|
+
Open **Claude Code**, **Cursor**, or any AI tool in the project folder.
|
|
85
|
+
|
|
86
|
+
The AI reads `AGENTS.md` automatically and knows the rules.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### 3. Follow the workflow with slash commands
|
|
91
|
+
|
|
92
|
+
#### Step 1 — Document the project
|
|
93
|
+
```
|
|
94
|
+
/start-project
|
|
95
|
+
```
|
|
96
|
+
Describe your idea. The AI asks questions and fills in `.brainforge/project.md`.
|
|
97
|
+
|
|
98
|
+
#### Step 2 — Create the roadmap
|
|
99
|
+
```
|
|
100
|
+
/create-roadmap
|
|
101
|
+
```
|
|
102
|
+
Breaks the project into phases with tasks and checklists.
|
|
103
|
+
|
|
104
|
+
#### Step 3 — Prepare a phase (before coding)
|
|
105
|
+
```
|
|
106
|
+
/initiate-phase 1
|
|
107
|
+
```
|
|
108
|
+
Research + planning. The AI proposes an approach and waits for your confirmation.
|
|
109
|
+
|
|
110
|
+
#### Step 4 — Execute the phase
|
|
111
|
+
```
|
|
112
|
+
/execute-phase 1
|
|
113
|
+
```
|
|
114
|
+
The AI codes **only what was planned**. Nothing more.
|
|
115
|
+
|
|
116
|
+
#### Step 5 — Write tests
|
|
117
|
+
```
|
|
118
|
+
/write-tests
|
|
119
|
+
```
|
|
120
|
+
Generates tests adapted to your stack and code level.
|
|
121
|
+
|
|
122
|
+
#### Step 6 — Review the phase
|
|
123
|
+
```
|
|
124
|
+
/review-phase 1
|
|
125
|
+
```
|
|
126
|
+
Checks for bugs, dead code, complexity, and level-appropriateness.
|
|
127
|
+
|
|
128
|
+
#### Step 7 — Save your progress
|
|
129
|
+
```
|
|
130
|
+
/checkpoint
|
|
131
|
+
```
|
|
132
|
+
Creates a local git commit. Never pushes automatically.
|
|
133
|
+
|
|
134
|
+
#### Step 8 — Watch the dashboard update live
|
|
135
|
+
```bash
|
|
136
|
+
brainforge serve
|
|
137
|
+
```
|
|
138
|
+
Opens `localhost:3000` — reloads automatically as you work.
|
|
139
|
+
|
|
140
|
+
Repeat steps 3–8 for each phase.
|
|
141
|
+
|
|
79
142
|
---
|
|
80
143
|
|
|
81
144
|
## CLI Commands
|
|
@@ -83,171 +146,274 @@ brainforge init
|
|
|
83
146
|
| Command | Description |
|
|
84
147
|
|---------|-------------|
|
|
85
148
|
| `brainforge init` | Initialize BrainForge in the current directory |
|
|
86
|
-
| `brainforge
|
|
87
|
-
| `brainforge dashboard` | Open the HTML dashboard in
|
|
88
|
-
| `brainforge update-dashboard` | Refresh dashboard data from
|
|
149
|
+
| `brainforge serve` | Live dashboard on localhost:3000 (auto-reloads) |
|
|
150
|
+
| `brainforge dashboard` | Open the static HTML dashboard in the browser |
|
|
151
|
+
| `brainforge update-dashboard` | Refresh dashboard data from project state |
|
|
152
|
+
| `brainforge doctor` | Health check — verify all files and setup |
|
|
153
|
+
| `brainforge guide` | Show all CLI and slash commands with project status |
|
|
89
154
|
| `brainforge version` | Show version info |
|
|
90
155
|
|
|
91
156
|
---
|
|
92
157
|
|
|
93
|
-
##
|
|
158
|
+
## Slash Commands
|
|
159
|
+
|
|
160
|
+
These are prompt files in `.brainforge/commands/` — paste the command name into your AI tool.
|
|
161
|
+
|
|
162
|
+
### Project Setup
|
|
163
|
+
|
|
164
|
+
| Command | What it does |
|
|
165
|
+
|---------|-------------|
|
|
166
|
+
| `/start-project` | Document your idea and gather all project info |
|
|
167
|
+
| `/create-roadmap` | Break project into phases (Epic › Feature › Task) |
|
|
168
|
+
|
|
169
|
+
### Phase Workflow
|
|
170
|
+
|
|
171
|
+
| Command | What it does |
|
|
172
|
+
|---------|-------------|
|
|
173
|
+
| `/initiate-phase N` | Research + plan phase N before any coding |
|
|
174
|
+
| `/execute-phase N` | Code phase N following the plan exactly |
|
|
175
|
+
| `/review-phase N` | Quality review — bugs, level check, academic check |
|
|
176
|
+
| `/checkpoint` | Local git commit (never pushes automatically) |
|
|
177
|
+
|
|
178
|
+
### Code Quality
|
|
179
|
+
|
|
180
|
+
| Command | What it does |
|
|
181
|
+
|---------|-------------|
|
|
182
|
+
| `/write-tests` | Generate tests for a file, function, or phase |
|
|
183
|
+
| `/humanize-code` | Adapt code to match your real coding level |
|
|
184
|
+
| `/debug-issue` | Systematic bug analysis and fix |
|
|
185
|
+
|
|
186
|
+
### Student Tools
|
|
187
|
+
|
|
188
|
+
| Command | What it does |
|
|
189
|
+
|---------|-------------|
|
|
190
|
+
| `/explain-my-code` | Generate an explanation for your professor or team |
|
|
191
|
+
| `/professor-check` | Detect code that looks suspiciously AI-generated |
|
|
192
|
+
| `/generate-report` | Generate an academic report template |
|
|
193
|
+
|
|
194
|
+
### Documentation & UI
|
|
195
|
+
|
|
196
|
+
| Command | What it does |
|
|
197
|
+
|---------|-------------|
|
|
198
|
+
| `/design-system` | Create a UI/UX design system guide |
|
|
199
|
+
| `/generate-docs` | Generate README and docs/ folder |
|
|
200
|
+
| `/update-dashboard` | Refresh the HTML dashboard data |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## The Live Dashboard
|
|
205
|
+
|
|
206
|
+
Run `brainforge serve` to open a live dashboard at `localhost:3000`.
|
|
207
|
+
|
|
208
|
+
It **auto-reloads** every time a file in `.brainforge/` changes — no manual refresh needed.
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
brainforge serve # localhost:3000
|
|
212
|
+
brainforge serve --port 4000 # custom port
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
It shows:
|
|
216
|
+
- Project name, description, stack, and level
|
|
217
|
+
- Phase progress bar
|
|
218
|
+
- Status of each phase (pending / in-progress / done)
|
|
219
|
+
- Recent git commits
|
|
220
|
+
- Known bugs
|
|
221
|
+
- Last architecture decisions
|
|
222
|
+
- Git status
|
|
223
|
+
- A green dot in the corner when live reload is active
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Code Level Engine
|
|
228
|
+
|
|
229
|
+
BrainForge adapts all generated and reviewed code to your target level:
|
|
230
|
+
|
|
231
|
+
| Level | Who it's for | What it produces |
|
|
232
|
+
|-------|-------------|-----------------|
|
|
233
|
+
| `beginner` | First year students | Simple functions, direct logic, FR comments |
|
|
234
|
+
| `intermediate` | 1-3 years experience | Clean structure, reusable components |
|
|
235
|
+
| `academic-realistic` | School / PFA projects | Credible student code — clean but explainable |
|
|
236
|
+
| `professional` | Production projects | Typed, tested, secure, scalable |
|
|
237
|
+
|
|
238
|
+
### The `academic-realistic` level
|
|
239
|
+
|
|
240
|
+
The most important level for students. It produces code that:
|
|
241
|
+
|
|
242
|
+
- ✅ Is clean enough to get a good grade
|
|
243
|
+
- ✅ Is simple enough to explain line by line in an oral defense
|
|
244
|
+
- ✅ Has no enterprise patterns that would raise suspicion
|
|
245
|
+
- ✅ Looks like it was written by a good student, not a senior engineer
|
|
246
|
+
- ✅ Has natural comments — not AI-generated-sounding ones
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## `/write-tests` — Test Generator
|
|
94
251
|
|
|
95
|
-
|
|
252
|
+
The `/write-tests` command generates tests adapted to your project:
|
|
253
|
+
|
|
254
|
+
- **Detects the right framework** automatically (Jest, Vitest, pytest, PHPUnit…)
|
|
255
|
+
- **Adapts test complexity** to your code level
|
|
256
|
+
- **Beginner:** 2-3 tests per function, happy path only, no mocks
|
|
257
|
+
- **Academic-realistic:** happy path + edge cases, mocks for external services, readable names
|
|
258
|
+
- **Professional:** full coverage, integration tests, all error paths
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
/write-tests src/auth/login.ts
|
|
262
|
+
/write-tests the login feature
|
|
263
|
+
/write-tests phase 2
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Project Structure
|
|
269
|
+
|
|
270
|
+
After `brainforge init`, your project contains:
|
|
96
271
|
|
|
97
272
|
```
|
|
98
273
|
.brainforge/
|
|
99
|
-
config.json ← project
|
|
274
|
+
config.json ← project config (level, stack, phases…)
|
|
100
275
|
project.md ← project definition
|
|
101
|
-
questions.md ←
|
|
102
|
-
decisions.md ← architecture
|
|
103
|
-
roadmap.md ← full
|
|
276
|
+
questions.md ← answered questions from init
|
|
277
|
+
decisions.md ← architecture decision log
|
|
278
|
+
roadmap.md ← full roadmap
|
|
104
279
|
memory/
|
|
105
|
-
architecture.md ← technical
|
|
280
|
+
architecture.md ← technical notes (updated each phase)
|
|
106
281
|
coding-style.md ← code level rules
|
|
107
282
|
known-bugs.md ← bug tracker
|
|
108
283
|
glossary.md ← project vocabulary
|
|
109
|
-
design-system.md ← UI/UX
|
|
284
|
+
design-system.md ← UI/UX guide
|
|
110
285
|
phases/
|
|
111
|
-
phase-01.md ←
|
|
286
|
+
phase-01.md ← plan + checklist for phase 1
|
|
112
287
|
phase-02.md
|
|
113
288
|
agents/
|
|
114
|
-
architect.md ← Architect agent
|
|
115
|
-
researcher.md
|
|
116
|
-
planner.md
|
|
117
|
-
coder.md
|
|
118
|
-
reviewer.md
|
|
119
|
-
teacher.md
|
|
120
|
-
git-agent.md
|
|
121
|
-
dashboard-agent.md
|
|
289
|
+
architect.md ← Architect agent
|
|
290
|
+
researcher.md ← Researcher agent
|
|
291
|
+
planner.md ← Planner agent
|
|
292
|
+
coder.md ← Coder agent
|
|
293
|
+
reviewer.md ← Reviewer agent
|
|
294
|
+
teacher.md ← Teacher agent (for students)
|
|
295
|
+
git-agent.md ← Git Agent
|
|
296
|
+
dashboard-agent.md ← Dashboard Agent
|
|
122
297
|
commands/
|
|
123
|
-
start-project.md ← /start-project
|
|
124
|
-
create-roadmap.md
|
|
125
|
-
initiate-phase.md
|
|
126
|
-
execute-phase.md
|
|
127
|
-
review-phase.md
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
generate-
|
|
136
|
-
|
|
298
|
+
start-project.md ← /start-project
|
|
299
|
+
create-roadmap.md ← /create-roadmap
|
|
300
|
+
initiate-phase.md ← /initiate-phase
|
|
301
|
+
execute-phase.md ← /execute-phase
|
|
302
|
+
review-phase.md ← /review-phase
|
|
303
|
+
write-tests.md ← /write-tests
|
|
304
|
+
humanize-code.md ← /humanize-code
|
|
305
|
+
explain-my-code.md ← /explain-my-code
|
|
306
|
+
professor-check.md ← /professor-check
|
|
307
|
+
checkpoint.md ← /checkpoint
|
|
308
|
+
debug-issue.md ← /debug-issue
|
|
309
|
+
design-system.md ← /design-system
|
|
310
|
+
generate-docs.md ← /generate-docs
|
|
311
|
+
generate-report.md ← /generate-report
|
|
312
|
+
update-dashboard.md ← /update-dashboard
|
|
137
313
|
dashboard/
|
|
138
314
|
index.html ← visual dashboard
|
|
139
315
|
style.css
|
|
140
316
|
data.json
|
|
141
317
|
AGENTS.md ← instructions for all AI agents
|
|
142
|
-
CLAUDE.md ← Claude Code specific
|
|
143
|
-
GEMINI.md ← Gemini CLI specific
|
|
144
|
-
OPENAI.md ← OpenAI / Codex specific
|
|
318
|
+
CLAUDE.md ← Claude Code specific config
|
|
319
|
+
GEMINI.md ← Gemini CLI specific config
|
|
320
|
+
OPENAI.md ← OpenAI / Codex specific config
|
|
145
321
|
```
|
|
146
322
|
|
|
147
323
|
---
|
|
148
324
|
|
|
149
|
-
##
|
|
150
|
-
|
|
151
|
-
BrainForge adapts the generated and reviewed code to your target level:
|
|
325
|
+
## Multi-AI Compatibility
|
|
152
326
|
|
|
153
|
-
|
|
154
|
-
|-------|-------------|
|
|
155
|
-
| `beginner` | Simple, direct, few files, comments in French |
|
|
156
|
-
| `intermediate` | Clean structure, reusable, good practices |
|
|
157
|
-
| `academic-realistic` | Credible student code — clean but not enterprise-perfect, easy to explain |
|
|
158
|
-
| `professional` | Strict typing, tests, security, scalable architecture |
|
|
327
|
+
BrainForge generates config files for every major AI tool:
|
|
159
328
|
|
|
160
|
-
|
|
329
|
+
| File | Tool |
|
|
330
|
+
|------|------|
|
|
331
|
+
| `CLAUDE.md` | Claude Code |
|
|
332
|
+
| `GEMINI.md` | Gemini CLI |
|
|
333
|
+
| `OPENAI.md` | Codex / ChatGPT |
|
|
334
|
+
| `AGENTS.md` | All tools (universal) |
|
|
161
335
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## Slash Commands Reference
|
|
165
|
-
|
|
166
|
-
| Command | Purpose |
|
|
167
|
-
|---------|---------|
|
|
168
|
-
| `/start-project` | Document your idea, gather project info |
|
|
169
|
-
| `/create-roadmap` | Break project into phases (Epic > Feature > Task) |
|
|
170
|
-
| `/initiate-phase N` | Research + plan phase N before coding |
|
|
171
|
-
| `/execute-phase N` | Implement phase N following the plan |
|
|
172
|
-
| `/review-phase N` | Code review for quality and level-appropriateness |
|
|
173
|
-
| `/humanize-code` | Adapt code to match the user's real level |
|
|
174
|
-
| `/explain-my-code` | Generate an explanation for professors or teams |
|
|
175
|
-
| `/professor-check` | Detect code that looks "too AI-generated" |
|
|
176
|
-
| `/checkpoint` | Local git commit (never pushes) |
|
|
177
|
-
| `/debug-issue` | Systematic bug analysis and fix |
|
|
178
|
-
| `/design-system` | Create UI/UX design system |
|
|
179
|
-
| `/generate-docs` | Generate README and docs/ |
|
|
180
|
-
| `/generate-report` | Generate academic report template |
|
|
181
|
-
| `/update-dashboard` | Refresh the HTML dashboard |
|
|
336
|
+
Each file tells the AI: what the project is, what code level to use, how to follow the workflow, what files to update, and git rules (never push).
|
|
182
337
|
|
|
183
338
|
---
|
|
184
339
|
|
|
185
|
-
##
|
|
340
|
+
## Git Rules
|
|
186
341
|
|
|
187
|
-
|
|
342
|
+
| Action | Status |
|
|
343
|
+
|--------|--------|
|
|
344
|
+
| `git init` | ✅ Auto on first init |
|
|
345
|
+
| `git add` + `git commit` | ✅ Via `/checkpoint` |
|
|
346
|
+
| `git push` | ❌ Never automatic |
|
|
347
|
+
| `git push --force` | ❌ Never |
|
|
188
348
|
|
|
189
|
-
|
|
190
|
-
- **Commander.js** — CLI framework
|
|
191
|
-
- **Inquirer** — interactive prompts
|
|
192
|
-
- **Chalk** — terminal colors
|
|
193
|
-
- **Ora** — spinners
|
|
194
|
-
- **simple-git** — Git operations
|
|
195
|
-
- **fs-extra** — file system utilities
|
|
349
|
+
You always control when and where you push.
|
|
196
350
|
|
|
197
351
|
---
|
|
198
352
|
|
|
199
|
-
##
|
|
353
|
+
## Example Use Cases
|
|
200
354
|
|
|
355
|
+
### School / PFA project
|
|
201
356
|
```bash
|
|
202
|
-
|
|
203
|
-
|
|
357
|
+
npx brainforge-ai init
|
|
358
|
+
# → choose "academic-realistic" code level
|
|
359
|
+
# → choose "yes" for academic project
|
|
360
|
+
# → /start-project → /create-roadmap → phases
|
|
361
|
+
# → /write-tests before each review
|
|
362
|
+
# → /professor-check before submission
|
|
363
|
+
# → /generate-report for the written report
|
|
364
|
+
```
|
|
204
365
|
|
|
205
|
-
|
|
206
|
-
|
|
366
|
+
### Personal MVP
|
|
367
|
+
```bash
|
|
368
|
+
npx brainforge-ai init
|
|
369
|
+
# → choose "intermediate" or "professional"
|
|
370
|
+
# → brainforge serve ← keep the dashboard open while you build
|
|
371
|
+
```
|
|
207
372
|
|
|
208
|
-
|
|
209
|
-
|
|
373
|
+
### Learning a new stack
|
|
374
|
+
```bash
|
|
375
|
+
npx brainforge-ai init
|
|
376
|
+
# → choose "beginner" or "intermediate"
|
|
377
|
+
# → /explain-my-code after each phase to understand what was built
|
|
378
|
+
```
|
|
210
379
|
|
|
211
|
-
|
|
212
|
-
npm link
|
|
213
|
-
brainforge init
|
|
380
|
+
---
|
|
214
381
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
382
|
+
## Requirements
|
|
383
|
+
|
|
384
|
+
- Node.js >= 16
|
|
385
|
+
- Git (optional but recommended)
|
|
386
|
+
- An AI tool: Claude Code, Cursor, Copilot, Gemini CLI, Codex…
|
|
218
387
|
|
|
219
388
|
---
|
|
220
389
|
|
|
221
|
-
##
|
|
390
|
+
## Development
|
|
222
391
|
|
|
223
392
|
```bash
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
npm
|
|
393
|
+
git clone https://github.com/MEHDImp4/brainforge-ai
|
|
394
|
+
cd brainforge-ai
|
|
395
|
+
npm install
|
|
396
|
+
npm run build
|
|
397
|
+
npm link
|
|
229
398
|
|
|
230
|
-
#
|
|
231
|
-
|
|
399
|
+
# Test locally
|
|
400
|
+
brainforge init
|
|
401
|
+
brainforge guide
|
|
402
|
+
brainforge serve
|
|
403
|
+
brainforge doctor
|
|
232
404
|
```
|
|
233
405
|
|
|
234
406
|
---
|
|
235
407
|
|
|
236
|
-
##
|
|
408
|
+
## Contributing
|
|
237
409
|
|
|
238
|
-
|
|
239
|
-
- [ ] `brainforge phase` — phase management (status, list, activate)
|
|
240
|
-
- [ ] `brainforge memory` — view and search project memory
|
|
241
|
-
- [ ] AI model integration for auto-generating roadmaps
|
|
242
|
-
- [ ] Export report to PDF
|
|
243
|
-
- [ ] VS Code extension
|
|
244
|
-
- [ ] Web-based dashboard with live reload
|
|
410
|
+
Issues and PRs welcome on [GitHub](https://github.com/MEHDImp4/brainforge-ai).
|
|
245
411
|
|
|
246
412
|
---
|
|
247
413
|
|
|
248
414
|
## License
|
|
249
415
|
|
|
250
|
-
MIT —
|
|
416
|
+
MIT — free to use, modify, and share.
|
|
251
417
|
|
|
252
418
|
---
|
|
253
419
|
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,8 @@ const init_1 = require("./commands/init");
|
|
|
6
6
|
const doctor_1 = require("./commands/doctor");
|
|
7
7
|
const dashboard_1 = require("./commands/dashboard");
|
|
8
8
|
const updateDashboard_1 = require("./commands/updateDashboard");
|
|
9
|
+
const serve_1 = require("./commands/serve");
|
|
10
|
+
const help_1 = require("./commands/help");
|
|
9
11
|
const program = new commander_1.Command();
|
|
10
12
|
program
|
|
11
13
|
.name('brainforge')
|
|
@@ -35,6 +37,19 @@ program
|
|
|
35
37
|
.action(async () => {
|
|
36
38
|
await (0, updateDashboard_1.updateDashboardCommand)();
|
|
37
39
|
});
|
|
40
|
+
program
|
|
41
|
+
.command('serve')
|
|
42
|
+
.description('Start a local server with live reload for the dashboard')
|
|
43
|
+
.option('-p, --port <number>', 'Port to listen on', '3000')
|
|
44
|
+
.action(async (opts) => {
|
|
45
|
+
await (0, serve_1.serveCommand)(parseInt(opts.port, 10));
|
|
46
|
+
});
|
|
47
|
+
program
|
|
48
|
+
.command('guide')
|
|
49
|
+
.description('Show all CLI and slash commands with project status')
|
|
50
|
+
.action(() => {
|
|
51
|
+
(0, help_1.helpCommand)();
|
|
52
|
+
});
|
|
38
53
|
program
|
|
39
54
|
.command('version')
|
|
40
55
|
.description('Show version information')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA8C;AAC9C,8CAAkD;AAClD,oDAAwD;AACxD,gEAAoE;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA8C;AAC9C,8CAAkD;AAClD,oDAAwD;AACxD,gEAAoE;AACpE,4CAAgD;AAChD,0CAA8C;AAE9C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CACV,yGAAyG,CAC1G;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,gDAAgD,CAAC;KAC7D,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,IAAA,kBAAW,GAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,4CAA4C,CAAC;KACzD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,IAAA,sBAAa,GAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,2CAA2C,CAAC;KACxD,MAAM,CAAC,GAAG,EAAE;IACX,IAAA,4BAAgB,GAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,IAAA,wCAAsB,GAAE,CAAC;AACjC,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,CAAC;KAC1D,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,IAAA,oBAAY,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,qDAAqD,CAAC;KAClE,MAAM,CAAC,GAAG,EAAE;IACX,IAAA,kBAAW,GAAE,CAAC;AAChB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAyDA,wBAAgB,WAAW,IAAI,IAAI,CAmFlC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.helpCommand = helpCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const config_1 = require("../core/config");
|
|
9
|
+
const logger_1 = require("../utils/logger");
|
|
10
|
+
const CLI_COMMANDS = [
|
|
11
|
+
{ cmd: 'brainforge init', desc: 'Initialize BrainForge in the current directory' },
|
|
12
|
+
{ cmd: 'brainforge serve', desc: 'Live dashboard on localhost:3000 (auto-reloads)' },
|
|
13
|
+
{ cmd: 'brainforge dashboard', desc: 'Open the HTML dashboard in the browser' },
|
|
14
|
+
{ cmd: 'brainforge update-dashboard', desc: 'Refresh dashboard data from project state' },
|
|
15
|
+
{ cmd: 'brainforge doctor', desc: 'Health check — verify setup and files' },
|
|
16
|
+
{ cmd: 'brainforge help', desc: 'Show this help screen' },
|
|
17
|
+
{ cmd: 'brainforge version', desc: 'Show version info' },
|
|
18
|
+
];
|
|
19
|
+
const SLASH_COMMANDS = [
|
|
20
|
+
{
|
|
21
|
+
group: 'Project Setup',
|
|
22
|
+
commands: [
|
|
23
|
+
{ cmd: '/start-project', desc: 'Document your idea and gather project info' },
|
|
24
|
+
{ cmd: '/create-roadmap', desc: 'Break project into phases (Epic › Feature › Task)' },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
group: 'Phase Workflow',
|
|
29
|
+
commands: [
|
|
30
|
+
{ cmd: '/initiate-phase N', desc: 'Research + plan phase N before any coding' },
|
|
31
|
+
{ cmd: '/execute-phase N', desc: 'Code phase N following the plan exactly' },
|
|
32
|
+
{ cmd: '/review-phase N', desc: 'Quality review — bugs, level check, academic check' },
|
|
33
|
+
{ cmd: '/checkpoint', desc: 'Local git commit (never pushes automatically)' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
group: 'Code Quality',
|
|
38
|
+
commands: [
|
|
39
|
+
{ cmd: '/write-tests', desc: 'Generate tests for a file, function, or phase' },
|
|
40
|
+
{ cmd: '/humanize-code', desc: 'Adapt code to match your real coding level' },
|
|
41
|
+
{ cmd: '/debug-issue', desc: 'Systematic bug analysis and fix' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
group: 'Student Tools',
|
|
46
|
+
commands: [
|
|
47
|
+
{ cmd: '/explain-my-code', desc: 'Generate an explanation for your professor or team' },
|
|
48
|
+
{ cmd: '/professor-check', desc: 'Detect code that looks suspiciously AI-generated' },
|
|
49
|
+
{ cmd: '/generate-report', desc: 'Generate an academic report template' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
group: 'Documentation & UI',
|
|
54
|
+
commands: [
|
|
55
|
+
{ cmd: '/design-system', desc: 'Create a UI/UX design system guide' },
|
|
56
|
+
{ cmd: '/generate-docs', desc: 'Generate README and docs/ folder' },
|
|
57
|
+
{ cmd: '/update-dashboard', desc: 'Refresh the HTML dashboard data' },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
function helpCommand() {
|
|
62
|
+
const cwd = process.cwd();
|
|
63
|
+
const initialized = (0, config_1.configExists)(cwd);
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk_1.default.bold.magenta(' ⚡ BrainForge') + chalk_1.default.gray(' — structured AI development'));
|
|
66
|
+
console.log();
|
|
67
|
+
// Project status banner
|
|
68
|
+
if (initialized) {
|
|
69
|
+
try {
|
|
70
|
+
const config = (0, config_1.readConfig)(cwd);
|
|
71
|
+
const bar = progressBar(config.currentPhase, config.totalPhases);
|
|
72
|
+
console.log(chalk_1.default.gray(' Project : ') + chalk_1.default.white(config.projectName));
|
|
73
|
+
console.log(chalk_1.default.gray(' Level : ') + chalk_1.default.cyan(config.codeLevel) +
|
|
74
|
+
chalk_1.default.gray(' · Stack: ') + chalk_1.default.cyan(config.stack.join(', ')));
|
|
75
|
+
console.log(chalk_1.default.gray(' Progress: ') + bar +
|
|
76
|
+
chalk_1.default.gray(` ${config.currentPhase}/${config.totalPhases} phases`));
|
|
77
|
+
console.log();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// skip if config unreadable
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.log(chalk_1.default.yellow(' ⚠ Not initialized.') +
|
|
85
|
+
chalk_1.default.gray(' Run: ') + chalk_1.default.white('brainforge init'));
|
|
86
|
+
console.log();
|
|
87
|
+
}
|
|
88
|
+
// CLI Commands
|
|
89
|
+
logger_1.logger.divider();
|
|
90
|
+
console.log(chalk_1.default.bold.white(' CLI Commands\n'));
|
|
91
|
+
for (const { cmd, desc } of CLI_COMMANDS) {
|
|
92
|
+
console.log(' ' + chalk_1.default.green(cmd.padEnd(34)) + chalk_1.default.gray(desc));
|
|
93
|
+
}
|
|
94
|
+
// Slash Commands
|
|
95
|
+
console.log();
|
|
96
|
+
logger_1.logger.divider();
|
|
97
|
+
console.log(chalk_1.default.bold.white(' Slash Commands') + chalk_1.default.gray(' (paste into your AI tool)\n'));
|
|
98
|
+
for (const group of SLASH_COMMANDS) {
|
|
99
|
+
console.log(chalk_1.default.bold.yellow(' ' + group.group));
|
|
100
|
+
for (const { cmd, desc } of group.commands) {
|
|
101
|
+
console.log(' ' + chalk_1.default.cyan(cmd.padEnd(22)) + chalk_1.default.gray(desc));
|
|
102
|
+
}
|
|
103
|
+
console.log();
|
|
104
|
+
}
|
|
105
|
+
// Workflow reminder
|
|
106
|
+
logger_1.logger.divider();
|
|
107
|
+
console.log(chalk_1.default.bold.white(' Workflow\n'));
|
|
108
|
+
const steps = [
|
|
109
|
+
'/start-project',
|
|
110
|
+
'/create-roadmap',
|
|
111
|
+
'/initiate-phase N',
|
|
112
|
+
'/execute-phase N',
|
|
113
|
+
'/write-tests',
|
|
114
|
+
'/review-phase N',
|
|
115
|
+
'/checkpoint',
|
|
116
|
+
];
|
|
117
|
+
console.log(' ' + steps.map((s) => chalk_1.default.cyan(s)).join(chalk_1.default.gray(' → ')));
|
|
118
|
+
console.log();
|
|
119
|
+
// Docs link
|
|
120
|
+
console.log(chalk_1.default.gray(' Docs: ') +
|
|
121
|
+
chalk_1.default.underline('https://github.com/MEHDImp4/brainforge-ai'));
|
|
122
|
+
console.log();
|
|
123
|
+
}
|
|
124
|
+
function progressBar(current, total) {
|
|
125
|
+
if (total === 0)
|
|
126
|
+
return chalk_1.default.gray('[──────────]');
|
|
127
|
+
const filled = Math.round((current / total) * 10);
|
|
128
|
+
const bar = '█'.repeat(filled) + '─'.repeat(10 - filled);
|
|
129
|
+
return chalk_1.default.green('[') + chalk_1.default.green(bar) + chalk_1.default.green(']') + ' ';
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;;;;AAyDA,kCAmFC;AA5ID,kDAA0B;AAC1B,2CAA0D;AAC1D,4CAAyC;AAEzC,MAAM,YAAY,GAAG;IACnB,EAAE,GAAG,EAAE,iBAAiB,EAAc,IAAI,EAAE,gDAAgD,EAAE;IAC9F,EAAE,GAAG,EAAE,kBAAkB,EAAa,IAAI,EAAE,iDAAiD,EAAE;IAC/F,EAAE,GAAG,EAAE,sBAAsB,EAAS,IAAI,EAAE,wCAAwC,EAAE;IACtF,EAAE,GAAG,EAAE,6BAA6B,EAAE,IAAI,EAAE,2CAA2C,EAAE;IACzF,EAAE,GAAG,EAAE,mBAAmB,EAAY,IAAI,EAAE,uCAAuC,EAAE;IACrF,EAAE,GAAG,EAAE,iBAAiB,EAAc,IAAI,EAAE,uBAAuB,EAAE;IACrE,EAAE,GAAG,EAAE,oBAAoB,EAAW,IAAI,EAAE,mBAAmB,EAAE;CAClE,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB;QACE,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE;YACR,EAAE,GAAG,EAAE,gBAAgB,EAAI,IAAI,EAAE,4CAA4C,EAAE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
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAgBA,wBAAsB,YAAY,CAAC,IAAI,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA6H7D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serveCommand = serveCommand;
|
|
7
|
+
const http_1 = __importDefault(require("http"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const config_1 = require("../core/config");
|
|
11
|
+
const dashboard_1 = require("../core/dashboard");
|
|
12
|
+
const logger_1 = require("../utils/logger");
|
|
13
|
+
const MIME = {
|
|
14
|
+
'.html': 'text/html',
|
|
15
|
+
'.css': 'text/css',
|
|
16
|
+
'.js': 'application/javascript',
|
|
17
|
+
'.json': 'application/json',
|
|
18
|
+
};
|
|
19
|
+
async function serveCommand(port = 3000) {
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
if (!(0, config_1.configExists)(cwd)) {
|
|
22
|
+
logger_1.logger.error('BrainForge not initialized. Run: brainforge init');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const brainDir = (0, config_1.getBrainforgeDir)(cwd);
|
|
26
|
+
const dashDir = path_1.default.join(brainDir, 'dashboard');
|
|
27
|
+
const clients = new Set();
|
|
28
|
+
// Debounce helper so rapid file saves don't spam reloads
|
|
29
|
+
let debounceTimer = null;
|
|
30
|
+
function scheduleReload() {
|
|
31
|
+
if (debounceTimer)
|
|
32
|
+
clearTimeout(debounceTimer);
|
|
33
|
+
debounceTimer = setTimeout(async () => {
|
|
34
|
+
try {
|
|
35
|
+
const config = (0, config_1.readConfig)(cwd);
|
|
36
|
+
const data = await (0, dashboard_1.generateDashboardData)(config, cwd);
|
|
37
|
+
await (0, dashboard_1.writeDashboardData)(data, cwd);
|
|
38
|
+
broadcast(clients, 'reload');
|
|
39
|
+
logger_1.logger.info('Dashboard refreshed — reloading browsers…');
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
logger_1.logger.warn('Reload failed: ' + (err instanceof Error ? err.message : String(err)));
|
|
43
|
+
}
|
|
44
|
+
}, 300);
|
|
45
|
+
}
|
|
46
|
+
// Watch the whole .brainforge/ directory recursively
|
|
47
|
+
fs_extra_1.default.watch(brainDir, { recursive: true }, (event, filename) => {
|
|
48
|
+
if (filename && filename.includes('dashboard'))
|
|
49
|
+
return; // avoid loop
|
|
50
|
+
scheduleReload();
|
|
51
|
+
});
|
|
52
|
+
const server = http_1.default.createServer(async (req, res) => {
|
|
53
|
+
const url = req.url ?? '/';
|
|
54
|
+
// SSE endpoint
|
|
55
|
+
if (url === '/events') {
|
|
56
|
+
res.writeHead(200, {
|
|
57
|
+
'Content-Type': 'text/event-stream',
|
|
58
|
+
'Cache-Control': 'no-cache',
|
|
59
|
+
Connection: 'keep-alive',
|
|
60
|
+
'Access-Control-Allow-Origin': '*',
|
|
61
|
+
});
|
|
62
|
+
res.write('data: connected\n\n');
|
|
63
|
+
clients.add(res);
|
|
64
|
+
req.on('close', () => clients.delete(res));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// Static file serving
|
|
68
|
+
let filePath = url === '/' ? path_1.default.join(dashDir, 'index.html') : path_1.default.join(dashDir, url);
|
|
69
|
+
filePath = path_1.default.normalize(filePath);
|
|
70
|
+
// Security: prevent directory traversal
|
|
71
|
+
if (!filePath.startsWith(path_1.default.normalize(dashDir))) {
|
|
72
|
+
res.writeHead(403);
|
|
73
|
+
res.end('Forbidden');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!fs_extra_1.default.existsSync(filePath)) {
|
|
77
|
+
res.writeHead(404);
|
|
78
|
+
res.end('Not found');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const ext = path_1.default.extname(filePath);
|
|
82
|
+
const mime = MIME[ext] ?? 'application/octet-stream';
|
|
83
|
+
// Inject SSE client into HTML
|
|
84
|
+
if (ext === '.html') {
|
|
85
|
+
let html = fs_extra_1.default.readFileSync(filePath, 'utf-8');
|
|
86
|
+
html = injectSseClient(html);
|
|
87
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
88
|
+
res.end(html);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
res.writeHead(200, { 'Content-Type': mime });
|
|
92
|
+
fs_extra_1.default.createReadStream(filePath).pipe(res);
|
|
93
|
+
});
|
|
94
|
+
// Initial data generation before starting
|
|
95
|
+
try {
|
|
96
|
+
const config = (0, config_1.readConfig)(cwd);
|
|
97
|
+
const data = await (0, dashboard_1.generateDashboardData)(config, cwd);
|
|
98
|
+
await (0, dashboard_1.writeDashboardData)(data, cwd);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// non-fatal
|
|
102
|
+
}
|
|
103
|
+
server.listen(port, () => {
|
|
104
|
+
logger_1.logger.title('⚡ BrainForge Dashboard — Live');
|
|
105
|
+
logger_1.logger.divider();
|
|
106
|
+
logger_1.logger.success(`Running at http://localhost:${port}`);
|
|
107
|
+
logger_1.logger.info('Dashboard reloads automatically when .brainforge/ files change.');
|
|
108
|
+
logger_1.logger.info('Press Ctrl+C to stop.');
|
|
109
|
+
logger_1.logger.divider();
|
|
110
|
+
// Try to open browser
|
|
111
|
+
try {
|
|
112
|
+
const { execSync } = require('child_process');
|
|
113
|
+
const open = process.platform === 'win32'
|
|
114
|
+
? `start http://localhost:${port}`
|
|
115
|
+
: process.platform === 'darwin'
|
|
116
|
+
? `open http://localhost:${port}`
|
|
117
|
+
: `xdg-open http://localhost:${port}`;
|
|
118
|
+
execSync(open, { stdio: 'ignore' });
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// ignore if can't open
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
server.on('error', (err) => {
|
|
125
|
+
if (err.code === 'EADDRINUSE') {
|
|
126
|
+
logger_1.logger.error(`Port ${port} is already in use. Try: brainforge serve --port ${port + 1}`);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
logger_1.logger.error(err.message);
|
|
130
|
+
}
|
|
131
|
+
process.exit(1);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function broadcast(clients, event) {
|
|
135
|
+
for (const client of clients) {
|
|
136
|
+
client.write(`event: ${event}\ndata: ${Date.now()}\n\n`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function injectSseClient(html) {
|
|
140
|
+
const script = `
|
|
141
|
+
<script>
|
|
142
|
+
(function () {
|
|
143
|
+
const es = new EventSource('/events');
|
|
144
|
+
es.addEventListener('reload', () => location.reload());
|
|
145
|
+
es.addEventListener('error', () => {
|
|
146
|
+
setTimeout(() => location.reload(), 2000);
|
|
147
|
+
});
|
|
148
|
+
// Show a small indicator in the corner
|
|
149
|
+
const dot = document.createElement('div');
|
|
150
|
+
dot.title = 'BrainForge live reload active';
|
|
151
|
+
dot.style.cssText = 'position:fixed;bottom:12px;right:12px;width:10px;height:10px;border-radius:50%;background:#22c55e;box-shadow:0 0 6px #22c55e;z-index:9999;';
|
|
152
|
+
document.addEventListener('DOMContentLoaded', () => document.body.appendChild(dot));
|
|
153
|
+
es.onopen = () => { dot.style.background = '#22c55e'; dot.style.boxShadow = '0 0 6px #22c55e'; };
|
|
154
|
+
es.onerror = () => { dot.style.background = '#ef4444'; dot.style.boxShadow = '0 0 6px #ef4444'; };
|
|
155
|
+
})();
|
|
156
|
+
</script>`;
|
|
157
|
+
// Inject before </body> if present, otherwise append
|
|
158
|
+
return html.includes('</body>')
|
|
159
|
+
? html.replace('</body>', script + '\n</body>')
|
|
160
|
+
: html + script;
|
|
161
|
+
}
|
|
162
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3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqTlF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAytBpF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgJrF"}
|
package/dist/core/templates.js
CHANGED
|
@@ -917,6 +917,104 @@ brainforge update-dashboard
|
|
|
917
917
|
|
|
918
918
|
- Updated \`.brainforge/dashboard/data.json\`
|
|
919
919
|
- Message: "Dashboard updated. Open .brainforge/dashboard/index.html"
|
|
920
|
+
`,
|
|
921
|
+
'write-tests.md': `# /write-tests
|
|
922
|
+
|
|
923
|
+
**Objective:** Generate tests for a file, function, or entire phase.
|
|
924
|
+
|
|
925
|
+
## Usage
|
|
926
|
+
|
|
927
|
+
\`\`\`
|
|
928
|
+
/write-tests [file or feature or phase number]
|
|
929
|
+
\`\`\`
|
|
930
|
+
|
|
931
|
+
Examples:
|
|
932
|
+
\`\`\`
|
|
933
|
+
/write-tests src/auth/login.ts
|
|
934
|
+
/write-tests the login feature
|
|
935
|
+
/write-tests phase 2
|
|
936
|
+
\`\`\`
|
|
937
|
+
|
|
938
|
+
## Context to Read First
|
|
939
|
+
|
|
940
|
+
- \`.brainforge/config.json\` — stack and code level
|
|
941
|
+
- \`.brainforge/memory/coding-style.md\` — test style rules
|
|
942
|
+
- Target file(s) to test
|
|
943
|
+
|
|
944
|
+
## Steps
|
|
945
|
+
|
|
946
|
+
1. Read the target file(s) and understand the logic
|
|
947
|
+
2. Identify what needs to be tested:
|
|
948
|
+
- Pure functions → unit tests
|
|
949
|
+
- API routes → integration tests
|
|
950
|
+
- UI components → component tests
|
|
951
|
+
3. Choose the right test framework for the stack (see below)
|
|
952
|
+
4. Write tests at **${config.codeLevel}** complexity level
|
|
953
|
+
5. Place test files next to source or in a \`tests/\` folder
|
|
954
|
+
6. Verify tests pass conceptually before writing
|
|
955
|
+
|
|
956
|
+
## Test Framework by Stack
|
|
957
|
+
|
|
958
|
+
| Stack | Framework | Command |
|
|
959
|
+
|-------|-----------|---------|
|
|
960
|
+
| Node.js / TypeScript | Jest or Vitest | \`npm test\` |
|
|
961
|
+
| React | Vitest + Testing Library | \`npm test\` |
|
|
962
|
+
| Next.js | Jest + Testing Library | \`npm test\` |
|
|
963
|
+
| Python | pytest | \`pytest\` |
|
|
964
|
+
| Laravel | PHPUnit | \`php artisan test\` |
|
|
965
|
+
|
|
966
|
+
## What to Test (by level)
|
|
967
|
+
|
|
968
|
+
### ${config.codeLevel === 'beginner' ? 'beginner' : config.codeLevel === 'academic-realistic' ? 'academic-realistic' : config.codeLevel === 'professional' ? 'professional' : 'intermediate'}
|
|
969
|
+
|
|
970
|
+
${config.codeLevel === 'beginner'
|
|
971
|
+
? `- Test the main happy path only
|
|
972
|
+
- 2-3 tests per function maximum
|
|
973
|
+
- Simple assertions (toBe, toEqual)
|
|
974
|
+
- No mocks — test real behavior
|
|
975
|
+
- Comments explaining what each test does`
|
|
976
|
+
: config.codeLevel === 'intermediate'
|
|
977
|
+
? `- Happy path + main edge cases
|
|
978
|
+
- Group tests with describe()
|
|
979
|
+
- Simple mocks for external dependencies
|
|
980
|
+
- Test error cases for user inputs
|
|
981
|
+
- Aim for ~60% coverage on critical files`
|
|
982
|
+
: config.codeLevel === 'academic-realistic'
|
|
983
|
+
? `- Happy path + 2-3 edge cases per function
|
|
984
|
+
- Group with describe(), use clear test names
|
|
985
|
+
- Mock external services (DB, API calls)
|
|
986
|
+
- Test error handling on inputs
|
|
987
|
+
- Coverage enough to show you care — not 100%
|
|
988
|
+
- Test names readable as plain English sentences`
|
|
989
|
+
: `- Full happy path + all edge cases
|
|
990
|
+
- Mock all external dependencies
|
|
991
|
+
- Test error boundaries and failure modes
|
|
992
|
+
- Aim for 80%+ coverage on business logic
|
|
993
|
+
- Integration tests for API endpoints
|
|
994
|
+
- Snapshot tests for stable UI components`}
|
|
995
|
+
|
|
996
|
+
## Test File Naming
|
|
997
|
+
|
|
998
|
+
\`\`\`
|
|
999
|
+
src/auth/login.ts → src/auth/login.test.ts
|
|
1000
|
+
src/utils/format.ts → src/utils/format.test.ts
|
|
1001
|
+
src/pages/Home.tsx → src/pages/Home.test.tsx
|
|
1002
|
+
\`\`\`
|
|
1003
|
+
|
|
1004
|
+
## Rules
|
|
1005
|
+
|
|
1006
|
+
- Do NOT test implementation details — test behavior
|
|
1007
|
+
- Do NOT write tests that always pass (useless assertions)
|
|
1008
|
+
- Keep test files under 150 lines — split if needed
|
|
1009
|
+
- Each test must have a clear, readable name
|
|
1010
|
+
- NEVER skip failing tests with \`.skip\` — fix them
|
|
1011
|
+
|
|
1012
|
+
## After Writing Tests
|
|
1013
|
+
|
|
1014
|
+
1. Add test script to \`package.json\` if missing
|
|
1015
|
+
2. Run the tests mentally to verify they make sense
|
|
1016
|
+
3. Update \`.brainforge/phases/phase-XX.md\` checklist
|
|
1017
|
+
4. Suggest: \`/checkpoint\` to commit the tests
|
|
920
1018
|
`,
|
|
921
1019
|
};
|
|
922
1020
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":";;AAEA,8CAqTC;AAED,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":";;AAEA,8CAqTC;AAED,kDAytBC;AAED,oDAgJC;AAlqCD,SAAgB,iBAAiB,CAAC,MAAwB;IACxD,OAAO;QACL,cAAc,EAAE;;;eAGL,MAAM,CAAC,WAAW;aACpB,MAAM,CAAC,KAAK,CAAC,IAAI,CA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AM,CAAC,WAAW;aACpB,QAAQ;;;;;;;;;;;;;iBAaJ,MAAM,CAAC,SAAS;;;;;;;;;;;CAWhC;QAEG,WAAW,EAAE;;eAEF,MAAM,CAAC,WAAW;aACpB,QAAQ;;;;;;;;;iBASJ,MAAM,CAAC,SAAS;;qBAEZ,MAAM,CAAC,SAAS;;;;;;;;;;;;;CAapC;KACE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainforge-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI to transform a vague idea into a structured, AI-assisted project with agents, slash commands, memory, and a live dashboard",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"vibe-coding",
|
|
15
15
|
"brainforge"
|
|
16
16
|
],
|
|
17
|
-
"homepage": "https://github.com/
|
|
17
|
+
"homepage": "https://github.com/MEHDImp4/brainforge-ai#readme",
|
|
18
18
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/MEHDImp4/brainforge-ai/issues"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "Mehdi Diouri <mehdidiouri17@gmail.com>",
|