Files
doubao-clone/scripts/gitea.mjs
l f056bcf45a 豆包复刻:原生安卓(Compose + 内嵌 Termux)+ Web / Windows
一个界面照着豆包抠的 AI 助手。主力是安卓端,完全离线自主:不依赖电脑、
不需要另外装 Termux。

安卓端
- 原生 Jetpack Compose,7 个页面,配色/圆角/间距对着真机截图量出来的
- 完整动效:抽屉滑入、页面切换、气泡淡入上移、面板底部升起、typing 三点、按钮回弹
- 内置 Termux:bash/apt/pkg 388 个命令、真 pty 终端;
  pty 不可用的 ROM 上自动降级成命令控制台
- APK 内嵌 CPython 3.13(Chaquopy),AI 内核跑在手机上
- 设备能力:定位 / 陀螺仪 / 加速度计 / 光线 / 电量 / 剪贴板
- 语音:朗读 + 语音输入,火山豆包音色 / OpenAI 兼容 / 设备自带三级引擎

AI 能力
- 10 家 OpenAI 兼容提供商:方舟 / OpenAI / DeepSeek / Kimi / 智谱 /
  通义 / 硅基流动 / OpenRouter / 本地 Ollama / 自定义
- 思考强度按各家支持情况发不同字段(thinking / reasoning_effort / 不发),
  认不出来的一律不发,避免给不支持的厂商发字段直接 400
- MCP 三种传输(http / stdio / inproc)、工具热加载、文件上传、权限模式

跨端
- 安卓走原生 Compose,Web / Windows 走 Lynx
- Node 与 Python 两份内核接口逐字段一致,关键路径都有对拍脚本

自检脚本(都不需要真 Key)
- verify-phone.mjs          设备端 24 项验收
- verify-speech.mjs         语音链路 31 项,两份内核各跑一遍
- parity-thinking.mjs       思考强度映射对拍
- probe-settings-wipe.mjs   设置防清空攻击测试
- mock-llm.mjs              假的 OpenAI + 火山语音服务

许可 MIT;第三方组件(Termux Apache-2.0、Chaquopy、Compose、LynxJS、Electron)
的授权见 LICENSE。
2026-10-09 14:09:36 +08:00

102 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Gitea 上的仓库操作(建仓 / 查仓 / 列出)。
*
* 凭据从环境变量读,不写进命令行参数也不落盘 —— 免得密码进 shell 历史或被提交。
* GIT_USER / GIT_PASS / GIT_HOST
*
* 用法:
* node scripts/gitea.mjs whoami
* node scripts/gitea.mjs list
* node scripts/gitea.mjs ensure <repoName> 建仓(已存在就复用)
*/
const HOST = process.env.GIT_HOST || 'https://git.xnhw.cc';
const USER = process.env.GIT_USER || '';
const PASS = process.env.GIT_PASS || '';
if (!USER || !PASS) {
console.error('缺少 GIT_USER / GIT_PASS 环境变量');
process.exit(2);
}
const auth = `Basic ${Buffer.from(`${USER}:${PASS}`).toString('base64')}`;
async function api(path, init = {}) {
const res = await fetch(`${HOST}/api/v1${path}`, {
...init,
headers: {
Authorization: auth,
'Content-Type': 'application/json',
...(init.headers || {}),
},
});
const text = await res.text();
let body;
try {
body = text ? JSON.parse(text) : {};
} catch {
body = { __raw: text.slice(0, 300) };
}
return { status: res.status, body };
}
const [cmd, arg] = process.argv.slice(2);
if (cmd === 'whoami') {
const r = await api('/user');
if (r.status !== 200) {
console.log('❌ 认证失败:HTTP', r.status, JSON.stringify(r.body).slice(0, 200));
process.exit(1);
}
console.log('✅ 认证通过');
console.log(' 用户名 :', r.body.login);
console.log(' 昵称 :', r.body.full_name || '(无)');
console.log(' 邮箱 :', r.body.email || '(隐藏)');
console.log(' 管理员 :', r.body.is_admin ? '是' : '否');
} else if (cmd === 'list') {
const r = await api(`/users/${encodeURIComponent(USER)}/repos?limit=50`);
if (r.status !== 200) {
console.log('❌ HTTP', r.status, JSON.stringify(r.body).slice(0, 200));
process.exit(1);
}
if (!r.body.length) {
console.log(` ${USER} 名下还没有仓库`);
} else {
console.log(` ${USER} 名下有 ${r.body.length} 个仓库:`);
for (const repo of r.body) {
console.log(` ${repo.full_name.padEnd(28)} ${repo.private ? '私有' : '公开'} ${repo.size ?? 0} KB ${repo.empty ? '(空)' : ''}`);
}
}
} else if (cmd === 'ensure') {
const name = arg;
if (!name) {
console.error('用法: ensure <repoName>');
process.exit(2);
}
const exists = await api(`/repos/${encodeURIComponent(USER)}/${encodeURIComponent(name)}`);
if (exists.status === 200) {
console.log(`✅ 仓库已存在:${exists.body.full_name}(${exists.body.private ? '私有' : '公开'},${exists.body.empty ? '空仓' : '有内容'})`);
console.log(` clone: ${exists.body.clone_url}`);
} else {
const created = await api('/user/repos', {
method: 'POST',
body: JSON.stringify({
name,
description: '豆包复刻 · 原生安卓(Compose + 内嵌 Termux)+ Web/Windows',
private: true,
auto_init: false,
default_branch: 'main',
}),
});
if (created.status === 201) {
console.log(`✅ 已创建:${created.body.full_name}(私有)`);
console.log(` clone: ${created.body.clone_url}`);
} else {
console.log('❌ 创建失败 HTTP', created.status, JSON.stringify(created.body).slice(0, 300));
process.exit(1);
}
}
} else {
console.error('用法: whoami | list | ensure <repoName>');
process.exit(2);
}