geordi 0.6.0 → 0.7.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/daemon/codex-acp.js +19 -2
- package/daemon/file-index-worker.js +666 -0
- package/daemon/host.js +79 -9
- package/daemon/main.js +20805 -12434
- package/forge/adapter-node.js +1 -1
- package/forge/client/_app/immutable/assets/0.DFcfwEv1.css +2 -0
- package/forge/client/_app/immutable/assets/0.DFcfwEv1.css.br +0 -0
- package/forge/client/_app/immutable/assets/0.DFcfwEv1.css.gz +0 -0
- package/forge/{server/_app/immutable/assets/_page.BAN_y_x-.css → client/_app/immutable/assets/6.Byk-vo6d.css} +1 -1
- package/forge/client/_app/immutable/assets/6.Byk-vo6d.css.br +0 -0
- package/forge/client/_app/immutable/assets/6.Byk-vo6d.css.gz +0 -0
- package/forge/client/_app/immutable/assets/Button.B17xKxm7.css +1 -0
- package/forge/client/_app/immutable/assets/Button.B17xKxm7.css.br +0 -0
- package/forge/client/_app/immutable/assets/Button.B17xKxm7.css.gz +0 -0
- package/forge/client/_app/immutable/chunks/{BPUcSU9Y.js → BT7OzaMO.js} +1 -1
- package/forge/client/_app/immutable/chunks/BT7OzaMO.js.br +0 -0
- package/forge/client/_app/immutable/chunks/BT7OzaMO.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BWMsj4Pm.js +1 -0
- package/forge/client/_app/immutable/chunks/BWMsj4Pm.js.br +0 -0
- package/forge/client/_app/immutable/chunks/BWMsj4Pm.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BeY39UVF.js +1 -0
- package/forge/client/_app/immutable/chunks/BeY39UVF.js.br +0 -0
- package/forge/client/_app/immutable/chunks/BeY39UVF.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/C-R9QLJ0.js +1 -0
- package/forge/client/_app/immutable/chunks/C-R9QLJ0.js.br +0 -0
- package/forge/client/_app/immutable/chunks/C-R9QLJ0.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/C4nuTpNF.js +1 -0
- package/forge/client/_app/immutable/chunks/C4nuTpNF.js.br +0 -0
- package/forge/client/_app/immutable/chunks/C4nuTpNF.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/C5OGEsfr.js +1 -0
- package/forge/client/_app/immutable/chunks/C5OGEsfr.js.br +0 -0
- package/forge/client/_app/immutable/chunks/C5OGEsfr.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/COPt_Q6n.js +1 -0
- package/forge/client/_app/immutable/chunks/COPt_Q6n.js.br +0 -0
- package/forge/client/_app/immutable/chunks/COPt_Q6n.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/CP6DlQft.js +1 -0
- package/forge/client/_app/immutable/chunks/CP6DlQft.js.br +0 -0
- package/forge/client/_app/immutable/chunks/CP6DlQft.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/{DBdrLgIP.js → Ccl56Gku.js} +1 -1
- package/forge/client/_app/immutable/chunks/Ccl56Gku.js.br +0 -0
- package/forge/client/_app/immutable/chunks/Ccl56Gku.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/ChNJxau2.js +1 -0
- package/forge/client/_app/immutable/chunks/ChNJxau2.js.br +0 -0
- package/forge/client/_app/immutable/chunks/ChNJxau2.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/Crc8gSXy.js +1 -0
- package/forge/client/_app/immutable/chunks/Crc8gSXy.js.br +1 -0
- package/forge/client/_app/immutable/chunks/Crc8gSXy.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/D5-O8vtP.js +1 -0
- package/forge/client/_app/immutable/chunks/D5-O8vtP.js.br +0 -0
- package/forge/client/_app/immutable/chunks/D5-O8vtP.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/DdkL87FE.js +1 -0
- package/forge/client/_app/immutable/chunks/DdkL87FE.js.br +0 -0
- package/forge/client/_app/immutable/chunks/DdkL87FE.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/DxvVjX9V.js +3 -0
- package/forge/client/_app/immutable/chunks/DxvVjX9V.js.br +0 -0
- package/forge/client/_app/immutable/chunks/DxvVjX9V.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/IrzRjtcH.js +3 -0
- package/forge/client/_app/immutable/chunks/IrzRjtcH.js.br +0 -0
- package/forge/client/_app/immutable/chunks/IrzRjtcH.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/NunfWefo.js +1 -0
- package/forge/client/_app/immutable/chunks/NunfWefo.js.br +2 -0
- package/forge/client/_app/immutable/chunks/NunfWefo.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/kSB3KwVn.js +3 -0
- package/forge/client/_app/immutable/chunks/kSB3KwVn.js.br +0 -0
- package/forge/client/_app/immutable/chunks/kSB3KwVn.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/wHjFYaJV.js +1 -0
- package/forge/client/_app/immutable/chunks/wHjFYaJV.js.br +0 -0
- package/forge/client/_app/immutable/chunks/wHjFYaJV.js.gz +0 -0
- package/forge/client/_app/immutable/entry/app.Bty1z-YK.js +2 -0
- package/forge/client/_app/immutable/entry/app.Bty1z-YK.js.br +0 -0
- package/forge/client/_app/immutable/entry/app.Bty1z-YK.js.gz +0 -0
- package/forge/client/_app/immutable/entry/start.BhKF-U-o.js +2 -0
- package/forge/client/_app/immutable/entry/start.BhKF-U-o.js.br +0 -0
- package/forge/client/_app/immutable/entry/start.BhKF-U-o.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/0.D-m9au7z.js +2 -0
- package/forge/client/_app/immutable/nodes/0.D-m9au7z.js.br +0 -0
- package/forge/client/_app/immutable/nodes/0.D-m9au7z.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/1.CGNIYHVw.js +1 -0
- package/forge/client/_app/immutable/nodes/1.CGNIYHVw.js.br +0 -0
- package/forge/client/_app/immutable/nodes/1.CGNIYHVw.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/2.C0mDCJBK.js +2 -0
- package/forge/client/_app/immutable/nodes/2.C0mDCJBK.js.br +0 -0
- package/forge/client/_app/immutable/nodes/2.C0mDCJBK.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/3.Bq6iWH-v.js +1 -0
- package/forge/client/_app/immutable/nodes/3.Bq6iWH-v.js.br +0 -0
- package/forge/client/_app/immutable/nodes/3.Bq6iWH-v.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/4.BoYXxxYH.js +1 -0
- package/forge/client/_app/immutable/nodes/4.BoYXxxYH.js.br +0 -0
- package/forge/client/_app/immutable/nodes/4.BoYXxxYH.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/5.vDQR2R7-.js +6 -0
- package/forge/client/_app/immutable/nodes/5.vDQR2R7-.js.br +0 -0
- package/forge/client/_app/immutable/nodes/5.vDQR2R7-.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/6.BDd5d1vh.js +32 -0
- package/forge/client/_app/immutable/nodes/6.BDd5d1vh.js.br +0 -0
- package/forge/client/_app/immutable/nodes/6.BDd5d1vh.js.gz +0 -0
- package/forge/client/_app/version.json +1 -1
- package/forge/client/_app/version.json.br +0 -0
- package/forge/client/_app/version.json.gz +0 -0
- package/forge/server/.vite/manifest.json +63 -35
- package/forge/server/_app/immutable/assets/Button.B17xKxm7.css +1 -0
- package/forge/server/_app/immutable/assets/_layout.DFcfwEv1.css +2 -0
- package/forge/{client/_app/immutable/assets/5.BAN_y_x-.css → server/_app/immutable/assets/_page.Byk-vo6d.css} +1 -1
- package/forge/server/chunks/Button.js +93 -0
- package/forge/server/chunks/Button.js.map +1 -0
- package/forge/server/chunks/Dialog.js +3 -3
- package/forge/server/chunks/Dialog.js.map +1 -1
- package/forge/server/chunks/MessageCopy.js +2 -2
- package/forge/server/chunks/MessageCopy.js.map +1 -1
- package/forge/server/chunks/NewWorkspace.js +370 -222
- package/forge/server/chunks/NewWorkspace.js.map +1 -1
- package/forge/server/chunks/TitleBar.js +3 -91
- package/forge/server/chunks/TitleBar.js.map +1 -1
- package/forge/server/chunks/WaitingForView.js.map +1 -1
- package/forge/server/chunks/WorkspaceActions.js +5 -4
- package/forge/server/chunks/WorkspaceActions.js.map +1 -1
- package/forge/server/chunks/app.js +234 -32
- package/forge/server/chunks/app.js.map +1 -1
- package/forge/server/chunks/dist.js +53 -1
- package/forge/server/chunks/dist.js.map +1 -1
- package/forge/server/chunks/instance.js +3 -3
- package/forge/server/chunks/internal.js +1 -1
- package/forge/server/chunks/keys.js +1 -1
- package/forge/server/chunks/keys.js.map +1 -1
- package/forge/server/chunks/motion.js +53 -16
- package/forge/server/chunks/motion.js.map +1 -1
- package/forge/server/chunks/navigation.js +2 -2
- package/forge/server/chunks/navigation.js.map +1 -1
- package/forge/server/chunks/overview.js.map +1 -1
- package/forge/server/chunks/{format.js → persisted.svelte.js} +2 -26
- package/forge/server/chunks/persisted.svelte.js.map +1 -0
- package/forge/server/chunks/remote-15qct20.js +1 -1
- package/forge/server/chunks/workspaces.remote.js +77 -11
- package/forge/server/chunks/workspaces.remote.js.map +1 -1
- package/forge/server/entries/endpoints/mcp/_server.ts.js +12 -8
- package/forge/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/forge/server/entries/endpoints/repos/_id_/icon/_server.ts.js +7 -3
- package/forge/server/entries/endpoints/repos/_id_/icon/_server.ts.js.map +1 -1
- package/forge/server/entries/endpoints/workspaces/_id_/picture/_server.ts.js +7 -3
- package/forge/server/entries/endpoints/workspaces/_id_/picture/_server.ts.js.map +1 -1
- package/forge/server/entries/pages/_layout.svelte.js +235 -88
- package/forge/server/entries/pages/_layout.svelte.js.map +1 -1
- package/forge/server/entries/pages/_page.svelte.js +5 -3
- package/forge/server/entries/pages/_page.svelte.js.map +1 -1
- package/forge/server/entries/pages/archive/_page.svelte.js +49 -0
- package/forge/server/entries/pages/archive/_page.svelte.js.map +1 -0
- package/forge/server/entries/pages/overview/_page.svelte.js +23 -5
- package/forge/server/entries/pages/overview/_page.svelte.js.map +1 -1
- package/forge/server/entries/pages/settings/__section__/_page.svelte.js +3 -2
- package/forge/server/entries/pages/settings/__section__/_page.svelte.js.map +1 -1
- package/forge/server/entries/pages/workspaces/_id_/_page.server.ts.js +2 -2
- package/forge/server/entries/pages/workspaces/_id_/_page.server.ts.js.map +1 -1
- package/forge/server/entries/pages/workspaces/_id_/_page.svelte.js +1045 -507
- package/forge/server/entries/pages/workspaces/_id_/_page.svelte.js.map +1 -1
- package/forge/server/manifest-full.js +15 -7
- package/forge/server/manifest.js +15 -7
- package/forge/server/nodes/0.js +2 -2
- package/forge/server/nodes/1.js +1 -1
- package/forge/server/nodes/2.js +2 -2
- package/forge/server/nodes/3.js +3 -3
- package/forge/server/nodes/4.js +4 -6
- package/forge/server/nodes/5.js +6 -6
- package/forge/server/nodes/6.js +10 -0
- package/forge/server/server.js +15 -7
- package/package.json +5 -2
- package/forge/client/_app/immutable/assets/0.MTPMv8jx.css +0 -2
- package/forge/client/_app/immutable/assets/0.MTPMv8jx.css.br +0 -0
- package/forge/client/_app/immutable/assets/0.MTPMv8jx.css.gz +0 -0
- package/forge/client/_app/immutable/assets/5.BAN_y_x-.css.br +0 -0
- package/forge/client/_app/immutable/assets/5.BAN_y_x-.css.gz +0 -0
- package/forge/client/_app/immutable/assets/TitleBar.C18R3Ash.css +0 -1
- package/forge/client/_app/immutable/assets/TitleBar.C18R3Ash.css.br +0 -0
- package/forge/client/_app/immutable/assets/TitleBar.C18R3Ash.css.gz +0 -0
- package/forge/client/_app/immutable/chunks/B3znLk1J.js +0 -1
- package/forge/client/_app/immutable/chunks/B3znLk1J.js.br +0 -1
- package/forge/client/_app/immutable/chunks/B3znLk1J.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BLYrrO5i.js +0 -1
- package/forge/client/_app/immutable/chunks/BLYrrO5i.js.br +0 -0
- package/forge/client/_app/immutable/chunks/BLYrrO5i.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BPUcSU9Y.js.br +0 -2
- package/forge/client/_app/immutable/chunks/BPUcSU9Y.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BV6RCEM1.js +0 -1
- package/forge/client/_app/immutable/chunks/BV6RCEM1.js.br +0 -2
- package/forge/client/_app/immutable/chunks/BV6RCEM1.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/B_mLdc9L.js +0 -1
- package/forge/client/_app/immutable/chunks/B_mLdc9L.js.br +0 -0
- package/forge/client/_app/immutable/chunks/B_mLdc9L.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/BvPSoxVj.js +0 -3
- package/forge/client/_app/immutable/chunks/BvPSoxVj.js.br +0 -0
- package/forge/client/_app/immutable/chunks/BvPSoxVj.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/C1DGY91i.js +0 -1
- package/forge/client/_app/immutable/chunks/C1DGY91i.js.br +0 -0
- package/forge/client/_app/immutable/chunks/C1DGY91i.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/CrbaLN9e.js +0 -3
- package/forge/client/_app/immutable/chunks/CrbaLN9e.js.br +0 -0
- package/forge/client/_app/immutable/chunks/CrbaLN9e.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/DBdrLgIP.js.br +0 -0
- package/forge/client/_app/immutable/chunks/DBdrLgIP.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/DHj6ofkw.js +0 -1
- package/forge/client/_app/immutable/chunks/DHj6ofkw.js.br +0 -0
- package/forge/client/_app/immutable/chunks/DHj6ofkw.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/Wy-MV1bx.js +0 -3
- package/forge/client/_app/immutable/chunks/Wy-MV1bx.js.br +0 -0
- package/forge/client/_app/immutable/chunks/Wy-MV1bx.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/YRCfaiJm.js +0 -1
- package/forge/client/_app/immutable/chunks/YRCfaiJm.js.br +0 -0
- package/forge/client/_app/immutable/chunks/YRCfaiJm.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/aqm7T3j0.js +0 -1
- package/forge/client/_app/immutable/chunks/aqm7T3j0.js.br +0 -0
- package/forge/client/_app/immutable/chunks/aqm7T3j0.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/e4tnLtM4.js +0 -1
- package/forge/client/_app/immutable/chunks/e4tnLtM4.js.br +0 -0
- package/forge/client/_app/immutable/chunks/e4tnLtM4.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/qtK8ANZN.js +0 -1
- package/forge/client/_app/immutable/chunks/qtK8ANZN.js.br +0 -0
- package/forge/client/_app/immutable/chunks/qtK8ANZN.js.gz +0 -0
- package/forge/client/_app/immutable/chunks/yLpFDVQa.js +0 -1
- package/forge/client/_app/immutable/chunks/yLpFDVQa.js.br +0 -0
- package/forge/client/_app/immutable/chunks/yLpFDVQa.js.gz +0 -0
- package/forge/client/_app/immutable/entry/app.CcN3jWRh.js +0 -2
- package/forge/client/_app/immutable/entry/app.CcN3jWRh.js.br +0 -0
- package/forge/client/_app/immutable/entry/app.CcN3jWRh.js.gz +0 -0
- package/forge/client/_app/immutable/entry/start.C2pXqDYu.js +0 -2
- package/forge/client/_app/immutable/entry/start.C2pXqDYu.js.br +0 -0
- package/forge/client/_app/immutable/entry/start.C2pXqDYu.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js +0 -1
- package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js.br +0 -0
- package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js +0 -1
- package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js.br +0 -0
- package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js +0 -1
- package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js.br +0 -0
- package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js +0 -1
- package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js.br +0 -0
- package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js +0 -6
- package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js.br +0 -0
- package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js.gz +0 -0
- package/forge/client/_app/immutable/nodes/5.C707zcjh.js +0 -31
- package/forge/client/_app/immutable/nodes/5.C707zcjh.js.br +0 -0
- package/forge/client/_app/immutable/nodes/5.C707zcjh.js.gz +0 -0
- package/forge/server/_app/immutable/assets/TitleBar.C18R3Ash.css +0 -1
- package/forge/server/_app/immutable/assets/_layout.MTPMv8jx.css +0 -2
- package/forge/server/chunks/format.js.map +0 -1
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import { createRequire as makeBundleRequire } from 'node:module'; const require = makeBundleRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// ../daemon/src/file-index-worker.ts
|
|
4
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
5
|
+
|
|
6
|
+
// ../daemon/src/file-index-cache.ts
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import {
|
|
9
|
+
mkdir,
|
|
10
|
+
mkdtemp,
|
|
11
|
+
opendir,
|
|
12
|
+
readFile,
|
|
13
|
+
realpath,
|
|
14
|
+
rename,
|
|
15
|
+
rm,
|
|
16
|
+
stat,
|
|
17
|
+
writeFile
|
|
18
|
+
} from "node:fs/promises";
|
|
19
|
+
import { homedir } from "node:os";
|
|
20
|
+
import { basename as basename2, dirname, isAbsolute, join as join2, relative, sep } from "node:path";
|
|
21
|
+
import { deserialize, serialize } from "node:v8";
|
|
22
|
+
|
|
23
|
+
// ../daemon/src/file-index.ts
|
|
24
|
+
import { spawn } from "node:child_process";
|
|
25
|
+
|
|
26
|
+
// ../../packages/protocol/src/images.ts
|
|
27
|
+
var MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
28
|
+
|
|
29
|
+
// ../../packages/protocol/src/index.ts
|
|
30
|
+
var FILE_SEARCH_TIMEOUT_MS = 12e4;
|
|
31
|
+
var DEFAULT_PORTS = 10;
|
|
32
|
+
var CONFIG_SETTINGS = {
|
|
33
|
+
default: {
|
|
34
|
+
does: "The job or URL for the Run button. Use its key, such as `jobs.web` or `urls.app`. Without a default, Run selects the first URL, or the first job if there are no URLs.",
|
|
35
|
+
example: "default: urls.app"
|
|
36
|
+
},
|
|
37
|
+
run: {
|
|
38
|
+
does: "The command that runs the project for someone to look at or use: its development server, a desktop app, a game. Short for a single job called `run`. Use this unless the project needs several things running.",
|
|
39
|
+
example: "run: pnpm dev --port $PORT"
|
|
40
|
+
},
|
|
41
|
+
jobs: {
|
|
42
|
+
does: "Several things to run, each a `command` under a name (lower case letters, digits and dashes). `needs` lists the jobs that have to be up first: starting a job starts those, and stopping one stops the jobs that need it. An optional `label` supplies a human-readable display name (1\u2013100 characters); the key still identifies dependencies and ports. Each job runs in a terminal of its own, in the workspace's directory, and should keep running until stopped.",
|
|
43
|
+
example: "jobs:\n db:\n command: docker compose up db\n web:\n label: Development server\n command: pnpm dev --port $PORT\n needs: [db]"
|
|
44
|
+
},
|
|
45
|
+
urls: {
|
|
46
|
+
does: "Places to open in the browser, each a `url` under a name. `{job}` stands for that job's port. Opening one first starts the jobs it mentions (and any listed under `needs`) and waits for them. An optional `label` supplies a human-readable display name (1\u2013100 characters); otherwise the key is shown. Only addresses on this machine (`localhost`).",
|
|
47
|
+
example: "urls:\n app:\n label: Open app\n url: http://localhost:{web}/"
|
|
48
|
+
},
|
|
49
|
+
setup: {
|
|
50
|
+
does: "A command that gets a new workspace ready to work in: installing dependencies, copying an `.env`, setting up a database. It runs once, in the workspace's directory, when its worktree is made from the main line (not in one an agent starts from its own branch: there the agent sets up itself), in a terminal the person can watch; the agent's first turn waits for it. If it fails, the agent is told, with the end of its output. It gets the workspace's ports (`GEORDI_PORT\u2026`) like everything else. A person has to agree to it once per repository (and again whenever it changes); until then it does not run, and the agent is told so.",
|
|
51
|
+
example: "setup: pnpm install && cp ../.env .env"
|
|
52
|
+
},
|
|
53
|
+
teardown: {
|
|
54
|
+
does: "A command that cleans up after a workspace when a person archives it, before its directory is removed: stopping services, dropping databases. It gets the same ports as everything in the workspace did. It has two minutes; archiving goes on however it ends. A person agrees to it together with the first commands they agree to run in the repository.",
|
|
55
|
+
example: "teardown: docker compose down --volumes"
|
|
56
|
+
},
|
|
57
|
+
ports: {
|
|
58
|
+
does: `How many ports each workspace gets: one per job unless said otherwise (and ${DEFAULT_PORTS} where there are no jobs). Only needed for spare ones, beyond the jobs'. Every job has one port of its own, and it stays the same for as long as the workspace lives: the command gets it as \`PORT\`, and every job's port is in \`GEORDI_PORT_<NAME>\` (upper case, dashes as underscores) for all jobs, terminals and agents of the workspace. \`GEORDI_PORT\` is the first of the workspace's ports and \`GEORDI_PORTS\` how many there are. \`GEORDI_ASSIGNED_PORTS\` is a JSON array of every assigned port, in allocation order; use it for spare ports because allocations need not be contiguous. Never hard-code a port: two workspaces would collide.`,
|
|
59
|
+
example: "ports: 20"
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var TEARDOWN_TIMEOUT_MS = 12e4;
|
|
63
|
+
var REMOVE_TIMEOUT_MS = TEARDOWN_TIMEOUT_MS + 3e4;
|
|
64
|
+
|
|
65
|
+
// ../../packages/protocol/src/fuzzy.ts
|
|
66
|
+
var startsWord = (text, index2) => index2 === 0 || !/[a-z0-9]/.test(text[index2 - 1]);
|
|
67
|
+
function fuzzyMatch(query, text) {
|
|
68
|
+
const wanted = query.toLowerCase().replace(/\s+/g, "");
|
|
69
|
+
const given = text.toLowerCase();
|
|
70
|
+
if (!wanted) return { score: 0, indices: [] };
|
|
71
|
+
let best = null;
|
|
72
|
+
for (let start = given.indexOf(wanted[0]); start !== -1; start = given.indexOf(wanted[0], start + 1)) {
|
|
73
|
+
const indices = [start];
|
|
74
|
+
let score = startsWord(given, start) ? 3 : 0;
|
|
75
|
+
for (let i = 1; i < wanted.length; i++) {
|
|
76
|
+
const last = indices[i - 1];
|
|
77
|
+
const next = given.indexOf(wanted[i], last + 1);
|
|
78
|
+
if (next === -1) break;
|
|
79
|
+
score += next === last + 1 ? 2 : startsWord(given, next) ? 1.5 : 0;
|
|
80
|
+
score -= (next - last - 1) * 0.1;
|
|
81
|
+
indices.push(next);
|
|
82
|
+
}
|
|
83
|
+
if (indices.length === wanted.length && (!best || score > best.score))
|
|
84
|
+
best = { score, indices };
|
|
85
|
+
}
|
|
86
|
+
if (best && given.length !== text.length) {
|
|
87
|
+
const offsets = [];
|
|
88
|
+
let offset = 0;
|
|
89
|
+
for (const character of text) {
|
|
90
|
+
const folded = character.toLowerCase();
|
|
91
|
+
for (let i = 0; i < folded.length; i++)
|
|
92
|
+
offsets.push(offset + Math.min(i, character.length - 1));
|
|
93
|
+
offset += character.length;
|
|
94
|
+
}
|
|
95
|
+
best.indices = [...new Set(best.indices.map((index2) => offsets[index2]))];
|
|
96
|
+
}
|
|
97
|
+
return best;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ../daemon/src/git.ts
|
|
101
|
+
import { execFile } from "node:child_process";
|
|
102
|
+
import { promisify } from "node:util";
|
|
103
|
+
var run = promisify(execFile);
|
|
104
|
+
var CHECKOUT_TIMEOUT = 12e4;
|
|
105
|
+
async function git(cwd, args, { env = process.env, timeout = 1e4 } = {}) {
|
|
106
|
+
try {
|
|
107
|
+
return (await run("git", args, {
|
|
108
|
+
cwd,
|
|
109
|
+
env,
|
|
110
|
+
timeout,
|
|
111
|
+
killSignal: "SIGKILL",
|
|
112
|
+
encoding: "utf8",
|
|
113
|
+
maxBuffer: 64 * 1024 * 1024
|
|
114
|
+
})).stdout;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error instanceof Error && "killed" in error && error.killed && "signal" in error && error.signal === "SIGKILL")
|
|
117
|
+
throw new Error(`git ${args.join(" ")} timed out after ${timeout} ms`, { cause: error });
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ../daemon/src/worktree.ts
|
|
123
|
+
import {
|
|
124
|
+
closeSync,
|
|
125
|
+
constants,
|
|
126
|
+
existsSync,
|
|
127
|
+
lstatSync,
|
|
128
|
+
mkdirSync,
|
|
129
|
+
openSync,
|
|
130
|
+
readFileSync,
|
|
131
|
+
realpathSync,
|
|
132
|
+
renameSync,
|
|
133
|
+
writeSync
|
|
134
|
+
} from "node:fs";
|
|
135
|
+
import { basename, join, resolve } from "node:path";
|
|
136
|
+
var read = (file) => readFileSync(file, "utf8").trim();
|
|
137
|
+
var BRANCH = /^(?![-./])(?!.*(?:\.\.|@\{|\/\/|\/\.|\.lock(?:\/|$)))[^\p{Cc} ~^:?*[\\]+(?<![./])$/u;
|
|
138
|
+
function headOf({ path, adminDir }) {
|
|
139
|
+
const head = read(join(adminDir, "HEAD"));
|
|
140
|
+
const branch = /^ref: refs\/heads\/(.+)$/.exec(head)?.[1];
|
|
141
|
+
if (branch && BRANCH.test(branch)) return `refs/heads/${branch}`;
|
|
142
|
+
const commit = /^([0-9a-f]{40,64})$/.exec(head)?.[1];
|
|
143
|
+
if (!commit) throw new Error(`Worktree ${path} has an unreadable HEAD`);
|
|
144
|
+
return commit;
|
|
145
|
+
}
|
|
146
|
+
var gitEnv = ({ path, adminDir, commonDir }) => ({
|
|
147
|
+
...process.env,
|
|
148
|
+
GIT_DIR: commonDir,
|
|
149
|
+
GIT_WORK_TREE: path,
|
|
150
|
+
GIT_INDEX_FILE: join(adminDir, "index"),
|
|
151
|
+
// Looking must not write (git would refresh the index): we watch these files.
|
|
152
|
+
GIT_OPTIONAL_LOCKS: "0"
|
|
153
|
+
});
|
|
154
|
+
function gitIn(worktree, ...args) {
|
|
155
|
+
return git(worktree.path, ["--literal-pathspecs", ...args], {
|
|
156
|
+
env: gitEnv(worktree),
|
|
157
|
+
timeout: ["merge-tree", "read-tree"].includes(args[0]) ? CHECKOUT_TIMEOUT : void 0
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ../daemon/src/file-index.ts
|
|
162
|
+
var LIMIT = 40;
|
|
163
|
+
var MAX_FILE_CHANGES = 128;
|
|
164
|
+
var SAFE_DIFF = ["--no-ext-diff", "--no-textconv", "--ignore-submodules=all", "--no-renames"];
|
|
165
|
+
function addFileScope(scopes, path) {
|
|
166
|
+
for (let parent = path; parent; parent = parent.slice(0, Math.max(0, parent.lastIndexOf("/")))) {
|
|
167
|
+
if (scopes.has(parent)) return true;
|
|
168
|
+
}
|
|
169
|
+
scopes.add(path);
|
|
170
|
+
if (scopes.size <= MAX_FILE_CHANGES) return true;
|
|
171
|
+
const parents = /* @__PURE__ */ new Set();
|
|
172
|
+
let shared = "";
|
|
173
|
+
for (const name of scopes) {
|
|
174
|
+
for (let slash = name.lastIndexOf("/"); slash >= 0; slash = name.lastIndexOf("/", slash - 1)) {
|
|
175
|
+
const parent = name.slice(0, slash);
|
|
176
|
+
if (parent.length <= shared.length) break;
|
|
177
|
+
if (parents.has(parent) || scopes.has(parent)) {
|
|
178
|
+
shared = parent;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
parents.add(parent);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!shared) return false;
|
|
185
|
+
for (const name of scopes) if (name.startsWith(shared + "/")) scopes.delete(name);
|
|
186
|
+
scopes.add(shared);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
function characterMask(lower) {
|
|
190
|
+
let mask = 0;
|
|
191
|
+
for (let i = 0; i < lower.length; i++) {
|
|
192
|
+
const code = lower.charCodeAt(i);
|
|
193
|
+
if (code >= 97 && code <= 122) mask |= 1 << code - 97;
|
|
194
|
+
else if (code >= 48 && code <= 57) mask |= 1 << 26 + (code - 48) % 6;
|
|
195
|
+
}
|
|
196
|
+
return mask;
|
|
197
|
+
}
|
|
198
|
+
async function list(source2, signal, args, visit) {
|
|
199
|
+
const worktree = "worktree" in source2 ? source2.worktree : void 0;
|
|
200
|
+
const child = spawn("git", ["--literal-pathspecs", ...args], {
|
|
201
|
+
cwd: "repoPath" in source2 ? source2.repoPath : source2.worktree.path,
|
|
202
|
+
env: worktree ? gitEnv(worktree) : process.env,
|
|
203
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
204
|
+
signal,
|
|
205
|
+
killSignal: "SIGKILL"
|
|
206
|
+
});
|
|
207
|
+
let diagnostic = "";
|
|
208
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
209
|
+
diagnostic = (diagnostic + chunk).slice(-2048);
|
|
210
|
+
});
|
|
211
|
+
const closed = new Promise((resolve2, reject) => {
|
|
212
|
+
child.once("error", reject);
|
|
213
|
+
child.once(
|
|
214
|
+
"close",
|
|
215
|
+
(code) => code === 0 ? resolve2() : reject(new Error(diagnostic || "Could not list repository files"))
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
await Promise.all([
|
|
219
|
+
closed,
|
|
220
|
+
(async () => {
|
|
221
|
+
let tail = "";
|
|
222
|
+
for await (const chunk of child.stdout.setEncoding("utf8")) {
|
|
223
|
+
const names = (tail + chunk).split("\0");
|
|
224
|
+
tail = names.pop();
|
|
225
|
+
for (const name of names) visit(name);
|
|
226
|
+
}
|
|
227
|
+
})()
|
|
228
|
+
]);
|
|
229
|
+
}
|
|
230
|
+
var FileIndex = class _FileIndex {
|
|
231
|
+
paths = [];
|
|
232
|
+
masks = [];
|
|
233
|
+
byName = /* @__PURE__ */ new Map();
|
|
234
|
+
directories;
|
|
235
|
+
holes = 0;
|
|
236
|
+
// Compare the live Git index with one fixed commit, even if HEAD subsequently moves.
|
|
237
|
+
staging;
|
|
238
|
+
constructor(mutable = true) {
|
|
239
|
+
if (mutable) this.directories = /* @__PURE__ */ new Map([["", /* @__PURE__ */ new Map()]]);
|
|
240
|
+
}
|
|
241
|
+
directory(path) {
|
|
242
|
+
const found = this.directories.get(path);
|
|
243
|
+
if (found) return found;
|
|
244
|
+
const split = path.lastIndexOf("/");
|
|
245
|
+
const parent = path.slice(0, Math.max(0, split));
|
|
246
|
+
const name = path.slice(split + 1);
|
|
247
|
+
if (typeof this.directories.get(parent)?.get(name) === "number") this.remove(path);
|
|
248
|
+
this.directory(parent).set(name, null);
|
|
249
|
+
const entries = /* @__PURE__ */ new Map();
|
|
250
|
+
this.directories.set(path, entries);
|
|
251
|
+
return entries;
|
|
252
|
+
}
|
|
253
|
+
add(path) {
|
|
254
|
+
const split = path.lastIndexOf("/");
|
|
255
|
+
const entries = this.directories && this.directory(path.slice(0, Math.max(0, split)));
|
|
256
|
+
const base = path.slice(split + 1);
|
|
257
|
+
if (typeof entries?.get(base) === "number") return;
|
|
258
|
+
const id = this.paths.length;
|
|
259
|
+
entries?.set(base, id);
|
|
260
|
+
this.paths.push(path);
|
|
261
|
+
this.masks.push(characterMask(path.toLowerCase()));
|
|
262
|
+
const name = base.toLowerCase();
|
|
263
|
+
const group = this.byName.get(name);
|
|
264
|
+
if (!group) this.byName.set(name, { created: id, first: id, mask: characterMask(name) });
|
|
265
|
+
else if (this.directories || (group.others?.size ?? 0) < LIMIT - 1)
|
|
266
|
+
(group.others ??= /* @__PURE__ */ new Set()).add(id);
|
|
267
|
+
}
|
|
268
|
+
/** Git can check a whole new or ignored directory with one literal pathspec. */
|
|
269
|
+
changeScope(path) {
|
|
270
|
+
for (let slash = path.indexOf("/"); slash >= 0; slash = path.indexOf("/", slash + 1)) {
|
|
271
|
+
const parent = path.slice(0, slash);
|
|
272
|
+
if (!this.directories?.has(parent)) return parent;
|
|
273
|
+
}
|
|
274
|
+
return path;
|
|
275
|
+
}
|
|
276
|
+
*under(path) {
|
|
277
|
+
const entries = this.directories.get(path);
|
|
278
|
+
if (!entries) {
|
|
279
|
+
const split = path.lastIndexOf("/");
|
|
280
|
+
if (this.directories.get(path.slice(0, Math.max(0, split)))?.has(path.slice(split + 1)))
|
|
281
|
+
yield path;
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
for (const [name, id] of entries) {
|
|
285
|
+
if (id === null) yield* this.under(path + "/" + name);
|
|
286
|
+
else yield this.paths[id];
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
remove(path) {
|
|
290
|
+
let split = path.lastIndexOf("/");
|
|
291
|
+
const base = path.slice(split + 1);
|
|
292
|
+
let dir = path.slice(0, Math.max(split, 0));
|
|
293
|
+
let entries = this.directories.get(dir);
|
|
294
|
+
const id = entries.get(base);
|
|
295
|
+
entries.delete(base);
|
|
296
|
+
while (dir && !entries.size) {
|
|
297
|
+
this.directories.delete(dir);
|
|
298
|
+
split = dir.lastIndexOf("/");
|
|
299
|
+
const child = dir.slice(split + 1);
|
|
300
|
+
dir = dir.slice(0, Math.max(0, split));
|
|
301
|
+
entries = this.directories.get(dir);
|
|
302
|
+
entries.delete(child);
|
|
303
|
+
}
|
|
304
|
+
this.paths[id] = "";
|
|
305
|
+
this.holes++;
|
|
306
|
+
const name = base.toLowerCase();
|
|
307
|
+
const group = this.byName.get(name);
|
|
308
|
+
if (id !== group.first) group.others.delete(id);
|
|
309
|
+
else {
|
|
310
|
+
const next = group.others?.values().next().value;
|
|
311
|
+
if (next === void 0) this.byName.delete(name);
|
|
312
|
+
else {
|
|
313
|
+
group.first = next;
|
|
314
|
+
group.others.delete(next);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/** Apply the batch only after Git has successfully reported every affected scope. */
|
|
319
|
+
reconcile(scopes, visible) {
|
|
320
|
+
const gone = /* @__PURE__ */ new Set();
|
|
321
|
+
for (const scope of scopes)
|
|
322
|
+
for (const path of this.under(scope)) if (!visible.has(path)) gone.add(path);
|
|
323
|
+
for (const path of gone) this.remove(path);
|
|
324
|
+
for (const path of visible) this.add(path);
|
|
325
|
+
if (this.holes > 4096 && this.holes > this.paths.length / 2) {
|
|
326
|
+
const compact = new _FileIndex();
|
|
327
|
+
compact.staging = this.staging;
|
|
328
|
+
for (const path of this.paths) if (path) compact.add(path);
|
|
329
|
+
return compact;
|
|
330
|
+
}
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
checkpointPaths() {
|
|
334
|
+
return this.holes ? this.paths.filter(Boolean) : this.paths;
|
|
335
|
+
}
|
|
336
|
+
search(query) {
|
|
337
|
+
if (!query) {
|
|
338
|
+
const matches = [];
|
|
339
|
+
for (const path of this.paths) {
|
|
340
|
+
if (path) matches.push({ path, indices: [] });
|
|
341
|
+
if (matches.length === LIMIT) break;
|
|
342
|
+
}
|
|
343
|
+
return matches;
|
|
344
|
+
}
|
|
345
|
+
const best = [];
|
|
346
|
+
const compare = (a, b) => a.tier - b.tier || b.score - a.score || a.id - b.id;
|
|
347
|
+
function offer(id, tier, score) {
|
|
348
|
+
const candidate = { id, tier, score };
|
|
349
|
+
if (best.length === LIMIT && compare(candidate, best[LIMIT - 1]) >= 0) return;
|
|
350
|
+
const at = best.findIndex((other) => compare(candidate, other) < 0);
|
|
351
|
+
best.splice(at < 0 ? best.length : at, 0, candidate);
|
|
352
|
+
if (best.length > LIMIT) best.pop();
|
|
353
|
+
}
|
|
354
|
+
const wanted = query.toLowerCase();
|
|
355
|
+
const required = characterMask(wanted);
|
|
356
|
+
function offerGroup(group, tier, score) {
|
|
357
|
+
offer(group.first, tier, score);
|
|
358
|
+
let count = 1;
|
|
359
|
+
for (const id of group.others ?? []) {
|
|
360
|
+
offer(id, tier, score);
|
|
361
|
+
if (++count === LIMIT) break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const exact = this.byName.get(wanted);
|
|
365
|
+
if (exact) offerGroup(exact, 0, 0);
|
|
366
|
+
if (!wanted.includes("/")) {
|
|
367
|
+
for (const [name, group] of this.byName) {
|
|
368
|
+
const last = best[LIMIT - 1];
|
|
369
|
+
if (last && (last.tier === 0 || last.tier === 1 && group.created > last.id)) break;
|
|
370
|
+
if (group === exact || (group.mask & required) !== required) continue;
|
|
371
|
+
if (name.startsWith(wanted)) offerGroup(group, 1, 0);
|
|
372
|
+
else {
|
|
373
|
+
const match = fuzzyMatch(wanted, name);
|
|
374
|
+
if (match) offerGroup(group, 2, match.score);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (best.length < LIMIT) {
|
|
379
|
+
const named = new Set(best.map((hit) => hit.id));
|
|
380
|
+
for (let id = 0; id < this.paths.length; id++) {
|
|
381
|
+
if (!this.paths[id] || (this.masks[id] & required) !== required || named.has(id)) continue;
|
|
382
|
+
const match = fuzzyMatch(wanted, this.paths[id]);
|
|
383
|
+
if (match) offer(id, 3, match.score);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return best.map(({ id, tier }) => {
|
|
387
|
+
const path = this.paths[id];
|
|
388
|
+
const offset = tier === 3 ? 0 : path.lastIndexOf("/") + 1;
|
|
389
|
+
const { indices } = fuzzyMatch(wanted, path.slice(offset));
|
|
390
|
+
return { path, indices: indices.map((i) => i + offset) };
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
async function listWorktreeFiles(source2, scopes, visit) {
|
|
395
|
+
const signal = AbortSignal.timeout(FILE_SEARCH_TIMEOUT_MS);
|
|
396
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
397
|
+
await list(
|
|
398
|
+
source2,
|
|
399
|
+
signal,
|
|
400
|
+
["diff-files", ...SAFE_DIFF, "--diff-filter=D", "--name-only", "-z", "--", ...scopes],
|
|
401
|
+
(path) => deleted.add(path)
|
|
402
|
+
);
|
|
403
|
+
await list(
|
|
404
|
+
source2,
|
|
405
|
+
signal,
|
|
406
|
+
[
|
|
407
|
+
"ls-files",
|
|
408
|
+
"--cached",
|
|
409
|
+
"--others",
|
|
410
|
+
"--exclude-standard",
|
|
411
|
+
"--deduplicate",
|
|
412
|
+
"-z",
|
|
413
|
+
"--",
|
|
414
|
+
...scopes
|
|
415
|
+
],
|
|
416
|
+
(path) => {
|
|
417
|
+
if (!deleted.has(path)) visit(path);
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
async function stagedNames(source2, commit) {
|
|
422
|
+
const changed = /* @__PURE__ */ new Set();
|
|
423
|
+
await list(
|
|
424
|
+
source2,
|
|
425
|
+
AbortSignal.timeout(FILE_SEARCH_TIMEOUT_MS),
|
|
426
|
+
[
|
|
427
|
+
"diff-index",
|
|
428
|
+
"--cached",
|
|
429
|
+
...SAFE_DIFF,
|
|
430
|
+
"--diff-filter=ADTU",
|
|
431
|
+
"--name-only",
|
|
432
|
+
"-z",
|
|
433
|
+
commit,
|
|
434
|
+
"--"
|
|
435
|
+
],
|
|
436
|
+
(path) => {
|
|
437
|
+
if (changed.size <= MAX_FILE_CHANGES) changed.add(path);
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
return changed.size <= MAX_FILE_CHANGES ? changed : null;
|
|
441
|
+
}
|
|
442
|
+
async function buildFileIndex(source2) {
|
|
443
|
+
const index2 = new FileIndex("worktree" in source2);
|
|
444
|
+
if ("revision" in source2) {
|
|
445
|
+
await list(
|
|
446
|
+
source2,
|
|
447
|
+
AbortSignal.timeout(FILE_SEARCH_TIMEOUT_MS),
|
|
448
|
+
["ls-tree", "-rz", "--name-only", source2.revision],
|
|
449
|
+
(path) => index2.add(path)
|
|
450
|
+
);
|
|
451
|
+
} else {
|
|
452
|
+
const commit = await gitIn(
|
|
453
|
+
source2.worktree,
|
|
454
|
+
"rev-parse",
|
|
455
|
+
"--verify",
|
|
456
|
+
headOf(source2.worktree)
|
|
457
|
+
).then(
|
|
458
|
+
(s) => s.trim(),
|
|
459
|
+
() => null
|
|
460
|
+
);
|
|
461
|
+
if (commit) index2.staging = { commit, changed: await stagedNames(source2, commit) };
|
|
462
|
+
await listWorktreeFiles(source2, [], (path) => index2.add(path));
|
|
463
|
+
}
|
|
464
|
+
return index2;
|
|
465
|
+
}
|
|
466
|
+
async function refreshFileIndex(index2, source2, changes) {
|
|
467
|
+
if (!("worktree" in source2)) return index2;
|
|
468
|
+
const scopes = new Set(changes.paths.map((path) => index2.changeScope(path)));
|
|
469
|
+
if (changes.gitIndex) {
|
|
470
|
+
if (!index2.staging?.changed) return buildFileIndex(source2);
|
|
471
|
+
const next = await stagedNames(source2, index2.staging.commit);
|
|
472
|
+
if (!next) return buildFileIndex(source2);
|
|
473
|
+
for (const path of index2.staging.changed) scopes.add(path);
|
|
474
|
+
for (const path of next) scopes.add(path);
|
|
475
|
+
index2.staging.changed = next;
|
|
476
|
+
}
|
|
477
|
+
if (scopes.size > MAX_FILE_CHANGES) return buildFileIndex(source2);
|
|
478
|
+
const paths = [...scopes];
|
|
479
|
+
const visible = /* @__PURE__ */ new Set();
|
|
480
|
+
for (let i = 0; i < paths.length; i += 8) {
|
|
481
|
+
await listWorktreeFiles(source2, paths.slice(i, i + 8), (path) => visible.add(path));
|
|
482
|
+
}
|
|
483
|
+
return index2.reconcile(paths, visible);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ../daemon/src/file-index-cache.ts
|
|
487
|
+
var digest = (data) => createHash("sha256").update(data).digest();
|
|
488
|
+
function checkpointName(root, path) {
|
|
489
|
+
return join2(root, digest(path).toString("hex"));
|
|
490
|
+
}
|
|
491
|
+
async function stamp(path, directory = false) {
|
|
492
|
+
try {
|
|
493
|
+
const s = await stat(path, { bigint: true });
|
|
494
|
+
return [path, s.dev, s.ino, s.birthtimeNs, directory ? "" : s.ctimeNs].join("/");
|
|
495
|
+
} catch (err) {
|
|
496
|
+
if (err.code === "ENOENT") return path + "/missing";
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
async function gitExcludesFile(tree) {
|
|
501
|
+
const defaultIgnore = join2(
|
|
502
|
+
process.env.XDG_CONFIG_HOME || join2(homedir(), ".config"),
|
|
503
|
+
"git",
|
|
504
|
+
"ignore"
|
|
505
|
+
);
|
|
506
|
+
const excludes2 = (await gitIn(tree, "config", "--path", "--default", defaultIgnore, "--get", "core.excludesFile")).trimEnd();
|
|
507
|
+
return isAbsolute(excludes2) ? excludes2 : join2(tree.path, excludes2);
|
|
508
|
+
}
|
|
509
|
+
async function readExcludesState(tree, knownPath) {
|
|
510
|
+
const path = knownPath ?? await gitExcludesFile(tree);
|
|
511
|
+
return { path, stamp: await stamp(path) };
|
|
512
|
+
}
|
|
513
|
+
async function worktreeState(tree, excludesStamp) {
|
|
514
|
+
const [root, admin, rules, config, gitIndex2] = await Promise.all([
|
|
515
|
+
stamp(tree.path, true),
|
|
516
|
+
stamp(tree.adminDir, true),
|
|
517
|
+
stamp(join2(tree.commonDir, "info/exclude")),
|
|
518
|
+
gitIn(tree, "config", "--null", "--list"),
|
|
519
|
+
stamp(join2(tree.adminDir, "index"))
|
|
520
|
+
]);
|
|
521
|
+
return {
|
|
522
|
+
identity: digest(JSON.stringify([root, admin, rules, excludesStamp, config])).toString("hex"),
|
|
523
|
+
gitIndex: gitIndex2
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
async function readCheckpoint(path, identity) {
|
|
527
|
+
const bytes = await readFile(path);
|
|
528
|
+
const data = bytes.subarray(32);
|
|
529
|
+
if (!digest(data).equals(bytes.subarray(0, 32))) return;
|
|
530
|
+
const saved = deserialize(data);
|
|
531
|
+
if (saved.identity === identity) return saved;
|
|
532
|
+
}
|
|
533
|
+
async function prepare(source2, temp, excludesStamp) {
|
|
534
|
+
if (!("worktree" in source2))
|
|
535
|
+
return { identity: JSON.stringify([1, source2.repoPath, source2.revision]) };
|
|
536
|
+
const tree = source2.worktree;
|
|
537
|
+
const root = await realpath(tree.path);
|
|
538
|
+
if (excludesStamp === void 0) throw new Error("Could not check Git ignore rules");
|
|
539
|
+
const state = await worktreeState(tree, excludesStamp);
|
|
540
|
+
const watcher = (await import("@parcel/watcher")).default;
|
|
541
|
+
const options = { backend: "fs-events" };
|
|
542
|
+
const file = join2(temp, "cursor");
|
|
543
|
+
await watcher.writeSnapshot(root, file, options);
|
|
544
|
+
const cursor = await readFile(file);
|
|
545
|
+
if (!cursor.length) throw new Error("Empty file watcher snapshot");
|
|
546
|
+
async function changedPaths(previous) {
|
|
547
|
+
if (!previous?.length) return;
|
|
548
|
+
await writeFile(file, previous);
|
|
549
|
+
const scopes = /* @__PURE__ */ new Set();
|
|
550
|
+
for (const event of await watcher.getEventsSince(root, file, options)) {
|
|
551
|
+
let name = relative(root, event.path).split(sep).join("/");
|
|
552
|
+
if (basename2(name) === ".gitignore") name = dirname(name);
|
|
553
|
+
if (!name || name === "." || name === ".." || name.startsWith("../") || isAbsolute(name))
|
|
554
|
+
return;
|
|
555
|
+
if (!addFileScope(scopes, name)) return;
|
|
556
|
+
}
|
|
557
|
+
return [...scopes];
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
identity: JSON.stringify([2, options.backend, state.identity]),
|
|
561
|
+
gitIndex: state.gitIndex,
|
|
562
|
+
cursor,
|
|
563
|
+
changedPaths
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
async function loadFileIndex(source2, cacheDir2, restore, excludesStamp) {
|
|
567
|
+
if (!cacheDir2 || "worktree" in source2 && process.platform !== "darwin" || "revision" in source2 && !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(source2.revision))
|
|
568
|
+
return buildFileIndex(source2);
|
|
569
|
+
const path = checkpointName(
|
|
570
|
+
cacheDir2,
|
|
571
|
+
"worktree" in source2 ? source2.worktree.path : source2.repoPath
|
|
572
|
+
);
|
|
573
|
+
let temp;
|
|
574
|
+
try {
|
|
575
|
+
let current;
|
|
576
|
+
try {
|
|
577
|
+
const pending2 = join2(cacheDir2, "pending");
|
|
578
|
+
await mkdir(pending2, { recursive: true, mode: 448 });
|
|
579
|
+
temp = await mkdtemp(join2(pending2, "write-"));
|
|
580
|
+
current = await prepare(source2, temp, excludesStamp);
|
|
581
|
+
} catch {
|
|
582
|
+
return await buildFileIndex(source2);
|
|
583
|
+
}
|
|
584
|
+
const saved = restore && await readCheckpoint(path, current.identity).catch(() => void 0);
|
|
585
|
+
let index2;
|
|
586
|
+
if (saved) {
|
|
587
|
+
const paths = current.changedPaths ? await current.changedPaths(saved.cursor).catch(() => void 0) : [];
|
|
588
|
+
if (paths) {
|
|
589
|
+
const previous = new FileIndex("worktree" in source2);
|
|
590
|
+
for (const name of saved.paths) previous.add(name);
|
|
591
|
+
previous.staging = saved.staging;
|
|
592
|
+
const gitIndex2 = current.gitIndex !== saved.gitIndex;
|
|
593
|
+
if (!paths.length && !gitIndex2) return previous;
|
|
594
|
+
index2 = await refreshFileIndex(previous, source2, { paths, gitIndex: gitIndex2 }).catch(
|
|
595
|
+
() => void 0
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
index2 ??= await buildFileIndex(source2);
|
|
600
|
+
try {
|
|
601
|
+
const data = serialize({
|
|
602
|
+
identity: current.identity,
|
|
603
|
+
gitIndex: current.gitIndex,
|
|
604
|
+
cursor: current.cursor,
|
|
605
|
+
paths: index2.checkpointPaths(),
|
|
606
|
+
staging: index2.staging
|
|
607
|
+
});
|
|
608
|
+
const output = join2(temp, "index");
|
|
609
|
+
await writeFile(output, Buffer.concat([digest(data), data]), { mode: 384 });
|
|
610
|
+
await rename(output, path);
|
|
611
|
+
} catch {
|
|
612
|
+
}
|
|
613
|
+
return index2;
|
|
614
|
+
} finally {
|
|
615
|
+
if (temp) await rm(temp, { recursive: true, force: true }).catch(() => {
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// ../daemon/src/file-index-worker.ts
|
|
621
|
+
var { source, cacheDir } = workerData;
|
|
622
|
+
var index;
|
|
623
|
+
var dirty = /* @__PURE__ */ new Set();
|
|
624
|
+
var gitIndex = false;
|
|
625
|
+
var excludes;
|
|
626
|
+
var revision = 0;
|
|
627
|
+
var pending = Promise.resolve();
|
|
628
|
+
parentPort.on("message", (message) => {
|
|
629
|
+
if (!("id" in message)) {
|
|
630
|
+
gitIndex ||= !!message.changes?.gitIndex;
|
|
631
|
+
if (!message.changes || !message.changes.paths.every((path) => addFileScope(dirty, index?.changeScope(path) ?? path))) {
|
|
632
|
+
revision++;
|
|
633
|
+
index = void 0;
|
|
634
|
+
dirty.clear();
|
|
635
|
+
}
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
pending = pending.then(async () => {
|
|
639
|
+
try {
|
|
640
|
+
const started = revision;
|
|
641
|
+
const changes = { paths: [...dirty], gitIndex };
|
|
642
|
+
gitIndex = false;
|
|
643
|
+
dirty.clear();
|
|
644
|
+
let snapshot = index;
|
|
645
|
+
if ("worktree" in source) {
|
|
646
|
+
const next = await readExcludesState(source.worktree, snapshot && excludes?.path).catch(
|
|
647
|
+
() => void 0
|
|
648
|
+
);
|
|
649
|
+
if (!next || next.stamp !== excludes?.stamp) snapshot = void 0;
|
|
650
|
+
excludes = next;
|
|
651
|
+
}
|
|
652
|
+
if (!snapshot)
|
|
653
|
+
snapshot = await loadFileIndex(source, cacheDir, started === 0, excludes?.stamp);
|
|
654
|
+
else if (changes.paths.length || changes.gitIndex)
|
|
655
|
+
snapshot = await refreshFileIndex(snapshot, source, changes);
|
|
656
|
+
if (started === revision) index = snapshot;
|
|
657
|
+
parentPort.postMessage({ id: message.id, result: snapshot.search(message.query) });
|
|
658
|
+
} catch (error) {
|
|
659
|
+
index = void 0;
|
|
660
|
+
parentPort.postMessage({
|
|
661
|
+
id: message.id,
|
|
662
|
+
error: error instanceof Error ? error.message : String(error)
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
});
|