bidtry-code-graph 0.0.0-stage → 0.1.1
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/BIDTRY_TEAM_SOURCE.txt +264 -0
- package/README.md +42 -2
- package/SOURCE.json +15 -0
- package/bin/cli.mjs +24 -0
- package/lib/runtime.mjs +502 -0
- package/package.json +38 -4
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Bidtry — Open Source Acknowledgements
|
|
2
|
+
|
|
3
|
+
Original project: Graphify
|
|
4
|
+
|
|
5
|
+
========================================================================
|
|
6
|
+
Original file: LICENSE
|
|
7
|
+
========================================================================
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Apache License
|
|
11
|
+
Version 2.0, January 2004
|
|
12
|
+
http://www.apache.org/licenses/
|
|
13
|
+
|
|
14
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
15
|
+
|
|
16
|
+
1. Definitions.
|
|
17
|
+
|
|
18
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
19
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
20
|
+
|
|
21
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
22
|
+
the copyright owner that is granting the License.
|
|
23
|
+
|
|
24
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
25
|
+
other entities that control, are controlled by, or are under common
|
|
26
|
+
control with that entity. For the purposes of this definition,
|
|
27
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
28
|
+
direction or management of such entity, whether by contract or
|
|
29
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
30
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
31
|
+
|
|
32
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
33
|
+
exercising permissions granted by this License.
|
|
34
|
+
|
|
35
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
36
|
+
including but not limited to software source code, documentation
|
|
37
|
+
source, and configuration files.
|
|
38
|
+
|
|
39
|
+
"Object" form shall mean any form resulting from mechanical
|
|
40
|
+
transformation or translation of a Source form, including but
|
|
41
|
+
not limited to compiled object code, generated documentation,
|
|
42
|
+
and conversions to other media types.
|
|
43
|
+
|
|
44
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
45
|
+
Object form, made available under the License, as indicated by a
|
|
46
|
+
copyright notice that is included in or attached to the work
|
|
47
|
+
(an example is provided in the Appendix below).
|
|
48
|
+
|
|
49
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
50
|
+
form, that is based on (or derived from) the Work and for which the
|
|
51
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
52
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
53
|
+
of this License, Derivative Works shall not include works that remain
|
|
54
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
55
|
+
the Work and Derivative Works thereof.
|
|
56
|
+
|
|
57
|
+
"Contribution" shall mean any work of authorship, including
|
|
58
|
+
the original version of the Work and any modifications or additions
|
|
59
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
60
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
61
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
62
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
63
|
+
means any form of electronic, verbal, or written communication sent
|
|
64
|
+
to the Licensor or its representatives, including but not limited to
|
|
65
|
+
communication on electronic mailing lists, source code control systems,
|
|
66
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
67
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
68
|
+
excluding communication that is conspicuously marked or otherwise
|
|
69
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
70
|
+
|
|
71
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
72
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
73
|
+
subsequently incorporated within the Work.
|
|
74
|
+
|
|
75
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
79
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
80
|
+
Work and such Derivative Works in Source or Object form.
|
|
81
|
+
|
|
82
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
83
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
84
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
85
|
+
(except as stated in this section) patent license to make, have made,
|
|
86
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
87
|
+
where such license applies only to those patent claims licensable
|
|
88
|
+
by such Contributor that are necessarily infringed by their
|
|
89
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
90
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
91
|
+
institute patent litigation against any entity (including a
|
|
92
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
93
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
94
|
+
or contributory patent infringement, then any patent licenses
|
|
95
|
+
granted to You under this License for that Work shall terminate
|
|
96
|
+
as of the date such litigation is filed.
|
|
97
|
+
|
|
98
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
99
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
100
|
+
modifications, and in Source or Object form, provided that You
|
|
101
|
+
meet the following conditions:
|
|
102
|
+
|
|
103
|
+
(a) You must give any other recipients of the Work or
|
|
104
|
+
Derivative Works a copy of this License; and
|
|
105
|
+
|
|
106
|
+
(b) You must cause any modified files to carry prominent notices
|
|
107
|
+
stating that You changed the files; and
|
|
108
|
+
|
|
109
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
110
|
+
that You distribute, all copyright, patent, trademark, and
|
|
111
|
+
attribution notices from the Source form of the Work,
|
|
112
|
+
excluding those notices that do not pertain to any part of
|
|
113
|
+
the Derivative Works; and
|
|
114
|
+
|
|
115
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
116
|
+
distribution, then any Derivative Works that You distribute must
|
|
117
|
+
include a readable copy of the attribution notices contained
|
|
118
|
+
within such NOTICE file, excluding those notices that do not
|
|
119
|
+
pertain to any part of the Derivative Works, in at least one
|
|
120
|
+
of the following places: within a NOTICE text file distributed
|
|
121
|
+
as part of the Derivative Works; within the Source form or
|
|
122
|
+
documentation, if provided along with the Derivative Works; or,
|
|
123
|
+
within a display generated by the Derivative Works, if and
|
|
124
|
+
wherever such third-party notices normally appear. The contents
|
|
125
|
+
of the NOTICE file are for informational purposes only and
|
|
126
|
+
do not modify the License. You may add Your own attribution
|
|
127
|
+
notices within Derivative Works that You distribute, alongside
|
|
128
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
129
|
+
that such additional attribution notices cannot be construed
|
|
130
|
+
as modifying the License.
|
|
131
|
+
|
|
132
|
+
You may add Your own copyright statement to Your modifications and
|
|
133
|
+
may provide additional or different license terms and conditions
|
|
134
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
135
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
136
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
137
|
+
the conditions stated in this License.
|
|
138
|
+
|
|
139
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
140
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
141
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
142
|
+
this License, without any additional terms or conditions.
|
|
143
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
144
|
+
the terms of any separate license agreement you may have executed
|
|
145
|
+
with Licensor regarding such Contributions.
|
|
146
|
+
|
|
147
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
148
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
149
|
+
except as required for reasonable and customary use in describing the
|
|
150
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
151
|
+
|
|
152
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
153
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
154
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
155
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
156
|
+
implied, including, without limitation, any warranties or conditions
|
|
157
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
158
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
159
|
+
appropriateness of using or redistributing the Work and assume any
|
|
160
|
+
risks associated with Your exercise of permissions under this License.
|
|
161
|
+
|
|
162
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
163
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
164
|
+
unless required by applicable law (such as deliberate and grossly
|
|
165
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
166
|
+
liable to You for damages, including any direct, indirect, special,
|
|
167
|
+
incidental, or consequential damages of any character arising as a
|
|
168
|
+
result of this License or out of the use or inability to use the
|
|
169
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
170
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
171
|
+
other commercial damages or losses), even if such Contributor
|
|
172
|
+
has been advised of the possibility of such damages.
|
|
173
|
+
|
|
174
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
175
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
176
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
177
|
+
or other liability obligations and/or rights consistent with this
|
|
178
|
+
License. However, in accepting such obligations, You may act only
|
|
179
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
180
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
181
|
+
defend, and hold each Contributor harmless for any liability
|
|
182
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
183
|
+
of your accepting any such warranty or additional liability.
|
|
184
|
+
|
|
185
|
+
END OF TERMS AND CONDITIONS
|
|
186
|
+
|
|
187
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
188
|
+
|
|
189
|
+
To apply the Apache License to your work, attach the following
|
|
190
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
191
|
+
replaced with your own identifying information. (Don't include
|
|
192
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
193
|
+
comment syntax for the file format. We also recommend that a
|
|
194
|
+
file or class name and description of purpose be included on the
|
|
195
|
+
same "printed page" as the copyright notice for easier
|
|
196
|
+
identification within third-party archives.
|
|
197
|
+
|
|
198
|
+
Copyright [yyyy] [name of copyright owner]
|
|
199
|
+
|
|
200
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
201
|
+
you may not use this file except in compliance with the License.
|
|
202
|
+
You may obtain a copy of the License at
|
|
203
|
+
|
|
204
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
205
|
+
|
|
206
|
+
Unless required by applicable law or agreed to in writing, software
|
|
207
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
208
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
209
|
+
See the License for the specific language governing permissions and
|
|
210
|
+
limitations under the License.
|
|
211
|
+
|
|
212
|
+
========================================================================
|
|
213
|
+
Original file: NOTICE
|
|
214
|
+
========================================================================
|
|
215
|
+
|
|
216
|
+
Graphify
|
|
217
|
+
Copyright 2026 Safi Shamsi and the Graphify contributors.
|
|
218
|
+
|
|
219
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
220
|
+
|
|
221
|
+
Portions of this software were contributed under the MIT License prior to the
|
|
222
|
+
relicensing and remain available under those terms. The original MIT license
|
|
223
|
+
text is retained in LICENSE-MIT.
|
|
224
|
+
|
|
225
|
+
========================================================================
|
|
226
|
+
Original file: NOTICE.md
|
|
227
|
+
========================================================================
|
|
228
|
+
|
|
229
|
+
# Attribution
|
|
230
|
+
|
|
231
|
+
## Bidtry product attribution
|
|
232
|
+
|
|
233
|
+
Bidtry Code Graph is the Bidtry-maintained project in this directory. Its implementation is derived from Graphify and retains compatible technical identifiers.
|
|
234
|
+
|
|
235
|
+
Original authorship, copyright notices, project license terms, and third-party licenses remain with their respective holders. Bidtry branding does not replace those notices.
|
|
236
|
+
|
|
237
|
+
See also the original [NOTICE](NOTICE), which is retained unchanged.
|
|
238
|
+
|
|
239
|
+
========================================================================
|
|
240
|
+
Original source: https://github.com/Graphify-Labs/graphify/blob/v8/LICENSE-MIT
|
|
241
|
+
Git blob: b1d9746fb5c6c39fd502e2ebe432a12ad9a097f3
|
|
242
|
+
========================================================================
|
|
243
|
+
|
|
244
|
+
MIT License
|
|
245
|
+
|
|
246
|
+
Copyright (c) 2026 Safi Shamsi
|
|
247
|
+
|
|
248
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
249
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
250
|
+
in the Software without restriction, including without limitation the rights
|
|
251
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
252
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
253
|
+
furnished to do so, subject to the following conditions:
|
|
254
|
+
|
|
255
|
+
The above copyright notice and this permission notice shall be included in all
|
|
256
|
+
copies or substantial portions of the Software.
|
|
257
|
+
|
|
258
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
259
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
260
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
261
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
262
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
263
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
264
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bidtry Code Graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Brand:** Bidtry · **Developer:** Keshab Amgain
|
|
4
|
+
|
|
5
|
+
Bidtry Code Graph: install project-local workflow instructions. Native engines are separate.
|
|
6
|
+
|
|
7
|
+
A workflow for repository maps, symbol relationships, and change impact.
|
|
8
|
+
|
|
9
|
+
## Why use it?
|
|
10
|
+
|
|
11
|
+
A small change may affect a distant caller. Explore relationships between modules and symbols, then confirm the important paths against the source before editing.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Requires Node.js 20 or newer. Open a terminal in your existing project folder, then run this command on macOS, Windows PowerShell, or Linux:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx bidtry-code-graph@0.1.1 install --target .
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The command installs and verifies workflow files under `.bidtry/skills/`. No particular coding assistant is required. Open `.bidtry/skills/bidtry-code-graph/START-HERE.md`, then read the workflow in `SKILL.md`. You can follow the instructions yourself or share them with your preferred assistant.
|
|
22
|
+
|
|
23
|
+
## Preview, verify, and remove
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx bidtry-code-graph@0.1.1 install --target . --dry-run
|
|
27
|
+
npx bidtry-code-graph@0.1.1 verify --target .
|
|
28
|
+
npx bidtry-code-graph@0.1.1 uninstall --target . --dry-run
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Remove `--dry-run` from the removal command only when ready. Unknown or edited files are preserved by refusing unsafe changes. Symlinked destinations are rejected.
|
|
32
|
+
|
|
33
|
+
Optional assistant integrations: pass `--agent codex`, `--agent claude`, or `--agent cursor`. These place instructions in that assistant's project skill directory. Start a new assistant session after installing. Dollar-sign and slash examples inside skill files are assistant requests, not terminal commands.
|
|
34
|
+
|
|
35
|
+
## What is included?
|
|
36
|
+
|
|
37
|
+
Workflow instructions and their supporting reference files. This npm release does not install a standalone application, native engine, compiler, browser, solver, API service, or project dependencies. Some workflow checks need separately installed native tools. They are not certified by installing these instructions. There are no npm runtime dependencies or install lifecycle scripts.
|
|
38
|
+
|
|
39
|
+
## Copyright and license texts
|
|
40
|
+
|
|
41
|
+
Original copyright notices and full license texts are included in `BIDTRY_TEAM_SOURCE.txt`. Different included materials retain their original terms. Bidtry branding does not replace original authorship.
|
|
42
|
+
|
|
43
|
+
[Tool information](https://bidtry.com/code-graph)
|
package/SOURCE.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "bidtry-code-graph@0.1.1",
|
|
3
|
+
"artifactKind": "project-local workflow installer; native engines excluded",
|
|
4
|
+
"runtimeSha256": "8a5a2db03bee2339c0d6085242a3fbdb1988f9bb75cc191683d48394cd52e00f",
|
|
5
|
+
"bundledRuntimeSha256": "4dea632f22d4e5302f0532c2b7a0709afb516f9c545b97c187f242ed0f9902c0",
|
|
6
|
+
"payloadSha256": "582cc2eaa21dc70890a77a8b24cf650f01974f146625bb702878f386c8364be4",
|
|
7
|
+
"products": [
|
|
8
|
+
{
|
|
9
|
+
"name": "bidtry-code-graph",
|
|
10
|
+
"version": "0.1.1",
|
|
11
|
+
"slug": "code-graph"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"noticeSha256": "d45bc0bf9b71644d8800ddac7f36c533b714e4b0c9d01c3b5ec482e8d8301c5c"
|
|
15
|
+
}
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runCli } from '../lib/runtime.mjs';
|
|
3
|
+
const product = {"name":"bidtry-code-graph","title":"Bidtry Code Graph","slug":"code-graph","version":"0.1.1"};
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const command = args[0];
|
|
6
|
+
const help = "\nBidtry Code Graph — project workflow installer\n\nUsage:\n bidtry-code-graph install [--target PATH] [--agent project|codex|claude|cursor|all] [--dry-run]\n bidtry-code-graph verify [options]\n bidtry-code-graph uninstall [options] [--dry-run]\n bidtry-code-graph list\n\nDefault: editor-readable workflow files in .bidtry/skills/ inside your project.\nInstall verifies the managed files automatically. Requires Node.js 20 or newer.\nThis package installs workflow instructions, not native engines or application dependencies.\nOriginal copyright notices and license texts: BIDTRY_TEAM_SOURCE.txt\n";
|
|
7
|
+
try {
|
|
8
|
+
if (!command || args.includes('--help') || args.includes('-h') || command === 'help') {
|
|
9
|
+
process.stdout.write(help);
|
|
10
|
+
} else if (args.includes('--version') || args.includes('-v') || command === 'version') {
|
|
11
|
+
process.stdout.write("0.1.1" + '\n');
|
|
12
|
+
} else {
|
|
13
|
+
if (!['install', 'verify', 'uninstall', 'remove', 'list'].includes(command)) throw new Error('Unknown command. Use --help.');
|
|
14
|
+
if (product && args.some(value => /^--(?:tool|tools|preset)(?:=|$)/.test(value))) throw new Error('This package installs ' + product.name + ' only. Use @bidtry/tools to choose other tools.');
|
|
15
|
+
const options = args.slice(1);
|
|
16
|
+
if (!args.some(value => /^--agent(?:=|$)/.test(value))) options.push('--agent', 'project');
|
|
17
|
+
if (product && command !== 'list') options.push('--tool', product.slug);
|
|
18
|
+
process.stdout.write(runCli([command, ...options], process.cwd()));
|
|
19
|
+
if (command === 'install' && !args.includes('--dry-run')) process.stdout.write(runCli(['verify', ...options], process.cwd()));
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
process.stderr.write(error.message + '\n');
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
}
|
package/lib/runtime.mjs
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import {
|
|
4
|
+
chmodSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
lstatSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
readdirSync,
|
|
10
|
+
realpathSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
rmdirSync,
|
|
13
|
+
unlinkSync,
|
|
14
|
+
writeFileSync
|
|
15
|
+
} from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { pathToFileURL } from 'node:url';
|
|
18
|
+
|
|
19
|
+
export default runCli;
|
|
20
|
+
|
|
21
|
+
const INSTALLER_VERSION = '1.1.0';
|
|
22
|
+
const PAYLOAD = JSON.parse(Buffer.from('eyJzY2hlbWFWZXJzaW9uIjoxLCJwcm9kdWN0cyI6W3sic2x1ZyI6ImNvZGUtZ3JhcGgiLCJuYW1lIjoiYmlkdHJ5LWNvZGUtZ3JhcGgiLCJ0aXRsZSI6IkJpZHRyeSBDb2RlIEdyYXBoIiwidmVyc2lvbiI6IjAuMS4xIiwicHJpbWFyeUFjdGlvbiI6Im1hcCIsImZpbGVzIjp7ImFnZW50cy9vcGVuYWkueWFtbCI6eyJjb250ZW50IjoiaW50ZXJmYWNlOlxuICBkaXNwbGF5X25hbWU6IFwiQmlkdHJ5IENvZGUgR3JhcGhcIlxuICBzaG9ydF9kZXNjcmlwdGlvbjogXCJCaWR0cnkgQ29kZSBHcmFwaCBwcm9qZWN0IHdvcmtmbG93c1wiXG4gIGRlZmF1bHRfcHJvbXB0OiBcIlVzZSAkYmlkdHJ5LWNvZGUtZ3JhcGggbWFwIHRoZSBhdXRoZW50aWNhdGlvbiBmbG93LlwiXG4iLCJtb2RlIjo0MjB9LCJTS0lMTC5tZCI6eyJjb250ZW50IjoiLS0tXG5uYW1lOiBiaWR0cnktY29kZS1ncmFwaFxuZGVzY3JpcHRpb246IFwiVHVybiBjb2RlIGFuZCBwcm9qZWN0IG1hdGVyaWFscyBpbnRvIGEgcXVlcnlhYmxlIGtub3dsZWRnZSBncmFwaC4gVXNlIGZvciB0aGUgYXV0aGVudGljYXRpb24gZmxvdyBhbmQgcmVsYXRlZCBjb2RlIGdyYXBoIHRhc2tzIGluIGFuIGV4aXN0aW5nIGxvY2FsIHByb2plY3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wcGxpY2F0aW9uIGludG8gdGhlIHRhcmdldCwgb3IgcmVwb3J0IG5hdGl2ZSBjaGVja3MgYXMgZXhlY3V0ZWQgd2hlbiB0aGV5IHdlcmUgbm90LlxuIiwibW9kZSI6NDIwfX19XX0=', 'base64').toString('utf8'));
|
|
23
|
+
const AGENT_PATHS = { codex: '.agents', claude: '.claude', cursor: '.cursor', project: '.bidtry' };
|
|
24
|
+
const MANIFEST = '.bidtry-install.json';
|
|
25
|
+
const DESIGN_PRESET = [
|
|
26
|
+
'design-improve',
|
|
27
|
+
'accessibility-improve',
|
|
28
|
+
'graph-interface'
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
function digest(contents) {
|
|
32
|
+
return createHash('sha256').update(contents).digest('hex');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function assertPayload() {
|
|
36
|
+
if (PAYLOAD?.schemaVersion !== 1 || !Array.isArray(PAYLOAD.products)) {
|
|
37
|
+
throw new Error('The Bidtry installer payload is missing or invalid.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function productMap() {
|
|
42
|
+
assertPayload();
|
|
43
|
+
return new Map(PAYLOAD.products.map(product => [product.slug, product]));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseValue(args, index, option) {
|
|
47
|
+
const argument = args[index];
|
|
48
|
+
const value = argument.includes('=')
|
|
49
|
+
? argument.slice(option.length + 1)
|
|
50
|
+
: args[index + 1];
|
|
51
|
+
if (!value || value.startsWith('--')) {
|
|
52
|
+
throw new Error(`Missing value for ${option}.`);
|
|
53
|
+
}
|
|
54
|
+
return { value, consumed: argument.includes('=') ? 0 : 1 };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Parse options without touching the target project. */
|
|
58
|
+
export function parseArguments(args, cwd) {
|
|
59
|
+
const knownCommands = new Set([
|
|
60
|
+
'help',
|
|
61
|
+
'version',
|
|
62
|
+
'list',
|
|
63
|
+
'install',
|
|
64
|
+
'verify',
|
|
65
|
+
'uninstall',
|
|
66
|
+
'remove'
|
|
67
|
+
]);
|
|
68
|
+
let command = 'help';
|
|
69
|
+
let agent = 'codex';
|
|
70
|
+
let target = cwd;
|
|
71
|
+
let dryRun = false;
|
|
72
|
+
let selector = null;
|
|
73
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
74
|
+
const argument = args[index];
|
|
75
|
+
if (index === 0 && knownCommands.has(argument)) {
|
|
76
|
+
command = argument === 'remove' ? 'uninstall' : argument;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (argument === '--help' || argument === '-h') {
|
|
80
|
+
command = 'help';
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (argument === '--version' || argument === '-v') {
|
|
84
|
+
command = 'version';
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (argument === '--dry-run') {
|
|
88
|
+
dryRun = true;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const option = argument.split('=', 1)[0];
|
|
92
|
+
if (!['--agent', '--target', '--tool', '--tools', '--preset'].includes(option)) {
|
|
93
|
+
throw new Error(`Unknown argument: ${argument}. Use --help for usage.`);
|
|
94
|
+
}
|
|
95
|
+
const parsed = parseValue(args, index, option);
|
|
96
|
+
index += parsed.consumed;
|
|
97
|
+
if (option === '--agent') agent = parsed.value;
|
|
98
|
+
if (option === '--target') target = parsed.value;
|
|
99
|
+
if (['--tool', '--tools', '--preset'].includes(option)) {
|
|
100
|
+
if (selector) {
|
|
101
|
+
throw new Error('Choose exactly one of --tool, --tools, or --preset.');
|
|
102
|
+
}
|
|
103
|
+
selector = { option, value: parsed.value };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (agent !== 'all' && !Object.hasOwn(AGENT_PATHS, agent)) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Unsupported installation format: ${agent}. Choose project, codex, claude, cursor, or all.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (['install', 'verify', 'uninstall'].includes(command) && !selector) {
|
|
112
|
+
throw new Error('Choose tools with --tool, --tools, or --preset.');
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
command,
|
|
116
|
+
target: path.resolve(cwd, target),
|
|
117
|
+
agents: agent === 'all' ? ['codex', 'claude', 'cursor'] : [agent],
|
|
118
|
+
dryRun,
|
|
119
|
+
selector
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function selectProducts(selector) {
|
|
124
|
+
const products = productMap();
|
|
125
|
+
let slugs;
|
|
126
|
+
if (selector.option === '--preset') {
|
|
127
|
+
if (selector.value === 'design') slugs = DESIGN_PRESET;
|
|
128
|
+
else if (selector.value === 'all') slugs = [...products.keys()].sort();
|
|
129
|
+
else throw new Error('Unsupported preset. Choose design or all.');
|
|
130
|
+
} else if (selector.option === '--tool') {
|
|
131
|
+
slugs = [selector.value];
|
|
132
|
+
} else {
|
|
133
|
+
slugs = selector.value.split(',').map(value => value.trim()).filter(Boolean);
|
|
134
|
+
}
|
|
135
|
+
if (!slugs.length) throw new Error('No tools were selected.');
|
|
136
|
+
if (new Set(slugs).size !== slugs.length) {
|
|
137
|
+
throw new Error('Tool selection contains duplicates.');
|
|
138
|
+
}
|
|
139
|
+
return slugs.map(slug => {
|
|
140
|
+
const product = products.get(slug);
|
|
141
|
+
if (!product) throw new Error(`Unknown Bidtry tool: ${slug}.`);
|
|
142
|
+
return product;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function assertRelative(relative) {
|
|
147
|
+
if (
|
|
148
|
+
typeof relative !== 'string' ||
|
|
149
|
+
!relative ||
|
|
150
|
+
path.isAbsolute(relative) ||
|
|
151
|
+
relative.split(/[\\/]/).includes('..')
|
|
152
|
+
) {
|
|
153
|
+
throw new Error(`Invalid packaged file path: ${relative}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function assertRegularPath(root, relative) {
|
|
158
|
+
assertRelative(relative);
|
|
159
|
+
let current = root;
|
|
160
|
+
const parts = relative.split(/[\\/]/);
|
|
161
|
+
for (const [index, part] of parts.entries()) {
|
|
162
|
+
current = path.join(current, part);
|
|
163
|
+
let info;
|
|
164
|
+
try {
|
|
165
|
+
info = lstatSync(current);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (error.code === 'ENOENT') return;
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
if (info.isSymbolicLink()) {
|
|
171
|
+
throw new Error(`Refusing to follow a symlink: ${current}`);
|
|
172
|
+
}
|
|
173
|
+
if (index < parts.length - 1 && !info.isDirectory()) {
|
|
174
|
+
throw new Error(`Expected a directory: ${current}`);
|
|
175
|
+
}
|
|
176
|
+
if (index === parts.length - 1 && !info.isFile()) {
|
|
177
|
+
throw new Error(`Expected a regular file: ${current}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function materializeFiles(product, agent) {
|
|
183
|
+
const result = {};
|
|
184
|
+
const agentSkill = `${AGENT_PATHS[agent]}/skills/bidtry-design-improve`;
|
|
185
|
+
for (const [name, file] of Object.entries(product.files)) {
|
|
186
|
+
assertRelative(name);
|
|
187
|
+
if (
|
|
188
|
+
typeof file?.content !== 'string' ||
|
|
189
|
+
![0o644, 0o755].includes(file.mode)
|
|
190
|
+
) {
|
|
191
|
+
throw new Error(`Invalid packaged skill file: ${product.slug}/${name}`);
|
|
192
|
+
}
|
|
193
|
+
let contents = file.content;
|
|
194
|
+
if (product.slug === 'design-improve') {
|
|
195
|
+
contents = contents.replaceAll(
|
|
196
|
+
'.agents/skills/bidtry-design-improve',
|
|
197
|
+
agentSkill
|
|
198
|
+
);
|
|
199
|
+
if (agent !== 'codex' && agent !== 'project') {
|
|
200
|
+
contents = contents.replaceAll(
|
|
201
|
+
'$bidtry-design-improve',
|
|
202
|
+
'/bidtry-design-improve'
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
result[name] = { contents, mode: file.mode };
|
|
207
|
+
}
|
|
208
|
+
if (agent === 'project') {
|
|
209
|
+
result['START-HERE.md'] = {
|
|
210
|
+
contents: `# ${product.title}\n\nThese are project-local workflow files. Open SKILL.md in any editor, follow the workflow yourself, or give the instructions to your coding assistant. No particular assistant is required to store or read these files.\n\nThe skill's dollar-sign and slash examples are requests for compatible assistants, not shell commands. This installation does not install a standalone application, native engine, or project dependencies.\n\nTool: https://bidtry.com/${product.slug}\n`,
|
|
211
|
+
mode: 0o644
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function readManifest(root, relative, productName, isRequired = false) {
|
|
218
|
+
assertRegularPath(root, relative);
|
|
219
|
+
const absolute = path.join(root, relative);
|
|
220
|
+
if (!existsSync(absolute)) {
|
|
221
|
+
if (isRequired) throw new Error(`Bidtry installation not found: ${absolute}`);
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
let manifest;
|
|
225
|
+
try {
|
|
226
|
+
manifest = JSON.parse(readFileSync(absolute, 'utf8'));
|
|
227
|
+
} catch {
|
|
228
|
+
throw new Error(`Invalid installer manifest: ${absolute}`);
|
|
229
|
+
}
|
|
230
|
+
if (
|
|
231
|
+
manifest?.schemaVersion !== 1 ||
|
|
232
|
+
manifest?.package !== productName ||
|
|
233
|
+
!manifest.files ||
|
|
234
|
+
typeof manifest.files !== 'object'
|
|
235
|
+
) {
|
|
236
|
+
throw new Error(`Unrecognized installer manifest: ${absolute}`);
|
|
237
|
+
}
|
|
238
|
+
return manifest;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Validate every requested destination before any file changes. */
|
|
242
|
+
export function createInstallPlan(selected, options) {
|
|
243
|
+
const root = realpathSync(options.target);
|
|
244
|
+
if (!lstatSync(root).isDirectory()) {
|
|
245
|
+
throw new Error(`Target is not a directory: ${root}`);
|
|
246
|
+
}
|
|
247
|
+
const files = [];
|
|
248
|
+
for (const product of selected) {
|
|
249
|
+
if (!/^bidtry-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(product.name)) {
|
|
250
|
+
throw new Error(`Invalid Bidtry package name: ${product.name}`);
|
|
251
|
+
}
|
|
252
|
+
for (const agent of options.agents) {
|
|
253
|
+
const skillDirectory = path.join(
|
|
254
|
+
AGENT_PATHS[agent],
|
|
255
|
+
'skills',
|
|
256
|
+
product.name
|
|
257
|
+
);
|
|
258
|
+
const manifestRelative = path.join(skillDirectory, MANIFEST);
|
|
259
|
+
const previousManifest = readManifest(
|
|
260
|
+
root,
|
|
261
|
+
manifestRelative,
|
|
262
|
+
product.name
|
|
263
|
+
);
|
|
264
|
+
const payload = materializeFiles(product, agent);
|
|
265
|
+
const hashes = {};
|
|
266
|
+
for (const [name, file] of Object.entries(payload)) {
|
|
267
|
+
const relative = path.join(skillDirectory, name);
|
|
268
|
+
assertRegularPath(root, relative);
|
|
269
|
+
const destination = path.join(root, relative);
|
|
270
|
+
const previous = existsSync(destination)
|
|
271
|
+
? readFileSync(destination, 'utf8')
|
|
272
|
+
: null;
|
|
273
|
+
if (
|
|
274
|
+
previous !== null &&
|
|
275
|
+
previous !== file.contents &&
|
|
276
|
+
previousManifest?.files?.[name] !== digest(previous)
|
|
277
|
+
) {
|
|
278
|
+
throw new Error(
|
|
279
|
+
`Preserving your existing file: ${destination}. Move or rename this skill folder before installing.`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
hashes[name] = digest(file.contents);
|
|
283
|
+
files.push({
|
|
284
|
+
path: destination,
|
|
285
|
+
relative,
|
|
286
|
+
contents: file.contents,
|
|
287
|
+
previous,
|
|
288
|
+
mode: file.mode
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
const manifestContents =
|
|
292
|
+
JSON.stringify(
|
|
293
|
+
{
|
|
294
|
+
schemaVersion: 1,
|
|
295
|
+
package: product.name,
|
|
296
|
+
version: product.version,
|
|
297
|
+
installedBy: `bidtry-tools-installer@${INSTALLER_VERSION}`,
|
|
298
|
+
files: hashes
|
|
299
|
+
},
|
|
300
|
+
null,
|
|
301
|
+
2
|
|
302
|
+
) + '\n';
|
|
303
|
+
const manifestPath = path.join(root, manifestRelative);
|
|
304
|
+
files.push({
|
|
305
|
+
path: manifestPath,
|
|
306
|
+
relative: manifestRelative,
|
|
307
|
+
contents: manifestContents,
|
|
308
|
+
previous: existsSync(manifestPath)
|
|
309
|
+
? readFileSync(manifestPath, 'utf8')
|
|
310
|
+
: null,
|
|
311
|
+
mode: 0o644
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return { root, files, skills: selected.length * options.agents.length };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function applyInstallPlan(plan) {
|
|
319
|
+
let changed = 0;
|
|
320
|
+
for (const file of plan.files) {
|
|
321
|
+
assertRegularPath(plan.root, file.relative);
|
|
322
|
+
const current = existsSync(file.path)
|
|
323
|
+
? readFileSync(file.path, 'utf8')
|
|
324
|
+
: null;
|
|
325
|
+
if (current !== file.previous) {
|
|
326
|
+
throw new Error(`File changed during installation: ${file.path}`);
|
|
327
|
+
}
|
|
328
|
+
const currentMode = existsSync(file.path) ? lstatSync(file.path).mode & 0o777 : null;
|
|
329
|
+
if (current === file.contents && currentMode === file.mode) continue;
|
|
330
|
+
mkdirSync(path.dirname(file.path), { recursive: true });
|
|
331
|
+
if (current !== file.contents) {
|
|
332
|
+
const temporary = `${file.path}.${randomUUID()}.tmp`;
|
|
333
|
+
try {
|
|
334
|
+
writeFileSync(temporary, file.contents, {
|
|
335
|
+
flag: 'wx',
|
|
336
|
+
mode: file.mode
|
|
337
|
+
});
|
|
338
|
+
renameSync(temporary, file.path);
|
|
339
|
+
} finally {
|
|
340
|
+
if (existsSync(temporary)) unlinkSync(temporary);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
chmodSync(file.path, file.mode);
|
|
344
|
+
changed += 1;
|
|
345
|
+
}
|
|
346
|
+
return changed;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function createVerification(selected, options) {
|
|
350
|
+
const root = realpathSync(options.target);
|
|
351
|
+
const failures = [];
|
|
352
|
+
let skills = 0;
|
|
353
|
+
for (const product of selected) {
|
|
354
|
+
for (const agent of options.agents) {
|
|
355
|
+
const skillDirectory = path.join(
|
|
356
|
+
AGENT_PATHS[agent],
|
|
357
|
+
'skills',
|
|
358
|
+
product.name
|
|
359
|
+
);
|
|
360
|
+
const manifestRelative = path.join(skillDirectory, MANIFEST);
|
|
361
|
+
const manifest = readManifest(root, manifestRelative, product.name, true);
|
|
362
|
+
const payload = materializeFiles(product, agent);
|
|
363
|
+
for (const [name, file] of Object.entries(payload)) {
|
|
364
|
+
const relative = path.join(skillDirectory, name);
|
|
365
|
+
try {
|
|
366
|
+
assertRegularPath(root, relative);
|
|
367
|
+
const absolute = path.join(root, relative);
|
|
368
|
+
if (!existsSync(absolute)) throw new Error('file is missing');
|
|
369
|
+
const actual = digest(readFileSync(absolute));
|
|
370
|
+
if (actual !== digest(file.contents)) throw new Error('file is outdated or edited');
|
|
371
|
+
if (manifest.files[name] !== actual) throw new Error('manifest hash does not match');
|
|
372
|
+
} catch (error) {
|
|
373
|
+
failures.push(`${relative}: ${error.message}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
skills += 1;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (failures.length) {
|
|
380
|
+
throw new Error(`Verification failed:\n${failures.map(item => ` ${item}`).join('\n')}`);
|
|
381
|
+
}
|
|
382
|
+
return { root, skills };
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function createUninstallPlan(selected, options) {
|
|
386
|
+
const root = realpathSync(options.target);
|
|
387
|
+
const files = [];
|
|
388
|
+
const directories = new Set();
|
|
389
|
+
for (const product of selected) {
|
|
390
|
+
for (const agent of options.agents) {
|
|
391
|
+
const skillDirectory = path.join(
|
|
392
|
+
AGENT_PATHS[agent],
|
|
393
|
+
'skills',
|
|
394
|
+
product.name
|
|
395
|
+
);
|
|
396
|
+
const manifestRelative = path.join(skillDirectory, MANIFEST);
|
|
397
|
+
const manifest = readManifest(root, manifestRelative, product.name, true);
|
|
398
|
+
for (const [name, expected] of Object.entries(manifest.files)) {
|
|
399
|
+
assertRelative(name);
|
|
400
|
+
if (!/^[a-f0-9]{64}$/.test(expected)) {
|
|
401
|
+
throw new Error(`Invalid managed-file hash: ${manifestRelative}`);
|
|
402
|
+
}
|
|
403
|
+
const relative = path.join(skillDirectory, name);
|
|
404
|
+
assertRegularPath(root, relative);
|
|
405
|
+
const absolute = path.join(root, relative);
|
|
406
|
+
if (!existsSync(absolute)) {
|
|
407
|
+
throw new Error(`Managed file is missing: ${absolute}`);
|
|
408
|
+
}
|
|
409
|
+
if (digest(readFileSync(absolute)) !== expected) {
|
|
410
|
+
throw new Error(`Preserving your edited file: ${absolute}`);
|
|
411
|
+
}
|
|
412
|
+
files.push({ path: absolute, relative });
|
|
413
|
+
let directory = path.dirname(absolute);
|
|
414
|
+
const skillRoot = path.join(root, skillDirectory);
|
|
415
|
+
while (directory.startsWith(skillRoot)) {
|
|
416
|
+
directories.add(directory);
|
|
417
|
+
if (directory === skillRoot) break;
|
|
418
|
+
directory = path.dirname(directory);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
files.push({
|
|
422
|
+
path: path.join(root, manifestRelative),
|
|
423
|
+
relative: manifestRelative
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
root,
|
|
429
|
+
files,
|
|
430
|
+
directories: [...directories].sort((a, b) => b.length - a.length),
|
|
431
|
+
skills: selected.length * options.agents.length
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function applyUninstallPlan(plan) {
|
|
436
|
+
for (const file of plan.files) {
|
|
437
|
+
assertRegularPath(plan.root, file.relative);
|
|
438
|
+
if (existsSync(file.path)) unlinkSync(file.path);
|
|
439
|
+
}
|
|
440
|
+
for (const directory of plan.directories) {
|
|
441
|
+
if (existsSync(directory) && readdirSync(directory).length === 0) {
|
|
442
|
+
rmdirSync(directory);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function help() {
|
|
448
|
+
return `Bidtry Tools Installer ${INSTALLER_VERSION}\n\nUsage:\n node bidtry-install.mjs list\n node bidtry-install.mjs install --tool SLUG [options]\n node bidtry-install.mjs install --tools SLUG,SLUG [options]\n node bidtry-install.mjs install --preset design|all [options]\n node bidtry-install.mjs verify --tool|--tools|--preset VALUE [options]\n node bidtry-install.mjs uninstall --tool|--tools|--preset VALUE [options]\n\nOptions:\n --agent project|codex|claude|cursor|all Default: codex\n --target PATH Default: current directory\n --dry-run Show changes without writing\n\nThe installer adds project-local agent skills only, or editor-readable workflow files with --agent project. It does not change application code, install dependencies, configure credentials, or install native engines.\n`;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** Run a complete installer command. */
|
|
452
|
+
export function runCli(args, cwd) {
|
|
453
|
+
const options = parseArguments(args, cwd);
|
|
454
|
+
if (options.command === 'help') return help();
|
|
455
|
+
if (options.command === 'version') return `bidtry-tools-installer ${INSTALLER_VERSION}\n`;
|
|
456
|
+
if (options.command === 'list') {
|
|
457
|
+
return `${[...productMap().values()]
|
|
458
|
+
.sort((a, b) => a.title.localeCompare(b.title))
|
|
459
|
+
.map(product => `${product.slug}\t${product.title}`)
|
|
460
|
+
.join('\n')}\n`;
|
|
461
|
+
}
|
|
462
|
+
const selected = selectProducts(options.selector);
|
|
463
|
+
if (options.command === 'install') {
|
|
464
|
+
const plan = createInstallPlan(selected, options);
|
|
465
|
+
if (options.dryRun) {
|
|
466
|
+
return `Dry run — no files written (${plan.skills} skills):\n${plan.files
|
|
467
|
+
.map(file => ` ${file.path}`)
|
|
468
|
+
.join('\n')}\n`;
|
|
469
|
+
}
|
|
470
|
+
const changed = applyInstallPlan(plan);
|
|
471
|
+
const first = selected[0].name;
|
|
472
|
+
if (options.agents.includes('project')) {
|
|
473
|
+
return `${changed ? 'Installed or updated' : 'Already current:'} ${plan.skills} Bidtry workflow${plan.skills === 1 ? '' : 's'} in ${plan.root}.\nOpen .bidtry/skills/${first}/START-HERE.md in your editor.\nWorkflow files only; native engines and project dependencies remain separate.\n`;
|
|
474
|
+
}
|
|
475
|
+
const invocation = options.agents.includes('codex') ? `$${first} init` : `/${first} init`;
|
|
476
|
+
return `${changed ? 'Installed or updated' : 'Already current:'} ${plan.skills} Bidtry skill${plan.skills === 1 ? '' : 's'} in ${plan.root}.\nReload your coding agent, then start with ${invocation} inside the agent.\nApplication code and dependencies were not changed. Native engines remain separate.\n`;
|
|
477
|
+
}
|
|
478
|
+
if (options.command === 'verify') {
|
|
479
|
+
const result = createVerification(selected, options);
|
|
480
|
+
return `Verified ${result.skills} current Bidtry skill${result.skills === 1 ? '' : 's'} in ${result.root}.\n`;
|
|
481
|
+
}
|
|
482
|
+
const plan = createUninstallPlan(selected, options);
|
|
483
|
+
if (options.dryRun) {
|
|
484
|
+
return `Dry run — no files removed (${plan.skills} skills):\n${plan.files
|
|
485
|
+
.map(file => ` ${file.path}`)
|
|
486
|
+
.join('\n')}\n`;
|
|
487
|
+
}
|
|
488
|
+
applyUninstallPlan(plan);
|
|
489
|
+
return `Removed ${plan.skills} managed Bidtry skill${plan.skills === 1 ? '' : 's'} from ${plan.root}. Unrelated files were preserved.\n`;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (
|
|
493
|
+
process.argv[1] &&
|
|
494
|
+
import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href
|
|
495
|
+
) {
|
|
496
|
+
try {
|
|
497
|
+
process.stdout.write(runCli(process.argv.slice(2), process.cwd()));
|
|
498
|
+
} catch (error) {
|
|
499
|
+
process.stderr.write(`${error.message}\n`);
|
|
500
|
+
process.exitCode = 1;
|
|
501
|
+
}
|
|
502
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bidtry-code-graph",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Bidtry Code Graph: install project-local workflow instructions. Native engines are separate.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "SEE LICENSE IN BIDTRY_TEAM_SOURCE.txt",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Bidtry",
|
|
9
|
+
"url": "https://bidtry.com"
|
|
10
|
+
},
|
|
11
|
+
"contributors": [
|
|
12
|
+
{
|
|
13
|
+
"name": "Keshab Amgain"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://bidtry.com/code-graph",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"bidtry-code-graph": "bin/cli.mjs"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/cli.mjs",
|
|
25
|
+
"lib/runtime.mjs",
|
|
26
|
+
"README.md",
|
|
27
|
+
"BIDTRY_TEAM_SOURCE.txt",
|
|
28
|
+
"SOURCE.json"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"bidtry",
|
|
36
|
+
"developer-tools",
|
|
37
|
+
"project-workflow",
|
|
38
|
+
"code-graph"
|
|
39
|
+
]
|
|
40
|
+
}
|