adhdev 0.1.53 → 0.2.0

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 (109) hide show
  1. package/dist/cli-entrypoint.js +12020 -0
  2. package/dist/cli-entrypoint.js.map +1 -0
  3. package/dist/index.js +9789 -9864
  4. package/dist/index.js.map +1 -0
  5. package/package.json +19 -16
  6. package/providers/_builtin/CONTRIBUTING.md +141 -0
  7. package/providers/_builtin/README.md +51 -0
  8. package/providers/_builtin/acp/agentpool/provider.json +47 -0
  9. package/providers/_builtin/acp/amp/provider.json +45 -0
  10. package/providers/_builtin/acp/auggie/provider.json +50 -0
  11. package/providers/_builtin/acp/autodev/provider.json +47 -0
  12. package/providers/_builtin/acp/autohand/provider.json +45 -0
  13. package/providers/_builtin/acp/blackbox-ai/provider.json +47 -0
  14. package/providers/_builtin/acp/claude-agent/provider.json +50 -0
  15. package/providers/_builtin/acp/cline-acp/provider.json +47 -0
  16. package/providers/_builtin/acp/code-assistant/provider.json +47 -0
  17. package/providers/_builtin/acp/codebuddy/provider.json +47 -0
  18. package/providers/_builtin/acp/codex-cli/provider.json +50 -0
  19. package/providers/_builtin/acp/corust-agent/provider.json +45 -0
  20. package/providers/_builtin/acp/crow-cli/provider.json +47 -0
  21. package/providers/_builtin/acp/cursor-acp/provider.json +47 -0
  22. package/providers/_builtin/acp/deepagents/provider.json +45 -0
  23. package/providers/_builtin/acp/dimcode/provider.json +47 -0
  24. package/providers/_builtin/acp/docker-cagent/provider.json +50 -0
  25. package/providers/_builtin/acp/factory-droid/provider.json +53 -0
  26. package/providers/_builtin/acp/fast-agent/provider.json +45 -0
  27. package/providers/_builtin/acp/fount/provider.json +47 -0
  28. package/providers/_builtin/acp/gemini-cli/provider.json +107 -0
  29. package/providers/_builtin/acp/github-copilot/provider.json +47 -0
  30. package/providers/_builtin/acp/goose/provider.json +50 -0
  31. package/providers/_builtin/acp/junie/provider.json +45 -0
  32. package/providers/_builtin/acp/kilo/provider.json +45 -0
  33. package/providers/_builtin/acp/kimi-cli/provider.json +50 -0
  34. package/providers/_builtin/acp/kiro-cli/provider.json +47 -0
  35. package/providers/_builtin/acp/minion-code/provider.json +45 -0
  36. package/providers/_builtin/acp/mistral-vibe/provider.json +50 -0
  37. package/providers/_builtin/acp/nova/provider.json +47 -0
  38. package/providers/_builtin/acp/openclaw/provider.json +47 -0
  39. package/providers/_builtin/acp/opencode/provider.json +45 -0
  40. package/providers/_builtin/acp/openhands/provider.json +47 -0
  41. package/providers/_builtin/acp/pi-acp/provider.json +45 -0
  42. package/providers/_builtin/acp/qoder/provider.json +47 -0
  43. package/providers/_builtin/acp/qwen-code/provider.json +53 -0
  44. package/providers/_builtin/acp/stakpak/provider.json +47 -0
  45. package/providers/_builtin/acp/vtcode/provider.json +47 -0
  46. package/providers/_builtin/cli/claude-cli/provider.json +78 -0
  47. package/providers/_builtin/cli/codex-cli/provider.json +60 -0
  48. package/providers/_builtin/cli/gemini-cli/provider.json +64 -0
  49. package/providers/_builtin/extension/cline/provider.json +11 -0
  50. package/providers/_builtin/extension/cline/scripts/open_panel.js +1 -1
  51. package/providers/_builtin/extension/cline/{provider.js → scripts.js} +29 -55
  52. package/providers/_builtin/extension/roo-code/provider.json +11 -0
  53. package/providers/_builtin/extension/roo-code/{provider.js → scripts.js} +27 -97
  54. package/providers/_builtin/ide/antigravity/provider.json +32 -0
  55. package/providers/_builtin/ide/antigravity/scripts.js +73 -0
  56. package/providers/_builtin/ide/cursor/provider.json +35 -0
  57. package/providers/_builtin/ide/cursor/{provider.js → scripts.js} +31 -69
  58. package/providers/_builtin/ide/kiro/provider.json +36 -0
  59. package/providers/_builtin/ide/kiro/scripts/webview_send_message.js +72 -0
  60. package/providers/_builtin/ide/kiro/scripts.js +62 -0
  61. package/providers/_builtin/ide/pearai/provider.json +36 -0
  62. package/providers/_builtin/ide/pearai/scripts/list_sessions.js +38 -0
  63. package/providers/_builtin/ide/pearai/scripts/new_session.js +55 -0
  64. package/providers/_builtin/ide/pearai/scripts/webview_list_sessions.js +62 -0
  65. package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +32 -4
  66. package/providers/_builtin/ide/pearai/scripts/webview_send_message.js +72 -0
  67. package/providers/_builtin/ide/pearai/scripts/webview_switch_session.js +34 -0
  68. package/providers/_builtin/ide/pearai/scripts.js +74 -0
  69. package/providers/_builtin/ide/trae/provider.json +35 -0
  70. package/providers/_builtin/ide/trae/scripts/send_message.js +53 -3
  71. package/providers/_builtin/ide/trae/scripts.js +57 -0
  72. package/providers/_builtin/ide/vscode/provider.json +33 -0
  73. package/providers/_builtin/ide/vscode-insiders/provider.json +31 -0
  74. package/providers/_builtin/ide/vscodium/provider.json +32 -0
  75. package/providers/_builtin/ide/windsurf/provider.json +22 -0
  76. package/providers/_builtin/ide/windsurf/scripts.js +57 -0
  77. package/providers/_builtin/validate.js +156 -0
  78. package/README.md +0 -43
  79. package/dist/dev-console-monaco.js +0 -176
  80. package/dist/dev-console.css +0 -326
  81. package/dist/dev-console.html +0 -148
  82. package/dist/dev-console.js +0 -1165
  83. package/dist/index.d.ts +0 -2
  84. package/dist/node_datachannel-LPY6EJH5.node +0 -0
  85. package/providers/_builtin/acp/codex-cli/provider.js +0 -54
  86. package/providers/_builtin/acp/goose/provider.js +0 -32
  87. package/providers/_builtin/acp/opencode/provider.js +0 -32
  88. package/providers/_builtin/cli/claude-cli/provider.js +0 -125
  89. package/providers/_builtin/cli/codex-cli/provider.js +0 -77
  90. package/providers/_builtin/cli/gemini-cli/provider.js +0 -121
  91. package/providers/_builtin/ide/antigravity/provider.js +0 -114
  92. package/providers/_builtin/ide/cursor/provider.js.backup +0 -116
  93. package/providers/_builtin/ide/cursor/provider.js.bak +0 -127
  94. package/providers/_builtin/ide/cursor/scripts_backup/focus_editor.js +0 -20
  95. package/providers/_builtin/ide/cursor/scripts_backup/list_chats.js +0 -111
  96. package/providers/_builtin/ide/cursor/scripts_backup/new_session.js +0 -62
  97. package/providers/_builtin/ide/cursor/scripts_backup/open_panel.js +0 -31
  98. package/providers/_builtin/ide/cursor/scripts_backup/read_chat.js +0 -433
  99. package/providers/_builtin/ide/cursor/scripts_backup/resolve_action.js +0 -90
  100. package/providers/_builtin/ide/cursor/scripts_backup/send_message.js +0 -86
  101. package/providers/_builtin/ide/cursor/scripts_backup/switch_session.js +0 -63
  102. package/providers/_builtin/ide/kiro/provider.js +0 -86
  103. package/providers/_builtin/ide/pearai/provider.js +0 -88
  104. package/providers/_builtin/ide/trae/provider.js +0 -83
  105. package/providers/_builtin/ide/vscode/provider.js +0 -36
  106. package/providers/_builtin/ide/vscode-insiders/provider.js +0 -27
  107. package/providers/_builtin/ide/vscodium/provider.js +0 -27
  108. package/providers/_builtin/ide/windsurf/provider.js +0 -76
  109. /package/providers/{_helpers → _builtin/_helpers}/index.js +0 -0
@@ -0,0 +1,33 @@
1
+ {
2
+ "type": "vscode",
3
+ "name": "Visual Studio Code",
4
+ "category": "ide",
5
+ "displayName": "VS Code",
6
+ "icon": "💙",
7
+ "cli": "code",
8
+ "cdpPorts": [
9
+ 9339,
10
+ 9340
11
+ ],
12
+ "processNames": {
13
+ "darwin": "Visual Studio Code",
14
+ "win32": [
15
+ "Code.exe"
16
+ ]
17
+ },
18
+ "paths": {
19
+ "darwin": [
20
+ "/Applications/Visual Studio Code.app"
21
+ ],
22
+ "win32": [
23
+ "C:\\Program Files\\Microsoft VS Code\\Code.exe",
24
+ "C:\\Users\\*\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
25
+ ],
26
+ "linux": [
27
+ "/usr/share/code",
28
+ "/snap/code/current"
29
+ ]
30
+ },
31
+ "inputMethod": "cdp-type-and-send",
32
+ "inputSelector": "[contenteditable=\"true\"][role=\"textbox\"]"
33
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "type": "vscode-insiders",
3
+ "name": "Visual Studio Code - Insiders",
4
+ "category": "ide",
5
+ "displayName": "VS Code Insiders",
6
+ "icon": "💚",
7
+ "cli": "code-insiders",
8
+ "cdpPorts": [
9
+ 9341,
10
+ 9342
11
+ ],
12
+ "processNames": {
13
+ "darwin": "Visual Studio Code - Insiders",
14
+ "win32": [
15
+ "Code - Insiders.exe"
16
+ ]
17
+ },
18
+ "paths": {
19
+ "darwin": [
20
+ "/Applications/Visual Studio Code - Insiders.app"
21
+ ],
22
+ "win32": [
23
+ "C:\\Program Files\\Microsoft VS Code Insiders\\Code - Insiders.exe"
24
+ ],
25
+ "linux": [
26
+ "/usr/share/code-insiders"
27
+ ]
28
+ },
29
+ "inputMethod": "cdp-type-and-send",
30
+ "inputSelector": "[contenteditable=\"true\"][role=\"textbox\"]"
31
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "type": "vscodium",
3
+ "name": "VSCodium",
4
+ "category": "ide",
5
+ "displayName": "VSCodium",
6
+ "icon": "💚",
7
+ "cli": "codium",
8
+ "cdpPorts": [
9
+ 9343,
10
+ 9344
11
+ ],
12
+ "processNames": {
13
+ "darwin": "VSCodium",
14
+ "win32": [
15
+ "VSCodium.exe"
16
+ ]
17
+ },
18
+ "paths": {
19
+ "darwin": [
20
+ "/Applications/VSCodium.app"
21
+ ],
22
+ "win32": [
23
+ "C:\\Program Files\\VSCodium\\VSCodium.exe"
24
+ ],
25
+ "linux": [
26
+ "/usr/share/codium",
27
+ "/snap/codium/current"
28
+ ]
29
+ },
30
+ "inputMethod": "cdp-type-and-send",
31
+ "inputSelector": "[contenteditable=\"true\"][role=\"textbox\"]"
32
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "type": "windsurf",
3
+ "name": "Windsurf",
4
+ "category": "ide",
5
+ "displayName": "Windsurf",
6
+ "icon": "🏄",
7
+ "cli": "windsurf",
8
+ "cdpPorts": [
9
+ 9337,
10
+ 9338
11
+ ],
12
+ "processNames": {
13
+ "darwin": "Windsurf"
14
+ },
15
+ "paths": {
16
+ "darwin": [
17
+ "/Applications/Windsurf.app"
18
+ ]
19
+ },
20
+ "inputMethod": "cdp-type-and-send",
21
+ "inputSelector": "[contenteditable=\"true\"][role=\"textbox\"]"
22
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * CDP Scripts for Windsurf
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const SCRIPTS_DIR = path.join(__dirname, 'scripts');
8
+ function loadScript(name) {
9
+ try { return fs.readFileSync(path.join(SCRIPTS_DIR, name), 'utf8'); }
10
+ catch { return null; }
11
+ }
12
+
13
+
14
+ module.exports.readChat = function readChat() { return loadScript('read_chat.js'); };
15
+
16
+ module.exports.sendMessage = function sendMessage(text) {
17
+ const s = loadScript('send_message.js');
18
+ return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
19
+ };
20
+
21
+ module.exports.listSessions = function listSessions() { return loadScript('list_chats.js'); };
22
+
23
+ module.exports.switchSession = function switchSession(sessionId) {
24
+ const s = loadScript('switch_session.js');
25
+ return s ? s.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId)) : null;
26
+ };
27
+
28
+ module.exports.newSession = function newSession() { return loadScript('new_session.js'); };
29
+
30
+ module.exports.resolveAction = function resolveAction(params) {
31
+ const action = typeof params === 'string' ? params : params?.action || 'approve';
32
+ const buttonText = params?.button || params?.buttonText
33
+ || (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
34
+ const s = loadScript('resolve_action.js');
35
+ return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
36
+ };
37
+
38
+ module.exports.focusEditor = function focusEditor() { return loadScript('focus_editor.js'); };
39
+
40
+ module.exports.listModels = function listModels() { return loadScript('list_models.js'); };
41
+
42
+ module.exports.setModel = function setModel(params) {
43
+ const model = typeof params === 'string' ? params : params?.model;
44
+ const s = loadScript('set_model.js');
45
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
46
+ };
47
+
48
+ module.exports.listModes = function listModes() { return loadScript('list_modes.js'); };
49
+
50
+ module.exports.setMode = function setMode(params) {
51
+ const mode = typeof params === 'string' ? params : params?.mode;
52
+ const s = loadScript('set_mode.js');
53
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
54
+ };
55
+
56
+ module.exports.openPanel = function openPanel() { return loadScript('open_panel.js'); };
57
+
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ADHDev Provider Validator
4
+ *
5
+ * Usage:
6
+ * node validate.js # validate all providers
7
+ * node validate.js ide/my-ide/provider.js # validate a single file
8
+ */
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+
12
+ const REQUIRED_FIELDS = ['type', 'name', 'category'];
13
+ const VALID_CATEGORIES = ['ide', 'extension', 'cli', 'acp'];
14
+ const USED_PORTS = new Map();
15
+ const USED_TYPES = new Map();
16
+
17
+ let errors = 0;
18
+ let warnings = 0;
19
+ let validated = 0;
20
+
21
+ function validate(filePath) {
22
+ const rel = path.relative(process.cwd(), filePath);
23
+
24
+ // 1. Syntax check
25
+ try {
26
+ delete require.cache[require.resolve(filePath)];
27
+ } catch {}
28
+
29
+ let mod;
30
+ try {
31
+ mod = require(filePath);
32
+ } catch (e) {
33
+ console.error(`❌ ${rel}: syntax error — ${e.message}`);
34
+ errors++;
35
+ return;
36
+ }
37
+
38
+ // 2. Required fields
39
+ for (const field of REQUIRED_FIELDS) {
40
+ if (!mod[field]) {
41
+ console.error(`❌ ${rel}: missing required field '${field}'`);
42
+ errors++;
43
+ return;
44
+ }
45
+ }
46
+
47
+ // 3. Valid category
48
+ if (!VALID_CATEGORIES.includes(mod.category)) {
49
+ console.error(`❌ ${rel}: invalid category '${mod.category}' (must be: ${VALID_CATEGORIES.join(', ')})`);
50
+ errors++;
51
+ return;
52
+ }
53
+
54
+ // 4. Unique type
55
+ if (USED_TYPES.has(mod.type)) {
56
+ console.error(`❌ ${rel}: duplicate type '${mod.type}' (also in ${USED_TYPES.get(mod.type)})`);
57
+ errors++;
58
+ return;
59
+ }
60
+ USED_TYPES.set(mod.type, rel);
61
+
62
+ // 5. IDE-specific checks
63
+ if (mod.category === 'ide') {
64
+ if (!mod.cdpPorts || !Array.isArray(mod.cdpPorts) || mod.cdpPorts.length < 2) {
65
+ console.warn(`⚠ ${rel}: IDE missing cdpPorts [primary, fallback]`);
66
+ warnings++;
67
+ } else {
68
+ for (const port of mod.cdpPorts) {
69
+ if (USED_PORTS.has(port)) {
70
+ console.error(`❌ ${rel}: CDP port ${port} conflicts with ${USED_PORTS.get(port)}`);
71
+ errors++;
72
+ }
73
+ USED_PORTS.set(port, rel);
74
+ }
75
+ }
76
+
77
+ if (!mod.cli) {
78
+ console.warn(`⚠ ${rel}: IDE missing 'cli' field`);
79
+ warnings++;
80
+ }
81
+
82
+ if (!mod.paths) {
83
+ console.warn(`⚠ ${rel}: IDE missing 'paths' (install detection won't work)`);
84
+ warnings++;
85
+ }
86
+ }
87
+
88
+ // 6. ACP-specific checks
89
+ if (mod.category === 'acp') {
90
+ if (!mod.spawn || !mod.spawn.command) {
91
+ console.warn(`⚠ ${rel}: ACP missing spawn.command`);
92
+ warnings++;
93
+ }
94
+ }
95
+
96
+ // 7. Scripts check
97
+ if (mod.category === 'ide' || mod.category === 'extension') {
98
+ const hasRead = mod.scripts?.readChat || mod.scripts?.webviewReadChat;
99
+ const hasSend = mod.scripts?.sendMessage || mod.scripts?.webviewSendMessage;
100
+ if (!hasRead) {
101
+ console.warn(`⚠ ${rel}: no readChat/webviewReadChat script`);
102
+ warnings++;
103
+ }
104
+ if (!hasSend) {
105
+ console.warn(`⚠ ${rel}: no sendMessage/webviewSendMessage script`);
106
+ warnings++;
107
+ }
108
+ }
109
+
110
+ // 8. Webview IDE consistency
111
+ if (mod.category === 'ide' && mod.webviewMatchText) {
112
+ if (!mod.scripts?.webviewReadChat) {
113
+ console.warn(`⚠ ${rel}: has webviewMatchText but no webviewReadChat script`);
114
+ warnings++;
115
+ }
116
+ }
117
+
118
+ validated++;
119
+ console.log(`✅ ${rel}: ${mod.type} (${mod.category}) — ${mod.name}`);
120
+ }
121
+
122
+ function scanDir(dir) {
123
+ if (!fs.existsSync(dir)) return;
124
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
125
+ const full = path.join(dir, entry.name);
126
+ if (entry.isDirectory()) {
127
+ if (entry.name.startsWith('_') || entry.name.startsWith('.')) continue;
128
+ scanDir(full);
129
+ } else if (entry.name === 'provider.js') {
130
+ validate(full);
131
+ }
132
+ }
133
+ }
134
+
135
+ // ─── Main ───
136
+ const args = process.argv.slice(2);
137
+
138
+ if (args.length > 0) {
139
+ // Validate specific file(s)
140
+ for (const arg of args) {
141
+ const filePath = path.resolve(arg);
142
+ if (!fs.existsSync(filePath)) {
143
+ console.error(`❌ File not found: ${arg}`);
144
+ errors++;
145
+ continue;
146
+ }
147
+ validate(filePath);
148
+ }
149
+ } else {
150
+ // Validate all
151
+ console.log('🔍 Validating all providers...\n');
152
+ scanDir(process.cwd());
153
+ }
154
+
155
+ console.log(`\n━━━ Result: ${validated} passed, ${errors} errors, ${warnings} warnings ━━━`);
156
+ process.exit(errors > 0 ? 1 : 0);
package/README.md DELETED
@@ -1,43 +0,0 @@
1
- # adhdev
2
-
3
- **ADHDev CLI** — Setup wizard for the ADHDev platform. Detect, install, and configure IDE + AI agent extensions.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- npx adhdev
9
- ```
10
-
11
- Or install globally:
12
-
13
- ```bash
14
- npm install -g adhdev
15
- adhdev setup
16
- ```
17
-
18
- ## Commands
19
-
20
- | Command | Description |
21
- |---------|-------------|
22
- | `adhdev setup` | Interactive setup wizard |
23
- | `adhdev status` | Show current configuration |
24
- | `adhdev detect` | Detect installed IDEs |
25
- | `adhdev reset` | Reset all configuration |
26
-
27
- ## Supported IDEs
28
-
29
- - ✅ VS Code
30
- - ✅ Cursor
31
- - ✅ Antigravity
32
- - 🔜 JetBrains (coming soon)
33
-
34
- ## What it does
35
-
36
- 1. **Detects** installed IDEs on your system
37
- 2. **Installs** the ADHDev Bridge extension
38
- 3. **Configures** connection to your ADHDev dashboard
39
- 4. **Verifies** the setup is working
40
-
41
- ## License
42
-
43
- Proprietary — All rights reserved.
@@ -1,176 +0,0 @@
1
- require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.2/min/vs' } });
2
-
3
- require(['vs/editor/editor.main'], function() {
4
- // ─── Custom Dark Theme ───
5
- monaco.editor.defineTheme('adhdev-dark', {
6
- base: 'vs-dark',
7
- inherit: true,
8
- rules: [
9
- { token: 'comment', foreground: '6a9955', fontStyle: 'italic' },
10
- { token: 'keyword', foreground: 'c586c0' },
11
- { token: 'string', foreground: 'ce9178' },
12
- { token: 'number', foreground: 'b5cea8' },
13
- { token: 'type', foreground: '4ec9b0' },
14
- { token: 'identifier', foreground: '9cdcfe' },
15
- { token: 'delimiter', foreground: 'd4d4d4' },
16
- ],
17
- colors: {
18
- 'editor.background': '#0d1117',
19
- 'editor.foreground': '#c9d1d9',
20
- 'editor.lineHighlightBackground': '#161b2280',
21
- 'editorLineNumber.foreground': '#484f58',
22
- 'editorLineNumber.activeForeground': '#8b949e',
23
- 'editor.selectionBackground': '#264f7840',
24
- 'editorCursor.foreground': '#58a6ff',
25
- 'editor.inactiveSelectionBackground': '#264f7820',
26
- 'editorGutter.background': '#0d1117',
27
- 'minimap.background': '#0d1117',
28
- 'editorWidget.background': '#161b22',
29
- 'editorSuggestWidget.background': '#161b22',
30
- 'editorSuggestWidget.border': '#30363d',
31
- 'editorSuggestWidget.selectedBackground': '#1f6feb40',
32
- },
33
- });
34
-
35
- // ─── Helper Function Typedefs (autocomplete) ───
36
- const helperDefs = `
37
- /** Log a message to DevConsole output */
38
- declare function log(message: any, ...args: any[]): void;
39
- /** Probe an element — returns bounds, styles, attributes */
40
- declare function probe(el: Element, opts?: { bounds?: boolean, styles?: string[], attributes?: boolean }): { tag: string, id: string, classes: string[], bounds?: DOMRect, styles?: Record<string, string>, attributes?: Record<string, string> };
41
- /** Query all elements matching selector, returns summary array */
42
- declare function queryAll(selector: string, limit?: number): Array<{ index: number, tag: string, text: string, visible: boolean, bounds: DOMRect }>;
43
- /** Click an element by selector */
44
- declare function click(selector: string): boolean;
45
- /** Wait for an element to appear (polls) */
46
- declare function waitFor(selector: string, timeoutMs?: number): Promise<Element | null>;
47
- /** Get computed style value */
48
- declare function getStyle(el: Element, prop: string): string;
49
- /** Sleep for ms */
50
- declare function sleep(ms: number): Promise<void>;
51
- `;
52
- monaco.languages.typescript.javascriptDefaults.addExtraLib(helperDefs, 'helpers.d.ts');
53
- monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
54
- noSemanticValidation: true,
55
- noSyntaxValidation: false,
56
- });
57
- monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
58
- target: monaco.languages.typescript.ScriptTarget.ES2020,
59
- allowNonTsExtensions: true,
60
- allowJs: true,
61
- });
62
-
63
- const defaultCode = `// Write JS to evaluate via CDP — Ctrl+Enter to run
64
- // Helpers: log(), probe(), queryAll(), click(), waitFor()
65
-
66
- (() => {
67
- const title = document.title;
68
- log('Page title:', title);
69
- return title;
70
- })()`;
71
-
72
- const container = document.getElementById('editor-container');
73
- const monacoEditor = monaco.editor.create(container, {
74
- value: defaultCode,
75
- language: 'javascript',
76
- theme: 'adhdev-dark',
77
- fontFamily: "'JetBrains Mono', monospace",
78
- fontSize: 13,
79
- lineHeight: 22,
80
- minimap: { enabled: true, scale: 1, showSlider: 'mouseover' },
81
- scrollBeyondLastLine: false,
82
- renderLineHighlight: 'all',
83
- cursorBlinking: 'smooth',
84
- cursorSmoothCaretAnimation: 'on',
85
- smoothScrolling: true,
86
- bracketPairColorization: { enabled: true },
87
- autoIndent: 'full',
88
- formatOnPaste: true,
89
- tabSize: 2,
90
- wordWrap: 'on',
91
- padding: { top: 8 },
92
- suggest: {
93
- showKeywords: true,
94
- showSnippets: true,
95
- showFunctions: true,
96
- },
97
- quickSuggestions: true,
98
- parameterHints: { enabled: true },
99
- automaticLayout: true,
100
- });
101
-
102
- // Ctrl+Enter → Run
103
- monacoEditor.addAction({
104
- id: 'run-script',
105
- label: 'Run Script',
106
- keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
107
- run: () => window.runEditor?.(),
108
- });
109
-
110
- // ─── Proxy textarea.value → Monaco ───
111
- const ta = document.getElementById('editor');
112
- Object.defineProperty(ta, 'value', {
113
- get() { return monacoEditor.getValue(); },
114
- set(v) { monacoEditor.setValue(v); },
115
- });
116
- ta.focus = () => monacoEditor.focus();
117
-
118
- window.monacoEditor = monacoEditor;
119
-
120
- // ─── Snippets ───
121
- monaco.languages.registerCompletionItemProvider('javascript', {
122
- provideCompletionItems: (model, position) => {
123
- const word = model.getWordUntilPosition(position);
124
- const range = {
125
- startLineNumber: position.lineNumber,
126
- endLineNumber: position.lineNumber,
127
- startColumn: word.startColumn,
128
- endColumn: word.endColumn,
129
- };
130
- return {
131
- suggestions: [
132
- {
133
- label: 'iife',
134
- kind: monaco.languages.CompletionItemKind.Snippet,
135
- insertText: '(() => {\n ${1:// code}\n return ${2:result};\n})()',
136
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
137
- documentation: 'Immediately Invoked Function Expression (CDP pattern)',
138
- range,
139
- },
140
- {
141
- label: 'aiife',
142
- kind: monaco.languages.CompletionItemKind.Snippet,
143
- insertText: '(async () => {\n ${1:// async code}\n return ${2:result};\n})()',
144
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
145
- documentation: 'Async IIFE (for await/Promise)',
146
- range,
147
- },
148
- {
149
- label: 'qsa',
150
- kind: monaco.languages.CompletionItemKind.Snippet,
151
- insertText: "[...document.querySelectorAll('${1:selector}')].map(el => ({\n tag: el.tagName,\n text: el.textContent?.trim().substring(0, 100),\n visible: el.offsetWidth > 0,\n}))",
152
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
153
- documentation: 'QuerySelectorAll with element mapping',
154
- range,
155
- },
156
- {
157
- label: 'readchat',
158
- kind: monaco.languages.CompletionItemKind.Snippet,
159
- insertText: "(() => {\n const msgs = [];\n document.querySelectorAll('${1:.message}').forEach((el, i) => {\n msgs.push({\n role: el.classList.contains('${2:user}') ? 'user' : 'assistant',\n content: el.textContent.trim().substring(0, 6000),\n index: i,\n });\n });\n return JSON.stringify({ messages: msgs, status: 'idle' });\n})()",
160
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
161
- documentation: 'readChat template',
162
- range,
163
- },
164
- {
165
- label: 'probe',
166
- kind: monaco.languages.CompletionItemKind.Snippet,
167
- insertText: "(() => {\n const el = document.querySelector('${1:selector}');\n if (!el) return JSON.stringify({ error: 'not found' });\n const r = el.getBoundingClientRect();\n return JSON.stringify({\n tag: el.tagName, id: el.id,\n classes: [...el.classList],\n text: el.textContent?.trim().substring(0, 200),\n bounds: { top: r.top, left: r.left, width: r.width, height: r.height },\n styles: { color: getComputedStyle(el).color, bg: getComputedStyle(el).background },\n attrs: Object.fromEntries([...el.attributes].map(a => [a.name, a.value])),\n });\n})()",
168
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
169
- documentation: 'Probe element details (bounds, styles, attrs)',
170
- range,
171
- },
172
- ],
173
- };
174
- },
175
- });
176
- });