dws-doc-cli-mock
GitHub提供钉钉文档CLI的本地Mock环境,模拟dws命令行为。用于在无需真实凭证和网络的情况下测试和验证钉钉文档工作流,支持JSON输出、状态重置及干跑模式,确保开发安全与效率。
Trigger Scenarios
Install
npx skills add Accio-org/RealReplicaBench --skill dws-doc-cli-mock -g -y
SKILL.md
Frontmatter
{
"name": "dws-doc-cli-mock",
"metadata": {
"category": "benchmark-mock",
"requires": {
"bins": [
"dws"
]
}
},
"description": "Use when an agent needs to run against the dws_doc_cli DingTalk Workspace CLI mock for DingTalk Doc workflows with the real command prefix `dws`, without real DingTalk credentials or network access."
}
dws_doc_cli Skill
dws_doc_cli is a Bun/Node-compatible mock of the DingTalk Workspace CLI. It is scoped to DingTalk Doc behavior and should not be used for real DingTalk data or real enterprise operations.
The mock lives under ditto_site/mocks/dws_doc_cli/. The package and service identify as a mock, but the command exposed to agents is exactly dws.
Invocation
From the mock directory:
DWS_MOCK_HOME=/private/tmp/dws-doc-cli-state dws <command> --format json
The formal harness should put this package's npm bin on PATH, or npm link can be used during setup. Use a writable DWS_MOCK_HOME for every isolated agent run; the default is ~/.dws-mock.
Service Mode
Use service mode only for ditto_site health and verifier checks. Agents should still interact through the dws CLI.
bun server.js
curl http://localhost:3020/health
curl http://localhost:3020/api/verify
Verifier endpoints are /api/state, /api/sessions, /api/access-log, and /api/verify. Set MOCK_VERIFIER_TOKEN to require X-Mock-Verifier-Token on those routes.
Agent Rules
- Always request machine-readable output with
--format json. - Use
dws schema --format jsonanddws doc --helpfor discovery. - Treat this as a doc-only mock. Non-doc products are intentionally absent and should be considered unsupported.
- Do not run login or auth setup. The doc mock runs from local state and fixtures without authentication.
- Use
--dry-runbefore write/delete operations when validating an invocation shape. - Add
--yesonly after the user has explicitly approved destructive or externally visible operations. In this mock, writes affect only local state, but keep the same habit as realdws. - Reset state between independent tests with
DWS_MOCK_RESET=1ordws mock-reset. - Use
--jqand--fieldsonly for simple extraction; the mock implements a small jq-like subset, not full jq. - Never put real tokens, client secrets, or enterprise data into mock fixtures.
Discovery
Use these first:
dws --help
dws schema --format json
dws doc --help
dws doc read --help
The real behavior source lives in the upstream dingtalk-workspace-cli
repository. In a checkout of that repository, consult:
docs/command-index.mdskills/mono/SKILL.mdskills/mono/references/products/doc.md
When extending the mock, compare against those files first, then update command handlers, fixtures, and schema coverage together.
Product Coverage
Only the DingTalk Doc product is implemented. It includes search, browse, metadata, read/write, upload/download, file/folder creation, copy/move/rename, block editing, and comments.
Common fixture IDs:
| Purpose | ID |
|---|---|
| Workspace | Y7kmbeElo8lkqXLq |
| Default folder | X6GRezwJlAgaoedehQQ6En2z8dqbropQ |
| Folder node | Kx9mRzJWqPpvo939iQQ7vRAyJGXn6lpz |
| Sample doc | dxXB52LJqnX4ovLvfMoneyXo8qjMp697 |
Useful commands:
dws doc search --query "API" --format json
dws doc list --workspace Y7kmbeElo8lkqXLq --format json
dws doc info --node dxXB52LJqnX4ovLvfMoneyXo8qjMp697 --format json
dws doc read --node dxXB52LJqnX4ovLvfMoneyXo8qjMp697 --format json
dws doc create --name "TestDoc" --markdown "# Title" --yes --format json
dws doc update --node dxXB52LJqnX4ovLvfMoneyXo8qjMp697 --content "new text" --mode append --yes --format json
dws doc block list --node dxXB52LJqnX4ovLvfMoneyXo8qjMp697 --format json
dws doc comment list --node dxXB52LJqnX4ovLvfMoneyXo8qjMp697 --format json
Doc command notes:
doc createuses--name; optional content is--markdown.doc updateuses--node,--contentor--content-file, and--mode overwrite|append. In the current mock,--content-fileis treated as the literal argument value; use--contentfor behavioral tests unless this gap is being fixed.doc info/read/update/... --nodeworks with raw node IDs and/i/nodes/<id>URLs.doc block insertanddoc block updateexpect--elementJSON.doc block deleteis irreversible in local mock state; confirm before adding--yes.
Mock State
State is JSON on disk:
- Default state: generated from
src/fixtures/documents.jsonplus defaults insrc/state.js - Runtime state:
$DWS_MOCK_HOME/state.json - Optional config:
$DWS_MOCK_HOME/config.json
src/fixtures/documents.json contains the initial document environment: workspace IDs, folder relationships, document nodes, blocks, comments, and content. src/state.js adds the default workspace ID, default folder ID, and mock user metadata used for creator fields.
Supported state controls:
DWS_MOCK_RESET=1 dws doc list --format json
dws mock-reset
dws mock-inject --file custom-state.json
Config options:
{
"latency": 0,
"errorRate": 0
}
Extending The Mock
- Read the real command reference in
../dingtalk-workspace-cli/docs/command-index.md. - Read the real doc product reference in
../dingtalk-workspace-cli/skills/mono/references/products/doc.md. - Register the command in
src/commands/doc.js. - Add or update
src/fixtures/documents.jsonif the command needs state. - Keep response envelopes close to the real CLI and include stable mock IDs where useful.
- Update
src/commands/schema.jswhen the command should be discoverable throughdws schema. - Verify the CLI and service health paths before publishing the mock.
Version History
- 42693bb Current 2026-08-08 08:00


