Repository navigation
Add JSON output, a Python API and a GitHub Action - #81
Merged
Merged
Conversation
lcode -p --output json prints one result object (status, answer, tool calls, files changed, usage); --output stream-json prints an event per model step and tool result, then the result. --max-steps and --allowed-tools limit a run, and the exit code says how it ended. Without a person to ask, permission requests are refused. from lcode import Session runs requests from Python: run() returns the same result, stream() yields the events, and approve() decides permission requests. cmd_chat now sets up its agent through the same open_agent(). lcode action, with action.yml, runs lcode as a GitHub Action on a self-hosted runner: it answers @lcode in issues and pull requests from trusted people, commits changes to a new pull request (or the pull request's branch), and can review pull requests. The model can't run git steps itself, and its reply is written after the change is proposed. Closes #48 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
This file contains hidden or 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
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.
Closes #48.
What
lcode -p "…" --output jsonprints one result object:status,text,tool_calls(arguments, output, error),files_changed(from the request's checkpoint, so shell commands count too),usage,seconds,session_id.--output stream-jsonprints astartevent, then anassistantevent per model step and atool_resultper call, then the same result.--max-steps Nand--allowed-tools LISTlimit a run.0success,1error,3stopped at max steps,130interrupted.from lcode import Session(loaded lazily, soimport lcodestays fast).run()returns theResult;stream()yields the events.approve(request)decides permission requests; for shell commands, the target is the command without itscd <dir> &&prefix.cmd_chatnow sets up its agent through the sameapi.open_agent(), which raisesSetupErrorinstead of exiting.examples/api/fix_tests.py.action.yml(composite) runslcode actionon a self-hosted runner.@lcodecomments from owners, members and collaborators (bots are ignored), and, withreview: true, new and updated pull requests (forks only withreview-forks).lcode, with a pull request that closes the issue. On a pull request, they're pushed to its branch.git commit/push/checkout/switch/…andgh. Its reply is asked for after the change is proposed, so it describes the change instead of talking about committing.allow-commandslets the model run tests inauto-editmode. The prompt marks issue text and code as information, not commands.uvx, an installedlcode, or pip in a virtual environment.Tests
tests/test_api.py(7 tests): results, files and usage;approve; max steps; errors; unknown tools; streaming; multi-turn sessions;--output jsonandstream-jsonthroughcli.main; JSON errors before a run starts.tests/test_action.py(6 tests), with a fake GitHub API, a bare remote and a scripted model:--output json: fixed two bugs and reportedcalc.pyas changed, with 6 requests and about 35K prompt tokens.--output stream-json --max-steps 3: the expected events, exit code 3, and the refusedbashcall marked as an error.examples/api/fix_tests.py: approved onlypytest; fixed the code; tests pass.lcode actionon a simulated@lcodeissue comment, with a fake GitHub API and a bare remote. lcode reacted, ran the tests throughallow-commands, and pushedlcode/issue-4-…with the fix. It opened a pull request that closes /undo and automatic checkpoints before changes #4 and replied with a clean summary.🤖 Generated with Claude Code