kythia-core 0.9.5-beta → 0.11.0-beta

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/README.md CHANGED
@@ -289,10 +289,105 @@ module.exports = {
289
289
 
290
290
  -----
291
291
 
292
- ## 🗄️ Database Layer (`KythiaModel` & `KythiaORM`)
292
+ ## 🗄️ Database Layer (`KythiaModel` & Migrations)
293
293
 
294
- * **`KythiaModel`:** Provides a robust caching layer out-of-the-box. Extend it for all your models. Remember to call `KythiaModel.setDependencies` once. The hybrid Redis/Map cache ensures performance and resilience. Tag-based invalidation keeps caches fresh with precision.
295
- * **`KythiaORM`:** Handles database synchronization safely. It only alters tables when necessary, preventing accidental data loss in production and speeding up development startup. Ensure all models extend `KythiaModel` and have a `static init(sequelize)` method for `KythiaORM` to discover and initialize them correctly.
294
+ The core abandons traditional `sync()` operations in favor of a robust, **Laravel-style migration system** combined with **Database Introspection**.
295
+
296
+ ### 1. `KythiaModel` (The Base Model)
297
+ * **Hybrid Caching:** Provides a zero-config caching layer. It prioritizes **Redis** for distributed caching and falls back to a local **LRU Map** if Redis is unreachable (Shard Mode aware).
298
+ * **Auto-Boot Introspection:** You don't need to define attributes manually in your model classes. The `autoBoot` method automatically introspects the database table schema to define Sequelize attributes at runtime.
299
+ * **Smart Invalidation:** Includes `afterSave`, `afterDestroy`, and `afterBulk` hooks that automatically invalidate cache entries using **tag-based sniper invalidation** (e.g., clearing `User:ID:1` also clears related queries).
300
+
301
+ ### 2. `KythiaMigrator` (Migration Engine)
302
+ * **Addon Scanning:** Automatically discovers migration files located in `addons/*/database/migrations`.
303
+ * **Laravel-Style Batching:** Uses a custom `LaravelStorage` adapter for Umzug. It tracks migration **batches** (not just files), allowing you to rollback the entire last deployment (batch) rather than one file at a time.
304
+ * **Production Safe:** Schema changes are strictly handled via migration files, eliminating the risk of accidental data loss caused by `sequelize.sync({ alter: true })` in production environments.
305
+
306
+ -----
307
+
308
+ ## �️ CLI Tools & Commands
309
+
310
+ Kythia Core comes with a powerful CLI to streamline development, database management, and localization tasks.
311
+
312
+ Run `npx kythia --help` to see all available commands.
313
+
314
+ ### Database Management
315
+
316
+ #### `migrate`
317
+ Run pending database migrations.
318
+ ```bash
319
+ npx kythia migrate
320
+ ```
321
+ **Options:**
322
+ * `-f, --fresh`: **[DANGER]** Wipe the entire database (drop all tables) and re-run all migrations from scratch.
323
+ * `-r, --rollback`: Rollback the last *batch* of migrations.
324
+
325
+ #### `make:migration`
326
+ Create a new timestamped migration file in an addon.
327
+ ```bash
328
+ npx kythia make:migration --name create_users_table --addon core
329
+ ```
330
+ **Options:**
331
+ * `--name <string>`: Name of the migration (snake_case recommended).
332
+ * `--addon <string>`: Target addon name (must exist in `addons/`).
333
+
334
+ #### `make:model`
335
+ Scaffold a new Sequelize model file in an addon.
336
+ ```bash
337
+ npx kythia make:model --name User --addon core
338
+ ```
339
+ **Options:**
340
+ * `--name <string>`: Name of the model (PascalCase recommended).
341
+ * `--addon <string>`: Target addon name.
342
+
343
+ #### `cache:clear`
344
+ Flush Redis cache. Supports multi-instance selection if `REDIS_URLS` is configured.
345
+ ```bash
346
+ npx kythia cache:clear
347
+ ```
348
+
349
+ ### Localization (i18n)
350
+
351
+ #### `lang:check`
352
+ Lint translation key usage in your code against your language files.
353
+ ```bash
354
+ npx kythia lang:check
355
+ ```
356
+ * **Static Analysis:** Uses AST parsing to find `t('key')` calls.
357
+ * **Validation:** Reports missing keys in JSON files.
358
+ * **Unused Keys:** Reports keys defined in `en.json` but never used in code.
359
+
360
+ #### `lang:translate`
361
+ Auto-translate your `en.json` to a target language using Google Gemini AI.
362
+ ```bash
363
+ npx kythia lang:translate --target ja
364
+ ```
365
+ **Options:**
366
+ * `--target <lang>`: Target language code (default: `ja`).
367
+ * **Requires:** `GEMINI_API_KEYS` in `.env`.
368
+
369
+ ### Development Utilities
370
+
371
+ #### `dev:namespace`
372
+ Automatically add or update JSDoc `@namespace` headers in all project files.
373
+ ```bash
374
+ npx kythia dev:namespace
375
+ ```
376
+ Useful for maintaining consistent file documentation and ownership headers.
377
+
378
+ #### `gen:structure`
379
+ Generate a markdown tree representation of your project structure.
380
+ ```bash
381
+ npx kythia gen:structure
382
+ ```
383
+ Outputs to `temp/structure.md`. Great for documentation or sharing context with AI.
384
+
385
+ #### `version:up`
386
+ Synchronize JSDoc `@version` tags across the project with `package.json`.
387
+ ```bash
388
+ npx kythia version:up
389
+ ```
390
+ Run this after bumping your package version to keep file headers in sync.
296
391
 
297
392
  -----
298
393
 
@@ -304,4 +399,4 @@ module.exports = {
304
399
 
305
400
  ## 📜 License
306
401
 
307
- This project is licensed under the CC BY NC 4.0 License - see the [LICENSE](./LICENSE) file for details.
402
+ This project is licensed under the CC BY NC 4.0 License - see the [LICENSE](./LICENSE) file for details.
package/changelog.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.9.6-beta](https://github.com/kenndeclouv/kythia-core/compare/v0.9.5-beta...v0.9.6-beta) (2025-11-18)
6
+
7
+
8
+ ### ✨ Added
9
+
10
+ * Enhance KythiaModel with Redis scheduling methods for adding, removing, and retrieving expired items, improving cache management and scheduling capabilities. ([b98160a](https://github.com/kenndeclouv/kythia-core/commit/b98160abfa8396e06b432c91740c62c8f3a9e084))
11
+
5
12
  ### [0.9.5-beta](https://github.com/kenndeclouv/kythia-core/compare/v0.9.4-beta.3...v0.9.5-beta) (2025-11-11)
6
13
 
7
14
 
package/index.js CHANGED
@@ -10,8 +10,6 @@ module.exports.KythiaModel = require('./src/database/KythiaModel.js');
10
10
 
11
11
  module.exports.createSequelizeInstance = require('./src/database/KythiaSequelize.js');
12
12
 
13
- module.exports.KythiaORM = require('./src/database/KythiaORM.js');
14
-
15
13
  module.exports.utils = require('./src/utils/index.js');
16
14
 
17
- module.exports.BaseCommand = require('./src/structures/BaseCommand.js')
15
+ module.exports.BaseCommand = require('./src/structures/BaseCommand.js');
package/package.json CHANGED
@@ -1,46 +1,69 @@
1
1
  {
2
- "name": "kythia-core",
3
- "version": "0.9.5-beta",
4
- "description": "Core library for the Kythia main Discord bot: extensible, modular, and scalable foundation for commands, components, and event management.",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [
10
- "kythia",
11
- "discord",
12
- "bot",
13
- "core",
14
- "framework",
15
- "addon",
16
- "commands",
17
- "components",
18
- "extensible",
19
- "modular"
20
- ],
21
- "author": {
22
- "name": "kenndeclouv",
23
- "mail": "kenndeclouv@gmail.com"
24
- },
25
- "license": "CC BY NC 4.0",
26
- "type": "commonjs",
27
- "dependencies": {
28
- "@sentry/node": "^10.10.0",
29
- "async-exit-hook": "^2.0.1",
30
- "async-mutex": "^0.5.0",
31
- "cli-color": "^2.0.4",
32
- "dotenv": "^16.6.1",
33
- "figlet": "^1.9.3",
34
- "ioredis": "^5.7.0",
35
- "json-stable-stringify": "^1.3.0",
36
- "lru-cache": "^11.2.2",
37
- "sequelize": "^6.37.7"
38
- },
39
- "peerDependencies": {
40
- "discord.js": "^14.22.1"
41
- },
42
- "repository": {
43
- "type": "git",
44
- "url": "git+https://github.com/kenndeclouv/kythia-core.git"
45
- }
2
+ "name": "kythia-core",
3
+ "version": "0.11.0-beta",
4
+ "description": "Core library for the Kythia main Discord bot: extensible, modular, and scalable foundation for commands, components, and event management.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "format": "biome format --write .",
8
+ "fix": "biome check --write .",
9
+ "prepare": "husky"
10
+ },
11
+ "lint-staged": {
12
+ "*.{js,json}": [
13
+ "biome check --write --no-errors-on-unmatched"
14
+ ]
15
+ },
16
+ "bin": {
17
+ "kythia": "./src/cli/index.js"
18
+ },
19
+ "keywords": [
20
+ "kythia",
21
+ "discord",
22
+ "bot",
23
+ "core",
24
+ "framework",
25
+ "addon",
26
+ "commands",
27
+ "components",
28
+ "extensible",
29
+ "modular"
30
+ ],
31
+ "author": {
32
+ "name": "kenndeclouv",
33
+ "email": "kenndeclouv@gmail.com"
34
+ },
35
+ "license": "CC BY NC 4.0",
36
+ "type": "commonjs",
37
+ "dependencies": {
38
+ "@babel/parser": "^7.28.5",
39
+ "@babel/traverse": "^7.28.5",
40
+ "@dotenvx/dotenvx": "^1.51.1",
41
+ "@google/genai": "^1.30.0",
42
+ "@sentry/node": "^10.10.0",
43
+ "async-exit-hook": "^2.0.1",
44
+ "async-mutex": "^0.5.0",
45
+ "cli-color": "^2.0.4",
46
+ "commander": "^14.0.2",
47
+ "dotenv": "^16.6.1",
48
+ "figlet": "^1.9.3",
49
+ "glob": "^13.0.0",
50
+ "ioredis": "^5.7.0",
51
+ "json-stable-stringify": "^1.3.0",
52
+ "lru-cache": "^11.2.2",
53
+ "picocolors": "^1.1.1",
54
+ "sequelize": "^6.37.7",
55
+ "umzug": "^3.8.2"
56
+ },
57
+ "peerDependencies": {
58
+ "discord.js": "^14.22.1"
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/kenndeclouv/kythia-core.git"
63
+ },
64
+ "devDependencies": {
65
+ "@biomejs/biome": "^2.3.7",
66
+ "husky": "^9.1.7",
67
+ "lint-staged": "^16.2.7"
68
+ }
46
69
  }