dsh-codearts-complete
v0.2.0
Published
DSH tool + settings page: fill a block of code at a cursor position in an existing file via Huawei Cloud CodeArts (thinking disabled, FIM + instruction mode, optional in-place insert).
Maintainers
Readme
dsh-codearts-complete
A DSH tool: code_complete fills a block of code at a cursor position in an existing file, through Huawei Cloud CodeArts.
Give it a file and a 1-based line/column plus an optional one-line instruction; it reads the text before and after the cursor, asks CodeArts, and returns only the insertion — or writes it into the file with apply: true.
write file -> whole files (DSH's write tool)
edit file -> targeted replacements (DSH's edit tool)
code_complete -> "fill 5–20 lines here, keep the surroundings"Why it exists
Most editor autocomplete is a low-latency local model. This is the opposite trade: a 1.5–3 s cloud call that can produce 10–20 correct lines in one shot. Measured on this machine:
| Request | Latency | Output |
| --- | --- | --- |
| body of def add(a, b): | 1.4 s | result = a + b |
| "3 retries, exponential backoff, 10 s timeout" | 3.2 s | 23-line retry loop |
| CSV header-skip parser | 2.4 s | 6 lines |
One thing matters more than the model: enable_thinking: false. The same request without it spends ~190 reasoning tokens and takes ~20 s, often returning an empty message when the token budget runs out.
Requirements
- DSH (DeepSeek Harness) with the Huawei Cloud CodeArts channel signed in, so that
~/.dsh/.codearts-accounts.jsonholds a live STS credential. Thedsh-codeartsplugin (or any CodeArts account plugin) provides that file; this plugin only reads it. - Tools service (
ctx.get('tools')), i.e. any normal DSH host.
Settings (no restart needed)
DSH settings → CodeArts completion:
| Field | What it does |
| --- | --- |
| Enable code_complete | Turn the tool off without uninstalling |
| Default model | CodeArts model id for completions (empty = deepseek-v4.1-flash-1017) |
| Default token budget | Output cap per call (default 256; 400–800 for blocks) |
| Credential file | Empty = ~/.dsh/.codearts-accounts.json; point it at your own JSON if you keep credentials elsewhere |
The fields are volatile row config: saving applies to the next code_complete call, no restart.
Credential sources, in priority order:
CODEARTS_ACCESS_KEY_ID+CODEARTS_SECRET_ACCESS_KEY+CODEARTS_SECURITY_TOKENenvironment variables.- The file configured in settings (or
CODEARTS_ACCOUNTS_FILE), accepting{ "accounts": { ... } }or a single{ accessKeyId, secretAccessKey, token }. ~/.dsh/.codearts-accounts.json, maintained by a DSH CodeArts account plugin such asdsh-codearts.
Install
Through the DSH plugin manager (recommended), or manually in a profile:
// profiles/<name>/package.json
"dependencies": { "dsh-codearts-complete": "0.1.0" }and add "dsh-codearts-complete" to dsh.profile.bundles. Restart DSH afterwards — plugin modules are loaded once at host start.
Tool
{
"path": "D:/repo/src/fetch.ts",
"line": 2,
"column": 3,
"instruction": "add 3 retries with exponential backoff and a 10 s timeout",
"apply": true,
"max_tokens": 500
}| Field | Required | Meaning |
| --- | --- | --- |
| path | yes | File to complete in (absolute, or relative to the workspace cwd) |
| line | yes | Cursor line, 1-based |
| column | no | Cursor column, 1-based (default 1) |
| instruction | no | What to write; omit for plain fill-in-the-middle |
| apply | no | Insert the completion into the file (default false) |
| max_tokens | no | Output budget (default 256; 400–800 for bigger blocks) |
| model | no | CodeArts model id (default deepseek-v4.1-flash-1017) |
Returns text, applied, ms, prompt_tokens, completion_tokens, path/line/column, language.
Notes and limits
- Use it for 5–20 line blocks. A single identifier is not worth a 1.5 s round trip; whole-file generation belongs to
write. - Each call is one CodeArts request and consumes a little quota.
- The STS credential lives ~2 hours; DSH's keeper refreshes
~/.dsh/.codearts-accounts.jsonand this plugin re-reads the file on every call. - CodeArts allows 3 concurrent sessions per account; parallel completions queue.
- Context sent upstream is capped (6 000 chars before the cursor, 2 000 after).
License
MIT
