Kingsoft Docs CLI Skill provides a complete set of online document operation tools, interacting with the Kingsoft Docs API through the kdocs-cli command-line tool. It supports creating, querying, reading, editing, sharing, and moving multiple types of online documents.
Strict Rules
NEVER
- NEVER allow the Token to appear in plaintext in conversations, logs, command output, code comments, or any file; the Token may only be saved to the system keychain via
kdocs-cli auth set-tokenorkdocs-cli auth loginSave to system keychain - Interfaces such as upload and write require passing in a
content_base64that may be very large (over 1 MB after encoding). NEVER generate the Base64 string token by token in the conversation; use a script to read the file, encode it, and pass the parameter
MUST
- Before executing irreversible operations (delete/close type), confirmation must be obtained from the user
- After a write operation is completed, an independent read request must be used to verify the actual result (do not trust
code: 0) - After creating a document and verifying it passes, you must call
get_file_linkto get the link and show it to the user - Temporary JSON files created via
--fileor scripts (such aspayload.json、temp.json) must be deleted after the entire operation process ends, to avoid leaving residue in the user's working directory
Keep the latest version
When to trigger:First use Skill / More than 24h since the last self-check / Received unknown action or unknown service error。
- CLI version:
kdocs-cli version— if the command does not exist, install it according to "Tool Installation and Authentication" below; if it is lower than the frontmatterversionin this file, runkdocs-cli upgrade -y(automatically backs up the old version; on failure you cankdocs-cli upgrade --rollback) - Skill version: if this file's
versionis lower thankdocs-cli version, runkdocs-cli call check_skill_update version=<本文件version>, if it returnsupdate_available: true, extract the zip download link frominstruction(formathttps://...kdocs.zip), download, extract, and replace the current Skill directory
If both upgrade and rollback fail, rerun the installation script in this Skill directory (bash setup.sh / powershell setup.ps1 / node setup.cjs, the script is located at scripts/) to reinstall from the CDN. If it still cannot be updated, rely on the toolset actually supported by kdocs-cli --help .
Tool Installation and Authentication
| Operation | Command |
|---|---|
| Install | bash scripts/setup.sh / powershell scripts/setup.ps1 / node scripts/setup.cjs |
| Authenticate | User has provided Token: kdocs-cli auth set-token "<token>" · No Token: kdocs-cli auth login |
For the manual acquisition process when login fails,auth status diagnosis,auth logout logout, etc., see references/auth.md。
Invocation Format
kdocs-cli [parameters]
Parameter Passing
| Parameter characteristics | Recommended method | Example |
|---|---|---|
| Simple value (no Chinese) | key=value | kdocs-cli drive search-files keyword=test type=all |
| Array/object, short JSON | JSON string | kdocs-cli sheet query-records '{"file_id":"xxx","filter":{}}' |
| Array/object, or contains Chinese/newlines/>200 characters | --file | kdocs-cli otl insert-content --file payload.json |
| Script pipeline integration | stdin | node gen.js | kdocs-cli otl insert-content - |
--file/ stdin input must be that tool'sFull JSON parameter object- Chinese/multiline parametersProhibited key=value (Windows/PowerShell corrupts UTF-8 encoding)
- Generate JSON files with Node.js/Python;Prohibited ConvertTo-Json (output includes BOM)
- PowerShell must escape JSON strings with backslashes:
'{\"key\":[\"val\"]}'
--file example: when writing large amounts of content, use a script to generate a JSON file and then
--filepass it in; delete the temporary file after the operation is complete:const fs = require('fs'); fs.writeFileSync('payload.json', JSON.stringify({ file_id: "<file_id>", content: fs.readFileSync('article.md', 'utf8'), format: "markdown", mode: "append" }), 'utf8');kdocs-cli otl insert-content --file payload.json --silent// 操作完成后清理临时文件 fs.unlinkSync('payload.json');
Global options:
| Option | Description |
|---|---|
--token <token> |
One-time Token (highest priority, not persisted) |
--endpoint <url> |
Override default endpoint |
--compact |
Output compact JSON |
--silent |
Output only the data field |
--verbose |
Output request details to stderr |
--timeout <ms> |
HTTP request timeout (milliseconds, default 30000) |
Help:kdocs-cli --help、kdocs-cli <service> --help、kdocs-cli <service> <action> --help
The following tools are irreversible; you must confirm with the user before invoking them (for detailed constraints, see the "Operation Constraints" section in each tool's reference documentation):
otl.block_delete、dbsheet.delete_sheet、kwiki.close_knowledge_view、sheet.delete_sheets、sheet.delete_range、dbsheet.delete_view、dbsheet.delete_fields、cancel_share、kwiki.delete_item、sheet.delete_protection_ranges、dbsheet.delete_records、sheet.delete_data_validations、sheet.delete_conditional_format_rules、sheet.delete_float_images、sheet.delete_filters、dbsheet.sheet_batch_delete、dbsheet.permission_delete_roles_async
Capability scope
Supported document types
| Type | Alias | File extension | Description | Detailed reference |
|---|---|---|---|---|
| Smart document preferred | ap | .otl | Beautiful layout, supports rich components | references/otl.md — operations on pages, text, headings, to-dos, and other elements |
| Table | et / Excel | .xlsx | Dedicated to data tables | references/sheet.md — worksheet management, range data retrieval, batch updates |
| PDF document | Dedicated to PDF documents | references/pdf.md — PDF creation and content reading |
||
| Word document | wps / Word | .docx | Traditional format | references/wps.md — Word document creation and content operations |
| Presentation | wpp | .pptx | Dedicated to PPT documents | references/wpp.md — slide theme font and color scheme settings, download and export |
| Smart table | as | .ksheet | Structured table, supports multiple views and field management | references/sheet.md — worksheet management, range data retrieval, batch updates |
| Multi-dimensional table | db / dbsheet | .dbt | Multiple data tables, rich field types and views (table/kanban/gantt, etc.) | references/dbsheet.md — supports full CRUD for data tables/views/fields/records, including form views, parent-child records, sharing and collaboration, advanced permissions, and Webhooks |
General tools overview
Document creation and upload
| Tool | Purpose |
|---|---|
create_file |
Create a new file in the cloud drive |
scrape_url |
Web page clipping: scrape web page content and automatically save it as a smart document |
scrape_progress |
Query web page clipping task progress |
upload_file |
Full upload to write files (update an existing docx/pdf or create and upload a local file) |
Document reading and download
| Tool | Purpose |
|---|---|
list_files |
Get the list of subfiles under the specified folder |
download_file |
Get file download information |
read_file_content |
Extract document content as Markdown/plain text |
File organization
| Tool | Purpose |
|---|---|
move_file |
Batch move files (folders) |
rename_file |
Rename files (folders) |
Sharing and access
| Tools | Purpose |
|---|---|
share_file |
Enable file sharing |
set_share_permission |
Modify sharing link properties |
cancel_share |
Cancel file sharing |
get_share_info |
Get sharing link information |
get_file_link |
Get the cloud document online access link for a file |
Search
| Tools | Purpose |
|---|---|
search_files |
File (folder) search |
For complete parameters, examples, and return values, see references/drive.md。
Unsupported operations
- No batch delete files tool (only move is supported)
- The cloud drive side currently has no per-file ACL member matrix (sharing links are the main mechanism); for multi-dimensional tables (.dbt), see dbsheet.permission_* and dbsheet.share_* (see references/dbsheet.md for details)
- For online Excel / smart sheet worksheet range protection, see the sheet.*_protection_ranges related tools (see references/sheet.md for details)
- No file version rollback
- No real-time collaborative editing control
Operation guide
Execution guide
Before performing the following operations,you mustfirst read the corresponding guide file:
| Operation type | Guide file | When to read |
|---|---|---|
| File identifier retrieval guide | references/file-locating-guide.md |
When you need to search or browse files |
| File reading guide | references/file-reading-guide.md |
When you need to get document content |
| File creation and writing guide | references/file-writing-guide.md |
When you need to create or edit a document |
⚠️ Operating directly without reading the guide may cause: parameter errors, content loss, format anomalies.
High-frequency process guidance
Create and write a document
Execution order:
- First, according to
references/file-locating-guide.mdget the target directorydrive_id(optional),parent_id(optional). - Then, according to
references/file-writing-guide.mdselect the document type and write path. Field passing: Step 1 obtainsdrive_id(optional),parent_id(optional), as the input for step 2, and executes the "new write" process.
Upload local files to the cloud drive
Execution order:
- First, according to
references/file-locating-guide.mdget the target directorydrive_id(optional),parent_id(optional),file_id(optional). - Then, according to
references/file-writing-guide.md's "local file upload (upload_file)" path, call the upload capability (new upload or overwrite update). Field passing: New upload uses step 1'sdrive_id(optional),parent_id(optional) +name; overwrite update uses step 1'sfile_id。
Search and locate documents
Tool description:search_files(keyword="关键词", type="all", page_size=20), get file_id、drive_id for use in subsequent chains.
For detailed parameters and return structure, see references/drive/search.md。
More operation processes
| Process | Description | Detailed reference |
|---|---|---|
| AI-generated presentation (full text) | aippt.execute single-interface full-text generation chain: two calls complete requirement clarification and generation, supports two sources: topic/document, and uses html mode by default | references/workflows/aippt-whole.md |
| Web page clipping | Scrape web page content and automatically save it as a smart document | references/workflows/web-scrape.md |
| Search-Read-Report Writing | Search multiple documents, extract information, and compile a new report | references/workflows/search-read-report.md |
| Scheduled Reading and Broadcasting | Regularly read specified documents, extract key information, and generate summaries | references/workflows/periodic-read-summary.md |
| Smart Classification and Organization | List directories, create folders by content or specified dimensions, and archive | references/workflows/smart-classify.md |
| Precise Search and Risk Investigation | Batch search documents in a specific directory, read and analyze each one, and compile into a new document | references/workflows/precise-search-analysis.md |
| Import Cloud Document Slides | Import specified slides from an external PPTX file into an existing presentation | references/workflows/import-slides.md |
| Convert Sign-up Chain to Table | Recognize sign-up chain text content, automatically extract it, and convert it into an online table | references/workflows/jielong-to-table.md |
| Information Collection Form Generation | Automatically design and create information collection forms based on user needs | references/workflows/form-generator.md |
| Smart Knowledge Organization | Intelligently organize and structurally reorganize scattered content in the knowledge base | references/workflows/knowledge-format.md |
| One-Click Knowledge Saving | Save various types of content (web pages, files, text) to the knowledge base with one click | references/workflows/knowledge-save.md |
| Table Beautification and Data Standardization | Read table data, perform format beautification, data standardization, and style adjustments, and solidify rules through conditional formatting, data validation, and range permissions | references/workflows/table-beautify.md |
Quick Error Lookup
| Error Feature | Cause | Handling Method |
|---|---|---|
400006 / Authentication Failed |
Token expired or not configured | Run kdocs-cli auth login to log in again, or kdocs-cli auth set-token <token> to set it again |
Expecting value: line 1 column 1 (char 0) or similar JSON parsing failure |
The upstream returned an empty response or non-JSON (HTML error page / redirect / gateway error), not a crash of the CLI itself. Common triggers: incorrect file ID, file deleted, no access permission, Token expired but did not trigger 400006, temporary network interruption | Troubleshoot in order: ① kdocs-cli auth status confirm the Token is valid; ② use kdocs-cli drive search or kdocs-cli wps file_info to recheck the file_id; ③ confirm the current account has read permission for the file (verify by opening the link in the Kingsoft Docs web client); ④ wait 3-5 seconds and retry once; if it still fails, report to the user |
429001 / Rate Limited |
Requests are too frequent, response containsrate limit recovery time | Immediately stop command calls until the recovery time is reached; do not immediately retry, change parameters, or continuously request with different subcommands |
429002 / Circuit Breaker |
Multiple consecutive triggers of 429001 within a short time, response containscircuit breaker duration |
Make zero requests during the circuit breaker duration, then try again after it expires; replan the task to avoid overly frequent requests |
unknown action / unknown service |
CLI version is too old or the name is misspelled | First run kdocs-cli upgrade to upgrade to the latest version; if it still reports an error, then run kdocs-cli <service> --help to confirm available commands |
| No search results | Keywords too precise / index delay | Shorten keywords / wait 3-5 seconds and retry |
| Read content is empty | The file has no content or the format is not supported | Confirm the file is non-empty and the extension is correct |
| Failed to create file | Incorrect file name extension | Check extension:.otl / .docx / .xlsx / .ksheet / .dbt / .pdf / .pptx |
| Failed to move file | Target folder does not exist | Search to confirm or create the folder first |
| HTTP 5xx / timeout | Server-side failure | Wait 3 seconds and retry once |
| Validation failed (read-back value does not match expected) | Write did not take effect or is delayed | Wait 2 seconds and re-validate; if still failing, report to the user |
setup.sh Execution failed / installation error |
The current version may no longer be compatible | Run the "Keep the latest version" process above |
| CLI interface returned an unknown error code (not 5xx, not 400006, not 429001/429002, not tool not found) | Skill version is too old, causing interface incompatibility | Run the "Keep the latest version" process above |
Error message contains version、incompatible、not_supported、deprecated and other version keywords |
Skill or API version is incompatible | Run the "Keep the latest version" process above |
| Tool call failed for an unknown reason | May be because the Skill version is too old | Run the "Keep the latest version" process above |
| The above handling methods have all been tried but the issue still cannot be resolved | Unknown issue | Run kdocs-cli feedback to get the feedback link, and guide the user to submit feedback |
| Tool call failure requires determining whether it can be retried | Different tools have different idempotency | Check the idempotency description in the "Operation Constraints" section of the tool's reference documentation; idempotent tools can be safely retried, while non-idempotent tools must have their state confirmed first |
Security constraints
- Credentials are managed by the
kdocs-clisystem keychain; the Skill itself does not store or log them - Stateless proxy; does not cache any document content or business data
- Calls the corresponding API only when the user actively initiates an operation
WPS Cloud Document Skill (wps skill) issue feedback
When any of the following conditions is met, generate a feedback link and provide it to the user:
- The handling methods in the error quick reference table (retry, keep the latest version, etc.) have all been tried but the issue still cannot be resolved
- The user proactively requests feedback or files a complaint
Run kdocs-cli feedback to get the feedback link, show the complete link to the user and tell them "click to open the feedback page"; the user decides whether to open it.