Google Workspace CLI 内容创作者(Content Creator)Persona 实战:用 gws 完成内容的创建、组织与分发
【免费下载链接】cliGoogle Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.项目地址: https://gitcode.com/gh_mirrors/cli413/cli
导读
persona-content-creator是 Google Workspace CLI(gws)内置的"角色技能包"(Persona Skill),它把 Docs、Drive、Gmail、Chat、Slides 五个服务的能力编排成一套面向内容生产的工作流。阅读本文后,你将掌握如何以 Content Creator 角色运行gws:在 Google Docs 起草内容、在 Drive 中组织素材、用 Chat 分发成品、通过 Gmail 发起评审,并理解 Persona 技能从注册表到 SKILL.md 的生成原理。
Persona 是什么:角色化的技能包
在gws中,Persona 是一类特殊的 OpenClaw 技能(category 为persona),本质上是"围绕某个工作角色打包的指令集"。它不新增任何 CLI 命令,而是告诉 Agent 在扮演该角色时应该优先调用哪些既有命令、按什么顺序执行。
Content Creator 角色的定义位于 skills/persona-content-creator/SKILL.md,其 frontmatter 声明了:
--- name: persona-content-creator description: "Create, organize, and distribute content across Workspace." metadata: version: 0.22.5 openclaw: category: "persona" requires: bins: - gws skills: - gws-docs - gws-drive - gws-gmail - gws-chat - gws-slides ---其中requires.bins要求本机$PATH中存在gws可执行文件;requires.skills列出该角色运行所依赖的五个实用技能(utility skills),它们是角色执行具体操作时的"工具库"。正文中的 PREREQUISITE 提示与此一一对应:
PREREQUISITE:Load the following utility skills to operate as this persona:
gws-docs,gws-drive,gws-gmail,gws-chat,gws-slides
从注册表到 SKILL.md 的生成链路
Persona 技能并非手写维护,而是由 CLI 自身从注册表生成。注册表文件是 crates/google-workspace-cli/registry/personas.toml,其中content-creator条目与 SKILL.md 一一对应:
[[personas]] name = "content-creator" title = "Content Creator" description = "Create, organize, and distribute content across Workspace." services = [ "docs", "drive", "gmail", "chat", "slides" ] workflows = [ "+file-announce" ] instructions = [ "Draft content in Google Docs with `gws docs +write`.", "Organize content assets in Drive folders — use `gws drive files list` to browse.", "Share finished content by announcing in Chat with `gws workflow +file-announce`.", "Send content review requests via email with `gws gmail +send`.", "Upload media assets to Drive with `gws drive +upload`." ] tips = [ "Use `gws docs +write` for quick content updates — it handles the Docs API formatting.", "Keep a 'Content Calendar' in a shared Sheet for tracking publication schedules.", "Use `--format yaml` for human-readable output when debugging API responses." ]生成逻辑位于 crates/google-workspace-cli/src/generate_skills.rs 的render_persona_skill函数:它读取PERSONAS_TOML(include_str!("../registry/personas.toml")),把services列表渲染为 frontmatter 中的requires.skills块、把workflows渲染为gws workflow +xxx形式的命令列表,最后将instructions与tips原样写入正文。运行时执行gws generate-skills即可重新生成(默认输出到skills/目录),生成结果索引会写入 docs/skills.md。
角色的核心工作流:file-announce
Content Creator 角色声明的唯一相关工作流(Relevant Workflows)是:
gws workflow +file-announce+file-announce是一个跨服务工作流命令,其作用是"在 Chat 空间中宣布一个 Drive 文件"——它先向 Drive 请求文件元数据拿到文件名,再向指定的 Chat space 发送一条消息。技能说明见 skills/gws-workflow-file-announce/SKILL.md,基本用法:
gws workflow +file-announce --file-id <ID> --space <SPACE>| Flag | 必填 | 说明 |
|---|---|---|
--file-id | ✓ | 要宣布的 Drive 文件 ID |
--space | ✓ | Chat 空间名,如spaces/ABC123 |
--message | — | 自定义宣布消息文本 |
--format | — | 输出格式:json(默认)、table、yaml、csv |
实际示例:
gws workflow +file-announce --file-id FILE_ID --space spaces/ABC123 gws workflow +file-announce --file-id FILE_ID --space spaces/ABC123 --message 'Check this out!'推荐的使用顺序是先用gws drive +upload上传文件,再用本命令宣布——这也是角色 Instructions 中"上传媒体资产 → 在 Chat 宣布成品"的编排逻辑。注意该命令会真实发送 Chat 消息,属于写操作,执行前应向用户确认。
五条角色指令逐一拆解
Content Creator 的 Instructions 定义了从起草、组织、分发到评审的完整内容生产闭环,每条指令对应一个具体的gws命令。
1. 在 Google Docs 起草内容:gws docs +write
Draft content in Google Docs with
gws docs +write.
+write是 Docs 服务的 helper 命令(参见 skills/gws-docs-write/SKILL.md),功能是向文档末尾追加纯文本:
gws docs +write --document <ID> --text <TEXT>| Flag | 必填 | 默认 | 说明 |
|---|---|---|---|
--document | ✓ | — | 文档 ID |
--text | ✓ | — | 要追加的纯文本 |
gws docs +write --document DOC_ID --text 'Hello, world!'文本总是插入文档正文末尾。如果需要富文本排版,则应改用 Docs API 的原始batchUpdate方法。由于是写命令,执行前需与用户确认。Docs 服务级技能 skills/gws-docs/SKILL.md 还列出了documents资源下的create(创建空白文档)与get(读取最新文档版本)等方法,可结合使用完成"建文档 → 写内容"的完整起草流程。
2. 在 Drive 中组织内容资产:gws drive files list
Organize content assets in Drive folders — use
gws drive files listto browse.
gws drive files list是 Drive v3 APIfiles.list方法的直接映射,用于浏览用户的文件与文件夹。该方法接受q参数进行搜索,默认返回全部文件(含回收站文件),因此实践中建议显式过滤。例如从 skills/gws-drive/SKILL.md 与 personas.toml 中其他角色(如 project-manager)的经验可知,可用--params传入搜索条件:
# 只列出未被删除的文件,每页 10 条 gws drive files list --params '{"pageSize": 10, "q": "trashed=false"}' # 按名称模糊搜索项目文件夹 gws drive files list --params '{"q": "name contains \"Project\""}'--params中传递的是 URL/query 参数(JSON 字符串),外层用单引号包裹以避免 shell 展开内层双引号。浏览目录、确认素材位置之后,即可进入下一步分发。
3. 在 Chat 中宣布成品:gws workflow +file-announce
Share finished content by announcing in Chat with
gws workflow +file-announce.
对应上文的 核心工作流 一节:上传完成后,将文件 ID 与目标 space 传给+file-announce,自动从 Drive 拉取文件名并生成宣布消息发送到团队 Chat 空间。
4. 通过邮件发起评审:gws gmail +send
Send content review requests via email with
gws gmail +send.
+send是 Gmail 服务的 helper(参见 skills/gws-gmail-send/SKILL.md),自动处理 RFC 5322 格式、MIME 编码与 base64,是内容评审请求的标准出口:
gws gmail +send --to <EMAILS> --subject <SUBJECT> --body <TEXT>| Flag | 必填 | 默认 | 说明 |
|---|---|---|---|
--to | ✓ | — | 收件人邮箱,逗号分隔多个 |
--subject | ✓ | — | 邮件主题 |
--body | ✓ | — | 邮件正文(纯文本,加--html则为 HTML) |
--from | — | — | 发件地址(send-as 别名) |
--attach | — | — | 附件文件路径,可多次指定 |
--cc/--bcc | — | — | 抄送 / 密送,逗号分隔 |
--html | — | — | 将--body视为 HTML 片段 |
--dry-run | — | — | 只展示待发送请求,不真正发送 |
--draft | — | — | 保存为草稿而非直接发送 |
评审请求示例:
gws gmail +send --to editor@example.com --subject 'Content Review: Q3 Blog Draft' \ --body '<p>Please review the attached draft.</p>' --html -a draft.pdf附件总大小上限 25 MB,单个附件可用-a/--attach简写。内容创作者可以把成品文档链接写进正文、把 PDF 作为附件,一次性完成评审分发。
5. 上传媒体素材到 Drive:gws drive +upload
Upload media assets to Drive with
gws drive +upload.
+upload是 Drive 服务的 helper(参见 skills/gws-drive-upload/SKILL.md),负责带自动元数据上传文件:
gws drive +upload <file>| Flag | 必填 | 默认 | 说明 |
|---|---|---|---|
<file> | ✓ | — | 要上传的本地文件路径 |
--parent | — | — | 父文件夹 ID |
--name | — | 源文件名 | 目标文件名 |
gws drive +upload ./report.pdf gws drive +upload ./report.pdf --parent FOLDER_ID gws drive +upload ./data.csv --name 'Sales Data.csv'MIME 类型自动检测,文件名默认取自本地路径。它同样是写命令,且通常作为+file-announce的前置步骤——先上传、后宣布,构成"素材入库 → 团队可见"的完整链路。
Tips:角色级实战技巧
Content Creator 技能正文给出的三条 Tips 值得展开:
gws docs +write用于快速内容更新——它替你处理了 Docs API 的格式编排(追加语义、纯文本入参),适合草稿迭代;需要精细排版时再退到底层batchUpdate。- 在共享 Sheet 中维护一个 'Content Calendar' 追踪发布排期——这与 gws-sheets 系列技能(如
gws sheets +append)配合使用,可以形成"排期表 → 按计划产稿"的节奏化内容管理。 - 调试 API 响应时使用
--format yaml——--format是全局输出格式开关,支持json(默认)、table、yaml、csv。YAML 对人类阅读友好,是排查响应结构的推荐姿势。
运行前置:认证与全局参数
角色技能默认依赖 skills/gws-shared/SKILL.md 中约定的认证与安全规则:
# 交互式浏览器 OAuth gws auth login # 或服务账号方式 export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json常用全局/方法级参数:
| 参数 | 说明 |
|---|---|
--format <FORMAT> | 输出格式:json(默认)、table、yaml、csv |
--dry-run | 本地校验、不真正调用 API |
--sanitize <TEMPLATE> | 通过 Model Armor 对响应做内容安全过滤 |
--params '{"key":"val"}' | URL/query 参数 |
--json '{"key":"val"}' | 请求体 |
--page-all/--page-limit <N>/--page-delay <MS> | 自动分页(默认每页间隔 100ms,最多 10 页) |
安全规则包括:绝不直接输出密钥/令牌;执行写/删命令前必须征得用户确认;破坏性操作优先--dry-run;涉敏数据使用--sanitize。在 zsh 下使用 Sheet 范围(含!)时需注意历史展开问题,建议用双引号包裹。
小结
Content Creator Persona 展示了gws角色化技能的设计思路:用一份 SKILL.md 把五个服务的命令编排成一条内容生产流水线——Docs 起草、Drive 归档、Chat 宣布、Gmail 评审、Drive 上传。对 Agent 而言,加载persona-content-creator即获得该角色的完整操作范式;对开发者而言,crates/google-workspace-cli/registry/personas.toml 与 crates/google-workspace-cli/src/generate_skills.rs 则展示了如何通过声明式注册表批量生成、维护这类角色技能。若需查阅全部技能分类(Services / Helpers / Personas / Recipes),可查看自动生成的 docs/skills.md。
【免费下载链接】cliGoogle Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.项目地址: https://gitcode.com/gh_mirrors/cli413/cli
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考