-
Notifications
You must be signed in to change notification settings - Fork 3
fix: add streaming + v2 compat, tsup => bun build #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Changes from 2 commits
053bc53
926bb47
4e1f62e
7c26aa5
7a9bc5b
18a0752
388f6b2
f6a675f
2e3634a
db5fdb3
7fd7803
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,42 @@ | ||
| # Dependencies | ||
| node_modules | ||
| .turbo | ||
|
|
||
| # Build outputs | ||
| dist | ||
| build | ||
| *.tsbuildinfo | ||
| .turbo | ||
| .turbo-tsconfig.json | ||
|
|
||
| # Environment files | ||
| .env | ||
| .eliza** | ||
| .env.local | ||
| .env.production | ||
| .env.bak | ||
|
|
||
| # IDE | ||
| .idea | ||
| .vscode | ||
| .zed | ||
| .DS_Store | ||
|
|
||
| # Test coverage | ||
| coverage | ||
| .nyc_output | ||
|
|
||
| # Logs | ||
| *.log | ||
| logs | ||
|
|
||
| # Cache | ||
| cache | ||
| .cache | ||
| tokencache | ||
|
|
||
| # Temporary files | ||
| *.tmp | ||
| *.temp | ||
| .tmp | ||
|
|
||
| # Bundler artifacts | ||
| tsup.config.bundled_*.mjs |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { $ } from "bun"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async function build() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const totalStart = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pkg = await Bun.file("package.json").json(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const externalDeps = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...Object.keys(pkg.dependencies ?? {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...Object.keys(pkg.peerDependencies ?? {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use the clean script from package.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pkg.scripts?.clean) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("🧹 Cleaning..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await $`bun run clean`.quiet(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build script deletes node_modules before tsc needs themHigh Severity
Additional Locations (1) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const esmStart = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("🔨 Building @elizaos/plugin-ollama..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const esmResult = await Bun.build({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoints: ["src/index.ts"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outdir: "dist", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: "node", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format: "esm", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sourcemap: "external", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minify: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| external: externalDeps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!esmResult.success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(esmResult.logs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error("ESM build failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`✅ Build complete in ${((Date.now() - esmStart) / 1000).toFixed(2)}s`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const dtsStart = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (true) { // Always generate .d.ts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("📝 Generating TypeScript declarations..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await $`tsc --project tsconfig.build.json`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`✅ Declarations generated in ${((Date.now() - dtsStart) / 1000).toFixed(2)}s`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(`⚠️ TypeScript declaration generation had errors (${((Date.now() - dtsStart) / 1000).toFixed(2)}s)`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(" Build will continue - fix type errors when possible"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("🔍 Type checking..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await $`tsc --noEmit --incremental --project tsconfig.build.json`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`✅ Type check passed in ${((Date.now() - dtsStart) / 1000).toFixed(2)}s`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(`⚠️ Type checking had errors (${((Date.now() - dtsStart) / 1000).toFixed(2)}s)`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(" Build will continue - fix type errors when possible"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (true) { // Always generate .d.ts | |
| console.log("📝 Generating TypeScript declarations..."); | |
| try { | |
| await $`tsc --project tsconfig.build.json`; | |
| console.log(`✅ Declarations generated in ${((Date.now() - dtsStart) / 1000).toFixed(2)}s`); | |
| } catch (error) { | |
| console.warn(`⚠️ TypeScript declaration generation had errors (${((Date.now() - dtsStart) / 1000).toFixed(2)}s)`); | |
| console.warn(" Build will continue - fix type errors when possible"); | |
| } | |
| } else { | |
| console.log("🔍 Type checking..."); | |
| try { | |
| await $`tsc --noEmit --incremental --project tsconfig.build.json`; | |
| console.log(`✅ Type check passed in ${((Date.now() - dtsStart) / 1000).toFixed(2)}s`); | |
| } catch (error) { | |
| console.warn(`⚠️ Type checking had errors (${((Date.now() - dtsStart) / 1000).toFixed(2)}s)`); | |
| console.warn(" Build will continue - fix type errors when possible"); | |
| } | |
| } | |
| // Always generate .d.ts | |
| console.log("📝 Generating TypeScript declarations..."); | |
| try { | |
| await $`tsc --project tsconfig.build.json`; | |
| console.log(`✅ Declarations generated in ${((Date.now() - dtsStart) / 1000).toFixed(2)}s`); | |
| } catch (error) { | |
| console.warn(`⚠️ TypeScript declaration generation had errors (${((Date.now() - dtsStart) / 1000).toFixed(2)}s)`); | |
| console.warn(" Build will continue - fix type errors when possible"); | |
| } |
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,15 +23,15 @@ | |||||
| ], | ||||||
| "dependencies": { | ||||||
| "@ai-sdk/ui-utils": "^1.2.8", | ||||||
| "@elizaos/core": "^1.0.0", | ||||||
| "@elizaos/core": "1.7.2", | ||||||
| "ai": "^4.3.9", | ||||||
| "js-tiktoken": "^1.0.18", | ||||||
| "ollama-ai-provider": "^1.2.0", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Move the line to |
||||||
| "tsup": "8.4.0" | ||||||
| }, | ||||||
| "scripts": { | ||||||
| "build": "tsup", | ||||||
| "dev": "tsup --watch", | ||||||
| "build": "bun run build.ts", | ||||||
| "dev": "bun run build.ts --watch", | ||||||
|
||||||
| "dev": "bun run build.ts --watch", | |
| "dev": "bun --watch run build.ts", |
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dev script's --watch flag is not handled by build.ts.
The dev script passes --watch to build.ts, but build.ts doesn't parse command-line arguments or implement watch mode. The script will run once and exit, not providing the expected continuous rebuild behavior.
Consider either:
- Implementing watch mode in
build.tsusingBun.argvor a flag parser - Using a different approach for dev mode (e.g., keeping tsup for watch mode)
♻️ Example watch mode implementation
+const watchMode = Bun.argv.includes("--watch");
+
async function build() {
// ... existing build logic ...
}
-build().catch((err) => {
- console.error("Build failed:", err);
- process.exit(1);
-});
+if (watchMode) {
+ const { watch } = await import("fs");
+ console.log("👀 Watching for changes...");
+ build(); // Initial build
+ watch("src", { recursive: true }, async (event, filename) => {
+ console.log(`\n📝 ${filename} changed, rebuilding...`);
+ await build();
+ });
+} else {
+ build().catch((err) => {
+ console.error("Build failed:", err);
+ process.exit(1);
+ });
+}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@package.json` around lines 33 - 34, The dev script passes --watch to build.ts
but build.ts doesn't read CLI flags, so implement watch handling: update
build.ts to parse Bun.argv (or a flag parser) and add a watch mode that runs the
existing build logic repeatedly or hooks into a file watcher; specifically
detect the presence of "--watch" (or "--watch=true") in Bun.argv inside build.ts
and, when present, start a file watcher loop that re-runs the build routine (the
same function currently performing the single build) on file changes, or
alternatively remove the flag from package.json and use a separate watcher
tool—ensure changes reference build.ts and Bun.argv (or the chosen flag parser)
and reuse the existing build function to avoid duplication.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build.ts always runs the package's clean script before building. In this repo the clean script removes
node_modules, so running build/dev will delete installed dependencies and can break or severely slow builds. Consider limiting clean to build artifacts (e.g., dist/tsbuildinfo) or make cleaning opt-in via a flag.