持久化常驻复用现有 hose-aipro service start(detached + pid 文件、
127.0.0.1:8889),本次只补前端与数据出口,不做端口/K8s 化改造。
是否映射公网由使用者自行决定,工具仍只监听回环地址。
- web/:Vue 3.5 + Vite 6 + TS + vue-router + Tailwind 3 子工程,配置对齐
本机 twc-approval-go-bridge/web(base /static/、outDir 到后端内嵌目录、
dev proxy → 8889、hash 路由)。5 个视图:总览、审批会话、规则与要点、
审计流水、命令终端;统一经 POST /api/cli 调用现有 CLI 能力。
- scripts/build/build-webui.mjs:把 Vite 产物 JS/CSS 内联成单文件 HTML,
生成 src/packaging/generated/webui.txt。生成物随 git 提交,编译二进制
与 CI 不需要安装前端依赖;.webui-dist/ 为忽略的中间产物。
- src/packaging/embedded-webui.ts:with { type: text } 内嵌。用 .txt 后缀
而非 .html,避开 Bun 对 .html 的 HTMLBundle 类型推断导致 tsc 报错。
- src/http/routes.ts:AI Pro daemon 暴露 GET /report(含 /report/* 兜底);
server.ts 启动日志补控制台地址;hose-use daemon 不暴露该路由。
- src/cli/commands/aipro/report.ts:新增 report --json 聚合命令,一次返回
场景/规则/会话/要点/流水/授权状态;单据快照等大字段不下发,避免撑爆
浏览器。命令在统一门禁之后,未激活仍会被拦截。
- 新增 embedded-webui / webui 路由 / report 聚合三组测试;同步
SKILL.md、README.md、packaging README、.gitignore 与 package.json 脚本。
校验:bun test 1108 pass / 0 fail,bun run check、check:readme 全通过;
编译二进制实测 GET /report 返回 200 且资源全内联(140KB、零外链),
POST /api/cli report --json 返回真实聚合数据(2 场景/3 规则/45 条流水)。
本次不打 tag、不发版,留待 0.9.4。
58 lines
2.1 KiB
Vue
58 lines
2.1 KiB
Vue
<script setup lang="ts">
|
||
import { ref } from 'vue'
|
||
import { Play, RotateCcw } from 'lucide-vue-next'
|
||
import { runCommand } from '../api/client'
|
||
|
||
const command = ref('status --json')
|
||
const output = ref('')
|
||
const error = ref('')
|
||
const busy = ref(false)
|
||
|
||
const presets = ['status --json', 'report --json', 'version --json', 'scopes --json', 'rules --json', 'logs --json --limit=20', 'help --json']
|
||
|
||
async function execute() {
|
||
if (!command.value.trim()) return
|
||
busy.value = true
|
||
error.value = ''
|
||
try {
|
||
const result = await runCommand<unknown>(command.value.trim())
|
||
output.value = typeof result === 'string' ? result : JSON.stringify(result, null, 2)
|
||
} catch (err) {
|
||
error.value = err instanceof Error ? err.message : String(err)
|
||
output.value = ''
|
||
} finally {
|
||
busy.value = false
|
||
}
|
||
}
|
||
|
||
function reset() {
|
||
command.value = ''
|
||
output.value = ''
|
||
error.value = ''
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="p-7 space-y-5 max-w-5xl">
|
||
<header>
|
||
<h1 class="text-xl font-semibold">命令终端</h1>
|
||
<p class="text-sm text-text-muted mt-1">直接调用本地 CLI 网关,覆盖 AI PRO 全部命令能力</p>
|
||
</header>
|
||
|
||
<div class="card space-y-3">
|
||
<label class="label">命令(不需要 hose-aipro 前缀,默认追加 --json 由命令自行决定)</label>
|
||
<div class="flex gap-2">
|
||
<input v-model="command" class="input font-mono" placeholder="status --json" @keydown.enter="execute" />
|
||
<button class="btn-primary" :disabled="busy" @click="execute"><Play :size="15" />执行</button>
|
||
<button class="btn-ghost" @click="reset"><RotateCcw :size="15" /></button>
|
||
</div>
|
||
<div class="flex flex-wrap gap-1.5">
|
||
<button v-for="preset in presets" :key="preset" class="tag bg-bg border border-border text-text-muted hover:text-accent" @click="command = preset">{{ preset }}</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
|
||
<pre v-if="output" class="card bg-[#0f172a] text-[#e2e8f0] text-xs overflow-auto max-h-[60vh] whitespace-pre-wrap">{{ output }}</pre>
|
||
</div>
|
||
</template>
|