@f5-sales-demo/xcsh 21.27.0 → 21.27.1
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/package.json +8 -8
- package/src/debug/index.ts +10 -2
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/modes/components/settings-browser.ts +22 -4
- package/src/modes/components/settings-editors.ts +67 -14
- package/src/modes/components/settings-selector.ts +23 -5
- package/src/modes/controllers/command-controller.ts +18 -1
- package/src/slash-commands/export-command.ts +17 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.27.
|
|
4
|
+
"version": "21.27.1",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
65
|
-
"@f5-sales-demo/pi-agent-core": "21.27.
|
|
66
|
-
"@f5-sales-demo/pi-ai": "21.27.
|
|
67
|
-
"@f5-sales-demo/pi-natives": "21.27.
|
|
68
|
-
"@f5-sales-demo/pi-resource-management": "21.27.
|
|
69
|
-
"@f5-sales-demo/pi-tui": "21.27.
|
|
70
|
-
"@f5-sales-demo/pi-utils": "21.27.
|
|
71
|
-
"@f5-sales-demo/xcsh-stats": "21.27.
|
|
65
|
+
"@f5-sales-demo/pi-agent-core": "21.27.1",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.27.1",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.27.1",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.27.1",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.27.1",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.27.1",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.27.1",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "0.34.52",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
package/src/debug/index.ts
CHANGED
|
@@ -537,9 +537,17 @@ export class DebugSelectorComponent extends HookSelectorComponent {
|
|
|
537
537
|
const stat = await fs.lstat(artifactsDir);
|
|
538
538
|
if (!stat.isDirectory() || stat.isSymbolicLink()) return undefined;
|
|
539
539
|
const resolved = await fs.realpath(artifactsDir);
|
|
540
|
-
|
|
540
|
+
// `/var` resolves to `/private/var` on macOS even when the requested
|
|
541
|
+
// artifact directory itself is not a symlink. Compare canonical parent
|
|
542
|
+
// identity so that alias does not reject a valid local target, while
|
|
543
|
+
// retaining the requested path in the review and launcher contract.
|
|
544
|
+
const canonicalExpected = path.join(
|
|
545
|
+
await fs.realpath(path.dirname(artifactsDir)),
|
|
546
|
+
path.basename(artifactsDir),
|
|
547
|
+
);
|
|
548
|
+
if (resolved !== canonicalExpected) return undefined;
|
|
541
549
|
return {
|
|
542
|
-
path:
|
|
550
|
+
path: artifactsDir,
|
|
543
551
|
revision: `${stat.dev}:${stat.ino}:${stat.mtimeMs}`,
|
|
544
552
|
description: `Directory · device ${stat.dev} · inode ${stat.ino}`,
|
|
545
553
|
};
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.27.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.27.1",
|
|
21
|
+
"commit": "ef3b4c8f48b43f0e7851b50ec8899992d82c437e",
|
|
22
|
+
"shortCommit": "ef3b4c8",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.27.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.27.1",
|
|
25
|
+
"commitDate": "2026-09-13T03:58:03+00:00",
|
|
26
|
+
"buildDate": "2026-09-13T04:37:58.959Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.27.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/ef3b4c8f48b43f0e7851b50ec8899992d82c437e",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.27.1"
|
|
33
33
|
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Container,
|
|
3
|
+
Input,
|
|
4
|
+
type MouseRoutable,
|
|
5
|
+
type SettingItem,
|
|
6
|
+
type SgrMouseEvent,
|
|
7
|
+
wrapTextWithAnsi,
|
|
8
|
+
} from "@f5-sales-demo/pi-tui";
|
|
2
9
|
import { matchesSelectorKey, selectorFrame, selectorFrameContentWidth, selectorRow } from "./selector-frame";
|
|
3
10
|
|
|
4
11
|
/** Internal settings navigation; paths, not row offsets, retain selection across searches. */
|
|
@@ -12,7 +19,7 @@ export class SettingsBrowser extends Container {
|
|
|
12
19
|
|
|
13
20
|
constructor(
|
|
14
21
|
private items: SettingItem[],
|
|
15
|
-
private readonly navigation: () => string[],
|
|
22
|
+
private readonly navigation: (width: number) => string[],
|
|
16
23
|
private readonly onChange: (id: string, value: string) => void,
|
|
17
24
|
private readonly onCancel: () => void,
|
|
18
25
|
private readonly presentation: {
|
|
@@ -30,6 +37,11 @@ export class SettingsBrowser extends Container {
|
|
|
30
37
|
this.items = items;
|
|
31
38
|
}
|
|
32
39
|
|
|
40
|
+
/** Section arrows are reserved for the parent only when search is empty. */
|
|
41
|
+
hasSearch(): boolean {
|
|
42
|
+
return Boolean(this.#search.getValue());
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
#matches(): SettingItem[] {
|
|
34
46
|
const words = this.#search.getValue().toLocaleLowerCase().trim().split(/\s+/);
|
|
35
47
|
return this.items.filter(item =>
|
|
@@ -62,7 +74,7 @@ export class SettingsBrowser extends Container {
|
|
|
62
74
|
rows,
|
|
63
75
|
this.presentation.title ?? "Settings",
|
|
64
76
|
this.presentation.purpose ?? "Scope: user settings · Changes are drafts until saved",
|
|
65
|
-
[...this.navigation(), ...this.#search.render(Math.max(1, inner - 8)).map(line => `Search: ${line}`)],
|
|
77
|
+
[...this.navigation(inner), ...this.#search.render(Math.max(1, inner - 8)).map(line => `Search: ${line}`)],
|
|
66
78
|
items.length
|
|
67
79
|
? items.map((item, i) =>
|
|
68
80
|
selectorRow(
|
|
@@ -75,6 +87,7 @@ export class SettingsBrowser extends Container {
|
|
|
75
87
|
details.slice(this.#detailOffset, this.#detailOffset + this.#detailCapacity),
|
|
76
88
|
[
|
|
77
89
|
...(this.presentation.footer ?? ["Tab/Shift+Tab: section"]),
|
|
90
|
+
...(items.length ? [`Settings ${index + 1}/${items.length}`] : []),
|
|
78
91
|
...(details.length > this.#detailCapacity ? ["PgUp/PgDn: details"] : []),
|
|
79
92
|
],
|
|
80
93
|
{ selectedBodyIndex: index },
|
|
@@ -107,7 +120,7 @@ export class SettingsBrowser extends Container {
|
|
|
107
120
|
);
|
|
108
121
|
} else if (matchesSelectorKey(data, "pageUp")) {
|
|
109
122
|
this.#detailOffset = Math.max(0, this.#detailOffset - this.#detailCapacity);
|
|
110
|
-
} else if (matchesSelectorKey(data, "confirm")) {
|
|
123
|
+
} else if (matchesSelectorKey(data, "confirm") || (data === " " && !this.hasSearch())) {
|
|
111
124
|
const item = items[index];
|
|
112
125
|
if (item && this.presentation.open) {
|
|
113
126
|
this.#selected = item.id;
|
|
@@ -129,4 +142,9 @@ export class SettingsBrowser extends Container {
|
|
|
129
142
|
if (before !== this.#search.getValue()) this.#detailOffset = 0;
|
|
130
143
|
}
|
|
131
144
|
}
|
|
145
|
+
|
|
146
|
+
routeMouse(event: SgrMouseEvent, line: number, col: number): void {
|
|
147
|
+
const editor = this.#editor as Partial<MouseRoutable> | undefined;
|
|
148
|
+
editor?.routeMouse?.(event, line, col);
|
|
149
|
+
}
|
|
132
150
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Container,
|
|
3
|
+
Input,
|
|
4
|
+
type MouseRoutable,
|
|
5
|
+
type SelectItem,
|
|
6
|
+
type SgrMouseEvent,
|
|
7
|
+
wrapTextWithAnsi,
|
|
8
|
+
} from "@f5-sales-demo/pi-tui";
|
|
2
9
|
import { matchesSelectorKey, selectorFrame, selectorFrameContentWidth, selectorRow } from "./selector-frame";
|
|
3
10
|
|
|
4
11
|
export class SettingsTextEditor extends Container {
|
|
@@ -63,12 +70,14 @@ export class SettingsTextEditor extends Container {
|
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
/** Search and preview are local; only the caller's draft callback changes a proposed value. */
|
|
66
|
-
export class SettingsChoiceEditor extends Container {
|
|
73
|
+
export class SettingsChoiceEditor extends Container implements MouseRoutable {
|
|
67
74
|
#search = new Input();
|
|
68
75
|
#selected: string;
|
|
69
76
|
#offset = 0;
|
|
70
77
|
#capacity = 1;
|
|
71
78
|
#detailLength = 0;
|
|
79
|
+
#choiceCapacity = 1;
|
|
80
|
+
#hitRows = new Map<number, SelectItem>();
|
|
72
81
|
#previewQueue: Promise<void> = Promise.resolve();
|
|
73
82
|
#generation = 0;
|
|
74
83
|
#finishing = false;
|
|
@@ -99,6 +108,12 @@ export class SettingsChoiceEditor extends Container {
|
|
|
99
108
|
const items = this.#items();
|
|
100
109
|
return items.find(item => item.value === this.#selected) ?? items[0];
|
|
101
110
|
}
|
|
111
|
+
#select(item: SelectItem): void {
|
|
112
|
+
if (item.value === this.#selected) return;
|
|
113
|
+
this.#selected = item.value;
|
|
114
|
+
this.#preview(item.value);
|
|
115
|
+
this.#offset = 0;
|
|
116
|
+
}
|
|
102
117
|
#preview(value: string): void {
|
|
103
118
|
if (!this.onPreview) return;
|
|
104
119
|
const generation = ++this.#generation;
|
|
@@ -146,9 +161,10 @@ export class SettingsChoiceEditor extends Container {
|
|
|
146
161
|
inner,
|
|
147
162
|
);
|
|
148
163
|
this.#capacity = Math.max(1, Math.floor(rows / 4));
|
|
164
|
+
this.#choiceCapacity = Math.max(1, Math.floor(rows / 3));
|
|
149
165
|
this.#detailLength = details.length;
|
|
150
166
|
this.#offset = Math.min(this.#offset, Math.max(0, details.length - this.#capacity));
|
|
151
|
-
|
|
167
|
+
const rendered = selectorFrame(
|
|
152
168
|
width,
|
|
153
169
|
rows,
|
|
154
170
|
this.title,
|
|
@@ -166,16 +182,30 @@ export class SettingsChoiceEditor extends Container {
|
|
|
166
182
|
)
|
|
167
183
|
: [this.options.length ? "No matching values" : "No values available"],
|
|
168
184
|
details.slice(this.#offset, this.#offset + this.#capacity),
|
|
169
|
-
|
|
185
|
+
[
|
|
186
|
+
...(selected ? [`Choices ${items.indexOf(selected) + 1}/${items.length}`] : []),
|
|
187
|
+
...(items.length > this.#choiceCapacity ? ["PgUp/PgDn: choices"] : []),
|
|
188
|
+
...(details.length > this.#capacity ? ["PgUp/PgDn: details"] : []),
|
|
189
|
+
],
|
|
170
190
|
{ selectedBodyIndex: selected ? items.indexOf(selected) : 0 },
|
|
171
191
|
);
|
|
192
|
+
this.#hitRows.clear();
|
|
193
|
+
let from = 0;
|
|
194
|
+
for (const item of items) {
|
|
195
|
+
const row = rendered.findIndex((line, index) => index >= from && Bun.stripANSI(line).includes(item.label));
|
|
196
|
+
if (row >= 0) {
|
|
197
|
+
this.#hitRows.set(row, item);
|
|
198
|
+
from = row + 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return rendered;
|
|
172
202
|
}
|
|
173
203
|
handleInput(data: string): void {
|
|
174
204
|
if (this.#finishing) return;
|
|
175
205
|
if (matchesSelectorKey(data, "cancel")) {
|
|
176
206
|
if (this.#search.getValue()) this.#search.setValue("");
|
|
177
207
|
else this.#finish();
|
|
178
|
-
} else if (matchesSelectorKey(data, "confirm")) {
|
|
208
|
+
} else if (matchesSelectorKey(data, "confirm") || (data === " " && !this.#search.getValue())) {
|
|
179
209
|
const selected = this.#selection();
|
|
180
210
|
if (selected) this.#finish(selected.value);
|
|
181
211
|
} else if (matchesSelectorKey(data, "up") || matchesSelectorKey(data, "down")) {
|
|
@@ -184,17 +214,40 @@ export class SettingsChoiceEditor extends Container {
|
|
|
184
214
|
const index = current ? items.indexOf(current) : 0;
|
|
185
215
|
const delta = matchesSelectorKey(data, "up") ? -1 : 1;
|
|
186
216
|
const selected = items[(index + delta + items.length) % items.length];
|
|
187
|
-
if (selected)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
217
|
+
if (selected) this.#select(selected);
|
|
218
|
+
} else if (matchesSelectorKey(data, "pageDown") || matchesSelectorKey(data, "pageUp")) {
|
|
219
|
+
const items = this.#items();
|
|
220
|
+
if (items.length > this.#choiceCapacity) {
|
|
221
|
+
const current = this.#selection();
|
|
222
|
+
const index = Math.max(0, current ? items.indexOf(current) : 0);
|
|
223
|
+
const delta = matchesSelectorKey(data, "pageDown") ? this.#choiceCapacity : -this.#choiceCapacity;
|
|
224
|
+
const selected = items[Math.max(0, Math.min(items.length - 1, index + delta))];
|
|
225
|
+
if (selected) this.#select(selected);
|
|
226
|
+
} else if (matchesSelectorKey(data, "pageDown"))
|
|
227
|
+
this.#offset = Math.min(Math.max(0, this.#detailLength - this.#capacity), this.#offset + this.#capacity);
|
|
228
|
+
else this.#offset = Math.max(0, this.#offset - this.#capacity);
|
|
229
|
+
} else {
|
|
196
230
|
this.#search.handleInput(data);
|
|
197
231
|
this.#offset = 0;
|
|
198
232
|
}
|
|
199
233
|
}
|
|
234
|
+
|
|
235
|
+
routeMouse(event: SgrMouseEvent, line: number, _col: number): void {
|
|
236
|
+
if (this.#finishing) return;
|
|
237
|
+
if (event.wheel !== null) {
|
|
238
|
+
const items = this.#items();
|
|
239
|
+
const current = this.#selection();
|
|
240
|
+
const index = Math.max(0, current ? items.indexOf(current) : 0);
|
|
241
|
+
const selected = items[Math.max(0, Math.min(items.length - 1, index + event.wheel))];
|
|
242
|
+
if (selected) this.#select(selected);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const item = this.#hitRows.get(line);
|
|
246
|
+
if (!item) return;
|
|
247
|
+
if (event.motion) this.#select(item);
|
|
248
|
+
else if (event.leftClick) {
|
|
249
|
+
this.#select(item);
|
|
250
|
+
this.#finish(item.value);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
200
253
|
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
2
|
import type { ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
|
|
3
3
|
import type { Effort } from "@f5-sales-demo/pi-ai";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Container,
|
|
6
|
+
type MouseRoutable,
|
|
7
|
+
matchesKey,
|
|
8
|
+
type SettingItem,
|
|
9
|
+
type SgrMouseEvent,
|
|
10
|
+
type Tab,
|
|
11
|
+
TabBar,
|
|
12
|
+
wrapTextWithAnsi,
|
|
13
|
+
} from "@f5-sales-demo/pi-tui";
|
|
5
14
|
import { type SettingPath, type Settings, settings } from "../../config/settings";
|
|
6
15
|
import type {
|
|
7
16
|
SettingTab,
|
|
@@ -104,7 +113,7 @@ export interface SettingsCallbacks {
|
|
|
104
113
|
* Main tabbed settings selector component.
|
|
105
114
|
* Uses declarative settings definitions from settings-defs.ts.
|
|
106
115
|
*/
|
|
107
|
-
export class SettingsSelectorComponent extends Container {
|
|
116
|
+
export class SettingsSelectorComponent extends Container implements MouseRoutable {
|
|
108
117
|
#tabBar: TabBar;
|
|
109
118
|
#currentList: SettingsBrowser | null = null;
|
|
110
119
|
#browsers = new Map<SettingTab, SettingsBrowser>();
|
|
@@ -538,8 +547,8 @@ export class SettingsSelectorComponent extends Container {
|
|
|
538
547
|
|
|
539
548
|
this.#currentList = new SettingsBrowser(
|
|
540
549
|
items,
|
|
541
|
-
|
|
542
|
-
|
|
550
|
+
width => [
|
|
551
|
+
...this.#tabBar.render(width),
|
|
543
552
|
...(tabId === "appearance" ? [`Preview: ${this.#getStatusPreviewString()}`] : []),
|
|
544
553
|
...(this.#draftCount ? [`${this.#draftCount} unsaved changes · Ctrl+S: review changes`] : []),
|
|
545
554
|
],
|
|
@@ -648,7 +657,12 @@ export class SettingsSelectorComponent extends Container {
|
|
|
648
657
|
}
|
|
649
658
|
// Handle tab switching — but NOT when a text input is active, since
|
|
650
659
|
// arrow keys must reach the cursor and Tab must not switch tabs.
|
|
651
|
-
if (
|
|
660
|
+
if (
|
|
661
|
+
!editing &&
|
|
662
|
+
(matchesKey(data, "tab") ||
|
|
663
|
+
matchesKey(data, "shift+tab") ||
|
|
664
|
+
((matchesKey(data, "left") || matchesKey(data, "right")) && !this.#currentList?.hasSearch()))
|
|
665
|
+
) {
|
|
652
666
|
this.#tabBar.handleInput(data);
|
|
653
667
|
return;
|
|
654
668
|
}
|
|
@@ -660,4 +674,8 @@ export class SettingsSelectorComponent extends Container {
|
|
|
660
674
|
this.#pluginComponent.handleInput(data);
|
|
661
675
|
}
|
|
662
676
|
}
|
|
677
|
+
|
|
678
|
+
routeMouse(event: SgrMouseEvent, line: number, col: number): void {
|
|
679
|
+
this.#currentList?.routeMouse(event, line, col);
|
|
680
|
+
}
|
|
663
681
|
}
|
|
@@ -57,6 +57,18 @@ import { setSessionTerminalTitle } from "../../utils/title-generator";
|
|
|
57
57
|
import { reviewClipboardAction } from "../utils/clipboard-action";
|
|
58
58
|
import { reviewExternalUrlAction } from "../utils/open-action";
|
|
59
59
|
|
|
60
|
+
/** Accept macOS's documented logical temporary-directory aliases, but not arbitrary symlinks. */
|
|
61
|
+
function isExpectedResolvedDirectory(requested: string, resolved: string): boolean {
|
|
62
|
+
const absolute = path.resolve(requested);
|
|
63
|
+
const expected =
|
|
64
|
+
process.platform === "darwin" && (absolute === "/var" || absolute.startsWith("/var/"))
|
|
65
|
+
? `/private${absolute}`
|
|
66
|
+
: process.platform === "darwin" && (absolute === "/tmp" || absolute.startsWith("/tmp/"))
|
|
67
|
+
? `/private${absolute}`
|
|
68
|
+
: absolute;
|
|
69
|
+
return resolved === expected;
|
|
70
|
+
}
|
|
71
|
+
|
|
60
72
|
async function showMarkdownPanel(
|
|
61
73
|
ctx: InteractiveModeContext,
|
|
62
74
|
title: string,
|
|
@@ -232,7 +244,12 @@ export class CommandController {
|
|
|
232
244
|
throw new Error(`Destination changed: ${file.path}. Review again before overwriting.`);
|
|
233
245
|
if (file.before?.hash === file.hash) continue;
|
|
234
246
|
await fs.mkdir(path.dirname(file.path), { recursive: true });
|
|
235
|
-
if (
|
|
247
|
+
if (
|
|
248
|
+
!isExpectedResolvedDirectory(
|
|
249
|
+
path.dirname(file.path),
|
|
250
|
+
await fs.realpath(path.dirname(file.path)),
|
|
251
|
+
)
|
|
252
|
+
)
|
|
236
253
|
throw new Error("Export parent directory changed");
|
|
237
254
|
const temporary = path.join(path.dirname(file.path), `.xcsh-export-${Snowflake.next()}.tmp`);
|
|
238
255
|
const handle = await fs.open(temporary, "wx", 0o600);
|
|
@@ -33,6 +33,22 @@ function digest(value: string | Uint8Array): string {
|
|
|
33
33
|
return createHash("sha256").update(value).digest("hex");
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* macOS exposes /var and /tmp as documented logical aliases for /private/var
|
|
38
|
+
* and /private/tmp. Treat only those platform aliases as equivalent; a caller
|
|
39
|
+
* supplied symlink elsewhere remains a rejected export parent.
|
|
40
|
+
*/
|
|
41
|
+
function isExpectedResolvedDirectory(requested: string, resolved: string): boolean {
|
|
42
|
+
const absolute = path.resolve(requested);
|
|
43
|
+
const expected =
|
|
44
|
+
process.platform === "darwin" && (absolute === "/var" || absolute.startsWith("/var/"))
|
|
45
|
+
? `/private${absolute}`
|
|
46
|
+
: process.platform === "darwin" && (absolute === "/tmp" || absolute.startsWith("/tmp/"))
|
|
47
|
+
? `/private${absolute}`
|
|
48
|
+
: absolute;
|
|
49
|
+
return resolved === expected;
|
|
50
|
+
}
|
|
51
|
+
|
|
36
52
|
async function inspectDestination(filePath: string): Promise<DestinationState> {
|
|
37
53
|
try {
|
|
38
54
|
const stats = await fs.lstat(filePath);
|
|
@@ -266,7 +282,7 @@ export async function handleExportResourceCommand(
|
|
|
266
282
|
if (file.before.hash !== file.hash) {
|
|
267
283
|
const parent = path.dirname(file.path);
|
|
268
284
|
await fs.mkdir(parent, { recursive: true });
|
|
269
|
-
if ((await fs.realpath(parent))
|
|
285
|
+
if (!isExpectedResolvedDirectory(parent, await fs.realpath(parent)))
|
|
270
286
|
throw new Error("Destination parent resolves through a symbolic link");
|
|
271
287
|
const temporary = path.join(parent, `.xcsh-manifest-${Snowflake.next()}.tmp`);
|
|
272
288
|
const handle = await fs.open(temporary, "wx", 0o600);
|