Commit72a227d6Recorded24 Apr 2026Repositorysigil-format

refactor(cli,test,format): move (sigil json)-using code out of bootstrap

Message

Splits every bootstrap-compiled module that imported (sigil json) into a parent that stays in the bootstrap set and a sibling submodule that holds the json-using code and is loaded lazily at runtime. Needed because sigil-json was extracted to codeberg.org/sigil/sigil-json, so the monorepo bootstrap can no longer compile sigil/json.sgb. Dispatch pattern mirrors (sigil cli init): the parent quotes the submodule name and does module-exists? + eval '(import ...) + module-ref only on first use.

New post-bootstrap submodules: - (sigil cli watch) -- sigil build/test --watch JSON event lines - (sigil cli manager remote) -- sigil cli install/upgrade/use + release API + zig fetch - (sigil cli app manifest) -- ~/.sigil/apps manifest I/O + MCP JSON config - (sigil test report) -- sigil test --report JSON writer - (sigil format json) -- sigil format --json result printer

Parents that drop (sigil json) from their import list: - (sigil cli), (sigil cli manager), (sigil cli app) - (sigil test runner) - (sigil format)

Behavior is unchanged: sigil watch, sigil cli install/upgrade/use, sigil init, sigil format --json, sigil test --report all behave identically. Verified against the 2048-test baseline (2048/2048 pass).

test/stdlib/test-format.sgl picks up (sigil format json) for the format-result->json test that used to exercise (sigil format).

Task: t-ea65 Note: topics/sigil-bootstrap-trim-playbook

Changed
 src/sigil/format.sgl      | 42 +++---------------------------------------
 src/sigil/format/json.sgl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 39 deletions(-)
Diff
src/sigil/format.sglmodified
@@ -15,7 +15,6 @@
15
(import (sigil struct)
16
(sigil string)
17
(sigil io)
18
(sigil json)
18
(sigil fs))
19
20
(export
@@ -34,7 +33,6 @@
33
34
;; Output formatting
35
format-result->string
37
format-result->json
36
37
;; Error/warning/inference records
38
format-error?
@@ -937,43 +935,9 @@
935
(length warnings)
936
(length inferences)))))
937
940
;;; Format result as JSON string
941
(define (format-result->json result)
942
(let ((file (format-result-file result))
943
(success (format-result-success result))
944
(output (format-result-output result))
945
(errors (format-result-errors result))
946
(warnings (format-result-warnings result))
947
(inferences (format-result-inferences result)))
948
(json-encode
949
(list
950
(cons 'file file)
951
(cons 'success success)
952
;; Skip output for now if it's large - just indicate if present
953
(cons 'hasOutput (if output #t #f))
954
(cons 'errors
955
(map (lambda (e)
956
(list (cons 'line (format-error-line e))
957
(cons 'column (format-error-column e))
958
(cons 'message (format-error-message e))
959
(cons 'code (format-error-code e))))
960
errors))
961
(cons 'warnings
962
(map (lambda (w)
963
(list (cons 'line (format-warning-line w))
964
(cons 'column (format-warning-column w))
965
(cons 'message (format-warning-message w))
966
(cons 'code (format-warning-code w))))
967
warnings))
968
(cons 'inferences
969
(map (lambda (inf)
970
(list (cons 'line (paren-inference-line inf))
971
(cons 'column (paren-inference-column inf))
972
(cons 'type (symbol->string (paren-inference-type inf)))
973
(cons 'confidence (symbol->string (paren-inference-confidence inf)))
974
(cons 'reason (paren-inference-reason inf))))
975
inferences)))
976
indent: 2)))
+938
;; format-result->json is defined in (sigil format json), which imports
+939
;; (sigil json). Loaded lazily from the CLI so the bootstrap stdlib
+940
;; does not require (sigil json).
941
942
;; ============================================================
943
;;; Main API
src/sigil/format/json.sgladded
@@ -0,0 +1,50 @@
+1
;;; (sigil format json) - JSON output for format results (post-bootstrap)
+2
;;;
+3
;;; Factored out of (sigil format) so the bootstrap stdlib does not pull
+4
;;; in (sigil json). Loaded lazily from (sigil cli) when
+5
;;; `sigil format --format json` is used.
+6
+7
(define-library (sigil format json)
+8
(import (sigil format)
+9
(sigil json))
+10
(export format-result->json)
+11
+12
(begin
+13
+14
;;; Format result as JSON string
+15
(define (format-result->json result)
+16
(let ((file (format-result-file result))
+17
(success (format-result-success result))
+18
(output (format-result-output result))
+19
(errors (format-result-errors result))
+20
(warnings (format-result-warnings result))
+21
(inferences (format-result-inferences result)))
+22
(json-encode
+23
(list
+24
(cons 'file file)
+25
(cons 'success success)
+26
;; Skip output for now if it's large - just indicate if present
+27
(cons 'hasOutput (if output #t #f))
+28
(cons 'errors
+29
(map (lambda (e)
+30
(list (cons 'line (format-error-line e))
+31
(cons 'column (format-error-column e))
+32
(cons 'message (format-error-message e))
+33
(cons 'code (format-error-code e))))
+34
errors))
+35
(cons 'warnings
+36
(map (lambda (w)
+37
(list (cons 'line (format-warning-line w))
+38
(cons 'column (format-warning-column w))
+39
(cons 'message (format-warning-message w))
+40
(cons 'code (format-warning-code w))))
+41
warnings))
+42
(cons 'inferences
+43
(map (lambda (inf)
+44
(list (cons 'line (paren-inference-line inf))
+45
(cons 'column (paren-inference-column inf))
+46
(cons 'type (symbol->string (paren-inference-type inf)))
+47
(cons 'confidence (symbol->string (paren-inference-confidence inf)))
+48
(cons 'reason (paren-inference-reason inf))))
+49
inferences)))
+50
indent: 2)))))