Compare commits
3 Commits
sync-0.1.3
...
v0.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4705c2abaa | ||
|
|
a0666d6c81 | ||
|
|
6184aa21fb |
@@ -1,6 +1,6 @@
|
||||
# Nextest configuration — https://nexte.st/docs/configuration/
|
||||
#
|
||||
# The point of this file is a per-test timeout safety net. Luxe's test *execution* is fast
|
||||
# The point of this file is a per-test timeout safety net. luxe's test *execution* is fast
|
||||
# (~30s for the whole workspace once compiled), but a genuinely hung or runaway test — e.g. a
|
||||
# process-spawning integration test that never reaps its child, or the historical review-gate
|
||||
# fork bomb — could otherwise wedge the machine for many minutes. Nextest kills any test that
|
||||
|
||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -14,7 +14,7 @@
|
||||
|
||||
# Development-process artifacts — excluded from published release archives.
|
||||
#
|
||||
# These are Luxe's own planning spine, journal, and dogfooding memory. Luxe never
|
||||
# These are luxe's own planning spine, journal, and dogfooding memory. luxe never
|
||||
# *requires* them at runtime (every reader treats them as read-if-present), so a fresh
|
||||
# consumer repo starts clean. `git archive` (and scripts/publish-clean.sh) drop them via
|
||||
# the `export-ignore` attribute below; the files stay in this development repo for history.
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -21,7 +21,7 @@ __pycache__/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Luxe-specific
|
||||
# luxe-specific
|
||||
.luxe/
|
||||
# Verification captures — throwaway evidence for one session, megabytes of it.
|
||||
.pi/agent-loop/screenshots/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AGENTS.md
|
||||
|
||||
Rules for working on Luxe: only what you'd get wrong without being told. It's sent with every
|
||||
Rules for working on luxe: only what you'd get wrong without being told. It's sent with every
|
||||
request, so keep it short; the long version is [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
||||
|
||||
## Commands
|
||||
@@ -52,7 +52,7 @@ cargo run -p luxe-cli -- --headless -p "..." # one prompt, no UI
|
||||
- A UI talks to core over channels only: `Action` in, `Event` out. It never calls a provider or a
|
||||
tool and never blocks the runtime.
|
||||
- Behavior that cuts across the loop is a `Hook`, not a special case in the loop.
|
||||
- One owner per platform question: `user_dirs` (home and Luxe's folders), `program` (finding
|
||||
- One owner per platform question: `user_dirs` (home and luxe's folders), `program` (finding
|
||||
programs and shells, detaching, killing a process tree), `paths` (path to string), `fs_atomic`
|
||||
(safe file replace), `luxe-lsp::uri` (`file://` URLs).
|
||||
|
||||
@@ -108,7 +108,7 @@ Enforce these in code (the permission engine or a hook), never in prompt text.
|
||||
`gate.commands`, MCP and language servers need `--trust-project` (or global
|
||||
`lsp.project_servers`), so "always" approvals save globally. `project_tooling_allowed` is the one
|
||||
switch for project binaries; reuse it. Language servers still run `build.rs` and proc macros, so
|
||||
never say Luxe runs no repo code.
|
||||
never say luxe runs no repo code.
|
||||
- Secrets: `0600` files, `$ENV` or `!command`, held in `secrecy::SecretString`, scrubbed from tool
|
||||
results, logs and wire captures by `redact::process_secrets()`.
|
||||
- No telemetry. Every outbound call is one the user asked for or can turn off, sends nothing about
|
||||
@@ -159,7 +159,7 @@ Enforce these in code (the permission engine or a hook), never in prompt text.
|
||||
- Glyphs decorate; they never carry meaning alone. Every icon sits beside its words. Prefer block
|
||||
elements, which every terminal draws.
|
||||
- `web/src/assets/generated/` comes from Rust and CI checks it; `captures/` are real sessions from
|
||||
`scripts/site-record.sh`. Change how Luxe looks and you owe a `site-assets.sh` run and a
|
||||
`scripts/site-record.sh`. Change how luxe looks and you owe a `site-assets.sh` run and a
|
||||
re-record.
|
||||
- The wordmark constants in `luxe-tui/src/widgets/wordmark/art.rs` are the logo: one drawing, no
|
||||
alternatives.
|
||||
|
||||
41
CHANGELOG.md
41
CHANGELOG.md
@@ -1,7 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
Every release of Luxe, newest first. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html). While Luxe is below
|
||||
Every release of luxe, newest first. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html). While luxe is below
|
||||
1.0, a minor bump (0.x.0) may break config, flags or the `--rpc` protocol, and a patch bump never
|
||||
does.
|
||||
|
||||
@@ -9,6 +9,43 @@ The version on `main` is always the next release. The first change to what ships
|
||||
`Cargo.toml`, `Cargo.lock`) after a release bumps it one step and opens its section here, and later
|
||||
changes add to that section until it ships; `scripts/version-check.py` holds them to it.
|
||||
|
||||
## [0.1.4]
|
||||
|
||||
### Added
|
||||
|
||||
- luxe remembers the model you last chose in each project, and starts there. A project you haven't
|
||||
chosen in yet starts on the model you last chose anywhere, then on `default_model`.
|
||||
- The mouse wheel and the scrollbar work in every list in a modal: the model picker, the palette,
|
||||
themes, sessions, providers, settings and the `/` and `@` flyouts. Both move the cursor, so Enter
|
||||
never picks a row you can't see.
|
||||
- The dock's telemetry row starts with the provider, beside its own mark where the font has one.
|
||||
|
||||
### Changed
|
||||
|
||||
- The name is written lowercase everywhere, as **luxe**, even to start a sentence. The dot in
|
||||
**luxe.** belongs to the logo.
|
||||
- `luxe --help` opens with "A coding agent for your terminal."
|
||||
- Signing in no longer picks a model for you. The model picker opens at the top of its list, and
|
||||
nothing changes until you choose.
|
||||
- Loop output marks each phase with a colored rail and each iteration with a bracket inside it. In
|
||||
a terminal a tool's line shows `○` while it runs, then a green `✓` or a red `✗`.
|
||||
- The phone app shows a turn's reasoning in full, as the interface does. It was cut to three lines
|
||||
with nothing to say there was more.
|
||||
- A phone notification for a question reads "The agent has a question for you".
|
||||
|
||||
### Fixed
|
||||
|
||||
- On Windows, `luxe update` replaces the running luxe. Windows won't overwrite a program while
|
||||
it runs, so the old copy is moved aside and deleted at the next launch.
|
||||
- A luxe that's already signed in no longer opens first-run setup, even if setup was never
|
||||
finished. Quitting it partway left nothing saved, so it came back at the next launch.
|
||||
- Opening a large project in the file tree no longer shows "engine busy". It asked for every
|
||||
changed folder at once and overflowed the queue; it now asks for a few at a time.
|
||||
- The phone app stays where you are while you read back through a long session. Each new item
|
||||
dropped the oldest from the top of the page, which moved everything you were reading.
|
||||
- A question answered from the phone app shows its answer on its card, as the interface does. It
|
||||
was hidden behind a tap, as raw text.
|
||||
|
||||
## [0.1.3]
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Contributing to Luxe
|
||||
# Contributing to luxe
|
||||
|
||||
Process and tooling for people working on Luxe itself. The rules an agent has to hold to are in
|
||||
Process and tooling for people working on luxe itself. The rules an agent has to hold to are in
|
||||
[`AGENTS.md`](AGENTS.md), deliberately kept short because it rides in every request; this file is
|
||||
the long version, for humans, and nothing here is loaded into a prompt.
|
||||
|
||||
@@ -11,18 +11,18 @@ editing a page, and a test fails until you do.
|
||||
|
||||
## Licensing your contribution
|
||||
|
||||
Luxe is dual licensed under MIT (`LICENSE-MIT`) or Apache-2.0 (`LICENSE-APACHE`), at the user's
|
||||
luxe is dual licensed under MIT (`LICENSE-MIT`) or Apache-2.0 (`LICENSE-APACHE`), at the user's
|
||||
option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
|
||||
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
|
||||
additional terms or conditions.
|
||||
|
||||
## AI assistance
|
||||
|
||||
AI help is welcome. Luxe is built with plenty of it, much of it Luxe working on itself. Three things
|
||||
AI help is welcome. luxe is built with plenty of it, much of it luxe working on itself. Three things
|
||||
to hold to:
|
||||
|
||||
- **Say so.** Name the tool and how much of the change it wrote in the pull request: "written with
|
||||
Luxe on Claude Sonnet 5.5, then reviewed and edited by me", or "asked ChatGPT how the cache works,
|
||||
luxe on Claude Sonnet 5.5, then reviewed and edited by me", or "asked ChatGPT how the cache works,
|
||||
wrote the fix myself". Tab completion doesn't count. A commit can carry the Linux kernel's
|
||||
`Assisted-by: AGENT:MODEL` trailer.
|
||||
- **Understand it.** You should be able to explain what your change does and how it fits without
|
||||
@@ -280,7 +280,7 @@ python3 scripts/voice-check.py --review
|
||||
|
||||
The Tools page's bars are recorded, not generated: `scripts/tool-bench.sh NAME=REPO:CASES ...` runs
|
||||
each tool and the shell command it replaces in each checkout you name (the cases are in
|
||||
`scripts/tool-bench/`), then in Luxe itself, and writes `web/src/data/tool-bench.json` naming every
|
||||
`scripts/tool-bench/`), then in luxe itself, and writes `web/src/data/tool-bench.json` naming every
|
||||
repository's commit. Each shell row is also put through the other agents' own output limits, since
|
||||
that, not the raw output, is what their models are sent. Nothing checks the file; run it on
|
||||
committed trees when a tool's output changes. The page draws from the first repository.
|
||||
@@ -327,6 +327,7 @@ npm ci # TypeScript, Playwright, and the vendo
|
||||
npm run check # tsc
|
||||
npm test # unit tests
|
||||
cargo build -p luxe-cli && npm run e2e # end to end; LUXE_BIN picks another luxe
|
||||
node e2e/screenshots.mjs # the guide's phone shots, into docs/guide/phone/
|
||||
```
|
||||
|
||||
Every iOS browser is WebKit, so check the app there. Playwright's WebKit build wants Ubuntu's ICU,
|
||||
@@ -386,7 +387,7 @@ packages and builds every crate the way the registry will, dependencies first.
|
||||
|
||||
## Development-only files
|
||||
|
||||
A development checkout carries planning files, design notes and evaluation rigs that Luxe never
|
||||
A development checkout carries planning files, design notes and evaluation rigs that luxe never
|
||||
needs at runtime. They are marked `export-ignore` in `.gitattributes`, and
|
||||
`scripts/publish-clean.sh <dir>` writes a release tree without them, then scans what it wrote for
|
||||
anything that must not ship.
|
||||
|
||||
19
Cargo.lock
generated
19
Cargo.lock
generated
@@ -1690,7 +1690,7 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
|
||||
|
||||
[[package]]
|
||||
name = "luxe-cli"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -1717,12 +1717,13 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"unicode-width",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "luxe-core"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base16ct",
|
||||
@@ -1753,7 +1754,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-dap"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"luxe-core",
|
||||
@@ -1767,7 +1768,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-lsp"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base16ct",
|
||||
@@ -1791,7 +1792,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-mcp"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -1811,7 +1812,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-providers"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64",
|
||||
@@ -1830,7 +1831,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-remote"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"base16ct",
|
||||
@@ -1853,7 +1854,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-tools"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -1879,7 +1880,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luxe-tui"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arboard",
|
||||
|
||||
@@ -6,12 +6,12 @@ members = ["crates/*"]
|
||||
# Every crate here releases together from one workspace, so the versions move in lockstep and each
|
||||
# crate inherits this one. The internal `path` dependencies carry the same number explicitly — cargo
|
||||
# uses the path locally and the version on crates.io, and refuses to publish a path dep without one.
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/evanwhittaker/luxe"
|
||||
homepage = "https://luxe.dev"
|
||||
# Bound by the dependencies: uuid needs 1.89, and ratatui, image and darling 1.88. Luxe's own floor
|
||||
# Bound by the dependencies: uuid needs 1.89, and ratatui, image and darling 1.88. luxe's own floor
|
||||
# is lower (`user_dirs` relies on `std::env::home_dir`, which returned `$HOME` on Windows before
|
||||
# 1.85). The `msrv` CI job builds the workspace on exactly this version, so the number cannot drift.
|
||||
rust-version = "1.89"
|
||||
@@ -106,7 +106,7 @@ image = { version = "0.25", default-features = false, features = [
|
||||
[workspace.lints.rust]
|
||||
# `deny`, not `forbid`, so an audited exception can carry its own `#[allow]`, which is the line a
|
||||
# reviewer has to look at. The shipped program has one: `program::detach_from_terminal`, whose
|
||||
# `pre_exec(setsid)` is how a spawned command leaves Luxe's terminal (std's `Command::setsid` is not
|
||||
# `pre_exec(setsid)` is how a spawned command leaves luxe's terminal (std's `Command::setsid` is not
|
||||
# stable). The others are the counting allocators in luxe-tui's frame-budget test and render-perf
|
||||
# example, which never ship.
|
||||
unsafe_code = "deny"
|
||||
|
||||
34
README.md
34
README.md
@@ -1,15 +1,15 @@
|
||||
<h1 align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="web/src/assets/generated/wordmark-dark.gif">
|
||||
<img src="web/src/assets/generated/wordmark-light.gif" alt="Luxe" width="440">
|
||||
<img src="web/src/assets/generated/wordmark-light.gif" alt="luxe" width="440">
|
||||
</picture>
|
||||
</h1>
|
||||
|
||||
Luxe is a coding agent for your terminal, written in Rust. It works in your project with the model
|
||||
luxe is a coding agent for your terminal, written in Rust. It works in your project with the model
|
||||
you choose, then reads back what it changed as a Guided Review, so you can comment, ask for fixes,
|
||||
and open the pull request without leaving the terminal.
|
||||
|
||||

|
||||

|
||||
|
||||
*One take on Claude Sonnet 5.5, with only the waits cut: it writes `todo overdue` with a test, the
|
||||
change is read back in three chapters, and the pull request is drafted from the review.*
|
||||
@@ -40,13 +40,13 @@ change is read back in three chapters, and the pull request is drafted from the
|
||||
the turn fails, and `--format json` streams its messages, tool calls and each call's token usage.
|
||||
With nobody to answer, a call that would ask is allowed; `--on-ask deny` refuses it instead.
|
||||
`luxe --rpc` speaks the whole protocol.
|
||||
- **Extended with files and programs**, never code loaded into Luxe: skills, hooks, MCP servers,
|
||||
your own `@` sources, and an [RPC protocol](https://luxe.dev/docs/rpc/) for driving Luxe from
|
||||
- **Extended with files and programs**, never code loaded into luxe: skills, hooks, MCP servers,
|
||||
your own `@` sources, and an [RPC protocol](https://luxe.dev/docs/rpc/) for driving luxe from
|
||||
your own program.
|
||||
|
||||
Luxe connects to 24 providers and any OpenAI-compatible endpoint. Sign in with a ChatGPT or GitHub
|
||||
luxe connects to 24 providers and any OpenAI-compatible endpoint. Sign in with a ChatGPT or GitHub
|
||||
Copilot subscription or an OpenRouter account, or bring an API key; Anthropic and Google take API
|
||||
keys only. There is no telemetry: every connection Luxe makes is one you asked for or can turn off,
|
||||
keys only. There is no telemetry: every connection luxe makes is one you asked for or can turn off,
|
||||
and [the guide lists them](https://luxe.dev/docs/security/#what-luxe-sends-over-the-network).
|
||||
|
||||

|
||||
@@ -76,16 +76,16 @@ cargo build --release
|
||||
./target/release/luxe --version
|
||||
```
|
||||
|
||||
Luxe runs on Linux, macOS and Windows, in any UTF-8 terminal; on Windows, use Windows Terminal and
|
||||
luxe runs on Linux, macOS and Windows, in any UTF-8 terminal; on Windows, use Windows Terminal and
|
||||
install [Git for Windows](https://gitforwindows.org/) so the agent has a POSIX shell. You also need
|
||||
a model to talk to: an API key or a subscription. Your settings and credentials live in
|
||||
`~/.config/luxe/` (`%APPDATA%\luxe` on Windows).
|
||||
|
||||
Icons come from a [Nerd Font](https://www.nerdfonts.com/) when you have one, in its **Mono** build;
|
||||
without one, Luxe draws plain characters, and every icon has a word beside it. See
|
||||
without one, luxe draws plain characters, and every icon has a word beside it. See
|
||||
[Fonts](https://luxe.dev/docs/install/#fonts).
|
||||
|
||||
Luxe uses these when they are installed, and works without them:
|
||||
luxe uses these when they are installed, and works without them:
|
||||
|
||||
| | For |
|
||||
| --- | --- |
|
||||
@@ -95,7 +95,7 @@ Luxe uses these when they are installed, and works without them:
|
||||
| A debug adapter per language | The `debug` tool |
|
||||
| [ast-grep](https://ast-grep.github.io) | Search and replace by code structure |
|
||||
|
||||
`luxe doctor` checks which of them Luxe can use on your machine, and how to install the rest.
|
||||
`luxe doctor` checks which of them luxe can use on your machine, and how to install the rest.
|
||||
|
||||
## Quickstart
|
||||
|
||||
@@ -110,7 +110,7 @@ Luxe uses these when they are installed, and works without them:
|
||||
`luxe --worktree` does the same in a worktree, so your checkout is never touched.
|
||||
|
||||
2. **Answer setup.** The first launch asks for a theme, a provider, which tools the agent can use,
|
||||
and what Luxe opens on. Sign in with a subscription or paste an API key; a key already in your
|
||||
and what luxe opens on. Sign in with a subscription or paste an API key; a key already in your
|
||||
environment, such as `ANTHROPIC_API_KEY`, is found on its own. Choose a model when the picker
|
||||
opens.
|
||||
|
||||
@@ -132,9 +132,9 @@ on the screen you are on, and `ctrl+c` quits; the session is already saved. The
|
||||
|
||||
## Documentation
|
||||
|
||||
The guide is at [luxe.dev/docs](https://luxe.dev/docs/), and built into Luxe for the version you
|
||||
The guide is at [luxe.dev/docs](https://luxe.dev/docs/), and built into luxe for the version you
|
||||
have: `luxe docs`, `luxe docs hooks`, `luxe docs --search "on_ask"`. Ask the agent how to do
|
||||
something in Luxe and it reads the answer from the same pages.
|
||||
something in luxe and it reads the answer from the same pages.
|
||||
|
||||
| To | Read |
|
||||
| --- | --- |
|
||||
@@ -148,7 +148,7 @@ something in Luxe and it reads the answer from the same pages.
|
||||
| Give the agent your project's conventions | [Project context](https://luxe.dev/docs/project-context/) |
|
||||
| Change the theme, keys or statusline | [Configuration](https://luxe.dev/docs/configuration/) |
|
||||
| Control what the agent may do | [Security and permissions](https://luxe.dev/docs/security/) |
|
||||
| Add tools, skills, hooks or your own front end | [Extending Luxe](https://luxe.dev/docs/extending/) |
|
||||
| Add tools, skills, hooks or your own front end | [Extending luxe](https://luxe.dev/docs/extending/) |
|
||||
| Look up a flag or an environment variable | [Command line](https://luxe.dev/docs/cli/), [Environment variables](https://luxe.dev/docs/environment/) |
|
||||
| Fix something that is not working | [Troubleshooting](https://luxe.dev/docs/troubleshooting/) |
|
||||
|
||||
@@ -161,11 +161,11 @@ Every page is also plain markdown in [`docs/guide/`](docs/guide/), and
|
||||
the site and the demos are made; [`AGENTS.md`](AGENTS.md) has the rules an agent working here holds
|
||||
to. Problems and questions go to [GitHub issues](https://github.com/evanwhittaker/luxe/issues).
|
||||
|
||||
Luxe is built with AI assistance, much of it Luxe working on itself. Every change still passes the
|
||||
luxe is built with AI assistance, much of it luxe working on itself. Every change still passes the
|
||||
full test suite and CI before it merges, and its maintainer decides what does. If AI helped with
|
||||
yours, [say so](CONTRIBUTING.md#ai-assistance).
|
||||
|
||||
Luxe draws on Pi, by earendil-works, and on OpenCode, and on the unidirectional data flow of Elm
|
||||
luxe draws on Pi, by earendil-works, and on OpenCode, and on the unidirectional data flow of Elm
|
||||
and Ratatui.
|
||||
|
||||
## License
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Security
|
||||
|
||||
Luxe runs a model's commands on your machine, so a hole in it matters. If you find one, please tell
|
||||
luxe runs a model's commands on your machine, so a hole in it matters. If you find one, please tell
|
||||
me privately before anyone else.
|
||||
|
||||
## Reporting
|
||||
|
||||
[Open a private advisory](https://github.com/evanwhittaker/luxe/security/advisories/new) on GitHub,
|
||||
or email [contact@luxe.dev](mailto:contact@luxe.dev). Say what you did, what happened, and the
|
||||
Luxe version (`luxe --version`). A transcript or a minimal repository that shows it helps most.
|
||||
luxe version (`luxe --version`). A transcript or a minimal repository that shows it helps most.
|
||||
|
||||
I'll answer within a few days, keep you posted while it's fixed, and credit you in the advisory and
|
||||
the release notes unless you'd rather not be named. Please give the fix time to ship before you
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "luxe-cli"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description = "A beautiful coding agent for your terminal."
|
||||
description = "A coding agent for your terminal."
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
readme = "../../README.md"
|
||||
@@ -18,14 +18,14 @@ name = "luxe"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.3" }
|
||||
luxe-providers = { path = "../luxe-providers", version = "0.1.3" }
|
||||
luxe-tools = { path = "../luxe-tools", version = "0.1.3" }
|
||||
luxe-lsp = { path = "../luxe-lsp", version = "0.1.3" }
|
||||
luxe-dap = { path = "../luxe-dap", version = "0.1.3" }
|
||||
luxe-mcp = { path = "../luxe-mcp", version = "0.1.3" }
|
||||
luxe-tui = { path = "../luxe-tui", version = "0.1.3" }
|
||||
luxe-remote = { path = "../luxe-remote", version = "0.1.3", optional = true }
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.4" }
|
||||
luxe-providers = { path = "../luxe-providers", version = "0.1.4" }
|
||||
luxe-tools = { path = "../luxe-tools", version = "0.1.4" }
|
||||
luxe-lsp = { path = "../luxe-lsp", version = "0.1.4" }
|
||||
luxe-dap = { path = "../luxe-dap", version = "0.1.4" }
|
||||
luxe-mcp = { path = "../luxe-mcp", version = "0.1.4" }
|
||||
luxe-tui = { path = "../luxe-tui", version = "0.1.4" }
|
||||
luxe-remote = { path = "../luxe-remote", version = "0.1.4", optional = true }
|
||||
# The pairing QR in the terminal. Without its defaults it is the encoder and text renderer alone,
|
||||
# with no dependencies.
|
||||
qrcode = { version = "0.14", default-features = false, optional = true }
|
||||
@@ -48,18 +48,20 @@ reqwest = { workspace = true }
|
||||
# `luxe auth login` reads an API key without echoing it, which needs raw mode on the real terminal.
|
||||
# Pinned to luxe-tui's version so there is exactly one crossterm in the tree.
|
||||
crossterm = "0.29"
|
||||
# The loop view cuts each line to the terminal's width, so it can redraw a line in place
|
||||
unicode-width = { workspace = true }
|
||||
# Streaming the update manifest with a size cap, and comparing the version it reports.
|
||||
futures = { workspace = true }
|
||||
semver = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
# The guide check: what Luxe would silently ignore in a config example
|
||||
# The guide check: what luxe would silently ignore in a config example
|
||||
serde_ignored = "0.1"
|
||||
|
||||
[features]
|
||||
default = ["clipboard-images", "remote"]
|
||||
# `luxe remote`, the only server in Luxe. A packager can leave it out to ship a Luxe with no
|
||||
# `luxe remote`, the only server in luxe. A packager can leave it out to ship a luxe with no
|
||||
# server code at all.
|
||||
remote = ["dep:luxe-remote", "dep:qrcode"]
|
||||
clipboard = ["luxe-tui/clipboard"]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! model is sent a raw 900 KB `git log`: the honest comparison is with what a harness forwards.
|
||||
//!
|
||||
//! `TOOL_BENCH_CASES` names a JSON file of cases (`id`, `shell`, `tool`, `args`) for measuring in a
|
||||
//! repository other than this one; without it, the cases below measure Luxe itself.
|
||||
//! repository other than this one; without it, the cases below measure luxe itself.
|
||||
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -62,7 +62,7 @@ fn a_failed_call_summarizes_its_own_error() {
|
||||
"edited before reading the file",
|
||||
),
|
||||
(
|
||||
"Error: 'src/lib.rs' exists and has no read on record for this Luxe run \
|
||||
"Error: 'src/lib.rs' exists and has no read on record for this luxe run \
|
||||
(read-before-write guard), so overwriting it would be blind.",
|
||||
"overwrote a file it hadn't read",
|
||||
),
|
||||
|
||||
@@ -40,6 +40,44 @@ pub(crate) fn auth_service() -> luxe_tui::auth_wizard::AuthServiceHandle {
|
||||
std::sync::Arc::new(luxe_providers::auth::ProviderAuth::new())
|
||||
}
|
||||
|
||||
/// Carries the flags that shape this run, rather than where it starts, onto `settings`.
|
||||
fn apply_run_flags(args: &Args, settings: &mut crate::engine_setup::AgentSettings) {
|
||||
settings.resume = resume_from_args(args);
|
||||
settings.permission_mode = permission_mode_from_args(args);
|
||||
settings.trust_project = args.trust_project;
|
||||
settings.disable_tools = args.no_tool.clone();
|
||||
settings.enable_tools = args.with_tool.clone();
|
||||
apply_thinking_flag(args.thinking.as_deref(), settings);
|
||||
settings.auto_approve = args.auto_approve;
|
||||
if let Some(on_ask) = args.on_ask {
|
||||
settings.on_ask = on_ask.into();
|
||||
}
|
||||
if args.auto_approve && !args.prompts_a_human() && args.starts_an_engine() {
|
||||
settings.startup_notices.push(
|
||||
"--auto-approve: an unattended run already allows an `ask`. `--on-ask deny` is how to \
|
||||
make one refuse instead."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
if args.plan {
|
||||
settings.initial_mode = Some(luxe_core::mode::PLAN.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
/// Pins the thinking level `--thinking` names; a level luxe doesn't know is reported and ignored.
|
||||
fn apply_thinking_flag(raw: Option<&str>, settings: &mut crate::engine_setup::AgentSettings) {
|
||||
let Some(raw) = raw else {
|
||||
return;
|
||||
};
|
||||
match args::parse_thinking_level(raw) {
|
||||
Some(level) => {
|
||||
settings.initial_thinking = Some(level);
|
||||
settings.thinking_forced = true;
|
||||
}
|
||||
None => eprintln!("luxe: ignoring unknown --thinking level '{raw}'"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Top-level dispatch: parse args and route to the requested mode.
|
||||
pub(crate) async fn run(mut args: Args) -> anyhow::Result<()> {
|
||||
// The guide is in the binary and needs nothing else: no project, no settings, no network
|
||||
@@ -58,34 +96,7 @@ pub(crate) async fn run(mut args: Args) -> anyhow::Result<()> {
|
||||
let root = enter_project(&mut args, &invoked_from)?;
|
||||
// Resolve provider/model/auth once (CLI flags > env > config) and share it downstream.
|
||||
let mut settings = crate::engine_setup::AgentSettings::resolve(root, args.overrides());
|
||||
settings.resume = resume_from_args(&args);
|
||||
settings.permission_mode = permission_mode_from_args(&args);
|
||||
settings.trust_project = args.trust_project;
|
||||
settings.disable_tools = args.no_tool.clone();
|
||||
settings.enable_tools = args.with_tool.clone();
|
||||
if let Some(raw) = args.thinking.as_deref() {
|
||||
match args::parse_thinking_level(raw) {
|
||||
Some(level) => {
|
||||
settings.initial_thinking = Some(level);
|
||||
settings.thinking_forced = true;
|
||||
}
|
||||
None => eprintln!("luxe: ignoring unknown --thinking level '{raw}'"),
|
||||
}
|
||||
}
|
||||
settings.auto_approve = args.auto_approve;
|
||||
if let Some(on_ask) = args.on_ask {
|
||||
settings.on_ask = on_ask.into();
|
||||
}
|
||||
if args.auto_approve && !args.prompts_a_human() && args.starts_an_engine() {
|
||||
settings.startup_notices.push(
|
||||
"--auto-approve: an unattended run already allows an `ask`. `--on-ask deny` is how to \
|
||||
make one refuse instead."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
if args.plan {
|
||||
settings.initial_mode = Some(luxe_core::mode::PLAN.to_string());
|
||||
}
|
||||
apply_run_flags(&args, &mut settings);
|
||||
|
||||
if args.starts_an_engine() {
|
||||
enter_worktree(&args, &mut settings).await?;
|
||||
@@ -104,9 +115,13 @@ pub(crate) async fn run(mut args: Args) -> anyhow::Result<()> {
|
||||
// loop run needs the right context window just as much. Best-effort and non-blocking.
|
||||
crate::model_catalog::spawn_refresh();
|
||||
|
||||
// Ask, at most daily, whether a newer Luxe exists. The answer lands in a cache and is read by
|
||||
// Ask, at most daily, whether a newer luxe exists. The answer lands in a cache and is read by
|
||||
// the *next* launch's dashboard, so nothing here is on the path to a first token.
|
||||
crate::update_check::spawn_check(&settings.state_root);
|
||||
// The copy a Windows update moved aside; nothing to find anywhere else
|
||||
if cfg!(windows) {
|
||||
update_command::remove_leftover();
|
||||
}
|
||||
|
||||
if let Some(cmd) = args.command {
|
||||
match cmd {
|
||||
|
||||
@@ -8,7 +8,7 @@ mod permission_mode;
|
||||
pub(crate) use commands::*;
|
||||
pub(crate) use permission_mode::PermissionModeArg;
|
||||
|
||||
/// Luxe's command line. `--help` shows the crate description from `Cargo.toml`, not this doc.
|
||||
/// luxe's command line. `--help` shows the crate description from `Cargo.toml`, not this doc.
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "luxe", version, about)]
|
||||
pub(crate) struct Args {
|
||||
@@ -17,7 +17,7 @@ pub(crate) struct Args {
|
||||
pub(crate) headless: bool,
|
||||
|
||||
/// Speak the JSONL front-end protocol on stdio: wire actions in, events out. For editor
|
||||
/// plugins, alternative UIs, and anything driving Luxe as a session rather than a one-shot.
|
||||
/// plugins, alternative UIs, and anything driving luxe as a session rather than a one-shot.
|
||||
/// See `docs/guide/rpc.md`.
|
||||
#[arg(long, conflicts_with = "headless")]
|
||||
pub(crate) rpc: bool,
|
||||
@@ -279,7 +279,7 @@ impl Args {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a `--thinking` level name into a `ThinkingLevel`, accepting the same spellings Luxe
|
||||
/// Parse a `--thinking` level name into a `ThinkingLevel`, accepting the same spellings luxe
|
||||
/// displays (`off`..`ultra`, plus `max` as an alias for `ultra`). Returns `None` for unknown input.
|
||||
pub(crate) fn parse_thinking_level(raw: &str) -> Option<luxe_core::provider::ThinkingLevel> {
|
||||
let name = raw.trim().to_ascii_lowercase();
|
||||
|
||||
@@ -7,13 +7,13 @@ use clap::{Parser, Subcommand};
|
||||
pub(crate) enum SubCommand {
|
||||
/// Sign in to a provider, check credentials, or sign out.
|
||||
Auth(AuthArgs),
|
||||
/// Read Luxe's user guide, for this version.
|
||||
/// Read luxe's user guide, for this version.
|
||||
Docs(DocsArgs),
|
||||
/// Check which language servers, debug adapters and tools work on this machine.
|
||||
Doctor,
|
||||
/// Set Luxe up: a theme, a provider, the tools and the start screen.
|
||||
/// Set luxe up: a theme, a provider, the tools and the start screen.
|
||||
Init(InitArgs),
|
||||
/// Join a session another Luxe on this machine is running, speaking the `--rpc` protocol on
|
||||
/// Join a session another luxe on this machine is running, speaking the `--rpc` protocol on
|
||||
/// stdin and stdout.
|
||||
Join(JoinArgs),
|
||||
/// Serve your sessions to your own phone or tablet, through Tailscale.
|
||||
@@ -27,7 +27,7 @@ pub(crate) enum SubCommand {
|
||||
Models(ModelsArgs),
|
||||
/// List this project's sessions.
|
||||
Sessions(SessionsArgs),
|
||||
/// Update Luxe with the command for however it was installed.
|
||||
/// Update luxe with the command for however it was installed.
|
||||
Update(UpdateArgs),
|
||||
/// Summarize a `LUXE_WIRE_LOG` capture.
|
||||
Wire(WireArgs),
|
||||
@@ -109,10 +109,10 @@ pub(crate) struct ModelsArgs {
|
||||
pub(crate) command: ModelsCommand,
|
||||
}
|
||||
|
||||
/// Models subcommand — what Luxe knows about a model, and where it learned it.
|
||||
/// Models subcommand — what luxe knows about a model, and where it learned it.
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub(crate) enum ModelsCommand {
|
||||
/// List known models for the providers Luxe can route to.
|
||||
/// List known models for the providers luxe can route to.
|
||||
List {
|
||||
/// Only this provider.
|
||||
#[arg(long)]
|
||||
@@ -148,7 +148,7 @@ pub(crate) struct InitArgs {
|
||||
/// Join arguments.
|
||||
#[derive(Parser, Debug)]
|
||||
pub(crate) struct JoinArgs {
|
||||
/// The session: its id or the start of it, or the process id of the Luxe running it. Omit
|
||||
/// The session: its id or the start of it, or the process id of the luxe running it. Omit
|
||||
/// it to join the one running in this folder.
|
||||
pub(crate) target: Option<String>,
|
||||
/// List the sessions running on this machine that can be joined, and exit.
|
||||
|
||||
@@ -105,17 +105,11 @@ fn report_success(service: &ProviderAuth, outcome: &LoginOutcome) {
|
||||
field("models", note);
|
||||
}
|
||||
field("saved to", &luxe_core::paths::home_relative(&service.store_path()));
|
||||
if let Some(model) = &outcome.suggested_model {
|
||||
field("model", &format!("{model} {}", style::dim("(now the default)")));
|
||||
}
|
||||
// Advice sits apart from the summary: it's about what to do later, not what just happened.
|
||||
for advice in &outcome.advice {
|
||||
outln!("\n {}", style::dim(advice));
|
||||
}
|
||||
match outcome.suggested_model {
|
||||
Some(_) => outln!("\nRun `luxe` to start, or `/model` to pick another."),
|
||||
None => outln!("\nRun `luxe` to start, then `/model` to pick a model."),
|
||||
}
|
||||
outln!("\nRun `luxe` to start, then `/model` to pick a model.");
|
||||
}
|
||||
|
||||
/// `luxe auth list` — every provider and how it's configured.
|
||||
|
||||
@@ -172,7 +172,7 @@ async fn start_loop(
|
||||
event_rx,
|
||||
running_rx,
|
||||
kickoff,
|
||||
crate::loop_view::LoopView::new(quiet),
|
||||
crate::loop_view::LoopView::new(quiet, phase),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! The guide ships in the binary, so it works offline and always describes the version installed:
|
||||
//! `scripts/guide-bundle.sh` writes every page of `docs/guide/` into `src/guide.md`, and this reads
|
||||
//! that bundle. The agent is told the command exists, so asking Luxe how to configure Luxe gets an
|
||||
//! that bundle. The agent is told the command exists, so asking luxe how to configure luxe gets an
|
||||
//! answer from the manual rather than a guess.
|
||||
|
||||
use crate::cli::args::DocsArgs;
|
||||
@@ -11,7 +11,7 @@ use crate::cli::args::DocsArgs;
|
||||
const BUNDLE: &str = include_str!("../guide.md");
|
||||
|
||||
/// The sidebar's groups, in reading order. `web/src/content.config.ts` holds the same list.
|
||||
const GROUPS: [&str; 5] = ["Get started", "Using Luxe", "Customize", "Extend", "Reference"];
|
||||
const GROUPS: [&str; 5] = ["Get started", "Using luxe", "Customize", "Extend", "Reference"];
|
||||
|
||||
/// The most lines `--search` prints, so a common word cannot flood a tool result.
|
||||
const SEARCH_LIMIT: usize = 40;
|
||||
@@ -74,7 +74,7 @@ pub(crate) fn run(args: &DocsArgs) -> anyhow::Result<()> {
|
||||
/// Every page, under its group, with its summary and how to read it.
|
||||
fn index(pages: &[Page]) -> String {
|
||||
let mut out = String::from(
|
||||
"Luxe's user guide, for this version. `luxe docs <page>` prints a page; \
|
||||
"luxe's user guide, for this version. `luxe docs <page>` prints a page; \
|
||||
`luxe docs --search <words>` finds lines across all of them.\n",
|
||||
);
|
||||
for group in GROUPS {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `luxe doctor` — is the tooling on this machine actually going to work?
|
||||
//!
|
||||
//! Luxe launches language servers and debug adapters; it does not install them, and it does not
|
||||
//! luxe launches language servers and debug adapters; it does not install them, and it does not
|
||||
//! bundle them: installation would mean owning each language's package manager and update policy.
|
||||
//! A broken or absent one can otherwise stay invisible until a tool call comes back empty.
|
||||
//!
|
||||
@@ -63,7 +63,7 @@ async fn language_servers() {
|
||||
let configured: std::collections::HashSet<String> = user.keys().cloned().collect();
|
||||
for language in registry.merge_patches(user) {
|
||||
say(&format!(
|
||||
" FAIL {language:<12} lsp-servers.json gives no `command`, and Luxe ships none"
|
||||
" FAIL {language:<12} lsp-servers.json gives no `command`, and luxe ships none"
|
||||
));
|
||||
}
|
||||
let mut languages: Vec<(&String, &ServerEntry)> = registry.iter().collect();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `luxe join` — a session another Luxe is running, over stdin and stdout.
|
||||
//! `luxe join` — a session another luxe is running, over stdin and stdout.
|
||||
//!
|
||||
//! The running Luxe shares its session on a local endpoint (`cli::share`), and this command is the
|
||||
//! The running luxe shares its session on a local endpoint (`cli::share`), and this command is the
|
||||
//! plain way in: it picks the session from the records in the runtime folder, connects, and copies
|
||||
//! bytes both ways. What crosses is the `--rpc` protocol untouched, so a client written for
|
||||
//! `luxe --rpc` drives a joined session by launching `luxe join` instead.
|
||||
@@ -63,7 +63,7 @@ fn nothing_to_join(running: &[LiveSession], target: Option<&str>, cwd: &str) ->
|
||||
};
|
||||
if running.is_empty() {
|
||||
return format!(
|
||||
"{wanted}, and none is running on this machine that can be joined. A Luxe shares \
|
||||
"{wanted}, and none is running on this machine that can be joined. A luxe shares \
|
||||
its session unless `joinable` is off or LUXE_JOINABLE=0."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ fn sessions() -> Vec<LiveSession> {
|
||||
/// With no target, the session running in this folder is the one joined.
|
||||
///
|
||||
/// The break this catches: ignoring the folder, so `luxe join` in one project lands in another's
|
||||
/// session, or refuses because more than one Luxe is running somewhere.
|
||||
/// session, or refuses because more than one luxe is running somewhere.
|
||||
#[test]
|
||||
fn no_target_joins_the_session_running_here() {
|
||||
let all = sessions();
|
||||
@@ -39,7 +39,7 @@ fn two_sessions_in_the_folder_are_listed_not_guessed() {
|
||||
assert!(error.contains("aaab-2222") && error.contains("cccc-3333"), "{error}");
|
||||
}
|
||||
|
||||
/// A target names a session by the start of its id or by its Luxe's process id.
|
||||
/// A target names a session by the start of its id or by its luxe's process id.
|
||||
///
|
||||
/// The break this catches: matching the id exactly, so the short form the listing invites fails,
|
||||
/// or not accepting a pid, which is what `ps` and herdr show.
|
||||
@@ -62,7 +62,7 @@ fn an_ambiguous_or_empty_target_is_refused() {
|
||||
|
||||
/// Nothing to join says why, and how sharing is turned back on when nothing is running.
|
||||
///
|
||||
/// The break this catches: a bare "not found" when every Luxe has `joinable` off, which leaves the
|
||||
/// The break this catches: a bare "not found" when every luxe has `joinable` off, which leaves the
|
||||
/// reader with nothing to try.
|
||||
#[test]
|
||||
fn nothing_to_join_says_what_is_running() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `luxe models` — inspect and refresh the model catalog.
|
||||
//!
|
||||
//! Exists mostly for one question: *why does Luxe think my model has a 128k window?* `show`
|
||||
//! Exists mostly for one question: *why does luxe think my model has a 128k window?* `show`
|
||||
//! answers it directly by printing which layer won each field, so a stale cache, a missing
|
||||
//! provider mapping, and a forgotten config override are all distinguishable at a glance.
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ async fn serve(port: u16, allow: Vec<String>, devices: DeviceBook) -> anyhow::Re
|
||||
let logins = allowed_logins(tailnet, allow)?;
|
||||
let access = Access { logins: logins.clone(), devices };
|
||||
let bridge = bridge(port, access, machine).await?;
|
||||
outln!("Luxe remote is listening on http://{}. Ctrl-C stops it.", bridge.address());
|
||||
outln!("luxe remote is listening on http://{}. Ctrl-C stops it.", bridge.address());
|
||||
outln!("It lets in {}, from a paired device.", logins.join(", "));
|
||||
bridge
|
||||
.serve(async {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! `luxe remote setup` — from nothing to a paired phone, asking before each step that changes
|
||||
//! something outside Luxe.
|
||||
//! something outside luxe.
|
||||
//!
|
||||
//! Four steps: Tailscale is there and signed in; Serve carries `https://<this machine>/` to the
|
||||
//! bridge; a user service runs the bridge at login; and an invitation to scan. Each step that is
|
||||
@@ -108,7 +108,7 @@ fn service_step(port: u16, tailnet: &Tailnet, allow: Vec<String>) {
|
||||
return;
|
||||
}
|
||||
if !confirm("Run the bridge whenever you're signed in, as a user service?") {
|
||||
outln!("Skipped. Run `luxe remote` yourself whenever your devices should reach Luxe.");
|
||||
outln!("Skipped. Run `luxe remote` yourself whenever your devices should reach luxe.");
|
||||
return;
|
||||
}
|
||||
let launch =
|
||||
|
||||
@@ -75,7 +75,7 @@ impl GithubWrites {
|
||||
match self {
|
||||
Self::Allowed => None,
|
||||
Self::NotEnabled => Some(format!(
|
||||
"{kind} publishes to GitHub, which this session does not allow: start Luxe with \
|
||||
"{kind} publishes to GitHub, which this session does not allow: start luxe with \
|
||||
--github-writes to let a client do that"
|
||||
)),
|
||||
Self::ReadOnly => Some(format!(
|
||||
@@ -151,7 +151,7 @@ fn session_refusal(wire: &WireAction, policy: &Policy) -> Option<String> {
|
||||
let switches = matches!(wire, WireAction::NewSession | WireAction::LoadSession(_));
|
||||
if policy.joined && switches {
|
||||
let reason = "would switch the session the terminal is showing: switch it there, or start \
|
||||
another Luxe";
|
||||
another luxe";
|
||||
return Some(format!("{kind} {reason}"));
|
||||
}
|
||||
None
|
||||
|
||||
@@ -447,7 +447,7 @@ fn github_writes_need_the_flag_and_read_only_refuses_them_anyway() {
|
||||
]
|
||||
};
|
||||
for (gate, needle) in [
|
||||
(GithubWrites::NotEnabled, "start Luxe with --github-writes"),
|
||||
(GithubWrites::NotEnabled, "start luxe with --github-writes"),
|
||||
(GithubWrites::ReadOnly, "read-only"),
|
||||
] {
|
||||
for wire in writes() {
|
||||
|
||||
@@ -11,7 +11,7 @@ fn footer_note(repo_root: &std::path::Path) -> Option<String> {
|
||||
crate::update_check::cached_notice(repo_root).map(|_| UPDATE_HINT.to_string())
|
||||
}
|
||||
|
||||
/// What the dashboard says when a newer Luxe exists.
|
||||
/// What the dashboard says when a newer luxe exists.
|
||||
const UPDATE_HINT: &str = "Update available · /update";
|
||||
|
||||
/// Whether the startup dashboard should be shown.
|
||||
@@ -295,7 +295,7 @@ async fn starting_status(
|
||||
/// mid-session shows up without relaunching. The probe is the same menu built after asking every
|
||||
/// connected local server what it is serving — a list that changes the moment somebody loads a
|
||||
/// model, and that only the endpoint knows. An Azure resource is the same question asked of a
|
||||
/// cloud: what is deployed there changes in a portal Luxe never sees. A server that is off leaves
|
||||
/// cloud: what is deployed there changes in a portal luxe never sees. A server that is off leaves
|
||||
/// the record standing.
|
||||
fn model_menu_sources(
|
||||
settings: &crate::engine_setup::AgentSettings,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! `luxe update` — run the update this install's owner provides, then check that it took.
|
||||
//!
|
||||
//! The policy is [`luxe_core::update`]'s: which owner installed this copy, which commands update
|
||||
//! it, and a refusal where Luxe cannot know them. This runs those commands one program at a time
|
||||
//! with the terminal attached, so the reader sees the package manager's own output, and Luxe never
|
||||
//! it, and a refusal where luxe cannot know them. This runs those commands one program at a time
|
||||
//! with the terminal attached, so the reader sees the package manager's own output, and luxe never
|
||||
//! writes a binary itself. `/update` on the dashboard comes here too, once the TUI has handed the
|
||||
//! terminal back.
|
||||
|
||||
@@ -10,6 +10,8 @@ use anyhow::{anyhow, bail, Context};
|
||||
use luxe_core::update::{self, InstallSource};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub(crate) use aside::remove_leftover;
|
||||
|
||||
/// Checks for a newer release now and, unless `check_only`, runs the update and checks the result.
|
||||
pub(crate) async fn run(check_only: bool) -> anyhow::Result<()> {
|
||||
let current = luxe_core::version::VERSION;
|
||||
@@ -17,50 +19,62 @@ pub(crate) async fn run(check_only: bool) -> anyhow::Result<()> {
|
||||
.await
|
||||
.map_err(|error| anyhow!("could not check for a newer release: {error}"))?;
|
||||
if !update::is_newer(&latest, current) {
|
||||
println!("Luxe {current} is the newest release.");
|
||||
println!("luxe {current} is the newest release.");
|
||||
return Ok(());
|
||||
}
|
||||
println!("Luxe {latest} is available (you have {current}).");
|
||||
println!("luxe {latest} is available (you have {current}).");
|
||||
let source = InstallSource::detect();
|
||||
match (source.update_steps(), check_only) {
|
||||
(Some(steps), false) if !cfg!(windows) => {
|
||||
run_steps(steps).await?;
|
||||
report(installed_now(&latest).await)
|
||||
}
|
||||
(Some(steps), false) => update_with(steps, &latest).await,
|
||||
_ => {
|
||||
println!("{}", instructions(source, check_only, cfg!(windows)));
|
||||
println!("{}", instructions(source, check_only));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What to tell a reader Luxe will not run an update for: they asked only to check, Windows cannot
|
||||
/// replace the running program, or no owner's command is known.
|
||||
fn instructions(source: InstallSource, check_only: bool, windows: bool) -> String {
|
||||
/// Runs the owner's steps over this copy, then checks the `luxe` a shell finds now.
|
||||
///
|
||||
/// Windows won't let a running program's file be overwritten, and `luxe update` is itself a
|
||||
/// running luxe. It does allow a rename, so the running copy steps aside first and the owner
|
||||
/// writes a new file where it was.
|
||||
async fn update_with(steps: &[&[&str]], latest: &str) -> anyhow::Result<()> {
|
||||
let exe = std::env::current_exe().context("could not find the running luxe")?;
|
||||
let aside = match cfg!(windows) {
|
||||
true => Some(aside::MovedAside::move_running(&exe)?),
|
||||
false => None,
|
||||
};
|
||||
let ran = run_steps(steps, exe.parent()).await;
|
||||
if let Some(aside) = &aside {
|
||||
aside.restore_if_missing()?;
|
||||
}
|
||||
ran?;
|
||||
report(installed_now(latest, &exe).await)
|
||||
}
|
||||
|
||||
/// What to tell a reader luxe will not run an update for: they asked only to check, or no owner's
|
||||
/// command is known.
|
||||
fn instructions(source: InstallSource, check_only: bool) -> String {
|
||||
match source.update_command() {
|
||||
Some(command) if !check_only && windows => format!(
|
||||
"Windows can't replace Luxe while it runs, so run this once it has exited: {command}"
|
||||
),
|
||||
Some(_) if check_only => format!("Run `luxe update`, or {}.", source.advice()),
|
||||
_ => format!("To update: {}.", source.advice()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs each step in turn, the terminal attached, stopping at the first that fails.
|
||||
async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
|
||||
/// Runs each step in turn, the terminal attached, stopping at the first that fails. `beside` is
|
||||
/// the running binary's directory.
|
||||
async fn run_steps(steps: &[&[&str]], beside: Option<&Path>) -> anyhow::Result<()> {
|
||||
for step in steps {
|
||||
let Some((program, args)) = step.split_first() else { continue };
|
||||
let line = step.join(" ");
|
||||
println!("Running: {line}");
|
||||
let beside =
|
||||
std::env::current_exe().ok().and_then(|exe| exe.parent().map(Path::to_path_buf));
|
||||
let status = tokio::process::Command::new(program_path(program, beside.as_deref()))
|
||||
let status = tokio::process::Command::new(program_path(program, beside))
|
||||
.args(args)
|
||||
.status()
|
||||
.await
|
||||
.with_context(|| format!("could not start `{program}`"))?;
|
||||
if !status.success() {
|
||||
bail!("`{line}` failed ({status}), so Luxe is unchanged");
|
||||
bail!("`{line}` failed ({status}), so luxe is unchanged");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -108,15 +122,15 @@ fn outcome(found: Option<&Path>, updated: &Path, reported: Option<&str>, latest:
|
||||
}
|
||||
}
|
||||
|
||||
/// The `luxe` a shell would run now, and the outcome it shows.
|
||||
async fn installed_now(latest: &str) -> Outcome {
|
||||
/// The `luxe` a shell would run now, and the outcome it shows. `updated` is where the running copy
|
||||
/// was, read before a Windows update moved it aside.
|
||||
async fn installed_now(latest: &str, updated: &Path) -> Outcome {
|
||||
let found = luxe_core::program::resolve("luxe");
|
||||
let reported = match &found {
|
||||
Some(path) => version_of(path).await,
|
||||
None => None,
|
||||
};
|
||||
let updated = std::env::current_exe().unwrap_or_default();
|
||||
outcome(found.as_deref(), &updated, reported.as_deref(), latest)
|
||||
outcome(found.as_deref(), updated, reported.as_deref(), latest)
|
||||
}
|
||||
|
||||
/// The version `path --version` prints, as `luxe 0.2.0`.
|
||||
@@ -150,5 +164,7 @@ fn report(outcome: Outcome) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
mod aside;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
118
crates/luxe-cli/src/cli/update_command/aside.rs
Normal file
118
crates/luxe-cli/src/cli/update_command/aside.rs
Normal file
@@ -0,0 +1,118 @@
|
||||
//! Moving the running copy aside — how `luxe update` gets out of its own way on Windows.
|
||||
//!
|
||||
//! Windows locks a running program's file against being overwritten or deleted, but not against
|
||||
//! being renamed. The running `luxe.exe` becomes `luxe.exe.old`, the owner's updater writes a new
|
||||
//! `luxe.exe`, and the next launch deletes the leftover once nothing is running from it. Nothing
|
||||
//! here writes a binary: it only renames the one that is already there.
|
||||
|
||||
use anyhow::Context;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// The running copy, renamed out of the way of the update.
|
||||
pub(super) struct MovedAside {
|
||||
from: PathBuf,
|
||||
to: PathBuf,
|
||||
}
|
||||
|
||||
impl MovedAside {
|
||||
/// Renames `exe` to its leftover name, clearing a leftover a previous update left behind.
|
||||
pub(super) fn move_running(exe: &Path) -> anyhow::Result<Self> {
|
||||
let to = leftover_path(exe);
|
||||
remove_if_present(&to).with_context(|| {
|
||||
format!("could not remove {}, left by an earlier update", to.display())
|
||||
})?;
|
||||
std::fs::rename(exe, &to).with_context(|| {
|
||||
format!("could not move the running {} aside to update it", exe.display())
|
||||
})?;
|
||||
Ok(Self { from: exe.to_path_buf(), to })
|
||||
}
|
||||
|
||||
/// Puts the running copy back when the update left nothing where it was, so a failed update
|
||||
/// never leaves the reader without a `luxe`.
|
||||
pub(super) fn restore_if_missing(&self) -> anyhow::Result<()> {
|
||||
if self.from.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
std::fs::rename(&self.to, &self.from).with_context(|| {
|
||||
format!(
|
||||
"the update left no luxe behind and {} could not be moved back to {}",
|
||||
self.to.display(),
|
||||
self.from.display()
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes the copy an earlier update moved aside, if there is one. Called at launch, when the
|
||||
/// old copy has exited. Still running elsewhere is normal (another session), so a failure is
|
||||
/// only logged and the next launch tries again.
|
||||
pub(crate) fn remove_leftover() {
|
||||
let Ok(exe) = std::env::current_exe() else { return };
|
||||
let leftover = leftover_path(&exe);
|
||||
if let Err(error) = remove_if_present(&leftover) {
|
||||
tracing::debug!(%error, path = %leftover.display(), "leftover from an update is still in use");
|
||||
}
|
||||
}
|
||||
|
||||
/// `luxe.exe` beside itself as `luxe.exe.old`.
|
||||
fn leftover_path(exe: &Path) -> PathBuf {
|
||||
let mut name = exe.file_name().unwrap_or_default().to_os_string();
|
||||
name.push(".old");
|
||||
exe.with_file_name(name)
|
||||
}
|
||||
|
||||
/// Removes `path`; already gone is success.
|
||||
fn remove_if_present(path: &Path) -> std::io::Result<()> {
|
||||
match std::fs::remove_file(path) {
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn installed() -> (tempfile::TempDir, PathBuf) {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let exe = dir.path().join("luxe.exe");
|
||||
std::fs::write(&exe, b"old").expect("a stand-in binary");
|
||||
(dir, exe)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_leftover_sits_beside_the_binary() {
|
||||
assert_eq!(leftover_path(Path::new("/bin/luxe.exe")), PathBuf::from("/bin/luxe.exe.old"));
|
||||
}
|
||||
|
||||
/// The update writes a new file where the old one was, and the old one is left to delete.
|
||||
#[test]
|
||||
fn an_update_that_wrote_a_new_copy_keeps_it() {
|
||||
let (_dir, exe) = installed();
|
||||
let aside = MovedAside::move_running(&exe).expect("moved");
|
||||
assert!(!exe.exists(), "the name is free for the updater");
|
||||
std::fs::write(&exe, b"new").expect("the updater's copy");
|
||||
aside.restore_if_missing().expect("nothing to restore");
|
||||
assert_eq!(std::fs::read(&exe).expect("read"), b"new");
|
||||
assert_eq!(std::fs::read(leftover_path(&exe)).expect("read"), b"old");
|
||||
}
|
||||
|
||||
/// A failed update puts the running copy back rather than leaving no `luxe` at all.
|
||||
#[test]
|
||||
fn an_update_that_wrote_nothing_puts_the_old_copy_back() {
|
||||
let (_dir, exe) = installed();
|
||||
let aside = MovedAside::move_running(&exe).expect("moved");
|
||||
aside.restore_if_missing().expect("restored");
|
||||
assert_eq!(std::fs::read(&exe).expect("read"), b"old");
|
||||
assert!(!leftover_path(&exe).exists());
|
||||
}
|
||||
|
||||
/// A leftover from the last update is cleared, not a reason to refuse this one.
|
||||
#[test]
|
||||
fn a_leftover_from_last_time_is_replaced() {
|
||||
let (_dir, exe) = installed();
|
||||
std::fs::write(leftover_path(&exe), b"older").expect("a leftover");
|
||||
MovedAside::move_running(&exe).expect("moved");
|
||||
assert_eq!(std::fs::read(leftover_path(&exe)).expect("read"), b"old");
|
||||
}
|
||||
}
|
||||
@@ -69,13 +69,8 @@ fn no_luxe_on_path_or_no_version_cannot_be_judged() {
|
||||
/// Only the reader's own command is ever named, and a check offers `luxe update` beside it.
|
||||
#[test]
|
||||
fn the_instructions_name_the_owners_command_or_none() {
|
||||
let check = instructions(InstallSource::Cargo, true, false);
|
||||
let check = instructions(InstallSource::Cargo, true);
|
||||
assert!(check.contains("luxe update") && check.contains("cargo install"), "{check}");
|
||||
let download = instructions(InstallSource::Archive, false, false);
|
||||
let download = instructions(InstallSource::Archive, false);
|
||||
assert!(download.contains("download it from"), "{download}");
|
||||
let windows = instructions(InstallSource::Cargo, false, true);
|
||||
assert!(
|
||||
windows.contains("once it has exited") && windows.contains("cargo install"),
|
||||
"{windows}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const SECRET_PREFIXES: &[&str] = &["sk-", "sk_live_", "ghp_", "gho_", "xoxb-", "
|
||||
|
||||
/// Minimum run of key-shaped characters after a prefix before it counts as a credential.
|
||||
///
|
||||
/// Without this, reading Luxe's own `redact.rs` — whose source *contains* every prefix — reports a
|
||||
/// Without this, reading luxe's own `redact.rs` — whose source *contains* every prefix — reports a
|
||||
/// leak on every audit. The prefix alone is prose; the prefix plus a key is a secret.
|
||||
const SECRET_BODY: usize = 16;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ fn a_bold_label_outside_the_tools_section_is_not_a_duplicate() {
|
||||
|
||||
#[test]
|
||||
fn a_credential_prefix_in_prose_is_not_a_leak_but_a_real_key_is() {
|
||||
// Reading Luxe's own redact.rs puts every prefix in a tool result; that is not a leak.
|
||||
// Reading luxe's own redact.rs puts every prefix in a tool result; that is not a leak.
|
||||
assert!(looks_like_credential("patterns like sk- and ghp_ and AKIA").is_none());
|
||||
assert!(looks_like_credential("Authorization: Bearer short").is_none());
|
||||
let leak = looks_like_credential("key=sk-abcdefghijklmnopqrstuvwxyz0123")
|
||||
|
||||
@@ -248,7 +248,7 @@ pub(super) fn worktree_notice(
|
||||
)
|
||||
}
|
||||
|
||||
/// Leaves the session's worktree and removes it, saying how it went on the terminal Luxe has
|
||||
/// Leaves the session's worktree and removes it, saying how it went on the terminal luxe has
|
||||
/// just handed back.
|
||||
pub(super) async fn remove_worktree(project: &std::path::Path, path: &std::path::Path) {
|
||||
if let Err(error) = std::env::set_current_dir(project) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Config editor handoff — opens one of Luxe's files outside the alternate screen.
|
||||
//! Config editor handoff — opens one of luxe's files outside the alternate screen.
|
||||
//!
|
||||
//! The TUI returns control before this runs, so terminal editors inherit a normal terminal.
|
||||
//! When the editor exits, the CLI rebuilds the TUI and reloads the updated configuration.
|
||||
@@ -47,7 +47,7 @@ pub(crate) async fn open_config_file(path: PathBuf) -> anyhow::Result<PathBuf> {
|
||||
/// credential file created world-readable is a credential file leaked.
|
||||
fn ensure_file(path: PathBuf) -> anyhow::Result<PathBuf> {
|
||||
if path == Config::global_path() {
|
||||
return Config::ensure_global_file().context("creating Luxe user config");
|
||||
return Config::ensure_global_file().context("creating luxe user config");
|
||||
}
|
||||
if path.exists() {
|
||||
return Ok(path);
|
||||
|
||||
@@ -135,7 +135,7 @@ pub(crate) async fn build_engine(
|
||||
|
||||
let model = settings.launch_model();
|
||||
|
||||
// Provider routing: the adapter the settings selected, plus a registry of every provider Luxe
|
||||
// Provider routing: the adapter the settings selected, plus a registry of every provider luxe
|
||||
// knows about, so an in-session model switch *or* a mid-session `/login` reaches the right one.
|
||||
let provider = build_active_adapter(settings);
|
||||
let providers = build_provider_registry(settings, &provider);
|
||||
@@ -183,8 +183,9 @@ pub(crate) async fn build_engine(
|
||||
external_work: Some(services::shared_external_work()),
|
||||
review_context_files: config.review.context_files.clone(),
|
||||
review_exclude: config.review.exclude.clone(),
|
||||
// A real session remembers what the user picked; embedders and tests leave no trace.
|
||||
remember_runtime_state: config.agent.remember_model(),
|
||||
// A real session remembers what the user picked, here and anywhere; embedders and tests
|
||||
// leave no trace.
|
||||
remember_choices_in: config.agent.remember_model().then(|| settings.work_root.clone()),
|
||||
cache_warming: config.agent.cache_warming(),
|
||||
// Ground Guided Review in real structure (relevant files + test gaps) from the warm graph.
|
||||
review_insight_provider: Some(Arc::new(crate::review_insight::GraphReviewInsight::new(
|
||||
@@ -322,8 +323,8 @@ fn assemble_hooks(
|
||||
(hook_registry, session_end_budget)
|
||||
}
|
||||
|
||||
/// The hook that reports the agent's state to the Herdr pane Luxe runs in, so its sidebar tracks
|
||||
/// Luxe. `None` outside Herdr, under `LUXE_HERDR=0`, or with `"herdr": false`.
|
||||
/// The hook that reports the agent's state to the Herdr pane luxe runs in, so its sidebar tracks
|
||||
/// luxe. `None` outside Herdr, under `LUXE_HERDR=0`, or with `"herdr": false`.
|
||||
fn herdr_hook(config: &luxe_core::config::Config) -> Option<luxe_core::hooks::herdr::HerdrHook> {
|
||||
config.herdr().then(luxe_core::hooks::herdr::HerdrHook::detect).flatten()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Configuration loading — auth/models, permissions, command hooks, and env resolution.
|
||||
//!
|
||||
//! Every reader treats its file as read-if-present: a missing or malformed config degrades to
|
||||
//! defaults rather than failing, so Luxe runs the same with or without user config.
|
||||
//! defaults rather than failing, so luxe runs the same with or without user config.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -65,7 +65,7 @@ pub(crate) fn load_luxe_config() -> ModelsConfig {
|
||||
|
||||
/// Warn if a secrets file is readable by group or other.
|
||||
///
|
||||
/// Luxe writes its own secret files `0600` (MCP token store, review stores), but `auth.json`/
|
||||
/// luxe writes its own secret files `0600` (MCP token store, review stores), but `auth.json`/
|
||||
/// `models.json` are user-authored, so we can only nudge: ssh and aws-cli take the same stance
|
||||
/// (warn/refuse on loose credential permissions). Unix-only; a no-op elsewhere.
|
||||
#[cfg(unix)]
|
||||
@@ -230,7 +230,7 @@ pub(crate) fn global_permissions_path() -> PathBuf {
|
||||
luxe_config_dir().join("permissions.json")
|
||||
}
|
||||
|
||||
/// Luxe's own config directory. See [`luxe_core::user_dirs::luxe_config_dir`], the one owner.
|
||||
/// luxe's own config directory. See [`luxe_core::user_dirs::luxe_config_dir`], the one owner.
|
||||
pub(crate) fn luxe_config_dir() -> PathBuf {
|
||||
luxe_core::user_dirs::luxe_config_dir()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Provider adapter construction — the active adapter plus a registry of every provider Luxe can
|
||||
//! Provider adapter construction — the active adapter plus a registry of every provider luxe can
|
||||
//! route to, so an in-session model switch or a mid-session `/login` reaches the right backend.
|
||||
|
||||
use std::collections::HashMap;
|
||||
@@ -88,7 +88,7 @@ pub(super) fn active_auth(
|
||||
/// the provider's own variable, then the key its block names.
|
||||
///
|
||||
/// One chain for the provider a session starts on and every one it can switch to, so the key that
|
||||
/// goes out never depends on how the session got there. A provider Luxe does not know has no
|
||||
/// goes out never depends on how the session got there. A provider luxe does not know has no
|
||||
/// variable of its own, only the `OPENAI_API_KEY` fallback, so its configured key comes first: an
|
||||
/// OpenAI key must not go to someone else's endpoint in place of the key written for it. Keys stay
|
||||
/// as written; the source expands them per request.
|
||||
@@ -108,7 +108,7 @@ fn provider_auth(store: AuthStore, name: &str, config: Option<&ProviderConfig>)
|
||||
|
||||
/// Assemble the provider registry the engine routes through on an in-session model switch.
|
||||
///
|
||||
/// Every provider Luxe knows about is registered: the built-in catalog plus anything declared in
|
||||
/// Every provider luxe knows about is registered: the built-in catalog plus anything declared in
|
||||
/// `~/.config/luxe/{auth,models}.json`. That is what makes `/login` take effect mid-session — the
|
||||
/// adapter is already there, and its store-backed auth source finds the new credential on the next
|
||||
/// turn. A provider with no credential registers too, and answers with an actionable auth error
|
||||
@@ -154,7 +154,7 @@ pub(crate) fn build_provider_registry(
|
||||
|
||||
/// A `--model` that names its provider, `anthropic/claude-opus-5-5`, split into the two.
|
||||
///
|
||||
/// Only when the prefix is a provider Luxe knows, built in or configured, and no other provider
|
||||
/// Only when the prefix is a provider luxe knows, built in or configured, and no other provider
|
||||
/// was named: under `--provider openrouter`, `anthropic/claude-x` is OpenRouter's own id, slash and
|
||||
/// all. Without the split the whole string went to the default provider as an id, which is the
|
||||
/// form the "no model selected" error tells you to type.
|
||||
|
||||
@@ -7,7 +7,7 @@ fn the_catalog_decides_which_adapter_a_known_provider_uses() {
|
||||
assert_eq!(resolve_api("openai", None), ApiKind::OpenaiResponses);
|
||||
assert_eq!(resolve_api("openai-codex", None), ApiKind::OpenaiCodex);
|
||||
assert_eq!(resolve_api("groq", None), ApiKind::OpenaiCompletions);
|
||||
// Luxe's historical default provider name is an alias of `openai`.
|
||||
// luxe's historical default provider name is an alias of `openai`.
|
||||
assert_eq!(resolve_api("openai_compat", None), ApiKind::OpenaiResponses);
|
||||
// An unknown provider is assumed to speak the most common dialect.
|
||||
assert_eq!(resolve_api("some-proxy", None), ApiKind::OpenaiCompletions);
|
||||
@@ -266,7 +266,7 @@ async fn the_launch_providers_command_key_runs_for_each_request() {
|
||||
}
|
||||
|
||||
/// Launch and a `/model` switch find a provider's key by one chain: a sign-in first, then the
|
||||
/// provider's own variable, then the key its block names, and for a provider Luxe does not know,
|
||||
/// provider's own variable, then the key its block names, and for a provider luxe does not know,
|
||||
/// its block before `OPENAI_API_KEY`. So a configured key always beats a key meant for another
|
||||
/// provider, and which one goes out never depends on how the session reached the provider.
|
||||
#[test]
|
||||
@@ -329,7 +329,7 @@ fn launch_and_a_model_switch_send_the_same_key() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Which key each kind of provider settles on with nothing stored: a provider Luxe does not know
|
||||
/// Which key each kind of provider settles on with nothing stored: a provider luxe does not know
|
||||
/// takes the key written for it before the `OPENAI_API_KEY` fallback, and one it knows takes its
|
||||
/// own variable first.
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Warm, process-wide service singletons — the LSP client, code graph, DAP debugger, and
|
||||
//! diagnostics cache — plus the per-project session store.
|
||||
//!
|
||||
//! Luxe runs one project per process, so each service is a `OnceLock` singleton reused across
|
||||
//! luxe runs one project per process, so each service is a `OnceLock` singleton reused across
|
||||
//! every tool call and hook instead of being spawned per request.
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -56,7 +56,7 @@ pub(crate) fn tool_statuses() -> Vec<luxe_core::ToolStatus> {
|
||||
/// Three inputs, and the judgement is here rather than in `luxe-lsp` so it can be read and tested
|
||||
/// in one place: the user's preference, whether a front-end can prompt, and `--trust-project`.
|
||||
///
|
||||
/// `interactive` carries the whole argument for the default. Luxe is a coding agent someone sits
|
||||
/// `interactive` carries the whole argument for the default. luxe is a coding agent someone sits
|
||||
/// in front of; the loop is a feature, not the usual way it runs. With a person there, using the
|
||||
/// server the project pinned is ordinary work — and `node_modules/.bin` exists only because
|
||||
/// `npm install` already ran that project's install scripts, which is arbitrary code and a wider
|
||||
@@ -96,7 +96,7 @@ pub(crate) fn project_tooling_allowed() -> bool {
|
||||
|
||||
/// The process-wide warm LSP service. A singleton (like [`shared_diagnostics_store`]) so the tools,
|
||||
/// the diagnostics-on-edit hook, and the workspace collector (which reads running-server state for
|
||||
/// `/lsp`) all share one instance. Luxe runs one project per process; the collector scopes
|
||||
/// `/lsp`) all share one instance. luxe runs one project per process; the collector scopes
|
||||
/// running servers to the active root.
|
||||
pub(crate) fn build_lsp_service() -> SharedLspService {
|
||||
static SERVICE: std::sync::OnceLock<SharedLspService> = std::sync::OnceLock::new();
|
||||
@@ -112,7 +112,7 @@ pub(crate) fn build_lsp_service() -> SharedLspService {
|
||||
|
||||
/// The process-wide warm code graph service, shared by the `impact` / `module_report` tools and the
|
||||
/// graph-invalidation hook. Singleton like the LSP/DAP services; rooted at the workspace on first
|
||||
/// use (Luxe runs one project per process).
|
||||
/// use (luxe runs one project per process).
|
||||
pub(crate) fn build_graph_service(
|
||||
repo_root: &std::path::Path,
|
||||
) -> Arc<luxe_lsp::graph::GraphService> {
|
||||
@@ -223,7 +223,7 @@ fn read_config_text(path: &std::path::Path) -> Result<Option<String>, String> {
|
||||
///
|
||||
/// A shared handle at the binary boundary: it lets the (core) hook publish per-file diagnostics
|
||||
/// that the (core-agnostic) collector reads for the Context Dock without threading a channel
|
||||
/// through every front-end. Luxe runs one project per process; the collector filters entries to the
|
||||
/// through every front-end. luxe runs one project per process; the collector filters entries to the
|
||||
/// active root, so a project switch never leaks another tree's diagnostics.
|
||||
pub(crate) fn shared_diagnostics_store() -> luxe_core::lsp::DiagnosticsStore {
|
||||
static STORE: std::sync::OnceLock<luxe_core::lsp::DiagnosticsStore> =
|
||||
|
||||
@@ -169,7 +169,7 @@ pub(super) fn attach_session(
|
||||
Ok((session_id, claim))
|
||||
}
|
||||
|
||||
/// Claim `session_id` for this process, or say which Luxe has it open and how to get there.
|
||||
/// Claim `session_id` for this process, or say which luxe has it open and how to get there.
|
||||
fn claim_session(
|
||||
store: &luxe_core::session::JsonlSessionStore,
|
||||
session_id: &SessionId,
|
||||
@@ -181,7 +181,7 @@ fn claim_session(
|
||||
}
|
||||
}
|
||||
|
||||
/// Why `session` can't be opened here right now, when another Luxe has it open.
|
||||
/// Why `session` can't be opened here right now, when another luxe has it open.
|
||||
///
|
||||
/// Asked before leaving the session that's running, so the reader stays where they are rather
|
||||
/// than landing outside the TUI. This process's own claims don't count against it.
|
||||
@@ -195,7 +195,7 @@ pub(crate) fn open_elsewhere_now(state_root: &std::path::Path, session: &str) ->
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the session is open, when the Luxe that has it says so, and what to do about it.
|
||||
/// Where the session is open, when the luxe that has it says so, and what to do about it.
|
||||
fn open_elsewhere(id: &SessionId) -> String {
|
||||
let runtime = luxe_core::user_dirs::luxe_runtime_dir();
|
||||
let holder = luxe_core::local_endpoint::live_sessions(&runtime)
|
||||
@@ -207,7 +207,7 @@ fn open_elsewhere(id: &SessionId) -> String {
|
||||
};
|
||||
// `luxe join` is not offered: it speaks the protocol, so a person running it sees JSON
|
||||
format!(
|
||||
"session {id} is already open in another Luxe{place}. Carry on there, or close it \
|
||||
"session {id} is already open in another luxe{place}. Carry on there, or close it \
|
||||
there first"
|
||||
)
|
||||
}
|
||||
@@ -299,7 +299,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let refused = attach_session(&settings, &mut store).expect_err("held elsewhere");
|
||||
let expected = format!("session {id} is already open in another Luxe");
|
||||
let expected = format!("session {id} is already open in another luxe");
|
||||
assert!(refused.to_string().contains(&expected), "{refused}");
|
||||
assert!(open_elsewhere_now(dir.path(), &id.0).is_some());
|
||||
drop(other_process);
|
||||
|
||||
@@ -153,16 +153,17 @@ impl AgentSettings {
|
||||
/// Resolve settings, letting `cli` overrides win over env and config.
|
||||
pub(crate) fn resolve(repo_root: PathBuf, cli: CliOverrides) -> Self {
|
||||
let config = load_luxe_config();
|
||||
// What the last session picked, unless the user asked us not to remember. It sits *below*
|
||||
// the CLI and the environment (a one-off `--model` must stay a one-off) and *above* the
|
||||
// configured default, which is the point: the default is where you start, not where you are
|
||||
// pinned.
|
||||
// What the last session picked in this project, or anywhere when this project has no pick
|
||||
// of its own, unless the user asked us not to remember. It sits *below* the CLI and the
|
||||
// environment (a one-off `--model` must stay a one-off) and *above* the configured
|
||||
// default, which is the point: the default is where you start, not where you are pinned.
|
||||
let ui_config = luxe_core::config::Config::load(&repo_root);
|
||||
let remembered = ui_config
|
||||
.agent
|
||||
.remember_model()
|
||||
.then(luxe_core::runtime_state::RuntimeState::load)
|
||||
.unwrap_or_default();
|
||||
let last_chosen = remembered.model_for(&repo_root);
|
||||
|
||||
let named_provider = cli.provider.or_else(|| env_nonempty("LUXE_PROVIDER"));
|
||||
let from_flag_or_env = cli.model.clone().or_else(|| env_nonempty("LUXE_MODEL"));
|
||||
@@ -175,17 +176,14 @@ impl AgentSettings {
|
||||
};
|
||||
let provider = named_provider
|
||||
.or(provider_in_model)
|
||||
.or_else(|| remembered.model.as_ref().map(|model| model.provider.clone()))
|
||||
.or_else(|| last_chosen.map(|model| model.provider.clone()))
|
||||
.or_else(|| config.default_provider.clone())
|
||||
.unwrap_or_else(|| "openai_compat".to_string());
|
||||
|
||||
// A remembered model only applies to the provider it was chosen for: pairing last session's
|
||||
// Anthropic model id with a locally forced provider would resolve to nothing.
|
||||
let remembered_model = remembered
|
||||
.model
|
||||
.as_ref()
|
||||
.filter(|model| model.provider == provider)
|
||||
.map(|model| model.id.clone());
|
||||
let remembered_model =
|
||||
last_chosen.filter(|model| model.provider == provider).map(|model| model.id.clone());
|
||||
// A configured `default_model` belongs to the provider it was configured alongside. Pairing
|
||||
// it with a provider forced on the command line produces combinations that don't exist —
|
||||
// `claude-sonnet-5` on Codex — so it only applies when that provider can actually serve it.
|
||||
|
||||
@@ -131,7 +131,7 @@ fn tool_registry_has_builtins_and_lsp() {
|
||||
/// The loop is opt-in, so nothing it owns may reach an ordinary session.
|
||||
///
|
||||
/// `loop_control` was registered unconditionally, and since it is not a core tool it landed in
|
||||
/// the "available on demand" catalog of every prompt Luxe sent — offering a plain chat session a
|
||||
/// the "available on demand" catalog of every prompt luxe sent — offering a plain chat session a
|
||||
/// tool for advancing phases of an autonomous run that was not happening.
|
||||
#[test]
|
||||
fn loop_control_is_absent_unless_a_loop_is_driving() {
|
||||
@@ -189,6 +189,7 @@ fn a_remembered_model_beats_the_configured_default_but_not_a_flag() {
|
||||
provider: "anthropic".into(),
|
||||
id: "claude-opus-5".into(),
|
||||
}),
|
||||
project_models: Vec::new(),
|
||||
thinking: Some(luxe_core::provider::ThinkingLevel::High),
|
||||
recent_commands: Vec::new(),
|
||||
panes: Default::default(),
|
||||
@@ -213,6 +214,40 @@ fn a_remembered_model_beats_the_configured_default_but_not_a_flag() {
|
||||
assert_eq!(overridden.chosen().r#ref.id, "claude-sonnet-5");
|
||||
}
|
||||
|
||||
/// The model last chosen in this project outranks the one last chosen anywhere, and a project with
|
||||
/// no pick of its own starts on the latter.
|
||||
#[test]
|
||||
fn a_projects_own_pick_beats_the_last_one_anywhere() {
|
||||
use luxe_core::runtime_state::{ProjectModel, RememberedModel, RuntimeState};
|
||||
let _guard = ENV_LOCK.lock().unwrap_or_else(|error| error.into_inner());
|
||||
let home = tempfile::tempdir().expect("temp home");
|
||||
let state = home.path().join("state");
|
||||
std::fs::create_dir_all(&state).expect("state dir");
|
||||
let here = tempfile::tempdir().expect("temp project");
|
||||
let model =
|
||||
|provider: &str, id: &str| RememberedModel { provider: provider.into(), id: id.into() };
|
||||
RuntimeState {
|
||||
model: Some(model("anthropic", "claude-opus-5")),
|
||||
project_models: vec![ProjectModel {
|
||||
project: luxe_core::paths::display(here.path()),
|
||||
model: model("openai", "gpt-5.6"),
|
||||
}],
|
||||
..RuntimeState::default()
|
||||
}
|
||||
.save_to(&state.join("state.json"))
|
||||
.expect("write state");
|
||||
let _state_dir = EnvGuard::set("LUXE_STATE_DIR", state.to_str().expect("utf-8 path"));
|
||||
|
||||
let in_project = AgentSettings::resolve(here.path().to_path_buf(), CliOverrides::default());
|
||||
assert_eq!(
|
||||
(in_project.provider.as_str(), in_project.chosen().r#ref.id.as_str()),
|
||||
("openai", "gpt-5.6")
|
||||
);
|
||||
let elsewhere = tempfile::tempdir().expect("another project");
|
||||
let fresh = AgentSettings::resolve(elsewhere.path().to_path_buf(), CliOverrides::default());
|
||||
assert_eq!(fresh.chosen().r#ref.id, "claude-opus-5", "no pick here, so the last anywhere");
|
||||
}
|
||||
|
||||
/// A remembered model must not be pasted onto a different provider.
|
||||
#[test]
|
||||
fn a_remembered_model_is_ignored_when_the_provider_is_forced_elsewhere() {
|
||||
@@ -226,6 +261,7 @@ fn a_remembered_model_is_ignored_when_the_provider_is_forced_elsewhere() {
|
||||
provider: "anthropic".into(),
|
||||
id: "claude-opus-5".into(),
|
||||
}),
|
||||
project_models: Vec::new(),
|
||||
thinking: None,
|
||||
recent_commands: Vec::new(),
|
||||
panes: Default::default(),
|
||||
@@ -359,7 +395,7 @@ impl Drop for EnvGuard {
|
||||
}
|
||||
}
|
||||
|
||||
/// Nothing configured means nothing chosen. Luxe used to reach for whichever id the provider
|
||||
/// Nothing configured means nothing chosen. luxe used to reach for whichever id the provider
|
||||
/// catalog named first, which is a literal in the binary: it goes stale as models turn over,
|
||||
/// and the first thing a fresh install did with it was send it.
|
||||
#[test]
|
||||
@@ -541,6 +577,7 @@ fn a_models_own_thinking_level_outranks_the_remembered_one() {
|
||||
luxe_core::runtime_state::RuntimeState {
|
||||
schema_version: luxe_core::runtime_state::RUNTIME_STATE_SCHEMA_VERSION,
|
||||
model: None,
|
||||
project_models: Vec::new(),
|
||||
thinking: Some(ThinkingLevel::XHigh),
|
||||
recent_commands: Vec::new(),
|
||||
panes: Default::default(),
|
||||
|
||||
@@ -54,7 +54,7 @@ pub(crate) struct ToolDenyReport {
|
||||
removed: Vec<DeniedTool>,
|
||||
/// Essential, so the request was refused
|
||||
refused: Vec<DeniedTool>,
|
||||
/// A tool Luxe knows, not registered on this machine
|
||||
/// A tool luxe knows, not registered on this machine
|
||||
unavailable: Vec<DeniedTool>,
|
||||
/// No tool of that name anywhere, with the nearest one when there is a near miss
|
||||
unknown: Vec<(DeniedTool, Option<&'static str>)>,
|
||||
@@ -162,7 +162,7 @@ pub(crate) fn apply_tool_deny_list(
|
||||
report
|
||||
}
|
||||
|
||||
/// Every tool Luxe can register, whatever this machine happens to have installed.
|
||||
/// Every tool luxe can register, whatever this machine happens to have installed.
|
||||
///
|
||||
/// The set that makes "no such tool" tellable from "not here": four tools register only where
|
||||
/// their program exists (`debug`, `screenshot`, `ast_grep`) or where something is configured
|
||||
@@ -344,7 +344,7 @@ pub(crate) async fn register_mcp_tools(registry: &mut ToolRegistry, repo_root: &
|
||||
/// The MCP servers this run may start, and the ids of any the project declared that it may not.
|
||||
///
|
||||
/// A stdio server in `.mcp.json` is a command the repository chose, and an `eager` one must not
|
||||
/// start the moment Luxe opens a cloned tree, headless included. It answers to the gate project
|
||||
/// start the moment luxe opens a cloned tree, headless included. It answers to the gate project
|
||||
/// language servers and formatters already use, not a second one.
|
||||
pub(crate) fn mcp_servers_for_run(
|
||||
repo_root: &std::path::Path,
|
||||
|
||||
@@ -108,7 +108,7 @@ fn the_deny_list_classifies_what_a_real_run_asks_for() {
|
||||
assert_eq!(
|
||||
report.unavailable.iter().map(|d| d.name.as_str()).collect::<Vec<_>>(),
|
||||
["mcp"],
|
||||
"a tool Luxe knows that this run never registered is not a typo"
|
||||
"a tool luxe knows that this run never registered is not a typo"
|
||||
);
|
||||
assert_eq!(report.unknown.len(), 1);
|
||||
assert_eq!(report.unknown[0].0.name, "websearch");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
//! Guide check — the user guide's config examples, flags and slash commands, held against the code.
|
||||
//!
|
||||
//! `docs/guide/` is what a user copies from and what an agent follows. Luxe ignores a config key it
|
||||
//! does not know, on purpose, so an old config loads on a new Luxe; the cost is that a misspelled
|
||||
//! `docs/guide/` is what a user copies from and what an agent follows. luxe ignores a config key it
|
||||
//! does not know, on purpose, so an old config loads on a new luxe; the cost is that a misspelled
|
||||
//! or invented key in the docs loads too, and does nothing. These tests load every example the
|
||||
//! guide names a file for as that file, and fail on anything Luxe would ignore.
|
||||
//! guide names a file for as that file, and fail on anything luxe would ignore.
|
||||
//!
|
||||
//! A code block opts in by naming its file in the fence, ` ```json title="config.json" `, which is
|
||||
//! also what the site shows above the block. `scripts/docs-check.py` covers links and voice.
|
||||
@@ -76,7 +76,7 @@ fn blocks(page: &str, text: &str) -> Vec<Block> {
|
||||
blocks
|
||||
}
|
||||
|
||||
/// The keys Luxe would ignore reading `text` as `T`, as paths like `dock.mode`.
|
||||
/// The keys luxe would ignore reading `text` as `T`, as paths like `dock.mode`.
|
||||
fn ignored<T: DeserializeOwned>(text: &str) -> Result<Vec<String>, String> {
|
||||
let value: serde_json::Value = serde_json::from_str(text).map_err(|error| error.to_string())?;
|
||||
let mut paths = Vec::new();
|
||||
@@ -85,7 +85,7 @@ fn ignored<T: DeserializeOwned>(text: &str) -> Result<Vec<String>, String> {
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
/// The keys Luxe would ignore in an `auth.json`: every top-level key is a provider's credential,
|
||||
/// The keys luxe would ignore in an `auth.json`: every top-level key is a provider's credential,
|
||||
/// except the configuration keys it shares with `models.json`.
|
||||
fn auth_file(text: &str) -> Result<Vec<String>, String> {
|
||||
const CONFIGURATION: &[&str] =
|
||||
@@ -153,7 +153,7 @@ fn check_file(title: &str, text: &str) -> Result<(), String> {
|
||||
if unknown.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Luxe would ignore {}", unknown.join(", ")))
|
||||
Err(format!("luxe would ignore {}", unknown.join(", ")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ fn every_named_config_example_loads() {
|
||||
}
|
||||
assert!(
|
||||
failures.is_empty(),
|
||||
"config examples Luxe would not read as written:\n{}",
|
||||
"config examples luxe would not read as written:\n{}",
|
||||
failures.join("\n")
|
||||
);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ fn shell_words(line: &str) -> Vec<String> {
|
||||
words
|
||||
}
|
||||
|
||||
/// What is wrong with a `luxe …` command line, if anything: a flag or subcommand Luxe lacks.
|
||||
/// What is wrong with a `luxe …` command line, if anything: a flag or subcommand luxe lacks.
|
||||
fn check_command_line(root: &clap::Command, line: &str) -> Result<(), String> {
|
||||
let mut path: Vec<&clap::Command> = vec![root];
|
||||
let words = shell_words(line);
|
||||
@@ -286,14 +286,14 @@ fn every_command_line_in_the_guide_exists() {
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(failures.is_empty(), "command lines Luxe would refuse:\n{}", failures.join("\n"));
|
||||
assert!(failures.is_empty(), "command lines luxe would refuse:\n{}", failures.join("\n"));
|
||||
}
|
||||
|
||||
/// Paths that look like a slash command in a code span.
|
||||
const NOT_COMMANDS: &[&str] =
|
||||
&["/tmp", "/etc", "/usr", "/dev", "/home", "/var", "/opt", "/bin", "/proc"];
|
||||
|
||||
/// Every slash command the guide names is one Luxe has.
|
||||
/// Every slash command the guide names is one luxe has.
|
||||
#[test]
|
||||
fn every_slash_command_in_the_guide_exists() {
|
||||
let registry = luxe_tui::commands::CommandRegistry::all();
|
||||
@@ -329,10 +329,10 @@ fn every_slash_command_in_the_guide_exists() {
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(failures.is_empty(), "slash commands Luxe does not have:\n{}", failures.join("\n"));
|
||||
assert!(failures.is_empty(), "slash commands luxe does not have:\n{}", failures.join("\n"));
|
||||
}
|
||||
|
||||
/// The command reference lists every slash command Luxe has, and every key it binds by default, so a
|
||||
/// The command reference lists every slash command luxe has, and every key it binds by default, so a
|
||||
/// new command or binding cannot ship undocumented.
|
||||
#[test]
|
||||
fn the_command_reference_is_complete() {
|
||||
@@ -350,7 +350,7 @@ fn the_command_reference_is_complete() {
|
||||
assert!(missing.is_empty(), "commands.md does not mention:\n{}", missing.join("\n"));
|
||||
}
|
||||
|
||||
/// The configuration reference names every key `config.json` takes, from the schema Luxe writes
|
||||
/// The configuration reference names every key `config.json` takes, from the schema luxe writes
|
||||
/// beside it, so a new setting cannot ship undocumented.
|
||||
#[test]
|
||||
fn the_configuration_reference_is_complete() {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! ranks a directory holding one above a nearer checkout, so a stray left in `/tmp` re-roots every
|
||||
//! repository beneath it.
|
||||
//!
|
||||
//! Level is controlled by `LUXE_LOG` (or `RUST_LOG`). The default is `info` for Luxe's own crates
|
||||
//! Level is controlled by `LUXE_LOG` (or `RUST_LOG`). The default is `info` for luxe's own crates
|
||||
//! and `warn` for everything else — a normal run leaves a readable account of what the agent did,
|
||||
//! without `hyper` and `rustls` narrating every socket. Init is best-effort: logging must never
|
||||
//! crash or block the app.
|
||||
@@ -54,7 +54,7 @@ impl<'a> MakeWriter<'a> for RedactingFile {
|
||||
}
|
||||
}
|
||||
|
||||
/// Luxe's own crates, which is what the default filter turns up.
|
||||
/// luxe's own crates, which is what the default filter turns up.
|
||||
///
|
||||
/// Spelled out rather than matched by prefix because `EnvFilter` has no glob for a target prefix, and
|
||||
/// a filter that quietly matched nothing would look exactly like a quiet run.
|
||||
@@ -69,7 +69,7 @@ const LUXE_TARGETS: [&str; 8] = [
|
||||
"luxe_tools",
|
||||
];
|
||||
|
||||
/// The default filter: Luxe at `info`, everything else at `warn`.
|
||||
/// The default filter: luxe at `info`, everything else at `warn`.
|
||||
///
|
||||
/// Two things have to be true at once. A normal run should leave an account someone can read — which
|
||||
/// `warn` did not, and which is why routine loop behavior had drifted up to `warn!` just to be
|
||||
@@ -167,22 +167,22 @@ fn open_log(dir: &Path, rotate_at: u64) -> io::Result<(File, Option<io::Error>)>
|
||||
#[cfg(unix)]
|
||||
std::os::unix::fs::OpenOptionsExt::mode(&mut options, 0o600);
|
||||
let file = options.open(&path)?;
|
||||
// a log an older Luxe created at the umask's default is tightened too
|
||||
// a log an older luxe created at the umask's default is tightened too
|
||||
#[cfg(unix)]
|
||||
file.set_permissions(std::os::unix::fs::PermissionsExt::from_mode(0o600))?;
|
||||
Ok((file, rotated))
|
||||
}
|
||||
|
||||
/// Drop a self-ignoring `.gitignore` into `.luxe/`, and upgrade one Luxe wrote itself.
|
||||
/// Drop a self-ignoring `.gitignore` into `.luxe/`, and upgrade one luxe wrote itself.
|
||||
///
|
||||
/// The directory ignores itself (the trick pytest/ruff/venv use), so running Luxe inside any repo
|
||||
/// The directory ignores itself (the trick pytest/ruff/venv use), so running luxe inside any repo
|
||||
/// needs no root-`.gitignore` edit or global git config. The rule is an *allowlist*: everything is
|
||||
/// machine-local by default (`*` — sessions, logs, caches, review memory, per-user UI prefs), with
|
||||
/// explicit exceptions for the handful of project-config files a team may want to version
|
||||
/// (`permissions.json`, `mcp.json`, `hooks.json`, `skills/`). Ignoring by default is the safe
|
||||
/// direction: a new artifact kind Luxe writes later stays out of git until someone opts it in.
|
||||
/// direction: a new artifact kind luxe writes later stays out of git until someone opts it in.
|
||||
///
|
||||
/// A file Luxe did not author is never touched, so a user's own curation survives.
|
||||
/// A file luxe did not author is never touched, so a user's own curation survives.
|
||||
fn ensure_self_ignored(luxe_dir: &Path) {
|
||||
let ignore = luxe_dir.join(".gitignore");
|
||||
match std::fs::read_to_string(&ignore) {
|
||||
@@ -219,7 +219,7 @@ const SELF_IGNORE_BODY: &str = "\
|
||||
# and luxe keeps it out of its own reviews and changes lists for the same reason.
|
||||
*
|
||||
|
||||
# Exceptions: project config you may want to version and share. Luxe rewrites
|
||||
# Exceptions: project config you may want to version and share. luxe rewrites
|
||||
# this file while its first line says it made it; to choose for yourself, replace
|
||||
# the file, first line included, with your own.
|
||||
!permissions.json
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::*;
|
||||
use std::io::Write;
|
||||
|
||||
/// Luxe's own crates are visible at `info`, and dependencies are not.
|
||||
/// luxe's own crates are visible at `info`, and dependencies are not.
|
||||
///
|
||||
/// The break this catches is the one that shipped: with a bare `warn` default, nothing Luxe
|
||||
/// The break this catches is the one that shipped: with a bare `warn` default, nothing luxe
|
||||
/// logged at `info` was ever seen, so routine loop behavior drifted up to `warn!` just to be
|
||||
/// visible — an ordinary steer arrived labeled as a warning. Widening it to `info` for
|
||||
/// everything instead would swap that for a firehose, because `hyper` and `rustls` narrate every
|
||||
@@ -46,7 +46,7 @@ fn the_default_filter_shows_luxe_at_info_and_nothing_else() {
|
||||
let seen = seen.lock().expect("not poisoned").clone();
|
||||
assert!(
|
||||
seen.contains(&"luxe_core@INFO".to_string()),
|
||||
"Luxe's own routine logging must be visible: {seen:?}"
|
||||
"luxe's own routine logging must be visible: {seen:?}"
|
||||
);
|
||||
assert!(!seen.contains(&"luxe_core@DEBUG".to_string()), "debug stays opt-in: {seen:?}");
|
||||
assert!(
|
||||
@@ -153,7 +153,7 @@ fn self_ignore_hides_the_whole_directory_and_never_clobbers() {
|
||||
}
|
||||
|
||||
/// A log holds what the agent read and ran, so a new one is readable by its owner only, and one an
|
||||
/// older Luxe left at the umask's default is tightened when it is next opened.
|
||||
/// older luxe left at the umask's default is tightened when it is next opened.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_log_file_is_owner_only() {
|
||||
|
||||
@@ -179,7 +179,7 @@ mod tests {
|
||||
external_work: None,
|
||||
review_context_files: Vec::new(),
|
||||
review_exclude: Vec::new(),
|
||||
remember_runtime_state: false,
|
||||
remember_choices_in: None,
|
||||
cache_warming: luxe_core::cache_warming::CacheWarming::Off,
|
||||
review_insight_provider: None,
|
||||
github: None,
|
||||
@@ -197,7 +197,7 @@ mod tests {
|
||||
event_rx,
|
||||
running_rx,
|
||||
"Continue building.".into(),
|
||||
crate::loop_view::LoopView::new(true),
|
||||
crate::loop_view::LoopView::new(true, 0),
|
||||
)
|
||||
.await
|
||||
});
|
||||
|
||||
@@ -14,12 +14,20 @@
|
||||
//! Timed from the run's own start rather than the wall clock. "Twenty minutes in and still on
|
||||
//! phase 0" is the shape of the question being asked, and the absolute time is in the log for
|
||||
//! anything forensic.
|
||||
//!
|
||||
//! Each line is led by guides for the phase and iteration it belongs to ([`paint`]), and a tool
|
||||
//! call's line takes the color of its result once it has one ([`screen`]).
|
||||
|
||||
use crate::output::outln;
|
||||
mod paint;
|
||||
mod screen;
|
||||
|
||||
use paint::{CallState, Depth, Edge, Paint};
|
||||
use screen::{Printed, Screen};
|
||||
use std::collections::HashMap;
|
||||
use std::time::Instant;
|
||||
|
||||
use luxe_core::event::Event;
|
||||
use luxe_core::hooks::self_continuation::parse_iteration_notice;
|
||||
use luxe_core::message::{ContentBlock, Role};
|
||||
|
||||
/// Longest assistant line echoed into the view.
|
||||
@@ -43,16 +51,47 @@ pub(crate) struct LoopView {
|
||||
tools_this_turn: usize,
|
||||
/// When the turn now running began.
|
||||
turn_started: Option<Instant>,
|
||||
/// The phase the run is on, once known
|
||||
phase: Option<u32>,
|
||||
/// Whether an iteration's rail is open
|
||||
in_iteration: bool,
|
||||
/// The phase the run started on, until its first turn opens it: no iteration notice does
|
||||
start_phase: Option<u32>,
|
||||
/// Calls that have started and not ended, with their line and what it said
|
||||
running: HashMap<String, RunningCall>,
|
||||
paint: Paint,
|
||||
screen: Screen,
|
||||
}
|
||||
|
||||
/// A started call's line, kept to redraw it with the result.
|
||||
struct RunningCall {
|
||||
printed: Printed,
|
||||
/// When in the run it was printed, so the redraw keeps its time
|
||||
at: std::time::Duration,
|
||||
name: String,
|
||||
label: String,
|
||||
depth: Depth,
|
||||
}
|
||||
|
||||
impl LoopView {
|
||||
pub(crate) fn new(quiet: bool) -> Self {
|
||||
/// A view for a run starting on `phase`, in color on a terminal.
|
||||
pub(crate) fn new(quiet: bool, phase: u32) -> Self {
|
||||
Self::with(quiet, Some(phase), Paint::detect(), Screen::detect())
|
||||
}
|
||||
|
||||
fn with(quiet: bool, start_phase: Option<u32>, paint: Paint, screen: Screen) -> Self {
|
||||
Self {
|
||||
quiet,
|
||||
started: Instant::now(),
|
||||
labels: HashMap::new(),
|
||||
tools_this_turn: 0,
|
||||
turn_started: None,
|
||||
phase: None,
|
||||
in_iteration: false,
|
||||
start_phase,
|
||||
running: HashMap::new(),
|
||||
paint,
|
||||
screen,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +103,14 @@ impl LoopView {
|
||||
match event {
|
||||
// A hook talking: the phase moved, the gate refused, the run is blocked. These are the
|
||||
// lines the whole view exists for.
|
||||
Event::Notice(message) => self.line("", message),
|
||||
Event::Notice(message) => match parse_iteration_notice(message) {
|
||||
Some((iteration, phase)) => {
|
||||
self.open_iteration(phase, &format!("iteration {iteration}"))
|
||||
}
|
||||
None => self.note(message),
|
||||
},
|
||||
Event::ProviderRetrying { attempt, attempts, reason } => {
|
||||
self.line("", &format!("retrying ({attempt}/{attempts}): {reason}"));
|
||||
self.note(&format!("retrying ({attempt}/{attempts}): {reason}"));
|
||||
}
|
||||
// Only the assistant's. The steer that opens each iteration and the gate's refusals
|
||||
// arrive as user messages the engine wrote to itself, and the notices above already
|
||||
@@ -78,7 +122,8 @@ impl LoopView {
|
||||
for block in &message.content {
|
||||
match block {
|
||||
ContentBlock::Text(text) if !text.trim().is_empty() => {
|
||||
self.line("· ", &bounded(first_line(text), MAX_SAID));
|
||||
let said = format!("· {}", bounded(first_line(text), MAX_SAID));
|
||||
self.within(&said);
|
||||
}
|
||||
ContentBlock::ToolCall { id, name, arguments } => {
|
||||
let label = luxe_core::describe_call(
|
||||
@@ -92,49 +137,114 @@ impl LoopView {
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::ToolStarted { call_id, name } => {
|
||||
if luxe_core::activity::is_bookkeeping(name) {
|
||||
return;
|
||||
}
|
||||
self.tools_this_turn += 1;
|
||||
match self.labels.get(call_id) {
|
||||
Some(label) if !label.is_empty() => self.line(" ", &format!("{name} {label}")),
|
||||
_ => self.line(" ", name),
|
||||
}
|
||||
}
|
||||
Event::ToolEnded { call_id, is_error } if *is_error => {
|
||||
let label = self.labels.get(call_id).cloned().unwrap_or_default();
|
||||
self.line(" ", format!("failed: {label}").trim_end());
|
||||
}
|
||||
Event::CompactionDone { tokens_before, tokens_after } => self.line(
|
||||
"",
|
||||
&format!("compacted {} → {}", thousands(*tokens_before), thousands(*tokens_after)),
|
||||
),
|
||||
Event::Error(message) => self.line("", &format!("error: {}", first_line(message))),
|
||||
Event::TurnEnded { reason } => {
|
||||
let took = self.turn_started.take().map(|at| at.elapsed()).unwrap_or_default();
|
||||
let tools = std::mem::take(&mut self.tools_this_turn);
|
||||
self.labels.clear();
|
||||
let ended = match reason {
|
||||
// Every ordinary ending says the same thing; the interesting ones name
|
||||
// themselves — a runaway guard, a cancel, a turn that failed.
|
||||
luxe_core::StopReason::EndTurn => "turn ended".to_string(),
|
||||
other => format!("turn ended: {other:?}"),
|
||||
};
|
||||
self.line("", &format!("{ended} · {tools} tools · {}", duration(took)));
|
||||
}
|
||||
Event::ToolStarted { call_id, name } => self.tool_started(call_id, name),
|
||||
Event::ToolEnded { call_id, is_error } => self.tool_ended(call_id, *is_error),
|
||||
Event::CompactionDone { tokens_before, tokens_after } => self.note(&format!(
|
||||
"compacted {} → {}",
|
||||
thousands(*tokens_before),
|
||||
thousands(*tokens_after)
|
||||
)),
|
||||
Event::Error(message) => self.note(&format!("error: {}", first_line(message))),
|
||||
Event::TurnEnded { reason } => self.turn_ended(reason),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that a turn has begun, so the line closing it can say how long it took.
|
||||
/// Note that a turn has begun, so the line closing it can say how long it took. The run's
|
||||
/// first turn opens its phase here, since no iteration notice comes before it.
|
||||
pub(crate) fn turn_started(&mut self) {
|
||||
self.turn_started = Some(Instant::now());
|
||||
if self.quiet {
|
||||
return;
|
||||
}
|
||||
if let Some(phase) = self.start_phase.take() {
|
||||
self.open_iteration(phase, "start");
|
||||
}
|
||||
}
|
||||
|
||||
/// One line: how long the run has been going, then what happened.
|
||||
fn line(&self, indent: &str, message: &str) {
|
||||
outln!("{:>9} {indent}{message}", duration(self.started.elapsed()));
|
||||
fn tool_started(&mut self, call_id: &str, name: &str) {
|
||||
if luxe_core::activity::is_bookkeeping(name) {
|
||||
return;
|
||||
}
|
||||
self.tools_this_turn += 1;
|
||||
let label = self.labels.get(call_id).cloned().unwrap_or_default();
|
||||
let depth = self.body_depth();
|
||||
let at = self.started.elapsed();
|
||||
let printed = self.print(depth, &self.paint.tool(name, &label, CallState::Running));
|
||||
let call = RunningCall { printed, at, name: name.to_string(), label, depth };
|
||||
self.running.insert(call_id.to_string(), call);
|
||||
}
|
||||
|
||||
/// Redraws the call's line in its result's color. Where it can't be redrawn, a failure gets a
|
||||
/// line of its own and a success needs none.
|
||||
fn tool_ended(&mut self, call_id: &str, is_error: bool) {
|
||||
let Some(call) = self.running.remove(call_id) else { return };
|
||||
let state = if is_error { CallState::Failed } else { CallState::Succeeded };
|
||||
let line = self.paint.tool(&call.name, &call.label, state);
|
||||
let stamped = self.stamped(call.at, call.depth, &line);
|
||||
let redrawn = self.paint.in_color() && self.screen.rewrite(call.printed, &stamped);
|
||||
if !redrawn && is_error {
|
||||
self.print(self.body_depth(), &line);
|
||||
}
|
||||
}
|
||||
|
||||
fn turn_ended(&mut self, reason: &luxe_core::StopReason) {
|
||||
let took = self.turn_started.take().map(|at| at.elapsed()).unwrap_or_default();
|
||||
let tools = std::mem::take(&mut self.tools_this_turn);
|
||||
self.labels.clear();
|
||||
self.running.clear();
|
||||
let ended = match reason {
|
||||
// Every ordinary ending says the same thing; the interesting ones name
|
||||
// themselves — a runaway guard, a cancel, a turn that failed.
|
||||
luxe_core::StopReason::EndTurn => "turn ended".to_string(),
|
||||
other => format!("turn ended: {other:?}"),
|
||||
};
|
||||
let summary = self.paint.dim(&format!("{ended} · {tools} tools · {}", duration(took)));
|
||||
let depth = match (self.phase, self.in_iteration) {
|
||||
(Some(phase), true) => Depth::Iteration(phase, Edge::Close),
|
||||
_ => self.body_depth(),
|
||||
};
|
||||
self.in_iteration = false;
|
||||
self.print(depth, &summary);
|
||||
}
|
||||
|
||||
/// Opens an iteration, under a heading first when it starts a new phase.
|
||||
fn open_iteration(&mut self, phase: u32, label: &str) {
|
||||
if self.phase != Some(phase) {
|
||||
self.print(Depth::Phase(phase), &self.paint.phase_heading(phase));
|
||||
self.phase = Some(phase);
|
||||
}
|
||||
self.in_iteration = true;
|
||||
self.print(Depth::Iteration(phase, Edge::Open), label);
|
||||
}
|
||||
|
||||
/// A line inside whatever is open.
|
||||
fn within(&mut self, text: &str) {
|
||||
self.print(self.body_depth(), text);
|
||||
}
|
||||
|
||||
/// A hook's or the engine's notice: inside the iteration when one is open.
|
||||
fn note(&mut self, text: &str) {
|
||||
self.within(text);
|
||||
}
|
||||
|
||||
/// The depth a body line sits at now.
|
||||
fn body_depth(&self) -> Depth {
|
||||
match (self.phase, self.in_iteration) {
|
||||
(Some(phase), true) => Depth::Iteration(phase, Edge::Within),
|
||||
(Some(phase), false) => Depth::Phase(phase),
|
||||
(None, _) => Depth::Run,
|
||||
}
|
||||
}
|
||||
|
||||
/// One line: how long the run has been going, the guides, then what happened.
|
||||
fn print(&mut self, depth: Depth, text: &str) -> Printed {
|
||||
let line = self.stamped(self.started.elapsed(), depth, text);
|
||||
self.screen.print(&line)
|
||||
}
|
||||
|
||||
fn stamped(&self, elapsed: std::time::Duration, depth: Depth, text: &str) -> String {
|
||||
format!("{:>9} {}{text}", duration(elapsed), self.paint.guides(depth))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +328,7 @@ mod tests {
|
||||
/// still built labels would be a memory cost for output nobody asked for.
|
||||
#[test]
|
||||
fn a_quiet_view_does_not_even_look() {
|
||||
let mut view = LoopView::new(true);
|
||||
let mut view = recording(true);
|
||||
view.observe(&Event::MessageCommitted {
|
||||
session_id: "s".into(),
|
||||
entry_id: luxe_core::session::EntryId::new(),
|
||||
@@ -232,7 +342,7 @@ mod tests {
|
||||
/// A turn's tool count belongs to that turn, and starts again with the next one.
|
||||
#[test]
|
||||
fn each_turn_counts_its_own_tools() {
|
||||
let mut view = LoopView::new(false);
|
||||
let mut view = recording(false);
|
||||
view.turn_started();
|
||||
view.observe(&Event::ToolStarted { call_id: "a".into(), name: "read".into() });
|
||||
view.observe(&Event::ToolStarted { call_id: "b".into(), name: "edit".into() });
|
||||
@@ -243,14 +353,83 @@ mod tests {
|
||||
assert!(view.labels.is_empty(), "and does not inherit the last turn's labels");
|
||||
}
|
||||
|
||||
/// Luxe's own bookkeeping is not work anyone asked to watch.
|
||||
/// luxe's own bookkeeping is not work anyone asked to watch.
|
||||
#[test]
|
||||
fn activating_a_tool_is_not_a_step_worth_a_line() {
|
||||
let mut view = LoopView::new(false);
|
||||
let mut view = recording(false);
|
||||
view.observe(&Event::ToolStarted {
|
||||
call_id: "c".into(),
|
||||
name: luxe_core::tool::ACTIVATE_TOOLS_NAME.into(),
|
||||
});
|
||||
assert_eq!(view.tools_this_turn, 0);
|
||||
}
|
||||
|
||||
/// A plain view of a run starting on phase 0, its lines kept.
|
||||
fn recording(quiet: bool) -> LoopView {
|
||||
LoopView::with(quiet, Some(0), Paint::plain(), Screen::recording())
|
||||
}
|
||||
|
||||
/// What the view printed, past the time column.
|
||||
fn printed(view: &LoopView) -> Vec<String> {
|
||||
view.screen.lines().iter().map(|line| line[11..].to_string()).collect()
|
||||
}
|
||||
|
||||
fn notice(text: &str) -> Event {
|
||||
Event::Notice(text.into())
|
||||
}
|
||||
|
||||
fn ended(view: &mut LoopView, call_id: &str, is_error: bool) {
|
||||
view.observe(&Event::ToolEnded { call_id: call_id.into(), is_error });
|
||||
}
|
||||
|
||||
/// The first turn opens its phase and iteration itself; the turn's end closes the iteration.
|
||||
#[test]
|
||||
fn the_first_turn_is_bracketed_under_its_phase() {
|
||||
let mut view = recording(false);
|
||||
view.turn_started();
|
||||
view.observe(&Event::ToolStarted { call_id: "a".into(), name: "read".into() });
|
||||
view.observe(&Event::TurnEnded { reason: luxe_core::StopReason::EndTurn });
|
||||
let lines = printed(&view);
|
||||
assert_eq!(lines[..3], ["┃ phase 0", "┃ ┌ start", "┃ │ ○ read"], "{lines:?}");
|
||||
assert!(lines[3].starts_with("┃ └ turn ended · 1 tools"), "{lines:?}");
|
||||
}
|
||||
|
||||
/// An iteration in the same phase opens without a heading; a new phase gets one first.
|
||||
#[test]
|
||||
fn a_new_phase_gets_a_heading_and_the_same_phase_does_not() {
|
||||
let mut view = recording(false);
|
||||
view.turn_started();
|
||||
view.observe(¬ice("iteration 2 · phase 0"));
|
||||
view.observe(¬ice("iteration 3 · phase 1"));
|
||||
let lines = printed(&view);
|
||||
assert_eq!(lines[2..], ["┃ ┌ iteration 2", "┃ phase 1", "┃ ┌ iteration 3"], "{lines:?}");
|
||||
}
|
||||
|
||||
/// Other notices sit inside the open iteration, and between iterations on the phase rail.
|
||||
#[test]
|
||||
fn a_notice_sits_at_the_depth_it_arrives() {
|
||||
let mut view = recording(false);
|
||||
view.turn_started();
|
||||
view.observe(¬ice("phase 0 claimed complete — running the gate"));
|
||||
view.observe(&Event::TurnEnded { reason: luxe_core::StopReason::EndTurn });
|
||||
view.observe(¬ice("phase 0 accepted — now on phase 1"));
|
||||
let lines = printed(&view);
|
||||
assert_eq!(lines[2], "┃ │ phase 0 claimed complete — running the gate", "{lines:?}");
|
||||
assert_eq!(lines[4], "┃ phase 0 accepted — now on phase 1", "{lines:?}");
|
||||
}
|
||||
|
||||
/// Where the line can't be redrawn, a failure still gets a line saying so, and a success
|
||||
/// adds nothing to the call's own line.
|
||||
#[test]
|
||||
fn without_a_redraw_only_a_failure_adds_a_line() {
|
||||
let mut view = recording(false);
|
||||
view.turn_started();
|
||||
view.observe(&Event::ToolStarted { call_id: "a".into(), name: "read".into() });
|
||||
view.observe(&Event::ToolStarted { call_id: "b".into(), name: "bash".into() });
|
||||
ended(&mut view, "a", false);
|
||||
ended(&mut view, "b", true);
|
||||
let lines = printed(&view);
|
||||
assert_eq!(lines.len(), 5, "{lines:?}");
|
||||
assert_eq!(lines[4], "┃ │ ✗ bash · failed", "{lines:?}");
|
||||
}
|
||||
}
|
||||
|
||||
193
crates/luxe-cli/src/loop_view/paint.rs
Normal file
193
crates/luxe-cli/src/loop_view/paint.rs
Normal file
@@ -0,0 +1,193 @@
|
||||
//! Paint — how a loop line looks: the guides that lead it, and its colors when there are any.
|
||||
//!
|
||||
//! The guides work like an editor's indent guides. A phase draws a heavy rail down the left, in
|
||||
//! a color of its own; an iteration draws a light one inside it, opened with `┌` and closed with
|
||||
//! `└`. Scrolled back through a long run, or seen in a minimap, each phase is a band of one color
|
||||
//! and each iteration a bracket within it. Colors come from the terminal's own sixteen, so its
|
||||
//! theme picks the shades, and the guides are plain characters, so a log without color keeps them.
|
||||
|
||||
use crossterm::style::{Color, Stylize};
|
||||
|
||||
/// Phase rail colors, cycled by phase number so two neighboring phases never share one.
|
||||
const PHASE_COLORS: [Color; 4] = [Color::Cyan, Color::Magenta, Color::Blue, Color::Yellow];
|
||||
|
||||
/// Where a line sits in the run, which decides the guides leading it.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub(super) enum Depth {
|
||||
/// Before the run has a phase
|
||||
Run,
|
||||
/// Inside a phase, between iterations
|
||||
Phase(u32),
|
||||
/// Inside an iteration of a phase.
|
||||
///
|
||||
/// Args: the phase, and which edge of the iteration the line is.
|
||||
Iteration(u32, Edge),
|
||||
}
|
||||
|
||||
/// Which part of an iteration a line is: its opening, its body, or its closing line.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub(super) enum Edge {
|
||||
/// `┌`, the iteration's first line
|
||||
Open,
|
||||
/// `│`, every line between
|
||||
Within,
|
||||
/// `└`, the turn's summary
|
||||
Close,
|
||||
}
|
||||
|
||||
/// How a tool call has gone so far.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub(super) enum CallState {
|
||||
/// Started, no result yet
|
||||
Running,
|
||||
/// Ended without an error
|
||||
Succeeded,
|
||||
/// Ended in an error
|
||||
Failed,
|
||||
}
|
||||
|
||||
/// Draws loop lines, in color or not.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(super) struct Paint {
|
||||
color: bool,
|
||||
}
|
||||
|
||||
impl Paint {
|
||||
/// Color when stdout is a terminal that wants it: not `NO_COLOR`, not `TERM=dumb`.
|
||||
pub(super) fn detect() -> Self {
|
||||
use std::io::IsTerminal;
|
||||
let no_color = std::env::var_os("NO_COLOR").is_some_and(|value| !value.is_empty());
|
||||
let dumb = std::env::var("TERM").is_ok_and(|term| term == "dumb");
|
||||
Self { color: std::io::stdout().is_terminal() && !no_color && !dumb }
|
||||
}
|
||||
|
||||
/// No color at all, as a pipe or a log gets.
|
||||
#[cfg(test)]
|
||||
pub(super) fn plain() -> Self {
|
||||
Self { color: false }
|
||||
}
|
||||
|
||||
/// Whether this paints in color.
|
||||
pub(super) fn in_color(self) -> bool {
|
||||
self.color
|
||||
}
|
||||
|
||||
/// The guides for a line at `depth`, each followed by a space.
|
||||
pub(super) fn guides(self, depth: Depth) -> String {
|
||||
match depth {
|
||||
Depth::Run => String::new(),
|
||||
Depth::Phase(phase) => format!("{} ", self.rail(phase)),
|
||||
Depth::Iteration(phase, edge) => {
|
||||
format!("{} {} ", self.rail(phase), self.dim(edge_glyph(edge)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The line that opens a phase: its number in the phase's color.
|
||||
pub(super) fn phase_heading(self, phase: u32) -> String {
|
||||
let text = format!("phase {phase}");
|
||||
match self.color {
|
||||
true => text.with(phase_color(phase)).bold().to_string(),
|
||||
false => text,
|
||||
}
|
||||
}
|
||||
|
||||
/// A tool call: a mark and the tool's name colored by how it went, then what it was asked.
|
||||
/// A failure says so in words too, so the color never carries it alone.
|
||||
pub(super) fn tool(self, name: &str, label: &str, state: CallState) -> String {
|
||||
let (mark, color) = match state {
|
||||
CallState::Running => ("○", None),
|
||||
CallState::Succeeded => ("✓", Some(Color::Green)),
|
||||
CallState::Failed => ("✗", Some(Color::Red)),
|
||||
};
|
||||
let head = format!("{mark} {name}");
|
||||
let head = match (self.color, color) {
|
||||
(true, Some(color)) => head.with(color).bold().to_string(),
|
||||
(true, None) => head.bold().to_string(),
|
||||
(false, _) => head,
|
||||
};
|
||||
let failed = match state {
|
||||
CallState::Failed => format!(" · {}", self.colored("failed", Color::Red)),
|
||||
_ => String::new(),
|
||||
};
|
||||
format!("{head} {label}").trim_end().to_string() + &failed
|
||||
}
|
||||
|
||||
/// Secondary text: a turn's summary, the iteration rail.
|
||||
pub(super) fn dim(self, text: &str) -> String {
|
||||
match self.color {
|
||||
true => text.dim().to_string(),
|
||||
false => text.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn colored(self, text: &str, color: Color) -> String {
|
||||
match self.color {
|
||||
true => text.with(color).to_string(),
|
||||
false => text.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rail(self, phase: u32) -> String {
|
||||
self.colored("┃", phase_color(phase))
|
||||
}
|
||||
}
|
||||
|
||||
fn phase_color(phase: u32) -> Color {
|
||||
PHASE_COLORS[phase as usize % PHASE_COLORS.len()]
|
||||
}
|
||||
|
||||
fn edge_glyph(edge: Edge) -> &'static str {
|
||||
match edge {
|
||||
Edge::Open => "┌",
|
||||
Edge::Within => "│",
|
||||
Edge::Close => "└",
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn each_depth_draws_its_own_guides() {
|
||||
let paint = Paint::plain();
|
||||
assert_eq!(paint.guides(Depth::Run), "");
|
||||
assert_eq!(paint.guides(Depth::Phase(2)), "┃ ");
|
||||
assert_eq!(paint.guides(Depth::Iteration(2, Edge::Open)), "┃ ┌ ");
|
||||
assert_eq!(paint.guides(Depth::Iteration(2, Edge::Within)), "┃ │ ");
|
||||
assert_eq!(paint.guides(Depth::Iteration(2, Edge::Close)), "┃ └ ");
|
||||
}
|
||||
|
||||
/// Without color a failure still reads as one, and a success has no word to need.
|
||||
#[test]
|
||||
fn a_failed_call_says_so_in_words() {
|
||||
let paint = Paint::plain();
|
||||
assert_eq!(paint.tool("read", "a.rs", CallState::Running), "○ read a.rs");
|
||||
assert_eq!(paint.tool("read", "a.rs", CallState::Succeeded), "✓ read a.rs");
|
||||
assert_eq!(
|
||||
paint.tool("bash", "cargo test", CallState::Failed),
|
||||
"✗ bash cargo test · failed"
|
||||
);
|
||||
assert_eq!(paint.tool("todo", "", CallState::Succeeded), "✓ todo", "no trailing space");
|
||||
}
|
||||
|
||||
/// The tool's name takes the result's color; a plain view has no escapes at all.
|
||||
#[test]
|
||||
fn the_name_is_colored_by_the_result() {
|
||||
let paint = Paint { color: true };
|
||||
let ok = paint.tool("read", "a.rs", CallState::Succeeded);
|
||||
let failed = paint.tool("read", "a.rs", CallState::Failed);
|
||||
assert!(ok.contains(&"✓ read".with(Color::Green).bold().to_string()), "{ok:?}");
|
||||
assert!(failed.contains(&"✗ read".with(Color::Red).bold().to_string()), "{failed:?}");
|
||||
assert!(!Paint::plain().tool("read", "a.rs", CallState::Failed).contains('\x1b'));
|
||||
}
|
||||
|
||||
/// Neighboring phases never share a rail color, so a phase boundary shows in a minimap.
|
||||
#[test]
|
||||
fn neighboring_phases_differ() {
|
||||
for phase in 0..8 {
|
||||
assert_ne!(phase_color(phase), phase_color(phase + 1), "{phase}");
|
||||
}
|
||||
}
|
||||
}
|
||||
177
crates/luxe-cli/src/loop_view/screen.rs
Normal file
177
crates/luxe-cli/src/loop_view/screen.rs
Normal file
@@ -0,0 +1,177 @@
|
||||
//! Screen — where loop lines go, and taking one back to redraw it.
|
||||
//!
|
||||
//! A tool call is printed when it starts, because "is it still going?" is the first question about
|
||||
//! an unattended run, and its result only exists once it ends. On a terminal the start line is
|
||||
//! redrawn in place with the result. That's only safe when every line is exactly one row, so on a
|
||||
//! terminal each line is cut to the width rather than left to wrap, and a resize since the line
|
||||
//! was printed means it's left alone. A pipe or a file never gets a redraw.
|
||||
|
||||
use crate::output::{out, outln};
|
||||
use unicode_width::UnicodeWidthChar;
|
||||
|
||||
/// A line already printed, and what's needed to find it again.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(super) struct Printed {
|
||||
/// How many lines came before it
|
||||
index: u64,
|
||||
/// The terminal's width when it was printed
|
||||
width: Option<u16>,
|
||||
}
|
||||
|
||||
/// The terminal or pipe the view prints to.
|
||||
pub(super) struct Screen {
|
||||
/// Whether lines may be cut to the width and redrawn
|
||||
terminal: bool,
|
||||
/// Lines printed so far
|
||||
printed: u64,
|
||||
/// Where a test's lines go instead of stdout
|
||||
recorded: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Screen {
|
||||
/// A terminal when stdout is one.
|
||||
pub(super) fn detect() -> Self {
|
||||
use std::io::IsTerminal;
|
||||
Self { terminal: std::io::stdout().is_terminal(), printed: 0, recorded: None }
|
||||
}
|
||||
|
||||
/// A pipe that keeps its lines for a test to read.
|
||||
#[cfg(test)]
|
||||
pub(super) fn recording() -> Self {
|
||||
Self { terminal: false, printed: 0, recorded: Some(Vec::new()) }
|
||||
}
|
||||
|
||||
/// What a [`Screen::recording`] was given.
|
||||
#[cfg(test)]
|
||||
pub(super) fn lines(&self) -> &[String] {
|
||||
self.recorded.as_deref().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Prints `line` as one row, and says where it went.
|
||||
pub(super) fn print(&mut self, line: &str) -> Printed {
|
||||
let width = self.width();
|
||||
let printed = Printed { index: self.printed, width };
|
||||
self.printed += 1;
|
||||
if let Some(recorded) = &mut self.recorded {
|
||||
recorded.push(line.to_string());
|
||||
return printed;
|
||||
}
|
||||
match width {
|
||||
Some(cells) => outln!("{}", fit(line, usize::from(cells))),
|
||||
None => outln!("{line}"),
|
||||
}
|
||||
printed
|
||||
}
|
||||
|
||||
/// Redraws an earlier line in place. False, and nothing written, when it can't be trusted to
|
||||
/// land on the same row: not a terminal, a resize since, or scrolled past the top.
|
||||
pub(super) fn rewrite(&mut self, at: Printed, line: &str) -> bool {
|
||||
let Some(cells) = self.width().filter(|now| Some(*now) == at.width) else { return false };
|
||||
let up = self.printed - at.index;
|
||||
let rows = crossterm::terminal::size().map_or(0, |(_, rows)| u64::from(rows));
|
||||
if up == 0 || up >= rows {
|
||||
return false;
|
||||
}
|
||||
// Up to the line, clear it, draw, then back down to where the next line goes
|
||||
out!("\x1b[{up}A\r\x1b[2K{}\x1b[{up}B\r", fit(line, usize::from(cells)));
|
||||
true
|
||||
}
|
||||
|
||||
fn width(&self) -> Option<u16> {
|
||||
match self.terminal {
|
||||
true => crossterm::terminal::size().ok().map(|(cols, _)| cols),
|
||||
false => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `line` cut to fit in `width` cells, so it never wraps. Escape sequences pass through uncounted,
|
||||
/// and a cut line ends in `…` and, if it had color, a reset.
|
||||
pub(super) fn fit(line: &str, width: usize) -> String {
|
||||
if visible_width(line) <= width {
|
||||
return line.to_string();
|
||||
}
|
||||
let (cut, _) = scan(line, width.saturating_sub(1));
|
||||
let reset = if line.contains('\x1b') { "\x1b[0m" } else { "" };
|
||||
format!("{cut}…{reset}")
|
||||
}
|
||||
|
||||
/// Where the scanner is: in text, just past an escape, or inside a `CSI` sequence.
|
||||
#[derive(Clone, Copy)]
|
||||
enum Scan {
|
||||
Text,
|
||||
Escape,
|
||||
Csi,
|
||||
}
|
||||
|
||||
/// `line` up to `budget` visible cells, with every escape sequence kept, and the cells it used.
|
||||
fn scan(line: &str, budget: usize) -> (String, usize) {
|
||||
let mut kept = String::with_capacity(line.len());
|
||||
let mut used = 0;
|
||||
let mut state = Scan::Text;
|
||||
for ch in line.chars() {
|
||||
state = match (state, ch) {
|
||||
(Scan::Text, '\x1b') => Scan::Escape,
|
||||
(Scan::Escape, '[') => Scan::Csi,
|
||||
(Scan::Escape, _) => Scan::Text,
|
||||
(Scan::Csi, '@'..='~') => Scan::Text,
|
||||
(Scan::Csi, _) => Scan::Csi,
|
||||
(Scan::Text, text) => {
|
||||
let cells = text.width().unwrap_or(0);
|
||||
if used + cells > budget {
|
||||
break;
|
||||
}
|
||||
used += cells;
|
||||
Scan::Text
|
||||
}
|
||||
};
|
||||
kept.push(ch);
|
||||
}
|
||||
(kept, used)
|
||||
}
|
||||
|
||||
fn visible_width(line: &str) -> usize {
|
||||
scan(line, usize::MAX).1
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_line_that_fits_is_left_alone() {
|
||||
assert_eq!(fit("○ read a.rs", 40), "○ read a.rs");
|
||||
assert_eq!(fit("exactly", 7), "exactly");
|
||||
}
|
||||
|
||||
/// One cell short of the width plus the ellipsis is the width, so the row never wraps.
|
||||
#[test]
|
||||
fn a_long_line_is_cut_to_the_width() {
|
||||
assert_eq!(fit("abcdefghij", 6), "abcde…");
|
||||
assert_eq!(visible_width(&fit("abcdefghij", 6)), 6);
|
||||
}
|
||||
|
||||
/// Escapes take no cells: a colored line that fits isn't cut, and a cut one is reset.
|
||||
#[test]
|
||||
fn escapes_are_not_counted() {
|
||||
let green = "\x1b[32m✓ read\x1b[39m a.rs";
|
||||
assert_eq!(visible_width(green), "✓ read a.rs".chars().count());
|
||||
assert_eq!(fit(green, 11), green);
|
||||
assert_eq!(fit(green, 5), "\x1b[32m✓ re…\x1b[0m");
|
||||
}
|
||||
|
||||
/// A wide character counts as the two cells it takes.
|
||||
#[test]
|
||||
fn wide_characters_count_double() {
|
||||
assert_eq!(visible_width("日本"), 4);
|
||||
assert_eq!(fit("日本語", 5), "日本…");
|
||||
}
|
||||
|
||||
/// A pipe never redraws: there's no row to go back to.
|
||||
#[test]
|
||||
fn a_pipe_never_redraws() {
|
||||
let mut screen = Screen::recording();
|
||||
let line = screen.print("○ read a.rs");
|
||||
assert!(!screen.rewrite(line, "✓ read a.rs"));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Model catalog wiring — cache location, refresh scheduling, and the `/model` menu.
|
||||
//!
|
||||
//! Metadata itself is resolved by [`luxe_providers::catalog`]; this module owns the parts that
|
||||
//! depend on where Luxe keeps files and when it's allowed to touch the network. Resolution is
|
||||
//! depend on where luxe keeps files and when it's allowed to touch the network. Resolution is
|
||||
//! always offline-safe — it reads the embedded snapshot plus a local cache and never blocks —
|
||||
//! while [`spawn_refresh`] keeps that cache current in the background.
|
||||
|
||||
@@ -71,7 +71,7 @@ pub(crate) fn build_menu(settings: &AgentSettings) -> ModelMenu {
|
||||
push(&mut entries, resolve_model(&config, provider, id).0, true);
|
||||
}
|
||||
|
||||
// Then everything the catalog knows for providers Luxe can actually route to: the ones with a
|
||||
// Then everything the catalog knows for providers luxe can actually route to: the ones with a
|
||||
// config block, anything the user has signed in to (a Copilot login is worthless if its models
|
||||
// never appear), and the launch's own provider when the launch itself carries the credentials
|
||||
// to reach it.
|
||||
|
||||
@@ -187,7 +187,7 @@ fn an_unconfigured_machine_has_no_models_to_choose_between() {
|
||||
let with_key = AgentSettings::resolve(std::path::PathBuf::from("."), Default::default());
|
||||
let catalog = build_menu(&with_key).catalog;
|
||||
std::env::remove_var("ANTHROPIC_API_KEY");
|
||||
assert!(!catalog.is_empty(), "an ambient key is a provider Luxe can route to");
|
||||
assert!(!catalog.is_empty(), "an ambient key is a provider luxe can route to");
|
||||
assert!(
|
||||
catalog.iter().all(|entry| entry.info.r#ref.provider == "anthropic"),
|
||||
"and only that provider's models: {:?}",
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
//! idiom.
|
||||
//!
|
||||
//! The usual cure — resetting `SIGPIPE` to its default so the process dies silently — is wrong
|
||||
//! here. Luxe writes to hook, MCP and LSP pipes and relies on `EPIPE` arriving as an error: the
|
||||
//! here. luxe writes to hook, MCP and LSP pipes and relies on `EPIPE` arriving as an error: the
|
||||
//! command-hook runner deliberately tolerates a hook that exits without reading its stdin, and a
|
||||
//! default `SIGPIPE` would kill Luxe at that line instead. So the pipe stays ignored and the
|
||||
//! default `SIGPIPE` would kill luxe at that line instead. So the pipe stays ignored and the
|
||||
//! writing goes through one place, where a reader that has gone away is a quiet, successful end of
|
||||
//! output.
|
||||
//!
|
||||
|
||||
@@ -249,10 +249,10 @@ async fn look<G: Discovery + Branches + ?Sized>(
|
||||
fn unavailable(error: &GitHubError) -> Option<String> {
|
||||
let reason = match error {
|
||||
GitHubError::NotInstalled => {
|
||||
"The GitHub CLI (`gh`) is not installed, so Luxe cannot see this branch's pull request."
|
||||
"The GitHub CLI (`gh`) is not installed, so luxe cannot see this branch's pull request."
|
||||
}
|
||||
GitHubError::NotAuthenticated { .. } => {
|
||||
"The GitHub CLI is not signed in. Run `gh auth login`, and Luxe picks it up the next \
|
||||
"The GitHub CLI is not signed in. Run `gh auth login`, and luxe picks it up the next \
|
||||
time the terminal has focus."
|
||||
}
|
||||
GitHubError::NotGitHub => "This repository has no remote on GitHub.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The reviewer as an agent — a real turn, with the real tools, in a session of its own.
|
||||
//!
|
||||
//! A review is a model driving Luxe. It gets the same pipeline every other turn gets: the tool
|
||||
//! A review is a model driving luxe. It gets the same pipeline every other turn gets: the tool
|
||||
//! registry, the permission engine, per-tool deadlines, cancellation, the hook chain. What makes it
|
||||
//! a *review* is how its engine is built — the reviewer's model, the reviewer's tools and no others,
|
||||
//! and a mode that refuses every write — and the brief it is handed, which says who it is.
|
||||
|
||||
@@ -313,7 +313,7 @@ fn bounded_text(text: &str, limit: usize) -> String {
|
||||
value
|
||||
}
|
||||
|
||||
/// Luxe's own project directory, excluded from what it reports as *your* changes.
|
||||
/// luxe's own project directory, excluded from what it reports as *your* changes.
|
||||
const LUXE_PROJECT_DIR: &str = ".luxe";
|
||||
|
||||
async fn project_identity(root: &Path) -> ProjectIdentity {
|
||||
|
||||
@@ -17,7 +17,7 @@ pub(super) async fn collect_change_summary(root: PathBuf) -> WorkspaceChangesSum
|
||||
let counts = numstat.as_deref().map(parse_numstat).unwrap_or_default();
|
||||
let files = parse_status(&status)
|
||||
.into_iter()
|
||||
// Luxe's own project directory — sessions, logs, tasks, review artifacts — is not the
|
||||
// luxe's own project directory — sessions, logs, tasks, review artifacts — is not the
|
||||
// user's work. Listing it made the dock's count disagree with the review's forever.
|
||||
.filter(|(path, _)| !path.starts_with(LUXE_PROJECT_DIR))
|
||||
.map(|(path, status)| {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub(super) async fn collect_external_summary(
|
||||
}
|
||||
let changes = collect_change_summary(root.clone()).await;
|
||||
// A repository that *contains* the project — an edit in a sibling directory of a checkout
|
||||
// Luxe was opened one level inside — reports the project's own files too. Those already
|
||||
// luxe was opened one level inside — reports the project's own files too. Those already
|
||||
// have a section, and listing them twice would double every number on the screen.
|
||||
let mut files = changes.files;
|
||||
files.retain(|file| !luxe_core::paths::contains(project_root, &root.join(&file.path)));
|
||||
|
||||
@@ -118,7 +118,7 @@ fn git_repo_with_a_commit(root: &Path) {
|
||||
}
|
||||
|
||||
/// A checkout is asked the same question the project is asked, which is the whole point of
|
||||
/// recording the root instead of the file: this change is made with the shell, so nothing Luxe
|
||||
/// recording the root instead of the file: this change is made with the shell, so nothing luxe
|
||||
/// tracks per-file could have seen it.
|
||||
#[tokio::test]
|
||||
async fn an_external_checkout_is_reported_by_git() {
|
||||
@@ -130,7 +130,7 @@ async fn an_external_checkout_is_reported_by_git() {
|
||||
|
||||
let work = ExternalWork::new();
|
||||
work.observe(&sibling.join("lib.rs"));
|
||||
// Not through any Luxe tool — exactly what the per-file ledger cannot know about.
|
||||
// Not through any luxe tool — exactly what the per-file ledger cannot know about.
|
||||
std::fs::write(sibling.join("lib.rs"), "alpha\nbeta\ngamma\n").unwrap();
|
||||
|
||||
let summary = collect_external_summary(work.record(), &project).await;
|
||||
@@ -143,7 +143,7 @@ async fn an_external_checkout_is_reported_by_git() {
|
||||
assert_eq!(summary.total_files, 1);
|
||||
}
|
||||
|
||||
/// A repository Luxe was opened *inside* reports the project's own files too. They already have
|
||||
/// A repository luxe was opened *inside* reports the project's own files too. They already have
|
||||
/// a section, and counting them twice would double every number on screen.
|
||||
#[tokio::test]
|
||||
async fn a_parent_checkout_does_not_report_the_project_twice() {
|
||||
|
||||
@@ -119,7 +119,7 @@ async fn bridge_tracks_real_engine_startup_and_new_sessions() {
|
||||
external_work: None,
|
||||
review_context_files: Vec::new(),
|
||||
review_exclude: Vec::new(),
|
||||
remember_runtime_state: false,
|
||||
remember_choices_in: None,
|
||||
cache_warming: luxe_core::cache_warming::CacheWarming::Off,
|
||||
review_insight_provider: None,
|
||||
github: None,
|
||||
|
||||
@@ -15,15 +15,15 @@ fn project_server(project: &Path) {
|
||||
std::fs::write(project.join(".mcp.json"), config.to_string()).unwrap();
|
||||
}
|
||||
|
||||
/// Whether Luxe launched the project's server. The marker is the proof when the child gets that far,
|
||||
/// but the child is this test binary starting up again, and on a slow runner Luxe can give up on the
|
||||
/// Whether luxe launched the project's server. The marker is the proof when the child gets that far,
|
||||
/// but the child is this test binary starting up again, and on a slow runner luxe can give up on the
|
||||
/// closed connection before that startup reaches the write; its report of the attempt is the proof
|
||||
/// then. A refused server is never launched, so neither can appear.
|
||||
fn started(project: &Path, stdout: &str) -> bool {
|
||||
project.join("mcp-ran").exists() || stdout.contains("project-marker: failed to connect")
|
||||
}
|
||||
|
||||
/// Whether Luxe refused to start the project's server: it says so, naming it. Checked alongside the
|
||||
/// Whether luxe refused to start the project's server: it says so, naming it. Checked alongside the
|
||||
/// absent marker, which alone would also pass for a server launched too slowly to have written it.
|
||||
fn refused(project: &Path, stdout: &str) -> bool {
|
||||
stdout.contains("Not starting project MCP servers: project-marker")
|
||||
|
||||
@@ -272,7 +272,7 @@ fn changed_repository() -> tempfile::TempDir {
|
||||
};
|
||||
git(&["init", "--quiet", "--initial-branch=main"]);
|
||||
git(&["config", "user.email", "tests@example.invalid"]);
|
||||
git(&["config", "user.name", "Luxe Tests"]);
|
||||
git(&["config", "user.name", "luxe Tests"]);
|
||||
std::fs::write(project.path().join("total.rs"), "fn total() -> u32 {\n 1\n}\n").unwrap();
|
||||
git(&["add", "total.rs"]);
|
||||
git(&["commit", "--quiet", "-m", "initial"]);
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "luxe-core"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description = "Luxe's engine: the agent loop, session model, context assembly, permissions, and the Provider/Tool/Hook traits"
|
||||
description = "luxe's engine: the agent loop, session model, context assembly, permissions, and the Provider/Tool/Hook traits"
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
|
||||
@@ -66,7 +66,7 @@ globset = "0.4"
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
rustix = { version = "1", features = ["process", "stdio", "system"] }
|
||||
|
||||
# Pointing stdin at the null device on Windows, and keeping the pipe Luxe took out of every child:
|
||||
# Pointing stdin at the null device on Windows, and keeping the pipe luxe took out of every child:
|
||||
# no safe API does either, and without it every child of `luxe --rpc` stalls behind the protocol
|
||||
# read. See `program::take_stdin`. Job objects end a command's whole tree on a timeout, where
|
||||
# Windows has no process group to signal; see `program::TreeGuard`. A session's named pipe needs a
|
||||
|
||||
@@ -211,7 +211,7 @@ impl ToolActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a tool is Luxe's own housekeeping rather than work someone asked for.
|
||||
/// Whether a tool is luxe's own housekeeping rather than work someone asked for.
|
||||
///
|
||||
/// Only [`crate::tool::ACTIVATE_TOOLS_NAME`], and only because *we* tier the registry: the model
|
||||
/// asks for a deferred tool's schema before it can call it, which is a fact about our request
|
||||
|
||||
@@ -189,7 +189,7 @@ pub enum LoginScope {
|
||||
/// Every configurable provider, with every method it offers.
|
||||
#[default]
|
||||
Any,
|
||||
/// Providers whose subscription Luxe is allowed to sign in to.
|
||||
/// Providers whose subscription luxe is allowed to sign in to.
|
||||
Subscription,
|
||||
/// Providers that take a key you already have.
|
||||
ApiKey,
|
||||
@@ -360,8 +360,6 @@ pub struct LoginOutcome {
|
||||
/// A local server takes no credential, and "API key" would be a claim the file contradicts.
|
||||
pub kind: Option<CredentialKind>,
|
||||
pub account: Option<String>,
|
||||
/// A model id worth defaulting to, when the flow learned one.
|
||||
pub suggested_model: Option<String>,
|
||||
/// Factual summary lines about what now exists (e.g. "17 models available").
|
||||
pub notes: Vec<String>,
|
||||
/// Advice that only makes sense once the credential exists, shown apart from the summary.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Briefs — the messages Luxe writes to the agent itself, told apart from the reader's own.
|
||||
//! Briefs — the messages luxe writes to the agent itself, told apart from the reader's own.
|
||||
//!
|
||||
//! A draft, a question from a review and a batch of review comments each reach the agent as a
|
||||
//! user message Luxe composed: the instructions, the evidence, the IDs a report has to echo. The
|
||||
//! user message luxe composed: the instructions, the evidence, the IDs a report has to echo. The
|
||||
//! transcript is the reader's conversation, and a page of plumbing in their own colors reads as
|
||||
//! something they said. So a front-end shows one line saying what happened instead — or, for a
|
||||
//! question from a review, just the question, since those words *are* the reader's — and the
|
||||
@@ -90,7 +90,7 @@ const FINDING_ID: &str = " Finding ID: ";
|
||||
const EVIDENCE: &str = " Evidence: ";
|
||||
const REVIEWER: &str = " Reviewer: ";
|
||||
/// The lines that follow a comment's body; none of them is the reader's question.
|
||||
const AFTER_BODY: [&str; 4] = [" Source: ", " Proposed fix: ", " Agent: ", " Luxe: "];
|
||||
const AFTER_BODY: [&str; 4] = [" Source: ", " Proposed fix: ", " Agent: ", " luxe: "];
|
||||
/// How review feedback closes.
|
||||
const CLOSING: &str = "Do not rewrite unrelated code.";
|
||||
|
||||
@@ -158,7 +158,7 @@ pub fn review_questions(text: &str) -> Vec<ReviewQuestion> {
|
||||
/// How a draft's fence opens, its newline included.
|
||||
const DRAFT_FENCE: &str = "```luxe-draft\n";
|
||||
|
||||
/// An answer as the reader sees it: without what the agent wrote for Luxe to read.
|
||||
/// An answer as the reader sees it: without what the agent wrote for luxe to read.
|
||||
///
|
||||
/// A fix's remediation report goes, since the review shows it comment by comment, and the prose
|
||||
/// around it stays. An answer carrying a draft goes whole: the draft opens in the card or composer
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
//!
|
||||
//! # Design
|
||||
//!
|
||||
//! Same policy as Pi's, checked against Luxe's own ledgers:
|
||||
//! Same policy as Pi's, checked against luxe's own ledgers:
|
||||
//!
|
||||
//! - **While a turn runs** the next request is certain, so a refresh pays whenever a read costs
|
||||
//! less than the write it saves. Across 2,980 recorded Claude calls this rescued 12 of 14 waits
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn estimate_message_tokens(messages: &[Message]) -> u64 {
|
||||
/// Estimate the tokens a request spends before any conversation: the system prompt and the tool
|
||||
/// schemas.
|
||||
///
|
||||
/// Far from negligible — Luxe's harness plus two dozen JSON schemas is tens of thousands of
|
||||
/// Far from negligible — luxe's harness plus two dozen JSON schemas is tens of thousands of
|
||||
/// tokens, and leaving it out of a prompt figure is how a request that "fits" turns into a 400.
|
||||
pub fn estimate_prefix_tokens(system: Option<&str>, tools: &[ToolSchema]) -> u64 {
|
||||
let system = system.map(|text| text.len() as u64 / 4).unwrap_or(0);
|
||||
@@ -176,7 +176,7 @@ pub fn usable_context_window(context_window: u64, max_tokens: u32, reserve_token
|
||||
/// percent on a 200K prompt is thousands of tokens out. Mirrors Pi's margin.
|
||||
pub const CONTEXT_SAFETY_TOKENS: u32 = 4_096;
|
||||
|
||||
/// The smallest output cap Luxe will ask for once the window is full. Useless as an answer, but a
|
||||
/// The smallest output cap luxe will ask for once the window is full. Useless as an answer, but a
|
||||
/// request that asks for zero (or a negative) output is a hard rejection rather than a short reply.
|
||||
const MIN_MAX_TOKENS: u32 = 1;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! Loads `~/.config/luxe/config.json` (global) and `<repo>/.luxe/config.json`
|
||||
//! (project-local), merges them (project wins), and falls back to defaults on any
|
||||
//! parse error. Unknown fields are ignored so a newer Luxe's config keeps working
|
||||
//! parse error. Unknown fields are ignored so a newer luxe's config keeps working
|
||||
//! with an older build and vice versa.
|
||||
//!
|
||||
//! The schema is published via [`Config::schema_json`] for editor autocomplete
|
||||
@@ -31,7 +31,7 @@ pub use integrations::*;
|
||||
use merge::{merge_color_overrides, merge_disabled};
|
||||
pub use write::{value_at, ConfigLayers, ConfigWriteError, Layer};
|
||||
|
||||
/// The theme a launch lands on when nothing else decides: Luxe's own.
|
||||
/// The theme a launch lands on when nothing else decides: luxe's own.
|
||||
///
|
||||
/// A default theme is the product's face, so it is the one drawn for it rather than a neutral
|
||||
/// stand-in. An explicit setting and a matching desktop theme both still win.
|
||||
@@ -75,7 +75,7 @@ pub struct Config {
|
||||
/// use default (silent), because a modern terminal turns a bell into a window-manager attention
|
||||
/// request, which pulls focus off whatever the reader walked away to do.
|
||||
pub bell: Option<bool>,
|
||||
/// Report the agent's state to herdr when Luxe runs in one of its panes. `None` = use default
|
||||
/// Report the agent's state to herdr when luxe runs in one of its panes. `None` = use default
|
||||
/// (on).
|
||||
pub herdr: Option<bool>,
|
||||
/// Let another front-end on this machine join a running session. `None` = use default (on).
|
||||
@@ -105,9 +105,9 @@ pub struct Config {
|
||||
pub compaction: CompactionConfig,
|
||||
/// Language-server behavior
|
||||
pub lsp: LspConfig,
|
||||
/// Whether Luxe checks for a newer release
|
||||
/// Whether luxe checks for a newer release
|
||||
pub update: UpdateConfig,
|
||||
/// How Luxe keeps up with GitHub
|
||||
/// How luxe keeps up with GitHub
|
||||
pub github: GithubConfig,
|
||||
/// Whether sessions work in worktrees of their own
|
||||
pub worktree: WorktreeConfig,
|
||||
@@ -137,7 +137,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether Luxe opens on the start screen (default: yes).
|
||||
/// Whether luxe opens on the start screen (default: yes).
|
||||
pub fn dashboard_shown(&self) -> bool {
|
||||
!matches!(self.dashboard, Some(DashboardSetting::Enabled(false)))
|
||||
}
|
||||
@@ -186,7 +186,7 @@ impl Config {
|
||||
self.notifications.as_ref().is_some_and(Notifications::any)
|
||||
}
|
||||
|
||||
/// Whether the agent's state is reported to herdr when Luxe runs inside it (default: yes).
|
||||
/// Whether the agent's state is reported to herdr when luxe runs inside it (default: yes).
|
||||
pub fn herdr(&self) -> bool {
|
||||
self.herdr.unwrap_or(true)
|
||||
}
|
||||
@@ -202,7 +202,7 @@ impl Config {
|
||||
|
||||
/// Resolves the active theme name, falling back to the current desktop theme when known.
|
||||
///
|
||||
/// An explicit Luxe setting always wins. Without one, the desktop's theme is used when the
|
||||
/// An explicit luxe setting always wins. Without one, the desktop's theme is used when the
|
||||
/// registry carries one (Omarchy's, see [`crate::omarchy`]), because matching the desktop beats
|
||||
/// showing off, and anything else lands on [`DEFAULT_THEME`].
|
||||
pub fn resolved_theme_name(&self, registry: &ThemeRegistry) -> String {
|
||||
@@ -242,7 +242,7 @@ impl Config {
|
||||
resolved
|
||||
}
|
||||
|
||||
/// The JSON Schema for the config files: the checked-in `config.schema.json`, which Luxe writes
|
||||
/// The JSON Schema for the config files: the checked-in `config.schema.json`, which luxe writes
|
||||
/// beside the user's config so an editor can complete and check every key.
|
||||
pub fn schema_json() -> &'static str {
|
||||
include_str!("config/config.schema.json")
|
||||
@@ -349,7 +349,7 @@ mod activity_bar_config_tests {
|
||||
assert_eq!(config.theme.as_deref(), Some("nord"), "and the rest of the file still lands");
|
||||
}
|
||||
|
||||
/// A source's kind is the one set, or its name folded; it may not take one of Luxe's own tabs',
|
||||
/// A source's kind is the one set, or its name folded; it may not take one of luxe's own tabs',
|
||||
/// and it needs a program to run.
|
||||
#[test]
|
||||
fn a_mention_source_has_a_kind_of_its_own() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Luxe config",
|
||||
"title": "luxe config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"theme": {
|
||||
"type": "string",
|
||||
"description": "Theme name: a built-in (luxe, catppuccin, nord, tokyo-night, and more — /theme lists them all), the name of a file in themes/, or omarchy to follow the Omarchy desktop's theme. When omitted, Luxe follows Omarchy when it is running there, and uses luxe otherwise."
|
||||
"description": "Theme name: a built-in (luxe, catppuccin, nord, tokyo-night, and more — /theme lists them all), the name of a file in themes/, or omarchy to follow the Omarchy desktop's theme. When omitted, luxe follows Omarchy when it is running there, and uses luxe otherwise."
|
||||
},
|
||||
"colors": {
|
||||
"type": "object",
|
||||
@@ -54,7 +54,7 @@
|
||||
"type": "string",
|
||||
"enum": ["auto", "nerd", "nerd_wide", "unicode", "ascii"],
|
||||
"default": "auto",
|
||||
"description": "How much glyph fidelity the TUI asks for. Icons are decoration \u2014 the words beside them carry the meaning \u2014 so every setting is fully usable. nerd draws Material Design icons from a Nerd Font (the look Luxe ships with); nerd_wide draws the same icons with a second cell of clearance, for a Nerd Font's non-Mono cut, whose icons carry two cells of ink behind a one-cell advance and so paint over the space after them; unicode uses Geometric Shapes and Arrows only, so no patched font is needed; ascii reduces to plain punctuation for a minimal or non-UTF-8 terminal. auto (default) picks nerd where those glyphs can actually be drawn \u2014 kitty bundles its own symbol font, and elsewhere fontconfig is asked whether any installed font provides them \u2014 and unicode otherwise. auto never picks nerd_wide: both cuts of a face report the same advance, so there is nothing to measure."
|
||||
"description": "How much glyph fidelity the TUI asks for. Icons are decoration \u2014 the words beside them carry the meaning \u2014 so every setting is fully usable. nerd draws Material Design icons from a Nerd Font (the look luxe ships with); nerd_wide draws the same icons with a second cell of clearance, for a Nerd Font's non-Mono cut, whose icons carry two cells of ink behind a one-cell advance and so paint over the space after them; unicode uses Geometric Shapes and Arrows only, so no patched font is needed; ascii reduces to plain punctuation for a minimal or non-UTF-8 terminal. auto (default) picks nerd where those glyphs can actually be drawn \u2014 kitty bundles its own symbol font, and elsewhere fontconfig is asked whether any installed font provides them \u2014 and unicode otherwise. auto never picks nerd_wide: both cuts of a face report the same advance, so there is nothing to measure."
|
||||
},
|
||||
"images": {
|
||||
"type": "string",
|
||||
@@ -108,7 +108,7 @@
|
||||
"herdr": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "When Luxe runs in a herdr pane, report whether it is working, idle or waiting on you, so herdr's sidebar, notifications and `herdr agent wait` follow it. On by default; nothing is sent outside herdr."
|
||||
"description": "When luxe runs in a herdr pane, report whether it is working, idle or waiting on you, so herdr's sidebar, notifications and `herdr agent wait` follow it. On by default; nothing is sent outside herdr."
|
||||
},
|
||||
"joinable": {
|
||||
"type": "boolean",
|
||||
@@ -147,7 +147,7 @@
|
||||
"type": "array",
|
||||
"items": { "type": "string" },
|
||||
"default": [],
|
||||
"description": "Project-relative globs a review leaves out, e.g. [\"PROGRESS.md\", \"docs/design/**\"]. Luxe's own .luxe/ directory is always excluded and needs no entry. Supports *, ** and ?; a trailing / matches a directory and everything under it. Excluded files are counted and named in the Brief, never silently dropped."
|
||||
"description": "Project-relative globs a review leaves out, e.g. [\"PROGRESS.md\", \"docs/design/**\"]. luxe's own .luxe/ directory is always excluded and needs no entry. Supports *, ** and ?; a trailing / matches a directory and everything under it. Excluded files are counted and named in the Brief, never silently dropped."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@@ -183,7 +183,7 @@
|
||||
"remember_model": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Remember the model and thinking level picked in a session and use them next launch. Precedence: --model/--thinking flag, then LUXE_MODEL/LUXE_PROVIDER, then what you last picked, then default_model in models.json — and nothing under that, because Luxe never picks a model for you. Set false to always start from the configured default."
|
||||
"description": "Remember the model and thinking level picked in a session and use them next launch. Precedence: --model/--thinking flag, then LUXE_MODEL/LUXE_PROVIDER, then what you last picked, then default_model in models.json — and nothing under that, because luxe never picks a model for you. Set false to always start from the configured default."
|
||||
},
|
||||
"on_ask": {
|
||||
"type": "string",
|
||||
@@ -195,7 +195,7 @@
|
||||
"type": "string",
|
||||
"enum": ["off", "streaming", "idle"],
|
||||
"default": "streaming",
|
||||
"description": "When Luxe keeps a conversation's prompt cache alive through a long wait, by re-sending the last request with a one-token cap just before the cache entry expires (five minutes on Anthropic, unless supports_long_cache_retention asks for an hour). A refresh is a cache read of the prompt; the write it saves is usually ten times that. streaming (the default) does it while a turn is running — a slow tool, a permission prompt, a question — where the next request is certain. idle also does it for up to 30 minutes after a turn ends, where a reply is a guess, so a refresh is sent only on a conversation large enough to make the guess pay. off never does. Either way nothing is sent unless it is expected to save at least $0.05, never on a subscription plan, and its cost shows on /cost as cache warming. A project's config may turn this down and may not turn it up."
|
||||
"description": "When luxe keeps a conversation's prompt cache alive through a long wait, by re-sending the last request with a one-token cap just before the cache entry expires (five minutes on Anthropic, unless supports_long_cache_retention asks for an hour). A refresh is a cache read of the prompt; the write it saves is usually ten times that. streaming (the default) does it while a turn is running — a slow tool, a permission prompt, a question — where the next request is certain. idle also does it for up to 30 minutes after a turn ends, where a reply is a guess, so a refresh is sent only on a conversation large enough to make the guess pay. off never does. Either way nothing is sent unless it is expected to save at least $0.05, never on a subscription plan, and its cost shows on /cost as cache warming. A project's config may turn this down and may not turn it up."
|
||||
},
|
||||
"default_mode": {
|
||||
"type": "string",
|
||||
@@ -289,7 +289,7 @@
|
||||
},
|
||||
"launchers": {
|
||||
"type": "array",
|
||||
"description": "Programs a key hands the terminal to — gh-dash, lazygit, anything that takes over a terminal and gives it back. Luxe keeps running underneath, a turn included, and redraws when the program exits; text the program writes to the file named by $LUXE_HANDOFF lands in the composer. Read from the global config only: a key that runs a program a repository named is arbitrary execution.",
|
||||
"description": "Programs a key hands the terminal to — gh-dash, lazygit, anything that takes over a terminal and gives it back. luxe keeps running underneath, a turn included, and redraws when the program exits; text the program writes to the file named by $LUXE_HANDOFF lands in the composer. Read from the global config only: a key that runs a program a repository named is arbitrary execution.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -319,7 +319,7 @@
|
||||
},
|
||||
"github": {
|
||||
"type": "object",
|
||||
"description": "How Luxe keeps up with GitHub: the checked-out branch's pull request, and what /github lists. The refresh interval is read from the global config only — how often Luxe calls out on a timer is not a decision a repository you cloned makes; a project may add its own /github sections.",
|
||||
"description": "How luxe keeps up with GitHub: the checked-out branch's pull request, and what /github lists. The refresh interval is read from the global config only — how often luxe calls out on a timer is not a decision a repository you cloned makes; a project may add its own /github sections.",
|
||||
"properties": {
|
||||
"refresh_secs": {
|
||||
"type": "integer",
|
||||
@@ -345,12 +345,12 @@
|
||||
},
|
||||
"update": {
|
||||
"type": "object",
|
||||
"description": "Whether Luxe checks for a newer release. Read from the global config only — whether Luxe reaches the network on your behalf is not a decision a repository you cloned makes.",
|
||||
"description": "Whether luxe checks for a newer release. Read from the global config only — whether luxe reaches the network on your behalf is not a decision a repository you cloned makes.",
|
||||
"properties": {
|
||||
"check": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Look for a newer release, at most once a day, and mention it under the dashboard's footer. Luxe never updates itself; the notice names the command that matches how you installed it. The request sends nothing about you — no version, no platform, no identifier — and every failure is silent. Set false, or LUXE_UPDATE_CHECK=0, to turn it off."
|
||||
"description": "Look for a newer release, at most once a day, and mention it under the dashboard's footer. luxe never updates itself; the notice names the command that matches how you installed it. The request sends nothing about you — no version, no platform, no identifier — and every failure is silent. Set false, or LUXE_UPDATE_CHECK=0, to turn it off."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -283,7 +283,7 @@ pub enum NotificationMethod {
|
||||
/// The moments that send a desktop notification: all of them, none, or a list.
|
||||
///
|
||||
/// Read leniently, like every other key: a value that is neither a boolean nor a list is treated as
|
||||
/// unset and a name Luxe does not know is skipped, so one typo never takes the whole config with it.
|
||||
/// unset and a name luxe does not know is skipped, so one typo never takes the whole config with it.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum Notifications {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use super::{known_or, Lenient};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// How a diff is drawn, wherever Luxe draws one.
|
||||
/// How a diff is drawn, wherever luxe draws one.
|
||||
///
|
||||
/// One setting for three surfaces — the `edit`/`write` tool card, the peeked file beside the
|
||||
/// conversation, and Guided Review. They differ only in how much room they have, and
|
||||
|
||||
@@ -71,7 +71,7 @@ impl MentionSource {
|
||||
!kind.is_empty() && !self.reserved() && !self.command.trim().is_empty()
|
||||
}
|
||||
|
||||
/// Whether its kind is one Luxe's own tabs use, which leaves it without a tab of its own.
|
||||
/// Whether its kind is one luxe's own tabs use, which leaves it without a tab of its own.
|
||||
///
|
||||
/// Worth telling the reader rather than only skipping: `mcp` joined the list after sources
|
||||
/// could be named anything, so a source that worked yesterday can be the one it displaced.
|
||||
@@ -80,7 +80,7 @@ impl MentionSource {
|
||||
}
|
||||
}
|
||||
|
||||
/// The reference kinds Luxe's own `@` tabs use: `@[file:…]`, `@[skill:…]`, `@[github:…]`,
|
||||
/// The reference kinds luxe's own `@` tabs use: `@[file:…]`, `@[skill:…]`, `@[github:…]`,
|
||||
/// `@[mcp:…]`.
|
||||
pub const RESERVED_MENTION_KINDS: [&str; 4] = ["file", "skill", "github", "mcp"];
|
||||
|
||||
@@ -102,7 +102,7 @@ impl WorktreeConfig {
|
||||
|
||||
/// GitHub preferences.
|
||||
///
|
||||
/// Read from the global config only, like [`UpdateConfig`]: how often Luxe calls out on a timer is
|
||||
/// Read from the global config only, like [`UpdateConfig`]: how often luxe calls out on a timer is
|
||||
/// the reader's decision, not one a repository they cloned gets to make.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||||
#[serde(default)]
|
||||
@@ -152,7 +152,7 @@ impl GithubConfig {
|
||||
|
||||
/// Update-notice preferences.
|
||||
///
|
||||
/// Luxe never updates itself; the only question here is whether it may *notice* that it is behind.
|
||||
/// luxe never updates itself; the only question here is whether it may *notice* that it is behind.
|
||||
/// The check fetches a public manifest and sends nothing about you — see `luxe_core::update` — but
|
||||
/// it is still an outbound request, so it gets a switch like every other one.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||||
@@ -186,7 +186,7 @@ pub struct LspConfig {
|
||||
pub project_servers: Option<ProjectServers>,
|
||||
}
|
||||
|
||||
/// Whether Luxe may launch a language server out of the project's `node_modules/.bin`.
|
||||
/// Whether luxe may launch a language server out of the project's `node_modules/.bin`.
|
||||
///
|
||||
/// npm puts a dev dependency there rather than on `PATH`, so for the JavaScript servers it is
|
||||
/// routinely the only copy that matches the project — `svelteserver` has to agree with the Svelte
|
||||
@@ -223,7 +223,7 @@ pub struct ReviewConfig {
|
||||
/// `PLAN.md`/`AGENTS.md`. Each must resolve inside the opened project.
|
||||
#[serde(default)]
|
||||
pub context_files: Vec<String>,
|
||||
/// Project-relative globs a review leaves out, on top of Luxe's own `.luxe/` directory.
|
||||
/// Project-relative globs a review leaves out, on top of luxe's own `.luxe/` directory.
|
||||
///
|
||||
/// For bookkeeping a repo carries but nobody reviews — a loop's `PROGRESS.md`, a planning
|
||||
/// directory, another agent's memory. Excluded files are *counted and named*, never silently
|
||||
|
||||
@@ -259,7 +259,7 @@ impl Layered for LspConfig {
|
||||
}
|
||||
|
||||
impl Layered for UpdateConfig {
|
||||
// `global` only, same reasoning in a lower key: whether Luxe reaches the network on your
|
||||
// `global` only, same reasoning in a lower key: whether luxe reaches the network on your
|
||||
// behalf is your decision, not a decision a repository you cloned makes.
|
||||
fn layered(global: Self, project: Self) -> Self {
|
||||
let Self { check: _ } = project;
|
||||
|
||||
@@ -98,7 +98,7 @@ fn partial_config_round_trips() {
|
||||
assert_eq!(config.dock, DockConfig::default());
|
||||
}
|
||||
|
||||
/// Every leniently read setting, through its resolver: each value it knows, one from a newer Luxe,
|
||||
/// Every leniently read setting, through its resolver: each value it knows, one from a newer luxe,
|
||||
/// and none at all.
|
||||
#[test]
|
||||
fn every_lenient_setting_resolves_known_unknown_and_absent_values() {
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::*;
|
||||
#[test]
|
||||
fn schema_is_valid_json() {
|
||||
let schema: serde_json::Value = serde_json::from_str(Config::schema_json()).unwrap();
|
||||
assert_eq!(schema["title"], "Luxe config");
|
||||
assert_eq!(schema["title"], "luxe config");
|
||||
assert!(schema.get("properties").is_some());
|
||||
assert!(schema["properties"].get("$schema").is_some());
|
||||
assert!(schema["properties"].get("notifications").is_some());
|
||||
|
||||
@@ -138,7 +138,7 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Edit the global config under [`JsonFile`]'s lock. Called from the UI thread; the wait for the
|
||||
/// lock is bounded (a few seconds), and only another Luxe writing the same file at that moment, or
|
||||
/// lock is bounded (a few seconds), and only another luxe writing the same file at that moment, or
|
||||
/// one that crashed holding the lock, makes it wait at all.
|
||||
fn edit_global(edit: impl FnOnce(&mut Map<String, Value>)) -> Result<PathBuf, ConfigWriteError> {
|
||||
let path = Config::global_path();
|
||||
|
||||
@@ -27,10 +27,10 @@ use std::path::PathBuf;
|
||||
#[cfg(test)]
|
||||
const HARNESS_TOOLS: &[&str] = &["question", "todo"];
|
||||
|
||||
/// Where questions about Luxe itself are answered: its own guide, built into the binary and run
|
||||
/// Where questions about luxe itself are answered: its own guide, built into the binary and run
|
||||
/// through `bash`. Static text, so the prompt stays byte-identical between turns; without it, a
|
||||
/// model asked how to configure Luxe answers from what other harnesses do.
|
||||
const LUXE_DOCS: &str = " Questions about Luxe itself are answered by its guide: `luxe docs`.";
|
||||
/// model asked how to configure luxe answers from what other harnesses do.
|
||||
const LUXE_DOCS: &str = " Questions about luxe itself are answered by its guide: `luxe docs`.";
|
||||
|
||||
/// Purpose-built tools paired with the shell command a model reaches for instead.
|
||||
///
|
||||
@@ -239,7 +239,7 @@ impl SystemPromptBuilder {
|
||||
|
||||
format!(
|
||||
"## Tools\n\
|
||||
Every tool in Luxe is designed to beat the shell command it replaces by providing \
|
||||
Every tool in luxe is designed to beat the shell command it replaces by providing \
|
||||
structured, bounded output for a fraction of the context. They also make your actions \
|
||||
easier for the user to read, which improves clarity and efficiency. So, always reach \
|
||||
for the purpose-built tool before `bash`, which should be reserved for everything they \
|
||||
@@ -294,7 +294,7 @@ pub(crate) fn shared_len(sections: &[MeasuredSection]) -> usize {
|
||||
}
|
||||
|
||||
/// The `## Memory` section: the repository as what outlives the conversation, and where to ask
|
||||
/// about Luxe itself when the agent can run `luxe docs`.
|
||||
/// about luxe itself when the agent can run `luxe docs`.
|
||||
fn memory_section(ctx: &PromptContext) -> String {
|
||||
let docs = if ctx.tools.iter().any(|tool| tool == "bash") { LUXE_DOCS } else { "" };
|
||||
format!(
|
||||
@@ -335,7 +335,7 @@ fn plans_section() -> String {
|
||||
|
||||
/// Who the agent is, in every session and every mode.
|
||||
pub(crate) const DEFAULT_ROLE: &str =
|
||||
"You are an agentic engineering assistant operating in Luxe, a coding \
|
||||
"You are an agentic engineering assistant operating in luxe, a coding \
|
||||
agent harness. Build features incrementally with small, safe diffs, and verify them before calling \
|
||||
the work done.";
|
||||
|
||||
@@ -382,7 +382,7 @@ own conventions say otherwise:
|
||||
- Comments should say *why*, never *what*.
|
||||
- Use specific names and types: no `data`, `handler`, or `Manager`.
|
||||
- Errors should be detailed and never swallowed.
|
||||
- Luxe features specialized tools to read, write, and debug code. Use them.";
|
||||
- luxe features specialized tools to read, write, and debug code. Use them.";
|
||||
|
||||
/// What makes a test worth having.
|
||||
const TESTING: &str = "## Testing
|
||||
|
||||
@@ -26,7 +26,7 @@ fn ctx() -> PromptContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// An agent that can run commands is told where Luxe's own guide is, so a question about Luxe
|
||||
/// An agent that can run commands is told where luxe's own guide is, so a question about luxe
|
||||
/// is answered from it; one that cannot run `luxe docs` is not told about it.
|
||||
#[test]
|
||||
fn the_prompt_points_at_luxes_own_guide() {
|
||||
@@ -122,7 +122,7 @@ fn the_harness_names_no_tool_it_cannot_offer() {
|
||||
/// It is product, not taste. A model asked for something it cannot determine will reach for a
|
||||
/// plausible answer instead of admitting the gap, and a fabricated one is worse than a refusal
|
||||
/// precisely because nothing distinguishes it from a real one — so each clause here is a
|
||||
/// specific shape that failure takes, and losing any of them silently makes Luxe less
|
||||
/// specific shape that failure takes, and losing any of them silently makes luxe less
|
||||
/// trustworthy rather than merely less tidy.
|
||||
#[test]
|
||||
fn the_honesty_contract_is_always_on() {
|
||||
@@ -285,7 +285,7 @@ fn no_live_work_state_reaches_the_cached_prefix() {
|
||||
/// It is product, not taste: "write a test" is an instruction a model already follows, and
|
||||
/// following only that is what produced the hollow suites this section exists to prevent. Each
|
||||
/// clause below is one of those failure shapes, so losing any of them silently is a
|
||||
/// regression in what Luxe writes rather than in how it reads.
|
||||
/// regression in what luxe writes rather than in how it reads.
|
||||
#[test]
|
||||
fn the_testing_contract_is_always_on() {
|
||||
{
|
||||
|
||||
@@ -187,7 +187,7 @@ pub struct ContextComposition {
|
||||
pub cache_write_pct: Option<f32>,
|
||||
/// Enabled MCP servers, and the tokens their single gateway tool costs.
|
||||
///
|
||||
/// A line rather than a part: Luxe exposes every server through one gateway tool, so the
|
||||
/// A line rather than a part: luxe exposes every server through one gateway tool, so the
|
||||
/// category the rest of the field warns about is always near zero here — and a row that always
|
||||
/// reads zero teaches nothing.
|
||||
pub mcp: Option<McpFootprint>,
|
||||
|
||||
@@ -81,7 +81,7 @@ pub struct Engine {
|
||||
/// Mutable session id — updated when loading/resuming a session so the next turn chains
|
||||
/// from the resumed state, matching the `--resume` path.
|
||||
session_id: tokio::sync::Mutex<crate::session::SessionId>,
|
||||
/// This process's claim on `session_id`, which keeps a second Luxe from writing it too
|
||||
/// This process's claim on `session_id`, which keeps a second luxe from writing it too
|
||||
session_claim: std::sync::Mutex<Option<crate::session::SessionClaim>>,
|
||||
last_turn_baseline: tokio::sync::Mutex<Option<RetainedTurnBaseline>>,
|
||||
active_guided_review: Arc<tokio::sync::Mutex<ActiveGuidedReview>>,
|
||||
|
||||
@@ -120,7 +120,7 @@ fn threads_of(
|
||||
|
||||
impl Engine {
|
||||
/// Reports what in the working tree is not committed, asked fresh from git rather than read
|
||||
/// from the last snapshot, which may predate a file made outside Luxe.
|
||||
/// from the last snapshot, which may predate a file made outside luxe.
|
||||
pub(crate) fn check_worktree_removal(&self, event_tx: &mpsc::Sender<Event>) {
|
||||
let root = self.config.guided_review_project_root.clone();
|
||||
let event_tx = event_tx.clone();
|
||||
|
||||
@@ -53,7 +53,7 @@ pub struct EngineConfig {
|
||||
///
|
||||
/// `None` disables runtime review loading for embedding and test callers.
|
||||
pub guided_review_project_root: Option<std::path::PathBuf>,
|
||||
/// The directory Luxe was launched in, when that is not the project root.
|
||||
/// The directory luxe was launched in, when that is not the project root.
|
||||
///
|
||||
/// The one thing the *shell's* directory still answers after [`crate::project::discover`] has
|
||||
/// moved the process to the top of the working copy: which instruction files apply. A monorepo
|
||||
@@ -72,9 +72,13 @@ pub struct EngineConfig {
|
||||
pub review_context_files: Vec<String>,
|
||||
/// Project-relative globs a review leaves out (`review.exclude`), on top of `.luxe/`.
|
||||
pub review_exclude: Vec<String>,
|
||||
/// Whether an in-session model/thinking choice is remembered for the next launch
|
||||
/// (`agent.remember_model`). Off for embedders and tests, which should leave no trace.
|
||||
pub remember_runtime_state: bool,
|
||||
/// The project an in-session model or thinking choice is remembered for, for the next launch
|
||||
/// (`agent.remember_model`).
|
||||
///
|
||||
/// A model is kept for this project and as the latest anywhere, so the next launch here starts
|
||||
/// on it and a project never opened before starts on it too. `None` for embedders and tests,
|
||||
/// which should leave no trace.
|
||||
pub remember_choices_in: Option<std::path::PathBuf>,
|
||||
/// When the prompt cache is kept warm through a long wait (`agent.cache_warming`).
|
||||
///
|
||||
/// Only matters for a provider whose `prompt_cache_ttl` answers, so an embedder's or a test's
|
||||
|
||||
@@ -223,7 +223,7 @@ impl Engine {
|
||||
/// or stopping. What it should do is hand the command to the person.
|
||||
pub(super) fn deny_message(request: &crate::permission::PermissionRequest) -> String {
|
||||
if crate::permission::defaults::runs_as_root(request) {
|
||||
return "Blocked: Luxe does not run commands as root. A command that needs root needs the \
|
||||
return "Blocked: luxe does not run commands as root. A command that needs root needs the \
|
||||
user's attention and consent, so they run it: give them the exact command in a \
|
||||
fenced code block, ask them to run it in their own terminal, and continue once \
|
||||
they say it is done. Do not look for another way to run it here."
|
||||
|
||||
@@ -4,7 +4,7 @@ use super::*;
|
||||
|
||||
impl Engine {
|
||||
/// Nudge toward the `debug` tool when tests keep failing — runtime reinforcement for models
|
||||
/// that default to print-and-retry (the debugger is a Luxe differentiator, but under-used).
|
||||
/// that default to print-and-retry (the debugger is a luxe differentiator, but under-used).
|
||||
/// Fires once per failing streak (≥3 consecutive failing test runs); a passing test resets it.
|
||||
/// Disable with `LUXE_DEBUG_NUDGE=0`.
|
||||
pub(super) async fn maybe_nudge_debugger(&self, is_test: bool, result: &mut ToolResultData) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! A draft is an ordinary turn in this session, so it is written by the agent that did the work,
|
||||
//! with the transcript it already holds in the prompt cache. What the turn adds is appended once,
|
||||
//! as one message, never in the system prompt: the thing being answered in full, Luxe's own evidence
|
||||
//! as one message, never in the system prompt: the thing being answered in full, luxe's own evidence
|
||||
//! about it — the code at the line now, the commits since, the review comment it became and whether
|
||||
//! the fix was verified — and the rest of the conversation as a digest, sent whole the first time
|
||||
//! and only what is new after, until compaction or a session load forgets what was sent.
|
||||
|
||||
@@ -155,7 +155,7 @@ async fn a_thread_brief_carries_the_code_now_and_the_commits_since() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
git(root, &["init", "--quiet", "-b", "main"]);
|
||||
git(root, &["config", "user.name", "Luxe Tests"]);
|
||||
git(root, &["config", "user.name", "luxe Tests"]);
|
||||
git(root, &["config", "user.email", "tests@luxe.local"]);
|
||||
let lines: Vec<String> = (1..=20).map(|n| format!("line {n}")).collect();
|
||||
std::fs::write(root.join("router.rs"), lines.join("\n")).unwrap();
|
||||
|
||||
@@ -22,7 +22,7 @@ pub enum EngineError {
|
||||
///
|
||||
/// The gate, rather than the courtesy: a front-end should ask before it submits, and this is
|
||||
/// what holds when one does not. See [`crate::provider::ModelRef::is_unset`].
|
||||
#[error("no model selected — pick one with /model, or start Luxe with --model <provider/id>")]
|
||||
#[error("no model selected — pick one with /model, or start luxe with --model <provider/id>")]
|
||||
NoModel,
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ mod tests {
|
||||
let session = SessionError::Other("gone".into());
|
||||
let session_said = format!("session error: {session}");
|
||||
let no_model =
|
||||
"no model selected — pick one with /model, or start Luxe with --model <provider/id>";
|
||||
"no model selected — pick one with /model, or start luxe with --model <provider/id>";
|
||||
let cases: [(EngineError, String, bool); 5] = [
|
||||
(provider.into(), provider_said, false),
|
||||
(session.into(), session_said, false),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! repository and number asked about, so a reply that lands after the reader moved on is matched
|
||||
//! to nothing rather than drawn over the wrong row.
|
||||
//!
|
||||
//! An issue's answer also says whether one of your sessions took it up — Luxe's own knowledge, read
|
||||
//! An issue's answer also says whether one of your sessions took it up — luxe's own knowledge, read
|
||||
//! from the session store, which GitHub has no way to know.
|
||||
|
||||
use super::posting::sentence;
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
/// What this engine leaves out of a review: Luxe's own directory, plus `review.exclude`.
|
||||
/// What this engine leaves out of a review: luxe's own directory, plus `review.exclude`.
|
||||
pub(crate) fn review_exclusions(&self) -> crate::guided_review::ReviewExclusions {
|
||||
crate::guided_review::ReviewExclusions::new(&self.config.review_exclude)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub(super) fn pull_request_failure(error: &PullRequestResolveError) -> GuidedRev
|
||||
GuidedReviewFailure::unavailable(format!("Could not run `gh`: {source}."))
|
||||
}
|
||||
GitHubError::Unreadable(_) => GuidedReviewFailure::unavailable(
|
||||
"`gh` answered with something Luxe could not read. Updating the GitHub CLI may fix it.",
|
||||
"`gh` answered with something luxe could not read. Updating the GitHub CLI may fix it.",
|
||||
),
|
||||
GitHubError::RateLimited => GuidedReviewFailure::unavailable(
|
||||
"GitHub's rate limit for this account is spent. It refills within the hour.",
|
||||
|
||||
@@ -190,7 +190,7 @@ impl Engine {
|
||||
.read()
|
||||
.map_err(|_| SessionError::Other("session store lock poisoned".to_string()))?;
|
||||
let entries = store.load(&id)?;
|
||||
// Before anything changes, so a session open in another Luxe leaves this one as it was
|
||||
// Before anything changes, so a session open in another luxe leaves this one as it was
|
||||
let claim = store.claim(&id)?;
|
||||
let leaf = crate::session::latest_leaf(&entries);
|
||||
let active = match leaf.as_ref() {
|
||||
|
||||
@@ -74,7 +74,7 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
/// The nested files `call` reached, from Luxe launched at `launch`.
|
||||
/// The nested files `call` reached, from luxe launched at `launch`.
|
||||
///
|
||||
/// Relative paths resolve the way the tool resolved them, against where tools run.
|
||||
fn reached(launch: &std::path::Path, call: &ToolCallInfo) -> Vec<NestedFile> {
|
||||
|
||||
@@ -267,7 +267,7 @@ pub(super) fn sentence(error: &GitHubError) -> String {
|
||||
}
|
||||
GitHubError::Run { source, .. } => format!("Could not run `gh`: {source}."),
|
||||
GitHubError::Unreadable(_) => {
|
||||
"`gh` answered with something Luxe could not read. Updating the GitHub CLI may fix it."
|
||||
"`gh` answered with something luxe could not read. Updating the GitHub CLI may fix it."
|
||||
.into()
|
||||
}
|
||||
GitHubError::RateLimited => {
|
||||
|
||||
@@ -12,7 +12,7 @@ impl Engine {
|
||||
pub(super) async fn assemble_prompt(
|
||||
&self,
|
||||
) -> Result<(Vec<MeasuredSection>, Option<String>), EngineError> {
|
||||
// Two directories, and they differ whenever Luxe is launched below the project root: the
|
||||
// Two directories, and they differ whenever luxe is launched below the project root: the
|
||||
// one the launch named, which only decides which `AGENTS.md` files apply, and the one every
|
||||
// tool actually runs in. The prompt reports the second as `cwd`: a session opened in
|
||||
// `packages/app` must not be told it is there while `pwd` answers with the root, and a
|
||||
@@ -147,7 +147,7 @@ fn build_deferred_tools_section(catalog: &[(String, String)]) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
/// Hand-written catalog lines for Luxe's own deferred tools, shorter than anything
|
||||
/// Hand-written catalog lines for luxe's own deferred tools, shorter than anything
|
||||
/// [`catalog_line`] can cut from a description. A tool not listed here, an MCP server's or a newer
|
||||
/// one, gets the generated line.
|
||||
const CATALOG_SUMMARIES: &[(&str, &str)] = &[
|
||||
|
||||
@@ -69,7 +69,7 @@ impl ReviewDesk {
|
||||
}
|
||||
if interrupted > 0 {
|
||||
effects.push(Effect::Event(Event::Notice(
|
||||
"A review feedback turn was cut off when Luxe last stopped. It can be sent again \
|
||||
"A review feedback turn was cut off when luxe last stopped. It can be sent again \
|
||||
from the review."
|
||||
.into(),
|
||||
)));
|
||||
|
||||
@@ -126,13 +126,13 @@ impl ReviewDesk {
|
||||
"Review comments cannot be saved without a project.".to_string()
|
||||
}
|
||||
SaveError::Store(ReviewSessionStoreError::RevisionConflict { .. }) => {
|
||||
// Another Luxe on this project wrote first. Holding on to the older revision would
|
||||
// Another luxe on this project wrote first. Holding on to the older revision would
|
||||
// refuse every later change too, so take theirs and say so.
|
||||
if let Some(stored) = self.load(&review_id).await {
|
||||
self.session = Some(stored);
|
||||
self.persisted = true;
|
||||
}
|
||||
"Another Luxe changed this review's comments at the same time, so this change was \
|
||||
"Another luxe changed this review's comments at the same time, so this change was \
|
||||
not saved. The review shows theirs now; make the change again."
|
||||
.to_string()
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user