@pratikpsl/agent-skills 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +92 -0
- package/bin/agent-skills.js +7 -0
- package/package.json +37 -0
- package/src/__tests__/copySkills.test.js +161 -0
- package/src/__tests__/list.test.js +49 -0
- package/src/__tests__/manifest.test.js +72 -0
- package/src/commands/add.js +89 -0
- package/src/commands/dotnet-setup.js +67 -0
- package/src/commands/init.js +42 -0
- package/src/commands/list.js +41 -0
- package/src/index.js +33 -0
- package/src/lib/copySkills.js +84 -0
- package/src/lib/manifest.js +117 -0
- package/src/lib/resolvePack.js +44 -0
- package/src/templates/dotnet/AgentSkills/OPERATING.md +85 -0
- package/src/templates/dotnet/AgentSkills/README.md +64 -0
- package/src/templates/dotnet/AgentSkills/agents/README.md +16 -0
- package/src/templates/dotnet/AgentSkills/agents/architect.agent.md +59 -0
- package/src/templates/dotnet/AgentSkills/agents/developer.agent.md +88 -0
- package/src/templates/dotnet/AgentSkills/entry-points/AGENTS.md +16 -0
- package/src/templates/dotnet/AgentSkills/entry-points/CLAUDE.md +16 -0
- package/src/templates/dotnet/AgentSkills/entry-points/copilot-instructions.md +16 -0
- package/src/templates/dotnet/AgentSkills/entry-points/cursor-instructions.md +16 -0
- package/src/templates/dotnet/AgentSkills/memory/index.md +22 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/api.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/auth.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/csharp.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/db.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/design.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/infra.md +7 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/mcp.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/lessons/testing.md +3 -0
- package/src/templates/dotnet/AgentSkills/memory/schema.md +26 -0
- package/src/templates/dotnet/AgentSkills/skills/INDEX.md +21 -0
- package/src/templates/dotnet/AgentSkills/skills/README.md +14 -0
- package/src/templates/dotnet/AgentSkills/skills/code-standards/SKILL.md +122 -0
- package/src/templates/dotnet/AgentSkills/skills/core/SKILL.md +83 -0
- package/src/templates/dotnet/AgentSkills/skills/csharp-xunit/SKILL.md +68 -0
- package/src/templates/dotnet/AgentSkills/skills/design/SKILL.md +108 -0
- package/src/templates/dotnet/AgentSkills/skills/dotnet-api/SKILL.md +303 -0
- package/src/templates/dotnet/AgentSkills/skills/dotnet-best-practices/SKILL.md +170 -0
- package/src/templates/dotnet/AgentSkills/skills/harness/SKILL.md +62 -0
- package/src/templates/dotnet/AgentSkills/skills/mcp_dotnet/SKILL.md +54 -0
- package/src/templates/dotnet/manifest.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# agent-skills
|
|
2
|
+
|
|
3
|
+
> Scaffold and manage AI agent skills across any project — like `shadcn/ui` but for AI coding agents.
|
|
4
|
+
|
|
5
|
+
This single package `@pratikpsl/agent-skills` bundles both the CLI tool and the template definitions. This makes installation and publishing simple and ensures offline usage capability with zero network delays at runtime.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Usage (Consumers)
|
|
10
|
+
|
|
11
|
+
To setup agent skills in any target project, run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# In any .NET project root:
|
|
15
|
+
npx @pratikpsl/agent-skills dotnet-setup
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Other Commands
|
|
19
|
+
|
|
20
|
+
| Command | Description |
|
|
21
|
+
|---------|-------------|
|
|
22
|
+
| `npx @pratikpsl/agent-skills init` | Scaffold an empty `AgentSkills/` folder and `index.json` |
|
|
23
|
+
| `npx @pratikpsl/agent-skills list dotnet` | List available skills inside the dotnet pack |
|
|
24
|
+
| `npx @pratikpsl/agent-skills add dotnet <skill>` | Copy a single skill into your project |
|
|
25
|
+
| `npx @pratikpsl/agent-skills add dotnet --all` | Copy all skills (alternative to `dotnet-setup`) |
|
|
26
|
+
| `npx @pratikpsl/agent-skills --help` | Show CLI help |
|
|
27
|
+
| `npx @pratikpsl/agent-skills --version` | Show CLI version |
|
|
28
|
+
|
|
29
|
+
### Options
|
|
30
|
+
- `--force`: Overwrite existing skill and entry point files.
|
|
31
|
+
- `--path <dir>`: Target project root (defaults to `process.cwd()`).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Repository Structure
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
agent-skills/
|
|
39
|
+
├── bin/
|
|
40
|
+
│ └── agent-skills.js (CLI binary entrypoint)
|
|
41
|
+
├── src/
|
|
42
|
+
│ ├── index.js (CLI commands setup)
|
|
43
|
+
│ ├── commands/ (init, list, add, dotnet-setup)
|
|
44
|
+
│ ├── lib/ (copySkills, manifest parsing, resolvePack)
|
|
45
|
+
│ ├── templates/ (bundled language packs)
|
|
46
|
+
│ │ └── dotnet/
|
|
47
|
+
│ │ ├── AgentSkills/ (C# best practices, agents, memory, lessons)
|
|
48
|
+
│ │ └── manifest.json (declaration of files and destinations)
|
|
49
|
+
│ └── __tests__/ (unit test suite)
|
|
50
|
+
├── package.json (unified package configuration)
|
|
51
|
+
├── LICENSE (MIT)
|
|
52
|
+
└── README.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Local Development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Install dependencies
|
|
61
|
+
npm install
|
|
62
|
+
|
|
63
|
+
# Run unit tests
|
|
64
|
+
npm test
|
|
65
|
+
|
|
66
|
+
# Link CLI globally for local command line testing
|
|
67
|
+
npm link
|
|
68
|
+
|
|
69
|
+
# Test the linked binary inside any other project directory
|
|
70
|
+
agent-skills dotnet-setup
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Publishing to npm
|
|
76
|
+
|
|
77
|
+
Since this is a unified package, publishing is straightforward:
|
|
78
|
+
|
|
79
|
+
1. **Log in to npm** (if not already):
|
|
80
|
+
```bash
|
|
81
|
+
npm login
|
|
82
|
+
```
|
|
83
|
+
2. **Publish the package**:
|
|
84
|
+
```bash
|
|
85
|
+
npm publish --otp=YOUR_6_DIGIT_OTP
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pratikpsl/agent-skills",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "CLI to scaffold and manage AI agent skills across projects",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agent-skills": "bin/agent-skills.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/pratik/agent-skills.git"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"dry-run": "npm publish --dry-run"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"commander": "^12.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"vitest": "^3.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// src/__tests__/copySkills.test.js
|
|
2
|
+
// Unit tests for the copySkills utility.
|
|
3
|
+
// Key invariants tested:
|
|
4
|
+
// 1. Files are copied when destination does not exist.
|
|
5
|
+
// 2. Existing files are NOT overwritten without --force.
|
|
6
|
+
// 3. Existing files ARE overwritten with --force.
|
|
7
|
+
// 4. Summary counts (written/skipped) are correct.
|
|
8
|
+
// 5. The optional `dest` field routes a file to a different target path (IDE entry-points).
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
11
|
+
import { mkdirSync, writeFileSync, readFileSync, rmSync, existsSync } from 'fs';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import os from 'os';
|
|
14
|
+
import { copySkills } from '../lib/copySkills.js';
|
|
15
|
+
|
|
16
|
+
function makeTempDir() {
|
|
17
|
+
const dir = path.join(os.tmpdir(), `agent-skills-copy-test-${Date.now()}`);
|
|
18
|
+
mkdirSync(dir, { recursive: true });
|
|
19
|
+
return dir;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createSkillSource(packDir, skillRelPath, content = 'skill content') {
|
|
23
|
+
const fullPath = path.join(packDir, skillRelPath);
|
|
24
|
+
mkdirSync(fullPath, { recursive: true });
|
|
25
|
+
writeFileSync(path.join(fullPath, 'SKILL.md'), content);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('copySkills', () => {
|
|
29
|
+
let packDir;
|
|
30
|
+
let targetDir;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
const ts = Date.now();
|
|
34
|
+
packDir = path.join(os.tmpdir(), `agent-skills-pack-${ts}`);
|
|
35
|
+
targetDir = path.join(os.tmpdir(), `agent-skills-target-${ts}`);
|
|
36
|
+
mkdirSync(packDir, { recursive: true });
|
|
37
|
+
mkdirSync(targetDir, { recursive: true });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
rmSync(packDir, { recursive: true, force: true });
|
|
42
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const skills = [
|
|
46
|
+
{ name: 'core', description: 'Core principles', path: 'AgentSkills/skills/core' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
it('copies a skill when destination does not exist', () => {
|
|
50
|
+
createSkillSource(packDir, 'AgentSkills/skills/core');
|
|
51
|
+
|
|
52
|
+
const { written, skipped } = copySkills({ skills, packDir, targetDir, force: false });
|
|
53
|
+
|
|
54
|
+
expect(written).toHaveLength(1);
|
|
55
|
+
expect(skipped).toHaveLength(0);
|
|
56
|
+
expect(existsSync(path.join(targetDir, 'AgentSkills/skills/core/SKILL.md'))).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('skips an existing skill without --force', () => {
|
|
60
|
+
createSkillSource(packDir, 'AgentSkills/skills/core', 'original');
|
|
61
|
+
// Pre-create destination with different content
|
|
62
|
+
const destSkillDir = path.join(targetDir, 'AgentSkills/skills/core');
|
|
63
|
+
mkdirSync(destSkillDir, { recursive: true });
|
|
64
|
+
writeFileSync(path.join(destSkillDir, 'SKILL.md'), 'existing content');
|
|
65
|
+
|
|
66
|
+
const { written, skipped } = copySkills({ skills, packDir, targetDir, force: false });
|
|
67
|
+
|
|
68
|
+
expect(written).toHaveLength(0);
|
|
69
|
+
expect(skipped).toHaveLength(1);
|
|
70
|
+
// Existing content should be preserved
|
|
71
|
+
const content = readFileSync(path.join(destSkillDir, 'SKILL.md'), 'utf8');
|
|
72
|
+
expect(content).toBe('existing content');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('overwrites an existing skill with --force', () => {
|
|
76
|
+
createSkillSource(packDir, 'AgentSkills/skills/core', 'new content');
|
|
77
|
+
const destSkillDir = path.join(targetDir, 'AgentSkills/skills/core');
|
|
78
|
+
mkdirSync(destSkillDir, { recursive: true });
|
|
79
|
+
writeFileSync(path.join(destSkillDir, 'SKILL.md'), 'old content');
|
|
80
|
+
|
|
81
|
+
const { written, skipped } = copySkills({ skills, packDir, targetDir, force: true });
|
|
82
|
+
|
|
83
|
+
expect(written).toHaveLength(1);
|
|
84
|
+
expect(skipped).toHaveLength(0);
|
|
85
|
+
const content = readFileSync(path.join(destSkillDir, 'SKILL.md'), 'utf8');
|
|
86
|
+
expect(content).toBe('new content');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('returns correct counts for mixed written/skipped', () => {
|
|
90
|
+
const twoSkills = [
|
|
91
|
+
{ name: 'core', description: 'Core', path: 'AgentSkills/skills/core' },
|
|
92
|
+
{ name: 'design', description: 'Design', path: 'AgentSkills/skills/design' },
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
createSkillSource(packDir, 'AgentSkills/skills/core');
|
|
96
|
+
createSkillSource(packDir, 'AgentSkills/skills/design');
|
|
97
|
+
|
|
98
|
+
// Pre-create only core in the destination
|
|
99
|
+
const destCore = path.join(targetDir, 'AgentSkills/skills/core');
|
|
100
|
+
mkdirSync(destCore, { recursive: true });
|
|
101
|
+
writeFileSync(path.join(destCore, 'SKILL.md'), 'existing');
|
|
102
|
+
|
|
103
|
+
const { written, skipped } = copySkills({ skills: twoSkills, packDir, targetDir, force: false });
|
|
104
|
+
|
|
105
|
+
expect(written).toHaveLength(1);
|
|
106
|
+
expect(skipped).toHaveLength(1);
|
|
107
|
+
expect(written[0]).toBe('AgentSkills/skills/design');
|
|
108
|
+
expect(skipped[0]).toBe('AgentSkills/skills/core');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('copies an entry-point file to the dest path, not the source path', () => {
|
|
112
|
+
// Simulate an IDE entry-point: source lives inside the pack, dest is at project root.
|
|
113
|
+
const entryPointSkills = [
|
|
114
|
+
{
|
|
115
|
+
name: 'entry-point:claude',
|
|
116
|
+
description: 'Claude entry point',
|
|
117
|
+
path: 'AgentSkills/entry-points/CLAUDE.md',
|
|
118
|
+
dest: 'CLAUDE.md',
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
// Create source file (a plain file, not a directory)
|
|
123
|
+
const srcDir = path.join(packDir, 'AgentSkills/entry-points');
|
|
124
|
+
mkdirSync(srcDir, { recursive: true });
|
|
125
|
+
writeFileSync(path.join(srcDir, 'CLAUDE.md'), '# Claude Entry Point');
|
|
126
|
+
|
|
127
|
+
const { written, skipped } = copySkills({ skills: entryPointSkills, packDir, targetDir, force: false });
|
|
128
|
+
|
|
129
|
+
// Should land at target root as CLAUDE.md, not inside AgentSkills/entry-points/
|
|
130
|
+
expect(written).toHaveLength(1);
|
|
131
|
+
expect(written[0]).toBe('CLAUDE.md');
|
|
132
|
+
expect(existsSync(path.join(targetDir, 'CLAUDE.md'))).toBe(true);
|
|
133
|
+
expect(existsSync(path.join(targetDir, 'AgentSkills/entry-points/CLAUDE.md'))).toBe(false);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('skips an existing entry-point file without --force (uses dest path)', () => {
|
|
137
|
+
const entryPointSkills = [
|
|
138
|
+
{
|
|
139
|
+
name: 'entry-point:claude',
|
|
140
|
+
description: 'Claude entry point',
|
|
141
|
+
path: 'AgentSkills/entry-points/CLAUDE.md',
|
|
142
|
+
dest: 'CLAUDE.md',
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
const srcDir = path.join(packDir, 'AgentSkills/entry-points');
|
|
147
|
+
mkdirSync(srcDir, { recursive: true });
|
|
148
|
+
writeFileSync(path.join(srcDir, 'CLAUDE.md'), 'new content');
|
|
149
|
+
|
|
150
|
+
// Pre-create destination
|
|
151
|
+
writeFileSync(path.join(targetDir, 'CLAUDE.md'), 'existing content');
|
|
152
|
+
|
|
153
|
+
const { written, skipped } = copySkills({ skills: entryPointSkills, packDir, targetDir, force: false });
|
|
154
|
+
|
|
155
|
+
expect(written).toHaveLength(0);
|
|
156
|
+
expect(skipped).toHaveLength(1);
|
|
157
|
+
expect(skipped[0]).toBe('CLAUDE.md');
|
|
158
|
+
// Existing content untouched
|
|
159
|
+
expect(readFileSync(path.join(targetDir, 'CLAUDE.md'), 'utf8')).toBe('existing content');
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/__tests__/list.test.js
|
|
2
|
+
// Integration-style test: verifies that list output matches manifest contents.
|
|
3
|
+
// We don't spawn the CLI process — instead we call the underlying lib functions
|
|
4
|
+
// that the list command uses, which is the behaviour that matters.
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
7
|
+
import { mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import os from 'os';
|
|
10
|
+
import { readManifest } from '../lib/manifest.js';
|
|
11
|
+
|
|
12
|
+
function makeTempDir() {
|
|
13
|
+
const dir = path.join(os.tmpdir(), `agent-skills-list-test-${Date.now()}`);
|
|
14
|
+
mkdirSync(dir, { recursive: true });
|
|
15
|
+
return dir;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('list — manifest content matches output data', () => {
|
|
19
|
+
let tmpDir;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
tmpDir = makeTempDir();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns all skills declared in manifest', () => {
|
|
30
|
+
const manifest = {
|
|
31
|
+
name: '@pratikpsl/agent-skills-dotnet',
|
|
32
|
+
version: '0.1.0',
|
|
33
|
+
skills: [
|
|
34
|
+
{ name: 'core', description: 'Core principles', path: 'AgentSkills/skills/core' },
|
|
35
|
+
{ name: 'design', description: 'Design principles', path: 'AgentSkills/skills/design' },
|
|
36
|
+
{ name: 'dotnet-api', description: '.NET API rules', path: 'AgentSkills/skills/dotnet-api' },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), JSON.stringify(manifest));
|
|
40
|
+
|
|
41
|
+
const result = readManifest(tmpDir);
|
|
42
|
+
|
|
43
|
+
// The list command renders result.skills — verify the data is identical.
|
|
44
|
+
expect(result.skills.map((s) => s.name)).toEqual(['core', 'design', 'dotnet-api']);
|
|
45
|
+
expect(result.skills.every((s) => typeof s.description === 'string')).toBe(true);
|
|
46
|
+
expect(result.name).toBe(manifest.name);
|
|
47
|
+
expect(result.version).toBe(manifest.version);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/__tests__/manifest.test.js
|
|
2
|
+
// Unit tests for the manifest reader/validator.
|
|
3
|
+
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
5
|
+
import { mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import { readManifest } from '../lib/manifest.js';
|
|
9
|
+
|
|
10
|
+
function makeTempDir() {
|
|
11
|
+
const dir = path.join(os.tmpdir(), `agent-skills-test-${Date.now()}`);
|
|
12
|
+
mkdirSync(dir, { recursive: true });
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('readManifest', () => {
|
|
17
|
+
let tmpDir;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
tmpDir = makeTempDir();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('parses a valid manifest', () => {
|
|
28
|
+
const manifest = {
|
|
29
|
+
name: '@pratikpsl/agent-skills-dotnet',
|
|
30
|
+
version: '0.1.0',
|
|
31
|
+
skills: [
|
|
32
|
+
{ name: 'core', description: 'Core principles', path: 'AgentSkills/skills/core' },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), JSON.stringify(manifest));
|
|
36
|
+
const result = readManifest(tmpDir);
|
|
37
|
+
expect(result.name).toBe('@pratikpsl/agent-skills-dotnet');
|
|
38
|
+
expect(result.skills).toHaveLength(1);
|
|
39
|
+
expect(result.skills[0].name).toBe('core');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('throws when manifest.json is missing', () => {
|
|
43
|
+
expect(() => readManifest(tmpDir)).toThrowError(/manifest.json not found/);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('throws when manifest.json is not valid JSON', () => {
|
|
47
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), 'not json!');
|
|
48
|
+
expect(() => readManifest(tmpDir)).toThrowError(/not valid JSON/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('throws when "name" field is missing', () => {
|
|
52
|
+
const bad = { version: '0.1.0', skills: [] };
|
|
53
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), JSON.stringify(bad));
|
|
54
|
+
expect(() => readManifest(tmpDir)).toThrowError(/missing required field "name"/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('throws when "skills" is not an array', () => {
|
|
58
|
+
const bad = { name: 'test', version: '0.1.0', skills: 'not-an-array' };
|
|
59
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), JSON.stringify(bad));
|
|
60
|
+
expect(() => readManifest(tmpDir)).toThrowError(/"skills" must be an array/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('throws when a skill entry is missing the "path" field', () => {
|
|
64
|
+
const bad = {
|
|
65
|
+
name: 'test',
|
|
66
|
+
version: '0.1.0',
|
|
67
|
+
skills: [{ name: 'core', description: 'desc' }],
|
|
68
|
+
};
|
|
69
|
+
writeFileSync(path.join(tmpDir, 'manifest.json'), JSON.stringify(bad));
|
|
70
|
+
expect(() => readManifest(tmpDir)).toThrowError(/missing or has an empty "path" field/);
|
|
71
|
+
});
|
|
72
|
+
});
|