@marktrue/dsh-mobile-remote 3.2.4-alpha.2 → 3.2.4-alpha.20
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 +527 -0
- package/README.md +2 -0
- package/docs/03-api.md +328 -26
- package/docs/04-security.md +14 -0
- package/docs/09-compatibility.md +25 -4
- package/docs/10-release.md +33 -60
- package/docs/11-notification-reliability.md +45 -0
- package/docs/12-implementation-status.md +41 -0
- package/docs/13-device-acceptance-2026-11-03.md +37 -0
- package/docs/16-next-window-handoff-2026-11-04.md +44 -0
- package/docs/17-remaining-work-review-2026-11-04.md +53 -0
- package/docs/18-device-reliability-acceptance-2026-11-04.md +63 -0
- package/docs/19-issue-followup-2026-11-04.md +39 -0
- package/docs/20-dsh-022-compatibility-2026-11-05.md +32 -0
- package/lib/client.js +23 -1
- package/lib/endpoint-registry.js +32 -12
- package/lib/git-read-bundled-provider.js +27 -13
- package/lib/git-read-service.js +309 -38
- package/lib/host-manager-update.js +178 -0
- package/lib/host-update-capabilities.js +209 -0
- package/lib/index.js +3019 -145
- package/lib/npm-update-source.js +16 -16
- package/lib/plugin-self-update.js +127 -12
- package/lib/plugin-update-check.js +268 -0
- package/lib/plugin-update-controller.js +129 -7
- package/lib/plugin-update-transaction.js +38 -2
- package/lib/update-lock-arbiter.js +46 -6
- package/lib/update-supervisor.js +38 -5
- package/package.json +9 -6
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# DSH v0.2.2-rc.1 compatibility review
|
|
2
|
+
|
|
3
|
+
## Upstream version
|
|
4
|
+
|
|
5
|
+
Reviewed on 2026-11-05/06 against the latest DSH GitHub release, [`dsh-v0.2.2-rc.1`](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.2-rc.1), published 2026-11-04. Upstream `master` is `fcc0ad462172522aaf5c93a7b2e01f6b9f0b0159`, the release merge commit dated 2026-11-04; no later published DSH release was present during this review. Public npm tags differ from the GitHub release: `@deepseek-ai/dsh` has `next=0.2.2-rc.1`, `alpha=0.2.2-alpha.3`, and `latest=0.2.1-rc.5`.
|
|
6
|
+
|
|
7
|
+
The current unpublished `develop` plugin is `3.2.4-alpha.3` plus the commits through the compatibility review. Node 24.15.0 is available locally. DSH v0.2.2-rc.1 declares Node `>=24.9.0`; hosts running older Node must upgrade the runtime before moving to that DSH version. The plugin itself does not raise its engine floor, preserving older supported hosts.
|
|
8
|
+
|
|
9
|
+
## Compatibility findings
|
|
10
|
+
|
|
11
|
+
Four directly imported DSH peer packages (`dsh-credentials`, `dsh-llm`, `dsh-sandbox-policy`, `dsh-scope`) have a peer range `>=0.1.0-rc.6 <0.3.0`. Although the upper bound includes `0.2.2-rc.1` as a version comparison, npm's default prerelease semantics exclude it because the range did not mention the `0.2.2` prerelease base. The same issue excluded `0.2.1-rc.5` and `0.2.2-alpha.3`. Updated all four ranges with explicit prerelease branches for the released `0.2.0`, `0.2.1` and `0.2.2` series, while retaining the stable `0.1.x` / `0.2.x` range and refusing `<0.1.0-rc.6` and `0.3.0`.
|
|
12
|
+
|
|
13
|
+
An actual `npm install --dry-run --ignore-scripts --package-lock=false --legacy-peer-deps=false` against the local plugin folder and the exact four DSH `0.2.2-rc.1` peer packages plus `schemastery@3.19.0` resolved all 20 packages successfully. This did not install into the project profile or publish packages.
|
|
14
|
+
|
|
15
|
+
Verified the published `0.2.2-rc.1` package source for APIs used by this plugin:
|
|
16
|
+
|
|
17
|
+
- `dsh-session-query.readSession()` still calls `Session.create(...)`; `Session.fromRestore(...)` exists but is not used there. The `session/end-seed` marker validation also remains. This is the known legacy seeded-history limitation in issue #20; it is not represented as fixed.
|
|
18
|
+
- `dsh-session-query.readSurface()`, `listEvents(sessionId)`, and `readEvent({sessionId, seq, ...})` remain available for the existing explicit degraded history and configuration recovery paths.
|
|
19
|
+
- Agent `create(options)` / `resume(options)` and workspace registry `resolveByPath(path)` / `create(path, title)` remain available with their existing call shapes.
|
|
20
|
+
- Remote gateway methods retain `dispatchRpc(endpoint, payload, signal, peer)` and `openWireStream(endpoint, payload, uplink, peer, signal, control, uplinkWindow)`. The plugin's 0.2.1+ Peer adapter uses the same required argument positions.
|
|
21
|
+
- Cordis 4.1.0 retains `ctx.get`, `ctx.provide`, `ctx.on`, `ctx.effect`, and waterfall dispatch used by the plugin. DSH's Schemastery `~3.19.0` satisfies the plugin's `>=3.18.1` range.
|
|
22
|
+
- DSH v0.2.2-rc.1 publishes its packages with prerelease versions. npm's default semver rules do not treat `>=0.1.0-rc.6 <0.3.0` as admitting later 0.2.x prereleases. That previously made the four peer dependencies above fail npm resolution even though the version numbers looked in-range. Added explicit prerelease branches for 0.2.0, 0.2.1, and 0.2.2; the manifest/lock compatibility test pins supported versions and the lower/next-major boundaries.
|
|
23
|
+
- PR #70 only changes notification channel importance and notification-settings access. It does not change APIs consumed by the plugin. Its `MainActivity` additions occupy separate channel/lifecycle regions from the new download bridge. It was retargeted to `develop` and merged after integration checks; a follow-up regression covers the notification-permission recovery path.
|
|
24
|
+
|
|
25
|
+
No additional host API adapter change is indicated by the inspected upstream source. This is package/API-source compatibility review, not a complete boot of the DSH 0.2.2-rc.1 desktop runtime; the latest runtime includes substantial platform and package-bundle changes beyond the mobile plugin.
|
|
26
|
+
|
|
27
|
+
## Validation
|
|
28
|
+
|
|
29
|
+
- Added `test/host-compat-022.test.mjs`: checks both `package.json` and `package-lock.json` declare ranges that accept `0.1.0-rc.6`, `0.2.1-rc.5`, `0.2.2-alpha.3`, `0.2.2-rc.1` and stable `0.2.2`, while rejecting pre-lower-bound and `0.3.0` versions.
|
|
30
|
+
- Targeted compatibility matrix: 47/47 passed. Full Node suite: 282/282; Python: 8/8; `npm run check` passed; Flutter 3.47.0 `flutter analyze` reports no issues. These verify package resolution, metadata and the adapter seams covered by tests; they do not substitute for a complete desktop runtime boot on the new DSH release.
|
|
31
|
+
|
|
32
|
+
No release tag, GitHub Release, npm publication, desktop Harness action, phone install, or issue #20 modification was performed for this review.
|
package/lib/client.js
CHANGED
|
@@ -340,12 +340,27 @@ window.__ModuleLoader__.load({
|
|
|
340
340
|
var state = String(value.state || "unknown");
|
|
341
341
|
var transaction = value.transaction && typeof value.transaction === "object" ? value.transaction : null;
|
|
342
342
|
var appVersion = String(carrier.appVersion || transaction?.targetAppVersion || "");
|
|
343
|
+
var hostManager = value.hostManager && typeof value.hostManager === "object" ? value.hostManager : null;
|
|
344
|
+
var updateChannel = String(value.updateChannel || "");
|
|
343
345
|
return {
|
|
344
346
|
state: state,
|
|
345
347
|
reason: String(value.reason || ""),
|
|
346
348
|
candidate: candidate,
|
|
347
349
|
hasUpdate: state === "update-available" && Boolean(plugin.version),
|
|
348
350
|
canSelfUpdate: value.canSelfUpdate === true,
|
|
351
|
+
// 通道(v3.5):host-manager = 进程内更新不重启;restart = 装完要重启宿主。
|
|
352
|
+
updateChannel: updateChannel,
|
|
353
|
+
updateChannelDescription: String(value.updateChannelDescription || ""),
|
|
354
|
+
canRestartHost: value.canRestartHost === true,
|
|
355
|
+
// 是否由宿主管理器在进程内完成(界面据此选择"不中断"措辞)。
|
|
356
|
+
usesHostManager: updateChannel === "host-manager",
|
|
357
|
+
hostManagerHmrAvailable: hostManager ? hostManager.hmrAvailable === true : null,
|
|
358
|
+
// 本次更新是否会让连接短暂断开(决定要不要提前预告)。
|
|
359
|
+
updateRestartsHost: updateChannel === "host-manager"
|
|
360
|
+
? (hostManager ? hostManager.hmrAvailable === false : false)
|
|
361
|
+
: updateChannel === "restart"
|
|
362
|
+
? true
|
|
363
|
+
: (updateChannel === "" && value.canSelfUpdate === true),
|
|
349
364
|
pluginVersion: String(plugin.version || transaction?.targetVersion || ""),
|
|
350
365
|
appVersion: appVersion,
|
|
351
366
|
needsPreparation: state === "update-available" && !appVersion,
|
|
@@ -817,11 +832,18 @@ window.__ModuleLoader__.load({
|
|
|
817
832
|
jsxRuntime.jsx("div", { style: { fontSize: "12.5px", color: "var(--dsw-alias-label-secondary, #888)" }, children: statusText }),
|
|
818
833
|
progressBox,
|
|
819
834
|
model.hasUpdate ? jsxRuntime.jsx("div", { style: { fontSize: "12.5px", lineHeight: "1.6" }, children: "插件 v" + pluginVersion + (appVersion ? " · App build " + appVersion : " · App build 将在准备后核验") }) : null,
|
|
835
|
+
// v3.5:把实际更新通道讲清楚——「不重启」与「会重启」对用户是完全不同的体验,
|
|
836
|
+
// 不能只在出错时才让用户猜。
|
|
837
|
+
model.hasUpdate && model.updateChannelDescription
|
|
838
|
+
? jsxRuntime.jsx("div", { style: { fontSize: "12px", lineHeight: "1.6", color: "var(--dsw-alias-label-secondary, #888)" },
|
|
839
|
+
children: model.updateChannelDescription + (model.updateRestartsHost ? ";期间连接会短暂断开,重连后自动接续。" : ";连接不会中断。") })
|
|
840
|
+
: null,
|
|
820
841
|
operationTarget,
|
|
821
842
|
model.hasUpdate && !model.canSelfUpdate ? jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary, #888)" }, children: model.guidance?.summary || "当前安装形态需要按电脑端指引更新。" }) : null,
|
|
822
843
|
workflow.status === "preparing" ? jsxRuntime.jsx("div", { style: { fontSize: "12px" }, children: "正在从主机 NPM 源准备并校验 carrier;profile 尚未修改…" }) : null,
|
|
844
|
+
workflow.status === "submitting" && model.usesHostManager ? jsxRuntime.jsx("div", { style: { fontSize: "12px" }, children: "正在交给宿主插件管理器处理…" }) : null,
|
|
823
845
|
workflow.status === "submitting" ? jsxRuntime.jsx("div", { style: { fontSize: "12px" }, children: "正在提交安装事务…" }) : null,
|
|
824
|
-
workflow.status === "running" ? jsxRuntime.jsx("div", { style: { fontSize: "12px" }, children: "
|
|
846
|
+
workflow.status === "running" ? jsxRuntime.jsx("div", { style: { fontSize: "12px" }, children: model.updateRestartsHost ? "安装/重启进行中;输出会保留并可在重连后继续查看。" : "宿主插件管理器正在进程内更新;连接不会中断,输出会保留。" }) : null,
|
|
825
847
|
workflow.message ? jsxRuntime.jsx("div", { style: { fontSize: "12px", color: workflow.status === "failed" ? "var(--dsw-alias-text-danger, #e5484d)" : "inherit" }, children: workflow.message }) : null,
|
|
826
848
|
detailsPanel,
|
|
827
849
|
actionButton,
|
package/lib/endpoint-registry.js
CHANGED
|
@@ -33,8 +33,22 @@ export function extractEndpointDetails(source) {
|
|
|
33
33
|
if (out.has(path)) continue;
|
|
34
34
|
const next = markLines.find((l) => l > index);
|
|
35
35
|
const segment = lines.slice(index, next ?? Math.min(lines.length, index + 400)).join("\n");
|
|
36
|
+
// 路由**头部**(分派行 + 紧随其后的 2 行)才代表该端点的方法契约;块内更深处的
|
|
37
|
+
// GET/HEAD 分支(如 /goal 内部图片/下载分支)不能把整个端点判成 GET/HEAD。
|
|
38
|
+
const header = lines.slice(index, Math.min(lines.length, index + 3)).join("\n");
|
|
36
39
|
let methods = "GET/POST";
|
|
37
|
-
|
|
40
|
+
// issue #60 recheck-2(R02):头部显式 `(method === "GET" || method === "HEAD")`
|
|
41
|
+
// 必须抽成 GET/HEAD——HEAD 是真实分派语义,不能被默认成 GET/POST。
|
|
42
|
+
const allowsHead = /method\s*===\s*['"]GET['"]\s*\|\|\s*method\s*===\s*['"]HEAD['"]/.test(header)
|
|
43
|
+
// 只读端点也可写成「GET/HEAD 之外 405」;排除紧跟 POST 的三方法形态。
|
|
44
|
+
|| /method\s*!==\s*['"]GET['"]\s*&&\s*method\s*!==\s*['"]HEAD['"](?!\s*&&\s*method\s*!==\s*['"]POST['"])/.test(header);
|
|
45
|
+
const allowsPost = /method\s*===\s*['"]POST['"]/.test(segment) || /requirePost\(method,\s*res\)/.test(segment);
|
|
46
|
+
// re-review P1-1:图端点用「GET/HEAD/POST 之外的都 405」显式三分派;
|
|
47
|
+
// 只认这一种精确形态,避免把 GET/HEAD + 块内 POST(真实 GET/POST)误判成三方法。
|
|
48
|
+
const explicitHeadPost = /method\s*!==\s*['"]GET['"]\s*&&\s*method\s*!==\s*['"]HEAD['"]\s*&&\s*method\s*!==\s*['"]POST['"]/.test(header);
|
|
49
|
+
if (explicitHeadPost) methods = "GET/HEAD/POST";
|
|
50
|
+
else if (allowsHead && !allowsPost) methods = "GET/HEAD";
|
|
51
|
+
else if (/requireGet\(method,\s*res\)/.test(segment) || /method\s*!==\s*['"]GET['"]/.test(segment)) methods = "GET";
|
|
38
52
|
else if (/method\s*!==\s*['"]POST['"]/.test(segment)) methods = "POST";
|
|
39
53
|
out.set(path, methods);
|
|
40
54
|
}
|
|
@@ -109,7 +123,10 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
|
|
|
109
123
|
{ path: "/balance", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
110
124
|
{ path: "/bootstrap", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
111
125
|
{ path: "/catalog", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
126
|
+
{ path: "/changes/diff", methods: "GET", capability: "turnTail" },
|
|
127
|
+
{ path: "/changes/summary", methods: "GET", capability: "turnTail" },
|
|
112
128
|
{ path: "/commands", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
129
|
+
{ path: "/skills", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
113
130
|
{ path: "/defaults", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
114
131
|
{ path: "/dev/approval-test", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
115
132
|
{ path: "/diagnostics", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
@@ -117,17 +134,19 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
|
|
|
117
134
|
{ path: "/event-detail", methods: "GET", capability: "eventTimeline" },
|
|
118
135
|
{ path: "/events", methods: "GET", capability: "eventTimeline" },
|
|
119
136
|
{ path: "/feedback", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
120
|
-
{ path: "/files", methods: "GET/
|
|
137
|
+
{ path: "/files", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
121
138
|
{ path: "/files/upload", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
122
|
-
{ path: "/
|
|
123
|
-
{ path: "/
|
|
124
|
-
{ path: "/git/
|
|
125
|
-
{ path: "/git/
|
|
126
|
-
{ path: "/git/
|
|
127
|
-
{ path: "/git/
|
|
128
|
-
{ path: "/git/
|
|
129
|
-
{ path: "/git/
|
|
130
|
-
{ path: "/git/
|
|
139
|
+
{ path: "/workspace-image", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
140
|
+
{ path: "/workspace-image/consent", methods: "POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
141
|
+
{ path: "/git/branches", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
142
|
+
{ path: "/git/capabilities", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
143
|
+
{ path: "/git/commit", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
144
|
+
{ path: "/git/file-history", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
145
|
+
{ path: "/git/files", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
146
|
+
{ path: "/git/graph", methods: "GET/HEAD/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
147
|
+
{ path: "/git/preview", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
148
|
+
{ path: "/git/repository", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
149
|
+
{ path: "/git/worktree", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
131
150
|
{ path: "/goal", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
132
151
|
{ path: "/history", methods: "GET", capability: "eventTimeline" },
|
|
133
152
|
{ path: "/jobs", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
@@ -138,7 +157,7 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
|
|
|
138
157
|
{ path: "/notifications", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
139
158
|
{ path: "/notifications/delete", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
140
159
|
{ path: "/notifications/read", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
141
|
-
{ path: "/plugin-update/check", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
|
|
160
|
+
{ path: "/plugin-update/check", methods: "GET/POST", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
|
|
142
161
|
{ path: "/plugin-update/prepare", methods: "POST", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
|
|
143
162
|
{ path: "/plugin-update/log", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
|
|
144
163
|
{ path: "/plugin-update", methods: "POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
@@ -158,6 +177,7 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
|
|
|
158
177
|
{ path: "/subagents", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
159
178
|
{ path: "/subagents/interrupt", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
160
179
|
{ path: "/todos", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
|
|
180
|
+
{ path: "/turn-file", methods: "GET/HEAD", capability: "turnTail" },
|
|
161
181
|
{ path: "/turn-outline", methods: "GET", capability: "turnOutline" },
|
|
162
182
|
{ path: "/update/apk", methods: "GET", capability: null, auth: "anonymous", why: NO_CAPABILITY_NEEDED },
|
|
163
183
|
{ path: "/update/manifest", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
|
|
@@ -209,9 +209,11 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
209
209
|
async resolveTip(root, ref) {
|
|
210
210
|
return (await run(root, ["rev-parse", "--verify", `${ref}^{commit}`])).trim();
|
|
211
211
|
},
|
|
212
|
-
async graph(root, { refs, offset, limit }) {
|
|
212
|
+
async graph(root, { refs, offset, limit, timeoutMs = 0 }) {
|
|
213
213
|
if (refs.length === 0) return [];
|
|
214
|
-
const
|
|
214
|
+
const graphResult = await spawnGit(root, ["log", "--topo-order", "--date-order", `--skip=${offset}`, `--max-count=${limit}`, "--decorate=full", "--format=%H%x1f%P%x1f%an%x1f%at%x1f%s%x1f%D%x00", ...refs], { timeoutMs });
|
|
215
|
+
if (graphResult.timedOut) throw gitError("graph-timeout", 504);
|
|
216
|
+
const text = graphResult.stdout;
|
|
215
217
|
return text.split("\0").map((record) => record.replace(/^[\r\n]+|[\r\n]+$/g, "")).filter(Boolean).map((record) => {
|
|
216
218
|
const [oid, parents, author, timestamp, subject, decorations] = record.split("\x1f");
|
|
217
219
|
return { oid, parents: parents ? parents.split(" ") : [], author, timestamp: Number(timestamp) || 0, subject, refs: decorations ? decorations.split(",").map((value) => value.trim()).filter(Boolean) : [] };
|
|
@@ -261,22 +263,25 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
261
263
|
* annotated-tag metadata. Non-commit and nested tag targets carry a hint
|
|
262
264
|
* instead of failing the whole read.
|
|
263
265
|
*/
|
|
264
|
-
async refs(root) {
|
|
266
|
+
async refs(root, { timeoutMs = 0 } = {}) {
|
|
265
267
|
const records = [];
|
|
266
268
|
// NUL/US-delimited fields keep tagger names and tag subjects that contain
|
|
267
269
|
// tabs intact; a tab-delimited line format would corrupt such records.
|
|
268
|
-
const
|
|
270
|
+
const refsResult = await spawnGit(root, ["for-each-ref", "--format=%(refname)%1f%(objectname)%1f%(objecttype)%1f%(HEAD)%1f%(taggername)%1f%(taggerdate:unix)%1f%(subject)%1f%(*objectname)%1f%(*objecttype)%1f%(type)%00", "refs/heads", "refs/remotes", "refs/tags"], { timeoutMs });
|
|
271
|
+
if (refsResult.timedOut) throw gitError("graph-timeout", 504);
|
|
272
|
+
const text = refsResult.stdout;
|
|
269
273
|
for (const raw of text.split("\0")) {
|
|
270
274
|
const record = raw.replace(/^[\r\n]+|[\r\n]+$/g, "");
|
|
271
275
|
if (!record) continue;
|
|
272
276
|
const fields = record.split("\x1f");
|
|
273
|
-
if (fields.length <
|
|
277
|
+
if (fields.length < 10) continue;
|
|
274
278
|
// Peeled fields are fixed at the tail so a subject containing the
|
|
275
279
|
// unit separator cannot swallow them.
|
|
276
280
|
const [name, oid, objectType, headFlag, taggerName, taggerDate] = fields;
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const
|
|
281
|
+
const targetType = fields.at(-1); // %(type) is the direct tag target, including on Git 2.52+.
|
|
282
|
+
const peeledType = fields.at(-2);
|
|
283
|
+
const peeledOid = fields.at(-3);
|
|
284
|
+
const subject = fields.slice(6, -3).join("\x1f");
|
|
280
285
|
if (!name || !oid) continue;
|
|
281
286
|
if (name.startsWith("refs/remotes/") && name.endsWith("/HEAD")) continue;
|
|
282
287
|
if (name.startsWith("refs/heads/") || name.startsWith("refs/remotes/")) {
|
|
@@ -301,7 +306,10 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
301
306
|
continue;
|
|
302
307
|
}
|
|
303
308
|
let commitOid = null, hint;
|
|
304
|
-
if (peeledType === "commit")
|
|
309
|
+
if (targetType === "tag" && peeledType === "commit") {
|
|
310
|
+
commitOid = peeledOid;
|
|
311
|
+
hint = "nested-tag";
|
|
312
|
+
} else if (peeledType === "commit") commitOid = peeledOid;
|
|
305
313
|
else if (peeledType === "tag") {
|
|
306
314
|
// Nested tag: peel recursively; when the chain ends outside a
|
|
307
315
|
// commit we still keep the name and advertise the hint.
|
|
@@ -354,14 +362,20 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
354
362
|
*/
|
|
355
363
|
async fileHistory(root, path, { maxCommits = 5000, timeoutMs = 20000 } = {}) {
|
|
356
364
|
if (typeof path !== "string" || path === "" || path.includes("\0")) throw gitError("git-command-failed", 400);
|
|
357
|
-
|
|
365
|
+
const deadline = Date.now() + timeoutMs;
|
|
366
|
+
const historyRun = (args) => spawnGit(root, args, { timeoutMs: Math.max(1, deadline - Date.now()) });
|
|
367
|
+
try {
|
|
368
|
+
const check = await historyRun(["rev-parse", "--verify", "HEAD"]);
|
|
369
|
+
if (check.timedOut) return { entries: [], truncated: true };
|
|
370
|
+
} catch (error) {
|
|
358
371
|
if (error?.code === "git-command-failed") return { entries: [], truncated: false, reason: "no-history" };
|
|
359
372
|
throw error;
|
|
360
373
|
}
|
|
361
374
|
let tracked = false;
|
|
362
375
|
try {
|
|
363
|
-
const tree = await
|
|
364
|
-
|
|
376
|
+
const tree = await historyRun(["ls-tree", "-z", "HEAD", "--", `:(literal)${path}`]);
|
|
377
|
+
if (tree.timedOut) return { entries: [], truncated: true };
|
|
378
|
+
for (const record of tree.stdout.split("\0")) {
|
|
365
379
|
const separator = record.indexOf("\t");
|
|
366
380
|
if (separator < 0) continue;
|
|
367
381
|
const entryPath = record.slice(separator + 1);
|
|
@@ -375,7 +389,7 @@ export function createBundledGitReadProvider(ctx) {
|
|
|
375
389
|
}
|
|
376
390
|
if (!tracked) return { entries: [], truncated: false, reason: "not-tracked" };
|
|
377
391
|
const cap = Math.max(1, Math.min(5000, Number(maxCommits) || 5000));
|
|
378
|
-
const result = await
|
|
392
|
+
const result = await historyRun(["--literal-pathspecs", "log", `--max-count=${cap + 1}`, "--format=%x00%H%x1f%h%x1f%an%x1f%at%x1f%s", "--name-status", "-M", "-z", "--", path]);
|
|
379
393
|
let entries = parseFileHistory(result.stdout);
|
|
380
394
|
let truncated = result.timedOut === true;
|
|
381
395
|
if (entries.length > cap) {
|