@jaypie/mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/prompts/Branch_Management.md +34 -0
- package/prompts/Development_Process.md +67 -0
- package/prompts/Jaypie_Agent_Rules.md +110 -0
- package/prompts/Jaypie_Auth0_Express_Mongoose.md +736 -0
- package/prompts/Jaypie_Browser_and_Frontend_Web_Packages.md +18 -0
- package/prompts/Jaypie_CDK_Constructs_and_Patterns.md +156 -0
- package/prompts/Jaypie_CICD_with_GitHub_Actions.md +151 -0
- package/prompts/Jaypie_Commander_CLI_Package.md +166 -0
- package/prompts/Jaypie_Core_Errors_and_Logging.md +39 -0
- package/prompts/Jaypie_Eslint_NPM_Package.md +78 -0
- package/prompts/Jaypie_Ideal_Project_Structure.md +78 -0
- package/prompts/Jaypie_Init_Express_on_Lambda.md +87 -0
- package/prompts/Jaypie_Init_Jaypie_CDK_Package.md +35 -0
- package/prompts/Jaypie_Init_Lambda_Package.md +245 -0
- package/prompts/Jaypie_Init_Monorepo_Project.md +44 -0
- package/prompts/Jaypie_Init_Project_Subpackage.md +70 -0
- package/prompts/Jaypie_Legacy_Patterns.md +11 -0
- package/prompts/Jaypie_Llm_Calls.md +113 -0
- package/prompts/Jaypie_Llm_Tools.md +124 -0
- package/prompts/Jaypie_Mocks_and_Testkit.md +137 -0
- package/prompts/Jaypie_Mongoose_Models_Package.md +231 -0
- package/prompts/Jaypie_Mongoose_with_Express_CRUD.md +1000 -0
- package/prompts/Jaypie_Scrub.md +177 -0
- package/prompts/Write_Efficient_Prompt_Guides.md +48 -0
- package/prompts/Write_and_Maintain_Engaging_Readme.md +67 -0
- package/prompts/templates/cdk-subpackage/bin/cdk.ts +11 -0
- package/prompts/templates/cdk-subpackage/cdk.json +19 -0
- package/prompts/templates/cdk-subpackage/lib/cdk-app.ts +41 -0
- package/prompts/templates/cdk-subpackage/lib/cdk-infrastructure.ts +15 -0
- package/prompts/templates/express-subpackage/index.ts +8 -0
- package/prompts/templates/express-subpackage/src/app.ts +18 -0
- package/prompts/templates/express-subpackage/src/handler.config.ts +44 -0
- package/prompts/templates/express-subpackage/src/routes/resource/__tests__/resourceGet.route.spec.ts +29 -0
- package/prompts/templates/express-subpackage/src/routes/resource/resourceGet.route.ts +22 -0
- package/prompts/templates/express-subpackage/src/routes/resource.router.ts +11 -0
- package/prompts/templates/express-subpackage/src/types/express.ts +9 -0
- package/prompts/templates/project-monorepo/.vscode/settings.json +72 -0
- package/prompts/templates/project-monorepo/eslint.config.mjs +1 -0
- package/prompts/templates/project-monorepo/package.json +20 -0
- package/prompts/templates/project-monorepo/tsconfig.base.json +18 -0
- package/prompts/templates/project-monorepo/tsconfig.json +6 -0
- package/prompts/templates/project-monorepo/vitest.workspace.js +3 -0
- package/prompts/templates/project-subpackage/package.json +16 -0
- package/prompts/templates/project-subpackage/tsconfig.json +11 -0
- package/prompts/templates/project-subpackage/vite.config.ts +21 -0
- package/prompts/templates/project-subpackage/vitest.config.ts +7 -0
- package/prompts/templates/project-subpackage/vitest.setup.ts +6 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: When asked to create a new workspace or subpackage for express, usually packages/express, to run as serverless Lambdas behind API Gateway
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Jaypie Initialize Express on Lambda Subpackage
|
|
7
|
+
|
|
8
|
+
## Process
|
|
9
|
+
|
|
10
|
+
1. Follow Jaypie_Init_Project_Subpackage.md:
|
|
11
|
+
* Use @project-org/express in packages/express
|
|
12
|
+
* This creates the basic subpackage structure with package.json, tsconfig.json, and vitest config files
|
|
13
|
+
|
|
14
|
+
2. Copy Express-specific template files:
|
|
15
|
+
* Copy `prompts/templates/express-subpackage/index.ts` to `packages/express/index.ts`
|
|
16
|
+
* Copy `prompts/templates/express-subpackage/src/app.ts` to `packages/express/src/app.ts`
|
|
17
|
+
* Copy `prompts/templates/express-subpackage/src/handler.config.ts` to `packages/express/src/handler.config.ts`
|
|
18
|
+
* Copy `prompts/templates/express-subpackage/src/routes/resource.router.ts` to `packages/express/src/routes/resource.router.ts`
|
|
19
|
+
* Copy `prompts/templates/express-subpackage/src/routes/resource/resourceGet.route.ts` to `packages/express/src/routes/resource/resourceGet.route.ts`
|
|
20
|
+
* Copy `prompts/templates/express-subpackage/src/routes/resource/__tests__/resourceGet.route.spec.ts` to `packages/express/src/routes/resource/__tests__/resourceGet.route.spec.ts`
|
|
21
|
+
* Copy `prompts/templates/express-subpackage/src/types/express.ts` to `packages/express/src/types/express.ts`
|
|
22
|
+
|
|
23
|
+
3. Update package.json scripts:
|
|
24
|
+
* Modify the existing scripts section to include:
|
|
25
|
+
* `"dev": "tsx watch index.ts"`
|
|
26
|
+
* `"start": "node dist/index.js"`
|
|
27
|
+
* `"build": "tsc"`
|
|
28
|
+
* Run `npm run format:package`
|
|
29
|
+
|
|
30
|
+
4. Install dependencies:
|
|
31
|
+
* `npm --workspace ./packages/express install jaypie express @codegenie/serverless-express`
|
|
32
|
+
* `npm --workspace ./packages/express install --save-dev @types/express @types/cors`
|
|
33
|
+
* Always run `npm install`, never update package.json with dependencies from memory
|
|
34
|
+
|
|
35
|
+
5. Update TypeScript configuration:
|
|
36
|
+
* Update packages/express/tsconfig.json to include index.ts in the include array: `"include": ["src/**/*", "index.ts"]`
|
|
37
|
+
* Change exclude to: `"exclude": ["node_modules", "dist", "**/*.spec.ts"]`
|
|
38
|
+
* Test the build
|
|
39
|
+
* Ensure dist/ is in gitignore
|
|
40
|
+
|
|
41
|
+
6. Update the top-level package.json:
|
|
42
|
+
* Add `"dev:express": "npm --workspace packages/express run dev"` and `"start:express": "npm --workspace packages/express run start"`
|
|
43
|
+
* If there is no stand-alone `dev` or `start`, create a `dev` running `dev:express` and `start` running `start:express`
|
|
44
|
+
* If `dev` or `start` exist, add calls to express if it fits the goal of the current commands
|
|
45
|
+
|
|
46
|
+
## Pattern
|
|
47
|
+
|
|
48
|
+
- TypeScript with ES modules (`"type": "module"`)
|
|
49
|
+
- Handler pattern: configuration → lifecycle → processing → response
|
|
50
|
+
- Optional `handlerConfig` for shared configuration and lifecycle management
|
|
51
|
+
- Clean separation of concerns with middleware patterns
|
|
52
|
+
- Lambda-optimized Express configuration
|
|
53
|
+
|
|
54
|
+
## Structure
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
express/
|
|
58
|
+
├── package.json
|
|
59
|
+
├── tsconfig.json
|
|
60
|
+
├── vitest.config.ts
|
|
61
|
+
├── vitest.setup.ts
|
|
62
|
+
├── index.ts
|
|
63
|
+
├── src/
|
|
64
|
+
│ ├── app.ts
|
|
65
|
+
│ ├── handler.config.ts
|
|
66
|
+
│ ├── routes/
|
|
67
|
+
│ │ ├── resource.router.ts
|
|
68
|
+
│ │ └── resource/
|
|
69
|
+
│ │ ├── resourceGet.route.ts
|
|
70
|
+
│ │ └── __tests__/
|
|
71
|
+
│ │ └── resourceGet.route.spec.ts
|
|
72
|
+
│ └── types/
|
|
73
|
+
│ └── express.ts
|
|
74
|
+
└── dist/
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Local Development
|
|
78
|
+
|
|
79
|
+
### Listening on Port 8080
|
|
80
|
+
|
|
81
|
+
A local entrypoint, usually index.ts, may check `process.env.NODE_ENV === "development"` and be allowed to listen on port 8080 (preserving 3000 for front ends).
|
|
82
|
+
`npm run dev:express` should be configured to initialize this mode locally.
|
|
83
|
+
|
|
84
|
+
## Version Compatibility
|
|
85
|
+
|
|
86
|
+
Jaypie uses Express 4.
|
|
87
|
+
There is no immediately planned upgrade to Express 5.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: When asked to create a new workspace or subpackage for cdk, usually packages/cdk
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Jaypie Initialize CDK Subpackage
|
|
7
|
+
|
|
8
|
+
## Process
|
|
9
|
+
|
|
10
|
+
1. Follow Jaypie_Init_Project_Subpackage.md:
|
|
11
|
+
* Use @project-org/cdk in packages/cdk
|
|
12
|
+
* Skip the src structure
|
|
13
|
+
|
|
14
|
+
2. Copy template files:
|
|
15
|
+
* Copy `prompts/templates/cdk-subpackage/bin/cdk.ts` to `packages/cdk/bin/cdk.ts`
|
|
16
|
+
* Copy `prompts/templates/cdk-subpackage/lib/cdk-app.ts` to `packages/cdk/lib/cdk-app.ts`
|
|
17
|
+
* Copy `prompts/templates/cdk-subpackage/lib/cdk-infrastructure.ts` to `packages/cdk/lib/cdk-infrastructure.ts`
|
|
18
|
+
* Copy `prompts/templates/cdk-subpackage/cdk.json` to `packages/cdk/cdk.json`
|
|
19
|
+
|
|
20
|
+
3. Update package.json:
|
|
21
|
+
* Add `"bin": {"cdk": "dist/cdk.js"}`
|
|
22
|
+
* In `scripts`,
|
|
23
|
+
* Make `"clean": "rimfaf cdk.out",`
|
|
24
|
+
* Add `"cdk": "cdk",`
|
|
25
|
+
* Run `npm run format:package`
|
|
26
|
+
|
|
27
|
+
4. Install dependencies:
|
|
28
|
+
* `npm --workspace ./packages/cdk install @jaypie/constructs aws-cdk-lib constructs`
|
|
29
|
+
* `npm --workspace ./packages/cdk install --save-dev aws-cdk`
|
|
30
|
+
* Always run `npm install`, never update package.json with dependencies from memory
|
|
31
|
+
|
|
32
|
+
5. Update TypeScript build:
|
|
33
|
+
* Update packages/cdk/tsconfig.json and packages/cdk/vite.config.ts to build from bin and lib while creating dist/cdk.js
|
|
34
|
+
* Test the build
|
|
35
|
+
* Make sure `cdk.out` is in gitignore
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: When asked to create a new workspace or subpackage for lambdas
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Jaypie Lambda Package
|
|
7
|
+
|
|
8
|
+
Lambda package structure for AWS Lambda functions using Jaypie.
|
|
9
|
+
|
|
10
|
+
## Goal
|
|
11
|
+
|
|
12
|
+
Create AWS Lambda functions that integrate with Jaypie for event-driven processing.
|
|
13
|
+
|
|
14
|
+
## Guidelines
|
|
15
|
+
|
|
16
|
+
- Uses TypeScript with ES modules
|
|
17
|
+
- Leverages Jaypie's lambdaHandler wrapper for setup/teardown
|
|
18
|
+
- Built with Rollup for optimized deployment packages
|
|
19
|
+
- Tests with Vitest and Jaypie testkit
|
|
20
|
+
|
|
21
|
+
## Process
|
|
22
|
+
|
|
23
|
+
### 1. Setup Package Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
packages/lambda/
|
|
27
|
+
├── package.json # Define dependencies and scripts
|
|
28
|
+
├── tsconfig.json # TypeScript configuration
|
|
29
|
+
├── rollup.config.ts # Bundle configuration
|
|
30
|
+
├── vitest.config.ts # Test configuration
|
|
31
|
+
├── vitest.setup.ts # Test setup and mocks
|
|
32
|
+
└── src/
|
|
33
|
+
├── index.ts # Export handlers
|
|
34
|
+
├── worker.ts # Lambda function implementation
|
|
35
|
+
└── __tests__/ # Test files
|
|
36
|
+
└── worker.spec.ts
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Configure package.json
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"name": "@yourorg/lambda",
|
|
44
|
+
"version": "0.1.0",
|
|
45
|
+
"type": "module",
|
|
46
|
+
"main": "dist/index.js",
|
|
47
|
+
"types": "dist/index.d.ts",
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rollup --config",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"jaypie": "^1.1.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@rollup/plugin-typescript": "^12.0.0",
|
|
59
|
+
"@types/aws-lambda": "^8.10.0",
|
|
60
|
+
"rollup": "^4.0.0",
|
|
61
|
+
"typescript": "^5.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Configure TypeScript
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
"target": "ES2020",
|
|
72
|
+
"module": "ESNext",
|
|
73
|
+
"moduleResolution": "node",
|
|
74
|
+
"declaration": true,
|
|
75
|
+
"outDir": "./dist",
|
|
76
|
+
"strict": true,
|
|
77
|
+
"esModuleInterop": true
|
|
78
|
+
},
|
|
79
|
+
"include": ["src/**/*"],
|
|
80
|
+
"exclude": ["node_modules", "dist"]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 4. Configure Rollup
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import typescript from "@rollup/plugin-typescript";
|
|
88
|
+
import type { RollupOptions } from "rollup";
|
|
89
|
+
|
|
90
|
+
const config: RollupOptions[] = [
|
|
91
|
+
{
|
|
92
|
+
input: "src/worker.ts",
|
|
93
|
+
output: {
|
|
94
|
+
file: "dist/worker.js",
|
|
95
|
+
format: "es",
|
|
96
|
+
sourcemap: true
|
|
97
|
+
},
|
|
98
|
+
plugins: [
|
|
99
|
+
typescript({
|
|
100
|
+
exclude: ["**/__tests__/**/*"]
|
|
101
|
+
})
|
|
102
|
+
],
|
|
103
|
+
external: ["jaypie"]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
input: "src/index.ts",
|
|
107
|
+
output: {
|
|
108
|
+
file: "dist/index.js",
|
|
109
|
+
format: "es",
|
|
110
|
+
sourcemap: true
|
|
111
|
+
},
|
|
112
|
+
plugins: [
|
|
113
|
+
typescript({
|
|
114
|
+
exclude: ["**/__tests__/**/*"]
|
|
115
|
+
})
|
|
116
|
+
],
|
|
117
|
+
external: ["jaypie"]
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
export default config;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 5. Setup Vitest
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// vitest.config.ts
|
|
128
|
+
import { defineConfig } from "vite";
|
|
129
|
+
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
test: {
|
|
132
|
+
setupFiles: ["./vitest.setup.ts"]
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// vitest.setup.ts
|
|
137
|
+
import { matchers as jaypieMatchers } from "@jaypie/testkit";
|
|
138
|
+
import * as extendedMatchers from "jest-extended";
|
|
139
|
+
import { expect, vi } from "vitest";
|
|
140
|
+
|
|
141
|
+
expect.extend(extendedMatchers);
|
|
142
|
+
expect.extend(jaypieMatchers);
|
|
143
|
+
|
|
144
|
+
vi.mock("jaypie", async () => vi.importActual("@jaypie/testkit/mock"));
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 6. Create Handler Implementation
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// src/worker.ts
|
|
151
|
+
import { lambdaHandler, log } from "jaypie";
|
|
152
|
+
import type { Context } from "jaypie";
|
|
153
|
+
|
|
154
|
+
export interface WorkerEvent {
|
|
155
|
+
message?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const handler = lambdaHandler(
|
|
159
|
+
async (event: WorkerEvent, context: Context) => {
|
|
160
|
+
log.trace("worker: start");
|
|
161
|
+
|
|
162
|
+
const message = event?.message || "Hello, world!";
|
|
163
|
+
|
|
164
|
+
log.trace("worker: processing message", { message });
|
|
165
|
+
|
|
166
|
+
const response = {
|
|
167
|
+
status: "success",
|
|
168
|
+
message,
|
|
169
|
+
timestamp: new Date().toISOString()
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
log.trace("worker: complete");
|
|
173
|
+
return response;
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "worker"
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 7. Export Handler
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// src/index.ts
|
|
185
|
+
export { handler as workerHandler } from "./worker.js";
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 8. Write Tests
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// src/__tests__/worker.spec.ts
|
|
192
|
+
import { vi, describe, it, expect, beforeEach } from "vitest";
|
|
193
|
+
import { handler, WorkerEvent } from "../worker.js";
|
|
194
|
+
import { log } from "jaypie";
|
|
195
|
+
import type { Context } from "jaypie";
|
|
196
|
+
|
|
197
|
+
vi.mock("jaypie", async () => vi.importActual("@jaypie/testkit/mock"));
|
|
198
|
+
|
|
199
|
+
describe("worker Lambda handler", () => {
|
|
200
|
+
beforeEach(() => {
|
|
201
|
+
vi.clearAllMocks();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("returns success with provided message", async () => {
|
|
205
|
+
const event: WorkerEvent = {
|
|
206
|
+
message: "Test message"
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const result = await handler(event, {} as Context);
|
|
210
|
+
|
|
211
|
+
expect(result).toHaveProperty("status", "success");
|
|
212
|
+
expect(result).toHaveProperty("message", "Test message");
|
|
213
|
+
expect(result).toHaveProperty("timestamp");
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("returns default message when none provided", async () => {
|
|
217
|
+
const event = {} as WorkerEvent;
|
|
218
|
+
|
|
219
|
+
const result = await handler(event, {} as Context);
|
|
220
|
+
|
|
221
|
+
expect(result).toHaveProperty("message", "Hello, world!");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("logs trace for operations", async () => {
|
|
225
|
+
const event: WorkerEvent = {
|
|
226
|
+
message: "Test message"
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
await handler(event, {} as Context);
|
|
230
|
+
|
|
231
|
+
expect(log.trace).toHaveBeenCalled();
|
|
232
|
+
expect(log).not.toBeCalledAboveTrace();
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 9. Build and Deploy
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Build the Lambda package
|
|
241
|
+
npm run build
|
|
242
|
+
|
|
243
|
+
# Deploy using AWS CDK or other deployment tool
|
|
244
|
+
# The Lambda handler will be referenced as "workerHandler"
|
|
245
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Monorepo setup using Jaypie conventions and utilities
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Jaypie Initialize Monorepo Project
|
|
6
|
+
|
|
7
|
+
Monorepo setup using Jaypie conventions and utilities
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
* Jaypie project opinions and tooling
|
|
12
|
+
* ESLint 9+ flat config with @jaypie/eslint
|
|
13
|
+
* NPM with Workspaces ("monorepo")
|
|
14
|
+
* TypeScript
|
|
15
|
+
* Vite and Vitest
|
|
16
|
+
|
|
17
|
+
## Guidelines
|
|
18
|
+
|
|
19
|
+
* This guide should compliment Jaypie_Project_Structure.md. The two should not conflict. Raise any conflicts with the user.
|
|
20
|
+
* Run `npm install` to get the latest version of all software and generate a package-lock.json. Do not hard-code package versions from memory.
|
|
21
|
+
* If this is the very first commit, you should make it on main. This is the only time a commit should be made and pushed on main.
|
|
22
|
+
|
|
23
|
+
## Process
|
|
24
|
+
|
|
25
|
+
1. Copy all the files from `prompts/templates/project-monorepo/` to the root directory
|
|
26
|
+
2. Edit name in "@project-org/project-name" based on user instruction or infer from the directory name
|
|
27
|
+
3. Remove the sample paths from tsconfig.base.json
|
|
28
|
+
4. Remove the sample references from tsconfig.json
|
|
29
|
+
5. Install requisite packages
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install --save-dev @jaypie/eslint @jaypie/testkit eslint rimraf sort-package-json tsx vite vite-plugin-dts vitest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Context
|
|
36
|
+
|
|
37
|
+
prompts/Jaypie_Ideal_Project_Structure.md
|
|
38
|
+
prompts/templates/project-monorepo/.gitignore
|
|
39
|
+
prompts/templates/project-monorepo/.vscode/settings.json
|
|
40
|
+
prompts/templates/project-monorepo/eslint.config.mjs
|
|
41
|
+
prompts/templates/project-monorepo/package.json
|
|
42
|
+
prompts/templates/project-monorepo/tsconfig.base.json
|
|
43
|
+
prompts/templates/project-monorepo/tsconfig.json
|
|
44
|
+
prompts/templates/project-monorepo/vitest.workspace.js
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a subpackage within an existing monorepo project
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Jaypie Initialize Project Subpackage
|
|
6
|
+
|
|
7
|
+
Create a subpackage within an existing monorepo project.
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
* TypeScript subpackage with Vite/Vitest
|
|
12
|
+
* Standard Jaypie project structure
|
|
13
|
+
* NPM workspace integration
|
|
14
|
+
* ESLint configuration inheritance
|
|
15
|
+
|
|
16
|
+
## Guidelines
|
|
17
|
+
|
|
18
|
+
* Follow Jaypie_Project_Structure.md conventions
|
|
19
|
+
* Subpackage names follow "@project-org/package-name" pattern
|
|
20
|
+
* Use `"version": "0.0.1"`, `"type": "module"`, and `"private": true`
|
|
21
|
+
* Place packages in `packages/<package-name>/` directory
|
|
22
|
+
|
|
23
|
+
## Process
|
|
24
|
+
|
|
25
|
+
1. Create package directory structure:
|
|
26
|
+
```
|
|
27
|
+
packages/<package-name>/
|
|
28
|
+
├── src/
|
|
29
|
+
├── package.json
|
|
30
|
+
└── tsconfig.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. Copy template files:
|
|
34
|
+
* Copy `prompts/templates/project-subpackage/package.json` to `packages/<package-name>/package.json`
|
|
35
|
+
* Copy `prompts/templates/project-subpackage/tsconfig.json` to `packages/<package-name>/tsconfig.json`
|
|
36
|
+
* Copy `prompts/templates/project-subpackage/vite.config.ts` to `packages/<package-name>/vite.config.ts`
|
|
37
|
+
* Copy `prompts/templates/project-subpackage/vitest.config.ts` to `packages/<package-name>/vitest.config.ts`
|
|
38
|
+
* Copy `prompts/templates/project-subpackage/vitest.setup.ts` to `packages/<package-name>/vitest.setup.ts`
|
|
39
|
+
|
|
40
|
+
3. Update package.json:
|
|
41
|
+
* Edit name from "@project-org/project-name" to "@project-org/<package-name>"
|
|
42
|
+
* Keep all other fields as-is from template
|
|
43
|
+
|
|
44
|
+
4. Create basic src structure:
|
|
45
|
+
* Create `src/index.ts` with basic export
|
|
46
|
+
* Create `src/index.spec.ts` with basic test
|
|
47
|
+
|
|
48
|
+
5. Update workspace configuration:
|
|
49
|
+
* Update `references` in root `tsconfig.json`
|
|
50
|
+
* Update `paths` in root `tsconfig.base.json`
|
|
51
|
+
* Add package path to root `vitest.workspace.js`
|
|
52
|
+
* Remove wildcards from `vitest.workspace.js` if present
|
|
53
|
+
|
|
54
|
+
6. Install requested software:
|
|
55
|
+
* Always use `npm --workspace ./packages/new-package install`
|
|
56
|
+
* Never edit `package.json` from memory
|
|
57
|
+
|
|
58
|
+
## Context
|
|
59
|
+
|
|
60
|
+
prompts/prompts/Jaypie_Project_Structure.md
|
|
61
|
+
prompts/templates/project-monorepo/tsconfig.base.json
|
|
62
|
+
prompts/templates/project-subpackage/package.json
|
|
63
|
+
prompts/templates/project-subpackage/tsconfig.json
|
|
64
|
+
prompts/templates/project-subpackage/vite.config.ts
|
|
65
|
+
prompts/templates/project-subpackage/vitest.config.ts
|
|
66
|
+
prompts/templates/project-subpackage/vitest.setup.ts
|
|
67
|
+
package.json
|
|
68
|
+
tsconfig.json
|
|
69
|
+
tsconfig.base.json
|
|
70
|
+
vitest.workspace.js
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Old conventions repositories should update and the new conventions they should follow
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Jaypie Legacy Patterns
|
|
6
|
+
|
|
7
|
+
## TypeScript, Not Vanilla JavaScript
|
|
8
|
+
|
|
9
|
+
## Vite for Builds
|
|
10
|
+
|
|
11
|
+
Subpackage `build` script should run `vite build && tsc --emitDeclarationOnly`
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Calling OpenAI and other provider LLM functions from Jaypie, specifically using Jaypie's Llm class and Llm.operate() function
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# LLM Calls with Jaypie 🗣️
|
|
7
|
+
|
|
8
|
+
Streamline API calls with multi-model capabilities
|
|
9
|
+
|
|
10
|
+
## Types
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
export interface LlmProvider {
|
|
14
|
+
operate(
|
|
15
|
+
input: string | LlmHistory | LlmInputMessage,
|
|
16
|
+
options?: LlmOperateOptions,
|
|
17
|
+
): Promise<LlmOperateResponse>;
|
|
18
|
+
send(
|
|
19
|
+
message: string,
|
|
20
|
+
options?: LlmMessageOptions,
|
|
21
|
+
): Promise<string | JsonObject>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LlmOperateOptions {
|
|
25
|
+
data?: NaturalMap;
|
|
26
|
+
explain?: boolean;
|
|
27
|
+
format?: JsonObject | NaturalSchema | z.ZodType;
|
|
28
|
+
history?: LlmHistory;
|
|
29
|
+
instructions?: string;
|
|
30
|
+
model?: string;
|
|
31
|
+
placeholders?: {
|
|
32
|
+
input?: boolean;
|
|
33
|
+
instructions?: boolean;
|
|
34
|
+
system?: boolean;
|
|
35
|
+
};
|
|
36
|
+
providerOptions?: JsonObject;
|
|
37
|
+
system?: string;
|
|
38
|
+
tools?: LlmTool[];
|
|
39
|
+
turns?: boolean | number;
|
|
40
|
+
user?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LlmOperateResponse {
|
|
44
|
+
content?: string | JsonObject;
|
|
45
|
+
error?: LlmError;
|
|
46
|
+
history: LlmHistory;
|
|
47
|
+
output: LlmOutput;
|
|
48
|
+
responses: JsonReturn[];
|
|
49
|
+
status: LlmResponseStatus;
|
|
50
|
+
usage: LlmUsage;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface LlmUsage {
|
|
54
|
+
input: number;
|
|
55
|
+
output: number;
|
|
56
|
+
reasoning: number;
|
|
57
|
+
total: number;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Declaring an Llm
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
import { Llm } from "jaypie";
|
|
65
|
+
|
|
66
|
+
const llm = new Llm();
|
|
67
|
+
|
|
68
|
+
const result = await llm.operate("Give me advice on Yahtzee");
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## "Operating" an Llm
|
|
72
|
+
|
|
73
|
+
operate takes an optional second object of options
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
import { Llm, toolkit } from "jaypie";
|
|
77
|
+
|
|
78
|
+
const result = await llm.operate("Take a Yahtzee turn and report the results", {
|
|
79
|
+
format: {
|
|
80
|
+
throws: Array,
|
|
81
|
+
score: Number,
|
|
82
|
+
category: String,
|
|
83
|
+
},
|
|
84
|
+
tools: [toolkit.roll]
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
data is an object that will be used for variable replacements in input, instruction, and system.
|
|
89
|
+
explain will pass a rationale explaining its choice to the tool call.
|
|
90
|
+
format causes structured output to follow the provided schema.
|
|
91
|
+
history is an existing llm history.
|
|
92
|
+
Calls to the same instance automatically pass history.
|
|
93
|
+
instructions are one-time instructions.
|
|
94
|
+
placeholders object toggles what data applies to.
|
|
95
|
+
providerOptions passes additional options to the provider.
|
|
96
|
+
system is a permanent starting instruction.
|
|
97
|
+
See ./Llm_Tool_with_Jaypie.md for tool formats.
|
|
98
|
+
turns disables or restricts the number of turns that can be taken.
|
|
99
|
+
user tracks the end user
|
|
100
|
+
|
|
101
|
+
## Response
|
|
102
|
+
|
|
103
|
+
content is a convenience string for the model's response.
|
|
104
|
+
content will be an object when format was passed and the provider supports structured data.
|
|
105
|
+
error will include any errors.
|
|
106
|
+
output is just the output components of full responses.
|
|
107
|
+
responses are the complete responses.
|
|
108
|
+
|
|
109
|
+
## Footnotes
|
|
110
|
+
|
|
111
|
+
Llm.operate(input, options)
|
|
112
|
+
The Llm.send function is an older version replaced by operate.
|
|
113
|
+
Llm.send's `response` option is `format` in operate.
|