@dexhq/canvas 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +5 -3
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +9 -9
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +88 -8
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +88 -8
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +4 -0
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/config/project-files.d.mts +6 -0
- package/dist/config/project-files.mjs +14 -2
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -62
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +27 -13
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +33 -48
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +2 -2
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +67 -17
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.mjs +1 -1
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +9 -9
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +7 -1
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/hook.ts +4 -1
- package/src/config/project-files.ts +21 -6
- package/src/config/renamed.ts +0 -3
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -241
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/channel.ts +94 -52
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +36 -15
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/web-app.ts +11 -9
- package/src/setup/create.ts +91 -17
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect.ts +0 -4
- package/src/setup/project.ts +9 -8
- package/src/setup/starters.ts +8 -1
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
package/dist/server/me.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Contributor } from "../
|
|
1
|
+
import { Contributor } from "../shared/studio-files.mjs";
|
|
2
2
|
//#region src/server/me.d.ts
|
|
3
3
|
/** The person's git user name, or "" when git has none. */
|
|
4
4
|
export declare const gitUser: (content: string) => Promise<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ThreadWithPrototype } from "../shared/threads-core.mjs";
|
|
2
|
+
import { PresenceEntry } from "../shared/presence-core.mjs";
|
|
2
3
|
import { SavedFocus } from "./state.mjs";
|
|
3
4
|
//#region src/server/open-page.d.ts
|
|
4
5
|
/** A section of the canvas, as an agent reads it. */
|
|
@@ -44,6 +45,27 @@ export type WhereThePersonIs = {
|
|
|
44
45
|
export declare function agoFrom(ms: number): string;
|
|
45
46
|
/** Where the person is in Dex, or that nobody has it open. */
|
|
46
47
|
export declare function whereThePersonIs(root: string, now?: number): Promise<WhereThePersonIs>;
|
|
48
|
+
/** An agent the canvas shows at work on a file, as an agent reads it (`where`). */
|
|
49
|
+
export interface AtWork {
|
|
50
|
+
agent: string;
|
|
51
|
+
/**
|
|
52
|
+
* Whose mark it is: the agent reading it (its own session, or the Claude
|
|
53
|
+
* Code session it serves, sub-agents too), another session on this
|
|
54
|
+
* machine, or a teammate in the live workspace.
|
|
55
|
+
*/
|
|
56
|
+
by: "you" | "another session" | "a teammate";
|
|
57
|
+
/** When it ends, unless it is marked again or its work ends first. */
|
|
58
|
+
ends: string;
|
|
59
|
+
/** When it was last marked. */
|
|
60
|
+
marked: string;
|
|
61
|
+
/** "view:<name>", "doc:<name>", or "prototype": shared code, so every view. */
|
|
62
|
+
on: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Who the canvas shows at work on file `slug`, from the fresh `entries`, as
|
|
66
|
+
* the agent whose marks are under the sessions `mine` reads it.
|
|
67
|
+
*/
|
|
68
|
+
export declare const atWorkOn: (entries: readonly PresenceEntry[], slug: string, mine: readonly string[]) => AtWork[];
|
|
47
69
|
/** A thread with whether it is on the page the person has open. */
|
|
48
70
|
export interface PlacedThread<T> {
|
|
49
71
|
onOpenPage: boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { canvasFrames, frameTitle, parseFrameKey, viewOf } from "../shared/canvas-core.mjs";
|
|
2
|
+
import { fromRoom } from "../shared/live-presence.mjs";
|
|
3
|
+
import { endsAt, underSession } from "../shared/presence-core.mjs";
|
|
1
4
|
import { readFocus } from "./state.mjs";
|
|
2
5
|
import { prototypeTitle } from "../content/prototypes.mjs";
|
|
3
|
-
import { canvasFrames, frameTitle, parseFrameKey, viewOf } from "../shared/canvas-core.mjs";
|
|
4
6
|
import { readCanvas } from "../content/content.mjs";
|
|
5
7
|
import { plural } from "./response-budget.mjs";
|
|
6
8
|
import { onOpenPage } from "../shared/open-page-core.mjs";
|
|
@@ -76,6 +78,22 @@ async function whereThePersonIs(root, now = Date.now()) {
|
|
|
76
78
|
};
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
81
|
+
* Who the canvas shows at work on file `slug`, from the fresh `entries`, as
|
|
82
|
+
* the agent whose marks are under the sessions `mine` reads it.
|
|
83
|
+
*/
|
|
84
|
+
const atWorkOn = (entries, slug, mine) => entries.filter((entry) => entry.slug === slug).map((entry) => {
|
|
85
|
+
let by = "another session";
|
|
86
|
+
if (fromRoom(entry)) by = "a teammate";
|
|
87
|
+
else if (mine.some((session) => underSession(entry.session, session))) by = "you";
|
|
88
|
+
return {
|
|
89
|
+
agent: entry.agent,
|
|
90
|
+
on: entry.target,
|
|
91
|
+
by,
|
|
92
|
+
marked: entry.updated,
|
|
93
|
+
ends: new Date(endsAt(entry)).toISOString()
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
79
97
|
* Threads with those on the page the person has open first, then the rest
|
|
80
98
|
* of the open file's, then other files', each part in the order it came in.
|
|
81
99
|
* As they came when nobody has a file open.
|
|
@@ -98,4 +116,4 @@ function openPageFirst(threads, focus) {
|
|
|
98
116
|
}));
|
|
99
117
|
}
|
|
100
118
|
//#endregion
|
|
101
|
-
export { agoFrom, openPageFirst, whereThePersonIs };
|
|
119
|
+
export { agoFrom, atWorkOn, openPageFirst, whereThePersonIs };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/server/outcome.d.ts
|
|
2
|
+
/** What kind of refusal a problem is. */
|
|
3
|
+
export type ProblemKind = "not-found" | "conflict" | "invalid" | "not-allowed";
|
|
4
|
+
/** Why an action did not happen, in words for people: most say one thing. */
|
|
5
|
+
export interface Problem {
|
|
6
|
+
kind: ProblemKind;
|
|
7
|
+
messages: string[];
|
|
8
|
+
}
|
|
9
|
+
/** What an action did, or the problem that stopped it. */
|
|
10
|
+
export type Outcome<T> = {
|
|
11
|
+
problem?: undefined;
|
|
12
|
+
value: T;
|
|
13
|
+
} | {
|
|
14
|
+
problem: Problem;
|
|
15
|
+
value?: undefined;
|
|
16
|
+
};
|
|
17
|
+
/** An action refused, of `kind`, with what to tell people. */
|
|
18
|
+
export declare const refused: (kind: ProblemKind, messages: string[]) => {
|
|
19
|
+
problem: Problem;
|
|
20
|
+
value?: undefined;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { youOf } from "../shared/studio-routes.mjs";
|
|
2
|
-
import { prototypePaths, viewFiles } from "../content/prototypes.mjs";
|
|
3
2
|
import { stepsOf } from "../shared/canvas-core.mjs";
|
|
3
|
+
import { prototypePaths, viewFiles } from "../content/prototypes.mjs";
|
|
4
|
+
import { groupWork } from "./work-groups.mjs";
|
|
4
5
|
import { openThreads } from "../content/thread-module.mjs";
|
|
5
6
|
import { currentPerson, identify, joinCurrentPerson, placeViewFrame, readCanvas } from "../content/content.mjs";
|
|
6
|
-
import { groupWork } from "./work-groups.mjs";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
package/dist/server/people.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Contributor } from "../
|
|
1
|
+
import { Contributor } from "../shared/studio-files.mjs";
|
|
2
2
|
import { Person } from "../shared/studio-routes.mjs";
|
|
3
3
|
//#region src/server/people.d.ts
|
|
4
4
|
/** What git's log says of each author, by name in lower case. */
|
package/dist/server/port.d.mts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ViteDevServer } from "vite";
|
|
2
2
|
//#region src/server/port.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Whether anything listens on `port` where `localhost` may reach it, on
|
|
5
|
+
* either address family.
|
|
6
|
+
*/
|
|
7
|
+
export declare function heldOnLocalhost(port: number): Promise<boolean>;
|
|
3
8
|
/** A web app answering on a port, as its manifest says. */
|
|
4
9
|
interface AppOnPort {
|
|
5
10
|
/** Its project, as a Dex names it in PROJECT_ID_HEADER. */
|
|
@@ -17,6 +22,8 @@ export interface PortHolder {
|
|
|
17
22
|
}
|
|
18
23
|
/** The process listening on the port, as lsof names it, where there is lsof. */
|
|
19
24
|
export declare function lsofHolder(port: number): Promise<PortHolder | undefined>;
|
|
25
|
+
/** A Dex on a port that isn't this project's, as a person is told of it. */
|
|
26
|
+
export declare const OTHER_DEX = "another checkout's Dex";
|
|
20
27
|
/** What holds a port `dex dev` wanted. */
|
|
21
28
|
export interface PortTaken {
|
|
22
29
|
/**
|
|
@@ -48,6 +55,11 @@ export interface ListenOptions {
|
|
|
48
55
|
/** The project's root, to tell its own Dex on the port from another's. */
|
|
49
56
|
root?: string;
|
|
50
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The port `server` is served on, once it listens. listenOnPort may have
|
|
60
|
+
* moved it off the configured one.
|
|
61
|
+
*/
|
|
62
|
+
export declare function servedPort(server: ViteDevServer): number;
|
|
51
63
|
/** How many ports past a taken one `dex dev` tries. */
|
|
52
64
|
export declare const MOVE_TRIES = 20;
|
|
53
65
|
/**
|
package/dist/server/port.mjs
CHANGED
|
@@ -2,10 +2,39 @@ import { MANIFEST_FILE } from "../shared/studio-routes.mjs";
|
|
|
2
2
|
import { projectId } from "./project-id.mjs";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
|
+
import { connect } from "node:net";
|
|
5
6
|
//#region src/server/port.ts
|
|
6
7
|
const IN_USE_RE = /already in use/;
|
|
7
8
|
const ASK_TIMEOUT_MS = 1e3;
|
|
8
9
|
const run = promisify(execFile);
|
|
10
|
+
/** Where `localhost` may reach a port: either family. */
|
|
11
|
+
const LOCALHOST_ADDRESSES = ["127.0.0.1", "::1"];
|
|
12
|
+
/**
|
|
13
|
+
* How long a connection on loopback may take: one is made at once, but
|
|
14
|
+
* Windows takes seconds to refuse one.
|
|
15
|
+
*/
|
|
16
|
+
const CONNECT_TIMEOUT_MS = 250;
|
|
17
|
+
/** Whether anything accepts a connection on `port` at `host`. */
|
|
18
|
+
const accepts = (port, host) => new Promise((answer) => {
|
|
19
|
+
const socket = connect({
|
|
20
|
+
port,
|
|
21
|
+
host
|
|
22
|
+
});
|
|
23
|
+
const done = (listens) => {
|
|
24
|
+
socket.destroy();
|
|
25
|
+
answer(listens);
|
|
26
|
+
};
|
|
27
|
+
socket.once("connect", () => done(true));
|
|
28
|
+
socket.once("error", () => done(false));
|
|
29
|
+
socket.setTimeout(CONNECT_TIMEOUT_MS, () => setImmediate(() => done(false)));
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Whether anything listens on `port` where `localhost` may reach it, on
|
|
33
|
+
* either address family.
|
|
34
|
+
*/
|
|
35
|
+
async function heldOnLocalhost(port) {
|
|
36
|
+
return (await Promise.all(LOCALHOST_ADDRESSES.map((host) => accepts(port, host).catch(() => false)))).includes(true);
|
|
37
|
+
}
|
|
9
38
|
/** The web app on the port, another Dex included, from its manifest. */
|
|
10
39
|
async function appOn(port) {
|
|
11
40
|
try {
|
|
@@ -43,6 +72,8 @@ async function lsofHolder(port) {
|
|
|
43
72
|
return;
|
|
44
73
|
}
|
|
45
74
|
}
|
|
75
|
+
/** A Dex on a port that isn't this project's, as a person is told of it. */
|
|
76
|
+
const OTHER_DEX = "another checkout's Dex";
|
|
46
77
|
/** The port `dex dev` keeps to is taken; `taken` says by what. */
|
|
47
78
|
var PortInUseError = class extends Error {
|
|
48
79
|
taken;
|
|
@@ -65,9 +96,36 @@ async function whatHolds(port, id, holderOf = lsofHolder) {
|
|
|
65
96
|
sameProject: Boolean(id && app?.id === id)
|
|
66
97
|
};
|
|
67
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The port `server` is served on, once it listens. listenOnPort may have
|
|
101
|
+
* moved it off the configured one.
|
|
102
|
+
*/
|
|
103
|
+
function servedPort(server) {
|
|
104
|
+
const address = server.httpServer?.address();
|
|
105
|
+
return typeof address === "object" && address ? address.port : server.config.server.port;
|
|
106
|
+
}
|
|
68
107
|
/** How many ports past a taken one `dex dev` tries. */
|
|
69
108
|
const MOVE_TRIES = 20;
|
|
70
109
|
/**
|
|
110
|
+
* Listen on `port`: false when anything holds it. Vite's listen fails
|
|
111
|
+
* only for a holder of the very address it takes (the one `localhost`
|
|
112
|
+
* resolves to first, or STUDIO_HOST's). Yet a browser, and Dex itself,
|
|
113
|
+
* reach the studio at `localhost`, where a holder on the other family,
|
|
114
|
+
* or (on macOS) on a narrower or wider address, would answer instead:
|
|
115
|
+
* that is taken too. Any other failure closes the server and throws.
|
|
116
|
+
*/
|
|
117
|
+
async function listenIfFree(server, port) {
|
|
118
|
+
if (await heldOnLocalhost(port)) return false;
|
|
119
|
+
try {
|
|
120
|
+
await server.listen(port);
|
|
121
|
+
return true;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (error instanceof Error && IN_USE_RE.test(error.message)) return false;
|
|
124
|
+
await server.close();
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
71
129
|
* Listen on the configured port, or, while anything but this project's
|
|
72
130
|
* Dex holds it, on the next free one: answers what held the port it moved
|
|
73
131
|
* from, undefined when it did not move. Otherwise closes the server and
|
|
@@ -79,28 +137,22 @@ async function listenOnPort(server, { holderOf = lsofHolder, keepPort = false, r
|
|
|
79
137
|
let movedFrom;
|
|
80
138
|
for (let port = wanted; port < wanted + 20; port += 1) {
|
|
81
139
|
server.config.server.port = port;
|
|
82
|
-
|
|
83
|
-
await server.listen(port);
|
|
140
|
+
if (await listenIfFree(server, port)) {
|
|
84
141
|
server.config.inlineConfig.server = {
|
|
85
142
|
...server.config.inlineConfig.server,
|
|
86
143
|
port
|
|
87
144
|
};
|
|
88
145
|
return movedFrom;
|
|
89
|
-
} catch (error) {
|
|
90
|
-
if (!(error instanceof Error && IN_USE_RE.test(error.message))) {
|
|
91
|
-
await server.close();
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
const taken = await whatHolds(port, id, holderOf);
|
|
95
|
-
if (keepPort || taken.sameProject) {
|
|
96
|
-
await server.close();
|
|
97
|
-
throw new PortInUseError(taken);
|
|
98
|
-
}
|
|
99
|
-
movedFrom ??= taken;
|
|
100
146
|
}
|
|
147
|
+
const taken = await whatHolds(port, id, holderOf);
|
|
148
|
+
if (keepPort || taken.sameProject) {
|
|
149
|
+
await server.close();
|
|
150
|
+
throw new PortInUseError(taken);
|
|
151
|
+
}
|
|
152
|
+
movedFrom ??= taken;
|
|
101
153
|
}
|
|
102
154
|
await server.close();
|
|
103
155
|
throw new PortInUseError(movedFrom);
|
|
104
156
|
}
|
|
105
157
|
//#endregion
|
|
106
|
-
export { MOVE_TRIES, PortInUseError, answersAs, appOn, listenOnPort, lsofHolder, whatHolds };
|
|
158
|
+
export { MOVE_TRIES, OTHER_DEX, PortInUseError, answersAs, appOn, heldOnLocalhost, listenOnPort, lsofHolder, servedPort, whatHolds };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { PresenceEntry, PresenceTarget } from "../shared/presence-core.mjs";
|
|
2
2
|
//#region src/server/presence.d.ts
|
|
3
3
|
/** What to clear entries by: any field left out matches every entry. */
|
|
4
|
-
export type PresenceMatch = Partial<Pick<PresenceEntry, "agent" | "session" | "slug" | "target"
|
|
4
|
+
export type PresenceMatch = Partial<Pick<PresenceEntry, "agent" | "session" | "slug" | "target">> & {
|
|
5
|
+
/** A session: its own entries and its sub-agents' (workerSession). */
|
|
6
|
+
within?: string;
|
|
7
|
+
};
|
|
5
8
|
/** A View, Doc or Prototype marked as worked on, and by whom. */
|
|
6
9
|
export interface PresenceMark extends PresenceTarget {
|
|
7
10
|
/** "Agent" when left out. */
|
package/dist/server/presence.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fromRoom, teammateSession as teammateSession$1 } from "../shared/live-presence.mjs";
|
|
2
|
-
import { freshPresence } from "../shared/presence-core.mjs";
|
|
2
|
+
import { freshPresence, underSession } from "../shared/presence-core.mjs";
|
|
3
3
|
import { withLock } from "./file-lock.mjs";
|
|
4
4
|
import { legacyState, prepareState, studioState } from "./state.mjs";
|
|
5
5
|
import { basename, join } from "node:path";
|
|
@@ -10,7 +10,7 @@ const teammateSession = teammateSession$1;
|
|
|
10
10
|
/** Whether an entry was brought in from the live room, not marked here. */
|
|
11
11
|
const isTeammate = fromRoom;
|
|
12
12
|
const sameSlot = (a, b) => a.slug === b.slug && a.target === b.target && a.session === b.session;
|
|
13
|
-
const matches = (entry,
|
|
13
|
+
const matches = (entry, { within, ...fields }) => (within === void 0 || underSession(entry.session, within)) && Object.entries(fields).every(([key, value]) => value === void 0 || entry[key] === value);
|
|
14
14
|
const readEntries = async (path) => {
|
|
15
15
|
try {
|
|
16
16
|
const entries = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -44,7 +44,11 @@ export type DesktopAppHost = {
|
|
|
44
44
|
export interface StudioRequestOptions {
|
|
45
45
|
agents?: AgentTracker;
|
|
46
46
|
base?: string;
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Where the studio can make its app, asked each time: the dev server's
|
|
49
|
+
* port is known only once it listens.
|
|
50
|
+
*/
|
|
51
|
+
desktop?: () => DesktopAppHost;
|
|
48
52
|
events: EventHub;
|
|
49
53
|
format?: Formatter;
|
|
50
54
|
launcher?: AgentLauncher;
|
package/dist/server/requests.mjs
CHANGED
|
@@ -13,21 +13,21 @@ import { readSaved, restoreSaved } from "./saved.mjs";
|
|
|
13
13
|
import { checkForUpdateWithin } from "./updates.mjs";
|
|
14
14
|
import { moveToPullRequest, queueSync, switchToSyncBranch } from "./git-sync.mjs";
|
|
15
15
|
import { ORPHANED_LINE, RUN_ID, canRestart, orphaned, restartWhenIdle } from "./restart.mjs";
|
|
16
|
-
import { guidelinesPerson, isEditableMarkdown } from "../shared/studio-files.mjs";
|
|
16
|
+
import { STUDIO_FILES, guidelinesPerson, isEditableMarkdown } from "../shared/studio-files.mjs";
|
|
17
|
+
import { COMMAND_SWITCHES, menuRenamed, menuWith, quickNames, switchOn } from "../shared/commands-core.mjs";
|
|
18
|
+
import { listCommands, removeCommand, saveCommand } from "../content/commands.mjs";
|
|
19
|
+
import { codebaseSkills, readCommandMenu, skillFolders, writeCommandMenu } from "./command-settings.mjs";
|
|
17
20
|
import { features } from "./features.mjs";
|
|
18
21
|
import { otherServers, readRoster, stopOthers } from "./roster.mjs";
|
|
19
22
|
import { findBiome } from "../content/biome.mjs";
|
|
20
23
|
import { loadDevices, saveDevices } from "../content/devices.mjs";
|
|
21
24
|
import { parseReviewFile } from "../shared/review-file.mjs";
|
|
22
25
|
import { createPrototype, createUntitledPrototype, currentPerson, deletePrototype, duplicatePrototype, joinCurrentPerson, readCanvasRevision, readPrototypeAnnotations, removeAnnotation, saveAnnotation, setPrototypeCover, setPrototypeStatus, setPrototypeTitle, writeCanvas } from "../content/content.mjs";
|
|
23
|
-
import {
|
|
24
|
-
import { listCommands, removeCommand, saveCommand } from "../content/commands.mjs";
|
|
25
|
-
import { codebaseSkills, readCommandMenu, skillFolders, writeCommandMenu } from "./command-settings.mjs";
|
|
26
|
+
import { readAuthor, readMe } from "./me.mjs";
|
|
26
27
|
import { NotAnOldSession, connectedAgents, isWatching, setWatching, stopAgentServer, trackAgents } from "./channel.mjs";
|
|
27
28
|
import { addAgent, agentRootOf, agentSetups, isLaunchAgent, launchAgent } from "./agents.mjs";
|
|
28
29
|
import { BUILD_DEFAULTS } from "../shared/build-settings.mjs";
|
|
29
30
|
import { saveCaptures } from "../content/capture.mjs";
|
|
30
|
-
import { PasteProblem, readPaste } from "../paste/paste.mjs";
|
|
31
31
|
import { readText } from "../content/read-text.mjs";
|
|
32
32
|
import { removedSpecs } from "../content/flow-specs.mjs";
|
|
33
33
|
import { editProps } from "../content/prop-edit.mjs";
|
|
@@ -36,7 +36,9 @@ import { lastEdited } from "../content/last-edited.mjs";
|
|
|
36
36
|
import { placeReviewPages } from "../content/review-pages.mjs";
|
|
37
37
|
import { isViewPage, screenshotFrame } from "../content/screenshot.mjs";
|
|
38
38
|
import { editText } from "../content/text-edit.mjs";
|
|
39
|
+
import { replaceText, undoReplace } from "../content/text-replace.mjs";
|
|
39
40
|
import { dismissThreadsOn, emptyTrash, removedViewsWithComments, trashHolds, trashViews } from "../content/trash.mjs";
|
|
41
|
+
import { PasteProblem, readPaste } from "../paste/paste.mjs";
|
|
40
42
|
import { readGitSettings, writeGitSettings } from "./git-settings.mjs";
|
|
41
43
|
import { checkGitSetup, checkLog, realGitProbes } from "../setup/git-checks.mjs";
|
|
42
44
|
import { bundlePath, desktopAppState, installDesktopApp, removeDesktopApp } from "../setup/desktop-app.mjs";
|
|
@@ -47,10 +49,10 @@ import { AvatarRefused, removeAvatar, writeAvatar } from "./avatars.mjs";
|
|
|
47
49
|
import { writeInstructions } from "./instructions.mjs";
|
|
48
50
|
import { readBuildSettings, writeBuildSettings } from "./build-settings.mjs";
|
|
49
51
|
import { notesSince } from "./changelog.mjs";
|
|
52
|
+
import { COMMENT_HANDLERS } from "./comments/routes.mjs";
|
|
50
53
|
import { gitAskBody } from "./git-asks.mjs";
|
|
51
54
|
import { settlePaused, undoPaused } from "./git-paused.mjs";
|
|
52
55
|
import { currentActivity, machineState, markActivity, ranBeforeThis, updateMachine } from "./machine-update.mjs";
|
|
53
|
-
import { readAuthor, readMe } from "./me.mjs";
|
|
54
56
|
import { loadPeople } from "./people.mjs";
|
|
55
57
|
import { framePictures, latestAround, latestChange } from "./pictures.mjs";
|
|
56
58
|
import { readPreferences, savePreferences } from "./preferences.mjs";
|
|
@@ -269,19 +271,19 @@ const emptyTheTrash = async ({ project }) => {
|
|
|
269
271
|
await emptyTrash(project.content);
|
|
270
272
|
return {};
|
|
271
273
|
};
|
|
272
|
-
const listConnectedAgents = async ({ project }) => ({ agents: await connectedAgents(project.content) });
|
|
274
|
+
const listConnectedAgents = async ({ project, threads }) => ({ agents: await connectedAgents(project.content, { threads }) });
|
|
273
275
|
/** Only on this machine, where that process runs. */
|
|
274
|
-
const stopOldAgent = async ({ project, body, request }) => {
|
|
276
|
+
const stopOldAgent = async ({ project, body, request, threads }) => {
|
|
275
277
|
onlyFromThisMachine(request, "Stop agents from the machine Dex runs on.");
|
|
276
278
|
const pid = body?.pid;
|
|
277
279
|
if (!(typeof pid === "number" && Number.isInteger(pid))) throw new Problems(422, ["Say which agent to stop, by its process."]);
|
|
278
280
|
try {
|
|
279
|
-
await stopAgentServer(project.content, pid);
|
|
281
|
+
await stopAgentServer(project.content, pid, threads);
|
|
280
282
|
} catch (error) {
|
|
281
283
|
if (error instanceof NotAnOldSession) throw new Problems(409, [error.message]);
|
|
282
284
|
throw error;
|
|
283
285
|
}
|
|
284
|
-
return { agents: await connectedAgents(project.content) };
|
|
286
|
+
return { agents: await connectedAgents(project.content, { threads }) };
|
|
285
287
|
};
|
|
286
288
|
const listAgentSetups = async ({ project }) => ({ agents: await agentSetups(project.root, project.content, agentRootOf(project.root)) });
|
|
287
289
|
async function addAgentSetup(context) {
|
|
@@ -429,12 +431,13 @@ const desktopAnswer = async (desktop) => "unavailable" in desktop ? {
|
|
|
429
431
|
};
|
|
430
432
|
const loadDesktopApp = ({ request, desktop }) => {
|
|
431
433
|
fromThisMac(request, false);
|
|
432
|
-
return desktopAnswer(desktop);
|
|
434
|
+
return desktopAnswer(desktop());
|
|
433
435
|
};
|
|
434
436
|
async function changeDesktopApp({ request, desktop, body }) {
|
|
435
437
|
fromThisMac(request, true);
|
|
436
|
-
|
|
437
|
-
|
|
438
|
+
const host = desktop();
|
|
439
|
+
if ("unavailable" in host) throw new Problems(409, [host.unavailable === "hosted" ? "A hosted studio can't install an app." : "Installing outside the browser is macOS-only for now."]);
|
|
440
|
+
const { app, home, reveal, open, launchServices } = host;
|
|
438
441
|
switch (body?.action) {
|
|
439
442
|
case "install":
|
|
440
443
|
await reveal(await refusable(() => installDesktopApp(app, home, launchServices))).catch(() => void 0);
|
|
@@ -448,7 +451,7 @@ async function changeDesktopApp({ request, desktop, body }) {
|
|
|
448
451
|
break;
|
|
449
452
|
default: throw new Problems(400, ["Send an action: \"install\", \"open\" or \"remove\"."]);
|
|
450
453
|
}
|
|
451
|
-
return desktopAnswer(
|
|
454
|
+
return desktopAnswer(host);
|
|
452
455
|
}
|
|
453
456
|
const readWatch = async ({ project }) => ({ on: await isWatching(project.content) });
|
|
454
457
|
/** Every open page hears it, so each switch shows the same. */
|
|
@@ -541,6 +544,19 @@ async function changeText({ project, body }) {
|
|
|
541
544
|
if (!("file" in result)) throw new Problems(409, [result.reason]);
|
|
542
545
|
return result;
|
|
543
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Find and replace on the canvas: { find, to, seen } changes the words in
|
|
549
|
+
* the person's own folder of the file, where the frames showed them;
|
|
550
|
+
* { undo } puts a replacement back.
|
|
551
|
+
*/
|
|
552
|
+
async function replaceOnCanvas({ project, body }) {
|
|
553
|
+
const { folder } = prototypeNamed(project.content, body ?? {});
|
|
554
|
+
const own = join(folder, STUDIO_FILES.people, await whoChanges(project.content));
|
|
555
|
+
if (typeof body?.undo === "string") return await undoReplace(own, body.undo);
|
|
556
|
+
const { find, to, seen } = body ?? {};
|
|
557
|
+
if (!(typeof find === "string" && typeof to === "string" && Array.isArray(seen))) throw new Problems(400, ["Say what to find, and what to change it to."]);
|
|
558
|
+
return await replaceText(own, find, to, seen.filter((text) => typeof text === "string"));
|
|
559
|
+
}
|
|
544
560
|
const needsFeature = (name) => {
|
|
545
561
|
if (!features()[name]) throw new Problems(404, ["That is not on in this studio."]);
|
|
546
562
|
};
|
|
@@ -634,35 +650,6 @@ async function pictureOfView({ request, body, pageBase, project, response }) {
|
|
|
634
650
|
}
|
|
635
651
|
/** Threads are never kept for a folder that is not a prototype. */
|
|
636
652
|
const threadsPrototype = (content, url) => prototypeOf(content, url).slug;
|
|
637
|
-
const listThreads = ({ project, url, threads }) => url.searchParams.has("slug") ? threads.list({ prototype: threadsPrototype(project.content, url) }) : threads.list();
|
|
638
|
-
/** A request for one prototype never changes another's thread. */
|
|
639
|
-
const isThreadOf = async (threads, id, prototype) => {
|
|
640
|
-
const thread = await threads.find(id);
|
|
641
|
-
return thread !== void 0 && thread.slug === prototype;
|
|
642
|
-
};
|
|
643
|
-
async function postThread({ project, url, body, threads }) {
|
|
644
|
-
const prototype = threadsPrototype(project.content, url);
|
|
645
|
-
if (!body) throw new Problems(400, ["Send a thread to start, or a change to one."]);
|
|
646
|
-
const { name: author, slug: authorId } = await readAuthor(project.content);
|
|
647
|
-
const id = body.id;
|
|
648
|
-
if (id && !await isThreadOf(threads, id, prototype)) throw new Problems(404, ["That thread is gone."]);
|
|
649
|
-
const result = id ? await threads.respond(id, {
|
|
650
|
-
...body,
|
|
651
|
-
author,
|
|
652
|
-
authorId
|
|
653
|
-
}) : await threads.start({
|
|
654
|
-
prototype,
|
|
655
|
-
target: body.target,
|
|
656
|
-
body: body.body,
|
|
657
|
-
for: body.for,
|
|
658
|
-
sketch: body.sketch,
|
|
659
|
-
author,
|
|
660
|
-
authorId
|
|
661
|
-
});
|
|
662
|
-
if (!result) throw new Problems(404, ["That thread is gone."]);
|
|
663
|
-
if (result.problems) throw new Problems(422, result.problems);
|
|
664
|
-
return result.thread;
|
|
665
|
-
}
|
|
666
653
|
const REVIEW_FILE_PROBLEMS = {
|
|
667
654
|
"not-a-review": "This is not a Dex review.",
|
|
668
655
|
newer: "This review is from a newer Dex: update to import it.",
|
|
@@ -1272,6 +1259,7 @@ function studioPages({ project, events, threads, agents }) {
|
|
|
1272
1259
|
};
|
|
1273
1260
|
}
|
|
1274
1261
|
const ROUTES = {
|
|
1262
|
+
...COMMENT_HANDLERS,
|
|
1275
1263
|
canvas: {
|
|
1276
1264
|
prototype: true,
|
|
1277
1265
|
GET: loadCanvas,
|
|
@@ -1293,10 +1281,6 @@ const ROUTES = {
|
|
|
1293
1281
|
POST: trashRemovedViews
|
|
1294
1282
|
},
|
|
1295
1283
|
trash: { DELETE: emptyTheTrash },
|
|
1296
|
-
threads: {
|
|
1297
|
-
GET: listThreads,
|
|
1298
|
-
POST: postThread
|
|
1299
|
-
},
|
|
1300
1284
|
reviews: {
|
|
1301
1285
|
limit: MAX_REVIEW_BYTES,
|
|
1302
1286
|
POST: importReviews
|
|
@@ -1317,6 +1301,7 @@ const ROUTES = {
|
|
|
1317
1301
|
frame: { POST: addBlankFrame },
|
|
1318
1302
|
show: { POST: showOnCanvas },
|
|
1319
1303
|
text: { POST: changeText },
|
|
1304
|
+
replace: { POST: replaceOnCanvas },
|
|
1320
1305
|
props: { POST: changeProps },
|
|
1321
1306
|
insert: { POST: insertIntoView },
|
|
1322
1307
|
screenshot: { POST: screenshotView },
|
|
@@ -1439,7 +1424,7 @@ async function answer(route, context) {
|
|
|
1439
1424
|
* The handler resolves false for any other request, for whatever serves the
|
|
1440
1425
|
* rest.
|
|
1441
1426
|
*/
|
|
1442
|
-
function studioRequests({ project, threads, events, format = formatter(project.content), launcher = launchAgent, agents = trackAgents(project.content, { threads }), server = {}, base = "/", desktop = { unavailable: "platform" } }) {
|
|
1427
|
+
function studioRequests({ project, threads, events, format = formatter(project.content), launcher = launchAgent, agents = trackAgents(project.content, { threads }), server = {}, base = "/", desktop = () => ({ unavailable: "platform" }) }) {
|
|
1443
1428
|
const pages = studioPages({
|
|
1444
1429
|
project,
|
|
1445
1430
|
events,
|
|
@@ -51,6 +51,11 @@ export interface StudioForOptions {
|
|
|
51
51
|
}
|
|
52
52
|
/** Which Dex is serving the checkout at `place` (see StudioFor). */
|
|
53
53
|
export declare function studioFor({ content, root, port: configured }: StudioPlace, { holderOf }?: StudioForOptions): Promise<StudioFor>;
|
|
54
|
+
/**
|
|
55
|
+
* The port this checkout's Dex is on, also while it restarts there, or
|
|
56
|
+
* undefined when none is: what the app opens, and where it says to look.
|
|
57
|
+
*/
|
|
58
|
+
export declare function ownPort(found: StudioFor): number | undefined;
|
|
54
59
|
/** Why there is no Dex to ask, in words a person can act on. */
|
|
55
60
|
export declare function notRunning(found: Exclude<StudioFor, {
|
|
56
61
|
kind: "running";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { projectId } from "./project-id.mjs";
|
|
2
|
-
import { answersAs, lsofHolder, whatHolds } from "./port.mjs";
|
|
2
|
+
import { OTHER_DEX, answersAs, lsofHolder, whatHolds } from "./port.mjs";
|
|
3
3
|
import { RESTART_PATH } from "../shared/server-page.mjs";
|
|
4
4
|
import { readRoster } from "./roster.mjs";
|
|
5
5
|
//#region src/server/studio-for.ts
|
|
@@ -16,7 +16,7 @@ async function restartFailed(port) {
|
|
|
16
16
|
}
|
|
17
17
|
/** What holds a port, as an agent is told: "another checkout's Dex". */
|
|
18
18
|
function holderName({ by, pid }) {
|
|
19
|
-
if (by === "Dex") return
|
|
19
|
+
if (by === "Dex") return OTHER_DEX;
|
|
20
20
|
return pid ? `${by} (pid ${pid})` : String(by);
|
|
21
21
|
}
|
|
22
22
|
/** The newest of `servers` that answers as the project `id` names. */
|
|
@@ -57,6 +57,20 @@ async function studioFor({ content, root, port: configured }, { holderOf = lsofH
|
|
|
57
57
|
holder: holderName(holder)
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The port this checkout's Dex is on, also while it restarts there, or
|
|
62
|
+
* undefined when none is: what the app opens, and where it says to look.
|
|
63
|
+
*/
|
|
64
|
+
function ownPort(found) {
|
|
65
|
+
switch (found.kind) {
|
|
66
|
+
case "running":
|
|
67
|
+
case "starting":
|
|
68
|
+
case "failed": return found.port;
|
|
69
|
+
case "none":
|
|
70
|
+
case "elsewhere": return;
|
|
71
|
+
default: return found;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
60
74
|
const START = "Start it with `npx dex dev` (or the project's own script, such as `npm run dex`), then try again.";
|
|
61
75
|
const ports = (tried) => tried.map((port) => `:${port}`).join(", ");
|
|
62
76
|
/** Why there is no Dex to ask, in words a person can act on. */
|
|
@@ -70,4 +84,4 @@ function notRunning(found) {
|
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
86
|
//#endregion
|
|
73
|
-
export { notRunning, studioFor };
|
|
87
|
+
export { notRunning, ownPort, studioFor };
|
|
@@ -17,28 +17,24 @@ export interface SyncPlace {
|
|
|
17
17
|
* work is in by then. Why Sync stopped comes back with where the machine
|
|
18
18
|
* stands, rather than thrown. Run it inside the repository's turn.
|
|
19
19
|
*/
|
|
20
|
-
export declare
|
|
20
|
+
export declare const syncAndUpdate: ({ keep, message, ...place }: SyncPlace & {
|
|
21
21
|
keep?: SyncKeep;
|
|
22
22
|
/** The commit's message, in place of one written from the changes. */
|
|
23
23
|
message?: string;
|
|
24
|
-
},
|
|
25
|
-
run?: StepRunner;
|
|
26
|
-
running?: string;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
machine: MachineState;
|
|
29
|
-
stopped?: GitError;
|
|
30
|
-
}>;
|
|
24
|
+
}, steps?: UpdateSteps) => Promise<Updated>;
|
|
31
25
|
/**
|
|
32
26
|
* Pull from base, then bring the machine up to date with what it brought
|
|
33
27
|
* in, as syncAndUpdate does for Sync. Run it inside the repository's turn.
|
|
34
28
|
*/
|
|
35
|
-
export declare
|
|
29
|
+
export declare const pullBaseAndUpdate: ({ keep, ...place }: SyncPlace & {
|
|
36
30
|
keep?: SyncKeep;
|
|
37
|
-
},
|
|
31
|
+
}, steps?: UpdateSteps) => Promise<Updated>;
|
|
32
|
+
interface UpdateSteps {
|
|
38
33
|
run?: StepRunner;
|
|
39
34
|
running?: string;
|
|
40
|
-
}
|
|
35
|
+
}
|
|
36
|
+
interface Updated {
|
|
41
37
|
machine: MachineState;
|
|
42
38
|
stopped?: GitError;
|
|
43
|
-
}
|
|
39
|
+
}
|
|
44
40
|
//#endregion
|