-
Notifications
You must be signed in to change notification settings - Fork 0
hyp context.md
maoxiaoyue edited this page May 14, 2026
·
2 revisions
生成機器可讀的專案描述(YAML/JSON),讓 AI 用最少 token 掌握專案全貌。
hyp context # YAML 到 stdout hyp context -f json # JSON 格式 hyp context -o .hyp/manifest.yaml # 儲存到檔案 hyp context -o manifest.json -f json # JSON 儲存到檔案
| Flag | 說明 | 預設值 |
|---|---|---|
-o, --output |
輸出檔案路徑 | stdout |
-f, --format |
輸出格式:yaml 或 json
|
yaml |
version: "1.0" framework: HypGo generated_at: "2026年04月03日T14:30:00+08:00" server: addr: ":8080" protocol: http2 tls: true routes: - method: POST path: /api/users handler_names: [controllers.CreateUser] summary: "Create user" tags: [users] input_type: CreateUserReq output_type: UserResp responses: 201: "User created" database: driver: postgres has_replicas: true
| 時機 | 原因 |
|---|---|
| 專案建立後 | 產出初始 manifest |
| 新增/修改 Schema 路由後 | 更新路由資訊 |
執行 hyp ai-rules 前 |
讓 AI 配置檔包含路由表 |
Server.Start() 啟動時會自動呼叫 autosync.SyncSafe(),將 manifest 寫入 .hyp/context.yaml。手動執行 hyp context 適合在開發時預覽或指定不同格式。
| 場景 | 傳統框架 | HypGo Manifest |
|---|---|---|
| AI 理解 API 結構 | 讀 handler 原始碼(~5,000 tokens) | 讀 manifest(~500 tokens) |
Manifest 不包含:密碼、DSN、token、API key。只包含路由路徑、型別名稱、server 設定。
v0.8.5+--llmflag 為 v0.8.5 新增功能,v0.8.1 不支援。
# 指定 LLM 配置檔(自動偵測 config/llm.yaml 或 .hyp/llm.yaml) hyp context --llm config/llm.yaml # 結合其他選項 hyp context --llm config/llm.yaml -o .hyp/manifest.yaml
啟用後,Manifest 的 Summary、Tags 等欄位會由 LLM 自動補齊(Ollama / OpenAI / RAG 三種模式)。詳見 manifest.md。
- hyp ai-rules — 讀取 manifest 並注入 AI 配置檔
- hyp generate — 生成程式碼(Schema 路由會出現在 manifest 中)
設計文件
套件
- config — 設定
- context — 請求上下文
- router — 路由器
- server — 伺服器
- middleware — 中介層
- websocket — WebSocket
- hidb — 資料庫 ORM
- hidb/cassandra — Cassandra
- logger — 日誌
- json — JSON 處理
- grpc — gRPC
AI 協作工具鏈
- schema — Schema-first 路由
- manifest — 專案 Manifest
- contract — Contract Testing
- errors — Typed Error Catalog
- migrate — Migration Diff
- scaffold — 智慧 Scaffold
- airules — AI Rules
CLI 命令
- hyp 總覽
- hyp new
- hyp api
- hyp run
- hyp restart
- hyp generate
- hyp migrate
- hyp context
- hyp ai-rules
- hyp chkcomment
- hyp impact
- hyp docker
- hyp health
- hyp version
- hyp difflog
Design Docs
Packages
- config — Configuration
- context — Request Context
- router — Router
- server — Server
- middleware — Middleware
- websocket — WebSocket
- hidb — Database ORM
- hidb/cassandra - Cassandra 5.0
- logger — Logger
- json — JSON
- grpc — gRPC
AI Collaboration Toolchain
- schema — Schema-first Routing
- manifest — Project Manifest
- contract — Contract Testing
- errors — Typed Error Catalog
- migrate — Migration Diff
- scaffold — Smart Scaffold
- airules — AI Rules
CLI Commands