Download packages/coding-agent/src/cli/project-trust.ts from SaylorTwift/pi: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/cli/project-trust.ts
- Command line
-
hf download hf://SaylorTwift/pi/packages/coding-agent/src/cli/project-trust.ts
-
curl -L -o project-trust.ts https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/cli/project-trust.ts
1.76 kB
| import chalk from "chalk"; | |
| import type { ProjectTrustContext } from "../core/extensions/types.ts"; | |
| import type { AppMode } from "../core/project-trust.ts"; | |
| import type { SettingsManager } from "../core/settings-manager.ts"; | |
| import { showStartupInput, showStartupSelector } from "./startup-ui.ts"; | |
| export function createProjectTrustContext(options: { | |
| cwd: string; | |
| mode: AppMode; | |
| settingsManager: SettingsManager; | |
| hasUI: boolean; | |
| }): ProjectTrustContext { | |
| return { | |
| cwd: options.cwd, | |
| mode: options.mode === "interactive" ? "tui" : options.mode, | |
| hasUI: options.hasUI, | |
| ui: { | |
| select: async (title, selectOptions) => { | |
| if (!options.hasUI) { | |
| return undefined; | |
| } | |
| if (options.mode !== "interactive") { | |
| return undefined; | |
| } | |
| return showStartupSelector( | |
| options.settingsManager, | |
| title, | |
| selectOptions.map((option) => ({ label: option, value: option })), | |
| ); | |
| }, | |
| confirm: async (title, message) => { | |
| if (!options.hasUI) { | |
| return false; | |
| } | |
| if (options.mode !== "interactive") { | |
| return false; | |
| } | |
| return ( | |
| (await showStartupSelector(options.settingsManager, `${title}\n${message}`, [ | |
| { label: "Yes", value: true }, | |
| { label: "No", value: false }, | |
| ])) ?? false | |
| ); | |
| }, | |
| input: async (title, placeholder) => { | |
| if (!options.hasUI) { | |
| return undefined; | |
| } | |
| if (options.mode !== "interactive") { | |
| return undefined; | |
| } | |
| return showStartupInput(options.settingsManager, title, placeholder); | |
| }, | |
| notify: (message, type = "info") => { | |
| if (options.mode !== "interactive") { | |
| const color = type === "error" ? chalk.red : type === "warning" ? chalk.yellow : chalk.cyan; | |
| console.error(color(message)); | |
| } | |
| }, | |
| }, | |
| }; | |
| } | |