Skip to content

Commit 8172601

Browse files
author
Vitor Castro
committed
Fix Code-OSS setup the right way: Spectre, Node 24.19, VS 2026 patch
Install Spectre-mitigated libs, require Node matching .nvmrc, patch preinstall for VS 2026, and drop ignore-scripts workarounds so native modules build correctly.
1 parent 55f9f29 commit 8172601

4 files changed

Lines changed: 112 additions & 36 deletions

File tree

‎docs/code-oss-integration.md‎

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Run OpenCodeIDE as a **branded Code-OSS** with the embedded AI extension loaded.
66

7-
## Architecture (current)
7+
## Architecture
88

99
```
1010
CodeForge/
@@ -13,69 +13,98 @@ CodeForge/
1313
├── extensions/opencodeide-ai/ # AI sidebar + VS Code bridge
1414
├── src/ai/ # Embedded AI Platform (shared logic)
1515
└── scripts/
16-
├── setup-vscode.mjs # clone + brand + npm install
16+
├── setup-vscode.mjs # clone + brand + patches + npm install
1717
├── apply-branding.mjs # product.json branding
18+
├── apply-vscode-patches.mjs # VS 2026 toolchain recognition, etc.
1819
└── dev-vscode.mjs # launch Code-OSS + extension
1920
```
2021

22+
## Prerequisites (Windows)
23+
24+
| Requirement | Details |
25+
|-------------|---------|
26+
| **Node.js** | Exact major from `vscode/.nvmrc` (currently **24.x ≥ 24.18.0**). Use [Node.js LTS](https://nodejs.org/) / `winget install OpenJS.NodeJS.LTS` |
27+
| **npm** | < 13 (comes with Node 24 LTS) |
28+
| **Python 3** | For node-gyp |
29+
| **Visual Studio** | C++ desktop workload + **MSVC Spectre-mitigated libs** (x64/x86) |
30+
31+
### Install Spectre libs (required)
32+
33+
Visual Studio Installer → Modify → Individual components → search **Spectre**:
34+
35+
- MSVC v14x - VS 202x C++ x64/x86 Spectre-mitigated libs
36+
- C++ ATL / MFC Spectre-mitigated libs (if prompted)
37+
38+
Or via elevated installer:
39+
40+
```powershell
41+
$setup = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
42+
$vs = "C:\Program Files\Microsoft Visual Studio\18\Community" # adjust path
43+
Start-Process $setup -Verb RunAs -Wait -ArgumentList @(
44+
"modify","--installPath",$vs,
45+
"--add","Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
46+
"--add","Microsoft.VisualStudio.Component.VC.ATL.Spectre",
47+
"--add","Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre",
48+
"--passive","--norestart"
49+
)
50+
```
51+
52+
> OpenCodeIDE patches Code-OSS `preinstall.ts` to accept **Visual Studio 2026** (`18`), which upstream does not list yet.
53+
2154
## One-time setup
2255

2356
```bash
2457
npm run vscode:setup
2558
```
2659

2760
This will:
61+
2862
1. Clone `microsoft/vscode` into `vscode/` (shallow)
29-
2. Apply OpenCodeIDE branding to `product.json`
30-
3. Run `npm install` inside `vscode/` (10–20+ minutes)
63+
2. Apply OpenCodeIDE branding
64+
3. Apply toolchain patches (VS 2026)
65+
4. Run full `npm install` (native modules included)
3166

3267
If Code-OSS is already cloned:
3368

3469
```bash
3570
npm run vscode:brand
71+
node scripts/apply-vscode-patches.mjs
3672
npm run vscode:install
3773
```
3874

3975
## Develop / launch
4076

4177
```bash
42-
# Compile AI extension
43-
npm run build:extensions
44-
45-
# Compile Code-OSS (first time is slow)
46-
npm run vscode:compile
47-
48-
# Launch branded IDE with AI extension in development mode
49-
npm run vscode:dev
78+
npm run build:extensions # compile AI extension
79+
npm run vscode:compile # compile editor (first time is slow)
80+
npm run vscode:dev # launch OpenCodeIDE with AI sidebar
5081
```
5182

5283
What you should see:
53-
- Window title / product name: **OpenCodeIDE**
54-
- Activity bar: **AI Agent** icon
55-
- Chat sidebar can run:
56-
- `list files`
57-
- `read README.md`
58-
- `search TODO`
59-
- Configure LLM: Command Palette → **OpenCodeIDE AI: Configure AI Provider**
60-
61-
## Branding fields applied
62-
63-
| Field | Value |
64-
|-------|--------|
65-
| nameShort | OpenCodeIDE |
66-
| applicationName | opencodeide |
67-
| dataFolderName | .opencodeide |
68-
| urlProtocol | opencodeide |
69-
| darwinBundleIdentifier | com.kortexio.opencodeide |
84+
85+
- Product name: **OpenCodeIDE**
86+
- Activity bar: **AI Agent**
87+
- Chat: `list files` · `read README.md` · `search TODO`
88+
- Command Palette → **OpenCodeIDE AI: Configure AI Provider**
89+
90+
## Scripts
91+
92+
| Script | Purpose |
93+
|--------|---------|
94+
| `npm run vscode:setup` | Clone + brand + patch + install |
95+
| `npm run vscode:brand` | Re-apply product.json branding |
96+
| `npm run vscode:install` | `npm install` inside `vscode/` |
97+
| `npm run vscode:compile` | `compile-client` |
98+
| `npm run vscode:dev` | Launch with `--extensionDevelopmentPath` |
7099

71100
## Next hardening steps
72101

73-
1. Register `opencodeide-ai` as a **built-in** extension (add to `gulpfile.extensions.ts` compilations)
74-
2. Replace Electron placeholder packaging with Code-OSS gulp packaging
75-
3. Wire full Agent Runtime (`src/ai`) into the extension host (not only chat/LLM shortcuts)
76-
4. Continuous rebase workflow against upstream `microsoft/vscode`
102+
1. Register `opencodeide-ai` in `gulpfile.extensions.ts` as built-in
103+
2. Package via Code-OSS gulp (replace Electron placeholder)
104+
3. Wire full `src/ai` Agent Runtime into the extension host
105+
4. Continuous rebase against upstream `microsoft/vscode`
77106

78107
## Notes
79108

80109
- `vscode/` is **not committed** (too large). Use `npm run vscode:setup` on each machine.
81-
- Upstream Code-OSS uses its own Node/npm toolchain; prefer Node 20 LTS if install fails on newer Node.
110+
- Do **not** use `--ignore-scripts` for vscode install — native modules must build.

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
"verify": "npm run build && npm run test:unit",
5151
"vscode:setup": "node scripts/setup-vscode.mjs",
5252
"vscode:setup:skip-install": "node scripts/setup-vscode.mjs --skip-install",
53-
"vscode:brand": "node scripts/apply-branding.mjs",
53+
"vscode:brand": "node scripts/apply-branding.mjs && node scripts/apply-vscode-patches.mjs",
5454
"vscode:install": "npm --prefix vscode install",
55-
"vscode:compile": "npm --prefix vscode run compile",
55+
"vscode:compile": "npm --prefix vscode run compile-client",
56+
"vscode:compile:all": "npm --prefix vscode run compile",
5657
"vscode:watch": "npm --prefix vscode run watch",
5758
"vscode:dev": "node scripts/dev-vscode.mjs",
5859
"package": "npm run clean && npm run build && electron-builder --dir",

‎scripts/apply-vscode-patches.mjs‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Apply OpenCodeIDE patches on top of Code-OSS.
3+
* Currently:
4+
* - Allow Visual Studio 2026 (folder "18") in Windows toolchain check
5+
*/
6+
7+
import fs from 'fs';
8+
import path from 'path';
9+
import { fileURLToPath } from 'url';
10+
11+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
12+
const root = path.resolve(__dirname, '..');
13+
const preinstallPath = path.join(root, 'vscode', 'build', 'npm', 'preinstall.ts');
14+
15+
if (!fs.existsSync(preinstallPath)) {
16+
console.error('vscode/build/npm/preinstall.ts not found. Run vscode setup first.');
17+
process.exit(1);
18+
}
19+
20+
let source = fs.readFileSync(preinstallPath, 'utf8');
21+
22+
const oldVersions = `const supportedVersions = ['2022', '2019'];`;
23+
const newVersions = `const supportedVersions = ['2022', '2019', '18', '2026'];`;
24+
25+
if (!source.includes(oldVersions) && source.includes(newVersions)) {
26+
console.log('VS toolchain patch already applied');
27+
process.exit(0);
28+
}
29+
30+
if (!source.includes(oldVersions)) {
31+
console.error('Could not find supportedVersions marker in preinstall.ts — upstream may have changed.');
32+
process.exit(1);
33+
}
34+
35+
source = source.replace(oldVersions, newVersions);
36+
37+
// Also teach the custom-location hint about VS 2026
38+
source = source.replace(
39+
'set vs2022_install=<path> (or vs2019_install for older versions)',
40+
'set vs2022_install=<path> (or vs2019_install / vs18_install / vs2026_install)'
41+
);
42+
43+
fs.writeFileSync(preinstallPath, source, 'utf8');
44+
console.log('Patched vscode/build/npm/preinstall.ts to accept Visual Studio 2026 (18)');

‎scripts/setup-vscode.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ if (!fs.existsSync(vscodeDir)) {
3838
}
3939

4040
run('node', [path.join('scripts', 'apply-branding.mjs')], root);
41+
run('node', [path.join('scripts', 'apply-vscode-patches.mjs')], root);
4142

4243
if (!skipInstall) {
4344
console.log('\nInstalling Code-OSS dependencies (this can take 10–20 minutes)...');
45+
console.log('Requires: Node matching vscode/.nvmrc, VS C++ tools + Spectre libs');
4446
run('npm', ['install'], vscodeDir);
4547
} else {
4648
console.log('\nSkipped npm install (--skip-install)');

0 commit comments

Comments
 (0)