Usage
cd <the_skill_dir_path>/scripts
python3 cli.py config check
python3 cli.py search "关键词1 关键词2 关键词3"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>"
python3 cli.py read <node_id>
Configuration
First run configuration validation:
python3 cli.py config check
These configurations are required:
| Configuration | Purpose | How to obtain |
|---|---|---|
DINGTALK_APP_KEY |
Call the DingTalk Open Platform API | DingTalk Open Platform -> Application Management -> Enterprise Internal Application -> Credentials and Basic Information |
DINGTALK_APP_SECRET |
Obtain API token | Same as above, view in the application credential information |
DINGTALK_MY_USER_ID |
Current operator identity | Admin Console -> Contacts -> Member Management -> Click a member to view userId |
DINGTALK_MY_OPERATOR_ID |
operatorId/unionId of the document API | With DINGTALK_MY_USER_ID , it can be automatically converted |
Missing DINGTALK_MY_OPERATOR_ID , execute:
python3 cli.py config to-unionid
What you get
search: Returns a list of matching documents; can use--limit <n>to control the numberread: Returns Markdown; long content will be written to a file and the path returned; non-ALIDOC files will be downloaded as original files- PDF to text:
read <pdf_node_or_url> --mode pdf2textwill first download the PDF, then use the systempdftotext -layoutto output.txt; if the system does not havepdftotext, it will prompt to installpoppler-utils, and fall back to returning the PDF path - Default output: write to the
.skills-workspace/dingtalk-knowledge-search/outputs/ - Project accumulation: use
--output-dir "$PWD/dingtalk-docs" --output-pathto write the result to the current project - Output cache: download/conversion results will be kept in the user-level cache directory, and the remote
modifiedTimewill be reused when unchanged; by default, hard links are used to write to--output-dir, use--output-strategy copyto copy and isolate - Image localization: use
--with img-local, images will be downloaded to the same directory as the Markdown.assets/<文档名>/ - Image proxy: use
--with img, saves local space, but depends on the proxy service and the validity period of the original link - diagram: use
--with diagramto export together
Examples
python3 cli.py search "项目背景 年假 晋升" --limit 10
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>" --output-dir "$PWD/dingtalk-docs" --output-path
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<node_id>" --with img-local --with diagram --output-dir "$PWD/dingtalk-docs" --output-path
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<file_node_id>" --output-dir "$PWD/dingtalk-docs"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<pdf_node_id>" --mode pdf2text --output-dir "$PWD/dingtalk-docs"
python3 cli.py read "https://alidocs.dingtalk.com/i/nodes/<pdf_node_id>" --mode pdf2text --output-dir "$PWD/dingtalk-docs" --output-strategy copy
Cache
searchNot cached, directly query the remote every timenode、resolve-url、blocksStill uses the SQLite API cache, affected by--cache-ttlinfluence- Output file cache is not affected by TTL, uses the remote
modifiedTimeto determine whether to reuse - Default output cache location:
~/.dingtalk-skills/dingtalk-knowledge-search/output-cache/ - Default
--output-strategy link: hard-link the global cache to the current--output-dir, saving space; editing any hard-linked file will affect the same content --output-strategy copy: copy to the current--output-dir, isolated from the global cachepython3 cli.py cache clear --namespace output --yeswill delete output cache records and associated local files
Login
- When a QR code scan is required, the command will return
loginRequired: trueandscreenshotPath - After scanning the QR code, re-execute the same command