tabherd 0.0.0-stage → 0.6.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.
- package/CHANGELOG.md +166 -0
- package/LICENSE +674 -0
- package/README.md +540 -2
- package/launcher/npm.js +9 -0
- package/lib/agents.js +324 -0
- package/lib/codex-client.js +306 -0
- package/lib/codex-rollout.js +251 -0
- package/lib/codex.js +424 -0
- package/lib/comfy.js +479 -0
- package/lib/completed.js +55 -0
- package/lib/copilot.js +359 -0
- package/lib/cursor.js +516 -0
- package/lib/dismissed.js +30 -0
- package/lib/filters.js +120 -0
- package/lib/groups.js +144 -0
- package/lib/history.js +253 -0
- package/lib/llamacpp.js +159 -0
- package/lib/lmstudio.js +134 -0
- package/lib/localai.js +291 -0
- package/lib/memory.js +55 -0
- package/lib/ollama.js +124 -0
- package/lib/open-dashboard.js +39 -0
- package/lib/opencode.js +371 -0
- package/lib/repos.js +81 -0
- package/lib/saved.js +33 -0
- package/lib/secrets.js +196 -0
- package/lib/session-id.js +9 -0
- package/lib/settings.js +231 -0
- package/lib/store.js +44 -0
- package/lib/terminals/index.js +62 -0
- package/lib/terminals/kitty.js +126 -0
- package/lib/terminals/linux.js +310 -0
- package/lib/terminals/macos.js +468 -0
- package/lib/terminals/tmux.js +89 -0
- package/lib/terminals/unix-driver.js +172 -0
- package/lib/terminals/unix.js +204 -0
- package/lib/terminals/unsupported.js +22 -0
- package/lib/terminals/wezterm.js +103 -0
- package/lib/terminals/windows-close.ps1 +125 -0
- package/lib/terminals/windows-focus.ps1 +235 -0
- package/lib/terminals/windows-pick-folder.ps1 +57 -0
- package/lib/terminals/windows-titles.js +124 -0
- package/lib/terminals/windows-titles.ps1 +95 -0
- package/lib/terminals/windows.js +166 -0
- package/lib/ticket-refs.js +184 -0
- package/lib/tickets.js +437 -0
- package/lib/todos.js +166 -0
- package/lib/trackers.js +541 -0
- package/lib/transcript.js +314 -0
- package/lib/updates.js +186 -0
- package/package.json +44 -4
- package/public/app.js +4077 -0
- package/public/favicon.svg +1 -0
- package/public/icons/tabherd-128.png +0 -0
- package/public/icons/tabherd-16.png +0 -0
- package/public/icons/tabherd-20.png +0 -0
- package/public/icons/tabherd-24.png +0 -0
- package/public/icons/tabherd-256.png +0 -0
- package/public/icons/tabherd-32.png +0 -0
- package/public/icons/tabherd-40.png +0 -0
- package/public/icons/tabherd-48.png +0 -0
- package/public/icons/tabherd-512.png +0 -0
- package/public/icons/tabherd-64.png +0 -0
- package/public/index.html +655 -0
- package/public/lang/es.js +742 -0
- package/public/style.css +1443 -0
- package/server.js +814 -0
package/lib/todos.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const store = require('./store');
|
|
5
|
+
const { itemsIn } = require('./ticket-refs');
|
|
6
|
+
|
|
7
|
+
// To-dos: a title and notes, then a folder, then a Claude session started
|
|
8
|
+
// there with --session-id, so the server knows which session it became, or a
|
|
9
|
+
// Codex session, linked once it's seen starting there. Saved as todos.json.
|
|
10
|
+
const MAX_TODOS = 200;
|
|
11
|
+
const MAX_TITLE = 200;
|
|
12
|
+
const MAX_NOTES = 20000;
|
|
13
|
+
const MAX_TICKETS = 10;
|
|
14
|
+
// How long a started to-do waits for its session before offering Start again.
|
|
15
|
+
const START_WAIT_MS = 60 * 1000;
|
|
16
|
+
// A to-do whose session closed is kept this long, hidden, in case the session
|
|
17
|
+
// is resumed and the to-do comes back with it.
|
|
18
|
+
const KEEP_CLOSED_MS = 30 * 24 * 60 * 60 * 1000;
|
|
19
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
20
|
+
|
|
21
|
+
let todos = load();
|
|
22
|
+
|
|
23
|
+
function load() {
|
|
24
|
+
const saved = store.read('todos', null);
|
|
25
|
+
const list = Array.isArray(saved?.todos) ? saved.todos : [];
|
|
26
|
+
return list.filter((t) => t && UUID.test(t.id) && typeof t.title === 'string' && typeof t.notes === 'string');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Writes first and only then keeps the change, so a failed write changes nothing.
|
|
30
|
+
function commit(next) {
|
|
31
|
+
try {
|
|
32
|
+
store.write('todos', { todos: next });
|
|
33
|
+
} catch (err) {
|
|
34
|
+
return { ok: false, error: `Couldn't save the to-dos: ${err.message}` };
|
|
35
|
+
}
|
|
36
|
+
todos = next;
|
|
37
|
+
return { ok: true };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cleanText(body) {
|
|
41
|
+
const title = typeof body?.title === 'string' ? body.title.replace(/\s+/g, ' ').trim() : '';
|
|
42
|
+
const notes = typeof body?.notes === 'string' ? body.notes.replace(/\r\n?/g, '\n').trimEnd() : '';
|
|
43
|
+
if (!title) return { error: 'A to-do needs a title.' };
|
|
44
|
+
if (title.length > MAX_TITLE) return { error: `Keep the title under ${MAX_TITLE} characters.` };
|
|
45
|
+
if (notes.length > MAX_NOTES) return { error: `Keep the notes under ${MAX_NOTES.toLocaleString('en')} characters.` };
|
|
46
|
+
// The app it starts in: Claude, Codex, or (null) the one Settings names.
|
|
47
|
+
const app = ['claude', 'codex', 'copilot'].includes(body?.app) ? body.app : null;
|
|
48
|
+
// Its tickets, as keys or links, which its session starts with. Left as
|
|
49
|
+
// they were if not given.
|
|
50
|
+
if (typeof body?.tickets !== 'string') return { title, notes, app };
|
|
51
|
+
const ticketRefs = itemsIn(body.tickets.slice(0, 2000));
|
|
52
|
+
if (ticketRefs.length > MAX_TICKETS) return { error: 'Give at most 10 tickets.' };
|
|
53
|
+
return { title, notes, app, ticketRefs };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const find = (id) => todos.find((t) => t.id === id) || null;
|
|
57
|
+
|
|
58
|
+
// Changes one to-do and saves.
|
|
59
|
+
function change(id, fields) {
|
|
60
|
+
return commit(todos.map((t) => (t.id === id ? { ...t, ...fields } : t)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function create(body) {
|
|
64
|
+
const text = cleanText(body);
|
|
65
|
+
if (text.error) return { ok: false, error: text.error };
|
|
66
|
+
if (todos.length >= MAX_TODOS) return { ok: false, error: `There are already ${MAX_TODOS} to-dos.` };
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
const todo = {
|
|
69
|
+
id: crypto.randomUUID(),
|
|
70
|
+
...text,
|
|
71
|
+
createdAt: now,
|
|
72
|
+
updatedAt: now,
|
|
73
|
+
cwd: null,
|
|
74
|
+
sessionId: null,
|
|
75
|
+
startedAt: null,
|
|
76
|
+
// Whether its session has been seen running. A Codex session's window,
|
|
77
|
+
// and so its process, may not be known.
|
|
78
|
+
seen: false,
|
|
79
|
+
// The session's process once it's been seen, which keeps the link if the
|
|
80
|
+
// session ID changes, as /clear does.
|
|
81
|
+
pid: null,
|
|
82
|
+
agentStartedAt: null,
|
|
83
|
+
// How many prompts the session has had, so a session closed unused can
|
|
84
|
+
// give its to-do back.
|
|
85
|
+
prompts: 0,
|
|
86
|
+
closedAt: null,
|
|
87
|
+
};
|
|
88
|
+
const result = commit([...todos, todo]);
|
|
89
|
+
return result.ok ? { ok: true, todo } : result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function edit(id, body) {
|
|
93
|
+
const text = cleanText(body);
|
|
94
|
+
if (text.error) return { ok: false, error: text.error };
|
|
95
|
+
return change(id, { ...text, updatedAt: Date.now() });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const remove = (id) => commit(todos.filter((t) => t.id !== id));
|
|
99
|
+
const setFolder = (id, cwd) => change(id, { cwd });
|
|
100
|
+
const started = (id, sessionId) => change(id, { sessionId, startedAt: Date.now() });
|
|
101
|
+
// A Codex to-do's session, once it's seen starting.
|
|
102
|
+
const linked = (id, sessionId) => change(id, { sessionId });
|
|
103
|
+
// Seen running, in to-dos saved before `seen` was kept too.
|
|
104
|
+
const wasSeen = (t) => Boolean(t.seen || t.pid);
|
|
105
|
+
|
|
106
|
+
// Linked to a session that's running now.
|
|
107
|
+
function isLive(id) {
|
|
108
|
+
const t = find(id);
|
|
109
|
+
return Boolean(t && wasSeen(t) && !t.closedAt);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Called with each snapshot. Links a started to-do to its session and puts the
|
|
113
|
+
// to-do on that session's card. Once the session closes, the to-do is hidden,
|
|
114
|
+
// unless the session closed before it was asked anything. Claude keeps no
|
|
115
|
+
// conversation for that, so there's nothing to resume, and the to-do goes back
|
|
116
|
+
// to its own card to be started again.
|
|
117
|
+
function observe(agents, now) {
|
|
118
|
+
let changed = false;
|
|
119
|
+
const next = [];
|
|
120
|
+
for (const t of todos) {
|
|
121
|
+
if (t.closedAt && now - t.closedAt > KEEP_CLOSED_MS) {
|
|
122
|
+
changed = true;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const a = t.sessionId
|
|
126
|
+
? agents.find((x) => x.id === t.sessionId || (t.pid && x.pid === t.pid && x.startedAt === t.agentStartedAt))
|
|
127
|
+
: null;
|
|
128
|
+
if (a) {
|
|
129
|
+
a.todo = { id: t.id, title: t.title, notes: t.notes, createdAt: t.createdAt, ticketRefs: t.ticketRefs || [] };
|
|
130
|
+
const prompts = a.prompts || 0;
|
|
131
|
+
if (!t.seen || t.pid !== a.pid || t.agentStartedAt !== a.startedAt || t.sessionId !== a.id || t.closedAt || t.prompts !== prompts) {
|
|
132
|
+
next.push({ ...t, seen: true, pid: a.pid, agentStartedAt: a.startedAt, sessionId: a.id, prompts, closedAt: null });
|
|
133
|
+
changed = true;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
} else if (wasSeen(t) && !t.closedAt) {
|
|
137
|
+
const unused = { ...t, sessionId: null, startedAt: null, seen: false, pid: null, agentStartedAt: null, prompts: 0 };
|
|
138
|
+
next.push(t.prompts ? { ...t, closedAt: now } : unused);
|
|
139
|
+
changed = true;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
next.push(t);
|
|
143
|
+
}
|
|
144
|
+
if (changed) commit(next);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// The to-dos that get their own cards: those not started yet, or started but
|
|
148
|
+
// not yet seen as a session.
|
|
149
|
+
function pending(now) {
|
|
150
|
+
return todos
|
|
151
|
+
.filter((t) => !wasSeen(t))
|
|
152
|
+
.map((t) => ({
|
|
153
|
+
id: t.id,
|
|
154
|
+
title: t.title,
|
|
155
|
+
notes: t.notes,
|
|
156
|
+
createdAt: t.createdAt,
|
|
157
|
+
updatedAt: t.updatedAt,
|
|
158
|
+
cwd: t.cwd,
|
|
159
|
+
app: t.app || null,
|
|
160
|
+
ticketRefs: t.ticketRefs || [],
|
|
161
|
+
startedAt: t.startedAt,
|
|
162
|
+
starting: Boolean(t.startedAt && now - t.startedAt < START_WAIT_MS),
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
module.exports = { find, create, edit, remove, setFolder, started, linked, isLive, observe, pending };
|