Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 80 additions & 8 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@ on:
branches: [ "main" ]
release:
types: [ published ]
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish to VS Code Marketplace (e.g. 0.2.4 or v0.2.4)"
required: true
type: string
pre_release:
description: "Publish as a VS Code Marketplace pre-release"
required: false
default: false
type: boolean

permissions:
contents: read

jobs:
build:
if: github.event_name != 'workflow_dispatch'
name: Build and test (${{ matrix.os }})
strategy:
fail-fast: false
Expand Down Expand Up @@ -102,10 +114,13 @@ jobs:
if-no-files-found: error
retention-days: 14

# Publishing a GitHub release (tag vX.Y.Z) builds the distribution jars and
# the compiled VS Code extension (.vsix) in separate, cache-free jobs so npm
# packaging cannot touch the tested CLI jars. Only the upload job, which runs
# no project code, receives `contents: write`.
# Publishing a GitHub release (tag X.Y.Z or vX.Y.Z) builds the distribution jars
# and the compiled VS Code extension (.vsix) in separate, cache-free jobs so npm
# packaging cannot touch the tested CLI jars. Only `publish-release` receives
# `contents: write`, and only `publish-vscode-marketplace` receives
# `id-token: write` (scoped to the `vscode-marketplace` environment for OIDC
# Trusted Publishing); neither runs project code. Manual `workflow_dispatch`
# runs only the VSIX build and Marketplace publish for an existing tag.
build-release-jars:
if: github.event_name == 'release'
needs: build
Expand Down Expand Up @@ -151,14 +166,27 @@ jobs:
if-no-files-found: error

build-release-vsix:
if: github.event_name == 'release'
if: ${{ !cancelled() && ((github.event_name == 'release' && needs.build.result == 'success') || github.event_name == 'workflow_dispatch') }}
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
version: ${{ steps.version.outputs.version }}
pre_release: ${{ steps.version.outputs.pre_release }}

steps:
- name: Validate release tag input
if: github.event_name == 'workflow_dispatch'
env:
TAG: ${{ inputs.tag }}
run: |
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::tag '$TAG' must match v?MAJOR.MINOR.PATCH (e.g. 0.2.4 or v0.2.4)"
exit 1
fi
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || '' }}
persist-credentials: false
- name: Set up Node.js 22
uses: actions/setup-node@v4
Expand All @@ -167,11 +195,12 @@ jobs:
- name: Check that the release tag matches Versions.atc and vscode/package.json
id: version
env:
TAG: ${{ github.event.release.tag_name }}
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.release.tag_name }}
PRE_RELEASE: ${{ (github.event_name == 'workflow_dispatch' && inputs.pre_release) || (github.event_name == 'release' && github.event.release.prerelease) }}
run: |
version=$(sed -nE 's/^ *val atc = "([^"]+)".*/\1/p' build.mill)
vscode_version=$(node -p "require('./vscode/package.json').version")
echo "tag: $TAG, Versions.atc: $version, vscode/package.json: $vscode_version"
echo "tag: $TAG, Versions.atc: $version, vscode/package.json: $vscode_version, pre_release: $PRE_RELEASE"
if [ "$TAG" != "v$version" ] && [ "$TAG" != "$version" ]; then
echo "::error::release tag '$TAG' does not match Versions.atc = \"$version\" in build.mill; bump the version, move the tag and publish again"
exit 1
Expand All @@ -181,14 +210,24 @@ jobs:
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
if [ "$PRE_RELEASE" = "true" ]; then
echo "pre_release=true" >> "$GITHUB_OUTPUT"
else
echo "pre_release=false" >> "$GITHUB_OUTPUT"
fi
- name: Build, test, and package VS Code extension
env:
VERSION: ${{ steps.version.outputs.version }}
PRE_RELEASE: ${{ steps.version.outputs.pre_release }}
run: |
npm --prefix vscode ci
npm --prefix vscode run typecheck
npm --prefix vscode run test:unit
npm --prefix vscode run package
if [ "$PRE_RELEASE" = "true" ]; then
npm --prefix vscode run package -- --pre-release
else
npm --prefix vscode run package
fi
test -f "vscode/atc-vscode-${VERSION}.vsix"
- name: Stage release VSIX
env:
Expand Down Expand Up @@ -233,3 +272,36 @@ jobs:
fi
gh release upload "$TAG" assets/atc.jar assets/atc-lib.jar "${vsix[0]}"
gh release view "$TAG" --json assets --jq '.assets[] | "\(.name)\t\(.size) bytes"'

publish-vscode-marketplace:
if: ${{ !cancelled() && needs.build-release-vsix.result == 'success' && ((github.event_name == 'release' && needs.publish-release.result == 'success') || github.event_name == 'workflow_dispatch') }}
needs: [build-release-vsix, publish-release]
runs-on: ubuntu-latest
timeout-minutes: 10
environment: vscode-marketplace
permissions:
id-token: write

steps:
- uses: actions/download-artifact@v4
with:
name: release-vsix
path: assets
- name: Set up Node.js 22
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Publish VS Code extension to Visual Studio Marketplace (OIDC)
env:
PRE_RELEASE: ${{ needs.build-release-vsix.outputs.pre_release }}
run: |
vsix=(assets/atc-vscode-*.vsix)
if [ "${#vsix[@]}" -ne 1 ] || [ ! -f "${vsix[0]}" ]; then
echo "::error::expected exactly one .vsix asset in assets/, found: ${vsix[*]}"
exit 1
fi
publish_args=(publish --oidc --skip-duplicate --packagePath "${vsix[0]}")
if [ "$PRE_RELEASE" = "true" ]; then
publish_args+=(--pre-release)
fi
npx --yes @vscode/vsce@4.1.1 "${publish_args[@]}"
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ atc -p 'summarize the README'
atc -p 'summarize the README' --output json
```

To use ATC inside VS Code, see the [VS Code extension](#vs-code-extension).

## Capabilities and ambient authority

In ordinary Scala, any expression can call `Files.readString` or spawn a subprocess;
Expand Down Expand Up @@ -569,7 +571,13 @@ any retained run in full. Press Ctrl-O to toggle expanded streaming of code, out
diffs, and reasoning. While the agent is working, you can type and submit a steering
message (using Backspace, Ctrl-W, Ctrl-U, or Esc to edit or discard the draft); it is
delivered before the next tool call. Long pastes collapse into placeholders such as
`[Pasted text #1: 120 lines]` in the input buffer while sending the full text. Interactive
`[Pasted text #1: 120 lines]` in the input buffer while sending the full text. You can
attach images to prompts with `/image <path>` (alias `/attach`), `Ctrl-V` (reads the OS
clipboard), or by dragging and dropping image files onto the terminal; the agent can also
inspect readable, unclassified image files or raw image bytes directly from the REPL via
`viewImage`. Large images are automatically resized and compressed, classified paths are
guarded, and saved sessions replace binary image payloads with compact metadata
placeholders. Interactive
sessions auto-save after each turn, and the next interactive start in the same directory
offers to resume. ATC notifies you when a turn finishes or awaits input, and emits Program
Status Protocol updates for supporting terminals. Background monitor messages trigger a
Expand All @@ -582,7 +590,9 @@ The terminal tab (and the tmux window when running inside tmux) is titled
<name>` or the agent's `setTitle` renames it for the session.

In `-p` non-interactive mode, ATC never prompts: unpermitted operations fail immediately
unless `--approve-all` is passed (intended only for trusted environments). By default, the
unless `--approve-all` is passed (intended only for trusted environments). Pass repeatable
`-i` / `--image <file>` flags to attach images to a `-p` request (or pre-stage them on
interactive startup). By default, the
final answer is written to standard output while notices, tool blocks, and statistics go to
standard error; with `--output json`, structured JSONL events (`start`, `tool_start`,
`tool_end`, `delta`, `result`, …) are emitted to standard output instead.
Expand All @@ -591,11 +601,25 @@ standard error; with `--output json`, structured JSONL events (`start`, `tool_st

A VS Code extension lives in [vscode/](vscode/README.md) and communicates with a persistent
`atc --ide` session over a bidirectional JSONL stdio protocol. It provides a native sidebar
chat panel with streaming Markdown, collapsible Scala 3 REPL tool blocks, clickable inline
chat panel with streaming Markdown, collapsible Scala 3 REPL tool blocks, image attachments
(paste, drag-and-drop, file picker, and inline `viewImage` previews), clickable inline
diffs, interactive permission/question/skill/project-trust approval cards, mode and model
pickers, editor actions (send/explain selection, fix diagnostics, run Scala selection in the
shared REPL), a status bar indicator, and JSON Schema validation for `.atc/config.json`.

After [installing ATC](#setup), install the extension from the
[Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noti0na1.atc-vscode)
(search for **ATC — Agent with Tracked Capabilities** in the Extensions view) or from the
command line:

```bash
code --install-extension noti0na1.atc-vscode
```

Pre-built `.vsix` packages are also attached to every
[GitHub release](https://github.com/lampepfl/atc/releases). Open the ATC sidebar with
`Cmd+Alt+A` (macOS) or `Ctrl+Alt+A` (Windows/Linux).

## License

Apache-2.0.
57 changes: 40 additions & 17 deletions app/src/atc/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import atc.commands.{Commands, SlashCommand}
import atc.config.{Config, Configuration, ProjectConventions, ProjectRules}
import atc.host.{FileChange, Host, HostLlm, HostOutput, HostUi}
import atc.lib.Todo
import atc.llm.{CancelledException, ChatGPTAuth, ChatModel, TokenUsage}
import atc.llm.{CancelledException, ChatGPTAuth, ChatModel, ImageInput, Images, TokenUsage}
import atc.memory.MemoryStore
import atc.perms.*
import atc.platform.PlatformPath
Expand Down Expand Up @@ -221,6 +221,8 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)

private val commands = Commands(this)

private[atc] def clearStagedImages(): Unit = commands.imageCommands.clearStaged()

// ── running ───────────────────────────────────────────────────────

private def cleanup(action: => Unit): Unit =
Expand All @@ -231,9 +233,12 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)
updateStatus()
tui.completions = commands.complete
tui.commandList = commands.commandTable
tui.onPasteImage = () => commands.imageCommands.pasteForPrompt()
tui.onPastedPaths = text => commands.imageCommands.handlePastedPaths(text)
try
args.prompt match
case Some(p) =>
val cliImages = commands.imageCommands.loadCliImages(args.images, nonInteractive = true)
json.foreach: reporter =>
reporter.start(Main.Version, agent.model.ref, policy.mode.label, PlatformPath.display(cwd))
startupWarnings.foreach(reporter.warn)
Expand All @@ -252,14 +257,15 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)
agentUi.info(s"Using ${models.describe(agent.model)}: no model was named with -m or in a config.")
sandbox.warm()
// Report a failed turn through the process exit code so scripts can detect it.
runTurn(p).exitCode
runTurn(p, cliImages).exitCode
case None =>
if !policy.effective(ScopeId.Base, PlatformPath.canonical(cwd)).canRead then
tui.info(
s"No configuration grants access to ${PlatformPath.display(cwd)}, so the agent has to ask for every file. " +
"Run `atc --init` to give this project a config, or add a rule to ~/.atc/config.json."
)
banner()
if args.images.nonEmpty then commands.imageCommands.stageCliImages(args.images)
models.catalog.refresh()
if tui.menusAvailable then commands.sessionCommands.offerResume()
sandbox.warm() // after the resume offer: restoring would only discard it
Expand Down Expand Up @@ -313,14 +319,14 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)
)

/** Run one turn and retain its outcome for the terminal summary and scripted exit code. */
private def runTurn(input: String): TurnOutcome =
private def runTurn(input: String, images: List[ImageInput] = Nil): TurnOutcome =
predictor.invalidate()
tui.beginTurn()
val started = System.nanoTime()
val (usageBefore, callsBefore) = (agent.usage, agent.toolCalls)
var outcome = TurnOutcome.Failed
try
outcome = agent.turn(sandbox.ensure(), input, () => tui.isInterrupted)
outcome = agent.turn(sandbox.ensure(), input, () => tui.isInterrupted, images)
outcome
catch
case _: CancelledException | _: InterruptedException =>
Expand Down Expand Up @@ -374,27 +380,41 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)
var running = true
while running do
// A monitor message ends the read (`tui.wake`), which keeps what the user typed.
val next = if hasPendingInput then Some("") else tui.readLine(prompt)
val next = if hasPendingInput then Some(Tui.UserInput("")) else tui.readInput(prompt)
next match
case Some("") if hasPendingInput => afterTurn(runTurn(""))
case Some(Tui.UserInput("", Nil)) if hasPendingInput => afterTurn(runTurn(""))
case None =>
Debug.log("input closed, exiting")
running = false
case Some(line) if line.trim.isEmpty => ()
case Some(Tui.UserInput(line, Nil)) if line.trim.isEmpty =>
val staged = commands.imageCommands.stagedCount
if staged > 0 then
tui.info(
s"${atc.ui.Format.plural(staged, "image")} staged — type a message to send, or /image clear to discard."
)
// Typed out of habit; not listed in /help.
case Some(line) if App.QuitWords.contains(line.trim.toLowerCase(Locale.ROOT)) => running = false
case Some(line) if SlashCommand.isCommandLine(line) =>
case Some(Tui.UserInput(line, Nil)) if App.QuitWords.contains(line.trim.toLowerCase(Locale.ROOT)) =>
running = false
case Some(Tui.UserInput(line, Nil)) if SlashCommand.isCommandLine(line) =>
commands.run(line.trim) match
case Commands.Action.Continue =>
tui.commandList = commands.commandTable
case Commands.Action.Quit =>
running = false
case Commands.Action.SendPrompt(expanded) =>
monitorsHeld = false
afterTurn(runTurn(expanded))
case Some(line) =>
monitorsHeld = false
afterTurn(runTurn(line))
val staged = commands.imageCommands.takeStaged()
afterTurn(runTurn(expanded, staged))
case Some(Tui.UserInput(line, inlineImages)) =>
val combined = commands.imageCommands.staged ++ inlineImages
if combined.size > Images.MaxImagesPerMessage then
tui.error(
s"Too many images (${combined.size}; at most ${Images.MaxImagesPerMessage} allowed). Use /image rm or /image clear."
)
else
commands.imageCommands.clearStaged()
monitorsHeld = false
afterTurn(runTurn(line, combined))

/** After Ctrl-C, a correction typed during the turn goes back to the prompt: starting
* another turn with it would contact the model right after the user stopped it. Monitor
Expand All @@ -410,10 +430,13 @@ final class App(args: Cli.Args, val tui: Tui, json: Option[JsonReporter] = None)
tui.commandList = commands.commandTable
if tui.menusAvailable then commands.sessionCommands.checkpoint()

/** The input prompt names the mode unless it is the full one. */
def prompt: String = policy.mode match
case Mode.Full => "> "
case m => s"${m.label} > "
/** The input prompt names the mode unless it is the full one, plus any staged image count. */
def prompt: String =
val count = commands.imageCommands.stagedCount
val tag = if count == 0 then "" else s"[${atc.ui.Format.plural(count, "image")}] "
policy.mode match
case Mode.Full => s"$tag> "
case m => s"${m.label} $tag> "

object App:
/** Thrown to end the program from setup, before there is anything to run. */
Expand Down
Loading
Loading