groove-dev 0.17.8 → 0.18.2

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 (131) hide show
  1. package/node_modules/@groove-dev/cli/package.json +4 -3
  2. package/node_modules/@groove-dev/daemon/google-oauth.json +5 -0
  3. package/node_modules/@groove-dev/daemon/integrations-registry.json +0 -40
  4. package/node_modules/@groove-dev/daemon/package.json +4 -3
  5. package/node_modules/@groove-dev/daemon/src/api.js +212 -21
  6. package/node_modules/@groove-dev/daemon/src/index.js +68 -1
  7. package/node_modules/@groove-dev/daemon/src/integrations.js +59 -20
  8. package/node_modules/@groove-dev/daemon/src/process.js +83 -11
  9. package/node_modules/@groove-dev/daemon/src/providers/claude-code.js +4 -0
  10. package/node_modules/@groove-dev/daemon/src/registry.js +1 -1
  11. package/node_modules/@groove-dev/gui/.groove/audit.log +1 -0
  12. package/node_modules/@groove-dev/gui/.groove/codebase-index.json +64 -0
  13. package/node_modules/@groove-dev/gui/.groove/config.json +10 -0
  14. package/node_modules/@groove-dev/gui/.groove/coordination.md +5 -0
  15. package/node_modules/@groove-dev/gui/.groove/credentials.json +6 -0
  16. package/node_modules/@groove-dev/gui/.groove/daemon.port +1 -0
  17. package/node_modules/@groove-dev/gui/.groove/federation/identity.key +3 -0
  18. package/node_modules/@groove-dev/gui/.groove/federation/identity.pub +3 -0
  19. package/node_modules/@groove-dev/gui/.groove/integrations/package.json +6 -0
  20. package/node_modules/@groove-dev/gui/.groove/state.json +3 -0
  21. package/node_modules/@groove-dev/gui/dist/assets/index-x5suAiK7.js +182 -0
  22. package/node_modules/@groove-dev/gui/dist/index.html +1 -1
  23. package/node_modules/@groove-dev/gui/package.json +5 -4
  24. package/node_modules/@groove-dev/gui/src/App.jsx +149 -76
  25. package/node_modules/@groove-dev/gui/src/components/AgentActions.jsx +130 -1
  26. package/node_modules/@groove-dev/gui/src/components/AgentChat.jsx +47 -7
  27. package/node_modules/@groove-dev/gui/src/components/AgentNode.jsx +13 -83
  28. package/node_modules/@groove-dev/gui/src/components/SpawnPanel.jsx +918 -580
  29. package/node_modules/@groove-dev/gui/src/stores/groove.js +31 -2
  30. package/node_modules/@groove-dev/gui/src/views/AgentTree.jsx +133 -67
  31. package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +85 -1
  32. package/node_modules/@groove-dev/gui/src/views/IntegrationsStore.jsx +121 -44
  33. package/package.json +1 -2
  34. package/packages/cli/package.json +4 -3
  35. package/packages/daemon/integrations-registry.json +0 -40
  36. package/packages/daemon/package.json +4 -3
  37. package/packages/daemon/src/api.js +212 -21
  38. package/packages/daemon/src/index.js +68 -1
  39. package/packages/daemon/src/integrations.js +59 -20
  40. package/packages/daemon/src/process.js +83 -11
  41. package/packages/daemon/src/providers/claude-code.js +4 -0
  42. package/packages/daemon/src/registry.js +1 -1
  43. package/packages/gui/dist/assets/index-x5suAiK7.js +182 -0
  44. package/packages/gui/dist/index.html +1 -1
  45. package/packages/gui/node_modules/.vite/deps/@codemirror_autocomplete.js +68 -0
  46. package/packages/gui/node_modules/.vite/deps/@codemirror_autocomplete.js.map +7 -0
  47. package/packages/gui/node_modules/.vite/deps/@codemirror_commands.js +1420 -0
  48. package/packages/gui/node_modules/.vite/deps/@codemirror_commands.js.map +7 -0
  49. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-css.js +17 -0
  50. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-css.js.map +7 -0
  51. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-html.js +22 -0
  52. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-html.js.map +7 -0
  53. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-javascript.js +34 -0
  54. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-javascript.js.map +7 -0
  55. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-json.js +101 -0
  56. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-json.js.map +7 -0
  57. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-markdown.js +2534 -0
  58. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-markdown.js.map +7 -0
  59. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-python.js +789 -0
  60. package/packages/gui/node_modules/.vite/deps/@codemirror_lang-python.js.map +7 -0
  61. package/packages/gui/node_modules/.vite/deps/@codemirror_language.js +115 -0
  62. package/packages/gui/node_modules/.vite/deps/@codemirror_language.js.map +7 -0
  63. package/packages/gui/node_modules/.vite/deps/@codemirror_search.js +1136 -0
  64. package/packages/gui/node_modules/.vite/deps/@codemirror_search.js.map +7 -0
  65. package/packages/gui/node_modules/.vite/deps/@codemirror_state.js +63 -0
  66. package/packages/gui/node_modules/.vite/deps/@codemirror_state.js.map +7 -0
  67. package/packages/gui/node_modules/.vite/deps/@codemirror_theme-one-dark.js +179 -0
  68. package/packages/gui/node_modules/.vite/deps/@codemirror_theme-one-dark.js.map +7 -0
  69. package/packages/gui/node_modules/.vite/deps/@codemirror_view.js +104 -0
  70. package/packages/gui/node_modules/.vite/deps/@codemirror_view.js.map +7 -0
  71. package/packages/gui/node_modules/.vite/deps/@xterm_addon-fit.js +46 -0
  72. package/packages/gui/node_modules/.vite/deps/@xterm_addon-fit.js.map +7 -0
  73. package/packages/gui/node_modules/.vite/deps/@xterm_addon-web-links.js +121 -0
  74. package/packages/gui/node_modules/.vite/deps/@xterm_addon-web-links.js.map +7 -0
  75. package/packages/gui/node_modules/.vite/deps/@xterm_xterm.js +9237 -0
  76. package/packages/gui/node_modules/.vite/deps/@xterm_xterm.js.map +7 -0
  77. package/packages/gui/node_modules/.vite/deps/@xyflow_react.js +9934 -0
  78. package/packages/gui/node_modules/.vite/deps/@xyflow_react.js.map +7 -0
  79. package/packages/gui/node_modules/.vite/deps/_metadata.json +184 -0
  80. package/packages/gui/node_modules/.vite/deps/chunk-3EE34IFC.js +5169 -0
  81. package/packages/gui/node_modules/.vite/deps/chunk-3EE34IFC.js.map +7 -0
  82. package/packages/gui/node_modules/.vite/deps/chunk-3IB5EUP7.js +2000 -0
  83. package/packages/gui/node_modules/.vite/deps/chunk-3IB5EUP7.js.map +7 -0
  84. package/packages/gui/node_modules/.vite/deps/chunk-3LBP22MX.js +1115 -0
  85. package/packages/gui/node_modules/.vite/deps/chunk-3LBP22MX.js.map +7 -0
  86. package/packages/gui/node_modules/.vite/deps/chunk-3Q7HT7ZF.js +701 -0
  87. package/packages/gui/node_modules/.vite/deps/chunk-3Q7HT7ZF.js.map +7 -0
  88. package/packages/gui/node_modules/.vite/deps/chunk-44CLUOQE.js +1776 -0
  89. package/packages/gui/node_modules/.vite/deps/chunk-44CLUOQE.js.map +7 -0
  90. package/packages/gui/node_modules/.vite/deps/chunk-5RZAEUNX.js +280 -0
  91. package/packages/gui/node_modules/.vite/deps/chunk-5RZAEUNX.js.map +7 -0
  92. package/packages/gui/node_modules/.vite/deps/chunk-5WRI5ZAA.js +30 -0
  93. package/packages/gui/node_modules/.vite/deps/chunk-5WRI5ZAA.js.map +7 -0
  94. package/packages/gui/node_modules/.vite/deps/chunk-7FYDPZIO.js +1004 -0
  95. package/packages/gui/node_modules/.vite/deps/chunk-7FYDPZIO.js.map +7 -0
  96. package/packages/gui/node_modules/.vite/deps/chunk-BX6POZPY.js +292 -0
  97. package/packages/gui/node_modules/.vite/deps/chunk-BX6POZPY.js.map +7 -0
  98. package/packages/gui/node_modules/.vite/deps/chunk-HVFOBSCQ.js +1062 -0
  99. package/packages/gui/node_modules/.vite/deps/chunk-HVFOBSCQ.js.map +7 -0
  100. package/packages/gui/node_modules/.vite/deps/chunk-RE2FU7ZU.js +10985 -0
  101. package/packages/gui/node_modules/.vite/deps/chunk-RE2FU7ZU.js.map +7 -0
  102. package/packages/gui/node_modules/.vite/deps/chunk-YYJMNVCJ.js +3459 -0
  103. package/packages/gui/node_modules/.vite/deps/chunk-YYJMNVCJ.js.map +7 -0
  104. package/packages/gui/node_modules/.vite/deps/package.json +3 -0
  105. package/packages/gui/node_modules/.vite/deps/react-dom.js +6 -0
  106. package/packages/gui/node_modules/.vite/deps/react-dom.js.map +7 -0
  107. package/packages/gui/node_modules/.vite/deps/react-dom_client.js +20217 -0
  108. package/packages/gui/node_modules/.vite/deps/react-dom_client.js.map +7 -0
  109. package/packages/gui/node_modules/.vite/deps/react.js +5 -0
  110. package/packages/gui/node_modules/.vite/deps/react.js.map +7 -0
  111. package/packages/gui/node_modules/.vite/deps/react_jsx-dev-runtime.js +278 -0
  112. package/packages/gui/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
  113. package/packages/gui/node_modules/.vite/deps/react_jsx-runtime.js +6 -0
  114. package/packages/gui/node_modules/.vite/deps/react_jsx-runtime.js.map +7 -0
  115. package/packages/gui/node_modules/.vite/deps/zustand.js +56 -0
  116. package/packages/gui/node_modules/.vite/deps/zustand.js.map +7 -0
  117. package/packages/gui/package.json +5 -4
  118. package/packages/gui/src/App.jsx +149 -76
  119. package/packages/gui/src/components/AgentActions.jsx +130 -1
  120. package/packages/gui/src/components/AgentChat.jsx +47 -7
  121. package/packages/gui/src/components/AgentNode.jsx +13 -83
  122. package/packages/gui/src/components/SpawnPanel.jsx +918 -580
  123. package/packages/gui/src/stores/groove.js +31 -2
  124. package/packages/gui/src/views/AgentTree.jsx +133 -67
  125. package/packages/gui/src/views/FileEditor.jsx +85 -1
  126. package/packages/gui/src/views/IntegrationsStore.jsx +121 -44
  127. package/docs/FILE-EDITOR-PLAN.md +0 -253
  128. package/docs/GUI_DESIGN_SPEC.md +0 -402
  129. package/docs/SKILLS-API-SPEC.md +0 -277
  130. package/node_modules/@groove-dev/gui/dist/assets/index-D5dtDQf0.js +0 -156
  131. package/packages/gui/dist/assets/index-D5dtDQf0.js +0 -156
@@ -84,6 +84,7 @@ function CredentialModal({ integration, onClose }) {
84
84
  const [googleClientId, setGoogleClientId] = useState('');
85
85
  const [googleClientSecret, setGoogleClientSecret] = useState('');
86
86
  const [showGoogleSetup, setShowGoogleSetup] = useState(false);
87
+ const [errorMsg, setErrorMsg] = useState('');
87
88
 
88
89
  useEffect(() => {
89
90
  if (integration?.authType === 'oauth-google' || integration?.authType === 'google-autoauth' || integration?._googleSetupNeeded) {
@@ -106,6 +107,7 @@ function CredentialModal({ integration, onClose }) {
106
107
  async function handleSave(key) {
107
108
  if (!values[key]) return;
108
109
  setSaving(true);
110
+ setErrorMsg('');
109
111
  try {
110
112
  const res = await fetch(`/api/integrations/${integration.id}/credentials`, {
111
113
  method: 'POST',
@@ -115,44 +117,61 @@ function CredentialModal({ integration, onClose }) {
115
117
  if (res.ok) {
116
118
  setSaved((prev) => ({ ...prev, [key]: true }));
117
119
  setValues((prev) => ({ ...prev, [key]: '' }));
120
+ } else {
121
+ const data = await res.json();
122
+ setErrorMsg(data.error || `Failed to save ${key}`);
118
123
  }
119
- } catch { /* ignore */ }
124
+ } catch {
125
+ setErrorMsg('Could not reach the server');
126
+ }
120
127
  setSaving(false);
121
128
  }
122
129
 
123
130
  async function handleGoogleSetup() {
124
131
  if (!googleClientId || !googleClientSecret) return;
125
132
  setSaving(true);
133
+ setErrorMsg('');
126
134
  try {
127
- await fetch('/api/integrations/google-oauth/setup', {
135
+ const res = await fetch('/api/integrations/google-oauth/setup', {
128
136
  method: 'POST',
129
137
  headers: { 'Content-Type': 'application/json' },
130
138
  body: JSON.stringify({ clientId: googleClientId, clientSecret: googleClientSecret }),
131
139
  });
132
- setOauthStatus('ready');
133
- setShowGoogleSetup(false);
134
- } catch { /* ignore */ }
140
+ if (res.ok) {
141
+ setOauthStatus('ready');
142
+ setShowGoogleSetup(false);
143
+ } else {
144
+ const data = await res.json();
145
+ setErrorMsg(data.error || 'Failed to save credentials');
146
+ }
147
+ } catch {
148
+ setErrorMsg('Could not reach the server');
149
+ }
135
150
  setSaving(false);
136
151
  }
137
152
 
138
153
  async function handleAutoAuthConnect() {
139
154
  setOauthStatus('connecting');
155
+ setErrorMsg('');
140
156
  try {
141
157
  const res = await fetch(`/api/integrations/${integration.id}/authenticate`, { method: 'POST' });
142
158
  const data = await res.json();
143
- if (!data.ok) {
159
+ if (data.ok) {
160
+ // MCP server spawned — it will open a browser for OAuth consent
161
+ setTimeout(() => onClose(), 3000);
162
+ } else {
163
+ setErrorMsg(data.error || 'Authentication failed');
144
164
  setOauthStatus('ready');
145
165
  }
146
- // The MCP server will open a browser — poll isn't needed since
147
- // the server handles auth internally. Just close after a moment.
148
- setTimeout(() => onClose(), 2000);
149
166
  } catch {
167
+ setErrorMsg('Could not reach the server');
150
168
  setOauthStatus('ready');
151
169
  }
152
170
  }
153
171
 
154
172
  async function handleOAuthConnect() {
155
173
  setOauthStatus('connecting');
174
+ setErrorMsg('');
156
175
  try {
157
176
  const res = await fetch(`/api/integrations/${integration.id}/oauth/start`, { method: 'POST' });
158
177
  const data = await res.json();
@@ -172,8 +191,12 @@ function CredentialModal({ integration, onClose }) {
172
191
  }, 2000);
173
192
  // Stop polling after 5 minutes
174
193
  setTimeout(() => clearInterval(poll), 300000);
194
+ } else {
195
+ setErrorMsg(data.error || 'Failed to start OAuth flow');
196
+ setOauthStatus('ready');
175
197
  }
176
198
  } catch {
199
+ setErrorMsg('Could not reach the server');
177
200
  setOauthStatus('ready');
178
201
  }
179
202
  }
@@ -236,32 +259,59 @@ function CredentialModal({ integration, onClose }) {
236
259
  </a>
237
260
  )}
238
261
 
262
+ {/* Error message */}
263
+ {errorMsg && (
264
+ <div style={{
265
+ padding: '10px 14px', marginBottom: 14, borderRadius: 6,
266
+ background: 'rgba(224, 108, 117, 0.08)', border: '1px solid var(--red)',
267
+ fontSize: 11, color: 'var(--red)', lineHeight: 1.5,
268
+ }}>
269
+ {errorMsg}
270
+ </div>
271
+ )}
272
+
239
273
  {/* OAuth flow for Google integrations (both oauth-google and google-autoauth) */}
240
274
  {(isOAuth || isGoogleAutoAuth) && (
241
275
  <div style={{ marginBottom: 16 }}>
242
- {/* Always show the primary Connect button */}
243
- <button
244
- onClick={oauthStatus === 'ready'
245
- ? (isGoogleAutoAuth ? handleAutoAuthConnect : handleOAuthConnect)
246
- : () => setShowGoogleSetup(true)}
247
- disabled={oauthStatus === 'checking' || oauthStatus === 'connecting'}
248
- style={{
249
- display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
250
- width: '100%', padding: '12px 16px', marginBottom: 12,
251
- background: oauthStatus === 'connecting' ? 'var(--bg-active)' : '#4285f4',
252
- color: '#fff', border: 'none', borderRadius: 6,
253
- fontSize: 13, fontWeight: 600, cursor: 'pointer',
254
- fontFamily: 'var(--font)',
255
- opacity: oauthStatus === 'checking' ? 0.5 : 1,
256
- }}
257
- >
258
- {oauthStatus === 'checking' ? 'Checking...'
259
- : oauthStatus === 'connecting' ? 'Waiting for authorization...'
260
- : `Connect with Google`}
261
- </button>
276
+ {/* Show Connect button only when OAuth is configured */}
277
+ {oauthStatus === 'ready' && (
278
+ <button
279
+ onClick={isGoogleAutoAuth ? handleAutoAuthConnect : handleOAuthConnect}
280
+ disabled={oauthStatus === 'connecting'}
281
+ style={{
282
+ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
283
+ width: '100%', padding: '12px 16px', marginBottom: 12,
284
+ background: '#4285f4',
285
+ color: '#fff', border: 'none', borderRadius: 6,
286
+ fontSize: 13, fontWeight: 600, cursor: 'pointer',
287
+ fontFamily: 'var(--font)',
288
+ }}
289
+ >
290
+ Connect with Google
291
+ </button>
292
+ )}
293
+ {oauthStatus === 'checking' && (
294
+ <div style={{
295
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
296
+ padding: '12px 16px', marginBottom: 12,
297
+ color: 'var(--text-muted)', fontSize: 12,
298
+ }}>
299
+ Checking Google credentials...
300
+ </div>
301
+ )}
302
+ {oauthStatus === 'connecting' && (
303
+ <div style={{
304
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
305
+ padding: '12px 16px', marginBottom: 12,
306
+ background: 'var(--bg-active)', borderRadius: 6,
307
+ color: 'var(--text-primary)', fontSize: 12, fontWeight: 600,
308
+ }}>
309
+ Waiting for authorization — check your browser...
310
+ </div>
311
+ )}
262
312
 
263
- {/* First-time setup: show inline when Connect is clicked and OAuth not configured */}
264
- {showGoogleSetup && oauthStatus === 'not-configured' && (
313
+ {/* First-time setup: shown when OAuth not configured */}
314
+ {oauthStatus === 'not-configured' && (
265
315
  <div style={{
266
316
  padding: 14, borderRadius: 8,
267
317
  background: 'var(--bg-surface)', border: '1px solid var(--border)',
@@ -707,26 +757,42 @@ export default function IntegrationsStore() {
707
757
  async function handleInstall(id) {
708
758
  setInstalling(id);
709
759
  try {
710
- await fetch(`/api/integrations/${id}/install`, { method: 'POST' });
760
+ const res = await fetch(`/api/integrations/${id}/install`, { method: 'POST' });
761
+ const data = await res.json();
762
+ if (!res.ok) {
763
+ flash(data.error || 'Install failed', 'error');
764
+ setInstalling(null);
765
+ return;
766
+ }
711
767
  await fetchIntegrations();
712
768
  // After install, refresh selected item
713
769
  if (selectedItem?.id === id) {
714
770
  const updated = integrations.find((s) => s.id === id);
715
771
  if (updated) setSelectedItem({ ...updated, installed: true });
716
772
  }
717
- } catch { /* ignore */ }
773
+ } catch (err) {
774
+ flash('Install failed — check daemon logs', 'error');
775
+ }
718
776
  setInstalling(null);
719
777
  }
720
778
 
721
779
  async function handleUninstall(id) {
722
780
  setInstalling(id);
723
781
  try {
724
- await fetch(`/api/integrations/${id}`, { method: 'DELETE' });
782
+ const res = await fetch(`/api/integrations/${id}`, { method: 'DELETE' });
783
+ if (!res.ok) {
784
+ const data = await res.json();
785
+ flash(data.error || 'Uninstall failed', 'error');
786
+ setInstalling(null);
787
+ return;
788
+ }
725
789
  await fetchIntegrations();
726
790
  if (selectedItem?.id === id) {
727
791
  setSelectedItem((prev) => prev ? { ...prev, installed: false, configured: false } : null);
728
792
  }
729
- } catch { /* ignore */ }
793
+ } catch {
794
+ flash('Uninstall failed', 'error');
795
+ }
730
796
  setInstalling(null);
731
797
  }
732
798
 
@@ -746,31 +812,38 @@ export default function IntegrationsStore() {
746
812
  const statusRes = await fetch('/api/integrations/google-oauth/status');
747
813
  const statusData = await statusRes.json();
748
814
  if (!statusData.configured) {
749
- // Need Google OAuth setup first — open the credential modal
815
+ // Need Google OAuth setup first — open the credential modal with setup form
750
816
  setSelectedItem(null);
751
817
  setConfiguring({ ...item, _googleSetupNeeded: true });
752
818
  return;
753
819
  }
754
- } catch { /* proceed anyway */ }
820
+ } catch {
821
+ // Can't check status — open setup form as fallback
822
+ setSelectedItem(null);
823
+ setConfiguring({ ...item, _googleSetupNeeded: true });
824
+ return;
825
+ }
755
826
  }
756
827
 
828
+ // OAuth is configured — trigger the authentication flow
757
829
  setSelectedItem(null);
830
+ setConfiguring({ ...item }); // Show credential modal in connecting state
758
831
  try {
759
832
  const res = await fetch(`/api/integrations/${item.id}/authenticate`, { method: 'POST' });
760
833
  const data = await res.json();
761
834
  if (data.ok) {
762
835
  flash('Sign-in window opened — check your browser');
763
836
  } else {
764
- flash(data.error || 'Authentication failed');
837
+ flash(data.error || 'Authentication failed', 'error');
765
838
  }
766
839
  } catch {
767
- flash('Authentication failed');
840
+ flash('Authentication failed — check daemon logs', 'error');
768
841
  }
769
842
  }
770
843
 
771
- function flash(msg) {
772
- setStatusMsg(msg);
773
- setTimeout(() => setStatusMsg(''), 4000);
844
+ function flash(msg, type = 'info') {
845
+ setStatusMsg({ text: msg, type });
846
+ setTimeout(() => setStatusMsg(''), 6000);
774
847
  }
775
848
 
776
849
  function handleConfigureClose() {
@@ -821,8 +894,12 @@ export default function IntegrationsStore() {
821
894
 
822
895
  {/* Status message */}
823
896
  {statusMsg && (
824
- <div style={{ padding: '4px 20px', fontSize: 10, color: 'var(--accent)', flexShrink: 0 }}>
825
- {statusMsg}
897
+ <div style={{
898
+ padding: '8px 20px', fontSize: 12, fontWeight: 500, flexShrink: 0,
899
+ color: statusMsg.type === 'error' ? 'var(--red)' : 'var(--accent)',
900
+ background: statusMsg.type === 'error' ? 'rgba(224, 108, 117, 0.06)' : 'transparent',
901
+ }}>
902
+ {statusMsg.text || statusMsg}
826
903
  </div>
827
904
  )}
828
905
 
@@ -1,253 +0,0 @@
1
- # File Editor — Implementation Plan
2
-
3
- ## Context
4
-
5
- Power users want to watch and verify what agents are doing in real-time. A VS Code-style file editor embedded in the GROOVE GUI lets users browse project files, see agent changes as they happen, and make quick edits — all without leaving the dashboard.
6
-
7
- ## Architecture
8
-
9
- ```
10
- +------------------------------------------+
11
- | [EditorTabs: file1.js | file2.css | ...] |
12
- +----------+-------------------------------+
13
- | FileTree | CodeEditor (CodeMirror 6) |
14
- | (240px) | (flex: 1) |
15
- | | |
16
- | | [file changed banner] |
17
- | | |
18
- +----------+-------------------------------+
19
- ```
20
-
21
- **Editor library: CodeMirror 6** — modular (~200KB vs Monaco's ~3MB), has a native One Dark theme matching GROOVE's palette, supports programmatic content updates for live agent changes. No new daemon dependencies — file watching uses Node.js built-in `fs.watch`.
22
-
23
- ## Files to Create
24
-
25
- | File | Purpose |
26
- |------|---------|
27
- | `packages/gui/src/views/FileEditor.jsx` | Main view — composes tree + tabs + editor |
28
- | `packages/gui/src/components/FileTree.jsx` | Expandable directory tree sidebar |
29
- | `packages/gui/src/components/EditorTabs.jsx` | Horizontal tab bar for open files |
30
- | `packages/gui/src/components/CodeEditor.jsx` | CodeMirror 6 wrapper |
31
- | `packages/daemon/src/filewatcher.js` | Per-file fs.watch + debounced WebSocket broadcast |
32
-
33
- ## Files to Modify
34
-
35
- | File | Changes |
36
- |------|---------|
37
- | `packages/daemon/src/api.js` | Add `/api/files/tree`, `/api/files/read`, `/api/files/write` endpoints |
38
- | `packages/daemon/src/index.js` | Wire `FileWatcher`, handle `editor:watch`/`editor:unwatch` WS messages |
39
- | `packages/gui/src/stores/groove.js` | Add editor state + actions + `file:changed` WS handler |
40
- | `packages/gui/src/App.jsx` | Add "Editor" tab, import + render `<FileEditor />` |
41
- | `packages/gui/package.json` | Add CodeMirror 6 dependencies |
42
-
43
- ## Build Order
44
-
45
- ### Step 1: Backend — File API endpoints
46
-
47
- **File: `packages/daemon/src/api.js`**
48
-
49
- Add after the existing `// --- Directory Browser ---` section. Reuse the same path validation pattern from `/api/browse`.
50
-
51
- **`GET /api/files/tree?path=<relPath>`**
52
- Returns files AND directories for a given path. Response:
53
- ```json
54
- {
55
- "current": "src/components",
56
- "parent": "src",
57
- "entries": [
58
- { "name": "subdir", "type": "dir", "path": "src/components/subdir", "hasChildren": true },
59
- { "name": "App.jsx", "type": "file", "path": "src/components/App.jsx", "size": 4521, "language": "javascript" }
60
- ]
61
- }
62
- ```
63
- - Dirs first (sorted), then files (sorted)
64
- - Filter: no `.git`, `node_modules`, dotfiles
65
- - Language detected from extension via a simple map
66
-
67
- **`GET /api/files/read?path=<relPath>`**
68
- Returns file contents. Response:
69
- ```json
70
- { "path": "src/App.jsx", "content": "...", "size": 4521, "language": "javascript" }
71
- ```
72
- - Reject files > 5MB
73
- - Detect binary (null bytes in first 8KB) → return `{ binary: true }`
74
-
75
- **`POST /api/files/write`**
76
- Saves file contents. Body: `{ path, content }`. Response: `{ ok: true, size: N }`
77
- - Same path validation
78
- - Audit log: `daemon.audit.log('file.write', { path })`
79
-
80
- **Language detection helper:**
81
- ```javascript
82
- const LANG_MAP = {
83
- js: 'javascript', jsx: 'javascript', mjs: 'javascript',
84
- ts: 'typescript', tsx: 'typescript',
85
- css: 'css', scss: 'css', html: 'html', json: 'json',
86
- md: 'markdown', py: 'python', rs: 'rust', go: 'go',
87
- sh: 'shell', yaml: 'yaml', yml: 'yaml', toml: 'toml',
88
- sql: 'sql', xml: 'xml', java: 'java',
89
- };
90
- function detectLanguage(filename) {
91
- const ext = filename.split('.').pop()?.toLowerCase();
92
- return LANG_MAP[ext] || 'text';
93
- }
94
- ```
95
-
96
- ### Step 2: Backend — File Watcher
97
-
98
- **New file: `packages/daemon/src/filewatcher.js`**
99
-
100
- Lightweight class that watches individual files (only files the user has open in the editor):
101
- - `watch(relPath)` — start watching with `fs.watch`, debounce 300ms, broadcast `{ type: 'file:changed', path, timestamp }` via `daemon.broadcast()`
102
- - `unwatch(relPath)` — stop watching, clean up
103
- - `unwatchAll()` — cleanup on daemon shutdown
104
-
105
- **Wire in `packages/daemon/src/index.js`:**
106
- - Instantiate `this.fileWatcher = new FileWatcher(this)` in daemon constructor
107
- - In the WebSocket `connection` handler, add a `message` listener:
108
- - `editor:watch` → `this.fileWatcher.watch(msg.path)`
109
- - `editor:unwatch` → `this.fileWatcher.unwatch(msg.path)`
110
- - Call `this.fileWatcher.unwatchAll()` on daemon shutdown
111
-
112
- ### Step 3: Dependencies — Install CodeMirror 6
113
-
114
- Add to `packages/gui/package.json`:
115
- ```
116
- @codemirror/view, @codemirror/state, @codemirror/language,
117
- @codemirror/commands, @codemirror/search, @codemirror/autocomplete,
118
- @codemirror/lang-javascript, @codemirror/lang-css, @codemirror/lang-html,
119
- @codemirror/lang-json, @codemirror/lang-markdown, @codemirror/lang-python,
120
- @codemirror/theme-one-dark
121
- ```
122
-
123
- Run `npm install` from project root.
124
-
125
- ### Step 4: Zustand Store — Editor State
126
-
127
- **File: `packages/gui/src/stores/groove.js`**
128
-
129
- Add to initial state:
130
- ```javascript
131
- editorFiles: {}, // { [path]: { content, originalContent, language, loadedAt } }
132
- editorActiveFile: null, // currently visible file path
133
- editorOpenTabs: [], // ordered array of open file paths
134
- editorTreeCache: {}, // { [dirPath]: entries[] } — cached tree data
135
- editorChangedFiles: {}, // { [path]: timestamp } — externally modified files
136
- ```
137
-
138
- Add actions:
139
- - `openFile(path)` — fetch from `/api/files/read`, add to `editorFiles` + `editorOpenTabs`, set `editorActiveFile`, send `editor:watch` via WS
140
- - `closeFile(path)` — remove from tabs/files, send `editor:unwatch`, switch to next tab
141
- - `setActiveFile(path)` — switch active tab
142
- - `updateFileContent(path, content)` — on every editor keystroke (dirty = content !== originalContent)
143
- - `saveFile(path)` — POST to `/api/files/write`, reset originalContent
144
- - `reloadFile(path)` — re-fetch from server, clear changed notification
145
- - `dismissFileChange(path)` — clear from `editorChangedFiles`
146
- - `fetchTreeDir(path)` — fetch `/api/files/tree?path=...`, cache in `editorTreeCache`
147
-
148
- Add WS handler case:
149
- ```javascript
150
- case 'file:changed':
151
- set((s) => ({ editorChangedFiles: { ...s.editorChangedFiles, [msg.path]: msg.timestamp } }));
152
- break;
153
- ```
154
-
155
- ### Step 5: FileTree Component
156
-
157
- **New file: `packages/gui/src/components/FileTree.jsx`**
158
-
159
- - Recursive expandable tree, lazy-loads children on directory expand
160
- - Click file → `openFile(path)`
161
- - Click directory → toggle expand, fetch children if not cached
162
- - Visual: 16px indent per level, `>` / `v` arrows for dirs
163
- - Active file highlighted with accent left border
164
- - File colors by extension (`.js` amber, `.css` blue, `.json` green, `.md` purple, etc.)
165
- - Search input at top for client-side filtering
166
- - Style: `var(--bg-chrome)` background, `var(--border)` separators, matching DirPicker patterns
167
-
168
- ### Step 6: EditorTabs Component
169
-
170
- **New file: `packages/gui/src/components/EditorTabs.jsx`**
171
-
172
- - Horizontal scrollable row of open file tabs
173
- - Each tab: filename (tooltip = full path), close `x` button
174
- - Active tab: `border-bottom: 2px solid var(--accent)`, bright text
175
- - Dirty indicator: small amber dot next to filename when content !== originalContent
176
- - `overflow-x: auto` for many open files
177
- - Style: `var(--bg-chrome)` background, 32px height, matching header tab patterns from App.jsx
178
-
179
- ### Step 7: CodeEditor Component (CodeMirror 6)
180
-
181
- **New file: `packages/gui/src/components/CodeEditor.jsx`**
182
-
183
- React wrapper around CodeMirror 6. Key details:
184
-
185
- - `useRef` for container div + EditorView instance
186
- - `useEffect` on mount: create EditorView with extensions (line numbers, bracket matching, search, auto-indent, one-dark theme, language support)
187
- - When `content` prop changes externally (file reload / different file selected): dispatch full content replacement via `view.dispatch()`
188
- - `onChange` callback on every transaction → `updateFileContent(path, newContent)` in store
189
- - Language switching: reconfigure compartment when language prop changes
190
- - Custom theme override: set editor bg to `var(--bg-base)` (#24282f) since One Dark default is `--bg-chrome` (#282c34)
191
- - Ctrl/Cmd+S handler → `saveFile(path)`
192
- - Cleanup on unmount: `view.destroy()`
193
-
194
- ### Step 8: FileEditor View (Composition)
195
-
196
- **New file: `packages/gui/src/views/FileEditor.jsx`**
197
-
198
- Composes all pieces:
199
- ```
200
- Container (flex column, height 100%)
201
- ├── EditorTabs (flexShrink: 0)
202
- └── Content Row (flex row, flex: 1, overflow: hidden)
203
- ├── FileTree (width: 240px, flexShrink: 0, border-right)
204
- └── Editor Area (flex: 1, position: relative)
205
- ├── External Change Banner (absolute top, z-index 10, amber)
206
- │ "File modified externally" [Reload] [Dismiss]
207
- └── CodeEditor (flex: 1)
208
- ```
209
-
210
- Empty state when no file open: centered "Select a file from the tree" text.
211
-
212
- ### Step 9: App.jsx Integration
213
-
214
- **File: `packages/gui/src/App.jsx`**
215
-
216
- 1. Add to TABS: `{ id: 'editor', label: 'Editor' }` — position it second (after Agents)
217
- 2. Import `FileEditor` from `'./views/FileEditor'`
218
- 3. Add render: `{activeTab === 'editor' && <FileEditor />}`
219
-
220
- The detail panel (agent chat, journalist) continues to work alongside the editor.
221
-
222
- ## Security
223
-
224
- All file endpoints reuse the path validation from `/api/browse`:
225
- - No absolute paths (`startsWith('/')`)
226
- - No traversal (`includes('..')`)
227
- - No null bytes (`includes('\0')`)
228
- - Must resolve within `daemon.projectDir`
229
- - 5MB size limit on read/write
230
- - Binary detection (null bytes in first 8KB)
231
- - Audit logging on writes
232
-
233
- ## Verification
234
-
235
- 1. `npm run build:gui` — should build clean with CodeMirror included
236
- 2. `node --test packages/daemon/test/` — all 137 tests pass
237
- 3. Start daemon (`groove start`), open GUI, click Editor tab
238
- 4. File tree should show project structure
239
- 5. Click a file → opens in CodeMirror with syntax highlighting
240
- 6. Edit content → tab shows dirty dot
241
- 7. Cmd+S → saves, dirty dot clears
242
- 8. Spawn an agent that modifies an open file → amber banner appears "File modified externally"
243
- 9. Click Reload → file content updates
244
- 10. Open multiple files → tabs work, switching preserves state
245
-
246
- ## Future Extensions (not in this build)
247
-
248
- - Diff view for external changes (`@codemirror/merge`)
249
- - Git status colors in file tree (modified/untracked)
250
- - File create/delete/rename via right-click context menu
251
- - Cmd+P fuzzy file finder
252
- - Search across files (grep-like panel)
253
- - Breadcrumb path bar above editor