dsh-arcgispro: Enabling DeepSeek Harness to Operate ArcGIS Pro via a Persistent arcpy Bridge

Introduction

In DeepSeek Harness (DSH), doing GIS automation usually involves spawning a separate Python process for each call and executing import arcpy. Measured cold start import takes about 20 seconds, warm start about 7 seconds, while a single tool call takes only 5-40ms. If the agent spawns a process at every step, time is wasted on repeated loading, and it is difficult to maintain a consistent state with .aprx projects, maps, layers, and layouts.

dsh-arcgispro is a client-side plugin for DSH, maintained by haiwenxiang061-dev. It starts a resident Python bridge in the background and communicates with the host via JSON Lines: the first tool call pays the import cost, and subsequent calls use the warm process. It exposes 87 wrapped tools, covering approximately 1,977 geoprocessing capabilities, and supports project read/write, maps and layers, layout export, feature class read/write, licensing, and environment variables.

What is this

The plugin is available in the npm package dsh-arcgispro, current release version 0.1.2, under the MIT license. It requires Node.js ≥ 22 and DSH >=0.2.0-rc.2 <0.3.0-0.

One-sentence positioning: Connects ArcGIS Pro’s arcpy capabilities to the DSH tool call surface, avoids repeated import costs via a resident bridge, and reduces the risk of accidental disk modifications through explicit write authorization.

Community directory page: https://www.skillhub.cn/plugins/haiwenxiang061-dev/dsh-arcgispro. Source code and documentation: https://github.com/haiwenxiang061-dev/dsh-arcgispro. SkillHub is an independent community directory, with no official affiliation with DeepSeek or Huafang.

Why a Resident Bridge is Necessary

The design motivation provided in the README is straightforward: import arcpy cold start is about 20.6s, warm start about 7.2s; after the bridge process is started, call latency is in the millisecond range.

The bridge process also separates the protocol channel from GP output: GP tools print Chinese progress to stdout; mixing this with JSON Lines would break parsing. The implementation redirects fd1 to the protocol channel, points sys.stdout to stderr, and ensures only protocol JSON goes through the agreed channel, while GP prints go to stderr.

Core Feature Overview

Below is a summary of the tool families listed in the README; facts are based on the repository documentation.

Status, License, and Environment

  • arcgis_status (including restart)
  • arcgis_license (info / checkout / checkin / setProduct)
  • arcgis_environment (read/write 74 GP environment variables)

GP Tool Catalog and Execution

  • arcgis_tool_list, arcgis_tool_info
  • arcgis_tool_run: Parameters can be passed by name params or by position args

Arbitrary arcpy Code

  • arcgis_python: Executes Python within the bridge process; the namespace already includes arcpy, arcutil, and the current project aprx; the script’s result is returned along with stdout/stderr. Requires writeAllowed: true, has no parameter validation, and no rollback.

Projects, Maps, Layers, and Layouts

Projects: arcgis_project_open / info / new / save / close / broken_sources.

Maps and Layers: arcgis_map_*, arcgis_layer_*, as well as the layout series arcgis_layout_*.

Map Series: arcgis_mapseries_info / create / export.

Selection and Data: arcgis_select_*; arcgis_data_* covers query, statistics, CRUD, database/table creation, merging, etc.

Projection and Formats: arcgis_reproject, arcgis_define_projection, arcgis_convert_data.

Raster, Annotation, etc.: Includes arcgis_raster_*, basemaps and .lyrx, bookmarks, CIM-related tools, etc. (See the “Tools (87)” section in the GitHub README for the full list).

Three Design Constraints

It is recommended to understand these three points before installing and using to avoid inconsistencies with expectations.

  1. Changes only occur in memory; project_save is the only step that writes to disk. Layer visibility, symbology, definition queries, and adding/removing data all operate on memory project objects; a series of operations must be either saved as a whole or discarded as a whole.

  2. Calls are serialized. Since arcpy is not thread-safe, the bridge internally uses a queue to serialize calls, and concurrent calls will be queued.

  3. Write operations require explicit writeAllowed: true. Operations like writing projects, modifying data, deleting fields, or exporting files will be rejected if authorization is missing; arcgis_data_delete also requires allowAll: true when the where clause is empty.

Installation and Activation

Plugins in the DSH ecosystem are installed via dsh plugin; the host must already have plugin_manager (built into dsh-base). After installation, refresh the page; you will see ArcGIS Pro Bridge marked inline in Settings → Plugins.

Replace web or desktop with your actual profile: desktop corresponds to the ArcGIS Pro desktop profile with a window, web corresponds to the browser profile.

dsh plugin --profile web add dsh-arcgispro
dsh plugin --profile desktop add dsh-arcgispro

You can check the latest npm version with the following command:

npm view dsh-arcgispro version

Method 2: Install from GitHub (bypassing npm)

Use the tarball via codeload to avoid common git transmission resets in China:

dsh plugin --profile web add https://codeload.github.com/haiwenxiang061-dev/dsh-arcgispro/tar.gz/refs/tags/v0.1.2
dsh plugin --profile desktop add https://codeload.github.com/haiwenxiang061-dev/dsh-arcgispro/tar.gz/refs/tags/v0.1.2

Or use the Release attachment:

dsh plugin --profile desktop add https://github.com/haiwenxiang061-dev/dsh-arcgispro/releases/download/v0.1.2/dsh-arcgispro-0.1.2.tgz

Note: dsh plugin forwards arguments to pnpm in the profile directory, so pnpm must be available on your machine (e.g., npm i -g pnpm).

Python Interpreter Location

The bridge looks in the following order: configuration item python -> environment variable DSH_ARCGISPRO_PYTHON -> registry key HKLM\SOFTWARE\ESRI\ArcGISPro InstallDir -> common installation root directory. The default environment is <InstallDir>\bin\Python\envs\arcgispro-py3\python.exe.

Typical Usage

The examples below come from the README, demonstrating “check the parameter contract first, then run GP” as well as common data and export chains.

Run a GP Tool

First use arcgis_tool_info to see the parameter names, then arcgis_tool_run passing by name:

arcgis_tool_info analysis.Buffer
arcgis_tool_run  analysis.Buffer
# params: { in_features, out_feature_class, buffer_distance_or_field }

Create Database, Insert, and Buffer

arcgis_data_create_gdb      → arcgis_data_create_featureclass → arcgis_data_insert
arcgis_data_query           → geometry fields return {wkt, type, area, length}
arcgis_tool_run analysis.Buffer → output feature class is saved to disk

Open Project, Update Layer, Save, and Export

arcgis_project_open  → arcgis_layer_update (definition query/visibility) → arcgis_project_save
                     → arcgis_layout_export (formal export with legend and scale)

Disk-writing steps need to include writeAllowed: true on the DSH side according to plugin conventions (specifically check the runtime tool schema).

Use Cases and Notes

Suitable for: Developers who have installed ArcGIS Pro on Windows and wish to stably call arcpy/GP within DSH agents or command-line workflows, without paying the full import cost for every call.

Permissions and Security: The plugin runs with the permissions of the current DSH process. Although write operations have the writeAllowed threshold, the capabilities of arcgis_python are extensive. It is recommended to read the source code and the MIT license before installation to ensure consistency with unit data and licensing strategies.

Environment and Encoding: The bridge process is fixed to PYTHONIOENCODING=utf-8 and PYTHONUTF8=1 to avoid garbled text in cp936 for Chinese paths and GP messages. After migrating a project, you can use arcgis_map_info to check the dataSource / dataSourceMissing of layers to determine if connections are broken.

Common Pitfalls Measured in README (such as SHAPE@, using arcpy.Exists for gdb paths, MapSeries member limitations, arcgis_map_new being slower on Pro 3.6, etc.) have been partially handled at the bridge or tool layer. See the repository documentation for details; this section will not expand on them.

Conclusion

dsh-arcgispro connects ArcGIS Pro’s arcpy and GP capabilities to DSH: a resident bridge lowers the cost of repeated imports, 87 tools cover projects, maps, data, rasters, and export, and serial calls along with write authorization constrain process-level global state and disk modifications.

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

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

Xiaoye