dsh-remote-vs 0.21.1 → 0.23.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/README.en.md +489 -473
- package/README.md +434 -424
- package/cordis.patch.yml +13 -5
- package/lib/client.js +946 -256
- package/lib/index.js +187 -15
- package/lib/p2-router-fs.js +6 -7
- package/lib/types/changes/recorder.d.ts +21 -0
- package/lib/types/changes/status.d.ts +41 -1
- package/lib/types/changes/text-diff.d.ts +18 -0
- package/lib/types/client/changes/ChangesDock.d.ts +9 -2
- package/lib/types/client/changes/model.d.ts +3 -1
- package/lib/types/client/changes/review-state.d.ts +67 -0
- package/lib/types/client/notices.d.ts +35 -0
- package/lib/types/client/store.d.ts +51 -0
- package/lib/types/client/vsc/change-marks.d.ts +17 -0
- package/lib/types/client/vsc/kit.d.ts +9 -0
- package/lib/types/deploy.d.ts +28 -2
- package/lib/types/notices.d.ts +22 -0
- package/lib/types/p2/router-fs.d.ts +4 -5
- package/lib/types/p2/worlds.d.ts +10 -0
- package/lib/types/protocol.d.ts +37 -1
- package/lib/{worlds-DSzyajOB.js → worlds-DXdP4SMn.js} +80 -4
- package/package.json +37 -37
- package/src/changes/recorder.ts +93 -28
- package/src/changes/status.ts +69 -2
- package/src/changes/text-diff.ts +42 -0
- package/src/client/DirectoryFlow.tsx +65 -5
- package/src/client/api.ts +5 -0
- package/src/client/changes/ChangesDock.tsx +241 -39
- package/src/client/changes/changes.css +122 -9
- package/src/client/changes/model.ts +106 -22
- package/src/client/changes/review-state.ts +133 -0
- package/src/client/i18n.ts +48 -8
- package/src/client/index.tsx +24 -5
- package/src/client/notices.ts +86 -0
- package/src/client/store.tsx +186 -2
- package/src/client/vsc/change-marks.ts +39 -6
- package/src/client/vsc/kit.tsx +16 -1
- package/src/client/vsc/vsc.css +23 -0
- package/src/deploy.ts +38 -2
- package/src/http.ts +12 -1
- package/src/notices.ts +37 -0
- package/src/p2/router-fs.ts +5 -6
- package/src/p2/worlds.ts +46 -2
- package/src/protocol.ts +37 -1
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.helper.json +19 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz +4 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz.sha256 +1 -0
- package/vendor/dsh-remote-helpers/ssh-helper-runtime-deps.patch +14 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.helper.json +0 -16
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.tar.gz +0 -4
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.1-alpha.2-linux-x64.tar.gz.sha256 +0 -1
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as ensurePrivateDir, S as dshHome, T as storePath, _ as MIN_TIMEOUT_MS, a as helperAvailability, b as require_lib, c as seedHelperCache, d as attachmentHeader, f as DEFAULT_GIT_TIMEOUT_MS, g as MAX_TIMEOUT_MS, h as DeadlineError, i as drainHostNotices, l as RemoteFiles, m as DEFAULT_TIMEOUTS, n as TombstonedError, o as probe, p as DEFAULT_READ_TIMEOUT_MS, s as pushPipeline, t as RemoteWorlds, u as WriteConflictError, v as clampExecTimeout, w as keysDir, x as aliasRoot, y as resolveTimeouts } from "./worlds-DXdP4SMn.js";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, statSync, writeSync } from "node:fs";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -2094,11 +2094,16 @@ function isJsonObject(value) {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
/** Write one JSON response. */
|
|
2096
2096
|
function writeJson(res, status, body, headers = {}) {
|
|
2097
|
+
const notices = typeof body === "object" && body !== null && !Array.isArray(body) ? drainHostNotices() : [];
|
|
2098
|
+
const payload = notices.length > 0 ? {
|
|
2099
|
+
...body,
|
|
2100
|
+
notices
|
|
2101
|
+
} : body;
|
|
2097
2102
|
res.writeHead(status, {
|
|
2098
2103
|
...JSON_HEADERS,
|
|
2099
2104
|
...headers
|
|
2100
2105
|
});
|
|
2101
|
-
res.end(JSON.stringify(
|
|
2106
|
+
res.end(JSON.stringify(payload));
|
|
2102
2107
|
}
|
|
2103
2108
|
/**
|
|
2104
2109
|
* Write one failed-operation response, tagging a budget that merely ran out.
|
|
@@ -4861,13 +4866,89 @@ function trackedStatusCommand(root) {
|
|
|
4861
4866
|
return [cdLine(root), "git --no-pager status --porcelain -z -uno -- ."].join("\n");
|
|
4862
4867
|
}
|
|
4863
4868
|
/**
|
|
4869
|
+
* Directory names the ledger does not count as session changes.
|
|
4870
|
+
*
|
|
4871
|
+
* Build output and dependency caches are the two things a build leaves behind,
|
|
4872
|
+
* and neither is this session's work. `--exclude-standard` only covers what the
|
|
4873
|
+
* repository's own ignore rules name, so a checkout whose build directory is NOT
|
|
4874
|
+
* ignored pays twice: thousands of paths fill the 500-row list (sorted, and
|
|
4875
|
+
* `build/`/`out/` sort BEFORE `src/`, so the real changes get truncated away) and
|
|
4876
|
+
* every listed path costs a read out of the 8 MiB transfer budget.
|
|
4877
|
+
*
|
|
4878
|
+
* The names mirror the three lists the plugin already prunes by elsewhere
|
|
4879
|
+
* (`client/quickopen-model.ts` `EXCLUDED_DIRECTORIES`, `p2/file-refs.ts`
|
|
4880
|
+
* `REMOTE_FILE_SEARCH_EXCLUDED_DIRECTORIES`, `search-ops.ts` `PRUNE_DIRS`). One
|
|
4881
|
+
* vocabulary, four consumers: fold them into a shared module when one of those
|
|
4882
|
+
* surfaces is next touched, instead of adding a fifth spelling here.
|
|
4883
|
+
*/
|
|
4884
|
+
const UNTRACKED_EXCLUDED_DIRECTORIES = [
|
|
4885
|
+
".git",
|
|
4886
|
+
"node_modules",
|
|
4887
|
+
"dist",
|
|
4888
|
+
"build",
|
|
4889
|
+
"out",
|
|
4890
|
+
"coverage",
|
|
4891
|
+
"target",
|
|
4892
|
+
".next",
|
|
4893
|
+
".nuxt",
|
|
4894
|
+
".turbo",
|
|
4895
|
+
".venv",
|
|
4896
|
+
"__pycache__",
|
|
4897
|
+
".pytest_cache",
|
|
4898
|
+
".mypy_cache",
|
|
4899
|
+
".gradle"
|
|
4900
|
+
];
|
|
4901
|
+
/** Ceiling on the pathspecs one command carries (a cap, not a policy). */
|
|
4902
|
+
const MAX_EXCLUDE_DIRS = 32;
|
|
4903
|
+
/**
|
|
4904
|
+
* Keep only directory names a pathspec may name safely.
|
|
4905
|
+
*
|
|
4906
|
+
* A value that is absolute, carries a separator, walks up or looks like a flag
|
|
4907
|
+
* is DROPPED rather than rejected: the list is configuration, and one bad entry
|
|
4908
|
+
* must not stop the scan — the scan's job is to say what changed, not to police
|
|
4909
|
+
* a setting. Dropping is also the conservative direction: a name that is not
|
|
4910
|
+
* excluded is merely visible, while a malformed pathspec would hide paths the
|
|
4911
|
+
* user never asked to hide (or turn `--exclude` into another flag).
|
|
4912
|
+
*
|
|
4913
|
+
* @param dirs - candidate names (undefined = none).
|
|
4914
|
+
* @returns the usable names, deduplicated, in the given order.
|
|
4915
|
+
*/
|
|
4916
|
+
function excludeDirNames(dirs) {
|
|
4917
|
+
const kept = [];
|
|
4918
|
+
for (const raw of dirs ?? []) {
|
|
4919
|
+
const name = raw.trim();
|
|
4920
|
+
if (name === "" || name === "." || name === "..") continue;
|
|
4921
|
+
if (name.includes("/") || name.includes("\\") || name.includes("\0")) continue;
|
|
4922
|
+
if (/[*?[\]]/.test(name)) continue;
|
|
4923
|
+
if (name.startsWith("-")) continue;
|
|
4924
|
+
if (kept.includes(name)) continue;
|
|
4925
|
+
if (kept.length >= MAX_EXCLUDE_DIRS) break;
|
|
4926
|
+
kept.push(name);
|
|
4927
|
+
}
|
|
4928
|
+
return kept;
|
|
4929
|
+
}
|
|
4930
|
+
/**
|
|
4864
4931
|
* New files git is not tracking yet (the ones a session usually creates).
|
|
4865
4932
|
*
|
|
4933
|
+
* The exclusions are pushed down as pathspecs (`:(exclude)out`) rather than
|
|
4934
|
+
* filtered after the fact, so those paths never cross the wire and never enter
|
|
4935
|
+
* the 500-row cap. Measured on a tree with 3000 build outputs + 300 sources:
|
|
4936
|
+
* 3300 records / 61.5 KB unfiltered versus 300 records / 6.8 KB with two
|
|
4937
|
+
* exclusions — the walk itself costs the same either way (git still descends
|
|
4938
|
+
* those directories), so the win is wire bytes, parse time and the read budget,
|
|
4939
|
+
* not scan latency.
|
|
4940
|
+
*
|
|
4866
4941
|
* @param root - remote absolute POSIX directory (the session cwd).
|
|
4942
|
+
* @param excludeDirs - directory names to leave out (see {@link excludeDirNames}).
|
|
4867
4943
|
* @returns a `sh` script printing NUL-separated paths.
|
|
4868
4944
|
*/
|
|
4869
|
-
function untrackedCommand(root) {
|
|
4870
|
-
|
|
4945
|
+
function untrackedCommand(root, excludeDirs = []) {
|
|
4946
|
+
const pathspec = [
|
|
4947
|
+
"--",
|
|
4948
|
+
".",
|
|
4949
|
+
...excludeDirNames(excludeDirs).map((name) => shq(`:(exclude)${name}`))
|
|
4950
|
+
].join(" ");
|
|
4951
|
+
return [cdLine(root), `git ls-files --others --exclude-standard -z ${pathspec}`].join("\n");
|
|
4871
4952
|
}
|
|
4872
4953
|
/**
|
|
4873
4954
|
* Parse `git status --porcelain -z -uno` output.
|
|
@@ -5518,6 +5599,44 @@ function lastLineOfSide(lines, tag) {
|
|
|
5518
5599
|
}
|
|
5519
5600
|
return -1;
|
|
5520
5601
|
}
|
|
5602
|
+
/**
|
|
5603
|
+
* Serialize a WHOLE file comparison as ONE patch (one header, every hunk).
|
|
5604
|
+
*
|
|
5605
|
+
* "Revert everything this session did to this file" is `git apply -R` of the
|
|
5606
|
+
* file's complete diff, and that is a single write instead of one write per
|
|
5607
|
+
* hunk. Concatenating `hunkPatch` output would also apply (git tolerates the
|
|
5608
|
+
* repeated headers and re-anchors each block by offset), but it says the same
|
|
5609
|
+
* file begins twice and depends on offset guessing — a real unified diff names
|
|
5610
|
+
* the file once and lets git place every hunk against one picture.
|
|
5611
|
+
*
|
|
5612
|
+
* Verified against git 2.x: the result reverse-applies to a file whose content
|
|
5613
|
+
* is `hunks`' new side, and leaves it byte-identical to the old side.
|
|
5614
|
+
*
|
|
5615
|
+
* @param displayPath - repo-relative path, as the panel shows it.
|
|
5616
|
+
* @param hunks - every hunk of the comparison, in ascending order.
|
|
5617
|
+
* @returns the patch, or '' when there is nothing to write (no hunks).
|
|
5618
|
+
*/
|
|
5619
|
+
function filePatch(displayPath, hunks) {
|
|
5620
|
+
if (hunks.length === 0) return "";
|
|
5621
|
+
const out = [`--- a/${displayPath}`, `+++ b/${displayPath}`];
|
|
5622
|
+
for (const hunk of hunks) {
|
|
5623
|
+
out.push(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`);
|
|
5624
|
+
const markers = /* @__PURE__ */ new Set();
|
|
5625
|
+
if (hunk.oldNoEol === true) {
|
|
5626
|
+
const at = lastLineOfSide(hunk.lines, "-");
|
|
5627
|
+
if (at >= 0) markers.add(at);
|
|
5628
|
+
}
|
|
5629
|
+
if (hunk.newNoEol === true) {
|
|
5630
|
+
const at = lastLineOfSide(hunk.lines, "+");
|
|
5631
|
+
if (at >= 0) markers.add(at);
|
|
5632
|
+
}
|
|
5633
|
+
for (let index = 0; index < hunk.lines.length; index += 1) {
|
|
5634
|
+
out.push(hunk.lines[index] ?? "");
|
|
5635
|
+
if (markers.has(index)) out.push("\");
|
|
5636
|
+
}
|
|
5637
|
+
}
|
|
5638
|
+
return `${out.join("\n")}\n`;
|
|
5639
|
+
}
|
|
5521
5640
|
//#endregion
|
|
5522
5641
|
//#region src/changes/recorder.ts
|
|
5523
5642
|
/**
|
|
@@ -5533,6 +5652,20 @@ function panelStatus(status) {
|
|
|
5533
5652
|
const WATCHDOG_GRACE_MS = 5e3;
|
|
5534
5653
|
/** Sentinel for "the host call never came back". */
|
|
5535
5654
|
const WATCHDOG_FIRED = "watchdog-fired";
|
|
5655
|
+
/**
|
|
5656
|
+
* Per-file budget for the ONE read a click asks for (`diff`).
|
|
5657
|
+
*
|
|
5658
|
+
* A scan compares hundreds of paths and stays at 256 KiB; a single file the user
|
|
5659
|
+
* asked to review is a different trade — 2 MiB is enough for the large sources
|
|
5660
|
+
* a monorepo carries while keeping the base64 reply (≈2.7 MB) inside what one
|
|
5661
|
+
* exec comfortably returns.
|
|
5662
|
+
*/
|
|
5663
|
+
const DIFF_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
5664
|
+
/** The single-file read budget, as `readPaths` wants it. */
|
|
5665
|
+
const DIFF_LIMITS = {
|
|
5666
|
+
perFile: DIFF_MAX_FILE_BYTES,
|
|
5667
|
+
total: DIFF_MAX_FILE_BYTES
|
|
5668
|
+
};
|
|
5536
5669
|
/** POSIX join — `node:path` would apply Windows semantics on the host. */
|
|
5537
5670
|
function posixJoin(base, rel) {
|
|
5538
5671
|
if (rel.startsWith("/")) return rel;
|
|
@@ -5582,6 +5715,7 @@ var SessionChanges = class {
|
|
|
5582
5715
|
const ledger = this.ledgers.get(sessionId);
|
|
5583
5716
|
if (ledger === void 0) return null;
|
|
5584
5717
|
const unavailable = ledger.unavailable ?? (ledger.untrackedFailure === void 0 ? void 0 : `new-file scan unavailable: ${ledger.untrackedFailure} (use the refresh button to retry)`);
|
|
5718
|
+
const excludedDirs = this.excludedDirs();
|
|
5585
5719
|
return {
|
|
5586
5720
|
alias: ledger.alias,
|
|
5587
5721
|
root: ledger.root,
|
|
@@ -5590,6 +5724,7 @@ var SessionChanges = class {
|
|
|
5590
5724
|
added: ledger.added,
|
|
5591
5725
|
deleted: ledger.deleted,
|
|
5592
5726
|
at: ledger.at,
|
|
5727
|
+
...excludedDirs.length === 0 ? {} : { excludedDirs },
|
|
5593
5728
|
pending: ledger.untrackedJob !== void 0 || ledger.pending && ledger.files.length > 0,
|
|
5594
5729
|
...ledger.truncated === true ? { truncated: true } : {},
|
|
5595
5730
|
...unavailable === void 0 ? {} : { unavailable }
|
|
@@ -5604,6 +5739,14 @@ var SessionChanges = class {
|
|
|
5604
5739
|
* change the file between scans, and replaying a cached copy against a fresh
|
|
5605
5740
|
* buffer is exactly how the painted lines end up at the wrong places.
|
|
5606
5741
|
*
|
|
5742
|
+
* This is the ONE read a user asks for by clicking a row, so it is allowed a
|
|
5743
|
+
* larger per-file budget than a scan (`DIFF_MAX_FILE_BYTES`): a file the list
|
|
5744
|
+
* had to withhold as "too large" can still be reviewed and reverted here,
|
|
5745
|
+
* while a scan stays cheap. A withheld HEAD side is retaken at that budget
|
|
5746
|
+
* (git has the bytes); a withheld BASELINE side is not — that snapshot
|
|
5747
|
+
* described the session's own starting point and cannot be reconstructed, so
|
|
5748
|
+
* the file stays display-only rather than guessing a wrong reverse.
|
|
5749
|
+
*
|
|
5607
5750
|
* @param sessionId - live session owning the ledger.
|
|
5608
5751
|
* @param path - the file's remote absolute path (as listed in the summary).
|
|
5609
5752
|
* @returns hunks for decorations, or null when the session/file is unknown.
|
|
@@ -5617,7 +5760,7 @@ var SessionChanges = class {
|
|
|
5617
5760
|
let afterText = record.after;
|
|
5618
5761
|
let binary = record.binary;
|
|
5619
5762
|
let truncated = record.truncated;
|
|
5620
|
-
const fresh = await this.readPaths(ledger, [record.display], "worktree");
|
|
5763
|
+
const fresh = await this.readPaths(ledger, [record.display], "worktree", DIFF_LIMITS);
|
|
5621
5764
|
if (ledger.disposed) return null;
|
|
5622
5765
|
const side = fresh.get(record.display);
|
|
5623
5766
|
if (side !== void 0) {
|
|
@@ -5633,14 +5776,30 @@ var SessionChanges = class {
|
|
|
5633
5776
|
hunks: [],
|
|
5634
5777
|
...status === void 0 ? {} : { status }
|
|
5635
5778
|
};
|
|
5636
|
-
|
|
5779
|
+
let beforeText = record.before;
|
|
5780
|
+
if (beforeText === null && record.beforeFrom === "head") {
|
|
5781
|
+
const head = await this.readPaths(ledger, [record.display], "head", DIFF_LIMITS);
|
|
5782
|
+
if (ledger.disposed) return null;
|
|
5783
|
+
beforeText = head.get(record.display)?.text ?? null;
|
|
5784
|
+
}
|
|
5785
|
+
const result = diffText(beforeText ?? "", afterText ?? "");
|
|
5786
|
+
/**
|
|
5787
|
+
* The reverse patch exists only when the comparison is complete and has an
|
|
5788
|
+
* old side. A whole-file creation has no old side: its reverse is "delete the
|
|
5789
|
+
* file", which a patch cannot express (the client uses
|
|
5790
|
+
* `RemoteChangedFile.revert` for that case instead). Withheld bytes are not
|
|
5791
|
+
* evidence either, so a truncated after side gets no patch — the client's
|
|
5792
|
+
* undo path then refuses (`changes.undoMissing`) instead of guessing.
|
|
5793
|
+
*/
|
|
5794
|
+
const reverse = beforeText !== null && !truncated ? filePatch(record.display, result.hunks) : "";
|
|
5795
|
+
const hunks = result.hunks.map((hunk) => ({
|
|
5637
5796
|
oldStart: hunk.oldStart,
|
|
5638
5797
|
oldCount: hunk.oldLines,
|
|
5639
5798
|
newStart: hunk.newStart,
|
|
5640
5799
|
newCount: hunk.newLines,
|
|
5641
5800
|
heading: "",
|
|
5642
5801
|
lines: hunk.lines,
|
|
5643
|
-
patch:
|
|
5802
|
+
patch: reverse === "" ? "" : hunkPatch(record.display, hunk)
|
|
5644
5803
|
}));
|
|
5645
5804
|
if (hunks.length === 0) return {
|
|
5646
5805
|
kind: "missing",
|
|
@@ -5654,6 +5813,7 @@ var SessionChanges = class {
|
|
|
5654
5813
|
path,
|
|
5655
5814
|
display: record.display,
|
|
5656
5815
|
hunks,
|
|
5816
|
+
...reverse === "" ? {} : { patch: reverse },
|
|
5657
5817
|
...status === void 0 ? {} : { status },
|
|
5658
5818
|
...truncated ? { truncated: true } : {}
|
|
5659
5819
|
};
|
|
@@ -5922,7 +6082,9 @@ var SessionChanges = class {
|
|
|
5922
6082
|
let added = 0;
|
|
5923
6083
|
let deleted = 0;
|
|
5924
6084
|
for (const entry of listed) {
|
|
5925
|
-
const
|
|
6085
|
+
const fromBaseline = baseline.get(entry.path);
|
|
6086
|
+
const fromHead = head.get(entry.path);
|
|
6087
|
+
const beforeSide = fromBaseline ?? fromHead;
|
|
5926
6088
|
const afterSide = after.get(entry.path);
|
|
5927
6089
|
const before = beforeSide?.text ?? null;
|
|
5928
6090
|
const afterText = afterSide?.text ?? null;
|
|
@@ -5932,7 +6094,7 @@ var SessionChanges = class {
|
|
|
5932
6094
|
if (!binary && !fileTruncated && before === afterText) continue;
|
|
5933
6095
|
if ((binary || fileTruncated) && sameStat(beforeSide, afterSide)) continue;
|
|
5934
6096
|
const oversized = fileTruncated && !binary;
|
|
5935
|
-
const
|
|
6097
|
+
const revert = !binary && !oversized && beforeSide !== void 0 && !(before === null) ? "patch" : entry.status === "A" ? "delete" : void 0;
|
|
5936
6098
|
const diff = binary || oversized ? {
|
|
5937
6099
|
added: 0,
|
|
5938
6100
|
deleted: 0
|
|
@@ -5947,7 +6109,7 @@ var SessionChanges = class {
|
|
|
5947
6109
|
after: afterText,
|
|
5948
6110
|
binary,
|
|
5949
6111
|
truncated: fileTruncated,
|
|
5950
|
-
|
|
6112
|
+
beforeFrom: fromBaseline !== void 0 ? "baseline" : fromHead !== void 0 ? "head" : "none"
|
|
5951
6113
|
});
|
|
5952
6114
|
added += diff.added;
|
|
5953
6115
|
deleted += diff.deleted;
|
|
@@ -5958,7 +6120,8 @@ var SessionChanges = class {
|
|
|
5958
6120
|
deleted: diff.deleted,
|
|
5959
6121
|
...binary ? { binary: true } : {},
|
|
5960
6122
|
...oversized ? { oversized: true } : {},
|
|
5961
|
-
...status === void 0 ? {} : { status }
|
|
6123
|
+
...status === void 0 ? {} : { status },
|
|
6124
|
+
...revert === void 0 ? {} : { revert }
|
|
5962
6125
|
});
|
|
5963
6126
|
}
|
|
5964
6127
|
files.sort((left, right) => left.display.localeCompare(right.display));
|
|
@@ -6077,7 +6240,7 @@ var SessionChanges = class {
|
|
|
6077
6240
|
ledger.untrackedAt = Date.now();
|
|
6078
6241
|
ledger.untrackedJob = (async () => {
|
|
6079
6242
|
const started = Date.now();
|
|
6080
|
-
const scan = await this.run(ledger.alias, untrackedCommand(root), this.untrackedBudget());
|
|
6243
|
+
const scan = await this.run(ledger.alias, untrackedCommand(root, this.excludedDirs()), this.untrackedBudget());
|
|
6081
6244
|
ledger.untrackedMs = Date.now() - started;
|
|
6082
6245
|
if (ledger.disposed) return;
|
|
6083
6246
|
if (ledger.root !== root) return;
|
|
@@ -6159,10 +6322,10 @@ var SessionChanges = class {
|
|
|
6159
6322
|
}
|
|
6160
6323
|
}
|
|
6161
6324
|
/** Read a batch of files, capped per file and in total. */
|
|
6162
|
-
async readPaths(ledger, paths, side) {
|
|
6325
|
+
async readPaths(ledger, paths, side, limits) {
|
|
6163
6326
|
if (paths.length === 0) return /* @__PURE__ */ new Map();
|
|
6164
|
-
const perFile = this.deps.maxFileBytes ?? 256 * 1024;
|
|
6165
|
-
const total = this.deps.maxTotalBytes ?? 8 * 1024 * 1024;
|
|
6327
|
+
const perFile = limits?.perFile ?? this.deps.maxFileBytes ?? 256 * 1024;
|
|
6328
|
+
const total = limits?.total ?? this.deps.maxTotalBytes ?? 8 * 1024 * 1024;
|
|
6166
6329
|
const command = side === "worktree" ? readWorktreeCommand(ledger.root, paths, perFile, total) : readHeadCommand(ledger.root, paths, perFile, total);
|
|
6167
6330
|
const result = await this.run(ledger.alias, command);
|
|
6168
6331
|
if (!result.ok) {
|
|
@@ -6225,6 +6388,15 @@ var SessionChanges = class {
|
|
|
6225
6388
|
untrackedBudget() {
|
|
6226
6389
|
return this.deps.untrackedBudgetMs ?? this.budget(this.deps.timeouts().gitMs, 1e4, 18e4);
|
|
6227
6390
|
}
|
|
6391
|
+
/**
|
|
6392
|
+
* The exclusions this ledger scans with, normalized once per call.
|
|
6393
|
+
*
|
|
6394
|
+
* `??` and not `||`: an explicit empty array is a caller saying "count
|
|
6395
|
+
* everything", which must stay distinguishable from "not configured".
|
|
6396
|
+
*/
|
|
6397
|
+
excludedDirs() {
|
|
6398
|
+
return excludeDirNames(this.deps.excludeDirs ?? UNTRACKED_EXCLUDED_DIRECTORIES);
|
|
6399
|
+
}
|
|
6228
6400
|
budget(configured, floor, ceiling) {
|
|
6229
6401
|
return Math.max(floor, Math.min(Number.isFinite(configured) && configured > 0 ? configured : 3e4, ceiling));
|
|
6230
6402
|
}
|
package/lib/p2-router-fs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as isWindowsAbsolute, x as aliasRoot } from "./worlds-DXdP4SMn.js";
|
|
2
2
|
import { FileSystem, FsError } from "@deepseek-ai/dsh-fs";
|
|
3
3
|
//#region src/p2/router-fs.ts
|
|
4
4
|
/**
|
|
@@ -245,14 +245,13 @@ var TransparentFileSystem = class extends FileSystem {
|
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
247
|
* alpha.3 added patch/delete/move to the FileSystem contract for the
|
|
248
|
-
* apply_patch tool.
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* pin `applyPatch: false`), so this only matters when it is enabled.
|
|
248
|
+
* apply_patch tool. As of 0.23.0 every provider this plugin mounts implements
|
|
249
|
+
* all three — fs-ssh 0.2.2 talks the protocol-3 helper, which serves
|
|
250
|
+
* `fs.patch`/`fs.delete`/`fs.move` — so the guards below are defensive: they
|
|
251
|
+
* turn a thinner provider into a typed FsError instead of a TypeError.
|
|
253
252
|
*/
|
|
254
253
|
unsupportedRemote(what) {
|
|
255
|
-
return new FsError(`${what} is not supported
|
|
254
|
+
return new FsError(`${what} is not supported by the remote fs provider mounted for this world; run it in a local workspace`, "FS_IO_ERROR");
|
|
256
255
|
}
|
|
257
256
|
async patchText(target, hunks, expected, signal, sandboxPolicy) {
|
|
258
257
|
const { fs, world } = await this.backendOf(target);
|
|
@@ -55,6 +55,12 @@ export interface SessionChangesDeps {
|
|
|
55
55
|
untrackedBudgetMs?: number;
|
|
56
56
|
/** How often the untracked scan may run again (default five seconds). */
|
|
57
57
|
untrackedRefreshMs?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Directory names the untracked scan leaves out (build output, dependency
|
|
60
|
+
* caches). Defaults to {@link UNTRACKED_EXCLUDED_DIRECTORIES}; an explicit
|
|
61
|
+
* empty array turns the exclusion off.
|
|
62
|
+
*/
|
|
63
|
+
excludeDirs?: readonly string[];
|
|
58
64
|
/**
|
|
59
65
|
* Override the per-exec budget outright.
|
|
60
66
|
*
|
|
@@ -84,6 +90,14 @@ export declare class SessionChanges {
|
|
|
84
90
|
* change the file between scans, and replaying a cached copy against a fresh
|
|
85
91
|
* buffer is exactly how the painted lines end up at the wrong places.
|
|
86
92
|
*
|
|
93
|
+
* This is the ONE read a user asks for by clicking a row, so it is allowed a
|
|
94
|
+
* larger per-file budget than a scan (`DIFF_MAX_FILE_BYTES`): a file the list
|
|
95
|
+
* had to withhold as "too large" can still be reviewed and reverted here,
|
|
96
|
+
* while a scan stays cheap. A withheld HEAD side is retaken at that budget
|
|
97
|
+
* (git has the bytes); a withheld BASELINE side is not — that snapshot
|
|
98
|
+
* described the session's own starting point and cannot be reconstructed, so
|
|
99
|
+
* the file stays display-only rather than guessing a wrong reverse.
|
|
100
|
+
*
|
|
87
101
|
* @param sessionId - live session owning the ledger.
|
|
88
102
|
* @param path - the file's remote absolute path (as listed in the summary).
|
|
89
103
|
* @returns hunks for decorations, or null when the session/file is unknown.
|
|
@@ -267,6 +281,13 @@ export declare class SessionChanges {
|
|
|
267
281
|
* command are visible ONLY through this scan.
|
|
268
282
|
*/
|
|
269
283
|
private untrackedBudget;
|
|
284
|
+
/**
|
|
285
|
+
* The exclusions this ledger scans with, normalized once per call.
|
|
286
|
+
*
|
|
287
|
+
* `??` and not `||`: an explicit empty array is a caller saying "count
|
|
288
|
+
* everything", which must stay distinguishable from "not configured".
|
|
289
|
+
*/
|
|
290
|
+
private excludedDirs;
|
|
270
291
|
private budget;
|
|
271
292
|
private warn;
|
|
272
293
|
}
|
|
@@ -109,13 +109,53 @@ export declare const READ_EXIT: {
|
|
|
109
109
|
* @returns a `sh` script printing NUL-separated porcelain v1 records.
|
|
110
110
|
*/
|
|
111
111
|
export declare function trackedStatusCommand(root: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Directory names the ledger does not count as session changes.
|
|
114
|
+
*
|
|
115
|
+
* Build output and dependency caches are the two things a build leaves behind,
|
|
116
|
+
* and neither is this session's work. `--exclude-standard` only covers what the
|
|
117
|
+
* repository's own ignore rules name, so a checkout whose build directory is NOT
|
|
118
|
+
* ignored pays twice: thousands of paths fill the 500-row list (sorted, and
|
|
119
|
+
* `build/`/`out/` sort BEFORE `src/`, so the real changes get truncated away) and
|
|
120
|
+
* every listed path costs a read out of the 8 MiB transfer budget.
|
|
121
|
+
*
|
|
122
|
+
* The names mirror the three lists the plugin already prunes by elsewhere
|
|
123
|
+
* (`client/quickopen-model.ts` `EXCLUDED_DIRECTORIES`, `p2/file-refs.ts`
|
|
124
|
+
* `REMOTE_FILE_SEARCH_EXCLUDED_DIRECTORIES`, `search-ops.ts` `PRUNE_DIRS`). One
|
|
125
|
+
* vocabulary, four consumers: fold them into a shared module when one of those
|
|
126
|
+
* surfaces is next touched, instead of adding a fifth spelling here.
|
|
127
|
+
*/
|
|
128
|
+
export declare const UNTRACKED_EXCLUDED_DIRECTORIES: readonly string[];
|
|
129
|
+
/**
|
|
130
|
+
* Keep only directory names a pathspec may name safely.
|
|
131
|
+
*
|
|
132
|
+
* A value that is absolute, carries a separator, walks up or looks like a flag
|
|
133
|
+
* is DROPPED rather than rejected: the list is configuration, and one bad entry
|
|
134
|
+
* must not stop the scan — the scan's job is to say what changed, not to police
|
|
135
|
+
* a setting. Dropping is also the conservative direction: a name that is not
|
|
136
|
+
* excluded is merely visible, while a malformed pathspec would hide paths the
|
|
137
|
+
* user never asked to hide (or turn `--exclude` into another flag).
|
|
138
|
+
*
|
|
139
|
+
* @param dirs - candidate names (undefined = none).
|
|
140
|
+
* @returns the usable names, deduplicated, in the given order.
|
|
141
|
+
*/
|
|
142
|
+
export declare function excludeDirNames(dirs: readonly string[] | undefined): string[];
|
|
112
143
|
/**
|
|
113
144
|
* New files git is not tracking yet (the ones a session usually creates).
|
|
114
145
|
*
|
|
146
|
+
* The exclusions are pushed down as pathspecs (`:(exclude)out`) rather than
|
|
147
|
+
* filtered after the fact, so those paths never cross the wire and never enter
|
|
148
|
+
* the 500-row cap. Measured on a tree with 3000 build outputs + 300 sources:
|
|
149
|
+
* 3300 records / 61.5 KB unfiltered versus 300 records / 6.8 KB with two
|
|
150
|
+
* exclusions — the walk itself costs the same either way (git still descends
|
|
151
|
+
* those directories), so the win is wire bytes, parse time and the read budget,
|
|
152
|
+
* not scan latency.
|
|
153
|
+
*
|
|
115
154
|
* @param root - remote absolute POSIX directory (the session cwd).
|
|
155
|
+
* @param excludeDirs - directory names to leave out (see {@link excludeDirNames}).
|
|
116
156
|
* @returns a `sh` script printing NUL-separated paths.
|
|
117
157
|
*/
|
|
118
|
-
export declare function untrackedCommand(root: string): string;
|
|
158
|
+
export declare function untrackedCommand(root: string, excludeDirs?: readonly string[]): string;
|
|
119
159
|
/**
|
|
120
160
|
* Parse `git status --porcelain -z -uno` output.
|
|
121
161
|
*
|
|
@@ -63,3 +63,21 @@ export declare function diffText(before: string, after: string, context?: number
|
|
|
63
63
|
* @param hunk - one hunk of {@link diffText}.
|
|
64
64
|
*/
|
|
65
65
|
export declare function hunkPatch(displayPath: string, hunk: TextHunk): string;
|
|
66
|
+
/**
|
|
67
|
+
* Serialize a WHOLE file comparison as ONE patch (one header, every hunk).
|
|
68
|
+
*
|
|
69
|
+
* "Revert everything this session did to this file" is `git apply -R` of the
|
|
70
|
+
* file's complete diff, and that is a single write instead of one write per
|
|
71
|
+
* hunk. Concatenating `hunkPatch` output would also apply (git tolerates the
|
|
72
|
+
* repeated headers and re-anchors each block by offset), but it says the same
|
|
73
|
+
* file begins twice and depends on offset guessing — a real unified diff names
|
|
74
|
+
* the file once and lets git place every hunk against one picture.
|
|
75
|
+
*
|
|
76
|
+
* Verified against git 2.x: the result reverse-applies to a file whose content
|
|
77
|
+
* is `hunks`' new side, and leaves it byte-identical to the old side.
|
|
78
|
+
*
|
|
79
|
+
* @param displayPath - repo-relative path, as the panel shows it.
|
|
80
|
+
* @param hunks - every hunk of the comparison, in ascending order.
|
|
81
|
+
* @returns the patch, or '' when there is nothing to write (no hunks).
|
|
82
|
+
*/
|
|
83
|
+
export declare function filePatch(displayPath: string, hunks: readonly TextHunk[]): string;
|
|
@@ -12,8 +12,15 @@
|
|
|
12
12
|
* written with `node:fs`), which the probe measured as 58 remote sessions with
|
|
13
13
|
* zero change events.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Three things happen here, and they are deliberately different in kind:
|
|
16
|
+
* - a row's LEFT click opens the file and hands the editor the same hunks, so the
|
|
17
|
+
* changed lines are painted in place;
|
|
18
|
+
* - a row's RIGHT click offers the writes ("revert everything this session did to
|
|
19
|
+
* this file", "undo a tracked creation") plus the navigation shortcuts. The
|
|
20
|
+
* host decides which of those exist (`RemoteChangedFile.revert`), because only
|
|
21
|
+
* git knows whether a creation has a copy to fall back on;
|
|
22
|
+
* - the ✓ on a row is a LOCAL review note (`review-state.ts`): it writes nothing,
|
|
23
|
+
* it is what makes a thirty-file refactor converge.
|
|
17
24
|
*/
|
|
18
25
|
import './changes.css';
|
|
19
26
|
/**
|
|
@@ -31,6 +31,8 @@ export declare const EMPTY_CHANGE_SET: ChangeSet;
|
|
|
31
31
|
*
|
|
32
32
|
* @param hunks - served hunks for the whole session.
|
|
33
33
|
* @param stamp - identity of the comparison (file + baseline + turn).
|
|
34
|
+
* @param filePatch - the host's whole-file reverse patch, when it served one
|
|
35
|
+
* (see `ChangeSet.filePatch`); '' / missing = nothing to revert as a whole.
|
|
34
36
|
* @returns the mark set the editor paints, or {@link EMPTY_CHANGE_SET}.
|
|
35
37
|
*/
|
|
36
|
-
export declare function changeSetFromHunks(hunks: readonly UnifiedHunk[], stamp: string): ChangeSet;
|
|
38
|
+
export declare function changeSetFromHunks(hunks: readonly UnifiedHunk[], stamp: string, filePatch?: string): ChangeSet;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「这个文件我看过了」的本地标记。
|
|
3
|
+
*
|
|
4
|
+
* 会话改动面板原本只能看、不能收敛:一次三十个文件的重构,没有任何地方记得"这个我
|
|
5
|
+
* 已经审过",列表和游标每次都从头上开始。这里补的是**纯客户端**的审阅状态 —— 它不
|
|
6
|
+
* 写远端、不进账本、不影响任何一次 `git` 调用,因此是这条路线上唯一零风险的收敛手段
|
|
7
|
+
* ("接受改动"的另一半语义是真正的 `git apply --cached`,那要求基线等于索引,属于另一
|
|
8
|
+
* 个决定,**不在本模块**里)。
|
|
9
|
+
*
|
|
10
|
+
* ## 为什么键里带计数
|
|
11
|
+
*
|
|
12
|
+
* 键 = 路径 + 增删行数 + 状态。会话又改了同一批行(行数随之变化)时,旧标记自然失效,
|
|
13
|
+
* 文件重新变成"未审阅"——这正是想要的效果,而且不需要监听任何事件。行数完全没变的
|
|
14
|
+
* 二次编辑仍会被当成"已审阅",这是这套方案的已知盲点:它与"审阅的是哪一版"这个事实
|
|
15
|
+
* 相比,代价远小于为每个文件拉一次 diff 去算指纹。
|
|
16
|
+
*
|
|
17
|
+
* 纯函数 + 一个带上限的表,`scripts/check-review-state.mjs` 直接驱动真实的判定。
|
|
18
|
+
*/
|
|
19
|
+
/** 面板能给的一行(`RemoteChangedFile` 的投影)。 */
|
|
20
|
+
export interface ReviewSubject {
|
|
21
|
+
/** 远端绝对路径(唯一标识)。 */
|
|
22
|
+
path: string;
|
|
23
|
+
added: number;
|
|
24
|
+
deleted: number;
|
|
25
|
+
status?: string;
|
|
26
|
+
}
|
|
27
|
+
/** 已审阅集合:键 → 1(用对象是为了能直接 JSON 往返)。 */
|
|
28
|
+
export type ReviewedMap = Readonly<Record<string, 1>>;
|
|
29
|
+
/** 一个会话最多记住这么多条(长命页面不能无限长)。 */
|
|
30
|
+
export declare const REVIEW_CAP = 1000;
|
|
31
|
+
/**
|
|
32
|
+
* 一行的审阅键。
|
|
33
|
+
*
|
|
34
|
+
* 计数进键里是刻意的:见文件头。`status` 也进键,因为"删掉了又加回来"和"一直在改"
|
|
35
|
+
* 是两件不同的事,标签变了就该重新看一遍。
|
|
36
|
+
*
|
|
37
|
+
* @param file - 面板的一行。
|
|
38
|
+
* @returns 稳定的键(路径里可能有任意字符,用 NUL 分隔不会与计数撞)。
|
|
39
|
+
*/
|
|
40
|
+
export declare function reviewKeyOf(file: ReviewSubject): string;
|
|
41
|
+
/** 这一行是否已被标为审阅。 */
|
|
42
|
+
export declare function isReviewed(file: ReviewSubject, reviewed: ReviewedMap): boolean;
|
|
43
|
+
/** 已审阅的行数(只数当前列表里的,所以它永远 ≤ 列表长度)。 */
|
|
44
|
+
export declare function reviewedCount(files: readonly ReviewSubject[], reviewed: ReviewedMap): number;
|
|
45
|
+
/** 切换一行的标记,返回新表(输入不被修改)。 */
|
|
46
|
+
export declare function toggleReviewed(files: readonly ReviewSubject[], reviewed: ReviewedMap, file: ReviewSubject): Record<string, 1>;
|
|
47
|
+
/** 全标或全清。 */
|
|
48
|
+
export declare function setAllReviewed(files: readonly ReviewSubject[], on: boolean): Record<string, 1>;
|
|
49
|
+
/**
|
|
50
|
+
* 丢掉不属于当前列表的键。
|
|
51
|
+
*
|
|
52
|
+
* 列表每 3 秒重建一次,一条被删掉(或计数变了)的键如果留着,下次同一路径回到列表
|
|
53
|
+
* 时会被当成"已审阅"——那是凭空出现的勾。清理放在每次写入与每次加载后都做,代价是
|
|
54
|
+
* O(列表长度)。
|
|
55
|
+
*/
|
|
56
|
+
export declare function pruneReviewed(files: readonly ReviewSubject[], reviewed: ReviewedMap): Record<string, 1>;
|
|
57
|
+
/**
|
|
58
|
+
* 解析持久化的一串 JSON。
|
|
59
|
+
*
|
|
60
|
+
* 任何畸形输入都给空表而不是抛错:这份状态是"看过没看过",读不出来最多重看一遍,
|
|
61
|
+
* 不值得让面板崩掉。键必须是字符串、值必须是 1,且受 {@link REVIEW_CAP} 限制。
|
|
62
|
+
*
|
|
63
|
+
* @param raw - `localStorage` 里存着的那串文本(可能为 null)。
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseReviewed(raw: string | null | undefined): Record<string, 1>;
|
|
66
|
+
/** 序列化(键数量已受上限约束,所以这串不会无限长)。 */
|
|
67
|
+
export declare function serializeReviewed(reviewed: ReviewedMap): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client side of the Host's one-shot notices (`src/notices.ts`).
|
|
3
|
+
*
|
|
4
|
+
* The Host attaches notices to a JSON response when an automatic helper push ran
|
|
5
|
+
* during that request; the API wrapper calls {@link dispatchHostNotices} after
|
|
6
|
+
* parsing, and the message goes through the plugin's toast layer (bottom-right,
|
|
7
|
+
* auto-dismiss) so the event is visible wherever the user is — including the
|
|
8
|
+
* conversation view, where no remote-workspace surface is mounted.
|
|
9
|
+
*
|
|
10
|
+
* The emitter is REGISTERED by the client entry instead of imported here: this
|
|
11
|
+
* module sits on the API path, which several offline gates load with a
|
|
12
|
+
* TypeScript-only loader. Importing the JSX widget kit from `api.ts` would drag
|
|
13
|
+
* React components into those loaders (they cannot transpile JSX) for a message
|
|
14
|
+
* that only needs a string.
|
|
15
|
+
*/
|
|
16
|
+
import type { HostNotice } from '../notices.ts';
|
|
17
|
+
/** How the toast layer receives one rendered message. */
|
|
18
|
+
export type HostNoticeEmitter = (text: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Install (or remove) the toast emitter; the client entry owns the lifetime.
|
|
21
|
+
*
|
|
22
|
+
* Messages that arrived before the entry registered are flushed, so a notice
|
|
23
|
+
* produced during the first remote operation of a page load cannot be lost.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setHostNoticeEmitter(next: HostNoticeEmitter | undefined): void;
|
|
26
|
+
/** Render one notice in the page language. */
|
|
27
|
+
export declare function formatHostNotice(notice: HostNotice, lang?: import("./i18n.ts").Lang): string;
|
|
28
|
+
/**
|
|
29
|
+
* Show every valid notice carried by one API response.
|
|
30
|
+
*
|
|
31
|
+
* `emit` is injectable so a gate can drive this without React or a DOM. A
|
|
32
|
+
* malformed payload is ignored: a newer/older peer must never turn a successful
|
|
33
|
+
* remote operation into a client exception.
|
|
34
|
+
*/
|
|
35
|
+
export declare function dispatchHostNotices(payload: unknown, emit?: HostNoticeEmitter): number;
|