Catalog · How the catalog works
SweetConsole
1-shot Delphi CLI apps with this AI agent for Delphi.
- ★ 1 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
SweetConsole
Build native Object Pascal command-line apps from a sentence.
Describe the CLI you want in plain English — SweetConsole drives an AI coding agent to write the Delphi / FreePascal project, compile-test it, and hand you a working binary. Keep iterating with follow-up instructions, or open the whole thing in a desktop studio and watch your app run as it's built.
What it is
SweetConsole is a small Object Pascal tool that turns natural-language requests into real, compiling CLI programs. You point it at any OpenAI-compatible chat-completions endpoint (it's tested with PasClaw, a native Pascal AI agent), give it a description, and it:
- Scaffolds the project —
.dpr,.dproj, source units,README.md,.gitignore. - Compiles it, reads the errors, fixes them, and recompiles until the build is clean.
- Writes a
CLAUDE.mddesign memo so the next iteration picks up where it left off.
Think Lovable for the terminal — but the output is native Object Pascal, the same language SweetConsole itself is written in, buildable with fpc -Mdelphi everywhere and openable in modern Delphi.
$ sweetconsole new tasker -d "track tasks with priorities and due dates"
?????? sweetconsole ?? tasker ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? language: Delphi (FireDAC for SQLite) ???
??? root: /home/you/tasker ???
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? working???
Created tasker.dpr, src/App.pas, src/Database.pas, src/Tasks.pas,
README.md, .gitignore. Compiled cleanly with
`fpc -Mdelphi -O2 tasker.dpr`. Try: ./tasker add "ship it" --priority high
?????? project snapshot ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? 6 file(s) in /home/you/tasker (delta +6) ???
??? tasker.dpr ???
??? src/App.pas ???
??? src/Database.pas ???
??? src/Tasks.pas ???
??? README.md ???
??? .gitignore ???
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????The agent does the file I/O and the compile loop itself through the endpoint's tool calls. SweetConsole sets up the working directory, streams the reply, snapshots the result, and validates the output for cross-compiler pitfalls.
Why SweetConsole
- Native target, native tool. SweetConsole both is and generates Object Pascal — one language, one toolchain. Generated code compiles with
fpc -Mdelphion Linux / macOS / Windows and the same source opens in Delphi. - Bring your own agent. Any endpoint speaking the OpenAI
/v1/chat/completionsprotocol works. Run PasClaw locally and your prompts, code, and data never leave your machine — or point at a hosted provider if you prefer. - It actually compiles. The agent isn't done until
fpc(ordcc32/msbuild) exits clean. No "here's some code that might work." - Persistent memory. Each project carries a
CLAUDE.mdcapturing the build command, layout, design decisions, and a change log — soiterateruns stay consistent across sessions. - Offline fallback.
--offlinescaffolds from a built-in Delphi + SQLite template with no agent call at all. - Pluggable language. Delphi is wired up today; the language registry (
SweetConsole.Languages) is built so other targets can be added without touching the pipeline.
SweetConsole Studio
For a graphical experience, SweetConsole Studio (studio/) is a FireMonkey desktop app — think Lovable, but native. Chat on the left, your compiled program running live on the right.
?????? SweetConsoleStudio ?? tasker ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? ??? Back ??? args [ -h ] [Run] ???
??? ????????? chat ????????? ??? ???????????????????????????????????????????????????????????????????????????????????? ???
??? ??? you add a --json flag ??? tasker 1.0.0 ???
??? ??? agent applied. recompiling??? ??? Usage: tasker <command> ... ???
??? ??? built tasker.exe ??? add <text> ???
??? [ type a change??? ] [ Send ] ??? list [--json] ???
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????- Chat-driven build & iterate — the same
new/iterateflow as the CLI, in a bubble-chat UI with per-project history. - Embedded live console — the just-built binary runs inside the right pane. Output is captured through pipes and rendered by a custom control with full ANSI color (16-color, 256-color, and 24-bit truecolor), text selection,
Ctrl+Ccopy, and find/highlight (Ctrl+F). - Run it your way — launch with
-h,--version, custom args, or plain; feed it stdin;Ctrl+Cor Stop to interrupt. - Bring-your-own gateway — a Settings dialog points the Studio at the same OpenAI-compatible endpoint the CLI uses.
Studio is a Windows / Delphi FireMonkey project (studio/SweetConsoleStudio.dproj). See studio/README.md for build steps and architecture.
Requirements
| Compiler | FreePascal 3.2+ (apt install fpc · brew install fpc · freepascal.org) or Delphi 11+. |
| AI gateway | Any OpenAI-compatible /v1/chat/completions endpoint with tool-use support. PasClaw is the reference — a native Pascal agent you run locally. It must run on the same machine as your project directory (it writes the files itself) with fpc on its PATH so it can compile-test. |
| SQLite | libsqlite3 on PATH for generated apps that use persistence. Present on most Linux / macOS systems; ship sqlite3.dll alongside the .exe on Windows. |
Not using persistence? SQLite is only needed by generated apps that actually store state — SweetConsole itself doesn't require it.
Install
Build the single static binary from source:
fpc -Mdelphi -O2 -Fusrc -o./sweetconsole SweetConsole.dprNo external Pascal packages required — only RTL units that ship with FreePascal (fpjson, fphttpclient, opensslsockets). Drop the resulting sweetconsole binary anywhere on your PATH.
Quick start
Point SweetConsole at your gateway (PasClaw's default is port 8088), then create a project:
# One-time: tell SweetConsole where the gateway lives
sweetconsole config --agent-url http://127.0.0.1:8088/v1/chat/completions
# Create a new project from a description
sweetconsole new tasker -d "track tasks with priorities and due dates"
# Iterate — add features, fix bugs, change behaviour
sweetconsole iterate tasker -d "add a --json flag to the list command"
# Build the project (auto-detects msbuild for .dproj, fpc for .dpr)
sweetconsole build tasker
# No gateway? Scaffold from the built-in template
sweetconsole new notes --offlineNote — the endpoint accepts any OpenAI-compatible URL, local or hosted. The older
--nanobot-urlflag,SWEETCONSOLE_NANOBOT_URLenv var, andnanobot_urlconfig key are still honoured as aliases, so existing setups keep working.
Commands
| Command | What it does |
|---|---|
new <name> -d "<desc>" |
Scaffold a new project from a description, compile-test until clean. |
iterate <name> -d "<change>" |
Apply a change to an existing project, recompile to confirm. |
chat [<name>] |
Interactive REPL — apply changes one turn at a time. |
build <name> [--tool msbuild|fpc] [--config Release|Debug] |
Compile a generated project. Detects .dproj → msbuild, .dpr → fpc. |
config [--agent-url <url>] [--model <name>] [--language <id>] |
Print or update saved configuration. |
version |
Print version. |
Common flags: -d/--description, -l/--language, -a/--agent-url, -m/--model, -y/--yes, -v/--verbose, --offline. Run sweetconsole --help for the full list.
What gets generated
The agent produces projects in a consistent shape:
<name>/
<name>.dpr # program entry point
<name>.dproj # Delphi MSBuild project (for the IDE)
src/
<name>.App.pas # TApp: argv dispatch
<name>.CLI.pas # argument parsing + --help / --version
<name>.Database.pas # TDatabase: SQLite open / migrate / exec / query (only if persistence is needed)
<name>.<Feature>.pas # one unit per domain concept
README.md # build + usage instructions
CLAUDE.md # persistent design memo for future iterations
.gitignoreThe agent runs the compiler from the project root and won't report success until the build is clean — if it fails, it edits the offending file and recompiles. The system prompt in src/SweetConsole.Prompts.pas pins the layout, the SQLite conventions, and the cross-compiler style rules; SweetConsole.Validator double-checks the output for FreePascal-only constructs that would break under Delphi (and vice-versa).
The exact files vary with the description, but the layout, build command, and conventions stay consistent.
Configuration
SweetConsole resolves settings in priority order:
- Command-line flags —
-a,-m,-l,-y,-v,--offline - Environment —
SWEETCONSOLE_AGENT_URL,SWEETCONSOLE_AGENT_MODEL,SWEETCONSOLE_LANGUAGE - Project-local —
./sweetconsole.config.json(keys:agent_url,agent_model,default_language) - User-global —
~/.sweetconsole/config.json - Built-in defaults — endpoint
http://127.0.0.1:8900/v1/chat/completions, languagedelphi
sweetconsole config with no flags prints the current resolved configuration and where it's stored.
Language targets
The --language flag selects the target dialect:
| id | Target |
|---|---|
delphi (default) |
Modern Delphi, FireDAC for SQLite. Compiles with dcc32 and opens in the IDE. |
fpc |
FreePascal-only, sqldb for SQLite. Single fpc -Mdelphi target. |
delphi-fpc |
One codebase that compiles under both via {$IFDEF FPC} guards. |
Project layout
SweetConsole/
SweetConsole.dpr # program entry
src/
SweetConsole.App.pas # orchestrator
SweetConsole.CLI.pas # argv parser
SweetConsole.Config.pas # settings resolution
SweetConsole.HttpClient.pas # HTTP POST wrapper (FPC + Delphi)
SweetConsole.JsonUtil.pas # JSON facade (FPC + Delphi)
SweetConsole.Logger.pas # log levels + ANSI colour
SweetConsole.TUI.pas # boxes, spinner, status output
SweetConsole.Languages.pas # registry of target languages
SweetConsole.Prompts.pas # system + per-turn prompts
SweetConsole.Nanobot.pas # OpenAI-compatible chat client (SSE streaming)
SweetConsole.Builder.pas # build command: msbuild / fpc dispatch
SweetConsole.Generator.pas # file apply / snapshot
SweetConsole.Validator.pas # cross-compiler guardrail checks
SweetConsole.Templates.pas # offline scaffold for Delphi + SQLite
studio/ # SweetConsole Studio ??? FireMonkey desktop app
third_party/ # vendored deps (DMVCFramework console, TPJConsoleApp)
tools/ # dfmvalidate ??? FMX/DFM form validator
templates/
delphi-sqlite-cli/ # mirror of the bundled offline scaffold
docs/
ARCHITECTURE.md
LICENSESee docs/ARCHITECTURE.md for how the pieces fit together.
License
MIT — see LICENSE.

