@bli-cockpit/cli 0.2.292 → 0.2.294

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 (69) hide show
  1. package/dist/adapters/claude-attribution-discovery.js +22 -0
  2. package/dist/adapters/claude-attribution-memoized-reads.js +3 -3
  3. package/dist/adapters/claude-attribution.js +5 -2
  4. package/dist/adapters/codex-attribution-memoized-reads.js +3 -3
  5. package/dist/adapters/codex-attribution.js +51 -12
  6. package/dist/adapters/codex-segment-discovery.js +75 -0
  7. package/dist/adapters/codex-session-revision.js +194 -0
  8. package/dist/adapters/codex-session-signals.js +2 -2
  9. package/dist/adapters/local-sources.js +1 -0
  10. package/dist/adapters/opencode-store.js +201 -0
  11. package/dist/adapters/pi-session-facts.js +28 -0
  12. package/dist/adapters/pi-session-reader.js +132 -0
  13. package/dist/adapters/raw-evidence-attribution-gaps.js +5 -0
  14. package/dist/adapters/raw-evidence-codex-reader.js +39 -7
  15. package/dist/adapters/raw-evidence-transcript-body.js +9 -1
  16. package/dist/adapters/raw-evidence-transcript-file.js +46 -4
  17. package/dist/adapters/raw-evidence-transcript-stream.js +36 -1
  18. package/dist/adapters/raw-evidence.js +13 -0
  19. package/dist/adapters/t3-projection-source.js +96 -0
  20. package/dist/collection-scope.js +2 -0
  21. package/dist/commands/backfill-checkpoint.js +3 -1
  22. package/dist/commands/backfill-history-scan.js +38 -0
  23. package/dist/commands/backfill-issues.js +13 -20
  24. package/dist/commands/backfill-output.js +6 -0
  25. package/dist/commands/backfill-report.js +3 -3
  26. package/dist/commands/backfill-scan.js +20 -40
  27. package/dist/commands/backfill-scope.js +2 -0
  28. package/dist/commands/backfill-upload.js +4 -2
  29. package/dist/commands/backfill.js +20 -3
  30. package/dist/commands/codex-revision-facts.js +64 -0
  31. package/dist/commands/collection-report.js +6 -0
  32. package/dist/commands/local-args-collector-status.js +2 -2
  33. package/dist/commands/local-args-collector-work.js +2 -2
  34. package/dist/commands/local-args-notes-targets.js +35 -0
  35. package/dist/commands/local-args-tower-notes.js +7 -18
  36. package/dist/commands/local-help-commands-tower.js +2 -2
  37. package/dist/commands/local-help-notes.js +2 -1
  38. package/dist/commands/local-help.js +3 -3
  39. package/dist/commands/notes-writes.js +24 -0
  40. package/dist/commands/notes.js +3 -2
  41. package/dist/commands/opencode-sync.js +163 -0
  42. package/dist/commands/public-root.js +1 -1
  43. package/dist/commands/session-sync-failures.js +4 -0
  44. package/dist/commands/session-sync-record.js +3 -1
  45. package/dist/commands/session-sync-scan.js +14 -6
  46. package/dist/commands/session-sync-shelf.js +2 -0
  47. package/dist/commands/session-sync-upload.js +3 -1
  48. package/dist/commands/session-sync.js +18 -1
  49. package/dist/commands/sessions.js +27 -8
  50. package/dist/commands/sources-check.js +54 -47
  51. package/dist/commands/sources-discovery.js +94 -14
  52. package/dist/commands/sources-reconciliation.js +7 -5
  53. package/dist/commands/sources-verdict.js +5 -2
  54. package/dist/cursors/raw-evidence-cursor.js +1 -0
  55. package/dist/image-description-session.js +4 -2
  56. package/dist/local-state-status.js +18 -1
  57. package/dist/native-session-roots.js +31 -0
  58. package/dist/opencode-inventory.js +203 -0
  59. package/dist/opencode-policy.js +29 -0
  60. package/dist/slim/slim-transcript.js +3 -2
  61. package/dist/source-opt-out.js +2 -1
  62. package/dist/spool/local-spool-parse.js +1 -1
  63. package/dist/state-dir-audit.js +2 -0
  64. package/dist/sync-health-class.js +2 -0
  65. package/dist/t3-native-homes.js +64 -0
  66. package/dist/upload-envelope-build.js +1 -0
  67. package/dist/upload-evidence-delivery-summary.js +10 -0
  68. package/dist/upload-session-reports-wire.js +15 -8
  69. package/package.json +4 -4
@@ -7,6 +7,7 @@
7
7
  * address they have always had.
8
8
  */
9
9
  import { optionalNonEmpty, optionalPositiveInteger, optionalUrl, parseNamedArgs, } from "./local-arg-values.js";
10
+ import { readNotesCorrection, readNotesShelfTarget } from "./local-args-notes-targets.js";
10
11
  /**
11
12
  * The notetakers `cockpit notes connect` will actually seal a key for
12
13
  * (BLI-4391). It mirrors `CONNECTABLE_NOTES_PROVIDERS` in the dashboard, and
@@ -34,7 +35,7 @@ const NOTES_ACTIONS = new Set([
34
35
  "upload",
35
36
  "paste",
36
37
  "share",
37
- "unshare",
38
+ "unshare", "correct",
38
39
  "summarize",
39
40
  "move",
40
41
  "place",
@@ -61,7 +62,7 @@ const NOTES_ACTIONS = new Set([
61
62
  const NOTES_ACTIONS_NEEDING_A_NOTE = new Set([
62
63
  "show",
63
64
  "share",
64
- "unshare",
65
+ "unshare", "correct",
65
66
  "summarize",
66
67
  "move",
67
68
  "place",
@@ -82,7 +83,7 @@ const NOTES_ALLOWED_FLAGS = [
82
83
  "--file",
83
84
  "--name",
84
85
  "--exclude",
85
- "--to",
86
+ "--to", "--from", "--transcript", // BLI-24437: `correct <id> --from <term> --to <term> [--transcript]`
86
87
  "--folder",
87
88
  "--clear-shelf",
88
89
  "--apply",
@@ -122,7 +123,7 @@ const NOTES_VALUE_FLAGS = [
122
123
  "--file",
123
124
  "--name",
124
125
  "--exclude",
125
- "--to",
126
+ "--to", "--from",
126
127
  "--folder",
127
128
  "--series",
128
129
  "--kind",
@@ -180,6 +181,7 @@ export function parseNotesArgs(args) {
180
181
  exclude: optionalNonEmpty(values.flags.get("--exclude")),
181
182
  ...(to ? { to } : {}),
182
183
  ...(clearShelf ? { clearShelf } : {}),
184
+ ...readNotesCorrection(action, values),
183
185
  // BLI-4058. `place` says where a note belongs; only `--apply` moves it.
184
186
  ...(values.booleans.has("--apply") ? { apply: true } : {}),
185
187
  series: optionalNonEmpty(values.flags.get("--series")),
@@ -201,7 +203,7 @@ function readNotesAction(first) {
201
203
  // almost always wants — same reasoning as bare `cockpit` running convergence.
202
204
  const action = (first === undefined ? "list" : first);
203
205
  if (!NOTES_ACTIONS.has(action)) {
204
- throw new Error(`Unknown notes command: ${first}. Try list, show, shelf, shelves, upload, paste, share, unshare, summarize, move, place, accounts, connect, detach, sync, sync-status, recordings, recording, webhook, granola-status, transcription-stats, or review (and record start|stop|status|cancel, app install|uninstall|status).`);
206
+ throw new Error(`Unknown notes command: ${first}. Try list, show, shelf, shelves, upload, paste, share, unshare, correct, summarize, move, place, accounts, connect, detach, sync, sync-status, recordings, recording, webhook, granola-status, transcription-stats, or review (and record start|stop|status|cancel, app install|uninstall|status).`);
205
207
  }
206
208
  return action;
207
209
  }
@@ -368,19 +370,6 @@ function readNotesPaths(action, rest) {
368
370
  }
369
371
  return undefined;
370
372
  }
371
- function readNotesShelfTarget(action, values) {
372
- const to = optionalNonEmpty(values.flags.get("--to"));
373
- const clearShelf = values.booleans.has("--clear-shelf");
374
- if (action !== "move")
375
- return { to, clearShelf };
376
- if (to && clearShelf) {
377
- throw new Error("notes move accepts either --to or --clear-shelf, not both.");
378
- }
379
- if (!to && !clearShelf && !values.flags.get("--folder")) {
380
- throw new Error('notes move needs --to "<shelf>", --clear-shelf, or --folder "<path>".');
381
- }
382
- return { to, clearShelf };
383
- }
384
373
  function readNotesMonth(action, values) {
385
374
  const month = optionalNonEmpty(values.flags.get("--month"));
386
375
  if (month === undefined)
@@ -112,7 +112,7 @@ export const TOWER_COMMAND_HELP = [
112
112
  "dm <email> [<email>...] — with several addresses, opens (or re-opens) the group message with exactly those people plus you; the same set always resolves to the same channel. channel <channel> [--json] — the channel's details: name, description, kind, archived, audience (a public channel is everyone in the org, not a member count), source workspace label (where it came from; it grants no access), whether you can manage it, and whether you hid it. channel <channel> --rename <name> | --describe <text> | --archive | --unarchive — changes it (one update; --rename and --describe can go together). Only the person who made the channel, its owners and its moderators can; anyone else is refused channel_manage_refused, a name in use channel_name_taken, a direct message dm_not_editable. Archiving keeps every message and link and stops new posts (channel_archived); unarchive restores posting. members <channel> [--json] — who is in a private channel or a direct message; a public channel says everyone in the org can read it. members <channel> --add <email> | --remove <email> — private channels only, by the same people who can manage it; a removed person's next read is refused. A direct message keeps the people it started with (dm_not_editable): start a new group with `msg dm a@x b@y`. hide <channel> / unhide <channel> — drops a PUBLIC channel from your own sidebar, or puts it back; it changes nothing for anyone else and nothing about reading, search, mentions or notifications. A private channel or direct message is refused hide_not_public.",
113
113
  "read <channel> [--limit <n>] [--thread <id>] [--mark-read] — the channel's most recent top-level messages, oldest first; --thread <id> reads one thread's replies instead. The first page also says where the messages come from (for an imported Slack channel: how long ago the archive was checked, or that it is unknown) and where YOUR read line stands. Reading never moves the read line; --mark-read moves it to the newest message shown, and says plainly if that failed.",
114
114
  "unread <channel> --from <message-id> — marks that message and everything after it unread, so the web sidebar badge and the NEW MESSAGES line start there. Opening or reading a channel never clears unseen history.",
115
- "send <channel> [--thread <id>] [--request-id <uuid>] — posts a message. The content is never accepted on the command line: pipe it in, e.g. `echo \"hello\" | cockpit msg send general`. Every send carries a request id (minted when you give none); retry a send whose answer was lost with the SAME --request-id and the same text and it posts once. The same id with different text is refused request_id_reused, not applied as an edit. send <channel> --file <id> [--file <id>...] — attaches up to 10 ready files (from `msg file upload`) to the message. The text is optional with a file; it is read from stdin only when something is piped in. file upload <channel> <path|-> [--name <name>] — uploads a file of 1 byte to 25 MB straight to storage (reserve, PUT, finalize) and prints its id and state; `-` reads stdin and needs --name. A file is ready, not sent: attach it with `msg send <channel> --file <id>`. file show <id> — the descriptor (state reserved, ready, attached, cancelled or abandoned). file download <id> [--out <path>] — saves the bytes (60-second signed link; never overwrites). file cancel <id> — ends an unattached file and removes its bytes. file list <channel> — your own unsent uploads there, with coverage. A file is readable only by readers of its channel, and only once attached to a live message. Refusals keep the door's reason: file_too_large, file_not_found_or_unreadable, file_not_uploaded, file_not_ready, file_already_attached, file_wrong_channel, storage_unreachable.",
115
+ "send <channel> [--thread <id>] [--request-id <uuid>] — posts a message. The content is never accepted on the command line: pipe it in, e.g. `echo \"hello\" | cockpit msg send general`. Every send carries a request id (minted when you give none); retry a send whose answer was lost with the SAME --request-id and the same text and it posts once. The same id with different text is refused request_id_reused, not applied as an edit. send <channel> --file <id> [--file <id>...] — attaches up to 10 ready files (from `msg file upload`) to the message. The text is optional with a file; it is read from stdin only when something is piped in. file upload <channel> <path|-> [--name <name>] — uploads a file of 1 byte to 25 MB straight to storage (reserve, PUT, finalize) and prints its id and state; `-` reads stdin and needs --name. A file is ready, not sent: attach it with `msg send <channel> --file <id>`. file show <id> — the descriptor (state reserved, ready, attached, cancelled or abandoned). file download <id> [--out <path>] — saves the bytes (60-second signed link; never overwrites). file cancel <id> — ends an unattached file and removes its bytes. file list <channel> — your own unsent uploads there, with coverage. A file is readable only by readers of its channel, and only once attached to a live message. Refusals keep the door's reason: file_too_large, file_not_found_or_unreadable, file_not_uploaded, file_not_ready, file_already_attached, file_wrong_channel, storage_unreachable (no answer: try again), storage_refused (storage said no: retrying will not help; the sentence names the step, HTTP status and class).",
116
116
  "edit <message-id> [--expected-revision <n>] [--request-id <uuid>] — replaces your own message's text (piped in). With --expected-revision, an edit of a message that has moved on is refused revision_conflict and nothing is saved over it; the current revision is printed. A message you did not write, or one that was deleted, is refused by name. delete <message-id> [--expected-revision <n>] [--request-id <uuid>] — deletes by tombstone: the text is cleared and every surface reads \"This message was deleted\", but the row stays so its thread, replies and reply count survive. Search and unread counts ignore it. A repeat answers already_deleted. outcome <request-uuid> — your own write receipt for a send, edit or delete: committed, not_committed (with the reason) or unknown_check_again. Run it after a timeout before retrying. draft [list|show|save|discard|restore|send] <channel> [--thread <id>] [--expected-revision <n>] [--request-id <uuid>] — the text you have not sent yet, one draft per channel and thread, the same drafts the browser autosaves. list shows all your unsent drafts (newest first, with coverage); show prints one; save takes the body on stdin (`echo \"half a thought\" | cockpit msg draft save general`) and with --expected-revision refuses draft_revision_conflict, naming the stored revision, instead of overwriting; discard keeps the text (state discarded) and restore brings it back; send posts the stored draft with a fresh request id (--request-id to retry the same send) and its revision, prints the receipt, and marks the draft sent only if it did not change meanwhile. Only you can read or change your drafts.",
117
117
  "thread <id> --channel <channel> [--before <cursor>] [--limit <n>] — one thread's replies by the parent message's id.",
118
118
  "show <message-id> — exact message, thread root and bounded neighbors. read/thread --before takes the preceding nextCursor; repeat until hasMore is false. activity [--mentions|--threads] [--unread] [--before <cursor>] [--limit <n>] [--mark-read] — your Mentions (messages that mention you) and Threads (replies in threads you follow: you started it, replied natively or followed it by hand), newest first, with unread counts and coverage; items whose message you can no longer read are left out and counted as dropped. Nothing is marked read by looking; --mark-read marks the unread items just printed, and the web marks one when its message is shown. Activity covers native Tower messages only, so the Slack import adds none. follow <message-id> / unfollow <message-id> — the id is the thread's top-level message; an explicit unfollow wins over a later auto follow, and earlier items stay. react <message-id> <emoji> [--remove] — adds or takes off your reaction (idempotent). Refusals: thread_root_not_found_or_unreadable, not_a_thread_root, reaction_not_found. notify — your message notification settings (the same ones the web header menu and Settings change): the default level (all, mentions or none; mentions is the default and covers direct messages, @mentions and replies in threads you follow), quiet hours and per-channel overrides. notify set --level <all|mentions|none> changes the default; add --channel <id|name> for one channel, with --mute / --unmute, or --clear to remove the override. notify quiet <HH:MM-HH:MM> [--timezone <zone>] sets quiet hours (24-hour, may wrap midnight; the zone defaults to this machine's) and notify quiet --off removes them. notify receipts [--message <id>] [--before <cursor>] [--limit <n>] lists what was delivered, suppressed or blocked and why (never message text): outcome shown means Tower told a browser tab to show a banner; push_accepted means the push service took the phone push, not that a phone showed it. Quiet hours and levels hold back banners and phone pushes, never the message or its unread badge. Refusals: invalid_notification_level, invalid_quiet_hours, invalid_timezone. search [words] [--from <email|me>]... [--in <channel>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--timezone <IANA>] [--replies|--top-level] [--has-file] [--before <cursor>] [--limit <n>] — message search on your own access, newest first (not ranked; `cockpit search --kind msg` is the ranked bar). Each hit prints its id, channel, author, time and snippet, then `more: --before <cursor>` or `complete`; repeat with the cursor until complete. --from takes an email, a user id or me and repeats; --in takes a channel id or #name (exact after case folding, an ambiguous name is refused); --since and --until are whole local days in --timezone, both inclusive (this machine's zone when you give none). The words may be left out when a filter is set, so `msg search --has-file` finds attachment-only messages. Inline operators work in the words as in the web box: from:<email|me> in:#name after:<day> before:<day> (exclusive) on:<day> has:file is:reply is:root. Recognised but unsupported operators (has:link, has:pin, has:reaction, is:saved, is:dm, to:, with:, during:) are refused unsupported_search_operator, naming the operator; a bad day, zone, person or channel is refused invalid_search_filter. Messages imported from Slack carry no file links, so has:file does not find them. Deleted messages, channels you cannot read and files you cannot read never appear.",
@@ -251,7 +251,7 @@ export const TOWER_COMMAND_HELP = [
251
251
  "usage",
252
252
  [
253
253
  "Usage: cockpit usage people [--by-repo | --by-topic | --by-subject | --by-task | --by-client] [--min-confidence high|medium|low] [--person <email|me>] [--all] [--since <n>d|<n>h|<iso>] [--detail] [--until <iso>] [--include-automated] [--json]",
254
- " cockpit usage sessions [--person <exact-name>] [--task <BLI-NNNN> | --subject <name>] [--repo <label>] [--tool claude|codex] [--since <window>] [--until <iso>] [--cursor <cursor>] [--limit <n>] [--json]",
254
+ " cockpit usage sessions [--person <exact-name>] [--task <BLI-NNNN> | --subject <name>] [--repo <label>] [--tool claude|codex|opencode] [--since <window>] [--until <iso>] [--cursor <cursor>] [--limit <n>] [--json]",
255
255
  " cockpit usage session <id> [--from-window <n>] [--json]",
256
256
  " --by-topic groups work types; --by-subject groups open subjects from session summaries.",
257
257
  "",
@@ -3,7 +3,7 @@ export const NOTES_HELP = [
3
3
  [
4
4
  "notes",
5
5
  [
6
- "Usage: cockpit notes [list|show <id>|shelf|shelves|folders|mkdir <path>|rmdir <path>|rename <path>|upload <paths...> [--wait]|paste|share <id>|unshare <id>|summarize <id>|move <id>|accounts|connect|detach <id>|sync <id>|sync-status [<id>]|recordings <note-id>|recording <id>|record start|stop|status|cancel|app install|uninstall|status|review [<note-id>] [--submit|--accept-all]] [flags]",
6
+ "Usage: cockpit notes [list|show <id>|shelf|shelves|folders|mkdir <path>|rmdir <path>|rename <path>|upload <paths...> [--wait]|paste|share <id>|unshare <id>|correct <id> --from <term> --to <term>|summarize <id>|move <id>|accounts|connect|detach <id>|sync <id>|sync-status [<id>]|recordings <note-id>|recording <id>|record start|stop|status|cancel|app install|uninstall|status|review [<note-id>] [--submit|--accept-all]] [flags]",
7
7
  "Audio uploads: MP3, M4A, WAV, WebM and OGG, up to 1 GB. Over 4 MB (a whole meeting) the file goes straight to storage and is transcribed in the background; --wait then polls for up to 4 hours and prints progress, otherwise for at most 330 seconds.",
8
8
  "",
9
9
  "record start|stop [<session-id>]|status|cancel — record a meeting in a room from this machine's microphone (Apple Silicon macOS and Windows; Linux says it is not supported). On Windows the microphone needs Settings > Privacy & security > Microphone on, including Let desktop apps access your microphone. Nothing leaves the machine while recording; the recorder stops by itself after 8 hours (under the 1 GB upload limit). `stop` uploads the whole original recording, silence included, and Tower writes a note with Speaker 1, Speaker 2... lines, or says no speech was detected (add --wait to watch the transcription). `cancel` stops and KEEPS the file; `status` lists what is recording and every session waiting for upload (`needs_upload`); `stop <session-id>` uploads a cancelled, crashed or auto-stopped session. The BLI Notetaker app uploads waiting sessions by itself. The recording also stays on this machine.",
@@ -24,6 +24,7 @@ export const NOTES_HELP = [
24
24
  "share <id> [--yes] — let everyone signed in read the statements that are safe to share. Asks first in a terminal; --yes is required without one, and --json implies --yes.",
25
25
  "summarize <id> — write a new summary (decisions, action items, key points) where every claim cites the speaker, timestamp and segment id (s12) it came from; claims the transcript does not support are dropped. Takes up to a minute; earlier summaries are kept. `show <id>` prints the newest one.",
26
26
  "unshare <id> — take it back. Never asks: it only ever narrows who can read.",
27
+ "correct <id> --from \"<misheard>\" --to \"<right>\" [--transcript] — fix a misheard term: every whole-word mention in the note's notes and summary in one write, the previous text kept. The transcript stays as recorded unless you pass --transcript, and then each fix is marked beside the words as heard. Owner or admin only. Then `cockpit glossary add` makes future transcripts and incoming notes spell it right.",
27
28
  "move <id> (--to \"<shelf>\"|--clear-shelf) — put it on a different shelf, or take the shelf off.",
28
29
  "place <id> [--apply] — say which shelf this note belongs on and why, from the meeting it is part of, who was in the room and its own name. Moves nothing without --apply, and never overrules a shelf somebody typed.",
29
30
  "",
@@ -146,9 +146,9 @@ const COMMAND_SUMMARY_LINES = [
146
146
  " cockpit correct --claim <claimId> --text \"<what is wrong>\" [--for <person>] [--version <pageId>] [--supersedes <id>] [--dashboard-url <url>] [--json]",
147
147
  " cockpit notes [list|show <id>|shelf|shelves|folders|mkdir <path>|rmdir <path>|rename <path>|upload <paths...> [--wait]|paste|share <id>|unshare <id>|summarize <id>|move <id>|place <id>] [--folder <path>] [--series <shelf>] [--kind <kind>] [--since <YYYY-MM-DD>] [--until <YYYY-MM-DD>] [--limit <n>] [--file <path>] [--name <n>] [--exclude \"<sentence>\"] [--to \"<shelf>\"|--clear-shelf] [--apply] [--yes] [--dashboard-url <url>] [--json]",
148
148
  " cockpit notes [accounts [--show-webhook <account-id>]|connect --provider fellow --workspace <sub> --key-stdin [--name <n>]|connect --provider wisprflow|recordings <note-id>|recording <id>|webhook <account-id> --secret-stdin|detach <account-id>|sync <account-id>] [--json] (the key and the signing secret are read from stdin, never a flag)",
149
- " cockpit backfill (--since-days <n>|--all) [--source codex|claude] [--dry-run] [--max-files <n>] [--max-depth <n>] [--max-repos <n>] [--lock-wait <seconds>] [--yes] [--workspace <path>] [--json]",
149
+ " cockpit backfill (--since-days <n>|--all) [--source codex|claude|opencode] [--dry-run] [--max-files <n>] [--max-depth <n>] [--max-repos <n>] [--lock-wait <seconds>] [--yes] [--workspace <path>] [--json]",
150
150
  " cockpit status [--workspace <path>] [--max-depth <n>] [--max-repos <n>] [--json]",
151
- " cockpit sessions [--source codex|claude] [--since-days <n>|--all] [--workspace <path>] [--max-depth <n>] [--max-repos <n>] [--json]",
151
+ " cockpit sessions [--source codex|claude|opencode] [--since-days <n>|--all] [--workspace <path>] [--max-depth <n>] [--max-repos <n>] [--json]",
152
152
  " cockpit serve [--port <port>] [--workspace <path>]",
153
153
  " cockpit autostart [install|uninstall|status] [--workspace <path>] [--dashboard-url <url>] [--interval-seconds <n>] [--json]",
154
154
  " cockpit agent-rules [install|uninstall|status] [--host codex|claude|all] [--workspace <path>] [--json]",
@@ -190,7 +190,7 @@ const COMMAND_SUMMARY_LINES = [
190
190
  " cockpit manager <clients|client <client>|run <run-id>|list <client>|queue <client>|show <id>|add <client> --title <t>|edit <id> --version <v>|done|reopen|link|approve|dismiss|proposal|archive|unarchive> [--timeline] [--dashboard-url <url>] [--json]",
191
191
  " cockpit image <describe <file> [--session <id>]|show <sha256-or-prefix>> [--dashboard-url <url>] [--json]",
192
192
  " cockpit setup [--since <duration|date>] [--until <date>] [--machines] [--details] [--person <name|email>] [--compare <name,name>] [--json]",
193
- " cockpit usage sessions [--person <exact-name>] [--task <BLI-NNNN> | --subject <name>] [--repo <label>] [--tool claude|codex] [--since <window>] [--until <iso>] [--cursor <cursor>] [--limit <n>] [--json]",
193
+ " cockpit usage sessions [--person <exact-name>] [--task <BLI-NNNN> | --subject <name>] [--repo <label>] [--tool claude|codex|opencode] [--since <window>] [--until <iso>] [--cursor <cursor>] [--limit <n>] [--json]",
194
194
  " cockpit usage session <id> [--from-window <n>] [--json]",
195
195
  " --by-topic groups work types; --by-subject groups open subjects from session summaries.",
196
196
  " cockpit ticket mutation-status <request-uuid> [--json] (check a lost write response)",
@@ -223,6 +223,30 @@ export async function shareNote(command, door) {
223
223
  sayUpload(door, body);
224
224
  return 0;
225
225
  }
226
+ /**
227
+ * `cockpit notes correct <note-id> --from <term> --to <term> [--transcript]` (BLI-24437): one call to
228
+ * `POST /api/notes/correct`, the door the browser, MCP and JARVIS use. The server counts; this prints its sentences.
229
+ * A refusal, including "nothing_to_correct" (no mention found, nothing changed), prints the server's sentence and exits 1.
230
+ */
231
+ export async function correctNote(command, door) {
232
+ const scope = command.transcript ? "notes_and_transcript" : "notes";
233
+ const answer = await ask(door, {
234
+ path: "/api/notes/correct",
235
+ method: "POST",
236
+ label: "notes correct",
237
+ timeoutMs: READ_DEADLINE_MS,
238
+ body: { note_id: command.noteId, from: command.from, to: command.to, scope },
239
+ });
240
+ if (!answer.ok) {
241
+ return fail(door, answer.reason, answer.detail);
242
+ }
243
+ const body = answer.body;
244
+ writeLine(door.io.stderr, `${TAG} corrected ${JSON.stringify({ note_id: command.noteId ?? null, scope, notes: body.counts?.notes ?? null, transcript: body.counts?.transcript ?? null, summary: body.counts?.summary ?? null })}`);
245
+ if (door.json)
246
+ return emit(door, body);
247
+ sayUpload(door, body);
248
+ return 0;
249
+ }
226
250
  /** A summary run is two model calls over a long transcript: give it room (BLI-20882). */
227
251
  const SUMMARIZE_DEADLINE_MS = 330_000;
228
252
  /**
@@ -48,7 +48,7 @@
48
48
  import os from "node:os";
49
49
  import { loadPairedSession } from "../tower-client.js";
50
50
  import { listNotes, listShelves, showNote, showShelf } from "./notes-reads.js";
51
- import { uploadNotes, pasteNote, shareNote, summarizeNote, moveNote, placeNote } from "./notes-writes.js";
51
+ import { uploadNotes, pasteNote, shareNote, summarizeNote, moveNote, placeNote, correctNote } from "./notes-writes.js";
52
52
  import { runFolderCommand } from "./notes-folders.js";
53
53
  import { armNotesWebhook, connectNotetaker, detachNotetaker, listNotesAccounts, showNotesWebhook, syncNotetaker, syncStatusNotetakers, } from "./notes-accounts.js";
54
54
  import { showBotUpcoming } from "./notes-bot-upcoming.js";
@@ -60,7 +60,7 @@ import { defaultRecordDeps, runNotesRecord } from "./notes-record.js";
60
60
  import { runNotesApp } from "./notes-app.js";
61
61
  import { defaultExec, errorMessage } from "./cli-io.js";
62
62
  export { listNotes, listShelves, showNote, showShelf } from "./notes-reads.js";
63
- export { uploadNotes, pasteNote, shareNote, summarizeNote, moveNote, placeNote } from "./notes-writes.js";
63
+ export { uploadNotes, pasteNote, shareNote, summarizeNote, moveNote, placeNote, correctNote } from "./notes-writes.js";
64
64
  export { armNotesWebhook, connectNotetaker, detachNotetaker, listNotesAccounts, showNotesWebhook, syncNotetaker, syncStatusNotetakers, } from "./notes-accounts.js";
65
65
  export { showGranolaStatus } from "./notes-granola-status.js";
66
66
  export { showTranscriptionStats } from "./notes-transcription-stats.js";
@@ -80,6 +80,7 @@ const NOTES_VERBS = {
80
80
  paste: pasteNote,
81
81
  share: shareNote,
82
82
  unshare: shareNote,
83
+ correct: correctNote,
83
84
  summarize: summarizeNote,
84
85
  move: moveNote,
85
86
  place: placeNote,
@@ -0,0 +1,163 @@
1
+ /** Route OpenCode's third native format through the existing evidence pack, spool, report queue and durable cursor. */
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { getCollectorRuntimePaths, readLocalCollectorConfig, readLocalCollectorSessionFile, startLocalWorkContext, startLocalWorkContextForAttributedTarget } from "../local-state.js";
5
+ import { writeJsonFileAtomic } from "../local-state-files.js";
6
+ import { reportShelvedSessions } from "../shelf-reports.js";
7
+ import { openCodeCollectionPolicy } from "../opencode-policy.js";
8
+ import { RAW_EVIDENCE_DEFAULT_BYTE_BUDGET, RAW_EVIDENCE_DEFAULT_OBJECT_BUDGET } from "../adapters/raw-evidence.js";
9
+ import { cwdInsideRoots } from "../collection-scope.js";
10
+ import { scoreSignalsAgainstWorktrees, sha256 } from "../adapters/attribution-core.js";
11
+ import { outsideRootsWorkspace, isOutsideRootsWorkspace } from "./backfill-outside-roots.js";
12
+ import { syncLocalAmbientEnvelope } from "../upload.js";
13
+ import { readRawEvidenceCursor, writeRawEvidenceCursor } from "../cursors/raw-evidence-cursor.js";
14
+ import { readOpenCodeInventory, acknowledgeOpenCodeUsage, OPENCODE_CURSOR_FILENAME } from "../opencode-inventory.js";
15
+ import { queueCodexSessionReport, flushPendingCodexSessionReports } from "../upload-session-reports.js";
16
+ import { recordSourceRetryFailure, clearSourceRetryFailure } from "../spool/local-spool.js";
17
+ import { describeError } from "../health-detail.js";
18
+ /** The all-history inventory is resumable through existing per-object acknowledgments, never a second delivery engine. */
19
+ export async function syncOpenCodeSessions(options) {
20
+ const paths = getCollectorRuntimePaths(options.homeDir);
21
+ const now = new Date();
22
+ const summary = { source: "opencode", new_since_last_scan: 0, outside_roots: 0, discovered: 0, eligible: 0, delivered: 0, pending: 0, withheld: 0, unique: 0, coverage: "complete", reasons: [] };
23
+ try {
24
+ const policy = await openCodeCollectionPolicy(options);
25
+ if (!policy.enabled) {
26
+ const held = await readOpenCodeInventory({ homeDir: options.homeDir, stateDir: paths.state_dir, metadataOnly: true, include: () => false, sinceMs: options.sinceMs });
27
+ summary.discovered = held.discovered;
28
+ summary.unique = held.discovered;
29
+ summary.withheld = held.withheld;
30
+ summary.coverage = held.failures.length || policy.reason === "owner_check_unavailable" ? "partial" : held.absent ? "absent" : "withheld";
31
+ summary.reasons.push(policy.reason, ...held.failures.map(failure => failure.reason));
32
+ if (summary.coverage === "partial")
33
+ await recordSourceRetryFailure(paths, { source: "opencode", attemptedAt: now.toISOString(), reason: held.failures[0]?.reason ?? policy.reason });
34
+ console.error("[opencode sync] source withheld", JSON.stringify(summary));
35
+ return summary;
36
+ }
37
+ const attributed = (directory) => scoreSignalsAgainstWorktrees({ cwds: [directory], workspaceRoots: [], originUrls: [], branches: [], headShas: [] }, options.worktrees, { collectionRoots: options.collectionRoots });
38
+ const cursor = await readRawEvidenceCursor(paths, { filename: OPENCODE_CURSOR_FILENAME, sessionsOnly: true });
39
+ const inventory = await readOpenCodeInventory({ homeDir: options.homeDir, stateDir: paths.state_dir, metadataOnly: options.dryRun, sinceMs: options.sinceMs, deliveredSessionIds: new Set(Object.entries(cursor.sessions).filter(([, entry]) => entry.uploaded_object_key).map(([id]) => id)), include: policy.include, countOnly: policy.drawer });
40
+ summary.discovered = inventory.discovered;
41
+ summary.withheld = inventory.withheld;
42
+ summary.eligible = inventory.eligible;
43
+ summary.pending = inventory.eligible - inventory.files.length;
44
+ summary.unique = inventory.discovered;
45
+ summary.reasons.push(...new Set(inventory.failures.map((failure) => failure.reason)));
46
+ if (inventory.absent)
47
+ summary.coverage = "absent";
48
+ if (options.dryRun) {
49
+ summary.pending = inventory.eligible;
50
+ if (inventory.failures.length)
51
+ summary.coverage = "partial";
52
+ return summary;
53
+ }
54
+ if (inventory.shelved.length) {
55
+ const [device, config] = await Promise.all([readLocalCollectorSessionFile(paths), readLocalCollectorConfig(paths)]);
56
+ const shelfReport = await reportShelvedSessions({ paths, dashboardUrl: options.dashboardUrl ?? config?.dashboard_url ?? null,
57
+ deviceToken: device?.device_token ?? null, fetchImpl: options.fetchImpl, allow: config?.shelf_metrics_allow ?? [], now,
58
+ shelved: inventory.shelved.map(file => ({ key: `opencode:${file.session.id}`, source: "opencode", reason: "drawer_shelf", facts: file.facts, recencyMs: file.session.updated_at_ms })) });
59
+ if (shelfReport.failed || shelfReport.not_counted)
60
+ summary.reasons.push("opencode_shelf_metrics_pending");
61
+ }
62
+ summary.new_since_last_scan = inventory.files.filter((file) => !cursor.sessions[file.session.id]).length;
63
+ summary.outside_roots = inventory.files.filter((file) => !cwdInsideRoots(file.session.directory, options.collectionRoots)).length;
64
+ const durableSessions = new Set();
65
+ const groups = new Map();
66
+ for (const file of inventory.files) {
67
+ const worktree = attributed(file.session.directory).worktree ?? outsideRootsWorkspace(options.homeDir);
68
+ const group = groups.get(worktree.worktree_fingerprint) ?? { worktree, files: [] };
69
+ group.files.push(file);
70
+ groups.set(worktree.worktree_fingerprint, group);
71
+ }
72
+ const budget = options.budget ?? { remainingBytes: RAW_EVIDENCE_DEFAULT_BYTE_BUDGET, remainingObjects: RAW_EVIDENCE_DEFAULT_OBJECT_BUDGET };
73
+ for (const { worktree, files } of groups.values()) {
74
+ if (options.deadlineMs && Date.now() >= options.deadlineMs) {
75
+ summary.reasons.push("opencode_deadline_deferred");
76
+ summary.pending = summary.eligible - summary.delivered;
77
+ break;
78
+ }
79
+ if (isOutsideRootsWorkspace(worktree))
80
+ await fs.mkdir(worktree.repo_root, { recursive: true, mode: 0o700 });
81
+ const contextOptions = { homeDir: options.homeDir, repoRoot: worktree.repo_root, branch: worktree.branch, leaveActiveContext: true };
82
+ const context = isOutsideRootsWorkspace(worktree) ? await startLocalWorkContextForAttributedTarget(contextOptions, worktree) : await startLocalWorkContext(contextOptions);
83
+ const sync = await syncLocalAmbientEnvelope({ homeDir: options.homeDir, repoRoot: worktree.repo_root, dashboardUrl: options.dashboardUrl,
84
+ rawEvidenceBudget: budget, codexSessionFiles: [], claudeSessionFiles: [], nativeSessionFiles: files.map((file) => ({ local_path: file.local_path, session_id: file.session.id, source: "opencode", redaction: file.redaction })), fetch: options.fetchImpl });
85
+ if (sync.status !== "uploaded")
86
+ summary.reasons.push(sync.failure_reason);
87
+ const rows = files.map((file) => {
88
+ const attribution = attributed(file.session.directory);
89
+ const outcome = sync.raw_evidence_outcomes.find((item) => item.kind === "opencode_jsonl" && item.codex_session_id === file.session.id);
90
+ const pointer = outcome && (outcome.upload_state === "uploaded" || outcome.upload_state === "reused_existing") ? outcome.raw_evidence_pointer_id : null;
91
+ if (!pointer)
92
+ summary.reasons.push(outcome?.reason ?? "opencode_delivery_pending");
93
+ return { source: "opencode", codex_session_id: file.session.id, observed_at: now.toISOString(), attribution_state: attribution.state,
94
+ attribution_reason: attribution.reason, attribution_score: attribution.attribution_score, path_score: attribution.path_score, signals: attribution.signals,
95
+ session_file_hash_sha256: file.revision, session_file_byte_size: file.byte_size, session_file_mtime: new Date(file.session.updated_at_ms).toISOString(), session_facts: file.facts,
96
+ repo_fingerprint: attribution.worktree?.repo_fingerprint, worktree_fingerprint: attribution.worktree?.worktree_fingerprint,
97
+ repo_label: attribution.worktree?.repo_label, branch: attribution.worktree?.branch, cwd_basename: path.basename(file.session.directory), cwd_hash: sha256(Buffer.from(file.session.directory)),
98
+ root_scope: cwdInsideRoots(file.session.directory, options.collectionRoots) ? "inside" : "outside",
99
+ raw_evidence_pointer_id: pointer ?? undefined, upload_state: pointer ? "uploaded" : "not_uploaded", upload_reason: pointer ? "durable_evidence_acknowledged" : outcome?.reason ?? "opencode_delivery_pending" };
100
+ });
101
+ // Durable metadata queue precedes cursor movement; an unavailable report endpoint cannot age sessions out.
102
+ await queueCodexSessionReport({ homeDir: options.homeDir, dashboardUrl: sync.dashboard_url, generatedAt: now.toISOString(), workContextId: context.work_context_id,
103
+ repoLabel: worktree.repo_label, branch: worktree.branch, repoFingerprint: worktree.repo_fingerprint, repoOriginUrl: worktree.repo_origin_url,
104
+ worktreeLabel: worktree.worktree_label, worktreeFingerprint: worktree.worktree_fingerprint, worktreeIsPrimary: worktree.worktree_is_primary, sessions: rows });
105
+ for (const [index, file] of files.entries()) {
106
+ const row = rows[index];
107
+ const pointer = row.raw_evidence_pointer_id ?? null;
108
+ if (pointer) {
109
+ summary.delivered += 1;
110
+ durableSessions.add(file.session.id);
111
+ }
112
+ else
113
+ summary.pending += 1;
114
+ cursor.sessions[file.session.id] = { file_hash_sha256: file.revision, file_mtime_ms: file.session.updated_at_ms, byte_size: file.byte_size, byte_offset: pointer ? file.byte_size : 0,
115
+ state: row.attribution_state, reason: row.attribution_reason, worktree_fingerprint: row.worktree_fingerprint ?? null, uploaded_object_key: pointer,
116
+ uploaded_at: pointer ? now.toISOString() : null, uploaded_byte_size: pointer ? file.byte_size : null, last_seen_at: now.toISOString() };
117
+ }
118
+ cursor.updated_at = now.toISOString();
119
+ await writeRawEvidenceCursor(paths, cursor, { filename: OPENCODE_CURSOR_FILENAME, sessionsOnly: true });
120
+ }
121
+ const report = await flushPendingCodexSessionReports({ homeDir: options.homeDir, fetch: options.fetchImpl });
122
+ if (report.posted && report.failed_count === 0) {
123
+ await acknowledgeOpenCodeUsage(paths.state_dir, durableSessions);
124
+ // The shared pack/spool owns acknowledged bytes now; these are disposable redacted reader derivatives.
125
+ for (const file of inventory.files)
126
+ if (durableSessions.has(file.session.id))
127
+ await fs.unlink(file.local_path).catch(() => undefined);
128
+ }
129
+ if (inventory.files.length && (!report.posted || report.failed_count > 0)) {
130
+ summary.reasons.push(report.reason);
131
+ summary.pending += summary.delivered;
132
+ summary.delivered = 0;
133
+ }
134
+ summary.reasons = [...new Set(summary.reasons)];
135
+ if (summary.pending || summary.reasons.length)
136
+ summary.coverage = "partial";
137
+ if (summary.coverage === "partial")
138
+ await recordSourceRetryFailure(paths, { source: "opencode", attemptedAt: now.toISOString(), reason: summary.reasons[0] ?? "opencode_delivery_pending" });
139
+ else
140
+ await clearSourceRetryFailure(paths, "opencode", now.toISOString());
141
+ }
142
+ catch (error) {
143
+ summary.pending = Math.max(summary.pending, summary.eligible - summary.delivered);
144
+ summary.coverage = "partial";
145
+ summary.reasons.push("opencode_sync_failed");
146
+ await recordSourceRetryFailure(paths, { source: "opencode", attemptedAt: now.toISOString(), reason: "opencode_sync_failed" });
147
+ console.error("[opencode sync] pass failed; native sessions remain retryable", JSON.stringify({ reason: "opencode_sync_failed", ...describeError(error) }));
148
+ }
149
+ finally {
150
+ if (!options.dryRun) {
151
+ try {
152
+ await writeJsonFileAtomic(path.join(paths.state_dir, "opencode-collection-status.json"), { observed_at: now.toISOString(), ...summary });
153
+ }
154
+ catch (error) {
155
+ summary.coverage = "partial";
156
+ summary.reasons.push("opencode_coverage_receipt_write_failed");
157
+ console.error("[opencode sync] coverage receipt not written", JSON.stringify({ reason: "opencode_coverage_receipt_write_failed", ...describeError(error) }));
158
+ }
159
+ }
160
+ }
161
+ console.error("[opencode sync] pass finished", JSON.stringify(summary));
162
+ return summary;
163
+ }
@@ -21,7 +21,7 @@ export async function runCockpitCli(argv, io) {
21
21
  }
22
22
 
23
23
  if (command === "--version" || command === "-V" || command === "version") {
24
- writeLine(io?.stdout ?? process.stdout, "0.2.292");
24
+ writeLine(io?.stdout ?? process.stdout, "0.2.294");
25
25
  return 0;
26
26
  }
27
27
 
@@ -170,4 +170,8 @@ export function recordUnexplainedFailure(ledger) {
170
170
  label: SYNC_FAILED_WITHOUT_REASON,
171
171
  rendered: SYNC_FAILED_WITHOUT_REASON,
172
172
  });
173
+ }
174
+ /** Keep native partial outcomes in the same closed failure ledger as legacy sources. */
175
+ export function recordOpenCodeFailures(ledger, native) {
176
+ ledger.fail(native.coverage === "partial", "opencode_scan_read_failed", native.reasons[0] ?? "opencode_delivery_pending");
173
177
  }
@@ -317,11 +317,13 @@ function recordSourceObservation(options, result) {
317
317
  const uploadedAt = uploadedThisSync
318
318
  ? options.now.toISOString()
319
319
  : (prior?.uploaded_at ?? (durableThisSync ? options.now.toISOString() : null));
320
- const uploadedByteSize = uploadedThisSync
320
+ const uploadedByteSize = uploadedThisSync || (durableThisSync && options.source === "codex")
321
321
  ? result.byte_size
322
322
  : (prior?.uploaded_byte_size ?? (durableThisSync ? result.byte_size : null));
323
323
  const entry = {
324
324
  file_hash_sha256: result.content_hash_sha256,
325
+ uploaded_source_revision: durableThisSync && !("t3_projection_incomplete" in result && result.t3_projection_incomplete) && !isRedactionStubObjectKey(uploadedObjectKey)
326
+ ? result.content_hash_sha256 : prior?.uploaded_source_revision ?? null,
325
327
  file_mtime_ms: result.session_file_mtime_ms,
326
328
  byte_size: result.byte_size,
327
329
  // Durable byte offset reflects how many bytes are durable remotely (the
@@ -1,3 +1,4 @@
1
+ import { nativeSessionRoots } from "../native-session-roots.js";
1
2
  /**
2
3
  * Reading both session stores, and settling what the reading owes.
3
4
  *
@@ -9,7 +10,7 @@
9
10
  */
10
11
  import path from "node:path";
11
12
  import { saveRootWorkScan } from "../root-work.js";
12
- import { CODEX_ATTRIBUTION_SCAN_WINDOW_SESSION_LIMIT, CODEX_ATTRIBUTION_SCAN_WINDOW_MINUTES, defaultCodexSessionDirs, scanAndAttributeCodexSessions, } from "../adapters/codex-attribution.js";
13
+ import { CODEX_ATTRIBUTION_SCAN_WINDOW_SESSION_LIMIT, CODEX_ATTRIBUTION_SCAN_WINDOW_MINUTES, scanAndAttributeCodexSessions, } from "../adapters/codex-attribution.js";
13
14
  import { scanAndAttributeClaudeSessions, } from "../adapters/claude-attribution.js";
14
15
  import { CLAUDE_CURSOR_FILENAME } from "../cursors/raw-evidence-cursor.js";
15
16
  import { isRedactionStubObjectKey } from "../cursors/raw-evidence-stub-entry.js";
@@ -31,9 +32,10 @@ const CLAUDE_DEFAULT_WINDOW_MINUTES = 24 * 60;
31
32
  */
32
33
  export async function scanAndAttributeBothSources(options) {
33
34
  const { plan } = options;
35
+ const roots = nativeSessionRoots(options.homeDir);
34
36
  const codexScanned = await scanCodexSessionsForSync({
35
37
  codexEnabled: plan.codexEnabled,
36
- homeDir: options.homeDir,
38
+ roots,
37
39
  worktrees: options.worktrees,
38
40
  now: options.now,
39
41
  collectionRoots: plan.collectionRoots,
@@ -48,7 +50,7 @@ export async function scanAndAttributeBothSources(options) {
48
50
  const firstRunBackfill = plan.claudeEnabled && !claudeCursorExists;
49
51
  const claudeScanned = await scanClaudeSessionsForSync({
50
52
  claudeEnabled: plan.claudeEnabled,
51
- homeDir: options.homeDir,
53
+ roots,
52
54
  worktrees: options.worktrees,
53
55
  now: options.now,
54
56
  collectionRoots: plan.collectionRoots,
@@ -58,6 +60,10 @@ export async function scanAndAttributeBothSources(options) {
58
60
  outsideRootCatchUpPending: plan.outsideRootCatchUpPending,
59
61
  stateDir: options.paths.state_dir,
60
62
  });
63
+ if (roots.discoveryFailed) {
64
+ codexScanned.directory_read_failed_count += 1;
65
+ claudeScanned.project_dir_read_failed_count += 1;
66
+ }
61
67
  // BLI-23590: under `roots_only` a session outside every approved root leaves the result HERE, before the retry
62
68
  // bookkeeping, the local work scan, the upload, the report or the git scan can see it.
63
69
  let codexAttribution = codexScanned;
@@ -117,7 +123,7 @@ async function scanCodexSessionsForSync(options) {
117
123
  const readMemo = await openTranscriptReadMemo(options.stateDir, "codex_attribution").catch(() => undefined);
118
124
  try {
119
125
  let scan = await scanAndAttributeCodexSessions({
120
- sessionsDirs: defaultCodexSessionDirs(options.homeDir),
126
+ sessionsDirs: options.roots.codex,
121
127
  worktrees: options.worktrees,
122
128
  now: options.now,
123
129
  sinceMinutes,
@@ -130,7 +136,7 @@ async function scanCodexSessionsForSync(options) {
130
136
  // capped scan still returns every session it found instead of silently
131
137
  // truncating at the window's default limit.
132
138
  scan = await scanAndAttributeCodexSessions({
133
- sessionsDirs: defaultCodexSessionDirs(options.homeDir),
139
+ sessionsDirs: options.roots.codex,
134
140
  worktrees: options.worktrees,
135
141
  now: options.now,
136
142
  sinceMinutes,
@@ -159,12 +165,13 @@ async function scanClaudeSessionsForSync(options) {
159
165
  : options.firstRunBackfill
160
166
  ? CLAUDE_FIRST_RUN_BACKFILL_MINUTES
161
167
  : undefined, options.outsideRootCatchUpPending, CLAUDE_DEFAULT_WINDOW_MINUTES);
162
- const projectsDir = path.join(options.homeDir, ".claude", "projects");
168
+ const { claudeProjects: projectsDir, claudeProjectDirs: projectsDirs } = options.roots;
163
169
  // BLI-22797: one memo for both passes, settled once, so an unchanged file is never opened.
164
170
  const readMemo = await openTranscriptReadMemo(options.stateDir, "attribution").catch(() => undefined);
165
171
  try {
166
172
  let scan = await scanAndAttributeClaudeSessions({
167
173
  projectsDir,
174
+ projectsDirs,
168
175
  worktrees: options.worktrees,
169
176
  now: options.now,
170
177
  collectionRoots: options.collectionRoots,
@@ -174,6 +181,7 @@ async function scanClaudeSessionsForSync(options) {
174
181
  if (scan.session_limit_applied) {
175
182
  scan = await scanAndAttributeClaudeSessions({
176
183
  projectsDir,
184
+ projectsDirs,
177
185
  worktrees: options.worktrees,
178
186
  now: options.now,
179
187
  collectionRoots: options.collectionRoots,
@@ -34,6 +34,8 @@ export function sessionShelf(result, rules) {
34
34
  return { shelf: "team", reason: "routing_inactive" };
35
35
  if (rules.failed)
36
36
  return { shelf: "drawer", reason: "shelf_resolve_failed" };
37
+ if (result.local_cwds && (result.local_cwds.length === 0 || result.local_cwds.some(cwd => !cwd || resolveShelfWith(rules, cwd).shelf !== "team")))
38
+ return { shelf: "drawer", reason: "shelf_identity_mismatch" };
37
39
  if (result.state === "ambiguous")
38
40
  return { shelf: "drawer", reason: "ambiguous_attribution" };
39
41
  const byWorktree = result.worktree && !isOutsideRootsWorkspace(result.worktree)
@@ -39,7 +39,7 @@ export async function syncEveryTargetWorktree(options) {
39
39
  // sessionId -> prior durable pointer for damped sessions (drives the
40
40
  // growth_damped count + the skip_main decision).
41
41
  const dampedClaudePointers = new Map();
42
- const rawEvidenceBudget = {
42
+ const rawEvidenceBudget = run.rawEvidenceBudget ?? {
43
43
  remainingBytes: RAW_EVIDENCE_DEFAULT_BYTE_BUDGET,
44
44
  remainingObjects: RAW_EVIDENCE_DEFAULT_OBJECT_BUDGET,
45
45
  };
@@ -180,6 +180,8 @@ function ambientEnvelopeForWorktree(options) {
180
180
  .map((result) => ({
181
181
  local_path: result.file_path,
182
182
  codex_session_id: result.codex_session_id,
183
+ ...(result.t3_projection ? { t3_projection: true } : {}),
184
+ ...(result.segment_paths ? { segment_paths: result.segment_paths, revision_hash: result.content_hash_sha256 ?? undefined, revision_bytes: result.byte_size } : {}),
183
185
  })),
184
186
  codexAttributionScan: scan.codexAttribution,
185
187
  claudeSessionFiles,
@@ -1,3 +1,4 @@
1
+ import { createSyncFailureLedger, recordOpenCodeFailures } from "./session-sync-failures.js";
1
2
  import { readLocalWorkContextForRepo } from "../local-state.js";
2
3
  /**
3
4
  * One attributed sync pass: scan both session stores, attribute what they hold,
@@ -39,6 +40,8 @@ import { readLocalWorkContextForRepo } from "../local-state.js";
39
40
  * `runtimeFiles`, or the repo tests stay green while the packed CLI breaks.
40
41
  */
41
42
  import os from "node:os";
43
+ import { RAW_EVIDENCE_DEFAULT_BYTE_BUDGET, RAW_EVIDENCE_DEFAULT_OBJECT_BUDGET } from "../adapters/raw-evidence.js";
44
+ import { syncOpenCodeSessions } from "./opencode-sync.js";
42
45
  import { getCollectorRuntimePaths, readLocalCollectorConfig, readLocalCollectorSessionFile } from "../local-state.js";
43
46
  import { reportShelvedSessions } from "../shelf-reports.js";
44
47
  import { splitScanByShelf } from "./session-sync-shelf.js";
@@ -106,7 +109,7 @@ export async function runAttributedWorktreeSync(requested) {
106
109
  return heldSyncRun(scannedAll);
107
110
  const shelfSplit = splitScanByShelf({ scan: scannedAll, worktrees: requested.worktrees, decision: shelfDecision });
108
111
  const scanned = shelfSplit.scan;
109
- const options = { ...requested, worktrees: shelfSplit.worktrees };
112
+ const options = { ...requested, worktrees: shelfSplit.worktrees, rawEvidenceBudget: requested.rawEvidenceBudget ?? { remainingBytes: RAW_EVIDENCE_DEFAULT_BYTE_BUDGET, remainingObjects: RAW_EVIDENCE_DEFAULT_OBJECT_BUDGET } };
110
113
  // BLI-17916: roots are a label, never a gate. Outside-root sessions ride this
111
114
  // tick's upload under the synthetic workspace, a few per tick, newest first.
112
115
  const scan = await admitOutsideRootSessions({
@@ -141,8 +144,22 @@ export async function runAttributedWorktreeSync(requested) {
141
144
  reportCountedSessionFacts(sessions);
142
145
  const shelfReports = await sendShelfReports(options, paths, shelfSplit, now);
143
146
  const run = await finishAttributedSync(options, { paths, now, plan, scan, sessions, worktreePass });
147
+ const opencode = await syncOpenCodeSessions({ homeDir, worktrees: requested.worktrees, collectionRoots: plan.collectionRoots, dashboardUrl: requested.dashboardUrl, fetchImpl: requested.fetchImpl, budget: options.rawEvidenceBudget });
148
+ const failures = createSyncFailureLedger();
149
+ for (const failure of run.failure_records)
150
+ failures.add(failure);
151
+ recordOpenCodeFailures(failures, opencode);
144
152
  return {
145
153
  ...run,
154
+ opencode,
155
+ summary: { ...run.summary, opencode },
156
+ sessions_new_this_tick: run.sessions_new_this_tick + opencode.new_since_last_scan,
157
+ sessions_outside_root: run.sessions_outside_root + opencode.outside_roots,
158
+ ok: run.ok && opencode.coverage !== "partial",
159
+ failure_reasons: [...run.failure_reasons, ...(opencode.coverage === "partial" ? opencode.reasons.length ? opencode.reasons : ["opencode_delivery_pending"] : [])],
160
+ failure_records: failures.sortedRecords(),
161
+ sessions_observed: run.sessions_observed + opencode.eligible,
162
+ sessions_pending_upload: run.sessions_pending_upload + opencode.pending,
146
163
  sessions_shelved: shelfSplit.shelved.length,
147
164
  packs_refused: worktreePass.packsRefused ?? 0,
148
165
  shelf_reports: shelfReports,