Add codemode: typechecked TypeScript execution with tools#16
Open
jonastemplestein wants to merge 14 commits intomainfrom
Open
Add codemode: typechecked TypeScript execution with tools#16jonastemplestein wants to merge 14 commits intomainfrom
jonastemplestein wants to merge 14 commits intomainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds codemode execution to the agent: the LLM can write TypeScript code blocks that are typechecked and executed, with access to tools for file I/O, shell commands, web fetching, and secrets.
Features
Code Execution
<codemode>...</codemode>blocks are typechecked with strict TypeScriptAvailable Tools
t.sendMessage(msg)— show message to USER (no agent turn)t.readFile(path)/t.writeFile(path, content)— file I/Ot.exec(command)— run shell commandst.fetch(url)— HTTP requestst.getSecret(name)— access secrets (hidden from LLM)Agent Loop
console.log()output triggers another agent turnt.sendMessage()output goes to user, no turnEvent Model
triggerAgentTurnproperty to all eventstriggerAgentTurn="after-current-turn"CodemodeResultEventpersisted with stdout/stderr for conversation historyFiles Added
src/codemode.model.ts— code block parsing, event typessrc/codemode.service.ts— orchestrates parse → typecheck → executesrc/codemode.repository.ts— stores generated code filessrc/code-executor.service.ts— runs code in Bun subprocesssrc/typechecker.service.ts— TypeScript type checkingtest/codemode.e2e.test.ts— end-to-end testsAll 75 tests pass.
Note
Adds codemode enabling LLM-emitted TypeScript to be typechecked and executed via Bun with tools, persisting results to drive an agent loop across CLI/UI/HTTP and a new per-context storage layout.
codemodepipeline: parse<codemode>blocks, typecheck (TS), execute via Bun subprocess, stream events.CodemodeService,TypecheckService,CodeExecutor,CodemodeRepository.CodemodeResultEvent,CodemodeValidationErrorEventand codemode streaming events; addtriggerAgentTurnto events.ContextService.addEventssupports codemode and emits codemode events; swaps in codemode system prompt when enabled.triggerAgentTurnwith persistedCodemodeResult.codemode runsubcommand; integrate codemode intochatflow with an agent loop (iteration cap) and colored streaming output.ContextOrCodemodeEvent.events.yaml; repository APIs updated (getContextDir, listing by directories).src/**/*.test.ts..mini-agent/**.Written by Cursor Bugbot for commit 8f32ec5. This will update automatically on new commits. Configure here.