@adhdev/daemon-core 0.6.12 → 0.6.15

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 (62) hide show
  1. package/dist/index.js +6688 -6598
  2. package/dist/index.js.map +1 -1
  3. package/package.json +1 -1
  4. package/providers/_builtin/ide/antigravity/provider.json +3 -2
  5. package/providers/_builtin/ide/antigravity/scripts/1.106/list_models.js +38 -0
  6. package/providers/_builtin/ide/antigravity/scripts/1.106/list_modes.js +48 -0
  7. package/providers/_builtin/ide/antigravity/scripts/1.106/read_chat.js +290 -0
  8. package/providers/_builtin/ide/antigravity/scripts/1.106/scripts.js +57 -0
  9. package/providers/_builtin/ide/antigravity/scripts/1.106/set_mode.js +34 -0
  10. package/providers/_builtin/ide/antigravity/scripts/1.106/set_model.js +47 -0
  11. package/providers/_builtin/ide/antigravity/scripts/1.107/focus_editor.js +20 -0
  12. package/providers/_builtin/ide/antigravity/scripts/1.107/list_chats.js +137 -0
  13. package/providers/_builtin/ide/antigravity/scripts/1.107/new_session.js +75 -0
  14. package/providers/_builtin/ide/antigravity/scripts/1.107/resolve_action.js +63 -0
  15. package/providers/_builtin/ide/antigravity/scripts/1.107/send_message.js +56 -0
  16. package/providers/_builtin/ide/antigravity/scripts/1.107/switch_session.js +114 -0
  17. package/providers/_builtin/ide/cursor/provider.json +2 -2
  18. package/providers/_builtin/ide/cursor/scripts/0.49/dismiss_notification.js +30 -0
  19. package/providers/_builtin/ide/cursor/scripts/0.49/focus_editor.js +13 -0
  20. package/providers/_builtin/ide/cursor/scripts/0.49/list_models.js +78 -0
  21. package/providers/_builtin/ide/cursor/scripts/0.49/list_modes.js +40 -0
  22. package/providers/_builtin/ide/cursor/scripts/0.49/list_notifications.js +23 -0
  23. package/providers/_builtin/ide/cursor/scripts/0.49/new_session.js +20 -0
  24. package/providers/_builtin/ide/cursor/scripts/0.49/open_panel.js +23 -0
  25. package/providers/_builtin/ide/cursor/scripts/0.49/resolve_action.js +19 -0
  26. package/providers/_builtin/ide/cursor/scripts/0.49/scripts.js +78 -0
  27. package/providers/_builtin/ide/cursor/scripts/0.49/send_message.js +23 -0
  28. package/providers/_builtin/ide/cursor/scripts/0.49/set_mode.js +38 -0
  29. package/providers/_builtin/ide/cursor/scripts/0.49/set_model.js +81 -0
  30. package/providers/_builtin/ide/cursor/scripts/0.49/switch_session.js +28 -0
  31. package/providers/_builtin/ide/cursor/scripts/0.49.bak/list_sessions.js +42 -0
  32. package/providers/_builtin/ide/cursor/scripts/0.49.bak/read_chat.js +79 -0
  33. package/src/commands/router.ts +3 -3
  34. package/src/daemon/dev-server.ts +201 -148
  35. package/src/daemon/scaffold-template.ts +9 -2
  36. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/focus_editor.js +0 -0
  37. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/list_chats.js +0 -0
  38. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/new_session.js +0 -0
  39. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/resolve_action.js +0 -0
  40. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/send_message.js +0 -0
  41. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.106}/switch_session.js +0 -0
  42. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/list_models.js +0 -0
  43. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/list_modes.js +0 -0
  44. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/read_chat.js +0 -0
  45. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/scripts.js +0 -0
  46. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/set_mode.js +0 -0
  47. /package/providers/_builtin/ide/antigravity/scripts/{1.0 → 1.107}/set_model.js +0 -0
  48. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49}/list_sessions.js +0 -0
  49. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49}/read_chat.js +0 -0
  50. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/dismiss_notification.js +0 -0
  51. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/focus_editor.js +0 -0
  52. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/list_models.js +0 -0
  53. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/list_modes.js +0 -0
  54. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/list_notifications.js +0 -0
  55. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/new_session.js +0 -0
  56. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/open_panel.js +0 -0
  57. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/resolve_action.js +0 -0
  58. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/scripts.js +0 -0
  59. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/send_message.js +0 -0
  60. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/set_mode.js +0 -0
  61. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/set_model.js +0 -0
  62. /package/providers/_builtin/ide/cursor/scripts/{1.0 → 0.49.bak}/switch_session.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.6.12",
3
+ "version": "0.6.15",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,9 +37,10 @@
37
37
  "versionCommand": "antigravity --version",
38
38
  "providerVersion": "1.0.0",
39
39
  "compatibility": [
40
- { "ideVersion": ">=1.0.0", "scriptDir": "scripts/1.0" }
40
+ { "ideVersion": ">=1.107.0", "scriptDir": "scripts/1.107" },
41
+ { "ideVersion": ">=1.105.0", "scriptDir": "scripts/1.106" }
41
42
  ],
42
- "defaultScriptDir": "scripts/1.0",
43
+ "defaultScriptDir": "scripts/1.107",
43
44
  "settings": {
44
45
  "approvalAlert": {
45
46
  "type": "boolean",
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Antigravity — list_models
3
+ * antigravity-agent-side-panel 내부 모델 드롭다운에서 목록 + 현재 모델 추출
4
+ * → { models: string[], current: string }
5
+ */
6
+ (() => {
7
+ try {
8
+ const models = [];
9
+ let current = '';
10
+
11
+ // 1. 모델 항목에서 목록 추출
12
+ // 셀렉터: .px-2.py-1.flex.items-center.justify-between.cursor-pointer
13
+ const items = document.querySelectorAll('.px-2.py-1.flex.items-center.justify-between.cursor-pointer');
14
+ for (const item of items) {
15
+ const label = item.querySelector('.text-xs.font-medium');
16
+ const text = (label || item).textContent?.trim();
17
+ if (!text || text.length > 60) continue;
18
+ // 모델명 검증 (Claude, Gemini, GPT, etc.)
19
+ models.push(text);
20
+ // 선택된 항목: bg-gray-500/20
21
+ if ((item.className || '').includes('bg-gray-500/20')) {
22
+ current = text;
23
+ }
24
+ }
25
+
26
+ // 2. 모델 목록이 없으면 (드롭다운 닫힘) → 트리거 버튼에서 현재 모델만
27
+ if (models.length === 0) {
28
+ const trigger = document.querySelector('.flex.min-w-0.max-w-full.cursor-pointer.items-center');
29
+ if (trigger) {
30
+ current = trigger.textContent?.trim() || '';
31
+ }
32
+ }
33
+
34
+ return JSON.stringify({ models, current });
35
+ } catch (e) {
36
+ return JSON.stringify({ models: [], current: '', error: e.message });
37
+ }
38
+ })()
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Antigravity — list_modes
3
+ * Conversation mode: Planning / Fast 세그먼트 컨트롤
4
+ * inputBox 근처의 "Conversation mode" 패널에서 읽기
5
+ * → { modes: string[], current: string }
6
+ */
7
+ (() => {
8
+ try {
9
+ const modes = [];
10
+ let current = '';
11
+
12
+ // "Conversation mode" 헤더를 포함하는 패널 찾기
13
+ const headers = document.querySelectorAll('.text-xs.px-2.pb-1.opacity-80');
14
+ for (const header of headers) {
15
+ if (header.textContent?.trim() === 'Conversation mode') {
16
+ // 형제 요소들에서 모드 항목 추출
17
+ const parent = header.parentElement;
18
+ if (!parent) continue;
19
+ const items = parent.querySelectorAll('.font-medium');
20
+ for (const item of items) {
21
+ const text = item.textContent?.trim();
22
+ if (text && text.length < 20) {
23
+ modes.push(text);
24
+ }
25
+ }
26
+ break;
27
+ }
28
+ }
29
+
30
+ // 현재 모드: Fast 버튼의 텍스트 (현재 활성 모드 표시)
31
+ const modeBtn = [...document.querySelectorAll('button')].find(b => {
32
+ const cls = b.className || '';
33
+ return cls.includes('py-1') && cls.includes('pl-1') && cls.includes('pr-2') && b.offsetWidth > 0;
34
+ });
35
+ if (modeBtn) {
36
+ current = modeBtn.textContent?.trim() || '';
37
+ }
38
+
39
+ // modes가 비어있으면 기본값
40
+ if (modes.length === 0) {
41
+ modes.push('Planning', 'Fast');
42
+ }
43
+
44
+ return JSON.stringify({ modes, current });
45
+ } catch (e) {
46
+ return JSON.stringify({ modes: [], current: '', error: e.message });
47
+ }
48
+ })()
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Antigravity v1 — read_chat (v4 — 스크롤 아래만, 가시 영역만 수집)
3
+ *
4
+ * 원칙:
5
+ * - 스크롤은 아래로만 (위로 절대 안 감)
6
+ * - 가상화로 사라진 과거 사용자 메시지는 무시
7
+ * - 현재 보이는 메시지만 수집 (최신 턴 중심)
8
+ *
9
+ * DOM 구조:
10
+ * 사용자: bg-gray-500/15 + select-text + p-2, 내부 whitespace-pre-wrap
11
+ * 어시스턴트: .leading-relaxed.select-text
12
+ */
13
+ (() => {
14
+ try {
15
+ const conv = document.querySelector('#conversation') || document.querySelector('.antigravity-agent-side-panel') || document.body;
16
+ const scroll = conv.querySelector('.overflow-y-auto') || conv;
17
+
18
+ // 1. 상태 감지 — 사이드바 하단 Send/Stop 버튼 기반 (오탐 방지)
19
+ let status = 'idle';
20
+
21
+ // 시그널 A (1순위): 사이드바 하단 빨간 Stop 사각형 (.bg-red-500) — generating 중일 때 표시됨
22
+ const stopSquare = conv.querySelector('[class*="bg-red-500"]') || conv.querySelector('button[class*="rounded"] [class*="bg-red"]');
23
+ if (stopSquare && stopSquare.offsetWidth > 0) {
24
+ status = 'generating';
25
+ }
26
+
27
+ // 시그널 B: conv 내부의 animate-markdown (생성 중 마크다운 렌더링)
28
+ if (status === 'idle') {
29
+ const animMarkdown = scroll.querySelector('.leading-relaxed [class*="animate-markdown"]');
30
+ if (animMarkdown && animMarkdown.offsetWidth > 0) status = 'generating';
31
+ }
32
+
33
+ const titleParts = document.title.split(' \u2014 ');
34
+ const title = (titleParts.length >= 2 ? titleParts[titleParts.length - 1] : titleParts[0] || '').trim() || 'Active Session';
35
+
36
+ // ─── HTML → Markdown 변환기 (대시보드가 ReactMarkdown+remarkGfm 사용) ───
37
+ // extractCodeText: layout-independent code text extraction
38
+ // Works on cloneNode'd (detached) elements where innerText == textContent
39
+ // Walks child nodes and inserts \n between block-level elements (DIV, P, etc.)
40
+ const BLOCK_TAGS = new Set(['DIV', 'P', 'BR', 'LI', 'TR', 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER']);
41
+ function extractCodeText(node) {
42
+ if (node.nodeType === 3) return node.textContent || '';
43
+ if (node.nodeType !== 1) return '';
44
+ if (node.tagName === 'BR') return '\n';
45
+ const parts = [];
46
+ for (const child of node.childNodes) {
47
+ const isBlock = child.nodeType === 1 && BLOCK_TAGS.has(child.tagName);
48
+ const text = extractCodeText(child);
49
+ if (text) {
50
+ if (isBlock && parts.length > 0) parts.push('\n');
51
+ parts.push(text);
52
+ if (isBlock) parts.push('\n');
53
+ }
54
+ }
55
+ // Collapse multiple consecutive newlines into single \n
56
+ return parts.join('').replace(/\n{2,}/g, '\n');
57
+ }
58
+ function htmlToMd(node) {
59
+ if (node.nodeType === 3) return node.textContent || '';
60
+ if (node.nodeType !== 1) return '';
61
+ const tag = node.tagName;
62
+
63
+ // 스타일/스크립트 제거
64
+ if (tag === 'STYLE' || tag === 'SCRIPT' || tag === 'SVG') return '';
65
+
66
+ // 테이블 → GFM
67
+ if (tag === 'TABLE') {
68
+ const rows = Array.from(node.querySelectorAll('tr'));
69
+ if (rows.length === 0) return '';
70
+ const table = rows.map(tr =>
71
+ Array.from(tr.querySelectorAll('th, td')).map(cell => (cell.textContent || '').trim().replace(/\|/g, '\\|'))
72
+ );
73
+ if (table.length === 0) return '';
74
+ const colCount = Math.max(...table.map(r => r.length));
75
+ const header = table[0];
76
+ const sep = Array(colCount).fill('---');
77
+ const body = table.slice(1);
78
+ let md = '| ' + header.join(' | ') + ' |\n';
79
+ md += '| ' + sep.join(' | ') + ' |\n';
80
+ for (const row of body) {
81
+ while (row.length < colCount) row.push('');
82
+ md += '| ' + row.join(' | ') + ' |\n';
83
+ }
84
+ return '\n' + md + '\n';
85
+ }
86
+
87
+ if (tag === 'UL') return '\n' + Array.from(node.children).map(li => '- ' + childrenToMd(li).trim()).join('\n') + '\n';
88
+ if (tag === 'OL') return '\n' + Array.from(node.children).map((li, i) => (i + 1) + '. ' + childrenToMd(li).trim()).join('\n') + '\n';
89
+ if (tag === 'LI') return childrenToMd(node);
90
+
91
+ if (tag === 'H1') return '\n# ' + childrenToMd(node).trim() + '\n';
92
+ if (tag === 'H2') return '\n## ' + childrenToMd(node).trim() + '\n';
93
+ if (tag === 'H3') return '\n### ' + childrenToMd(node).trim() + '\n';
94
+ if (tag === 'H4') return '\n#### ' + childrenToMd(node).trim() + '\n';
95
+
96
+ if (tag === 'STRONG' || tag === 'B') return '**' + childrenToMd(node).trim() + '**';
97
+ if (tag === 'EM' || tag === 'I') return '*' + childrenToMd(node).trim() + '*';
98
+
99
+ if (tag === 'PRE') {
100
+ const codeEl = node.querySelector('code');
101
+ const lang = codeEl ? (codeEl.className.match(/language-(\w+)/)?.[1] || '') : '';
102
+ // Custom extraction: walk child nodes and insert \n between block elements
103
+ // This works on cloneNode'd elements (no layout → innerText == textContent)
104
+ const code = extractCodeText(codeEl || node);
105
+ return '\n```' + lang + '\n' + code.trim() + '\n```\n';
106
+ }
107
+ if (tag === 'CODE') {
108
+ if (node.parentElement && node.parentElement.tagName === 'PRE') return node.textContent || '';
109
+ return '`' + (node.textContent || '').trim() + '`';
110
+ }
111
+
112
+ if (tag === 'BLOCKQUOTE') return '\n> ' + childrenToMd(node).trim().replace(/\n/g, '\n> ') + '\n';
113
+ if (tag === 'A') return '[' + childrenToMd(node).trim() + '](' + (node.getAttribute('href') || '') + ')';
114
+ if (tag === 'BR') return '\n';
115
+ if (tag === 'P') return '\n' + childrenToMd(node).trim() + '\n';
116
+
117
+ return childrenToMd(node);
118
+ }
119
+ function childrenToMd(node) {
120
+ return Array.from(node.childNodes).map(htmlToMd).join('');
121
+ }
122
+
123
+ function getCleanMd(el) {
124
+ const clone = el.cloneNode(true);
125
+ // 노이즈 제거
126
+ clone.querySelectorAll('button, [role="button"], style, script, svg, .codicon, [class*="feedback"], [aria-label*="Good"], [aria-label*="Bad"]').forEach(n => n.remove());
127
+ // 상태 텍스트 제거 (leaf만, 60자 이하만)
128
+ clone.querySelectorAll('*').forEach(child => {
129
+ if (!child.parentNode) return;
130
+ const t = (child.textContent || '').trim();
131
+ if (t.length > 60) return;
132
+ const low = t.toLowerCase();
133
+ if (/^(analyzed\s+\d|edited\s+\d|ran\s+\S|terminal\s|reading|searching)/i.test(low)) child.remove();
134
+ if (/^(mcp|customizationmcp|serversexport)/i.test(low)) child.remove();
135
+ });
136
+ let md = htmlToMd(clone);
137
+ // "Thought for X seconds" 제거
138
+ md = md.replace(/^Thought for\s+[\d.]+\s*(seconds?|s)\s*/i, '');
139
+ md = md.replace(/\n{3,}/g, '\n\n').trim();
140
+ return md;
141
+ }
142
+
143
+ // 2. 메시지 수집 (스크롤 조작 없음 — 현재 DOM에 있는 것만)
144
+ const collected = [];
145
+ const seenHashes = new Set();
146
+
147
+ // 사용자 메시지 (bg-gray-500/15 + select-text + p-2)
148
+ const allDivs = scroll.querySelectorAll('div');
149
+ for (const el of allDivs) {
150
+ const cls = (el.className || '');
151
+ if (typeof cls !== 'string') continue;
152
+ if (cls.includes('bg-gray-500/15') && cls.includes('select-text') && cls.includes('p-2')) {
153
+ const textEl = el.querySelector('[class*="whitespace-pre-wrap"]') || el;
154
+ const text = (textEl.innerText || '').trim();
155
+ if (!text || text.length < 1) continue;
156
+ const hash = 'user:' + text.slice(0, 200);
157
+ if (seenHashes.has(hash)) continue;
158
+ seenHashes.add(hash);
159
+ collected.push({ role: 'user', text, el });
160
+ }
161
+ }
162
+
163
+ // 어시스턴트 메시지 (leading-relaxed.select-text) — HTML→Markdown 변환
164
+ const assistantBlocks = scroll.querySelectorAll('.leading-relaxed.select-text');
165
+ for (const ab of assistantBlocks) {
166
+ if (ab.offsetHeight < 10) continue;
167
+ if (ab.closest('[class*="max-h-"][class*="overflow-y-auto"]')) continue;
168
+
169
+ let text = getCleanMd(ab);
170
+ if (!text || text.length < 2) continue;
171
+ if (/^(Running command|Checked command|collectStatus)/i.test(text)) continue;
172
+
173
+ const hash = 'assistant:' + text.slice(0, 200);
174
+ if (seenHashes.has(hash)) continue;
175
+ seenHashes.add(hash);
176
+ collected.push({ role: 'assistant', text, el: ab });
177
+ }
178
+
179
+ // 3. DOM 순서 정렬
180
+ collected.sort((a, b) => {
181
+ const pos = a.el.compareDocumentPosition(b.el);
182
+ if (pos & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
183
+ if (pos & Node.DOCUMENT_POSITION_PRECEDING) return 1;
184
+ return 0;
185
+ });
186
+
187
+ // 최신 30개만 유지 (대화 첫 로드 시 수백 개 수집 방지)
188
+ const trimmed = collected.length > 30 ? collected.slice(-30) : collected;
189
+
190
+ const final = trimmed.map((m, i) => ({
191
+ id: 'msg_' + i,
192
+ role: m.role,
193
+ content: m.text.length > 6000 ? m.text.slice(0, 6000) + '\n[... truncated]' : m.text,
194
+ index: i,
195
+ kind: 'standard',
196
+ vsc_history: true
197
+ }));
198
+
199
+ // 4. 입력창
200
+ const editor = conv.querySelector('[contenteditable="true"][role="textbox"]') ||
201
+ conv.querySelector('[data-lexical-editor="true"]') ||
202
+ conv.querySelector('textarea');
203
+ const inputContent = editor ? (editor.innerText || editor.value || '').trim() : '';
204
+
205
+ // 5. 모달/승인 감지 — Run⌥⏎/Reject 인라인 + Deny/Allow 브라우저 승인
206
+ let activeModal = null;
207
+ try {
208
+ // Strip Mac symbols and Windows shortcut labels (e.g. "RunAlt+⏎" → "Run")
209
+ const stripShortcut = (s) => s
210
+ .replace(/[⌥⏎⇧⌫⌘⌃↵]/g, '')
211
+ .replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi, '')
212
+ .trim();
213
+ const isApprovalLike = (el) => {
214
+ const raw = (el.textContent || '').trim();
215
+ const t = stripShortcut(raw).toLowerCase();
216
+ // 드롭다운 옵션 제외
217
+ if (t === 'ask every time') return false;
218
+ return /^(run|reject|skip|approve|allow|deny|cancel|accept|yes|no)\b/i.test(t)
219
+ || t === 'always allow' || t === 'always deny'
220
+ || t.includes('run ') || t.includes('approve') || t.includes('reject')
221
+ || t.includes('skip');
222
+ };
223
+ // A: 전통적 모달 다이얼로그
224
+ const dialog = document.querySelector('.monaco-dialog-box, [role="dialog"], .monaco-modal-block');
225
+ if (dialog && dialog.offsetWidth > 80 && dialog.offsetHeight > 40) {
226
+ const msg = (dialog.querySelector('.dialog-message, .dialog-message-text') || dialog).innerText?.trim() || '';
227
+ const buttons = Array.from(dialog.querySelectorAll('.monaco-button, button'))
228
+ .map(b => (b.innerText || '').trim())
229
+ .filter(t => t.length > 0 && t.length < 30);
230
+ if (msg || buttons.length > 0) {
231
+ activeModal = { message: msg.slice(0, 300), buttons, width: dialog.offsetWidth, height: dialog.offsetHeight };
232
+ }
233
+ }
234
+ // B: 인라인 approval 버튼 (Run⌥⏎, Reject, Deny, Allow 등)
235
+ // ⚠ 사이드바(conv) 내부의 버튼만 검사 — 에디터의 Accept/Reject Changes 제외
236
+ if (!activeModal) {
237
+ const panelBtns = Array.from(conv.querySelectorAll('button')).filter(b => b.offsetWidth > 0 && b.offsetHeight > 0);
238
+ const approvalBtns = panelBtns.filter(isApprovalLike);
239
+ if (approvalBtns.length > 0) {
240
+ const hasActionBtn = approvalBtns.some(b => {
241
+ const t = stripShortcut((b.textContent || '').trim()).toLowerCase();
242
+ return /^(run|reject|skip|deny|allow|accept|approve|yes|no)\b/.test(t)
243
+ || t === 'always allow' || t === 'always deny';
244
+ });
245
+ if (hasActionBtn) {
246
+ const btnTexts = [...new Set(
247
+ approvalBtns.map(b => (b.textContent || '').trim())
248
+ .filter(t => t.length > 0 && t.length < 40)
249
+ )];
250
+ const firstApproval = approvalBtns[0];
251
+ let wrapper = firstApproval.parentElement;
252
+ for (let up = 0; up < 5 && wrapper; up++, wrapper = wrapper.parentElement) {
253
+ if (wrapper.offsetHeight > 40) break;
254
+ }
255
+ const msg = wrapper ? (wrapper.textContent || '').trim().slice(0, 300) : '';
256
+ activeModal = { message: msg, buttons: btnTexts, width: 400, height: 100 };
257
+ }
258
+ }
259
+ }
260
+ // C: footer 기반 사용량/quota 다이얼로그 (Dismiss / See Plans / Enable Overages 등)
261
+ // <footer> 요소가 conv 안에 존재하고 2개 이상 버튼이 있으면 사용자 액션이 필요한 카드로 판단
262
+ if (!activeModal) {
263
+ const footers = Array.from(conv.querySelectorAll('footer')).filter(f => f.offsetWidth > 0 && f.offsetHeight > 0);
264
+ for (const footer of footers) {
265
+ const footerBtns = Array.from(footer.querySelectorAll('button, a')).filter(b => b.offsetWidth > 0);
266
+ if (footerBtns.length >= 2) {
267
+ // 카드 컨테이너: footer 상위에서 충분한 높이를 가진 첫 번째 요소
268
+ let card = footer.parentElement;
269
+ for (let up = 0; up < 4 && card; up++) {
270
+ if (card.offsetHeight > 60) break;
271
+ card = card.parentElement;
272
+ }
273
+ const msg = card ? (card.innerText || '').trim().slice(0, 300) : '';
274
+ const btnTexts = footerBtns.map(b => (b.innerText || '').trim()).filter(t => t.length > 0 && t.length < 40);
275
+ if (btnTexts.length >= 2) {
276
+ activeModal = { message: msg, buttons: btnTexts, width: card ? card.offsetWidth : 300, height: card ? card.offsetHeight : 100 };
277
+ break;
278
+ }
279
+ }
280
+ }
281
+ }
282
+ // 모달이 감지되면 status를 waiting_approval로 변경
283
+ if (activeModal) status = 'waiting_approval';
284
+ } catch (e) { activeModal = null; }
285
+
286
+ return { id: 'active_session', status, title, messages: final, inputContent, activeModal };
287
+ } catch (e) {
288
+ return { id: 'error', status: 'error', error: e.message, messages: [] };
289
+ }
290
+ })()
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Antigravity CDP Scripts — legacy (< 1.107.0)
3
+ * DOM uses exact CSS class selectors (original Tailwind classes without arbitrary values)
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const DIR = __dirname; // scripts/1.106/
11
+
12
+ function load(name) {
13
+ try { return fs.readFileSync(path.join(DIR, name), 'utf-8'); }
14
+ catch { return null; }
15
+ }
16
+
17
+ module.exports.readChat = () => load('read_chat.js');
18
+ module.exports.focusEditor = () => load('focus_editor.js');
19
+ module.exports.listSessions = () => load('list_chats.js');
20
+ module.exports.newSession = () => load('new_session.js');
21
+ module.exports.listModels = () => load('list_models.js');
22
+ module.exports.listModes = () => load('list_modes.js');
23
+
24
+ module.exports.sendMessage = (text) => {
25
+ const script = load('send_message.js');
26
+ if (!script) return null;
27
+ return script.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text));
28
+ };
29
+
30
+ module.exports.switchSession = (sessionId) => {
31
+ const script = load('switch_session.js');
32
+ if (!script) return null;
33
+ return script.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId));
34
+ };
35
+
36
+ module.exports.resolveAction = (params) => {
37
+ const action = typeof params === 'string' ? params : params?.action || 'approve';
38
+ const buttonText = params?.button || params?.buttonText
39
+ || (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
40
+ const script = load('resolve_action.js');
41
+ if (!script) return null;
42
+ return script.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText));
43
+ };
44
+
45
+ module.exports.setModel = (params) => {
46
+ const model = typeof params === 'string' ? params : params?.model;
47
+ const script = load('set_model.js');
48
+ if (!script) return null;
49
+ return script.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model));
50
+ };
51
+
52
+ module.exports.setMode = (params) => {
53
+ const mode = typeof params === 'string' ? params : params?.mode;
54
+ const script = load('set_mode.js');
55
+ if (!script) return null;
56
+ return script.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode));
57
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Antigravity — set_mode
3
+ * Conversation mode 패널에서 Planning/Fast 클릭
4
+ * ${MODE} → JSON.stringify(modeName)
5
+ * → { success: boolean, mode?: string }
6
+ */
7
+ (async () => {
8
+ try {
9
+ const target = ${MODE};
10
+
11
+ // "Conversation mode" 헤더의 부모에서 .font-medium 항목 찾기
12
+ const headers = document.querySelectorAll('.text-xs.px-2.pb-1.opacity-80');
13
+ for (const header of headers) {
14
+ if (header.textContent?.trim() === 'Conversation mode') {
15
+ const parent = header.parentElement;
16
+ if (!parent) continue;
17
+ const items = parent.querySelectorAll('.font-medium');
18
+ for (const item of items) {
19
+ const text = item.textContent?.trim();
20
+ if (text && text.toLowerCase() === target.toLowerCase()) {
21
+ item.click();
22
+ await new Promise(r => setTimeout(r, 300));
23
+ return JSON.stringify({ success: true, mode: text });
24
+ }
25
+ }
26
+ break;
27
+ }
28
+ }
29
+
30
+ return JSON.stringify({ success: false, error: 'mode not found: ' + target });
31
+ } catch (e) {
32
+ return JSON.stringify({ success: false, error: e.message });
33
+ }
34
+ })()
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Antigravity — set_model
3
+ * antigravity-agent-side-panel 모델 드롭다운에서 모델 선택
4
+ * ${MODEL} → JSON.stringify(modelName)
5
+ * → { success: boolean, model?: string }
6
+ */
7
+ (async () => {
8
+ try {
9
+ const target = ${MODEL};
10
+
11
+ // 1. 모델 드롭다운이 열려 있는 경우 → 직접 선택
12
+ const items = document.querySelectorAll('.px-2.py-1.flex.items-center.justify-between.cursor-pointer');
13
+ for (const item of items) {
14
+ const label = item.querySelector('.text-xs.font-medium');
15
+ const text = (label || item).textContent?.trim();
16
+ if (text && (text === target || text.toLowerCase().includes(target.toLowerCase()))) {
17
+ item.click();
18
+ await new Promise(r => setTimeout(r, 200));
19
+ return JSON.stringify({ success: true, model: text });
20
+ }
21
+ }
22
+
23
+ // 2. 드롭다운이 닫혀 있으면 → 트리거 버튼 클릭해서 열기
24
+ const trigger = document.querySelector('.flex.min-w-0.max-w-full.cursor-pointer.items-center');
25
+ if (trigger) {
26
+ trigger.click();
27
+ await new Promise(r => setTimeout(r, 400));
28
+
29
+ // 다시 항목 탐색
30
+ const newItems = document.querySelectorAll('.px-2.py-1.flex.items-center.justify-between.cursor-pointer');
31
+ for (const item of newItems) {
32
+ const label = item.querySelector('.text-xs.font-medium');
33
+ const text = (label || item).textContent?.trim();
34
+ if (text && (text === target || text.toLowerCase().includes(target.toLowerCase()))) {
35
+ item.click();
36
+ return JSON.stringify({ success: true, model: text });
37
+ }
38
+ }
39
+ // 못 찾으면 드롭다운 닫기
40
+ trigger.click();
41
+ }
42
+
43
+ return JSON.stringify({ success: false, error: 'model not found: ' + target });
44
+ } catch (e) {
45
+ return JSON.stringify({ success: false, error: e.message });
46
+ }
47
+ })()
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Cursor v1 — focus_editor
3
+ *
4
+ * CURSOR.md 4-5: 셀렉터 우선순위
5
+ * [contenteditable="true"][role="textbox"]
6
+ * → .chat-input textarea
7
+ * → .composer-input
8
+ * → textarea
9
+ *
10
+ * 최종 확인: 2026-03-06
11
+ */
12
+ (() => {
13
+ const editor = document.querySelector('[contenteditable="true"][role="textbox"]')
14
+ || document.querySelector('.chat-input textarea')
15
+ || document.querySelector('.composer-input')
16
+ || document.querySelector('textarea.native-input')
17
+ || document.querySelector('textarea');
18
+ if (editor) { editor.focus(); return 'focused'; }
19
+ return 'no editor found';
20
+ })()