@north-light/cli 0.3.706 → 0.3.708
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +1 -2
- package/dist/api/client.js +3 -3
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/human.d.ts +9 -6
- package/dist/api/dto/inbox.d.ts +2 -0
- package/dist/api/dto/review-comments.d.ts +12 -35
- package/dist/api/dto/reviews.d.ts +3 -10
- package/dist/api/routes.d.ts +0 -1
- package/dist/api/routes.js +1 -1
- package/dist/builtin-memory/05-kinds/review/companion/00-base.md +2 -2
- package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
- package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
- package/dist/clients/attach/chrome/canvas-panels.js +1 -1
- package/dist/clients/attach/chrome/roster.js +6 -6
- package/dist/clients/attach/chrome/status-line.js +1 -1
- package/dist/clients/attach/chrome/ticket-panel.js +1 -1
- package/dist/clients/attach/input/controller.d.ts +0 -1
- package/dist/clients/attach/input/controller.js +3 -3
- package/dist/clients/attach/input/overlay-owner.d.ts +0 -1
- package/dist/clients/attach/input/overlay-owner.js +1 -1
- package/dist/clients/attach/session/keys.d.ts +0 -2
- package/dist/clients/attach/session/keys.js +1 -1
- package/dist/clients/attach/session/surface-host.d.ts +0 -5
- package/dist/clients/attach/session/surface-host.js +1 -1
- package/dist/clients/attach/viewer.js +545 -560
- package/dist/clients/editor-roundtrip.js +3 -0
- package/dist/clients/inbox/controller.d.ts +1 -6
- package/dist/clients/inbox/controller.js +1 -1
- package/dist/clients/inbox/dto-adapt.js +1 -1
- package/dist/clients/inbox/tui/page-body.js +1 -1
- package/dist/clients/inbox/tui/render.js +2 -2
- package/dist/clients/open-browser.d.ts +2 -0
- package/dist/clients/open-browser.js +1 -0
- package/dist/clients/surfaces/host.d.ts +0 -6
- package/dist/commands/human/review.js +1 -1
- package/dist/commands/sys/context/admin/shell.js +1 -1
- package/dist/core/canvas/schema-pg/025-review-anchors.sql +19 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/human/page-markdown.js +10 -12
- package/dist/core/human/tickets.js +1 -1
- package/dist/core/human/types.d.ts +4 -6
- package/dist/core/keybindings/attach-control.d.ts +0 -3
- package/dist/core/keybindings/attach-control.js +1 -1
- package/dist/core/keybindings/catalog.d.ts +1 -1
- package/dist/core/keybindings/catalog.js +1 -1
- package/dist/core/review/anchors.d.ts +28 -0
- package/dist/core/review/anchors.js +6 -0
- package/dist/core/review/comments.d.ts +2 -2
- package/dist/core/review/comments.js +7 -8
- package/dist/core/review/companion.d.ts +2 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/document.d.ts +4 -17
- package/dist/core/review/document.js +1 -2
- package/dist/core/review/fork.js +2 -4
- package/dist/core/review/project.d.ts +1 -1
- package/dist/core/review/project.js +2 -2
- package/dist/core/review/realize.js +1 -1
- package/dist/core/review/stage.d.ts +2 -9
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/types.d.ts +16 -12
- package/dist/core/review/types.js +1 -1
- package/dist/core/runtime/broker/turn-replies.d.ts +1 -3
- package/dist/core/runtime/broker-cli.js +3 -3
- package/dist/core/runtime/broker-extension-render.js +1 -1
- package/dist/core/runtime/tmux-bindings.js +3 -3
- package/dist/daemon/api/canvas-host.js +1 -1
- package/dist/daemon/api/document-page.d.ts +12 -1
- package/dist/daemon/api/document-page.js +6 -6
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/review-comments.js +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/review-page.d.ts +3 -0
- package/dist/daemon/api/review-page.js +13 -0
- package/dist/daemon/broker-memory-cap.d.ts +9 -0
- package/dist/daemon/broker-memory-cap.js +2 -0
- package/dist/daemon/broker-signals/bus.d.ts +1 -1
- package/dist/daemon/broker-signals/bus.js +1 -1
- package/dist/daemon/crtrd.js +14 -14
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/review/comment-notify.js +2 -2
- package/dist/daemon/review/deliver.d.ts +2 -2
- package/dist/daemon/review/deliver.js +6 -2
- package/dist/daemon/review/finish.js +1 -1
- package/dist/doc-editor/Geist-Variable.woff2 +0 -0
- package/dist/doc-editor/GeistMono-Variable.woff2 +0 -0
- package/dist/doc-editor/editor.css +1 -1
- package/dist/doc-editor/review.css +2 -0
- package/dist/doc-editor/review.js +149 -0
- package/dist/pi-extensions/canvas-review-boundary.js +3 -3
- package/dist/shared/turn-replies.d.ts +3 -3
- package/dist/shared/turn-replies.js +3 -3
- package/docs/sdk/release-notes.md +6 -0
- package/package.json +13 -4
- package/packages/crouter-api/dist/api/client.js +0 -3
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/api/routes.js +0 -1
- package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +3 -3
- package/packages/crouter-api/dist/clients/attach/chrome/roster.js +9 -20
- package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +1 -6
- package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +1 -1
- package/packages/crouter-api/dist/clients/attach/input/controller.js +0 -3
- package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +0 -7
- package/packages/crouter-api/dist/clients/attach/session/keys.js +0 -1
- package/packages/crouter-api/dist/clients/attach/session/surface-host.js +0 -17
- package/packages/crouter-api/dist/clients/attach/viewer.js +0 -37
- package/packages/crouter-api/dist/clients/{inbox/review/roundtrip.js → editor-roundtrip.js} +1 -1
- package/packages/crouter-api/dist/clients/inbox/controller.js +12 -31
- package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +1 -0
- package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +0 -7
- package/packages/crouter-api/dist/clients/inbox/tui/render.js +0 -7
- package/packages/crouter-api/dist/clients/open-browser.js +6 -0
- package/packages/crouter-api/dist/commands/human/review.js +17 -18
- package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +1 -1
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/human/page-markdown.js +2 -6
- package/packages/crouter-api/dist/core/human/tickets.js +2 -11
- package/packages/crouter-api/dist/core/keybindings/attach-control.js +0 -1
- package/packages/crouter-api/dist/core/keybindings/catalog.js +1 -3
- package/packages/crouter-api/dist/core/review/anchors.js +91 -0
- package/packages/crouter-api/dist/core/review/comments.js +27 -46
- package/packages/crouter-api/dist/core/review/companion.js +5 -9
- package/packages/crouter-api/dist/core/review/document.js +17 -89
- package/packages/crouter-api/dist/core/review/project.js +2 -1
- package/packages/crouter-api/dist/core/review/types.js +2 -2
- package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +0 -5
- package/packages/crouter-api/dist/daemon/api/map.js +2 -6
- package/packages/crouter-api/dist/daemon/broker-signals/bus.js +1 -1
- package/packages/crouter-api/dist/daemon/review/deliver.js +4 -3
- package/packages/crouter-api/dist/daemon/review/finish.js +26 -47
- package/packages/crouter-api/dist/shared/turn-replies.js +9 -14
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +1740 -505
- package/dist/clients/attach/overlays/file-review.d.ts +0 -10
- package/dist/clients/attach/overlays/file-review.js +0 -2
- package/dist/clients/inbox/review/anchors.d.ts +0 -41
- package/dist/clients/inbox/review/anchors.js +0 -1
- package/dist/clients/inbox/review/comments-client.d.ts +0 -74
- package/dist/clients/inbox/review/comments-client.js +0 -1
- package/dist/clients/inbox/review/companion-pane.d.ts +0 -47
- package/dist/clients/inbox/review/companion-pane.js +0 -1
- package/dist/clients/inbox/review/document-surface.d.ts +0 -212
- package/dist/clients/inbox/review/document-surface.js +0 -2
- package/dist/clients/inbox/review/frame.d.ts +0 -57
- package/dist/clients/inbox/review/frame.js +0 -1
- package/dist/clients/inbox/review/keys.d.ts +0 -69
- package/dist/clients/inbox/review/keys.js +0 -1
- package/dist/clients/inbox/review/launch.d.ts +0 -16
- package/dist/clients/inbox/review/launch.js +0 -1
- package/dist/clients/inbox/review/live-source.d.ts +0 -24
- package/dist/clients/inbox/review/live-source.js +0 -1
- package/dist/clients/inbox/review/nvim.d.ts +0 -15
- package/dist/clients/inbox/review/nvim.js +0 -1
- package/dist/clients/inbox/review/remap.d.ts +0 -51
- package/dist/clients/inbox/review/remap.js +0 -1
- package/dist/clients/inbox/review/review-client.d.ts +0 -43
- package/dist/clients/inbox/review/review-client.js +0 -1
- package/dist/clients/inbox/review/roundtrip.js +0 -3
- package/dist/clients/inbox/review/state.d.ts +0 -153
- package/dist/clients/inbox/review/state.js +0 -4
- package/dist/clients/inbox/review-adapter.d.ts +0 -17
- package/dist/clients/inbox/review-adapter.js +0 -1
- package/dist/core/review/remap.d.ts +0 -24
- package/dist/core/review/remap.js +0 -19
- package/dist/core/review/signal.d.ts +0 -5
- package/dist/core/review/signal.js +0 -1
- package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +0 -146
- package/packages/crouter-api/dist/clients/inbox/review/anchors.js +0 -89
- package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +0 -103
- package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +0 -109
- package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +0 -1268
- package/packages/crouter-api/dist/clients/inbox/review/frame.js +0 -309
- package/packages/crouter-api/dist/clients/inbox/review/keys.js +0 -133
- package/packages/crouter-api/dist/clients/inbox/review/launch.js +0 -170
- package/packages/crouter-api/dist/clients/inbox/review/live-source.js +0 -160
- package/packages/crouter-api/dist/clients/inbox/review/nvim.js +0 -43
- package/packages/crouter-api/dist/clients/inbox/review/remap.js +0 -157
- package/packages/crouter-api/dist/clients/inbox/review/review-client.js +0 -125
- package/packages/crouter-api/dist/clients/inbox/review/state.js +0 -315
- package/packages/crouter-api/dist/clients/inbox/review-adapter.js +0 -43
- package/packages/crouter-api/dist/core/review/signal.js +0 -12
- package/packages/crouter-api/dist/core/termrender/code-doc.js +0 -92
- /package/dist/clients/{inbox/review/roundtrip.d.ts → editor-roundtrip.d.ts} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { SurfaceHost } from '../../surfaces/host.js';
|
|
2
|
-
import { type ResolvedReview } from './review-client.js';
|
|
3
|
-
export interface ReviewSurfaceOptions {
|
|
4
|
-
review: ResolvedReview;
|
|
5
|
-
}
|
|
6
|
-
/** Open a dedicated viewer window for a review without replacing the caller's
|
|
7
|
-
* conversation window. The fresh viewer consumes the review id at startup. */
|
|
8
|
-
export declare function openReviewWindow(host: SurfaceHost, review: ResolvedReview): boolean;
|
|
9
|
-
/** The status-line toast shown once a review window opens. */
|
|
10
|
-
export declare function reviewOpenedMessage(toIndex: number, windowName: string, fromIndex: number | null): string;
|
|
11
|
-
/** Consume the review id handed to a dedicated attach viewer. */
|
|
12
|
-
export declare function takeStartupReviewId(): string | undefined;
|
|
13
|
-
/** Resolve and mount the review seeded into a dedicated viewer window. */
|
|
14
|
-
export declare function openReviewSurfaceById(host: SurfaceHost, reviewId: string): Promise<void>;
|
|
15
|
-
/** Mount the review document inside its dedicated viewer window. */
|
|
16
|
-
export declare function openReviewSurface(host: SurfaceHost, opts: ReviewSurfaceOptions): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var y=Object.defineProperty;var i=(e,o)=>y(e,"name",{value:o,configurable:!0});import{basename as g}from"node:path";import{displayMessage as C,getPaneOption as I,openNodeWindow as E,paneLocation as T,selectWindow as x,shellQuote as P,viewerSplitEnv as S,windowIndex as h}from"../../../core/runtime/placement-tmux.js";import{ReviewDocumentSurface as A}from"./document-surface.js";import{openLiveSource as _}from"./live-source.js";import{createReviewClient as R,ReviewTerminalError as N,terminalRefusalNotice as W}from"./review-client.js";const m="CRTR_ATTACH_REVIEW_ID";function B(e,o){if(e.capabilities.remote)return e.notice("The review is unavailable in a remote attach \u2014 the file and companion live on the host."),!1;const n=e.capabilities.selfPane;if(n===void 0||n==="")return e.notice("Opening a review needs a local viewer in tmux."),!1;const r=T(n),c=I(n,"@crtr_node");if(r===null||c===void 0||c==="")return e.notice("Could not resolve the current viewer for this review."),!1;const a=`review:${g(o.file)}`,l=E({session:r.session,name:a,cwd:o.cwd,env:{...S(),[m]:o.reviewId},command:`crtr surface attach to ${P(c)}`});if(l===null)return e.notice("tmux could not open the review window."),!1;const u=h(r.window),s=h(l.window);return x(r.session,l.window),s!==null&&C(k(s,a,u),n,5e3),!0}i(B,"openReviewWindow");function k(e,o,n){const r=n===null?"":n<=9?` \u2014 prefix ${n} returns to window ${n}`:` \u2014 you were in window ${n}`;return`Review opened in new window ${e} (${o})${r}`}i(k,"reviewOpenedMessage");function Q(){const e=process.env[m];return delete process.env[m],e===void 0||e===""?void 0:e}i(Q,"takeStartupReviewId");async function j(e,o){try{const n=await R().byId(o);await H(e,{review:n})}catch(n){e.notice(n instanceof N?W(n):`couldn't open review: ${f(n)}`)}}i(j,"openReviewSurfaceById");async function H(e,o){const n=o.review;let r;try{r=_(n.file)}catch(t){e.notice(`couldn't open ${n.file}: ${f(t)}`);return}let c=!1;const a=R({onTerminalConflict:i(t=>{c=!0,w(t)},"onTerminalConflict")}),l=a.comments(n.reviewId);let u,s=!1,p=!1;const d=new A({review:n,source:r,comments:l,callerPane:e.capabilities.selfPane,services:{notice:i((t,v)=>e.notice(t,v),"notice"),suspendForChild:i(()=>e.suspendForChild(),"suspendForChild"),requestClose:i(()=>u?.close(),"requestClose"),submit:i(()=>{b()},"submit"),cancel:i(()=>{$()},"cancel")}});await d.open(),u=e.mount(d),d.setHandle(u),setImmediate(()=>{d.openCompanion()});async function b(){if(!s){s=!0;try{const t=await a.submit(n.reviewId);if(t.outcome==="approved"){w(O(t));return}w("Review submitted before the companion finished \u2014 the agent resumes when the review completes.",{sticky:!0})}catch(t){if(c)return;s=!1,e.notice(`couldn't submit review: ${f(t)}`)}}}i(b,"submit");function w(t,v){d.teardown(t,v)}i(w,"finish");async function $(){if(!p){p=!0;try{await a.cancel(n.reviewId,"canceled from the review surface"),w("Review canceled.")}catch(t){if(c)return;p=!1,e.notice(`couldn't cancel review: ${f(t)}`)}}}i($,"cancel")}i(H,"openReviewSurface");function O(e){return e.changed?`Approved \u2014 the document changed during review. Result: ${e.resultPath}`:`Approved \u2014 the document was not modified. Result: ${e.resultPath}`}i(O,"approvalNotice");function f(e){return e instanceof Error?e.message:String(e)}i(f,"describeError");export{H as openReviewSurface,j as openReviewSurfaceById,B as openReviewWindow,k as reviewOpenedMessage,Q as takeStartupReviewId};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** The trailing delay used to collapse an editor's write/rename burst. */
|
|
2
|
-
export declare const COALESCE_MS = 120;
|
|
3
|
-
export type StaleReason = 'missing' | 'unreadable' | 'too-large' | 'binary';
|
|
4
|
-
export interface SourceSnapshot {
|
|
5
|
-
text: string;
|
|
6
|
-
lines: string[];
|
|
7
|
-
revision: number;
|
|
8
|
-
status: 'live' | 'stale';
|
|
9
|
-
staleReason?: StaleReason;
|
|
10
|
-
sha256: string;
|
|
11
|
-
loadedAt: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LiveSource {
|
|
14
|
-
current(): SourceSnapshot;
|
|
15
|
-
/** The text captured when the surface opened. */
|
|
16
|
-
openText(): string;
|
|
17
|
-
/** Fires only when text changes or the live/stale status flips. */
|
|
18
|
-
onChange(fn: (next: SourceSnapshot, previous: SourceSnapshot) => void): void;
|
|
19
|
-
/** Read immediately, bypassing the directory watcher and coalescing timer. */
|
|
20
|
-
refreshNow(): void;
|
|
21
|
-
close(): void;
|
|
22
|
-
}
|
|
23
|
-
/** Watch the containing directory so atomic replacement of the file remains live. */
|
|
24
|
-
export declare function openLiveSource(absFile: string): LiveSource;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var w=Object.defineProperty;var r=(t,e)=>w(t,"name",{value:e,configurable:!0});import{createHash as T}from"node:crypto";import{readFileSync as y,statSync as A,watch as C}from"node:fs";import{basename as E,dirname as k}from"node:path";import{documentLines as x}from"../../../core/document-lines.js";import{checkReviewableFile as R}from"../../../core/human/visible-paths.js";const L=120;function N(t){return T("sha256").update(t,"utf8").digest("hex")}r(N,"hashText");function O(t){return t.includes("UTF-8")?"binary":t.includes("too large")||t.includes("too long")?"too-large":"unreadable"}r(O,"staleReasonFromCheck");function p(t){try{if(!A(t).isFile())return{status:"stale",reason:"missing"}}catch(a){return{status:"stale",reason:a.code==="ENOENT"?"missing":"unreadable"}}const e=R(t);if(!e.ok)return e.reason==="not a file"?{status:"stale",reason:"unreadable"}:{status:"stale",reason:O(e.reason)};try{const a=y(t,"utf8");return{status:"live",text:a,sha256:N(a),loadedAt:new Date().toISOString()}}catch{return{status:"stale",reason:"unreadable"}}}r(p,"readSource");function b(t){const e=p(t);if(e.status==="stale")throw new Error(`Unable to open live source ${t}: ${e.reason}`);return{text:e.text,lines:x(e.text),revision:0,status:"live",sha256:e.sha256,loadedAt:e.loadedAt}}r(b,"initialSnapshot");function M(t){let e=b(t);const a=e.text,c=new Set,g=E(t);let l,i,o=!1;const f=r(()=>{if(o)return;const s=p(t),n=e;if(s.status==="stale"){const u={...n,status:"stale",staleReason:s.reason};if(e=u,n.status===u.status)return;for(const S of c)o||S(u,n);return}const d=s.text!==n.text,h=n.status!=="live",m={text:s.text,lines:d?x(s.text):n.lines,revision:n.revision+(d?1:0),status:"live",sha256:s.sha256,loadedAt:d||h?s.loadedAt:n.loadedAt};if(e=m,!(!d&&!h))for(const u of c)o||u(m,n)},"refreshNow"),v=r(()=>{o||(i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,o||f()},L))},"scheduleRefresh");try{l=C(k(t),(s,n)=>{!o&&n!==null&&String(n)===g&&v()}),l.on("error",()=>{})}catch{}return{current:r(()=>e,"current"),openText:r(()=>a,"openText"),onChange:r(s=>{o||c.add(s)},"onChange"),refreshNow:f,close:r(()=>{if(!o){o=!0,i!==void 0&&(clearTimeout(i),i=void 0),c.clear();try{l?.close()}catch{}l=void 0}},"close")}}r(M,"openLiveSource");export{L as COALESCE_MS,M as openLiveSource};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Open the reviewed file in the user's configured editor, optionally at a specific line.
|
|
3
|
-
* Resolves $VISUAL, then $EDITOR, then the first installed of nano/pico/micro/nvim/vim/vi.
|
|
4
|
-
* The configured value may be a shell fragment such as "code --wait" — it runs whole
|
|
5
|
-
* through /bin/sh, exactly like the comment-compose round-trip editor.
|
|
6
|
-
* For vi-family editors (nvim, vim, vi, view), passes the line with the +line syntax.
|
|
7
|
-
* For other editors, opens the file without line positioning.
|
|
8
|
-
*
|
|
9
|
-
* @param absFile - Absolute path to the file to edit
|
|
10
|
-
* @param line - 1-based line number (only used for vi-family editors)
|
|
11
|
-
* @returns An object with an optional `error` property if the editor launch or execution failed
|
|
12
|
-
*/
|
|
13
|
-
export declare function openReviewedFileInEditor(absFile: string, line: number): {
|
|
14
|
-
error?: string;
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var o=(t,n)=>a(t,"name",{value:n,configurable:!0});import{spawnSync as l}from"node:child_process";import{announceFallbackEditor as c,editorBasename as u,isViFamilyEditor as $,NO_EDITOR_MESSAGE as d,resolveEditor as E}from"../../../core/editor-resolver.js";function I(t,n){const s=E();if(s===null)return{error:d};const e=s.command,i=$(e)||u(e)==="nano"?` "+${n}"`:"";try{c(s);const r=l("/bin/sh",["-c",`${e}${i} "$1"`,"sh",t],{stdio:"inherit"});return r.error?{error:`$EDITOR ("${e}") failed to launch: ${r.error.message}`}:r.signal!==null?{error:`$EDITOR ("${e}") was killed by signal ${r.signal}`}:r.status===127||r.status===126?{error:`$EDITOR ("${e}") failed to launch (shell exit ${r.status}) \u2014 check $VISUAL/$EDITOR`}:r.status!==0?{error:`$EDITOR ("${e}") exited with code ${r.status}`}:{}}catch(r){return{error:r instanceof Error?r.message:String(r)}}}o(I,"openReviewedFileInEditor");export{I as openReviewedFileInEditor};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Line-based range remapping with whole-line LCS.
|
|
3
|
-
*
|
|
4
|
-
* Normalizes lines, trims common prefix/suffix, applies monotone LCS to the
|
|
5
|
-
* middle section, and builds a stable mapping from old→new line numbers.
|
|
6
|
-
* Remapped ranges become detached when no line survives, shifted when partly
|
|
7
|
-
* deleted, or kept when both endpoints are unmoved.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* A monotone partial mapping from old line numbers to new ones (both 0-based).
|
|
11
|
-
* Returns undefined when a line was deleted.
|
|
12
|
-
*/
|
|
13
|
-
export interface LineMap {
|
|
14
|
-
get(oldLine: number): number | undefined;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The result of remapping a range: kept (unmoved), shifted (partially survived),
|
|
18
|
-
* or detached (no lines survived).
|
|
19
|
-
*/
|
|
20
|
-
export type RemapResult = {
|
|
21
|
-
kind: 'kept';
|
|
22
|
-
line: number;
|
|
23
|
-
endLine: number;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'shifted';
|
|
26
|
-
line: number;
|
|
27
|
-
endLine: number;
|
|
28
|
-
} | {
|
|
29
|
-
kind: 'detached';
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Build a monotone line-number mapping from old→new using LCS.
|
|
33
|
-
*
|
|
34
|
-
* - Normalizes all lines using D14: `line.replace(/\s+/g, ' ').trim()`
|
|
35
|
-
* - Trims common prefix and suffix before LCS
|
|
36
|
-
* - Applies whole-line LCS to the middle section
|
|
37
|
-
* - Returns a map where `get(oldLine)` is the new line number or undefined
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildLineMap(oldLines: readonly string[], newLines: readonly string[]): LineMap;
|
|
40
|
-
/**
|
|
41
|
-
* Remap a range [line, endLine) using the built LineMap.
|
|
42
|
-
*
|
|
43
|
-
* Returns:
|
|
44
|
-
* - `kept`: both endpoints are unmoved
|
|
45
|
-
* - `shifted`: the range is partially deleted; maps to the min/max of survivors
|
|
46
|
-
* - `detached`: no lines from the range survived
|
|
47
|
-
*/
|
|
48
|
-
export declare function remapRange(map: LineMap, range: {
|
|
49
|
-
line: number;
|
|
50
|
-
endLine: number;
|
|
51
|
-
}): RemapResult;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var x=Object.defineProperty;var u=(r,f)=>x(r,"name",{value:f,configurable:!0});function m(r){return r.replace(/\s+/g," ").trim()}u(m,"normalizeLine");function k(r,f){const i=r.map(m),l=f.map(m);let e=0;const s=Math.min(i.length,l.length);for(;e<s&&i[e]===l[e];)e++;let n=0;const c=Math.min(i.length-e,l.length-e);for(;n<c&&i[i.length-1-n]===l[l.length-1-n];)n++;const o=i.length-n,t=l.length-n,g=i.slice(e,o),p=l.slice(e,t),M=L(g,p),a=new Map;for(let d=0;d<e;d++)a.set(d,d);M.forEach((d,h)=>{a.set(e+h,e+d)});for(let d=0;d<n;d++){const h=o+d,w=t+d;a.set(h,w)}return{get(d){return a.get(d)}}}u(k,"buildLineMap");function L(r,f){const i=r.length,l=f.length;if(i===0||l===0)return new Map;const e=Array(i+1).fill(null).map(()=>Array(l+1).fill(0));for(let o=1;o<=i;o++)for(let t=1;t<=l;t++)r[o-1]===f[t-1]?e[o][t]=e[o-1][t-1]+1:e[o][t]=Math.max(e[o-1][t],e[o][t-1]);const s=new Map;let n=i,c=l;for(;n>0&&c>0;)r[n-1]===f[c-1]?(s.set(n-1,c-1),n--,c--):e[n-1][c]>e[n][c-1]?n--:c--;return s}u(L,"computeLCS");function v(r,f){const i=f.line,l=f.endLine;let e,s;for(let o=i;o<l;o++){const t=r.get(o);t!==void 0&&((e===void 0||t<e)&&(e=t),(s===void 0||t>s)&&(s=t))}if(e===void 0)return{kind:"detached"};const n=r.get(i),c=r.get(l-1);return n===i&&c===l-1?{kind:"kept",line:n,endLine:c+1}:{kind:"shifted",line:e,endLine:s+1}}u(v,"remapRange");export{k as buildLineMap,v as remapRange};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type CommentAuthority } from './comments-client.js';
|
|
2
|
-
export declare class ReviewTerminalError extends Error {
|
|
3
|
-
readonly state: 'approved' | 'canceled';
|
|
4
|
-
readonly resultPath?: string;
|
|
5
|
-
readonly reason?: string;
|
|
6
|
-
constructor(state: 'approved', resultPath: string);
|
|
7
|
-
constructor(state: 'canceled', reason?: string);
|
|
8
|
-
}
|
|
9
|
-
export interface ResolvedReview {
|
|
10
|
-
reviewId: string;
|
|
11
|
-
companionNodeId: string;
|
|
12
|
-
file: string;
|
|
13
|
-
cwd: string;
|
|
14
|
-
}
|
|
15
|
-
export interface ReviewClient {
|
|
16
|
-
byId(reviewId: string): Promise<ResolvedReview>;
|
|
17
|
-
/** Exactly one of a file path or a document ref. */
|
|
18
|
-
createInline(p: {
|
|
19
|
-
originNodeId: string;
|
|
20
|
-
} & ({
|
|
21
|
-
file: string;
|
|
22
|
-
} | {
|
|
23
|
-
document: string;
|
|
24
|
-
})): Promise<ResolvedReview>;
|
|
25
|
-
comments(reviewId: string): CommentAuthority;
|
|
26
|
-
submit(reviewId: string): Promise<SubmitDisposition>;
|
|
27
|
-
cancel(reviewId: string, reason: string): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
/** An approval that landed, or one the daemon is holding for the companion. */
|
|
30
|
-
export type SubmitDisposition = {
|
|
31
|
-
outcome: 'approved';
|
|
32
|
-
changed: boolean;
|
|
33
|
-
resultPath: string;
|
|
34
|
-
} | {
|
|
35
|
-
outcome: 'awaiting_companion';
|
|
36
|
-
};
|
|
37
|
-
export interface ReviewClientOptions {
|
|
38
|
-
onTerminalConflict?: (notice: string) => void;
|
|
39
|
-
}
|
|
40
|
-
/** The terminal's complete daemon seam for review lifecycle and comment operations. */
|
|
41
|
-
export declare function createReviewClient(opts?: ReviewClientOptions): ReviewClient;
|
|
42
|
-
export declare function terminalRefusalNotice(error: ReviewTerminalError): string;
|
|
43
|
-
export declare function terminalConflictNotice(error: unknown): string | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=Object.defineProperty;var r=(e,i)=>u(e,"name",{value:i,configurable:!0});import{randomUUID as l}from"node:crypto";import{ApiError as f}from"../../../api/errors.js";import{filesCrossByUpload as p,uploadNodeFile as w}from"../../../core/storage/node-transfer.js";import{cliClient as o}from"../../../commands/api-client.js";import{createCommentAuthority as m}from"./comments-client.js";class s extends Error{static{r(this,"ReviewTerminalError")}state;resultPath;reason;constructor(i,n){if(i==="approved"){if(n===void 0||n==="")throw new Error("approved review omitted its canonical result path");super(`review is already approved; see ${n}`),this.resultPath=n}else super(n===void 0||n===""?"review is already canceled":`review is already canceled: ${n}`),n!==void 0&&n!==""&&(this.reason=n);this.name="ReviewTerminalError",this.state=i}}function E(e={}){const i=r(async n=>{try{return await n()}catch(t){const a=_(t);throw a!==void 0&&e.onTerminalConflict?.(a),t}},"request");return{async byId(n){const t=await i(()=>o().getReview(n));return await d(t,t.companion_node_id,i)},async createInline(n){const t="file"in n&&p()?await w(n.file):void 0,a=await i(()=>o().createReview({origin_kind:"inline",origin_node_id:n.originNodeId,..."file"in n?t!==void 0?{file_upload_id:t}:{file:n.file}:{document:n.document},idempotency_key:l()}));return await d(a,a.companion_node_id,i)},comments(n){return m(n,i)},async submit(n){const t=await i(()=>o().submitReview(n));return t.outcome==="awaiting_companion"?{outcome:"awaiting_companion"}:{outcome:"approved",changed:v(t.review),resultPath:c(t.review)}},async cancel(n,t){await i(()=>o().cancelReview(n,{reason:t,actor:"human",disposition:"dismissed"}))}}}r(E,"createReviewClient");async function d(e,i,n){if(e.state!=="open")throw h(e);const t=await n(()=>o().getNode(i));return{reviewId:e.review_id,companionNodeId:i,file:e.file,cwd:t.cwd}}r(d,"resolveReview");function h(e){if(e.state!=="approved"&&e.state!=="canceled")throw new Error(`terminal review ${e.review_id} has invalid state ${e.state}`);return e.state==="approved"?new s("approved",c(e)):new s("canceled",e.cancel_reason)}r(h,"terminalError");function v(e){if(typeof e.changed!="boolean")throw new Error(`approved review ${e.review_id} omitted its changed disposition`);return e.changed}r(v,"requireChanged");function c(e){if(typeof e.result_path!="string"||e.result_path==="")throw new Error(`terminal review ${e.review_id} omitted its canonical result path`);return e.result_path}r(c,"requireResultPath");function C(e){return e.state==="approved"?`This review was already approved. Result: ${e.resultPath??"unknown"}`:e.reason===void 0||e.reason===""?"This review was canceled.":`This review was canceled: ${e.reason}`}r(C,"terminalRefusalNotice");function _(e){if(!(e instanceof f)||e.status!==409||e.code!=="review_terminal_conflict")return;const i=e.details?.review;if(i!==void 0){if(i.state==="approved")return i.result_path===void 0?"This review was already approved by someone else.":`This review was already approved by someone else. Result: ${i.result_path}`;if(i.state==="canceled")return i.cancel_reason===void 0||i.cancel_reason===""?"This review was canceled before this submission landed.":`This review was canceled before this submission landed: ${i.cancel_reason}`}}r(_,"terminalConflictNotice");export{s as ReviewTerminalError,E as createReviewClient,_ as terminalConflictNotice,C as terminalRefusalNotice};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var l=Object.defineProperty;var s=(r,e)=>l(r,"name",{value:e,configurable:!0});import{readFileSync as a,unlinkSync as c,writeFileSync as d}from"node:fs";import{spawnSync as m}from"node:child_process";import{randomUUID as u}from"node:crypto";import{tmpdir as $}from"node:os";import{join as p}from"node:path";import{announceFallbackEditor as E,NO_EDITOR_MESSAGE as h,resolveEditor as x}from"../../../core/editor-resolver.js";function R(r){const e=p($(),`crtr-input-${u()}.txt`),o=x();if(o===null)return{text:r,error:h};const i=o.command;try{d(e,r),E(o);const t=m("/bin/sh",["-c",`${i} "$1"`,"sh",e],{stdio:"inherit"});if(t.error)return{text:r,error:`$EDITOR ("${i}") failed to launch: ${t.error.message}`};if(t.signal!==null)return{text:r,error:`$EDITOR ("${i}") was killed by signal ${t.signal}`};if(t.status===127||t.status===126)return{text:r,error:`$EDITOR ("${i}") failed to launch (shell exit ${t.status})`};if(t.status!==0)return{text:r,error:`$EDITOR ("${i}") exited with status ${t.status}`};let n=a(e,"utf8");return n.endsWith(`
|
|
2
|
-
`)&&!r.endsWith(`
|
|
3
|
-
`)&&(n=n.slice(0,-1)),{text:n}}catch(t){return{text:r,error:`$EDITOR round-trip failed: ${t instanceof Error?t.message:String(t)}`}}finally{try{c(e)}catch{}}}s(R,"editBufferInEditor");export{R as editBufferInEditor};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import type { AnchoredComment } from './comments-client.js';
|
|
2
|
-
import type { RenderedDoc } from '../../../core/termrender/termrender.js';
|
|
3
|
-
import { type AnchorDoc, type AnchorUnit } from './anchors.js';
|
|
4
|
-
export interface ComposeState {
|
|
5
|
-
buffer: string;
|
|
6
|
-
cursor: number;
|
|
7
|
-
/** Id of the comment being edited, or null when composing a new comment. */
|
|
8
|
-
editingId: string | null;
|
|
9
|
-
/** Submode to return to once compose closes (Escape or a successful save). */
|
|
10
|
-
returnMode: 'view' | 'list';
|
|
11
|
-
anchor: {
|
|
12
|
-
line: number;
|
|
13
|
-
endLine: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface ReviewState {
|
|
17
|
-
sourceLines: string[];
|
|
18
|
-
/** Ordered leaf anchor units. Never empty. */
|
|
19
|
-
units: AnchorUnit[];
|
|
20
|
-
/** Per rendered row: owning unit index, or null for separator rows. */
|
|
21
|
-
rowUnits: (number | null)[];
|
|
22
|
-
/** Current comment projection supplied by the daemon. */
|
|
23
|
-
comments: AnchoredComment[];
|
|
24
|
-
/** Revision of the live source snapshot the rendered units came from. */
|
|
25
|
-
sourceRevision: number;
|
|
26
|
-
/** Original ranges for comments whose current source range no longer survives. */
|
|
27
|
-
detached: Record<string, {
|
|
28
|
-
line: number;
|
|
29
|
-
endLine: number;
|
|
30
|
-
}>;
|
|
31
|
-
/** 0-based index of the anchored unit. */
|
|
32
|
-
activeUnit: number;
|
|
33
|
-
/** Set while a Shift+j/k range is being extended from this unit. */
|
|
34
|
-
selectionAnchor: number | null;
|
|
35
|
-
/** Scroll offset into the rendered (termrender) lines. */
|
|
36
|
-
scroll: number;
|
|
37
|
-
/** Horizontal pan offset, in display cells, for rows wider than the body
|
|
38
|
-
* rectangle (diagrams). Rows that fit never move. */
|
|
39
|
-
hscroll: number;
|
|
40
|
-
mode: 'view' | 'list' | 'compose' | 'help';
|
|
41
|
-
compose: ComposeState | null;
|
|
42
|
-
listIndex: number;
|
|
43
|
-
}
|
|
44
|
-
/** Best unit for a source line: the NARROWEST unit containing it — code/table
|
|
45
|
-
* chrome units carry their whole block's range and sit before the per-line
|
|
46
|
-
* content units in rendered order, so "first whose end reaches the line"
|
|
47
|
-
* would wrongly pick the chrome over the exact code line. A line no unit
|
|
48
|
-
* contains (a blank separator) snaps forward to the next unit; past the end
|
|
49
|
-
* clamps to the last. */
|
|
50
|
-
export declare function initReviewState(sourceLines: string[], anchor: AnchorDoc, comments: AnchoredComment[], sourceRevision: number): ReviewState;
|
|
51
|
-
export declare function selectedUnitBounds(state: ReviewState): {
|
|
52
|
-
lo: number;
|
|
53
|
-
hi: number;
|
|
54
|
-
};
|
|
55
|
-
/** Source-line anchor of the current unit selection — what a committed
|
|
56
|
-
* comment records as `line`/`endLine`. Whole-block chrome units can carry a
|
|
57
|
-
* wider range than their neighbors, so take the min/max over the selection
|
|
58
|
-
* rather than trusting the endpoints alone. */
|
|
59
|
-
export declare function currentAnchor(state: ReviewState): {
|
|
60
|
-
line: number;
|
|
61
|
-
endLine: number;
|
|
62
|
-
};
|
|
63
|
-
export declare function moveActiveUnit(state: ReviewState, delta: number, extend: boolean): ReviewState;
|
|
64
|
-
/** Unit indices overlapped by any existing comment's source range. A projected
|
|
65
|
-
* range lying wholly past the last unit (the file shrank before its range was
|
|
66
|
-
* remapped) still gets a marker on its clamped unit, so every comment is
|
|
67
|
-
* visible somewhere in the document. */
|
|
68
|
-
export declare function commentedUnitSet(state: ReviewState): Set<number>;
|
|
69
|
-
/** First/last rendered-row indices spanned by units `lo..hi`, or null when
|
|
70
|
-
* the indices fall outside the unit list. */
|
|
71
|
-
export declare function anchorRowRange(units: AnchorUnit[], lo: number, hi: number): {
|
|
72
|
-
first: number;
|
|
73
|
-
last: number;
|
|
74
|
-
} | null;
|
|
75
|
-
/** Minimal scroll adjustment that keeps rows `first..last` visible with
|
|
76
|
-
* `margin` rows of context (the margin yields whenever honoring it would push
|
|
77
|
-
* either edge of the span out of view); a taller-than-view span pins `first`
|
|
78
|
-
* at the top — one row down when scrolled, so the `↑ more above` indicator
|
|
79
|
-
* overwrites the preceding row, never the pinned one. Always returns a scroll
|
|
80
|
-
* clamped to the document. */
|
|
81
|
-
export declare function scrollToReveal(scroll: number, first: number, last: number, bodyHeight: number, total: number, margin?: number): number;
|
|
82
|
-
/** Auto-scroll so the active unit (the moving edge of a selection) is
|
|
83
|
-
* visible. The wheel free-scrolls and is untouched until the next anchor move. */
|
|
84
|
-
export declare function ensureAnchorVisible(state: ReviewState, doc: RenderedDoc, bodyHeight: number): ReviewState;
|
|
85
|
-
export declare function scrollBy(state: ReviewState, delta: number, bodyHeight: number, totalLines: number): ReviewState;
|
|
86
|
-
/** Rows one `u`/`d` press travels: half the visible body, and never fewer than
|
|
87
|
-
* one row, so a diagram taller than the pane cannot hold the document still. */
|
|
88
|
-
export declare function halfPageRows(bodyHeight: number): number;
|
|
89
|
-
/** Move the view by `rows` and carry the anchored unit the same distance, so
|
|
90
|
-
* the selection keeps its place on screen rather than being left behind. The
|
|
91
|
-
* selection lands on the unit owning the row it would occupy after the move,
|
|
92
|
-
* clamped into the rows the frame actually paints; at the end of the document,
|
|
93
|
-
* where the view can no longer move, the selection walks the rest on its own. */
|
|
94
|
-
export declare function moveViewRows(state: ReviewState, rows: number, bodyHeight: number, totalRows: number): ReviewState;
|
|
95
|
-
export declare function openComposeNew(state: ReviewState): ReviewState;
|
|
96
|
-
export declare function openComposeEdit(state: ReviewState, index: number): ReviewState;
|
|
97
|
-
export declare function closeCompose(state: ReviewState): ReviewState;
|
|
98
|
-
export interface ComposeCommit {
|
|
99
|
-
editingId: string | null;
|
|
100
|
-
anchor: {
|
|
101
|
-
line: number;
|
|
102
|
-
endLine: number;
|
|
103
|
-
};
|
|
104
|
-
text: string;
|
|
105
|
-
}
|
|
106
|
-
/** Closes compose and returns the daemon mutation payload. The daemon projection, not this reducer, repaints comments. */
|
|
107
|
-
export declare function commitCompose(state: ReviewState): {
|
|
108
|
-
state: ReviewState;
|
|
109
|
-
commit: ComposeCommit | null;
|
|
110
|
-
};
|
|
111
|
-
export declare function openList(state: ReviewState): ReviewState;
|
|
112
|
-
export declare function closeList(state: ReviewState): ReviewState;
|
|
113
|
-
export declare function moveListIndex(state: ReviewState, delta: number): ReviewState;
|
|
114
|
-
export declare function deleteAtListIndex(state: ReviewState): {
|
|
115
|
-
state: ReviewState;
|
|
116
|
-
id: string | null;
|
|
117
|
-
};
|
|
118
|
-
export declare function undoLast(state: ReviewState): {
|
|
119
|
-
state: ReviewState;
|
|
120
|
-
id: string | null;
|
|
121
|
-
};
|
|
122
|
-
export declare function openHelp(state: ReviewState): ReviewState;
|
|
123
|
-
export declare function closeHelp(state: ReviewState): ReviewState;
|
|
124
|
-
export declare function cleanPastedText(input: string): string;
|
|
125
|
-
export declare function textInsert(buffer: string, cursor: number, text: string): {
|
|
126
|
-
buffer: string;
|
|
127
|
-
cursor: number;
|
|
128
|
-
};
|
|
129
|
-
export declare function textBackspace(buffer: string, cursor: number): {
|
|
130
|
-
buffer: string;
|
|
131
|
-
cursor: number;
|
|
132
|
-
};
|
|
133
|
-
export declare function textDelete(buffer: string, cursor: number): {
|
|
134
|
-
buffer: string;
|
|
135
|
-
cursor: number;
|
|
136
|
-
};
|
|
137
|
-
export declare function textHome(buffer: string, cursor: number): number;
|
|
138
|
-
export declare function textEnd(buffer: string, cursor: number): number;
|
|
139
|
-
export declare function textVertical(buffer: string, cursor: number, delta: number): number;
|
|
140
|
-
/** Vertical motion by *visual* row (what up/down mean in a wrapped compose box):
|
|
141
|
-
* a long soft-wrapped comment has many rows even though it is one logical
|
|
142
|
-
* line. Shares `verticalCursor` with the frame renderer's own wrap. */
|
|
143
|
-
export declare function textVerticalWrapped(buffer: string, cursor: number, delta: number, width: number): number;
|
|
144
|
-
/** Start of the word before the cursor (readline alt-b / alt+left). Shares one
|
|
145
|
-
* word-motion implementation with the page compose box. */
|
|
146
|
-
export declare function textWordLeft(buffer: string, cursor: number): number;
|
|
147
|
-
/** Just past the end of the word after the cursor (readline alt-f / alt+right). */
|
|
148
|
-
export declare function textWordRight(buffer: string, cursor: number): number;
|
|
149
|
-
/** Delete back to the start of the previous word (alt+backspace / ctrl+w). */
|
|
150
|
-
export declare function textWordBackspace(buffer: string, cursor: number): {
|
|
151
|
-
buffer: string;
|
|
152
|
-
cursor: number;
|
|
153
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var M=Object.defineProperty;var r=(n,t)=>M(n,"name",{value:t,configurable:!0});import{verticalCursor as v,wordLeftIndex as g,wordRightIndex as w}from"../tui/render.js";import{unitIndexForLine as h,unitRangeForSpan as U}from"./anchors.js";function j(n,t,e,o){const i=t.units.length>0?t:{units:[{start:1,end:Math.max(1,n.length),firstRow:0,lastRow:0}],rowUnits:t.rowUnits};return{sourceLines:n,units:i.units,rowUnits:i.rowUnits,comments:[...e],sourceRevision:o,detached:Object.fromEntries(e.flatMap(c=>c.anchorStatus==="detached"?[[c.id,c.originalRange??{line:c.line,endLine:c.endLine}]]:[])),activeUnit:e.length>0?h(i.units,e[0].line):0,selectionAnchor:null,scroll:0,hscroll:0,mode:"view",compose:null,listIndex:0}}r(j,"initReviewState");function I(n){const t=n.selectionAnchor??n.activeUnit;return{lo:Math.min(n.activeUnit,t),hi:Math.max(n.activeUnit,t)}}r(I,"selectedUnitBounds");function L(n){const{lo:t,hi:e}=I(n);let o=Number.POSITIVE_INFINITY,i=0;for(let c=t;c<=e;c++){const l=n.units[c];l!==void 0&&(o=Math.min(o,l.start),i=Math.max(i,l.end))}return Number.isFinite(o)?{line:o,endLine:Math.max(o,i)}:{line:1,endLine:Math.max(1,n.sourceLines.length)}}r(L,"currentAnchor");function C(n,t,e){const o=Math.max(0,n.units.length-1),i=Math.max(0,Math.min(o,n.activeUnit+t));return e?{...n,activeUnit:i,selectionAnchor:n.selectionAnchor??n.activeUnit}:{...n,activeUnit:i,selectionAnchor:null}}r(C,"moveActiveUnit");function V(n){const t=new Set;for(const e of n.comments){if(e.status==="deleted"||e.anchorStatus==="detached")continue;let o=!1;n.units.forEach((i,c)=>{i.start<=e.endLine&&i.end>=e.line&&(t.add(c),o=!0)}),o||t.add(h(n.units,e.line))}return t}r(V,"commentedUnitSet");function R(n,t,e){const o=n[t],i=n[e];return o===void 0||i===void 0?null:{first:o.firstRow,last:i.lastRow}}r(R,"anchorRowRange");function A(n,t,e,o,i,c=2){const l=Math.max(0,i-o);let u=Math.max(0,Math.min(n,l));return e-t+1>=o?Math.max(0,Math.min(Math.max(0,t-1),l)):(t-c<u?u=Math.max(t-c,e-(o-1)):e+c>u+o-1&&(u=Math.min(e+c-(o-1),t)),Math.max(0,Math.min(u,l)))}r(A,"scrollToReveal");function b(n,t,e){const o=R(n.units,n.activeUnit,n.activeUnit);if(o===null)return n;const i=A(n.scroll,o.first,o.last,e,t.lines.length);return i===n.scroll?n:{...n,scroll:i}}r(b,"ensureAnchorVisible");function P(n,t,e,o){const i=Math.max(0,o-e);return{...n,scroll:Math.max(0,Math.min(n.scroll+t,i))}}r(P,"scrollBy");function T(n){return Math.max(1,Math.floor(n/2))}r(T,"halfPageRows");function W(n,t,e,o){if(t===0)return n;const i=t>0?1:-1,c=Math.max(0,o-e),l=Math.max(0,Math.min(n.scroll+t,c)),u=l+(l>0?1:0),a=Math.max(u,l+e-1-(l+e<o?1:0)),m=n.units[n.activeUnit]?.firstRow??n.scroll,d=Math.max(u,Math.min(m+t,a)),f=S(n,d,u,a,i)??n.activeUnit;return l===n.scroll&&f===n.activeUnit?n:{...n,scroll:l,activeUnit:f,selectionAnchor:null}}r(W,"moveViewRows");function S(n,t,e,o,i){const c=Math.max(0,n.units.length-1);for(let l=0;l<=o-e;l++)for(const u of[t+l*i,t-l*i]){if(u<e||u>o)continue;const a=n.rowUnits[u];if(a!=null)return Math.max(0,Math.min(c,a))}return null}r(S,"unitNearRow");function k(n){return{...n,mode:"compose",compose:{buffer:"",cursor:0,editingId:null,returnMode:"view",anchor:L(n)}}}r(k,"openComposeNew");function O(n,t){const e=n.comments[t];if(e===void 0)return n;const o=e.comment,{lo:i,hi:c}=U(n.units,e.line,e.endLine);return{...n,activeUnit:c,selectionAnchor:i===c?null:i,mode:"compose",compose:{buffer:o,cursor:[...o].length,editingId:e.id,returnMode:"list",anchor:{line:e.line,endLine:e.endLine}}}}r(O,"openComposeEdit");function p(n){const t=n.compose?.returnMode??"view";return{...n,mode:t,compose:null}}r(p,"closeCompose");function z(n){const t=n.compose;if(t==null)return{state:n,commit:null};const e=t.buffer.trim();return e.length===0?{state:p(n),commit:null}:{state:p(n),commit:{editingId:t.editingId,anchor:t.anchor,text:e}}}r(z,"commitCompose");function D(n){return{...n,mode:"list",listIndex:Math.max(0,Math.min(n.listIndex,n.comments.length-1))}}r(D,"openList");function Y(n){return{...n,mode:"view"}}r(Y,"closeList");function Z(n,t){if(n.comments.length===0)return n;const e=Math.max(0,Math.min(n.comments.length-1,n.listIndex+t));return{...n,listIndex:e}}r(Z,"moveListIndex");function _(n){const t=n.comments[n.listIndex];return{state:n,id:t?.id??null}}r(_,"deleteAtListIndex");function q(n){return{state:n,id:n.comments.at(-1)?.id??null}}r(q,"undoLast");function G(n){return{...n,mode:"help"}}r(G,"openHelp");function J(n){return{...n,mode:"view"}}r(J,"closeHelp");function s(n){return[...n]}r(s,"codePoints");function K(n){return n.replace(/\x1b\[20[01]~/g,"").replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,"").replace(/\r\n?/g,`
|
|
2
|
-
`).replace(/[\x00-\x09\x0B-\x1F\x7F]/g,"")}r(K,"cleanPastedText");function Q(n,t,e){const o=s(n),i=Math.max(0,Math.min(t,o.length));return{buffer:[...o.slice(0,i),...s(e),...o.slice(i)].join(""),cursor:i+s(e).length}}r(Q,"textInsert");function X(n,t){if(t<=0)return{buffer:n,cursor:t};const e=s(n);return{buffer:[...e.slice(0,t-1),...e.slice(t)].join(""),cursor:t-1}}r(X,"textBackspace");function $(n,t){const e=s(n);return t>=e.length?{buffer:n,cursor:t}:{buffer:[...e.slice(0,t),...e.slice(t+1)].join(""),cursor:t}}r($,"textDelete");function x(n,t){let e=t;for(;e>0&&n[e-1]!==`
|
|
3
|
-
`;)e--;let o=t;for(;o<n.length&&n[o]!==`
|
|
4
|
-
`;)o++;return{start:e,end:o}}r(x,"lineBoundsAt");function H(n,t){return x(s(n),t).start}r(H,"textHome");function y(n,t){return x(s(n),t).end}r(y,"textEnd");function nn(n,t,e){const o=s(n),{start:i,end:c}=x(o,t),l=t-i;if(e<0){if(i===0)return t;const m=i-1,d=x(o,m).start;return Math.min(m,d+l)}if(c>=o.length)return t;const u=c+1,a=x(o,u).end;return Math.min(a,u+l)}r(nn,"textVertical");function tn(n,t,e,o){return v(n,t,e,o)}r(tn,"textVerticalWrapped");function E(n,t){return g(n,t)}r(E,"textWordLeft");function en(n,t){return w(n,t)}r(en,"textWordRight");function on(n,t){const e=s(n),o=Math.max(0,Math.min(t,e.length)),i=E(n,o);return i===o?{buffer:n,cursor:o}:{buffer:[...e.slice(0,i),...e.slice(o)].join(""),cursor:i}}r(on,"textWordBackspace");export{R as anchorRowRange,K as cleanPastedText,p as closeCompose,J as closeHelp,Y as closeList,V as commentedUnitSet,z as commitCompose,L as currentAnchor,_ as deleteAtListIndex,b as ensureAnchorVisible,T as halfPageRows,j as initReviewState,C as moveActiveUnit,Z as moveListIndex,W as moveViewRows,O as openComposeEdit,k as openComposeNew,G as openHelp,D as openList,P as scrollBy,A as scrollToReveal,I as selectedUnitBounds,X as textBackspace,$ as textDelete,y as textEnd,H as textHome,Q as textInsert,nn as textVertical,tn as textVerticalWrapped,on as textWordBackspace,E as textWordLeft,en as textWordRight,q as undoLast};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { SurfaceHost } from '../surfaces/host.js';
|
|
2
|
-
export interface ReviewAdapterOptions {
|
|
3
|
-
host: SurfaceHost;
|
|
4
|
-
/** The review request's own id — the same id its inbox row carries. */
|
|
5
|
-
reviewId: string;
|
|
6
|
-
}
|
|
7
|
-
/** Resolve a durable review ticket and open it in its own tmux window. */
|
|
8
|
-
export declare class ReviewAdapter {
|
|
9
|
-
private readonly opts;
|
|
10
|
-
private running;
|
|
11
|
-
private stopped;
|
|
12
|
-
constructor(opts: ReviewAdapterOptions);
|
|
13
|
-
/** Resolves true once the review window has opened and been selected. */
|
|
14
|
-
start(): Promise<boolean>;
|
|
15
|
-
stop(): Promise<void>;
|
|
16
|
-
private run;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var n=(t,i)=>s(t,"name",{value:i,configurable:!0});import{openReviewWindow as r}from"./review/launch.js";import{createReviewClient as o,ReviewTerminalError as a,terminalRefusalNotice as u}from"./review/review-client.js";class f{static{n(this,"ReviewAdapter")}opts;running=null;stopped=!1;constructor(i){this.opts=i}start(){return this.running!==null?this.running:(this.running=this.run(),this.running)}async stop(){this.stopped=!0,this.running!==null&&await this.running}async run(){if(this.opts.host.capabilities.remote)return this.opts.host.notice("The review is unavailable in a remote attach \u2014 the file and companion live on the host."),!1;let i;try{i=await o().byId(this.opts.reviewId)}catch(e){return this.opts.host.notice(h(e)),!1}return!this.stopped&&r(this.opts.host,i)}}function h(t){return t instanceof a?u(t):t instanceof Error?t.message:String(t)}n(h,"noticeForLookupFailure");export{f as ReviewAdapter};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type CommentAnchor, type CommentAuthorKind } from './types.js';
|
|
2
|
-
export interface RangeBatchEntry {
|
|
3
|
-
comment_id: string;
|
|
4
|
-
anchor?: CommentAnchor;
|
|
5
|
-
detached?: true;
|
|
6
|
-
}
|
|
7
|
-
interface Actor {
|
|
8
|
-
kind: CommentAuthorKind;
|
|
9
|
-
node_id: string | null;
|
|
10
|
-
}
|
|
11
|
-
/** Atomically replace every live review coordinate with ranges expressed against the current source. */
|
|
12
|
-
export declare function applyRangeBatch(args: {
|
|
13
|
-
review_id: string;
|
|
14
|
-
from_doc_hash: string;
|
|
15
|
-
to_doc_hash: string;
|
|
16
|
-
entries: RangeBatchEntry[];
|
|
17
|
-
actor: Actor;
|
|
18
|
-
operation_id: string;
|
|
19
|
-
}): Promise<{
|
|
20
|
-
updated: number;
|
|
21
|
-
detached: number;
|
|
22
|
-
anchor_base_sha256: string;
|
|
23
|
-
}>;
|
|
24
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var q=Object.defineProperty;var r=(e,o)=>q(e,"name",{value:o,configurable:!0});import{withCanvasWrite as A}from"../canvas/db.js";import{nowIso as S}from"../fs-utils.js";import{signalReviewActivity as k}from"./signal.js";import{replaceAnchorBaseLocked as T}from"./store.js";import{ReviewOperationError as h}from"./types.js";import{captureAnchorText as b,readReviewSource as O,validateAnchorShape as N}from"./document.js";function D(e){return{line:e.anchor_line,end_line:e.anchor_end_line,...e.anchor_col_start===null?{}:{col_start:e.anchor_col_start},...e.anchor_col_end===null?{}:{col_end:e.anchor_col_end},...e.anchor_quote===null?{}:{quote:e.anchor_quote}}}r(D,"anchorFromRow");function p(e,o,c,i){throw new h("range_batch_stale","review comment ranges are stale",{reason:e,expected:o,actual:c,...i===void 0?{}:{comment_id:i}})}r(p,"rangeBatchStale");function I(e){if(typeof e.comment_id!="string"||e.comment_id==="")throw new h("invalid_anchor","comment anchor is invalid",{violations:["comment_id must be a non-empty string"]});const o=e.anchor!==void 0,c=e.detached===!0;if(o===c)throw new h("invalid_anchor","comment anchor is invalid",{violations:["each range batch entry must provide exactly one of anchor or detached"]});o&&N(e.anchor)}r(I,"validateEntry");async function L(e,o){await e.prepare(`
|
|
2
|
-
INSERT INTO review_comment_events
|
|
3
|
-
(review_id, comment_id, kind, state_change, revision_after, actor_kind, actor_node_id, at, operation_id, payload)
|
|
4
|
-
SELECT review_id, ?, 'reanchored', 1, ?, ?, ?, ?, ?, ?
|
|
5
|
-
FROM review_comments WHERE comment_id = ?
|
|
6
|
-
`).run(o.row.comment_id,o.row.revision+1,o.actor.kind,o.actor.node_id,o.at,o.operation_id,JSON.stringify({previous_anchor:o.previous_anchor,anchor:o.anchor,previous_anchor_state:o.previous_anchor_state,anchor_state:o.anchor_state,previous_doc_hash:o.previous_doc_hash,doc_hash:o.doc_hash,line_text:o.line_text}),o.row.comment_id)}r(L,"appendReanchorEvent");async function U(e){const o=await A(async c=>{const i=await c.prepare("SELECT file, anchor_base_sha256 FROM human_requests WHERE request_id = ? AND kind = 'review' AND state = 'open'").get(e.review_id);if(i===void 0)throw new h("unknown_review","review was not found",{received:e.review_id});const a=await O(i.file,"comment");a.sha256!==e.to_doc_hash&&p("to_doc_hash",e.to_doc_hash,a.sha256),i.anchor_base_sha256!==e.from_doc_hash&&p("from_doc_hash",i.anchor_base_sha256,e.from_doc_hash);const d=await c.prepare(`
|
|
7
|
-
SELECT comment_id, status, revision, text, anchor_line, anchor_end_line,
|
|
8
|
-
anchor_col_start, anchor_col_end, anchor_quote, anchor_line_text,
|
|
9
|
-
anchor_doc_hash, anchor_state
|
|
10
|
-
FROM review_comments
|
|
11
|
-
WHERE review_id = ? AND status != 'deleted'
|
|
12
|
-
ORDER BY created_seq
|
|
13
|
-
`).all(e.review_id);for(const n of d)n.anchor_doc_hash!==e.from_doc_hash&&p("comment_hash",e.from_doc_hash,n.anchor_doc_hash,n.comment_id);const _=new Map,s=[];for(const n of e.entries)I(n),_.has(n.comment_id)?s.push(n.comment_id):_.set(n.comment_id,n);const y=new Set(d.map(n=>n.comment_id));for(const n of _.keys())y.has(n)||s.push(n);const v=d.filter(n=>!_.has(n.comment_id)).map(n=>n.comment_id);if(v.length>0||s.length>0)throw new h("range_batch_incomplete","range batch must cover every non-deleted comment exactly once",{missing:v,extra:s});let f=0,w=0;const E=S();for(const n of d){const m=_.get(n.comment_id),x=D(n),t=m.detached===!0?x:m.anchor,l=m.detached===!0?"detached":"live",u=m.detached===!0?n.anchor_line_text:b(a.lines,t);if(!(n.anchor_state!==l||n.anchor_doc_hash!==a.sha256||n.anchor_line!==t.line||n.anchor_end_line!==t.end_line||n.anchor_col_start!==(t.col_start??null)||n.anchor_col_end!==(t.col_end??null)||n.anchor_quote!==(t.quote??null)||n.anchor_line_text!==u))continue;const R=n.revision+1;await c.prepare(`
|
|
14
|
-
UPDATE review_comments
|
|
15
|
-
SET revision = ?, anchor_line = ?, anchor_end_line = ?, anchor_col_start = ?, anchor_col_end = ?,
|
|
16
|
-
anchor_quote = ?, anchor_line_text = ?, anchor_doc_hash = ?, anchor_state = ?,
|
|
17
|
-
updated_by_kind = ?, updated_by_node_id = ?, updated_at = ?
|
|
18
|
-
WHERE comment_id = ?
|
|
19
|
-
`).run(R,t.line,t.end_line,t.col_start??null,t.col_end??null,t.quote??null,u,a.sha256,l,e.actor.kind,e.actor.node_id,E,n.comment_id),await L(c,{row:n,actor:e.actor,operation_id:e.operation_id,at:E,previous_anchor:x,anchor:t,previous_anchor_state:n.anchor_state,anchor_state:l,previous_doc_hash:n.anchor_doc_hash,doc_hash:a.sha256,line_text:u}),f+=1,l==="detached"&&(w+=1)}return await T(c,e.review_id,a.bytes,a.sha256),{updated:f,detached:w,anchor_base_sha256:a.sha256}});return k(),o}r(U,"applyRangeBatch");export{U as applyRangeBatch};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Signal one durable review mutation to every open viewer without watching every review directory. */
|
|
2
|
-
export declare function reviewActivityPath(): string;
|
|
3
|
-
/** Signal one review mutation (comment create/edit/resolve/delete/reanchor/delivery) to every open review surface. */
|
|
4
|
-
export declare function signalReviewActivity(): void;
|
|
5
|
-
export declare function watchReviewActivity(onChange: () => void): () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var v=Object.defineProperty;var t=(i,e)=>v(i,"name",{value:e,configurable:!0});import{activityPath as c,signalActivity as r,watchActivity as a}from"../activity-signal.js";function o(){return c("review-activity")}t(o,"reviewActivityPath");function w(){r("review-activity")}t(w,"signalReviewActivity");function u(i){return a("review-activity",i)}t(u,"watchReviewActivity");export{o as reviewActivityPath,w as signalReviewActivity,u as watchReviewActivity};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
-
import { Input, SelectList, getKeybindings, } from '@earendil-works/pi-tui';
|
|
4
|
-
import { getSelectListTheme } from '@earendil-works/pi-coding-agent';
|
|
5
|
-
import { openReviewWindow } from '../../inbox/review/launch.js';
|
|
6
|
-
import { createReviewClient, ReviewTerminalError, terminalRefusalNotice } from '../../inbox/review/review-client.js';
|
|
7
|
-
import { checkReviewableFile, extractFilePaths } from '../../../core/human/visible-paths.js';
|
|
8
|
-
import { docLinkText } from '../render/doc-links.js';
|
|
9
|
-
const MAX_VISIBLE_ROWS = 12;
|
|
10
|
-
/** A candidate naming a canvas document, as `[[ref]]`. */
|
|
11
|
-
function documentRef(candidate) {
|
|
12
|
-
const match = /^\[\[([^[\]\n]+)\]\]$/.exec(candidate.trim());
|
|
13
|
-
return match === null ? undefined : match[1].trim();
|
|
14
|
-
}
|
|
15
|
-
function labelForPath(file, cwd) {
|
|
16
|
-
const ref = documentRef(file);
|
|
17
|
-
if (ref !== undefined)
|
|
18
|
-
return `${docLinkText(ref)} (document)`;
|
|
19
|
-
const rel = relative(cwd, file);
|
|
20
|
-
if (rel !== '' && !rel.startsWith('..') && !isAbsolute(rel))
|
|
21
|
-
return rel;
|
|
22
|
-
const home = homedir();
|
|
23
|
-
return file === home || file.startsWith(`${home}/`) ? `~${file.slice(home.length)}` : file;
|
|
24
|
-
}
|
|
25
|
-
function resolveTypedPath(value, cwd) {
|
|
26
|
-
const expanded = value === '~' ? homedir() : value.startsWith('~/') ? join(homedir(), value.slice(2)) : value;
|
|
27
|
-
return resolve(cwd, expanded);
|
|
28
|
-
}
|
|
29
|
-
class FileReviewPicker {
|
|
30
|
-
candidates;
|
|
31
|
-
cwd;
|
|
32
|
-
onChoose;
|
|
33
|
-
close;
|
|
34
|
-
notify;
|
|
35
|
-
focused = false;
|
|
36
|
-
input = new Input();
|
|
37
|
-
list = new SelectList([], MAX_VISIBLE_ROWS, getSelectListTheme());
|
|
38
|
-
constructor(candidates, cwd, onChoose, close, notify) {
|
|
39
|
-
this.candidates = candidates;
|
|
40
|
-
this.cwd = cwd;
|
|
41
|
-
this.onChoose = onChoose;
|
|
42
|
-
this.close = close;
|
|
43
|
-
this.notify = notify;
|
|
44
|
-
this.input.onEscape = close;
|
|
45
|
-
this.input.onSubmit = () => this.chooseSelected();
|
|
46
|
-
this.refreshList();
|
|
47
|
-
}
|
|
48
|
-
render(width) {
|
|
49
|
-
this.input.focused = this.focused;
|
|
50
|
-
const inputWidth = Math.max(1, width - 8);
|
|
51
|
-
return [
|
|
52
|
-
'Review a file or document named in this transcript',
|
|
53
|
-
...this.input.render(inputWidth).map((line) => `Path: ${line}`),
|
|
54
|
-
...this.list.render(width),
|
|
55
|
-
];
|
|
56
|
-
}
|
|
57
|
-
handleInput(data) {
|
|
58
|
-
const kb = getKeybindings();
|
|
59
|
-
if (kb.matches(data, 'tui.select.up') || kb.matches(data, 'tui.select.down')) {
|
|
60
|
-
this.list.handleInput(data);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (kb.matches(data, 'tui.select.confirm') || data === '\n') {
|
|
64
|
-
this.chooseSelected();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const before = this.input.getValue();
|
|
68
|
-
this.input.handleInput(data);
|
|
69
|
-
if (this.input.getValue() !== before)
|
|
70
|
-
this.refreshList();
|
|
71
|
-
}
|
|
72
|
-
invalidate() {
|
|
73
|
-
this.input.invalidate();
|
|
74
|
-
this.list.invalidate();
|
|
75
|
-
}
|
|
76
|
-
refreshList() {
|
|
77
|
-
const typed = this.input.getValue();
|
|
78
|
-
const query = typed.toLowerCase();
|
|
79
|
-
const matches = this.candidates.filter((file) => {
|
|
80
|
-
const label = labelForPath(file, this.cwd).toLowerCase();
|
|
81
|
-
return query === '' || label.includes(query) || file.toLowerCase().includes(query);
|
|
82
|
-
});
|
|
83
|
-
const typedPath = typed === '' ? undefined : documentRef(typed) !== undefined ? typed.trim() : resolveTypedPath(typed, this.cwd);
|
|
84
|
-
const hasExactCandidate = typedPath !== undefined && this.candidates.some((file) => file === typedPath);
|
|
85
|
-
// Matches first: typing is primarily a filter, so Enter picks the best
|
|
86
|
-
// visible match. The free-typed path is the escape hatch and sits last —
|
|
87
|
-
// it is selected by default only when nothing matches.
|
|
88
|
-
const items = [
|
|
89
|
-
// No description: the label already IS the path, and a detail column
|
|
90
|
-
// repeating it just spends width twice on the same string.
|
|
91
|
-
...matches.map((file) => ({ value: file, label: labelForPath(file, this.cwd) })),
|
|
92
|
-
...(typedPath !== undefined && !hasExactCandidate
|
|
93
|
-
? [{ value: typedPath, label: `use ${JSON.stringify(typed)}`, description: typedPath }]
|
|
94
|
-
: []),
|
|
95
|
-
];
|
|
96
|
-
this.list = new SelectList(items, MAX_VISIBLE_ROWS, getSelectListTheme());
|
|
97
|
-
this.list.onSelect = () => this.chooseSelected();
|
|
98
|
-
this.list.onCancel = this.close;
|
|
99
|
-
}
|
|
100
|
-
chooseSelected() {
|
|
101
|
-
const typed = this.input.getValue();
|
|
102
|
-
const item = this.list.getSelectedItem();
|
|
103
|
-
const picked = item?.value ?? typed;
|
|
104
|
-
if (picked === '')
|
|
105
|
-
return;
|
|
106
|
-
if (documentRef(picked) !== undefined) {
|
|
107
|
-
this.onChoose(picked);
|
|
108
|
-
this.close();
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const file = resolveTypedPath(picked, this.cwd);
|
|
112
|
-
const check = checkReviewableFile(file);
|
|
113
|
-
if (!check.ok) {
|
|
114
|
-
this.notify(check.reason);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
this.onChoose(file);
|
|
118
|
-
this.close();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export function buildFileReviewPicker(candidates, cwd, onChoose, close, notify) {
|
|
122
|
-
const picker = new FileReviewPicker(candidates, cwd, onChoose, close, notify);
|
|
123
|
-
return { component: picker, focus: picker };
|
|
124
|
-
}
|
|
125
|
-
/** Open an inline review of a file path, or of a document given as `[[ref]]`. */
|
|
126
|
-
export async function launchFileReview(host, file, opts) {
|
|
127
|
-
// The refusal precedes the record creation: a remote viewer can reach neither
|
|
128
|
-
// the reviewed file nor the companion's pane.
|
|
129
|
-
if (host.capabilities.remote) {
|
|
130
|
-
opts.onNotice('The review is unavailable in a remote attach — the file and companion live on the host.');
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const document = documentRef(file);
|
|
134
|
-
let review;
|
|
135
|
-
try {
|
|
136
|
-
review = await createReviewClient().createInline(document === undefined
|
|
137
|
-
? { originNodeId: opts.originNodeId, file }
|
|
138
|
-
: { originNodeId: opts.originNodeId, document });
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
opts.onNotice(err instanceof ReviewTerminalError ? terminalRefusalNotice(err) : err instanceof Error ? err.message : String(err));
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
openReviewWindow(host, review);
|
|
145
|
-
}
|
|
146
|
-
export { extractFilePaths };
|