# spaceinventor/slash architecture

> Architecture diagram of the GitHub repository spaceinventor/slash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spaceinventor/slash
- Repository: https://github.com/spaceinventor/slash

## Overview

Slash is a C command-line shell library: it reads and edits interactive input, resolves commands, and runs registered handlers. Its capabilities include built-in commands, scripts via `run`, command and path completion, option parsing, and extension commands supplied by dynamically loaded APMs. The excerpts show key calls among these components; APM section registration and command-list behavior are documented in the README. Other links are omitted where the sampled source does not establish them.

Main entry points: [`src/slash.c`](https://github.com/spaceinventor/slash/blob/missions/src/slash.c) (Shell runtime), [`src/builtins.c`](https://github.com/spaceinventor/slash/blob/missions/src/builtins.c) (Built-in commands), [`src/run.c`](https://github.com/spaceinventor/slash/blob/missions/src/run.c) (Script runner), [`src/slash_list.c`](https://github.com/spaceinventor/slash/blob/missions/src/slash_list.c) (Command registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Interactive Shell"]
  node_shell["Shell runtime<br/>[slash.c]"]
  node_line_edit["Line editing<br/>[slash.c]"]
  node_history["Command history<br/>[slash.c]"]
  node_io["Input and output<br/>[slash.c]"]
end

subgraph group_commands["Commands"]
  node_builtin_handlers["Built-in commands<br/>[builtins.c]"]
  node_script_runner["Script runner<br/>[run.c]"]
  node_builtin_declarations["Builtin declarations<br/>[builtins.h]"]
end

subgraph group_extensions["Extensions"]
  node_command_registry["Command registry<br/>[slash_list.c]"]
  node_apm["APM extension"]
  node_command_api["Command API<br/>[slash.h]"]
end

subgraph group_parsing["Parsing Utilities"]
  node_arg_builder["Argument builder<br/>[slash.c]"]
  node_option_parser["Option parser<br/>[optparse.c]"]
  node_default_options["Default options API<br/>[dflopt.h]"]
end

subgraph group_completion["Completion"]
  node_completion_engine["Completion engine<br/>[completer.c]"]
  node_completion_api["Completion API<br/>[completer.h]"]
end

node_user(("Shell user"))

node_user -->|"enters commands"| node_shell
node_shell -->|"builds arguments"| node_arg_builder
node_shell -.->|"finds commands"| node_command_registry
node_shell -->|"reads and writes"| node_io
node_shell -.->|"edits input"| node_line_edit
node_line_edit -->|"updates history"| node_history
node_shell -.->|"dispatches commands"| node_builtin_handlers
node_builtin_handlers -->|"parses options"| node_option_parser
node_builtin_handlers -->|"repeats command"| node_shell
node_builtin_handlers -->|"uses completers"| node_completion_engine
node_shell -.->|"dispatches run"| node_script_runner
node_script_runner -->|"parses options"| node_option_parser
node_script_runner -->|"executes script lines"| node_shell
node_apm -.->|"registers commands"| node_command_registry
node_command_registry -.->|"provides commands"| node_shell
node_completion_engine -->|"uses command data"| node_command_api
node_completion_api -->|"declares API for"| node_completion_engine

click node_shell "https://github.com/spaceinventor/slash/blob/missions/src/slash.c"
click node_line_edit "https://github.com/spaceinventor/slash/blob/missions/src/slash.c"
click node_history "https://github.com/spaceinventor/slash/blob/missions/src/slash.c"
click node_io "https://github.com/spaceinventor/slash/blob/missions/src/slash.c"
click node_builtin_handlers "https://github.com/spaceinventor/slash/blob/missions/src/builtins.c"
click node_script_runner "https://github.com/spaceinventor/slash/blob/missions/src/run.c"
click node_command_registry "https://github.com/spaceinventor/slash/blob/missions/src/slash_list.c"
click node_command_api "https://github.com/spaceinventor/slash/blob/missions/include/slash/slash.h"
click node_arg_builder "https://github.com/spaceinventor/slash/blob/missions/src/slash.c"
click node_option_parser "https://github.com/spaceinventor/slash/blob/missions/src/optparse.c"
click node_completion_engine "https://github.com/spaceinventor/slash/blob/missions/src/completer.c"
click node_completion_api "https://github.com/spaceinventor/slash/blob/missions/include/slash/completer.h"
click node_builtin_declarations "https://github.com/spaceinventor/slash/blob/missions/src/builtins.h"
click node_default_options "https://github.com/spaceinventor/slash/blob/missions/include/slash/dflopt.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shell,node_line_edit,node_history,node_io,node_user toneBlue
class node_builtin_handlers,node_script_runner,node_builtin_declarations toneAmber
class node_command_registry,node_apm,node_command_api toneMint
class node_arg_builder,node_option_parser,node_default_options toneRose
class node_completion_engine,node_completion_api toneIndigo
```

## Components

### Interactive Shell

- [Shell runtime](https://github.com/spaceinventor/slash/blob/missions/src/slash.c): `src/slash.c`
- [Line editing](https://github.com/spaceinventor/slash/blob/missions/src/slash.c): `src/slash.c`
- [Command history](https://github.com/spaceinventor/slash/blob/missions/src/slash.c): `src/slash.c`
- [Input and output](https://github.com/spaceinventor/slash/blob/missions/src/slash.c): `src/slash.c`

### Commands

- [Built-in commands](https://github.com/spaceinventor/slash/blob/missions/src/builtins.c): `src/builtins.c`
- [Script runner](https://github.com/spaceinventor/slash/blob/missions/src/run.c): `src/run.c`
- [Builtin declarations](https://github.com/spaceinventor/slash/blob/missions/src/builtins.h): `src/builtins.h`

### Extensions

- [Command registry](https://github.com/spaceinventor/slash/blob/missions/src/slash_list.c): `src/slash_list.c`
- **APM extension**
- [Command API](https://github.com/spaceinventor/slash/blob/missions/include/slash/slash.h): `include/slash/slash.h`

### Parsing Utilities

- [Argument builder](https://github.com/spaceinventor/slash/blob/missions/src/slash.c): `src/slash.c`
- [Option parser](https://github.com/spaceinventor/slash/blob/missions/src/optparse.c): `src/optparse.c`
- [Default options API](https://github.com/spaceinventor/slash/blob/missions/include/slash/dflopt.h): `include/slash/dflopt.h`

### Completion

- [Completion engine](https://github.com/spaceinventor/slash/blob/missions/src/completer.c): `src/completer.c`
- [Completion API](https://github.com/spaceinventor/slash/blob/missions/include/slash/completer.h): `include/slash/completer.h`

### Other components

- **Shell user**

## Connections

- Shell user → Shell runtime: enters commands (evidence: `src/slash.c`)
- Shell runtime → Argument builder: builds arguments (evidence: `src/slash.c`)
- Shell runtime → Command registry: finds commands
- Shell runtime → Input and output: reads and writes (evidence: `src/slash.c`)
- Shell runtime → Line editing: edits input (evidence: `src/slash.c`)
- Line editing → Command history: updates history (evidence: `src/slash.c`)
- Shell runtime → Built-in commands: dispatches commands
- Built-in commands → Option parser: parses options (evidence: `src/builtins.c`)
- Built-in commands → Shell runtime: repeats command (evidence: `src/builtins.c`)
- Built-in commands → Completion engine: uses completers (evidence: `src/builtins.c`)
- Shell runtime → Script runner: dispatches run
- Script runner → Option parser: parses options (evidence: `src/run.c`)
- Script runner → Shell runtime: executes script lines (evidence: `src/run.c`)
- APM extension → Command registry: registers commands (evidence: `README.md`)
- Command registry → Shell runtime: provides commands (evidence: `README.md`)
- Completion engine → Command API: uses command data (evidence: `src/completer.c`)
- Completion API → Completion engine: declares API for (evidence: `include/slash/completer.h`)
