dsh-arch-grower 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tobiichieigetsu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # dsh-arch-grower
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 在 DeepSeek Harness 里驱动 [arch-grower](../) 的插件:注册 `arch_*` 工具,让 agent 直接在对话里推进架构推演,不必切终端。Python 引擎零依赖,插件通过子进程调用项目内嵌的 CLI。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g dsh-arch-grower
9
+ ```
10
+
11
+ 随后在 DSH 里启用本插件(插件默认不自动启用)。
12
+
13
+ ## 前置条件
14
+
15
+ - 本机有 `python`(Windows 上通常是 `python`,可用插件配置 `python` 覆盖)
16
+ - 目标项目已经内嵌引擎:项目根目录存在 `.arch/scripts/arch_cli.py`。没有就先在项目里跑 `python -m arch_grower bootstrap`
17
+
18
+ ## 项目定位
19
+
20
+ 插件按以下顺序决定操作哪个项目:
21
+
22
+ 1. 插件配置里的 `projectDir`
23
+ 2. 环境变量 `ARCH_ROOT`
24
+ 3. 会话当前工作目录
25
+
26
+ 都没有且当前目录不是 arch-grower 项目时,工具会返回可操作的提示,而不是空结果。
27
+
28
+ ## 工具
29
+
30
+ | 工具 | 作用 | 写盘 |
31
+ | :--- | :--- | :--- |
32
+ | `arch_status` | 阶段、节点数、焦点、下一步建议 | 否 |
33
+
34
+ 后续版本陆续加入 `arch_focus`、`arch_facts`、`arch_collapse`、`arch_add_node`,见仓库 `.scratch/dsh-plugin/issues/` 下的工单。
35
+
36
+ ## 配置示例
37
+
38
+ ```yaml
39
+ - insert:
40
+ - id: arch-grower
41
+ name: dsh-arch-grower
42
+ config:
43
+ projectDir: D:/github-downloader
44
+ python: python
45
+ ```
46
+
47
+ ## 已知限制
48
+
49
+ - 目前只有服务端工具,右侧栏看板面板尚未加入。
50
+ - 依赖 `@deepseek-ai/cordis ~4.1.0` 与 `@deepseek-ai/dsh-tools 0.2.2-rc.5`;与本机 DSH 版本不一致时插件可能加载失败。
51
+
52
+ ## 许可
53
+
54
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: arch-grower
3
+ name: dsh-arch-grower
package/lib/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "arch-grower";
3
+ export declare const inject: string[];
4
+ export interface Config {
5
+ /** 项目根目录;缺省时依次看 ARCH_ROOT 与会话 cwd。 */
6
+ projectDir?: string;
7
+ /** Python 可执行文件,缺省 python。 */
8
+ python?: string;
9
+ }
10
+ export interface RunResult {
11
+ code: number;
12
+ stdout: string;
13
+ stderr: string;
14
+ }
15
+ /** 唯一对外接缝:给定命令行参数,返回退出码与输出。测试用它注入假实现。 */
16
+ export type Runner = (args: string[]) => Promise<RunResult>;
17
+ /** 项目目录解析顺序:显式配置 > ARCH_ROOT > 当前工作目录。 */
18
+ export declare function resolveProjectDir(explicit?: string, env?: Record<string, string | undefined>, cwd?: string): string;
19
+ /** 把引擎的失败变成可操作的一句话,原文照给,不改写。 */
20
+ export declare function toUserError(result: RunResult): string;
21
+ /** 子进程 runner:在项目目录下调用内嵌 CLI。 */
22
+ export declare function makeRunner(projectDir: string, python: string): Runner;
23
+ /** 只读:当前项目状态。 */
24
+ export declare function archStatus(run: Runner): Promise<{
25
+ content: string;
26
+ }>;
27
+ export declare function apply(ctx: Context, config?: Config): void;
package/lib/index.js ADDED
@@ -0,0 +1,82 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { defineTool } from '@deepseek-ai/dsh-tools';
5
+ export const name = 'arch-grower';
6
+ export const inject = ['tools'];
7
+ const output = {
8
+ schema: {
9
+ type: 'object',
10
+ additionalProperties: false,
11
+ properties: { content: { type: 'string', required: true } },
12
+ },
13
+ render: (_args, value) => [{ type: 'text', text: value.content }],
14
+ };
15
+ /** 项目目录解析顺序:显式配置 > ARCH_ROOT > 当前工作目录。 */
16
+ export function resolveProjectDir(explicit, env = process.env, cwd = process.cwd()) {
17
+ const configured = explicit?.trim();
18
+ if (configured) {
19
+ return configured;
20
+ }
21
+ const fromEnv = env.ARCH_ROOT?.trim();
22
+ if (fromEnv) {
23
+ return fromEnv;
24
+ }
25
+ return cwd;
26
+ }
27
+ /** 把引擎的失败变成可操作的一句话,原文照给,不改写。 */
28
+ export function toUserError(result) {
29
+ const detail = (result.stderr || result.stdout).trim();
30
+ return detail || `arch_cli 退出码 ${result.code}`;
31
+ }
32
+ /** 子进程 runner:在项目目录下调用内嵌 CLI。 */
33
+ export function makeRunner(projectDir, python) {
34
+ const cli = join(projectDir, '.arch', 'scripts', 'arch_cli.py');
35
+ return (args) => {
36
+ if (!existsSync(cli)) {
37
+ return Promise.resolve({
38
+ code: -1,
39
+ stdout: '',
40
+ stderr: `没找到 ${cli}。这个项目还没有内嵌引擎:先在项目根目录运行 ` +
41
+ '`python -m arch_grower bootstrap`,或把本插件的 projectDir 指向已有 .arch 的项目。',
42
+ });
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ const child = spawn(python, [cli, ...args], { cwd: projectDir, windowsHide: true });
46
+ let stdout = '';
47
+ let stderr = '';
48
+ child.stdout.on('data', (chunk) => {
49
+ stdout += String(chunk);
50
+ });
51
+ child.stderr.on('data', (chunk) => {
52
+ stderr += String(chunk);
53
+ });
54
+ child.on('error', reject);
55
+ child.on('close', (code) => {
56
+ resolve({ code: code ?? -1, stdout, stderr });
57
+ });
58
+ });
59
+ };
60
+ }
61
+ /** 只读:当前项目状态。 */
62
+ export async function archStatus(run) {
63
+ const result = await run(['status']);
64
+ if (result.code !== 0) {
65
+ throw new Error(toUserError(result));
66
+ }
67
+ return { content: result.stdout.trim() };
68
+ }
69
+ export function apply(ctx, config = {}) {
70
+ const projectDir = resolveProjectDir(config.projectDir);
71
+ const python = config.python?.trim() || 'python';
72
+ const run = makeRunner(projectDir, python);
73
+ ctx.effect(() => ctx.tools.register(defineTool({
74
+ name: 'arch_status',
75
+ description: '读取 arch-grower 项目的架构状态:阶段、节点数、当前焦点与下一步建议。只读。',
76
+ parameters: {},
77
+ output,
78
+ async execute() {
79
+ return archStatus(run);
80
+ },
81
+ })));
82
+ }
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "dsh-arch-grower",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "在 DeepSeek Harness 里驱动 arch-grower:注册 arch_* 工具,并在右侧栏展示架构图。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "files": [
8
+ "lib",
9
+ "cordis.patch.yml",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "dsh": {
14
+ "bundle": {
15
+ "patch": "./cordis.patch.yml"
16
+ }
17
+ },
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "peerDependencies": {
22
+ "@deepseek-ai/cordis": "~4.1.0",
23
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5"
24
+ },
25
+ "devDependencies": {
26
+ "@deepseek-ai/cordis": "~4.1.0",
27
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5",
28
+ "tsdown": "^0.15.0",
29
+ "typescript": "^5.6.0",
30
+ "@types/node": "^22.0.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "test": "node --test test/"
35
+ }
6
36
  }