@narumitw/pi-starship 0.58.0 → 0.59.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.md +23 -1
- package/dist/chunks/{commands-WUB5ZYZR.ts → commands-M6GHLJIR.ts} +324 -15
- package/dist/chunks/commands-M6GHLJIR.ts.map +7 -0
- package/dist/index.ts +1 -1
- package/package.json +5 -5
- package/skills/configuring-pi-starship/references/configuration.md +4 -1
- package/src/command-configuration.ts +12 -0
- package/src/command-gist.ts +208 -0
- package/src/commands.ts +44 -6
- package/src/gist.ts +133 -0
- package/dist/chunks/commands-WUB5ZYZR.ts.map +0 -7
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ The extension parses and renders the footer itself, so it does not need the `sta
|
|
|
17
17
|
- Wraps native multiline layouts to terminal width instead of truncating them.
|
|
18
18
|
- Keeps rendering pure while refreshing filesystem, process, and network-derived data through bounded caches.
|
|
19
19
|
- Uses `/starship` for presets, preview, configuration health, searchable module details, customization, and recovery.
|
|
20
|
+
- Shares settings through unlisted GitHub Gists and reviews imported settings before replacement.
|
|
20
21
|
- Bundles the authoritative configuration skill and references for editing `pi-starship.toml` or answering setup questions.
|
|
21
22
|
- Loads a generated split runtime to reduce Pi package startup work.
|
|
22
23
|
|
|
@@ -70,7 +71,7 @@ It does not cover general TOML, shell Starship configuration, extension source d
|
|
|
70
71
|
|
|
71
72
|
All routes support TUI and RPC with the exceptions above and reject unknown or trailing arguments.
|
|
72
73
|
Print and JSON modes produce no command output; the footer runs only in TUI mode.
|
|
73
|
-
Preset selection, module inspection, and recovery are menu-only, not extra subcommands.
|
|
74
|
+
Preset selection, module inspection, Gist sharing and import, and recovery are menu-only, not extra subcommands.
|
|
74
75
|
Restoring built-in configuration requires an existing settings document to replace; see [Settings](#-settings).
|
|
75
76
|
|
|
76
77
|
## ⚙️ Settings
|
|
@@ -102,6 +103,27 @@ See [Configuration and format](./skills/configuring-pi-starship/references/confi
|
|
|
102
103
|
Use `/starship` for interactive configuration, preview, diagnostics, presets, and recovery.
|
|
103
104
|
Manual file edits load at the next `session_start`, including `/reload`.
|
|
104
105
|
|
|
106
|
+
## 🔗 Share and import settings
|
|
107
|
+
|
|
108
|
+
In TUI mode, open `/starship` → **Configuration** and select **Share settings as Gist…** or **Import settings from Gist…**.
|
|
109
|
+
Install GitHub CLI (`gh`) and run `gh auth login` for github.com with Gist access first; pi-starship uses that authentication and stores no GitHub credentials.
|
|
110
|
+
|
|
111
|
+
Sharing reviews the exact loaded TOML, including comments and unknown fields, then asks permission to upload a new unlisted Gist with a `pi-starship.toml` file.
|
|
112
|
+
With no settings file, it shares the built-in example without creating a local file.
|
|
113
|
+
**Unlisted is not private: anyone with the link can read it. Remove secrets and local paths before sharing.**
|
|
114
|
+
The result is a shareable Gist URL; existing Gists are never updated.
|
|
115
|
+
|
|
116
|
+
Import accepts a Gist ID or an `https://gist.github.com/<owner>/<id>` link and reads only `pi-starship.toml`.
|
|
117
|
+
It validates the TOML, shows the full document for review, then previews the footer and asks permission to replace the entire local settings document.
|
|
118
|
+
Review untrusted settings carefully: they can enable command execution and network requests.
|
|
119
|
+
A successful import applies immediately, preserves the imported bytes, and keeps no backup; application failure attempts to restore the previous document and footer.
|
|
120
|
+
Concurrent in-process settings changes or disk changes during review block the import; this is not a cross-process lock.
|
|
121
|
+
|
|
122
|
+
Only github.com Gists are supported, with a 64 KiB document limit, a 512 KiB API response limit, and a 30-second request timeout.
|
|
123
|
+
Incomplete or truncated files are rejected without following raw-file URLs.
|
|
124
|
+
Escape or Ctrl+C cancels a request, and session replacement or shutdown stops owned work.
|
|
125
|
+
Cancelling or losing an upload response cannot undo a Gist already created on GitHub: check your Gists before retrying.
|
|
126
|
+
|
|
105
127
|
## 🔒 Security and privacy
|
|
106
128
|
|
|
107
129
|
Some opt-in modules read local development, deployment, cloud, host, or user metadata, run bounded local commands, or query GitHub through `gh`.
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-MTFSZ63Q.ts";
|
|
15
15
|
|
|
16
16
|
// src/commands.ts
|
|
17
|
-
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
17
|
+
import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
|
|
18
18
|
|
|
19
19
|
// src/command-configuration.ts
|
|
20
20
|
import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
|
|
@@ -1071,6 +1071,18 @@ function configurationMenuScreen(loaded) {
|
|
|
1071
1071
|
label: "Reload from disk\u2026",
|
|
1072
1072
|
description: "Validate and preview external changes",
|
|
1073
1073
|
action: "configuration-reload"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
id: "gist-share",
|
|
1077
|
+
label: "Share settings as Gist\u2026",
|
|
1078
|
+
description: "Upload reviewed TOML to GitHub \xB7 unlisted, not private \xB7 requires gh",
|
|
1079
|
+
action: "gist-share"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
id: "gist-import",
|
|
1083
|
+
label: "Import settings from Gist\u2026",
|
|
1084
|
+
description: "Review and preview remote TOML before replacing settings \xB7 requires gh",
|
|
1085
|
+
action: "gist-import"
|
|
1074
1086
|
}
|
|
1075
1087
|
],
|
|
1076
1088
|
hint: "back"
|
|
@@ -1267,6 +1279,277 @@ function formatError(error) {
|
|
|
1267
1279
|
return error instanceof Error ? error.message : String(error);
|
|
1268
1280
|
}
|
|
1269
1281
|
|
|
1282
|
+
// src/command-gist.ts
|
|
1283
|
+
import { defineMenu, runMenu, runTask } from "@narumitw/pi-tui-kit";
|
|
1284
|
+
import { sanitizeTerminalText as sanitizeTerminalText2 } from "@narumitw/pi-tui-kit/terminal-text";
|
|
1285
|
+
|
|
1286
|
+
// src/gist.ts
|
|
1287
|
+
import { spawn } from "node:child_process";
|
|
1288
|
+
var GIST_FILENAME = "pi-starship.toml";
|
|
1289
|
+
var MAX_GIST_DOCUMENT_BYTES = 64 * 1024;
|
|
1290
|
+
var MAX_RESPONSE_BYTES = 512 * 1024;
|
|
1291
|
+
var REQUEST_TIMEOUT_MS = 3e4;
|
|
1292
|
+
function gistId(value) {
|
|
1293
|
+
const text = value.trim();
|
|
1294
|
+
if (/^[a-f\d]{5,64}$/iu.test(text)) return text;
|
|
1295
|
+
try {
|
|
1296
|
+
const url = new URL(text);
|
|
1297
|
+
const match = /^\/(?:[\w-]+\/)?([a-f\d]{5,64})\/?$/iu.exec(url.pathname);
|
|
1298
|
+
if (url.protocol === "https:" && url.hostname === "gist.github.com" && !url.port && !url.username && !url.password && !url.search && match?.[1])
|
|
1299
|
+
return match[1];
|
|
1300
|
+
} catch {
|
|
1301
|
+
}
|
|
1302
|
+
throw new Error("Enter a github.com Gist ID or https://gist.github.com/<owner>/<id> URL.");
|
|
1303
|
+
}
|
|
1304
|
+
function checkGistDocument(rawDocument) {
|
|
1305
|
+
if (!rawDocument.trim()) throw new Error("The Gist settings document is empty.");
|
|
1306
|
+
if (Buffer.byteLength(rawDocument, "utf8") > MAX_GIST_DOCUMENT_BYTES) {
|
|
1307
|
+
throw new Error("The Gist settings document exceeds 64 KiB.");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
async function createSettingsGist(rawDocument, signal, api = executeGhApi) {
|
|
1311
|
+
checkGistDocument(rawDocument);
|
|
1312
|
+
const response = JSON.parse(
|
|
1313
|
+
await api(
|
|
1314
|
+
["/gists", "--method", "POST", "--input", "-"],
|
|
1315
|
+
JSON.stringify({
|
|
1316
|
+
description: "pi-starship footer settings",
|
|
1317
|
+
public: false,
|
|
1318
|
+
files: { [GIST_FILENAME]: { content: rawDocument } }
|
|
1319
|
+
}),
|
|
1320
|
+
signal
|
|
1321
|
+
)
|
|
1322
|
+
);
|
|
1323
|
+
signal.throwIfAborted();
|
|
1324
|
+
if (!isRecord(response) || response.public !== false || typeof response.html_url !== "string") {
|
|
1325
|
+
throw new Error("GitHub returned an invalid Gist response. Check your Gists before retrying.");
|
|
1326
|
+
}
|
|
1327
|
+
return `https://gist.github.com/${gistId(response.html_url)}`;
|
|
1328
|
+
}
|
|
1329
|
+
async function fetchSettingsGist(value, signal, api = executeGhApi) {
|
|
1330
|
+
const id = gistId(value);
|
|
1331
|
+
const response = JSON.parse(await api([`/gists/${id}`, "--method", "GET"], void 0, signal));
|
|
1332
|
+
signal.throwIfAborted();
|
|
1333
|
+
const file = isRecord(response) && isRecord(response.files) ? response.files[GIST_FILENAME] : void 0;
|
|
1334
|
+
if (!isRecord(file) || typeof file.content !== "string" || file.truncated !== false) {
|
|
1335
|
+
throw new Error(`The Gist must contain a complete ${GIST_FILENAME} file. Truncated files are not supported.`);
|
|
1336
|
+
}
|
|
1337
|
+
checkGistDocument(file.content);
|
|
1338
|
+
return file.content;
|
|
1339
|
+
}
|
|
1340
|
+
function isRecord(value) {
|
|
1341
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1342
|
+
}
|
|
1343
|
+
var executeGhApi = (args, input, signal) => {
|
|
1344
|
+
signal.throwIfAborted();
|
|
1345
|
+
return new Promise((resolve, reject) => {
|
|
1346
|
+
const child = spawn(process.platform === "win32" ? "gh.exe" : "gh", ["api", "--hostname", "github.com", ...args], {
|
|
1347
|
+
env: { ...process.env, GH_PROMPT_DISABLED: "1", GH_PAGER: "", GH_DEBUG: "" },
|
|
1348
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1349
|
+
windowsHide: true
|
|
1350
|
+
});
|
|
1351
|
+
const chunks = [];
|
|
1352
|
+
let bytes = 0;
|
|
1353
|
+
let failure;
|
|
1354
|
+
const stop = (error) => {
|
|
1355
|
+
failure ??= error;
|
|
1356
|
+
child.kill("SIGKILL");
|
|
1357
|
+
};
|
|
1358
|
+
const onAbort = () => stop(new Error("Gist request cancelled."));
|
|
1359
|
+
const timer = setTimeout(
|
|
1360
|
+
() => stop(new Error("Gist request timed out. Check GitHub before retrying an upload.")),
|
|
1361
|
+
REQUEST_TIMEOUT_MS
|
|
1362
|
+
);
|
|
1363
|
+
timer.unref();
|
|
1364
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1365
|
+
child.stdout.on("data", (chunk) => {
|
|
1366
|
+
bytes += chunk.length;
|
|
1367
|
+
if (bytes > MAX_RESPONSE_BYTES) stop(new Error("GitHub Gist response exceeds 512 KiB."));
|
|
1368
|
+
else chunks.push(chunk);
|
|
1369
|
+
});
|
|
1370
|
+
child.stdin.on("error", () => {
|
|
1371
|
+
stop(new Error("Unable to send settings to gh."));
|
|
1372
|
+
});
|
|
1373
|
+
child.on("error", () => {
|
|
1374
|
+
failure ??= new Error("Unable to start gh. Install GitHub CLI and run gh auth login with Gist access.");
|
|
1375
|
+
});
|
|
1376
|
+
child.on("close", (code) => {
|
|
1377
|
+
clearTimeout(timer);
|
|
1378
|
+
signal.removeEventListener("abort", onAbort);
|
|
1379
|
+
if (failure) reject(failure);
|
|
1380
|
+
else if (code !== 0)
|
|
1381
|
+
reject(
|
|
1382
|
+
new Error(
|
|
1383
|
+
"Gist request failed. Check gh auth status, Gist access, and connectivity. An upload may already exist."
|
|
1384
|
+
)
|
|
1385
|
+
);
|
|
1386
|
+
else resolve(Buffer.concat(chunks).toString("utf8"));
|
|
1387
|
+
});
|
|
1388
|
+
if (signal.aborted) onAbort();
|
|
1389
|
+
child.stdin.end(input);
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
// src/command-gist.ts
|
|
1394
|
+
async function shareSettingsGist(ctx, options, owner, api) {
|
|
1395
|
+
if (ctx.mode !== "tui" || !current(owner)) return "cancel";
|
|
1396
|
+
const loaded = options.getLoaded();
|
|
1397
|
+
if (loaded.diagnostics.some((item) => item.severity === "error")) {
|
|
1398
|
+
ctx.ui.notify("Fix configuration errors before sharing settings.", "warning");
|
|
1399
|
+
return "cancel";
|
|
1400
|
+
}
|
|
1401
|
+
const raw = loaded.rawDocument ?? BUILT_IN_EXAMPLE;
|
|
1402
|
+
try {
|
|
1403
|
+
checkGistDocument(raw);
|
|
1404
|
+
} catch (error) {
|
|
1405
|
+
ctx.ui.notify(safeError2(error), "error");
|
|
1406
|
+
return "cancel";
|
|
1407
|
+
}
|
|
1408
|
+
const review = await reviewDocument(
|
|
1409
|
+
ctx,
|
|
1410
|
+
owner,
|
|
1411
|
+
"Share settings as Gist",
|
|
1412
|
+
raw,
|
|
1413
|
+
[
|
|
1414
|
+
"Review the entire loaded document, including comments and unknown fields, for secrets and local paths.",
|
|
1415
|
+
"No settings file is created when sharing built-in defaults."
|
|
1416
|
+
],
|
|
1417
|
+
"Share unlisted Gist\u2026"
|
|
1418
|
+
);
|
|
1419
|
+
if (!current(owner)) return "cancel";
|
|
1420
|
+
if (!review) return "close";
|
|
1421
|
+
const confirmed = await ctx.ui.confirm(
|
|
1422
|
+
"Upload settings to GitHub?",
|
|
1423
|
+
[
|
|
1424
|
+
"Send the reviewed pi-starship.toml to github.com as a new unlisted Gist?",
|
|
1425
|
+
"Unlisted is not private: anyone with the link can read it. Comments and unknown fields are included.",
|
|
1426
|
+
"Cancellation or a network error cannot undo an upload already accepted by GitHub; check your Gists before retrying."
|
|
1427
|
+
].join("\n"),
|
|
1428
|
+
{ signal: owner.signal }
|
|
1429
|
+
);
|
|
1430
|
+
if (!current(owner) || !confirmed) return "cancel";
|
|
1431
|
+
const result = await runTask(ctx, {
|
|
1432
|
+
label: "Sharing settings with GitHub\u2026",
|
|
1433
|
+
signal: owner.signal,
|
|
1434
|
+
isCurrent: owner.isCurrent,
|
|
1435
|
+
task: ({ signal }) => createSettingsGist(raw, signal, api),
|
|
1436
|
+
onError: () => ctx.ui.notify(
|
|
1437
|
+
"Gist upload failed. Check gh auth status, Gist access, connectivity, and your Gists before retrying. The upload may already exist.",
|
|
1438
|
+
"error"
|
|
1439
|
+
)
|
|
1440
|
+
});
|
|
1441
|
+
if (!current(owner)) return "cancel";
|
|
1442
|
+
if (result.kind === "completed") {
|
|
1443
|
+
ctx.ui.notify(`Settings Gist: ${result.value}`, "info");
|
|
1444
|
+
return "cancel";
|
|
1445
|
+
}
|
|
1446
|
+
return result.kind === "error" ? "cancel" : "close";
|
|
1447
|
+
}
|
|
1448
|
+
async function importSettingsGist(ctx, options, owner, reviewImport, api) {
|
|
1449
|
+
if (ctx.mode !== "tui" || !current(owner)) return "cancel";
|
|
1450
|
+
const previous = options.getLoaded();
|
|
1451
|
+
const revision = options.getLoadedRevision?.();
|
|
1452
|
+
const disk = diskSnapshot(options);
|
|
1453
|
+
const guardedOwner = {
|
|
1454
|
+
signal: owner.signal,
|
|
1455
|
+
isCurrent: () => current(owner) && options.getLoadedRevision?.() === revision && options.getLoaded().rawDocument === previous.rawDocument && options.getLoaded().source === previous.source
|
|
1456
|
+
};
|
|
1457
|
+
const value = await ctx.ui.input("Import pi-starship settings from Gist", "https://gist.github.com/<owner>/<id>", {
|
|
1458
|
+
signal: owner.signal
|
|
1459
|
+
});
|
|
1460
|
+
if (!current(guardedOwner) || value === void 0) return "cancel";
|
|
1461
|
+
let id;
|
|
1462
|
+
try {
|
|
1463
|
+
id = gistId(value);
|
|
1464
|
+
} catch (error) {
|
|
1465
|
+
ctx.ui.notify(safeError2(error), "error");
|
|
1466
|
+
return "cancel";
|
|
1467
|
+
}
|
|
1468
|
+
const result = await runTask(ctx, {
|
|
1469
|
+
label: "Reading settings from GitHub\u2026",
|
|
1470
|
+
signal: owner.signal,
|
|
1471
|
+
isCurrent: guardedOwner.isCurrent,
|
|
1472
|
+
task: ({ signal }) => fetchSettingsGist(id, signal, api),
|
|
1473
|
+
onError: () => ctx.ui.notify(
|
|
1474
|
+
"Gist import failed. Check the Gist ID, gh auth status, connectivity, and a complete pi-starship.toml file (up to 64 KiB).",
|
|
1475
|
+
"error"
|
|
1476
|
+
)
|
|
1477
|
+
});
|
|
1478
|
+
if (!current(guardedOwner)) return "cancel";
|
|
1479
|
+
if (result.kind !== "completed") return result.kind === "error" ? "cancel" : "close";
|
|
1480
|
+
let validated;
|
|
1481
|
+
try {
|
|
1482
|
+
validated = (options.validate ?? validateConfigDocument)(options.settingsPath, result.value);
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
ctx.ui.notify(`Gist settings are invalid: ${safeError2(error)}`, "error");
|
|
1485
|
+
return "cancel";
|
|
1486
|
+
}
|
|
1487
|
+
const reviewed = await reviewDocument(
|
|
1488
|
+
ctx,
|
|
1489
|
+
guardedOwner,
|
|
1490
|
+
"Review Gist settings",
|
|
1491
|
+
result.value,
|
|
1492
|
+
[
|
|
1493
|
+
`Source: https://gist.github.com/${id}`,
|
|
1494
|
+
"Untrusted settings can enable local commands and network requests. Review the complete TOML before applying.",
|
|
1495
|
+
"Import replaces the entire local document, including comments and unknown fields; no backup is kept after success."
|
|
1496
|
+
],
|
|
1497
|
+
"Preview imported footer\u2026"
|
|
1498
|
+
);
|
|
1499
|
+
if (!current(guardedOwner)) return "cancel";
|
|
1500
|
+
if (!reviewed) return "close";
|
|
1501
|
+
return reviewImport(
|
|
1502
|
+
validated,
|
|
1503
|
+
{
|
|
1504
|
+
...options,
|
|
1505
|
+
save(path, raw) {
|
|
1506
|
+
if (!current(guardedOwner) || diskSnapshot(options) !== disk) {
|
|
1507
|
+
throw new Error("Settings changed during import. Start a new import to review the latest state.");
|
|
1508
|
+
}
|
|
1509
|
+
return (options.save ?? atomicSaveConfigDocument)(path, raw);
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
guardedOwner
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
async function reviewDocument(ctx, owner, title, content, lines, label) {
|
|
1516
|
+
let approved = false;
|
|
1517
|
+
const menu = defineMenu({
|
|
1518
|
+
start: "document",
|
|
1519
|
+
screens: {
|
|
1520
|
+
document: () => ({
|
|
1521
|
+
kind: "review",
|
|
1522
|
+
title,
|
|
1523
|
+
lines,
|
|
1524
|
+
content,
|
|
1525
|
+
format: { kind: "code", language: "toml" },
|
|
1526
|
+
viewportSize: "adaptive",
|
|
1527
|
+
enableSearch: true,
|
|
1528
|
+
confirm: { id: "continue", label, action: "continue" },
|
|
1529
|
+
hint: "close"
|
|
1530
|
+
})
|
|
1531
|
+
},
|
|
1532
|
+
actions: {
|
|
1533
|
+
continue: () => {
|
|
1534
|
+
approved = true;
|
|
1535
|
+
return { kind: "close" };
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
await runMenu(ctx, menu, { getState: () => void 0, signal: owner.signal, isCurrent: owner.isCurrent });
|
|
1540
|
+
return current(owner) && approved;
|
|
1541
|
+
}
|
|
1542
|
+
function diskSnapshot(options) {
|
|
1543
|
+
const loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);
|
|
1544
|
+
return JSON.stringify([loaded.rawDocument, loaded.source, loaded.diagnostics]);
|
|
1545
|
+
}
|
|
1546
|
+
function current(owner) {
|
|
1547
|
+
return !owner.signal.aborted && owner.isCurrent();
|
|
1548
|
+
}
|
|
1549
|
+
function safeError2(error) {
|
|
1550
|
+
return sanitizeTerminalText2(error instanceof Error ? error.message : String(error));
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1270
1553
|
// src/command-inspector.ts
|
|
1271
1554
|
import { stripVTControlCharacters as stripVTControlCharacters2 } from "node:util";
|
|
1272
1555
|
function formatFooterExplanation(inspection) {
|
|
@@ -1308,9 +1591,9 @@ function safeDisplayText2(value) {
|
|
|
1308
1591
|
// src/command-preset-picker.ts
|
|
1309
1592
|
import { runLiveChoice } from "@narumitw/pi-tui-kit";
|
|
1310
1593
|
async function showPresetPicker(ctx, options) {
|
|
1311
|
-
const
|
|
1594
|
+
const current2 = options.presets.find((preset) => preset.id === options.activePresetId)?.label ?? "Custom configuration";
|
|
1312
1595
|
const result = await runLiveChoice(ctx, {
|
|
1313
|
-
title: `Presets \xB7 current: ${
|
|
1596
|
+
title: `Presets \xB7 current: ${current2}`,
|
|
1314
1597
|
items: options.presets.map((preset) => ({
|
|
1315
1598
|
id: preset.id,
|
|
1316
1599
|
label: preset.label,
|
|
@@ -1397,7 +1680,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1397
1680
|
signal: fallbackController.signal,
|
|
1398
1681
|
isCurrent: () => !fallbackController.signal.aborted
|
|
1399
1682
|
};
|
|
1400
|
-
const menu =
|
|
1683
|
+
const menu = defineMenu2({
|
|
1401
1684
|
start: "main",
|
|
1402
1685
|
screens: {
|
|
1403
1686
|
main: () => {
|
|
@@ -1502,7 +1785,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1502
1785
|
"Presets live-previews the cursor in the footer; Enter confirms apply and e customizes first.",
|
|
1503
1786
|
"Explain footer breaks down the modules currently showing from the existing snapshot.",
|
|
1504
1787
|
"Modules searches every supported module and explains its current read-only state.",
|
|
1505
|
-
"Configuration
|
|
1788
|
+
"Configuration includes disk reload plus unlisted Gist sharing and reviewed Gist import through gh.",
|
|
1506
1789
|
`Settings: ${safeText(options.settingsPath)}`,
|
|
1507
1790
|
"Docs: https://github.com/narumiruna/pi-extensions/tree/main/packages/pi-starship"
|
|
1508
1791
|
],
|
|
@@ -1518,6 +1801,23 @@ async function showMainMenu(ctx, options) {
|
|
|
1518
1801
|
const result = await choosePreset(ctx, options, owner);
|
|
1519
1802
|
return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1520
1803
|
},
|
|
1804
|
+
"gist-share": async () => {
|
|
1805
|
+
const result = await shareSettingsGist(ctx, options, owner, options.gistApi);
|
|
1806
|
+
return result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1807
|
+
},
|
|
1808
|
+
"gist-import": async () => {
|
|
1809
|
+
const result = await importSettingsGist(
|
|
1810
|
+
ctx,
|
|
1811
|
+
options,
|
|
1812
|
+
owner,
|
|
1813
|
+
async (loaded, guardedOptions, guardedOwner) => {
|
|
1814
|
+
const applied = await reviewAndApply(ctx, guardedOptions, loaded, { kind: "import" }, guardedOwner);
|
|
1815
|
+
return applied === "edit" ? "cancel" : applied;
|
|
1816
|
+
},
|
|
1817
|
+
options.gistApi
|
|
1818
|
+
);
|
|
1819
|
+
return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1820
|
+
},
|
|
1521
1821
|
"configuration-reload": async () => {
|
|
1522
1822
|
const result = await reloadConfiguration(ctx, options, owner);
|
|
1523
1823
|
return result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
@@ -1534,7 +1834,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1534
1834
|
}
|
|
1535
1835
|
});
|
|
1536
1836
|
try {
|
|
1537
|
-
await
|
|
1837
|
+
await runMenu2(ctx, menu, {
|
|
1538
1838
|
getState: () => void 0,
|
|
1539
1839
|
signal: owner.signal,
|
|
1540
1840
|
isCurrent: owner.isCurrent
|
|
@@ -1675,7 +1975,7 @@ async function reviewAndApply(ctx, options, validated, intent, owner, skipReview
|
|
|
1675
1975
|
(width) => reviewPreviewBody(ctx, options, validated, width, intent),
|
|
1676
1976
|
[
|
|
1677
1977
|
{ value: PREVIEW_ACTIONS.continue, label: continueLabel(intent) },
|
|
1678
|
-
...intent.kind === "restore" ? [] : [
|
|
1978
|
+
...intent.kind === "restore" || intent.kind === "import" ? [] : [
|
|
1679
1979
|
{
|
|
1680
1980
|
value: PREVIEW_ACTIONS.edit,
|
|
1681
1981
|
label: intent.kind === "preset" ? "Customize before applying" : "Continue editing"
|
|
@@ -1698,7 +1998,8 @@ async function reviewAndApply(ctx, options, validated, intent, owner, skipReview
|
|
|
1698
1998
|
reviewRequired = true;
|
|
1699
1999
|
const confirmed = await ctx.ui.confirm(
|
|
1700
2000
|
confirmationTitle(intent),
|
|
1701
|
-
confirmationMessage(options.settingsPath, intent)
|
|
2001
|
+
confirmationMessage(options.settingsPath, intent),
|
|
2002
|
+
{ signal: owner.signal }
|
|
1702
2003
|
);
|
|
1703
2004
|
if (!isCurrentOwner2(owner)) return "cancel";
|
|
1704
2005
|
if (!confirmed) {
|
|
@@ -1740,6 +2041,8 @@ function reviewTitle(intent) {
|
|
|
1740
2041
|
return "Footer preview";
|
|
1741
2042
|
case "restore":
|
|
1742
2043
|
return "Restore preview";
|
|
2044
|
+
case "import":
|
|
2045
|
+
return "Gist footer preview";
|
|
1743
2046
|
case "preset":
|
|
1744
2047
|
return `${intent.preset.label} preset preview`;
|
|
1745
2048
|
}
|
|
@@ -1750,6 +2053,8 @@ function continueLabel(intent) {
|
|
|
1750
2053
|
return "Apply changes\u2026";
|
|
1751
2054
|
case "restore":
|
|
1752
2055
|
return "Replace with built-in\u2026";
|
|
2056
|
+
case "import":
|
|
2057
|
+
return "Replace with Gist settings\u2026";
|
|
1753
2058
|
case "preset":
|
|
1754
2059
|
return `Apply ${intent.preset.label} preset\u2026`;
|
|
1755
2060
|
}
|
|
@@ -1760,13 +2065,15 @@ function confirmationTitle(intent) {
|
|
|
1760
2065
|
return "Apply footer changes?";
|
|
1761
2066
|
case "restore":
|
|
1762
2067
|
return "Restore built-in footer?";
|
|
2068
|
+
case "import":
|
|
2069
|
+
return "Replace settings with Gist?";
|
|
1763
2070
|
case "preset":
|
|
1764
2071
|
return `Apply ${intent.preset.label} preset?`;
|
|
1765
2072
|
}
|
|
1766
2073
|
}
|
|
1767
2074
|
function confirmationMessage(settingsPath, intent) {
|
|
1768
2075
|
if (intent.kind === "customize") return "Save this configuration and apply it immediately?";
|
|
1769
|
-
const replacement = intent.kind === "restore" ? "the built-in configuration" : `the ${intent.preset.label} preset`;
|
|
2076
|
+
const replacement = intent.kind === "restore" ? "the built-in configuration" : intent.kind === "import" ? "the reviewed Gist settings" : `the ${intent.preset.label} preset`;
|
|
1770
2077
|
return `Replace ${safeText(settingsPath)} entirely with ${replacement}? All custom settings, unknown fields, and comments will be removed. No backup is kept after success.`;
|
|
1771
2078
|
}
|
|
1772
2079
|
function successMessage(intent) {
|
|
@@ -1775,6 +2082,8 @@ function successMessage(intent) {
|
|
|
1775
2082
|
return "Footer settings saved and applied";
|
|
1776
2083
|
case "restore":
|
|
1777
2084
|
return "Built-in footer restored and applied";
|
|
2085
|
+
case "import":
|
|
2086
|
+
return "Gist settings saved and applied";
|
|
1778
2087
|
case "preset":
|
|
1779
2088
|
return `${intent.preset.label} preset saved and applied`;
|
|
1780
2089
|
}
|
|
@@ -1808,12 +2117,12 @@ function restorePreviousConfiguration(ctx, options, previous, saved) {
|
|
|
1808
2117
|
}
|
|
1809
2118
|
function reviewPreviewBody(ctx, options, loaded, width, intent) {
|
|
1810
2119
|
if (intent.kind === "restore") return restorePreviewBody(ctx, options, loaded, width);
|
|
1811
|
-
if (intent.kind === "customize") return previewBody(ctx, options, loaded, width);
|
|
1812
|
-
const
|
|
2120
|
+
if (intent.kind === "customize" || intent.kind === "import") return previewBody(ctx, options, loaded, width);
|
|
2121
|
+
const current2 = configurationPresentation(options.getLoaded());
|
|
1813
2122
|
return [
|
|
1814
2123
|
`Preset: ${intent.preset.label}`,
|
|
1815
2124
|
`Requirement: ${intent.preset.requiresNerdFont ? "Nerd Font" : "No special font"}`,
|
|
1816
|
-
`Current: ${
|
|
2125
|
+
`Current: ${current2.state}`,
|
|
1817
2126
|
`Path: ${safeText(options.settingsPath)}`,
|
|
1818
2127
|
"Applying replaces the entire settings document, including custom settings, unknown fields, and comments.",
|
|
1819
2128
|
"No backup is kept after a successful apply.",
|
|
@@ -1822,9 +2131,9 @@ function reviewPreviewBody(ctx, options, loaded, width, intent) {
|
|
|
1822
2131
|
];
|
|
1823
2132
|
}
|
|
1824
2133
|
function restorePreviewBody(ctx, options, loaded, width) {
|
|
1825
|
-
const
|
|
2134
|
+
const current2 = configurationPresentation(options.getLoaded());
|
|
1826
2135
|
return [
|
|
1827
|
-
`Current: ${
|
|
2136
|
+
`Current: ${current2.state}`,
|
|
1828
2137
|
`Path: ${safeText(options.settingsPath)}`,
|
|
1829
2138
|
"The entire settings document will be replaced, including custom settings, unknown fields, and comments.",
|
|
1830
2139
|
"No backup is kept after a successful restore.",
|
|
@@ -1892,4 +2201,4 @@ export {
|
|
|
1892
2201
|
handleStarshipCommand,
|
|
1893
2202
|
registerStarshipCommand
|
|
1894
2203
|
};
|
|
1895
|
-
//# sourceMappingURL=commands-
|
|
2204
|
+
//# sourceMappingURL=commands-M6GHLJIR.ts.map
|