mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 10:00:39 +00:00
fix(coding-agent): git temp path resolution, add pi list command (#645)
- Fix getGitInstallPath to check scope === 'temporary' directly - Remove redundant temporary parameter from git methods - Add 'pi list' command to show installed extensions from settings
This commit is contained in:
parent
4058680d22
commit
8ec7d6867a
4 changed files with 46 additions and 15 deletions
|
|
@ -1245,6 +1245,7 @@ pi [options] [@files...] [messages...]
|
||||||
| `install <source> [-l]` | Install extension source and add to settings (`-l` for project) |
|
| `install <source> [-l]` | Install extension source and add to settings (`-l` for project) |
|
||||||
| `remove <source> [-l]` | Remove extension source from settings |
|
| `remove <source> [-l]` | Remove extension source from settings |
|
||||||
| `update [source]` | Update installed extensions (skips pinned sources) |
|
| `update [source]` | Update installed extensions (skips pinned sources) |
|
||||||
|
| `list` | List installed extensions from settings |
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ ${chalk.bold("Commands:")}
|
||||||
${APP_NAME} install <source> [-l] Install extension source and add to settings
|
${APP_NAME} install <source> [-l] Install extension source and add to settings
|
||||||
${APP_NAME} remove <source> [-l] Remove extension source from settings
|
${APP_NAME} remove <source> [-l] Remove extension source from settings
|
||||||
${APP_NAME} update [source] Update installed extensions (skips pinned sources)
|
${APP_NAME} update [source] Update installed extensions (skips pinned sources)
|
||||||
|
${APP_NAME} list List installed extensions from settings
|
||||||
|
|
||||||
${chalk.bold("Options:")}
|
${chalk.bold("Options:")}
|
||||||
--provider <name> Provider name (default: google)
|
--provider <name> Provider name (default: google)
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsed.type === "git") {
|
if (parsed.type === "git") {
|
||||||
await this.installGit(parsed, scope, false);
|
await this.installGit(parsed, scope);
|
||||||
this.emitProgress({ type: "complete", action: "install", source });
|
this.emitProgress({ type: "complete", action: "install", source });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +184,7 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsed.type === "git") {
|
if (parsed.type === "git") {
|
||||||
await this.removeGit(parsed, scope, false);
|
await this.removeGit(parsed, scope);
|
||||||
this.emitProgress({ type: "complete", action: "remove", source });
|
this.emitProgress({ type: "complete", action: "remove", source });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
if (parsed.pinned) return;
|
if (parsed.pinned) return;
|
||||||
this.emitProgress({ type: "start", action: "update", source, message: `Updating ${source}...` });
|
this.emitProgress({ type: "start", action: "update", source, message: `Updating ${source}...` });
|
||||||
try {
|
try {
|
||||||
await this.updateGit(parsed, scope, false);
|
await this.updateGit(parsed, scope);
|
||||||
this.emitProgress({ type: "complete", action: "update", source });
|
this.emitProgress({ type: "complete", action: "update", source });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
const message = error instanceof Error ? error.message : String(error);
|
||||||
|
|
@ -317,7 +317,7 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsed.type === "git") {
|
if (parsed.type === "git") {
|
||||||
await this.installGit(parsed, scope, scope === "temporary");
|
await this.installGit(parsed, scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -394,8 +394,8 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
await this.runCommand("npm", ["uninstall", source.name, "--prefix", installRoot]);
|
await this.runCommand("npm", ["uninstall", source.name, "--prefix", installRoot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async installGit(source: GitSource, scope: SourceScope, temporary: boolean): Promise<void> {
|
private async installGit(source: GitSource, scope: SourceScope): Promise<void> {
|
||||||
const targetDir = this.getGitInstallPath(source, scope, temporary);
|
const targetDir = this.getGitInstallPath(source, scope);
|
||||||
if (existsSync(targetDir)) {
|
if (existsSync(targetDir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -407,17 +407,17 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateGit(source: GitSource, scope: SourceScope, temporary: boolean): Promise<void> {
|
private async updateGit(source: GitSource, scope: SourceScope): Promise<void> {
|
||||||
const targetDir = this.getGitInstallPath(source, scope, temporary);
|
const targetDir = this.getGitInstallPath(source, scope);
|
||||||
if (!existsSync(targetDir)) {
|
if (!existsSync(targetDir)) {
|
||||||
await this.installGit(source, scope, temporary);
|
await this.installGit(source, scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.runCommand("git", ["pull"], { cwd: targetDir });
|
await this.runCommand("git", ["pull"], { cwd: targetDir });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async removeGit(source: GitSource, scope: SourceScope, temporary: boolean): Promise<void> {
|
private async removeGit(source: GitSource, scope: SourceScope): Promise<void> {
|
||||||
const targetDir = this.getGitInstallPath(source, scope, temporary);
|
const targetDir = this.getGitInstallPath(source, scope);
|
||||||
if (!existsSync(targetDir)) return;
|
if (!existsSync(targetDir)) return;
|
||||||
rmSync(targetDir, { recursive: true, force: true });
|
rmSync(targetDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
|
@ -462,8 +462,8 @@ export class DefaultPackageManager implements PackageManager {
|
||||||
return join(this.getGlobalNpmRoot(), source.name);
|
return join(this.getGlobalNpmRoot(), source.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getGitInstallPath(source: GitSource, scope: SourceScope, temporary?: boolean): string {
|
private getGitInstallPath(source: GitSource, scope: SourceScope): string {
|
||||||
if (temporary) {
|
if (scope === "temporary") {
|
||||||
return this.getTemporaryDir(`git-${source.host}`, source.path);
|
return this.getTemporaryDir(`git-${source.host}`, source.path);
|
||||||
}
|
}
|
||||||
if (scope === "project") {
|
if (scope === "project") {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ async function readPipedStdin(): Promise<string | undefined> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
type PackageCommand = "install" | "remove" | "update";
|
type PackageCommand = "install" | "remove" | "update" | "list";
|
||||||
|
|
||||||
interface PackageCommandOptions {
|
interface PackageCommandOptions {
|
||||||
command: PackageCommand;
|
command: PackageCommand;
|
||||||
|
|
@ -63,7 +63,7 @@ interface PackageCommandOptions {
|
||||||
|
|
||||||
function parsePackageCommand(args: string[]): PackageCommandOptions | undefined {
|
function parsePackageCommand(args: string[]): PackageCommandOptions | undefined {
|
||||||
const [command, ...rest] = args;
|
const [command, ...rest] = args;
|
||||||
if (command !== "install" && command !== "remove" && command !== "update") {
|
if (command !== "install" && command !== "remove" && command !== "update" && command !== "list") {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,6 +165,35 @@ async function handlePackageCommand(args: string[]): Promise<boolean> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.command === "list") {
|
||||||
|
const globalSettings = settingsManager.getGlobalSettings();
|
||||||
|
const projectSettings = settingsManager.getProjectSettings();
|
||||||
|
const globalExtensions = globalSettings.extensions ?? [];
|
||||||
|
const projectExtensions = projectSettings.extensions ?? [];
|
||||||
|
|
||||||
|
if (globalExtensions.length === 0 && projectExtensions.length === 0) {
|
||||||
|
console.log(chalk.dim("No extensions installed."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalExtensions.length > 0) {
|
||||||
|
console.log(chalk.bold("Global extensions:"));
|
||||||
|
for (const ext of globalExtensions) {
|
||||||
|
console.log(` ${ext}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectExtensions.length > 0) {
|
||||||
|
if (globalExtensions.length > 0) console.log();
|
||||||
|
console.log(chalk.bold("Project extensions:"));
|
||||||
|
for (const ext of projectExtensions) {
|
||||||
|
console.log(` ${ext}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
await packageManager.update(options.source);
|
await packageManager.update(options.source);
|
||||||
if (options.source) {
|
if (options.source) {
|
||||||
console.log(chalk.green(`Updated ${options.source}`));
|
console.log(chalk.green(`Updated ${options.source}`));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue