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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
88 changes: 88 additions & 0 deletions .github/workflows/check-debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Check on Debian trixie

# 静态检查 CI:只跑格式化检查(gf fmt --check)与代码度量检查(gf check),
# 不执行测试(测试在 test-debian.yml 中独立运行)。
# 与 liii 固定 GOLDFISH_VERSION 不同,这里通过 releases/latest API 取最新 tag,
# 始终用最新发布的 Goldfish(参考 liii/cd-debian13.yml 的取最新版做法)。

on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'ai/**'
- 'agent/**'
- 'code/**'
- 'extensions/**'
- 'review/**'
- 'simplify/**'
- 'tests/**'
- 'tui/**'
- 'web-search/**'
- 'gfproject.json'
- 'gf_check.json'
- 'gf_fmt.json'
- '.github/workflows/check-debian.yml'
pull_request:
paths:
- 'ai/**'
- 'agent/**'
- 'code/**'
- 'extensions/**'
- 'review/**'
- 'simplify/**'
- 'tests/**'
- 'tui/**'
- 'web-search/**'
- 'gfproject.json'
- 'gf_check.json'
- 'gf_fmt.json'
- '.github/workflows/check-debian.yml'

env:
DEBIAN_FRONTEND: noninteractive

jobs:
check:
container: debian:trixie
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y git curl ca-certificates python3

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: git add safe directory
run: git config --global --add safe.directory '*'

- name: Install Goldfish (latest)
run: |
TAG=$(curl -fsSL -H "User-Agent: gfcode-ci" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/MoganLab/goldfish/releases/latest \
| python3 -c "import sys, json; print(json.load(sys.stdin)['tag_name'])")
echo "Latest goldfish release: $TAG"
curl -fsSL -o /tmp/goldfish.deb \
"https://github.com/MoganLab/goldfish/releases/download/$TAG/goldfish-scheme-x86_64-$TAG.deb"
apt-get install -y /tmp/goldfish.deb
gf version

- name: Format Check
run: |
gf fmt --check ai
gf fmt --check agent
gf fmt --check code
gf fmt --check extensions
gf fmt --check review
gf fmt --check simplify
gf fmt --check tui
gf fmt --check web-search
gf fmt --check tests

- name: Run code metrics check
run: gf check
85 changes: 85 additions & 0 deletions .github/workflows/test-debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Test on Debian trixie

# 测试 CI:只跑单元测试(gf test 各 domain 的 tests),
# 不执行格式化与代码度量检查(静态检查在 check-debian.yml 中独立运行)。
# 与 liii 固定 GOLDFISH_VERSION 不同,这里通过 releases/latest API 取最新 tag,
# 始终用最新发布的 Goldfish(参考 liii/cd-debian13.yml 的取最新版做法)。

on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'ai/**'
- 'agent/**'
- 'code/**'
- 'extensions/**'
- 'review/**'
- 'simplify/**'
- 'tests/**'
- 'tui/**'
- 'web-search/**'
- 'gfproject.json'
- '.github/workflows/test-debian.yml'
pull_request:
paths:
- 'ai/**'
- 'agent/**'
- 'code/**'
- 'extensions/**'
- 'review/**'
- 'simplify/**'
- 'tests/**'
- 'tui/**'
- 'web-search/**'
- 'gfproject.json'
- '.github/workflows/test-debian.yml'

env:
DEBIAN_FRONTEND: noninteractive

jobs:
test:
container: debian:trixie
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
domain:
- ai
- agent
- code
- review
- simplify
- tui
- web-search
- tests
name: test (${{ matrix.domain }})
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y git curl ca-certificates python3

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: git add safe directory
run: git config --global --add safe.directory '*'

- name: Install Goldfish (latest)
run: |
TAG=$(curl -fsSL -H "User-Agent: gfcode-ci" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/MoganLab/goldfish/releases/latest \
| python3 -c "import sys, json; print(json.load(sys.stdin)['tag_name'])")
echo "Latest goldfish release: $TAG"
curl -fsSL -o /tmp/goldfish.deb \
"https://github.com/MoganLab/goldfish/releases/download/$TAG/goldfish-scheme-x86_64-$TAG.deb"
apt-get install -y /tmp/goldfish.deb
gf version

- name: Run tests
run: gf test ${{ matrix.domain }}/tests/liii
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-end "tc-001" "read" "文件内容" #f 42))
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f)
) ;obj-b
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f))
) ;
(check (pi-event-tool-execution-end-duration-ms obj-a) => 42)
(check (pi-event-tool-execution-end-duration-ms obj-b) => #f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-end "tc-001" "read" "文件内容" #f 42))
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f)
) ;obj-b
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f))
) ;
(check (pi-event-tool-execution-end-is-error obj-a) => #f)
(check (pi-event-tool-execution-end-is-error obj-b) => #t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-end "tc-001" "read" "文件内容" #f 42))
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f)
) ;obj-b
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f))
) ;
(check (pi-event-tool-execution-end-result obj-a) => "文件内容")
(check (pi-event-tool-execution-end-result obj-b) => "command not found")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-end "tc-001" "read" "文件内容" #f 42))
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f)
) ;obj-b
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f))
) ;
(check (pi-event-tool-execution-end-tool-call-id obj-a) => "tc-001")
(check (pi-event-tool-execution-end-tool-call-id obj-b) => "tc-002")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-end "tc-001" "read" "文件内容" #f 42))
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f)
) ;obj-b
(obj-b (pi-event-tool-execution-end "tc-002" "bash" "command not found" #t #f))
) ;
(check (pi-event-tool-execution-end-tool-name obj-a) => "read")
(check (pi-event-tool-execution-end-tool-name obj-b) => "bash")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-start "tc-001" "read" '(("path"
. "foo.txt")))
) ;obj-a
. "foo.txt"))))
(obj-b (pi-event-tool-execution-start "tc-002" "bash" '(("command"
. "ls")))
) ;obj-b
. "ls"))))
) ;
(check (pi-event-tool-execution-start-args obj-a) => '(("path" . "foo.txt")))
(check (pi-event-tool-execution-start-args obj-b) => '(("command" . "ls")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

(check-set-mode! 'report-failed)

(let ((obj (pi-event-tool-execution-start "tc-001" "read" '(("path"
. "foo.txt")))
) ;obj
) ;
(let ((obj (pi-event-tool-execution-start "tc-001" "read" '(("path" . "foo.txt")))))
(check-true (pi-event-tool-execution-start? obj))
) ;let
(check-false (pi-event-tool-execution-start? '()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-start "tc-001" "read" '(("path"
. "foo.txt")))
) ;obj-a
. "foo.txt"))))
(obj-b (pi-event-tool-execution-start "tc-002" "bash" '(("command"
. "ls")))
) ;obj-b
. "ls"))))
) ;
(check (pi-event-tool-execution-start-tool-call-id obj-a) => "tc-001")
(check (pi-event-tool-execution-start-tool-call-id obj-b) => "tc-002")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
(check-set-mode! 'report-failed)

(let* ((obj-a (pi-event-tool-execution-start "tc-001" "read" '(("path"
. "foo.txt")))
) ;obj-a
. "foo.txt"))))
(obj-b (pi-event-tool-execution-start "tc-002" "bash" '(("command"
. "ls")))
) ;obj-b
. "ls"))))
) ;
(check (pi-event-tool-execution-start-tool-name obj-a) => "read")
(check (pi-event-tool-execution-start-tool-name obj-b) => "bash")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

(check-set-mode! 'report-failed)

(check-true (pi-text-block? (%maybe-json-block '(("type" . "text") ("text" . "hi")))))
(check-true (pi-text-block? (%maybe-json-block '((type . "text") (text . "hi")))))
(check-true
(pi-text-block? (%maybe-json-block '(("type" . "text") ("text" . "hi"))))
) ;check-true
(check-true
(pi-text-block? (%maybe-json-block '((type . "text") (text . "hi"))))
) ;check-true
(check (%maybe-json-block "raw") => "raw")

(check-report)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

(check-set-mode! 'report-failed)

(check-true (pi-user-message? (%maybe-json-msg '(("role" . "user") ("content" . "hi")))))
(check-true
(pi-user-message? (%maybe-json-msg '(("role" . "user") ("content" . "hi"))))
) ;check-true
(check (%maybe-json-msg '((role . "user"))) => '((role . "user")))

(check-report)
28 changes: 15 additions & 13 deletions ai/liii/pi/ai/api/google-generative-ai/stream-parse.scm
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@
(let ((json-data (string->json body)))
(and (json-object? json-data)
(let ((err (json-ref json-data "error")))
(cond
((json-object? err) (json-ref-string err "message" #f))
((string? err) err)
(else #f)
(cond ((json-object? err) (json-ref-string err "message" #f))
((string? err) err)
(else #f)
) ;cond
) ;let
) ;and
Expand Down Expand Up @@ -125,13 +124,15 @@
(define (process-stream-function-call fc blocks stream-state on-event)
(let* ((name (if (json-object? fc) (json-ref-string fc "name" "") ""))
(args (if (json-object? fc) (json-ref fc "args") '()))
(id (or (and (json-object? fc) (json-ref-string fc "id" #f))
(cdr (or (assoc 'id fc) '(#f . #f)))
) ;or
(id
(or (and (json-object? fc) (json-ref-string fc "id" #f))
(cdr (or (assoc 'id fc) '(#f . #f)))
) ;or
) ;id
(ts (or (and (json-object? fc) (json-ref-string fc "thoughtSignature" #f))
(cdr (or (assoc 'thoughtSignature fc) '(#f . #f)))
) ;or
(ts
(or (and (json-object? fc) (json-ref-string fc "thoughtSignature" #f))
(cdr (or (assoc 'thoughtSignature fc) '(#f . #f)))
) ;or
) ;ts
(eff-id
(if (and (string? id) (not (string-null? id)))
Expand Down Expand Up @@ -178,9 +179,10 @@
(let* ((blocks (gemini-stream-state-blocks stream-state))
(last-text (gemini-stream-state-last-text stream-state))
(usage (gemini-stream-state-usage stream-state))
(part-ts (or (and (json-object? part) (json-ref-string part "thoughtSignature" #f))
(cdr (or (assoc 'thoughtSignature part) '(#f . #f)))
) ;or
(part-ts
(or (and (json-object? part) (json-ref-string part "thoughtSignature" #f))
(cdr (or (assoc 'thoughtSignature part) '(#f . #f)))
) ;or
) ;part-ts
) ;
(cond
Expand Down
7 changes: 2 additions & 5 deletions ai/liii/pi/ai/api/google-generative-ai/stream-state.scm
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
(begin

(define*-record-type <gemini-stream-state>
(make-gemini-stream-state
(blocks '())
(make-gemini-stream-state (blocks '())
(last-text #f)
(usage '())
(tool-calls '())
Expand All @@ -37,9 +36,7 @@
(blocks gemini-stream-state-blocks gemini-stream-state-blocks-set!)
(last-text gemini-stream-state-last-text gemini-stream-state-last-text-set!)
(usage gemini-stream-state-usage gemini-stream-state-usage-set!)
(tool-calls gemini-stream-state-tool-calls
gemini-stream-state-tool-calls-set!
) ;tool-calls
(tool-calls gemini-stream-state-tool-calls gemini-stream-state-tool-calls-set!)
(finish-reason gemini-stream-state-finish-reason
gemini-stream-state-finish-reason-set!
) ;finish-reason
Expand Down
Loading
Loading