@reticlehq/init 3.8.1 → 3.9.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 CHANGED
@@ -1,105 +1,202 @@
1
- # Functional Source License, Version 1.1, ALv2 Future License
2
1
 
3
- ## Abbreviation
4
-
5
- FSL-1.1-ALv2
6
-
7
- ## Notice
8
-
9
- Copyright 2026 Reticle Labs
10
-
11
- ## Terms and Conditions
12
-
13
- ### Licensor ("We")
14
-
15
- The party offering the Software under these Terms and Conditions.
16
-
17
- ### The Software
18
-
19
- The "Software" is each version of the software that we make available under
20
- these Terms and Conditions, as indicated by our inclusion of these Terms and
21
- Conditions with the Software.
22
-
23
- ### License Grant
24
-
25
- Subject to your compliance with this License Grant and the Patents,
26
- Redistribution and Trademark clauses below, we hereby grant you the right to
27
- use, copy, modify, create derivative works, publicly perform, publicly display
28
- and redistribute the Software for any Permitted Purpose identified below.
29
-
30
- ### Permitted Purpose
31
-
32
- A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
- means making the Software available to others in a commercial product or
34
- service that:
35
-
36
- 1. substitutes for the Software;
37
-
38
- 2. substitutes for any other product or service we offer using the Software
39
- that exists as of the date we make the Software available; or
40
-
41
- 3. offers the same or substantially similar functionality as the Software.
42
-
43
- Permitted Purposes specifically include using the Software:
44
-
45
- 1. for your internal use and access;
46
-
47
- 2. for non-commercial education;
48
-
49
- 3. for non-commercial research; and
50
-
51
- 4. in connection with professional services that you provide to a licensee
52
- using the Software in accordance with these Terms and Conditions.
53
-
54
- ### Patents
55
-
56
- To the extent your use for a Permitted Purpose would necessarily infringe our
57
- patents, the license grant above includes a license under our patents. If you
58
- make a claim against any party that the Software infringes or contributes to
59
- the infringement of any patent, then your patent license to the Software ends
60
- immediately.
61
-
62
- ### Redistribution
63
-
64
- The Terms and Conditions apply to all copies, modifications and derivatives of
65
- the Software.
66
-
67
- If you redistribute any copies, modifications or derivatives of the Software,
68
- you must include a copy of or a link to these Terms and Conditions and not
69
- remove any copyright notices provided in or with the Software.
70
-
71
- ### Disclaimer
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
- IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
- PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
-
77
- IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
- SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
- EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
-
81
- ### Trademarks
82
-
83
- Except for displaying the License Details and identifying us as the origin of
84
- the Software, you have no right under these Terms and Conditions to use our
85
- trademarks, trade names, service marks or product names.
86
-
87
- ## Grant of Future License
88
-
89
- We hereby irrevocably grant you an additional license to use the Software under
90
- the Apache License, Version 2.0 that is effective on the second anniversary of
91
- the date we make the Software available. On or after that date, you may use the
92
- Software under the Apache License, Version 2.0, in which case the following
93
- will apply:
94
-
95
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
- this file except in compliance with the License.
97
-
98
- You may obtain a copy of the License at
99
-
100
- http://www.apache.org/licenses/LICENSE-2.0
101
-
102
- Unless required by applicable law or agreed to in writing, software distributed
103
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
- CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
- specific language governing permissions and limitations under the License.
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Reticle Labs
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Reticle
2
+ Copyright 2026 Reticle Labs
3
+
4
+ This product includes software developed at Reticle Labs.
5
+ Licensed under the Apache License, Version 2.0.
package/README.md CHANGED
@@ -26,4 +26,4 @@ const result = runInit(
26
26
 
27
27
  ## License
28
28
 
29
- FSL-1.1-ALv2 — free for any Permitted Purpose, converts to Apache-2.0 two years after release. See [LICENSE](./LICENSE).
29
+ Apache-2.0. See [LICENSE](./LICENSE).
@@ -24,7 +24,7 @@ import { tanstackStartConnectPath } from './patch/tanstack-start.js';
24
24
  import { installedViteMajor } from './patch/vite-owning-config.js';
25
25
  import { PRETTIERIGNORE_PATH } from './patch/prettier-ignore.js';
26
26
  import { RETICLE_CONFIG_FILE } from './plan/plan.js';
27
- import { claudeAvailableProbe, claudeHasReticle, codexAvailableProbe } from './register/mcp.js';
27
+ import { claudeAvailableProbe, claudeHasReticle, claudeUserEntryIsFloating, claudePluginInstalled, codexAvailableProbe, } from './register/mcp.js';
28
28
  import { nextUsesTypeScript, reticleDevLocation } from './patch/next-patch.js';
29
29
  import { scanTestids, storeHints, scanStores } from './detect/capabilities.js';
30
30
  import { CLAUDE_PROJECT_CONFIG, CURSOR_PROJECT_MARKER, McpClient } from './register/mcp-clients.js';
@@ -265,6 +265,10 @@ export function gatherPlanInput(options, io, pkg) {
265
265
  const claudeCli = options.mcp ? io.probe(availableProbe.command, availableProbe.args) : false;
266
266
  // Read from Claude's config, never `claude mcp get`: that launches the server — see claudeHasReticle.
267
267
  const mcpExists = claudeCli ? claudeHasReticle(io, io.cwd()) : false;
268
+ // The plugin brings its own server; a user-scope entry next to it is a duplicate.
269
+ const claudePlugin = options.mcp ? claudePluginInstalled(io) : false;
270
+ const claudeUserEntry = claudePlugin ? claudeHasReticle(io, undefined) : false;
271
+ const claudeUserEntryFloating = mcpExists && !claudePlugin && claudeUserEntryIsFloating(io);
268
272
  // Every MCP client this machine shows evidence of. Conservative and one-directional: we write
269
273
  // into a config a client ALREADY has, and never create ~/.gemini or ~/.codeium for somebody who
270
274
  // does not use them.
@@ -325,6 +329,9 @@ export function gatherPlanInput(options, io, pkg) {
325
329
  prettierIgnoreSource: io.readFile(PRETTIERIGNORE_PATH),
326
330
  claudeCli,
327
331
  mcpExists,
332
+ claudePlugin,
333
+ claudeUserEntry,
334
+ claudeUserEntryFloating,
328
335
  insideClaudeCode: io.host.insideClaudeCode(),
329
336
  claudeProjectConfig: options.mcp ? io.readFile(agentFile(CLAUDE_PROJECT_CONFIG)) : undefined,
330
337
  platform: process.platform,
@@ -432,6 +439,7 @@ export function gatherPlanInput(options, io, pkg) {
432
439
  const bin = io.host.hookBin?.();
433
440
  return bin === undefined ? {} : { hookBin: bin };
434
441
  })(),
442
+ mcpLauncher: io.host.mcpLauncher?.(),
435
443
  ...(agentRoot === undefined
436
444
  ? {}
437
445
  : {
package/dist/host.d.ts CHANGED
@@ -55,6 +55,12 @@ export interface InitHost {
55
55
  * where a direct command is not wanted (Windows shells), and the hooks use npx alone.
56
56
  */
57
57
  hookBin?(): string | undefined;
58
+ /**
59
+ * The installed CLI's bin, as an absolute path, for the MCP registration (`node <bin> mcp`).
60
+ * Undefined when this CLI runs from a run-once copy such as npx's cache: the registration then
61
+ * names the pinned npx command. See `installedLauncher`.
62
+ */
63
+ mcpLauncher?(): string | undefined;
58
64
  }
59
65
  /**
60
66
  * A host that does nothing, for callers that drive `init`'s file surface without running an install
package/dist/index.d.ts CHANGED
@@ -46,8 +46,8 @@ export { reticleConfigContent } from './patch/snippets.js';
46
46
  * the same detection `init` uses — a second copy would be a second answer to "which agents are
47
47
  * here", and the two would disagree the first time a client was added to one of them.
48
48
  */
49
- export { McpClient, ConfigScope, MCP_CLIENTS, ClientMergeStatus, clientSpec, mergeClientConfig, } from './register/mcp-clients.js';
50
- export { claudeAddCommand, claudeAvailableProbe, claudeHasReticle, codexAddCommand, codexAvailableProbe, } from './register/mcp.js';
49
+ export { McpClient, ConfigScope, MCP_CLIENTS, ClientMergeStatus, ConfigFormat, clientSpec, mergeClientConfig, type ClientSpec, } from './register/mcp-clients.js';
50
+ export { claudeAddCommand, claudeAvailableProbe, claudeHasReticle, claudePluginInstalled, claudeRemoveUserCommand, claudeReticleEntries, claudeStaleEntryNote, claudeUserEntryIsFloating, codexAddCommand, codexAvailableProbe, installedLauncher, isReticleLauncher, isReticleRegistration, serverInvocation, } from './register/mcp.js';
51
51
  export { codexNamesOurServer } from './register/codex-toml.js';
52
52
  export { detectMcpClients, type DetectedClient } from './register/detect-clients.js';
53
53
  /**
package/dist/index.js CHANGED
@@ -46,15 +46,17 @@ export { reticleConfigContent } from './patch/snippets.js';
46
46
  * the same detection `init` uses — a second copy would be a second answer to "which agents are
47
47
  * here", and the two would disagree the first time a client was added to one of them.
48
48
  */
49
- export { McpClient, ConfigScope, MCP_CLIENTS, ClientMergeStatus, clientSpec, mergeClientConfig, } from './register/mcp-clients.js';
49
+ export { McpClient, ConfigScope, MCP_CLIENTS, ClientMergeStatus, ConfigFormat, clientSpec, mergeClientConfig, } from './register/mcp-clients.js';
50
50
  export { claudeAddCommand,
51
51
  // The two probes `run.ts` uses to decide about Claude Code. Exported because `reticle setup mcp`
52
52
  // asks the same question and had no way to ask it: Claude Code keeps no config file, so the
53
53
  // file-reading detector cannot see it, and the installer silently skipped the commonest client.
54
- claudeAvailableProbe, claudeHasReticle,
54
+ claudeAvailableProbe, claudeHasReticle, claudePluginInstalled, claudeRemoveUserCommand, claudeReticleEntries, claudeStaleEntryNote, claudeUserEntryIsFloating,
55
55
  // Codex keeps its registration behind `codex mcp add`, like Claude. `reticle setup mcp` needs the
56
56
  // command, the probe and the "is the entry already there, in any shape" check to do the same.
57
- codexAddCommand, codexAvailableProbe, } from './register/mcp.js';
57
+ codexAddCommand, codexAvailableProbe,
58
+ // The MCP launch rule, for `reticle setup` (other agents) and `reticle doctor` (a launcher gone).
59
+ installedLauncher, isReticleLauncher, isReticleRegistration, serverInvocation, } from './register/mcp.js';
58
60
  export { codexNamesOurServer } from './register/codex-toml.js';
59
61
  export { detectMcpClients } from './register/detect-clients.js';
60
62
  /**
@@ -125,6 +125,12 @@ export interface PlanInput {
125
125
  claudeCli: boolean;
126
126
  /** Whether an `reticle` MCP server is already registered with Claude (any scope) — idempotency. */
127
127
  mcpExists: boolean;
128
+ /** The Reticle Claude Code plugin is installed, and it brings its own `reticle` server. */
129
+ claudePlugin?: boolean | undefined;
130
+ /** A user-scope `reticle` entry exists too. Next to the plugin, that is a duplicate. */
131
+ claudeUserEntry?: boolean | undefined;
132
+ /** The user-scope `reticle` entry is the floating npx form. Reported, never replaced. */
133
+ claudeUserEntryFloating?: boolean | undefined;
128
134
  /**
129
135
  * Whether `init` is running inside Claude Code itself, which is the one case where writing its
130
136
  * project-scope `.mcp.json` is known to be wanted. See `CLAUDE_PROJECT_SPEC`.
@@ -372,6 +378,8 @@ export interface PlanInput {
372
378
  promptHooks?: readonly PromptHookTarget[] | undefined;
373
379
  /** See `InitHost.hookBin`. */
374
380
  hookBin?: string | undefined;
381
+ /** See `InitHost.mcpLauncher`. Absent: the MCP registration uses the pinned npx command. */
382
+ mcpLauncher?: string | undefined;
375
383
  /**
376
384
  * Absolute directory the AGENT runs in, when that is not the app's directory.
377
385
  *
package/dist/plan/plan.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * contents, produce an ordered list of steps — each marked apply / manual / already / skip. The
4
4
  * runner performs the `write` side-effects; this module decides *what* should happen.
5
5
  */
6
- import { claudeAddCommand, claudeProjectMcpJson, codexAddCommand, mcpManual, } from '../register/mcp.js';
6
+ import { claudeAddCommand, claudeProjectMcpJson, claudeRemoveUserCommand, claudeStaleEntryNote, codexAddCommand, mcpManual, } from '../register/mcp.js';
7
7
  import { codexNamesOurServer } from '../register/codex-toml.js';
8
8
  import { mergeClientConfig, ClientMergeStatus, clientSnippet, clientSpec, CLAUDE_PROJECT_CONFIG, CLAUDE_PROJECT_SPEC, McpClient, } from '../register/mcp-clients.js';
9
9
  import { CLAUDE_COMMAND_PATH, CURSOR_COMMAND_PATH, SLASH_COMMAND_BODY, SLASH_COMMAND_SIGNATURE, } from '../register/slash-command.js';
@@ -39,7 +39,47 @@ function agentFile(input, relPath) {
39
39
  return root === undefined || 0 === root.length ? relPath : join(root, relPath);
40
40
  }
41
41
  const CLAUDE_MCP_TITLE = 'MCP server (Claude, global)';
42
+ /**
43
+ * The Reticle plugin brings its own `reticle` server. A user-scope entry next to it gives Claude
44
+ * Code two servers with the same tools, so none is added. An old one is named, not removed.
45
+ */
46
+ function claudePluginStep(input) {
47
+ if (true === input.claudeUserEntry) {
48
+ return {
49
+ title: CLAUDE_MCP_TITLE,
50
+ target: MCP_TARGET,
51
+ status: StepStatus.MANUAL,
52
+ detail: `the Reticle plugin is active and a user-scope reticle server is registered too, so Claude Code has two. Remove the user-scope one: ${claudeRemoveUserCommand()}`,
53
+ };
54
+ }
55
+ return {
56
+ title: CLAUDE_MCP_TITLE,
57
+ target: MCP_TARGET,
58
+ status: StepStatus.ALREADY,
59
+ detail: 'the Reticle plugin is active and gives Claude Code its server; no user-scope entry added',
60
+ };
61
+ }
62
+ /**
63
+ * The floating npx entry, kept and named. A NOTICE after the Claude Code step, so the step that
64
+ * decides the closing hint still reads ALREADY.
65
+ */
66
+ function claudeFloatingSteps(input) {
67
+ if (true !== input.claudeUserEntryFloating) {
68
+ return [];
69
+ }
70
+ return [
71
+ {
72
+ title: 'Old MCP entry (Claude, global)',
73
+ target: MCP_TARGET,
74
+ status: StepStatus.NOTICE,
75
+ detail: claudeStaleEntryNote(input.mcpLauncher),
76
+ },
77
+ ];
78
+ }
42
79
  function claudeMcpStep(input) {
80
+ if (true === input.claudePlugin) {
81
+ return claudePluginStep(input);
82
+ }
43
83
  if (!input.claudeCli) {
44
84
  return null;
45
85
  }
@@ -51,7 +91,7 @@ function claudeMcpStep(input) {
51
91
  detail: 'reticle already registered (install once, used by every project)',
52
92
  };
53
93
  }
54
- const cmd = claudeAddCommand();
94
+ const cmd = claudeAddCommand(input.mcpLauncher);
55
95
  return {
56
96
  title: CLAUDE_MCP_TITLE,
57
97
  target: MCP_TARGET,
@@ -71,7 +111,7 @@ function otherClientSteps(input) {
71
111
  return (input.detectedClients ?? []).map((detected) => {
72
112
  const spec = clientSpec(detected.id);
73
113
  return (codexCliStep(spec, detected.configPath, detected.existing, input) ??
74
- clientStep(spec, detected.configPath, detected.existing));
114
+ clientStep(spec, detected.configPath, detected.existing, input.mcpLauncher));
75
115
  });
76
116
  }
77
117
  /**
@@ -90,7 +130,7 @@ function codexCliStep(spec, configPath, existing, input) {
90
130
  if (codexNamesOurServer(existing, spec.serversKey)) {
91
131
  return null;
92
132
  }
93
- const cmd = codexAddCommand();
133
+ const cmd = codexAddCommand(input.mcpLauncher);
94
134
  return {
95
135
  title: `MCP server (${spec.label})`,
96
136
  target: configPath,
@@ -100,8 +140,8 @@ function codexCliStep(spec, configPath, existing, input) {
100
140
  };
101
141
  }
102
142
  /** One client's step: already-correct is left alone, an unparseable file gets a paste-able block. */
103
- function clientStep(spec, configPath, existing) {
104
- const merged = mergeClientConfig(spec, existing);
143
+ function clientStep(spec, configPath, existing, launcher) {
144
+ const merged = mergeClientConfig(spec, existing, launcher);
105
145
  const title = `MCP server (${spec.label})`;
106
146
  if (merged.status === ClientMergeStatus.ALREADY) {
107
147
  return {
@@ -118,7 +158,7 @@ function clientStep(spec, configPath, existing) {
118
158
  title,
119
159
  target: configPath,
120
160
  status: StepStatus.MANUAL,
121
- detail: `add this to ${configPath} by hand:\n${clientSnippet(spec)}`,
161
+ detail: `add this to ${configPath} by hand:\n${clientSnippet(spec, launcher)}`,
122
162
  };
123
163
  }
124
164
  return {
@@ -136,11 +176,11 @@ function clientStep(spec, configPath, existing) {
136
176
  * they get the notice instead.
137
177
  */
138
178
  function claudeProjectStep(input) {
139
- if (input.claudeCli || true !== input.insideClaudeCode) {
179
+ if (input.claudeCli || true !== input.insideClaudeCode || true === input.claudePlugin) {
140
180
  return null;
141
181
  }
142
182
  const path = agentFile(input, CLAUDE_PROJECT_CONFIG);
143
- return clientStep(CLAUDE_PROJECT_SPEC, path, input.claudeProjectConfig ?? null);
183
+ return clientStep(CLAUDE_PROJECT_SPEC, path, input.claudeProjectConfig ?? null, input.mcpLauncher);
144
184
  }
145
185
  /** One global registration per detected agent (Claude + Cursor). Falls back to a manual note. */
146
186
  function mcpSteps(input) {
@@ -163,6 +203,7 @@ function mcpSteps(input) {
163
203
  const claudeProject = claudeProjectStep(input);
164
204
  const steps = [
165
205
  ...stepsForAgents(input, (a) => a.mcpStep),
206
+ ...claudeFloatingSteps(input),
166
207
  ...(null === claudeProject ? [] : [claudeProject]),
167
208
  ...otherClientSteps(input),
168
209
  ];
@@ -173,7 +214,7 @@ function mcpSteps(input) {
173
214
  title: 'MCP server (global)',
174
215
  target: MCP_TARGET,
175
216
  status: StepStatus.MANUAL,
176
- detail: mcpManual(),
217
+ detail: mcpManual(input.mcpLauncher),
177
218
  },
178
219
  ];
179
220
  }
@@ -191,7 +232,10 @@ function mcpSteps(input) {
191
232
  * to register, so nothing has silently vanished — and leaving that path untouched keeps every
192
233
  * pristine scaffold in the install baseline reading exactly as it did.
193
234
  */
194
- if (!input.claudeCli && null === claudeProject && steps.length > 0) {
235
+ if (!input.claudeCli &&
236
+ true !== input.claudePlugin &&
237
+ null === claudeProject &&
238
+ steps.length > 0) {
195
239
  steps.push({
196
240
  title: CLAUDE_MCP_TITLE,
197
241
  target: MCP_TARGET,
@@ -200,7 +244,7 @@ function mcpSteps(input) {
200
244
  // which would turn an informational line into a gate failure on any machine that happens to
201
245
  // have another agent's config. A notice prints in full exactly like a manual step.
202
246
  status: StepStatus.NOTICE,
203
- detail: `no \`claude\` on PATH, so it could not be registered from here. Inside a Claude Code VS Code extension session the CLI is genuinely absent while the editor is not — add ${claudeProjectMcpJson()}`,
247
+ detail: `no \`claude\` on PATH, so it could not be registered from here. Inside a Claude Code VS Code extension session the CLI is genuinely absent while the editor is not — add ${claudeProjectMcpJson(input.mcpLauncher)}`,
204
248
  });
205
249
  }
206
250
  const windowsNote = windowsMcpNoteStep(input);
@@ -32,8 +32,8 @@ export interface ClientSpec {
32
32
  format: ConfigFormat;
33
33
  /** The object key holding the server map — `mcpServers`, `servers`, or `mcp`. */
34
34
  serversKey: string;
35
- /** Our entry, in THIS client's shape. */
36
- entry: () => unknown;
35
+ /** Our entry, in THIS client's shape. `launcher`: see `serverInvocation`. */
36
+ entry: (launcher?: string) => unknown;
37
37
  /** Where the shape came from, so the next person can re-check it rather than trust this file. */
38
38
  docs: string;
39
39
  }
@@ -74,14 +74,14 @@ interface ClientMergeResult {
74
74
  * already has the table is a warning they must not act on, and the setup contract makes a `⚠`
75
75
  * blocking (#681). Detection is read-only and cannot corrupt anything.
76
76
  */
77
- export declare function mergeClientConfig(spec: ClientSpec, existing: string | null): ClientMergeResult;
77
+ export declare function mergeClientConfig(spec: ClientSpec, existing: string | null, launcher?: string): ClientMergeResult;
78
78
  /**
79
79
  * A block the user can paste, for a client we could not write.
80
80
  *
81
81
  * Every client gets one, including the ones we CAN write: when a merge comes back MANUAL because the
82
82
  * file could not be parsed, the snippet is the only actionable thing left to give.
83
83
  */
84
- export declare function clientSnippet(spec: ClientSpec): string;
84
+ export declare function clientSnippet(spec: ClientSpec, launcher?: string): string;
85
85
  /**
86
86
  * The path whose existence means "this user has this client".
87
87
  *
@@ -18,7 +18,7 @@
18
18
  * an install that reports success and registers nothing, which is the exact failure class this
19
19
  * repo's install gate exists to catch.
20
20
  */
21
- import { NPX, MCP_SERVER_NAME, npxServerArgs, isReticleRegistration } from './mcp.js';
21
+ import { MCP_SERVER_NAME, isReticleRegistration, serverInvocation } from './mcp.js';
22
22
  import { codexServerTokens } from './codex-toml.js';
23
23
  export const McpClient = {
24
24
  CLAUDE_CODE: 'claude-code',
@@ -43,15 +43,16 @@ export const ConfigFormat = {
43
43
  CLI: 'cli',
44
44
  };
45
45
  /** The `{ command, args }` entry Cursor, Windsurf, Gemini and VS Code all take. */
46
- function commandArgsEntry() {
47
- return { command: NPX, args: npxServerArgs() };
46
+ function commandArgsEntry(launcher) {
47
+ const [command, ...args] = serverInvocation(launcher);
48
+ return { command, args };
48
49
  }
49
50
  /**
50
51
  * OpenCode's entry. `command` is a single ARRAY containing the executable and its arguments, and
51
52
  * `enabled` is explicit — a server registered but disabled is the quietest possible failure.
52
53
  */
53
- function openCodeEntry() {
54
- return { type: 'local', command: [NPX, ...npxServerArgs()], enabled: true };
54
+ function openCodeEntry(launcher) {
55
+ return { type: 'local', command: serverInvocation(launcher), enabled: true };
55
56
  }
56
57
  /**
57
58
  * Claude Code's project-scope MCP config, which needs no CLI on PATH.
@@ -189,8 +190,9 @@ export const MCP_CLIENTS = [
189
190
  ];
190
191
  export function clientSpec(id) {
191
192
  const found = MCP_CLIENTS.find((spec) => spec.id === id);
192
- if (found === undefined)
193
+ if (found === undefined) {
193
194
  throw new Error(`no MCP client spec for '${id}'`);
195
+ }
194
196
  return found;
195
197
  }
196
198
  export const ClientMergeStatus = {
@@ -199,15 +201,17 @@ export const ClientMergeStatus = {
199
201
  MANUAL: 'manual',
200
202
  };
201
203
  function parseConfig(existing) {
202
- if (null === existing || 0 === existing.trim().length)
204
+ if (null === existing || 0 === existing.trim().length) {
203
205
  return { ok: true, config: {} };
206
+ }
204
207
  try {
205
208
  const parsed = JSON.parse(existing);
206
209
  // Valid JSON that is not a PLAIN OBJECT — `[]`, `3`, `"x"`, `null` — must not fall through to an
207
210
  // empty config, because the file then gets rewritten wholesale. Unparseable JSON was always
208
211
  // handled conservatively; this adjacent case destroyed the file instead.
209
- if (typeof parsed !== 'object' || null === parsed || Array.isArray(parsed))
212
+ if (typeof parsed !== 'object' || null === parsed || Array.isArray(parsed)) {
210
213
  return { ok: false };
214
+ }
211
215
  return { ok: true, config: parsed };
212
216
  }
213
217
  catch {
@@ -228,11 +232,13 @@ function parseConfig(existing) {
228
232
  * not repair the thing an upgrade exists to repair — and a WRONG one, naming a Reticle package that
229
233
  * has no MCP server in it (see isReticleRegistration).
230
234
  */
231
- function leaveEntryAlone(existing, spec) {
232
- if (JSON.stringify(existing) === JSON.stringify(spec.entry()))
235
+ function leaveEntryAlone(existing, spec, launcher) {
236
+ if (JSON.stringify(existing) === JSON.stringify(spec.entry(launcher))) {
233
237
  return true;
234
- if (typeof existing !== 'object' || null === existing)
238
+ }
239
+ if (typeof existing !== 'object' || null === existing) {
235
240
  return true;
241
+ }
236
242
  const record = existing;
237
243
  // Both shapes carry the package name somewhere in a string; find it without assuming which field.
238
244
  const tokens = [record.command, record.args].flat().filter((v) => 'string' === typeof v);
@@ -246,14 +252,23 @@ function leaveEntryAlone(existing, spec) {
246
252
  * drifted from what we would write, and when the shape was not one the scanner reads — every one of
247
253
  * those keeps today's MANUAL answer, and the snippet is then the actionable thing to print.
248
254
  */
249
- function tomlEntryIsSettled(spec, existing) {
255
+ /** `@reticlehq/server@3.8.2` → `@reticlehq/server`. Every other string is returned as it is. */
256
+ const unpinned = (token) => token.replace(/^(@reticlehq\/server)@.*$/, '$1');
257
+ function tomlEntryIsSettled(spec, existing, launcher) {
250
258
  const tokens = codexServerTokens(existing, spec.serversKey);
251
- if (0 === tokens.length)
259
+ if (0 === tokens.length) {
252
260
  return false;
253
- const expected = [NPX, ...npxServerArgs()];
261
+ }
254
262
  // Same strings, and no others: an entry carrying an extra flag is not the one we would write.
255
- if (tokens.length === expected.length && expected.every((t) => tokens.includes(t)))
263
+ const same = (a, b) => a.length === b.length && b.every((t) => a.includes(t));
264
+ if (same(tokens, serverInvocation(launcher))) {
256
265
  return true;
266
+ }
267
+ // An npx entry of an older version still starts Reticle. TOML is never written by us, so asking
268
+ // for a hand edit at each release is a warning with no defect behind it.
269
+ if (same(tokens.map(unpinned), serverInvocation().map(unpinned))) {
270
+ return true;
271
+ }
257
272
  // Not ours to touch. Somebody pointing `reticle` at their own local build made a deliberate
258
273
  // choice, and telling them to hand-edit it back is the same wrong answer as overwriting it.
259
274
  return !isReticleRegistration(tokens);
@@ -269,29 +284,30 @@ function tomlEntryIsSettled(spec, existing) {
269
284
  * already has the table is a warning they must not act on, and the setup contract makes a `⚠`
270
285
  * blocking (#681). Detection is read-only and cannot corrupt anything.
271
286
  */
272
- export function mergeClientConfig(spec, existing) {
287
+ export function mergeClientConfig(spec, existing, launcher) {
273
288
  if (spec.format !== ConfigFormat.JSON) {
274
- if (ConfigFormat.TOML === spec.format && tomlEntryIsSettled(spec, existing)) {
289
+ if (ConfigFormat.TOML === spec.format && tomlEntryIsSettled(spec, existing, launcher)) {
275
290
  return { status: ClientMergeStatus.ALREADY, content: existing ?? '' };
276
291
  }
277
292
  return { status: ClientMergeStatus.MANUAL, content: existing ?? '' };
278
293
  }
279
294
  const parsed = parseConfig(existing);
280
- if (!parsed.ok)
295
+ if (!parsed.ok) {
281
296
  return { status: ClientMergeStatus.MANUAL, content: existing ?? '' };
297
+ }
282
298
  const config = parsed.config;
283
299
  const current = config[spec.serversKey];
284
300
  const servers = 'object' === typeof current && null !== current && !Array.isArray(current)
285
301
  ? current
286
302
  : {};
287
303
  if (Object.prototype.hasOwnProperty.call(servers, MCP_SERVER_NAME) &&
288
- leaveEntryAlone(servers[MCP_SERVER_NAME], spec)) {
304
+ leaveEntryAlone(servers[MCP_SERVER_NAME], spec, launcher)) {
289
305
  return { status: ClientMergeStatus.ALREADY, content: existing ?? '' };
290
306
  }
291
307
  // Only OUR key is replaced; every other server and top-level key is carried through untouched.
292
308
  const merged = {
293
309
  ...config,
294
- [spec.serversKey]: { ...servers, [MCP_SERVER_NAME]: spec.entry() },
310
+ [spec.serversKey]: { ...servers, [MCP_SERVER_NAME]: spec.entry(launcher) },
295
311
  };
296
312
  return { status: ClientMergeStatus.APPLY, content: `${JSON.stringify(merged, null, 2)}\n` };
297
313
  }
@@ -301,17 +317,17 @@ export function mergeClientConfig(spec, existing) {
301
317
  * Every client gets one, including the ones we CAN write: when a merge comes back MANUAL because the
302
318
  * file could not be parsed, the snippet is the only actionable thing left to give.
303
319
  */
304
- export function clientSnippet(spec) {
320
+ export function clientSnippet(spec, launcher) {
321
+ const [command, ...rest] = serverInvocation(launcher);
305
322
  if (spec.format === ConfigFormat.TOML) {
306
- const args = npxServerArgs()
307
- .map((a) => `"${a}"`)
308
- .join(', ');
309
- return `[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "${NPX}"\nargs = [${args}]\n`;
323
+ // JSON string escapes are valid TOML basic-string escapes, so a Windows path stays valid.
324
+ const args = rest.map((a) => JSON.stringify(a)).join(', ');
325
+ return `[mcp_servers.${MCP_SERVER_NAME}]\ncommand = ${JSON.stringify(command)}\nargs = [${args}]\n`;
310
326
  }
311
327
  if (spec.format === ConfigFormat.CLI) {
312
- return `claude mcp add -s user ${MCP_SERVER_NAME} -- ${NPX} ${npxServerArgs().join(' ')}\n`;
328
+ return `claude mcp add -s user ${MCP_SERVER_NAME} -- ${[command, ...rest].join(' ')}\n`;
313
329
  }
314
- return `${JSON.stringify({ [spec.serversKey]: { [MCP_SERVER_NAME]: spec.entry() } }, null, 2)}\n`;
330
+ return `${JSON.stringify({ [spec.serversKey]: { [MCP_SERVER_NAME]: spec.entry(launcher) } }, null, 2)}\n`;
315
331
  }
316
332
  /**
317
333
  * The path whose existence means "this user has this client".
@@ -326,11 +342,13 @@ export function clientSnippet(spec) {
326
342
  * because a fresh Cursor profile has not written `~/.cursor` yet.
327
343
  */
328
344
  export function clientMarkerRelPath(spec) {
329
- if (spec.scope === ConfigScope.CLI)
345
+ if (spec.scope === ConfigScope.CLI) {
330
346
  return '';
347
+ }
331
348
  // Antigravity also creates ~/.gemini. The shared parent is not evidence of Gemini CLI.
332
- if (spec.id === McpClient.GEMINI)
349
+ if (spec.id === McpClient.GEMINI) {
333
350
  return spec.relPath;
351
+ }
334
352
  const parts = spec.relPath.split('/');
335
353
  return parts.length > 1 ? parts.slice(0, -1).join('/') : spec.relPath;
336
354
  }
@@ -5,7 +5,7 @@
5
5
  * hand-editing `~/.claude.json` (a large stateful file). When the `claude` CLI is absent we print a
6
6
  * manual instruction instead.
7
7
  *
8
- * The registration is intentionally PORTLESS — `npx @reticlehq/server mcp`, never `--port N`. A single
8
+ * The registration is intentionally PORTLESS — it never carries `--port N`. A single
9
9
  * global entry serves every project, so baking a port into it would pin every project to one port
10
10
  * and defeat per-project isolation. Instead `reticle mcp` resolves the port at runtime from the
11
11
  * project's `.reticle.json` in its CWD (see cli-port.ts). The port belongs to the project, not the
@@ -26,23 +26,26 @@ export { MCP_SERVER_NAME } from '@reticlehq/core';
26
26
  */
27
27
  export declare const NPX = "npx";
28
28
  /**
29
- * Args after `npx` that launch the bridge: `@reticlehq/server mcp`. Portless — the port comes from
30
- * the project's `.reticle.json` at runtime, so one global entry works for every project.
29
+ * Args after `npx` that launch the bridge: `@reticlehq/server@<this version> mcp`. Portless — the
30
+ * port comes from the project's `.reticle.json` at runtime, so one global entry works for every
31
+ * project.
31
32
  *
32
- * DELIBERATELY UNPINNED, and the trade is worth stating. `reticle init` pins the SDK to the CLI's
33
- * exact version, so on release day the app can be on the new one while npx serves a cached older
34
- * build — a real skew, reported from the field. Pinning this entry would remove that window.
35
- *
36
- * It would also freeze the agent's MCP server at whatever version was installed the day `init` ran,
37
- * for as long as that entry survives — and `reticle update` upgrades the CLI, not a global agent
38
- * config. A permanent pin trades a window that lasts until the next npx cache miss for one that
39
- * lasts forever.
40
- *
41
- * So it stays unpinned, and the skew is handled where it actually shows up: the contract fingerprint
42
- * makes a real mismatch loud on the next tool result (see version-skew), and a stale entry of our own
43
- * shape is now repaired on re-run rather than reported "already registered" (see mcp-clients.ts).
33
+ * PINNED to one exact version. With a floating `@reticlehq/server`, npx asks the registry on every
34
+ * start. A fresh sandbox (an empty npm cache) downloaded about 131 MB before the MCP server
35
+ * answered: 3.9 s to 5.6 s on each boot, against 0.6 s warm. With an exact version, an image that
36
+ * ran it once uses its cache again. A re-run of `init` or `reticle setup mcp` writes the new
37
+ * version into a stale entry of our own shape (see mcp-clients.ts), and the contract fingerprint
38
+ * makes a real mismatch loud on the next tool result (see version-skew).
44
39
  */
45
40
  export declare function npxServerArgs(): string[];
41
+ /** Is this string the bin of an installed `@reticlehq/server`? */
42
+ export declare function isReticleLauncher(token: string): boolean;
43
+ /**
44
+ * The bin to register, when the CLI that runs now is an install that stays on disk: a global
45
+ * install, or one in a project's `node_modules`. `undefined` for a run-once copy and for a source
46
+ * checkout. Registration then uses the pinned npx command.
47
+ */
48
+ export declare function installedLauncher(bin: string | undefined): string | undefined;
46
49
  /**
47
50
  * Is this existing registration one WE are responsible for?
48
51
  *
@@ -58,6 +61,11 @@ export declare function npxServerArgs(): string[];
58
61
  * @param tokens every string in the entry's command + args, in any of the client shapes.
59
62
  */
60
63
  export declare function isReticleRegistration(tokens: readonly string[]): boolean;
64
+ /**
65
+ * The command that starts the MCP server: `node <launcher> mcp` for an installed copy, else the
66
+ * pinned npx command. `node` is a real executable on Windows too, so it needs no `cmd /c`.
67
+ */
68
+ export declare function serverInvocation(launcher?: string): string[];
61
69
  interface CliAddCommand {
62
70
  command: string;
63
71
  args: string[];
@@ -65,7 +73,7 @@ interface CliAddCommand {
65
73
  display: string;
66
74
  }
67
75
  /** `claude mcp add reticle -s user -- npx @reticlehq/server mcp` — registers globally for all projects (portless). */
68
- export declare function claudeAddCommand(): CliAddCommand;
76
+ export declare function claudeAddCommand(launcher?: string): CliAddCommand;
69
77
  /**
70
78
  * Is a `reticle` server already registered with Claude Code, in any scope this project sees?
71
79
  *
@@ -84,6 +92,33 @@ export declare function claudeHasReticle(io: {
84
92
  readFile(path: string): string | null;
85
93
  homeDir(): string;
86
94
  }, projectDir: string | undefined, configDir?: string | undefined): boolean;
95
+ /** The `reticle` entries Claude Code has, in the scopes `claudeHasReticle` reads. */
96
+ export declare function claudeReticleEntries(io: {
97
+ readFile(path: string): string | null;
98
+ homeDir(): string;
99
+ }, projectDir: string | undefined, configDir?: string | undefined): unknown[];
100
+ /**
101
+ * Is the Reticle Claude Code plugin installed? The plugin brings its own `reticle` MCP server, so a
102
+ * `claude mcp add` next to it gives Claude Code two servers with the same tools. An unreadable
103
+ * record reads as "not installed".
104
+ */
105
+ export declare function claudePluginInstalled(io: {
106
+ readFile(path: string): string | null;
107
+ homeDir(): string;
108
+ }, configDir?: string | undefined): boolean;
109
+ /** The one command that removes a user-scope `reticle` entry left next to the plugin. */
110
+ export declare function claudeRemoveUserCommand(): string;
111
+ /**
112
+ * Claude Code's user-scope `reticle` entry is the floating npx form that registration wrote before
113
+ * it pinned a version or used the installed launcher. `claudeHasReticle` reads it as registered, so
114
+ * nothing replaced it. Reported only: a Claude Code entry is changed only by the person.
115
+ */
116
+ export declare function claudeUserEntryIsFloating(io: {
117
+ readFile(path: string): string | null;
118
+ homeDir(): string;
119
+ }, configDir?: string | undefined): boolean;
120
+ /** The one sentence about a floating entry, and the commands that replace it. */
121
+ export declare function claudeStaleEntryNote(launcher?: string): string;
87
122
  /** Probe args for whether the `claude` CLI is installed at all. */
88
123
  export declare function claudeAvailableProbe(): {
89
124
  command: string;
@@ -96,7 +131,7 @@ export declare function claudeAvailableProbe(): {
96
131
  * It REPLACES an existing entry of the same name and still exits 0, so callers run it only when the
97
132
  * config names no `reticle` server at all (see `codexNamesOurServer`).
98
133
  */
99
- export declare function codexAddCommand(): CliAddCommand;
134
+ export declare function codexAddCommand(launcher?: string): CliAddCommand;
100
135
  /** Probe args for whether the `codex` CLI is installed at all. */
101
136
  export declare function codexAvailableProbe(): {
102
137
  command: string;
@@ -116,5 +151,5 @@ export declare function mcpWindowsNote(): string;
116
151
  * session the `claude` binary is not on PATH, so every CLI-based route is shut and `.mcp.json` in
117
152
  * the project root is the one that still works.
118
153
  */
119
- export declare function claudeProjectMcpJson(): string;
120
- export declare function mcpManual(): string;
154
+ export declare function claudeProjectMcpJson(launcher?: string): string;
155
+ export declare function mcpManual(launcher?: string): string;
@@ -5,14 +5,14 @@
5
5
  * hand-editing `~/.claude.json` (a large stateful file). When the `claude` CLI is absent we print a
6
6
  * manual instruction instead.
7
7
  *
8
- * The registration is intentionally PORTLESS — `npx @reticlehq/server mcp`, never `--port N`. A single
8
+ * The registration is intentionally PORTLESS — it never carries `--port N`. A single
9
9
  * global entry serves every project, so baking a port into it would pin every project to one port
10
10
  * and defeat per-project isolation. Instead `reticle mcp` resolves the port at runtime from the
11
11
  * project's `.reticle.json` in its CWD (see cli-port.ts). The port belongs to the project, not the
12
12
  * global agent config.
13
13
  */
14
14
  import { join } from 'node:path';
15
- import { RETICLE_NPM_PACKAGE } from '../version.js';
15
+ import { RETICLE_NPM_PACKAGE, RETICLE_VERSION } from '../version.js';
16
16
  // The name is a wire identity and lives in the contract; re-exported here so the registration writers
17
17
  // below (and their tests) keep reading it from the module that USES it.
18
18
  export { MCP_SERVER_NAME } from '@reticlehq/core';
@@ -40,25 +40,40 @@ const CODEX_CLI = 'codex';
40
40
  /** Windows `cmd /c` — the spawn that PowerShell's execution policy does not gate. */
41
41
  const WINDOWS_SHELL = 'cmd';
42
42
  const WINDOWS_SHELL_C = '/c';
43
+ const NODE = 'node';
43
44
  /**
44
- * Args after `npx` that launch the bridge: `@reticlehq/server mcp`. Portless — the port comes from
45
- * the project's `.reticle.json` at runtime, so one global entry works for every project.
45
+ * Args after `npx` that launch the bridge: `@reticlehq/server@<this version> mcp`. Portless — the
46
+ * port comes from the project's `.reticle.json` at runtime, so one global entry works for every
47
+ * project.
46
48
  *
47
- * DELIBERATELY UNPINNED, and the trade is worth stating. `reticle init` pins the SDK to the CLI's
48
- * exact version, so on release day the app can be on the new one while npx serves a cached older
49
- * build — a real skew, reported from the field. Pinning this entry would remove that window.
50
- *
51
- * It would also freeze the agent's MCP server at whatever version was installed the day `init` ran,
52
- * for as long as that entry survives — and `reticle update` upgrades the CLI, not a global agent
53
- * config. A permanent pin trades a window that lasts until the next npx cache miss for one that
54
- * lasts forever.
55
- *
56
- * So it stays unpinned, and the skew is handled where it actually shows up: the contract fingerprint
57
- * makes a real mismatch loud on the next tool result (see version-skew), and a stale entry of our own
58
- * shape is now repaired on re-run rather than reported "already registered" (see mcp-clients.ts).
49
+ * PINNED to one exact version. With a floating `@reticlehq/server`, npx asks the registry on every
50
+ * start. A fresh sandbox (an empty npm cache) downloaded about 131 MB before the MCP server
51
+ * answered: 3.9 s to 5.6 s on each boot, against 0.6 s warm. With an exact version, an image that
52
+ * ran it once uses its cache again. A re-run of `init` or `reticle setup mcp` writes the new
53
+ * version into a stale entry of our own shape (see mcp-clients.ts), and the contract fingerprint
54
+ * makes a real mismatch loud on the next tool result (see version-skew).
59
55
  */
60
56
  export function npxServerArgs() {
61
- return [RETICLE_PACKAGE, MCP_SUBCOMMAND];
57
+ return [`${RETICLE_PACKAGE}@${RETICLE_VERSION}`, MCP_SUBCOMMAND];
58
+ }
59
+ /** `<…>/@reticlehq/server/bin/reticle.js`, with either separator. */
60
+ const LAUNCHER_TAIL = /[\\/]@reticlehq[\\/]server[\\/]bin[\\/]reticle\.js$/;
61
+ /** A copy that a runner can delete at any time: npx `_npx`, pnpm `dlx`, yarn `dlx-*`, `bunx-*`. */
62
+ const RUN_ONCE_COPY = /[\\/](?:_npx|dlx(?:-[^\\/]*)?|bunx-[^\\/]*)[\\/]/;
63
+ /** Is this string the bin of an installed `@reticlehq/server`? */
64
+ export function isReticleLauncher(token) {
65
+ return LAUNCHER_TAIL.test(token);
66
+ }
67
+ /**
68
+ * The bin to register, when the CLI that runs now is an install that stays on disk: a global
69
+ * install, or one in a project's `node_modules`. `undefined` for a run-once copy and for a source
70
+ * checkout. Registration then uses the pinned npx command.
71
+ */
72
+ export function installedLauncher(bin) {
73
+ if (bin === undefined || !isReticleLauncher(bin) || RUN_ONCE_COPY.test(bin)) {
74
+ return undefined;
75
+ }
76
+ return bin;
62
77
  }
63
78
  /** The npm scope every Reticle package shares — the marker of a registration we are entitled to fix. */
64
79
  const RETICLE_SCOPE = '@reticlehq/';
@@ -77,30 +92,44 @@ const RETICLE_SCOPE = '@reticlehq/';
77
92
  * @param tokens every string in the entry's command + args, in any of the client shapes.
78
93
  */
79
94
  export function isReticleRegistration(tokens) {
95
+ if (tokens.some(isReticleLauncher)) {
96
+ return true;
97
+ }
80
98
  return tokens.includes(NPX) && tokens.some((t) => t.includes(RETICLE_SCOPE));
81
99
  }
82
- /** The full `npx …` invocation — the tail after `claude mcp add … --`. */
83
- function serverInvocation() {
84
- return [NPX, ...npxServerArgs()];
100
+ /**
101
+ * The command that starts the MCP server: `node <launcher> mcp` for an installed copy, else the
102
+ * pinned npx command. `node` is a real executable on Windows too, so it needs no `cmd /c`.
103
+ */
104
+ export function serverInvocation(launcher) {
105
+ if (launcher === undefined) {
106
+ return [NPX, ...npxServerArgs()];
107
+ }
108
+ return [NODE, launcher, MCP_SUBCOMMAND];
85
109
  }
86
110
  /** `claude mcp add reticle -s user -- npx @reticlehq/server mcp` — registers globally for all projects (portless). */
87
- export function claudeAddCommand() {
88
- const tail = serverInvocation();
111
+ export function claudeAddCommand(launcher) {
112
+ const tail = serverInvocation(launcher);
89
113
  const args = [MCP_SUBCOMMAND, 'add', MCP_SERVER_NAME, '-s', 'user', '--', ...tail];
90
114
  return { command: CLAUDE_CLI, args, display: `${CLAUDE_CLI} ${args.join(' ')}` };
91
115
  }
92
116
  /** Where Claude Code keeps its state: `$CLAUDE_CONFIG_DIR/.claude.json`, else `~/.claude.json`. */
93
117
  const CLAUDE_STATE_FILE = '.claude.json';
94
118
  /** `mcpServers` holds a `reticle` entry. */
95
- function namesReticle(scope) {
96
- if ('object' !== typeof scope || null === scope)
97
- return false;
119
+ function reticleEntry(scope) {
120
+ if ('object' !== typeof scope || null === scope) {
121
+ return undefined;
122
+ }
98
123
  const servers = scope.mcpServers;
99
- return 'object' === typeof servers && null !== servers && MCP_SERVER_NAME in servers;
124
+ if ('object' !== typeof servers || null === servers) {
125
+ return undefined;
126
+ }
127
+ return servers[MCP_SERVER_NAME];
100
128
  }
101
129
  function parsed(source) {
102
- if (null === source)
130
+ if (null === source) {
103
131
  return undefined;
132
+ }
104
133
  try {
105
134
  return JSON.parse(source);
106
135
  }
@@ -123,19 +152,80 @@ function parsed(source) {
123
152
  * which costs at worst a `claude mcp add` that reports the entry already exists.
124
153
  */
125
154
  export function claudeHasReticle(io, projectDir, configDir = process.env['CLAUDE_CONFIG_DIR']) {
155
+ return 0 < claudeReticleEntries(io, projectDir, configDir).length;
156
+ }
157
+ /** The `reticle` entries Claude Code has, in the scopes `claudeHasReticle` reads. */
158
+ export function claudeReticleEntries(io, projectDir, configDir = process.env['CLAUDE_CONFIG_DIR']) {
126
159
  const state = parsed(io.readFile(join(configDir ?? io.homeDir(), CLAUDE_STATE_FILE)));
127
- if (namesReticle(state))
128
- return true;
129
- if (projectDir === undefined)
130
- return false;
131
- const projects = 'object' === typeof state && null !== state
132
- ? state.projects
160
+ const scopes = [state];
161
+ if (projectDir !== undefined) {
162
+ const projects = 'object' === typeof state && null !== state
163
+ ? state.projects
164
+ : undefined;
165
+ if ('object' === typeof projects && null !== projects) {
166
+ scopes.push(projects[projectDir]);
167
+ }
168
+ scopes.push(parsed(io.readFile(join(projectDir, CLAUDE_PROJECT_CONFIG))));
169
+ }
170
+ return scopes.map(reticleEntry).filter((entry) => entry !== undefined);
171
+ }
172
+ /** Claude Code's plugin install record, under `$CLAUDE_CONFIG_DIR`, else `~/.claude`. */
173
+ const CLAUDE_PLUGINS_FILE = join('plugins', 'installed_plugins.json');
174
+ const CLAUDE_CONFIG_HOME = '.claude';
175
+ /** A plugin key is `<name>@<marketplace>`. */
176
+ const RETICLE_PLUGIN_PREFIX = `${MCP_SERVER_NAME}@`;
177
+ /**
178
+ * Is the Reticle Claude Code plugin installed? The plugin brings its own `reticle` MCP server, so a
179
+ * `claude mcp add` next to it gives Claude Code two servers with the same tools. An unreadable
180
+ * record reads as "not installed".
181
+ */
182
+ export function claudePluginInstalled(io, configDir = process.env['CLAUDE_CONFIG_DIR']) {
183
+ const dir = configDir ?? join(io.homeDir(), CLAUDE_CONFIG_HOME);
184
+ const record = parsed(io.readFile(join(dir, CLAUDE_PLUGINS_FILE)));
185
+ const plugins = 'object' === typeof record && null !== record
186
+ ? record.plugins
133
187
  : undefined;
134
- if ('object' === typeof projects && null !== projects) {
135
- if (namesReticle(projects[projectDir]))
136
- return true;
188
+ if ('object' !== typeof plugins || null === plugins) {
189
+ return false;
190
+ }
191
+ return Object.keys(plugins).some((key) => key.startsWith(RETICLE_PLUGIN_PREFIX));
192
+ }
193
+ /** The one command that removes a user-scope `reticle` entry left next to the plugin. */
194
+ export function claudeRemoveUserCommand() {
195
+ return `${CLAUDE_CLI} ${MCP_SUBCOMMAND} remove ${MCP_SERVER_NAME} -s user`;
196
+ }
197
+ /** `x.y.z`, or `x.y.z-pre`: one exact version. `latest`, a range or nothing is not one. */
198
+ const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
199
+ const PACKAGE_AT = `${RETICLE_PACKAGE}@`;
200
+ /** Every string in an entry's `command` and `args`. */
201
+ function entryTokens(entry) {
202
+ if ('object' !== typeof entry || null === entry) {
203
+ return [];
204
+ }
205
+ const { command, args } = entry;
206
+ return [command, args].flat().filter((v) => 'string' === typeof v);
207
+ }
208
+ /** The npx form of `@reticlehq/server` with no exact version: npx starts whatever its cache holds. */
209
+ function isFloatingNpx(tokens) {
210
+ if (!tokens.includes(NPX) || tokens.some(isReticleLauncher)) {
211
+ return false;
137
212
  }
138
- return namesReticle(parsed(io.readFile(join(projectDir, CLAUDE_PROJECT_CONFIG))));
213
+ return tokens.some((t) => RETICLE_PACKAGE === t ||
214
+ (t.startsWith(PACKAGE_AT) && !EXACT_VERSION.test(t.slice(PACKAGE_AT.length))));
215
+ }
216
+ /**
217
+ * Claude Code's user-scope `reticle` entry is the floating npx form that registration wrote before
218
+ * it pinned a version or used the installed launcher. `claudeHasReticle` reads it as registered, so
219
+ * nothing replaced it. Reported only: a Claude Code entry is changed only by the person.
220
+ */
221
+ export function claudeUserEntryIsFloating(io, configDir = process.env['CLAUDE_CONFIG_DIR']) {
222
+ return claudeReticleEntries(io, undefined, configDir).some((e) => isFloatingNpx(entryTokens(e)));
223
+ }
224
+ /** The one sentence about a floating entry, and the commands that replace it. */
225
+ export function claudeStaleEntryNote(launcher) {
226
+ return (`the user-scope reticle entry runs \`${NPX} ${RETICLE_PACKAGE}\` with no version, so it can ` +
227
+ `start a different Reticle version. Run: ${claudeRemoveUserCommand()}, then ` +
228
+ claudeAddCommand(launcher).display);
139
229
  }
140
230
  /** Probe args for whether the `claude` CLI is installed at all. */
141
231
  export function claudeAvailableProbe() {
@@ -148,8 +238,8 @@ export function claudeAvailableProbe() {
148
238
  * It REPLACES an existing entry of the same name and still exits 0, so callers run it only when the
149
239
  * config names no `reticle` server at all (see `codexNamesOurServer`).
150
240
  */
151
- export function codexAddCommand() {
152
- const args = [MCP_SUBCOMMAND, 'add', MCP_SERVER_NAME, '--', ...serverInvocation()];
241
+ export function codexAddCommand(launcher) {
242
+ const args = [MCP_SUBCOMMAND, 'add', MCP_SERVER_NAME, '--', ...serverInvocation(launcher)];
153
243
  return { command: CODEX_CLI, args, display: `${CODEX_CLI} ${args.join(' ')}` };
154
244
  }
155
245
  /** Probe args for whether the `codex` CLI is installed at all. */
@@ -166,7 +256,7 @@ export function mcpWindowsNote() {
166
256
  on this system" — a PowerShell execution policy), register it through cmd instead, which that policy
167
257
  does not gate:
168
258
 
169
- "${MCP_SERVER_NAME}": { "command": "${WINDOWS_SHELL}", "args": ${JSON.stringify([WINDOWS_SHELL_C, NPX, ...serverInvocation().slice(1)])} }`;
259
+ "${MCP_SERVER_NAME}": { "command": "${WINDOWS_SHELL}", "args": ${JSON.stringify([WINDOWS_SHELL_C, NPX, ...npxServerArgs()])} }`;
170
260
  }
171
261
  /** Printed when the `claude` CLI isn't available — register Reticle globally once, by hand. */
172
262
  /**
@@ -176,23 +266,24 @@ does not gate:
176
266
  * session the `claude` binary is not on PATH, so every CLI-based route is shut and `.mcp.json` in
177
267
  * the project root is the one that still works.
178
268
  */
179
- export function claudeProjectMcpJson() {
180
- const [command, ...args] = serverInvocation();
269
+ export function claudeProjectMcpJson(launcher) {
270
+ const [command, ...args] = serverInvocation(launcher);
181
271
  return `${CLAUDE_PROJECT_CONFIG} (project root):
182
272
 
183
273
  { "mcpServers": { "${MCP_SERVER_NAME}": { "command": "${command ?? NPX}", "args": ${JSON.stringify(args)} } } }`;
184
274
  }
185
- export function mcpManual() {
186
- const tail = serverInvocation().join(' ');
275
+ export function mcpManual(launcher) {
276
+ const [command, ...args] = serverInvocation(launcher);
277
+ const tail = [command, ...args].join(' ');
187
278
  return `Register the Reticle MCP server ONCE, globally (so every project gets it):
188
279
 
189
280
  ${CLAUDE_CLI} ${MCP_SUBCOMMAND} add ${MCP_SERVER_NAME} -s user -- ${tail}
190
281
 
191
- Or, in Claude Code with no \`claude\` on PATH (a VS Code extension session), write ${claudeProjectMcpJson()}
282
+ Or, in Claude Code with no \`claude\` on PATH (a VS Code extension session), write ${claudeProjectMcpJson(launcher)}
192
283
 
193
284
  Or, for another agent, add this to its global MCP config (e.g. Cursor's ~/.cursor/mcp.json):
194
285
 
195
- "${MCP_SERVER_NAME}": { "command": "${NPX}", "args": ${JSON.stringify(serverInvocation().slice(1))} }
286
+ "${MCP_SERVER_NAME}": { "command": "${command ?? NPX}", "args": ${JSON.stringify(args)} }
196
287
 
197
288
  ${mcpWindowsNote()}`;
198
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/init",
3
- "version": "3.8.1",
3
+ "version": "3.9.0",
4
4
  "description": "Reticle project scaffolder — detects the framework, writes the config, patches the build and registers the MCP server. The build-time half of `reticle init`.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,9 +13,9 @@
13
13
  "./package.json": "./package.json"
14
14
  },
15
15
  "dependencies": {
16
- "@reticlehq/core": "3.8.1"
16
+ "@reticlehq/core": "3.9.0"
17
17
  },
18
- "license": "FSL-1.1-ALv2",
18
+ "license": "Apache-2.0",
19
19
  "author": "Reticle contributors",
20
20
  "repository": {
21
21
  "type": "git",
@@ -27,7 +27,8 @@
27
27
  "files": [
28
28
  "dist",
29
29
  "README.md",
30
- "LICENSE"
30
+ "LICENSE",
31
+ "NOTICE"
31
32
  ],
32
33
  "sideEffects": false,
33
34
  "keywords": [