Appearance
comments
View existing comments, add a new comment, delete or update an existing comment on a memo.
# View comments on a memo $RUNTIME "$API_SCRIPT" comments abc123 # Add a comment to a memo $RUNTIME "$API_SCRIPT" comments abc123 "这是一条评论" # Add a comment with explicit visibility $RUNTIME "$API_SCRIPT" comments abc123 "这是一条公开评论" --visibility=PUBLIC # Update a comment $RUNTIME "$API_SCRIPT" comments abc123 "更新后的评论内容" --operation=update --comment-id=comment_memo_id # Delete a comment $RUNTIME "$API_SCRIPT" comments abc123 "" --operation=delete --comment-id=comment_memo_id
触发关键词映射表:
当用户使用以下自然语言表达时,应识别为评论操作:
comments --operation=delete
comments --operation=update
Implementation details:
GET /api/v1/memos/{id}/comments
POST /api/v1/memos/{id}/comments
{ "content": "评论内容", "visibility": "PRIVATE" }
--operation=delete --comment-id=xxx
DELETE /api/v1/memos/{comment_id}
memos/[ID]
--operation=update --comment-id=xxx
PATCH /api/v1/memos/{comment_id}
核心原则:评论的可见性与父笔记独立管理,但默认继承父笔记的可见性。
--visibility
--visibility=PUBLIC
--visibility=PRIVATE
--visibility=PROTECTED
所有 Agent 需统一遵守此规则,保证行为一致性。
当评论内容包含 Markdown 反引号 (`)、双引号 (") 或特殊字符时,直接通过命令行传参会被 Shell 截断或解析错误。
错误示例 (内容会被 Shell 吃掉):
node api.cjs comments abc123 "请检查 `story.cjs` 的引用" # ❌ 反引号会执行或被删
正确做法 (使用脚本绕过 Shell): 对于复杂评论内容(如自动化任务回复、代码反馈),请创建临时脚本文件:
// /tmp/add_comment.cjs process.chdir('/opt/data/skills/memos'); const { BASE_URL, ACCESS_TOKEN } = require('/opt/data/skills/memos/scripts/env.cjs'); (async function() { const content = "包含 `代码块` 和 **Markdown** 的复杂评论内容..."; const res = await fetch(BASE_URL + '/api/v1/memos/memos/abc123/comments', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + ACCESS_TOKEN }, body: JSON.stringify({ content, visibility: 'PROTECTED' }) }); const data = await res.json(); console.log('✅ 评论已添加:', data.name); })();
然后运行: node /tmp/add_comment.cjs
node /tmp/add_comment.cjs
有两种主要方法:
要将评论添加到现有的 memo,需要创建一个新 memo 并建立 COMMENT 关系:
// 步骤 1: 创建评论内容作为新的 memo const commentPayload = { content: "评论内容", visibility: "PROTECTED" }; const commentResponse = await callAPI('POST', `/api/v1/memos`, commentPayload); // 步骤 2: 将新创建的评论与原 memo 建立关系 const relationPayload = { relatedMemo: commentResponse.name, // 新评论的名称 type: "COMMENT" }; const relationResponse = await callAPI('POST', `/api/v1/memos/${originalMemoId}/relation`, relationPayload);
更简单的方法是使用专用的评论 API 端点:
const commentPayload = { content: "评论内容", visibility: "PROTECTED" }; const commentResponse = await callAPI('POST', `/api/v1/memos/${originalMemoId}/comments`, commentPayload);
在进行 API 调用时,确保正确设置环境变量:
const baseUrl = process.env.MEMOS_BASE_URL; const accessToken = process.env.MEMOS_ACCESS_TOKEN;
get
原因: ID 格式可能不正确,Memos API 中的完整名称是 memos/[ID] 格式 解决方案: 使用正确的完整名称格式,例如 memos/8oW2zMmxb5FbxJzcpLCkJC
memos/8oW2zMmxb5FbxJzcpLCkJC
原因: 直接将评论内容添加到原 memo 的内容中,而不是创建独立的 memo 并建立关系 解决方案: 先创建评论作为独立的 memo,然后使用 relation API 建立 COMMENT 关系
memos/{id}
Comments are created as memo-like objects with the same structure. Returns the created comment's ID and a summary.
View display format:
💬 Comments on memos/abc123 (共 3 条) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. Test comment 创建者: users/1 (tnnevol) 可见性: PRIVATE 创建时间: 2026-04-14 14:30 ID: memos/xyz789 ─────────────────────────────── 2. Another comment 创建者: users/2 (alice) 可见性: PROTECTED 创建时间: 2026-04-14 15:00 ID: memos/abc456 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Add display format:
✅ Comment added successfully ID: memos/xyz789 内容: 这是一条评论 可见性: PROTECTED (继承自父笔记) 创建时间: 2026-04-14 16:00
Delete display format:
✅ Comment deleted successfully ID: memos/xyz789 删除时间: 2026-04-14 17:00
Update display format:
✅ Comment updated successfully ID: memos/xyz789 新内容: 这是更新后的评论 更新时间: 2026-04-14 17:00
Comment Actions
comments— View/Add/Delete/Update Comments on a Memo View existing comments, add a new comment, delete or update an existing comment on a memo.
触发关键词映射表:
当用户使用以下自然语言表达时,应识别为评论操作:
commentscommentscommentscommentscomments(无内容参数)comments(无内容参数)comments --operation=deletecomments --operation=updatecomments --operation=updateImplementation details:
View Comments
GET /api/v1/memos/{id}/commentsAdd Comment
POST /api/v1/memos/{id}/commentswith body:Delete Comment
POST /api/v1/memos/{id}/commentswith body:--operation=delete --comment-id=xxxpatternDELETE /api/v1/memos/{comment_id}internallymemos/[ID],可在评论列表中获取Update Comment
POST /api/v1/memos/{id}/commentswith body:--operation=update --comment-id=xxxpatternPATCH /api/v1/memos/{comment_id}internallymemos/[ID],可在评论列表中获取Visibility 默认继承规则
核心原则:评论的可见性与父笔记独立管理,但默认继承父笔记的可见性。
--visibility--visibility=PUBLIC--visibility=PRIVATE--visibility=PROTECTED所有 Agent 需统一遵守此规则,保证行为一致性。
⚠️ 重要:Shell 转义问题与脚本调用法
当评论内容包含 Markdown 反引号 (`)、双引号 (") 或特殊字符时,直接通过命令行传参会被 Shell 截断或解析错误。
错误示例 (内容会被 Shell 吃掉):
正确做法 (使用脚本绕过 Shell): 对于复杂评论内容(如自动化任务回复、代码反馈),请创建临时脚本文件:
然后运行:
node /tmp/add_comment.cjs高级用法
1. 添加评论到现有 Memo
有两种主要方法:
方法 A: 通过关系建立评论(传统方法)
要将评论添加到现有的 memo,需要创建一个新 memo 并建立 COMMENT 关系:
方法 B: 直接使用评论 API(推荐)
更简单的方法是使用专用的评论 API 端点:
2. 使用环境变量
在进行 API 调用时,确保正确设置环境变量:
常见问题解决
问题:无法通过
get操作访问特定 ID 的 memo 原因: ID 格式可能不正确,Memos API 中的完整名称是
memos/[ID]格式 解决方案: 使用正确的完整名称格式,例如memos/8oW2zMmxb5FbxJzcpLCkJC问题:创建评论后无法正确关联到原 memo
原因: 直接将评论内容添加到原 memo 的内容中,而不是创建独立的 memo 并建立关系 解决方案: 先创建评论作为独立的 memo,然后使用 relation API 建立 COMMENT 关系
错误处理
memos/{id}格式注意事项
memos/[ID],在 API 调用时可能只需要使用 ID 部分Comments are created as memo-like objects with the same structure. Returns the created comment's ID and a summary.
View display format:
Add display format:
Delete display format:
Update display format: