@mockingbird_konwlage_cli/cli 1.0.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/.windsurf/rules/document-public-apis.md +325 -0
- package/index.js +174 -0
- package/package.json +22 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: document-public-apis
|
|
3
|
+
description: Document undocumented public APIs in PyTorch by removing functions from coverage_ignore_functions and coverage_ignore_classes in docs/source/conf.py, running Sphinx coverage, and adding the appropriate autodoc directives to the correct .md or .rst doc files. Use when a user asks to remove functions from conf.py ignore lists.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Document Public APIs
|
|
7
|
+
|
|
8
|
+
This skill documents undocumented public APIs in PyTorch by removing entries from the coverage ignore lists in `docs/source/conf.py` and adding Sphinx autodoc directives (e.g., `autosummary`, `currentmodule`, `autoclass`, `automodule`) to the corresponding `.md` or `.rst` doc source files in `docs/source/`.
|
|
9
|
+
|
|
10
|
+
**"Documenting" means adding autodoc directives to doc source files — NEVER modifying Python source code.** Do not add or edit docstrings in `.py` files. Do not read or inspect Python source files. Sphinx will pull whatever docstring exists (or render an empty entry if none exists). Your only job is to add the correct directive to the correct doc file.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
`docs/source/conf.py` contains two lists that suppress Sphinx coverage warnings for undocumented APIs:
|
|
15
|
+
|
|
16
|
+
- `coverage_ignore_functions`: undocumented functions
|
|
17
|
+
- `coverage_ignore_classes`: undocumented classes
|
|
18
|
+
|
|
19
|
+
Entries are organized by **module comment groups**. Each group has a module label comment followed by the function/class names that belong to that module:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
coverage_ignore_functions = [
|
|
23
|
+
# torch.ao.quantization.fx.convert <-- module label comment
|
|
24
|
+
"convert", # <-- entries belonging to this module
|
|
25
|
+
"convert_custom_module",
|
|
26
|
+
"convert_standalone_module",
|
|
27
|
+
"convert_weighted_module",
|
|
28
|
+
# torch.ao.quantization.fx.fuse <-- next module group
|
|
29
|
+
"fuse",
|
|
30
|
+
# torch.nn.functional
|
|
31
|
+
"assert_int_or_pair", # looks unintentionally public <-- entry with inline comment
|
|
32
|
+
"constant", # deprecated <-- entry with inline comment
|
|
33
|
+
]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
There are two kinds of comments:
|
|
37
|
+
- **Module label comments** (`# torch.ao.quantization.fx.convert`): these label which module the entries below belong to. They appear on their own line before a group of entries.
|
|
38
|
+
- **Inline comments** (`# deprecated`, `# documented as adaptive_max_pool1d`): these appear after a string entry on the same line and explain *why* the entry is in the ignore list.
|
|
39
|
+
|
|
40
|
+
The module label comment directly tells you:
|
|
41
|
+
1. Which module the functions belong to
|
|
42
|
+
2. Where to add them in the docs (e.g., `# torch.ao.quantization.fx.convert` → the functions go under `torch.ao.quantization.fx.convert` in the doc file)
|
|
43
|
+
|
|
44
|
+
## Instructions
|
|
45
|
+
|
|
46
|
+
Each invocation of this skill processes **one batch** of module groups. Pick one or more complete module groups from the ignore lists, document their functions, and verify.
|
|
47
|
+
|
|
48
|
+
### Step 1: Select module groups to document
|
|
49
|
+
|
|
50
|
+
Read `docs/source/conf.py` and select one or more **complete module groups** to document. A module group is a module label comment and all entries beneath it up to the next module label comment. Process entire groups — never split a group across batches.
|
|
51
|
+
|
|
52
|
+
For example, selecting the `torch.ao.quantization.fx.convert` group means taking all of:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# torch.ao.quantization.fx.convert
|
|
56
|
+
"convert",
|
|
57
|
+
"convert_custom_module",
|
|
58
|
+
"convert_standalone_module",
|
|
59
|
+
"convert_weighted_module",
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Work through the lists top-to-bottom. Choose enough groups to make meaningful progress (aim for 5–15 functions total, but always include complete groups even if that means going slightly over).
|
|
63
|
+
|
|
64
|
+
**Check inline comments before including an entry.** Some entries have inline comments that indicate they should not be documented:
|
|
65
|
+
|
|
66
|
+
- `# deprecated` — The function is deprecated. Leave it in the ignore list.
|
|
67
|
+
- `# documented as <other_name>` — Already documented under a different name. Leave it.
|
|
68
|
+
- `# looks unintentionally public` — Probably not meant to be public API. Leave it.
|
|
69
|
+
- `# legacy helper for ...` — Same as deprecated. Leave it.
|
|
70
|
+
- `# utility function` - Leave it.
|
|
71
|
+
|
|
72
|
+
If a module group has a **mix** of regular entries and entries with inline comments, still process the group — but only comment out the regular entries. Leave entries with inline comments untouched in the ignore list.
|
|
73
|
+
|
|
74
|
+
### Step 2: Present the batch to the user
|
|
75
|
+
|
|
76
|
+
**Before making any edits**, present the selected module groups and their functions to the user. Show them organized by module:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Module: torch.ao.quantization.fx.convert
|
|
80
|
+
- convert
|
|
81
|
+
- convert_custom_module
|
|
82
|
+
- convert_standalone_module
|
|
83
|
+
- convert_weighted_module
|
|
84
|
+
|
|
85
|
+
Module: torch.ao.quantization.fx.fuse
|
|
86
|
+
- fuse
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then use the `AskUserQuestion` tool to let the user confirm, with options like:
|
|
90
|
+
- "Proceed with this batch"
|
|
91
|
+
- "Skip some entries" (user can specify which to remove)
|
|
92
|
+
- "Pick a different batch"
|
|
93
|
+
|
|
94
|
+
### Step 3: Comment out entries in conf.py
|
|
95
|
+
|
|
96
|
+
After the user confirms, edit `docs/source/conf.py` and **comment out** (do not delete) the selected entries. Use a `#` prefix on each string entry line:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
# torch.ao.quantization.fx.convert
|
|
100
|
+
# "convert",
|
|
101
|
+
# "convert_custom_module",
|
|
102
|
+
# "convert_standalone_module",
|
|
103
|
+
# "convert_weighted_module",
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This preserves the original entries so they can be restored if verification fails.
|
|
107
|
+
|
|
108
|
+
### Step 4: Run Sphinx coverage
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
cd docs && make coverage
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Ignore the terminal output of `make coverage`.** It often contains unrelated tracebacks and errors from Sphinx extensions (e.g., `onnx_ir`, `katex`, `sphinxcontrib`) that have nothing to do with coverage. The only thing that matters is whether `docs/build/coverage/python.txt` was generated. Read that file to see the specific undocumented APIs.
|
|
115
|
+
|
|
116
|
+
The format of `python.txt` lists each undocumented API as:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
torch.ao.quantization.fx.convert
|
|
120
|
+
* convert
|
|
121
|
+
* convert_custom_module
|
|
122
|
+
* convert_standalone_module
|
|
123
|
+
* convert_weighted_module
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Not all commented-out functions will appear in `python.txt`.** Some may already be documented elsewhere. This is fine — only add directives for functions that actually appear in `python.txt`.
|
|
127
|
+
|
|
128
|
+
If `make coverage` fails due to missing dependencies, first run:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
cd docs && pip install -r requirements.txt
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Step 5: Add documentation directives
|
|
135
|
+
|
|
136
|
+
For each function listed in `python.txt`, use the **module label comment** from `conf.py` to determine where it should be added. The module comment gives you the full module path, which maps to a doc source file and a section within that file.
|
|
137
|
+
|
|
138
|
+
#### Finding the correct doc file
|
|
139
|
+
|
|
140
|
+
The module comment maps to a doc source file in `docs/source/`. When unsure, search for other functions from the same module:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
grep -rn "torch.module_name" docs/source/*.md docs/source/*.rst
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or list candidate files:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
ls docs/source/*module_name*
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If no doc file exists for a submodule, check whether a parent module's doc file has a section for it (e.g., `backends.md` has sections for `torch.backends.cuda`, `torch.backends.cudnn`, etc.). If not, add a new section to the parent file following existing patterns.
|
|
153
|
+
|
|
154
|
+
#### Adding the directives
|
|
155
|
+
|
|
156
|
+
**Read the target doc file first** and match the exact patterns already used there. Do not invent new patterns or use bare `autofunction` with fully qualified names — always use the proper hierarchical structure with `automodule`, `currentmodule`, and short names. Do not use `. py:module::` since that just suppresses errors and doesn't actually document the function. Look at other files that match the target file's format (e.g., `.md` vs. `.rst`) under `docs/source/` to see examples.
|
|
157
|
+
|
|
158
|
+
There are two file formats. Match the one used in the target file.
|
|
159
|
+
|
|
160
|
+
**Pattern A — MyST Markdown files (`.md`):** Used in files like `accelerator.md`, `backends.md`, `cuda.md`.
|
|
161
|
+
|
|
162
|
+
The hierarchical structure uses `automodule` to register the module, `currentmodule` to set context, then short names:
|
|
163
|
+
|
|
164
|
+
```markdown
|
|
165
|
+
## torch.ao.quantization.fx.convert
|
|
166
|
+
|
|
167
|
+
```{eval-rst}
|
|
168
|
+
.. automodule:: torch.ao.quantization.fx.convert
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```{eval-rst}
|
|
172
|
+
.. currentmodule:: torch.ao.quantization.fx.convert
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```{eval-rst}
|
|
176
|
+
.. autofunction:: convert
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```{eval-rst}
|
|
180
|
+
.. autofunction:: convert_custom_module
|
|
181
|
+
```
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
For `autosummary` blocks (used in some files instead of individual directives):
|
|
185
|
+
|
|
186
|
+
```markdown
|
|
187
|
+
```{eval-rst}
|
|
188
|
+
.. autosummary::
|
|
189
|
+
:toctree: generated
|
|
190
|
+
:nosignatures:
|
|
191
|
+
|
|
192
|
+
existing_function
|
|
193
|
+
your_new_function
|
|
194
|
+
`` `
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
For classes:
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
```{eval-rst}
|
|
201
|
+
.. autoclass:: YourClass
|
|
202
|
+
:members:
|
|
203
|
+
`` `
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Pattern B — reStructuredText files (`.rst`):** Used in files like `torch.rst`, `nn.rst`.
|
|
207
|
+
|
|
208
|
+
Same hierarchical structure without the markdown fences:
|
|
209
|
+
|
|
210
|
+
```rst
|
|
211
|
+
torch.ao.quantization.fx.convert
|
|
212
|
+
---------------------------------
|
|
213
|
+
|
|
214
|
+
.. automodule:: torch.ao.quantization.fx.convert
|
|
215
|
+
|
|
216
|
+
.. currentmodule:: torch.ao.quantization.fx.convert
|
|
217
|
+
|
|
218
|
+
.. autosummary::
|
|
219
|
+
:toctree: generated
|
|
220
|
+
:nosignatures:
|
|
221
|
+
|
|
222
|
+
convert
|
|
223
|
+
convert_custom_module
|
|
224
|
+
convert_standalone_module
|
|
225
|
+
convert_weighted_module
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
For individual directives:
|
|
229
|
+
|
|
230
|
+
```rst
|
|
231
|
+
.. automodule:: torch.submodule
|
|
232
|
+
|
|
233
|
+
.. currentmodule:: torch.submodule
|
|
234
|
+
|
|
235
|
+
.. autofunction:: function_name
|
|
236
|
+
|
|
237
|
+
.. autoclass:: ClassName
|
|
238
|
+
:members:
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Key rules:**
|
|
242
|
+
- The module label comment from `conf.py` (e.g., `# torch.ao.quantization.fx.convert`) tells you exactly which `automodule` and `currentmodule` to use.
|
|
243
|
+
- Always set `.. automodule::` and `.. currentmodule::` before documenting functions from a module.
|
|
244
|
+
- Use **short names** (e.g., `convert`, not `torch.ao.quantization.fx.convert.convert`) after `currentmodule` is set.
|
|
245
|
+
- If the module already has an `automodule`/`currentmodule` in the file, don't add another — just add your function under the existing one.
|
|
246
|
+
- Match whichever style the file already uses (`autosummary` blocks vs. individual `autofunction` directives).
|
|
247
|
+
|
|
248
|
+
#### Placing in the right section
|
|
249
|
+
|
|
250
|
+
Read the target doc file and find the appropriate section. If the module already has a section (e.g., `## torch.backends.cuda` in `backends.md`), add the functions there. If no section exists yet, create one following the existing section patterns in the file. Group all functions from the same module group together.
|
|
251
|
+
|
|
252
|
+
### Step 6: Verify with coverage
|
|
253
|
+
|
|
254
|
+
Run coverage again:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
cd docs && make coverage
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Ignore the terminal output — only read `docs/build/coverage/python.txt`. Verification passes when `python.txt` contains **zero undocumented functions across ALL modules**. It should only have the statistics table with 100% coverage and 0 undocumented for every module. For example:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
Undocumented Python objects
|
|
264
|
+
===========================
|
|
265
|
+
|
|
266
|
+
Statistics
|
|
267
|
+
----------
|
|
268
|
+
|
|
269
|
+
+---------------------------+----------+--------------+
|
|
270
|
+
| Module | Coverage | Undocumented |
|
|
271
|
+
+===========================+==========+==============+
|
|
272
|
+
| torch | 100.00% | 0 |
|
|
273
|
+
+---------------------------+----------+--------------+
|
|
274
|
+
| torch.accelerator | 100.00% | 0 |
|
|
275
|
+
+---------------------------+----------+--------------+
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
If any module shows undocumented functions (coverage below 100% or undocumented count > 0), verification has failed.
|
|
279
|
+
|
|
280
|
+
**If verification succeeds (zero undocumented across all modules):** Go to Step 7.
|
|
281
|
+
|
|
282
|
+
**If verification fails (any undocumented functions remain):** Read `docs/build/coverage/python.txt` to see which functions are still listed as undocumented. Common issues include:
|
|
283
|
+
|
|
284
|
+
- Wrong doc file: the function was added to the wrong `.md`/`.rst` file. Move the directive to the correct file.
|
|
285
|
+
- Wrong directive type: e.g., used `autofunction` for a class, or `autoclass` for a function. Fix the directive.
|
|
286
|
+
- Wrong module path in the directive: e.g., `torch.foo.bar` should be `torch.foo.baz.bar`. Correct the qualified name.
|
|
287
|
+
- Function added to an `autosummary` block with the wrong `currentmodule`: make sure the `.. currentmodule::` directive above the block matches.
|
|
288
|
+
- Missing `automodule` for a submodule that hasn't been registered yet. Add a `.. automodule:: torch.submodule` directive before documenting functions from that submodule.
|
|
289
|
+
|
|
290
|
+
Fix the doc directive based on the error, then re-run `make coverage`. Repeat until verification passes.
|
|
291
|
+
|
|
292
|
+
If a function still fails after multiple attempts, **stop and show the error to the user.** Present the function name and the error, then use the `AskUserQuestion` tool with options like:
|
|
293
|
+
- "Uncomment it to restore to ignore list (skip for now)"
|
|
294
|
+
- "Try a different approach"
|
|
295
|
+
- "Investigate further"
|
|
296
|
+
|
|
297
|
+
### Step 7: Report progress
|
|
298
|
+
|
|
299
|
+
**Present a progress summary to the user** showing:
|
|
300
|
+
|
|
301
|
+
- Which module groups were processed and how many functions were documented
|
|
302
|
+
- Which functions were skipped or restored to the ignore list (and why)
|
|
303
|
+
- How many entries remain in `coverage_ignore_functions` and `coverage_ignore_classes`
|
|
304
|
+
|
|
305
|
+
### Step 8: Clean up commented-out entries in conf.py
|
|
306
|
+
|
|
307
|
+
Now that verification has passed, delete the commented-out string entries from Step 3. These are lines that start with `# "` inside `coverage_ignore_functions` and `coverage_ignore_classes`. Commented-out string entries always contain **quotes** — that's how you distinguish them from module label comments:
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
# "disable_global_flags", <-- commented-out string entry (has quotes) → DELETE
|
|
311
|
+
# torch.backends <-- module label comment (no quotes) → KEEP if it has active entries
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Also delete any module label comments that no longer have active entries beneath them (i.e., all their entries were either commented out and now deleted, or had inline comments and were left in place but the module label is otherwise empty).
|
|
315
|
+
|
|
316
|
+
## Important notes
|
|
317
|
+
|
|
318
|
+
- **Follow the steps exactly as written.** Do not add extra investigation steps like importing Python modules to check docstrings, inspecting source code to verify function signatures, or running any commands not specified in the instructions. The `make coverage` step is the only verification needed — let it tell you what's wrong.
|
|
319
|
+
- **Never modify Python source files (`.py`).** This skill only edits `docs/source/conf.py` and doc source files (`.md`/`.rst`) in `docs/source/`. Do not add or edit docstrings, do not read Python source to check function signatures, do not inspect implementations.
|
|
320
|
+
- Entries are commented out in Step 3, verified in Step 6, and cleaned up in Step 8 after verification passes. Never delete uncommented entries directly.
|
|
321
|
+
- **Read inline comments** on entries before deciding to document them. Entries marked `# deprecated`, `# documented as ...`, `# looks unintentionally public`, or `# legacy helper` should stay in the ignore list.
|
|
322
|
+
- The `coverage_ignore_functions` list uses bare function names (not fully qualified), so the same name can appear multiple times for different modules. Use the module label comment above each entry to identify which module it belongs to. Be careful during Step 8 cleanup to only delete the correct commented-out lines — commented-out string entries have **quotes** (`# "func_name",`), module label comments do not.
|
|
323
|
+
- Always match the existing style of the target doc file — don't mix `.md` style directives into `.rst` files or vice versa.
|
|
324
|
+
- **Use the module label comment** (e.g., `# torch.ao.quantization.fx.convert`) as the primary guide for both the `automodule`/`currentmodule` directives and for finding the right section in the doc file.
|
|
325
|
+
- Always process complete module groups — never split a group across invocations.
|
package/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const axios = require('axios');
|
|
7
|
+
const chalk = require('chalk');
|
|
8
|
+
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.name('mockingbird-cli')
|
|
13
|
+
.description('Installs and manages AI skills for various coding clients')
|
|
14
|
+
.version('1.0.0');
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('add <slug>')
|
|
18
|
+
.description('Add an AI skill by its Mockingbird slug or GitHub <org>/<repo>')
|
|
19
|
+
.option('--agent <agent>', 'The AI client to install the skill for (e.g., cursor, windsurf, claude-code)')
|
|
20
|
+
.action(async (slug, options) => {
|
|
21
|
+
const agent = (options.agent || 'cursor').toLowerCase();
|
|
22
|
+
|
|
23
|
+
console.log(chalk.blue(`[Mockingbird] Installing skill '${slug}' for agent '${agent}'...`));
|
|
24
|
+
|
|
25
|
+
// Map known Mockingbird prefixes to their actual GitHub raw paths
|
|
26
|
+
// e.g., pytorch-skills/document-public-apis -> https://raw.githubusercontent.com/pytorch/pytorch/main/.claude/skills/document-public-apis/SKILL.md
|
|
27
|
+
|
|
28
|
+
// First, try to see if it matches our known internal mapping
|
|
29
|
+
const repoMap = {
|
|
30
|
+
"anthropic-skills": "anthropics/skills/main/skills",
|
|
31
|
+
"awesome-copilot": "github/awesome-copilot/main/skills",
|
|
32
|
+
"gemini-cli": "google-gemini/gemini-cli/main/.gemini/skills",
|
|
33
|
+
"openai-skills": "openai/skills/main/skills",
|
|
34
|
+
"playwright-skills": "microsoft/playwright/main/packages/playwright/src/skill",
|
|
35
|
+
"pytorch-skills": "pytorch/pytorch/main/.claude/skills",
|
|
36
|
+
"antfu-skills": "antfu/skills/main/skills",
|
|
37
|
+
"dimillian-skills": "Dimillian/Skills/main",
|
|
38
|
+
"prompts-chat-skills": "f/prompts.chat/main/.windsurf/skills",
|
|
39
|
+
"huggingface-skills": "huggingface/skills/main/skills"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let rawUrl = '';
|
|
43
|
+
|
|
44
|
+
if (slug.includes('/')) {
|
|
45
|
+
const parts = slug.split('/');
|
|
46
|
+
const prefix = parts[0];
|
|
47
|
+
const skillName = parts[1];
|
|
48
|
+
|
|
49
|
+
if (repoMap[prefix]) {
|
|
50
|
+
rawUrl = `https://raw.githubusercontent.com/${repoMap[prefix]}/${skillName}/SKILL.md`;
|
|
51
|
+
} else {
|
|
52
|
+
// Generic fallback for org/repo/skillname
|
|
53
|
+
let filePath = parts.slice(2).join('/') || 'SKILL.md';
|
|
54
|
+
if (!filePath.endsWith('.md')) {
|
|
55
|
+
filePath += filePath ? '/SKILL.md' : 'SKILL.md';
|
|
56
|
+
}
|
|
57
|
+
rawUrl = `https://raw.githubusercontent.com/${parts[0]}/${parts[1]}/main/${filePath}`;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
rawUrl = `https://raw.githubusercontent.com/mockingbird-ai/skills/main/${slug}/SKILL.md`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
console.log(chalk.gray(`Fetching from: ${rawUrl}`));
|
|
65
|
+
const response = await axios.get(rawUrl);
|
|
66
|
+
const skillContent = response.data;
|
|
67
|
+
|
|
68
|
+
await installForAgent(agent, slug, skillContent);
|
|
69
|
+
console.log(chalk.green(`\n✓ Successfully installed skill '${slug}' for ${agent}!`));
|
|
70
|
+
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (error.response && error.response.status === 404) {
|
|
73
|
+
console.error(chalk.red(`\n✖ Error: Skill not found at ${rawUrl}. Please check the slug or repository.`));
|
|
74
|
+
} else {
|
|
75
|
+
console.error(chalk.red(`\n✖ Error: Failed to fetch the skill. ${error.message}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
async function installForAgent(agent, slug, content) {
|
|
81
|
+
const cwd = process.cwd();
|
|
82
|
+
// Use the last part of the slug as a clean filename basis
|
|
83
|
+
const cleanSlug = slug.includes('/') ? slug.split('/').pop() : slug;
|
|
84
|
+
|
|
85
|
+
let targetPath = '';
|
|
86
|
+
let append = false;
|
|
87
|
+
let finalContent = content;
|
|
88
|
+
|
|
89
|
+
const mkDirSafe = (dir) => {
|
|
90
|
+
if (!fs.existsSync(dir)) {
|
|
91
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
switch (agent) {
|
|
96
|
+
case 'cursor':
|
|
97
|
+
mkDirSafe(path.join(cwd, '.cursor', 'rules'));
|
|
98
|
+
targetPath = path.join(cwd, '.cursor', 'rules', `${cleanSlug}.mdc`);
|
|
99
|
+
// Add MDC frontmatter if missing
|
|
100
|
+
if (!finalContent.startsWith('---')) {
|
|
101
|
+
finalContent = `---\ndescription: Cursor rule for ${cleanSlug}\nglobs: *\n---\n\n` + finalContent;
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
|
|
105
|
+
case 'windsurf':
|
|
106
|
+
const wsDir = path.join(cwd, '.windsurf', 'rules');
|
|
107
|
+
mkDirSafe(wsDir);
|
|
108
|
+
targetPath = path.join(wsDir, `${cleanSlug}.md`);
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case 'claude-code':
|
|
112
|
+
// Claude-code usually uses a single CLAUDE.md in the root
|
|
113
|
+
targetPath = path.join(cwd, 'CLAUDE.md');
|
|
114
|
+
append = true;
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case 'copilot':
|
|
118
|
+
const cpDir = path.join(cwd, '.github', 'instructions');
|
|
119
|
+
mkDirSafe(cpDir);
|
|
120
|
+
targetPath = path.join(cpDir, `${cleanSlug}.instructions.md`);
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case 'gemini':
|
|
124
|
+
const geminiDir = path.join(cwd, '.gemini', 'skills', cleanSlug);
|
|
125
|
+
mkDirSafe(geminiDir);
|
|
126
|
+
targetPath = path.join(geminiDir, 'SKILL.md');
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'amp':
|
|
130
|
+
const ampDir = path.join(cwd, '.agents', 'commands');
|
|
131
|
+
mkDirSafe(ampDir);
|
|
132
|
+
targetPath = path.join(ampDir, `${cleanSlug}.md`);
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 'kilocode':
|
|
136
|
+
const kiloDir = path.join(cwd, '.kilocode', 'rules');
|
|
137
|
+
mkDirSafe(kiloDir);
|
|
138
|
+
targetPath = path.join(kiloDir, `${cleanSlug}.md`);
|
|
139
|
+
break;
|
|
140
|
+
|
|
141
|
+
case 'trae':
|
|
142
|
+
const traeDir = path.join(cwd, '.trae', 'rules');
|
|
143
|
+
mkDirSafe(traeDir);
|
|
144
|
+
targetPath = path.join(traeDir, `${cleanSlug}.md`);
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case 'codex':
|
|
148
|
+
case 'openclaw':
|
|
149
|
+
mkDirSafe(path.join(cwd, '.mockingbird', 'rules'));
|
|
150
|
+
targetPath = path.join(cwd, '.mockingbird', 'rules', `${cleanSlug}.md`);
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 'antigravity':
|
|
154
|
+
const agDir = path.join(cwd, '.agent', 'skills', cleanSlug);
|
|
155
|
+
mkDirSafe(agDir);
|
|
156
|
+
targetPath = path.join(agDir, 'SKILL.md');
|
|
157
|
+
break;
|
|
158
|
+
|
|
159
|
+
default:
|
|
160
|
+
console.log(chalk.yellow(`[Warning] Agent '${agent}' is not fully mapped. Defaulting to general SKILL.md.`));
|
|
161
|
+
targetPath = path.join(cwd, `${cleanSlug}_SKILL.md`);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (append && fs.existsSync(targetPath)) {
|
|
166
|
+
console.log(chalk.magenta(`Appending rules to ${targetPath}...`));
|
|
167
|
+
fs.appendFileSync(targetPath, `\n\n## Extension Rules: ${cleanSlug}\n\n${finalContent}`);
|
|
168
|
+
} else {
|
|
169
|
+
console.log(chalk.magenta(`Writing rules to ${targetPath}...`));
|
|
170
|
+
fs.writeFileSync(targetPath, finalContent);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mockingbird_konwlage_cli/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mockingbird AI Developer Client CLI",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mockingbird-cli": "./index.js",
|
|
8
|
+
"@mockingbird-ai/cli": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"type": "commonjs",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"axios": "^1.13.5",
|
|
19
|
+
"chalk": "^4.1.2",
|
|
20
|
+
"commander": "^14.0.3"
|
|
21
|
+
}
|
|
22
|
+
}
|