diff --git a/docs/cn/usage/cli-query.md b/docs/cn/usage/cli-query.md index b94ce463..ecd9b10d 100644 --- a/docs/cn/usage/cli-query.md +++ b/docs/cn/usage/cli-query.md @@ -18,6 +18,24 @@ ChatLab 可以作为 Codex、Claude Code、HermesAgent 等外部 Agent 的本地 安装:`npm i chatlab-cli -g`(需要 Node.js ≥ 20),并先在 ChatLab 中导入聊天记录。 +## 使用 AI Agent + +推荐通过通用 Agent Skills CLI 安装官方中文 `chatlab-analyze-cn` 技能: + +```bash +npx skills add ChatLab/ChatLab --skill chatlab-analyze-cn -g +``` + +安装后,可以在 Codex、Claude Code、Cursor 等外部 Agent 中直接说: + +```text +chatlab-analyze-cn 帮我分析我和小红的聊天记录 +``` + +这个技能会引导 Agent 先执行 `chatlab manifest` 获取机读命令清单,再用安全的 `--format agent/json` 查询聊天记录。 + +`chatlab-analyze-cn` 始终只读。如果你希望 Agent 导入新的聊天导出文件,请改用独立的 `chatlab-import-cn` Skill;它会先预览导入计划,再自动新建或增量导入,详见[导入聊天记录指南](./how-to-import.md)。 + ## 命令总览 ```bash @@ -77,23 +95,7 @@ agent/json 模式下 stdout 只包含一个 JSON 响应信封,日志一律走 - `--raw`(绕过预处理)默认禁用,仅当你显式执行 `chatlab config set cli.allow_raw true` 或设置 `CHATLAB_CLI_ALLOW_RAW=1` 后可用。 - 不需要 SQL 兜底能力时,可用 `chatlab config set cli.allow_sql false` 关闭 `sql` 命令。 -## 给 Agent 的使用指南 - -推荐通过通用 Agent Skills CLI 安装官方中文 `chatlab-analyze-cn` 技能: - -```bash -npx skills add ChatLab/ChatLab --skill chatlab-analyze-cn -g -``` - -安装后,可以在 Codex、Claude Code、Cursor 等外部 Agent 中直接说: - -```text -chatlab-analyze-cn 帮我分析我和小红的聊天记录 -``` - -这个技能会引导 Agent 先执行 `chatlab manifest` 获取机读命令清单,再用安全的 `--format agent/json` 查询聊天记录。 - -`chatlab-analyze-cn` 始终只读。如果你希望 Agent 导入新的聊天导出文件,请改用独立的 `chatlab-import-cn` Skill;它会先预览导入计划,再自动新建或增量导入,详见[导入聊天记录指南](./how-to-import.md)。 +## 查询示例 典型配方——"谁最早提到某个问题?查看现场": diff --git a/docs/en/usage/cli-query.md b/docs/en/usage/cli-query.md index 69621d5b..f5b06b3a 100644 --- a/docs/en/usage/cli-query.md +++ b/docs/en/usage/cli-query.md @@ -18,6 +18,24 @@ The `chatlab` CLI ships a set of query commands optimized for AI agents while st Install with `npm i chatlab-cli -g` (Node.js ≥ 20) and import chat records in ChatLab first. +## Use it with an AI agent + +Install the official `chatlab-analyze` skill through the general Agent Skills CLI: + +```bash +npx skills add ChatLab/ChatLab --skill chatlab-analyze -g +``` + +After installation, ask Codex, Claude Code, Cursor, or another external agent: + +```text +chatlab-analyze help me analyze my chat history with Alice +``` + +The skill tells the agent to run `chatlab manifest` first, then query chat records safely with explicit `--format agent/json` commands. + +`chatlab-analyze` always remains read-only. To let an agent import a new chat export, use the separate `chatlab-import` skill; it previews the import, then automatically creates or incrementally updates a session. See the [Import Chat Records Guide](./how-to-import.md). + ## Command overview ```bash @@ -77,23 +95,7 @@ Failures return `{ "ok": false, "error": { "code", "message", "hint", "candidate - `--raw` (bypassing preprocessing) is disabled by default; it only works after you explicitly run `chatlab config set cli.allow_raw true` or set `CHATLAB_CLI_ALLOW_RAW=1`. - If you don't need the SQL fallback, disable it with `chatlab config set cli.allow_sql false`. -## Agent usage guide - -Install the official `chatlab-analyze` skill through the general Agent Skills CLI: - -```bash -npx skills add ChatLab/ChatLab --skill chatlab-analyze -g -``` - -After installation, ask Codex, Claude Code, Cursor, or another external agent: - -```text -chatlab-analyze help me analyze my chat history with Alice -``` - -The skill tells the agent to run `chatlab manifest` first, then query chat records safely with explicit `--format agent/json` commands. - -`chatlab-analyze` always remains read-only. To let an agent import a new chat export, use the separate `chatlab-import` skill; it previews the import, then automatically creates or incrementally updates a session. See the [Import Chat Records Guide](./how-to-import.md). +## Query example A typical recipe — "who mentioned this first? inspect the surrounding context": diff --git a/src/i18n/locales/en-US/home.json b/src/i18n/locales/en-US/home.json index 11023756..a35078a8 100644 --- a/src/i18n/locales/en-US/home.json +++ b/src/i18n/locales/en-US/home.json @@ -2,12 +2,20 @@ "tagline": "Explore New Chat Memories", "tabs": { "file": "File Import", - "api": "Auto Sync", - "push": "API Push", - "apiDescription": "Connect external platform data sources to automatically sync chat records to ChatLab on a schedule.", - "apiButton": "Configure Auto Sync", - "pushDescription": "Start the local API server to let third-party tools, plugins, or scripts push chat records directly into ChatLab.", - "pushButton": "Configure API Server" + "api": "API Import", + "cli": "CLI Import", + "autoSyncTitle": "Automatic Sync", + "autoSyncDescription": "Let ChatLab periodically pull new chat records from an external data source.", + "autoSyncButton": "Configure Sync", + "apiPushTitle": "API Push", + "apiPushDescription": "Let third-party tools, plugins, or scripts write through the local API.", + "apiPushButton": "Configure API", + "agentImportTitle": "Import with an AI Agent", + "agentImportDescription": "Install the official Skill to import chat records automatically.", + "manualCliTitle": "Use the CLI Manually", + "manualCliDescription": "Ideal for terminal workflows, batch scripts, and repeatable automation.", + "copyCommand": "Copy command", + "viewDocs": "View documentation" }, "import": { "dropHint": "Drop to import files", diff --git a/src/i18n/locales/ja-JP/home.json b/src/i18n/locales/ja-JP/home.json index 55ad96c5..6d4e9234 100644 --- a/src/i18n/locales/ja-JP/home.json +++ b/src/i18n/locales/ja-JP/home.json @@ -2,12 +2,20 @@ "tagline": "新しいチャットの記憶を探索する", "tabs": { "file": "ファイルインポート", - "api": "自動同期", - "push": "APIプッシュ", - "apiDescription": "外部プラットフォームのデータソースを設定し、チャット履歴をChatLabへ定期的に自動同期します。", - "apiButton": "自動同期を設定する", - "pushDescription": "ローカルAPIサーバーを起動し、サードパーティのツール・プラグイン・スクリプトからChatLabへチャット履歴をプッシュできます。", - "pushButton": "APIサーバーを設定する" + "api": "API インポート", + "cli": "CLI インポート", + "autoSyncTitle": "自動同期", + "autoSyncDescription": "ChatLab が外部データソースから新しいチャット履歴を定期的に取得します。", + "autoSyncButton": "自動同期を設定", + "apiPushTitle": "API プッシュ", + "apiPushDescription": "外部ツール、プラグイン、スクリプトからローカル API 経由で書き込みます。", + "apiPushButton": "API を設定", + "agentImportTitle": "AI Agent でインポート", + "agentImportDescription": "公式 Skill をインストールして、チャット履歴を自動的にインポートします。", + "manualCliTitle": "CLI を手動で使用", + "manualCliDescription": "ターミナル操作、バッチスクリプト、繰り返し可能な自動化に適しています。", + "copyCommand": "コマンドをコピー", + "viewDocs": "ドキュメントを見る" }, "import": { "dropHint": "マウスを離してファイルをインポート", diff --git a/src/i18n/locales/zh-CN/home.json b/src/i18n/locales/zh-CN/home.json index ae784a9e..40990ba0 100644 --- a/src/i18n/locales/zh-CN/home.json +++ b/src/i18n/locales/zh-CN/home.json @@ -2,12 +2,20 @@ "tagline": "探索新的聊天记忆", "tabs": { "file": "文件导入", - "api": "自动同步", - "push": "API推送", - "apiDescription": "配置外部平台的数据源,让聊天记录定期自动同步到ChatLab。", - "apiButton": "去配置自动同步", - "pushDescription": "开启本地API服务,允许第三方工具/插件或脚本将聊天记录主动推送至ChatLab。", - "pushButton": "去开启 API 服务" + "api": "API 导入", + "cli": "CLI 导入", + "autoSyncTitle": "自动同步", + "autoSyncDescription": "由 ChatLab 定时从外部数据源拉取新增聊天记录。", + "autoSyncButton": "配置自动同步", + "apiPushTitle": "API 推送", + "apiPushDescription": "让第三方工具、插件或脚本通过本地 API 主动写入。", + "apiPushButton": "配置 API 服务", + "agentImportTitle": "使用 AI Agent 导入", + "agentImportDescription": "安装官方Skill,使用Skill自动导入聊天记录。", + "manualCliTitle": "手动使用 CLI", + "manualCliDescription": "适合终端操作、批处理脚本和可重复的自动化流程。", + "copyCommand": "复制命令", + "viewDocs": "查看文档" }, "import": { "dropHint": "松开鼠标导入文件", diff --git a/src/i18n/locales/zh-TW/home.json b/src/i18n/locales/zh-TW/home.json index be2f2e86..cc38eb2a 100644 --- a/src/i18n/locales/zh-TW/home.json +++ b/src/i18n/locales/zh-TW/home.json @@ -2,12 +2,20 @@ "tagline": "探索新的聊天記憶", "tabs": { "file": "檔案匯入", - "api": "自動同步", - "push": "API推送", - "apiDescription": "設定外部平台的資料來源,讓聊天記錄定期自動同步到ChatLab。", - "apiButton": "前往設定自動同步", - "pushDescription": "開啟本地API服務,允許第三方工具/掛件或腳本將聊天記錄主動推送至ChatLab。", - "pushButton": "前往設定 API 服務" + "api": "API 匯入", + "cli": "命令列匯入", + "autoSyncTitle": "自動同步", + "autoSyncDescription": "由 ChatLab 定期從外部資料來源拉取新增聊天記錄。", + "autoSyncButton": "設定自動同步", + "apiPushTitle": "API 推送", + "apiPushDescription": "讓第三方工具、外掛或腳本透過本機 API 主動寫入。", + "apiPushButton": "設定 API 服務", + "agentImportTitle": "使用 AI Agent 匯入", + "agentImportDescription": "安裝官方 Skill,使用 Skill 自動匯入聊天記錄。", + "manualCliTitle": "手動使用 CLI", + "manualCliDescription": "適合終端操作、批次腳本與可重複的自動化流程。", + "copyCommand": "複製命令", + "viewDocs": "查看文件" }, "import": { "dropHint": "鬆開滑鼠匯入檔案", diff --git a/src/pages/home/components/import/ApiImportCard.vue b/src/pages/home/components/import/ApiImportCard.vue index 10c81c5e..2fedf90e 100644 --- a/src/pages/home/components/import/ApiImportCard.vue +++ b/src/pages/home/components/import/ApiImportCard.vue @@ -5,34 +5,67 @@ import { useLayoutStore } from '@/stores/layout' const { t } = useI18n() const layoutStore = useLayoutStore() -// 打开设置弹窗并定位到 API 服务子 Tab +// Pull 与 Push 共用“API 导入”入口,但继续进入各自独立的配置子页。 +function openSyncSettings() { + layoutStore.openSettings('api', 'sync') +} + function openApiSettings() { layoutStore.openSettings('api', 'api') } diff --git a/src/pages/home/components/import/AutoSyncCard.vue b/src/pages/home/components/import/AutoSyncCard.vue deleted file mode 100644 index 5945315a..00000000 --- a/src/pages/home/components/import/AutoSyncCard.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/src/pages/home/components/import/CliImportCard.vue b/src/pages/home/components/import/CliImportCard.vue new file mode 100644 index 00000000..f6276b5f --- /dev/null +++ b/src/pages/home/components/import/CliImportCard.vue @@ -0,0 +1,102 @@ + + + diff --git a/src/pages/home/components/import/ImportArea.vue b/src/pages/home/components/import/ImportArea.vue index d6522c82..47009206 100644 --- a/src/pages/home/components/import/ImportArea.vue +++ b/src/pages/home/components/import/ImportArea.vue @@ -878,7 +878,7 @@ const getMergeFileProgressText = (file: MergeFileInfo) =>
@@ -924,7 +924,7 @@ const getMergeFileProgressText = (file: MergeFileInfo) =>
@@ -977,7 +977,7 @@ const getMergeFileProgressText = (file: MergeFileInfo) =>
@@ -1005,7 +1005,7 @@ const getMergeFileProgressText = (file: MergeFileInfo) =>
@@ -1088,9 +1088,9 @@ const getMergeFileProgressText = (file: MergeFileInfo) => >