Compare commits

...
Author SHA1 Message Date
weichen b6d428ba35 Add pinned and archived flags to Conversation
Why: the approved task-centric sidebar (proposal 2026-09-30, option A) needs
server-authoritative pin and archive state on conversations; client-side
storage would be fake state against the event-sourced model.

Evidence: go test ./... passes; omitempty keeps wire format and golden
samples byte-identical for zero values (backward compatible).

Impact: additive optional fields; consumers ignoring unknown fields are
unaffected (forward-compat principle). Backend consumes via submodule bump.

Refs: Agent-System-Documents docs/proposals/2026-09-30-ui-redesign-and-auth.md (P6/P8, R1)
2026-09-30 10:39:16 +00:00
weichen 1728c95eae Merge pull request 'feature/prompt-library' (#3) from feature/prompt-library into main 2026-09-30 10:36:34 +00:00
weichen 0cb0a40dc8 Add the prompt module contract and profile references
Why: prompts are moving from code into a data library; core needs the
PromptModule/Trigger/Block contract and profiles need an ordered
promptModules reference (empty = default base+env set).

Evidence: unit-covered via backend prompts package tests over this
contract; composite make test green.

Impact: additive contract fields only; no behavior change in core.

Refs: feature/prompt-library task card.
2026-09-30 10:28:59 +00:00
weichen a2050d848f Merge pull request 'Add activity card, card events, HITL anchoring and UI vocabulary extension' (#2) from feature/core-cards-commands-r1 into main 2026-09-30 06:22:01 +00:00
4 changed files with 98 additions and 0 deletions
+2
View File
@@ -31,6 +31,8 @@ type Conversation struct {
Owner ID `json:"owner,omitempty"` // 冗余自项目,查询过滤用
Title string `json:"title"`
ProfileID ID `json:"profileId,omitempty"` // 空为默认画像
Pinned bool `json:"pinned,omitempty"` // 侧栏置顶(方案 A P6/P8:本端组织偏好,服务端权威)
Archived bool `json:"archived,omitempty"` // 归档:列表默认隐藏,数据保留
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
+3
View File
@@ -11,6 +11,9 @@ type AgentProfile struct {
Builtin bool `json:"builtin,omitempty"`
Source string `json:"source,omitempty"` // builtin | plugin | user
SystemPrompt string `json:"systemPrompt"`
// PromptModules 引用提示词库模块 ID(有序;空 = 组装默认基座全集)。
// SystemPrompt 兼容保留:非空时作为附加段追加在模块组装结果之后。
PromptModules []string `json:"promptModules,omitempty"`
Model ModelRoute `json:"model"`
Tools ToolPolicy `json:"tools"`
Context ContextPolicy `json:"context"`
+71
View File
@@ -0,0 +1,71 @@
package core
// 提示词模块契约(prompt-library):提示词从代码移入数据,按层组装、按触发注入。
//
// 分层(Layer):
// - base 常驻基座块(身份/行为/谨慎/工具/风格),始终组装
// - env 动态环境段(占位符填充:日期/模型/附件清单)
// - task 任务技能(触发命中才注入;同层只注入优先级最高者)
// - agent 子代理/小队角色提示词(派生 run 时取用)
// - tool 工具描述文案(ToolDecl.description 的数据来源)
// - aux 辅助模板(压缩摘要/标题生成等;入库先行,接线随功能走)
// - style 输出风格(叠加在基座之上的表达方式变体)
type PromptModule struct {
ID string `json:"id"` // "base.identity" / "task.doc-minutes"
Layer string `json:"layer"` // base|env|task|agent|tool|aux|style
Version int `json:"version"` // 内置升级判定
Title string `json:"title"`
Description string `json:"description"` // 给人看(设置界面/命令菜单)
Priority int `json:"priority,omitempty"` // task 层多命中时的取舍;缺省 50,大者优先
Triggers []PromptTrigger `json:"triggers,omitempty"` // 空 = 基座,始终组装
RequiresAttachments bool `json:"requiresAttachments,omitempty"` // 命中还需本轮有附件
Body string `json:"body"` // 模板正文,{{placeholder}} 占位
OutputContract string `json:"outputContract,omitempty"` // 期望产出形态(注入模型 + 供验收)
Source string `json:"source,omitempty"` // builtin | plugin | user
Owner string `json:"owner,omitempty"`
BasedOnVersion int `json:"basedOnVersion,omitempty"` // 用户副本基于的内置版本
Drifted bool `json:"drifted,omitempty"` // 用户副本落后于当前内置版本(提示用,不阻断)
Disabled bool `json:"disabled,omitempty"` // 用户停用
}
// PromptTrigger 触发条件;模块命中 = 任一 trigger 命中(再过 RequiresAttachments)。
type PromptTrigger struct {
Kind string `json:"kind"` // intent | command | attachment | manual
Keywords []string `json:"keywords,omitempty"`
Command string `json:"command,omitempty"` // "/minutes"
}
// 触发 Kind 常量。
const (
TriggerIntent = "intent"
TriggerCommand = "command"
TriggerAttachment = "attachment"
TriggerManual = "manual"
)
// 层常量。
const (
LayerBase = "base"
LayerEnv = "env"
LayerTask = "task"
LayerAgent = "agent"
LayerTool = "tool"
LayerAux = "aux"
LayerStyle = "style"
)
// PromptBlock 组装产物:一个已解析占位符的 system 段。
type PromptBlock struct {
ModuleID string `json:"moduleId"`
Version int `json:"version"`
Layer string `json:"layer"`
Body string `json:"body"`
}
// PromptHitRecord 触发判定记录(可观测:哪个技能因何种原因注入/让位)。
type PromptHitRecord struct {
ModuleID string `json:"moduleId"`
Layer string `json:"layer"`
Reason string `json:"reason"` // "intent:纪要" / "command:/minutes" / "always" / "superseded-by:<id>"
Injected bool `json:"injected"`
}
+22
View File
@@ -13,6 +13,7 @@ export interface Project {
export interface Conversation {
id: ID; projectId: ID; owner?: ID; title: string; profileId?: ID;
pinned?: boolean; archived?: boolean;
createdAt: string; updatedAt: string;
}
@@ -191,11 +192,32 @@ export interface UIField {
options?: string[]; required?: boolean; placeholder?: string; help?: string; default?: string;
}
// ---- 提示词库(prompt-library)----
export interface PromptTrigger {
kind: 'intent' | 'command' | 'attachment' | 'manual';
keywords?: string[]; command?: string;
}
export interface PromptModule {
id: string; layer: 'base' | 'env' | 'task' | 'agent' | 'tool' | 'aux' | 'style';
version: number; title: string; description?: string; priority?: number;
triggers?: PromptTrigger[]; requiresAttachments?: boolean;
body: string; outputContract?: string;
source?: 'builtin' | 'plugin' | 'user'; owner?: string;
basedOnVersion?: number; drifted?: boolean; disabled?: boolean;
}
export interface PromptBlock { moduleId: string; version: number; layer: string; body: string; }
export interface PromptHitRecord { moduleId: string; layer: string; reason: string; injected: boolean; }
// ---- 画像 / 设置 ----
export interface AgentProfile {
id: string; owner?: string; name: string; description?: string; builtin?: boolean; source?: string;
systemPrompt: string;
/** 提示词库模块引用(有序;空 = 默认 base+env 全集)。 */
promptModules?: string[];
model: { chat?: string; lightweight?: string; embedding?: string; rerank?: string };
tools: { allow: string[]; deny?: string[]; confirm?: string[] };
context: {