-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix plugins installing during init and plugins add
- Loading branch information
1 parent
edcd6b3
commit 88dcefd
Showing
5 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# No configuration needed for SQLite | ||
# No configuration needed for SQLite | ||
ELIZA_BRANCH=v2-develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { execa } from "execa"; | ||
import path from "node:path"; | ||
import { logger } from "@/src/utils/logger"; | ||
import { runBunCommand } from "@/src/utils/run-bun"; | ||
import { promises as fs } from "fs"; | ||
|
||
export async function installPlugin( | ||
pluginName: string, | ||
cwd: string, | ||
): Promise<void> { | ||
// Remove 'github:' or leading '@' prefix if present | ||
const cleanedName = pluginName.replace(/^github:|^@/, ""); | ||
let installed = false; | ||
try { | ||
//logger.info(`Attempting to install ${pluginName} using bun add...`); | ||
//await runBunCommand(["add", `${pluginName}`], cwd); | ||
//logger.success(`Successfully installed ${pluginName} via bun add.`); | ||
//installed = true; | ||
// Set the directory to clone into the packages folder (each plugin gets its own subfolder) | ||
const cloneDir = path.join(cwd, "packages", cleanedName.replace(/\S+\//, "")); | ||
logger.info(`Cloning ${pluginName} from https://github.com/${cleanedName}.git to ${cloneDir}`); | ||
await execa("git",["clone", `https://github.com/${cleanedName}.git`, cloneDir],{ cwd, stdio: "inherit" }); | ||
logger.success(`Successfully cloned repository for ${cleanedName}.`); | ||
installed = true; | ||
} catch (error: any) { | ||
logger.warn( | ||
`failed to install packages for ${cleanedName}, falling back: ${error.message}` | ||
); | ||
} | ||
|
||
if (installed) { | ||
// Try to read the package.json file from the cloned plugin repo | ||
let pkgName = cleanedName; | ||
const pkgPath = path.join(cwd, "packages", cleanedName.replace(/\S+\//, ""), "package.json"); | ||
try { | ||
const pkgContent = await fs.readFile(pkgPath, "utf-8"); | ||
const pkg = JSON.parse(pkgContent); | ||
if (pkg.name) { | ||
pkgName = pkg.name; | ||
logger.info(`Found package.json name: ${pkgName}`); | ||
} | ||
} catch (err: any) { | ||
logger.warn(`Could not read package.json from ${pkgPath}: ${err.message}`); | ||
} | ||
|
||
logger.info(`Adding ${pkgName} to workspace's agent package (packages/agent/package.json)...`); | ||
await runBunCommand( | ||
["add", `${pkgName}@workspace:*`, "--filter", "./packages/agent"], | ||
cwd | ||
); | ||
logger.success(`Successfully added ${pkgName} to agent workspace.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { execa } from "execa"; | ||
|
||
export async function runBunCommand(args: string[], cwd: string): Promise<void> { | ||
await execa("bun", args, { cwd, stdio: "inherit" }); | ||
} |