Skip to content

Commit e30a2c0

Browse files
jbickerjonah-iden
andauthored
OCT Agent Prototype (#196)
Signed-off-by: Jan Bicker <jan.bicker@typefox.io> Co-authored-by: Jonah Iden <jonah.iden@typefox.io>
1 parent 8fabb2d commit e30a2c0

34 files changed

Lines changed: 4660 additions & 940 deletions

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ensure shell scripts always use LF line endings
2+
*.sh text eol=lf
3+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ dist/
55
*.tsbuildinfo
66
.DS_Store
77
.env
8+
9+
test-collab-project/*
10+
!test-collab-project/.gitkeep
11+
.vscode/extension-host-data-1/
12+
.vscode/extension-host-data-2/

.vscode/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# VS Code Debug Configuration
2+
3+
## Node.js Version Manager Support
4+
5+
This project uses a Node.js wrapper script (`node-wrapper.sh`) to ensure debugging works regardless of how Node.js is installed on your system.
6+
7+
### Supported Node Version Managers
8+
9+
- **nvm** (Node Version Manager)
10+
- **volta**
11+
- System-installed Node.js
12+
13+
### How It Works
14+
15+
The `node-wrapper.sh` script automatically detects and loads your Node version manager before running Node.js. This ensures VS Code can find Node.js even when launched from the Dock/Finder on macOS or Start Menu on Windows.
16+
17+
### Troubleshooting
18+
19+
If you're still having issues with Node.js not being found:
20+
21+
1. **Ensure Node.js is installed**: Run `node --version` in your terminal
22+
2. **Check the wrapper is executable**: It should be executable by default, but you can verify with:
23+
```bash
24+
chmod +x .vscode/node-wrapper.sh
25+
```
26+
3. **Alternative: Launch VS Code from terminal**:
27+
```bash
28+
code .
29+
```
30+
This ensures VS Code inherits your shell's PATH environment.
31+
32+
### For Other Version Managers
33+
34+
If you use a different Node version manager (e.g., `fnm`, `asdf`), you can modify `node-wrapper.sh` to add support for it.

.vscode/launch-extension-host.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Spawns a second Extension Development Host window (separate process).
3+
* Used for chat testing: run "Run VS Code Extension" first, then this config.
4+
* Requires env: WORKSPACE_FOLDER, VSCODE_EXEC_PATH. Args: folder path, user-data-dir path (relative to workspace).
5+
*/
6+
import { spawn } from 'child_process';
7+
import path from 'path';
8+
9+
const workspaceFolder = process.env.WORKSPACE_FOLDER || process.cwd();
10+
const execPath = process.env.VSCODE_EXEC_PATH;
11+
const folderArg = process.argv[2];
12+
const userDataDirArg = process.argv[3];
13+
14+
if (!execPath || !folderArg || !userDataDirArg) {
15+
console.error('Usage: node launch-extension-host.js <folder> <user-data-dir>');
16+
console.error('Requires env: WORKSPACE_FOLDER, VSCODE_EXEC_PATH');
17+
process.exit(1);
18+
}
19+
20+
const folder = path.resolve(workspaceFolder, folderArg);
21+
const userDataDir = path.resolve(workspaceFolder, userDataDirArg);
22+
const extPath = path.resolve(workspaceFolder, 'packages/open-collaboration-vscode');
23+
24+
// Always use local server (testing only)
25+
const spawnEnv = {
26+
...process.env,
27+
DEVELOPMENT: 'true',
28+
OCT_SERVER_URL: 'http://localhost:8100',
29+
};
30+
31+
const child = spawn(execPath, [
32+
folder,
33+
'--extensionDevelopmentPath=' + extPath,
34+
'--user-data-dir=' + userDataDir,
35+
], { detached: true, stdio: 'ignore', env: spawnEnv });
36+
child.unref();

.vscode/launch.json

Lines changed: 168 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,170 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "attach",
10-
"name": "Attach to Service Process",
11-
"port": "${input:attachPort}",
12-
13-
},
14-
{
15-
"type": "node",
16-
"request": "launch",
17-
"name": "Launch Server",
18-
"skipFiles": [
19-
"<node_internals>/**"
20-
],
21-
"program": "${workspaceFolder}/packages/open-collaboration-server/lib/app.js",
22-
"args": [
23-
"--hostname=0.0.0.0"
24-
],
25-
"sourceMaps": true,
26-
"outFiles": [
27-
"${workspaceFolder}/packages/open-collaboration-server/lib/**/*.js",
28-
],
29-
"env": {
30-
"OCT_ACTIVATE_SIMPLE_LOGIN": "true",
31-
"OCT_REDIRECT_URL_WHITELIST": "http://localhost:5173/",
32-
}
33-
},
34-
{
35-
"name": "Run VS Code Extension",
36-
"type": "extensionHost",
37-
"request": "launch",
38-
"args": [
39-
"--extensionDevelopmentPath=${workspaceFolder}/packages/open-collaboration-vscode"
40-
],
41-
"env": {
42-
"DEVELOPMENT": "true"
43-
},
44-
"sourceMaps": true,
45-
"outFiles": [
46-
"${workspaceFolder}/packages/open-collaboration-vscode/dist/**/*.js"
47-
]
48-
},
49-
{
50-
"name": "Run VS Code Web Extension",
51-
"type": "extensionHost",
52-
"request": "launch",
53-
"args": [
54-
"--extensionDevelopmentPath=${workspaceFolder}/packages/open-collaboration-vscode",
55-
"--extensionDevelopmentKind=web"
56-
],
57-
// VS Code cannot debug the web extension directly, which is why we don't configure source maps here
58-
// Instead, use VS Code browser dev tools (Help -> Toggle Developer Tools) to debug the web extension
59-
},
60-
{
61-
"name": "Launch Service Process",
62-
"type": "node",
63-
"request": "launch",
64-
"console": "integratedTerminal",
65-
"outFiles": [
66-
"${workspaceFolder}/packages/open-collaboration-service-process/lib/**/*.js"
67-
],
68-
"sourceMaps": true,
69-
"program": "${workspaceFolder}/packages/open-collaboration-service-process/lib/process.js",
70-
"args": [
71-
"--server-address=http://localhost:8100",
72-
"--auth-token=12312"
73-
]
74-
},
75-
{
76-
"name": "Debug Monaco Examples",
77-
"request": "launch",
78-
"type": "chrome",
79-
"url": "http://localhost:5173/",
80-
"webRoot": "${workspaceFolder}/packages/open-collaboration-monaco",
81-
},
82-
{
83-
"name": "Vitest: Run Selected File",
84-
"type": "node",
85-
"request": "launch",
86-
"autoAttachChildProcesses": true,
87-
"skipFiles": ["<node_internals>/**", "**/node_modules/**", "!**/node_modules/vscode-*/**"],
88-
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
89-
"args": ["run", "${relativeFile}"],
90-
"console": "integratedTerminal",
91-
"smartStep": true,
92-
"sourceMaps": true,
93-
"outFiles": []
94-
}
95-
],
96-
"inputs": [
97-
{
98-
"id": "attachPort",
99-
"type": "promptString",
100-
"description": "What port should the application use for debugging?",
101-
"default": "23698"
102-
}
103-
]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Server",
11+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
12+
"skipFiles": ["<node_internals>/**"],
13+
"program": "${workspaceFolder}/packages/open-collaboration-server/lib/app.js",
14+
"args": ["--hostname=0.0.0.0"],
15+
"sourceMaps": true,
16+
"outFiles": [
17+
"${workspaceFolder}/packages/open-collaboration-server/lib/**/*.js"
18+
],
19+
"env": {
20+
"OCT_ACTIVATE_SIMPLE_LOGIN": "true",
21+
"OCT_REDIRECT_URL_WHITELIST": "http://localhost:5173/"
22+
}
23+
},
24+
// Chat test: run "Run VS Code Extension", then "Spawn Second Extension Instance" to get two windows (protocol + vscode).
25+
{
26+
"name": "Run VS Code Extension",
27+
"type": "extensionHost",
28+
"request": "launch",
29+
"args": [
30+
"--extensionDevelopmentPath=${workspaceFolder}/packages/open-collaboration-vscode",
31+
"--user-data-dir=${workspaceFolder}/.vscode/extension-host-data-1"
32+
],
33+
"env": {
34+
"DEVELOPMENT": "true"
35+
},
36+
"sourceMaps": true,
37+
"outFiles": [
38+
"${workspaceFolder}/packages/open-collaboration-vscode/dist/**/*.js"
39+
]
40+
},
41+
{
42+
"name": "Spawn Second Extension Instance",
43+
"type": "node",
44+
"request": "launch",
45+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
46+
"program": "${workspaceFolder}/.vscode/launch-extension-host.js",
47+
"args": [
48+
"packages/open-collaboration-vscode",
49+
".vscode/extension-host-data-2"
50+
],
51+
"env": {
52+
"WORKSPACE_FOLDER": "${workspaceFolder}",
53+
"VSCODE_EXEC_PATH": "${execPath}",
54+
"OCT_SERVER_URL": "http://localhost:8100"
55+
},
56+
"console": "integratedTerminal"
57+
},
58+
{
59+
"name": "Run VS Code Web Extension",
60+
"type": "extensionHost",
61+
"request": "launch",
62+
"args": [
63+
"--extensionDevelopmentPath=${workspaceFolder}/packages/open-collaboration-vscode",
64+
"--extensionDevelopmentKind=web"
65+
]
66+
// VS Code cannot debug the web extension directly, which is why we don't configure source maps here
67+
// Instead, use VS Code browser dev tools (Help -> Toggle Developer Tools) to debug the web extension
68+
},
69+
{
70+
"name": "Launch Service Process",
71+
"type": "node",
72+
"request": "launch",
73+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
74+
"console": "integratedTerminal",
75+
"outFiles": [
76+
"${workspaceFolder}/packages/open-collaboration-service-process/lib/**/*.js"
77+
],
78+
"sourceMaps": true,
79+
"program": "${workspaceFolder}/packages/open-collaboration-service-process/lib/process.js",
80+
"args": ["--server-address=http://localhost:8100", "--auth-token=12312"]
81+
},
82+
{
83+
"name": "Debug Monaco Examples",
84+
"request": "launch",
85+
"type": "chrome",
86+
"url": "http://localhost:5173/",
87+
"webRoot": "${workspaceFolder}/packages/open-collaboration-monaco"
88+
},
89+
{
90+
"name": "Vitest: Run Selected File",
91+
"type": "node",
92+
"request": "launch",
93+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
94+
"autoAttachChildProcesses": true,
95+
"skipFiles": [
96+
"<node_internals>/**",
97+
"**/node_modules/**",
98+
"!**/node_modules/vscode-*/**"
99+
],
100+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
101+
"args": ["run", "${relativeFile}"],
102+
"console": "integratedTerminal",
103+
"smartStep": true,
104+
"sourceMaps": true,
105+
"outFiles": []
106+
},
107+
{
108+
"name": "Debug Agent",
109+
"type": "node",
110+
"request": "launch",
111+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
112+
"skipFiles": ["<node_internals>/**"],
113+
"program": "${workspaceFolder}/packages/open-collaboration-agent/lib/main.js",
114+
"args": [
115+
"--room",
116+
"${input:roomToken}",
117+
"--server",
118+
"https://api.open-collab.tools"
119+
// Optional: Add "--acp-agent", "npx @zed-industries/claude-code-acp" to override default ACP agent
120+
],
121+
"cwd": "${input:workspaceFolder}",
122+
"console": "integratedTerminal",
123+
"sourceMaps": true,
124+
"outFiles": [
125+
"${workspaceFolder}/packages/open-collaboration-agent/lib/**/*.js"
126+
],
127+
"env": {
128+
"NODE_ENV": "development"
129+
},
130+
"envFile": "${workspaceFolder}/.env"
131+
},
132+
{
133+
"name": "Debug Agent (Local)",
134+
"type": "node",
135+
"request": "launch",
136+
"runtimeExecutable": "${workspaceFolder}/.vscode/node-wrapper.sh",
137+
"skipFiles": ["<node_internals>/**"],
138+
"program": "${workspaceFolder}/node_modules/.bin/tsx",
139+
"args": [
140+
"watch",
141+
"${workspaceFolder}/packages/open-collaboration-agent/src/main.ts",
142+
"--room",
143+
"${input:roomToken}",
144+
"--server",
145+
"http://localhost:8100"
146+
// Optional: Add "--acp-agent", "npx @zed-industries/claude-code-acp" to override default ACP agent
147+
],
148+
"cwd": "${input:workspaceFolder}",
149+
"console": "integratedTerminal",
150+
"restart": true,
151+
"env": {
152+
"NODE_ENV": "development"
153+
},
154+
"envFile": "${workspaceFolder}/.env"
155+
}
156+
],
157+
"inputs": [
158+
{
159+
"id": "roomToken",
160+
"type": "promptString",
161+
"description": "Enter the room token to join"
162+
},
163+
{
164+
"id": "workspaceFolder",
165+
"type": "promptString",
166+
"description": "Enter the workspace folder to use",
167+
"default": "${workspaceFolder}"
168+
}
169+
]
104170
}

.vscode/node-wrapper.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Node.js wrapper for VS Code debugging
3+
# This script ensures Node.js is available regardless of version manager (nvm, volta, etc.)
4+
5+
# Try to source nvm if it exists
6+
if [ -s "$HOME/.nvm/nvm.sh" ]; then
7+
export NVM_DIR="$HOME/.nvm"
8+
source "$NVM_DIR/nvm.sh"
9+
fi
10+
11+
# Try to source volta if it exists
12+
if [ -d "$HOME/.volta" ]; then
13+
export VOLTA_HOME="$HOME/.volta"
14+
export PATH="$VOLTA_HOME/bin:$PATH"
15+
fi
16+
17+
# Execute node with all arguments passed to this script
18+
exec node "$@"
19+

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export default [{
3838
'**/*env.d.ts'
3939
],
4040
}, ...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended'), {
41+
// Node-based helper scripts (e.g. .vscode/*.js) need Node globals like `process` and `console`.
42+
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
43+
languageOptions: {
44+
globals: {
45+
...globals.node
46+
},
47+
ecmaVersion: 2022,
48+
sourceType: 'module'
49+
}
50+
}, {
4151
files: [
4252
'**/src/**/*.ts',
4353
'**/src/**/*.tsx',

0 commit comments

Comments
 (0)