Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gfproject.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"package": {
"name": "pi",
"organization": "liii",
"version": "2026.11.24",
"description": "Pi coding agent for Goldfish Scheme"
},
"domains": {
Expand Down
31 changes: 29 additions & 2 deletions tui/liii/pi/tui/interactive/header.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
(import (scheme base)
(liii format base)
(liii format color)
(liii json)
(liii path)
(liii string)
(liii tui component)
(liii gfproject tools)
(liii pi tui interactive common)
) ;import
(begin
Expand Down Expand Up @@ -40,7 +44,8 @@
;; 页眉内容只随 version 变化,与宽度无关,故一次构造后复用
(define (%header-lines version)
(let* ((dot (%fg %c-mid " · "))
(line1 (string-append " " (%fg-bold %c-brand "gf") (%fg %c-dim " v" version)))
(line1 (string-append " " (%fg-bold %c-brand "gfcode") (%fg %c-dim " v" version))
) ;line1
(line2 (string-append " "
(%fg %c-dim "escape")
(%fg %c-mid " interrupt")
Expand All @@ -67,8 +72,30 @@
) ;let*
) ;define

;; 读取 gfcode 自身 gfproject.json 的 package.version 作为首屏版本号;
;; 解析失败或缺字段时回退到 Goldfish 的 (version),保证总有展示值。
(define (%pi-tool-version)
(catch #t
(lambda ()
(let* ((bundle (gfproject-resolve-tool-bundle "pi"))
(base (bundle-ref bundle "tool_base_dir"))
) ;
(if (not (string? base))
(version)
(let* ((file (path->string (path-join (path base) "gfproject.json")))
(pkg (json-ref (string->json (path-read-text file)) "package"))
) ;
(or (json-ref-string pkg "version" #f) (version))
) ;let*
) ;if
) ;let*
) ;lambda
(lambda args (version))
) ;catch
) ;define

(define (make-pi-header . args)
(let* ((version (%keyword-value :version args (version)))
(let* ((version (%keyword-value :version args (%pi-tool-version)))
(lines (%header-lines version))
(comp (make-component :render (lambda (self width) lines)))
) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
;; 24 行终端:对话记录视口 19 行 + 输入区 3 行 + 页脚 2 行
(check (length plain) => 24)
;; 页眉位于对话记录视口顶部
(check-true (string-contains? (list-ref plain 1) " gf v"))
(check-true (string-contains? (list-ref plain 1) " gfcode v"))
;; 输入区上边框贴在底部(视口 19 + 上边框)
(check-true (string-contains? (list-ref plain 19) "─"))
;; 页脚最后两行(页脚含路径/分支与用量/模型,内容随环境变化,只断言非空)
Expand Down
2 changes: 1 addition & 1 deletion tui/tests/liii/pi/tui/interactive/app/integration-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
(check (length lines) => 40)
;; Header
(check (list-ref plain-lines 0) => "")
(check-true (string-contains? (list-ref plain-lines 1) " gf v"))
(check-true (string-contains? (list-ref plain-lines 1) " gfcode v"))
;; Editor 分隔线(输入区固定贴在屏幕底部)
(check (list-ref plain-lines 35) => (utf8-make-string 100 #\─))
(check (string-trim (list-ref plain-lines 36)) => "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
(check (component? hdr) => #t)
(check (length lines) => 6)
(check (list-ref plain-lines 0) => "")
(check-true (string-contains? (list-ref plain-lines 1) (string-append " gf v" (version)))
) ;check-true
(check-true (string-contains? (list-ref plain-lines 1) " gfcode v"))
(check-true (string-contains? (list-ref plain-lines 1) (version)))
(check-true (string-contains? (list-ref plain-lines 2) "escape interrupt"))
(check-true (string-contains? (list-ref plain-lines 2) "ctrl+c/ctrl+d clear/exit")
) ;check-true
Expand All @@ -52,7 +52,7 @@
(lines (component-render hdr 80))
(plain-lines (map strip-ansi lines))
) ;
(check-true (string-contains? (list-ref plain-lines 1) " gf v1.2.3"))
(check-true (string-contains? (list-ref plain-lines 1) " gfcode v1.2.3"))
) ;let*

(check-report)
Loading