novac 2.0.1 → 2.2.0

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 (161) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1574 -597
  3. package/bin/novac +468 -171
  4. package/bin/nvc +522 -0
  5. package/bin/nvml +78 -17
  6. package/demo.nv +0 -0
  7. package/demo_builtins.nv +0 -0
  8. package/demo_http.nv +0 -0
  9. package/examples/bf.nv +69 -0
  10. package/examples/math.nv +21 -0
  11. package/kits/birdAPI/kitdef.js +954 -0
  12. package/kits/kitRNG/kitdef.js +740 -0
  13. package/kits/kitSSH/kitdef.js +1272 -0
  14. package/kits/kitadb/kitdef.js +606 -0
  15. package/kits/kitai/kitdef.js +2185 -0
  16. package/kits/kitansi/kitdef.js +1402 -0
  17. package/kits/kitcanvas/kitdef.js +914 -0
  18. package/kits/kitclippy/kitdef.js +925 -0
  19. package/kits/kitformat/kitdef.js +1485 -0
  20. package/kits/kitgps/kitdef.js +1862 -0
  21. package/kits/kitlibproc/kitdef.js +3 -2
  22. package/kits/kitmatrix/ex.js +19 -0
  23. package/kits/kitmatrix/kitdef.js +960 -0
  24. package/kits/kitmorse/kitdef.js +229 -0
  25. package/kits/kitmpatch/kitdef.js +906 -0
  26. package/kits/kitnet/kitdef.js +1401 -0
  27. package/kits/kitnovacweb/README.md +1416 -143
  28. package/kits/kitnovacweb/kitdef.js +92 -2
  29. package/kits/kitnovacweb/nvml/executor.js +578 -176
  30. package/kits/kitnovacweb/nvml/index.js +2 -2
  31. package/kits/kitnovacweb/nvml/lexer.js +72 -69
  32. package/kits/kitnovacweb/nvml/parser.js +328 -159
  33. package/kits/kitnovacweb/nvml/renderer.js +770 -270
  34. package/kits/kitparse/kitdef.js +1688 -0
  35. package/kits/kitproto/kitdef.js +613 -0
  36. package/kits/kitqr/kitdef.js +637 -0
  37. package/kits/kitregex++/kitdef.js +1353 -0
  38. package/kits/kitrequire/kitdef.js +1599 -0
  39. package/kits/kitx11/kitdef.js +1 -0
  40. package/kits/kitx11/kitx11.js +2472 -0
  41. package/kits/kitx11/kitx11_conn.js +948 -0
  42. package/kits/kitx11/kitx11_worker.js +121 -0
  43. package/kits/libtea/kitdef.js +2691 -0
  44. package/kits/libterm/ex.js +285 -0
  45. package/kits/libterm/kitdef.js +1927 -0
  46. package/novac/LICENSE +21 -0
  47. package/novac/README.md +1823 -0
  48. package/novac/bin/novac +950 -0
  49. package/novac/bin/nvc +522 -0
  50. package/novac/bin/nvml +542 -0
  51. package/novac/demo.nv +245 -0
  52. package/novac/demo_builtins.nv +209 -0
  53. package/novac/demo_http.nv +62 -0
  54. package/novac/examples/bf.nv +69 -0
  55. package/novac/examples/math.nv +21 -0
  56. package/novac/kits/kitai/kitdef.js +2185 -0
  57. package/novac/kits/kitansi/kitdef.js +1402 -0
  58. package/novac/kits/kitformat/kitdef.js +1485 -0
  59. package/novac/kits/kitgps/kitdef.js +1862 -0
  60. package/novac/kits/kitlibfs/kitdef.js +231 -0
  61. package/{examples/example-project/nova_modules → novac/kits}/kitlibproc/kitdef.js +3 -2
  62. package/novac/kits/kitmatrix/ex.js +19 -0
  63. package/novac/kits/kitmatrix/kitdef.js +960 -0
  64. package/novac/kits/kitmpatch/kitdef.js +906 -0
  65. package/novac/kits/kitnovacweb/README.md +1572 -0
  66. package/novac/kits/kitnovacweb/demo.nv +12 -0
  67. package/novac/kits/kitnovacweb/demo.nvml +71 -0
  68. package/novac/kits/kitnovacweb/index.nova +12 -0
  69. package/novac/kits/kitnovacweb/kitdef.js +692 -0
  70. package/novac/kits/kitnovacweb/nova.kit.json +8 -0
  71. package/novac/kits/kitnovacweb/nvml/executor.js +739 -0
  72. package/novac/kits/kitnovacweb/nvml/index.js +67 -0
  73. package/novac/kits/kitnovacweb/nvml/lexer.js +263 -0
  74. package/novac/kits/kitnovacweb/nvml/parser.js +508 -0
  75. package/novac/kits/kitnovacweb/nvml/renderer.js +924 -0
  76. package/novac/kits/kitparse/kitdef.js +1688 -0
  77. package/novac/kits/kitregex++/kitdef.js +1353 -0
  78. package/novac/kits/kitrequire/kitdef.js +1599 -0
  79. package/novac/kits/kitx11/kitdef.js +1 -0
  80. package/novac/kits/kitx11/kitx11.js +2472 -0
  81. package/novac/kits/kitx11/kitx11_conn.js +948 -0
  82. package/novac/kits/kitx11/kitx11_worker.js +121 -0
  83. package/novac/kits/libtea/tf.js +2691 -0
  84. package/novac/kits/libterm/ex.js +285 -0
  85. package/novac/kits/libterm/kitdef.js +1927 -0
  86. package/novac/node_modules/chalk/license +9 -0
  87. package/novac/node_modules/chalk/package.json +83 -0
  88. package/novac/node_modules/chalk/readme.md +297 -0
  89. package/novac/node_modules/chalk/source/index.d.ts +325 -0
  90. package/novac/node_modules/chalk/source/index.js +225 -0
  91. package/novac/node_modules/chalk/source/utilities.js +33 -0
  92. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
  93. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
  94. package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
  95. package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
  96. package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
  97. package/novac/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
  98. package/novac/node_modules/commander/LICENSE +22 -0
  99. package/novac/node_modules/commander/Readme.md +1176 -0
  100. package/novac/node_modules/commander/esm.mjs +16 -0
  101. package/novac/node_modules/commander/index.js +24 -0
  102. package/novac/node_modules/commander/lib/argument.js +150 -0
  103. package/novac/node_modules/commander/lib/command.js +2777 -0
  104. package/novac/node_modules/commander/lib/error.js +39 -0
  105. package/novac/node_modules/commander/lib/help.js +747 -0
  106. package/novac/node_modules/commander/lib/option.js +380 -0
  107. package/novac/node_modules/commander/lib/suggestSimilar.js +101 -0
  108. package/novac/node_modules/commander/package-support.json +19 -0
  109. package/novac/node_modules/commander/package.json +82 -0
  110. package/novac/node_modules/commander/typings/esm.d.mts +3 -0
  111. package/novac/node_modules/commander/typings/index.d.ts +1113 -0
  112. package/novac/node_modules/node-addon-api/LICENSE.md +9 -0
  113. package/novac/node_modules/node-addon-api/README.md +95 -0
  114. package/novac/node_modules/node-addon-api/common.gypi +21 -0
  115. package/novac/node_modules/node-addon-api/except.gypi +25 -0
  116. package/novac/node_modules/node-addon-api/index.js +14 -0
  117. package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  118. package/novac/node_modules/node-addon-api/napi-inl.h +7165 -0
  119. package/novac/node_modules/node-addon-api/napi.h +3364 -0
  120. package/novac/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  121. package/novac/node_modules/node-addon-api/node_api.gyp +9 -0
  122. package/novac/node_modules/node-addon-api/noexcept.gypi +26 -0
  123. package/novac/node_modules/node-addon-api/package-support.json +21 -0
  124. package/novac/node_modules/node-addon-api/package.json +480 -0
  125. package/novac/node_modules/node-addon-api/tools/README.md +73 -0
  126. package/novac/node_modules/node-addon-api/tools/check-napi.js +99 -0
  127. package/novac/node_modules/node-addon-api/tools/clang-format.js +71 -0
  128. package/novac/node_modules/node-addon-api/tools/conversion.js +301 -0
  129. package/novac/node_modules/serialize-javascript/LICENSE +27 -0
  130. package/novac/node_modules/serialize-javascript/README.md +149 -0
  131. package/novac/node_modules/serialize-javascript/index.js +297 -0
  132. package/novac/node_modules/serialize-javascript/package.json +33 -0
  133. package/novac/package.json +27 -0
  134. package/novac/scripts/update-bin.js +24 -0
  135. package/novac/src/core/bstd.js +1035 -0
  136. package/novac/src/core/config.js +155 -0
  137. package/novac/src/core/describe.js +187 -0
  138. package/novac/src/core/emitter.js +499 -0
  139. package/novac/src/core/error.js +86 -0
  140. package/novac/src/core/executor.js +5606 -0
  141. package/novac/src/core/formatter.js +686 -0
  142. package/novac/src/core/lexer.js +1026 -0
  143. package/novac/src/core/nova_builtins.js +717 -0
  144. package/novac/src/core/nova_thread_worker.js +166 -0
  145. package/novac/src/core/parser.js +2181 -0
  146. package/novac/src/core/types.js +112 -0
  147. package/novac/src/index.js +28 -0
  148. package/novac/src/runtime/stdlib.js +244 -0
  149. package/package.json +6 -3
  150. package/scripts/update-bin.js +0 -0
  151. package/src/core/bstd.js +838 -362
  152. package/src/core/executor.js +2578 -170
  153. package/src/core/lexer.js +502 -54
  154. package/src/core/nova_builtins.js +21 -3
  155. package/src/core/parser.js +413 -72
  156. package/src/core/types.js +30 -2
  157. package/src/index.js +0 -0
  158. package/examples/example-project/README.md +0 -3
  159. package/examples/example-project/src/main.nova +0 -3
  160. package/src/core/environment.js +0 -0
  161. /package/{examples/example-project/bin/example-project.nv → novac/node_modules/node-addon-api/nothing.c} +0 -0
@@ -0,0 +1,155 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+ const { ConfigFile, Shema, ShemaType } = require('./bstd');
5
+
6
+ // Define the Nova config schema
7
+ const novaConfigSchema = new Shema({
8
+ name: new ShemaType('String', val => typeof val === 'string'),
9
+ version: new ShemaType('String', val => typeof val === 'string'),
10
+ author: new ShemaType('String', val => typeof val === 'string'),
11
+ description: new ShemaType('String', val => typeof val === 'string'),
12
+ main: new ShemaType('String', val => typeof val === 'string'),
13
+ license: new ShemaType('String', val => typeof val === 'string'),
14
+ scripts: new ShemaType('Object', val => typeof val === 'object' && val !== null),
15
+ dependencies: new ShemaType('Object', val => typeof val === 'object' && val !== null),
16
+ devDependencies: new ShemaType('Object', val => typeof val === 'object' && val !== null),
17
+ });
18
+
19
+ // Initialize or load the global Nova config
20
+ function initializeConfig() {
21
+ const configPath = path.join(os.homedir(), '.novac', 'nvconfig.json');
22
+ const configDir = path.dirname(configPath);
23
+
24
+ // Create config directory if it doesn't exist
25
+ if (!fs.existsSync(configDir)) {
26
+ fs.mkdirSync(configDir, { recursive: true });
27
+ }
28
+
29
+ // Create config file if it doesn't exist
30
+ if (!fs.existsSync(configPath)) {
31
+ const defaultConfig = {
32
+ name: 'nova-project',
33
+ version: '1.0.0',
34
+ author: '',
35
+ description: '',
36
+ main: 'src/main.nova',
37
+ license: 'MIT',
38
+ scripts: {},
39
+ dependencies: {},
40
+ devDependencies: {},
41
+ };
42
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
43
+ }
44
+
45
+ return configPath;
46
+ }
47
+
48
+ // Get config value
49
+ function getConfig(keyPath) {
50
+ const configPath = initializeConfig();
51
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
52
+
53
+ if (!keyPath) {
54
+ return config;
55
+ }
56
+
57
+ // Parse key path like "scripts.build" or "dependencies.lodash"
58
+ const keys = keyPath.split('.');
59
+ let current = config;
60
+
61
+ for (const key of keys) {
62
+ if (current && typeof current === 'object' && key in current) {
63
+ current = current[key];
64
+ } else {
65
+ return undefined;
66
+ }
67
+ }
68
+
69
+ return current;
70
+ }
71
+
72
+ // Set config value
73
+ function setConfig(keyPath, value) {
74
+ const configPath = initializeConfig();
75
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
76
+
77
+ const keys = keyPath.split('.');
78
+ let current = config;
79
+
80
+ // Navigate to the parent object
81
+ for (let i = 0; i < keys.length - 1; i++) {
82
+ const key = keys[i];
83
+ if (!(key in current) || typeof current[key] !== 'object') {
84
+ current[key] = {};
85
+ }
86
+ current = current[key];
87
+ }
88
+
89
+ // Set the value
90
+ current[keys[keys.length - 1]] = parseValue(value);
91
+
92
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
93
+ }
94
+
95
+ // Parse string value to appropriate type
96
+ function parseValue(value) {
97
+ if (value === 'true') return true;
98
+ if (value === 'false') return false;
99
+ if (value === 'null') return null;
100
+ if (value === 'undefined') return undefined;
101
+ if (!isNaN(value) && value !== '') return Number(value);
102
+ try {
103
+ return JSON.parse(value);
104
+ } catch {
105
+ return value;
106
+ }
107
+ }
108
+
109
+ // Interactive setup for config
110
+ function interactiveSetup() {
111
+ const configPath = initializeConfig();
112
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
113
+
114
+ const questions = [
115
+ { key: 'name', default: config.name || 'nova-project' },
116
+ { key: 'version', default: config.version || '1.0.0' },
117
+ { key: 'author', default: config.author || '' },
118
+ { key: 'description', default: config.description || '' },
119
+ { key: 'main', default: config.main || 'src/main.nova' },
120
+ { key: 'license', default: config.license || 'MIT' },
121
+ ];
122
+
123
+ const readline = require('readline');
124
+ const rl = readline.createInterface({
125
+ input: process.stdin,
126
+ output: process.stdout,
127
+ });
128
+
129
+ let questionIndex = 0;
130
+
131
+ const askQuestion = () => {
132
+ if (questionIndex >= questions.length) {
133
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
134
+ console.log('Config saved successfully!');
135
+ rl.close();
136
+ return;
137
+ }
138
+
139
+ const question = questions[questionIndex];
140
+ rl.question(`${question.key} (${question.default}): `, (answer) => {
141
+ config[question.key] = answer.trim() === '' ? question.default : answer.trim();
142
+ questionIndex++;
143
+ askQuestion();
144
+ });
145
+ };
146
+
147
+ askQuestion();
148
+ }
149
+
150
+ module.exports = {
151
+ initializeConfig,
152
+ getConfig,
153
+ setConfig,
154
+ interactiveSetup,
155
+ };
@@ -0,0 +1,187 @@
1
+ /**
2
+ * describe.js
3
+ * Converts Nova Air AST into natural-language explanations.
4
+ * Style: clear, rhythmic, and human — with natural punctuation.
5
+ */
6
+
7
+ function describe(node, depth = 0) {
8
+ const indent = " ".repeat(depth);
9
+ if (!node) return "";
10
+ if (Array.isArray(node))
11
+ return node.map(n => describe(n, depth)).join("\n");
12
+
13
+ switch (node.kind) {
14
+ // ─────────── ROOT ───────────
15
+ case "program":
16
+ return node.nodes.map(n => describe(n, depth)).join("\n");
17
+
18
+ // ─────────── DECLARATION ───────────
19
+ case "declare": {
20
+ const kind = node.isConst ? "constant" : "variable";
21
+ const pointer = node.isPointer ? "pointer to " : "";
22
+ if (node.destructure)
23
+ return `${indent}Create a ${kind} pattern: unpack into { ${node.destructure.props
24
+ .map(p => p.alias)
25
+ .join(", ")} }${node.value ? `, using ${describe(node.value)}` : ""}.`;
26
+ if (node.value)
27
+ return `${indent}Declare ${kind}: ${pointer}${node.name}, and set it to ${describe(node.value)}.`;
28
+ return `${indent}Declare ${kind}: ${pointer}${node.name}.`;
29
+ }
30
+
31
+ // ─────────── ASSIGNMENT ───────────
32
+ case "assign":
33
+ return `${indent}Set ${describe(node.name)} to ${describe(node.value)}.`;
34
+
35
+ // ─────────── REFERENCES ───────────
36
+ case "ref":
37
+ return node.name;
38
+
39
+ // ─────────── VALUES ───────────
40
+ case "value":
41
+ return JSON.stringify(node.value);
42
+
43
+ // ─────────── FUNCTIONS ───────────
44
+ case "function": {
45
+ const args = node.args.length
46
+ ? node.args.map(a => describe(a)).join(", ")
47
+ : "no arguments";
48
+ return `${indent}${node.isAsync ? "Async " : ""}function '${node.name}': takes (${args}), and ${summarizeBody(node.body)}.`;
49
+ }
50
+
51
+ case "arrowfunc": {
52
+ const args = node.args.length
53
+ ? node.args.map(a => describe(a)).join(", ")
54
+ : "no arguments";
55
+ return `${indent}Arrow function: takes (${args}), and ${summarizeBody(node.body)}.`;
56
+ }
57
+
58
+ // ─────────── RETURN ───────────
59
+ case "return":
60
+ return `${indent}Return ${node.value ? describe(node.value) : "nothing"}${node.terminate ? ", immediately" : ""}.`;
61
+
62
+ // ─────────── CLASS ───────────
63
+ case "class":
64
+ return `${indent}Define a class '${node.name}'${node.superClass ? `, extending ${describe(node.superClass)}` : ""}: \n${node.members
65
+ .map(m => describe(m, depth + 1))
66
+ .join("\n")}`;
67
+
68
+ // ─────────── BRANCHING ───────────
69
+ case "branch": {
70
+ const base = `${indent}${capitalize(node.type)} statement: ${
71
+ node.args ? `when (${describe(node.args)})` : ""
72
+ }, then:\n${describe(node.body, depth + 1)}`;
73
+ const next = node.next
74
+ ? `\n${indent}else:\n${describe(node.next.body, depth + 1)}`
75
+ : "";
76
+ return base + next;
77
+ }
78
+
79
+ // ─────────── LOOPS ───────────
80
+ case "while":
81
+ case "repeat":
82
+ case "for":
83
+ case "do":
84
+ case "until":
85
+ return `${indent}${capitalize(node.kind)} loop: ${
86
+ node.args ? `condition is ${describe(node.args)},` : ""
87
+ } running:\n${describe(node.body, depth + 1)}`;
88
+
89
+ // ─────────── CALLS ───────────
90
+ case "call": {
91
+ const name = typeof node.name === "string" ? node.name : describe(node.name);
92
+ const args = node.args.length
93
+ ? `, with arguments: ${node.args.map(a => describe(a)).join(", ")}`
94
+ : "";
95
+ return `${indent}Call ${name}${args}.`;
96
+ }
97
+
98
+ // ─────────── PROPERTY ACCESS ───────────
99
+ case "prop":
100
+ return `${describe(node.object)}.${node.name}`;
101
+
102
+ // ─────────── INDEX ACCESS ───────────
103
+ case "subscript":
104
+ return `${describe(node.object)}[${describe(node.index)}]`;
105
+
106
+ // ─────────── ASYNC / AWAIT ───────────
107
+ case "await":
108
+ return `${indent}Await: wait for ${describe(node.operand)} to complete.`;
109
+
110
+ // ─────────── ERROR HANDLING ───────────
111
+ case "throw":
112
+ return `${indent}Throw ${describe(node.value)}.`;
113
+
114
+ case "try":
115
+ return `${indent}Try block:\n${describe(node.tryBody, depth + 1)}${
116
+ node.catchBody
117
+ ? `\n${indent}If an error occurs: catch it as '${node.catchName}', then:\n${describe(node.catchBody, depth + 1)}`
118
+ : ""
119
+ }${node.finallyBody ? `\n${indent}Finally: always run\n${describe(node.finallyBody, depth + 1)}` : ""}`;
120
+
121
+ // ─────────── EXPRESSIONS ───────────
122
+ case "binary":
123
+ return `${describe(node.left)} ${node.operator} ${describe(node.right)}.`;
124
+
125
+ case "unary":
126
+ return `${node.operator}${describe(node.operand)}.`;
127
+
128
+ case "postfix":
129
+ return `${describe(node.operand)}${node.operator}.`;
130
+
131
+ // ─────────── MEMORY / POINTERS ───────────
132
+ case "deref":
133
+ return `the value pointed to by ${describe(node.operand)}.`;
134
+
135
+ case "currency":
136
+ return `${describe(node.operand)} (in ${node.name}).`;
137
+
138
+ // ─────────── STRUCTURES ───────────
139
+ case "object":
140
+ return `object: { ${Object.entries(node.props)
141
+ .map(([k, v]) => `${k}: ${describe(v)}`)
142
+ .join(", ")} }.`;
143
+
144
+ case "array":
145
+ return `array: [${node.elements.map(e => describe(e)).join(", ")}].`;
146
+
147
+ // ─────────── PATTERNS ───────────
148
+ case "objpattern":
149
+ return `{ ${node.props
150
+ .map(p => `${p.key}${p.key !== p.alias ? ` as ${p.alias}` : ""}`)
151
+ .join(", ")} }`;
152
+
153
+ case "arrpattern":
154
+ return `[${node.elements.map(e => describe(e)).join(", ")}]`;
155
+
156
+ // ─────────── TEMPLATES ───────────
157
+ case "template":
158
+ return node.parts.map(p => describe(p)).join("");
159
+
160
+ // ─────────── EXECUTION ───────────
161
+ case "exec":
162
+ return `${indent}Execute: ${describe(node.expr)}.`;
163
+
164
+ // ─────────── FALLBACK ───────────
165
+ case "EOF":
166
+ return "";
167
+ default:
168
+ return `${indent}(Unknown node type: '${node.kind}')`;
169
+ }
170
+ }
171
+
172
+ // ─────────── HELPERS ───────────
173
+ function summarizeBody(body) {
174
+ if (!body || !body.length) return "does nothing";
175
+ const first = describe(body[0]);
176
+ if (body.length === 1) {
177
+ if (first.startsWith("Return")) return `returns ${first.replace(/^Return /, "").trim()}`;
178
+ return `does: ${first.toLowerCase()}`;
179
+ }
180
+ return "runs several steps in order";
181
+ }
182
+
183
+ function capitalize(str) {
184
+ return str.charAt(0).toUpperCase() + str.slice(1);
185
+ }
186
+
187
+ module.exports = { describe };