feat: 品牌替换 + 启动优化 + AGENTS.md 模板定制
- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件) - Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃 - 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针 - dev 模式默认 --pure 跳过外部插件加载 - AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落 - architect prompt + plugin:强化 AGENTS.md 产出验证
This commit is contained in:
78
packages/opencode/test/session/session-schema.test.ts
Normal file
78
packages/opencode/test/session/session-schema.test.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { Schema } from "effect"
|
||||
import { ProjectV2 } from "@opencode-ai/core/project"
|
||||
import { MessageID, SessionID } from "../../src/session/schema"
|
||||
import { Session } from "../../src/session/session"
|
||||
|
||||
const info = {
|
||||
id: SessionID.descending(),
|
||||
slug: "test-session",
|
||||
projectID: ProjectV2.ID.global,
|
||||
workspaceID: undefined,
|
||||
directory: "/tmp/opencode",
|
||||
parentID: undefined,
|
||||
summary: undefined,
|
||||
cost: 0,
|
||||
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
||||
share: undefined,
|
||||
title: "Test session",
|
||||
version: "1.0.0",
|
||||
time: {
|
||||
created: 1,
|
||||
updated: 2,
|
||||
compacting: undefined,
|
||||
archived: undefined,
|
||||
},
|
||||
permission: undefined,
|
||||
revert: undefined,
|
||||
} satisfies Session.Info
|
||||
|
||||
describe("Session schema", () => {
|
||||
test("encodes undefined optional session fields as omitted keys", () => {
|
||||
const encoded = Schema.encodeUnknownSync(Session.Info)(info) as Record<string, unknown>
|
||||
|
||||
for (const key of ["workspaceID", "parentID", "summary", "share", "permission", "revert"]) {
|
||||
expect(Object.hasOwn(encoded, key)).toBe(false)
|
||||
}
|
||||
expect(Object.hasOwn(encoded.time as Record<string, unknown>, "compacting")).toBe(false)
|
||||
expect(Object.hasOwn(encoded.time as Record<string, unknown>, "archived")).toBe(false)
|
||||
expect(JSON.stringify(encoded)).not.toContain("parentID")
|
||||
})
|
||||
|
||||
test("encodes undefined optional global session project fields as omitted keys", () => {
|
||||
const encoded = Schema.encodeUnknownSync(Session.GlobalInfo)({
|
||||
...info,
|
||||
project: {
|
||||
id: ProjectV2.ID.global,
|
||||
name: undefined,
|
||||
worktree: "/tmp/opencode",
|
||||
},
|
||||
}) as Record<string, unknown>
|
||||
|
||||
expect(Object.hasOwn(encoded, "parentID")).toBe(false)
|
||||
expect(Object.hasOwn(encoded.project as Record<string, unknown>, "name")).toBe(false)
|
||||
})
|
||||
|
||||
test("encodes nested undefined optional session fields as omitted keys", () => {
|
||||
const encoded = Schema.encodeUnknownSync(Session.Info)({
|
||||
...info,
|
||||
summary: {
|
||||
additions: 1,
|
||||
deletions: 2,
|
||||
files: 3,
|
||||
diffs: undefined,
|
||||
},
|
||||
revert: {
|
||||
messageID: MessageID.ascending(),
|
||||
partID: undefined,
|
||||
snapshot: undefined,
|
||||
diff: undefined,
|
||||
},
|
||||
}) as Record<string, unknown>
|
||||
|
||||
expect(Object.hasOwn(encoded.summary as Record<string, unknown>, "diffs")).toBe(false)
|
||||
for (const key of ["partID", "snapshot", "diff"]) {
|
||||
expect(Object.hasOwn(encoded.revert as Record<string, unknown>, key)).toBe(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user