@hazeljs/cli 2.0.6 → 2.0.7

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": "2.0.6",
7
+ "version": "2.0.7",
8
8
  "description": "CLI for generating HazelJS components and applications"
9
9
  },
10
10
  "commands": [
@@ -156,7 +156,7 @@ Wire real \`@Tool\` / Skillgate handlers in your Hazel app for production behavi
156
156
  `,
157
157
  };
158
158
  }
159
- function agentOsOpsFiles(npm, projectName) {
159
+ function agentOsOpsFiles(npm, _projectName) {
160
160
  const deployment = npm;
161
161
  const hpaName = `${npm}-hpa`;
162
162
  return {
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * `hazel organism` — inspect / control organism snapshots (Phase 1).
4
+ * Live runtime control uses the programmatic API; CLI reads/writes local snapshots.
5
+ */
6
+ export declare function registerOrganismCommand(program: Command): void;
@@ -0,0 +1,214 @@
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.registerOrganismCommand = registerOrganismCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const DEFAULT_STORE = path.join('.hazel', 'organisms.json');
40
+ function loadStore(storePath) {
41
+ const resolved = path.resolve(storePath);
42
+ if (!fs.existsSync(resolved))
43
+ return {};
44
+ try {
45
+ return JSON.parse(fs.readFileSync(resolved, 'utf8'));
46
+ }
47
+ catch {
48
+ return {};
49
+ }
50
+ }
51
+ function saveStore(storePath, data) {
52
+ const resolved = path.resolve(storePath);
53
+ fs.mkdirSync(path.dirname(resolved), { recursive: true });
54
+ fs.writeFileSync(resolved, JSON.stringify(data, null, 2));
55
+ }
56
+ /**
57
+ * `hazel organism` — inspect / control organism snapshots (Phase 1).
58
+ * Live runtime control uses the programmatic API; CLI reads/writes local snapshots.
59
+ */
60
+ function registerOrganismCommand(program) {
61
+ const org = program.command('organism').description('Agentic Organism Runtime commands');
62
+ org
63
+ .command('list')
64
+ .description('List known organisms from the local snapshot store')
65
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
66
+ .option('--json', 'Print JSON')
67
+ .action((opts) => {
68
+ const data = loadStore(opts.store);
69
+ const rows = Object.values(data);
70
+ if (opts.json) {
71
+ console.log(JSON.stringify({ organisms: rows }, null, 2));
72
+ return;
73
+ }
74
+ if (!rows.length) {
75
+ console.log('No organisms found. Use createOrganism() then persist a snapshot.');
76
+ return;
77
+ }
78
+ for (const r of rows) {
79
+ console.log(`${r.id}\t${r.status}\t${r.mission.objective}`);
80
+ }
81
+ });
82
+ org
83
+ .command('inspect <id>')
84
+ .description('Inspect an organism snapshot')
85
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
86
+ .option('--json', 'Print JSON')
87
+ .action((id, opts) => {
88
+ const data = loadStore(opts.store);
89
+ const snap = data[id];
90
+ if (!snap) {
91
+ console.error(`Organism not found: ${id}`);
92
+ process.exitCode = 1;
93
+ return;
94
+ }
95
+ console.log(opts.json ? JSON.stringify(snap, null, 2) : formatInspect(snap));
96
+ });
97
+ org
98
+ .command('agents <id>')
99
+ .description('List agents for an organism')
100
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
101
+ .option('--json', 'Print JSON')
102
+ .action((id, opts) => {
103
+ const snap = loadStore(opts.store)[id];
104
+ if (!snap) {
105
+ console.error(`Organism not found: ${id}`);
106
+ process.exitCode = 1;
107
+ return;
108
+ }
109
+ if (opts.json) {
110
+ console.log(JSON.stringify({ agents: snap.agents }, null, 2));
111
+ return;
112
+ }
113
+ for (const a of snap.agents) {
114
+ console.log(`${a.id}\t${a.status}\tgen=${a.generation}\t${a.name ?? ''}`);
115
+ }
116
+ });
117
+ org
118
+ .command('genealogy <id>')
119
+ .description('Show agent genealogy')
120
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
121
+ .option('--json', 'Print JSON')
122
+ .action((id, opts) => {
123
+ const snap = loadStore(opts.store)[id];
124
+ if (!snap) {
125
+ console.error(`Organism not found: ${id}`);
126
+ process.exitCode = 1;
127
+ return;
128
+ }
129
+ console.log(opts.json
130
+ ? JSON.stringify(snap.genealogy ?? [], null, 2)
131
+ : JSON.stringify(snap.genealogy ?? [], null, 2));
132
+ });
133
+ org
134
+ .command('resources <id>')
135
+ .description('Show organism resource pool')
136
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
137
+ .option('--json', 'Print JSON')
138
+ .action((id, opts) => {
139
+ const snap = loadStore(opts.store)[id];
140
+ if (!snap) {
141
+ console.error(`Organism not found: ${id}`);
142
+ process.exitCode = 1;
143
+ return;
144
+ }
145
+ console.log(JSON.stringify(snap.resources ?? {}, null, 2));
146
+ });
147
+ org
148
+ .command('events <id>')
149
+ .description('Show recent organism events')
150
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
151
+ .option('--json', 'Print JSON')
152
+ .action((id, opts) => {
153
+ const snap = loadStore(opts.store)[id];
154
+ if (!snap) {
155
+ console.error(`Organism not found: ${id}`);
156
+ process.exitCode = 1;
157
+ return;
158
+ }
159
+ console.log(JSON.stringify(snap.events ?? [], null, 2));
160
+ });
161
+ for (const action of ['pause', 'resume', 'stop']) {
162
+ org
163
+ .command(`${action} <id>`)
164
+ .description(`${action} an organism snapshot (status flag only in Phase 1 CLI)`)
165
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
166
+ .action((id, opts) => {
167
+ const data = loadStore(opts.store);
168
+ const snap = data[id];
169
+ if (!snap) {
170
+ console.error(`Organism not found: ${id}`);
171
+ process.exitCode = 1;
172
+ return;
173
+ }
174
+ snap.status =
175
+ action === 'pause' ? 'paused' : action === 'resume' ? 'operating' : 'terminated';
176
+ snap.updatedAt = new Date().toISOString();
177
+ data[id] = snap;
178
+ saveStore(opts.store, data);
179
+ console.log(`Organism ${id} marked ${snap.status}`);
180
+ });
181
+ }
182
+ org
183
+ .command('save-snapshot')
184
+ .description('Helper: write a minimal demo snapshot for CLI testing')
185
+ .option('--store <path>', 'Snapshot store path', DEFAULT_STORE)
186
+ .option('--id <id>', 'Organism id', 'demo-org')
187
+ .action((opts) => {
188
+ const data = loadStore(opts.store);
189
+ data[opts.id] = {
190
+ id: opts.id,
191
+ status: 'operating',
192
+ mission: {
193
+ id: 'demo',
194
+ objective: 'Operate customer support while maintaining 90% CSAT',
195
+ },
196
+ agents: [],
197
+ genealogy: [],
198
+ resources: { tokensRemaining: 5000000 },
199
+ events: [],
200
+ updatedAt: new Date().toISOString(),
201
+ };
202
+ saveStore(opts.store, data);
203
+ console.log(`Wrote snapshot ${opts.id} to ${opts.store}`);
204
+ });
205
+ }
206
+ function formatInspect(snap) {
207
+ return [
208
+ `id: ${snap.id}`,
209
+ `status: ${snap.status}`,
210
+ `mission: ${snap.mission.objective}`,
211
+ `agents: ${snap.agents.length}`,
212
+ `updatedAt: ${snap.updatedAt}`,
213
+ ].join('\n');
214
+ }
package/dist/index.js CHANGED
@@ -59,6 +59,7 @@ const agent_1 = require("./commands/agent");
59
59
  const skillgate_1 = require("./commands/skillgate");
60
60
  const gatekeeper_1 = require("./commands/gatekeeper");
61
61
  const store_1 = require("./commands/store");
62
+ const organism_1 = require("./commands/organism");
62
63
  // Read version from package.json to ensure consistency
63
64
  const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json'), 'utf8'));
64
65
  const program = new commander_1.Command();
@@ -77,6 +78,7 @@ program
77
78
  (0, skillgate_1.registerSkillgateCommand)(program);
78
79
  (0, gatekeeper_1.registerGatekeeperCommand)(program);
79
80
  (0, store_1.registerStoreCommand)(program);
81
+ (0, organism_1.registerOrganismCommand)(program);
80
82
  // Generate command group (unified: hazel g <type> <name> [--path] [--dry-run] [--json], or hazel g --list)
81
83
  const generateCommand = program
82
84
  .command('generate')
@@ -285,6 +285,26 @@ export const gatekeeper = new AgentGatekeeper({
285
285
  defaultDecision: 'deny',
286
286
  policies: [],
287
287
  });
288
+ `,
289
+ },
290
+ {
291
+ shortName: 'organism',
292
+ npm: '@hazeljs/organism',
293
+ label: 'Agentic Organism Runtime (@hazeljs/organism)',
294
+ hint: 'import { createOrganism, OrganismRuntime } from "@hazeljs/organism";\n // const organism = await createOrganism({ mission, genes, constitution })',
295
+ moduleImport: null,
296
+ moduleExpression: null,
297
+ setupTemplate: `import { createOrganism } from '@hazeljs/organism';
298
+
299
+ export async function startOrganism() {
300
+ const organism = await createOrganism({
301
+ mission: { id: 'ops', objective: 'Operate within budget and constraints' },
302
+ genes: [],
303
+ limits: { maxAgents: 10, maxGenerationDepth: 3 },
304
+ });
305
+ await organism.start();
306
+ return organism;
307
+ }
288
308
  `,
289
309
  },
290
310
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/cli",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
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,11 +31,11 @@
31
31
  "mustache": "^4.2.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@hazeljs/eval": "^2.0.6",
35
- "@hazeljs/benchmark": "^2.0.6",
36
- "@hazeljs/agent": "^2.0.6",
37
- "@hazeljs/skillgate": "^2.0.6",
38
- "@hazeljs/agent-gatekeeper": "^2.0.6"
34
+ "@hazeljs/eval": "^2.0.7",
35
+ "@hazeljs/benchmark": "^2.0.7",
36
+ "@hazeljs/agent": "^2.0.7",
37
+ "@hazeljs/skillgate": "^2.0.7",
38
+ "@hazeljs/agent-gatekeeper": "^2.0.7"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@hazeljs/eval": {
@@ -55,11 +55,11 @@
55
55
  }
56
56
  },
57
57
  "devDependencies": {
58
- "@hazeljs/eval": "^2.0.6",
59
- "@hazeljs/benchmark": "^2.0.6",
60
- "@hazeljs/agent": "^2.0.6",
61
- "@hazeljs/skillgate": "^2.0.6",
62
- "@hazeljs/agent-gatekeeper": "^2.0.6",
58
+ "@hazeljs/eval": "^2.0.7",
59
+ "@hazeljs/benchmark": "^2.0.7",
60
+ "@hazeljs/agent": "^2.0.7",
61
+ "@hazeljs/skillgate": "^2.0.7",
62
+ "@hazeljs/agent-gatekeeper": "^2.0.7",
63
63
  "@types/inquirer": "^8.2.10",
64
64
  "@types/mustache": "^4.2.5",
65
65
  "typescript": "^6.0.3"