入门
owlmeans2026-10-25查看 235复制 658
启动一个协议优先的 OwlMeans 应用,包含共享契约、服务端入口点和浏览器入口点。
📘如何使用这个技能
- 1复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
- 2打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
- 3粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
- 4直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景
💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。
SKILL.md2224 chars
---
name: getting-started
description: Start a protocol-first OwlMeans application with shared contracts, server entrypoints and browser entrypoints.
metadata:
scope: general
---
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
# Protocol-first application shape
An OwlMeans application owns one shared protocol declaration and creates local entrypoints for each
runtime. The declaration is never modified by a server or browser.
```ts
// common/src/entrypoints.ts
export const sessionProtocols = {
list: protocol(
route(session.list, '/session', backend()),
contract.request({ query: typed<SessionQuery>(SessionQuerySchema) }, typed<Session[]>())
),
}
```
```ts
// api/src/entrypoints.ts
const api = handlers<Context>()
export const serverBindings = [
...frameworkEntrypoints,
bind(sessionProtocols.list, api.request(sessionProtocols.list, listSessions)),
]
```
```ts
// web/src/entrypoints.ts
export const clientBindings = [
...frameworkEntrypoints,
...bindAll(sessionProtocols),
]
const sessions = await context.entrypoint(sessionProtocols.list).call({ query: { sid } })
```
Use `schema<T>(...)` or `typed<T>(...)` at the contract boundary. Bind all route parents with their
children. Keep organization entity values on the wire as `entitySlug`; database relations use
`entityId` only.
## Configuration per runtime
The shared config in `common` (services, alias, security) is imported by both runtimes, so it
never reads `process.env` or `import.meta.env`, and it never sets `cfg.debug = { all: true }`.
Each runtime's own `config.ts` adds what depends on its environment — the log level above all
(`logging`, `log`), behind a type-only `import type {} from '@owlmeans/log'`:
```ts
// api/src/config.ts — Bun runtime env
cfg.log = { level: process.env.LOG_LEVEL || 'info', debug: process.env.LOG_DEBUG ?? '' }
// web/src/config.ts — Vite build-time env, typed in vite-env.d.ts
const env = import.meta.env
cfg.log = { level: env.VITE_LOG_LEVEL || (env.PROD ? 'info' : 'debug'), debug: env.VITE_LOG_DEBUG ?? '' }
```
The server and client contexts apply `cfg.log` themselves; application code logs through
`logger('<scope>')` from `@owlmeans/log`, never `console.*`.