aifirstdev

module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0

README

aiFirstDev

English | 简体中文

v0.7.0 introduces the independent aifd-log entry point, local text logs, typed CSV Stat, and size/calendar-day rotation with recovery and retention. APIs may change incompatibly.

Read the v0.7.0 release notes before upgrading logging imports, handlers, Stat calls, or log consumers. Native HTTPS/WSS setup and limits are covered in v0.6.0, and earlier Mail migrations in v0.5.0. Documentation follows its source snapshot. Applications should use the documentation and rules for their pinned version.

This release requires Go 1.27.3 or newer. Frontend development uses Node.js 24.22.1 LTS or a newer 24.x release. The canonical repository is li9chuan/aifirstdev. The desktop example currently targets Windows amd64 and Wails 3 beta.34.

aiFirstDev is a lightweight backend framework for AI-first development. It is organized as one framework Go module with two separate example modules in the local workspace. The current runtime first covers game backend scenarios, while the framework language uses user/service runtime concepts. Business applications name their own backend services by domain, making the framework extensible to Wails tools, desktop applications, and other business backends.

Directories retain their responsibility, API, and dependency boundaries while sharing one framework version. Business projects continue to write feature code:

  • aifd-contracts: minimal shared contracts.
  • aifd-auth: signed tickets shared by the account center and proxy.
  • aifd-account: login identity, global account IDs, provider binding, and login payload/token issuance. Business user, owner, and realm mappings belong to the application.
  • aifd-client: Go client connections, login, message routing, and requests.
  • aifd-config: typed configuration bundle lifecycle, validation, manifest diff, and Luban bundle builder adapters.
  • aifd-llm: provider-neutral LLM request, response, stream, error, and adapter contracts.
  • aifd-log: local text logs, typed CSV Stat, and size/calendar-day rotation.
  • aifd-observe: observable events, optional logging adapters, async sinks, and bounded queries.
  • aifd-proxy: client gateway contracts, sessions, delivery, and adapters.
  • aifd-robot: integration test robots, run groups, behaviors, and statistics.
  • aifd-rpc: RPC contracts, routing, dispatchers, and adapters.
  • aifd-rdb: persistence saver primitives and storage adapters.
  • aifd-runtime: user/service runtime, user store, module lifecycle, and configuration/lifecycle helpers.
  • aifd-schema: proto/message descriptions, compatibility checks, and RPC binding.
  • aifd-tools: CLI, tool installation, and a reserved update command.
  • aifd-rules: AI rules, skills, templates, and checklists.
  • aifd-plugins/mail: optional mail storage, mailbox access, and runtime modules, explicitly composed by the application.
  • aifd-examples: business-shape examples. minigame demonstrates the full game backend framework flow, and desktool demonstrates a desktop tool.

Dependencies must remain one-way:

business projects
  -> aifd-runtime
       -> auth/account/client/config/observe/proxy/robot/rpc/rdb/schema
       -> aifd-log
  -> aifd-llm

infrastructure -> aifd-contracts / aifd-log (as needed)
aifd-log -> standard library + Lumberjack

aifd-config, aifd-llm, aifd-log, aifd-observe, aifd-proxy, aifd-robot, aifd-rpc, aifd-rdb, and aifd-schema do not understand player, world, feature, DBPlayer, concrete .proto files, real Luban tables, or business prompt policy. aifd-runtime provides service.Service and user.Runtime; game, player, world, and similar terms belong only to business examples, not to the framework public API.

The framework is still in a new-design stage. Framework APIs are intentionally allowed to converge through breaking changes toward the smallest business-facing surface. Experimental legacy interfaces do not keep compatibility wrappers. Complexity should move down into the framework layer, while business projects only touch the necessary business parameters and domain objects.

Module taxonomy and future aifd-core admission rules are described in docs/module-boundary.md. Scope runtime organization principles are described in docs/scope-runtime.md.

Documentation

The linked design documents and skills are currently written in Chinese.

Quick start

AI-first describes the development workflow: repository rules, skills, templates, and reproducible checks help AI agents work within module boundaries. Applications do not require an LLM at runtime; aifd-llm is optional.

Install Go 1.27.3 or later and Git, then start the in-memory backend example:

git clone https://github.com/li9chuan/aifirstdev.git
cd aifirstdev/aifd-examples/minigame
go run ./cmd/minigame

In a second terminal, from the same aifd-examples/minigame directory:

go run ./cmd/client -uid 1001 -counter-delta 1

On a fresh server the client prints auth ret=0 and counter value=1. This default example uses local RPC and memory storage; no Redis or NATS service is required. Stop the server with Ctrl+C. See minigame for split services and desktool for the desktop example. Desktop builds additionally need Node.js/npm and the pinned Wails CLI; Windows installer builds need NSIS.

Use from another Go project

From an initialized Go module outside this workspace, pin the whole framework. Use the unified framework version and its current package APIs:

go get github.com/li9chuan/aifirstdev@v0.7.0
go install github.com/li9chuan/aifirstdev/aifd-tools/cmd/aifd@v0.7.0

Framework packages, CLI, and official plugins share the root go.mod/go.sum and one root release tag. The two example modules isolate their build environments and verify consumption; they do not receive separate release tags. See the version and release policy.

aifd update is a reserved placeholder: it prints guidance but does not check, download, or apply updates. Third-party tool versions remain pinned in aifd.lock.

Build and verify

Use Go 1.27.3 or later, Node.js 24.22.1 or a newer 24.x release with npm, and PowerShell 5.1 or 7. Put go, node, and npm on PATH, then run from the repository root:

.\scripts\verify.ps1

If Windows PowerShell 5.1 blocks local scripts, run powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\verify.ps1. This sets the execution policy for that process only.

The script installs the locked frontend dependencies with npm ci, tests and builds both the desktool frontend and proxy Web client, then runs go test -mod=readonly -count=1 -timeout=2m ./... in the root module and both examples listed in go.work, with workspace mode disabled to test each declared dependency graph. Root-level go test ./... covers framework packages but excludes the two nested examples. The first run needs network access to download dependencies.

Desktool embeds frontend/dist in Go; build its frontend before running its Go tests. Frontend output and installer downloads are generated locally and are not versioned. Protobuf sources, generated bindings, and dependency lockfiles remain in the repository.

The two external NATS integration tests are skipped when AIFD_NATS_URL is unset. Set it to a reachable test NATS server to include them; the verification script does not start an external server. Native desktop execution and Windows installer builds are separate checks; see desktool. ACME/Pebble integration tests additionally require the integration build tag and AIFD_PEBBLE_BIN; the default script does not run them. See HTTPS verification. Mail's real Redis tests use AIFD_REDIS_SERVER or a redis-server executable on PATH, and otherwise skip by default. Set AIFD_MAIL_REDIS_REQUIRED=1 to make a missing dependency fail; see Mail verification.

License

Copyright 2026 aiFirstDev contributors. Licensed under Apache-2.0. Third-party components retain their own licenses; the desktop packaging assets and templates have third-party notices.

Directories

Path Synopsis
aifd-auth module
Package client provides a protobuf-first client-side Call/On facade.
Package client provides a protobuf-first client-side Call/On facade.
adapters/proxyws
Package proxyws 提供连接真实 aifd-proxy gateway 的客户端 WebSocket transport。
Package proxyws 提供连接真实 aifd-proxy gateway 的客户端 WebSocket transport。
aifd-config module
adapters/viper
Package viper provides an optional Viper-backed typed config loader.
Package viper provides an optional Viper-backed typed config loader.
examples
Package examples 包含不依赖真实业务表的干净配置工作流示例。
Package examples 包含不依赖真实业务表的干净配置工作流示例。
tools/luban
Package luban 预留给 Luban 生成包装器和配置工作流命令;这里有意不承载真实业务表。
Package luban 预留给 Luban 生成包装器和配置工作流命令;这里有意不承载真实业务表。
aifd-examples
native-https command
Command native-https demonstrates one native HTTP/HTTPS/WSS endpoint.
Command native-https demonstrates one native HTTP/HTTPS/WSS endpoint.
Package llm defines provider-neutral contracts for calling large language model APIs from backend services and desktop Go bindings.
Package llm defines provider-neutral contracts for calling large language model APIs from backend services and desktop Go bindings.
adapters/anthropic
Package anthropic provides an adapter for Anthropic's Messages API.
Package anthropic provides an adapter for Anthropic's Messages API.
adapters/deepseek
Package deepseek provides an adapter for DeepSeek's OpenAI-compatible API.
Package deepseek provides an adapter for DeepSeek's OpenAI-compatible API.
adapters/fake
Package fake provides an in-memory llm.Client for tests and local development.
Package fake provides an in-memory llm.Client for tests and local development.
adapters/internal/chatcompat
Package chatcompat implements OpenAI-compatible chat completions adapters.
Package chatcompat implements OpenAI-compatible chat completions adapters.
adapters/openai
Package openai provides an adapter for OpenAI-compatible chat completions.
Package openai provides an adapter for OpenAI-compatible chat completions.
internal/lumberjack
Package lumberjack is an internal copy of Lumberjack v2.2.1 with a terminal Close that stops its cleanup worker.
Package lumberjack is an internal copy of Lumberjack v2.2.1 with a terminal Close that stops its cleanup worker.
aifd-observe module
aifd-plugins
mail
Package mail defines the public surface shared by the optional mail plugin modules.
Package mail defines the public surface shared by the optional mail plugin modules.
mail/internal/id
Package id contains mail-plugin-local ID generation implementations.
Package id contains mail-plugin-local ID generation implementations.
mail/internal/redistest
Package redistest starts process-owned Redis instances for mail integration tests.
Package redistest starts process-owned Redis instances for mail integration tests.
mail/mailbox
Package mailbox owns the mail service's canonical in-memory state.
Package mailbox owns the mail service's canonical in-memory state.
mail/service
Package service is the sole owner of personal and shared mail state.
Package service is the sole owner of personal and shared mail state.
mail/user
Package user authenticates mailbox clients and forwards trusted requests to the sole mail owner.
Package user authenticates mailbox clients and forwards trusted requests to the sole mail owner.
aifd-proxy module
adapters/httpserver
Package httpserver provides an explicitly started HTTP/HTTPS listener with optional, persistent ACME certificate management.
Package httpserver provides an explicitly started HTTP/HTTPS listener with optional, persistent ACME certificate management.
adapters/tcp
Package tcp 预留给 TCP 客户端连接。
Package tcp 预留给 TCP 客户端连接。
adapters/websocket
Package websocket 提供客户端 websocket 连接 adapter。
Package websocket 提供客户端 websocket 连接 adapter。
aifd-robot module
examples
Package examples 预留给不依赖私有业务代码的小型 robot 示例。
Package examples 预留给不依赖私有业务代码的小型 robot 示例。
Package rpc 提供面向业务 feature 的 protobuf RPC 门面。
Package rpc 提供面向业务 feature 的 protobuf RPC 门面。
adapters/nats
Package nats 实现 NATS request/reply 和 JetStream adapter。
Package nats 实现 NATS request/reply 和 JetStream adapter。
adapters/websocket
Package websocket 预留给 websocket 客户端 transport。
Package websocket 预留给 websocket 客户端 transport。
rpcpb
Package rpcpb 保留旧业务门面路径的兼容别名。
Package rpcpb 保留旧业务门面路径的兼容别名。
aifd-runtime module
aifd-schema module
examples
Package examples 包含干净的 schema 工作流示例,不包含真实业务协议定义。
Package examples 包含干净的 schema 工作流示例,不包含真实业务协议定义。
tools/protoc
Package protoc 预留给 protoc 包装辅助和生成 schema 检查;这里不承载项目专属 proto 文件。
Package protoc 预留给 protoc 包装辅助和生成 schema 检查;这里不承载项目专属 proto 文件。
aifd-tools module
cmd/aifd command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL