Fix Pi package updates and merge feynman-model
This commit is contained in:
@@ -18,6 +18,7 @@ import { ensureFeynmanHome, getDefaultSessionDir, getFeynmanAgentDir, getFeynman
|
||||
import { launchPiChat } from "./pi/launch.js";
|
||||
import { CORE_PACKAGE_SOURCES, getOptionalPackagePresetSources, listOptionalPackagePresets } from "./pi/package-presets.js";
|
||||
import { normalizeFeynmanSettings, normalizeThinkingLevel, parseModelSpec } from "./pi/settings.js";
|
||||
import { applyFeynmanPackageManagerEnv } from "./pi/runtime.js";
|
||||
import {
|
||||
authenticateModelProvider,
|
||||
getCurrentModelSpec,
|
||||
@@ -154,6 +155,7 @@ async function handleModelCommand(subcommand: string | undefined, args: string[]
|
||||
}
|
||||
|
||||
async function handleUpdateCommand(workingDir: string, feynmanAgentDir: string, source?: string): Promise<void> {
|
||||
applyFeynmanPackageManagerEnv(feynmanAgentDir);
|
||||
const settingsManager = SettingsManager.create(workingDir, feynmanAgentDir);
|
||||
const packageManager = new DefaultPackageManager({
|
||||
cwd: workingDir,
|
||||
@@ -177,6 +179,7 @@ async function handleUpdateCommand(workingDir: string, feynmanAgentDir: string,
|
||||
}
|
||||
|
||||
async function handlePackagesCommand(subcommand: string | undefined, args: string[], workingDir: string, feynmanAgentDir: string): Promise<void> {
|
||||
applyFeynmanPackageManagerEnv(feynmanAgentDir);
|
||||
const settingsManager = SettingsManager.create(workingDir, feynmanAgentDir);
|
||||
const configuredSources = new Set(
|
||||
settingsManager
|
||||
|
||||
@@ -7,6 +7,5 @@ export function getModelsJsonPath(authPath: string): string {
|
||||
}
|
||||
|
||||
export function createModelRegistry(authPath: string): ModelRegistry {
|
||||
return new ModelRegistry(AuthStorage.create(authPath), getModelsJsonPath(authPath));
|
||||
return ModelRegistry.create(AuthStorage.create(authPath), getModelsJsonPath(authPath));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,18 @@ export type PiRuntimeOptions = {
|
||||
initialPrompt?: string;
|
||||
};
|
||||
|
||||
export function getFeynmanNpmPrefixPath(feynmanAgentDir: string): string {
|
||||
return resolve(dirname(feynmanAgentDir), "npm-global");
|
||||
}
|
||||
|
||||
export function applyFeynmanPackageManagerEnv(feynmanAgentDir: string): string {
|
||||
const feynmanNpmPrefixPath = getFeynmanNpmPrefixPath(feynmanAgentDir);
|
||||
process.env.FEYNMAN_NPM_PREFIX = feynmanNpmPrefixPath;
|
||||
process.env.NPM_CONFIG_PREFIX = feynmanNpmPrefixPath;
|
||||
process.env.npm_config_prefix = feynmanNpmPrefixPath;
|
||||
return feynmanNpmPrefixPath;
|
||||
}
|
||||
|
||||
export function resolvePiPaths(appRoot: string) {
|
||||
return {
|
||||
piPackageRoot: resolve(appRoot, "node_modules", "@mariozechner", "pi-coding-agent"),
|
||||
@@ -83,8 +95,7 @@ export function buildPiArgs(options: PiRuntimeOptions): string[] {
|
||||
|
||||
export function buildPiEnv(options: PiRuntimeOptions): NodeJS.ProcessEnv {
|
||||
const paths = resolvePiPaths(options.appRoot);
|
||||
const feynmanHome = dirname(options.feynmanAgentDir);
|
||||
const feynmanNpmPrefixPath = resolve(feynmanHome, "npm-global");
|
||||
const feynmanNpmPrefixPath = getFeynmanNpmPrefixPath(options.feynmanAgentDir);
|
||||
const feynmanNpmBinPath = resolve(feynmanNpmPrefixPath, "bin");
|
||||
|
||||
const currentPath = process.env.PATH ?? "";
|
||||
|
||||
Reference in New Issue
Block a user