heyquilt 0.3.175 → 0.3.177
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/RELEASES.md +23 -0
- package/bin/quilt.js +1 -1
- package/package.json +1 -1
- package/src/agent-task-workflow.js +3 -3
- package/src/connection.js +6 -12
- package/src/control.js +0 -1
- package/src/duties.js +2 -4
- package/src/gitstate.js +475 -0
- package/src/hooks.js +2 -2
- package/src/identity.js +1 -1
- package/src/live-merge.js +21 -2
- package/src/mcp.js +3 -17
- package/src/merge3.js +17 -1
- package/src/now-summary.js +2 -4
- package/src/pathrules.js +1 -1
- package/src/protocol.js +2 -2
- package/src/relay-ask.js +2 -3
- package/src/relay-live-write.js +10 -5
- package/src/relay-mcp.js +7 -48
- package/src/relay-prune.js +1 -2
- package/src/relay-turn-sync.js +11 -37
- package/src/server.js +20 -287
- package/src/session.js +1096 -271
- package/src/setup.js +23 -25
- package/src/status.js +5 -8
- package/src/ui/agent-guide.js +9 -17
- package/src/ui/app.css +22 -121
- package/src/ui/common.js +1 -4
- package/src/ui/feedback.js +3 -3
- package/src/ui/fileview.js +6 -12
- package/src/ui/rail-model.js +19 -35
- package/src/ui/rail.js +13 -153
- package/src/ui/session.js +63 -146
- package/src/ui/tree.js +5 -28
- package/src/ui-server.js +0 -4
- package/src/boxes.js +0 -36
- package/src/ui/boxes.js +0 -80
package/src/identity.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Per-person identity: an Ed25519 key pair kept in ~/.quilt/identity.json.
|
|
2
2
|
// The relay ties each name in a room to the first key that used it, and
|
|
3
3
|
// checks a signature on every connect, so nobody can act under someone
|
|
4
|
-
// else's name (for example to fake their messages
|
|
4
|
+
// else's name (for example to fake their messages).
|
|
5
5
|
import fs from 'node:fs'
|
|
6
6
|
import os from 'node:os'
|
|
7
7
|
import path from 'node:path'
|
package/src/live-merge.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// those lines lands, or when its held lines already match the file.
|
|
19
19
|
import path from 'node:path'
|
|
20
20
|
import { diffLines as diffIndices } from './textdiff.js'
|
|
21
|
-
import { mergeLive } from './merge3.js'
|
|
21
|
+
import { mergeLive, withHeldMarkers } from './merge3.js'
|
|
22
22
|
import { HELD_MAP, addHeld, readHeld, dropVersions, heldRegions, locateHunk, overBudget, heldTaskTitle } from './held.js'
|
|
23
23
|
|
|
24
24
|
export const MOVES_MAP = 'moves' // in the file's document: old path -> { to, by, ts, text }
|
|
@@ -220,6 +220,16 @@ export function goneNameWarning (p, list, me = '') {
|
|
|
220
220
|
return `${parts.join('; ')}. Nothing was blocked: check it still exists (it may have been renamed or moved).`
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/** What a writer's AI hears when its save clashed and both versions are in its own file to settle. */
|
|
224
|
+
export function clashNotice (p, who) {
|
|
225
|
+
return `⚖️ Your save of ${p} was not shared: ${who || 'someone'} changed the same lines first. ${p} in your folder now has both versions of those lines, yours between "<<<<<<< mine" and "=======", theirs between "=======" and ">>>>>>> session", with their other changes merged in. Read ${p}, edit those lines to what they should be, delete the three marker lines of each, and save: it is shared then. Until you do, your changes to ${p} stay in your folder only.`
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** The same file saved again with markers still in it. */
|
|
229
|
+
export function clashStillNotice (p) {
|
|
230
|
+
return `⚖️ ${p} still has conflict markers ("<<<<<<< mine", "=======", ">>>>>>> session"), so it is not shared yet. Settle each one, delete the marker lines, and save.`
|
|
231
|
+
}
|
|
232
|
+
|
|
223
233
|
/**
|
|
224
234
|
* The engine both live paths share, one per session. Options: `room()` the room's Y.Doc (held
|
|
225
235
|
* conflicts); `notice(text)` for the writer's AI;
|
|
@@ -249,7 +259,7 @@ export class LiveRules {
|
|
|
249
259
|
* `text` is what the shared file and the writer's folder get.
|
|
250
260
|
* `older`: a save proven made from an older text than `base` (it landed in the file Quilt replaced: base-pick.js).
|
|
251
261
|
*/
|
|
252
|
-
write ({ doc, where = {}, path: p, base = null, ours, theirs = null, by, byId = null, others = [], texts = null, union = false, nameSearch = true, older = null }) {
|
|
262
|
+
write ({ doc, where = {}, path: p, base = null, ours, theirs = null, by, byId = null, others = [], texts = null, union = false, nameSearch = true, older = null, markers = false }) {
|
|
253
263
|
const now = Date.now()
|
|
254
264
|
const map = this.heldMap()
|
|
255
265
|
const all = map ? readHeld(map) : []
|
|
@@ -282,6 +292,15 @@ export class LiveRules {
|
|
|
282
292
|
const r = mergeLive(base, ours, theirs, { union })
|
|
283
293
|
text = r.text; mine = r.mine; held = r.held
|
|
284
294
|
}
|
|
295
|
+
// A writer who settles a clash in its own file (`markers`: a folder, session.js relayClashed): nothing of
|
|
296
|
+
// this save is taken and no record is kept. It gets the save back merged onto the shared text as it is
|
|
297
|
+
// now, with both versions of each clashing run of lines between markers, and sends it again once settled.
|
|
298
|
+
if (markers && (held.length || olderHeld.length) && typeof theirs === 'string') {
|
|
299
|
+
const made = typeof older === 'string' && typeof base === 'string' ? older : base
|
|
300
|
+
const r = mergeLive(made ?? '', saved, theirs, { union })
|
|
301
|
+
const first = others.filter((n) => n && n !== by)
|
|
302
|
+
if (r.held.length) return { conflict: true, text: withHeldMarkers(r, { mine: by || 'you', theirs: first.join(', ') || 'someone else' }), others: first, held: [], warnings: [], gone: [] }
|
|
303
|
+
}
|
|
285
304
|
const cur = typeof theirs === 'string' ? theirs : null
|
|
286
305
|
// The open records on this path, on this branch: this write may join, supersede or match them. (A record
|
|
287
306
|
// stored by an earlier version may name a `square` instead of a branch: it is no branch's.)
|
package/src/mcp.js
CHANGED
|
@@ -82,8 +82,7 @@ export const MCP_INSTRUCTIONS =
|
|
|
82
82
|
'If the person you work for lets their AI pick up work by itself (their cloud AI, on the cloud machine they connected), finishing (quilt_set_work done, a task to QA or Done) hands you your next task from the board: start it. ' +
|
|
83
83
|
'Before you change files, call quilt_before_edit with their paths: it shows what people said about those files in chat and who else changed them lately, ' +
|
|
84
84
|
'so you know what was asked or planned before you change them. It never refuses: nobody holds files. ' +
|
|
85
|
-
'Edit any file you may change: edits merge as they arrive, and if your change clashes with someone\'s on the same lines, Quilt
|
|
86
|
-
'A boxed file\'s edits are only in its owner\'s folder; quilt_unpack shares a box when someone needs it: decide yourself, and ask your person first for a large, risky or critical change or when the project\'s rules say so. A file boxed by someone else (quilt_status lists Boxed work) is not in your folder yet: if you edit it, their box opens and your change merges with their work. ' +
|
|
85
|
+
'Edit any file you may change: edits merge as they arrive, and if your change clashes with someone\'s on the same lines, Quilt tells you. In your own folder the clash is in the file itself: your save is not shared, and the file has both versions of those lines between conflict markers ("<<<<<<< mine", "=======", ">>>>>>> session"). Edit them to what they should be, delete the marker lines and save: it is shared then. A conflict listed at the top of a Quilt answer instead (an agent with no folder made it, or an older app) is resolved at once with quilt_resolve_merge. A conflict must not sit: until you resolve your own, moving a task to QA or Done, quilt_set_work done and commits refuse, and a conflict whose writer\'s AI is gone is handed to another AI in the session. ' +
|
|
87
86
|
'For an agent of its own (not a person\'s AI session), every quilt answer starts with anything new for it (direct messages, mentions, tasks handed to it): act on it. ' +
|
|
88
87
|
'These rules are enforced for agents: while someone who messaged or mentioned you is waiting for an answer, the tools that move work on (tasks, focus, quilt_set_work) refuse until you answer them with quilt_message. ' +
|
|
89
88
|
'When you start a piece of work, call quilt_set_work with "working" and a note of what it is (with quilt_set_focus), so the loom shows you stitching; when you finish, call it with "done". ' +
|
|
@@ -204,7 +203,7 @@ export async function runMcp () {
|
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
server.registerTool('quilt_status', {
|
|
207
|
-
description: 'See who else is in the live session, what they are working on, which files they recently edited,
|
|
206
|
+
description: 'See who else is in the live session, what they are working on, which files they recently edited, recent messages, and which open tasks are assigned to you. Call this before starting work.',
|
|
208
207
|
inputSchema: {}
|
|
209
208
|
}, () => withDaemon(async (d) => {
|
|
210
209
|
const st = await call(d, 'GET', '/status')
|
|
@@ -359,18 +358,6 @@ export async function runMcp () {
|
|
|
359
358
|
return r.typing ? `Showing that you are typing${to ? ` to ${to}` : ''}.` : 'Not showing that you are typing.'
|
|
360
359
|
}))
|
|
361
360
|
|
|
362
|
-
server.registerTool('quilt_unpack', {
|
|
363
|
-
description: 'Share boxed work before you commit it. In a folder that is a git repository, your edits to a file stay in a box: everyone sees the change, but it is only in your folder, so nobody else\'s git can commit it, until you commit it. ' +
|
|
364
|
-
'Unpack when someone needs your change now: it reaches everyone\'s folder, and the file stays yours. Decide this yourself; for a large, risky or critical change, or when the project\'s rules say so, ask your person first.',
|
|
365
|
-
inputSchema: { paths: z.array(z.string().min(1).max(500)).min(1).max(100).describe('Your boxed files, relative to the project folder') }
|
|
366
|
-
}, ({ paths }) => withDaemon(async (d) => {
|
|
367
|
-
const rels = paths.map((p) => path.relative(d.dir, path.resolve(d.dir, p)).split(path.sep).join('/'))
|
|
368
|
-
const r = await call(d, 'POST', '/unpack', { paths: rels })
|
|
369
|
-
if (!r.unpacked.length) throw new Error(`${r.notBoxed.join(', ')} ${r.notBoxed.length === 1 ? 'is' : 'are'} not boxed by you.`)
|
|
370
|
-
return `Unpacked ${r.unpacked.join(', ')}: in everyone's folder now. Your next edit to one boxes it again.${r.notBoxed.length ? ` Not boxed by you: ${r.notBoxed.join(', ')}.` : ''}`
|
|
371
|
-
}))
|
|
372
|
-
|
|
373
|
-
|
|
374
361
|
server.registerTool('quilt_message', {
|
|
375
362
|
description: CHAT_RULES + ' Set "to" to message one person directly.',
|
|
376
363
|
inputSchema: {
|
|
@@ -906,7 +893,7 @@ export async function runMcp () {
|
|
|
906
893
|
}))
|
|
907
894
|
|
|
908
895
|
server.registerTool('quilt_list_files', {
|
|
909
|
-
description: 'List the shared project\'s files with who edited each one recently
|
|
896
|
+
description: 'List the shared project\'s files with who edited each one recently, so you can see where others are working.',
|
|
910
897
|
inputSchema: { prefix: z.string().optional().describe('Only paths under this folder, e.g. "src/auth"') }
|
|
911
898
|
}, ({ prefix }) => withDaemon(async (d) => {
|
|
912
899
|
const { files } = await call(d, 'GET', '/tree')
|
|
@@ -917,7 +904,6 @@ export async function runMcp () {
|
|
|
917
904
|
const lines = shown.slice(0, 400).map((f) => {
|
|
918
905
|
const notes = []
|
|
919
906
|
if (f.edited && now - f.edited.ts < 10 * 60 * 1000) notes.push(`edited by ${f.edited.by === me ? 'you' : f.edited.by} ${Math.round((now - f.edited.ts) / 1000)}s ago`)
|
|
920
|
-
if (f.box) notes.push(`${f.box.by === me ? 'your' : `${f.box.by}'s`} unfinished work, boxed`)
|
|
921
907
|
if (f.chat) notes.push(`sent in chat by ${f.chat.by === me ? 'you' : f.chat.by}: in your folder only, never synced or committed`)
|
|
922
908
|
if (f.binary) notes.push('binary')
|
|
923
909
|
return `${f.path}${notes.length ? ` [${notes.join('; ')}]` : ''}`
|
package/src/merge3.js
CHANGED
|
@@ -71,7 +71,23 @@ export const withMarkers = eolAware(function withMarkers (base, ours, theirs, na
|
|
|
71
71
|
return out.join('\n')
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* A live merge (mergeLive's { text, held }) with each clash written out between markers: the writer's lines,
|
|
76
|
+
* then the lines that landed first. What the writer's own file gets when the relay takes nothing of a save.
|
|
77
|
+
*/
|
|
78
|
+
export function withHeldMarkers (r, names) {
|
|
79
|
+
const crlf = eolOf(r.text) === 'crlf'
|
|
80
|
+
const bare = (ls) => ls.map((l) => l.replace(/\r$/, ''))
|
|
81
|
+
const out = lines(crlf ? r.text.replace(/\r\n/g, '\n') : r.text)
|
|
82
|
+
// From the last clash to the first, so each one's place in the text still holds.
|
|
83
|
+
for (const h of [...r.held].sort((x, y) => y.at - x.at)) {
|
|
84
|
+
out.splice(h.at, h.theirs.length, `${MARK.start} (${names.mine})`, ...bare(h.ours), MARK.mid, ...bare(h.theirs), `${MARK.end} (${names.theirs})`)
|
|
85
|
+
}
|
|
86
|
+
const text = out.join('\n')
|
|
87
|
+
return crlf ? text.replace(/\n/g, '\r\n') : text
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** True when the text still holds markers that withMarkers or withHeldMarkers put there. */
|
|
75
91
|
export function hasMarkers (text) {
|
|
76
92
|
return typeof text === 'string' && text.split('\n').some((l) => l.startsWith(`${MARK.start} (`) || l.startsWith(`${MARK.end} (`))
|
|
77
93
|
}
|
package/src/now-summary.js
CHANGED
|
@@ -62,7 +62,7 @@ function peopleIn (room, now) {
|
|
|
62
62
|
/**
|
|
63
63
|
* The summary of `room` for `account`, or null when the account isn't in it. `now` is the time;
|
|
64
64
|
* `detail` (one session's page) keeps more of the latest file changes, for its Activity tab.
|
|
65
|
-
* The room is read through what Room already offers (server.js): meta, awareness, doc,
|
|
65
|
+
* The room is read through what Room already offers (server.js): meta, awareness, doc, pendingList.
|
|
66
66
|
*/
|
|
67
67
|
export function nowSummary (room, account, { now = Date.now(), detail = false } = {}) {
|
|
68
68
|
const me = nameIn(room, account)
|
|
@@ -71,7 +71,6 @@ export function nowSummary (room, account, { now = Date.now(), detail = false }
|
|
|
71
71
|
const doc = room.doc
|
|
72
72
|
const chat = doc ? doc.getArray('chat').toArray() : []
|
|
73
73
|
const tasks = doc ? activeTasks(readTasks(doc.getMap('tasks'))) : []
|
|
74
|
-
const boxes = room.boxList ? room.boxList() : []
|
|
75
74
|
const people = peopleIn(room, now)
|
|
76
75
|
|
|
77
76
|
const needs = []
|
|
@@ -103,8 +102,7 @@ export function nowSummary (room, account, { now = Date.now(), detail = false }
|
|
|
103
102
|
working: people.filter((p) => p.ai === 'working').length,
|
|
104
103
|
tasks: { open: byColumn.todo + byColumn.doing + byColumn.qa, ...byColumn, mine: tasks.filter((t) => t.column !== 'done' && t.assignee === me).length },
|
|
105
104
|
recent,
|
|
106
|
-
|
|
107
|
-
held: boxes.slice(0, NOW_LIMITS.held).map((c) => ({ path: clip(c.pattern, 200), by: clip(c.by, 64), box: true, waiting: [] })),
|
|
105
|
+
held: [], // nobody holds files; the field stays for older readers
|
|
108
106
|
needs: needs.slice(0, NOW_LIMITS.needs),
|
|
109
107
|
at: now
|
|
110
108
|
}
|
package/src/pathrules.js
CHANGED
|
@@ -115,7 +115,7 @@ export function isSafeRelPath (rel) {
|
|
|
115
115
|
return true
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/** Whether two path patterns (
|
|
118
|
+
/** Whether two path patterns (access scopes) can cover the same file (paths: files that exist now). */
|
|
119
119
|
export function patternsOverlap (a, b, paths = []) {
|
|
120
120
|
if (a === b) return true
|
|
121
121
|
const ma = globMatcher(a)
|
package/src/protocol.js
CHANGED
|
@@ -10,8 +10,8 @@ export const MSG_AWARENESS = 1
|
|
|
10
10
|
export const MSG_QUERY_AWARENESS = 3
|
|
11
11
|
// quilt extensions (ignored by plain y-websocket clients):
|
|
12
12
|
export const MSG_AUTH = 10 // relay -> client: nonce; client -> relay: signature
|
|
13
|
-
export const MSG_CLAIM = 11 // client -> relay: JSON { id, op: 'box'|'unbox', pattern
|
|
14
|
-
export const MSG_CLAIMS = 12 // relay -> client: JSON { claims:
|
|
13
|
+
export const MSG_CLAIM = 11 // client -> relay, from apps before 0.3.177: JSON { id, op: 'box'|'unbox', pattern }; nothing is kept out of a folder, and they are told so
|
|
14
|
+
export const MSG_CLAIMS = 12 // relay -> client, for apps before 0.3.177: JSON { claims: [], reply?: { id, ok, boxed: 0 | unboxed: 0 } }
|
|
15
15
|
export const MSG_ACCESS = 13 // relay -> client: JSON { state: 'pending'|'approved', role, scopes, scopesExcept, talk, owner, controlled, refresh?, refused?, why?, secret?, viewSecret? } (the last two: the room's links, for someone let in by their account)
|
|
16
16
|
export const MSG_ADMIN = 14 // client (owner) -> relay: JSON { id, op: 'approve'|'deny'|'set'|'remove'|'end'|'name', key, role, scopes, access?, typeId?, name }
|
|
17
17
|
export const MSG_MEMBERS = 15 // relay -> client: JSON { members, sessionName, pending?, reply?: { id, ok, error } }
|
package/src/relay-ask.js
CHANGED
|
@@ -72,16 +72,15 @@ function branchesAnswer (room, now) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* The branches trim would remove: not the default, nobody on it
|
|
75
|
+
* The branches trim would remove: not the default, nobody on it, no
|
|
76
76
|
* hosted agent's choice, and no member on it for TRIM_IDLE_MS. A branch from before `used` was
|
|
77
77
|
* kept counts from its last `seen` (the relay's own saves move that too, so it only waits longer).
|
|
78
78
|
*/
|
|
79
79
|
export function unusedBranches (room, now = Date.now()) {
|
|
80
80
|
const on = whoIsOn(room)
|
|
81
|
-
const boxed = new Set(Object.values(room.meta.boxes || {}).map((c) => room.branchOf(c)))
|
|
82
81
|
const chosen = new Set(Object.values(room.meta.hostedBranch || {}))
|
|
83
82
|
return Object.entries(room.meta.branches)
|
|
84
|
-
.filter(([k, b]) => k !== room.defaultKey && !on.has(k) && !
|
|
83
|
+
.filter(([k, b]) => k !== room.defaultKey && !on.has(k) && !chosen.has(k) && now - (b.used || b.seen || b.at || 0) >= TRIM_IDLE_MS)
|
|
85
84
|
.map(([k]) => k)
|
|
86
85
|
}
|
|
87
86
|
|
package/src/relay-live-write.js
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
// check-then-write race."). A folder that saw a text file change on disk (session.js ingest, into its
|
|
4
4
|
// branch document) sends the relay
|
|
5
5
|
//
|
|
6
|
-
// MSG_BRANCH { op: 'live-write', branch, path, base, baseText?, text, older?, retry?, baseUnknown?, fromGit? }
|
|
6
|
+
// MSG_BRANCH { op: 'live-write', branch, path, base, baseText?, text, older?, retry?, baseUnknown?, fromGit?, markers? }
|
|
7
7
|
//
|
|
8
8
|
// `base`: the version (sha1, read-bases.js versionOf) of the shared text the folder last synced for the
|
|
9
9
|
// path, null for a file it never had; `baseText`: that text itself, when the relay may not know it
|
|
10
10
|
// (the folder sends it when it is small, or when the relay asked for it); `text`: what disk holds now;
|
|
11
11
|
// `older`: the older text the save was made from, one its folder's disk held before Quilt wrote over it
|
|
12
12
|
// (base-pick.js); `fromGit`: a diff branch's first edit of a file only git had, `base` being git's text (the
|
|
13
|
-
// shared file has no entry: it is git's, so the base is what it holds)
|
|
14
|
-
//
|
|
13
|
+
// shared file has no entry: it is git's, so the base is what it holds); `markers`: the folder settles a clash
|
|
14
|
+
// in its own file, so a save that clashes is not taken at all (the reply is { ok, conflict: true, text, base,
|
|
15
|
+
// others }: the save with both versions of the clashing lines between markers, made on `base`, the shared
|
|
16
|
+
// text now). A `trusted` or a `seen` from older folders is ignored.
|
|
15
17
|
// The relay merges it here, synchronously (nothing else runs on the room between the read of the
|
|
16
18
|
// shared text and the write of the result), through the same engine every live write uses
|
|
17
19
|
// (live-merge.js LiveRules: same lines keep what landed first and the writer's are held; the removed-name
|
|
@@ -132,7 +134,8 @@ export function liveWrite (room, ws, req, { origin = WRITE_ORIGIN, now = Date.no
|
|
|
132
134
|
const before = t0 ? t0.toString() : theirs
|
|
133
135
|
// The merge and the result: one transaction, so every member gets the write as one update.
|
|
134
136
|
doc.transact(() => {
|
|
135
|
-
r = rules.write({ doc, where, path: rel, base, ours: req.text, theirs, by, byId, others, nameSearch: false, older })
|
|
137
|
+
r = rules.write({ doc, where, path: rel, base, ours: req.text, theirs, by, byId, others, nameSearch: false, older, markers: req.markers === true })
|
|
138
|
+
if (r.conflict) return
|
|
136
139
|
let t = files.get(rel)
|
|
137
140
|
blobs.delete(rel)
|
|
138
141
|
// Who wrote it, in the same update as the text (WRITERS_MAP): a folder that takes the text in names its
|
|
@@ -141,12 +144,14 @@ export function liveWrite (room, ws, req, { origin = WRITE_ORIGIN, now = Date.no
|
|
|
141
144
|
if (!t) { t = new Y.Text(); if (typeof theirs === 'string') t.insert(0, theirs); files.set(rel, t) }
|
|
142
145
|
detail = applyLineDiff(t, r.text)
|
|
143
146
|
}, origin)
|
|
147
|
+
// Someone changed the same lines first, and this writer settles that in its own file: nothing is taken.
|
|
148
|
+
// `base` is the shared text its marked-up file was made on, which its next save is merged against.
|
|
149
|
+
if (r.conflict) return { ok: true, path: rel, conflict: true, text: r.text, base: theirs, others: r.others, notices, logs }
|
|
144
150
|
if (r.text !== (theirs ?? '')) {
|
|
145
151
|
room.liveWriters.delete(wkey)
|
|
146
152
|
room.liveWriters.set(wkey, { by, ts: now })
|
|
147
153
|
if (room.liveWriters.size > 5000) room.liveWriters.delete(room.liveWriters.keys().next().value)
|
|
148
154
|
}
|
|
149
|
-
if (room.noteActivity && room.holderKeys) room.noteActivity(room.holderKeys(ws))
|
|
150
155
|
// An agent's write is its AI at work (server.js handHeld: its held conflicts stay its own while it is).
|
|
151
156
|
if (a.kind === 'agent' && room.noteAi) room.noteAi(by, now)
|
|
152
157
|
const version = bases.note(by || 'folder', k, rel, r.text)
|
package/src/relay-mcp.js
CHANGED
|
@@ -59,7 +59,7 @@ export function freshEditPaths (editing, now = Date.now()) {
|
|
|
59
59
|
}
|
|
60
60
|
const MAX_READ_CHARS = 200 * 1024
|
|
61
61
|
// Tools that read or change a branch's files or history: a hosted agent's first one pins its branch (Room.pinHostedBranch).
|
|
62
|
-
const FILE_TOOLS = new Set(['quilt_sync', 'quilt_history', 'quilt_list_files', 'quilt_read_file', 'quilt_project_rules', 'quilt_write_file'
|
|
62
|
+
const FILE_TOOLS = new Set(['quilt_sync', 'quilt_history', 'quilt_list_files', 'quilt_read_file', 'quilt_project_rules', 'quilt_write_file'])
|
|
63
63
|
const AGENT = 'agent-mcp' // transaction origin
|
|
64
64
|
// The board's columns, from tasks.js: hosted agents move tasks to every one of them (QA included), like the local MCP.
|
|
65
65
|
const COLUMN_IDS_LIST = COLUMNS.map((c) => c.id)
|
|
@@ -135,7 +135,7 @@ const cleanPath = (p) => String(p || '').trim().replace(/^\.\//, '').replace(/^\
|
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* The tools every relay-hosted MCP offers, on whatever room `ctx.room()` gives now.
|
|
138
|
-
* ctx: { room(), me, who(), access(), tool(), warn() }: `who` is
|
|
138
|
+
* ctx: { room(), me, who(), access(), tool(), warn() }: `who` is the caller
|
|
139
139
|
* ({ name } or { name, id }), `access` the caller's role and folders, `warn` extra text
|
|
140
140
|
* for status, `withSession(fn)` runs a tool with the current room or explains why not.
|
|
141
141
|
*/
|
|
@@ -242,10 +242,6 @@ function sessionTools (server, ctx) {
|
|
|
242
242
|
for (const h of room.hostedOnline ? room.hostedOnline() : []) if (h.name !== me && !out.some((p) => p.name === h.name)) out.push({ name: h.name, kind: h.kind, tool: 'hosted', hosted: true })
|
|
243
243
|
return out
|
|
244
244
|
}
|
|
245
|
-
// Boxes (someone's unfinished work on a file) as people see them: an older app's AI session ("Dana · login", of: Dana) is its person.
|
|
246
|
-
const boxesOf = (room) => (room.boxList ? room.boxList(branchOf(room)) : []).map((c) => (c.of ? { ...c, by: c.of } : c))
|
|
247
|
-
// Boxes are per branch: who the agent is, on the branch it works on.
|
|
248
|
-
const who = (room) => ({ ...ctx.who(room), branch: branchOf(room) })
|
|
249
245
|
// The rules every agent is held to (duties.js), enforced here because hosted agents work through these tools.
|
|
250
246
|
const seen = (doc) => doc.getArray('chat').toArray().filter(visible)
|
|
251
247
|
// Messages this agent settled as needing no reply (quilt_inbox no_reply), kept with its inbox.
|
|
@@ -297,7 +293,7 @@ function sessionTools (server, ctx) {
|
|
|
297
293
|
})
|
|
298
294
|
|
|
299
295
|
tool('quilt_status', {
|
|
300
|
-
description: 'See who else is in the live session, what they and their AIs are doing, recent file changes
|
|
296
|
+
description: 'See who else is in the live session, what they and their AIs are doing, recent file changes and recent messages. Call this before starting a task.',
|
|
301
297
|
inputSchema: {}
|
|
302
298
|
}, (_, { room, doc, chat, activity }) => {
|
|
303
299
|
const a = ctx.access(room)
|
|
@@ -323,8 +319,6 @@ function sessionTools (server, ctx) {
|
|
|
323
319
|
if (agents.length) lines.push('', '## Agents and how Quilt wakes them', ...agents.map((m) => `- ${m.name}: ${m.wake || 'not known yet'}`))
|
|
324
320
|
const away = room.memberList ? room.memberList().filter((m) => m.away && m.name !== me && !ps.some((p) => p.name === m.name)) : []
|
|
325
321
|
if (away.length) lines.push('', '## Away (agents that work in turns, between turns: they read what you write at their next turn)', ...away.map((m) => `- ${m.name} (agent) · last here ${ago(m.lastSeen)}`))
|
|
326
|
-
const bxs = boxesOf(room)
|
|
327
|
-
if (bxs.length) lines.push('', '## Boxed work', ...bxs.map((c) => `- ${c.pattern}: ${c.by === me ? 'your unfinished work, in nobody else\'s folder until you commit it or quilt_unpack it' : `${c.by}'s unfinished work: not in anyone else's folder until they commit or unpack it`}`))
|
|
328
322
|
const acts = activity.toArray().filter(Boolean).slice(-12).reverse()
|
|
329
323
|
lines.push('', '## Recent file changes', ...(acts.length ? acts.map((x) => x.kind === 'pulled' ? `- ${x.by} pulled ${x.detail || 'commits'} (${ago(x.ts)})` : x.kind === 'brought' ? `- ${x.by} brought in ${x.detail || 'commits'}${x.branch ? ` on ${x.branch}` : ''} (${ago(x.ts)})` : x.kind === 'switched' ? `- ${x.by} switched to ${x.branch} (${ago(x.ts)})` : `- ${x.by} ${x.kind} ${x.path} (${ago(x.ts)})`) : ['- None yet.']))
|
|
330
324
|
const msgs = chat.toArray().filter(visible).slice(-8)
|
|
@@ -750,18 +744,14 @@ function sessionTools (server, ctx) {
|
|
|
750
744
|
})
|
|
751
745
|
|
|
752
746
|
tool('quilt_list_files', {
|
|
753
|
-
description: 'List the shared project files
|
|
747
|
+
description: 'List the shared project files.',
|
|
754
748
|
inputSchema: { under: z.string().optional().describe('Only files under this folder') }
|
|
755
749
|
}, async ({ under }, { room, files, blobs, branch }) => {
|
|
756
750
|
const pre = under ? cleanPath(under).replace(/\/+$/, '') + '/' : ''
|
|
757
|
-
const bx = new Map(boxesOf(room).map((c) => [c.pattern, c]))
|
|
758
751
|
let all
|
|
759
752
|
try { all = branch && isDiff(branch) ? [...(await listPaths(room, branch.key, branch)).keys()] : [...files.keys(), ...blobs.keys()] } catch (err) { return fail(err.message) }
|
|
760
753
|
const paths = [...new Set(all)].filter((p) => isSafeRelPath(p) && (!pre || p.startsWith(pre))).sort()
|
|
761
|
-
const shown = paths.slice(0, 500).map((p) => {
|
|
762
|
-
const c = bx.get(p)
|
|
763
|
-
return `- ${p}${c ? ` (boxed by ${c.by}: their unfinished work)` : ''}`
|
|
764
|
-
})
|
|
754
|
+
const shown = paths.slice(0, 500).map((p) => `- ${p}`)
|
|
765
755
|
return text(paths.length ? shown.join('\n') + (paths.length > 500 ? `\n… and ${paths.length - 500} more` : '') : 'No files.')
|
|
766
756
|
})
|
|
767
757
|
|
|
@@ -778,12 +768,10 @@ function sessionTools (server, ctx) {
|
|
|
778
768
|
}, async ({ path: p }, { room, files, blobs, branch }) => {
|
|
779
769
|
const rel = cleanPath(p)
|
|
780
770
|
if (!isSafeRelPath(rel)) return fail('That is not a path inside the project.')
|
|
781
|
-
const bx = boxesOf(room).find((c) => c.by !== me && c.pattern === rel)
|
|
782
|
-
const boxNote = bx ? `(Boxed by ${bx.by}: their unfinished work, not committed yet and in nobody else's folder. Don't build on it as if it were done; writing the file opens the box.)\n\n` : ''
|
|
783
771
|
// What this agent read is its next write's base (read-bases.js): the version goes in a block of its own, never in the file's text.
|
|
784
772
|
const shown = (s) => {
|
|
785
773
|
const version = readBasesOf(room).note(readerId(room), branch ? branch.key : '', rel, s)
|
|
786
|
-
const body =
|
|
774
|
+
const body = s.length > MAX_READ_CHARS ? s.slice(0, MAX_READ_CHARS) + `\n… (${s.length - MAX_READ_CHARS} more characters not shown)` : s
|
|
787
775
|
return { content: [{ type: 'text', text: body }, { type: 'text', text: `(Version ${version}: pass it to quilt_write_file as base.)` }] }
|
|
788
776
|
}
|
|
789
777
|
if (branch && isDiff(branch)) {
|
|
@@ -839,10 +827,6 @@ function sessionTools (server, ctx) {
|
|
|
839
827
|
if (diff && !hasEntry(branch, rel) && !branch.gone.has(rel)) {
|
|
840
828
|
try { const r = await readPath(room, branch.key, branch, rel); fromGit = r.kind === 'text' ? r.text : r.kind === 'binary' ? '' : null } catch (err) { return fail(err.message) }
|
|
841
829
|
}
|
|
842
|
-
// Someone else's unfinished work boxed on it: the write is never refused; the box opens, so their
|
|
843
|
-
// work and this change reach every folder together (the write merges with what the file has now).
|
|
844
|
-
const opened = boxesOf(room).find((c) => c.by !== me && c.pattern === rel)
|
|
845
|
-
if (opened) { try { room.boxRequest({ ...who(room), talk: ctx.access(room)?.talk !== false }, { op: 'unbox', pattern: rel, edit: true }); room.broadcastBoxes() } catch {} }
|
|
846
830
|
// The merge, in one step with the write (nothing awaits between them): what the file holds now, against
|
|
847
831
|
// the version this agent's content was made from. Same lines changed first keep theirs; this agent's are held.
|
|
848
832
|
const bases = readBasesOf(room)
|
|
@@ -887,28 +871,9 @@ function sessionTools (server, ctx) {
|
|
|
887
871
|
if (known.from === 'unknown') notes.push(`Quilt no longer has the version ${version ? `you gave as base (${String(version).slice(0, 12)})` : 'you last read'}, so your write was merged against ${typeof known.text === 'string' && known.text !== cur ? 'the oldest version it still has' : 'the file as it is'}. Read the file again before your next write, and give its version as base.`)
|
|
888
872
|
if (next !== content && !(merged && merged.held.length)) notes.push(`Others had changed ${rel} since you read it: their changes are kept alongside yours, so the file is not exactly what you wrote. Read it again before your next write.`)
|
|
889
873
|
notes.push(...notices)
|
|
890
|
-
return text(`${existed ? 'Updated' : 'Created'} ${rel}${onBranchNote(room, branch)}${detail ? ` (${detail} lines)` : ' (no change)'}. Everyone in the session has it now
|
|
874
|
+
return text(`${existed ? 'Updated' : 'Created'} ${rel}${onBranchNote(room, branch)}${detail ? ` (${detail} lines)` : ' (no change)'}. Everyone in the session has it now. (Version ${version2}: your next write's base.)${notes.length ? `\n\n${notes.join('\n\n')}` : ''}${context ? `\n\n${context}` : ''}`)
|
|
891
875
|
})
|
|
892
876
|
|
|
893
|
-
tool('quilt_unpack', {
|
|
894
|
-
description: 'Share boxed work before it is committed. Your writes stay in a box: everyone sees the change, but it is in nobody else\'s folder, so nobody else\'s git can commit it, until you commit it (quilt_git_commit). ' +
|
|
895
|
-
'Unpack when someone needs your change now: your boxed files reach everyone\'s folder, and you keep them. Decide this yourself; for a large, risky or critical change, or when the project\'s rules say so, ask your person first.',
|
|
896
|
-
inputSchema: { paths: z.array(z.string().min(1).max(500)).min(1).max(100).describe('Your boxed files, relative paths') }
|
|
897
|
-
}, ({ paths }, { room, doc }) => {
|
|
898
|
-
{ const w = waitRefusal(doc, 'quilt_unpack', room); if (w) return fail(w) }
|
|
899
|
-
const done = []
|
|
900
|
-
const not = []
|
|
901
|
-
for (const p of [...new Set(paths.map(cleanPath))]) {
|
|
902
|
-
const c = boxesOf(room).find((x) => x.pattern === p && x.by === me)
|
|
903
|
-
if (!c) { not.push(p); continue }
|
|
904
|
-
try { if (room.boxRequest(who(room), { op: 'unbox', pattern: p }).unboxed) done.push(p); else not.push(p) } catch { not.push(p) }
|
|
905
|
-
}
|
|
906
|
-
if (done.length) room.broadcastBoxes()
|
|
907
|
-
if (!done.length) return fail(`${not.join(', ')} ${not.length === 1 ? 'is' : 'are'} not boxed by you.`)
|
|
908
|
-
return text(`Unpacked ${done.join(', ')}: in everyone's folder now. Your next write to one boxes it again.${not.length ? ` Not boxed by you: ${not.join(', ')}.` : ''}`)
|
|
909
|
-
})
|
|
910
|
-
|
|
911
|
-
|
|
912
877
|
// `quilt sync` (npx heyquilt sync): a sandboxed agent's folder in one shot, its sync state kept
|
|
913
878
|
// here (relay-turn-sync.js). Hosted only: the CLI reaches it with the agent's QUILT_AGENT_KEY.
|
|
914
879
|
if (ctx.multi) {
|
|
@@ -965,9 +930,6 @@ function sessionTools (server, ctx) {
|
|
|
965
930
|
historyOf(room).record({ by: me, path: rel, kind, before, after, detail, task: currentTask(readTasks(taskMap(doc)), me) })
|
|
966
931
|
},
|
|
967
932
|
lastEditor: (rel) => lastWriter(room, activity, branch, rel),
|
|
968
|
-
// Others' boxes: their unfinished work stays out of this folder until this folder changes the file (relay-turn-sync.js).
|
|
969
|
-
ghosts: new Set(boxesOf(room).filter((c) => c.by !== me).map((c) => c.pattern)),
|
|
970
|
-
openBox: (rel) => { try { room.boxRequest({ ...who(room), talk: a?.talk !== false }, { op: 'unbox', pattern: rel, edit: true }); room.broadcastBoxes() } catch {} },
|
|
971
933
|
// A push is a live write: the same engine as every other (held conflicts for this agent to resolve).
|
|
972
934
|
rules: liveRules(room, files)
|
|
973
935
|
})
|
|
@@ -1327,9 +1289,6 @@ export async function handleHostedMcp ({ req, res, pass, relay, workspaces = nul
|
|
|
1327
1289
|
room.hostedSeen.delete(account)
|
|
1328
1290
|
room.forgetHostedBranch(account)
|
|
1329
1291
|
for (const [k, p] of room.pending) if (k.hosted && p.id === account) room.pending.delete(k)
|
|
1330
|
-
// Leaving opens its boxes: nobody else could commit them.
|
|
1331
|
-
room.dropBoxes((c) => c.byId === account)
|
|
1332
|
-
room.broadcastBoxes()
|
|
1333
1292
|
room.broadcastMembers()
|
|
1334
1293
|
}
|
|
1335
1294
|
const left = allRooms(h)
|
package/src/relay-prune.js
CHANGED
|
@@ -10,11 +10,10 @@ export const INACTIVE_MS = 7 * 24 * 60 * 60 * 1000
|
|
|
10
10
|
export const ARCHIVE_KEEP_MS = 30 * 24 * 60 * 60 * 1000
|
|
11
11
|
const TRUNKS = new Set(['main', 'master'])
|
|
12
12
|
|
|
13
|
-
/** Who is on which branch now: connected folders,
|
|
13
|
+
/** Who is on which branch now: connected folders, and hosted agents' choices of a branch worked on this week (chosenBranches). */
|
|
14
14
|
function inUse (room, now = Date.now()) {
|
|
15
15
|
const on = chosenBranches(room, now)
|
|
16
16
|
for (const ws of room.conns.keys()) if (ws.branch) on.add(ws.branch)
|
|
17
|
-
for (const c of Object.values(room.meta.boxes || {})) on.add(room.branchOf(c))
|
|
18
17
|
return on
|
|
19
18
|
}
|
|
20
19
|
|
package/src/relay-turn-sync.js
CHANGED
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
// changed the same lines the session keeps what landed first and the folder's lines are held for its
|
|
15
15
|
// writer (or any AI) to resolve (held.js, quilt_resolve_merge): the agent hears in the sync's answer
|
|
16
16
|
// (`held`), and its copy is kept aside in the folder. The newer edit no longer wins. The removed-name
|
|
17
|
-
// warning runs on it too. Nobody holds files
|
|
18
|
-
//
|
|
19
|
-
// an older relay held for someone ('claimed' records) go in at the agent's next sync (settleWaiting).
|
|
17
|
+
// warning runs on it too. Nobody holds files: versions an older relay held for someone ('claimed'
|
|
18
|
+
// records) go in at the agent's next sync (settleWaiting).
|
|
20
19
|
import fs from 'node:fs'
|
|
21
20
|
import path from 'node:path'
|
|
22
21
|
import zlib from 'node:zlib'
|
|
@@ -179,11 +178,8 @@ const heldOut = (r) => { const v = r.version || r; return { path: r.path, id: r.
|
|
|
179
178
|
* One step of a sync. `args`: { step, slot, files?, paths? }. `ctx`: { room, fdoc, files, blobs,
|
|
180
179
|
* branchKey, epoch, account, me, origin, globalRefusal(), pathRefusal(rel) -> { kind: 'aside' |
|
|
181
180
|
* 'keep', why } | null (access only: a viewer, outside its folders), record({ rel, kind, before, after, detail }),
|
|
182
|
-
* lastEditor(rel),
|
|
181
|
+
* lastEditor(rel), rules? }.
|
|
183
182
|
* `rules`: the live-write engine (live-merge.js LiveRules); else one on ctx.room's document.
|
|
184
|
-
* `ghosts`: the paths someone else has boxed (docs/superpowers/specs/2026-10-16-git-boxes-design.md): their
|
|
185
|
-
* unfinished work never reaches this folder. The folder sees each as it last had it (its checkpoint), or as it
|
|
186
|
-
* has it now. An edit to one is never refused: `openBox(rel)` opens the box, and the edit merges with the work in it.
|
|
187
183
|
* Returns the answer (a plain object, sent as JSON).
|
|
188
184
|
*/
|
|
189
185
|
export function turnSyncStep (args, ctx) {
|
|
@@ -194,28 +190,16 @@ export function turnSyncStep (args, ctx) {
|
|
|
194
190
|
const saved = all[ctx.branchKey]
|
|
195
191
|
// A checkpoint of an older document of this branch (removed and started again) says nothing about this one.
|
|
196
192
|
const checkpoint = saved && (saved.epoch || null) === (ctx.epoch || null) ? saved : null
|
|
197
|
-
const ghosts = ctx.ghosts instanceof Set ? ctx.ghosts : new Set()
|
|
198
193
|
// A diff branch says what it deleted (ctx.gone); a full one, by the entries Yjs remembers it had.
|
|
199
|
-
const deleted = (rel) => !
|
|
200
|
-
const
|
|
201
|
-
// The session as this folder may see it: someone else's box shows as the folder's own version.
|
|
202
|
-
const session = (local = null) => {
|
|
203
|
-
const out = sessionState(ctx.files, ctx.blobs, ctx.git)
|
|
204
|
-
for (const rel of ghosts) {
|
|
205
|
-
const cp = cpFiles[rel]
|
|
206
|
-
if (cp && HASH.test(String(cp.h || ''))) out.set(rel, sessionEntry(cp.h, { text: typeof cp.t === 'string' ? cp.t : null }))
|
|
207
|
-
else if (local && local[rel] && local[rel] !== SKIP) out.set(rel, sessionEntry(local[rel]))
|
|
208
|
-
else out.delete(rel)
|
|
209
|
-
}
|
|
210
|
-
return out
|
|
211
|
-
}
|
|
194
|
+
const deleted = (rel) => !ctx.files.has(rel) && !ctx.blobs.has(rel) && (ctx.git ? ctx.gone.has(rel) : (ctx.files._map.has(rel) || ctx.blobs._map.has(rel)))
|
|
195
|
+
const session = () => sessionState(ctx.files, ctx.blobs, ctx.git)
|
|
212
196
|
const step = args.step
|
|
213
197
|
|
|
214
198
|
if (step === 'plan') {
|
|
215
199
|
const local = cleanManifest(args.files)
|
|
216
200
|
// What an older relay kept waiting for a holder goes in first, so the plan already sees it.
|
|
217
|
-
const settled = settleWaiting(ctx
|
|
218
|
-
const p = planSync({ local, session: session(
|
|
201
|
+
const settled = settleWaiting(ctx)
|
|
202
|
+
const p = planSync({ local, session: session(), checkpoint, deleted })
|
|
219
203
|
const refused = p.upload.length || p.delete.length ? ctx.globalRefusal() : null
|
|
220
204
|
return { step, ...p, ...(settled.merged.length ? { settled: settled.merged } : {}), ...(settled.lost.length ? { lost: settled.lost } : {}), ...(settled.held.length ? { held: settled.held } : {}), ...(settled.warnings.length ? { warnings: settled.warnings } : {}), ...(refused ? { refused } : {}) }
|
|
221
205
|
}
|
|
@@ -226,20 +210,12 @@ export function turnSyncStep (args, ctx) {
|
|
|
226
210
|
const refusedAll = ctx.globalRefusal()
|
|
227
211
|
const first = !checkpoint
|
|
228
212
|
const base = (checkpoint && checkpoint.files) || {}
|
|
229
|
-
// Each path is only changed once, after it was looked at: one look at the session is enough
|
|
230
|
-
|
|
231
|
-
let state = session()
|
|
213
|
+
// Each path is only changed once, after it was looked at: one look at the session is enough.
|
|
214
|
+
const state = session()
|
|
232
215
|
for (const [rel, v] of Object.entries(args.files || {})) {
|
|
233
216
|
if (!isSafeRelPath(rel)) continue
|
|
234
217
|
const c = content(v)
|
|
235
218
|
if (!c) { out.skipped.push(rel); continue }
|
|
236
|
-
// Someone else's box this folder changed: it opens, so this change merges with the work in it (never refused).
|
|
237
|
-
if (ghosts.has(rel) && (c.gone || !cpFiles[rel] || c.hash !== cpFiles[rel].h)) {
|
|
238
|
-
if (!ctx.openBox) { out.kept.push({ path: rel, why: `${rel} is someone else's unfinished work` }); continue }
|
|
239
|
-
ctx.openBox(rel)
|
|
240
|
-
ghosts.delete(rel)
|
|
241
|
-
state = session()
|
|
242
|
-
}
|
|
243
219
|
const now = state.get(rel) || null
|
|
244
220
|
const d = decide({ local: c.gone ? null : c.hash, session: now, base: base[rel] || null, first, deleted: deleted(rel) })
|
|
245
221
|
if (d === 'same') continue
|
|
@@ -269,8 +245,6 @@ export function turnSyncStep (args, ctx) {
|
|
|
269
245
|
if (typeof rel !== 'string' || !isSafeRelPath(rel)) continue
|
|
270
246
|
const s = now.get(rel)
|
|
271
247
|
if (bytes >= MAX_PULL_BYTES) { more.push(rel); continue }
|
|
272
|
-
// Someone else's box: the folder's own last version when it has the text, else nothing (the folder keeps what it has).
|
|
273
|
-
if (ghosts.has(rel)) { if (s && typeof s.text === 'string') { files[rel] = { text: s.text, h: s.h }; bytes += s.text.length } continue }
|
|
274
248
|
if (!s) { files[rel] = { gone: true }; continue }
|
|
275
249
|
if (s.stored) { files[rel] = { stored: true }; continue }
|
|
276
250
|
if (typeof s.text === 'string') { files[rel] = { text: s.text, h: s.h }; bytes += s.text.length; continue }
|
|
@@ -486,13 +460,13 @@ function closeWaiting (rel, ctx, reason) {
|
|
|
486
460
|
* too long for the record, is only in the folder: it goes in with the folder's next push.
|
|
487
461
|
* Returns { merged, lost, held, warnings }.
|
|
488
462
|
*/
|
|
489
|
-
function settleWaiting (ctx
|
|
463
|
+
function settleWaiting (ctx) {
|
|
490
464
|
const res = { merged: [], lost: [], held: [], warnings: [] }
|
|
491
465
|
const mine = readMerges(ctx.fdoc.getMap('merges')).filter((m) => m.kind === 'claimed' && m.state === 'open' && m.by === ctx.me && (!m.byId || m.byId === ctx.account))
|
|
492
466
|
if (!mine.length || ctx.globalRefusal()) return res
|
|
493
467
|
for (const rec of mine) {
|
|
494
468
|
const rel = rec.path
|
|
495
|
-
if (
|
|
469
|
+
if (ctx.pathRefusal(rel)) continue // no longer ours to change
|
|
496
470
|
if (rec.binary || (rec.ours === null && !rec.oursDeleted)) continue
|
|
497
471
|
const now = sessionState(ctx.files, ctx.blobs, ctx.git).get(rel) || null
|
|
498
472
|
const holder = rec.claimedBy || rec.others[0] || 'someone'
|