@earendil-works/pi-coding-agent
Version:
Coding agent CLI with read, bash, edit, write tools and session management
240 lines • 8.73 kB
TypeScript
import type { SettingsManager } from "./settings-manager.ts";
/** Whether PI_OFFLINE is set; package installs and updates then skip all network access. */
export declare function isOfflineModeEnabled(): boolean;
export interface PathMetadata {
source: string;
scope: SourceScope;
origin: "package" | "top-level";
baseDir?: string;
changelogPath?: string;
packageRoot?: string;
}
export interface ResolvedResource {
path: string;
enabled: boolean;
metadata: PathMetadata;
}
export interface ResolvedPaths {
extensions: ResolvedResource[];
skills: ResolvedResource[];
prompts: ResolvedResource[];
themes: ResolvedResource[];
/** Configured packages that were skipped because installing them failed. */
installFailures?: PackageInstallFailure[];
}
/** A configured package that could not be installed while resolving resources. */
export interface PackageInstallFailure {
source: string;
scope: SourceScope;
message: string;
}
export type MissingSourceAction = "install" | "skip" | "error";
export interface ProgressEvent {
/**
* `start` is followed by exactly one `complete` or `error` for the same source.
* `progress` carries an intermediate message or warning.
* `result` reports an outcome outside that pairing, e.g. one changed package
* after update(): `npm:foo 1.2.0 -> 1.3.0`.
*/
type: "start" | "progress" | "complete" | "error" | "result";
action: "install" | "remove" | "update" | "clone" | "pull";
source: string;
message?: string;
}
export type ProgressCallback = (event: ProgressEvent) => void;
export interface PackageUpdate {
source: string;
displayName: string;
type: "npm" | "git";
scope: Exclude<SourceScope, "temporary">;
}
export interface ConfiguredPackage {
source: string;
scope: "user" | "project";
filtered: boolean;
installedPath?: string;
}
export interface PackageManager {
resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths>;
install(source: string, options?: {
local?: boolean;
}): Promise<void>;
installAndPersist(source: string, options?: {
local?: boolean;
}): Promise<void>;
remove(source: string, options?: {
local?: boolean;
}): Promise<void>;
removeAndPersist(source: string, options?: {
local?: boolean;
}): Promise<boolean>;
update(source?: string): Promise<void>;
listConfiguredPackages(): ConfiguredPackage[];
resolveExtensionSources(sources: string[], options?: {
local?: boolean;
temporary?: boolean;
}): Promise<ResolvedPaths>;
addSourceToSettings(source: string, options?: {
local?: boolean;
}): boolean;
removeSourceFromSettings(source: string, options?: {
local?: boolean;
}): boolean;
setProgressCallback(callback: ProgressCallback | undefined): void;
getInstalledPath(source: string, scope: "user" | "project"): string | undefined;
}
interface PackageManagerOptions {
cwd: string;
agentDir: string;
settingsManager: SettingsManager;
/** Names of built-in extensions, resolved as `builtin:<name>` extension resources. */
builtinExtensions?: string[];
}
type SourceScope = "user" | "project" | "temporary";
export declare function getExtensionTempFolder(agentDir: string): string;
export declare class DefaultPackageManager implements PackageManager {
private cwd;
private agentDir;
private settingsManager;
private builtinExtensions;
private globalNpmRoot;
private globalNpmRootCommandKey;
private progressCallback;
constructor(options: PackageManagerOptions);
setProgressCallback(callback: ProgressCallback | undefined): void;
addSourceToSettings(source: string, options?: {
local?: boolean;
}): boolean;
removeSourceFromSettings(source: string, options?: {
local?: boolean;
}): boolean;
getInstalledPath(source: string, scope: "user" | "project"): string | undefined;
private emitProgress;
private withProgress;
resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths>;
resolveExtensionSources(sources: string[], options?: {
local?: boolean;
temporary?: boolean;
}): Promise<ResolvedPaths>;
listConfiguredPackages(): ConfiguredPackage[];
install(source: string, options?: {
local?: boolean;
}): Promise<void>;
installAndPersist(source: string, options?: {
local?: boolean;
}): Promise<void>;
remove(source: string, options?: {
local?: boolean;
}): Promise<void>;
removeAndPersist(source: string, options?: {
local?: boolean;
}): Promise<boolean>;
update(source?: string): Promise<void>;
private updateConfiguredSources;
private getGitHead;
private shouldUpdateNpmSource;
private updateNpmBatch;
/**
* npm can resolve stale registry metadata shortly after a publish and install the old
* version without an error. Warn when an announced update did not change the installed version.
*/
private reportUnchangedNpmUpdates;
private installNpmBatch;
checkForAvailableUpdates(): Promise<PackageUpdate[]>;
private resolvePackageSources;
private findAutoloadDeltaBase;
private resolveLocalExtensionSource;
private installParsedSource;
private getPackageSourceString;
private getSourceMatchKeyForInput;
private getSourceMatchKeyForSettings;
private buildNoMatchingPackageMessage;
private findSuggestedConfiguredSource;
private packageSourcesMatch;
private normalizePackageSourceForSettings;
private parseSource;
private installedNpmMatchesConfiguredVersion;
private npmHasAvailableUpdate;
private getInstalledNpmVersion;
private getLatestNpmVersion;
private gitHasAvailableUpdate;
private getRemoteGitHead;
private getLocalGitUpdateTarget;
private getGitUpstreamRef;
private runGitRemoteCommand;
private runWithConcurrency;
/**
* Get a unique identity for a package, ignoring version/ref.
* Used to detect when the same package is in both global and project settings.
* For git packages, uses normalized host/path to ensure SSH and HTTPS URLs
* for the same repository are treated as identical.
*/
private getPackageIdentity;
/**
* Dedupe packages: if same package identity appears in both global and project,
* keep only the project one (project wins). A project entry with autoload=false
* is a delta over the global entry, so both are kept (delta first).
*/
private dedupePackages;
private parseNpmSpec;
private assertProjectTrustedForScope;
private getNpmCommand;
private getPackageManagerName;
private runNpmCommand;
private getGitDependencyInstallArgs;
private runNpmCommandSync;
private getNpmInstallArgs;
private installNpm;
private uninstallNpm;
private installGit;
private updateGit;
private hasMissingGitDependencies;
private repairMissingGitDependencies;
private getGitUpdateMarkerPath;
private cleanAndInstallGitDependencies;
private ensureGitRef;
private refreshTemporaryGitSource;
private removeGit;
private pruneEmptyGitParents;
private ensureNpmProject;
private ensureGitIgnore;
private getNpmInstallRoot;
private getGlobalNpmRoot;
private getPnpmGlobalPackagePath;
private getManagedNpmInstallPath;
private getLegacyGlobalNpmInstallPath;
private getNpmInstallPath;
private getGitInstallPath;
private getGitInstallRoot;
private getTemporaryDir;
private resolveManagedPath;
private getBaseDirForScope;
private resolvePath;
private resolvePathFromBase;
private collectPackageResources;
private collectDefaultResources;
private applyPackageFilter;
private applyPackageDeltaFilter;
/**
* Collect all files from a package for a resource type, applying manifest patterns.
* Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files
* that pass the manifest's own patterns.
*/
private collectManifestFiles;
private addManifestEntries;
private collectFilesFromManifestEntries;
private resolveLocalEntries;
private addAutoDiscoveredResources;
private collectFilesFromPaths;
private getTargetMap;
private addResource;
private createAccumulator;
private toResolvedPaths;
private spawnCommand;
private spawnCaptureCommand;
private runCommandCapture;
private runCommand;
private runCommandSync;
}
export {};
//# sourceMappingURL=package-manager.d.ts.map