@hazeljs/cli 0.7.9 → 0.8.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.
Files changed (36) hide show
  1. package/@template/.eslintrc.js +4 -18
  2. package/@template/README.md +4 -1
  3. package/@template-ai-native/HazelJS-AI-Native.postman_collection.json +503 -479
  4. package/@template-ai-native/README.md +19 -5
  5. package/@template-ai-native/package.json +1 -1
  6. package/@template-ai-native/prisma/seed.ts +16 -9
  7. package/@template-ai-native/src/agent/agent.controller.ts +20 -8
  8. package/@template-ai-native/src/agent/travel.controller.ts +29 -9
  9. package/@template-ai-native/src/rag/rag.controller.ts +34 -30
  10. package/README.md +35 -27
  11. package/cli-manifest.json +1 -1
  12. package/dist/commands/add.test.js +16 -3
  13. package/dist/commands/eval.d.ts +6 -0
  14. package/dist/commands/eval.js +65 -0
  15. package/dist/commands/generate-app.interactive-packages.test.js +2 -1
  16. package/dist/commands/generate-app.js +5 -4
  17. package/dist/commands/generate-app.new-command.test.js +3 -1
  18. package/dist/commands/generate-app.skeleton.test.js +2 -1
  19. package/dist/commands/generate-auth.js +31 -13
  20. package/dist/commands/generate-auth.test.js +8 -9
  21. package/dist/commands/generate-crud.test.js +7 -9
  22. package/dist/commands/generate-dto.test.js +4 -4
  23. package/dist/commands/generate-module.test.js +10 -10
  24. package/dist/commands/generate-simple.js +173 -19
  25. package/dist/commands/generate-simple.test.js +8 -2
  26. package/dist/commands/info.test.js +1 -3
  27. package/dist/commands/templates.d.ts +1 -0
  28. package/dist/commands/templates.js +35 -1
  29. package/dist/index.js +2 -0
  30. package/dist/index.list.test.js +7 -1
  31. package/dist/index.test.js +7 -1
  32. package/dist/utils/generator-registry.js +17 -3
  33. package/dist/utils/generator.js +3 -1
  34. package/dist/utils/generator.test.js +3 -1
  35. package/dist/utils/packages-registry.js +3 -3
  36. package/package.json +9 -5
@@ -16,7 +16,7 @@
16
16
  * here and add a config entry in generate-simple.ts.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.SERVERLESS_CLOUD_FUNCTION_TEMPLATE = exports.SERVERLESS_LAMBDA_TEMPLATE = exports.CONFIG_TEMPLATE = exports.DISCOVERY_TEMPLATE = exports.RAG_SERVICE_TEMPLATE = exports.CRON_SERVICE_TEMPLATE = exports.CACHE_SERVICE_TEMPLATE = exports.AGENT_TEMPLATE = exports.AI_SERVICE_TEMPLATE = exports.WEBSOCKET_GATEWAY_TEMPLATE = exports.REPOSITORY_TEMPLATE = exports.EXCEPTION_FILTER_TEMPLATE = exports.PIPE_TEMPLATE = exports.MIDDLEWARE_TEMPLATE = exports.INTERCEPTOR_TEMPLATE = exports.GUARD_TEMPLATE = exports.SERVICE_TEMPLATE = exports.CONTROLLER_TEMPLATE = void 0;
19
+ exports.SERVERLESS_CLOUD_FUNCTION_TEMPLATE = exports.SERVERLESS_LAMBDA_TEMPLATE = exports.CONFIG_TEMPLATE = exports.DISCOVERY_TEMPLATE = exports.RAG_PIPELINE_TEMPLATE = exports.RAG_SERVICE_TEMPLATE = exports.CRON_SERVICE_TEMPLATE = exports.CACHE_SERVICE_TEMPLATE = exports.AGENT_TEMPLATE = exports.AI_SERVICE_TEMPLATE = exports.WEBSOCKET_GATEWAY_TEMPLATE = exports.REPOSITORY_TEMPLATE = exports.EXCEPTION_FILTER_TEMPLATE = exports.PIPE_TEMPLATE = exports.MIDDLEWARE_TEMPLATE = exports.INTERCEPTOR_TEMPLATE = exports.GUARD_TEMPLATE = exports.SERVICE_TEMPLATE = exports.CONTROLLER_TEMPLATE = void 0;
20
20
  // ── Core framework generators ────────────────────────────────────────────────
21
21
  exports.CONTROLLER_TEMPLATE = `import { Controller, Get, Post, Body, Param, Delete, Put } from '@hazeljs/core';
22
22
  import { {{className}}Service } from './{{fileName}}.service';
@@ -324,6 +324,40 @@ export class {{className}}RagService {
324
324
  }
325
325
  }
326
326
  `;
327
+ exports.RAG_PIPELINE_TEMPLATE = `import { Service } from '@hazeljs/core';
328
+ import { RAGPipeline } from '@hazeljs/rag';
329
+
330
+ /**
331
+ * RAG pipeline scaffold — uses {@link RAGPipeline.from} with in-memory vectors.
332
+ * Swap persistence via HazelAI \`persistence.rag\` or construct {@link RAGPipeline} with Pinecone/Qdrant/Weaviate/Chroma.
333
+ */
334
+ @Service()
335
+ export class {{className}}RagPipelineService {
336
+ private pipeline: RAGPipeline | null = null;
337
+
338
+ async ensurePipeline(): Promise<RAGPipeline> {
339
+ if (this.pipeline) return this.pipeline;
340
+ this.pipeline = RAGPipeline.from({
341
+ provider: 'openai',
342
+ vectorStore: 'memory',
343
+ topK: 5,
344
+ chunkSize: 1000,
345
+ chunkOverlap: 200,
346
+ llm: async (prompt: string) => {
347
+ // Wire to your LLM (HazelAI, AIService, or HTTP)
348
+ return prompt;
349
+ },
350
+ });
351
+ await this.pipeline.initialize();
352
+ return this.pipeline;
353
+ }
354
+
355
+ async query(question: string) {
356
+ const p = await this.ensurePipeline();
357
+ return p.query(question);
358
+ }
359
+ }
360
+ `;
327
361
  exports.DISCOVERY_TEMPLATE = `import { Service } from '@hazeljs/core';
328
362
  import { ServiceRegistry, DiscoveryClient } from '@hazeljs/discovery';
329
363
 
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ const generate_simple_1 = require("./commands/generate-simple");
53
53
  const generator_registry_1 = require("./utils/generator-registry");
54
54
  const info_1 = require("./commands/info");
55
55
  const add_1 = require("./commands/add");
56
+ const eval_1 = require("./commands/eval");
56
57
  // Read version from package.json to ensure consistency
57
58
  const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json'), 'utf8'));
58
59
  const program = new commander_1.Command();
@@ -65,6 +66,7 @@ program
65
66
  // Utility commands
66
67
  (0, info_1.infoCommand)(program);
67
68
  (0, add_1.addCommand)(program);
69
+ (0, eval_1.registerEvalCommand)(program);
68
70
  // Generate command group (unified: hazel g <type> <name> [--path] [--dry-run] [--json], or hazel g --list)
69
71
  const generateCommand = program
70
72
  .command('generate')
@@ -11,7 +11,13 @@ jest.mock('./commands/generate-auth', () => ({ generateAuth: jest.fn() }));
11
11
  jest.mock('./commands/generate-simple', () => ({
12
12
  registerSimpleGenerators: jest.fn(),
13
13
  SIMPLE_GENERATORS: [
14
- { type: 'controller', description: 'REST controller', suffix: 'controller', template: '', nameRequired: true },
14
+ {
15
+ type: 'controller',
16
+ description: 'REST controller',
17
+ suffix: 'controller',
18
+ template: '',
19
+ nameRequired: true,
20
+ },
15
21
  ],
16
22
  findSimpleGenerator: jest.fn(),
17
23
  runSimpleGenerator: jest.fn(),
@@ -17,7 +17,13 @@ jest.mock('./commands/generate-auth');
17
17
  jest.mock('./commands/generate-simple', () => ({
18
18
  registerSimpleGenerators: jest.fn(),
19
19
  SIMPLE_GENERATORS: [
20
- { type: 'controller', description: 'REST controller', suffix: 'controller', template: '', nameRequired: true },
20
+ {
21
+ type: 'controller',
22
+ description: 'REST controller',
23
+ suffix: 'controller',
24
+ template: '',
25
+ nameRequired: true,
26
+ },
21
27
  ],
22
28
  findSimpleGenerator: jest.fn(),
23
29
  runSimpleGenerator: jest.fn(),
@@ -11,11 +11,25 @@ const generate_app_1 = require("../commands/generate-app");
11
11
  const generate_simple_1 = require("../commands/generate-simple");
12
12
  /** Complex generators that need their own files (multi-file output or custom logic) */
13
13
  const COMPLEX_GENERATORS = [
14
- { type: 'app', description: 'Skeleton HazelJS application (minimal template)', nameRequired: true, options: ['path'] },
14
+ {
15
+ type: 'app',
16
+ description: 'Skeleton HazelJS application (minimal template)',
17
+ nameRequired: true,
18
+ options: ['path'],
19
+ },
15
20
  { type: 'module', description: 'Module with controller, service, DTOs', nameRequired: true },
16
21
  { type: 'dto', description: 'Create and update DTOs', nameRequired: true },
17
- { type: 'crud', description: 'Full CRUD resource (controller, service, module, DTOs)', nameRequired: true, options: ['route'] },
18
- { type: 'auth', description: 'Auth module (JWT guard, service, controller, DTOs)', nameRequired: false },
22
+ {
23
+ type: 'crud',
24
+ description: 'Full CRUD resource (controller, service, module, DTOs)',
25
+ nameRequired: true,
26
+ options: ['route'],
27
+ },
28
+ {
29
+ type: 'auth',
30
+ description: 'Auth module (JWT guard, service, controller, DTOs)',
31
+ nameRequired: false,
32
+ },
19
33
  ];
20
34
  /** All available generator types and their metadata (for --list). */
21
35
  exports.GENERATOR_LIST = [
@@ -93,7 +93,9 @@ function printGenerateResult(result, options) {
93
93
  console.error(chalk_1.default.red(result.error ?? 'Generation failed'));
94
94
  return;
95
95
  }
96
- const prefix = result.dryRun ? chalk_1.default.blue('[dry-run] Would create ') : chalk_1.default.green('✓ Generated ');
96
+ const prefix = result.dryRun
97
+ ? chalk_1.default.blue('[dry-run] Would create ')
98
+ : chalk_1.default.green('✓ Generated ');
97
99
  for (const file of result.created) {
98
100
  console.log(prefix + file);
99
101
  }
@@ -75,7 +75,9 @@ describe('Generator class', () => {
75
75
  path: 'src/test',
76
76
  template: 'test template',
77
77
  });
78
- expect(mockFs.mkdirSync).toHaveBeenCalledWith(path_1.default.join(process.cwd(), 'src/test'), { recursive: true });
78
+ expect(mockFs.mkdirSync).toHaveBeenCalledWith(path_1.default.join(process.cwd(), 'src/test'), {
79
+ recursive: true,
80
+ });
79
81
  });
80
82
  it('should write file with rendered template', async () => {
81
83
  await generator.generate({
@@ -31,7 +31,7 @@ exports.HAZEL_PACKAGES = [
31
31
  label: 'Audit Logging (@hazeljs/audit)',
32
32
  hint: 'import { AuditModule, ConsoleAuditTransport } from "@hazeljs/audit";\n // AuditModule.forRoot({ transports: [new ConsoleAuditTransport()] })',
33
33
  moduleImport: "import { AuditModule, ConsoleAuditTransport } from '@hazeljs/audit';",
34
- moduleExpression: "AuditModule.forRoot({ transports: [new ConsoleAuditTransport()] })",
34
+ moduleExpression: 'AuditModule.forRoot({ transports: [new ConsoleAuditTransport()] })',
35
35
  setupTemplate: `import { AuditModule, ConsoleAuditTransport } from '@hazeljs/audit';
36
36
 
37
37
  // Add AuditModule.forRoot(...) to your HazelModule imports.
@@ -53,7 +53,7 @@ export const auditImports = [AuditModule.forRoot({ transports: [new ConsoleAudit
53
53
  label: 'OAuth - Google/Microsoft/GitHub (@hazeljs/oauth)',
54
54
  hint: 'import { OAuthModule } from "@hazeljs/oauth";\n // OAuthModule.forRoot({ providers: { google: {...}, microsoft: {...}, github: {...} } })',
55
55
  moduleImport: "import { OAuthModule } from '@hazeljs/oauth';",
56
- moduleExpression: "OAuthModule.forRoot({ providers: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, redirectUri: process.env.OAUTH_REDIRECT_URI! } } })",
56
+ moduleExpression: 'OAuthModule.forRoot({ providers: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, redirectUri: process.env.OAUTH_REDIRECT_URI! } } })',
57
57
  setupTemplate: `import { OAuthModule } from '@hazeljs/oauth';
58
58
 
59
59
  // Example (Google). Put secrets in env vars:
@@ -154,7 +154,7 @@ export const gatewayImports = [GatewayModule];
154
154
  label: 'Guardrails (@hazeljs/guardrails)',
155
155
  hint: 'import { GuardrailsModule } from "@hazeljs/guardrails";\n // GuardrailsModule.forRoot({ redactPIIByDefault: true })',
156
156
  moduleImport: "import { GuardrailsModule } from '@hazeljs/guardrails';",
157
- moduleExpression: "GuardrailsModule.forRoot({ redactPIIByDefault: true })",
157
+ moduleExpression: 'GuardrailsModule.forRoot({ redactPIIByDefault: true })',
158
158
  setupTemplate: null,
159
159
  },
160
160
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/cli",
3
- "version": "0.7.9",
3
+ "version": "0.8.1",
4
4
  "description": "Command-line interface for scaffolding and generating HazelJS applications and components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,14 +14,18 @@
14
14
  "hazel": "./dist/index.js"
15
15
  },
16
16
  "scripts": {
17
- "build": "tsc && node scripts/generate-manifest.js",
18
- "build:types": "tsc",
17
+ "build": "tsc -b && node scripts/generate-manifest.js",
18
+ "build:types": "tsc -b",
19
+ "typecheck": "tsc -b --noEmit",
19
20
  "test": "jest",
20
21
  "lint": "eslint src --ext .ts",
22
+ "lint:fix": "eslint src --ext .ts --fix",
21
23
  "format": "prettier --write \"src/**/*.ts\"",
22
- "prepare": "npm run build"
24
+ "format:check": "prettier --check \"src/**/*.ts\"",
25
+ "prepublishOnly": "npm run build"
23
26
  },
24
27
  "dependencies": {
28
+ "@hazeljs/eval": "^0.8.1",
25
29
  "chalk": "^4.1.2",
26
30
  "commander": "^11.1.0",
27
31
  "inquirer": "^8.2.7",
@@ -70,5 +74,5 @@
70
74
  "type": "opencollective",
71
75
  "url": "https://opencollective.com/hazeljs"
72
76
  },
73
- "gitHead": "28c21c509aeca3bf2d0878fbee737d906b654c67"
77
+ "gitHead": "8b7685d1250c4622f25d83992f58e13a59bb3dba"
74
78
  }