@firstpick/pi-package-webui 0.8.5 → 0.8.6
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/bin/pi-webui.mjs +375 -30
- package/index.ts +8 -1
- package/lib/git-workflow-preferences.mjs +3 -0
- package/lib/session-summary-core.mjs +4 -3
- package/lib/trust-boundaries.mjs +13 -0
- package/lib/workspace-session-summaries.mjs +400 -0
- package/package.json +2 -2
- package/public/app.js +1197 -267
- package/public/index.html +76 -3
- package/public/service-worker.js +3 -1
- package/public/stream-output-controller.mjs +327 -0
- package/public/styles.css +249 -70
- package/public/theme-contract.mjs +244 -0
- package/session-summary.ts +164 -4
- package/tests/aur-review-widget-static.test.mjs +2 -1
- package/tests/browser/interaction-continuity.spec.mjs +2 -2
- package/tests/browser/session-summary.spec.mjs +131 -3
- package/tests/browser/stream-output-isolation.spec.mjs +510 -0
- package/tests/codex-fast-mode-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +1 -1
- package/tests/fast-mode-client-static.test.mjs +2 -1
- package/tests/fixtures/fake-pi.mjs +203 -2
- package/tests/git-workflow-preferences.test.mjs +7 -1
- package/tests/guided-git-aur-review.test.mjs +4 -3
- package/tests/http-endpoints-harness.test.mjs +207 -6
- package/tests/mobile-continuity-tablet-static.test.mjs +1 -1
- package/tests/mobile-foundation-static.test.mjs +2 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +62 -29
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -3
- package/tests/persistent-ui-layout-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +1 -1
- package/tests/remote-auth-settings-harness.test.mjs +9 -0
- package/tests/session-summary-core.test.mjs +183 -1
- package/tests/side-panel-section-reorder-static.test.mjs +1 -1
- package/tests/stream-lifecycle-core.test.mjs +134 -0
- package/tests/stream-output-controller.test.mjs +252 -0
- package/tests/stream-output-isolation-static.test.mjs +89 -0
- package/tests/streaming-ui-coupling.test.mjs +50 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +104 -0
- package/tests/theme-customizer-static.test.mjs +82 -0
- package/tests/theme-scheme-mode.test.mjs +15 -0
- package/tests/workspace-session-summaries.test.mjs +288 -0
package/README.md
CHANGED
|
@@ -162,12 +162,21 @@ Successful summaries are append-only, branch-aware Pi session state. Native `/su
|
|
|
162
162
|
|
|
163
163
|
Main-agent context injection is off by default. When explicitly enabled, exactly one latest active-branch summary is added ephemerally as reference-only data; historical, display, and RPC summary messages are filtered out. Authenticated remote Web UI clients may configure and trigger summaries after the same privacy/cost confirmation. No credentials, raw transcript, or provider payload is returned through the summary HTTP APIs. To pause recurring calls without deleting prompts or prior results, turn off **Generate automatically** in setup. To roll back operationally, keep it off and use `/summary` only when needed.
|
|
164
164
|
|
|
165
|
+
#### Workspace Session Summaries and Peer Coordination
|
|
166
|
+
|
|
167
|
+
The extension exposes `/summary workspace` and the agent-facing `workspace_session_summaries` tool to discover summaries from other Pi sessions in the same canonical working directory.
|
|
168
|
+
|
|
169
|
+
- **Live Transport & Availability:** When the optional `pi-intercom` extension bus is present, connected same-CWD peers exchange summaries over namespace `firstpick/session-summary/v1` without transcript pollution or model turns. When pi-intercom is absent or disconnected, the feature falls back to read-only persisted session discovery and explicitly reports that live peer status is unavailable.
|
|
170
|
+
- **Privacy & Safety:** The shared projection never includes raw transcript entries, thinking, images, tool arguments/results, provider payloads, or session-file metadata. Before live publication and display, bounded generated-summary prose is redacted for recognized credential families, labelled secret/token values, private-key blocks, and Unix/Windows session paths. Because generated prose is free text, detection cannot prove that every semantically sensitive string is a credential; treat connected same-user, same-CWD peers as the local trust boundary and avoid placing secrets in prompts or summaries.
|
|
171
|
+
- **Coordination Semantics:** Tool output and guidelines instruct agents to compare semantic overlap across goals, files/symbols, decisions, and next steps, and to coordinate via `intercom` before performing writes when material overlap exists or ownership is unclear. Summaries never send automatic messages, apply locks, or assign ownership automatically.
|
|
172
|
+
|
|
165
173
|
Troubleshooting:
|
|
166
174
|
|
|
167
175
|
- If the configured model or authentication is unavailable, run `/login` or choose another explicitly available model in `/summary-setup`; the previous successful result is retained.
|
|
168
176
|
- A malformed or unsupported future config fails closed and is never overwritten automatically. Correct or move the private config, then rerun setup.
|
|
169
177
|
- In `--no-session` mode, generation can work in memory but is reported as non-durable.
|
|
170
178
|
- `/summary refresh` or the overlay **Refresh** action forces a bounded manual update without provider fallback.
|
|
179
|
+
- `/summary workspace` displays same-canonical-CWD workspace summaries from active live peers and persisted session files.
|
|
171
180
|
|
|
172
181
|
### Optional-feature startup audit and migration
|
|
173
182
|
|
|
@@ -255,7 +264,7 @@ Optional Natural Conversation server-side voice fallback variables:
|
|
|
255
264
|
- Model, thinking, session, workspace, theme, optional-feature, Codex usage, optional Remote WebUI, update/restart/stop, event, notification, thinking-visibility, terminal-tab-layout, and custom-background controls in collapsible side-panel sections.
|
|
256
265
|
- A side-panel **Git** section mirrors the repositories represented by every open terminal tab/group. Repository cards are shown directly—without session-name parent disclosures—and always use the Git-root or cwd basename as their title. One repository can be expanded at a time. First/stale expansion refreshes local status after a five-minute cache window, while live filesystem updates use a debounced server watcher and SSE invalidation to refresh visible repositories without periodic Git polling or an automatic network `git fetch`. Its compact Changes tree groups conflicted, staged, modified, and untracked paths with additions/deletions; right-click a repository, folder, or file (or press Shift+F10/the Context Menu key) for View Diff, refresh, stage/unstage, and confirmed discard/delete actions. History lists the latest 30 commits and opens bounded read-only commit diffs.
|
|
257
266
|
- Persistent context-window meter with manual compact and auto-compaction controls near the composer; side-panel thinking changes made while a tab is busy are queued for the next prompt.
|
|
258
|
-
- Side-panel theme picker backed by optional `@firstpick/pi-themes-bundle` themes
|
|
267
|
+
- Side-panel theme picker backed by optional `@firstpick/pi-themes-bundle` themes plus Pi-native project/global custom themes. **Customize…** provides all 51 required color tokens, variables, optional `thinkingMax`/export colors, synchronized advanced JSON, valid-only live preview, scope badges, and explicit target-bound overwrite confirmation.
|
|
259
268
|
- Per-tab cwd changes, a clickable footer cwd picker, directory creation/search in the picker, saved path fast picks, server-persisted fast picks, and restart-safe restoration of open tabs. When the optional stats and git-footer companions are loaded, clicking the footer **PI** token metric dispatches `/calibrate` in the background and refreshes the metric after the isolated calibration sample is recorded.
|
|
260
269
|
- Detected app runner dropdown for the active tab cwd, including Cargo, Bun, npm/npx/pnpm, Python/uv, Go/Golang, Zig, C/C++, Docker Compose, root/dev/scripts shell scripts, and other common project runners with live output pinned at the top of the terminal. Running app runners expose line-oriented stdin in the widget for interactive scripts. Projects can add browseable custom runners in `.pi-webui-runners.json` with a command (default `./`) plus a relative path to the file to run. The same dialog also configures project discovery paths: project-relative directories that are scanned one level deep (no subdirectories) for `.sh`, `.bash`, `.zsh`, `.fish`, and `.py` files plus extensionless files with a bash/sh, zsh, fish, or Python shebang. Python candidates use `uv run` and/or the available `python3`/`python` interpreter. Discovered scripts extend the built-in root, `dev/`, `scripts/`, and `dev/scripts/` detection and run from the resolved project root.
|
|
261
270
|
- Guided Git workflow for existing repos and new repos with persistent model/reasoning preferences, review-first staging, an optional manual staged repository-review gate from `aur-review`, generated or typed commit messages, explicit push/PR confirmation, and optional PR worktrees. When the review extension is loaded/enabled, both `git add .` and accepting the current staged set send `/aur-review start --scope staged --origin guided-git` to the same tab. Only its matching approval advances to message generation. The browser and server recheck the approved domain-separated staged-content hash before message generation, commit, and PR-worktree transfer; drift, missing hashes, or hash-check errors return to Stage and require a new review. A decline returns to staging and rejects an unchanged declined staged hash until corrected content is restaged. Guided Git never stages, commits, or pushes remediation automatically. The extension remains the decision authority; direct API callers are not granted an approval by this browser workflow.
|
|
@@ -264,6 +273,19 @@ Optional Natural Conversation server-side voice fallback variables:
|
|
|
264
273
|
- Feedback reactions (`👍`, `👎`, `?`) on final assistant output plus tool/bash action cards, which can ask Pi to create or update a LEARNING.
|
|
265
274
|
- Mobile-friendly layout, PWA install support where the browser allows it, backend-offline recovery, and a dedicated server-restart overlay while confirmed restart/update actions run.
|
|
266
275
|
|
|
276
|
+
### Custom themes
|
|
277
|
+
|
|
278
|
+
Open **Controls → Interface → Theme → Customize…** to start from the current browser theme. The responsive dialog exposes visual controls for Pi’s exact 51 required theme tokens and optional `thinkingMax`, variables, export colors, and advanced JSON. Valid edits stay synchronized and preview immediately; malformed JSON, invalid values, missing variables, and cycles remain editable but do not replace the last valid preview and cannot be saved.
|
|
279
|
+
|
|
280
|
+
Preview is temporary: it does not write local storage, a theme file, Pi settings, or the browser’s Light/Dark slots. **Cancel** (including Escape) restores the opening WebUI theme, scheme presentation, meta color, and that theme’s custom background. **Reset draft** returns to the initial editor draft without changing saved settings. Light, Dark, and Auto continue to behave exactly as the normal theme picker defines them; only an explicit normal picker choice uses the existing persistent selection path.
|
|
281
|
+
|
|
282
|
+
Save destinations are server-derived:
|
|
283
|
+
|
|
284
|
+
- **This project** writes `<active trusted cwd>/.pi/themes/<name>.json` and is disabled unless Pi has a saved trusted-project decision for that active tab.
|
|
285
|
+
- **Global themes** writes `<PI_CODING_AGENT_DIR>/themes/<name>.json` (normally `~/.pi/agent/themes/<name>.json`).
|
|
286
|
+
|
|
287
|
+
An existing same-scope target requires a second confirmation naming the exact scope and file. Changing the draft, name, or destination invalidates that confirmation; a changed-on-disk file is not overwritten from stale confirmation. Bundled and opposite-scope name collisions are rejected. Saving refreshes the WebUI catalog and adds a **Project** or **Global** badge, but deliberately does not select the theme or mutate Pi/browser settings. To use the file in Pi TUI, run `/reload` or restart Pi, then choose the custom theme with `/theme`; no disruptive reload is triggered automatically.
|
|
288
|
+
|
|
267
289
|
## Native Pi command coverage
|
|
268
290
|
|
|
269
291
|
Web UI keeps a packaged parity matrix at `lib/WEBUI_TUI_NATIVE_PARITY.json` and exposes it at `GET /api/native-parity`.
|
package/bin/pi-webui.mjs
CHANGED
|
@@ -12,6 +12,14 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
12
12
|
import { promisify } from "node:util";
|
|
13
13
|
import { brotliCompress, constants as zlibConstants, gzip } from "node:zlib";
|
|
14
14
|
import { SessionManager, SettingsManager, DefaultPackageManager } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import {
|
|
16
|
+
ThemeContractError,
|
|
17
|
+
canonicalizeTheme,
|
|
18
|
+
normalizeThemeFileName,
|
|
19
|
+
serializeTheme,
|
|
20
|
+
themeNameFromFileName,
|
|
21
|
+
validateTheme,
|
|
22
|
+
} from "../public/theme-contract.mjs";
|
|
15
23
|
import { authProvidersPayload, createAuthContext, logoutStoredProvider } from "../lib/auth-actions.mjs";
|
|
16
24
|
import { resolveCodexUsageAuth } from "../lib/codex-usage-auth.mjs";
|
|
17
25
|
import { resolveScopedModelsFromPatterns } from "../lib/scoped-models.mjs";
|
|
@@ -105,6 +113,7 @@ import {
|
|
|
105
113
|
evaluateDispatchTrustGuards,
|
|
106
114
|
guardsForNativeCommand,
|
|
107
115
|
isLocalRequest,
|
|
116
|
+
projectTrustDecision,
|
|
108
117
|
remoteShellTrustWarning,
|
|
109
118
|
requireLocalhost,
|
|
110
119
|
requireLocalhostRoute,
|
|
@@ -199,6 +208,7 @@ const CLAUDE_USAGE_OUTPUT_MAX_CHARS = 60_000;
|
|
|
199
208
|
const CLAUDE_USAGE_COMMAND = process.env.PI_WEBUI_CLAUDE_BIN || "claude";
|
|
200
209
|
const CLAUDE_USAGE_ARGS = ["--safe-mode", "--no-session-persistence", "-p", "/usage", "--output-format", "json"];
|
|
201
210
|
const BODY_LIMIT_BYTES = 1024 * 1024;
|
|
211
|
+
const CUSTOM_THEME_BODY_LIMIT_BYTES = 256 * 1024;
|
|
202
212
|
const SESSION_SUMMARY_REQUEST_MAX_BYTES = 32 * 1024;
|
|
203
213
|
const SESSION_SUMMARY_RPC_TYPE = "firstpick:session-summary-rpc";
|
|
204
214
|
const SESSION_SUMMARY_DISPLAY_TYPE = "firstpick:session-summary-display";
|
|
@@ -1114,6 +1124,9 @@ function makeHttpError(statusCode, message) {
|
|
|
1114
1124
|
function sendError(res, statusCode, error) {
|
|
1115
1125
|
const message = statusCode >= 500 ? sanitizeError(error) : formatCliError(error);
|
|
1116
1126
|
const payload = { ok: false, error: message };
|
|
1127
|
+
const isThemeError = typeof error?.code === "string" && error.code.startsWith("THEME_");
|
|
1128
|
+
if (isThemeError) payload.code = error.code;
|
|
1129
|
+
if (isThemeError && error?.details && typeof error.details === "object") payload.details = error.details;
|
|
1117
1130
|
if (error?.optionalFeatureInstall) payload.optionalFeatureInstall = error.optionalFeatureInstall;
|
|
1118
1131
|
sendJson(res, statusCode, payload);
|
|
1119
1132
|
}
|
|
@@ -2736,6 +2749,11 @@ function requireGitWorkflowChoice(value, key, choices) {
|
|
|
2736
2749
|
return text;
|
|
2737
2750
|
}
|
|
2738
2751
|
|
|
2752
|
+
function requireGitWorkflowBoolean(value, key) {
|
|
2753
|
+
if (typeof value !== "boolean") throw makeHttpError(400, `${key} must be a boolean`);
|
|
2754
|
+
return value;
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2739
2757
|
async function saveGitWorkflowPreferencesData(tab, body = {}) {
|
|
2740
2758
|
const submitted = body.preferences && typeof body.preferences === "object" ? body.preferences : body;
|
|
2741
2759
|
if (submitted.generation?.thinkingLevel !== undefined) requireGitWorkflowChoice(submitted.generation.thinkingLevel, "generation.thinkingLevel", GIT_WORKFLOW_THINKING_LEVELS);
|
|
@@ -2743,6 +2761,7 @@ async function saveGitWorkflowPreferencesData(tab, body = {}) {
|
|
|
2743
2761
|
if (submitted.commit?.defaultVariant !== undefined) requireGitWorkflowChoice(submitted.commit.defaultVariant, "commit.defaultVariant", GIT_WORKFLOW_DEFAULT_VARIANTS);
|
|
2744
2762
|
if (submitted.commit?.scope !== undefined) requireGitWorkflowChoice(submitted.commit.scope, "commit.scope", GIT_WORKFLOW_SCOPE_POLICIES);
|
|
2745
2763
|
if (submitted.stagingPolicy !== undefined) requireGitWorkflowChoice(submitted.stagingPolicy, "stagingPolicy", GIT_WORKFLOW_STAGING_POLICIES);
|
|
2764
|
+
if (submitted.reviewProcessEnabled !== undefined) requireGitWorkflowBoolean(submitted.reviewProcessEnabled, "reviewProcessEnabled");
|
|
2746
2765
|
if (submitted.deliveryMode !== undefined) requireGitWorkflowChoice(submitted.deliveryMode, "deliveryMode", GIT_WORKFLOW_DELIVERY_MODES);
|
|
2747
2766
|
if (submitted.verificationPolicy !== undefined) requireGitWorkflowChoice(submitted.verificationPolicy, "verificationPolicy", GIT_WORKFLOW_VERIFICATION_POLICIES);
|
|
2748
2767
|
|
|
@@ -6234,9 +6253,12 @@ async function readGitIncomingChanges(root, summary) {
|
|
|
6234
6253
|
}
|
|
6235
6254
|
}
|
|
6236
6255
|
|
|
6237
|
-
async function pullGitChanges(cwd) {
|
|
6256
|
+
async function pullGitChanges(cwd, { remote } = {}) {
|
|
6238
6257
|
const root = await getGitRoot(cwd);
|
|
6239
|
-
const
|
|
6258
|
+
const pullArgs = ["pull", "--ff-only"];
|
|
6259
|
+
if (remote === "origin") pullArgs.push("origin");
|
|
6260
|
+
else if (remote) throw new Error(`Unsupported Git pull remote: ${String(remote)}`);
|
|
6261
|
+
const payload = await runGuardedGitMutation(pullArgs, { cwd: root, timeoutMs: GIT_PULL_TIMEOUT_MS });
|
|
6240
6262
|
if (payload.data) payload.data.root = root;
|
|
6241
6263
|
if (payload.ok) payload.data.changes = await readGitChanges(root);
|
|
6242
6264
|
else {
|
|
@@ -8290,15 +8312,6 @@ function themeLabel(name) {
|
|
|
8290
8312
|
.join(" ");
|
|
8291
8313
|
}
|
|
8292
8314
|
|
|
8293
|
-
function stringRecord(value) {
|
|
8294
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
8295
|
-
const record = {};
|
|
8296
|
-
for (const [key, item] of Object.entries(value)) {
|
|
8297
|
-
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") record[key] = String(item);
|
|
8298
|
-
}
|
|
8299
|
-
return record;
|
|
8300
|
-
}
|
|
8301
|
-
|
|
8302
8315
|
async function directoryExists(dir) {
|
|
8303
8316
|
try {
|
|
8304
8317
|
const info = await stat(dir);
|
|
@@ -8309,7 +8322,9 @@ async function directoryExists(dir) {
|
|
|
8309
8322
|
}
|
|
8310
8323
|
|
|
8311
8324
|
async function resolveBundledThemesDir() {
|
|
8312
|
-
|
|
8325
|
+
// Pi-managed packages are the user's canonical installation. Prefer them to
|
|
8326
|
+
// any duplicate that happens to be visible from the WebUI's npm prefix.
|
|
8327
|
+
const candidates = [path.join(configuredAgentNpmRoot(), "node_modules", "@firstpick", "pi-themes-bundle", "themes")];
|
|
8313
8328
|
try {
|
|
8314
8329
|
const manifestPath = require.resolve("@firstpick/pi-themes-bundle/package.json");
|
|
8315
8330
|
const root = path.dirname(manifestPath);
|
|
@@ -8319,8 +8334,9 @@ async function resolveBundledThemesDir() {
|
|
|
8319
8334
|
if (typeof entry === "string" && entry.trim()) candidates.push(path.resolve(root, entry));
|
|
8320
8335
|
}
|
|
8321
8336
|
} catch {
|
|
8322
|
-
//
|
|
8337
|
+
// The bundle may live outside this package's Node resolution tree.
|
|
8323
8338
|
}
|
|
8339
|
+
// In repo development the bundle may be a sibling package instead.
|
|
8324
8340
|
candidates.push(path.resolve(packageRoot, "..", "pi-package-themes-bundle", "themes"));
|
|
8325
8341
|
|
|
8326
8342
|
for (const candidate of candidates) {
|
|
@@ -8329,39 +8345,350 @@ async function resolveBundledThemesDir() {
|
|
|
8329
8345
|
return null;
|
|
8330
8346
|
}
|
|
8331
8347
|
|
|
8332
|
-
function
|
|
8333
|
-
const
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8348
|
+
function themeHttpError(statusCode, code, message, details) {
|
|
8349
|
+
const error = makeHttpError(statusCode, message);
|
|
8350
|
+
error.code = code;
|
|
8351
|
+
if (details) error.details = details;
|
|
8352
|
+
return error;
|
|
8353
|
+
}
|
|
8354
|
+
|
|
8355
|
+
function catalogTheme(theme, fileName, scope) {
|
|
8356
|
+
const validation = validateTheme(theme, { allowWebuiExport: scope === "bundled" });
|
|
8357
|
+
if (!validation.ok) throw new ThemeContractError("Theme does not satisfy the installed Pi theme contract", validation.issues);
|
|
8358
|
+
const native = canonicalizeTheme(theme, { allowWebuiExport: scope === "bundled" });
|
|
8359
|
+
if (scope === "bundled" && theme.export) {
|
|
8360
|
+
native.export = { ...(native.export || {}) };
|
|
8361
|
+
for (const [key, value] of Object.entries(theme.export)) {
|
|
8362
|
+
if (typeof value === "string" && !Object.hasOwn(native.export, key)) native.export[key] = value;
|
|
8363
|
+
}
|
|
8364
|
+
}
|
|
8365
|
+
const entry = {
|
|
8366
|
+
name: native.name,
|
|
8367
|
+
label: themeLabel(native.name),
|
|
8368
|
+
vars: native.vars || {},
|
|
8369
|
+
colors: native.colors,
|
|
8370
|
+
export: native.export || {},
|
|
8371
|
+
scope,
|
|
8372
|
+
custom: scope !== "bundled",
|
|
8340
8373
|
};
|
|
8374
|
+
if (scope !== "bundled") entry.fileName = fileName;
|
|
8375
|
+
return entry;
|
|
8376
|
+
}
|
|
8377
|
+
|
|
8378
|
+
function themePathInside(root, candidate) {
|
|
8379
|
+
const relative = path.relative(root, candidate);
|
|
8380
|
+
return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative));
|
|
8381
|
+
}
|
|
8382
|
+
|
|
8383
|
+
async function existingThemeRoot(baseDir, segments) {
|
|
8384
|
+
let root;
|
|
8385
|
+
try {
|
|
8386
|
+
root = await realpath(baseDir);
|
|
8387
|
+
} catch {
|
|
8388
|
+
return null;
|
|
8389
|
+
}
|
|
8390
|
+
const confinementRoot = root;
|
|
8391
|
+
for (const segment of segments) {
|
|
8392
|
+
const candidate = path.join(root, segment);
|
|
8393
|
+
let info;
|
|
8394
|
+
try {
|
|
8395
|
+
info = await lstat(candidate);
|
|
8396
|
+
} catch (error) {
|
|
8397
|
+
if (error?.code === "ENOENT") return null;
|
|
8398
|
+
throw error;
|
|
8399
|
+
}
|
|
8400
|
+
if (info.isSymbolicLink() || !info.isDirectory()) return null;
|
|
8401
|
+
root = await realpath(candidate);
|
|
8402
|
+
if (!themePathInside(confinementRoot, root)) return null;
|
|
8403
|
+
}
|
|
8404
|
+
return root;
|
|
8405
|
+
}
|
|
8406
|
+
|
|
8407
|
+
async function ensureThemeRoot(baseDir, segments) {
|
|
8408
|
+
await mkdir(baseDir, { recursive: true, mode: 0o700 });
|
|
8409
|
+
const baseInfo = await stat(baseDir);
|
|
8410
|
+
if (!baseInfo.isDirectory()) throw themeHttpError(409, "THEME_UNSAFE_TARGET", "The server-derived theme base is not a directory.");
|
|
8411
|
+
let root = await realpath(baseDir);
|
|
8412
|
+
const confinementRoot = root;
|
|
8413
|
+
for (const segment of segments) {
|
|
8414
|
+
const candidate = path.join(root, segment);
|
|
8415
|
+
try {
|
|
8416
|
+
await mkdir(candidate, { mode: 0o700 });
|
|
8417
|
+
} catch (error) {
|
|
8418
|
+
if (error?.code !== "EEXIST") throw error;
|
|
8419
|
+
}
|
|
8420
|
+
const info = await lstat(candidate);
|
|
8421
|
+
if (info.isSymbolicLink() || !info.isDirectory()) {
|
|
8422
|
+
throw themeHttpError(409, "THEME_UNSAFE_TARGET", "The server-derived theme directory contains a symlink or non-directory component.");
|
|
8423
|
+
}
|
|
8424
|
+
root = await realpath(candidate);
|
|
8425
|
+
if (!themePathInside(confinementRoot, root)) {
|
|
8426
|
+
throw themeHttpError(409, "THEME_UNSAFE_TARGET", "The server-derived theme directory escapes its allowed root.");
|
|
8427
|
+
}
|
|
8428
|
+
}
|
|
8429
|
+
return root;
|
|
8430
|
+
}
|
|
8431
|
+
|
|
8432
|
+
async function readThemeDirectory(baseDir, segments, scope) {
|
|
8433
|
+
const root = await existingThemeRoot(baseDir, segments);
|
|
8434
|
+
if (!root) return [];
|
|
8435
|
+
const entries = [];
|
|
8436
|
+
let files;
|
|
8437
|
+
try {
|
|
8438
|
+
files = await readdir(root);
|
|
8439
|
+
} catch {
|
|
8440
|
+
return [];
|
|
8441
|
+
}
|
|
8442
|
+
for (const fileName of files.filter((name) => name.endsWith(".json")).sort((a, b) => a.localeCompare(b))) {
|
|
8443
|
+
try {
|
|
8444
|
+
const target = path.join(root, fileName);
|
|
8445
|
+
const info = await lstat(target);
|
|
8446
|
+
if (info.isSymbolicLink() || !info.isFile()) continue;
|
|
8447
|
+
const resolved = await realpath(target);
|
|
8448
|
+
if (!themePathInside(root, resolved)) continue;
|
|
8449
|
+
entries.push(catalogTheme(JSON.parse(await readFile(resolved, "utf8")), fileName, scope));
|
|
8450
|
+
} catch (error) {
|
|
8451
|
+
console.error(`Skipping invalid ${scope} theme ${fileName}: ${sanitizeError(error)}`);
|
|
8452
|
+
}
|
|
8453
|
+
}
|
|
8454
|
+
return entries.sort((a, b) => a.label.localeCompare(b.label) || a.fileName.localeCompare(b.fileName));
|
|
8341
8455
|
}
|
|
8342
8456
|
|
|
8343
8457
|
async function readBundledThemes() {
|
|
8344
8458
|
const dir = await resolveBundledThemesDir();
|
|
8345
8459
|
if (!dir) return { source: "@firstpick/pi-themes-bundle", themes: [] };
|
|
8346
|
-
|
|
8347
|
-
const files = (await readdir(dir)).filter((file) => file.endsWith(".json")).sort((a, b) => a.localeCompare(b));
|
|
8348
8460
|
const themes = [];
|
|
8349
|
-
for (const
|
|
8461
|
+
for (const fileName of (await readdir(dir)).filter((file) => file.endsWith(".json")).sort((a, b) => a.localeCompare(b))) {
|
|
8350
8462
|
try {
|
|
8351
|
-
const
|
|
8352
|
-
|
|
8463
|
+
const target = path.join(dir, fileName);
|
|
8464
|
+
const info = await lstat(target);
|
|
8465
|
+
if (info.isSymbolicLink() || !info.isFile()) continue;
|
|
8466
|
+
themes.push(catalogTheme(JSON.parse(await readFile(target, "utf8")), fileName, "bundled"));
|
|
8353
8467
|
} catch (error) {
|
|
8354
|
-
console.error(`Skipping invalid theme ${
|
|
8468
|
+
console.error(`Skipping invalid bundled theme ${fileName}: ${sanitizeError(error)}`);
|
|
8355
8469
|
}
|
|
8356
8470
|
}
|
|
8357
8471
|
themes.sort((a, b) => a.label.localeCompare(b.label));
|
|
8358
8472
|
return { source: "@firstpick/pi-themes-bundle", themes };
|
|
8359
8473
|
}
|
|
8360
8474
|
|
|
8475
|
+
function customThemeRoots(tab) {
|
|
8476
|
+
const projectTrusted = !!tab && projectTrustDecision(tab.cwd, agentDir);
|
|
8477
|
+
return {
|
|
8478
|
+
global: { baseDir: agentDir, segments: ["themes"] },
|
|
8479
|
+
project: { baseDir: tab?.cwd, segments: [".pi", "themes"], trusted: projectTrusted },
|
|
8480
|
+
};
|
|
8481
|
+
}
|
|
8482
|
+
|
|
8483
|
+
async function readThemeCatalog(tab) {
|
|
8484
|
+
const bundled = await readBundledThemes();
|
|
8485
|
+
const roots = customThemeRoots(tab);
|
|
8486
|
+
const globalThemes = await readThemeDirectory(roots.global.baseDir, roots.global.segments, "global");
|
|
8487
|
+
const projectThemes = roots.project.trusted
|
|
8488
|
+
? await readThemeDirectory(roots.project.baseDir, roots.project.segments, "project")
|
|
8489
|
+
: [];
|
|
8490
|
+
const themes = [];
|
|
8491
|
+
const names = new Map();
|
|
8492
|
+
const collisions = [];
|
|
8493
|
+
for (const entry of [...bundled.themes, ...globalThemes, ...projectThemes]) {
|
|
8494
|
+
const previous = names.get(entry.name);
|
|
8495
|
+
if (previous) {
|
|
8496
|
+
collisions.push({ name: entry.name, keptScope: previous.scope, skippedScope: entry.scope });
|
|
8497
|
+
continue;
|
|
8498
|
+
}
|
|
8499
|
+
names.set(entry.name, entry);
|
|
8500
|
+
themes.push(entry);
|
|
8501
|
+
}
|
|
8502
|
+
return {
|
|
8503
|
+
source: bundled.source,
|
|
8504
|
+
themes,
|
|
8505
|
+
collisions,
|
|
8506
|
+
scopes: {
|
|
8507
|
+
global: { available: true },
|
|
8508
|
+
project: { available: !!tab, trusted: roots.project.trusted },
|
|
8509
|
+
},
|
|
8510
|
+
};
|
|
8511
|
+
}
|
|
8512
|
+
|
|
8513
|
+
function requireCustomThemeJsonRequest(req) {
|
|
8514
|
+
const contentType = String(req.headers["content-type"] || "").split(";", 1)[0].trim().toLowerCase();
|
|
8515
|
+
if (contentType !== "application/json") throw themeHttpError(415, "THEME_JSON_REQUIRED", "Custom theme saves require Content-Type: application/json.");
|
|
8516
|
+
const fetchSite = String(req.headers["sec-fetch-site"] || "").trim().toLowerCase();
|
|
8517
|
+
if (fetchSite && !["same-origin", "same-site", "none"].includes(fetchSite)) {
|
|
8518
|
+
throw themeHttpError(403, "THEME_CROSS_SITE_BLOCKED", "Cross-site custom theme saves are blocked.");
|
|
8519
|
+
}
|
|
8520
|
+
}
|
|
8521
|
+
|
|
8522
|
+
function validateCustomThemeSaveBody(body) {
|
|
8523
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
8524
|
+
throw themeHttpError(400, "THEME_REQUEST_INVALID", "Custom theme save body must be an object.");
|
|
8525
|
+
}
|
|
8526
|
+
const allowed = new Set(["scope", "fileName", "theme", "overwrite", "expectedMtimeMs"]);
|
|
8527
|
+
const unknown = Object.keys(body).filter((key) => !allowed.has(key));
|
|
8528
|
+
if (unknown.length) throw themeHttpError(400, "THEME_REQUEST_INVALID", `Unsupported custom theme save field${unknown.length === 1 ? "" : "s"}: ${unknown.join(", ")}.`);
|
|
8529
|
+
if (body.scope !== "global" && body.scope !== "project") throw themeHttpError(400, "THEME_SCOPE_INVALID", "scope must be global or project.");
|
|
8530
|
+
let fileName;
|
|
8531
|
+
let theme;
|
|
8532
|
+
try {
|
|
8533
|
+
fileName = normalizeThemeFileName(body.fileName);
|
|
8534
|
+
theme = canonicalizeTheme(body.theme, { allowWebuiExport: true });
|
|
8535
|
+
} catch (error) {
|
|
8536
|
+
if (error instanceof ThemeContractError) throw themeHttpError(400, "THEME_INVALID", error.message, { issues: error.issues || [] });
|
|
8537
|
+
throw error;
|
|
8538
|
+
}
|
|
8539
|
+
if (theme.name !== themeNameFromFileName(fileName)) {
|
|
8540
|
+
throw themeHttpError(400, "THEME_NAME_MISMATCH", "Theme name must exactly match fileName without the .json suffix.");
|
|
8541
|
+
}
|
|
8542
|
+
if (typeof body.overwrite !== "boolean") throw themeHttpError(400, "THEME_REQUEST_INVALID", "overwrite must be a boolean.");
|
|
8543
|
+
if (body.expectedMtimeMs !== null && (typeof body.expectedMtimeMs !== "number" || !Number.isFinite(body.expectedMtimeMs) || body.expectedMtimeMs < 0)) {
|
|
8544
|
+
throw themeHttpError(400, "THEME_REQUEST_INVALID", "expectedMtimeMs must be a non-negative number or null.");
|
|
8545
|
+
}
|
|
8546
|
+
if (!body.overwrite && body.expectedMtimeMs !== null) {
|
|
8547
|
+
throw themeHttpError(400, "THEME_REQUEST_INVALID", "expectedMtimeMs must be null until overwrite is explicitly confirmed.");
|
|
8548
|
+
}
|
|
8549
|
+
if (body.overwrite && body.expectedMtimeMs === null) {
|
|
8550
|
+
throw themeHttpError(400, "THEME_REQUEST_INVALID", "An overwrite requires the target mtime returned by THEME_EXISTS.");
|
|
8551
|
+
}
|
|
8552
|
+
return { scope: body.scope, fileName, theme, overwrite: body.overwrite, expectedMtimeMs: body.expectedMtimeMs };
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
async function customThemeCollision(request, tab) {
|
|
8556
|
+
const bundled = await readBundledThemes();
|
|
8557
|
+
if (bundled.themes.some(({ name }) => name === request.theme.name)) return { scope: "bundled" };
|
|
8558
|
+
const roots = customThemeRoots(tab);
|
|
8559
|
+
for (const scope of ["global", "project"]) {
|
|
8560
|
+
if (scope === "project" && !roots.project.trusted) continue;
|
|
8561
|
+
const root = roots[scope];
|
|
8562
|
+
const entries = await readThemeDirectory(root.baseDir, root.segments, scope);
|
|
8563
|
+
for (const entry of entries) {
|
|
8564
|
+
if (entry.name !== request.theme.name) continue;
|
|
8565
|
+
if (scope === request.scope && entry.fileName === request.fileName) continue;
|
|
8566
|
+
if (scope === request.scope) {
|
|
8567
|
+
const directory = await existingThemeRoot(root.baseDir, root.segments);
|
|
8568
|
+
if (directory) {
|
|
8569
|
+
try {
|
|
8570
|
+
const [existingPath, requestedPath] = await Promise.all([
|
|
8571
|
+
realpath(path.join(directory, entry.fileName)),
|
|
8572
|
+
realpath(path.join(directory, request.fileName)),
|
|
8573
|
+
]);
|
|
8574
|
+
if (existingPath === requestedPath) continue;
|
|
8575
|
+
} catch {
|
|
8576
|
+
// A missing differently-cased path is a real collision on a case-sensitive filesystem.
|
|
8577
|
+
}
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
return { scope, fileName: entry.fileName };
|
|
8581
|
+
}
|
|
8582
|
+
}
|
|
8583
|
+
return null;
|
|
8584
|
+
}
|
|
8585
|
+
|
|
8586
|
+
let customThemeMutationQueue = Promise.resolve();
|
|
8587
|
+
|
|
8588
|
+
function queueCustomThemeMutation(operation) {
|
|
8589
|
+
const result = customThemeMutationQueue.catch(() => {}).then(operation);
|
|
8590
|
+
customThemeMutationQueue = result.catch(() => {});
|
|
8591
|
+
return result;
|
|
8592
|
+
}
|
|
8593
|
+
|
|
8594
|
+
async function saveCustomTheme(tab, request) {
|
|
8595
|
+
return queueCustomThemeMutation(async () => {
|
|
8596
|
+
const roots = customThemeRoots(tab);
|
|
8597
|
+
if (request.scope === "project" && !roots.project.trusted) {
|
|
8598
|
+
throw themeHttpError(403, "THEME_PROJECT_UNTRUSTED", "Project theme saves require a saved trusted-project decision in Pi.");
|
|
8599
|
+
}
|
|
8600
|
+
const collision = await customThemeCollision(request, tab);
|
|
8601
|
+
if (collision) {
|
|
8602
|
+
throw themeHttpError(409, "THEME_NAME_COLLISION", "A bundled or opposite-scope theme already uses this name.", {
|
|
8603
|
+
scope: collision.scope,
|
|
8604
|
+
...(collision.fileName ? { fileName: collision.fileName } : {}),
|
|
8605
|
+
});
|
|
8606
|
+
}
|
|
8607
|
+
const selected = roots[request.scope];
|
|
8608
|
+
const root = await ensureThemeRoot(selected.baseDir, selected.segments);
|
|
8609
|
+
const target = path.join(root, request.fileName);
|
|
8610
|
+
if (!themePathInside(root, target)) throw themeHttpError(409, "THEME_UNSAFE_TARGET", "Theme target escapes its server-derived root.");
|
|
8611
|
+
|
|
8612
|
+
let before = null;
|
|
8613
|
+
try {
|
|
8614
|
+
before = await lstat(target);
|
|
8615
|
+
} catch (error) {
|
|
8616
|
+
if (error?.code !== "ENOENT") throw error;
|
|
8617
|
+
}
|
|
8618
|
+
if (before?.isSymbolicLink() || (before && !before.isFile())) {
|
|
8619
|
+
throw themeHttpError(409, "THEME_UNSAFE_TARGET", "The theme target is a symlink or non-file entry.");
|
|
8620
|
+
}
|
|
8621
|
+
if (before && !request.overwrite) {
|
|
8622
|
+
throw themeHttpError(409, "THEME_EXISTS", "The custom theme already exists and requires explicit overwrite confirmation.", {
|
|
8623
|
+
scope: request.scope,
|
|
8624
|
+
fileName: request.fileName,
|
|
8625
|
+
mtimeMs: before.mtimeMs,
|
|
8626
|
+
});
|
|
8627
|
+
}
|
|
8628
|
+
if ((!before && request.overwrite) || (before && before.mtimeMs !== request.expectedMtimeMs)) {
|
|
8629
|
+
throw themeHttpError(409, "THEME_CHANGED", "The custom theme changed after overwrite confirmation.", {
|
|
8630
|
+
scope: request.scope,
|
|
8631
|
+
fileName: request.fileName,
|
|
8632
|
+
...(before ? { mtimeMs: before.mtimeMs } : {}),
|
|
8633
|
+
});
|
|
8634
|
+
}
|
|
8635
|
+
|
|
8636
|
+
const bytes = serializeTheme(request.theme, { allowWebuiExport: false });
|
|
8637
|
+
const temp = path.join(root, `.${request.fileName}.${randomUUID()}.tmp`);
|
|
8638
|
+
let handle;
|
|
8639
|
+
try {
|
|
8640
|
+
handle = await open(temp, "wx", 0o600);
|
|
8641
|
+
await handle.writeFile(bytes, "utf8");
|
|
8642
|
+
await handle.sync();
|
|
8643
|
+
await handle.close();
|
|
8644
|
+
handle = undefined;
|
|
8645
|
+
|
|
8646
|
+
const verifiedRoot = await existingThemeRoot(selected.baseDir, selected.segments);
|
|
8647
|
+
if (verifiedRoot !== root) throw themeHttpError(409, "THEME_UNSAFE_TARGET", "Theme directory changed during save.");
|
|
8648
|
+
let finalState = null;
|
|
8649
|
+
try {
|
|
8650
|
+
finalState = await lstat(target);
|
|
8651
|
+
} catch (error) {
|
|
8652
|
+
if (error?.code !== "ENOENT") throw error;
|
|
8653
|
+
}
|
|
8654
|
+
if (finalState?.isSymbolicLink() || (finalState && !finalState.isFile())) {
|
|
8655
|
+
throw themeHttpError(409, "THEME_UNSAFE_TARGET", "The theme target changed to an unsafe entry during save.");
|
|
8656
|
+
}
|
|
8657
|
+
if ((before && (!finalState || finalState.mtimeMs !== request.expectedMtimeMs)) || (!before && finalState)) {
|
|
8658
|
+
throw themeHttpError(409, "THEME_CHANGED", "The custom theme changed during save.", {
|
|
8659
|
+
scope: request.scope,
|
|
8660
|
+
fileName: request.fileName,
|
|
8661
|
+
...(finalState ? { mtimeMs: finalState.mtimeMs } : {}),
|
|
8662
|
+
});
|
|
8663
|
+
}
|
|
8664
|
+
await rename(temp, target);
|
|
8665
|
+
} finally {
|
|
8666
|
+
await handle?.close().catch(() => {});
|
|
8667
|
+
await rm(temp, { force: true }).catch(() => {});
|
|
8668
|
+
}
|
|
8669
|
+
const saved = await stat(target);
|
|
8670
|
+
return {
|
|
8671
|
+
scope: request.scope,
|
|
8672
|
+
fileName: request.fileName,
|
|
8673
|
+
themeName: request.theme.name,
|
|
8674
|
+
created: !before,
|
|
8675
|
+
overwritten: !!before,
|
|
8676
|
+
mtimeMs: saved.mtimeMs,
|
|
8677
|
+
reloadRequired: true,
|
|
8678
|
+
};
|
|
8679
|
+
});
|
|
8680
|
+
}
|
|
8681
|
+
|
|
8682
|
+
const STATIC_PUBLIC_FILE_EXTENSIONS = new Set([".html", ".css", ".js", ".mjs", ".svg", ".png", ".webp", ".webmanifest"]);
|
|
8683
|
+
|
|
8361
8684
|
function normalizeStaticPath(urlPath) {
|
|
8362
8685
|
if (urlPath === "/") return "index.html";
|
|
8363
8686
|
const name = urlPath.startsWith("/") ? urlPath.slice(1) : urlPath;
|
|
8364
|
-
|
|
8687
|
+
// public/ is the package's explicit browser-asset boundary. Accept any safe,
|
|
8688
|
+
// flat asset name from it so a newly imported module cannot outrun a second
|
|
8689
|
+
// manually maintained server allowlist during an in-place package update.
|
|
8690
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name)) return undefined;
|
|
8691
|
+
if (!STATIC_PUBLIC_FILE_EXTENSIONS.has(path.extname(name))) return undefined;
|
|
8365
8692
|
return name;
|
|
8366
8693
|
}
|
|
8367
8694
|
|
|
@@ -15188,7 +15515,25 @@ const server = createServer(async (req, res) => {
|
|
|
15188
15515
|
}
|
|
15189
15516
|
|
|
15190
15517
|
if (url.pathname === "/api/themes" && req.method === "GET") {
|
|
15191
|
-
|
|
15518
|
+
const tab = tabs.size ? getRequestedTab(req, url) : null;
|
|
15519
|
+
sendJson(res, 200, { ok: true, data: await readThemeCatalog(tab) });
|
|
15520
|
+
return;
|
|
15521
|
+
}
|
|
15522
|
+
|
|
15523
|
+
if (url.pathname === "/api/themes/custom" && req.method === "POST") {
|
|
15524
|
+
requireLocalhostRoute(req, url.pathname);
|
|
15525
|
+
requireCustomThemeJsonRequest(req);
|
|
15526
|
+
let body;
|
|
15527
|
+
try {
|
|
15528
|
+
body = await readJsonBody(req, { limitBytes: CUSTOM_THEME_BODY_LIMIT_BYTES });
|
|
15529
|
+
} catch (error) {
|
|
15530
|
+
if (error instanceof SyntaxError) throw themeHttpError(400, "THEME_JSON_INVALID", "Custom theme save body contains malformed JSON.");
|
|
15531
|
+
throw error;
|
|
15532
|
+
}
|
|
15533
|
+
const tab = getRequestedTab(req, url);
|
|
15534
|
+
const request = validateCustomThemeSaveBody(body);
|
|
15535
|
+
const data = await saveCustomTheme(tab, request);
|
|
15536
|
+
sendJson(res, data.created ? 201 : 200, { ok: true, data });
|
|
15192
15537
|
return;
|
|
15193
15538
|
}
|
|
15194
15539
|
|
|
@@ -15928,7 +16273,7 @@ const server = createServer(async (req, res) => {
|
|
|
15928
16273
|
const tab = getRequestedTab(req, url, body);
|
|
15929
16274
|
ensureNaturalConversationRouteAllowed(tab, "git pull is blocked");
|
|
15930
16275
|
try {
|
|
15931
|
-
sendJson(res, 200, await pullGitChanges(tab.cwd));
|
|
16276
|
+
sendJson(res, 200, await pullGitChanges(tab.cwd, { remote: body?.remote }));
|
|
15932
16277
|
} catch (error) {
|
|
15933
16278
|
sendJson(res, 200, { ok: false, error: sanitizeError(error) });
|
|
15934
16279
|
}
|
package/index.ts
CHANGED
|
@@ -824,6 +824,12 @@ async function runGitWorkflowSetup(ctx: ExtensionCommandContext): Promise<void>
|
|
|
824
824
|
], current.stagingPolicy);
|
|
825
825
|
if (!stagingPolicy) return;
|
|
826
826
|
|
|
827
|
+
const reviewProcess = await selectGitWorkflowSetupValue(ctx, "Manual review process", [
|
|
828
|
+
{ value: "enabled", label: "Enabled when aur-review is available" },
|
|
829
|
+
{ value: "disabled", label: "Disabled — continue directly to message generation" },
|
|
830
|
+
], current.reviewProcessEnabled ? "enabled" : "disabled");
|
|
831
|
+
if (!reviewProcess) return;
|
|
832
|
+
|
|
827
833
|
const deliveryMode = await selectGitWorkflowSetupValue(ctx, "Default delivery path", [
|
|
828
834
|
{ value: "ask", label: "Ask each workflow" },
|
|
829
835
|
{ value: "current", label: "Prefer the current branch" },
|
|
@@ -846,6 +852,7 @@ async function runGitWorkflowSetup(ctx: ExtensionCommandContext): Promise<void>
|
|
|
846
852
|
},
|
|
847
853
|
commit: { language, defaultVariant, scope },
|
|
848
854
|
stagingPolicy,
|
|
855
|
+
reviewProcessEnabled: reviewProcess === "enabled",
|
|
849
856
|
deliveryMode,
|
|
850
857
|
verificationPolicy,
|
|
851
858
|
};
|
|
@@ -896,7 +903,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
896
903
|
};
|
|
897
904
|
|
|
898
905
|
pi.registerCommand("git-workflow-setup", {
|
|
899
|
-
description: "Configure the model, reasoning effort, staging, and commit defaults for guided Git",
|
|
906
|
+
description: "Configure the model, reasoning effort, staging, review process, and commit defaults for guided Git",
|
|
900
907
|
handler: async (_args, ctx) => runGitWorkflowSetup(ctx),
|
|
901
908
|
});
|
|
902
909
|
|
|
@@ -58,6 +58,7 @@ export function defaultGitWorkflowPreferences() {
|
|
|
58
58
|
scope: "auto",
|
|
59
59
|
},
|
|
60
60
|
stagingPolicy: "review",
|
|
61
|
+
reviewProcessEnabled: true,
|
|
61
62
|
deliveryMode: "ask",
|
|
62
63
|
verificationPolicy: "ask",
|
|
63
64
|
};
|
|
@@ -81,6 +82,7 @@ export function normalizeGitWorkflowPreferences(value) {
|
|
|
81
82
|
scope: choice(value?.commit?.scope, GIT_WORKFLOW_SCOPE_POLICIES, defaults.commit.scope),
|
|
82
83
|
},
|
|
83
84
|
stagingPolicy: choice(value?.stagingPolicy, GIT_WORKFLOW_STAGING_POLICIES, defaults.stagingPolicy),
|
|
85
|
+
reviewProcessEnabled: typeof value?.reviewProcessEnabled === "boolean" ? value.reviewProcessEnabled : defaults.reviewProcessEnabled,
|
|
84
86
|
deliveryMode: choice(value?.deliveryMode, GIT_WORKFLOW_DELIVERY_MODES, defaults.deliveryMode),
|
|
85
87
|
verificationPolicy: choice(value?.verificationPolicy, GIT_WORKFLOW_VERIFICATION_POLICIES, defaults.verificationPolicy),
|
|
86
88
|
};
|
|
@@ -109,6 +111,7 @@ export function gitWorkflowPreferencesSummary(preferences) {
|
|
|
109
111
|
`Thinking: ${value.generation.thinkingLevel}`,
|
|
110
112
|
`Commit: ${value.commit.language} · ${value.commit.defaultVariant} · scope ${value.commit.scope}`,
|
|
111
113
|
`Staging: ${value.stagingPolicy}`,
|
|
114
|
+
`Review process: ${value.reviewProcessEnabled ? "enabled" : "disabled"}`,
|
|
112
115
|
`Delivery: ${value.deliveryMode}`,
|
|
113
116
|
`Verification: ${value.verificationPolicy}`,
|
|
114
117
|
].join("\n");
|
|
@@ -146,11 +146,12 @@ export function normalizeSummaryState(value) {
|
|
|
146
146
|
if (!value || typeof value !== "object" || value.version !== SESSION_SUMMARY_PROTOCOL_VERSION || !validSource(value.source)) return undefined;
|
|
147
147
|
let result;
|
|
148
148
|
try {
|
|
149
|
-
const
|
|
149
|
+
const resultInput = {
|
|
150
150
|
version: SESSION_SUMMARY_PROTOCOL_VERSION,
|
|
151
|
-
title: value.result?.title,
|
|
152
151
|
summaryMarkdown: value.result?.summaryMarkdown,
|
|
153
|
-
}
|
|
152
|
+
};
|
|
153
|
+
if (value.result?.title !== undefined) resultInput.title = value.result.title;
|
|
154
|
+
const parsed = parseSummaryObject(resultInput);
|
|
154
155
|
result = {
|
|
155
156
|
...(parsed.title ? { title: parsed.title } : {}),
|
|
156
157
|
summaryMarkdown: parsed.summaryMarkdown,
|