@earendil-works/pi-coding-agent 0.79.0 → 0.79.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/README.md +10 -8
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +17 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +128 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +9 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +6 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +41 -5
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +58 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +2 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +24 -26
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +25 -25
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +11 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +26 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/trust-manager.d.ts +28 -2
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +89 -20
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +32 -181
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +39 -34
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +103 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +7 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +6 -3
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +23 -18
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +22 -12
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts +6 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +66 -12
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -0
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +78 -0
- package/dist/utils/changelog.js.map +1 -1
- package/docs/extensions.md +11 -3
- package/docs/models.md +4 -3
- package/docs/packages.md +0 -2
- package/docs/prompt-templates.md +8 -1
- package/docs/security.md +13 -11
- package/docs/settings.md +9 -4
- package/docs/usage.md +12 -7
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -6,33 +6,31 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { createInterface } from "node:readline";
|
|
8
8
|
import { modelsAreEqual } from "@earendil-works/pi-ai";
|
|
9
|
-
import { ProcessTerminal, setKeybindings, TUI } from "@earendil-works/pi-tui";
|
|
10
9
|
import chalk from "chalk";
|
|
11
10
|
import { parseArgs, printHelp } from "./cli/args.js";
|
|
12
11
|
import { processFileArguments } from "./cli/file-processor.js";
|
|
13
12
|
import { buildInitialMessage } from "./cli/initial-message.js";
|
|
14
13
|
import { listModels } from "./cli/list-models.js";
|
|
14
|
+
import { createProjectTrustContext } from "./cli/project-trust.js";
|
|
15
15
|
import { selectSession } from "./cli/session-picker.js";
|
|
16
|
+
import { shouldRunFirstTimeSetup, showFirstTimeSetup, showStartupSelector } from "./cli/startup-ui.js";
|
|
16
17
|
import { ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir, VERSION } from "./config.js";
|
|
17
18
|
import { createAgentSessionRuntime } from "./core/agent-session-runtime.js";
|
|
18
19
|
import { createAgentSessionFromServices, createAgentSessionServices, } from "./core/agent-session-services.js";
|
|
19
20
|
import { formatNoModelsAvailableMessage } from "./core/auth-guidance.js";
|
|
20
21
|
import { AuthStorage } from "./core/auth-storage.js";
|
|
21
22
|
import { exportFromFile } from "./core/export-html/index.js";
|
|
22
|
-
import { emitProjectTrustEvent } from "./core/extensions/runner.js";
|
|
23
23
|
import { configureHttpDispatcher } from "./core/http-dispatcher.js";
|
|
24
|
-
import { KeybindingsManager } from "./core/keybindings.js";
|
|
25
24
|
import { resolveCliModel, resolveModelScope } from "./core/model-resolver.js";
|
|
26
25
|
import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
|
|
26
|
+
import { resolveProjectTrusted } from "./core/project-trust.js";
|
|
27
27
|
import { formatMissingSessionCwdPrompt, getMissingSessionCwdIssue, MissingSessionCwdError, } from "./core/session-cwd.js";
|
|
28
28
|
import { assertValidSessionId, SessionManager } from "./core/session-manager.js";
|
|
29
29
|
import { SettingsManager } from "./core/settings-manager.js";
|
|
30
30
|
import { printTimings, resetTimings, time } from "./core/timings.js";
|
|
31
|
-
import {
|
|
31
|
+
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/trust-manager.js";
|
|
32
32
|
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
|
|
33
33
|
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
|
|
34
|
-
import { ExtensionInputComponent } from "./modes/interactive/components/extension-input.js";
|
|
35
|
-
import { ExtensionSelectorComponent } from "./modes/interactive/components/extension-selector.js";
|
|
36
34
|
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
|
|
37
35
|
import { handleConfigCommand, handlePackageCommand } from "./package-manager-cli.js";
|
|
38
36
|
import { isLocalPath, normalizePath, resolvePath } from "./utils/paths.js";
|
|
@@ -76,14 +74,14 @@ function isTruthyEnvFlag(value) {
|
|
|
76
74
|
return false;
|
|
77
75
|
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
78
76
|
}
|
|
79
|
-
function resolveAppMode(parsed, stdinIsTTY) {
|
|
77
|
+
function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
|
|
80
78
|
if (parsed.mode === "rpc") {
|
|
81
79
|
return "rpc";
|
|
82
80
|
}
|
|
83
81
|
if (parsed.mode === "json") {
|
|
84
82
|
return "json";
|
|
85
83
|
}
|
|
86
|
-
if (parsed.print || !stdinIsTTY) {
|
|
84
|
+
if (parsed.print || !stdinIsTTY || !stdoutIsTTY) {
|
|
87
85
|
return "print";
|
|
88
86
|
}
|
|
89
87
|
return "interactive";
|
|
@@ -91,6 +89,9 @@ function resolveAppMode(parsed, stdinIsTTY) {
|
|
|
91
89
|
function toPrintOutputMode(appMode) {
|
|
92
90
|
return appMode === "json" ? "json" : "text";
|
|
93
91
|
}
|
|
92
|
+
function isPlainRuntimeMetadataCommand(parsed) {
|
|
93
|
+
return !parsed.print && parsed.mode === undefined && (parsed.help === true || parsed.listModels !== undefined);
|
|
94
|
+
}
|
|
94
95
|
async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
|
|
95
96
|
if (parsed.fileArgs.length === 0) {
|
|
96
97
|
return buildInitialMessage({ parsed, stdinContent });
|
|
@@ -270,6 +271,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
|
|
|
270
271
|
const resolved = resolveCliModel({
|
|
271
272
|
cliProvider: parsed.provider,
|
|
272
273
|
cliModel: parsed.model,
|
|
274
|
+
cliThinking: parsed.thinking,
|
|
273
275
|
modelRegistry,
|
|
274
276
|
});
|
|
275
277
|
if (resolved.warning) {
|
|
@@ -342,172 +344,12 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
|
|
|
342
344
|
function resolveCliPaths(cwd, paths) {
|
|
343
345
|
return paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));
|
|
344
346
|
}
|
|
345
|
-
function createStartupTui(settingsManager) {
|
|
346
|
-
initTheme(settingsManager.getTheme());
|
|
347
|
-
setKeybindings(KeybindingsManager.create());
|
|
348
|
-
const ui = new TUI(new ProcessTerminal(), settingsManager.getShowHardwareCursor());
|
|
349
|
-
ui.setClearOnShrink(settingsManager.getClearOnShrink());
|
|
350
|
-
return ui;
|
|
351
|
-
}
|
|
352
|
-
async function clearStartupTui(ui) {
|
|
353
|
-
ui.clear();
|
|
354
|
-
ui.requestRender();
|
|
355
|
-
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
356
|
-
}
|
|
357
|
-
async function showStartupSelector(settingsManager, title, options) {
|
|
358
|
-
return new Promise((resolve) => {
|
|
359
|
-
const ui = createStartupTui(settingsManager);
|
|
360
|
-
let settled = false;
|
|
361
|
-
const finish = async (result) => {
|
|
362
|
-
if (settled) {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
settled = true;
|
|
366
|
-
await clearStartupTui(ui);
|
|
367
|
-
ui.stop();
|
|
368
|
-
resolve(result);
|
|
369
|
-
};
|
|
370
|
-
const selector = new ExtensionSelectorComponent(title, options.map((option) => option.label), (option) => void finish(options.find((entry) => entry.label === option)?.value), () => void finish(undefined), { tui: ui });
|
|
371
|
-
ui.addChild(selector);
|
|
372
|
-
ui.setFocus(selector);
|
|
373
|
-
ui.start();
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
async function showStartupInput(settingsManager, title, placeholder) {
|
|
377
|
-
return new Promise((resolve) => {
|
|
378
|
-
const ui = createStartupTui(settingsManager);
|
|
379
|
-
let settled = false;
|
|
380
|
-
const finish = async (result) => {
|
|
381
|
-
if (settled) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
settled = true;
|
|
385
|
-
input.dispose();
|
|
386
|
-
await clearStartupTui(ui);
|
|
387
|
-
ui.stop();
|
|
388
|
-
resolve(result);
|
|
389
|
-
};
|
|
390
|
-
const input = new ExtensionInputComponent(title, placeholder, (value) => void finish(value), () => void finish(undefined), {
|
|
391
|
-
tui: ui,
|
|
392
|
-
});
|
|
393
|
-
ui.addChild(input);
|
|
394
|
-
ui.setFocus(input);
|
|
395
|
-
ui.start();
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
347
|
async function promptForMissingSessionCwd(issue, settingsManager) {
|
|
399
348
|
return showStartupSelector(settingsManager, formatMissingSessionCwdPrompt(issue), [
|
|
400
349
|
{ label: "Continue", value: issue.fallbackCwd },
|
|
401
350
|
{ label: "Cancel", value: undefined },
|
|
402
351
|
]);
|
|
403
352
|
}
|
|
404
|
-
const PROJECT_TRUST_PROMPT_OPTIONS = [
|
|
405
|
-
{ label: "Trust", value: { trusted: true, remember: true } },
|
|
406
|
-
{ label: "Trust (this session only)", value: { trusted: true, remember: false } },
|
|
407
|
-
{ label: "Do not trust", value: { trusted: false, remember: true } },
|
|
408
|
-
{ label: "Do not trust (this session only)", value: { trusted: false, remember: false } },
|
|
409
|
-
];
|
|
410
|
-
function formatProjectTrustPrompt(cwd) {
|
|
411
|
-
return `Trust project folder?\n${cwd}\n\nThis allows pi to read project instructions (AGENTS.md/CLAUDE.md), load .pi settings and resources, install missing project packages, and execute project extensions.`;
|
|
412
|
-
}
|
|
413
|
-
async function promptForProjectTrust(cwd, settingsManager) {
|
|
414
|
-
return showStartupSelector(settingsManager, formatProjectTrustPrompt(cwd), PROJECT_TRUST_PROMPT_OPTIONS);
|
|
415
|
-
}
|
|
416
|
-
async function promptForProjectTrustWithContext(cwd, ctx) {
|
|
417
|
-
const selected = await ctx.ui.select(formatProjectTrustPrompt(cwd), PROJECT_TRUST_PROMPT_OPTIONS.map((option) => option.label));
|
|
418
|
-
return PROJECT_TRUST_PROMPT_OPTIONS.find((option) => option.label === selected)?.value;
|
|
419
|
-
}
|
|
420
|
-
function createProjectTrustContext(options) {
|
|
421
|
-
return {
|
|
422
|
-
cwd: options.cwd,
|
|
423
|
-
mode: options.mode === "interactive" ? "tui" : options.mode,
|
|
424
|
-
hasUI: options.hasUI,
|
|
425
|
-
ui: {
|
|
426
|
-
select: async (title, selectOptions) => {
|
|
427
|
-
if (!options.hasUI) {
|
|
428
|
-
return undefined;
|
|
429
|
-
}
|
|
430
|
-
if (options.mode !== "interactive") {
|
|
431
|
-
return undefined;
|
|
432
|
-
}
|
|
433
|
-
return showStartupSelector(options.settingsManager, title, selectOptions.map((option) => ({ label: option, value: option })));
|
|
434
|
-
},
|
|
435
|
-
confirm: async (title, message) => {
|
|
436
|
-
if (!options.hasUI) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
if (options.mode !== "interactive") {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
return ((await showStartupSelector(options.settingsManager, `${title}\n${message}`, [
|
|
443
|
-
{ label: "Yes", value: true },
|
|
444
|
-
{ label: "No", value: false },
|
|
445
|
-
])) ?? false);
|
|
446
|
-
},
|
|
447
|
-
input: async (title, placeholder) => {
|
|
448
|
-
if (!options.hasUI) {
|
|
449
|
-
return undefined;
|
|
450
|
-
}
|
|
451
|
-
if (options.mode !== "interactive") {
|
|
452
|
-
return undefined;
|
|
453
|
-
}
|
|
454
|
-
return showStartupInput(options.settingsManager, title, placeholder);
|
|
455
|
-
},
|
|
456
|
-
notify: (message, type = "info") => {
|
|
457
|
-
if (options.mode !== "interactive") {
|
|
458
|
-
const color = type === "error" ? chalk.red : type === "warning" ? chalk.yellow : chalk.cyan;
|
|
459
|
-
console.error(color(message));
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
async function resolveProjectTrusted(options) {
|
|
466
|
-
if (options.trustOverride !== undefined) {
|
|
467
|
-
return options.trustOverride;
|
|
468
|
-
}
|
|
469
|
-
if (!hasProjectTrustInputs(options.cwd)) {
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
if (options.extensionsResult && options.projectTrustContext) {
|
|
473
|
-
const { result, errors } = await emitProjectTrustEvent(options.extensionsResult, { type: "project_trust", cwd: options.cwd }, options.projectTrustContext);
|
|
474
|
-
for (const error of errors) {
|
|
475
|
-
options.onExtensionError?.(`Extension "${error.extensionPath}" project_trust error: ${error.error}`);
|
|
476
|
-
}
|
|
477
|
-
if (result) {
|
|
478
|
-
const trusted = result.trusted === "yes";
|
|
479
|
-
if (result.remember === true) {
|
|
480
|
-
options.trustStore.set(options.cwd, trusted);
|
|
481
|
-
}
|
|
482
|
-
return trusted;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
const decision = options.trustStore.get(options.cwd);
|
|
486
|
-
if (decision !== null) {
|
|
487
|
-
return decision;
|
|
488
|
-
}
|
|
489
|
-
if (options.projectTrustContext?.hasUI) {
|
|
490
|
-
const selected = await promptForProjectTrustWithContext(options.cwd, options.projectTrustContext);
|
|
491
|
-
if (selected !== undefined) {
|
|
492
|
-
if (selected.remember) {
|
|
493
|
-
options.trustStore.set(options.cwd, selected.trusted);
|
|
494
|
-
}
|
|
495
|
-
return selected.trusted;
|
|
496
|
-
}
|
|
497
|
-
return false;
|
|
498
|
-
}
|
|
499
|
-
if (options.appMode !== "interactive") {
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
const selected = await promptForProjectTrust(options.cwd, options.settingsManagerForPrompt);
|
|
503
|
-
if (selected !== undefined) {
|
|
504
|
-
if (selected.remember) {
|
|
505
|
-
options.trustStore.set(options.cwd, selected.trusted);
|
|
506
|
-
}
|
|
507
|
-
return selected.trusted;
|
|
508
|
-
}
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
353
|
export async function main(args, options) {
|
|
512
354
|
resetTimings();
|
|
513
355
|
const offlineMode = args.includes("--offline") || isTruthyEnvFlag(process.env.PI_OFFLINE);
|
|
@@ -518,10 +360,10 @@ export async function main(args, options) {
|
|
|
518
360
|
if (process.platform === "win32") {
|
|
519
361
|
cleanupWindowsSelfUpdateQuarantine(getPackageDir());
|
|
520
362
|
}
|
|
521
|
-
if (await handlePackageCommand(args)) {
|
|
363
|
+
if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) {
|
|
522
364
|
return;
|
|
523
365
|
}
|
|
524
|
-
if (await handleConfigCommand(args)) {
|
|
366
|
+
if (await handleConfigCommand(args, { extensionFactories: options?.extensionFactories })) {
|
|
525
367
|
return;
|
|
526
368
|
}
|
|
527
369
|
const parsed = parseArgs(args);
|
|
@@ -535,11 +377,6 @@ export async function main(args, options) {
|
|
|
535
377
|
}
|
|
536
378
|
}
|
|
537
379
|
time("parseArgs");
|
|
538
|
-
let appMode = resolveAppMode(parsed, process.stdin.isTTY);
|
|
539
|
-
const shouldTakeOverStdout = appMode !== "interactive";
|
|
540
|
-
if (shouldTakeOverStdout) {
|
|
541
|
-
takeOverStdout();
|
|
542
|
-
}
|
|
543
380
|
if (parsed.version) {
|
|
544
381
|
console.log(VERSION);
|
|
545
382
|
process.exit(0);
|
|
@@ -558,6 +395,11 @@ export async function main(args, options) {
|
|
|
558
395
|
console.log(`Exported to: ${result}`);
|
|
559
396
|
process.exit(0);
|
|
560
397
|
}
|
|
398
|
+
let appMode = resolveAppMode(parsed, process.stdin.isTTY, process.stdout.isTTY);
|
|
399
|
+
const shouldTakeOverStdout = appMode !== "interactive" && !isPlainRuntimeMetadataCommand(parsed);
|
|
400
|
+
if (shouldTakeOverStdout) {
|
|
401
|
+
takeOverStdout();
|
|
402
|
+
}
|
|
561
403
|
if (parsed.mode === "rpc" && parsed.fileArgs.length > 0) {
|
|
562
404
|
console.error(chalk.red("Error: @file arguments are not supported in RPC mode"));
|
|
563
405
|
process.exit(1);
|
|
@@ -571,6 +413,12 @@ export async function main(args, options) {
|
|
|
571
413
|
const agentDir = getAgentDir();
|
|
572
414
|
const startupSettingsManager = SettingsManager.create(cwd, agentDir);
|
|
573
415
|
reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup"));
|
|
416
|
+
// Experimental first-time setup: theme choice and analytics opt-in.
|
|
417
|
+
// Runs before any runtime services are created so the chosen settings apply everywhere.
|
|
418
|
+
if (appMode === "interactive" && !parsed.help && parsed.listModels === undefined && shouldRunFirstTimeSetup()) {
|
|
419
|
+
await showFirstTimeSetup(startupSettingsManager);
|
|
420
|
+
time("firstTimeSetup");
|
|
421
|
+
}
|
|
574
422
|
// Decide the final runtime cwd before creating cwd-bound runtime services.
|
|
575
423
|
// --session and --resume may select a session from another project, so project-local
|
|
576
424
|
// settings, resources, provider registrations, and models must be resolved only after
|
|
@@ -606,7 +454,9 @@ export async function main(args, options) {
|
|
|
606
454
|
time("createSessionManager");
|
|
607
455
|
const trustStore = new ProjectTrustStore(agentDir);
|
|
608
456
|
const sessionCwd = sessionManager.getCwd();
|
|
609
|
-
const autoTrustOnReloadCwd = parsed.projectTrustOverride === undefined && !
|
|
457
|
+
const autoTrustOnReloadCwd = parsed.projectTrustOverride === undefined && !hasTrustRequiringProjectResources(sessionCwd)
|
|
458
|
+
? sessionCwd
|
|
459
|
+
: undefined;
|
|
610
460
|
const trustPromptMode = parsed.help || parsed.listModels !== undefined ? "print" : appMode;
|
|
611
461
|
const projectTrustByCwd = new Map();
|
|
612
462
|
const resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions);
|
|
@@ -618,11 +468,13 @@ export async function main(args, options) {
|
|
|
618
468
|
const isInitialRuntime = sessionStartEvent === undefined;
|
|
619
469
|
const projectTrustDiagnostics = [];
|
|
620
470
|
const cachedProjectTrust = projectTrustByCwd.get(cwd);
|
|
621
|
-
const
|
|
622
|
-
const shouldResolveProjectTrust = parsed.projectTrustOverride === undefined && cachedProjectTrust === undefined &&
|
|
471
|
+
const hasTrustRequiringResources = hasTrustRequiringProjectResources(cwd);
|
|
472
|
+
const shouldResolveProjectTrust = parsed.projectTrustOverride === undefined && cachedProjectTrust === undefined && hasTrustRequiringResources;
|
|
623
473
|
const projectTrusted = shouldResolveProjectTrust
|
|
624
474
|
? false
|
|
625
|
-
: (cachedProjectTrust ??
|
|
475
|
+
: (cachedProjectTrust ??
|
|
476
|
+
parsed.projectTrustOverride ??
|
|
477
|
+
(!hasTrustRequiringResources || trustStore.get(cwd) === true));
|
|
626
478
|
const runtimeSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted });
|
|
627
479
|
const services = await createAgentSessionServices({
|
|
628
480
|
cwd,
|
|
@@ -637,8 +489,7 @@ export async function main(args, options) {
|
|
|
637
489
|
cwd,
|
|
638
490
|
trustStore,
|
|
639
491
|
trustOverride: parsed.projectTrustOverride,
|
|
640
|
-
|
|
641
|
-
settingsManagerForPrompt: startupSettingsManager,
|
|
492
|
+
defaultProjectTrust: startupSettingsManager.getDefaultProjectTrust(),
|
|
642
493
|
extensionsResult,
|
|
643
494
|
projectTrustContext: projectTrustContext ??
|
|
644
495
|
createProjectTrustContext({
|