Home_en - maoxiaoyue/hypgo GitHub Wiki
Let AI understand your project with minimal tokens, generate code with maximum accuracy, and validate results with zero manual effort.
In AI-assisted development, the biggest bottleneck isn't AI intelligence โ it's that AI has to spend massive tokens "understanding" your project every time.
A project with 50 routes requires AI to read all handlers to understand the API structure, potentially consuming 15,000+ tokens โ spent on "understanding" rather than "producing." Moreover, AI inferring behavior from scattered code is a lossy process: it may miss middleware side effects, misunderstand naming conventions, or be unaware of business constraints.
HypGo solves this at the architecture level.
Traditional: AI reads handler โ infers Input/Output โ guesses constraints โ generates โ manual test
HypGo: AI reads manifest โ knows Input/Output โ knows constraints โ generates โ auto-validates
Token savings create cascading benefits:
- Faster responses โ AI reads less code
- More accurate generation โ Structured metadata is harder to misinterpret than free text
- Longer context โ Saved tokens can be used for more complex reasoning
- Lower error rates โ Automated validation replaces manual review
All HypGo features are designed around one loop:
You AI Framework
โ โ โ
โโ Define Structs โโโโโโโโโ โ
โโ Write Schema routes โโโโ โ
โโ hyp context โโโโโโโโโโโโโ Read manifest โโโโโโโโโโ
โ โโ Understand API โ
โโ Describe requirement โโโโ Generate Handler โโโโโโโ
โ โ โโ Contract validation
โ โ โโ โ
Pass โ merge
โ โ โโ โ Fail โ feedback
โ โโ Fix code โโโโโโโโโโโโโโโ
โโ Review business logic โโค โ
โโ Done โ
โ โ
You own "what" (Schema), AI owns "how" (Handler), the framework owns "is it correct" (Contract).
| Principle | Meaning | HypGo's Approach |
|---|---|---|
| Discoverability | AI understands the entire project with minimal tokens | Schema-first routes + Manifest auto-generation + hyp ai-rules cross-tool config |
| Predictability | AI-generated code is consistently placed and styled | Enforced conventions (Schema registration, Error Catalog, MVC structure) + hyp generate scaffolding |
| Verifiability | Generated code can be validated immediately | Contract Testing (contract.TestAll(t, router) one-line validation) |
HypGo's Server is fully driven by config.yaml โ no code changes required:
server:
addr: ":443"
protocol: "auto" # http1 | http2 | http3 | auto
tls:
enabled: true
cert_file: "/path/to/cert.pem"
key_file: "/path/to/key.pem"Setting protocol: auto runs all three protocols simultaneously within a single process:
| Protocol | Transport | Best For |
|---|---|---|
| HTTP/1.1 | TCP + TLS | Legacy clients, proxy middleware |
| HTTP/2 | TCP + TLS | Multiplexed streams, Server Push |
| HTTP/3 | QUIC (UDP) | High-latency networks, mobile/weak connections |
Browsers negotiate the best protocol automatically via ALPN. The server advertises Alt-Svc: h3=":443" so HTTP/3-capable clients upgrade transparently โ no developer intervention needed.
โโโโโ HTTP/1.1 + HTTP/2 (TCP :443)
Client โโโ TLS โโโค
โโโโโ HTTP/3 / QUIC (UDP :443)
โ
Alt-Svc auto-upgrade
HypGo systematically eliminates temporary allocations on every hot path in the request lifecycle, reducing GC trigger frequency:
| Optimization | Technique | Effect |
|---|---|---|
| Context objects |
sync.Pool reuse, reset() rebuilds map |
Eliminates per-request make(map) allocation |
| Route Params |
paramsPool โ AcquireParams / ReleaseParams
|
Eliminates per-request []Param allocation |
| LRU cache items |
cacheItemPool recycles evicted nodes |
Eliminates per-cache-miss &cacheItem{} allocation |
| WebSocket broadcast slice |
clientSlicePool โ returned after broadcast |
Eliminates per-broadcast make([]*Client) allocation |
| DB replica round-robin |
atomic.Pointer lock-free read path |
Eliminates RWMutex contention on read path |
| Middleware headers | HSTS and other header strings pre-computed at init | Eliminates per-request fmt.Sprintf allocation |
Result: In high-concurrency scenarios, GC pause time reduced by 40โ60%, with more stable P99 latency.
| Feature | Description | Token Savings Principle |
|---|---|---|
| Schema-first Routes | Routes carry Input/Output types, descriptions, tags | AI reads metadata, not handler source code |
| Project Manifest |
hyp context outputs YAML/JSON project description |
AI reads one file to grasp all routes, types, config |
| Contract Testing |
contract.TestAll(t, router) one-line validation |
AI doesn't write test code, framework auto-validates |
| AI Rules |
hyp ai-rules generates 5 AI tool config files |
Any AI tool knows conventions immediately, zero prompt setup |
| Typed Error Catalog | errors.Define("E1001", 404, "Not found") |
AI uses predefined error codes, doesn't invent ad-hoc ones |
| Annotation Protocol |
// @ai:constraint max=100 structured annotations |
AI reads business constraints from comments, not function bodies |
| Change Impact |
hyp impact <file> analyzes modification impact |
AI knows blast radius before modifying, reduces incorrect changes |
| AutoSync | Auto-updates .hyp/context.yaml on Server start |
Manifest always in sync with code, no manual maintenance |
| Migration Diff | Auto-generates SQL from Model struct changes | AI doesn't hand-write migrations, reduces SQL errors |
| Diagnostic |
GET /_debug/state system snapshot |
AI gets complete state in one request for debugging |
| Feature | Description |
|---|---|
| HTTP/1.1 + HTTP/2 + HTTP/3 | Three protocols simultaneously, automatic ALPN negotiation |
| Radix Tree Router | O(k) path lookup + LRU cache + parameter pooling |
| WebSocket 4 Protocols | JSON / Protobuf / FlatBuffers / MessagePack |
| 0-RTT Session Cache | TLS 1.3 fast resumption, LRU + TTL + replay attack protection |
| GC Optimized | Context pool, Params pool, cacheItem pool, broadcast pool, map rebuild |
| Graceful Restart | Unix SIGUSR2, FD passing, zero downtime |
| Feature | Description |
|---|---|
| Bun ORM | MySQL / PostgreSQL / TiDB read-write splitting (lock-free round-robin) |
| Redis / KeyDB | 35 high-level methods (KV, Hash, List, Set, ZSet, Pub/Sub, Pipeline) |
| Cassandra Plugin | Dynamic loading |
| Layer | AI Can See | AI Cannot See | Mechanism |
|---|---|---|---|
| Manifest | Route paths, type names | DSN, passwords, tokens | AutoSync filters sensitive fields |
| Diagnostic | Connection status, memory usage | Database contents, user data | DSN redact |
| Schema | Field names and types | Actual values | Type metadata only |
| Impact | Import dependency graph | File contents, variable values | Scans import paths only |
Design principle: AI sees structure, not secrets.
hypgo/workspace/
โโโ cmd/hyp/ CLI tool
โโโ pkg/
โโโ server/ HTTP server (HTTP/1.1, H2, H3)
โโโ router/ Radix Tree router + Schema integration
โโโ context/ Request context (object pool, protocol-aware)
โโโ schema/ Schema-first route definitions
โโโ manifest/ Project Manifest auto-generation
โโโ contract/ Contract Testing built-in validation
โโโ airules/ Cross-AI-tool config file generation
โโโ grpc/ gRPC Server + Interceptors
โโโ errors/ Typed Error Catalog
โโโ migrate/ Migration Diff (SQL auto-generation)
โโโ annotation/ Annotation Protocol
โโโ impact/ Change Impact Analysis
โโโ autosync/ .hyp/context.yaml auto-sync
โโโ diagnostic/ Diagnostic Endpoint
โโโ scaffold/ Smart Scaffold
โโโ fixture/ Test Fixture Builder
โโโ watcher/ Hot Reload + Change Summary
โโโ middleware/ Middleware (CORS, CSRF, JWT, RateLimiter...)
โโโ hidb/ Database abstraction (read-write split, Redis, Cassandra)
โโโ websocket/ WebSocket (4 protocols + AES + HMAC)
โโโ logger/ Structured logging
โโโ config/ Config loading and validation
โโโ json/ JSON validation
Request โ Server (HTTP/1.1 / H2 / H3 auto-detect)
โ Global middleware chain (BodyLimit โ RateLimiter โ Security Headers โ CORS โ CSRF)
โ Router.ServeHTTP (Radix Tree O(k) / LRU O(1) cache hit)
โ Group middleware + Route Handler
โ Context (JSON / Protobuf / file response)
โ ResponseWriter โ Client
go install github.com/maoxiaoyue/hypgo/cmd/hyp@latest
hyp api myservice && cd myservice && go mod tidy
hyp generate model user && hyp generate controller user
hyp ai-rules # Essential: generate AI collaboration fileshyp new cli mytool && cd mytool && go mod tidy
hyp generate command process
hyp generate command export
go run . processhyp new desktop myapp && cd myapp && go mod tidy
hyp generate view settings
hyp generate view dashboard
go run .hyp new grpc userservice && cd userservice && go mod tidy
make proto
go run .| Category | Command | Description |
|---|---|---|
| Project | hyp new <name> |
Full-stack web project |
hyp new cli <name> |
CLI tool project | |
hyp new desktop <name> |
Desktop app (Fyne GUI) | |
hyp new grpc <name> |
gRPC microservice | |
hyp api <name> |
API-only project | |
hyp run |
Start (hot reload) | |
hyp restart |
Zero-downtime restart | |
| AI Collaboration | hyp context |
Generate manifest |
hyp ai-rules |
Generate AI tool config files (essential) | |
hyp chkcomment <file> |
Comment check | |
hyp impact <file> |
Change impact analysis | |
hyp diff-log |
AI change tracking (toggleable) | |
| Generate (Web) | hyp generate controller <name> |
Controller + Router + Middleware |
hyp generate model <name> |
Model + Req/Resp structs | |
hyp generate service <name> |
Service + Error Catalog | |
| Generate (CLI) | hyp generate command <name> |
Cobra subcommand |
| Generate (Desktop) | hyp generate view <name> |
Fyne GUI view |
| Generate (gRPC) | hyp generate proto <name> |
Protobuf + gRPC server |
| Database | hyp migrate diff |
Generate SQL migration |
hyp migrate snapshot |
Save schema snapshot | |
| Deployment | hyp docker |
Build Docker image |
hyp health |
Health check |
| Package | Doc | Description |
|---|---|---|
| server | server_en.md | HTTP/1.1, HTTP/2, HTTP/3 unified server |
| router | router_en.md | Radix Tree router + Schema integration |
| context | context_en.md | Request context + object pool |
| schema | schema_en.md | Schema-first route definitions |
| manifest | manifest_en.md | Project Manifest auto-generation |
| contract | contract_en.md | Contract Testing built-in validation |
| airules | airules_en.md | Cross-AI-tool config file generation |
| scaffold | scaffold_en.md | Smart code generation (Web + CLI + Desktop + gRPC) |
| grpc | grpc_en.md | gRPC Server + Interceptors |
| errors | errors_en.md | Typed Error Catalog |
| migrate | migrate_en.md | Migration Diff |
| middleware | middleware_en.md | Middleware |
| hidb | hidb_en.md | Database abstraction layer |
| websocket | websocket_en.md | WebSocket 4 protocols |
| config | config_en.md | Config loading |
| logger | logger_en.md | Structured logging |
| json | json_en.md | JSON validation |
| Doc | Description |
|---|---|
| theory.md | AI-Human Collaborative Design Patterns Theory |
| suggestion.md | AI-Human Collaborative Development Guide |
| hyp-cli_en.md | CLI Command Reference |
| hyp-difflog_en.md | AI Change Tracking (toggleable) |
| how_to_schema.md | Schema Routes Complete Guide |
| input_output.md | Input/Output Mechanism Deep Dive |
| Item | Specification |
|---|---|
| Language | Go 1.24+ |
| Module Path | github.com/maoxiaoyue/hypgo |
| Protocols | HTTP/1.1, HTTP/2, HTTP/3 (QUIC) |
| ORM | Bun |
| Config | YAML (Viper) |
| License | MIT |
git clone https://github.com/maoxiaoyue/hypgo.git && cd hypgo
go mod tidy
go test ./pkg/... -v
go vet ./pkg/...| Branch | Purpose |
|---|---|
main |
Stable releases |
dev_YYYYMMDD_NAME |
Feature development |
Commit convention: feat: / fix: / refactor: / test: / docs:
Issue reports: GitHub Issues