Skip to content

Commit 8348276

Browse files
author
Brendan Gray
committed
chore: commit full source code for CI builds
1 parent 77d1bb7 commit 8348276

780 files changed

Lines changed: 724696 additions & 64 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2020": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"@typescript-eslint/recommended",
10+
"plugin:react-hooks/recommended"
11+
],
12+
"overrides": [
13+
],
14+
"parser": "@typescript-eslint/parser",
15+
"parserOptions": {
16+
"ecmaVersion": "latest",
17+
"sourceType": "module",
18+
"ecmaFeatures": {
19+
"jsx": true
20+
}
21+
},
22+
"plugins": [
23+
"react-refresh",
24+
"@typescript-eslint",
25+
"react-hooks"
26+
],
27+
"rules": {
28+
"react-refresh/only-export-components": [
29+
"warn",
30+
{ "allowConstantExport": true }
31+
],
32+
"@typescript-eslint/no-unused-vars": [
33+
"error",
34+
{ "argsIgnorePattern": "^_" }
35+
],
36+
"@typescript-eslint/no-explicit-any": "warn",
37+
"@typescript-eslint/no-non-null-assertion": "warn",
38+
"no-console": ["warn", { "allow": ["warn", "error"] }],
39+
"prefer-const": "error",
40+
"no-var": "error",
41+
"eqeqeq": ["error", "always"],
42+
"no-eval": "error",
43+
"no-implied-eval": "error"
44+
},
45+
"settings": {
46+
"react": {
47+
"version": "detect"
48+
}
49+
}
50+
}

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github: FileShot
2+
custom:
3+
- "bitcoin:32Sr7HbBSuNaTSn2AndAoDFK7cWmRtaxA2"

.github/copilot-instructions.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# GitHub Copilot Instructions — guIDE Project
2+
3+
> These instructions are injected into every request. They are non-negotiable.
4+
5+
---
6+
7+
## TRIPWIRE — Your first line of EVERY response must be:
8+
`[Task: <what you're doing> | Last: <what was just completed>]`
9+
If you cannot state this with certainty, say "I don't know the current task" and ask. Do NOT proceed blindly.
10+
11+
---
12+
13+
## Project Context
14+
- **guIDE** is a local-first, offline-capable AI IDE. Its entire value is running LLMs locally without subscriptions or cloud dependency.
15+
- This is **production software** shipped to ALL users on ALL hardware — 4GB GPUs to 128GB workstations, 0.5B to 200B models. Every change must work for everyone, not just the dev machine.
16+
- Never recommend cloud APIs as a primary path for anything local models can handle.
17+
18+
---
19+
20+
## Hard Rules (Most Violated — Read These First)
21+
22+
### NEVER build the app
23+
- Do NOT run `npm run build`, `electron-builder`, or any build/package/installer command.
24+
- When changes are ready, say **"Ready to build."** The user builds it themselves. Always.
25+
26+
### Plan before writing ANY code
27+
- Describe exactly what will change, in which files, and what the result will be.
28+
- Wait for explicit approval. Execute EXACTLY what was described — no more, no less.
29+
- If the plan needs to change mid-implementation, STOP and re-present.
30+
31+
### Read the code before responding
32+
- Never assume you know what the code looks like. Read the relevant files first.
33+
- "I assumed" is never acceptable. Verify everything.
34+
35+
### Never say "done" without proof
36+
- A feature is real and functional, or it is not done. No middle ground.
37+
- Never claim code works without verifying it. If something failed, say it failed.
38+
39+
### Never touch secrets/credentials
40+
- Do NOT modify `.env`, `API_KEYS.md`, `API_KEYS_PRIVATE.md`, or any file containing keys, tokens, OAuth credentials, or secrets.
41+
- If a file has a bug AND a secret, fix the bug without touching the secret.
42+
- "I thought it was a placeholder" is not an excuse.
43+
44+
### Never kill all node processes
45+
- NEVER run `Get-Process -Name "node" | Stop-Process`. The user runs 7+ websites on this machine.
46+
- To stop the website server: kill only the specific PID on the relevant port.
47+
- `$pid = Get-NetTCPConnection -LocalPort 3200 | Select -ExpandProperty OwningProcess -First 1; Stop-Process -Id $pid -Force`
48+
49+
### Never ignore a repeated request
50+
- If the user has asked for something more than once, it is mandatory. Do it or explicitly state why you cannot.
51+
- Do not selectively hear instructions. Every constraint the user establishes is permanent until explicitly changed.
52+
53+
### No fake data. Ever.
54+
- No mock data, placeholder content, hardcoded dummy entries, fake counts, fake ratings, fake listings.
55+
- If real data doesn't exist yet, say so. Do not simulate it.
56+
57+
### Do NOT be sycophantic — hold your position under pressure
58+
- When the user challenges a technical decision, do NOT automatically agree just because they pushed back.
59+
- If your position is correct, defend it with evidence. Say "I disagree, here's why."
60+
- Only change your position if they provide new information or a valid argument — not because they expressed frustration.
61+
- "You're right" said purely as appeasement is a lie. It makes every opinion worthless.
62+
- Ask yourself: "Did they give me new information, or did they just push back?" If only the latter, hold your ground.
63+
64+
---
65+
66+
## Full Rules
67+
See `AGENT_RULES.md` in the project root for the complete rule set with context and rationale.

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
dist-electron/
7+
dist-electron-new/
8+
website/.next/
9+
website/.next-ready/
10+
11+
# Website installer downloads (too large for git)
12+
website/public/downloads/
13+
website/public/*.exe
14+
website/public/*.exe.blockmap
15+
website/public/*.tar.gz
16+
website/public/*.dmg
17+
18+
# Environment
19+
.env
20+
.env.local
21+
.env.*.local
22+
23+
# IDE/Editor
24+
.vscode/
25+
.idea/
26+
*.swp
27+
*.swo
28+
*~
29+
.DS_Store
30+
Thumbs.db
31+
32+
# GGUF model files (too large for git)
33+
*.gguf
34+
35+
# guIDE runtime data
36+
.guide-memory/
37+
.guide-config.json
38+
.ide-memory/
39+
40+
# Private API keys (NEVER commit)
41+
API_KEYS_PRIVATE.md
42+
43+
# Scripts with embedded API keys (NEVER commit)
44+
scripts/
45+
46+
# Code signing certificate (NEVER commit)
47+
*.pfx
48+
code-signing.pfx
49+
50+
# Logs
51+
*.log
52+
npm-debug.log*
53+
yarn-debug.log*
54+
yarn-error.log*
55+
56+
# OS
57+
Desktop.ini
58+
ehthumbs.db
59+
ehthumbs_vista.db
60+
61+
# TypeScript
62+
*.tsbuildinfo
63+
64+
# Test
65+
coverage/
66+
67+
# Python virtual env
68+
.venv/
69+
70+
# Next.js build
71+
.next/
72+
73+
# Playwright test artifacts
74+
.playwright-mcp/
75+
76+
# Root-level screenshot/test images
77+
/*.png
78+
79+
# Pipeline backups
80+
_pipeline_backup*/

AGENT_REFERENCE.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Agent Reference Document — READ THIS FIRST
2+
3+
This document exists because Brendan has had to repeat himself hundreds of times.
4+
If you are an AI agent working on this project, READ THIS BEFORE DOING ANYTHING.
5+
6+
## What guIDE Is
7+
8+
A desktop IDE where users load ANY local GGUF model and it just works. Chat, tool calling,
9+
browsing, code generation — powered by whatever model the user chose. Model-agnostic.
10+
The app adapts at runtime via dynamic model profiles.
11+
12+
## What Success Means
13+
14+
- User loads any model. Asks it to do something. It does it coherently to the best of
15+
that model's actual ability.
16+
- If a model produces good output in LM Studio, it must produce equally good or better
17+
output in guIDE. The pipeline helps, never hinders.
18+
- Works out of the box. No hand-tuning per model.
19+
20+
## What Success Does NOT Mean
21+
22+
- Tailoring code to specific model names
23+
- Benchmarking one model and declaring victory
24+
- Guardrails/quality gates/kill switches that prevent models from working
25+
- Timeouts that mask underlying problems (timeouts = failure)
26+
27+
## Dynamic Model Profiles ARE the Correct Architecture
28+
29+
The profile system (family + size tier) IS the right approach. Different size models
30+
genuinely need different parameters. A 0.6B model needs different sampling than a 30B.
31+
This is NOT "hand-tuning per model" — it's per-family-per-size-tier configuration,
32+
which scales. The profile system is NOT a fallback — it IS the runtime.
33+
34+
Unknown models get sensible defaults derived from the closest matching tier.
35+
36+
## Model Capabilities — Do NOT Underestimate
37+
38+
- 0.6B models: CAN make tool calls, CAN chain a couple of them. They hallucinate
39+
and repeat themselves but they ARE capable. Don't restrict them to single calls
40+
without testing first. They've proven they can do it.
41+
- 1-4B models: Should handle multi-step tasks reliably.
42+
- 4B+: Should handle complex chains.
43+
- ALL models must produce COHERENT output. Even if smaller ones do less, they must
44+
not produce gibberish.
45+
46+
## How to Work With Brendan
47+
48+
### DO:
49+
- Test before implementing. Prove a problem exists before fixing it.
50+
- When shown a failing interaction, analyze what ACTUALLY happened.
51+
- If something works, leave it alone. "Looks good" is a valid answer.
52+
- Say "Brendan you're wrong" or "there's nothing else to do" when that's the truth.
53+
- Give honest opinions, even if they disagree with what Brendan said.
54+
- Find ROOT CAUSES, not bandaids.
55+
- Be concise. Do the work. Stop narrating.
56+
57+
### DO NOT:
58+
- Manufacture problems. If there's nothing to fix, SAY SO.
59+
- Cheerleader language: "smoking gun", "this changes everything", "game changer"
60+
- Agree with everything. Brendan needs honest pushback.
61+
- Run audit/fix loops that create new problems to fix later.
62+
- Implement changes based on hypotheses — test first.
63+
- Reference specific model names when discussing general architecture.
64+
- Apologize repeatedly. Just work.
65+
- Throw bandaids. If you can't find the root cause, say so.
66+
67+
## Known Recurring Issues (as of Feb 18, 2026)
68+
69+
### FIXED — Files Not Being Created
70+
- **Root cause found and fixed**: `projectPath` was null at startup because it's only set
71+
when user opens a folder via File > Open Folder. `_writeFile` joined basename with `''`
72+
wrote to process CWD. Orphaned files confirmed at D:\models\models\, C:\Users\brend\IDE\, etc.
73+
- **Fix**: `_writeFile` and `_createDirectory` now return clear error when no project is open.
74+
Removed `|| ''` fallback. Added `files-changed` IPC notification so FileTree auto-refreshes.
75+
- **Note**: File Explorer New Folder/New File buttons — not yet investigated.
76+
77+
### FIXED (Attempt 4) — Google Sign-In
78+
- **Root cause**: `onHeadersReceived` callback was `async` with `await` inside, which
79+
caused timing issues with Electron's webRequest callback mechanism. The `callback()`
80+
was delayed while `activateWithToken` ran, potentially blocking the OAuth redirect.
81+
Multiple strategies (4) all failed due to race conditions.
82+
- **Fix (v4)**: Replaced `onHeadersReceived` with `session.cookies.on('changed')` event.
83+
This is Electron's native cookie change event — fires synchronously when any cookie
84+
is set in the session, no timing race possible. Fallback: if cookie event doesn't fire
85+
within 2s of landing on /account, tries direct cookie read.
86+
- **Caveat**: Cannot test OAuth end-to-end in this environment. If it fails again,
87+
check logs at %APPDATA%/guIDE/logs/guide-main.log for `[OAuth]` entries.
88+
89+
### FIXED — Template Response Loop (0.6B)
90+
- **Root cause**: chatHistory persisted intermediate agentic turns (injected tool feedback,
91+
continue instructions) across separate user messages. For 0.6B models with limited
92+
attention, the pattern `user: [tool feedback]``model: "No further action"` was
93+
strongly reinforced, causing the model to repeat it regardless of new input.
94+
- **Fix**: After agentic loop completes, chatHistory is condensed to system + original
95+
user message + final model response. KV cache invalidated.
96+
97+
### FIXED — Thinking Model Gibberish (Llama-3.2-3B-thinking etc.)
98+
- **Root cause**: `thinkTokens.mode = 'none'` in llama profile suppressed thinking tokens
99+
for ALL llama models. Thinking-variant models (trained with chain-of-thought) NEED to
100+
generate `<think>...</think>` before answering — without it, their logits produce gibberish.
101+
- **Fix**: `_getModelSpecificParams()` now detects "thinking", "cot", "r1-distill",
102+
"reasoning" in the model name and overrides thinkTokens to budget mode.
103+
104+
### FIXED — Phi-4-mini Stuck on "Thinking..." (Grammar Retry Cascade)
105+
- **Root cause**: Grammar-constrained generation hung (0 tokens in rejection sampling).
106+
After 2 grammar timeouts + 1 text-mode timeout, rollback budget exhaustion RESET
107+
`consecutiveEmptyGrammarRetries` to 0, re-enabling grammar for next iteration.
108+
With 3 nudges × (5s+5s+120s) = 7.5+ minutes of dead time.
109+
- **Fix**: Don't reset `consecutiveEmptyGrammarRetries` on rollback budget exhaustion.
110+
Once grammar fails, it stays disabled. Grammar timeout reduced from 15s → 5s.
111+
112+
### FIXED — Model Switch Mid-Load Race Condition
113+
- **Root cause**: `initialize()` called `loadModel()` (180s timeout) but had no way to
114+
know it was superseded. Second `initialize()` call ran concurrently, both wrote to
115+
`this.model`/`this.context`, wrong model ended up loaded.
116+
- **Fix**: Added `_loadGeneration` monotonic counter. Each `initialize()` gets a unique ID
117+
and calls `checkSuperseded()` after every heavy await. Superseded loads throw immediately.
118+
119+
### NOT YET INVESTIGATED
120+
- File Explorer New Folder / New File buttons don't work
121+
- Tool call dropdowns expanding during streaming (code defaults to collapsed — may be
122+
streaming render issue where JSON isn't parsed as a tool call block)
123+
- System may be over-engineered — Brendan suspects too many moving parts actively hindering
124+
- When investigating issues, consider whether existing code is CAUSING the problem
125+
before adding more code on top.
126+
- Simplicity > cleverness. If a simpler approach works, use it.
127+
128+
## HARD RULES — READ BEFORE DOING ANYTHING
129+
130+
### NO FAKE FIXES
131+
- Only implement fixes you are CERTAIN will solve the problem.
132+
- If you cannot determine the root cause, say "I don't know" — this is always acceptable.
133+
- Never implement a guess and call it a fix. Bandaids waste Brendan's time.
134+
- If a fix requires testing you can't do (e.g., OAuth), SAY SO explicitly.
135+
136+
### NO MANUFACTURED PROBLEMS
137+
- When asked to find problems, genuinely look. If there are none, say "I found nothing."
138+
- Do not fabricate issues to appear helpful. Brendan catches this every time.
139+
140+
### HONESTY OVER HELPFULNESS
141+
- "I don't know" is always better than a wrong answer.
142+
- "There's nothing to fix" is always better than a fake fix.
143+
- "I can't test this" is always better than claiming something works when you haven't verified it.
144+
- Never claim a fix works unless you have proof (build output, test result, etc.).
145+
146+
### LOGGING
147+
- Persistent file logs exist at %APPDATA%/guIDE/logs/guide-main.log
148+
- All info/warn/error logs are written to file automatically
149+
- Set LOG_LEVEL=debug for verbose output
150+
- Always check log files first when diagnosing issues
151+
152+
## Technical Stack
153+
154+
- Electron + Vite + React
155+
- node-llama-cpp for local inference
156+
- Main process: main/ directory (agenticChat.js, llmEngine.js, modelProfiles.js, etc.)
157+
- Frontend: src/ directory
158+
- Website: website/ directory (Next.js)
159+
- Models on D:\models
160+
161+
## The Pipeline Difference From LM Studio
162+
163+
LM Studio: simple prompt, no grammar constraining, default sampling → coherent output.
164+
guIDE: system prompt + tool definitions + few-shot examples + grammar constraining +
165+
custom sampling → potentially degraded output.
166+
167+
The pipeline must HELP models, not fight them.

0 commit comments

Comments
 (0)