Skip to content
Closed
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ mmio-api = { version = "0.2.2", path = "components/mmio-api" }
lock_api = { version = "0.4", default-features = false }
log = "0.4"
spin = "0.10"
ostool = { version = "0.19" }
ostool = { version = "0.21" }
uefi = "0.36"
fdt-edit = "0.2.3"
fdt-raw = "0.3"
Expand Down
17 changes: 17 additions & 0 deletions apps/starry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ cargo xtask starry app run -t redis --arch riscv64
Stress configs are available through explicit QEMU config variants; see
`redis/README.md`.

## jcode

The `jcode` case is an x86_64 QEMU app workflow that downloads the jcode AI coding
agent from GitHub releases, patches the glibc-linked binary for musl compatibility
using `patchelf`, builds a glibc stub shared library, and injects everything into
the app rootfs overlay.

```bash
apps/starry/jcode/prepare_jcode_rootfs.sh
cargo xtask starry qemu \
--arch x86_64 \
--qemu-config apps/starry/jcode/qemu-x86_64.toml \
--rootfs tmp/axbuild/rootfs/rootfs-x86_64-jcode.img
```

See `jcode/README.md` for interactive usage and troubleshooting.

## Orange Pi 5 Plus UVC

The `orangepi-5-plus-uvc` case needs `/usr/bin/uvc-fps` to be installed in the
Expand Down
95 changes: 95 additions & 0 deletions apps/starry/jcode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# StarryOS jcode Example

这个目录提供在 StarryOS x86_64 QEMU 中运行 jcode(AI coding agent)的手动示例。它不是 `test-suit/starryos` 用例,也不会进入 CI;下载 jcode、glibc-to-musl 补丁、rootfs 注入都只会在用户显式执行本目录脚本时发生。

## 什么是 jcode

jcode 是一个 Rust 编写的 AI coding agent harness,采用 TUI client + background server 双进程架构,通过 Unix domain socket 通信。项目地址:<https://github.com/1jehuang/jcode>

## Host 依赖

脚本需要以下 host 工具(Debian/Ubuntu):

```bash
apt-get install -y patchelf binutils curl qemu-user-static
```

## 准备 jcode Rootfs

先在 host 侧准备本地 rootfs。脚本会自动:

1. 从 GitHub releases 下载 jcode linux-x86_64 二进制
2. 下载 Alpine minirootfs 作为 staging 环境
3. 使用 `patchelf` 将 glibc-linked 的 jcode 转换为 musl 兼容
4. 编译 glibc stub 共享库(提供 `mallopt`、`__res_init` 等 glibc-only 符号)
5. 注入 jcode 二进制、SSL 库、Kerberos 依赖到 rootfs

```bash
apps/starry/jcode/prepare_jcode_rootfs.sh
```

产物位于 `tmp/axbuild/rootfs/rootfs-x86_64-jcode.img`,是本地资产,不提交到仓库。

## 离线 Smoke 测试

验证 jcode 能在 StarryOS guest 中正常运行:

```bash
cargo xtask starry qemu \
--arch x86_64 \
--qemu-config apps/starry/jcode/qemu-x86_64.toml \
--rootfs tmp/axbuild/rootfs/rootfs-x86_64-jcode.img
```

期望输出包含:

```text
STARRY_JCODE_SMOKE_PASSED
```

## 手动交互

准备 rootfs 后,可以直接启动 QEMU 进入 StarryOS shell:

```bash
cargo xtask starry qemu \
--arch x86_64 \
--rootfs tmp/axbuild/rootfs/rootfs-x86_64-jcode.img
```

进入 `root@starry` 后:

```sh
export HOME=/root
export USER=root
export SHELL=/bin/sh
export TERM=xterm-256color
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin
export JCODE_NO_AUTO_UPDATE=1

# 配置 provider(需要网络和 API key)
jcode login --provider openai-compatible

# 运行 jcode TUI
jcode
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引用了不存在的路径。

test-suit/starryos/normal/qemu-smp1/jcode/ 在本 PR 和 dev 分支均不存在。如果这是未来计划的 CI 测试,建议改为说明性语言:「计划在 test-suit/starryos/normal/qemu-smp1/jcode/ 添加 CI 测试用例」,而非暗示它已经存在。

> **注意**:`JCODE_NO_AUTO_UPDATE=1` 必须设置。jcode 的自动更新会下载 glibc 版本的二进制,覆盖已打补丁的 musl 版本,导致 jcode 无法运行。如果误触发了自动更新,需要重新运行 `prepare_jcode_rootfs.sh`。

## 与 test-suit 的关系

本目录是操作者面向的工作流,提供完整的交互式 jcode 使用体验。计划在 `test-suit/starryos/normal/qemu-smp1/jcode/` 添加 CI 测试用例,验证 jcode 安装是否成功(`jcode --version`)。

## 内核修复

jcode 在 StarryOS 上运行需要以下内核修复(已合入 dev 分支):

- ext4 文件系统块分配和 JBD2 superblock 修复
- EPOLLET edge-triggered epoll 竞态修复

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引用了不存在的文件路径。

  • test-suit/starryos/normal/qemu-smp1/jcode/ 在本 PR 和 dev 分支均不存在。如果这是未来计划的 CI 测试,建议改为说明性语言,例如「计划在 test-suit/starryos/normal/qemu-smp1/jcode/ 添加 CI 测试用例」,而非暗示它已经存在。
  • report/kernel_changes_report.md 在仓库中任何位置都不存在。请删除此引用,或将报告文件加入本 PR。

- 非阻塞 socket waker 注册
- ARP 队列扩容(32→256,TTL 60s→300s)
- TTY 终端 ANSI CPR 和 SIGWINCH 支持

## 边界

这个 example 只声明 x86_64 QEMU 下的手动演示流程。它不覆盖 jcode TUI 在线模式、CI 测试、或其他架构上的 jcode。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引用了不存在的文件。

report/kernel_changes_report.md 在仓库中不存在。请删除此引用,或将报告文件加入本 PR。

5 changes: 5 additions & 0 deletions apps/starry/jcode/build-x86_64-unknown-none.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target = "x86_64-unknown-none"
env = { AX_IP = "10.0.2.15", AX_GW = "10.0.2.2" }
log = "Warn"
features = ["qemu"]
plat_dyn = false
17 changes: 17 additions & 0 deletions apps/starry/jcode/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# prebuild.sh for the jcode app case.
# Delegates to prepare_jcode_rootfs.sh which handles asset download, glibc-to-musl
# patching, and rootfs injection in one step.
set -euo pipefail

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
workspace="${STARRY_WORKSPACE:-$(cd "$script_dir/../../.." && pwd)}"
output_rootfs="$workspace/tmp/axbuild/rootfs/rootfs-x86_64-jcode.img"

if [[ -f "$output_rootfs" ]]; then
echo "jcode rootfs already exists: $output_rootfs"
echo "To rebuild, remove it first or run prepare_jcode_rootfs.sh directly."
exit 0
fi

"$script_dir/prepare_jcode_rootfs.sh"
Loading