@galaxycore/ai-chat 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ # 专利检索聊天原型复刻
2
+
3
+ 默认 `ChatPanel` 的颜色、字体、字重、圆角和间距来自已确认的交互原型。完整颜色和关键尺寸记录在 `docs/patent-visual-baseline.json`。浅色、深色均使用同一组语义 token,不依赖 Codex 宿主 CSS。
4
+
5
+ ## 查看实际组件
6
+
7
+ ```sh
8
+ npm run dev:playground
9
+ ```
10
+
11
+ 打开 `http://127.0.0.1:5178/patent.html`。该页面使用包里的真实 `ChatPanel`、`ChatComposer` 和 `ChatMessages`,可以确认术语、撤销、聚焦草稿和演示检索。模型及检索流程为本地演示,不连接专利库。
12
+
13
+ ## 直接接入
14
+
15
+ ```tsx
16
+ import { ListFilter, Search, ArrowRight, ScanSearch } from 'lucide-react';
17
+ import { ChatPanel, type ChatSuggestedAction } from '@galaxycore/ai-chat';
18
+ import '@galaxycore/ai-chat/styles.css';
19
+
20
+ const actions: ChatSuggestedAction[] = [
21
+ {
22
+ id: 'clarify', label: '明确术语含义', emphasis: 'recommended',
23
+ icon: <ListFilter />, trailingIcon: <ArrowRight />,
24
+ onSelect: () => setClarifying(true),
25
+ },
26
+ {
27
+ id: 'search', label: '按当前条件检索', pendingLabel: '正在检索…',
28
+ icon: <Search />, onSelect: () => searchWithCurrentConditions(),
29
+ },
30
+ { id: 'adjust', label: '继续调整条件', emphasis: 'quiet',
31
+ onSelect: ({ focusComposer }) => focusComposer() },
32
+ ];
33
+
34
+ <ChatPanel
35
+ chat={chat}
36
+ title="专利检索助手"
37
+ subtitle="把想法,变成清晰的检索条件"
38
+ headerIcon={<ScanSearch />}
39
+ labels={{ assistant: '检索助手' }}
40
+ suggestedActions={clarifying ? [] : actions}
41
+ suggestionsDescription="建议先确认术语,再开始检索"
42
+ renderMessageActions={clarifying ? () => <YourInlineClarification /> : undefined}
43
+ composerProps={{ context: <YourCurrentSearchTerms /> }}
44
+ />
45
+ ```
46
+
47
+ 示例中的 `chat`、`setClarifying`、`searchWithCurrentConditions` 和业务组件由宿主提供。不要把按钮标题当作自动发送的提示词;每个按钮显式调用自己的业务操作。完整可运行接法见 `examples/playground/src/patent-preview.tsx`。
48
+
49
+ ## 约定
50
+
51
+ - 建议仅出现在最后一条已完成的助手消息下;流式输出或最后一条为用户消息时不显示。
52
+ - 最多显示三个动作,最多一个强调推荐动作。异步执行时锁定同组动作,失败通过现有错误区域反馈。
53
+ - `focusComposer()` 只聚焦当前实例的输入框,保留已输入的草稿,不自动发送。
54
+ - 内联澄清区通过 `renderMessageActions` 接入;确认、撤销和检索条件由宿主业务状态控制。
55
+ - `renderMessageHeader` 可提供业务时间戳;默认只显示助手标识,不编造时间。返回 `null` 可隐藏。
56
+ - `header`、`composer`、`footer` 整体插槽仍有效;使用这些插槽时,宿主负责保持对应结构和样式。
57
+
58
+ ## 视觉基准
59
+
60
+ | 元素 | 基准 |
61
+ | --- | --- |
62
+ | 正文 | 14px / 400;正文段落行高 1.85 |
63
+ | 主标题 | 15px / 600;行高 1.5;字距 .02em |
64
+ | 助手名称 | 13px / 600 |
65
+ | 强调文本 | 600(显式锁定,避免浏览器默认 700) |
66
+ | 提示说明 | 12px / 400;标题 13px / 500 |
67
+ | 建议按钮 | 12px / 500;行高 1.45;8px 圆角 |
68
+ | 输入框 | 13px;窄屏与触屏为 16px;11px 圆角 |
69
+ | 图标 | 16 × 16px;1.6px 线宽 |
70
+ | 面板 | 16px 圆角;1px 边框;无装饰阴影 |
71
+
72
+ 原型外层的点阵背景和“交互原型”标签属于演示背景,不属于聊天组件。`variant`、`density`、主题和 CSS token 仍可显式覆盖;复刻验收使用默认 `comfortable` 密度,避免宿主全局字体、主题色或 `.gc-chat__*` 覆盖影响结果。系统字体在不同操作系统上的字形由系统决定;验收应固定设备、浏览器缩放、容器宽度和主题。
@@ -0,0 +1,121 @@
1
+ {
2
+ "baseline": "Approved in-conversation patent search prototype including inherited host typography and icon styles",
3
+ "sourceSha256": "b94b9c6c2e34a5069dd3d0979ee4fee27cc797e18a123c95b698e5150dd3855a",
4
+ "colors": {
5
+ "bg": {
6
+ "light": "#ffffff",
7
+ "dark": "#171b24"
8
+ },
9
+ "layer": {
10
+ "light": "#f7f8fb",
11
+ "dark": "#202632"
12
+ },
13
+ "ink": {
14
+ "light": "#253047",
15
+ "dark": "#e6ebf5"
16
+ },
17
+ "muted": {
18
+ "light": "#677287",
19
+ "dark": "#a4b0c5"
20
+ },
21
+ "line": {
22
+ "light": "#e8ecf3",
23
+ "dark": "#343e50"
24
+ },
25
+ "blue": {
26
+ "light": "#3157d5",
27
+ "dark": "#a2b6ff"
28
+ },
29
+ "blue-fill": {
30
+ "light": "#f0f4ff",
31
+ "dark": "#252f4d"
32
+ },
33
+ "blue-edge": {
34
+ "light": "#ced9ff",
35
+ "dark": "#50618f"
36
+ },
37
+ "solid": {
38
+ "light": "#365bd7",
39
+ "dark": "#a2b6ff"
40
+ },
41
+ "on-solid": {
42
+ "light": "#ffffff",
43
+ "dark": "#19213a"
44
+ },
45
+ "amber": {
46
+ "light": "#8b631c",
47
+ "dark": "#e9c078"
48
+ },
49
+ "amber-fill": {
50
+ "light": "#fff9ec",
51
+ "dark": "#322c22"
52
+ },
53
+ "green": {
54
+ "light": "#37745d",
55
+ "dark": "#8dc9ae"
56
+ },
57
+ "green-fill": {
58
+ "light": "#eff7f3",
59
+ "dark": "#22372e"
60
+ },
61
+ "red": {
62
+ "light": "#b44444",
63
+ "dark": "#ffabab"
64
+ },
65
+ "red-fill": {
66
+ "light": "#fff2f1",
67
+ "dark": "#3a272b"
68
+ }
69
+ },
70
+ "typography": {
71
+ "body": {
72
+ "fontSize": "14px",
73
+ "fontWeight": "400",
74
+ "lineHeight": "23.1px"
75
+ },
76
+ "title": {
77
+ "fontSize": "15px",
78
+ "fontWeight": "600",
79
+ "lineHeight": "22.5px",
80
+ "letterSpacing": "0.3px"
81
+ },
82
+ "assistant": {
83
+ "fontSize": "13px",
84
+ "fontWeight": "600"
85
+ },
86
+ "prose": {
87
+ "fontSize": "14px",
88
+ "fontWeight": "400",
89
+ "lineHeight": "25.9px"
90
+ },
91
+ "strong": {
92
+ "fontWeight": "600"
93
+ },
94
+ "suggestion": {
95
+ "fontSize": "12px",
96
+ "fontWeight": "500",
97
+ "lineHeight": "17.4px"
98
+ },
99
+ "input": {
100
+ "fontSize": "13px",
101
+ "lineHeight": "22.1px"
102
+ },
103
+ "inputNarrow": {
104
+ "fontSize": "16px",
105
+ "lineHeight": "27.2px"
106
+ }
107
+ },
108
+ "geometry": {
109
+ "panelRadius": "16px",
110
+ "noticeRadius": "9px",
111
+ "composerRadius": "11px",
112
+ "buttonRadius": "8px",
113
+ "buttonMinHeight": "39px",
114
+ "touchMinSize": "44px",
115
+ "sendSize": "31px",
116
+ "sendRadius": "7px",
117
+ "iconSize": "16px",
118
+ "iconStroke": "1.6px",
119
+ "narrowBreakpoint": "520px"
120
+ }
121
+ }
@@ -36,11 +36,11 @@ mkdir -p artifacts
36
36
  npm pack --pack-destination artifacts
37
37
 
38
38
  # 消费项目:替换为真实文件的绝对路径
39
- npm install /absolute/path/to/galaxycore-ai-chat-0.4.0.tgz
39
+ npm install /absolute/path/to/galaxycore-ai-chat-0.5.0.tgz
40
40
  npm install ai@^7.0.137 @ai-sdk/react@^4.0.140
41
41
  ```
42
42
 
43
- 消费项目需已有 React / React DOM。需要 Markdown 渲染时额外安装 `streamdown@^2.7.0`。发布后的版本号和 tarball 名称以实际产物为准。
43
+ 消费项目需已有 React / React DOM。Streamdown 随聊天包自动安装,助手回复默认启用 Markdown。发布后的版本号和 tarball 名称以实际产物为准。
44
44
 
45
45
  ## 发布前构建与验收
46
46
 
@@ -53,12 +53,12 @@ npm run check
53
53
  npm pack --dry-run
54
54
  mkdir -p artifacts
55
55
  npm pack --pack-destination artifacts
56
- tar -tzf artifacts/galaxycore-ai-chat-0.4.0.tgz
56
+ tar -tzf artifacts/galaxycore-ai-chat-0.5.0.tgz
57
57
  ```
58
58
 
59
59
  `check` 执行类型检查、组件与网关测试、库构建和可部署示例构建;示例构建包含文档站。`prepack` 构建库,`prepublishOnly` 执行完整检查。tarball 应包含公开 JS 入口、声明、CSS、README 和文档,不应包含模型凭据、认证配置或业务数据。
60
60
 
61
- 检查根入口及 `headless`、`markdown`、`ag-ui`、`context`、`gateway`、`appearance`、`voice`、`styles.css` 子入口。React 与 AI SDK 应保持 peer dependency,Markdown 保持可选入口。
61
+ 检查根入口及 `headless`、`markdown`、`ag-ui`、`context`、`gateway`、`appearance`、`voice`、`styles.css` 子入口。React 与 AI SDK 应保持 peer dependency,Markdown 默认启用并保留独立入口。
62
62
 
63
63
  在独立 Vite React 消费项目中安装 tarball,验证类型、样式、流式消息与停止;需要 Next.js 时另外验证客户端边界及 SSR 构建。不要只依赖仓库开发 alias 的演示结果。每次发布记录实际使用的 Node、React 和 AI SDK 版本,以及通过的消费测试,见 [验证记录](validation.md)。
64
64
 
@@ -85,12 +85,12 @@ CI 构建和测试步骤无需发布凭据。发布 job 可使用 CI secret 注
85
85
 
86
86
  ## 版本与发布
87
87
 
88
- 当前组件版本为 `0.4.0`,网关版本为 `0.1.0`,两者独立升级。0.x 阶段,修复使用 patch,新增功能和未冻结接口调整使用 minor,并在 changelog 说明兼容性。稳定 API 后再发布 1.0。
88
+ 当前组件版本为 `0.5.0`,网关版本为 `0.1.0`,两者独立升级。0.x 阶段,修复使用 patch,新增功能和未冻结接口调整使用 minor,并在 changelog 说明兼容性。稳定 API 后再发布 1.0。
89
89
 
90
90
  下面以 npmjs.org 公开发布为例。命令会实际上传产物,应在完成验收后由发布负责人执行;发布私有 registry 时替换地址,并按该服务调整可见性参数:
91
91
 
92
92
  ```sh
93
- npm publish ./artifacts/galaxycore-ai-chat-0.4.0.tgz \
93
+ npm publish ./artifacts/galaxycore-ai-chat-0.5.0.tgz \
94
94
  --access public --tag latest \
95
95
  --registry=https://registry.npmjs.org/
96
96
  ```
@@ -98,7 +98,7 @@ npm publish ./artifacts/galaxycore-ai-chat-0.4.0.tgz \
98
98
  使用 tarball 发布时,先显式执行完整检查,不依赖源仓库的生命周期脚本一定被触发。`latest` 是不指定版本安装时使用的标签,不代表 API 已冻结。需要独立试用通道时,可以采用预发布版本及 `next` 标签。发布后检查远端版本和完整性:
99
99
 
100
100
  ```sh
101
- npm view @galaxycore/ai-chat@0.4.0 version dist.integrity \
101
+ npm view @galaxycore/ai-chat@0.5.0 version dist.integrity \
102
102
  --registry=https://registry.npmjs.org/
103
103
  npm dist-tag ls @galaxycore/ai-chat \
104
104
  --registry=https://registry.npmjs.org/
@@ -9,6 +9,8 @@
9
9
 
10
10
  目标产物:`artifacts/galaxycore-ai-chat-0.4.0.tgz`、`artifacts/galaxycore-ai-chat-gateway-0.1.0.tgz`。发布与验证命令见 [发布与安装](publishing.md)。
11
11
 
12
+ 发布结果:两个包已公开发布到 npmjs.org,`latest` 分别为 `0.4.0` 和 `0.1.0`。已通过不带凭据的公开查询验证版本、标签和 registry 完整性;发布记录见 `artifacts/npm-publication-0.4.json`。前端包在消费测试后仅补充发布命令与验收文档,运行代码、声明、样式和 manifest 与已测试版本逐字节一致,比较结果保存在消费验收报告中。
13
+
12
14
  ---
13
15
 
14
16
  # 历史会话菜单验证 · 2026-10-13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxycore/ai-chat",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Composable React AI chat for GalaxyCore, powered by Vercel AI SDK",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -83,13 +83,7 @@
83
83
  "@ai-sdk/react": "^4.0.140",
84
84
  "ai": "^7.0.137",
85
85
  "react": "^18.3.1 || ^19.2.1",
86
- "react-dom": "^18.3.1 || ^19.2.1",
87
- "streamdown": "^2.7.0"
88
- },
89
- "peerDependenciesMeta": {
90
- "streamdown": {
91
- "optional": true
92
- }
86
+ "react-dom": "^18.3.1 || ^19.2.1"
93
87
  },
94
88
  "devDependencies": {
95
89
  "@ai-sdk/react": "4.0.140",
@@ -104,7 +98,6 @@
104
98
  "jsdom": "30.1.2",
105
99
  "react": "19.3.0",
106
100
  "react-dom": "19.3.0",
107
- "streamdown": "2.7.0",
108
101
  "tsdown": "0.23.1",
109
102
  "tsx": "4.23.15",
110
103
  "typescript": "7.0.2",
@@ -112,6 +105,7 @@
112
105
  "vitest": "5.0.4"
113
106
  },
114
107
  "dependencies": {
115
- "lucide-react": "1.55.0"
108
+ "lucide-react": "1.55.0",
109
+ "streamdown": "^2.7.0"
116
110
  }
117
111
  }