Commitabcc9157Recorded25 Apr 2026Repositorysigil-repl
Extract sigil-repl from sigil monorepo
Message
Library/CLI split: this standalone exposes (sigil repl) and (sigil repl commands) as embeddable REPL infrastructure for any Sigil application; the (sigil repl cli) sigil-repl-cli subcommand moves into sigil-cli at (sigil cli repl).
- Drop src/sigil/repl/cli.sgl (relocated to sigil-cli). - Scaffolding: README, .gitignore (build/, .sigil/), manifest.scm, dev-redirects.sgl pointing at ../sigil for monorepo deps. - package.sgl: version 0.13.1, url -> sigil-repl, swap 4 from-workspace deps (stdlib, ansi, hooks, docs) to from-git monorepo-resident form pinned to ^0.13.1.
Changed
.gitignore | 2 ++
README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dev-redirects.sgl | 7 +++++++
manifest.scm | 7 +++++++
package.sgl | 11 ++++++-----
sigil.lock | 23 +++++++++++++++++++++++
src/sigil/repl/cli.sgl | 97 -------------------------------------------------------------------------------------------------
7 files changed, 101 insertions(+), 102 deletions(-)Diff
.gitignoreadded
@@ -0,0 +1,2 @@
+1
build/+2
.sigil/README.mdadded
@@ -0,0 +1,56 @@
+1
# sigil-repl+2
+3
Interactive REPL infrastructure for+4
[Sigil](https://codeberg.org/sigil/sigil). Provides prompt rendering,+5
multi-line input handling, debug-mode stack inspection, and a shared+6
command registry so applications can embed a Sigil REPL with their+7
own commands.+8
+9
The `sigil repl` CLI command itself lives in sigil-cli at+10
`(sigil cli repl)`; this package exposes only the embeddable library+11
surface. sigil-nrepl reuses these primitives for the network REPL.+12
+13
## Modules+14
+15
| Module | Purpose |+16
|-------------------------|---------------------------------------------------------------------------------|+17
| `(sigil repl)` | REPL entry point, prompt rendering, debug-mode formatting, command parsing |+18
| `(sigil repl commands)` | Shared command registry plus the built-in REPL commands (`,help`, `,q`, etc.) |+19
+20
## Embedding a REPL+21
+22
```scheme+23
(import (sigil repl))+24
+25
(run-repl) ; starts the interactive loop on stdin/stdout+26
```+27
+28
To register custom commands:+29
+30
```scheme+31
(import (sigil repl commands))+32
+33
(register-repl-command!+34
name: ",time"+35
description: "Print elapsed time for an expression."+36
handler: (lambda (args) ...))+37
```+38
+39
## Build and test+40
+41
```+42
sigil deps install+43
sigil build+44
sigil test --report+45
```+46
+47
Local development against an unreleased sigil monorepo:+48
+49
```+50
sigil deps install --redirects ./dev-redirects.sgl+51
sigil build --redirects ./dev-redirects.sgl+52
```+53
+54
## License+55
+56
BSD-3-Clause. See `LICENSE` in the sigil monorepo for the canonical copy.dev-redirects.sgladded
@@ -0,0 +1,7 @@
+1
;; Development redirects — point from-git deps at local sibling checkouts+2
;; during monorepo dev. Use: sigil build --redirects ./dev-redirects.sgl+3
(redirects+4
repos: (list+5
(for-repo+6
url: "codeberg:sigil/sigil"+7
use: (from-path dir: "../sigil"))))manifest.scmadded
@@ -0,0 +1,7 @@
+1
;; sigil-repl Development Environment+2
;; Use with: guix shell -m manifest.scm+3
+4
(specifications->manifest+5
'("gcc-toolchain"+6
"make"+7
"pkg-config"))package.sglmodified
@@ -7,12 +7,13 @@
7
(package 8
name: "sigil-repl" 9
description: "Interactive REPL for Sigil"−10
url: "https://codeberg.org/sigil/sigil"+10
version: "0.13.1"+11
url: "https://codeberg.org/sigil/sigil-repl" 12
license: "BSD-3-Clause" 13
authors: (list "David Wilson <[email protected]>") 14
15
dependencies: (list−15
(from-workspace name: "sigil-stdlib")−16
(from-workspace name: "sigil-ansi")−17
(from-workspace name: "sigil-hooks")−18
(from-workspace name: "sigil-docs")))+16
(from-git url: "codeberg:sigil/sigil" package: "sigil-stdlib" version: "^0.13.1")+17
(from-git url: "codeberg:sigil/sigil" package: "sigil-ansi" version: "^0.13.1")+18
(from-git url: "codeberg:sigil/sigil" package: "sigil-hooks" version: "^0.13.1")+19
(from-git url: "codeberg:sigil/sigil" package: "sigil-docs" version: "^0.13.1")))sigil.lockadded
@@ -0,0 +1,23 @@
+1
;; Auto-generated by sigil deps install. Do not edit.+2
(lock+3
(package name: "sigil-stdlib"+4
url: "codeberg:sigil/sigil"+5
ref: "^0.13.1"+6
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"+7
package-selector: "sigil-stdlib")+8
(package name: "sigil-ansi"+9
url: "codeberg:sigil/sigil"+10
ref: "^0.13.1"+11
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"+12
package-selector: "sigil-ansi")+13
(package name: "sigil-hooks"+14
url: "codeberg:sigil/sigil"+15
ref: "^0.13.1"+16
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"+17
package-selector: "sigil-hooks")+18
(package name: "sigil-docs"+19
url: "codeberg:sigil/sigil"+20
ref: "^0.13.1"+21
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"+22
package-selector: "sigil-docs")+23
)src/sigil/repl/cli.sgldeleted
@@ -1,97 +0,0 @@
−1
;;; (sigil repl cli) - CLI command for REPL−2
;;;−3
;;; Provides the CLI command definition for `sigil repl`.−4
;;; This module is loaded dynamically by the CLI when available.−5
−6
(define-library (sigil repl cli)−7
(import (sigil core)−8
(sigil string)−9
(sigil io)−10
(sigil fs)−11
(sigil path)−12
(sigil process)−13
(sigil args)−14
(sigil repl)−15
(sigil nrepl))−16
(export−17
repl-handler−18
repl-cmd)−19
−20
(begin−21
−22
;; Common options−23
(define help-opt−24
(option−25
name: 'help−26
short: #\h−27
long: "help"−28
description: "Show help for this command"))−29
−30
(define verbose-opt−31
(option−32
name: 'verbose−33
short: #\v−34
long: "verbose"−35
description: "Enable verbose output"))−36
−37
;;; Set up load paths for a project−38
(define (setup-project-load-paths project-path verbose?)−39
(let ((pkg-file (path-join project-path "package.sgl")))−40
(when (file-exists? pkg-file)−41
;; Add standard source directories−42
(for-each−43
(lambda (subdir)−44
(let ((lib-dir (path-join project-path subdir)))−45
(when (directory-exists? lib-dir)−46
(when verbose?−47
(println "Adding to library path: ~a" lib-dir))−48
(add-library-path! lib-dir))))−49
'("src" "lib" "modules")))))−50
−51
;;; Handler for `sigil repl` command−52
(define (repl-handler opts args)−53
(let ((nrepl-port (alist-get 'nrepl opts))−54
(project-path (alist-get 'project opts))−55
(verbose? (alist-get 'verbose opts)))−56
;; Set up project load paths if specified−57
(when project-path−58
(setup-project-load-paths project-path verbose?))−59
(if nrepl-port−60
;; Start nREPL server mode−61
(let ((port (if (string? nrepl-port)−62
(string->number nrepl-port)−63
7888)))−64
(let ((server (nrepl-start port)))−65
(if server−66
;; Main loop - process nREPL requests−67
(let loop ()−68
(nrepl-process-pending server)−69
(sleep 0.01) ; 10ms poll interval−70
(loop))−71
(begin−72
(eprintln "Failed to start nREPL server on port ~a" port)−73
(exit 1)))))−74
;; Normal interactive REPL−75
(run-repl))))−76
−77
;;; CLI command definition−78
(define repl-cmd−79
(command−80
name: "repl"−81
description: "Start interactive REPL"−82
options: (list−83
help-opt−84
verbose-opt−85
(option−86
name: 'nrepl−87
long: "nrepl"−88
value: "PORT"−89
description: "Start nREPL server on PORT (default: 7888)")−90
(option−91
name: 'project−92
long: "project"−93
value: "PATH"−94
description: "Set up load paths for project at PATH"))−95
handler: repl-handler))−96
−97
))