Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Integrate acp protocol#23
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0ce0d158c1f2024e4853865eb224a75e0424ee83e48929d72d072b7f6ef49c31ef922d4bb93ddFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import type { Migration } from "../migrator.ts"; | ||
| export default { | ||
| name: "007_add_claude_state", | ||
| up(db) { | ||
| const cols = db.query<{ name: string }>("SELECT name FROM pragma_table_info('agents')"); | ||
| if (!cols.some((c) => c.name === "claude_state")) { | ||
| db.run("ALTER TABLE agents ADD COLUMN claude_state TEXT"); | ||
| } | ||
| }, | ||
| } satisfies Migration; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import type { Migration } from "../migrator.ts"; | ||
| export default { | ||
| name: "008_add_acp_state", | ||
| up(db) { | ||
| const cols = db.query<{ name: string }>("SELECT name FROM pragma_table_info('agents')"); | ||
| if (!cols.some((c) => c.name === "acp_state")) { | ||
| db.run("ALTER TABLE agents ADD COLUMN acp_state TEXT"); | ||
| } | ||
| }, | ||
| } satisfies Migration; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type { Migration } from "../migrator.ts"; | ||
| export default { | ||
| name: "009_add_agent_state", | ||
| up(db) { | ||
| const cols = db.query<{ name: string }>("SELECT name FROM pragma_table_info('agents')"); | ||
| const colNames = new Set(cols.map((c) => c.name)); | ||
| if (!colNames.has("agent_state")) { | ||
| db.run("ALTER TABLE agents ADD COLUMN agent_state TEXT"); | ||
| } | ||
| if (colNames.has("claude_state")) { | ||
| db.run("UPDATE agents SET agent_state = COALESCE(agent_state, claude_state)"); | ||
| db.run("ALTER TABLE agents DROP COLUMN claude_state"); | ||
| } | ||
| if (colNames.has("acp_state")) { | ||
| db.run("UPDATE agents SET agent_state = COALESCE(agent_state, acp_state)"); | ||
| db.run("ALTER TABLE agents DROP COLUMN acp_state"); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| }, | ||
| } satisfies Migration; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
🌐 Web query:
In Bun 1.3.x, doesbun:sqlite'sDatabase.query()return a statement that requires calling.all()/.get(), or can it be used directly with array methods like.map()?💡 Result:
In Bun 1.3.x,
bun:sqlite’sDatabase.query()returns a preparedStatementobject, and the SQL is not executed until you call methods like.all()or.get()on thatStatement.[1][2] So you cannot directly dodb.query(...).map(...)because the return value fromDatabase.query()is aStatement, not an array. To use array methods, you must execute the statement first, e.g.db.query(...).all().map(...)(or.get()if you expect a single row).[1][3] Example: const stmt = db.query("SELECT * FROM users"); // prepares; does not run yet const users = stmt.all; const names = users.map(u => u.name); This matches the docs showing:const stmt = db.query(...); // run the query stmt.all(...)and that.all()returns results as an array of objects.[2][3]Citations:
🏁 Script executed:
cat -n src/backend/db/migrations/009_add_agent_state.ts | head -30Repository: inputforge/agentforge
Length of output: 802
Call
.all()before iterating the pragma rows.db.query()returns aStatementobject inbun:sqlite, not an array. Calling.map()directly on it will throw a runtime error, causing the migration to fail. Use.all()to execute the statement and get results as an array.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents