@dibssoftware/dibs 0.0.178 → 0.0.180
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 +40 -2
- package/README.md +49 -196
- package/bin/dibs-guard.mjs +10 -1
- package/bin/dibs.mjs +72 -31
- package/docs/benchmarks.md +1 -1
- package/docs/files.md +1 -1
- package/docs/guard.md +6 -0
- package/docs/machines.md +1 -1
- package/docs/questions.md +7 -3
- package/docs/reference.md +157 -0
- package/docs/relay.md +9 -7
- package/docs/releasing.md +11 -8
- package/docs/scheduling.md +6 -6
- package/docs/windows.md +14 -0
- package/package.json +2 -1
- package/skills/dibs/SKILL.md +104 -83
- package/src/acquire.mjs +102 -34
- package/src/agents.mjs +7 -22
- package/src/alerts.mjs +157 -57
- package/src/answers.mjs +2 -2
- package/src/board.mjs +3 -4
- package/src/broker.mjs +26 -11
- package/src/commands.mjs +39 -14
- package/src/config.mjs +27 -6
- package/src/cool.mjs +104 -9
- package/src/diskwarn.mjs +32 -35
- package/src/events.mjs +13 -2
- package/src/files.mjs +52 -67
- package/src/guard.mjs +52 -6
- package/src/guardd.mjs +97 -0
- package/src/guardw.mjs +19 -0
- package/src/hogs.mjs +18 -5
- package/src/later.mjs +20 -25
- package/src/lock.mjs +292 -0
- package/src/measure.mjs +9 -4
- package/src/news.mjs +101 -0
- package/src/notes.mjs +171 -0
- package/src/notices.mjs +52 -13
- package/src/ondemand.mjs +6 -3
- package/src/override.mjs +60 -14
- package/src/plain.mjs +7 -4
- package/src/platform.mjs +165 -35
- package/src/preempt.mjs +54 -6
- package/src/primer.mjs +43 -15
- package/src/proc.mjs +39 -8
- package/src/progress.mjs +33 -4
- package/src/questions.mjs +8 -22
- package/src/relay.mjs +10 -22
- package/src/remote.mjs +12 -8
- package/src/schedule.mjs +182 -44
- package/src/serve.mjs +22 -3
- package/src/service.mjs +4 -3
- package/src/state.mjs +139 -47
- package/src/stats.mjs +3 -2
- package/src/talk.mjs +335 -73
- package/src/trust.mjs +7 -1
- package/src/util.mjs +28 -2
- package/src/version.mjs +1 -1
- package/src/web.mjs +19 -27
- package/src/worker.mjs +2 -1
package/src/progress.mjs
CHANGED
|
@@ -46,6 +46,7 @@ function parse(args) {
|
|
|
46
46
|
else if (a === '--agent') o.agent = val();
|
|
47
47
|
else if (a === '-n') o.n = Number(val());
|
|
48
48
|
else if (a === '--json') o.json = true;
|
|
49
|
+
else if (a === '--all') o.all = true;
|
|
49
50
|
else if (a.startsWith('-') && a.length > 1) die(`unknown flag ${a}. Try: dibs progress "ran the auth tests: 41 pass, 2 fail on token expiry" --task auth --eta 20m`);
|
|
50
51
|
else o.words.push(a);
|
|
51
52
|
}
|
|
@@ -70,8 +71,11 @@ function branch(dir) {
|
|
|
70
71
|
return { root: null, branch: null };
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
export function post(args) {
|
|
74
|
+
export async function post(args) {
|
|
74
75
|
const o = parse(args);
|
|
76
|
+
// dibs progress list: the open tasks. One word "list" is the command, never a post (2026-11-03: crews kept typing it).
|
|
77
|
+
if (o.words.length === 1 && o.words[0] === 'list' && !o.task && !o.state && !o.eta) return openTasks(o);
|
|
78
|
+
if (o.all) die('--all goes with dibs progress list');
|
|
75
79
|
if (!o.text) return list(o);
|
|
76
80
|
if (o.text.length > MAX_TEXT) die(`that's ${o.text.length} characters; keep a post under ${MAX_TEXT} and post again as you go. Nothing was posted.`);
|
|
77
81
|
if (o.task && o.task.length > MAX_TASK) die(`--task is a short name (under ${MAX_TASK} characters), not a description. Nothing was posted.`);
|
|
@@ -86,8 +90,13 @@ export function post(args) {
|
|
|
86
90
|
const id = identity(o);
|
|
87
91
|
const session = process.env.CLAUDE_CODE_SESSION_ID || sessionFiles().find(f => f.pid === id.spid)?.sessionId || null;
|
|
88
92
|
const where = branch(process.cwd());
|
|
93
|
+
// Which subagent of the session posts, as the hook saw it ask (src/files.mjs):
|
|
94
|
+
// its task is its own, and so is the nudge when it goes quiet. On 2026-11-03 a
|
|
95
|
+
// lead got overdue notices for its teammates' tasks.
|
|
96
|
+
const by = session ? (await import('./files.mjs')).takeAgent('progress', [], (await import('./files.mjs')).talkKey('progress', args)) : null;
|
|
89
97
|
const p = {
|
|
90
|
-
at: now(), who: id.who, ...(id.label && { label: id.label }), ...(session && { session }),
|
|
98
|
+
at: now(), who: id.who, ...((id.label || by?.agentType) && { label: id.label || by.agentType }), ...(session && { session }),
|
|
99
|
+
...(by?.agentId && by.agentId !== 'main' && { agentId: by.agentId }),
|
|
91
100
|
project: path.basename(where.root || process.cwd()), ...(where.branch && { branch: where.branch }),
|
|
92
101
|
...(o.task && { task: o.task }), state: o.state || 'doing', ...(eta && { eta }), text: o.text,
|
|
93
102
|
};
|
|
@@ -127,9 +136,10 @@ export function read({ since = 0, agent = null, limit = Infinity } = {}) {
|
|
|
127
136
|
export function tasks(posts, at = now()) {
|
|
128
137
|
const by = new Map();
|
|
129
138
|
for (const p of posts) {
|
|
130
|
-
|
|
139
|
+
// A subagent's task is its own, apart from its lead's of the same name.
|
|
140
|
+
const key = `${p.who}\0${p.agentId || ''}\0${p.task || ''}\0${p.task ? '' : p.project || ''}`;
|
|
131
141
|
let t = by.get(key);
|
|
132
|
-
if (!t) by.set(key, t = { who: p.who, label: p.label || null, task: p.task || null, project: p.project || null, branch: p.branch || null, started: p.at, posts: 0 });
|
|
142
|
+
if (!t) by.set(key, t = { who: p.who, label: p.label || null, ...(p.agentId && { agentId: p.agentId }), task: p.task || null, project: p.project || null, branch: p.branch || null, started: p.at, posts: 0 });
|
|
133
143
|
Object.assign(t, { last: p.at, state: p.state, text: p.text, branch: p.branch || t.branch, project: p.project || t.project, session: p.session || t.session || null });
|
|
134
144
|
if (p.eta) t.eta = p.eta;
|
|
135
145
|
if (p.state === 'doing' && t.state === 'doing' && t.doneAt) delete t.doneAt;
|
|
@@ -145,6 +155,25 @@ export function tasks(posts, at = now()) {
|
|
|
145
155
|
return [...by.values()].sort((a, b) => b.last - a.last);
|
|
146
156
|
}
|
|
147
157
|
|
|
158
|
+
// The open tasks of the caller's session (every agent in it), or every session's with
|
|
159
|
+
// --all: who owns each, its state, its ETA and its last post.
|
|
160
|
+
function openTasks(o) {
|
|
161
|
+
const id = identity(o);
|
|
162
|
+
const session = process.env.CLAUDE_CODE_SESSION_ID || sessionFiles().find(f => f.pid === id.spid)?.sessionId || null;
|
|
163
|
+
const mine = p => o.all || (session ? p.session === session : p.who === id.who);
|
|
164
|
+
const t = now();
|
|
165
|
+
const open = tasks(read().filter(mine), t).filter(k => k.state === 'doing' || k.state === 'blocked');
|
|
166
|
+
if (o.json) return console.log(JSON.stringify(open, null, 1));
|
|
167
|
+
if (!open.length) return console.log(o.all ? 'No open tasks on this machine.' : 'Your session has no open tasks. Every session\'s: dibs progress list --all');
|
|
168
|
+
for (const k of open) {
|
|
169
|
+
const owner = `${k.who}${k.label ? `/${k.label}` : ''}`;
|
|
170
|
+
const due = k.eta ? (k.overdue ? `overdue since ${clock(k.eta)}` : `expected by ${clock(k.eta)}`) : 'no ETA';
|
|
171
|
+
console.log(`${bold(k.task || `(untitled, in ${k.project || 'a folder'})`)} ${owner} ${k.state}, ${due}, last post ${dur(t - k.last)} ago`);
|
|
172
|
+
console.log(` ${k.text.replace(/\s*\n\s*/g, ' ').slice(0, 300)}`);
|
|
173
|
+
}
|
|
174
|
+
console.log(dim(`Close one: dibs progress "what's done" --task <name> --done${o.all ? '' : '. Every session\'s: dibs progress list --all'}`));
|
|
175
|
+
}
|
|
176
|
+
|
|
148
177
|
function list(o) {
|
|
149
178
|
const posts = read({ agent: o.agent, limit: o.n > 0 ? o.n : RECENT });
|
|
150
179
|
if (o.json) return console.log(JSON.stringify(posts, null, 1));
|
package/src/questions.mjs
CHANGED
|
@@ -24,13 +24,13 @@ import { defaultMaxWait } from './acquire.mjs';
|
|
|
24
24
|
import { event } from './events.mjs';
|
|
25
25
|
import { takeAgent, talkKey } from './files.mjs';
|
|
26
26
|
import { messageAsker } from './talk.mjs';
|
|
27
|
-
import {
|
|
27
|
+
import { underLock, commit } from './lock.mjs';
|
|
28
|
+
import { clock, die, dur, ms, now, say, sleep, fakeFull } from './util.mjs';
|
|
28
29
|
import { bold, dim, amber, wrap } from './style.mjs';
|
|
29
30
|
|
|
30
31
|
const FILE = path.join(HOME, 'questions.json');
|
|
31
32
|
const LOCK = path.join(HOME, 'questions.lock');
|
|
32
|
-
// Writes take milliseconds
|
|
33
|
-
const LOCK_STALE = 5000;
|
|
33
|
+
// Writes take milliseconds: a live holder past this is stuck on something else, and the caller hears so.
|
|
34
34
|
const LOCK_WAIT = 15e3;
|
|
35
35
|
// A waiting asker looks for its answer this often. A person reads the answer
|
|
36
36
|
// back slower than this, and each look is one small file read.
|
|
@@ -46,30 +46,16 @@ const OPEN = 'open';
|
|
|
46
46
|
const DECIDED = 'decided';
|
|
47
47
|
|
|
48
48
|
function locked(fn) {
|
|
49
|
-
|
|
50
|
-
const t0 = now();
|
|
51
|
-
for (;;) {
|
|
52
|
-
try { fs.mkdirSync(LOCK); break; } catch (e) {
|
|
53
|
-
if (e.code !== 'EEXIST') throw e;
|
|
54
|
-
try { if (now() - fs.statSync(LOCK).mtimeMs > LOCK_STALE) fs.rmSync(LOCK, { recursive: true, force: true }); } catch {}
|
|
55
|
-
if (now() - t0 > LOCK_WAIT) die(`${LOCK} stayed locked for ${LOCK_WAIT / 1000}s; remove it if no dibs is running. Nothing was changed.`, 75);
|
|
56
|
-
sleepSync(5 + Math.random() * 10);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
49
|
+
const r = underLock(LOCK, h => {
|
|
60
50
|
const s = load();
|
|
61
51
|
const before = JSON.stringify(s);
|
|
62
52
|
reap(s);
|
|
63
53
|
const out = fn(s);
|
|
64
|
-
if (JSON.stringify(s) !== before) {
|
|
65
|
-
fakeFull('state');
|
|
66
|
-
fs.writeFileSync(`${FILE}.tmp`, JSON.stringify(s, null, 1));
|
|
67
|
-
fs.renameSync(`${FILE}.tmp`, FILE);
|
|
68
|
-
}
|
|
54
|
+
if (JSON.stringify(s) !== before) commit(h, FILE, JSON.stringify(s, null, 1), { fake: () => fakeFull('state') });
|
|
69
55
|
return out;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
}, { wait: LOCK_WAIT, files: [FILE] });
|
|
57
|
+
if (!r) die(`${LOCK} is held by a dibs that's still running, and stayed held for ${LOCK_WAIT / 1000}s. Nothing was changed: run the same command again.`, 75);
|
|
58
|
+
return r.out;
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
// Writes are renames, so reading without the lock always sees a whole file.
|
package/src/relay.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import crypto from 'node:crypto';
|
|
|
30
30
|
import { HOME } from './config.mjs';
|
|
31
31
|
import { die, now, log, sleep, dur } from './util.mjs';
|
|
32
32
|
import { makeAlive, singleInstance } from './proc.mjs';
|
|
33
|
+
import { underLock, commit } from './lock.mjs';
|
|
33
34
|
import { qr, render } from './qr.mjs';
|
|
34
35
|
import { logChange } from './owner.mjs';
|
|
35
36
|
import { remoteAccess, LOCAL_ONLY_TEXT, lookOnlyText, remoteMcp, MCP_ORIGIN, mcpCodes } from './web.mjs';
|
|
@@ -39,6 +40,8 @@ export const RELAY = process.env.DIBS_RELAY_URL || 'wss://app.dibs.cc';
|
|
|
39
40
|
const KEYS = path.join(HOME, 'relay-keys.json');
|
|
40
41
|
const FILE = path.join(HOME, 'relay.json');
|
|
41
42
|
const LOCK = path.join(HOME, 'relay.lock');
|
|
43
|
+
// Writes take milliseconds: a holder still at it past this is stuck on something else.
|
|
44
|
+
const LOCK_WAIT = 5000;
|
|
42
45
|
export const STATUS = path.join(HOME, 'relay-status.json');
|
|
43
46
|
const PIDFILE = path.join(HOME, 'relay.pid');
|
|
44
47
|
|
|
@@ -156,31 +159,15 @@ export function load() {
|
|
|
156
159
|
|
|
157
160
|
// `dibs pair` and the connector both write relay.json; this keeps one from undoing the other.
|
|
158
161
|
function locked(fn) {
|
|
159
|
-
|
|
160
|
-
const t0 = now();
|
|
161
|
-
for (;;) {
|
|
162
|
-
try { fs.mkdirSync(LOCK); break; } catch (e) {
|
|
163
|
-
if (e.code !== 'EEXIST') throw e;
|
|
164
|
-
try {
|
|
165
|
-
if (now() - fs.statSync(LOCK).mtimeMs > 5000) {
|
|
166
|
-
const aside = `${LOCK}.stale.${process.pid}`;
|
|
167
|
-
fs.renameSync(LOCK, aside);
|
|
168
|
-
fs.rmSync(aside, { recursive: true, force: true });
|
|
169
|
-
}
|
|
170
|
-
} catch {}
|
|
171
|
-
if (now() - t0 > 5000) throw new Error(`${LOCK} stayed locked; remove it if no dibs is running`);
|
|
172
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
162
|
+
const r = underLock(LOCK, h => {
|
|
176
163
|
const w = load();
|
|
177
164
|
const out = fn(w);
|
|
178
165
|
w.pairs = w.pairs.filter(p => p.exp > now());
|
|
179
|
-
|
|
180
|
-
fs.writeFileSync(tmp, JSON.stringify(w), { mode: 0o600 });
|
|
181
|
-
fs.renameSync(tmp, FILE);
|
|
166
|
+
commit(h, FILE, JSON.stringify(w), { mode: 0o600 });
|
|
182
167
|
return out;
|
|
183
|
-
}
|
|
168
|
+
}, { wait: LOCK_WAIT, files: [FILE] });
|
|
169
|
+
if (!r) throw new Error(`${LOCK} is held by a dibs that's still running; try again in a moment`);
|
|
170
|
+
return r.out;
|
|
184
171
|
}
|
|
185
172
|
|
|
186
173
|
// A one-time pairing link. The secret is shown once and only its derived pieces are kept.
|
|
@@ -487,7 +474,8 @@ export function macPeer({ k = keys(), send, kick, call, admit = () => {}, clock
|
|
|
487
474
|
sid: hkdf(c.ss, salt, 'dibs-relay-v1 sid', 32), seqIn: 0, seqOut: 0, began: clock(), ss: null, th: null,
|
|
488
475
|
});
|
|
489
476
|
try { locked(w => { if (w.devices[c.did]) w.devices[c.did].seen = clock(); }); } catch {}
|
|
490
|
-
// Key confirmation
|
|
477
|
+
// Key confirmation. The page may already have sent its first call behind hello3 (it reads this
|
|
478
|
+
// before any answer); that frame is handled after this function, so the keys are in place.
|
|
491
479
|
out(ch, c, { t: 'ready' });
|
|
492
480
|
}
|
|
493
481
|
|
package/src/remote.mjs
CHANGED
|
@@ -125,10 +125,16 @@ export function tarExtract(dir, buf, only = null) {
|
|
|
125
125
|
return members;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// A path with its links resolved, the same way every time it's compared. On
|
|
129
|
+
// Windows only the native call also expands 8.3 names (C:\Users\RUNNER~1): the JS
|
|
130
|
+
// one left a temp folder short and the home folder long, so the job's folder came
|
|
131
|
+
// out as ../../RUNNER~1/... relative to its own project.
|
|
132
|
+
const real = p => { try { return (OS === 'windows' ? fs.realpathSync.native : fs.realpathSync)(p); } catch { return p; } };
|
|
133
|
+
|
|
128
134
|
// The folder a working copy comes from: the git repo around cwd, or cwd itself.
|
|
129
135
|
function projectRoot(cwd = process.cwd()) {
|
|
130
|
-
try { return
|
|
131
|
-
catch { return cwd; }
|
|
136
|
+
try { return real(execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()); }
|
|
137
|
+
catch { return real(cwd); }
|
|
132
138
|
}
|
|
133
139
|
// A load-held job may go to an on-demand machine on its own (acquire.mjs step)
|
|
134
140
|
// only when it can run there. Never one that needs macOS: a resource that
|
|
@@ -167,14 +173,13 @@ export function mayShip(me, cfg, cwd) {
|
|
|
167
173
|
if (macOnly(me.cmd, cwd) || !remoteConf(() => null) || namesPaths(me.cmd)) return false;
|
|
168
174
|
const root = gitRoot(cwd);
|
|
169
175
|
if (!root) return false;
|
|
170
|
-
|
|
171
|
-
try { home = fs.realpathSync(home); } catch {}
|
|
176
|
+
const home = real(os.homedir());
|
|
172
177
|
return !(root === path.parse(root).root || home === root || home.startsWith(root.endsWith(path.sep) ? root : root + path.sep));
|
|
173
178
|
}
|
|
174
179
|
// Only a git working copy ships on its own: that's what the copy is, and a
|
|
175
180
|
// folder outside git may hold anything.
|
|
176
181
|
function gitRoot(cwd) {
|
|
177
|
-
try { return
|
|
182
|
+
try { return real(execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()); }
|
|
178
183
|
catch { return null; }
|
|
179
184
|
}
|
|
180
185
|
// A command that names a path of this machine (/Users/..., ~/...) means a file the
|
|
@@ -258,7 +263,7 @@ function workingCopy(root, cwd = process.cwd()) {
|
|
|
258
263
|
if (st.isDirectory()) continue; // a submodule
|
|
259
264
|
(SECRET.test(f) ? secret : kept).push(f);
|
|
260
265
|
}
|
|
261
|
-
const cwdRel = path.relative(root,
|
|
266
|
+
const cwdRel = path.relative(root, real(cwd)).split(path.sep).join('/');
|
|
262
267
|
return { files: kept.sort(), secret, cwdRel };
|
|
263
268
|
}
|
|
264
269
|
|
|
@@ -292,8 +297,7 @@ export async function remoteRun(o, cfg) {
|
|
|
292
297
|
if (o.on && !ruleAllows(rule, o.on, rc.name)) return refuse(o.on, rule);
|
|
293
298
|
const root = projectRoot();
|
|
294
299
|
// Your home folder, or a folder above it, holds far more than a project, keys included.
|
|
295
|
-
|
|
296
|
-
try { home = fs.realpathSync(home); } catch {}
|
|
300
|
+
const home = real(os.homedir());
|
|
297
301
|
if (root === path.parse(root).root || home === root || home.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) {
|
|
298
302
|
const msg = `${root} is your home folder or above it, and dibs won't send all of that to another machine. Run from the project's folder`;
|
|
299
303
|
if (o.on && o.on !== rc.name) die(msg);
|