ArchMap: A Static Python Architecture Map Plugin

Introduction

When developing agents with DSH, you frequently need to understand the structure of a Python project: what modules exist, what the entry points actually do, where a particular method is called from, and how broad the blast radius of a change might be. The common approach is to read through source code, run a static analysis tool, and then manually draw diagrams or inspect dependency graphs. These methods either require installing extra tooling, or they require executing code during analysis, or they rely on an LLM to generate content — all of which can introduce noise.

Below is an introduction to a plugin: it uses static AST analysis to map a Python project into an interactive architecture map, and generates a self-contained single-file HTML locally. No code execution, no network access, and no LLM token consumption required.

What Is This

ArchMap is a static Python architecture mapping tool, provided as a DSH plugin. It parses a project into execution flows, module capability surfaces, and method details, and outputs a self-contained HTML file. The DSH plugin is responsible only for bridging DSH tools with the built-in Python core modules (AST analysis, graph projection, validation, and HTML rendering). The Python core ships inside the plugin package.

Core Capabilities

  • Project Overview & Execution Flow: The project page displays the execution flow skeleton of entry points (branches, loops, returns, dispatch) along with module capability cards.
  • Module Capability Surface: The module page shows the classes, providers, public APIs, and type relationships exposed by that module.
  • Method Details: The method page displays source code slices, callers, callees, and unresolved call relationships.
  • Impact Analysis: By comparing architecture JSON files before and after a change, it outputs the affected methods and modules.
  • Dependency Structure Matrix: Generates a module-level or provider-level Dependency Structure Matrix (DSM).
  • Read-Only Queries: Supports querying call chains, dependency surfaces, etc. from the architecture JSON for a given function, without modifying any files.
  • LLM Annotation Assist: Generates semantic annotations via archmap annotations; the Python side determines which ones are valid.

Installation & Activation

Install the ArchMap plugin in DSH (using the official command):

dsh plugin --profile web add github:MerlinSassoon/dsh-archmap-explorer
dsh --profile web --dump-config        # expected id: tool-archmap

The plugin package ships with a pre-compiled tarball, and can also be installed by downloading:

dsh plugin --profile web add \
  https://github.com/MerlinSassoon/dsh-archmap-explorer/releases/latest/download/dsh-archmap-explorer.tgz

Typical Usage

Create an archmap.config.json in the root directory of your Python project (minimal configuration example):

{
  "projectName": "my-project",
  "language": "python",
  "include": ["src/**/*.py"],
  "exclude": ["**/__pycache__/**", "**/.venv/**"],
  "entrypoints": ["src.app.main:main"],
  "executionEntrypoints": ["src.app.main:App.run"],
  "modules": [
    {
      "id": "app",
      "name": "Application entry",
      "include": ["src/app/**"],
      "note": "Entry points, configuration and top-level orchestration.",
      "role": "service"
    }
  ]
}

After installation, use it via DSH skills or commands:

  • Build the architecture map (generates architecture.json and architecture.html):
  • Use archmap_build (DSH skill/command).
  • Or run archmap build . directly in the project directory (requires Python dependencies to be installed first, see below).

  • Validate the architecture JSON structure:

  • archmap check architecture.json

  • Query the impact scope (compare before/after JSON):

  • archmap impact before.json after.json

  • Query the call chain:

  • archmap trace architecture.json --from <function-id> [--direction inbound]

  • Generate a Dependency Structure Matrix:

  • archmap dsm architecture.json [--level module|provider]

  • Use LLM annotation assist:

  • archmap annotations context architecture.json --scope functions --json
  • archmap annotations apply architecture.json --proposal proposal.json --provider <id> --model <id>

Use Cases & Notes

Suitable for scenarios where you need a static understanding of a Python project’s structure, such as:

  • Understanding module boundaries and entry-point flows in legacy code
  • Assessing the impact scope before making changes
  • Viewing the architecture map in offline or air-gapped environments

Note: The plugin runs with the permissions of the current DSH process. It is recommended to review the GitHub repository and documentation before installing, to confirm the license and implementation details.

In Short

ArchMap generates interactive architecture maps through static analysis, making it ideal for quickly understanding the structure and call relationships of Python projects within a DSH workflow. The plugin package includes the Python core and DSH tool bridge, requiring no additional pip installation. For more details and examples, see:

  • Directory page: https://www.skillhub.cn/plugins/MerlinSassoon/dsh-archmap-explorer
  • GitHub: https://github.com/MerlinSassoon/dsh-archmap-explorer
羽毛球分组比赛记分
小程序二维码

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

Xiaoye