@nathan-adk/dsh-rea-lazy 1.0.0 → 1.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/README.md +30 -37
- package/cordis.patch.yml +6 -65
- package/lib/index.js +267 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,63 +1,56 @@
|
|
|
1
1
|
# @nathan-adk/dsh-rea-lazy
|
|
2
2
|
|
|
3
|
-
REA 在 DeepSeek Harness(DSH)里的**按需启动配置层** —— DSH
|
|
3
|
+
REA 在 DeepSeek Harness(DSH)里的**按需启动配置层** —— DSH 侧专用。让 REA 的 263 个工具保持可搜索,但 `rea` 进程平时不运行、不烧后台 token。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 工作原理(v1.1.0 起自动探测)
|
|
6
6
|
|
|
7
|
-
REA
|
|
7
|
+
插件激活时自动探测本机 REA,按以下优先级:
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2.
|
|
9
|
+
1. 环境变量 `REA_COMMAND` —— 手动指定完整命令(最高优先级)
|
|
10
|
+
2. PATH 上的 `rea` 命令(标准 `npm install -g rea-agents` 安装)
|
|
11
|
+
3. 本机 `rea-agents/scripts/rea.mjs`(用当前 Node 运行时启动)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
探测到后把 REA 注册到 `@kirkchinese/dsh-capability-catalog`,配置:
|
|
14
|
+
- `catalogTtlMs`: 10 年 —— 目录缓存一旦生成就永不因陈旧而重新发现
|
|
15
|
+
- `idleDisconnectMs`: 5 分钟 —— 调用完空闲即断开
|
|
16
|
+
- `enabled: true` —— 工具留在目录里可搜索
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
**没有硬编码路径,任何电脑都能用。** 目录缓存由首次发现自动生成(会短暂启动一次 rea),之后不再自动启动。
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
## 沿用了哪些上游项目
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
- 沿用上游 [`@kirkchinese/dsh-capability-catalog`](https://github.com/kirkchinese/dsh-capability-catalog) 的懒加载能力目录(search / describe / call 三个元工具)。
|
|
20
|
-
- 沿用上游 [`@kirkchinese/dsh-rea`](https://github.com/kirkchinese/dsh-capability-catalog) 整理的 14 个能力族与工具匹配规则(本包的 `cordis.patch.yml` 中完整重述了这些族配置,便于独立安装;这些规则源自上游的 MIT 授权文件 `families.yml`)。
|
|
21
|
-
- 随包附带一份由 REA `tools/list` 生成的工具目录缓存(`catalog/mcp-rea.json`,263 个工具),使启动与空闲期间都无需连接 REA 服务。
|
|
22
|
+
本包是薄配置层,不改、不重新分发上游:
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
- [REA](https://github.com/morluto/rea) 的 `rea mcp` 标准输入输出接口(使用者自行安装 `rea-agents`)
|
|
25
|
+
- [`@kirkchinese/dsh-capability-catalog`](https://github.com/kirkchinese/dsh-capability-catalog) 的懒加载能力目录(search / describe / call)
|
|
26
|
+
- [`@kirkchinese/dsh-rea`](https://github.com/kirkchinese/dsh-capability-catalog) 整理的 14 个能力族与工具匹配规则(内联在引导插件中,源自其 MIT 授权的 `families.yml`)
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
上游项目均按其各自 MIT 许可授权,版权归各自作者。
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
- **无侵入启动**:本包配置的 `rea` 服务在缓存命中且 TTL(10 年)未过期时不会被自动拉起;只有在 DSH 中真正 `capability_call` 某个 REA 工具时才启动,空闲 5 分钟自动断开。
|
|
29
|
-
- **独立数据**:工具目录缓存写在你机器的 DSH 数据目录(`$DSH_HOME/capability-catalog`),不写入 REA 安装目录。
|
|
30
|
-
- **可逆**:卸载本包只是移除这一行插件配置,不影响 REA 本身或你已有的任何数据。
|
|
30
|
+
## 对 REA 的影响 / 删除声明
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
- 不修改 REA 仓库、npm 包或运行时文件
|
|
33
|
+
- 不自动常驻:缓存命中后 `rea mcp` 只在真正 `capability_call` 工具时启动,空闲 5 分钟断开
|
|
34
|
+
- 缓存写在 DSH 数据目录(`$DSH_HOME/capability-catalog`),不碰 REA 安装目录
|
|
35
|
+
- 卸载本包只是移除这一行插件配置,可逆、无残留
|
|
36
|
+
|
|
37
|
+
**如果本包对 REA 或你的环境造成任何影响,或希望我们停止发布/删除相关内容,可直接联系 GitHub: Nathan-ADK,我们会立即配合处理或下架。**
|
|
33
38
|
|
|
34
39
|
## 安装
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
1. 已安装 DSH 的能力目录包:`@kirkchinese/dsh-capability-catalog`(本包依赖它)。
|
|
38
|
-
2. REA 可执行文件 `rea` 在你的 PATH 上(例如 `npm install -g rea-agents`)。
|
|
39
|
-
3. 安装本包后,**首次使用前请先让能力目录完成一次 REA 工具发现**(详见下文「首次发现」)。
|
|
41
|
+
前置:先装能力目录 `@kirkchinese/dsh-capability-catalog`(本包依赖它的服务)。REA 可装可不装到 PATH —— 本包会自动探测;若探测不到,设 `REA_COMMAND` 即可。
|
|
40
42
|
|
|
41
43
|
```sh
|
|
42
44
|
dsh plugin add @nathan-adk/dsh-capability-catalog
|
|
43
45
|
dsh plugin add @nathan-adk/dsh-rea-lazy
|
|
46
|
+
# 可选:REA_COMMAND="node /path/to/rea.mjs mcp"
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
为了让 `rea` 工具出现在能力目录里,需要生成一次与本机 `rea` 命令匹配的缓存。本包内置的缓存以 `rea mcp` 为启动身份;如果你的 `rea` 命令解析结果不同,首次搜索不到 REA 工具时,在 DSH 中触发一次能力目录的重新发现(discovery),它会自动生成匹配本机的缓存,此后不再需要。
|
|
49
|
-
|
|
50
|
-
## 工作方式
|
|
51
|
-
|
|
52
|
-
- 常驻工具只有 3 个目录元工具:`capability_search` / `capability_describe` / `capability_call`。
|
|
53
|
-
- 263 个 REA 工具不注册为原生工具,只在目录里有紧凑索引(族名 + 工具名 + 参数大小)。
|
|
54
|
-
- 工具 schema 只有在 `capability_describe` 之后才进入上下文。
|
|
55
|
-
- 调用链固定 search → describe → call,一次只调一项,不会一次性挂载全部工具。
|
|
56
|
-
|
|
57
|
-
## 卸载
|
|
49
|
+
## 排障
|
|
58
50
|
|
|
59
|
-
|
|
51
|
+
- 目录里看不到 REA 工具 → 确认能力目录已装;若自动探测失败,设 `REA_COMMAND` 后重启 DSH。
|
|
52
|
+
- 首次使用会短暂启动一次 rea 建立目录缓存(属预期);此后不再自动启动。
|
|
60
53
|
|
|
61
54
|
## 许可
|
|
62
55
|
|
|
63
|
-
MIT ——
|
|
56
|
+
MIT —— 仅覆盖本配置层;上游 REA 与能力目录归各自作者所有。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,67 +1,8 @@
|
|
|
1
1
|
# REA on-demand config layer for DeepSeek Harness (DSH-only).
|
|
2
|
-
# Inserts
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# discovery only reads the on-disk cache, and a 10-year TTL prevents stale refresh.
|
|
2
|
+
# Inserts the bootstrap plugin row; the plugin autodetects the local REA command
|
|
3
|
+
# and registers it with @kirkchinese/dsh-capability-catalog. No local paths are
|
|
4
|
+
# hardcoded. REA_COMMAND env overrides detection when needed.
|
|
6
5
|
- insert:
|
|
7
|
-
- id:
|
|
8
|
-
name: '@
|
|
9
|
-
config:
|
|
10
|
-
name: rea
|
|
11
|
-
enabled: true
|
|
12
|
-
# Keep the row enabled so all REA tools stay searchable on demand, but
|
|
13
|
-
# never auto-spawn: a matching on-disk cache is never stale for 10 years.
|
|
14
|
-
catalogTtlMs: 315360000000
|
|
15
|
-
idleDisconnectMs: 300000
|
|
16
|
-
callTimeoutMs: 600000
|
|
17
|
-
discoveryTimeoutMs: 60000
|
|
18
|
-
command: rea
|
|
19
|
-
args: [mcp]
|
|
20
|
-
title: REA reverse engineering (on-demand)
|
|
21
|
-
description: >-
|
|
22
|
-
Reverse engineering of native binaries, JS/Electron, Android, .NET, Apple bundles,
|
|
23
|
-
firmware and runtime behaviour. 263 REA tools are indexed on demand via the
|
|
24
|
-
capability catalog; the rea process starts only when a tool is actually called.
|
|
25
|
-
families:
|
|
26
|
-
- name: session
|
|
27
|
-
description: 'open/close a target, provider binding, readiness and navigation context'
|
|
28
|
-
match: [open_binary, close_binary, binary_session, binary_overview, get_navigation_context, list_documents, current_document, list_architectures]
|
|
29
|
-
- name: native-code
|
|
30
|
-
description: 'functions, pseudocode, assembly, call graph and references in native binaries (Hopper/Ghidra/IDA)'
|
|
31
|
-
match: [procedure_*, list_procedures, search_procedures, current_procedure, resolve_containing_procedure, analyze_function, batch_decompile, read_function_instructions, get_call_graph, build_call_path, trace_call_path, xrefs, find_xrefs_to_name, resolve_native_call_targets, trace_native_values, compare_functions, inspect_native_*, inspect_address_context]
|
|
32
|
-
- name: native-navigation
|
|
33
|
-
description: 'addresses, bytes, strings, names, segments, comments and bookmarks'
|
|
34
|
-
match: ['*address*', goto_address, next_address, prev_address, read_bytes, search_bytes, list_strings, search_strings, list_names, list_segments, '*comment*', '*bookmark*', annotate_native_function]
|
|
35
|
-
- name: native-formats
|
|
36
|
-
description: 'Mach-O, PE, ELF layout, signatures, Go/Rust/Swift/ObjC metadata, objdump and rizin'
|
|
37
|
-
match: [inspect_macho, inspect_pe_resources, inspect_binary_layout, inspect_signature, inspect_go_binary, inspect_rust_binary, '*swift*', get_objc_*, inspect_native_dispatch_metadata, inspect_with_objdump, execute_rizin_command, cutter_command, list_cutter_sessions, trace_dylib_resolution, inspect_dart_aot, identify_flutter_build, inspect_wasm_artifact, compare_wasm_interfaces, inspect_evm_interface]
|
|
38
|
-
- name: javascript-electron
|
|
39
|
-
description: 'JavaScript/Electron apps, bundles, source maps, IPC and runtime tracing'
|
|
40
|
-
match: ['*javascript*', analyze_web_bundle, recover_javascript_sources, compare_source_to_bundle, compare_bundles, '*electron*', trace_application_feature, trace_feature, compare_application_versions]
|
|
41
|
-
- name: web-browser
|
|
42
|
-
description: 'live pages through a Chrome-family browser, network captures, screenshots and WebMCP'
|
|
43
|
-
match: ['*web*', capture_browser_scenario, list_browser_targets]
|
|
44
|
-
- name: android
|
|
45
|
-
description: 'APKs, classes, methods, resources (JADX, Apktool, JEB) and app graphs'
|
|
46
|
-
match: ['*android*', inspect_apktool_client, '*jeb*']
|
|
47
|
-
- name: adb-device
|
|
48
|
-
description: 'attached Android devices over adb: packages, files, logs, screens and app control'
|
|
49
|
-
match: ['*adb*']
|
|
50
|
-
- name: managed-dotnet
|
|
51
|
-
description: '.NET assemblies, members, native boundaries and reconstruction'
|
|
52
|
-
match: ['*managed*']
|
|
53
|
-
- name: apple-bundles
|
|
54
|
-
description: 'plists, keyed archives, asset catalogs, Interface Builder and Apple/Harmony app graphs'
|
|
55
|
-
match: [inspect_plist, inspect_keyed_archive, inspect_asset_catalog, decode_interface_builder, project_apple_application_graph, project_harmony_application_graph]
|
|
56
|
-
- name: artifacts
|
|
57
|
-
description: 'archives, packages, firmware, SQLite and file-level comparisons'
|
|
58
|
-
match: [inspect_artifact, extract_artifact, compare_artifacts, inspect_firmware_regions, extract_firmware, inspect_sqlite_database, inspect_analysis_view]
|
|
59
|
-
- name: runtime-debug
|
|
60
|
-
description: 'Frida, GDB and rizin debugging, process and native UI capture, recorded crashes'
|
|
61
|
-
match: ['*frida*', '*gdb*', '*rizin_debug*', capture_process_scenario, compare_process_captures, observe_native_*, capture_native_ui_scenario, trace_native_ui_action, inspect_recorded_crash, correlate_static_and_runtime, find_changed_behavior]
|
|
62
|
-
- name: captures-signals
|
|
63
|
-
description: 'pcap/pcapng packets and recorded logic signals'
|
|
64
|
-
match: ['*pcap*', '*packet*', '*signal*']
|
|
65
|
-
- name: evidence
|
|
66
|
-
description: 'evidence bundles, residual unknowns and reconstruction verification'
|
|
67
|
-
match: ['*evidence*', '*unknown*', '*reconstruction*']
|
|
6
|
+
- id: dsh-rea-lazy
|
|
7
|
+
name: '@nathan-adk/dsh-rea-lazy'
|
|
8
|
+
config: {}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* dsh-rea-lazy bootstrap (zero dependency).
|
|
4
|
+
* Detects a usable REA command at activation time and registers it with the
|
|
5
|
+
* capability catalog. No local paths are hardcoded: resolution order is
|
|
6
|
+
* REA_COMMAND env > "rea" on PATH > bundled rea-agents via process.execPath
|
|
7
|
+
* The server is configured with a 10-year catalog TTL and idle disconnect, so
|
|
8
|
+
* once the tool catalog is cached, rea mcp never starts in the background.
|
|
9
|
+
*/
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { spawnSync } = require('child_process');
|
|
13
|
+
|
|
14
|
+
const FAMILIES = [
|
|
15
|
+
{
|
|
16
|
+
"name": "session",
|
|
17
|
+
"description": "open/close a target, provider binding, readiness and navigation context",
|
|
18
|
+
"match": [
|
|
19
|
+
"open_binary",
|
|
20
|
+
"close_binary",
|
|
21
|
+
"binary_session",
|
|
22
|
+
"binary_overview",
|
|
23
|
+
"get_navigation_context",
|
|
24
|
+
"list_documents",
|
|
25
|
+
"current_document",
|
|
26
|
+
"list_architectures"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "native-code",
|
|
31
|
+
"description": "functions, pseudocode, assembly, call graph and references in native binaries (Hopper/Ghidra/IDA)",
|
|
32
|
+
"match": [
|
|
33
|
+
"procedure_*",
|
|
34
|
+
"list_procedures",
|
|
35
|
+
"search_procedures",
|
|
36
|
+
"current_procedure",
|
|
37
|
+
"resolve_containing_procedure",
|
|
38
|
+
"analyze_function",
|
|
39
|
+
"batch_decompile",
|
|
40
|
+
"read_function_instructions",
|
|
41
|
+
"get_call_graph",
|
|
42
|
+
"build_call_path",
|
|
43
|
+
"trace_call_path",
|
|
44
|
+
"xrefs",
|
|
45
|
+
"find_xrefs_to_name",
|
|
46
|
+
"resolve_native_call_targets",
|
|
47
|
+
"trace_native_values",
|
|
48
|
+
"compare_functions",
|
|
49
|
+
"inspect_native_*",
|
|
50
|
+
"inspect_address_context"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "native-navigation",
|
|
55
|
+
"description": "addresses, bytes, strings, names, segments, comments and bookmarks",
|
|
56
|
+
"match": [
|
|
57
|
+
"*address*",
|
|
58
|
+
"goto_address",
|
|
59
|
+
"next_address",
|
|
60
|
+
"prev_address",
|
|
61
|
+
"read_bytes",
|
|
62
|
+
"search_bytes",
|
|
63
|
+
"list_strings",
|
|
64
|
+
"search_strings",
|
|
65
|
+
"list_names",
|
|
66
|
+
"list_segments",
|
|
67
|
+
"*comment*",
|
|
68
|
+
"*bookmark*",
|
|
69
|
+
"annotate_native_function"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "native-formats",
|
|
74
|
+
"description": "Mach-O, PE, ELF layout, signatures, Go/Rust/Swift/ObjC metadata, objdump and rizin",
|
|
75
|
+
"match": [
|
|
76
|
+
"inspect_macho",
|
|
77
|
+
"inspect_pe_resources",
|
|
78
|
+
"inspect_binary_layout",
|
|
79
|
+
"inspect_signature",
|
|
80
|
+
"inspect_go_binary",
|
|
81
|
+
"inspect_rust_binary",
|
|
82
|
+
"*swift*",
|
|
83
|
+
"get_objc_*",
|
|
84
|
+
"inspect_native_dispatch_metadata",
|
|
85
|
+
"inspect_with_objdump",
|
|
86
|
+
"execute_rizin_command",
|
|
87
|
+
"cutter_command",
|
|
88
|
+
"list_cutter_sessions",
|
|
89
|
+
"trace_dylib_resolution",
|
|
90
|
+
"inspect_dart_aot",
|
|
91
|
+
"identify_flutter_build",
|
|
92
|
+
"inspect_wasm_artifact",
|
|
93
|
+
"compare_wasm_interfaces",
|
|
94
|
+
"inspect_evm_interface"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "javascript-electron",
|
|
99
|
+
"description": "JavaScript/Electron apps, bundles, source maps, IPC and runtime tracing",
|
|
100
|
+
"match": [
|
|
101
|
+
"*javascript*",
|
|
102
|
+
"analyze_web_bundle",
|
|
103
|
+
"recover_javascript_sources",
|
|
104
|
+
"compare_source_to_bundle",
|
|
105
|
+
"compare_bundles",
|
|
106
|
+
"*electron*",
|
|
107
|
+
"trace_application_feature",
|
|
108
|
+
"trace_feature",
|
|
109
|
+
"compare_application_versions"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "web-browser",
|
|
114
|
+
"description": "live pages through a Chrome-family browser, network captures, screenshots and WebMCP",
|
|
115
|
+
"match": [
|
|
116
|
+
"*web*",
|
|
117
|
+
"capture_browser_scenario",
|
|
118
|
+
"list_browser_targets"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "android",
|
|
123
|
+
"description": "APKs, classes, methods, resources (JADX, Apktool, JEB) and app graphs",
|
|
124
|
+
"match": [
|
|
125
|
+
"*android*",
|
|
126
|
+
"inspect_apktool_client",
|
|
127
|
+
"*jeb*"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "adb-device",
|
|
132
|
+
"description": "attached Android devices over adb: packages, files, logs, screens and app control",
|
|
133
|
+
"match": [
|
|
134
|
+
"*adb*"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "managed-dotnet",
|
|
139
|
+
"description": ".NET assemblies, members, native boundaries and reconstruction",
|
|
140
|
+
"match": [
|
|
141
|
+
"*managed*"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "apple-bundles",
|
|
146
|
+
"description": "plists, keyed archives, asset catalogs, Interface Builder and Apple/Harmony app graphs",
|
|
147
|
+
"match": [
|
|
148
|
+
"inspect_plist",
|
|
149
|
+
"inspect_keyed_archive",
|
|
150
|
+
"inspect_asset_catalog",
|
|
151
|
+
"decode_interface_builder",
|
|
152
|
+
"project_apple_application_graph",
|
|
153
|
+
"project_harmony_application_graph"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "artifacts",
|
|
158
|
+
"description": "archives, packages, firmware, SQLite and file-level comparisons",
|
|
159
|
+
"match": [
|
|
160
|
+
"inspect_artifact",
|
|
161
|
+
"extract_artifact",
|
|
162
|
+
"compare_artifacts",
|
|
163
|
+
"inspect_firmware_regions",
|
|
164
|
+
"extract_firmware",
|
|
165
|
+
"inspect_sqlite_database",
|
|
166
|
+
"inspect_analysis_view"
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "runtime-debug",
|
|
171
|
+
"description": "Frida, GDB and rizin debugging, process and native UI capture, recorded crashes",
|
|
172
|
+
"match": [
|
|
173
|
+
"*frida*",
|
|
174
|
+
"*gdb*",
|
|
175
|
+
"*rizin_debug*",
|
|
176
|
+
"capture_process_scenario",
|
|
177
|
+
"compare_process_captures",
|
|
178
|
+
"observe_native_*",
|
|
179
|
+
"capture_native_ui_scenario",
|
|
180
|
+
"trace_native_ui_action",
|
|
181
|
+
"inspect_recorded_crash",
|
|
182
|
+
"correlate_static_and_runtime",
|
|
183
|
+
"find_changed_behavior"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "captures-signals",
|
|
188
|
+
"description": "pcap/pcapng packets and recorded logic signals",
|
|
189
|
+
"match": [
|
|
190
|
+
"*pcap*",
|
|
191
|
+
"*packet*",
|
|
192
|
+
"*signal*"
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"name": "evidence",
|
|
197
|
+
"description": "evidence bundles, residual unknowns and reconstruction verification",
|
|
198
|
+
"match": [
|
|
199
|
+
"*evidence*",
|
|
200
|
+
"*unknown*",
|
|
201
|
+
"*reconstruction*"
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
function which(name) {
|
|
207
|
+
try {
|
|
208
|
+
const cmd = process.platform === 'win32' ? 'where' : 'which';
|
|
209
|
+
const r = spawnSync(cmd, [name], { encoding: 'utf8', timeout: 3000 });
|
|
210
|
+
if (r.status === 0 && r.stdout) {
|
|
211
|
+
const line = String(r.stdout).split(/\r?\n/).find(Boolean);
|
|
212
|
+
if (line) return line.trim();
|
|
213
|
+
}
|
|
214
|
+
} catch (_) {}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function findRea() {
|
|
219
|
+
// 1) explicit override
|
|
220
|
+
const envCmd = process.env.REA_COMMAND;
|
|
221
|
+
if (envCmd && envCmd.trim()) {
|
|
222
|
+
const parts = envCmd.trim().split(/\s+/);
|
|
223
|
+
return { command: parts[0], args: parts.slice(1) };
|
|
224
|
+
}
|
|
225
|
+
// 2) on PATH
|
|
226
|
+
const onPath = which('rea');
|
|
227
|
+
if (onPath) return { command: onPath, args: ['mcp'] };
|
|
228
|
+
// 3) rea-agents installed near this package / in the DSH profile
|
|
229
|
+
const roots = [
|
|
230
|
+
path.join(__dirname, '..', 'node_modules', 'rea-agents'),
|
|
231
|
+
path.join(process.cwd(), 'node_modules', 'rea-agents'),
|
|
232
|
+
];
|
|
233
|
+
for (const root of roots) {
|
|
234
|
+
const entry = path.join(root, 'scripts', 'rea.mjs');
|
|
235
|
+
if (fs.existsSync(entry)) {
|
|
236
|
+
return { command: process.execPath, args: [entry, 'mcp'] };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function apply(ctx, config = {}) {
|
|
243
|
+
const found = findRea();
|
|
244
|
+
if (!found) {
|
|
245
|
+
ctx.logger?.warn('[dsh-rea-lazy] no REA executable found; set REA_COMMAND to enable');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const server = {
|
|
249
|
+
name: 'rea',
|
|
250
|
+
title: 'REA reverse engineering (on-demand)',
|
|
251
|
+
description: '263 REA tools via the lazy capability catalog; the rea process starts only on an actual tool call.',
|
|
252
|
+
enabled: true,
|
|
253
|
+
transport: 'stdio',
|
|
254
|
+
command: found.command,
|
|
255
|
+
args: found.args,
|
|
256
|
+
catalogTtlMs: 315360000000,
|
|
257
|
+
idleDisconnectMs: 300000,
|
|
258
|
+
callTimeoutMs: 600000,
|
|
259
|
+
discoveryTimeoutMs: 60000,
|
|
260
|
+
families: FAMILIES,
|
|
261
|
+
...config,
|
|
262
|
+
};
|
|
263
|
+
const remove = await ctx.capabilityCatalogServers.addMcpServer(server);
|
|
264
|
+
ctx.effect(() => () => { try { remove && remove(); } catch (_) {} }, 'dsh-rea-lazy.server');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
module.exports = { name: 'dsh-rea-lazy', inject: ['capabilityCatalogServers'], apply, findRea };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathan-adk/dsh-rea-lazy",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "On-demand REA for DeepSeek Harness:
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "On-demand REA for DeepSeek Harness: auto-detects the local REA executable and registers it as a lazy capability, so 263 REA tools stay searchable while rea mcp never runs in the background. DSH-only.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
7
7
|
"dsh",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"author": "Nathan-ADK",
|
|
18
|
-
"type": "
|
|
18
|
+
"type": "commonjs",
|
|
19
19
|
"files": [
|
|
20
|
-
"
|
|
20
|
+
"lib/",
|
|
21
21
|
"catalog/mcp-rea.json",
|
|
22
|
+
"cordis.patch.yml",
|
|
22
23
|
"README.md",
|
|
23
24
|
"LICENSE"
|
|
24
25
|
],
|
|
@@ -37,5 +38,6 @@
|
|
|
37
38
|
"homepage": "https://github.com/Nathan-ADK/dsh-rea-lazy#readme",
|
|
38
39
|
"engines": {
|
|
39
40
|
"node": ">=18"
|
|
40
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"main": "lib/index.js"
|
|
41
43
|
}
|