dsh-codearts-complete: CodeArts Autocomplete Tool

Introduction

In the DSH (DeepSeek Harness) environment, write is typically used to write an entire file, while edit handles localized replacements. When you need to “complete a 5–20 line code block” at the cursor position in a file while keeping the surrounding code unchanged, the existing tool combination requires multiple edits or large-scale replacements, which is not precise enough. dsh-codearts-complete provides a dedicated tool code_complete for this specific scenario, generating and returning the insertion content in one call via Huawei Cloud CodeArts.

Plugin Overview

  • Name: dsh-codearts-complete
  • Maintainer: Raysnows
  • Category: Client plugin
  • Core value: Complete a 5–20 line code block at the cursor position via CodeArts, returning the insertion text or writing it directly to the file

Core Features

  • Tool name: code_complete
  • Input: file path, cursor position (line number, column number), optional instruction, whether to write immediately
  • Output: returns the insertion text, along with call duration, token consumption, and other metadata
  • Default model: deepseek-v4.1-flash-1017 (configurable via settings)

Installation & Enablement

Add the dependency in DSH’s profile configuration:

// profiles/<name>/package.json
"dependencies": { "dsh-codearts-complete": "0.1.0" }

Also add "dsh-codearts-complete" to dsh.profile.bundles. After installation, restart DSH — the plugin module will be loaded at startup.

Enable/configure in DSH Settings → CodeArts completion:

  • Enable code_complete: toggle switch; can be disabled without uninstalling
  • Default model: default model ID; leave empty to use deepseek-v4.1-flash-1017
  • Default token budget: per-call output limit, default 256; set to 400–800 for larger blocks
  • Credential file: path to the credential file; leave empty to use ~/.dsh/.codearts-accounts.json

These settings are line-level volatile — they take effect immediately upon saving, no restart required.

Typical Usage

When calling code_complete, pass the file and cursor position, along with an optional instruction and write options:

{
  "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 descriptions:

  • path: file path (absolute, or relative to the workspace)
  • line: cursor line number, 1-based
  • column: cursor column number, 1-based, defaults to 1
  • instruction: optional directive specifying what to complete
  • apply: whether to write the returned text to the file, defaults to false
  • max_tokens: output token limit, defaults to 256
  • model: specify a CodeArts model ID, defaults to deepseek-v4.1-flash-1017

Example return fields:

  • text: the insertion text
  • applied: whether it has been written to the file
  • ms: call duration in milliseconds
  • prompt_tokens, completion_tokens
  • path/line/column: file and position info
  • language: detected programming language

Use Cases & Notes

  • Suitable for: completing 5–20 line code blocks, such as function bodies, helper functions, small utility functions, etc.
  • Not suitable for: single-identifier completion, whole-file generation (use write instead)
  • Permissions: the plugin runs with the current DSH process’s privileges; review the source code and license (MIT) before installing
  • Concurrency limit: CodeArts allows up to 3 concurrent sessions per account; excess tasks will be queued
  • Credential management: STS credentials are valid for approximately 2 hours; DSH’s keeper refreshes ~/.dsh/.codearts-accounts.json, and the plugin reads this file on each call

Conclusion

dsh-codearts-complete provides a dedicated tool for cursor-based completion via CodeArts in DSH, ideal for quick generation and insertion of 5–20 line code blocks. See the plugin directory and GitHub repository for more details and source code.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye