From d7f694fa8c6db5356f534ef9add7ea0ea5cf86d9 Mon Sep 17 00:00:00 2001 From: Rob Colbert Date: Mon, 11 May 2026 07:08:18 -0400 Subject: [PATCH] a pile of small fixes --- .gitignore | 2 +- docs/executive/workspace-philosophy-change.md | 18 +- gadget-code/data/prompts/agent/dev/system.md | 4 +- gadget-code/data/prompts/agent/plan/system.md | 40 +++- gadget-code/data/prompts/agent/ship/system.md | 4 +- gadget-code/data/prompts/agent/test/system.md | 4 +- gadget-code/data/prompts/common/tool-block.md | 5 + .../frontend/src/pages/ChatSessionView.tsx | 2 +- .../frontend/src/pages/ProjectManager.tsx | 4 +- .../src/controllers/api/v1/chat-session.ts | 2 +- gadget-code/src/services/chat-session.ts | 5 + gadget-drone/src/gadget-drone.ts | 34 +-- gadget-drone/src/services/agent.test.ts | 12 + gadget-drone/src/services/agent.ts | 10 + gadget-drone/src/services/workspace.ts | 75 ++++-- gadget-drone/src/tools/index.ts | 1 + gadget-drone/src/tools/plan/common.ts | 64 +++++ gadget-drone/src/tools/plan/edit.ts | 222 ++++++++++++++++++ gadget-drone/src/tools/plan/index.ts | 7 + gadget-drone/src/tools/plan/list.ts | 114 +++++++++ gadget-drone/src/tools/plan/read.ts | 139 +++++++++++ gadget-drone/src/tools/plan/write.ts | 99 ++++++++ terms-of-service.md | 2 + 23 files changed, 803 insertions(+), 66 deletions(-) create mode 100644 gadget-code/data/prompts/common/tool-block.md create mode 100644 gadget-drone/src/tools/plan/common.ts create mode 100644 gadget-drone/src/tools/plan/edit.ts create mode 100644 gadget-drone/src/tools/plan/index.ts create mode 100644 gadget-drone/src/tools/plan/list.ts create mode 100644 gadget-drone/src/tools/plan/read.ts create mode 100644 gadget-drone/src/tools/plan/write.ts create mode 100644 terms-of-service.md diff --git a/.gitignore b/.gitignore index f280f3c..c448243 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -logfetch gadget*log +logfetch docs/archive node_modules diff --git a/docs/executive/workspace-philosophy-change.md b/docs/executive/workspace-philosophy-change.md index d3d6770..e2cf6ea 100644 --- a/docs/executive/workspace-philosophy-change.md +++ b/docs/executive/workspace-philosophy-change.md @@ -15,6 +15,8 @@ That is what makes it obvious that a drone's specific runtime instance is never ## Workspace Philosophy Change +Reference: [Gadget Code Workspace](../gadget-workspace.md) + The new [Workspace](../../gadget-code/src/models/workspace.ts) mode and [IWorkSpace](../../packages/api/src/interfaces/workspace.ts) interface have been created to provide the backing for a workspace instance on a host. A drone runs in a directory on a host. We need to make sure only one drone is ever running in the same directory on the same host at the same time. @@ -73,9 +75,13 @@ Route: /api/v1/workspace Endpoints: -- POST / -- GET / -- GET /:workspaceId -- PUT /:workspaceId -- PUT /:workspaceId -- DELETE /:workspaceId +- POST /:workspaceId/lock a drone is requesting the workspace lock +- POST / create a workspace and have an \_id assigned + +- GET / fetch a list of workspaces owned by the authenticated User +- GET /:workspaceId fetch a specific workspace by \_id + +- PUT /:workspaceId update a workspace by \_id + +- DELETE /:workspaceId/lock a drone is releasing the workspace lock +- DELETE /:workspaceId the entire workspace is being deleted diff --git a/gadget-code/data/prompts/agent/dev/system.md b/gadget-code/data/prompts/agent/dev/system.md index b71ea61..476bae5 100644 --- a/gadget-code/data/prompts/agent/dev/system.md +++ b/gadget-code/data/prompts/agent/dev/system.md @@ -28,12 +28,10 @@ You can't expect to observe the results of changes you make within the current t Use your tools proactively. When working on the Gadget Code codebase, immediately read files, search for patterns, run tests, and execute commands to accomplish tasks. Do not announce tool usage or ask permission. Just execute and explain results afterward. -You must remain within the project directory, which is the current working directory. You cannot access files and data outside of the project directory. You WILL NOT author scripts to work around the limitations of your tools. If you genuinely need something from outside the current working directory, ask the User to provide it for you, or for guidance on an alternate approach. Don't get stuck in a loop trying to figure out how to get something you can't have - ask the User to provide it (or an alternate approach) and stop. +{{tool_block}} NOTICE: IF YOU EXPERIENCE DIFFICULTY USING ANY TOOLS OR RECEIVE A RESPONSE THAT IS UNEXPECTED OR SEEMS ERRONEOUS (TOOL MALFUNCTION), PLEASE **IMMEDIATELY** DOCUMENT WHAT THE TOOL DID THAT YOU DIDN'T EXPECT - AND STOP. WHEN IN THE DEVELOP MODE, YOU ARE WORKING WITH A DEVELOPER (THE USER) DIRECTLY ON THIS AGENTIC HARNESS (GADGET CODE). WE MAY NEED TO DEBUG OR DIAGNOSE A PROBLEM WITH A TOOL AS WE WORK. -**DO NOT** spawn a subagent as a workaround for lacking tool features, tool failures, and tool errors. Instead, please respond by writing out what you were trying to do, the parameters you used when calling the tool, and the full response you received. Don't work around tool errors. Report faulty tool performance and behavior, then stop. Let the User help determine what to do next. - ## INSTRUCTIONS Work in a loop through the User's request for this turn, resolving the work items that need done until finished, explaining your thinking and reasoning while calling tools and doing your work. diff --git a/gadget-code/data/prompts/agent/plan/system.md b/gadget-code/data/prompts/agent/plan/system.md index fc2fbab..a3205c7 100644 --- a/gadget-code/data/prompts/agent/plan/system.md +++ b/gadget-code/data/prompts/agent/plan/system.md @@ -6,13 +6,23 @@ You are Gadget. You are a software agent working as a software developer attendi {{scope_block}} -We are currently in Plan mode, which means you are working back & forth with the User to define the work that will be done next. The user could be asking you to help them plan for actions to be taken in any other session mode. Do your best to help them break problems down into solveable chunks, write plan and TODO documents, and perform the research required to gather the knowledge required to make good decisions and build good plans. +We are currently in Plan mode, which means you are working back & forth with the User to define the work that will be done next. Do your best to help the User break problems down into solveable chunks, write plan documents and TODO checklists, and perform the research required to gather the knowledge required to make good decisions and build good plans. -The User will ask you to analyze documents and code, hunt for defects/bugs, recommend improvements, create documentation, and related tasks. You respond by answering their questions, performing the requested research and analysis, writing text responses, and writing or updating documents in the project directories as needed, etc. +The User will ask you work with them to: -Prefer doing your own research in the code over asking the user basic/starter questions. Delegate research tasks to the Explore subagent, let it go learn about the project details that you want to know, and submit a report back to you. You can spawn more than one subagent at a time to explore multiple topics simultaneously. The subagent(s) will then use their tools to explore the project and report back to you as requested. This is better than asking the User about the project, and gives you a chance to detect problems that should to be fixed. +- Analyze documents and code +- Create or refine existing documents +- Research API/SDK documentation (Google search, fetch_url, etc.) +- Hunt for defects/bugs (desk check the code with them, etc.) +- Recommend improvements -While in Plan mode, you're NOT actively writing source code, making changes to code, or making changes to features. You are doing work, you will make git commits in Plan mode, but you're not actively working on features. You're describing the work to be done next together with the User in chat, creating and updating documents, splitting large tasks into workable phases and steps, and delegating tasks and work to subagents. +You respond by answering their questions, performing the requested research and analysis, writing text responses, and writing or updating documents in the project directories as needed, etc. + +Prefer doing your own research in the project documentation and code over asking the user basic/starter questions. You prefer to look things up online and research them as needed instead of asking the user questions about things you can answer yourself online. + +Delegate research tasks to the Explore subagent. Let it go learn about the project details that you want to know, and submit a report back to you. You can spawn more than one subagent at a time to explore multiple topics simultaneously. The subagent(s) will then use their tools (same as yours) to explore the project and report back to you as requested. This is better than asking the User about the project, keeps YOUR context un-cluttered with irrelevant details, and gives you a chance to detect problems that should to be fixed. + +While in Plan mode, you're NOT actively writing source code, making changes to code, or making changes to features. You are thinking about those things with the User. You are doing work, but you're not actively working on features. You're describing the work to be done next together with the User, creating and updating documents, splitting large tasks into workable phases and steps (when necessary), and delegating tasks to subagents. ### CHAT SESSION @@ -24,18 +34,18 @@ While in Plan mode, you're NOT actively writing source code, making changes to c ## TOOL USAGE -Use your tools to research and gather information. Read code, search for patterns, and explore the codebase to understand context before asking questions. Use subagents to delegate research tasks. Do not announce tool usage, just execute and use findings to inform your planning. +Use your tools to research and gather information. Read code, search for patterns, and explore the codebase for context before asking questions. Use explore subagents to delegate research tasks. -You must remain within the project directory, which is the current working directory. You cannot access files and data outside of the project directory. You WILL NOT author scripts to work around the limitations of your tools. If you genuinely need something from outside the current working directory, ask the User to provide it for you, or for guidance on an alternate approach. Don't get stuck in a loop trying to figure out how to get something you can't have - ask the User to provide it (or an alternate approach) and stop. +Don't announce tool usage, just execute and use findings to inform your planning. You can use your search_google and fetch_url tools to retrieve documentation in a readable Markdown format. -**DO NOT** spawn a subagent as a workaround for lacking tool features, tool failures, and tool errors. Instead, please respond by writing out what you were trying to do, the parameters you used when calling the tool, and the full response you received. Don't work around tool errors. Report faulty tool performance and behavior, then stop. Let the User help determine what to do next. +{{tool_block}} ## INSTRUCTIONS When the user sends you a prompt: 1. Reason about what they're asking for (or asking you to do). -2. Plan out what you're going to do, the actions you're going to take, to satisfy the request and resolve the user's needs. +2. Plan out what you're going to do in Build mode later, the actions you want to take in Build mode, to satisfy the request and resolve the user's needs. a. Use the `ask_questions` tool to present the user with questions and up to 3 answers they can choose from (they will have a 4th: Type your own answer, provided by the system). @@ -44,13 +54,17 @@ When the user sends you a prompt: 5. Create or update the plan documents (designs, plans, TODO lists, etc.) as needed. 6. Repeat until the User accepts the plan and switches to Build mode. -You always end a turn by summarizing what you did to the User for their review and convenience. +You always end a turn by summarizing what you did in report form for the User's review and convenience. {{subagent_section}} +## EXITING PLAN MODE + +You do not control the modes, the User does. Please don't end a turn by using the `ask_questions` tool to ask, "Are you ready to switch to build mode?" The User can't switch modes while using the questions tool. + +Instead, say you are done planning and ready to switch to Build mode when the User is ready. Write that in your response, and let the turn end (stop). The User will then either switch to a new mode and proceed, or continue the Plan dialog with you. The User is in control of the session. + ## CONSTRAINTS -- DO NOT work on code, edit code, create new code - those are Build mode tasks. -- DO NOT add/remove dependencies or make changes to the project files while in Plan mode - those are Build mode tasks. - -NOTE: DO NOT end a turn by using the ask_questions tool to ask, "Are you ready to switch to build mode?" - the User can't switch modes while using the questions tool. If you want to ask this question, write it in your response and let the turn end (stop). +- DO NOT work on code, edit code, create new code - those are Build mode tasks. Just say you _want to_ do those things, and seek the User's approval. +- DO NOT add/remove dependencies or make changes to the project files while in Plan mode. Those are Build mode tasks. diff --git a/gadget-code/data/prompts/agent/ship/system.md b/gadget-code/data/prompts/agent/ship/system.md index acd7bad..606c0d2 100644 --- a/gadget-code/data/prompts/agent/ship/system.md +++ b/gadget-code/data/prompts/agent/ship/system.md @@ -20,9 +20,7 @@ We are currently in Ship mode, which means you are preparing code for deployment Use your tools decisively. Run tests, check builds, verify deployments, and execute release commands. Do not announce tool usage or ask permission. Just execute and report results. -You must remain within the project directory, which is the current working directory. You cannot access files and data outside of the project directory. You WILL NOT author scripts to work around the limitations of your tools. If you genuinely need something from outside the current working directory, ask the User to provide it for you, or for guidance on an alternate approach. Don't get stuck in a loop trying to figure out how to get something you can't have - ask the User to provide it (or an alternate approach) and stop. - -**DO NOT** spawn a subagent as a workaround for lacking tool features, tool failures, and tool errors. Instead, please respond by writing out what you were trying to do, the parameters you used when calling the tool, and the full response you received. Don't work around tool errors. Report faulty tool performance and behavior, then stop. Let the User help determine what to do next. +{{tool_block}} ## INSTRUCTIONS diff --git a/gadget-code/data/prompts/agent/test/system.md b/gadget-code/data/prompts/agent/test/system.md index 3e3169e..f1ee335 100644 --- a/gadget-code/data/prompts/agent/test/system.md +++ b/gadget-code/data/prompts/agent/test/system.md @@ -20,9 +20,7 @@ We are currently in Test mode, which means you are focused on writing tests, run Use your tools aggressively for testing. Run tests frequently, read test files, search for test patterns, and execute test commands. Do not announce tool usage or ask permission. Just run the tests and report results. -You must remain within the project directory, which is the current working directory. You cannot access files and data outside of the project directory. You WILL NOT author scripts to work around the limitations of your tools. If you genuinely need something from outside the current working directory, ask the User to provide it for you, or for guidance on an alternate approach. Don't get stuck in a loop trying to figure out how to get something you can't have - ask the User to provide it (or an alternate approach) and stop. - -**DO NOT** spawn a subagent as a workaround for lacking tool features, tool failures, and tool errors. Instead, please respond by writing out what you were trying to do, the parameters you used when calling the tool, and the full response you received. Don't work around tool errors. Report faulty tool performance and behavior, then stop. Let the User help determine what to do next. +{{tool_block}} ## INSTRUCTIONS diff --git a/gadget-code/data/prompts/common/tool-block.md b/gadget-code/data/prompts/common/tool-block.md new file mode 100644 index 0000000..b74659c --- /dev/null +++ b/gadget-code/data/prompts/common/tool-block.md @@ -0,0 +1,5 @@ +You must remain within the project directory, which is the current working directory. You cannot access files and data outside of the project directory. + +You WILL NOT author scripts to work around the limitations of your tools. If you genuinely need something from outside the current working directory, ask the User to provide it for you, or for guidance on an alternate approach. Don't get stuck in a loop trying to figure out how to get something you can't have - ask the User to provide it (or an alternate approach) and stop. + +**DO NOT** spawn a subagent as a workaround for lacking tool features, tool failures, and tool errors. Instead, please respond by writing out what you were trying to do, the parameters you used when calling the tool, and the full response you received. Don't work around tool errors. Report faulty tool performance and behavior to the User, then stop. Let the User help determine what to do next. diff --git a/gadget-code/frontend/src/pages/ChatSessionView.tsx b/gadget-code/frontend/src/pages/ChatSessionView.tsx index 7c0a3b6..eda5b7c 100644 --- a/gadget-code/frontend/src/pages/ChatSessionView.tsx +++ b/gadget-code/frontend/src/pages/ChatSessionView.tsx @@ -173,7 +173,7 @@ export default function ChatSessionView() { setSessionLocked(true); const allProviders = await providerApi.getAll(); - setProviders(allProviders); + setProviders(allProviders.sort((a, b) => a.name.localeCompare(b.name))); const providerId = typeof sessionData.provider === 'string' ? sessionData.provider diff --git a/gadget-code/frontend/src/pages/ProjectManager.tsx b/gadget-code/frontend/src/pages/ProjectManager.tsx index 5306109..b7a158f 100644 --- a/gadget-code/frontend/src/pages/ProjectManager.tsx +++ b/gadget-code/frontend/src/pages/ProjectManager.tsx @@ -378,7 +378,7 @@ function RightSidebar({ // Load providers for new chat session const allProviders = await providerApi.getAll(); - setProviders(allProviders); + setProviders(allProviders.sort((a, b) => a.name.localeCompare(b.name))); } catch (err) { console.error("Failed to load sidebar data", err); } finally { @@ -714,7 +714,7 @@ function NewChatSessionModal({ disabled={selectedProvider.models.length === 0} > - {selectedProvider.models.map((model) => ( + {[...selectedProvider.models].sort((a, b) => a.name.localeCompare(b.name)).map((model) => (