@cryptiklemur/lattice 1.3.0 → 1.5.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/bun.lock +776 -2
  2. package/client/index.html +1 -13
  3. package/client/package.json +7 -1
  4. package/client/src/App.tsx +2 -0
  5. package/client/src/commands.ts +36 -0
  6. package/client/src/components/analytics/AnalyticsView.tsx +61 -0
  7. package/client/src/components/analytics/ChartCard.tsx +22 -0
  8. package/client/src/components/analytics/PeriodSelector.tsx +42 -0
  9. package/client/src/components/analytics/QuickStats.tsx +99 -0
  10. package/client/src/components/analytics/charts/CostAreaChart.tsx +83 -0
  11. package/client/src/components/analytics/charts/CostDistributionChart.tsx +62 -0
  12. package/client/src/components/analytics/charts/CostDonutChart.tsx +93 -0
  13. package/client/src/components/analytics/charts/CumulativeCostChart.tsx +62 -0
  14. package/client/src/components/analytics/charts/SessionBubbleChart.tsx +122 -0
  15. package/client/src/components/chat/AttachmentChips.tsx +116 -0
  16. package/client/src/components/chat/ChatInput.tsx +250 -73
  17. package/client/src/components/chat/ChatView.tsx +242 -10
  18. package/client/src/components/chat/CommandPalette.tsx +162 -0
  19. package/client/src/components/chat/Message.tsx +23 -2
  20. package/client/src/components/chat/PromptQuestion.tsx +271 -0
  21. package/client/src/components/chat/TodoCard.tsx +57 -0
  22. package/client/src/components/chat/ToolResultRenderer.tsx +2 -1
  23. package/client/src/components/chat/VoiceRecorder.tsx +85 -0
  24. package/client/src/components/dashboard/DashboardView.tsx +5 -0
  25. package/client/src/components/project-settings/ProjectMemory.tsx +12 -2
  26. package/client/src/components/project-settings/ProjectNotifications.tsx +48 -0
  27. package/client/src/components/project-settings/ProjectRules.tsx +10 -1
  28. package/client/src/components/project-settings/ProjectSettingsView.tsx +6 -0
  29. package/client/src/components/settings/Appearance.tsx +1 -0
  30. package/client/src/components/settings/ClaudeSettings.tsx +10 -0
  31. package/client/src/components/settings/Editor.tsx +123 -0
  32. package/client/src/components/settings/GlobalMcp.tsx +10 -1
  33. package/client/src/components/settings/GlobalMemory.tsx +19 -0
  34. package/client/src/components/settings/GlobalRules.tsx +149 -0
  35. package/client/src/components/settings/GlobalSkills.tsx +10 -0
  36. package/client/src/components/settings/Notifications.tsx +88 -0
  37. package/client/src/components/settings/SettingsView.tsx +12 -0
  38. package/client/src/components/settings/skill-shared.tsx +2 -1
  39. package/client/src/components/setup/SetupWizard.tsx +1 -1
  40. package/client/src/components/sidebar/NodeSettingsModal.tsx +23 -1
  41. package/client/src/components/sidebar/ProjectDropdown.tsx +176 -27
  42. package/client/src/components/sidebar/SettingsSidebar.tsx +11 -1
  43. package/client/src/components/sidebar/Sidebar.tsx +43 -2
  44. package/client/src/components/sidebar/UserIsland.tsx +18 -7
  45. package/client/src/components/ui/UpdatePrompt.tsx +47 -0
  46. package/client/src/components/workspace/FileBrowser.tsx +174 -0
  47. package/client/src/components/workspace/FileTree.tsx +129 -0
  48. package/client/src/components/workspace/FileViewer.tsx +211 -0
  49. package/client/src/components/workspace/NoteCard.tsx +119 -0
  50. package/client/src/components/workspace/NotesView.tsx +102 -0
  51. package/client/src/components/workspace/ScheduledTasksView.tsx +117 -0
  52. package/client/src/components/workspace/SplitPane.tsx +81 -0
  53. package/client/src/components/workspace/TabBar.tsx +185 -0
  54. package/client/src/components/workspace/TaskCard.tsx +158 -0
  55. package/client/src/components/workspace/TaskEditModal.tsx +114 -0
  56. package/client/src/components/{panels/Terminal.tsx → workspace/TerminalInstance.tsx} +50 -7
  57. package/client/src/components/workspace/TerminalView.tsx +110 -0
  58. package/client/src/components/workspace/WorkspaceView.tsx +116 -0
  59. package/client/src/hooks/useAnalytics.ts +75 -0
  60. package/client/src/hooks/useAttachments.ts +280 -0
  61. package/client/src/hooks/useEditorConfig.ts +28 -0
  62. package/client/src/hooks/useIdleDetection.ts +44 -0
  63. package/client/src/hooks/useInstallPrompt.ts +53 -0
  64. package/client/src/hooks/useNotifications.ts +54 -0
  65. package/client/src/hooks/useOnline.ts +6 -0
  66. package/client/src/hooks/useSession.ts +110 -4
  67. package/client/src/hooks/useSpinnerVerb.ts +36 -0
  68. package/client/src/hooks/useSwipeDrawer.ts +275 -0
  69. package/client/src/hooks/useVoiceRecorder.ts +123 -0
  70. package/client/src/hooks/useWorkspace.ts +48 -0
  71. package/client/src/providers/WebSocketProvider.tsx +18 -0
  72. package/client/src/router.tsx +52 -20
  73. package/client/src/stores/analytics.ts +54 -0
  74. package/client/src/stores/session.ts +136 -0
  75. package/client/src/stores/sidebar.ts +11 -2
  76. package/client/src/stores/workspace.ts +254 -0
  77. package/client/src/styles/global.css +123 -0
  78. package/client/src/utils/editorUrl.ts +62 -0
  79. package/client/vite.config.ts +54 -1
  80. package/package.json +1 -1
  81. package/server/src/analytics/engine.ts +491 -0
  82. package/server/src/daemon.ts +12 -1
  83. package/server/src/features/scheduler.ts +23 -0
  84. package/server/src/features/sticky-notes.ts +5 -3
  85. package/server/src/handlers/analytics.ts +34 -0
  86. package/server/src/handlers/attachment.ts +172 -0
  87. package/server/src/handlers/chat.ts +43 -2
  88. package/server/src/handlers/editor.ts +40 -0
  89. package/server/src/handlers/fs.ts +10 -2
  90. package/server/src/handlers/memory.ts +3 -0
  91. package/server/src/handlers/notes.ts +4 -2
  92. package/server/src/handlers/scheduler.ts +18 -1
  93. package/server/src/handlers/session.ts +14 -8
  94. package/server/src/handlers/settings.ts +37 -2
  95. package/server/src/handlers/terminal.ts +13 -6
  96. package/server/src/project/pty-worker.cjs +83 -0
  97. package/server/src/project/sdk-bridge.ts +266 -11
  98. package/server/src/project/session.ts +4 -4
  99. package/server/src/project/terminal.ts +78 -34
  100. package/shared/src/analytics.ts +24 -0
  101. package/shared/src/index.ts +1 -0
  102. package/shared/src/messages.ts +173 -4
  103. package/shared/src/models.ts +27 -1
  104. package/shared/src/project-settings.ts +1 -1
  105. package/tp.js +19 -0
  106. package/client/public/manifest.json +0 -24
  107. package/client/public/sw.js +0 -61
  108. package/client/src/components/panels/FileBrowser.tsx +0 -241
  109. package/client/src/components/panels/StickyNotes.tsx +0 -187
@@ -1,241 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
2
- import { ChevronRight, FileIcon } from "lucide-react";
3
- import type { FileEntry, FsListResultMessage, FsReadResultMessage } from "@lattice/shared";
4
- import { useWebSocket } from "../../hooks/useWebSocket";
5
- import type { ServerMessage } from "@lattice/shared";
6
-
7
- interface TreeNode {
8
- entry: FileEntry;
9
- children: TreeNode[] | null;
10
- expanded: boolean;
11
- }
12
-
13
- function buildNodes(entries: FileEntry[]): TreeNode[] {
14
- return entries.map(function (entry) {
15
- return { entry, children: null, expanded: false };
16
- });
17
- }
18
-
19
- interface FileTreeItemProps {
20
- node: TreeNode;
21
- depth: number;
22
- selectedPath: string | null;
23
- onToggle: (path: string) => void;
24
- onSelect: (path: string) => void;
25
- }
26
-
27
- function FileTreeItem(props: FileTreeItemProps) {
28
- var { node, depth, selectedPath, onToggle, onSelect } = props;
29
- var isSelected = selectedPath === node.entry.path;
30
- var isDir = node.entry.isDirectory;
31
-
32
- return (
33
- <div>
34
- <div
35
- onClick={function () {
36
- if (isDir) {
37
- onToggle(node.entry.path);
38
- } else {
39
- onSelect(node.entry.path);
40
- }
41
- }}
42
- className={
43
- "flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer text-[13px] rounded select-none " +
44
- (isSelected ? "bg-base-300 text-primary" : "text-base-content hover:bg-base-200")
45
- }
46
- style={{ paddingLeft: (8 + depth * 16) + "px" }}
47
- >
48
- {isDir ? (
49
- <ChevronRight
50
- size={12}
51
- className="flex-shrink-0 text-base-content/40 transition-transform duration-[120ms]"
52
- style={{ transform: node.expanded ? "rotate(90deg)" : "none" }}
53
- />
54
- ) : (
55
- <FileIcon
56
- size={12}
57
- className="flex-shrink-0 text-base-content/40"
58
- />
59
- )}
60
- <span
61
- className={
62
- "truncate " +
63
- (isDir ? "text-info" : "text-base-content")
64
- }
65
- >
66
- {node.entry.name}
67
- </span>
68
- </div>
69
- {isDir && node.expanded && node.children && (
70
- <div>
71
- {node.children.map(function (child) {
72
- return (
73
- <FileTreeItem
74
- key={child.entry.path}
75
- node={child}
76
- depth={depth + 1}
77
- selectedPath={selectedPath}
78
- onToggle={onToggle}
79
- onSelect={onSelect}
80
- />
81
- );
82
- })}
83
- </div>
84
- )}
85
- </div>
86
- );
87
- }
88
-
89
- export function FileBrowser() {
90
- var { send, subscribe, unsubscribe } = useWebSocket();
91
- var [rootNodes, setRootNodes] = useState<TreeNode[]>([]);
92
- var [selectedPath, setSelectedPath] = useState<string | null>(null);
93
- var [fileContent, setFileContent] = useState<string | null>(null);
94
- var [loadingContent, setLoadingContent] = useState(false);
95
- var nodesRef = useRef<TreeNode[]>([]);
96
-
97
- nodesRef.current = rootNodes;
98
-
99
- var handleListResult = useCallback(function (msg: ServerMessage) {
100
- var listMsg = msg as FsListResultMessage;
101
- var newNodes = buildNodes(listMsg.entries);
102
-
103
- if (listMsg.path === "" || listMsg.path === ".") {
104
- setRootNodes(newNodes);
105
- return;
106
- }
107
-
108
- function updateNodes(nodes: TreeNode[]): TreeNode[] {
109
- return nodes.map(function (node) {
110
- if (node.entry.path === listMsg.path) {
111
- return Object.assign({}, node, { children: newNodes, expanded: true });
112
- }
113
- if (node.children) {
114
- return Object.assign({}, node, { children: updateNodes(node.children) });
115
- }
116
- return node;
117
- });
118
- }
119
-
120
- setRootNodes(function (prev) {
121
- return updateNodes(prev);
122
- });
123
- }, []);
124
-
125
- var handleReadResult = useCallback(function (msg: ServerMessage) {
126
- var readMsg = msg as FsReadResultMessage;
127
- setFileContent(readMsg.content);
128
- setLoadingContent(false);
129
- }, []);
130
-
131
- var handleFsChanged = useCallback(function (msg: ServerMessage) {
132
- var changedPath = (msg as { path: string }).path;
133
- if (changedPath === selectedPath) {
134
- send({ type: "fs:read", path: changedPath });
135
- }
136
- }, [selectedPath, send]);
137
-
138
- useEffect(function () {
139
- subscribe("fs:list_result", handleListResult);
140
- subscribe("fs:read_result", handleReadResult);
141
- subscribe("fs:changed", handleFsChanged);
142
-
143
- send({ type: "fs:list", path: "." });
144
-
145
- return function () {
146
- unsubscribe("fs:list_result", handleListResult);
147
- unsubscribe("fs:read_result", handleReadResult);
148
- unsubscribe("fs:changed", handleFsChanged);
149
- };
150
- }, [handleListResult, handleReadResult, handleFsChanged, send, subscribe, unsubscribe]);
151
-
152
- function handleToggle(path: string) {
153
- function findAndToggle(nodes: TreeNode[]): TreeNode[] {
154
- return nodes.map(function (node) {
155
- if (node.entry.path === path) {
156
- if (!node.expanded && !node.children) {
157
- send({ type: "fs:list", path });
158
- return Object.assign({}, node, { expanded: true });
159
- }
160
- return Object.assign({}, node, { expanded: !node.expanded });
161
- }
162
- if (node.children) {
163
- return Object.assign({}, node, { children: findAndToggle(node.children) });
164
- }
165
- return node;
166
- });
167
- }
168
- setRootNodes(function (prev) {
169
- return findAndToggle(prev);
170
- });
171
- }
172
-
173
- function handleSelect(path: string) {
174
- setSelectedPath(path);
175
- setFileContent(null);
176
- setLoadingContent(true);
177
- send({ type: "fs:read", path });
178
- }
179
-
180
- return (
181
- <div className="flex h-full w-full overflow-hidden bg-base-100">
182
- <div className="w-[220px] flex-shrink-0 border-r border-base-300 overflow-y-auto p-2">
183
- <div className="text-[11px] font-semibold tracking-[0.06em] uppercase text-base-content/40 px-2 pb-2 pt-1">
184
- Files
185
- </div>
186
- {rootNodes.length === 0 ? (
187
- <div className="px-2 py-3 text-[12px] text-base-content/40">
188
- Loading...
189
- </div>
190
- ) : (
191
- rootNodes.map(function (node) {
192
- return (
193
- <FileTreeItem
194
- key={node.entry.path}
195
- node={node}
196
- depth={0}
197
- selectedPath={selectedPath}
198
- onToggle={handleToggle}
199
- onSelect={handleSelect}
200
- />
201
- );
202
- })
203
- )}
204
- </div>
205
-
206
- <div className="flex-1 flex flex-col overflow-hidden">
207
- {selectedPath && (
208
- <div className="h-9 flex-shrink-0 flex items-center px-4 border-b border-base-300 bg-base-200 text-[12px] text-base-content/60 font-mono overflow-hidden">
209
- <span className="truncate">{selectedPath}</span>
210
- </div>
211
- )}
212
-
213
- <div className="flex-1 overflow-auto">
214
- {!selectedPath && (
215
- <div className="h-full flex items-center justify-center text-base-content/40 text-[13px]">
216
- Select a file to view its contents
217
- </div>
218
- )}
219
-
220
- {selectedPath && loadingContent && (
221
- <div className="h-full flex items-center justify-center text-base-content/40 text-[13px]">
222
- Loading...
223
- </div>
224
- )}
225
-
226
- {selectedPath && !loadingContent && fileContent !== null && (
227
- <pre className="m-0 p-4 text-[13px] font-mono text-base-content leading-relaxed whitespace-pre-wrap break-words">
228
- {fileContent}
229
- </pre>
230
- )}
231
-
232
- {selectedPath && !loadingContent && fileContent === null && (
233
- <div className="h-full flex items-center justify-center text-base-content/40 text-[13px]">
234
- Cannot display this file (binary or too large)
235
- </div>
236
- )}
237
- </div>
238
- </div>
239
- </div>
240
- );
241
- }
@@ -1,187 +0,0 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- import type { StickyNote, ServerMessage } from "@lattice/shared";
3
- import { useWebSocket } from "../../hooks/useWebSocket";
4
-
5
- interface NoteCardProps {
6
- note: StickyNote;
7
- onEdit: (id: string) => void;
8
- onDelete: (id: string) => void;
9
- }
10
-
11
- function NoteCard(props: NoteCardProps) {
12
- var { note, onEdit, onDelete } = props;
13
- return (
14
- <div className="card bg-base-200 border border-base-300">
15
- <div className="card-body p-3">
16
- <div className="text-[13px] text-base-content whitespace-pre-wrap break-words leading-relaxed min-h-12">
17
- {note.content}
18
- </div>
19
- <div className="flex gap-1.5 justify-end mt-2">
20
- <button
21
- onClick={function () { onEdit(note.id); }}
22
- className="btn btn-ghost btn-xs border border-base-300"
23
- >
24
- Edit
25
- </button>
26
- <button
27
- onClick={function () { onDelete(note.id); }}
28
- className="btn btn-ghost btn-xs border border-base-300 text-base-content/60"
29
- >
30
- Delete
31
- </button>
32
- </div>
33
- </div>
34
- </div>
35
- );
36
- }
37
-
38
- interface EditModalProps {
39
- initial: string;
40
- onSave: (content: string) => void;
41
- onCancel: () => void;
42
- }
43
-
44
- function EditModal(props: EditModalProps) {
45
- var { initial, onSave, onCancel } = props;
46
- var [content, setContent] = useState(initial);
47
-
48
- return (
49
- <div className="fixed inset-0 bg-black/50 z-[1000] flex items-center justify-center" role="dialog" aria-modal="true" aria-label="Edit note">
50
- <div className="card bg-base-200 border border-base-300 w-[400px] max-w-[90vw] shadow-2xl">
51
- <div className="card-body p-5">
52
- <div className="text-[13px] font-semibold text-base-content mb-3">Edit Note</div>
53
- <textarea
54
- autoFocus
55
- value={content}
56
- onChange={function (e) { setContent(e.target.value); }}
57
- className="textarea textarea-bordered w-full min-h-[120px] bg-base-300 text-base-content text-[13px] resize-y"
58
- />
59
- <div className="flex gap-2 justify-end mt-3">
60
- <button
61
- onClick={onCancel}
62
- className="btn btn-ghost btn-sm"
63
- >
64
- Cancel
65
- </button>
66
- <button
67
- onClick={function () { onSave(content); }}
68
- className="btn btn-primary btn-sm"
69
- >
70
- Save
71
- </button>
72
- </div>
73
- </div>
74
- </div>
75
- </div>
76
- );
77
- }
78
-
79
- export function StickyNotes() {
80
- var { send, subscribe, unsubscribe } = useWebSocket();
81
- var [notes, setNotes] = useState<StickyNote[]>([]);
82
- var [editingId, setEditingId] = useState<string | null>(null);
83
- var [creating, setCreating] = useState(false);
84
-
85
- var editingNote = editingId ? notes.find(function (n) { return n.id === editingId; }) : null;
86
-
87
- var handleMessage = useCallback(function (msg: ServerMessage) {
88
- if (msg.type === "notes:list_result") {
89
- setNotes(msg.notes);
90
- return;
91
- }
92
- if (msg.type === "notes:created") {
93
- setNotes(function (prev) { return [...prev, msg.note]; });
94
- return;
95
- }
96
- if (msg.type === "notes:updated") {
97
- setNotes(function (prev) {
98
- return prev.map(function (n) { return n.id === msg.note.id ? msg.note : n; });
99
- });
100
- return;
101
- }
102
- if (msg.type === "notes:deleted") {
103
- setNotes(function (prev) { return prev.filter(function (n) { return n.id !== msg.id; }); });
104
- return;
105
- }
106
- }, []);
107
-
108
- useEffect(function () {
109
- subscribe("notes:list_result", handleMessage);
110
- subscribe("notes:created", handleMessage);
111
- subscribe("notes:updated", handleMessage);
112
- subscribe("notes:deleted", handleMessage);
113
- send({ type: "notes:list" });
114
- return function () {
115
- unsubscribe("notes:list_result", handleMessage);
116
- unsubscribe("notes:created", handleMessage);
117
- unsubscribe("notes:updated", handleMessage);
118
- unsubscribe("notes:deleted", handleMessage);
119
- };
120
- }, [send, subscribe, unsubscribe, handleMessage]);
121
-
122
- function handleCreate(content: string) {
123
- if (content.trim()) {
124
- send({ type: "notes:create", content: content.trim() });
125
- }
126
- setCreating(false);
127
- }
128
-
129
- function handleEdit(content: string) {
130
- if (editingId && content.trim()) {
131
- send({ type: "notes:update", id: editingId, content: content.trim() });
132
- }
133
- setEditingId(null);
134
- }
135
-
136
- function handleDelete(id: string) {
137
- send({ type: "notes:delete", id });
138
- }
139
-
140
- return (
141
- <div className="flex flex-col h-full bg-base-100">
142
- <div className="flex items-center justify-between px-4 py-3 border-b border-base-300">
143
- <span className="text-[13px] font-semibold text-base-content">Sticky Notes</span>
144
- <button
145
- onClick={function () { setCreating(true); }}
146
- className="btn btn-primary btn-xs"
147
- >
148
- New Note
149
- </button>
150
- </div>
151
-
152
- <div className="flex-1 overflow-auto p-3 flex flex-col gap-2.5">
153
- {notes.length === 0 && (
154
- <div className="text-base-content/50 text-[13px] text-center mt-10">
155
- No notes yet. Create one to get started.
156
- </div>
157
- )}
158
- {notes.map(function (note) {
159
- return (
160
- <NoteCard
161
- key={note.id}
162
- note={note}
163
- onEdit={setEditingId}
164
- onDelete={handleDelete}
165
- />
166
- );
167
- })}
168
- </div>
169
-
170
- {creating && (
171
- <EditModal
172
- initial=""
173
- onSave={handleCreate}
174
- onCancel={function () { setCreating(false); }}
175
- />
176
- )}
177
-
178
- {editingNote && (
179
- <EditModal
180
- initial={editingNote.content}
181
- onSave={handleEdit}
182
- onCancel={function () { setEditingId(null); }}
183
- />
184
- )}
185
- </div>
186
- );
187
- }