Skip to content
Buchi-dev-dznPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

A-Shell

A-Shell is an AI-native shell frontend written in Rust. It keeps the familiar shell workflow while adding configurable AI CLI backends, structured execution history, task sessions, policy checks, and an interactive history picker.

A-Shell is an early prototype. Review the generated task plan and the permissions requested by an AI CLI before allowing changes to your workspace.

Highlights

  • Run ordinary commands through the user's $SHELL.
  • Use ? for read-oriented questions and @ for agent tasks.
  • Configure Codex, Claude Code, Gemini CLI, Ollama, or another executable through Lua.
  • Stream text or JSONL agent output, including background jobs.
  • Keep and resume Codex task sessions.
  • Store command output and metadata in a per-workspace SQLite database.
  • Search history with Ctrl-R: type to filter, use j/k or arrow keys to move, and press Enter to insert without executing.
  • Get dim inline predictions from history, built-ins, Lua commands, and $PATH executables; press Tab to accept one, or use the arrow keys to cycle matching history predictions.
  • Complete paths for cd and ls: press Tab on an empty argument to list the current directory, or continue typing a path to narrow candidates.
  • Customize colors, Nerd Font file icons, and the prompt with Lua.
  • Apply explicit allow/ask/deny policies to read, write, execute, and network capabilities.

Requirements

  • Rust stable and Cargo
  • A POSIX-compatible shell
  • Optional AI CLI tools, authenticated and available on PATH

Supported AI CLIs are external programs. A-Shell does not bundle them or their model access.

Install and update

If this repository is public, install directly with one command (Rust/Cargo and Git are required):

curl -fsSL https://raw.githubusercontent.com/Buchi-dev-dzn/a-shell/main/install.sh | sh

The installer downloads the latest main source, builds a release binary, and places a-shell in Cargo's binary directory. Run the same command again to update it. Set A_SHELL_REF to install another branch or tag.

From a source checkout, use the same installer locally:

./install.sh

The script runs cargo install --locked --force. After installation, start A-Shell from any directory:

a-shell

The equivalent direct Cargo command is:

cargo install --git https://github.com/Buchi-dev-dzn/a-shell.git --locked --force

Build and run

cargo run

The first run creates a user configuration unless a workspace configuration already exists. Build a release binary with:

cargo build --release

Run the test suite with:

cargo test

Command reference

Input Behavior
git status Execute through $SHELL and save a structured record
? why did this fail? Ask the configured question backend with workspace context
@ inspect the failing test Create and run a read-oriented task
@ fix the tests Create a write-aware plan and request confirmation
@ investigate memory leak & Start a background task
jobs, fg %1, kill %1 Inspect and manage background jobs
Ctrl-R Open the live history filter; Enter inserts the selected command
Tab Accept the inline prediction, or open completion when no prediction exists
↑ / ↓ Cycle matching history predictions
:history Show recent execution records
:permissions Show capability policy
:allow write, :ask network, :deny execute Change runtime policy
:llm Show active AI CLI profiles
:config Show the active config file path and precedence
:session Inspect the active task session and persisted resume ID
:resume [N or ID] Choose a saved task session and make it active
:new, :new-session Clear the active task session
:commands Show Lua-defined custom commands
:reload-config Reload config.lua
:checkpoint, :restore <id> Create or apply a Git stash checkpoint

Configuration

Configuration is Lua and must return one table. The runtime accepts strings, arrays, tables, and a restricted set of scalar values; custom commands are shell commands and should be treated as executable code.

Configuration precedence is:

  1. --config <PATH>
  2. A_SHELL_CONFIG
  3. Workspace .a-shell/config.lua (or a legacy .a-shell/config.toml waiting for migration)
  4. $XDG_CONFIG_HOME/a-shell/config.lua
  5. $HOME/.config/a-shell/config.lua
  6. macOS: $HOME/Library/Application Support/a-shell/config.lua

The first available user-level location is created automatically. Workspace history remains in .a-shell/history.sqlite3, independent of the user-level config.

Task session metadata is stored in the workspace history database. After restarting A-Shell, run another @ task and answer y when asked to continue the saved session. Use :new to force a new session.

:resume opens a live session picker: type to filter, use j/k or arrow keys to move, and press Enter to activate the selected conversation.

Useful commands:

a-shell --help
a-shell --version
a-shell --config /path/to/config.lua
return {
  llm = {
    provider = "codex",
    question = {
      command = "codex",
      model = "gpt-5.6-luna",
      reasoning_effort = "medium",
      args = { "exec", "--sandbox", "read-only", "--skip-git-repo-check" },
      stream = "text",
    },
    task = {
      command = "codex",
      model = "gpt-5.6-luna",
      reasoning_effort = "medium",
      args = { "exec", "--json", "--sandbox", "workspace-write", "--skip-git-repo-check" },
      stream = "jsonl",
    },
  },
  permissions = {
    filesystem_read = "allow",
    filesystem_write = "ask",
    process_execute = "allow",
    network_access = "ask",
  },
  task = {
    confirm_execution = true,
    session_mode = "ask", -- new | ask | continue
    resume_args = { "exec", "resume", "--json", "--skip-git-repo-check" },
  },
  ui = {
    nerd_font = false,
    colors = {
      accent = "#A78BFA",
      info = "#22D3EE",
      success = "#34D399",
      warning = "#FBBF24",
      danger = "#FB7185",
      muted = "#94A3B8",
    },
    prompt = function(ctx)
      local branch = ctx.git_branch and (" [" .. ctx.git_branch .. "]") or ""
      return ctx.dir .. branch .. " " .. ctx.symbol .. " "
    end,
  },
  commands = {
    test = { command = "cargo test", description = "Run the test suite" },
    status = "git status --short",
  },
}

Prompt functions receive ctx.cwd/ctx.path (absolute path), ctx.home, ctx.relative (for example ~/Documents/project), ctx.dir, ctx.project, ctx.git_branch, ctx.user, ctx.host, and ctx.symbol. For example, to show the current path instead of only its final directory name:

prompt = function(ctx)
  return ctx.cwd .. " " .. ctx.symbol .. " "
end

Because the prompt is a Lua function, you can compose these fields and conditionally show branches, users, hosts, or path segments without changing the Rust binary.

Model and reasoning settings

model adds --model <value> before the configured arguments. reasoning_effort is converted to Codex's -c model_reasoning_effort=<value> setting. Supported values are none, low, medium, high, xhigh, and max.

For a CLI with a different model syntax, put the provider-specific flags in args. For example, Ollama uses a positional model name:

{
  command = "ollama",
  args = { "run", "qwen3:8b" },
  stream = "text",
}

Examples for other CLIs:

-- Claude Code
{ command = "claude", model = "claude-sonnet-4-6", args = { "-p" }, stream = "text" }

-- Gemini CLI
{ command = "gemini", model = "gemini-2.5-flash", args = { "--prompt" }, stream = "text" }

jsonl is intended for a backend that emits the event format A-Shell understands. Use text for ordinary CLI output.

Prompt customization

ui.prompt may be a template string or a Lua function. A function receives cwd, path, dir, project, git_branch, user, host, and symbol. Its return value becomes the prompt text.

For a simple prompt, use a template such as "{dir} {symbol} ". Template fields are replaced automatically; {git_branch} is empty outside a Git branch.

Shell compatibility

Ordinary commands use $SHELL. For zsh, A-Shell runs zsh -lic with job-control monitoring disabled so aliases, functions, and PATH entries from .zshrc remain available without the child stealing the terminal and stopping A-Shell with SIGTTOU. Common read-only commands (ls, pwd, whoami, and date) bypass shell startup for low-latency execution; shell syntax and aliases still use $SHELL. A-Shell's cd command is handled internally so directory changes persist between commands.

Interactive invocations of Codex, Claude, Gemini CLI, and ollama run are attached directly to the terminal. Non-interactive forms such as codex exec remain captured in the execution history.

Terminal editors and TUIs (nvim, Vim, Helix, hx, Emacs, less, yazi, lazygit, and similar tools) are also attached directly, so their full-screen UI works normally. To make an editor command discoverable, define it in Lua, for example edit = { command = "nvim", description = "Open a file" }; edit README.md inserts the argument and launches the editor.

When no edit custom command is configured, edit [file] opens A-Shell's built-in minimal editor. aedit [file] always selects the built-in editor, even when edit is overridden. It uses an alternate screen, line numbers, Unicode-safe character editing, and a deliberately small keymap: arrows/Home/End/PageUp/PageDown, Enter, Backspace/Delete, Ctrl-S to save, and Ctrl-Q to quit. Unsaved changes require a second Ctrl-Q to discard. A file path is required for saving a new buffer.

When A-Shell is configured as the terminal's shell, it automatically falls back to /bin/zsh (macOS) or /bin/sh for ordinary commands if SHELL points back to A-Shell. Override this with A_SHELL_HOST_SHELL or A_SHELL_FALLBACK_SHELL.

Source layout

The binary is intentionally split by responsibility:

  • main.rs: application loop, command routing, and orchestration
  • config.rs: Lua configuration, profiles, permissions, and prompt rendering
  • agent.rs: provider execution, streaming, and JSONL event decoding
  • shell.rs: host-shell execution, terminal CLIs, fast commands, and ls rendering
  • history_ui.rs: history/resume interactive selectors
  • storage.rs: SQLite persistence
  • ui.rs: theme and terminal presentation
  • editor.rs: built-in lightweight text editor

Data and security

Workspace-local state is stored in .a-shell/:

  • config.lua: user configuration
  • history.sqlite3: command, output, exit status, timing, and working-directory records

Question prompts include a bounded workspace snapshot. Task backends receive the current workspace path and task prompt. External CLIs may have their own network, sandbox, authentication, and data-retention behavior; configure those flags explicitly and review their documentation.

Third-party software

Direct Rust dependency versions, authors, licenses, repositories, and important bundled components are documented in THIRD-PARTY-NOTICES.md. Cargo.lock records the complete resolved dependency graph, including transitive packages.

Project license

The project license has not yet been selected. Until a project license is added, do not assume that the A-Shell source code is available under an open-source license. The third-party licenses listed in THIRD-PARTY-NOTICES.md remain applicable to their respective packages.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages