@maestro-js/agent-skills 1.0.0-alpha.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/dist/choosing-an-npm-package/SKILL.md +72 -0
- package/dist/maestro-cli/SKILL.md +257 -0
- package/dist/maestro-packages/SKILL.md +42 -0
- package/dist/maestro-packages/broadcast.md +306 -0
- package/dist/maestro-packages/cache-control.md +337 -0
- package/dist/maestro-packages/cache.md +397 -0
- package/dist/maestro-packages/config.md +203 -0
- package/dist/maestro-packages/context.md +365 -0
- package/dist/maestro-packages/crypt.md +253 -0
- package/dist/maestro-packages/db.md +391 -0
- package/dist/maestro-packages/events.md +295 -0
- package/dist/maestro-packages/exceptions.md +231 -0
- package/dist/maestro-packages/form.md +391 -0
- package/dist/maestro-packages/hash.md +248 -0
- package/dist/maestro-packages/helpers.md +249 -0
- package/dist/maestro-packages/log.md +321 -0
- package/dist/maestro-packages/mail.md +365 -0
- package/dist/maestro-packages/metrics.md +236 -0
- package/dist/maestro-packages/queue.md +284 -0
- package/dist/maestro-packages/rate-limiting.md +206 -0
- package/dist/maestro-packages/react-router-file-routes.md +337 -0
- package/dist/maestro-packages/recurring-jobs.md +353 -0
- package/dist/maestro-packages/sql.md +316 -0
- package/dist/maestro-packages/tracing.md +240 -0
- package/package.json +33 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: choosing-an-npm-package
|
|
3
|
+
description: Consult before installing any npm package, running npm install, pnpm add, or adding a new dependency to package.json. Provides the user's preferred packages for common use cases including UI components, drag and drop, rich text editing, date/time utilities, animations, styling, pattern matching, PDF generation, email templates, routing, testing, maps, and databases. Check this skill to use the preferred package instead of alternatives.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Choosing an NPM Package
|
|
7
|
+
|
|
8
|
+
Before installing any dependency, check this list for the user's preferred package. Use the preferred package unless it genuinely cannot solve the problem.
|
|
9
|
+
|
|
10
|
+
## Preferred Packages
|
|
11
|
+
|
|
12
|
+
- **Headless UI:** `react-aria-components` — accessible, unstyled primitives
|
|
13
|
+
- **Drag & Drop:** `@dnd-kit/core` — + `@dnd-kit/sortable`, `@dnd-kit/utilities`
|
|
14
|
+
- **Rich Text:** `tiptap` — + `@tiptap/react`, `@tiptap/starter-kit`
|
|
15
|
+
- **Date/Time:** `iso-fns@alpha` — ISO 8601 type-safe date/time utilities (Instant, ZonedDateTime, Duration). Use this instead of moment or date-fns.
|
|
16
|
+
- **Advanced Animations:** `motion` — layout animations, gestures
|
|
17
|
+
- **Loading Delay:** `spin-delay` — prevents flash of spinner
|
|
18
|
+
- **Styling:** `tailwindcss` — utility-first CSS framework; prefer over custom CSS or other styling solutions
|
|
19
|
+
- **Class Merging:** `tailwind-merge` — Tailwind conflict resolution
|
|
20
|
+
- **Pattern Matching:** `ts-pattern` — exhaustive matching with type narrowing
|
|
21
|
+
- **PDF Generation:** `@react-pdf/renderer` — React components to PDF
|
|
22
|
+
- **PDF Display:** `react-pdf` — display PDFs in browser
|
|
23
|
+
- **Email Templates:** `react-email` — React-based email building
|
|
24
|
+
- **Frontend Router:** `react-router` — nested routes, data loading
|
|
25
|
+
- **CLI Prompts:** `prompts` — lightweight interactive prompts for CLI questions
|
|
26
|
+
- **CLI Framework:** `sade` — smooth, fast CLI tool builder
|
|
27
|
+
- **SVG Icons:** `vite-plugin-icons-spritesheet` — generates SVG sprite sheets from icon files
|
|
28
|
+
- **Maps:** `mapbox-gl` — + `react-map-gl` for React
|
|
29
|
+
- **Unit/Integration Tests:** `beartest-js` — project test framework
|
|
30
|
+
- **E2E Tests:** `playwright` — cross-browser with auto-waiting
|
|
31
|
+
- **Database:** Prefer the MySQL driver for @maestro-js/db
|
|
32
|
+
- **@maestro-js/agent-container** — Docker-based isolated agent execution environment with patch-based sync. Use when you need to create sandboxed containers for AI agents, run code in isolated Docker environments, pull container changes back to the host working tree as patches, or manage container lifecycles. Provides create, list, kill, shell, open (VS Code), and pull operations. Containers include Node.js 22, pnpm, Claude CLI, Playwright, git, and zsh.
|
|
33
|
+
- **@maestro-js/auth** —
|
|
34
|
+
- **@maestro-js/broadcast** — "Pattern-based event routing across channels and processes using @maestro-js/broadcast. Use when working with @maestro-js/broadcast, channel patterns, broadcast listeners, event name generation, or wildcard/dynamic-segment routing. Key capabilities: define typed channels with URL-like patterns (:id, optional segments, wildcards), emit and listen for events through a pluggable driver (e.g. Events/Redis), extract params from matched patterns, generate concrete event names from patterns, and manage listener lifecycles."
|
|
35
|
+
- **@maestro-js/cache** — Key-value caching with TTL, stale-while-revalidate, distributed locking, cache-aside pattern, atomic increment/decrement, and set-if-not-exists (add) for @maestro-js/cache. Use when working with @maestro-js/cache, adding caching to services, implementing distributed locks, using the remember/SWR pattern, incrementing or decrementing counters, adding values only if absent, configuring Redis or MockRedis drivers, or following the canonical Provider pattern from service-registry.
|
|
36
|
+
- **@maestro-js/cache-control** — HTTP Cache-Control-inspired caching for async functions with caller/callee directives. Use when working with @maestro-js/cache-control. Key capabilities: wrap async functions with cacheFn to add cache-control semantics, set response directives (maxAge, staleWhileRevalidate, noStore) from the callee, set request directives (maxAge, noStore) from the caller, automatic background revalidation of stale data, in-flight request deduplication, built-in LRU cache or custom cache backends, human-readable duration strings (e.g. '5 minutes'), structured logging of all cache lifecycle events, and optional tracing integration for observability.
|
|
37
|
+
- **@maestro-js/components** —
|
|
38
|
+
- **@maestro-js/config** — Configuration loader for .env files and TypeScript/JavaScript config modules with AES-256-GCM encryption support. Use when working with @maestro-js/config, including loading config into process.env, reading/writing encrypted .env files, creating config modules, deriving computed env values, and generating encryption keys. Key capabilities: load config files, parse .env files (plaintext or encrypted), encrypt/decrypt env files, generate encryption keys, resolve config modules (named exports, default exports, sync/async functions), type-safe process.env via Config.Resolve utility type, and auto-load via node --import @maestro-js/config/load.
|
|
39
|
+
- **@maestro-js/context** — Guide for working with @maestro-js/context, a request-scoped key-value storage package backed by Node.js AsyncLocalStorage. Use when working with @maestro-js/context, adding per-request state, storing visible or hidden context values, propagating context across async boundaries, integrating context with logging or tracing, creating typed context item handles, or transferring context stores between execution scopes. Covers the Provider pattern, visible/hidden buckets, run/runWith lifecycle, createItem typed handles, getStore for context propagation, and testing patterns.
|
|
40
|
+
- **@maestro-js/crypt** — AES-256-GCM encryption and decryption with automatic key rotation for the maestro-js framework. Use when working with @maestro-js/crypt, encrypting or decrypting strings, rotating encryption keys, checking key IDs on encrypted data, or setting up field-level encryption. Key capabilities include AES-256-GCM authenticated encryption, dot-delimited cipher format with embedded key IDs, zero-downtime key rotation via previousKeys, per-call random IV generation, Provider pattern with deferred resolution, and key identification without decryption.
|
|
41
|
+
- **@maestro-js/custom-errors** —
|
|
42
|
+
- **@maestro-js/db** — Use when working with @maestro-js/db, the database access package for Maestro. Covers MySQL driver setup, parameterized SQL queries (select, insert, update, delete, scalar, statement), transactions with automatic commit/rollback, streaming results via selectIterable, connection pooling, query formatting, and the provider pattern for multiple database instances. Maestro uses raw parameterized SQL with no ORM. Depends on service-registry and log. Used by queue for message storage. Works with the sql package for query builders.
|
|
43
|
+
- **@maestro-js/events** — Guide for @maestro-js/events — a pub/sub messaging package with pluggable drivers (Redis, WebSocket, Local). Use when working with @maestro-js/events, adding event-driven communication, creating typed event handles, configuring Redis pub/sub, setting up IPC via WebSocket, using in-process local events, or integrating with the Broadcast package. Covers the Provider pattern, driver configuration, typed Event handles, listener lifecycle, and cross-package usage with service-registry and broadcast.
|
|
44
|
+
- **@maestro-js/exceptions** — Centralized exception reporting with automatic severity mapping and structured context, backed by @maestro-js/log. Use when working with @maestro-js/exceptions — reporting errors, silencing expected exceptions, attaching tags/extra metadata to error reports, or integrating exception handling into application services. Key capabilities: report exceptions with auto-detected severity (Error maps to 'error', non-Error maps to 'warn'), override log level via context, ignore/unignore specific exception instances, attach structured tags and extra data to reports. Follows the Provider pattern from @maestro-js/service-registry.
|
|
45
|
+
- **@maestro-js/file-storage** —
|
|
46
|
+
- **@maestro-js/form** — Headless React form primitives with client and server validation, hidden inputs for custom components, controlled/uncontrolled state management, and Standard Schema (Zod) FormData parsing with automatic type coercion. Use when building custom form components that need native constraint validation, server error integration, file upload handling, or type-safe FormData parsing. Provides HeadlessForm root component, useValidation/useWarningState/useControlledState/useReset hooks, HiddenInput/HiddenFileInput/HiddenSelect components, parseFormData/parseFormDataClientSide utilities, and composeValidators.
|
|
47
|
+
- **@maestro-js/hash** — Pluggable hashing and verification with driver-based backends for @maestro-js/hash. Use when working with @maestro-js/hash, hashing values, verifying hashes, detecting when a rehash is needed, or rotating signing keys. Built-in drivers: SHA256 (HMAC-SHA256 with key rotation and timing-safe comparison).
|
|
48
|
+
- **@maestro-js/helpers** — Standalone utility functions for async control flow and file handling in the @maestro-js/helpers package. Use when working with @maestro-js/helpers. Key capabilities: retry with configurable attempts/delay/backoff, sleep, withMaxConcurrency for limiting parallel executions, withRateLimit with fixed or sliding window, raceWithFallback for promise racing with default values, AsyncIterableCollection for lazy async iteration (map, filter, reduce, forEach, toArray), sanitizeFilename for safe cross-platform filenames, and withRetry for wrapping functions with retry behavior.
|
|
49
|
+
- **@maestro-js/log** — Structured logging with pluggable transports and channel-based routing for the Maestro framework. Use when working with @maestro-js/log, adding or modifying log transports, configuring log channels, filtering log messages by level or channel, integrating logging into other packages, or writing tests that capture log output. Key capabilities: create loggers with pluggable transports (console, file, Sentry, stub), route messages through named channels, filter by level and channel, override Node.js console, custom formatters, and the silence transport for suppressing output.
|
|
50
|
+
- **@maestro-js/mail** — Driver-based email sending with queued delivery, scheduled sending, and mailable templates for the @maestro-js/mail package. Use when working with @maestro-js/mail. Covers creating mail services with SendGrid/SES/MailTrap/Stub drivers, sending emails immediately or via queue, scheduling future delivery, building reusable mailable templates, processing webhook events, generating ICS calendar attachments, and testing with the stub driver.
|
|
51
|
+
- **@maestro-js/metrics** — Use when working with @maestro-js/metrics. Unified metrics collection piped through the Log transport system. Covers four metric types (counters, distributions, sets, gauges), provider setup, logger integration, Sentry transport, and custom transport authoring. Trigger on metrics emission, observability instrumentation, Sentry metrics integration, or application telemetry tasks.
|
|
52
|
+
- **@maestro-js/password** —
|
|
53
|
+
- **@maestro-js/queue** — Database-backed job queue for deferring work beyond the current request with scheduled execution, concurrency control, and distributed tracing. Use when working with @maestro-js/queue, including dispatching jobs, processing queues, configuring the db driver, writing queue consumers, handling retries/stuck jobs, integrating with mail or recurring-jobs, and understanding the queue database schema.
|
|
54
|
+
- **@maestro-js/queue2** — Database-backed job queue for deferring work beyond the current request with scheduled execution, concurrency control, and distributed tracing. Use when working with @maestro-js/queue, including dispatching jobs, processing queues, configuring the db driver, writing queue consumers, handling retries/stuck jobs, integrating with mail or recurring-jobs, and understanding the queue database schema.
|
|
55
|
+
- **@maestro-js/rate-limiting** — Per-key rate limiting with configurable decay windows. Use when enforcing attempt limits on login, API endpoints, or any action that needs throttling. Provides increment/check/clear workflow, guarded callback execution via attempt(), and ISO 8601 duration reporting. Requires a cache driver (e.g. from @maestro-js/cache).
|
|
56
|
+
- **@maestro-js/react-router-file-routes** —
|
|
57
|
+
- **@maestro-js/recurring-jobs** — Use when working with @maestro-js/recurring-jobs. Cron-based job scheduling backed by the Queue package. Covers creating recurring jobs, managing schedules, start/stop processing, rescheduling, listing jobs, and inspecting upcoming runs. Follows the Provider pattern with ServiceRegistry. Key capabilities include cron expression parsing, deduplication across process restarts, per-job dedicated queues, structured log events, and paginated execution history.
|
|
58
|
+
- **@maestro-js/session** —
|
|
59
|
+
- **@maestro-js/signed-url** — URL signing and verification with pluggable hash drivers for @maestro-js/signed-url. Use when generating tamper-proof signed URLs with expiration (e.g. file download links, email verification) or validating signed URL parameters. Accepts any hash driver compatible with @maestro-js/hash.
|
|
60
|
+
- **@maestro-js/sql** — Composable SQL query builders for dynamic WHERE clauses and Common Table Expressions (CTEs). Use when working with @maestro-js/sql, building dynamic SQL filters, constructing parameterized WHERE clauses, wrapping Db services with CTEs, or generating safe parameterized SQL fragments. Key capabilities: WhereClauseBuilder for incremental AND/OR conditions with nested sub-groups, CommonTableExpressionBuilder for wrapping a Db service so all queries auto-prepend WITH clauses, cloning builders, recursive CTEs, and dynamic parameter resolution.
|
|
61
|
+
- **@maestro-js/tracing** — Distributed tracing package built on OpenTelemetry with pluggable providers (Sentry, Maestro). Use when working with @maestro-js/tracing. Key capabilities: wrap functions for automatic span tracking, create active spans with duration measurement, proxy entire objects for tracing, serialize/deserialize trace context across process boundaries (dehydrate/hydrate), add custom log transports for span events, integrate Sentry as a tracing provider.
|
|
62
|
+
|
|
63
|
+
## General Guidance
|
|
64
|
+
|
|
65
|
+
1. **Always check the list first.** If the use case matches a category above, use that package.
|
|
66
|
+
2. **Check `@maestro-js/*` packages before external deps.** The monorepo may already provide what you need (caching, logging, queuing, mail, etc.).
|
|
67
|
+
3. **Don't install packages that overlap existing dependencies.** Check `package.json` for what's already available before adding anything new.
|
|
68
|
+
4. **When no preference is listed** for a use case, ask the user which package they prefer before installing.
|
|
69
|
+
5. **When the preferred package doesn't fit** the specific requirement, explain the gap, propose an alternative, and wait for the user's approval before installing.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
{{MAESTRO_PACKAGES}}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-cli
|
|
3
|
+
description: "Skill for the @maestro-js/cli package, the command-line interface for the Maestro framework. Use when working with @maestro-js/cli or the maestro-cli package directory. Key capabilities: database migrations (create, run, rollback, status), environment encryption/decryption, Docker database container creation, and AWS WireGuard VPN client provisioning. Trigger when adding CLI commands, modifying migration workflows, working with env encryption, or integrating new Maestro packages into the CLI."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @maestro-js/cli
|
|
7
|
+
|
|
8
|
+
CLI tool for the Maestro framework, built with [sade](https://github.com/lukeed/sade). Provides commands for database migrations, environment file encryption, Docker container creation, and AWS WireGuard client provisioning.
|
|
9
|
+
|
|
10
|
+
Binary name: `maestro`. Installed via the `bin` field in package.json as `./dist/bin.js`.
|
|
11
|
+
|
|
12
|
+
## Package Location
|
|
13
|
+
|
|
14
|
+
- Source: `packages/maestro-cli/src/`
|
|
15
|
+
- Entry point: `packages/maestro-cli/src/bin.ts`
|
|
16
|
+
- Commands: `packages/maestro-cli/src/commands/`
|
|
17
|
+
- Utilities: `packages/maestro-cli/src/utils/`
|
|
18
|
+
- No tests directory exists for this package.
|
|
19
|
+
|
|
20
|
+
## Available Commands
|
|
21
|
+
|
|
22
|
+
| Command | Description |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `maestro db:make-migration <name>` | Create a new database migration |
|
|
25
|
+
| `maestro db:migrate` | Run pending database migrations |
|
|
26
|
+
| `maestro db:rollback` | Rollback database migrations |
|
|
27
|
+
| `maestro db:status` | Show database migration status |
|
|
28
|
+
| `maestro db:make-container` | Create a Docker database container |
|
|
29
|
+
| `maestro env:generate-key` | Generate an encryption key |
|
|
30
|
+
| `maestro env:encrypt` | Encrypt a .env file |
|
|
31
|
+
| `maestro env:decrypt` | Decrypt a .env.encrypted file |
|
|
32
|
+
| `maestro aws:make-wireguard-client [id]` | Add a WireGuard client peer to a VPN server |
|
|
33
|
+
|
|
34
|
+
## Command Details
|
|
35
|
+
|
|
36
|
+
### db:make-migration
|
|
37
|
+
|
|
38
|
+
Create a new migration in `infrastructure/db-migrations/` relative to cwd. Delegates to `DbMigrations.scaffold()` from `@maestro-js/db-migrate`.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
maestro db:make-migration <name>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Generates three files: a `.ts` migration file, an `.up.sql` file, and a `.down.sql` file.
|
|
45
|
+
|
|
46
|
+
### db:migrate
|
|
47
|
+
|
|
48
|
+
Run pending database migrations. Connects to the database using resolved config (CLI flags > env vars > config file).
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
maestro db:migrate [options]
|
|
52
|
+
--host Database host (env: DB_HOST)
|
|
53
|
+
--port Database port (env: DB_PORT)
|
|
54
|
+
--user Database user (env: DB_USER)
|
|
55
|
+
--password Database password (env: DB_PASSWORD)
|
|
56
|
+
--database Database name (env: DB_DATABASE)
|
|
57
|
+
--dry-run Preview migrations without executing
|
|
58
|
+
--count Number of migrations to run
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### db:rollback
|
|
62
|
+
|
|
63
|
+
Rollback database migrations. Default count is 1.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
maestro db:rollback [options]
|
|
67
|
+
--host Database host (env: DB_HOST)
|
|
68
|
+
--port Database port (env: DB_PORT)
|
|
69
|
+
--user Database user (env: DB_USER)
|
|
70
|
+
--password Database password (env: DB_PASSWORD)
|
|
71
|
+
--database Database name (env: DB_DATABASE)
|
|
72
|
+
--dry-run Preview rollback without executing
|
|
73
|
+
--count Number of migrations to rollback (default: 1)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### db:status
|
|
77
|
+
|
|
78
|
+
Show which migrations have been applied and which are pending.
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
maestro db:status [options]
|
|
82
|
+
--host Database host (env: DB_HOST)
|
|
83
|
+
--port Database port (env: DB_PORT)
|
|
84
|
+
--user Database user (env: DB_USER)
|
|
85
|
+
--password Database password (env: DB_PASSWORD)
|
|
86
|
+
--database Database name (env: DB_DATABASE)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### db:make-container
|
|
90
|
+
|
|
91
|
+
Interactive command that prompts for database type (MySQL, PostgreSQL, Redis), container name, port, database name, and password. Pulls the Docker image and runs the container.
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
maestro db:make-container
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Supported database images: `mysql:8`, `postgres:17`, `redis:7`.
|
|
98
|
+
|
|
99
|
+
### env:generate-key
|
|
100
|
+
|
|
101
|
+
Generate an encryption key via `Config.generateEncryptionKey()` from `@maestro-js/config`. Prints the key to stdout.
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
maestro env:generate-key
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### env:encrypt
|
|
108
|
+
|
|
109
|
+
Encrypt a `.env` file to `.env.encrypted`. Requires an encryption key via `--key` flag or `MAESTRO_ENV_ENCRYPTION_KEY` env var.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
maestro env:encrypt [options]
|
|
113
|
+
--env Environment name (e.g. production, creates .env.production.encrypted)
|
|
114
|
+
--key Encryption key (env: MAESTRO_ENV_ENCRYPTION_KEY)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### env:decrypt
|
|
118
|
+
|
|
119
|
+
Decrypt a `.env.encrypted` file back to `.env`. Requires an encryption key via `--key` flag or `MAESTRO_ENV_ENCRYPTION_KEY` env var.
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
maestro env:decrypt [options]
|
|
123
|
+
--env Environment name (e.g. production)
|
|
124
|
+
--key Encryption key (env: MAESTRO_ENV_ENCRYPTION_KEY)
|
|
125
|
+
--force Overwrite existing .env file
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### aws:make-wireguard-client
|
|
129
|
+
|
|
130
|
+
Add a WireGuard client peer to an existing VPN server managed via AWS SSM Parameter Store. If no `[id]` argument is provided, lists available WireGuard configurations from SSM and prompts for selection.
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
maestro aws:make-wireguard-client [id] [options]
|
|
134
|
+
--region AWS region (env: AWS_REGION)
|
|
135
|
+
--name Label for the peer
|
|
136
|
+
--endpoint Override auto-detected server IP
|
|
137
|
+
--dns DNS for client config
|
|
138
|
+
--allowed-ips Client AllowedIPs (default: "10.0.0.0/16, 10.100.0.0/24")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Generates a WireGuard client configuration, stores the peer in SSM, and applies it on the server via SSM Run Command.
|
|
142
|
+
|
|
143
|
+
## Adding New Commands
|
|
144
|
+
|
|
145
|
+
### 1. Create the command file
|
|
146
|
+
|
|
147
|
+
Add a new file in `packages/maestro-cli/src/commands/`. Follow the existing pattern: export a single async function that receives parsed options.
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// packages/maestro-cli/src/commands/my-command.ts
|
|
151
|
+
interface Options {
|
|
152
|
+
flag?: string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function myCommand(opts: Options) {
|
|
156
|
+
// Implementation
|
|
157
|
+
console.log('Done.')
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 2. Register in bin.ts
|
|
162
|
+
|
|
163
|
+
Import the command function and register it with sade in `packages/maestro-cli/src/bin.ts`:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
import { myCommand } from './commands/my-command.ts'
|
|
167
|
+
|
|
168
|
+
prog
|
|
169
|
+
.command('namespace:my-command')
|
|
170
|
+
.describe('Short description of what it does')
|
|
171
|
+
.option('--flag', 'Description of the flag')
|
|
172
|
+
.action(myCommand)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. Command naming convention
|
|
176
|
+
|
|
177
|
+
Use colon-separated namespaces matching existing groups:
|
|
178
|
+
- `db:*` for database-related commands
|
|
179
|
+
- `env:*` for environment/config commands
|
|
180
|
+
- `aws:*` for AWS infrastructure commands
|
|
181
|
+
|
|
182
|
+
### 4. For database commands
|
|
183
|
+
|
|
184
|
+
Use the shared utilities in `packages/maestro-cli/src/utils/db.ts`:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { createDb, resolveDbConfig, type DbConnectionConfig } from '../utils/db.ts'
|
|
188
|
+
|
|
189
|
+
export async function myDbCommand(opts: Partial<DbConnectionConfig>) {
|
|
190
|
+
const config = await resolveDbConfig(opts)
|
|
191
|
+
const db = await createDb(config)
|
|
192
|
+
try {
|
|
193
|
+
// Use db...
|
|
194
|
+
} finally {
|
|
195
|
+
await db.destroy()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The `resolveDbConfig` function resolves database connection settings with this precedence: CLI flags > environment variables > config file (loaded via `@maestro-js/config` with config name `db-migrate`).
|
|
201
|
+
|
|
202
|
+
## Common Patterns
|
|
203
|
+
|
|
204
|
+
### Database config resolution
|
|
205
|
+
|
|
206
|
+
All `db:*` commands (except `db:make-migration` and `db:make-container`) share the same connection options and resolution logic from `utils/db.ts`. The `resolveDbConfig` function reads from:
|
|
207
|
+
1. CLI flags (`--host`, `--port`, `--user`, `--password`, `--database`)
|
|
208
|
+
2. Environment variables (`DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`)
|
|
209
|
+
3. Config file via `@maestro-js/config` with config name `db-migrate`
|
|
210
|
+
|
|
211
|
+
### Migration directory
|
|
212
|
+
|
|
213
|
+
All migration commands expect migrations in `infrastructure/db-migrations/` relative to the current working directory.
|
|
214
|
+
|
|
215
|
+
### Interactive prompts
|
|
216
|
+
|
|
217
|
+
The `prompts` library is used for interactive input in `db:make-container` and `aws:make-wireguard-client`. All prompt flows call `process.exit(0)` on cancellation.
|
|
218
|
+
|
|
219
|
+
### Error handling
|
|
220
|
+
|
|
221
|
+
Commands print errors to stderr via `console.error()` and call `process.exit(1)` on failure. Database commands use `try/finally` to ensure `db.destroy()` is always called.
|
|
222
|
+
|
|
223
|
+
## Cross-Package Integration
|
|
224
|
+
|
|
225
|
+
| Dependency | Usage |
|
|
226
|
+
|---|---|
|
|
227
|
+
| `@maestro-js/config` | Env encryption/decryption (`Config.generateEncryptedEnvFile`, `Config.generateDecryptedEnvFile`, `Config.generateEncryptionKey`), config file loading for DB credentials |
|
|
228
|
+
| `@maestro-js/db` | Database connection creation via `Db.Provider.create` with `Db.drivers.mysql` driver |
|
|
229
|
+
| `@maestro-js/db-migrate` | Migration operations: `DbMigrations.scaffold`, `DbMigrations.migrate`, `DbMigrations.rollback`, `DbMigrations.status` |
|
|
230
|
+
| `sade` | CLI argument parsing and command registration |
|
|
231
|
+
| `prompts` | Interactive terminal prompts for `db:make-container` and `aws:make-wireguard-client` |
|
|
232
|
+
| `@aws-sdk/client-ssm` | SSM parameter read/write and Run Command for WireGuard provisioning |
|
|
233
|
+
| `@aws-sdk/client-sts` | Caller identity resolution for default peer naming |
|
|
234
|
+
|
|
235
|
+
## Utility Modules
|
|
236
|
+
|
|
237
|
+
### utils/db.ts
|
|
238
|
+
|
|
239
|
+
Exports `resolveDbConfig`, `createDb`, and the `DbConnectionConfig` / `CliDb` interfaces. Central place for database connection setup across all db commands.
|
|
240
|
+
|
|
241
|
+
### utils/migrations.ts
|
|
242
|
+
|
|
243
|
+
Re-exports `DbMigrations` from `@maestro-js/db-migrate`.
|
|
244
|
+
|
|
245
|
+
### utils/scaffolding.ts
|
|
246
|
+
|
|
247
|
+
General-purpose file scaffolding utility (`Scaffolding.scaffold`, `Scaffolding.previewScaffold`, `Scaffolding.fromDirectory`). Supports token replacement with `{{token}}` syntax, skip-existing behavior, and reading directory trees into scaffolding objects. Not currently used by any CLI command but available for future scaffolding needs.
|
|
248
|
+
|
|
249
|
+
## Build and Development
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
pnpm --filter @maestro-js/cli build # Build with tsup
|
|
253
|
+
pnpm --filter @maestro-js/cli typecheck # Typecheck
|
|
254
|
+
pnpm --filter @maestro-js/cli watch # Watch mode
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
No tests exist for this package. When adding tests, use `beartest-js` with `expect` assertions consistent with the rest of the monorepo.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-packages
|
|
3
|
+
description: "Reference for the @maestro-js backend framework. Use when working with any @maestro-js package — caching, database, queuing, mail, logging, events, encryption, config, tracing, and more. Covers package APIs and how packages compose together."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Maestro Packages
|
|
7
|
+
|
|
8
|
+
Maestro is a modular Node.js backend framework. Each package below handles a single concern (caching, logging, database, queuing, etc.) and composes with others.
|
|
9
|
+
|
|
10
|
+
Use this skill when you need to:
|
|
11
|
+
|
|
12
|
+
- **Understand a package's API** — find the right package below and open its detail page for full documentation
|
|
13
|
+
- **Choose between packages** — decide which package solves a given problem (e.g. Cache vs CacheControl, Queue vs RecurringJobs)
|
|
14
|
+
- **Wire packages together** — understand how packages relate (e.g. Queue powers Mail delivery, Log is used by most packages, Context provides request-scoped state)
|
|
15
|
+
|
|
16
|
+
## How to use this skill
|
|
17
|
+
|
|
18
|
+
Each package has a linked detail page with its full API, driver options, and usage examples. Start by scanning the list below to find the relevant package, then open its detail page.
|
|
19
|
+
|
|
20
|
+
## Packages
|
|
21
|
+
|
|
22
|
+
- **broadcast** — "Pattern-based event routing across channels and processes using @maestro-js/broadcast. Use when working with @maestro-js/broadcast, channel patterns, broadcast listeners, event name generation, or wildcard/dynamic-segment routing. Key capabilities: define typed channels with URL-like patterns (:id, optional segments, wildcards), emit and listen for events through a pluggable driver (e.g. Events/Redis), extract params from matched patterns, generate concrete event names from patterns, and manage listener lifecycles." [View details](./broadcast.md)
|
|
23
|
+
- **cache** — Key-value caching with TTL, stale-while-revalidate, distributed locking, cache-aside pattern, atomic increment/decrement, and set-if-not-exists (add) for @maestro-js/cache. Use when working with @maestro-js/cache, adding caching to services, implementing distributed locks, using the remember/SWR pattern, incrementing or decrementing counters, adding values only if absent, configuring Redis or MockRedis drivers, or following the canonical Provider pattern from service-registry. [View details](./cache.md)
|
|
24
|
+
- **cache-control** — HTTP Cache-Control-inspired caching for async functions with caller/callee directives. Use when working with @maestro-js/cache-control. Key capabilities: wrap async functions with cacheFn to add cache-control semantics, set response directives (maxAge, staleWhileRevalidate, noStore) from the callee, set request directives (maxAge, noStore) from the caller, automatic background revalidation of stale data, in-flight request deduplication, built-in LRU cache or custom cache backends, human-readable duration strings (e.g. '5 minutes'), structured logging of all cache lifecycle events, and optional tracing integration for observability. [View details](./cache-control.md)
|
|
25
|
+
- **config** — Configuration loader for .env files and TypeScript/JavaScript config modules with AES-256-GCM encryption support. Use when working with @maestro-js/config, including loading config into process.env, reading/writing encrypted .env files, creating config modules, deriving computed env values, and generating encryption keys. Key capabilities: load config files, parse .env files (plaintext or encrypted), encrypt/decrypt env files, generate encryption keys, resolve config modules (named exports, default exports, sync/async functions), type-safe process.env via Config.Resolve utility type, and auto-load via node --import @maestro-js/config/load. [View details](./config.md)
|
|
26
|
+
- **context** — Guide for working with @maestro-js/context, a request-scoped key-value storage package backed by Node.js AsyncLocalStorage. Use when working with @maestro-js/context, adding per-request state, storing visible or hidden context values, propagating context across async boundaries, integrating context with logging or tracing, creating typed context item handles, or transferring context stores between execution scopes. Covers the Provider pattern, visible/hidden buckets, run/runWith lifecycle, createItem typed handles, getStore for context propagation, and testing patterns. [View details](./context.md)
|
|
27
|
+
- **crypt** — AES-256-GCM encryption and decryption with automatic key rotation for the maestro-js framework. Use when working with @maestro-js/crypt, encrypting or decrypting strings, rotating encryption keys, checking key IDs on encrypted data, or setting up field-level encryption. Key capabilities include AES-256-GCM authenticated encryption, dot-delimited cipher format with embedded key IDs, zero-downtime key rotation via previousKeys, per-call random IV generation, Provider pattern with deferred resolution, and key identification without decryption. [View details](./crypt.md)
|
|
28
|
+
- **db** — Use when working with @maestro-js/db, the database access package for Maestro. Covers MySQL driver setup, parameterized SQL queries (select, insert, update, delete, scalar, statement), transactions with automatic commit/rollback, streaming results via selectIterable, connection pooling, query formatting, and the provider pattern for multiple database instances. Maestro uses raw parameterized SQL with no ORM. Depends on service-registry and log. Used by queue for message storage. Works with the sql package for query builders. [View details](./db.md)
|
|
29
|
+
- **events** — Guide for @maestro-js/events — a pub/sub messaging package with pluggable drivers (Redis, WebSocket, Local). Use when working with @maestro-js/events, adding event-driven communication, creating typed event handles, configuring Redis pub/sub, setting up IPC via WebSocket, using in-process local events, or integrating with the Broadcast package. Covers the Provider pattern, driver configuration, typed Event handles, listener lifecycle, and cross-package usage with service-registry and broadcast. [View details](./events.md)
|
|
30
|
+
- **exceptions** — Centralized exception reporting with automatic severity mapping and structured context, backed by @maestro-js/log. Use when working with @maestro-js/exceptions — reporting errors, silencing expected exceptions, attaching tags/extra metadata to error reports, or integrating exception handling into application services. Key capabilities: report exceptions with auto-detected severity (Error maps to 'error', non-Error maps to 'warn'), override log level via context, ignore/unignore specific exception instances, attach structured tags and extra data to reports. Follows the Provider pattern from @maestro-js/service-registry. [View details](./exceptions.md)
|
|
31
|
+
- **form** — Headless React form primitives with client and server validation, hidden inputs for custom components, controlled/uncontrolled state management, and Standard Schema (Zod) FormData parsing with automatic type coercion. Use when building custom form components that need native constraint validation, server error integration, file upload handling, or type-safe FormData parsing. Provides HeadlessForm root component, useValidation/useWarningState/useControlledState/useReset hooks, HiddenInput/HiddenFileInput/HiddenSelect components, parseFormData/parseFormDataClientSide utilities, and composeValidators. [View details](./form.md)
|
|
32
|
+
- **hash** — Pluggable hashing and verification with driver-based backends for @maestro-js/hash. Use when working with @maestro-js/hash, hashing values, verifying hashes, detecting when a rehash is needed, or rotating signing keys. Built-in drivers: SHA256 (HMAC-SHA256 with key rotation and timing-safe comparison). [View details](./hash.md)
|
|
33
|
+
- **helpers** — Standalone utility functions for async control flow and file handling in the @maestro-js/helpers package. Use when working with @maestro-js/helpers. Key capabilities: retry with configurable attempts/delay/backoff, sleep, withMaxConcurrency for limiting parallel executions, withRateLimit with fixed or sliding window, raceWithFallback for promise racing with default values, AsyncIterableCollection for lazy async iteration (map, filter, reduce, forEach, toArray), sanitizeFilename for safe cross-platform filenames, and withRetry for wrapping functions with retry behavior. [View details](./helpers.md)
|
|
34
|
+
- **log** — Structured logging with pluggable transports and channel-based routing for the Maestro framework. Use when working with @maestro-js/log, adding or modifying log transports, configuring log channels, filtering log messages by level or channel, integrating logging into other packages, or writing tests that capture log output. Key capabilities: create loggers with pluggable transports (console, file, Sentry, stub), route messages through named channels, filter by level and channel, override Node.js console, custom formatters, and the silence transport for suppressing output. [View details](./log.md)
|
|
35
|
+
- **mail** — Driver-based email sending with queued delivery, scheduled sending, and mailable templates for the @maestro-js/mail package. Use when working with @maestro-js/mail. Covers creating mail services with SendGrid/SES/MailTrap/Stub drivers, sending emails immediately or via queue, scheduling future delivery, building reusable mailable templates, processing webhook events, generating ICS calendar attachments, and testing with the stub driver. [View details](./mail.md)
|
|
36
|
+
- **metrics** — Use when working with @maestro-js/metrics. Unified metrics collection piped through the Log transport system. Covers four metric types (counters, distributions, sets, gauges), provider setup, logger integration, Sentry transport, and custom transport authoring. Trigger on metrics emission, observability instrumentation, Sentry metrics integration, or application telemetry tasks. [View details](./metrics.md)
|
|
37
|
+
- **queue** — Database-backed job queue for deferring work beyond the current request with scheduled execution, concurrency control, and distributed tracing. Use when working with @maestro-js/queue, including dispatching jobs, processing queues, configuring the db driver, writing queue consumers, handling retries/stuck jobs, integrating with mail or recurring-jobs, and understanding the queue database schema. [View details](./queue.md)
|
|
38
|
+
- **rate-limiting** — Per-key rate limiting with configurable decay windows. Use when enforcing attempt limits on login, API endpoints, or any action that needs throttling. Provides increment/check/clear workflow, guarded callback execution via attempt(), and ISO 8601 duration reporting. Requires a cache driver (e.g. from @maestro-js/cache). [View details](./rate-limiting.md)
|
|
39
|
+
- **react-router-file-routes** — [View details](./react-router-file-routes.md)
|
|
40
|
+
- **recurring-jobs** — Use when working with @maestro-js/recurring-jobs. Cron-based job scheduling backed by the Queue package. Covers creating recurring jobs, managing schedules, start/stop processing, rescheduling, listing jobs, and inspecting upcoming runs. Follows the Provider pattern with ServiceRegistry. Key capabilities include cron expression parsing, deduplication across process restarts, per-job dedicated queues, structured log events, and paginated execution history. [View details](./recurring-jobs.md)
|
|
41
|
+
- **sql** — Composable SQL query builders for dynamic WHERE clauses and Common Table Expressions (CTEs). Use when working with @maestro-js/sql, building dynamic SQL filters, constructing parameterized WHERE clauses, wrapping Db services with CTEs, or generating safe parameterized SQL fragments. Key capabilities: WhereClauseBuilder for incremental AND/OR conditions with nested sub-groups, CommonTableExpressionBuilder for wrapping a Db service so all queries auto-prepend WITH clauses, cloning builders, recursive CTEs, and dynamic parameter resolution. [View details](./sql.md)
|
|
42
|
+
- **tracing** — Distributed tracing package built on OpenTelemetry with pluggable providers (Sentry, Maestro). Use when working with @maestro-js/tracing. Key capabilities: wrap functions for automatic span tracking, create active spans with duration measurement, proxy entire objects for tracing, serialize/deserialize trace context across process boundaries (dehydrate/hydrate), add custom log transports for span events, integrate Sentry as a tracing provider. [View details](./tracing.md)
|