heyquilt 0.3.170 → 0.3.172

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 (62) hide show
  1. package/RELEASES.md +30 -0
  2. package/bin/quilt.js +16 -9
  3. package/package.json +2 -2
  4. package/src/agent-task-workflow.js +2 -9
  5. package/src/base-pick.js +212 -0
  6. package/src/boxes.js +6 -7
  7. package/src/catchup.js +1 -1
  8. package/src/chat-links.js +1 -3
  9. package/src/connection.js +24 -5
  10. package/src/control.js +27 -20
  11. package/src/duties.js +32 -56
  12. package/src/github-commit.js +1 -1
  13. package/src/held.js +323 -0
  14. package/src/hooks.js +27 -66
  15. package/src/identity.js +1 -1
  16. package/src/inbox.js +5 -4
  17. package/src/key-cli.js +1 -1
  18. package/src/live-merge.js +599 -0
  19. package/src/mcp.js +57 -102
  20. package/src/merge3.js +65 -1
  21. package/src/now-summary.js +4 -6
  22. package/src/pathrules.js +1 -1
  23. package/src/persona.js +1 -1
  24. package/src/presence.js +2 -0
  25. package/src/protocol.js +2 -2
  26. package/src/read-bases.js +123 -0
  27. package/src/relay-ask.js +2 -2
  28. package/src/relay-live-write.js +179 -0
  29. package/src/relay-mcp.js +173 -212
  30. package/src/relay-prune.js +2 -2
  31. package/src/relay-turn-sync.js +146 -142
  32. package/src/runner.js +0 -2
  33. package/src/server.js +253 -375
  34. package/src/session-follow.js +3 -1
  35. package/src/session-quilt.js +2 -21
  36. package/src/session-seam.js +35 -7
  37. package/src/session.js +795 -553
  38. package/src/setup.js +15 -25
  39. package/src/source-live/bring-in.js +5 -5
  40. package/src/source-live/land.js +20 -3
  41. package/src/source-live/live-block.js +503 -52
  42. package/src/status.js +8 -12
  43. package/src/swap-in.js +81 -0
  44. package/src/textdiff.js +54 -0
  45. package/src/turn-sync-plan.js +6 -18
  46. package/src/turn-sync.js +28 -21
  47. package/src/ui/agent-guide.js +13 -13
  48. package/src/ui/app.css +19 -40
  49. package/src/ui/boxes.js +8 -16
  50. package/src/ui/common.js +1 -1
  51. package/src/ui/fileview.js +11 -15
  52. package/src/ui/loom-model.js +18 -16
  53. package/src/ui/loom.css +1 -2
  54. package/src/ui/loom.js +6 -6
  55. package/src/ui/rail-model.js +25 -64
  56. package/src/ui/rail.js +48 -60
  57. package/src/ui/seam-model.js +39 -3
  58. package/src/ui/session.js +36 -54
  59. package/src/ui/tree.js +22 -129
  60. package/src/ui-server.js +2 -6
  61. package/src/release-words.js +0 -18
  62. package/src/seam-claims.js +0 -53
package/RELEASES.md CHANGED
@@ -11,6 +11,36 @@ Format: `## <version> — <YYYY-MM-DD>`, an optional one-line summary, then bull
11
11
  Lead each bullet with a short bold phrase. Inline `code` and **bold** are rendered;
12
12
  nothing else is.
13
13
 
14
+ ## 0.3.172 — 2026-11-14
15
+
16
+ An editor's save is never replaced by a partner's change, new files merge like edits, and a deliberate edit of a partner's line goes in.
17
+
18
+ - **An editor's save is no longer replaced by a partner's change.** When Quilt is about to write a partner's change into your folder just as your editor saves the file (by renaming its own copy into place), Quilt now sees your save, leaves it in place, takes it in, and writes the partner's change on top of it. The file is never missing from its folder while this happens. In the rare case your save lands in the very last instant, Quilt tells you to save again. A new file arriving from the session is also never put over a file you made at that moment.
19
+ - **New files and git pulls merge like any other save.** A file you create, and the edits a git pull brings into your folder, now go to the session the same way your saves do: one at a time, in whole lines. When you and a partner create the same file at once, the first to land is kept and the other is held for its writer to resolve, instead of one silently replacing the other.
20
+ - **A deliberate edit of a partner's fresh line goes in.** Changing a line a partner just wrote is no longer held for confirmation because your version drops some of their words. Quilt holds your line only when your folder shows you never saw theirs: nobody read the file after their change was written into it, or your save was already on its way. Lines your stale save never touched simply take the partner's version, with nothing held.
21
+
22
+ ## 0.3.171 — 2026-11-13
23
+
24
+ Nobody holds files any more, and when two edits change the same lines, the first one to land stays and the second waits to be resolved.
25
+
26
+ - **Nobody holds files any more.** Quilt no longer claims a file when you or your AI edit it, never refuses or undoes an edit because someone else is working on that file, and nobody waits in a file queue. Edits merge as they arrive. The lock pills and the file queue are gone from the app, and the Loom shows who wrote each file lately instead. AI tools that still call `quilt_claim`, `quilt_release`, `quilt_request_file`, `quilt_handoff` or `quilt_withdraw_request` are told "Quilt holds no files" and nothing changes.
27
+ - **The newer edit no longer wins.** When two people (or their AIs) change the same lines at once, the file keeps the version that landed first and the second writer's lines are held back, never overwritten and never written into the file as conflict markers. Changes to different lines still all go in. Two names added to the same import line are still combined by themselves; two different words changed on one line, or two blocks added at one spot, are held like any other clash. This holds everywhere a write lands: your folder, an agent's `quilt sync` at the end of its turn, and a cloud agent's `quilt_write_file`.
28
+ - **Cloud agents' writes merge with what they read.** `quilt_read_file` now ends with the version it read, and `quilt_write_file` takes it as `base`, so a write keeps whatever others changed since. Without a base, Quilt uses the version that agent last read.
29
+ - **Open conflicts are never unseen.** Every held conflict is listed at the top of every Quilt answer, to every AI in the session, in `quilt_status` and on a card in the app, until it's resolved. The writer is asked first, but any AI can take it with `quilt_resolve_merge` (`theirs` drops the held lines, `mine` puts them in, `edited` says the file is already fixed). Resolving one twice is harmless. Nothing holds the file meanwhile.
30
+ - **A held conflict doesn't land until it's resolved.** In a session in Seam, committing or merging leaves out a file with an open held conflict and says how to resolve it; everything else lands as usual.
31
+ - **A stale write can't wipe out a partner's new lines.** A write that removes lines someone else added in the last 15 minutes (a tool writing the whole file from an older read) keeps those lines and asks its writer to confirm; removing them again goes through. The session's owner can change the 15 minutes in Session settings → Version control, or with `quilt session stale-write <minutes>` (0 turns it off).
32
+ - **Removing a name other files still use gets a warning.** Delete or rename `makeEnemy` while `game.js:291` still calls it, and your AI is told where, without anything being blocked.
33
+ - **A merge that breaks a file is held.** If combining two edits would leave a `.json` file that no longer parses, or a plain `.js` file that no longer compiles, the second write is held for its writer instead.
34
+ - **A conflict left open doesn't stay unseen.** If nobody resolves a held conflict in 4 hours, Quilt writes to the person whose change was held (for an AI, the person it works for); after a day, to the session's owner too. If an AI's fix of a file is held again twice, the conflict becomes a task on the board for its person and every AI is told to leave it to them.
35
+ - **Edits follow a moved file.** When someone moves a file (deletes it and adds the same text elsewhere), a partner's later edit to the old path goes into the new one.
36
+ - **Saves never go missing, however many people write at once.** Your folder now sends each save to the session as a write, which is merged against the version your folder last had, one at a time per file, and put into the shared file in whole lines. Quilt also never writes a partner's change over a save it hasn't taken in yet, including one that lands in the same instant, or one an editor is still writing. In a test with eight writers saving the same file several times a second, no edit was lost (before this, about 2 in 100 were).
37
+ - **Two saves of the same line at once never come out mixed.** Saved within a moment of each other, the line keeps the one that landed first, letter for letter, and the other is held for its writer, instead of the two being spliced together into a line nobody wrote.
38
+ - **A whole file written from an older read can't quietly replace a partner's line.** When a tool saves the whole file from what it read before a partner's change reached it, and its version of that line merely looks like theirs, the partner's line stays and the save's line is held for its writer to resolve.
39
+ - **Cloud agents running many loops on one key no longer overwrite each other.** The session keeps many recent versions of every file, whoever read them, so each write is merged against the version it really started from. A version it no longer has is never swapped for the latest: the write is merged as a stale one, keeping every line anyone added in the last few minutes, the agent's own included, and the agent is told.
40
+ - **Fewer false warnings about removed names, and a new one.** Names only in comments or quoted strings no longer count, and adding a use of a name a partner just removed from another file now gets a warning too. Nothing is ever blocked.
41
+ - **Small fixes.** A cloud agent whose change is held is no longer told "your folder has it now" (it has no folder), and `quilt_status` counts the files in your square rather than the branch you left.
42
+ - **Apps from before this release still work**, but their edits go in as before, without these guarantees, until they update.
43
+
14
44
  ## 0.3.170 — 2026-11-13
15
45
 
16
46
  - **Your folder is in Seam by itself.** A new session's folder no longer shows "∅ has no square yet" with a button to press: Quilt opens its square on its own (and tries again every minute if it can't), so your edits reach everyone from the start. Only if that keeps failing does the session say why, with **Try again now**.
package/bin/quilt.js CHANGED
@@ -27,10 +27,10 @@ Usage:
27
27
  quilt join <invite-link> Join a partner's session in this folder
28
28
  quilt sync [--dir <folder>] Agents in a sandbox: sync this folder with the session once and exit
29
29
  (needs QUILT_AGENT_KEY; run it at the start and end of every turn).
30
- With the key, status, messages, say, tasks, task, history, claim,
31
- release, focus, tool and mcp work too
30
+ With the key, status, messages, say, tasks, task, history,
31
+ focus, tool and mcp work too
32
32
  quilt setup Connect Claude Code / Cursor / others via MCP
33
- quilt status Show collaborators, claims, activity, chat
33
+ quilt status Show collaborators, boxed work, activity, chat
34
34
  quilt history [path] [--by name] [--since 2h] [--task id] [--diff] [-n 30]
35
35
  Who changed what, when, and for which task
36
36
  quilt chat Live chat (messages, DMs, files) in this terminal
@@ -49,10 +49,10 @@ Usage:
49
49
  Quilt's vault; it never sees a value
50
50
  quilt commit <message> In a session that is a quilt: commit the square this folder follows
51
51
  quilt focus <what you're doing> Tell collaborators what you're working on
52
- quilt claim <path|glob> [reason] Mark files as yours for now
53
- quilt release <path|glob|*> Release a claim
54
52
  quilt chat-link [name] [--minutes N] Owner: a link for a chat-only AI (ChatGPT, claude.ai, Grok); 10 minutes
55
53
  quilt chat-link extend <name> <minutes> Owner: keep a chat link working for that long from now
54
+ quilt session stale-write [minutes] How long a write may not remove lines someone else added (default 15;
55
+ the owner sets it, 0 turns it off); no minutes: show it
56
56
  quilt invite Print this session's invite code
57
57
  quilt workspace list|files|get|put|write|mkdir|mv|rm The workspace library (quilt workspace for help)
58
58
  quilt stop Shut down everything quilt is running (relay, app, syncs)
@@ -113,9 +113,8 @@ async function main () {
113
113
  case 'git-pre-push': return gitPrePushLeftover()
114
114
  case 'chat': return chat()
115
115
  case 'focus': return simple('/focus', { text: argv.join(' ') }, () => 'focus updated')
116
- case 'claim': return simple('/claim', { pattern: argv[0], note: argv.slice(1).join(' ') }, (r) =>
117
- `claimed ${argv[0]}` + (r.overlapping?.length ? `\nwarning: overlaps ${r.overlapping.map((c) => `${c.by}'s ${c.pattern}`).join(', ')}` : ''))
118
- case 'release': { const { releaseWords } = await import('../src/release-words.js'); return simple('/release', { pattern: argv[0] || '*' }, (r) => releaseWords(r)) }
116
+ // Quilt holds no files (no-holds, 2026-11-13): kept for one release so scripts that call them don't fail.
117
+ case 'claim': case 'release': { const { NO_HOLDS } = await import('../src/duties.js'); console.log(NO_HOLDS); return }
119
118
  case 'chat-link': {
120
119
  if (argv[0] === 'extend') {
121
120
  if (!argv[1] || !Number(argv[2])) fail('usage: quilt chat-link extend <name> <minutes>')
@@ -589,11 +588,19 @@ async function doSetup () {
589
588
  // the session's files into its squares (layout 3); --back returns it to its branches. `follow <folder>`
590
589
  // then makes that folder follow this branch's square live (session-follow.js).
591
590
  async function sessionCmd () {
591
+ // stale_write_minutes (held.js): how long a write may not remove lines someone else added; the owner sets it, 0 turns it off.
592
+ if (argv[0] === 'stale-write') {
593
+ const say = (r) => r.minutes ? `A write that removes lines someone else added in the last ${r.minutes} minute${r.minutes === 1 ? '' : 's'} is held for its writer to confirm.` : 'The stale-write check is off: a write may remove any lines.'
594
+ if (argv[1] === undefined) return simple('/stale-write', undefined, say, 'GET')
595
+ const n = Number(argv[1])
596
+ if (!/^\d+$/.test(argv[1]) || n > 1440) fail('Usage: quilt session stale-write [minutes] (0 to 1440; 0 turns the check off)')
597
+ return simple('/stale-write', { minutes: n }, say)
598
+ }
592
599
  if (argv[0] === 'follow') {
593
600
  if (!argv[1]) fail('Usage: quilt session follow <folder>')
594
601
  return simple('/quilt-follow', { dir: path.resolve(argv[1]) }, (r) => r.text)
595
602
  }
596
- if (argv[0] !== 'migrate') fail('Usage: quilt session migrate [--dry-run | --link-only | --switch | --back [--carried <square,...>] | --shadow <quilt> | --unshadow] | quilt session follow <folder>')
603
+ if (argv[0] !== 'migrate') fail('Usage: quilt session migrate [--dry-run | --link-only | --switch | --back [--carried <square,...>] | --shadow <quilt> | --unshadow] | quilt session follow <folder> | quilt session stale-write [minutes]')
597
604
  if (argv.includes('--dry-run')) return simple('/quilt-plan', {}, (r) => r.text)
598
605
  if (argv.includes('--shadow')) {
599
606
  const q = argv[argv.indexOf('--shadow') + 1]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.170",
3
+ "version": "0.3.172",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@fontsource/ibm-plex-mono": "^5.3.0",
39
39
  "@fontsource/poppins": "^5.3.0",
40
- "@heyquilt/seam": "0.237.313",
40
+ "@heyquilt/seam": "0.237.359",
41
41
  "@modelcontextprotocol/sdk": "^1.30.1",
42
42
  "@noble/hashes": "^2.4.0",
43
43
  "@supabase/supabase-js": "^2.117.2",
@@ -88,17 +88,15 @@ function agoText (ts, now) {
88
88
 
89
89
  /**
90
90
  * What an agent gets when it moves a ticket to In progress: the ticket, its files,
91
- * recent changes to them (from the chronology), who holds claims on them, the
92
- * workflow and the project's checks.
91
+ * recent changes to them (from the chronology), the workflow and the project's checks.
93
92
  * @param {object} o
94
93
  * @param {{id:string,title:string,files?:string[]}} o.task
95
94
  * @param {Array<{by:string,path:string,kind:string,detail?:string,ts:number,task?:{title:string}|null}>} [o.history] oldest first
96
- * @param {Array<{by:string,pattern:string,note?:string}>} [o.claims]
97
95
  * @param {string} [o.checklist]
98
96
  * @param {string} [o.me]
99
97
  * @param {number} [o.now]
100
98
  */
101
- export function pickupBrief ({ task, history = [], claims = [], checklist = '', me = '', now = Date.now(), workflow = TASK_WORKFLOW }) {
99
+ export function pickupBrief ({ task, history = [], checklist = '', me = '', now = Date.now(), workflow = TASK_WORKFLOW }) {
102
100
  const files = task?.files || []
103
101
  const lines = [`Picked up "${task?.title || 'this ticket'}" [${task?.id || ''}].`]
104
102
  lines.push(files.length ? `Files: ${files.join(', ')}` : 'Files: none listed. Add them with quilt_assign_task once you know which you will touch.')
@@ -119,11 +117,6 @@ export function pickupBrief ({ task, history = [], claims = [], checklist = '',
119
117
  lines.push('', 'Comments on the task (latest last):')
120
118
  for (const c of comments) lines.push(`- ${c.by === me ? 'you' : c.by} [${agoText(c.ts, now)}]: ${String(c.text).replace(/\n/g, '\n ')}`)
121
119
  }
122
- const others = claims.filter((c) => c.by !== me)
123
- if (others.length) {
124
- lines.push('', 'Claims to respect (ask for the file with quilt_request_file instead of editing it):')
125
- for (const c of others) lines.push(`- ${c.pattern} by ${c.by}${c.note ? ` (${c.note})` : ''}`)
126
- }
127
120
  lines.push('', workflow, '', checklistBlock(checklist))
128
121
  return lines.join('\n')
129
122
  }
@@ -0,0 +1,212 @@
1
+ // Which version a save on disk was made from. A folder's last synced text is the usual base of a save,
2
+ // but an editor or AI that read the file before a partner's change reached disk saves a whole file made
3
+ // from the older version: taken against the newer one, its line would replace the partner's line as if
4
+ // it were an edit of it (2026-11-14: two saves of one line within a second, the second silently kept).
5
+ //
6
+ // So a folder keeps, for each path, the texts a partner's change was lately written over on its disk
7
+ // (since its own last save there), with proof of who read the file Quilt wrote: a save is merged against
8
+ // an older text only when its writer never saw the newer one, and that is shown by the disk, never
9
+ // guessed from what the save looks like (a deliberate edit of a partner's line, however much of it it
10
+ // changes, is an edit of it):
11
+ //
12
+ // - Quilt keeps the file it wrote open (keepWritten), and when it next looks at the path it asks whether
13
+ // anyone read that file since it was written (its access time; Linux's relatime and macOS update it on
14
+ // the first read after a change, `atimeWorks` checks this file system does). Quilt never reads its own
15
+ // unchanged write (session.js ingest, live-block.js diskChanges), so a read is someone else's: an
16
+ // editor reloading it, an AI reading it, or a tool (git) looking at it. Nobody read it: the save that
17
+ // is there now was made from what the file had before (`unseen`). Read: the writer may have seen it
18
+ // (`seen`), and the save is an edit of it.
19
+ // - A save that took the path in a file of its own made before Quilt's file was (its birth time) was
20
+ // made before Quilt's write: `unseen`, whatever read Quilt's file since.
21
+ // - A save that landed in the file Quilt replaced (session.js rescueSave, live-block.js rescue) is marked
22
+ // as made from the text before (`mark`).
23
+ //
24
+ // Where the disk cannot tell (a file system that does not keep access times, Windows, a file Quilt wrote
25
+ // before it could keep it open, or one Quilt read itself), nothing is proven: the save is merged against
26
+ // the last synced text, and the folder does not vouch for it (`sure` false), so the relay's own check of a
27
+ // stale write applies (live-merge.js editsOlder). Where it can, the folder vouches (`seen` on the write)
28
+ // and the relay holds nothing for looking like an older read.
29
+ //
30
+ // The folder's own saves never make a candidate (`forget`), so saving one line again and again is never
31
+ // held against itself. Choosing an older version than the save was made from loses nothing: what the save
32
+ // shares with the newer one is the same change on both sides of the merge.
33
+ import fs from 'node:fs'
34
+ import path from 'node:path'
35
+ import crypto from 'node:crypto'
36
+ import { diffLines as diffIndices } from './textdiff.js'
37
+
38
+ /** How long, and how many, texts a folder keeps per path as possible bases (as long as the stale-write window). */
39
+ export const RECENT_MS = 15 * 60 * 1000
40
+ export const RECENT_MAX = 6
41
+ /** Texts past this are not kept (too long to merge against twice). */
42
+ export const RECENT_TEXT = 256 * 1024
43
+ /** Files Quilt wrote kept open at once, across paths, waiting for the next look (past it the oldest are closed: no proof for those). */
44
+ export const MAX_KEPT = 64
45
+
46
+ const lines = (s) => String(s).split('\n')
47
+
48
+ /** How many lines `a` and `b` differ by (each changed, added or removed line counts once on each side). */
49
+ export function lineDistance (a, b) {
50
+ if (a === b) return 0
51
+ let n = 0
52
+ for (const h of diffIndices(lines(a), lines(b))) n += h.buffer1[1] + h.buffer2[1]
53
+ return n
54
+ }
55
+
56
+ const probed = new Map() // device -> whether a read moves the access time there
57
+
58
+ /**
59
+ * Whether reading a file on `dir`'s file system moves its access time (once per device): a file of
60
+ * Quilt's own is written, read, and looked at again. False on Windows, and where atime is not kept.
61
+ */
62
+ export function atimeWorks (dir) {
63
+ if (process.platform === 'win32') return false
64
+ let dev
65
+ try { dev = fs.statSync(dir).dev } catch { return false }
66
+ if (probed.has(dev)) return probed.get(dev)
67
+ let ok = false
68
+ const f = path.join(dir, `.atime-${process.pid}-${crypto.randomBytes(4).toString('hex')}.quilt-tmp`)
69
+ try {
70
+ fs.writeFileSync(f, 'quilt')
71
+ const a = fs.statSync(f).atimeMs
72
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3) // a clock tick, so a moved time shows
73
+ fs.readFileSync(f)
74
+ ok = fs.statSync(f).atimeMs > a
75
+ } catch {} finally { try { fs.rmSync(f, { force: true }) } catch {} }
76
+ probed.set(dev, ok)
77
+ return ok
78
+ }
79
+
80
+ /**
81
+ * The finished file `tmp` Quilt is about to put in place, kept open (opening it reads nothing) so that who
82
+ * read it after it took its place can be asked even once a save has replaced it: { fd, ino, dev, atimeMs,
83
+ * birthtimeMs, size, mtimeMs }, or null.
84
+ */
85
+ export function keepWritten (tmp) {
86
+ let fd = null
87
+ try {
88
+ fd = fs.openSync(tmp, 'r')
89
+ const st = fs.fstatSync(fd)
90
+ return { fd, ino: st.ino, dev: st.dev, atimeMs: st.atimeMs, birthtimeMs: st.birthtimeMs || 0, size: st.size, mtimeMs: st.mtimeMs }
91
+ } catch {
92
+ if (fd !== null) { try { fs.closeSync(fd) } catch {} }
93
+ return null
94
+ }
95
+ }
96
+
97
+ /** Closes a kept file (keepWritten). */
98
+ export function letGo (w) {
99
+ if (w && w.fd !== null && w.fd !== undefined) { try { fs.closeSync(w.fd) } catch {} w.fd = null }
100
+ }
101
+
102
+ export class RecentTexts {
103
+ constructor ({ ms = RECENT_MS, max = RECENT_MAX, kept = MAX_KEPT } = {}) {
104
+ this.ms = ms
105
+ this.max = max
106
+ this.kept = kept
107
+ this.map = new Map() // path -> [{ text, ts, wrote, verdict }], newest last
108
+ this.marks = new Map() // path -> { text, base }: a rescued save, made from base
109
+ }
110
+
111
+ /**
112
+ * `text` was on disk at `p` when a partner's change was written over it; `wrote` is the file Quilt put
113
+ * there (keepWritten), or null when it could not keep it (nothing is proven for this write then).
114
+ */
115
+ note (p, text, wrote = null, now = Date.now()) {
116
+ if (typeof text !== 'string' || text.length > RECENT_TEXT) { letGo(wrote); this.forget(p); return }
117
+ const list = (this.map.get(p) || []).filter((v) => {
118
+ const keep = now - v.ts <= this.ms && v.text !== text
119
+ if (!keep) letGo(v.wrote)
120
+ return keep
121
+ })
122
+ list.push({ text, ts: now, wrote: wrote || null, verdict: wrote ? null : 'unknown' })
123
+ while (list.length > this.max) letGo(list.shift().wrote)
124
+ this.map.set(p, list)
125
+ if (this.map.size > 2000) this.forget(this.map.keys().next().value)
126
+ this.limitKept()
127
+ }
128
+
129
+ /** Past `kept` files held open, the oldest are closed (their writes prove nothing any more). */
130
+ limitKept () {
131
+ const open = []
132
+ for (const list of this.map.values()) for (const v of list) if (v.wrote && v.wrote.fd !== null) open.push(v)
133
+ if (open.length <= this.kept) return
134
+ open.sort((a, b) => a.ts - b.ts)
135
+ for (const v of open.slice(0, open.length - this.kept)) { letGo(v.wrote); if (!v.verdict) v.verdict = 'unknown' }
136
+ }
137
+
138
+ has (p) { return this.map.has(p) || this.marks.has(p) }
139
+
140
+ /**
141
+ * Quilt is about to read the file at `p` (`st`: its lstat, taken before the read): for each write not
142
+ * judged yet, did its writer see it? Asked now, before Quilt's own read moves the access time. Quilt
143
+ * reading its own write unchanged spends the proof (`unknown`).
144
+ */
145
+ look (p, st, { atime = true } = {}) {
146
+ for (const v of this.map.get(p) || []) {
147
+ if (v.verdict) continue
148
+ v.verdict = judge(v.wrote, st, atime)
149
+ letGo(v.wrote)
150
+ }
151
+ }
152
+
153
+ /** A save of `p` with exactly `text` was made from `base` (it landed in the file Quilt replaced). */
154
+ mark (p, text, base) {
155
+ if (typeof text === 'string' && typeof base === 'string') this.marks.set(p, { text, base })
156
+ }
157
+
158
+ /** A save of this folder's at `p` was taken in: the texts before it are no save's base any more. */
159
+ forget (p) {
160
+ for (const v of this.map.get(p) || []) letGo(v.wrote)
161
+ this.map.delete(p)
162
+ this.marks.delete(p)
163
+ }
164
+
165
+ /** Closes every kept file (the folder stops). */
166
+ close () { for (const p of [...this.map.keys()]) this.forget(p) }
167
+
168
+ fresh (p, current, now) {
169
+ return (this.map.get(p) || []).filter((v) => now - v.ts <= this.ms && v.text !== current)
170
+ }
171
+
172
+ /**
173
+ * The base to merge a save `text` of `p` against: `current` (the last synced text), or the text before
174
+ * the partner's changes its writer is shown never to have seen (newest first: each write written over a
175
+ * text the writer never read past steps the base back one).
176
+ */
177
+ pick (p, current, text, now = Date.now()) {
178
+ const mk = this.marks.get(p)
179
+ if (mk && mk.text === text) return mk.base
180
+ if (typeof current !== 'string' || typeof text !== 'string' || text.length > RECENT_TEXT || current.length > RECENT_TEXT) return current
181
+ const older = this.fresh(p, current, now)
182
+ let base = current
183
+ for (let i = older.length - 1; i >= 0 && older[i].verdict === 'unseen'; i--) base = older[i].text
184
+ return base
185
+ }
186
+
187
+ /**
188
+ * Whether the folder vouches for a save of `p` merged against what pick gave: it could tell, for every
189
+ * partner's change written here lately, whether its writer saw it (none is `unknown`). `on`: this
190
+ * folder's disk keeps access times (atimeWorks).
191
+ */
192
+ sure (p, current, on, now = Date.now()) {
193
+ if (!on) return false
194
+ return this.fresh(p, current, now).every((v) => v.verdict === 'seen' || v.verdict === 'unseen')
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Whether the save now at the path (`st`) was made without seeing the file Quilt wrote (`w`): 'unseen',
200
+ * 'seen' or 'unknown'.
201
+ */
202
+ function judge (w, st, atime) {
203
+ if (!w) return 'unknown'
204
+ // A file of its own, made before Quilt's was: prepared before Quilt wrote.
205
+ if (st && (st.ino !== w.ino || st.dev !== w.dev) && st.birthtimeMs > 0 && w.birthtimeMs > 0 && st.birthtimeMs < w.birthtimeMs) return 'unseen'
206
+ if (!atime || w.fd === null || w.fd === undefined) return 'unknown'
207
+ let now
208
+ try { now = fs.fstatSync(w.fd) } catch { return 'unknown' }
209
+ // Quilt's own write, as written: nobody saved, and Quilt reading it now would read it itself.
210
+ if (st && st.ino === w.ino && st.dev === w.dev && st.size === w.size && st.mtimeMs === w.mtimeMs) return 'unknown'
211
+ return now.atimeMs === w.atimeMs ? 'unseen' : 'seen'
212
+ }
package/src/boxes.js CHANGED
@@ -10,7 +10,7 @@ const textOf = (v) => (v == null || isBin(v) ? '' : String(v))
10
10
  * One box for the app. `before` and `after` are the file's text, null (no file) or { binary: true }.
11
11
  * The diff is capped as history's are; added and removed count every line all the same.
12
12
  */
13
- export function boxEntry ({ claim, mine = false, before = null, after = null }) {
13
+ export function boxEntry ({ box, mine = false, before = null, after = null }) {
14
14
  const kind = before == null && after != null ? 'new' : after == null && before != null ? 'deleted' : isBin(before) || isBin(after) ? 'binary' : 'edited'
15
15
  let added = 0
16
16
  let removed = 0
@@ -23,15 +23,14 @@ export function boxEntry ({ claim, mine = false, before = null, after = null })
23
23
  }
24
24
  }
25
25
  return {
26
- path: claim.pattern,
27
- by: claim.by,
28
- ...(claim.of ? { of: claim.of } : {}),
29
- ts: claim.ts || 0,
26
+ path: box.pattern,
27
+ by: box.by,
28
+ ...(box.of ? { of: box.of } : {}),
29
+ ts: box.ts || 0,
30
30
  mine: !!mine,
31
31
  kind,
32
32
  added,
33
33
  removed,
34
- diff,
35
- queue: Array.isArray(claim.queue) ? claim.queue.map((r) => ({ id: r.id, by: r.by })) : []
34
+ diff
36
35
  }
37
36
  }
package/src/catchup.js CHANGED
@@ -104,7 +104,7 @@ export function catchUpMarkdown (c, { ago = () => '' } = {}) {
104
104
  const m = c.mine || {}
105
105
  if (m.shared) out.push(`- Your ${plural(m.shared, 'change')} from while you were away went into the session.`)
106
106
  if (m.merged?.length) out.push(`- Combined with the session's changes: ${m.merged.map((p) => `\`${p}\``).join(', ')}.`)
107
- if (m.conflicts?.length) out.push(`- Held by someone else, so waiting: Quilt merges your changes in when they let go of ${m.conflicts.map((p) => `\`${p}\``).join(', ')}.`)
107
+ if (m.conflicts?.length) out.push(`- Could not be merged, so your copy was kept in .quilt/conflicts and the session's is on disk: ${m.conflicts.map((p) => `\`${p}\``).join(', ')}.`)
108
108
  if (c.backups?.length) out.push(`- Your copies of ${plural(c.backups.length, 'file')} differed from the session's and were replaced; they are kept: ${c.backups.map((b) => `\`${b.path}\` → \`${b.copy}\``).join(', ')}.`)
109
109
  out.push('Read quilt_history for the diffs before you change these files.')
110
110
  return out
package/src/chat-links.js CHANGED
@@ -25,7 +25,7 @@ import dns from 'node:dns'
25
25
  import https from 'node:https'
26
26
  import net from 'node:net'
27
27
  import * as Y from 'yjs'
28
- import { globMatcher, isSafeRelPath } from './pathrules.js'
28
+ import { isSafeRelPath } from './pathrules.js'
29
29
  import { readTasks, addTask, updateTask, formatTasks, columnName, COLUMNS, COLUMN_IDS, assignmentFields } from './tasks.js'
30
30
  import { readComments, addComment, withComments, formatTaskDetails, MAX_COMMENT } from './task-comments.js'
31
31
  import { qaNotesEnough, qaRefusal, verifiedEnough, doneRefusal, pickChecklist } from './agent-task-workflow.js'
@@ -880,8 +880,6 @@ class ChatPage {
880
880
  if (there) return { code: 409, body: `${rel} already exists, and chat links only add new files. Pick another name.` }
881
881
  const refusal = changeRefusal(this.access, rel)
882
882
  if (refusal) return { code: 403, body: `The session owner says ${refusal}.` }
883
- const claim = (this.room.claimList ? this.room.claimList(this.branch.key) : []).find((c) => c.by !== this.me && globMatcher(c.pattern)(rel))
884
- if (claim) return { code: 409, body: `${rel} is in ${claim.pattern}, which ${claim.by} has claimed${claim.note ? ` (${claim.note})` : ''}. Put it somewhere else, or ask them with the "say" link.` }
885
883
  if (this.writable()) return { code: 403, body: this.writable() }
886
884
  return this.branchFull() ? { code: 403, body: this.branchFull() } : null
887
885
  }
package/src/connection.js CHANGED
@@ -395,7 +395,9 @@ export class Connection extends EventEmitter {
395
395
  this.noteSynced()
396
396
  }
397
397
  } else if (type === MSG_BRANCHES) {
398
- const { branches, reply, pushed, quilt, shadow, readOnly, moving, force, importing } = JSON.parse(decoding.readVarString(dec))
398
+ const { branches, reply, pushed, quilt, shadow, readOnly, moving, force, importing, writes } = JSON.parse(decoding.readVarString(dec))
399
+ // The relay takes folders' live writes (relay-live-write.js): text edits go to it as writes, not as edits of the text.
400
+ if (Array.isArray(branches)) this.relayWrites = writes === 1
399
401
  // "Make this a quilt" on a session with a git remote: Seam imports it ({ slug, repo }), or null.
400
402
  const im = importing && typeof importing.repo === 'string' ? { slug: String(importing.slug || ''), repo: importing.repo } : null
401
403
  if (JSON.stringify(im) !== JSON.stringify(this.importing || null)) { this.importing = im; this.emit('importing', im) }
@@ -456,9 +458,10 @@ export class Connection extends EventEmitter {
456
458
  this.emit('members', msg)
457
459
  this.settle(msg.reply, 'request refused')
458
460
  } else if (type === MSG_CLAIMS) {
461
+ // The room's boxes (the field keeps its old name): Quilt holds no files, so only boxes come here.
459
462
  const { claims, reply } = JSON.parse(decoding.readVarString(dec))
460
- this.emit('claims', claims)
461
- this.settle(reply, 'claim refused')
463
+ this.emit('boxes', claims)
464
+ this.settle(reply, 'box refused')
462
465
  }
463
466
  }
464
467
 
@@ -515,6 +518,22 @@ export class Connection extends EventEmitter {
515
518
  /** Any other branch request (remove). */
516
519
  branchRequest (req, { timeoutMs = REQUEST_TIMEOUT_MS } = {}) { return this.request(MSG_BRANCH, req, 'branch changes', null, timeoutMs) }
517
520
 
521
+ /**
522
+ * A live write of one text file (relay-live-write.js): `{ path, base, baseText?, text, mode?, at?, trusted? }`
523
+ * on the branch this connection is on. Resolves with the relay's reply; asks again with the base's text
524
+ * (`baseOf()`, or `retry` when there is none) when the relay doesn't know the base.
525
+ */
526
+ async liveWrite (req, { baseOf = null, timeoutMs = REQUEST_TIMEOUT_MS } = {}) {
527
+ if (this.branchKey === null) throw new Error('not on a branch')
528
+ let r = await this.branchRequest({ op: 'live-write', branch: this.branchKey, ...req }, { timeoutMs })
529
+ if (r.needBase) {
530
+ const t = baseOf ? baseOf() : null
531
+ r = await this.branchRequest({ op: 'live-write', branch: this.branchKey, ...req, ...(typeof t === 'string' ? { baseText: t } : { retry: true }) }, { timeoutMs })
532
+ if (r.needBase) r = await this.branchRequest({ op: 'live-write', branch: this.branchKey, ...req, retry: true }, { timeoutMs })
533
+ }
534
+ return r
535
+ }
536
+
518
537
  waitForBranchSync () {
519
538
  if (this.branchSynced) return Promise.resolve()
520
539
  return new Promise((resolve, reject) => {
@@ -552,8 +571,8 @@ export class Connection extends EventEmitter {
552
571
  })
553
572
  }
554
573
 
555
- /** Asks the relay to claim or release; resolves with its reply. Claims need a live connection. */
556
- claimRequest (req) { return this.request(MSG_CLAIM, req, 'claims') }
574
+ /** Asks the relay to box or unbox a file; resolves with its reply. Needs a live connection. */
575
+ boxRequest (req) { return this.request(MSG_CLAIM, req, 'boxes') }
557
576
 
558
577
  /** Approve / deny / change / remove someone, or set who may admit (relay enforces who may). */
559
578
  adminRequest (req, { timeoutMs } = {}) { return this.request(MSG_ADMIN, req, 'changes to who is in the session', null, timeoutMs) }
package/src/control.js CHANGED
@@ -6,6 +6,7 @@ import fs from 'node:fs'
6
6
  import path from 'node:path'
7
7
  import crypto from 'node:crypto'
8
8
  import { renderStatus } from './status.js'
9
+ import { NO_HOLDS } from './duties.js'
9
10
  import { migrateDir } from './legacy.js'
10
11
  import { createRun, waitRun, endRun, secretNames, apiCall } from './secrets-client.js'
11
12
  import { runMailTool, MAIL_TOOLS } from './mail-tools.js'
@@ -78,10 +79,17 @@ export async function startControl (session, extras = {}) {
78
79
  shareWithPeople(c.client, q.id, square, session.members || []).catch(() => shared.delete(square))
79
80
  }
80
81
  const next = at ? async () => session.conn.branchRequest({ op: 'quilt-next', token: c.token, branch }, { timeoutMs: QUILT_MOVE_TIMEOUT_MS }) : null
81
- return runSessionSeamTool(String(b.tool || ''), b.args || {}, { client: c.client, quilt: q.id, square, live, next, branch })
82
+ // Open held conflicts (held.js) keep their paths from landing until they are resolved.
83
+ return runSessionSeamTool(String(b.tool || ''), b.args || {}, { client: c.client, quilt: q.id, square, live, next, branch, held: () => (session.heldList ? session.heldList() : []) })
82
84
  }
83
85
  // The app's square panel (ui-server.js) commits and merges through the same tools, as the same member.
84
86
  session.seamTool = seamTool
87
+ // Every open held conflict in the session (held.js), whoever's, first among the notices every MCP answer
88
+ // starts with (an older `quilt mcp` too), until someone resolves it. Not taken: said again each time.
89
+ const heldFirst = (b) => {
90
+ const text = session.heldNotice ? session.heldNotice(session.actorName ? session.actorName(b && b.via ? String(b.via) : null) : session.name) : ''
91
+ return text ? [text] : []
92
+ }
85
93
  const routes = {
86
94
  'GET /status': (b) => {
87
95
  // To one of the AI sessions working through this app, "you" is that session (persona.js).
@@ -113,31 +121,24 @@ export async function startControl (session, extras = {}) {
113
121
  else session.setFocus(b.text)
114
122
  return { ok: true }
115
123
  },
116
- 'POST /claim': (b) => session.claim(b.pattern, b.note, b.via),
124
+ // Quilt holds no files (no-holds, 2026-11-13): the claim routes an older `quilt mcp` or hook may still call answer that, and change nothing.
125
+ 'POST /claim': () => ({ ok: true, note: NO_HOLDS }),
117
126
  // What this person's AI should hear (an edit of its that Quilt undone); handed over once.
118
127
  'POST /notices': async (b) => {
119
128
  const notices = session.takeNotices(b && b.via ? String(b.via) : null)
120
129
  const remind = await wake.reminder()
121
- return { notices: remind ? [...notices, remind] : notices }
130
+ return { notices: [...heldFirst(b), ...notices, ...(remind ? [remind] : [])] }
122
131
  },
123
- 'POST /release': (b) => session.releaseReport(b.pattern, b.via),
132
+ 'POST /release': () => ({ released: 0, note: NO_HOLDS }),
124
133
  'POST /unpack': (b) => session.unpack(b.paths, b.via),
125
- // The file queue: ask for a file someone holds, hand one we hold to someone waiting, take a request back.
126
- 'POST /request-file': (b) => session.requestFile(b.path, { title: b.title, description: b.description, task: b.task, via: b.via }),
127
- 'POST /handoff': (b) => session.handoff(b.path, { to: b.to, context: b.context, via: b.via }),
128
- 'POST /withdraw-request': async (b) => ({ withdrawn: await session.withdrawRequest(b.request, b.via) }),
129
- // Who owns one path (the hooks ask before every edit). `shared` is false for paths Quilt doesn't sync.
130
- 'POST /claim-for': (b) => {
131
- const rel = String(b.path || '').replace(/\\/g, '/').replace(/^\.\//, '')
132
- const shared = session.syncable(rel)
133
- const c = shared ? session.claimFor(rel) : null
134
- const me = session.actorName(b.via)
135
- return { path: rel, shared, claim: c ? { by: c.by, pattern: c.pattern, note: c.note, queue: c.queue || [] } : null, mine: !!c && c.by === me, me, focus: session.focus || '' }
136
- },
137
- // Before an agent changes files (any tool): is each one ours to edit (free ones are claimed for
138
- // us), and what did people ask about them? See Session.prepareEdit and duties.js.
134
+ 'POST /request-file': () => ({ ok: true, note: NO_HOLDS }),
135
+ 'POST /handoff': () => ({ ok: true, note: NO_HOLDS }),
136
+ 'POST /withdraw-request': () => ({ withdrawn: 0, note: NO_HOLDS }),
137
+ 'POST /claim-for': (b) => ({ path: String(b.path || ''), shared: session.syncable(String(b.path || '').replace(/\\/g, '/').replace(/^\.\//, '')), claim: null, mine: false, me: session.actorName(b.via), focus: session.focus || '' }),
138
+ // Before an agent changes files (any tool): who else changed them lately, and what did people say
139
+ // about them? It never refuses (Session.prepareEdit, duties.js).
139
140
  'POST /before-edit': (b) => session.prepareEdit(Array.isArray(b.paths) ? b.paths.slice(0, 100) : [], b.via),
140
- // An agent finished a piece of work: let go of the claims that followed its edits.
141
+ // An agent finished a piece of work.
141
142
  'POST /finish': (b) => session.finishEditing(b.via),
142
143
  // Who is waiting for an answer from this member (or AI session): the MCP and the hooks refuse to move work on until there's none.
143
144
  'GET /duties': (b) => session.duties(b.via),
@@ -210,7 +211,7 @@ export async function startControl (session, extras = {}) {
210
211
  if (task && (b.column === 'doing' || b.column === 'done')) session.stitchClock(b.via, b.column === 'doing')
211
212
  return { task, tasks: session.taskList() }
212
213
  },
213
- // What an agent gets when it picks a task up: history for its files, claims, the project's checks.
214
+ // What an agent gets when it picks a task up: history for its files, the project's checks.
214
215
  'POST /tasks/brief': (b) => session.taskBrief(b.id),
215
216
  'POST /tasks/comment': (b) => {
216
217
  const r = session.commentTask(b)
@@ -220,6 +221,12 @@ export async function startControl (session, extras = {}) {
220
221
  },
221
222
  'POST /tasks/delete': (b) => { session.deleteTask(b.id); return { tasks: session.taskList() } },
222
223
  'GET /rules': () => ({ text: session.projectRulesText() }),
224
+ // Held conflicts (held.js): the list (quilt_resolve_merge without a how), and resolving one { ref, how } (any member, any conflict).
225
+ 'GET /held': () => ({ held: session.heldList ? session.heldList() : [] }),
226
+ 'POST /resolve-merge': (b) => session.resolveHeld({ ref: String(b.ref || ''), how: String(b.how || ''), via: b.via ? String(b.via) : null }),
227
+ // The session's stale_write_minutes (Seam's 07): { minutes }; only the owner sets it.
228
+ 'GET /stale-write': () => session.staleWrite(),
229
+ 'POST /stale-write': (b) => session.setStaleWrite(b.minutes),
223
230
  // Secrets (`quilt run`, quilt_secret_names): asked of the API as this session's own identity
224
231
  // (its person, or the agent it runs as). Run tokens and names only: never a value.
225
232
  'POST /secrets/run': async (b) => createRun(await secretsApi(), { room: session.room, label: String(b.label || '').slice(0, 200) }),