CANN / cannbot-skills 代理文档

📅 2026/7/5 18:34:00 👁️ 阅读次数 📝 编程学习
CANN / cannbot-skills 代理文档

AGENTS.md — cannbot-insight

【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

Project

CANNBot-Insight: Session-level observability tool for LLM coding agents (opencode). Next.js 16 App Router + Prisma + SQLite. Chinese/English mixed UI. UI version tracked insrc/lib/version.ts(v0.31) —package.jsonversion (0.02) is not the display version.

CLI Frontend (New - 2026-06)

Adding a CLI frontend alongside the existing web UI. Backend remains unchanged; CLI is a pure API client.

Tech Stack

  • Ink 7.0.6+ React 19.2.7 (ESM required:"type": "module"in package.json)
  • Commander.jsfor command parsing
  • string-width+cli-truncatefor CJK character width handling
  • Run withtsx(not ts-node) due to yoga-layout top-level await

Key Decisions (PoC Verified)

  • No third-party Ink components— ink-table/ink-select/ink-spinner all incompatible with Ink v7
  • Self-implement all components: DataTable, Spinner (10 lines), TextInput (30 lines)
  • Dual render strategy: ink-testing-library for tests (has lastFrame), Ink native render for production
  • stdin handling:resume() + setRawMode(true)before Ink render, restore on exit
  • Pagination over virtual scroll: pageSize=20, n/p keys (Ink re-renders full tree anyway)
  • CLI types useApiprefix(ApiSessionListItem) to distinguish from shared types

Architecture

src/cli/ ├── index.ts # Commander entry point ├── client.ts # API client (15 endpoints) ├── types.ts # Api-prefixed response types ├── errors.ts # Error hierarchy ├── config.ts # Config management ├── commands/ # CLI commands (sessions, session, turn, search, compare, stats, import, delete, config) ├── hooks/ # useApi, useKeyboard, useNavigation, useTable ├── utils/ # format, colors, table (with padEndVisual/truncateVisual) └── tui/ ├── App.tsx # Root component (stdin switching, useMemo client) ├── screens/ # SessionList, SessionDetail, TurnDetail, CompareView, ImportPanel ├── tabs/ # OverviewTab, TurnsTab, WorkflowTab, SubagentsTab, SkillsTab, BridgesTab, ContextTab └── components/ # StatusBar, KeyBar, DataTable, MetricCards, AsciiBar, TreeView, TabBar, Spinner, TextInput

Dev Commands (CLI)

CommandNotes
npx tsx src/cli/index.ts tuiLaunch TUI mode (requires real TTY)
npx tsx src/cli/index.ts sessionsList sessions (command mode)
npx tsx src/cli/index.ts statsGlobal statistics
npm run test:cliCLI tests (uses ink-testing-library)

CLI Constraints

  • Ink v7 native render() has no lastFrame/frames/output— only ink-testing-library provides these
  • ESM strict: Cannot use require(), must use import
  • CJ width: Chinese characters = 2 columns, use string-width for all text measurement
  • No PTY in tests: TUI E2E tests only run manually, CI runs component tests only
  • Version: Import from@/lib/version, never hardcode

Dev Commands

CommandNotes
./start.shAuto port (21025+), kills existing dev server via.next/dev/lockPID, runsprisma migrate dev+next dev
./start.sh -uSame but also runsnpm installfirst
npm run devRuns on default port 3000 — prefer./start.shinstead
npm run buildStandardnext build
npm run testvitest run— 187 tests (web)
npm run test:cliCLI frontend tests
npm run linteslint(flat config,eslint.config.mjs) — run after edits to verify

Architecture

Data Flow

opencode sessions.db (external) → better-sqlite3 read → opencode-db adapter → normalize → turn-split → bridge-builder → execution-split → merge → contenteditable="false">【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考