dev-flow-deepseek 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 +201 -0
- package/README.md +129 -0
- package/cordis.patch.yml +27 -0
- package/lib/backend-client.js +139 -0
- package/lib/canonical-json.js +61 -0
- package/lib/compatibility.js +47 -0
- package/lib/environment.js +50 -0
- package/lib/proxy.js +87 -0
- package/lib/result-envelope.js +105 -0
- package/package.json +58 -0
- package/skills/dev-flow/SKILL.md +59 -0
- package/skills/dev-flow/references/activation-and-routing.md +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# dev-flow-deepseek
|
|
2
|
+
|
|
3
|
+
`dev-flow-deepseek` is a prebuilt DeepSeek Harness bundle that connects
|
|
4
|
+
the official DSH MCP client to an independently installed Dev Flow Orchestrator
|
|
5
|
+
runtime. Its local STDIO projection proxy exposes exactly six tools and renders
|
|
6
|
+
each complete Dev Flow result envelope as deterministic canonical JSON while
|
|
7
|
+
preserving valid upstream success and domain-error semantics. The external
|
|
8
|
+
Python Controller remains the only workflow and task-state authority.
|
|
9
|
+
|
|
10
|
+
## Exact compatibility
|
|
11
|
+
|
|
12
|
+
| Component | Supported baseline |
|
|
13
|
+
|---|---|
|
|
14
|
+
| This package | `0.1.0` |
|
|
15
|
+
| DeepSeek Harness | `@deepseek-ai/dsh@0.1.0-rc.6`, npm SHA-1 `de9fbf39056c7f4e658a3e284cb1d66ebc86d040`, public source baseline `47f943859bef60e4160492346772ded9b24f765a` |
|
|
16
|
+
| Dev Flow Orchestrator | release `0.6.12`, commit `7edd4fa12fe6787aac57f16246cbab00b8d79272` |
|
|
17
|
+
| Dev Flow MCP interface | `dev-flow-mcp/1.0.0` |
|
|
18
|
+
| Dev Flow result schema | `dev-flow-mcp-result/1.0.0` |
|
|
19
|
+
| Dev Flow model namespace | `0.4.0` |
|
|
20
|
+
| Node.js | `^22.19.0 || >=24.0.0` |
|
|
21
|
+
| MCP SDK | `1.12.0` |
|
|
22
|
+
|
|
23
|
+
Compatibility is exact. Later DSH or Dev Flow releases are not inferred to be
|
|
24
|
+
compatible.
|
|
25
|
+
|
|
26
|
+
## Prerequisites and installation
|
|
27
|
+
|
|
28
|
+
Install DeepSeek Harness `0.1.0-rc.6` and the separate `dev-flow-mcp` executable
|
|
29
|
+
from Dev Flow Orchestrator `0.6.12` before using this bundle. The executable may
|
|
30
|
+
be on `PATH` or selected with an absolute `DEV_FLOW_MCP_COMMAND` value. This npm
|
|
31
|
+
package does not install, update, repair, migrate, or remove Python, `uv`, or the
|
|
32
|
+
Dev Flow runtime.
|
|
33
|
+
|
|
34
|
+
Install the stable release into an isolated DSH profile:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
dsh plugin --profile web add dev-flow-deepseek@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Alternatively, build and pack locally with the pinned package manager:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
corepack pnpm@11.7.0 install --frozen-lockfile
|
|
44
|
+
corepack pnpm@11.7.0 run build
|
|
45
|
+
corepack pnpm@11.7.0 pack
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add the resulting tarball to an isolated DSH profile, for example the `web`
|
|
49
|
+
profile, then remove it by package name when no longer needed:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
dsh plugin --profile web add /absolute/path/dev-flow-deepseek-0.1.0.tgz
|
|
53
|
+
dsh plugin --profile web remove dev-flow-deepseek
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Removal deletes only the profile dependency and bundle layer. It does not
|
|
57
|
+
delete Dev Flow task data.
|
|
58
|
+
|
|
59
|
+
## Data and use
|
|
60
|
+
|
|
61
|
+
By default the bundle sets `DEV_FLOW_DATA_DIR` to
|
|
62
|
+
`$DSH_HOME/dev-flow-orchestrator/data`; the compatible backend appends its
|
|
63
|
+
`0.4.0` namespace. This keeps DSH tasks separate from Codex Dev Flow data. An
|
|
64
|
+
explicit `DEV_FLOW_DATA_DIR` set before DSH starts overrides that root.
|
|
65
|
+
|
|
66
|
+
Inside one existing Git worktree, invoke the Skill explicitly:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
/dev-flow Implement the requested change and verify it.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The Skill validates the exact runtime identity, discovers a compatible active
|
|
73
|
+
task or starts one `lite` task, follows only the Controller's fresh action and
|
|
74
|
+
binding, and stops on the Controller's Delivery Dossier.
|
|
75
|
+
|
|
76
|
+
The outward raw MCP surface is exactly:
|
|
77
|
+
|
|
78
|
+
- `dev_flow_server_info`
|
|
79
|
+
- `dev_flow_find_tasks_for_path`
|
|
80
|
+
- `dev_flow_get_task`
|
|
81
|
+
- `dev_flow_get_next_action`
|
|
82
|
+
- `dev_flow_start_task`
|
|
83
|
+
- `dev_flow_apply_action`
|
|
84
|
+
|
|
85
|
+
## Supported and unsupported scope
|
|
86
|
+
|
|
87
|
+
The MVP supports explicit `/dev-flow`, one current Git repository, compatible
|
|
88
|
+
active `lite` task resume, new `lite` tasks, local STDIO, safe mutation
|
|
89
|
+
read-after-write recovery, and complete spilled-result retrieval.
|
|
90
|
+
|
|
91
|
+
It does not support implicit activation, multiple repositories, another
|
|
92
|
+
workflow, task listing or cancellation, governance decisions, finding
|
|
93
|
+
disposition, contract revision, custom DSH UI, runtime installation, a generic
|
|
94
|
+
shell MCP, HTTP/SSE/remote MCP, OAuth, branch or worktree management, commits,
|
|
95
|
+
pushes, pull requests, tags, or releases. Windows is unverified.
|
|
96
|
+
|
|
97
|
+
## Troubleshooting
|
|
98
|
+
|
|
99
|
+
- If no Dev Flow tools appear, confirm that the package layer is installed and
|
|
100
|
+
that `DEV_FLOW_MCP_COMMAND` resolves directly to the `0.6.12`
|
|
101
|
+
`dev-flow-mcp` executable. DSH remains usable when startup fails because the
|
|
102
|
+
bundle sets `failOnStartupError: false`.
|
|
103
|
+
- If `/dev-flow` reports an incompatible identity, use the exact versions in
|
|
104
|
+
the compatibility table. Do not substitute a newer release.
|
|
105
|
+
- If a mutation response is lost, do not replay it. The Skill rediscovers a
|
|
106
|
+
possibly created task or reads the task and fresh action before any retry.
|
|
107
|
+
- If DSH reports a spilled, truncated, pruned, or preview result, the Skill
|
|
108
|
+
must read the complete saved canonical JSON text before using authority
|
|
109
|
+
fields.
|
|
110
|
+
|
|
111
|
+
## Trust and verification
|
|
112
|
+
|
|
113
|
+
The installed bundle executes its prebuilt Node proxy and the selected local
|
|
114
|
+
Dev Flow executable outside the DSH agent sandbox. Install the package only
|
|
115
|
+
from a publisher you trust. The proxy reduces ambient authority by using no
|
|
116
|
+
shell, passing only a closed child environment, opening no listener, and
|
|
117
|
+
exposing no tool outside the six-tool allowlist; it does not claim code signing,
|
|
118
|
+
provenance attestation, automatic updates, or protection from a compromised
|
|
119
|
+
publisher or runtime.
|
|
120
|
+
|
|
121
|
+
Deterministic verification consists of 25 bounded unit cases, one local fake
|
|
122
|
+
MCP suite with exactly eight scenarios, one package-contract check, strict
|
|
123
|
+
OpenSpec validation, and the documented default gate. The real-runtime smoke is
|
|
124
|
+
opt-in and requires Dev Flow `0.6.12`. A fake backend or static inspection is not
|
|
125
|
+
evidence of a real DSH GUI journey. The recorded evidence verifies the real DSH
|
|
126
|
+
happy path and restart/resume/removal journey on macOS arm64. The stable
|
|
127
|
+
release artifact was separately revalidated for package installation, composed
|
|
128
|
+
path resolution, and removal. Linux x64 and Windows remain `UNVERIFIED`; see
|
|
129
|
+
`tests/manual/deepseek-harness-journey.md` for the exact evidence boundary.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
- insert:
|
|
2
|
+
- id: dev-flow-mcp
|
|
3
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
4
|
+
config:
|
|
5
|
+
serverName: dev-flow
|
|
6
|
+
transport: stdio
|
|
7
|
+
command: !!js process.execPath
|
|
8
|
+
args:
|
|
9
|
+
- !!js process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('dev-flow-deepseek/lib/proxy.js')
|
|
10
|
+
env:
|
|
11
|
+
DEV_FLOW_MCP_COMMAND: !!js process.env.DEV_FLOW_MCP_COMMAND ?? 'dev-flow-mcp'
|
|
12
|
+
DEV_FLOW_DATA_DIR: !!js process.env.DEV_FLOW_DATA_DIR ?? dshHomePath('dev-flow-orchestrator/data')
|
|
13
|
+
toolCallTimeoutMs: 120000
|
|
14
|
+
failOnStartupError: false
|
|
15
|
+
reconnect:
|
|
16
|
+
enabled: true
|
|
17
|
+
initialDelayMs: 500
|
|
18
|
+
maxDelayMs: 30000
|
|
19
|
+
maxAttempts: 10
|
|
20
|
+
|
|
21
|
+
- id: dev-flow-skill-provider
|
|
22
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
23
|
+
config:
|
|
24
|
+
providerName: dev-flow-bundle
|
|
25
|
+
includeDefaultRoots: false
|
|
26
|
+
customSkillDirs:
|
|
27
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('dev-flow-deepseek/package.json')), 'skills')
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ADAPTER_ERROR_CODES, APPROVED_RAW_TOOLS, PACKAGE_NAME, PACKAGE_VERSION, SHUTDOWN_TIMEOUT_MS } from "./compatibility.js";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
4
|
+
|
|
5
|
+
//#region src/backend-client.ts
|
|
6
|
+
const BACKEND_CALL_TIMEOUT_MS = 12e4;
|
|
7
|
+
var BackendStartupError = class extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code) {
|
|
10
|
+
if (!ADAPTER_ERROR_CODES.includes(code)) throw new TypeError("Backend startup error code is not approved.");
|
|
11
|
+
super("The Dev Flow projection proxy could not start its backend.");
|
|
12
|
+
this.name = "BackendStartupError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var OwnedStdioClientTransport = class extends StdioClientTransport {
|
|
17
|
+
#child;
|
|
18
|
+
#resolveClosed;
|
|
19
|
+
#closed = new Promise((resolve) => {
|
|
20
|
+
this.#resolveClosed = resolve;
|
|
21
|
+
});
|
|
22
|
+
spawned = false;
|
|
23
|
+
get closed() {
|
|
24
|
+
return this.#closed;
|
|
25
|
+
}
|
|
26
|
+
async start() {
|
|
27
|
+
await super.start();
|
|
28
|
+
this.spawned = true;
|
|
29
|
+
const child = this._process;
|
|
30
|
+
if (child === void 0) throw new BackendStartupError("BACKEND_START_FAILED");
|
|
31
|
+
this.#child = child;
|
|
32
|
+
child.once("close", (code, signal) => {
|
|
33
|
+
this.#resolveClosed?.({
|
|
34
|
+
code,
|
|
35
|
+
signal
|
|
36
|
+
});
|
|
37
|
+
this.#resolveClosed = void 0;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async close() {
|
|
41
|
+
const child = this.#child;
|
|
42
|
+
await super.close();
|
|
43
|
+
if (child === void 0 || child.exitCode !== null || child.signalCode !== null) return;
|
|
44
|
+
let timer;
|
|
45
|
+
const exited = await Promise.race([this.#closed.then(() => true), new Promise((resolve) => {
|
|
46
|
+
timer = setTimeout(() => resolve(false), SHUTDOWN_TIMEOUT_MS);
|
|
47
|
+
timer.unref();
|
|
48
|
+
})]);
|
|
49
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
50
|
+
if (!exited && child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function isApprovedTool(name) {
|
|
54
|
+
return APPROVED_RAW_TOOLS.includes(name);
|
|
55
|
+
}
|
|
56
|
+
function filterCatalog(tools) {
|
|
57
|
+
const discovered = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const tool of APPROVED_RAW_TOOLS) discovered.set(tool, []);
|
|
59
|
+
for (const tool of tools) if (isApprovedTool(tool.name)) discovered.get(tool.name)?.push(tool);
|
|
60
|
+
const filtered = [];
|
|
61
|
+
for (const name of APPROVED_RAW_TOOLS) {
|
|
62
|
+
const matches = discovered.get(name);
|
|
63
|
+
if (matches === void 0 || matches.length !== 1) throw new BackendStartupError("BACKEND_CATALOG_INVALID");
|
|
64
|
+
const definition = matches[0];
|
|
65
|
+
if (definition === void 0) throw new BackendStartupError("BACKEND_CATALOG_INVALID");
|
|
66
|
+
filtered.push(definition);
|
|
67
|
+
}
|
|
68
|
+
return Object.freeze(filtered);
|
|
69
|
+
}
|
|
70
|
+
async function discoverTools(client) {
|
|
71
|
+
const tools = [];
|
|
72
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
73
|
+
let cursor;
|
|
74
|
+
do {
|
|
75
|
+
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor });
|
|
76
|
+
tools.push(...page.tools);
|
|
77
|
+
cursor = page.nextCursor;
|
|
78
|
+
if (cursor !== void 0) {
|
|
79
|
+
if (seenCursors.has(cursor)) throw new BackendStartupError("BACKEND_CATALOG_INVALID");
|
|
80
|
+
seenCursors.add(cursor);
|
|
81
|
+
}
|
|
82
|
+
} while (cursor !== void 0);
|
|
83
|
+
return filterCatalog(tools);
|
|
84
|
+
}
|
|
85
|
+
var BackendClient = class BackendClient {
|
|
86
|
+
#client;
|
|
87
|
+
#transport;
|
|
88
|
+
tools;
|
|
89
|
+
constructor(client, transport, tools) {
|
|
90
|
+
this.#client = client;
|
|
91
|
+
this.#transport = transport;
|
|
92
|
+
this.tools = tools;
|
|
93
|
+
}
|
|
94
|
+
static async connect(config) {
|
|
95
|
+
const transport = new OwnedStdioClientTransport({
|
|
96
|
+
command: config.command,
|
|
97
|
+
args: [...config.args],
|
|
98
|
+
env: config.env,
|
|
99
|
+
cwd: config.cwd,
|
|
100
|
+
stderr: "ignore"
|
|
101
|
+
});
|
|
102
|
+
const client = new Client({
|
|
103
|
+
name: `${PACKAGE_NAME}-backend-client`,
|
|
104
|
+
version: PACKAGE_VERSION
|
|
105
|
+
}, { capabilities: {} });
|
|
106
|
+
try {
|
|
107
|
+
await client.connect(transport);
|
|
108
|
+
} catch {
|
|
109
|
+
await transport.close().catch(() => void 0);
|
|
110
|
+
throw new BackendStartupError(transport.spawned ? "BACKEND_INITIALIZE_FAILED" : "BACKEND_START_FAILED");
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const tools = await discoverTools(client);
|
|
114
|
+
return new BackendClient(client, transport, tools);
|
|
115
|
+
} catch {
|
|
116
|
+
await client.close().catch(() => void 0);
|
|
117
|
+
throw new BackendStartupError("BACKEND_CATALOG_INVALID");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
get closed() {
|
|
121
|
+
return this.#transport.closed;
|
|
122
|
+
}
|
|
123
|
+
async call(tool, args, signal) {
|
|
124
|
+
return await this.#client.callTool({
|
|
125
|
+
name: tool,
|
|
126
|
+
arguments: args
|
|
127
|
+
}, void 0, {
|
|
128
|
+
signal,
|
|
129
|
+
timeout: BACKEND_CALL_TIMEOUT_MS,
|
|
130
|
+
maxTotalTimeout: BACKEND_CALL_TIMEOUT_MS
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async close() {
|
|
134
|
+
await this.#client.close();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
export { BackendClient, BackendStartupError };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MAX_CANONICAL_JSON_BYTES, MAX_CANONICAL_JSON_DEPTH } from "./compatibility.js";
|
|
2
|
+
|
|
3
|
+
//#region src/canonical-json.ts
|
|
4
|
+
var CanonicalJsonError = class extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "CanonicalJsonError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function reject(reason) {
|
|
11
|
+
throw new CanonicalJsonError(`Value is not lossless JSON: ${reason}.`);
|
|
12
|
+
}
|
|
13
|
+
function normalize(value, depth, ancestors) {
|
|
14
|
+
if (depth > 128) reject(`nesting exceeds depth ${128}`);
|
|
15
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
16
|
+
if (typeof value === "number") {
|
|
17
|
+
if (!Number.isFinite(value)) reject("number is not finite");
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value !== "object") reject(`unsupported ${typeof value} value`);
|
|
21
|
+
if (ancestors.has(value)) reject("cycle detected");
|
|
22
|
+
ancestors.add(value);
|
|
23
|
+
try {
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
const result = [];
|
|
26
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
27
|
+
if (!Object.hasOwn(value, index)) reject("sparse array hole detected");
|
|
28
|
+
result.push(normalize(value[index], depth + 1, ancestors));
|
|
29
|
+
}
|
|
30
|
+
if (Reflect.ownKeys(value).some((key) => {
|
|
31
|
+
if (key === "length") return false;
|
|
32
|
+
return typeof key !== "string" || !/^(0|[1-9]\d*)$/.test(key) || Number(key) >= value.length;
|
|
33
|
+
})) reject("array has non-index properties");
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
const prototype = Object.getPrototypeOf(value);
|
|
37
|
+
if (prototype !== Object.prototype && prototype !== null) reject("object is not plain");
|
|
38
|
+
const keys = Object.keys(value).sort();
|
|
39
|
+
const ownKeys = Reflect.ownKeys(value);
|
|
40
|
+
if (ownKeys.length !== keys.length || ownKeys.some((key) => typeof key !== "string")) reject("object has non-JSON properties");
|
|
41
|
+
const result = {};
|
|
42
|
+
const record = value;
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
45
|
+
if (descriptor === void 0 || descriptor.enumerable !== true || !("value" in descriptor)) reject("object has an accessor or non-enumerable property");
|
|
46
|
+
result[key] = normalize(record[key], depth + 1, ancestors);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
} finally {
|
|
50
|
+
ancestors.delete(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function canonicalJson(value) {
|
|
54
|
+
const normalized = normalize(value, 0, /* @__PURE__ */ new WeakSet());
|
|
55
|
+
const text = JSON.stringify(normalized);
|
|
56
|
+
if (Buffer.byteLength(text, "utf8") > 524288) throw new CanonicalJsonError(`Canonical JSON exceeds ${MAX_CANONICAL_JSON_BYTES} UTF-8 bytes.`);
|
|
57
|
+
return text;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { CanonicalJsonError, canonicalJson };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/compatibility.ts
|
|
2
|
+
const PACKAGE_NAME = "dev-flow-deepseek";
|
|
3
|
+
const PACKAGE_VERSION = "0.1.0";
|
|
4
|
+
const NODE_ENGINE = "^22.19.0 || >=24.0.0";
|
|
5
|
+
const OPENSPEC_VERSION = "1.7.0";
|
|
6
|
+
const MCP_SDK_VERSION = "1.12.0";
|
|
7
|
+
const DSH_VERSION = "0.1.0-rc.6";
|
|
8
|
+
const DSH_COMMIT = "47f943859bef60e4160492346772ded9b24f765a";
|
|
9
|
+
const DEV_FLOW_RELEASE = "0.6.12";
|
|
10
|
+
const DEV_FLOW_COMMIT = "7edd4fa12fe6787aac57f16246cbab00b8d79272";
|
|
11
|
+
const DEV_FLOW_MCP_INTERFACE = "dev-flow-mcp/1.0.0";
|
|
12
|
+
const DEV_FLOW_RESULT_SCHEMA = "dev-flow-mcp-result/1.0.0";
|
|
13
|
+
const DEV_FLOW_MODEL_NAMESPACE = "0.4.0";
|
|
14
|
+
const APPROVED_RAW_TOOLS = Object.freeze([
|
|
15
|
+
"dev_flow_server_info",
|
|
16
|
+
"dev_flow_find_tasks_for_path",
|
|
17
|
+
"dev_flow_get_task",
|
|
18
|
+
"dev_flow_get_next_action",
|
|
19
|
+
"dev_flow_start_task",
|
|
20
|
+
"dev_flow_apply_action"
|
|
21
|
+
]);
|
|
22
|
+
const APPROVED_MODEL_TOOLS = Object.freeze([
|
|
23
|
+
"mcp__dev-flow__dev_flow_server_info",
|
|
24
|
+
"mcp__dev-flow__dev_flow_find_tasks_for_path",
|
|
25
|
+
"mcp__dev-flow__dev_flow_get_task",
|
|
26
|
+
"mcp__dev-flow__dev_flow_get_next_action",
|
|
27
|
+
"mcp__dev-flow__dev_flow_start_task",
|
|
28
|
+
"mcp__dev-flow__dev_flow_apply_action"
|
|
29
|
+
]);
|
|
30
|
+
const MUTATION_TOOLS = Object.freeze(["dev_flow_start_task", "dev_flow_apply_action"]);
|
|
31
|
+
const ADAPTER_ERROR_SCHEMA = "dsh-dev-flow-proxy-error/1.0.0";
|
|
32
|
+
const ADAPTER_ERROR_CODES = Object.freeze([
|
|
33
|
+
"BACKEND_START_FAILED",
|
|
34
|
+
"BACKEND_INITIALIZE_FAILED",
|
|
35
|
+
"BACKEND_CATALOG_INVALID",
|
|
36
|
+
"UPSTREAM_CALL_FAILED",
|
|
37
|
+
"UPSTREAM_RESULT_INVALID",
|
|
38
|
+
"REQUEST_CANCELLED"
|
|
39
|
+
]);
|
|
40
|
+
const MAX_CANONICAL_JSON_DEPTH = 128;
|
|
41
|
+
const MAX_CANONICAL_JSON_BYTES = 524288;
|
|
42
|
+
const MAX_ADAPTER_DIAGNOSTIC_BYTES = 4096;
|
|
43
|
+
const SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
44
|
+
const STARTUP_EXIT_CODE = 2;
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ADAPTER_ERROR_CODES, ADAPTER_ERROR_SCHEMA, APPROVED_MODEL_TOOLS, APPROVED_RAW_TOOLS, DEV_FLOW_COMMIT, DEV_FLOW_MCP_INTERFACE, DEV_FLOW_MODEL_NAMESPACE, DEV_FLOW_RELEASE, DEV_FLOW_RESULT_SCHEMA, DSH_COMMIT, DSH_VERSION, MAX_ADAPTER_DIAGNOSTIC_BYTES, MAX_CANONICAL_JSON_BYTES, MAX_CANONICAL_JSON_DEPTH, MCP_SDK_VERSION, MUTATION_TOOLS, NODE_ENGINE, OPENSPEC_VERSION, PACKAGE_NAME, PACKAGE_VERSION, SHUTDOWN_TIMEOUT_MS, STARTUP_EXIT_CODE };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
//#region src/environment.ts
|
|
4
|
+
const CHILD_ENVIRONMENT_KEYS = Object.freeze([
|
|
5
|
+
"PATH",
|
|
6
|
+
"HOME",
|
|
7
|
+
"USERPROFILE",
|
|
8
|
+
"LOCALAPPDATA",
|
|
9
|
+
"SYSTEMROOT",
|
|
10
|
+
"COMSPEC",
|
|
11
|
+
"TEMP",
|
|
12
|
+
"TMP",
|
|
13
|
+
"TMPDIR",
|
|
14
|
+
"LANG",
|
|
15
|
+
"LC_ALL",
|
|
16
|
+
"LC_CTYPE"
|
|
17
|
+
]);
|
|
18
|
+
function validateCommand(command) {
|
|
19
|
+
if (command.length === 0 || command.trim() !== command || command.includes("\0") || command.includes("\n") || command.includes("\r")) throw new TypeError("DEV_FLOW_MCP_COMMAND must identify one direct executable.");
|
|
20
|
+
if (path.isAbsolute(command)) return command;
|
|
21
|
+
if (!/^[A-Za-z0-9._-]+$/.test(command)) throw new TypeError("DEV_FLOW_MCP_COMMAND must be an absolute path or a PATH-resolved executable name.");
|
|
22
|
+
return command;
|
|
23
|
+
}
|
|
24
|
+
function validateDataDirectory(value) {
|
|
25
|
+
if (value === void 0 || value.length === 0 || value.trim() !== value || value.includes("\0") || !path.isAbsolute(value)) throw new TypeError("DEV_FLOW_DATA_DIR must be a non-empty absolute path.");
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function buildChildEnvironment(parent, dataDirectory) {
|
|
29
|
+
const env = {};
|
|
30
|
+
for (const key of CHILD_ENVIRONMENT_KEYS) {
|
|
31
|
+
const value = parent[key];
|
|
32
|
+
if (typeof value === "string" && value.length > 0) env[key] = value;
|
|
33
|
+
}
|
|
34
|
+
env.DEV_FLOW_DATA_DIR = dataDirectory;
|
|
35
|
+
return env;
|
|
36
|
+
}
|
|
37
|
+
function readBackendConfiguration(source = process.env, cwd = process.cwd()) {
|
|
38
|
+
const command = validateCommand(source.DEV_FLOW_MCP_COMMAND ?? "dev-flow-mcp");
|
|
39
|
+
const dataDirectory = validateDataDirectory(source.DEV_FLOW_DATA_DIR);
|
|
40
|
+
if (!path.isAbsolute(cwd)) throw new TypeError("The proxy working directory must be absolute.");
|
|
41
|
+
return Object.freeze({
|
|
42
|
+
command,
|
|
43
|
+
args: Object.freeze(["--stdio"]),
|
|
44
|
+
env: Object.freeze(buildChildEnvironment(source, dataDirectory)),
|
|
45
|
+
cwd
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { buildChildEnvironment, readBackendConfiguration };
|
package/lib/proxy.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { APPROVED_RAW_TOOLS, MAX_ADAPTER_DIAGNOSTIC_BYTES, PACKAGE_NAME, PACKAGE_VERSION, STARTUP_EXIT_CODE } from "./compatibility.js";
|
|
3
|
+
import { BackendClient, BackendStartupError } from "./backend-client.js";
|
|
4
|
+
import { readBackendConfiguration } from "./environment.js";
|
|
5
|
+
import { createAdapterErrorResult, projectBackendResult } from "./result-envelope.js";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
|
|
11
|
+
//#region src/proxy.ts
|
|
12
|
+
function isApprovedTool(name) {
|
|
13
|
+
return APPROVED_RAW_TOOLS.includes(name);
|
|
14
|
+
}
|
|
15
|
+
function startupDiagnostic(code) {
|
|
16
|
+
const text = `dsh-dev-flow projection proxy startup failed (${code}).`;
|
|
17
|
+
if (Buffer.byteLength(text, "utf8") > 4096) return "dsh-dev-flow projection proxy startup failed.";
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
async function startProxy() {
|
|
21
|
+
let backend;
|
|
22
|
+
try {
|
|
23
|
+
backend = await BackendClient.connect(readBackendConfiguration());
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const code = error instanceof BackendStartupError ? error.code : "BACKEND_START_FAILED";
|
|
26
|
+
process.stderr.write(`${startupDiagnostic(code)}\n`);
|
|
27
|
+
process.exitCode = 2;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const server = new Server({
|
|
31
|
+
name: PACKAGE_NAME,
|
|
32
|
+
version: PACKAGE_VERSION
|
|
33
|
+
}, { capabilities: { tools: {} } });
|
|
34
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...backend.tools] }));
|
|
35
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
36
|
+
const name = request.params.name;
|
|
37
|
+
if (!isApprovedTool(name)) throw new TypeError("Requested tool is not exposed by this proxy.");
|
|
38
|
+
let upstream;
|
|
39
|
+
try {
|
|
40
|
+
upstream = await backend.call(name, request.params.arguments ?? {}, extra.signal);
|
|
41
|
+
} catch {
|
|
42
|
+
const code = extra.signal.aborted ? "REQUEST_CANCELLED" : "UPSTREAM_CALL_FAILED";
|
|
43
|
+
return createAdapterErrorResult(name, code);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
return projectBackendResult(name, upstream);
|
|
47
|
+
} catch {
|
|
48
|
+
return createAdapterErrorResult(name, "UPSTREAM_RESULT_INVALID");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const outwardTransport = new StdioServerTransport();
|
|
52
|
+
let shuttingDown = false;
|
|
53
|
+
const shutdown = async (exitCode) => {
|
|
54
|
+
if (shuttingDown) return;
|
|
55
|
+
shuttingDown = true;
|
|
56
|
+
if (exitCode !== 0) process.exitCode = exitCode;
|
|
57
|
+
await Promise.allSettled([server.close(), backend.close()]);
|
|
58
|
+
};
|
|
59
|
+
process.once("SIGINT", () => {
|
|
60
|
+
shutdown(0);
|
|
61
|
+
});
|
|
62
|
+
process.once("SIGTERM", () => {
|
|
63
|
+
shutdown(0);
|
|
64
|
+
});
|
|
65
|
+
backend.closed.then(() => {
|
|
66
|
+
if (!shuttingDown) shutdown(1);
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
await server.connect(outwardTransport);
|
|
70
|
+
} catch {
|
|
71
|
+
process.stderr.write(`${startupDiagnostic("BACKEND_INITIALIZE_FAILED")}\n`);
|
|
72
|
+
await shutdown(2);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const protocolClose = outwardTransport.onclose;
|
|
76
|
+
outwardTransport.onclose = () => {
|
|
77
|
+
protocolClose?.();
|
|
78
|
+
if (!shuttingDown) shutdown(0);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
startProxy().catch(() => {
|
|
82
|
+
process.stderr.write(`${startupDiagnostic("BACKEND_INITIALIZE_FAILED")}\n`);
|
|
83
|
+
process.exitCode = 2;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ADAPTER_ERROR_CODES, ADAPTER_ERROR_SCHEMA, APPROVED_RAW_TOOLS, DEV_FLOW_RESULT_SCHEMA, MAX_ADAPTER_DIAGNOSTIC_BYTES } from "./compatibility.js";
|
|
2
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
3
|
+
|
|
4
|
+
//#region src/result-envelope.ts
|
|
5
|
+
const REQUEST_ID_PATTERN = /^mcp-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6
|
+
const ADAPTER_MESSAGES = Object.freeze({
|
|
7
|
+
BACKEND_START_FAILED: "The Dev Flow backend could not be started.",
|
|
8
|
+
BACKEND_INITIALIZE_FAILED: "The Dev Flow backend could not be initialized.",
|
|
9
|
+
BACKEND_CATALOG_INVALID: "The Dev Flow backend tool catalog is invalid.",
|
|
10
|
+
UPSTREAM_CALL_FAILED: "The Dev Flow backend call did not return a valid result.",
|
|
11
|
+
UPSTREAM_RESULT_INVALID: "The Dev Flow backend returned an invalid result.",
|
|
12
|
+
REQUEST_CANCELLED: "The Dev Flow backend call was cancelled before a valid result was received."
|
|
13
|
+
});
|
|
14
|
+
function isPlainObject(value) {
|
|
15
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
16
|
+
const prototype = Object.getPrototypeOf(value);
|
|
17
|
+
return prototype === Object.prototype || prototype === null;
|
|
18
|
+
}
|
|
19
|
+
function hasExactKeys(value, expected) {
|
|
20
|
+
const actual = Object.keys(value).sort();
|
|
21
|
+
const sortedExpected = [...expected].sort();
|
|
22
|
+
return actual.length === sortedExpected.length && actual.every((key, index) => key === sortedExpected[index]);
|
|
23
|
+
}
|
|
24
|
+
function invalid(reason) {
|
|
25
|
+
throw new TypeError(`Invalid Dev Flow result envelope: ${reason}.`);
|
|
26
|
+
}
|
|
27
|
+
function validateDevFlowEnvelope(value, invokedTool) {
|
|
28
|
+
if (!APPROVED_RAW_TOOLS.includes(invokedTool)) invalid("invoked tool is not approved");
|
|
29
|
+
if (!isPlainObject(value)) invalid("structuredContent is not a plain object");
|
|
30
|
+
if (!hasExactKeys(value, [
|
|
31
|
+
"schema",
|
|
32
|
+
"ok",
|
|
33
|
+
"tool",
|
|
34
|
+
"request_id",
|
|
35
|
+
"result",
|
|
36
|
+
"error"
|
|
37
|
+
])) invalid("top-level fields do not match the closed envelope");
|
|
38
|
+
if (value.schema !== "dev-flow-mcp-result/1.0.0") invalid("schema identity does not match");
|
|
39
|
+
if (value.tool !== invokedTool) invalid("tool identity does not match the invoked tool");
|
|
40
|
+
if (typeof value.request_id !== "string" || !REQUEST_ID_PATTERN.test(value.request_id)) invalid("request_id does not match the pinned grammar");
|
|
41
|
+
if (typeof value.ok !== "boolean") invalid("ok is not boolean");
|
|
42
|
+
if (value.ok) {
|
|
43
|
+
if (value.error !== null) invalid("successful envelope error is not null");
|
|
44
|
+
} else {
|
|
45
|
+
if (value.result !== null) invalid("error envelope result is not null");
|
|
46
|
+
if (!isPlainObject(value.error)) invalid("error is not a plain object");
|
|
47
|
+
if (!hasExactKeys(value.error, [
|
|
48
|
+
"code",
|
|
49
|
+
"message",
|
|
50
|
+
"details",
|
|
51
|
+
"recovery"
|
|
52
|
+
])) invalid("error fields do not match the closed union");
|
|
53
|
+
if (typeof value.error.code !== "string" || value.error.code.length === 0) invalid("error code is not a non-empty string");
|
|
54
|
+
if (typeof value.error.message !== "string" || value.error.message.length === 0) invalid("error message is not a non-empty string");
|
|
55
|
+
if (!isPlainObject(value.error.details)) invalid("error details is not a plain object");
|
|
56
|
+
if (value.error.recovery !== null && !isPlainObject(value.error.recovery)) invalid("error recovery is neither a plain object nor null");
|
|
57
|
+
}
|
|
58
|
+
canonicalJson(value);
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function projectBackendResult(invokedTool, upstream) {
|
|
62
|
+
const envelope = validateDevFlowEnvelope(upstream.structuredContent, invokedTool);
|
|
63
|
+
return {
|
|
64
|
+
...upstream,
|
|
65
|
+
content: [{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: canonicalJson(envelope)
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function recoveryFor(tool) {
|
|
72
|
+
if (tool === "dev_flow_start_task") return Object.freeze(["dev_flow_find_tasks_for_path"]);
|
|
73
|
+
if (tool === "dev_flow_apply_action") return Object.freeze(["dev_flow_get_task", "dev_flow_get_next_action"]);
|
|
74
|
+
return Object.freeze([tool]);
|
|
75
|
+
}
|
|
76
|
+
function createAdapterErrorEnvelope(tool, code) {
|
|
77
|
+
if (!APPROVED_RAW_TOOLS.includes(tool)) throw new TypeError("Adapter error tool is not approved.");
|
|
78
|
+
if (!ADAPTER_ERROR_CODES.includes(code)) throw new TypeError("Adapter error code is not approved.");
|
|
79
|
+
const message = ADAPTER_MESSAGES[code];
|
|
80
|
+
if (Buffer.byteLength(message, "utf8") > 4096) throw new TypeError("Adapter diagnostic exceeds its fixed byte limit.");
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
schema: ADAPTER_ERROR_SCHEMA,
|
|
83
|
+
ok: false,
|
|
84
|
+
tool,
|
|
85
|
+
error: Object.freeze({
|
|
86
|
+
code,
|
|
87
|
+
message,
|
|
88
|
+
mutation_uncertain: tool === "dev_flow_start_task" || tool === "dev_flow_apply_action",
|
|
89
|
+
recovery: recoveryFor(tool)
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function createAdapterErrorResult(tool, code) {
|
|
94
|
+
const envelope = createAdapterErrorEnvelope(tool, code);
|
|
95
|
+
return {
|
|
96
|
+
content: [{
|
|
97
|
+
type: "text",
|
|
98
|
+
text: canonicalJson(envelope)
|
|
99
|
+
}],
|
|
100
|
+
isError: true
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { createAdapterErrorEnvelope, createAdapterErrorResult, projectBackendResult, validateDevFlowEnvelope };
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dev-flow-deepseek",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DeepSeek Harness bundle for the external Dev Flow Orchestrator MCP runtime.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"deepseek",
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"dev-flow",
|
|
11
|
+
"mcp",
|
|
12
|
+
"plugin"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/Innocent-children/dev-flow-deepseek.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Innocent-children/dev-flow-deepseek/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Innocent-children/dev-flow-deepseek#readme",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"tag": "latest"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib/",
|
|
31
|
+
"cordis.patch.yml",
|
|
32
|
+
"skills/",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": "1.12.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/js-yaml": "4.0.9",
|
|
41
|
+
"@types/node": "22.15.3",
|
|
42
|
+
"js-yaml": "4.1.0",
|
|
43
|
+
"tsdown": "0.15.4",
|
|
44
|
+
"typescript": "5.8.3"
|
|
45
|
+
},
|
|
46
|
+
"dsh": {
|
|
47
|
+
"bundle": {
|
|
48
|
+
"patch": "./cordis.patch.yml"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsdown && chmod 755 lib/proxy.js",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "node --test tests/unit/*.test.mjs tests/integration/proxy.test.mjs tests/package/package-contract.test.mjs",
|
|
55
|
+
"test:real": "node --test tests/integration/real-runtime.test.mjs",
|
|
56
|
+
"verify:package": "node scripts/verify-package.mjs"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-flow
|
|
3
|
+
description: Start or resume a governed single-repository Dev Flow lite task.
|
|
4
|
+
whenToUse: Use only when the user explicitly invokes /dev-flow for substantive repository work.
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
user-invocable: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Dev Flow
|
|
10
|
+
|
|
11
|
+
Use this Skill only after the user explicitly invokes `/dev-flow` with a
|
|
12
|
+
substantive repository task. Never activate it for an ordinary coding request.
|
|
13
|
+
|
|
14
|
+
Read [activation-and-routing.md](references/activation-and-routing.md) before
|
|
15
|
+
discovering, selecting, starting, or applying a task.
|
|
16
|
+
|
|
17
|
+
## Entry checks
|
|
18
|
+
|
|
19
|
+
Before task discovery or mutation:
|
|
20
|
+
|
|
21
|
+
1. Verify that all and only the required Dev Flow surface is available to this
|
|
22
|
+
Skill under these six model-facing names:
|
|
23
|
+
`mcp__dev-flow__dev_flow_server_info`,
|
|
24
|
+
`mcp__dev-flow__dev_flow_find_tasks_for_path`,
|
|
25
|
+
`mcp__dev-flow__dev_flow_get_task`,
|
|
26
|
+
`mcp__dev-flow__dev_flow_get_next_action`,
|
|
27
|
+
`mcp__dev-flow__dev_flow_start_task`, and
|
|
28
|
+
`mcp__dev-flow__dev_flow_apply_action`.
|
|
29
|
+
2. Call `mcp__dev-flow__dev_flow_server_info` and parse its complete canonical
|
|
30
|
+
JSON text. Require server `dev-flow`, release `0.6.12`, model version and
|
|
31
|
+
model namespace `0.4.0`, interface `dev-flow-mcp/1.0.0`, result schema
|
|
32
|
+
`dev-flow-mcp-result/1.0.0`, transport `stdio`, and health status `ready`.
|
|
33
|
+
Stop and name the exact incompatible field when any value differs; never
|
|
34
|
+
infer compatibility from a version range.
|
|
35
|
+
3. Require a substantive task after `/dev-flow`. Ask for the missing task and
|
|
36
|
+
do not create anything when the invocation is empty or conversational.
|
|
37
|
+
4. Resolve the current worktree root with `git rev-parse --show-toplevel`.
|
|
38
|
+
Stop before discovery when it fails. The exact canonical result is the sole
|
|
39
|
+
repository root; reject requests that require another repository.
|
|
40
|
+
|
|
41
|
+
If the runtime or tool surface is missing, report the separately installed
|
|
42
|
+
`dev-flow-mcp` release `0.6.12` prerequisite. Do not install, update, repair, or
|
|
43
|
+
replace the runtime.
|
|
44
|
+
|
|
45
|
+
## Authority boundary
|
|
46
|
+
|
|
47
|
+
The external Dev Flow Controller is the only workflow and task-state
|
|
48
|
+
authority. For every step, use the fresh returned action, guidance, allowed
|
|
49
|
+
effects, required evidence, payload schema, binding, repository set, recovery,
|
|
50
|
+
and terminal result. Do not invent actions, payload fields, transitions,
|
|
51
|
+
completion rules, task state, or a Delivery Dossier.
|
|
52
|
+
|
|
53
|
+
Use ordinary DSH Bash, filesystem, and search tools only for the currently
|
|
54
|
+
authorized repository work. Never use a generic shell MCP. Never create or
|
|
55
|
+
switch a branch or worktree, and never commit, push, open a pull request,
|
|
56
|
+
publish, tag, or release.
|
|
57
|
+
|
|
58
|
+
Stop only when the Controller returns a terminal result, then report that
|
|
59
|
+
result and its Delivery Dossier exactly.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Activation and routing
|
|
2
|
+
|
|
3
|
+
These rules refine explicit `/dev-flow` task selection and recovery. They do
|
|
4
|
+
not define Controller actions, payload schemas, transitions, or terminal
|
|
5
|
+
criteria.
|
|
6
|
+
|
|
7
|
+
## Complete-result rule
|
|
8
|
+
|
|
9
|
+
Treat tool text as authority only when it is the complete canonical JSON
|
|
10
|
+
result. If any result mentions `spill`, `truncated`, `pruned`, `preview`, or
|
|
11
|
+
`Full formatted result stored at`, use a normal DSH file-reading tool to read
|
|
12
|
+
the complete saved text before parsing it. If the complete text cannot be
|
|
13
|
+
read, stop. Never infer an action, binding, payload schema, repository set,
|
|
14
|
+
recovery operation, or terminal result from a preview.
|
|
15
|
+
|
|
16
|
+
## Select or start
|
|
17
|
+
|
|
18
|
+
1. Call `mcp__dev-flow__dev_flow_find_tasks_for_path` with the exact current
|
|
19
|
+
canonical Git root. Inventory must be authoritative; stop if it is
|
|
20
|
+
unavailable or inconsistent.
|
|
21
|
+
2. Discovery does not prove complete repository membership. For every
|
|
22
|
+
candidate that might be selected, call
|
|
23
|
+
`mcp__dev-flow__dev_flow_get_next_action` and use its fresh authority.
|
|
24
|
+
3. Canonicalize every returned `repository_set.repositories[].path`. A
|
|
25
|
+
candidate is compatible only when its workflow is exactly `lite`, its
|
|
26
|
+
repository array has cardinality one, and that one canonical path equals
|
|
27
|
+
the current root. Reject subsets, supersets, different members,
|
|
28
|
+
multi-repository tasks, unrelated paths, and non-`lite` workflows.
|
|
29
|
+
4. Resume one compatible active task when the result is unambiguous. If more
|
|
30
|
+
than one is compatible, present their bounded identities and ask the user
|
|
31
|
+
to choose; never select by recency. If discovery returns only incompatible
|
|
32
|
+
tasks, report the conflict and ask the user to resolve it outside this MVP.
|
|
33
|
+
5. When authoritative discovery returns no candidate and the request is
|
|
34
|
+
substantive, call `mcp__dev-flow__dev_flow_start_task` with only the user
|
|
35
|
+
requirement, workflow `lite`, and a one-element repositories array holding
|
|
36
|
+
the current root. Omit custom task ID and contract fields.
|
|
37
|
+
|
|
38
|
+
Never merge candidates, convert workflows, cancel tasks, revise contracts, or
|
|
39
|
+
use an unexposed inventory or governance operation.
|
|
40
|
+
|
|
41
|
+
## Drive current authority
|
|
42
|
+
|
|
43
|
+
For each nonterminal result:
|
|
44
|
+
|
|
45
|
+
1. Reconfirm exact one-root repository equality.
|
|
46
|
+
2. Read the fresh action ID, objective, guidance, allowed effects, required
|
|
47
|
+
evidence, closed payload schema, and complete binding.
|
|
48
|
+
3. Perform only that action in the current repository with normal DSH tools.
|
|
49
|
+
4. Build a payload containing exactly the schema-declared fields.
|
|
50
|
+
5. Call `mcp__dev-flow__dev_flow_apply_action` with the exact task ID, action
|
|
51
|
+
ID, payload, and unmodified current binding.
|
|
52
|
+
6. Continue only from the fresh action returned by a successful mutation or a
|
|
53
|
+
new `mcp__dev-flow__dev_flow_get_next_action` read. Never reuse an old
|
|
54
|
+
binding.
|
|
55
|
+
|
|
56
|
+
When the Controller returns a terminal result, report its Delivery Dossier.
|
|
57
|
+
Do not announce completion before that authority exists.
|
|
58
|
+
|
|
59
|
+
## Errors and mutation uncertainty
|
|
60
|
+
|
|
61
|
+
A valid `dev-flow-mcp-result/1.0.0` envelope with `ok: false` remains a
|
|
62
|
+
Controller domain error. Follow its recovery only when the named operation is
|
|
63
|
+
one of the six exposed tools. If it requires a hidden governance,
|
|
64
|
+
cancellation, finding, listing, or contract operation, report that the task is
|
|
65
|
+
outside this MVP and stop.
|
|
66
|
+
|
|
67
|
+
An adapter envelope with schema `dsh-dev-flow-proxy-error/1.0.0` is not a
|
|
68
|
+
Controller result. For a failed read, wait until the six-tool surface is
|
|
69
|
+
healthy and repeat that read at most once. Never reinterpret an adapter error
|
|
70
|
+
as task state.
|
|
71
|
+
|
|
72
|
+
If `mcp__dev-flow__dev_flow_start_task` loses or corrupts its response, assume
|
|
73
|
+
neither success nor failure. Rediscover tasks for the current root and inspect
|
|
74
|
+
fresh compatible authority before considering another start. Do not create a
|
|
75
|
+
replacement for a task that may already exist.
|
|
76
|
+
|
|
77
|
+
If `mcp__dev-flow__dev_flow_apply_action` loses or corrupts its response,
|
|
78
|
+
assume neither success nor failure. First call
|
|
79
|
+
`mcp__dev-flow__dev_flow_get_task`, then
|
|
80
|
+
`mcp__dev-flow__dev_flow_get_next_action`, and compare the fresh revision,
|
|
81
|
+
action, and binding. Retry only when that authority proves the mutation did not
|
|
82
|
+
commit and the current binding still authorizes it. Never blindly replay a
|
|
83
|
+
mutation.
|
|
84
|
+
|
|
85
|
+
## Repository and product boundary
|
|
86
|
+
|
|
87
|
+
Keep the repository set fixed at the one current user-prepared worktree. Do not
|
|
88
|
+
manage Git topology or publishing. Do not install a runtime, add a UI, expose
|
|
89
|
+
another MCP tool, use remote transport, or store adapter-owned task state.
|