kuhul-es 1.0.10 → 1.0.12

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 (2) hide show
  1. package/bin/kuhul-es.js +116 -6
  2. package/package.json +2 -2
package/bin/kuhul-es.js CHANGED
@@ -1,48 +1,158 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- // KUHUL-ES CLI
4
+ /*
5
+ * KUHUL-ES CLI
6
+ * v1.0.12 — Version Integrity + Trace Artifact
7
+ */
5
8
 
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const crypto = require('crypto');
6
12
  const { program } = require('commander');
7
13
 
14
+ // -----------------------------------------------------------------------------
15
+ // Version (single source of truth)
16
+ // -----------------------------------------------------------------------------
17
+ const pkg = require('../package.json');
18
+
19
+ // -----------------------------------------------------------------------------
20
+ // Banner
21
+ // -----------------------------------------------------------------------------
8
22
  console.log(`
9
23
  ╔══════════════════════════════════════╗
10
- ║ KUHUL-ES v1.0.10
24
+ ║ KUHUL-ES v${pkg.version}
11
25
  ║ ECMAScript syntax, KUHUL semantics ║
12
26
  ╚══════════════════════════════════════╝
13
27
  `);
14
28
 
29
+ // -----------------------------------------------------------------------------
30
+ // CLI Definition
31
+ // -----------------------------------------------------------------------------
15
32
  program
16
33
  .name('kuhul-es')
17
34
  .description('KUHUL-ES - The Trojan Horse for KUHUL semantics')
18
- .version('1.0.8');
35
+ .version(pkg.version);
19
36
 
37
+ // -----------------------------------------------------------------------------
38
+ // init
39
+ // -----------------------------------------------------------------------------
20
40
  program
21
41
  .command('init [project-name]')
22
42
  .description('Initialize a new KUHUL-ES project')
23
43
  .action((projectName = 'my-kuhul-app') => {
24
44
  console.log(`Creating project: ${projectName}`);
45
+ process.exit(0);
25
46
  });
26
47
 
48
+ // -----------------------------------------------------------------------------
49
+ // compile
50
+ // -----------------------------------------------------------------------------
27
51
  program
28
52
  .command('compile <file>')
29
53
  .description('Compile KUHUL-ES source file')
30
54
  .action((file) => {
31
55
  console.log(`Compiling: ${file}`);
56
+ process.exit(0);
32
57
  });
33
58
 
59
+ // -----------------------------------------------------------------------------
60
+ // run
61
+ // -----------------------------------------------------------------------------
34
62
  program
35
63
  .command('run <file>')
36
64
  .description('Run a KUHUL-ES program')
37
65
  .option('--record', 'Record deterministic execution trace')
38
- .option('--replay <hash>', 'Replay from a recorded trace')
66
+ .option('--replay <trace>', 'Replay from a recorded trace file')
39
67
  .action((file, options) => {
40
68
  console.log(`▶ Running: ${file}`);
41
- if (options.record) console.log('⏺ Recording execution');
42
- if (options.replay) console.log(`⏮ Replaying ${options.replay}`);
69
+
70
+ // -------------------------------------------------------------------------
71
+ // RECORD
72
+ // -------------------------------------------------------------------------
73
+ if (options.record) {
74
+ console.log('⏺ Recording execution');
75
+
76
+ const trace = {
77
+ version: pkg.version,
78
+ file,
79
+ argv: process.argv.slice(2),
80
+ cwd: process.cwd(),
81
+ timestamp: new Date().toISOString()
82
+ };
83
+
84
+ trace.hash = crypto
85
+ .createHash('sha256')
86
+ .update(JSON.stringify(trace))
87
+ .digest('hex');
88
+
89
+ const outPath = path.resolve(process.cwd(), 'trace.json');
90
+ fs.writeFileSync(outPath, JSON.stringify(trace, null, 2));
91
+
92
+ console.log(`📄 trace.json written`);
93
+ console.log(`🔑 trace hash: ${trace.hash}`);
94
+ }
95
+
96
+ // -------------------------------------------------------------------------
97
+ // REPLAY
98
+ // -------------------------------------------------------------------------
99
+ if (options.replay) {
100
+ console.log(`⏮ Replaying ${options.replay}`);
101
+
102
+ const replayPath = path.resolve(process.cwd(), options.replay);
103
+ const trace = JSON.parse(fs.readFileSync(replayPath, 'utf8'));
104
+
105
+ const expectedHash = crypto
106
+ .createHash('sha256')
107
+ .update(JSON.stringify({
108
+ ...trace,
109
+ hash: undefined
110
+ }))
111
+ .digest('hex');
112
+
113
+ if (trace.hash !== expectedHash) {
114
+ console.error('✗ Trace hash mismatch');
115
+ process.exit(1);
116
+ }
117
+
118
+ console.log(`✓ Trace verified`);
119
+ console.log(`🔑 trace hash: ${trace.hash}`);
120
+ }
121
+
43
122
  console.log('✓ Execution complete (stub)');
123
+ process.exit(0);
124
+ });
125
+
126
+ // -----------------------------------------------------------------------------
127
+ // doctor
128
+ // -----------------------------------------------------------------------------
129
+ program
130
+ .command('doctor')
131
+ .description('Run environment diagnostics for KUHUL-ES')
132
+ .action(() => {
133
+ console.log('🩺 KUHUL-ES Doctor\n');
134
+
135
+ console.log('Version:', pkg.version);
136
+ console.log('Node:', process.version);
137
+ console.log('Platform:', process.platform);
138
+ console.log('CLI path:', __filename);
139
+ console.log('CWD:', process.cwd());
140
+
141
+ try {
142
+ require.resolve('commander');
143
+ console.log('Commander: OK');
144
+ } catch {
145
+ console.log('Commander: MISSING');
146
+ process.exit(1);
147
+ }
148
+
149
+ console.log('\n✓ Diagnostics complete');
150
+ process.exit(0);
44
151
  });
45
152
 
153
+ // -----------------------------------------------------------------------------
154
+ // Parse
155
+ // -----------------------------------------------------------------------------
46
156
  program.parse(process.argv);
47
157
 
48
158
  if (!process.argv.slice(2).length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
1
+ {
2
2
  "name": "kuhul-es",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "main": "src/index.js",
5
5
  "bin": {
6
6
  "kuhul-es": "bin/kuhul-es.js"