@wthek/error-handling 0.0.0-stage → 1.0.0-beta.2
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 +22 -0
- package/README.md +246 -2
- package/dist/bin.d.ts +36 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +127 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/installer.d.ts +36 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +139 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/package.json +101 -3
- package/plugin.json +11 -0
- package/skills/wthek-error-handling/SKILL.md +711 -0
- package/skills/wthek-error-handling/examples/express-zod.js +44 -0
- package/skills/wthek-error-handling/examples/express-zod.ts +51 -0
- package/skills/wthek-error-handling/examples/fastify-zod.js +40 -0
- package/skills/wthek-error-handling/examples/fastify-zod.ts +45 -0
- package/skills/wthek-error-handling/examples/hono-valibot.ts +42 -0
- package/skills/wthek-error-handling/examples/koa-typebox.ts +54 -0
- package/skills/wthek-error-handling/references/express.md +73 -0
- package/skills/wthek-error-handling/references/fastify.md +81 -0
- package/skills/wthek-error-handling/references/formatters.md +241 -0
- package/skills/wthek-error-handling/references/hono.md +151 -0
- package/skills/wthek-error-handling/references/koa.md +62 -0
- package/skills/wthek-error-handling/references/mcp.md +148 -0
- package/skills/wthek-error-handling/references/nestjs.md +84 -0
- package/skills/wthek-error-handling/references/restify.md +68 -0
- package/skills/wthek-error-handling/references/status-codes.md +181 -0
- package/skills/wthek-error-handling/references/typebox.md +74 -0
- package/skills/wthek-error-handling/references/valibot.md +202 -0
- package/skills/wthek-error-handling/references/zod.md +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Himanshu Bansal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,247 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WTHek Error Handling - Agent Skill & Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@wthek/error-handling)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/Skillnter/wthek-error-handling/actions)
|
|
6
|
+
[](https://socket.dev/npm/package/@wthek/error-handling)
|
|
7
|
+
[](https://skills.sh/Skillnter/wthek-error-handling)
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
An AI agent skill and Antigravity plugin that helps developers and AI coding assistants implement consistent **HHTTP and MCP error handling**H across Node.js applications.
|
|
13
|
+
|
|
14
|
+
Includes framework-specific instructions, integration examples, and best practices for RFC 7807 / RFC 9457 Problem Details, HTTP status codes (RFC 9110), validation error handling, and MCP error responses.
|
|
15
|
+
|
|
16
|
+
It provides instructions, recipes, and best practices for RFC 7807 / RFC 9457 Problem Details, standard HTTP status codes (RFC 9110), validation error transformations, and standardized MCP error responses using `@wthek`, [`http-error-kit`](https://www.npmjs.com/package/http-error-kit), and [`http-response-status-code`](https://www.npmjs.com/package/http-response-status-code).
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What Is This?
|
|
21
|
+
|
|
22
|
+
Error handling in Node.js backend services and AI agents is often fragmented—every framework has its own middleware signature, validation libraries format errors differently, and MCP tool errors frequently lack consistent structure.
|
|
23
|
+
|
|
24
|
+
**WTHek Error Handling** bridges this gap for both humans and AI coding assistants. It serves as an on-demand instruction bundle and Antigravity plugin that helps developers and coding agents (Google Antigravity, Cursor, Claude Code, GitHub Copilot, Windsurf) implement, refactor, and review error handling patterns with zero guesswork.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
### Framework Support
|
|
31
|
+
Production-ready error handling patterns and middleware integrations for 6 major Node.js frameworks:
|
|
32
|
+
- **Express.js** ([`@wthek/express-middleware`](https://www.npmjs.com/package/@wthek/express-middleware))
|
|
33
|
+
- **Fastify** ([`@wthek/fastify-middleware`](https://www.npmjs.com/package/@wthek/fastify-middleware))
|
|
34
|
+
- **Hono** ([`@wthek/hono-middleware`](https://www.npmjs.com/package/@wthek/hono-middleware))
|
|
35
|
+
- **Koa** ([`@wthek/koa-middleware`](https://www.npmjs.com/package/@wthek/koa-middleware))
|
|
36
|
+
- **NestJS** ([`@wthek/nestjs-middleware`](https://www.npmjs.com/package/@wthek/nestjs-middleware))
|
|
37
|
+
- **Restify** ([`@wthek/restify-middleware`](https://www.npmjs.com/package/@wthek/restify-middleware))
|
|
38
|
+
|
|
39
|
+
### Validation Support
|
|
40
|
+
Seamless error transformation pipelines for popular TypeScript/JavaScript schema validation libraries:
|
|
41
|
+
- **Zod** ([`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/zod-express-interceptor`](https://www.npmjs.com/package/@wthek/zod-express-interceptor))
|
|
42
|
+
- **Valibot** ([`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer))
|
|
43
|
+
- **TypeBox** ([`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer))
|
|
44
|
+
|
|
45
|
+
### Standards and Specifications
|
|
46
|
+
- **RFC 7807 & RFC 9457**: Standardized Problem Details for HTTP APIs using `application/problem+json`.
|
|
47
|
+
- **RFC 9110**: Semantically correct HTTP status codes and headers.
|
|
48
|
+
- **Type-safe status codes**: Named constants, categories, and helpers provided by [`http-response-status-code`](https://www.npmjs.com/package/http-response-status-code).
|
|
49
|
+
|
|
50
|
+
### Model Context Protocol (MCP)
|
|
51
|
+
Dedicated guidance and utilities for AI agent tool and server development:
|
|
52
|
+
- **[`@wthek/mcp-error-formatter`](https://www.npmjs.com/package/@wthek/mcp-error-formatter)**: Format and standardize errors thrown inside MCP tools (`isError: true` responses).
|
|
53
|
+
- **[`@wthek/mcp`](https://www.npmjs.com/package/@wthek/mcp)**: Build standalone Model Context Protocol servers with built-in error containment.
|
|
54
|
+
|
|
55
|
+
### AI Agent Integration
|
|
56
|
+
When added to a workspace, the skill equips AI coding agents to:
|
|
57
|
+
- Follow consistent error handling conventions across your entire codebase.
|
|
58
|
+
- Pick the right middleware and transformer packages for each framework.
|
|
59
|
+
- Avoid asynchronous race conditions (e.g. `res.headersSent` or `reply.sent`).
|
|
60
|
+
- Standardize API errors to RFC-compliant Problem Details.
|
|
61
|
+
- Review and audit existing error handlers for gaps.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
You can install the skill into your current project, configure it globally, or add it as an npm development dependency.
|
|
68
|
+
|
|
69
|
+
### Method 1: Install Using NPX (Recommended)
|
|
70
|
+
|
|
71
|
+
Install directly into your current workspace:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @wthek/error-handling
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
By default, the skill is installed at:
|
|
78
|
+
```text
|
|
79
|
+
.agents/skills/wthek-error-handling
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Other Target Locations:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Install globally as an Antigravity plugin (~/.gemini/config/plugins/wthek-error-handling)
|
|
86
|
+
npx @wthek/error-handling --global
|
|
87
|
+
|
|
88
|
+
# Install into GitHub workflows & Copilot skills directory (.github/skills/wthek-error-handling)
|
|
89
|
+
npx @wthek/error-handling --github
|
|
90
|
+
|
|
91
|
+
# Install into a custom directory
|
|
92
|
+
npx @wthek/error-handling --dest ./my-skills/wthek-error-handling
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### Method 2: Install as an npm Dependency
|
|
98
|
+
|
|
99
|
+
Install the package as a development dependency:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install -D @wthek/error-handling
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Then run the bundled CLI to install the skill into your workspace:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx wthek-error-handling
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Programmatic Usage
|
|
112
|
+
|
|
113
|
+
The package exports helper functions to inspect paths and manifests programmatically:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { getSkillPath, getPluginManifest, installSkill } from "@wthek/error-handling";
|
|
117
|
+
|
|
118
|
+
console.log("Skill directory:", getSkillPath());
|
|
119
|
+
console.log("Plugin manifest:", getPluginManifest());
|
|
120
|
+
|
|
121
|
+
// Programmatically trigger installation:
|
|
122
|
+
installSkill({ github: true });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Method 3: Install Directly as an Antigravity Plugin
|
|
128
|
+
|
|
129
|
+
The repository includes a `plugin.json` manifest at its root. You can clone the repository directly into your Antigravity plugins directory:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/Skillnter/wthek-error-handling.git ~/.gemini/config/plugins/wthek-error-handling
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Once installed, Antigravity will discover the **WTHek Error Handling** plugin with all skills, prompts, and recipes enabled.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Package Selection Guide
|
|
140
|
+
|
|
141
|
+
| Framework / Requirement | Primary Package | Validation Integration |
|
|
142
|
+
| :--- | :--- | :--- |
|
|
143
|
+
| **Express.js** | [`@wthek/express-middleware`](https://www.npmjs.com/package/@wthek/express-middleware) | [`@wthek/zod-express-interceptor`](https://www.npmjs.com/package/@wthek/zod-express-interceptor), [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
144
|
+
| **Fastify** | [`@wthek/fastify-middleware`](https://www.npmjs.com/package/@wthek/fastify-middleware) | [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
145
|
+
| **Hono** | [`@wthek/hono-middleware`](https://www.npmjs.com/package/@wthek/hono-middleware) | [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
146
|
+
| **Koa** | [`@wthek/koa-middleware`](https://www.npmjs.com/package/@wthek/koa-middleware) | [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
147
|
+
| **NestJS** | [`@wthek/nestjs-middleware`](https://www.npmjs.com/package/@wthek/nestjs-middleware) | [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
148
|
+
| **Restify** | [`@wthek/restify-middleware`](https://www.npmjs.com/package/@wthek/restify-middleware) | [`@wthek/zod-transformer`](https://www.npmjs.com/package/@wthek/zod-transformer), [`@wthek/valibot-transformer`](https://www.npmjs.com/package/@wthek/valibot-transformer), [`@wthek/typebox-transformer`](https://www.npmjs.com/package/@wthek/typebox-transformer) |
|
|
149
|
+
| **Model Context Protocol** | [`@wthek/mcp-error-formatter`](https://www.npmjs.com/package/@wthek/mcp-error-formatter) | [`@wthek/mcp`](https://www.npmjs.com/package/@wthek/mcp) (Server) |
|
|
150
|
+
| **Core Error Handling** | [`http-error-kit`](https://www.npmjs.com/package/http-error-kit) | [`http-response-status-code`](https://www.npmjs.com/package/http-response-status-code) |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Project Structure
|
|
155
|
+
|
|
156
|
+
```text
|
|
157
|
+
wthek-error-handling/
|
|
158
|
+
├── plugin.json # Antigravity plugin manifest
|
|
159
|
+
├── package.json # npm package configuration
|
|
160
|
+
├── tsconfig.json # TypeScript compiler options
|
|
161
|
+
├── src/ # TypeScript source code
|
|
162
|
+
│ ├── index.ts # Programmatic API exports
|
|
163
|
+
│ ├── bin.ts # CLI installer implementation
|
|
164
|
+
│ ├── installer.ts # File copying & target resolution logic
|
|
165
|
+
│ └── types.ts # Type definitions & interfaces
|
|
166
|
+
├── dist/ # Compiled CommonJS & .d.ts files
|
|
167
|
+
├── test/ # 100% coverage Jest test suite
|
|
168
|
+
│ ├── index.spec.ts
|
|
169
|
+
│ ├── bin.spec.ts
|
|
170
|
+
│ └── installer.spec.ts
|
|
171
|
+
└── skills/
|
|
172
|
+
└── wthek-error-handling/
|
|
173
|
+
├── SKILL.md # Main AI agent skill instruction file
|
|
174
|
+
├── references/ # 12 detailed reference guides
|
|
175
|
+
│ ├── express.md
|
|
176
|
+
│ ├── fastify.md
|
|
177
|
+
│ ├── hono.md
|
|
178
|
+
│ ├── koa.md
|
|
179
|
+
│ ├── nestjs.md
|
|
180
|
+
│ ├── restify.md
|
|
181
|
+
│ ├── zod.md
|
|
182
|
+
│ ├── valibot.md
|
|
183
|
+
│ ├── typebox.md
|
|
184
|
+
│ ├── formatters.md # RFC 7807 & RFC 9457 specifications
|
|
185
|
+
│ ├── status-codes.md # RFC 9110 status codes & helpers
|
|
186
|
+
│ └── mcp.md # Model Context Protocol error handling
|
|
187
|
+
└── examples/ # Practical runnable code examples
|
|
188
|
+
├── express-zod.ts
|
|
189
|
+
├── express-zod.js
|
|
190
|
+
├── fastify-zod.ts
|
|
191
|
+
├── fastify-zod.js
|
|
192
|
+
├── hono-valibot.ts
|
|
193
|
+
└── koa-typebox.ts
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## CLI Reference
|
|
199
|
+
|
|
200
|
+
### Usage
|
|
201
|
+
```bash
|
|
202
|
+
npx @wthek/error-handling [command] [options]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Commands
|
|
206
|
+
| Command | Description |
|
|
207
|
+
| :--- | :--- |
|
|
208
|
+
| `install` | Installs the skill into the selected directory (default command). |
|
|
209
|
+
|
|
210
|
+
### Options
|
|
211
|
+
| Option | Description |
|
|
212
|
+
| :--- | :--- |
|
|
213
|
+
| `--workspace`, `-w` | Install into the current workspace at `.agents/skills/wthek-error-handling` (default). |
|
|
214
|
+
| `--global`, `-g` | Install into global Antigravity config at `~/.gemini/config/plugins/wthek-error-handling`. |
|
|
215
|
+
| `--github` | Install into `.github/skills/wthek-error-handling`. |
|
|
216
|
+
| `--dest <path>` | Install into a custom directory path. |
|
|
217
|
+
| `--help`, `-h` | Display the CLI help message. |
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Author
|
|
222
|
+
|
|
223
|
+
The original author of the project is [Himanshu Bansal][skillnter]
|
|
224
|
+
|
|
225
|
+
## Donations
|
|
226
|
+
|
|
227
|
+
**This is all voluntary work**, so if you want to support my efforts you can:
|
|
228
|
+
|
|
229
|
+
- [Buy Me A Coffee](https://www.buymeacoffee.com/skillnter)
|
|
230
|
+
- [PayPal](https://www.paypal.com/paypalme/skillnter)
|
|
231
|
+
- [GitHub Sponsors](https://github.com/sponsors/Skillnter)
|
|
232
|
+
- [Patreon](https://www.patreon.com/skillnter)
|
|
233
|
+
- [Open Collective](https://opencollective.com/skillnter)
|
|
234
|
+
|
|
235
|
+
You can also use the following crypto addresses:
|
|
236
|
+
|
|
237
|
+

|
|
238
|
+
|
|
239
|
+

|
|
240
|
+
|
|
241
|
+

|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
`wthek-error-handling` project is open-sourced software licensed under the [MIT license](LICENSE) by [Himanshu Bansal][skillnter].
|
|
246
|
+
|
|
247
|
+
[skillnter]: https://github.com/Skillnter/
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { IInstallOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Emits message directly to controlling terminal when available, falling back to console.log.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} text - Message text to write to terminal output.
|
|
7
|
+
* @returns {void} No return value.
|
|
8
|
+
*/
|
|
9
|
+
export declare const outputToTerminal: (text: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Prints CLI usage instructions and options to standard output.
|
|
12
|
+
*
|
|
13
|
+
* @returns {void} No return value.
|
|
14
|
+
*/
|
|
15
|
+
export declare const printHelp: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Parses command-line arguments and returns corresponding installation options.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} args - Command line arguments passed to process.
|
|
20
|
+
* @returns {IInstallOptions} Parsed installation options object.
|
|
21
|
+
*/
|
|
22
|
+
export declare const parseArgs: (args: string[]) => IInstallOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Prints success banner with installation details, agent compatibility, and sponsorship links.
|
|
25
|
+
*
|
|
26
|
+
* @param {string[]} targets - Destination paths where skills were installed.
|
|
27
|
+
* @returns {void} No return value.
|
|
28
|
+
*/
|
|
29
|
+
export declare const printSuccessBanner: (targets: string[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Executes CLI command workflow according to arguments.
|
|
32
|
+
*
|
|
33
|
+
* @returns {void} No return value.
|
|
34
|
+
*/
|
|
35
|
+
export declare const runCli: () => void;
|
|
36
|
+
//# sourceMappingURL=bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,IAY/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAO,IAwB5B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAG,eAe1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,KAAG,IA0CtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,IAkBzB,CAAC"}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.runCli = exports.printSuccessBanner = exports.parseArgs = exports.printHelp = exports.outputToTerminal = void 0;
|
|
38
|
+
var fs = __importStar(require("fs"));
|
|
39
|
+
var installer_1 = require("./installer");
|
|
40
|
+
/**
|
|
41
|
+
* Emits message directly to controlling terminal when available, falling back to console.log.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} text - Message text to write to terminal output.
|
|
44
|
+
* @returns {void} No return value.
|
|
45
|
+
*/
|
|
46
|
+
var outputToTerminal = function (text) {
|
|
47
|
+
if (process.stdout.isTTY) {
|
|
48
|
+
console.log(text);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
var ttyDevice = process.platform === "win32" ? "\\\\.\\CON" : "/dev/tty";
|
|
53
|
+
fs.appendFileSync(ttyDevice, text + "\n");
|
|
54
|
+
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
console.log(text);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.outputToTerminal = outputToTerminal;
|
|
60
|
+
/**
|
|
61
|
+
* Prints CLI usage instructions and options to standard output.
|
|
62
|
+
*
|
|
63
|
+
* @returns {void} No return value.
|
|
64
|
+
*/
|
|
65
|
+
var printHelp = function () {
|
|
66
|
+
(0, exports.outputToTerminal)("\n@wthek/error-handling Installer\n--------------------------------\nInstalls the WTHek Error Handling skill/plugin into your workspace or global Antigravity config.\n\nUsage:\n npx @wthek/error-handling [command] [options]\n\nCommands:\n install (default) Installs the skill into target location\n\nOptions:\n --workspace, -w Install to local workspace (.agents/skills/wthek-error-handling) [default]\n --global, -g Install to global Antigravity config (~/.gemini/config/plugins/wthek-error-handling)\n --github Install to GitHub workflows folder (.github/skills/wthek-error-handling)\n --dest <path> Install to a custom directory path\n --help, -h Display this help message\n\nExamples:\n npx @wthek/error-handling\n npx @wthek/error-handling --global\n npx @wthek/error-handling --dest ./my-skills/wthek-error-handling\n");
|
|
67
|
+
};
|
|
68
|
+
exports.printHelp = printHelp;
|
|
69
|
+
/**
|
|
70
|
+
* Parses command-line arguments and returns corresponding installation options.
|
|
71
|
+
*
|
|
72
|
+
* @param {string[]} args - Command line arguments passed to process.
|
|
73
|
+
* @returns {IInstallOptions} Parsed installation options object.
|
|
74
|
+
*/
|
|
75
|
+
var parseArgs = function (args) {
|
|
76
|
+
var isGlobal = args.includes("--global") || args.includes("-g");
|
|
77
|
+
var isGithub = args.includes("--github");
|
|
78
|
+
var destIndex = args.indexOf("--dest");
|
|
79
|
+
var dest = undefined;
|
|
80
|
+
if (destIndex !== -1 && args[destIndex + 1]) {
|
|
81
|
+
dest = args[destIndex + 1];
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
global: isGlobal,
|
|
85
|
+
github: isGithub,
|
|
86
|
+
dest: dest,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
exports.parseArgs = parseArgs;
|
|
90
|
+
/**
|
|
91
|
+
* Prints success banner with installation details, agent compatibility, and sponsorship links.
|
|
92
|
+
*
|
|
93
|
+
* @param {string[]} targets - Destination paths where skills were installed.
|
|
94
|
+
* @returns {void} No return value.
|
|
95
|
+
*/
|
|
96
|
+
var printSuccessBanner = function (targets) {
|
|
97
|
+
var targetLines = targets.map(function (t) { return " \u2022 ".concat(t); }).join("\n");
|
|
98
|
+
(0, exports.outputToTerminal)("\n================================================================================\n WTHek Error Handling Skill Installed Successfully\n================================================================================\n\n Provides standardized error handling, RFC 7807/9457 Problem Details,\n HTTP status codes (RFC 9110), and validation pipelines for:\n\n Express, Fastify, Hono, Koa, NestJS, Restify, and Model Context Protocol (MCP).\n\n Installation Path:\n ".concat(targetLines, "\n\n Supported AI Agents:\n - Antigravity (Native plugin and skill discovery)\n - Cursor (Workspace .agents/skills/ integration)\n - Claude Code (Automatic skill loading)\n - GitHub Copilot (.github/skills/ and workspace skills)\n - Windsurf, Roo, Codex, and Gemini CLI\n\n What It Does:\n AI agents that read this skill will follow the recommended @wthek,\n http-error-kit, and http-response-status-code patterns.\n\n This helps maintain consistent:\n - HTTP error responses and formatting\n - HTTP status code usage\n - Validation error handling\n - Error response structures across frameworks\n\n Support Open Source:\n GitHub: https://github.com/Skillnter/wthek-error-handling\n Sponsor: https://github.com/sponsors/Skillnter\n Coffee: https://buymeacoffee.com/skillnter\n\n If you find this project useful, consider giving the repository a\n \u2B50 on GitHub. Your support helps maintain and improve the project.\n\n================================================================================\n"));
|
|
99
|
+
};
|
|
100
|
+
exports.printSuccessBanner = printSuccessBanner;
|
|
101
|
+
/**
|
|
102
|
+
* Executes CLI command workflow according to arguments.
|
|
103
|
+
*
|
|
104
|
+
* @returns {void} No return value.
|
|
105
|
+
*/
|
|
106
|
+
var runCli = function () {
|
|
107
|
+
var args = process.argv.slice(2);
|
|
108
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
109
|
+
(0, exports.printHelp)();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var options = (0, exports.parseArgs)(args);
|
|
113
|
+
try {
|
|
114
|
+
var targetDir = (0, installer_1.installSkill)(options);
|
|
115
|
+
(0, exports.printSuccessBanner)([targetDir]);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
var message = error instanceof Error ? error.message : String(error);
|
|
119
|
+
console.error("\u274C Installation failed:", message);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
exports.runCli = runCli;
|
|
124
|
+
/* istanbul ignore next */
|
|
125
|
+
if (require.main === module) {
|
|
126
|
+
(0, exports.runCli)();
|
|
127
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { installSkill } from "./installer";
|
|
2
|
+
import { IWthekPluginManifest, IInstallOptions } from "./types";
|
|
3
|
+
export type { IWthekPluginManifest, IInstallOptions };
|
|
4
|
+
export { installSkill };
|
|
5
|
+
/**
|
|
6
|
+
* Returns absolute path to bundled wthek-error-handling skill folder.
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} Absolute path to skill directory.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSkillPath: () => string;
|
|
11
|
+
/**
|
|
12
|
+
* Returns absolute path to bundled plugin.json manifest.
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} Absolute path to plugin manifest file.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getPluginManifestPath: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* Reads and parses bundled plugin.json manifest.
|
|
19
|
+
*
|
|
20
|
+
* @returns {IWthekPluginManifest} Parsed plugin manifest object.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getPluginManifest: () => IWthekPluginManifest;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,MAE/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAExC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,oBAGpC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getPluginManifest = exports.getPluginManifestPath = exports.getSkillPath = exports.installSkill = void 0;
|
|
37
|
+
var fs = __importStar(require("fs"));
|
|
38
|
+
var installer_1 = require("./installer");
|
|
39
|
+
Object.defineProperty(exports, "installSkill", { enumerable: true, get: function () { return installer_1.installSkill; } });
|
|
40
|
+
/**
|
|
41
|
+
* Returns absolute path to bundled wthek-error-handling skill folder.
|
|
42
|
+
*
|
|
43
|
+
* @returns {string} Absolute path to skill directory.
|
|
44
|
+
*/
|
|
45
|
+
var getSkillPath = function () {
|
|
46
|
+
return installer_1.SOURCE_SKILL_DIR;
|
|
47
|
+
};
|
|
48
|
+
exports.getSkillPath = getSkillPath;
|
|
49
|
+
/**
|
|
50
|
+
* Returns absolute path to bundled plugin.json manifest.
|
|
51
|
+
*
|
|
52
|
+
* @returns {string} Absolute path to plugin manifest file.
|
|
53
|
+
*/
|
|
54
|
+
var getPluginManifestPath = function () {
|
|
55
|
+
return installer_1.SOURCE_PLUGIN_JSON;
|
|
56
|
+
};
|
|
57
|
+
exports.getPluginManifestPath = getPluginManifestPath;
|
|
58
|
+
/**
|
|
59
|
+
* Reads and parses bundled plugin.json manifest.
|
|
60
|
+
*
|
|
61
|
+
* @returns {IWthekPluginManifest} Parsed plugin manifest object.
|
|
62
|
+
*/
|
|
63
|
+
var getPluginManifest = function () {
|
|
64
|
+
var content = fs.readFileSync(installer_1.SOURCE_PLUGIN_JSON, "utf8");
|
|
65
|
+
return JSON.parse(content);
|
|
66
|
+
};
|
|
67
|
+
exports.getPluginManifest = getPluginManifest;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IInstallOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Path to package root directory.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PKG_ROOT: string;
|
|
6
|
+
/**
|
|
7
|
+
* Path to source skill directory inside package.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SOURCE_SKILL_DIR: string;
|
|
10
|
+
/**
|
|
11
|
+
* Path to plugin.json manifest inside package.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SOURCE_PLUGIN_JSON: string;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively copies a directory and its contents from source to destination.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} src - Source directory path to copy from.
|
|
18
|
+
* @param {string} dest - Destination directory path to copy into.
|
|
19
|
+
* @returns {void} No return value.
|
|
20
|
+
*/
|
|
21
|
+
export declare const copyDirRecursive: (src: string, dest: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves destination directory for installation based on provided options.
|
|
24
|
+
*
|
|
25
|
+
* @param {IInstallOptions} [options] - Configuration options determining installation target.
|
|
26
|
+
* @returns {string} Absolute path to resolved target installation directory.
|
|
27
|
+
*/
|
|
28
|
+
export declare const resolveTargetDir: (options?: IInstallOptions) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Installs skill files and plugin manifest to target directory.
|
|
31
|
+
*
|
|
32
|
+
* @param {IInstallOptions} [options] - Optional settings controlling target directory location.
|
|
33
|
+
* @returns {string} Absolute path where skill files were installed.
|
|
34
|
+
*/
|
|
35
|
+
export declare const installSkill: (options?: IInstallOptions) => string;
|
|
36
|
+
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAsC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAI9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAA2C,CAAC;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,KAAG,IAiB5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,eAAe,KAAG,MAiB5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,eAAe,KAAG,MAexD,CAAC"}
|