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
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。

## [0.0.29] — 2026-11-24

### 新增

- **ANSI 终端模拟器**:把 0.0.28 的「行式 PTY」升级为本地 xterm.js 5.5.0(MIT,随 APK 打包在 `assets/terminal/`)。PTY 原始字节直接写入 xterm,光标定位、颜色、清屏、备用屏、滚动回看与全屏重绘都由终端模拟器解释;`vim`、`top`、`less` 等程序可以正常显示。
- **窗口尺寸联动**:xterm 用 `FitAddon` 按容器计算行列,变化时经 JS 桥回调 `PtyBridge.resize`,shell 收到真实 `TIOCSWINSZ`。
- **移动端补充键**:终端下方提供 Esc / Tab / Ctrl-C / Ctrl-D / 方向键与「清屏」,解决软键盘没有这些键的问题。
- **亮暗双主题**:xterm 配色随应用 `effectiveDarkTheme()` 切换;WebView 强制 `blockNetworkLoads` 且拦截外部跳转,终端页不联网。

### 改变

- `EditorViewModel` 不再在 Kotlin 侧做 UTF-8 解码、按行切分、剥离 CSI/OSC;PTY 字节进 `MutableSharedFlow<ByteArray>`(replay 64)后交给 xterm,避免无换行提示符与全屏程序被吞。
- 终端面板在 PTY 模式下隐藏原来的单行输入框,键盘输入直接进 xterm;非 PTY 的轻量命令会话保持不变。

### 边界

- 终端渲染依赖系统 WebView(Android 8.0+ 自带)。WebView 被禁用/损坏时 PTY 仍能启动,但终端页面无法显示;这是当前为「成熟终端模拟器」付出的体积与依赖代价(xterm 资产约 296KB)。
- 本轮未取得 Android 真机/模拟器交互验收:TCG 模拟器仍受 QEMU hanging thread 影响;xterm 页面已用 Chromium 无头浏览器做 ANSI/主题/无报错冒烟,PTY 字节链路沿用 0.0.28 的宿主 `forkpty` 验证。

### 构建

- `versionCode 29` / `versionName 0.0.29`。
- 单元测试 130 个通过(本轮无新增 JVM 测试;新增 xterm 页面冒烟为构建外验证)。
- release APK 31,725,827 B(约 30.3MiB),SHA-256 `e4ff73ea6bbeb011137f5627db12197a06cf7a0d0232fa4e535ccb9721d6640f`;debug APK 51,315,765 B(约 48.9MiB),SHA-256 `d10e6668497fbe9d68d87aa1849b307c3b867f319b59a70b0245821e5482534a`。
- lint Release 38 个 issue(36 Warning + 2 Information),Fatal 0 / Error 0。
- APK 内 `assets/terminal/` 含 `index.html`、`xterm.js`、`xterm.css`、`addon-fit.js`、`LICENSE-xterm.txt`;`lib/arm64-v8a/libptybridge.so`、`lib/x86_64/libptybridge.so` 仍在。

## [0.0.28] — 2026-11-24

### 新增
Expand Down
8 changes: 8 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
- 许可证:Apache-2.0
- 通过 Maven Central 分发的官方 Android 组件。

## 9. xterm.js(终端模拟器)

- 项目地址:https://github.com/xtermjs/xterm.js
- 许可证:**MIT**
- 使用方式:`xterm.js 5.5.0` 与 `@xterm/addon-fit 0.10.0` 以静态文件形式随 APK
打包在 `app/src/main/assets/terminal/`,由本地 WebView 加载;不访问网络。
- 许可证原文:`app/src/main/assets/terminal/LICENSE-xterm.txt`。

---

本项目自身代码以 Apache License 2.0 发布,详见 [LICENSE](LICENSE)。
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ Three runtimes are bundled inside the APK: a natively cross-compiled CPython 3.1
- **Python pdb debugger**: real stdlib `pdb`; breakpoints, next/step/continue, `p locals()`, stack, quit; quick-action bar in output panel
- **Offline by design**: no language server process, no model download, hard caps at 300 `.py` files / 512KB per file

### Agent & terminal (0.0.28)
### Agent & terminal (0.0.29)
- **Agent plan mode**: plan → approval → tool execution, with cross-turn context and token budgets
- **Project rules**: reads `AGENTS.md` / `CLAUDE.md` / `.cursorrules` / `.windsurfrules` / Copilot instructions
- **Read-only sub-agent**: `delegate_task` explores multiple files in an isolated context
- **Offline semantic search**: TF-IDF index with file/line hits, no embedding download
- **Command terminal panel**: persistent cwd, `cd`/`pwd`, timeout and output caps
- **Real PTY mode**: `forkpty` + `/system/bin/sh -i` for `vim` / `top`; line-oriented UI, ANSI cursor control is stripped rather than emulated
- **Command terminal panel**: persistent cwd, `cd`/`pwd`, timeout and output caps; PTY mode switches to xterm with mobile Esc/Tab/Ctrl/arrow keys and light/dark themes
- **Real ANSI terminal**: `forkpty` + `/system/bin/sh -i` feeding a local xterm.js 5.5.0 screen; cursor addressing, 256-color SGR, alternate screen and scrollback work, with `vim` / `top` / `less`; resize is wired to `TIOCSWINSZ`
- **MCP tools/resources/prompts**, retrying providers, persisted AI history

### Manage projects
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId = "com.devterminal"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 28
versionName = "0.0.28"
versionCode = 29
versionName = "0.0.29"
vectorDrawables { useSupportLibrary = true }
// 原生 CPython 引擎:同时打 arm64 与 x86_64(后者用于模拟器/ChromeOS)
ndk { abiFilters += listOf("arm64-v8a", "x86_64") }
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@

# llama.cpp JNI:LocalLlama 的 native 方法按名字查找,必须保留类名与方法名
-keep class com.devterminal.model.LocalLlama { *; }

# WebView JS 桥:xterm 页面按方法名调用 Android.onData/onResize/onReady
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
21 changes: 21 additions & 0 deletions app/src/main/assets/terminal/LICENSE-xterm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 2 additions & 0 deletions app/src/main/assets/terminal/addon-fit.js

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

140 changes: 140 additions & 0 deletions app/src/main/assets/terminal/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="xterm.css">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
background: #0b0e14;
overflow: hidden;
-webkit-user-select: none;
}
#term {
box-sizing: border-box;
width: 100%;
height: 100%;
padding: 6px;
}
</style>
</head>
<body>
<div id="term"></div>

<script src="xterm.js"></script>
<script src="addon-fit.js"></script>
<script>
(function () {
var darkTheme = location.search.indexOf('dark=0') < 0;
var themes = {
dark: {
background: '#0b0e14',
foreground: '#c9d1d9',
cursor: '#7aa2f7',
cursorAccent: '#0b0e14',
selectionBackground: '#264f78',
black: '#1b1f27', red: '#f7768e', green: '#9ece6a', yellow: '#e0af68',
blue: '#7aa2f7', magenta: '#bb9af7', cyan: '#7dcfff', white: '#c9d1d9',
brightBlack: '#414868', brightRed: '#ff7a93', brightGreen: '#b9f27c',
brightYellow: '#ff9e64', brightBlue: '#7da6ff', brightMagenta: '#bb9af7',
brightCyan: '#0db9d7', brightWhite: '#ffffff'
},
light: {
background: '#f6f8fa',
foreground: '#24292f',
cursor: '#0969da',
cursorAccent: '#f6f8fa',
selectionBackground: '#b6d7ff',
black: '#24292f', red: '#cf222e', green: '#116329', yellow: '#4d2d00',
blue: '#0969da', magenta: '#8250df', cyan: '#1b7c83', white: '#6e7781',
brightBlack: '#57606a', brightRed: '#a40e26', brightGreen: '#1a7f37',
brightYellow: '#633c01', brightBlue: '#218bff', brightMagenta: '#a475f9',
brightCyan: '#3192aa', brightWhite: '#8c959f'
}
};

function applyTheme(dark) {
darkTheme = !!dark;
var theme = darkTheme ? themes.dark : themes.light;
document.body.style.background = theme.background;
document.getElementById('term').style.background = theme.background;
if (window.term) window.term.options.theme = theme;
}

var term = new Terminal({
cursorBlink: true,
cursorStyle: 'block',
fontFamily: 'monospace',
fontSize: 13,
lineHeight: 1.15,
scrollback: 5000,
convertEol: false,
theme: darkTheme ? themes.dark : themes.light
});

var fitAddon = new FitAddon.FitAddon();
term.loadAddon(fitAddon);
term.open(document.getElementById('term'));
window.term = term;
applyTheme(darkTheme);

var lastCols = 0;
var lastRows = 0;

function notifyResize() {
try {
fitAddon.fit();
} catch (e) {
// 容器尚未完成布局时忽略
}
if (term.cols !== lastCols || term.rows !== lastRows) {
lastCols = term.cols;
lastRows = term.rows;
if (window.Android && Android.onResize) {
Android.onResize(term.cols, term.rows);
}
}
}

term.onData(function (data) {
if (window.Android && Android.onData) {
Android.onData(data);
}
});

window.addEventListener('resize', notifyResize);
document.addEventListener('visibilitychange', function () {
if (!document.hidden) notifyResize();
});
if (window.ResizeObserver) {
new ResizeObserver(function () { notifyResize(); })
.observe(document.getElementById('term'));
}
document.getElementById('term').addEventListener('click', function () {
term.focus();
});

// Kotlin -> JS:base64 字节流直接交给 xterm,保留 UTF-8 与 ANSI 序列。
window.termWriteB64 = function (b64) {
var bin = atob(b64);
var bytes = new Uint8Array(bin.length);
for (var i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
term.write(bytes);
};

window.termReset = function () { term.reset(); };
window.termSetTheme = applyTheme;
window.termFocus = function () { term.focus(); };
window.termFit = notifyResize;

setTimeout(function () {
notifyResize();
if (window.Android && Android.onReady) Android.onReady();
}, 120);
})();
</script>
</body>
</html>
Loading
Loading