@hazeljs/cli 1.0.4 → 1.0.6

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/cli-manifest.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Machine-readable manifest of all CLI commands and options for LLM agent tool-use",
5
5
  "cli": {
6
6
  "name": "hazel",
7
- "version": "1.0.4",
7
+ "version": "1.0.6",
8
8
  "description": "CLI for generating HazelJS components and applications"
9
9
  },
10
10
  "commands": [
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * `hazel agent install <file.dna.json>` — validate / print marketplace install plan.
4
+ * Live hot-reload happens in-process via AgentRuntime.installAgentPackage().
5
+ */
6
+ export declare function registerAgentCommand(program: Command): void;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerAgentCommand = registerAgentCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ /**
40
+ * `hazel agent install <file.dna.json>` — validate / print marketplace install plan.
41
+ * Live hot-reload happens in-process via AgentRuntime.installAgentPackage().
42
+ */
43
+ function registerAgentCommand(program) {
44
+ const agent = program.command('agent').description('Agent OS DNA / marketplace helpers');
45
+ agent
46
+ .command('install')
47
+ .description('Validate a .dna / marketplace JSON package and print install plan')
48
+ .argument('<file>', 'Path to .dna.json or marketplace package JSON')
49
+ .option('--out <dir>', 'Write normalized marketplace package JSON to directory')
50
+ .action(async (file, opts) => {
51
+ try {
52
+ const { loadMarketplacePackage, saveMarketplacePackage } = await Promise.resolve().then(() => __importStar(require('@hazeljs/agent')));
53
+ const pkg = loadMarketplacePackage(path.resolve(process.cwd(), file));
54
+ // eslint-disable-next-line no-console
55
+ console.log(JSON.stringify({
56
+ package: pkg.name,
57
+ version: pkg.version,
58
+ agent: pkg.dna.name,
59
+ tools: pkg.dna.tools.map((t) => t.name),
60
+ hasPolicies: Boolean(pkg.dna.policies?.length),
61
+ note: 'Call runtime.installAgentPackage(path) in your app to hot-reload',
62
+ }, null, 2));
63
+ if (opts.out) {
64
+ const outPath = path.join(opts.out, `${pkg.dna.name}.marketplace.json`);
65
+ saveMarketplacePackage(pkg, outPath);
66
+ // eslint-disable-next-line no-console
67
+ console.log(`Wrote ${outPath}`);
68
+ }
69
+ }
70
+ catch (e) {
71
+ // eslint-disable-next-line no-console
72
+ console.error(e);
73
+ process.exitCode = 1;
74
+ }
75
+ });
76
+ agent
77
+ .command('dna')
78
+ .description('Print / validate Agent DNA JSON')
79
+ .argument('<file>', 'Path to DNA JSON')
80
+ .action(async (file) => {
81
+ try {
82
+ const { parseDna } = await Promise.resolve().then(() => __importStar(require('@hazeljs/agent')));
83
+ const raw = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
84
+ const dna = parseDna(raw);
85
+ // eslint-disable-next-line no-console
86
+ console.log(JSON.stringify(dna, null, 2));
87
+ }
88
+ catch (e) {
89
+ // eslint-disable-next-line no-console
90
+ console.error(e);
91
+ process.exitCode = 1;
92
+ }
93
+ });
94
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * `hazel benchmark <cases.json> [--baseline <file>] [--ci]`
4
+ * Smoke / commit-compare helper. Wire real agent runners in app code via @hazeljs/benchmark.
5
+ */
6
+ export declare function registerBenchmarkCommand(program: Command): void;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerBenchmarkCommand = registerBenchmarkCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ /**
40
+ * `hazel benchmark <cases.json> [--baseline <file>] [--ci]`
41
+ * Smoke / commit-compare helper. Wire real agent runners in app code via @hazeljs/benchmark.
42
+ */
43
+ function registerBenchmarkCommand(program) {
44
+ program
45
+ .command('benchmark')
46
+ .description('Run agent benchmark cases and optionally compare to a baseline JSON')
47
+ .argument('<cases>', 'Path to benchmark cases JSON: { label?, cases: [{ id, input, expected? }] }')
48
+ .option('--baseline <file>', 'Previous BenchmarkRun JSON to compare against')
49
+ .option('--out <file>', 'Write BenchmarkRun JSON to file')
50
+ .option('--label <label>', 'Run label', 'local')
51
+ .option('--commit <sha>', 'Commit SHA label')
52
+ .option('--ci', 'Exit 1 on regressions vs baseline or failed cases')
53
+ .action(async (casesPath, opts) => {
54
+ try {
55
+ const { runBenchmark, compareBenchmarkRuns } = await Promise.resolve().then(() => __importStar(require('@hazeljs/benchmark')));
56
+ const raw = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), casesPath), 'utf8'));
57
+ const run = await runBenchmark({
58
+ label: opts.label ?? raw.label ?? 'local',
59
+ commit: opts.commit,
60
+ cases: raw.cases,
61
+ run: async (input, id) => {
62
+ const expected = raw.cases.find((c) => c.id === id)?.expected;
63
+ // Smoke runner: score 1 if expected substring matches input echo, else 0.5
64
+ const output = input;
65
+ const score = expected == null
66
+ ? 1
67
+ : output.toLowerCase().includes(expected.toLowerCase())
68
+ ? 1
69
+ : 0;
70
+ return { score, durationMs: 0, passed: score >= 0.7 };
71
+ },
72
+ });
73
+ // eslint-disable-next-line no-console
74
+ console.log(JSON.stringify({
75
+ label: run.label,
76
+ commit: run.commit,
77
+ averageScore: run.averageScore,
78
+ passRate: run.passRate,
79
+ cases: run.cases.length,
80
+ }, null, 2));
81
+ if (opts.out) {
82
+ fs.writeFileSync(path.resolve(process.cwd(), opts.out), JSON.stringify(run, null, 2));
83
+ }
84
+ if (opts.baseline) {
85
+ const baseline = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), opts.baseline), 'utf8'));
86
+ const cmp = compareBenchmarkRuns(baseline, run);
87
+ // eslint-disable-next-line no-console
88
+ console.log(JSON.stringify({
89
+ scoreDelta: cmp.scoreDelta,
90
+ passRateDelta: cmp.passRateDelta,
91
+ regressions: cmp.regressions,
92
+ improvements: cmp.improvements,
93
+ }, null, 2));
94
+ if (opts.ci && cmp.regressions.length > 0) {
95
+ process.exitCode = 1;
96
+ }
97
+ }
98
+ if (opts.ci && run.passRate < 1) {
99
+ process.exitCode = 1;
100
+ }
101
+ }
102
+ catch (e) {
103
+ // eslint-disable-next-line no-console
104
+ console.error(e);
105
+ process.exitCode = 1;
106
+ }
107
+ });
108
+ }
package/dist/index.js CHANGED
@@ -54,6 +54,8 @@ 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
56
  const eval_1 = require("./commands/eval");
57
+ const benchmark_1 = require("./commands/benchmark");
58
+ const agent_1 = require("./commands/agent");
57
59
  // Read version from package.json to ensure consistency
58
60
  const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json'), 'utf8'));
59
61
  const program = new commander_1.Command();
@@ -67,6 +69,8 @@ program
67
69
  (0, info_1.infoCommand)(program);
68
70
  (0, add_1.addCommand)(program);
69
71
  (0, eval_1.registerEvalCommand)(program);
72
+ (0, benchmark_1.registerBenchmarkCommand)(program);
73
+ (0, agent_1.registerAgentCommand)(program);
70
74
  // Generate command group (unified: hazel g <type> <name> [--path] [--dry-run] [--json], or hazel g --list)
71
75
  const generateCommand = program
72
76
  .command('generate')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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",
@@ -31,15 +31,25 @@
31
31
  "mustache": "^4.2.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@hazeljs/eval": "^1.0.4"
34
+ "@hazeljs/eval": "^1.0.6",
35
+ "@hazeljs/benchmark": "^1.0.6",
36
+ "@hazeljs/agent": "^1.0.6"
35
37
  },
36
38
  "peerDependenciesMeta": {
37
39
  "@hazeljs/eval": {
38
40
  "optional": true
41
+ },
42
+ "@hazeljs/benchmark": {
43
+ "optional": true
44
+ },
45
+ "@hazeljs/agent": {
46
+ "optional": true
39
47
  }
40
48
  },
41
49
  "devDependencies": {
42
- "@hazeljs/eval": "^1.0.4",
50
+ "@hazeljs/eval": "^1.0.6",
51
+ "@hazeljs/benchmark": "^1.0.6",
52
+ "@hazeljs/agent": "^1.0.6",
43
53
  "@types/inquirer": "^8.2.12",
44
54
  "@types/jest": "^29.5.14",
45
55
  "@types/mustache": "^4.2.6",