@joktec/skills 0.1.2 → 0.1.4

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.
Files changed (88) hide show
  1. package/README.md +20 -4
  2. package/bin/joktec-skills.mjs +33 -27
  3. package/dist/claude/skills/joktec-adapter-skill/SKILL.md +5 -0
  4. package/dist/claude/skills/joktec-adapter-skill/references/adapters.md +28 -0
  5. package/dist/claude/skills/joktec-broker-skill/SKILL.md +5 -0
  6. package/dist/claude/skills/joktec-broker-skill/references/brokers.md +29 -0
  7. package/dist/claude/skills/joktec-common-skill/SKILL.md +4 -0
  8. package/dist/claude/skills/joktec-common-skill/references/core.md +56 -0
  9. package/dist/claude/skills/joktec-common-skill/references/utils-cron.md +28 -0
  10. package/dist/claude/skills/joktec-database-extended-skill/SKILL.md +5 -0
  11. package/dist/claude/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  12. package/dist/claude/skills/joktec-framework-skill/SKILL.md +1 -0
  13. package/dist/claude/skills/joktec-framework-skill/references/framework-map.md +34 -0
  14. package/dist/claude/skills/joktec-integration-skill/SKILL.md +5 -0
  15. package/dist/claude/skills/joktec-integration-skill/references/integrations.md +29 -0
  16. package/dist/claude/skills/joktec-mongo-skill/SKILL.md +5 -0
  17. package/dist/claude/skills/joktec-mongo-skill/references/repository.md +43 -0
  18. package/dist/claude/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
  19. package/dist/claude/skills/joktec-mysql-skill/SKILL.md +7 -1
  20. package/dist/claude/skills/joktec-mysql-skill/references/entities.md +100 -0
  21. package/dist/claude/skills/joktec-mysql-skill/references/repository.md +49 -0
  22. package/dist/claude/skills/joktec-tool-skill/SKILL.md +5 -0
  23. package/dist/claude/skills/joktec-tool-skill/references/tools.md +35 -0
  24. package/dist/codex/skills/joktec-adapter-skill/SKILL.md +5 -0
  25. package/dist/codex/skills/joktec-adapter-skill/references/adapters.md +28 -0
  26. package/dist/codex/skills/joktec-broker-skill/SKILL.md +5 -0
  27. package/dist/codex/skills/joktec-broker-skill/references/brokers.md +29 -0
  28. package/dist/codex/skills/joktec-common-skill/SKILL.md +4 -0
  29. package/dist/codex/skills/joktec-common-skill/references/core.md +56 -0
  30. package/dist/codex/skills/joktec-common-skill/references/utils-cron.md +28 -0
  31. package/dist/codex/skills/joktec-database-extended-skill/SKILL.md +5 -0
  32. package/dist/codex/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  33. package/dist/codex/skills/joktec-framework-skill/SKILL.md +1 -0
  34. package/dist/codex/skills/joktec-framework-skill/references/framework-map.md +34 -0
  35. package/dist/codex/skills/joktec-integration-skill/SKILL.md +5 -0
  36. package/dist/codex/skills/joktec-integration-skill/references/integrations.md +29 -0
  37. package/dist/codex/skills/joktec-mongo-skill/SKILL.md +5 -0
  38. package/dist/codex/skills/joktec-mongo-skill/references/repository.md +43 -0
  39. package/dist/codex/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
  40. package/dist/codex/skills/joktec-mysql-skill/SKILL.md +7 -1
  41. package/dist/codex/skills/joktec-mysql-skill/references/entities.md +100 -0
  42. package/dist/codex/skills/joktec-mysql-skill/references/repository.md +49 -0
  43. package/dist/codex/skills/joktec-tool-skill/SKILL.md +5 -0
  44. package/dist/codex/skills/joktec-tool-skill/references/tools.md +35 -0
  45. package/dist/copilot/.github/copilot-instructions.md +495 -1
  46. package/dist/cursor/.cursor/rules/joktec-adapter-skill.mdc +29 -0
  47. package/dist/cursor/.cursor/rules/joktec-broker-skill.mdc +30 -0
  48. package/dist/cursor/.cursor/rules/joktec-common-skill.mdc +85 -0
  49. package/dist/cursor/.cursor/rules/joktec-database-extended-skill.mdc +25 -0
  50. package/dist/cursor/.cursor/rules/joktec-framework-skill.mdc +35 -0
  51. package/dist/cursor/.cursor/rules/joktec-integration-skill.mdc +30 -0
  52. package/dist/cursor/.cursor/rules/joktec-mongo-skill.mdc +73 -0
  53. package/dist/cursor/.cursor/rules/joktec-mysql-skill.mdc +152 -1
  54. package/dist/cursor/.cursor/rules/joktec-tool-skill.mdc +36 -0
  55. package/dist/gemini/GEMINI.md +495 -1
  56. package/dist/windsurf/.windsurf/rules/joktec-adapter-skill.md +29 -0
  57. package/dist/windsurf/.windsurf/rules/joktec-broker-skill.md +30 -0
  58. package/dist/windsurf/.windsurf/rules/joktec-common-skill.md +85 -0
  59. package/dist/windsurf/.windsurf/rules/joktec-database-extended-skill.md +25 -0
  60. package/dist/windsurf/.windsurf/rules/joktec-framework-skill.md +35 -0
  61. package/dist/windsurf/.windsurf/rules/joktec-integration-skill.md +30 -0
  62. package/dist/windsurf/.windsurf/rules/joktec-mongo-skill.md +73 -0
  63. package/dist/windsurf/.windsurf/rules/joktec-mysql-skill.md +152 -1
  64. package/dist/windsurf/.windsurf/rules/joktec-tool-skill.md +36 -0
  65. package/package.json +1 -1
  66. package/scripts/validate-skills.mjs +32 -0
  67. package/skill-pack.json +261 -52
  68. package/skills/joktec-adapter-skill/SKILL.md +5 -0
  69. package/skills/joktec-adapter-skill/references/adapters.md +28 -0
  70. package/skills/joktec-broker-skill/SKILL.md +5 -0
  71. package/skills/joktec-broker-skill/references/brokers.md +29 -0
  72. package/skills/joktec-common-skill/SKILL.md +4 -0
  73. package/skills/joktec-common-skill/references/core.md +56 -0
  74. package/skills/joktec-common-skill/references/utils-cron.md +28 -0
  75. package/skills/joktec-database-extended-skill/SKILL.md +5 -0
  76. package/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  77. package/skills/joktec-framework-skill/SKILL.md +1 -0
  78. package/skills/joktec-framework-skill/references/framework-map.md +34 -0
  79. package/skills/joktec-integration-skill/SKILL.md +5 -0
  80. package/skills/joktec-integration-skill/references/integrations.md +29 -0
  81. package/skills/joktec-mongo-skill/SKILL.md +5 -0
  82. package/skills/joktec-mongo-skill/references/repository.md +43 -0
  83. package/skills/joktec-mongo-skill/references/schema-and-plugins.md +29 -0
  84. package/skills/joktec-mysql-skill/SKILL.md +7 -1
  85. package/skills/joktec-mysql-skill/references/entities.md +100 -0
  86. package/skills/joktec-mysql-skill/references/repository.md +49 -0
  87. package/skills/joktec-tool-skill/SKILL.md +5 -0
  88. package/skills/joktec-tool-skill/references/tools.md +35 -0
@@ -12,11 +12,13 @@ Use this skill for relational resources backed by JokTec's TypeORM wrapper.
12
12
  - Treat `mysql`, `mariadb`, and `postgres` as the first-class dialects.
13
13
  - Keep `sync` explicit and normally enabled only by an owner process or development bootstrap.
14
14
  - Do not add new behavior to deprecated `MysqlFinder`; use `MysqlRepo.qb()` and `MysqlHelper` paths.
15
+ - When migrating an entity to the new schema-first decorators, migrate the whole property decorator stack, not only the TypeORM primary key decorator.
16
+ - If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
15
17
 
16
18
  ## References
17
19
 
18
20
  - Read `references/repository.md` for connection lifecycle, repository usage, query safety, transaction, and cursor behavior.
19
- - Read `references/entities.md` for `@Tables`, `@Column`, `@PrimaryColumn`, uuidv7, and dialect guidance.
21
+ - Read `references/entities.md` for `@Tables`, `@Column`, `@PrimaryColumn`, uuidv7, dialect guidance, and legacy decorator migration rules.
20
22
 
21
23
  ## Bundled References
22
24
 
@@ -24,15 +26,115 @@ Use this skill for relational resources backed by JokTec's TypeORM wrapper.
24
26
 
25
27
  # MySQL Entity Decorators
26
28
 
29
+ ## Source Lookup
30
+
31
+ When blocked, inspect:
32
+
33
+ - `packages/databases/mysql/src/decorators/table.decorator.ts`
34
+ - `packages/databases/mysql/src/decorators/column.decorator.ts`
35
+ - `packages/databases/mysql/src/decorators/columns/column.type.ts`
36
+ - `packages/databases/mysql/src/decorators/columns/column.factory.ts`
37
+ - `packages/databases/mysql/src/decorators/columns/primary.column.ts`
38
+ - `packages/databases/mysql/src/decorators/columns/string.column.ts`
39
+ - `packages/databases/mysql/src/decorators/columns/number.column.ts`
40
+ - `packages/databases/mysql/src/decorators/columns/transform.column.ts`
41
+ - `packages/databases/mysql/src/decorators/columns/swagger.column.ts`
42
+
27
43
  ## Schema-First Entity Pattern
28
44
 
29
45
  Use `@Tables`, `@Column`, and `@PrimaryColumn` from `@joktec/mysql` when an entity should also act as the source class for mapped DTOs.
30
46
 
47
+ The new decorators are not thin TypeORM aliases. They are schema-first wrappers that compose:
48
+
49
+ - TypeORM column/primary column metadata.
50
+ - `class-validator` behavior through `@joktec/utils` validators.
51
+ - `class-transformer` expose/exclude behavior.
52
+ - Swagger property metadata.
53
+
54
+ When migrating old entities, remove duplicate property decorators from `typeorm`, `class-validator`, `class-transformer`, and Swagger when the wrapper option can represent the same behavior.
55
+
56
+ ## Legacy Decorator Migration
57
+
58
+ Migrate a whole property at a time. Do not only replace `PrimaryGeneratedColumn`.
59
+
60
+ Common mappings:
61
+
62
+ | Legacy decorators | New decorator shape |
63
+ | --- | --- |
64
+ | `@PrimaryGeneratedColumn()` | `@PrimaryColumn('increment')` |
65
+ | `@PrimaryGeneratedColumn('uuid')` | `@PrimaryColumn('uuid')` |
66
+ | app-generated ordered UUID id | `@PrimaryColumn('uuidv7')` |
67
+ | `@Column(...)` | `@Column(...)` from `@joktec/mysql` |
68
+ | `@IsNotEmpty()` | `@Column({ required: true })` |
69
+ | `@IsOptional()` | `@Column({ required: false })` or nullable TypeORM option when storage allows null |
70
+ | `@IsEmail()` | `@Column({ isEmail: true })` |
71
+ | `@IsMobilePhone()` | `@Column({ isPhone: true })` |
72
+ | `@IsHexColor()` | `@Column({ isHexColor: true })` |
73
+ | `@IsUrl()` | `@Column({ isUrl: true })` |
74
+ | `@MinLength(n)` | `@Column({ minLength: n })` |
75
+ | `@MaxLength(n)` | `@Column({ maxLength: n })` |
76
+ | `@Min(n)` | `@Column({ min: n })` |
77
+ | `@Max(n)` | `@Column({ max: n })` |
78
+ | `@Expose()` | default behavior of `@Column(...)` |
79
+ | `@Expose({ groups })` | `@Column({ groups })` |
80
+ | `@Exclude({ toPlainOnly: true })` plus hidden Swagger | `@Column({ hidden: true })` |
81
+ | `@ApiProperty(...)` | `@Column({ swagger: ... })`, or native options such as `example`, `comment`, `deprecated`, `min`, `max`, `minLength`, `maxLength` |
82
+
83
+ Preserve decorators only when the wrapper cannot express them, by passing them through `decorators: [...]`.
84
+
85
+ Migration checklist:
86
+
87
+ - Replace TypeORM column decorators with wrappers from `@joktec/mysql`.
88
+ - Remove duplicate `class-validator` decorators when equivalent wrapper options exist.
89
+ - Remove duplicate `class-transformer` decorators when `hidden` or `groups` expresses the same behavior.
90
+ - Move Swagger examples/descriptions/limits into wrapper options where possible.
91
+ - Preserve custom validators/transforms only through `decorators: [...]`.
92
+ - Keep database-specific options such as `type`, `length`, `nullable`, `unique`, `default`, `enum`, and `comment`.
93
+ - Rebuild and run entity-related tests after migration because DTO metadata and TypeORM metadata both change.
94
+
95
+ Example migration:
96
+
97
+ ```ts
98
+ // Before
99
+ @Column({ type: 'varchar', length: 255 })
100
+ @IsEmail()
101
+ @IsNotEmpty()
102
+ @Expose()
103
+ @ApiProperty({ example: 'user@example.com' })
104
+ email!: string;
105
+
106
+ // After
107
+ @Column('varchar', {
108
+ length: 255,
109
+ required: true,
110
+ isEmail: true,
111
+ example: 'user@example.com',
112
+ })
113
+ email!: string;
114
+ ```
115
+
116
+ For hidden fields:
117
+
118
+ ```ts
119
+ // Before
120
+ @Column({ type: 'varchar', length: 255 })
121
+ @Exclude({ toPlainOnly: true })
122
+ @ApiHideProperty()
123
+ password!: string;
124
+
125
+ // After
126
+ @Column('varchar', { length: 255, hidden: true })
127
+ password!: string;
128
+ ```
129
+
31
130
  ## Primary Keys
32
131
 
33
132
  - Prefer numeric auto-increment keys for write-heavy MySQL tables.
34
133
  - Use UUIDs when the app needs globally unique or public identifiers.
35
134
  - Prefer `uuidv7` over random UUIDs when the id participates in ordered indexes or cursor-like access.
135
+ - When switching from UUID v4 to uuidv7, verify downstream code does not assume random UUID ordering.
136
+
137
+ Do not blindly convert every primary key to uuidv7. Keep numeric increment keys when the table is internal, write-heavy, and does not need public/global identifiers.
36
138
 
37
139
  ## Dialects
38
140
 
@@ -42,24 +144,73 @@ The stable dialects are MySQL, MariaDB, and Postgres. Dialect capabilities own d
42
144
 
43
145
  # MySQL Repository Usage
44
146
 
147
+ ## Source Lookup
148
+
149
+ When blocked, inspect:
150
+
151
+ - `packages/databases/mysql/README.md`
152
+ - `packages/databases/mysql/AGENTS.md`
153
+ - `packages/databases/mysql/src/index.ts`
154
+ - `packages/databases/mysql/src/mysql.module.ts`
155
+ - `packages/databases/mysql/src/mysql.service.ts`
156
+ - `packages/databases/mysql/src/mysql.repo.ts`
157
+ - `packages/databases/mysql/src/helpers/mysql.helper.ts`
158
+ - `packages/databases/mysql/src/helpers/mysql.finder.ts`
159
+ - `packages/databases/mysql/src/services/mysql.dialect.ts`
160
+ - `packages/databases/mysql/src/models/*`
161
+
45
162
  ## Module Setup
46
163
 
47
164
  Register entities with `MysqlModule.forRoot({ conId, models: [...] })`. Use `conId` for multiple DataSources.
48
165
 
166
+ Best practice:
167
+
168
+ - Register consumer app entities in an app repository module.
169
+ - Keep `sync` disabled in request-facing processes unless the app intentionally owns schema sync.
170
+ - Use one controlled owner process for schema sync/migration in multi-process deployments.
171
+ - Preserve `conId` when resolving repositories or transaction-scoped managers.
172
+
49
173
  ## Repository Pattern
50
174
 
51
175
  Extend `MysqlRepo` and pass the entity class to the base constructor. Services can use `BaseService` when CRUD behavior follows the shared contract.
52
176
 
177
+ Repository checklist:
178
+
179
+ - Keep entity-specific SQL helpers in the app repository, not in controllers.
180
+ - Use `MysqlRepo.qb()` and repository methods for standard reads so field validation, relation loading, soft delete, and pagination stay consistent.
181
+ - Do not add new behavior to `MysqlFinder`; it is deprecated compatibility code.
182
+ - Keep read/write operations in the same transaction context when the app passes a manager or query runner.
183
+
53
184
  ## Query Safety
54
185
 
55
186
  - Validate field paths against TypeORM metadata before interpolating SQL identifiers.
56
187
  - Use parameter binding for values.
57
188
  - Keep logical operators such as `$and` and `$or` grouped through QueryBuilder behavior.
58
189
 
190
+ Anti-patterns:
191
+
192
+ - Do not interpolate user-provided field names or relation names into SQL without TypeORM metadata validation.
193
+ - Do not assume MySQL-only syntax when the package supports MySQL, MariaDB, and Postgres.
194
+ - Do not use a relation/populate path unless it maps to entity metadata.
195
+
59
196
  ## Pagination
60
197
 
61
198
  `MysqlRepo.paginate` supports page, offset, and cursor responses. Cursor mode defaults to `createdAt` plus primary key columns. Custom cursor keys must be mapped columns.
62
199
 
200
+ Cursor checklist:
201
+
202
+ - Use `createdAt + primary key` as the default stable cursor.
203
+ - Add primary keys as tie-breakers for non-unique cursor keys.
204
+ - Ensure cursor keys are indexed for hot list endpoints.
205
+ - Validate cursor payload shape before building SQL.
206
+ - Treat cursor tokens as opaque; clients should not parse them.
207
+
63
208
  ## Transactions
64
209
 
65
210
  When using transaction-scoped operations, pass the manager or query runner through repository options so pre-read and write operations use the same context.
211
+
212
+ Transaction checklist:
213
+
214
+ - Use one manager/query runner for read-modify-write flows.
215
+ - Rollback tests should prove that both pre-read dependent writes and writes are transaction-scoped.
216
+ - Avoid mixing default repositories and transaction-scoped repositories in one operation.
@@ -16,6 +16,7 @@ Use this skill for reusable utility services.
16
16
  - Use config-driven clients instead of direct ad hoc setup in app code.
17
17
  - Preserve retry, metrics, proxy, and upload behavior where the package exposes it.
18
18
  - Keep alert tokens and webhook URLs in runtime config only.
19
+ - If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
19
20
 
20
21
  ## Reference
21
22
 
@@ -27,14 +28,49 @@ Read `references/tools.md` for package-specific usage notes.
27
28
 
28
29
  # Tool Usage
29
30
 
31
+ ## Source Lookup
32
+
33
+ When blocked, inspect:
34
+
35
+ - `packages/tools/README.md`
36
+ - `packages/tools/AGENTS.md`
37
+ - `packages/tools/<package>/README.md`
38
+ - `packages/tools/<package>/src/index.ts`
39
+ - package config/module/service/helper files under `src/`
40
+
30
41
  ## HTTP
31
42
 
32
43
  Use `@joktec/http` for Axios-backed requests, uploads, proxy agent support, retry config, and metrics where exposed.
33
44
 
45
+ Best practice:
46
+
47
+ - Use the package service for outbound HTTP so retry/proxy/metrics behavior stays centralized.
48
+ - Keep external endpoint URLs and credentials in runtime config.
49
+ - Be careful with ESM/CommonJS import changes in HTTP/Axios ecosystem packages.
50
+ - Test request behavior with mocks unless the test is an explicit consumer integration scenario.
51
+
34
52
  ## File
35
53
 
36
54
  Use `@joktec/file` for shared file helpers and classification behavior instead of duplicating local utility code.
37
55
 
56
+ Best practice:
57
+
58
+ - Keep filesystem paths and temporary directories environment-specific.
59
+ - Validate upload/file inputs before passing them into business workflows.
60
+ - Use package helpers for MIME/classification behavior when consistency matters across services.
61
+
38
62
  ## Alert
39
63
 
40
64
  Use `@joktec/alert` for Slack-compatible webhook alerts. Keep webhook URLs and credentials out of source control.
65
+
66
+ Best practice:
67
+
68
+ - Treat alert messages as operational notifications, not business workflows.
69
+ - Do not leak secrets, tokens, connection strings, or personal data into alert payloads.
70
+ - `@joktec/alert` is present but less complete than core database/client packages; inspect source before depending on advanced behavior.
71
+
72
+ ## Anti-Patterns
73
+
74
+ - Do not scatter raw Axios instances across the app when `@joktec/http` should own shared behavior.
75
+ - Do not commit webhook URLs or proxy credentials.
76
+ - Do not use tool packages as hidden places for app business rules.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joktec/skills",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "Hybrid agent skill pack for using @joktec/* libraries in consumer projects.",
6
6
  "license": "MIT",
@@ -7,6 +7,32 @@ const pack = readJson(PACK_PATH);
7
7
  const { skills } = loadSkills();
8
8
 
9
9
  const skillIds = new Set(skills.map(skill => skill.id));
10
+ function readFrontmatterDependencies(raw) {
11
+ const match = raw.match(/^---\n([\s\S]*?)\n---/);
12
+ if (!match) return [];
13
+ const lines = match[1].split('\n');
14
+ const deps = [];
15
+ let inMetadata = false;
16
+ let inDependencies = false;
17
+ for (const line of lines) {
18
+ if (/^\S/.test(line)) {
19
+ inMetadata = line.trim() === 'metadata:';
20
+ inDependencies = false;
21
+ continue;
22
+ }
23
+ if (inMetadata && /^ dependencies:\s*$/.test(line)) {
24
+ inDependencies = true;
25
+ continue;
26
+ }
27
+ if (inDependencies) {
28
+ const item = line.match(/^ -\s+(.+?)\s*$/);
29
+ if (item) deps.push(item[1].trim());
30
+ else if (/^ \S/.test(line)) inDependencies = false;
31
+ }
32
+ }
33
+ return deps;
34
+ }
35
+
10
36
  for (const meta of pack.skills) {
11
37
  if (!skillIds.has(meta.id)) errors.push(`Missing skill directory for metadata id: ${meta.id}`);
12
38
  for (const dependency of meta.dependencies || []) {
@@ -38,6 +64,12 @@ for (const skill of skills) {
38
64
  if (!skill.frontmatter.description || skill.frontmatter.description.length < 80) {
39
65
  errors.push(`${skill.id}: description is missing or too short for reliable triggering`);
40
66
  }
67
+ const meta = pack.skills.find(item => item.id === skill.id);
68
+ const declaredDeps = readFrontmatterDependencies(skill.raw);
69
+ const packDeps = meta?.dependencies || [];
70
+ if (declaredDeps.join('|') !== packDeps.join('|')) {
71
+ errors.push(`${skill.id}: frontmatter metadata.dependencies must match skill-pack dependencies`);
72
+ }
41
73
 
42
74
  const refs = readReferences(skill);
43
75
  const linkedRefs = Array.from(skill.raw.matchAll(/references\/[A-Za-z0-9_.-]+\.md/g)).map(match => match[0]);