flowscript-core 1.0.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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -0
  3. package/bin/flowscript +12 -0
  4. package/dist/cli.d.ts +12 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +463 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/errors/indentation-error.d.ts +11 -0
  9. package/dist/errors/indentation-error.d.ts.map +1 -0
  10. package/dist/errors/indentation-error.js +22 -0
  11. package/dist/errors/indentation-error.js.map +1 -0
  12. package/dist/grammar.ohm +132 -0
  13. package/dist/hash.d.ts +21 -0
  14. package/dist/hash.d.ts.map +1 -0
  15. package/dist/hash.js +82 -0
  16. package/dist/hash.js.map +1 -0
  17. package/dist/indentation-scanner.d.ts +81 -0
  18. package/dist/indentation-scanner.d.ts.map +1 -0
  19. package/dist/indentation-scanner.js +290 -0
  20. package/dist/indentation-scanner.js.map +1 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +49 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/linter.d.ts +71 -0
  26. package/dist/linter.d.ts.map +1 -0
  27. package/dist/linter.js +122 -0
  28. package/dist/linter.js.map +1 -0
  29. package/dist/memory.d.ts +506 -0
  30. package/dist/memory.d.ts.map +1 -0
  31. package/dist/memory.js +1802 -0
  32. package/dist/memory.js.map +1 -0
  33. package/dist/parser.d.ts +53 -0
  34. package/dist/parser.d.ts.map +1 -0
  35. package/dist/parser.js +1184 -0
  36. package/dist/parser.js.map +1 -0
  37. package/dist/query-engine.d.ts +320 -0
  38. package/dist/query-engine.d.ts.map +1 -0
  39. package/dist/query-engine.js +884 -0
  40. package/dist/query-engine.js.map +1 -0
  41. package/dist/rules/alternatives-without-decision.d.ts +24 -0
  42. package/dist/rules/alternatives-without-decision.d.ts.map +1 -0
  43. package/dist/rules/alternatives-without-decision.js +58 -0
  44. package/dist/rules/alternatives-without-decision.js.map +1 -0
  45. package/dist/rules/causal-cycles.d.ts +23 -0
  46. package/dist/rules/causal-cycles.d.ts.map +1 -0
  47. package/dist/rules/causal-cycles.js +83 -0
  48. package/dist/rules/causal-cycles.js.map +1 -0
  49. package/dist/rules/deep-nesting.d.ts +23 -0
  50. package/dist/rules/deep-nesting.d.ts.map +1 -0
  51. package/dist/rules/deep-nesting.js +55 -0
  52. package/dist/rules/deep-nesting.js.map +1 -0
  53. package/dist/rules/index.d.ts +15 -0
  54. package/dist/rules/index.d.ts.map +1 -0
  55. package/dist/rules/index.js +29 -0
  56. package/dist/rules/index.js.map +1 -0
  57. package/dist/rules/invalid-syntax.d.ts +22 -0
  58. package/dist/rules/invalid-syntax.d.ts.map +1 -0
  59. package/dist/rules/invalid-syntax.js +52 -0
  60. package/dist/rules/invalid-syntax.js.map +1 -0
  61. package/dist/rules/long-causal-chains.d.ts +25 -0
  62. package/dist/rules/long-causal-chains.d.ts.map +1 -0
  63. package/dist/rules/long-causal-chains.js +75 -0
  64. package/dist/rules/long-causal-chains.js.map +1 -0
  65. package/dist/rules/missing-recommended-fields.d.ts +21 -0
  66. package/dist/rules/missing-recommended-fields.d.ts.map +1 -0
  67. package/dist/rules/missing-recommended-fields.js +45 -0
  68. package/dist/rules/missing-recommended-fields.js.map +1 -0
  69. package/dist/rules/missing-required-fields.d.ts +22 -0
  70. package/dist/rules/missing-required-fields.d.ts.map +1 -0
  71. package/dist/rules/missing-required-fields.js +46 -0
  72. package/dist/rules/missing-required-fields.js.map +1 -0
  73. package/dist/rules/orphaned-nodes.d.ts +22 -0
  74. package/dist/rules/orphaned-nodes.d.ts.map +1 -0
  75. package/dist/rules/orphaned-nodes.js +76 -0
  76. package/dist/rules/orphaned-nodes.js.map +1 -0
  77. package/dist/rules/unlabeled-tension.d.ts +20 -0
  78. package/dist/rules/unlabeled-tension.d.ts.map +1 -0
  79. package/dist/rules/unlabeled-tension.js +37 -0
  80. package/dist/rules/unlabeled-tension.js.map +1 -0
  81. package/dist/serializer.d.ts +40 -0
  82. package/dist/serializer.d.ts.map +1 -0
  83. package/dist/serializer.js +368 -0
  84. package/dist/serializer.js.map +1 -0
  85. package/dist/tokenizer.d.ts +26 -0
  86. package/dist/tokenizer.d.ts.map +1 -0
  87. package/dist/tokenizer.js +213 -0
  88. package/dist/tokenizer.js.map +1 -0
  89. package/dist/types.d.ts +96 -0
  90. package/dist/types.d.ts.map +1 -0
  91. package/dist/types.js +50 -0
  92. package/dist/types.js.map +1 -0
  93. package/dist/validate.d.ts +18 -0
  94. package/dist/validate.d.ts.map +1 -0
  95. package/dist/validate.js +68 -0
  96. package/dist/validate.js.map +1 -0
  97. package/package.json +69 -0
package/dist/cli.js ADDED
@@ -0,0 +1,463 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * FlowScript CLI
5
+ *
6
+ * Command-line interface for FlowScript toolchain:
7
+ * - parse: Compile FlowScript text → IR JSON
8
+ * - lint: Validate FlowScript semantics
9
+ * - validate: Verify IR JSON against schema
10
+ * - query: Query IR for cognitive insights (5 queries)
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ const commander_1 = require("commander");
47
+ const fs = __importStar(require("fs"));
48
+ const parser_1 = require("./parser");
49
+ const linter_1 = require("./linter");
50
+ const validate_1 = require("./validate");
51
+ const query_engine_1 = require("./query-engine");
52
+ const serializer_1 = require("./serializer");
53
+ const program = new commander_1.Command();
54
+ program
55
+ .name('flowscript')
56
+ .description('FlowScript toolchain - parser, linter, and validator for cognitive graphs')
57
+ .version('1.0.0');
58
+ /**
59
+ * Parse command: FlowScript text → IR JSON
60
+ */
61
+ program
62
+ .command('parse')
63
+ .description('Parse FlowScript text and emit IR JSON')
64
+ .argument('<file>', 'FlowScript file to parse (.fs)')
65
+ .option('-o, --output <file>', 'Output file for IR JSON (default: stdout)')
66
+ .option('-c, --compact', 'Compact JSON output (no formatting)')
67
+ .action((file, options) => {
68
+ try {
69
+ // Read input file
70
+ if (!fs.existsSync(file)) {
71
+ console.error(`Error: File not found: ${file}`);
72
+ process.exit(1);
73
+ }
74
+ const input = fs.readFileSync(file, 'utf-8');
75
+ // Parse
76
+ const parser = new parser_1.Parser(file);
77
+ const ir = parser.parse(input);
78
+ // Format output
79
+ const json = options.compact
80
+ ? JSON.stringify(ir)
81
+ : JSON.stringify(ir, null, 2);
82
+ // Write output
83
+ if (options.output) {
84
+ fs.writeFileSync(options.output, json, 'utf-8');
85
+ console.log(`✓ Parsed ${file} → ${options.output}`);
86
+ }
87
+ else {
88
+ console.log(json);
89
+ }
90
+ process.exit(0);
91
+ }
92
+ catch (error) {
93
+ if (error instanceof Error) {
94
+ console.error(`Parse error: ${error.message}`);
95
+ }
96
+ else {
97
+ console.error('Parse error:', error);
98
+ }
99
+ process.exit(1);
100
+ }
101
+ });
102
+ /**
103
+ * Serialize command: IR JSON → FlowScript text
104
+ */
105
+ program
106
+ .command('serialize')
107
+ .description('Convert IR JSON back to FlowScript text')
108
+ .argument('<file>', 'IR JSON file to serialize (.json)')
109
+ .option('-o, --output <file>', 'Output file for FlowScript text (default: stdout)')
110
+ .action((file, options) => {
111
+ try {
112
+ const ir = loadIR(file);
113
+ const output = (0, serializer_1.serialize)(ir);
114
+ if (options.output) {
115
+ fs.writeFileSync(options.output, output, 'utf-8');
116
+ console.log(`✓ Serialized ${file} → ${options.output}`);
117
+ }
118
+ else {
119
+ process.stdout.write(output);
120
+ }
121
+ process.exit(0);
122
+ }
123
+ catch (error) {
124
+ if (error instanceof Error) {
125
+ console.error(`Serialize error: ${error.message}`);
126
+ }
127
+ else {
128
+ console.error('Serialize error:', error);
129
+ }
130
+ process.exit(1);
131
+ }
132
+ });
133
+ /**
134
+ * Lint command: Validate FlowScript semantics
135
+ */
136
+ program
137
+ .command('lint')
138
+ .description('Lint FlowScript for semantic errors and warnings')
139
+ .argument('<file>', 'FlowScript file to lint (.fs)')
140
+ .option('-j, --json', 'Output results as JSON')
141
+ .action((file, options) => {
142
+ try {
143
+ // Read and parse input file
144
+ if (!fs.existsSync(file)) {
145
+ console.error(`Error: File not found: ${file}`);
146
+ process.exit(1);
147
+ }
148
+ const input = fs.readFileSync(file, 'utf-8');
149
+ const parser = new parser_1.Parser(file);
150
+ const ir = parser.parse(input);
151
+ // Run linter
152
+ const linter = new linter_1.Linter();
153
+ const results = linter.lint(ir);
154
+ // Get counts
155
+ const errors = linter.getErrors(results);
156
+ const warnings = linter.getWarnings(results);
157
+ // Output results
158
+ if (options.json) {
159
+ console.log(JSON.stringify({
160
+ file,
161
+ errors: errors.length,
162
+ warnings: warnings.length,
163
+ results
164
+ }, null, 2));
165
+ }
166
+ else {
167
+ // Human-readable output
168
+ if (results.length === 0) {
169
+ console.log(`✓ ${file}: No issues found`);
170
+ }
171
+ else {
172
+ console.log(`\nLinting ${file}:\n`);
173
+ for (const result of results) {
174
+ const prefix = result.severity === 'ERROR' ? '✗' : '⚠';
175
+ const location = result.location
176
+ ? `${result.location.file}:${result.location.line}`
177
+ : file;
178
+ console.log(`${prefix} ${result.rule}: ${result.message}`);
179
+ console.log(` at ${location}`);
180
+ if (result.suggestion) {
181
+ console.log(` Suggestion: ${result.suggestion}`);
182
+ }
183
+ console.log('');
184
+ }
185
+ console.log(`${errors.length} error(s), ${warnings.length} warning(s)`);
186
+ }
187
+ }
188
+ // Exit code: 0 if no errors, 1 if errors found (warnings OK)
189
+ process.exit(errors.length > 0 ? 1 : 0);
190
+ }
191
+ catch (error) {
192
+ if (error instanceof Error) {
193
+ console.error(`Lint error: ${error.message}`);
194
+ }
195
+ else {
196
+ console.error('Lint error:', error);
197
+ }
198
+ process.exit(1);
199
+ }
200
+ });
201
+ /**
202
+ * Validate command: Verify IR JSON against schema
203
+ */
204
+ program
205
+ .command('validate')
206
+ .description('Validate IR JSON against canonical schema')
207
+ .argument('<file>', 'IR JSON file to validate (.json)')
208
+ .option('-v, --verbose', 'Show detailed validation errors')
209
+ .action((file, options) => {
210
+ try {
211
+ // Read IR JSON file
212
+ if (!fs.existsSync(file)) {
213
+ console.error(`Error: File not found: ${file}`);
214
+ process.exit(1);
215
+ }
216
+ const json = fs.readFileSync(file, 'utf-8');
217
+ const ir = JSON.parse(json);
218
+ // Validate against schema
219
+ const result = (0, validate_1.validateIR)(ir);
220
+ if (result.valid) {
221
+ console.log(`✓ ${file}: Valid IR`);
222
+ process.exit(0);
223
+ }
224
+ else {
225
+ console.log(`✗ ${file}: Invalid IR`);
226
+ console.log(` ${result.errors.length} validation error(s)\n`);
227
+ if (options.verbose) {
228
+ for (const error of result.errors) {
229
+ console.log(` - ${error.instancePath || '/'}: ${error.message}`);
230
+ if (error.params) {
231
+ console.log(` Params: ${JSON.stringify(error.params)}`);
232
+ }
233
+ }
234
+ }
235
+ else {
236
+ console.log(' Use --verbose to see detailed errors');
237
+ }
238
+ process.exit(1);
239
+ }
240
+ }
241
+ catch (error) {
242
+ if (error instanceof Error) {
243
+ console.error(`Validation error: ${error.message}`);
244
+ }
245
+ else {
246
+ console.error('Validation error:', error);
247
+ }
248
+ process.exit(1);
249
+ }
250
+ });
251
+ /**
252
+ * Helper: Load IR from file
253
+ */
254
+ function loadIR(file) {
255
+ if (!fs.existsSync(file)) {
256
+ console.error(`Error: File not found: ${file}`);
257
+ process.exit(1);
258
+ }
259
+ const json = fs.readFileSync(file, 'utf-8');
260
+ try {
261
+ return JSON.parse(json);
262
+ }
263
+ catch (error) {
264
+ console.error(`Error: Invalid JSON in ${file}`);
265
+ process.exit(1);
266
+ }
267
+ }
268
+ /**
269
+ * Query command group: Query FlowScript IR for insights
270
+ */
271
+ const query = program
272
+ .command('query')
273
+ .description('Query FlowScript IR for cognitive insights');
274
+ /**
275
+ * Query: why - Trace causal ancestry
276
+ */
277
+ query
278
+ .command('why')
279
+ .description('Trace causal ancestry backward from a node')
280
+ .argument('<node-id>', 'Node ID to query')
281
+ .argument('<ir-file>', 'IR JSON file')
282
+ .option('-f, --format <format>', 'Output format: chain|tree|minimal', 'chain')
283
+ .option('-d, --max-depth <depth>', 'Maximum depth to traverse', parseInt)
284
+ .addHelpText('after', `
285
+ Examples:
286
+ $ flowscript query why decision-001 examples/decision.json
287
+ $ flowscript query why node-123 output.json --format=tree
288
+ $ flowscript query why node-456 output.json --max-depth=3`)
289
+ .action((nodeId, irFile, options) => {
290
+ try {
291
+ const ir = loadIR(irFile);
292
+ const engine = new query_engine_1.FlowScriptQueryEngine();
293
+ engine.load(ir);
294
+ const result = engine.why(nodeId, {
295
+ format: options.format,
296
+ maxDepth: options.maxDepth
297
+ });
298
+ console.log(JSON.stringify(result, null, 2));
299
+ process.exit(0);
300
+ }
301
+ catch (error) {
302
+ if (error instanceof Error) {
303
+ console.error(`Query error: ${error.message}`);
304
+ }
305
+ else {
306
+ console.error('Query error:', error);
307
+ }
308
+ process.exit(1);
309
+ }
310
+ });
311
+ /**
312
+ * Query: what-if - Calculate impact analysis
313
+ */
314
+ query
315
+ .command('what-if')
316
+ .description('Calculate forward impact analysis from a node')
317
+ .argument('<node-id>', 'Node ID to query')
318
+ .argument('<ir-file>', 'IR JSON file')
319
+ .option('-f, --format <format>', 'Output format: tree|list|summary', 'tree')
320
+ .option('-d, --max-depth <depth>', 'Maximum depth to traverse', parseInt)
321
+ .addHelpText('after', `
322
+ Examples:
323
+ $ flowscript query what-if decision-001 examples/decision.json
324
+ $ flowscript query what-if node-123 output.json --format=summary
325
+ $ flowscript query what-if node-456 output.json --max-depth=2`)
326
+ .action((nodeId, irFile, options) => {
327
+ try {
328
+ const ir = loadIR(irFile);
329
+ const engine = new query_engine_1.FlowScriptQueryEngine();
330
+ engine.load(ir);
331
+ const result = engine.whatIf(nodeId, {
332
+ format: options.format,
333
+ maxDepth: options.maxDepth
334
+ });
335
+ console.log(JSON.stringify(result, null, 2));
336
+ process.exit(0);
337
+ }
338
+ catch (error) {
339
+ if (error instanceof Error) {
340
+ console.error(`Query error: ${error.message}`);
341
+ }
342
+ else {
343
+ console.error('Query error:', error);
344
+ }
345
+ process.exit(1);
346
+ }
347
+ });
348
+ /**
349
+ * Query: tensions - Extract all tradeoffs
350
+ */
351
+ query
352
+ .command('tensions')
353
+ .description('Extract and group all tension/tradeoff nodes')
354
+ .argument('<ir-file>', 'IR JSON file')
355
+ .option('-g, --group-by <grouping>', 'Grouping: axis|node|none', 'axis')
356
+ .option('-a, --axis <axis>', 'Filter by specific axis')
357
+ .option('-c, --with-context', 'Include parent context')
358
+ .addHelpText('after', `
359
+ Examples:
360
+ $ flowscript query tensions examples/decision.json
361
+ $ flowscript query tensions output.json --group-by=node
362
+ $ flowscript query tensions output.json --axis="speed vs quality"
363
+ $ flowscript query tensions output.json --with-context`)
364
+ .action((irFile, options) => {
365
+ try {
366
+ const ir = loadIR(irFile);
367
+ const engine = new query_engine_1.FlowScriptQueryEngine();
368
+ engine.load(ir);
369
+ const result = engine.tensions({
370
+ groupBy: options.groupBy,
371
+ filterByAxis: options.axis ? [options.axis] : undefined,
372
+ includeContext: options.withContext
373
+ });
374
+ console.log(JSON.stringify(result, null, 2));
375
+ process.exit(0);
376
+ }
377
+ catch (error) {
378
+ if (error instanceof Error) {
379
+ console.error(`Query error: ${error.message}`);
380
+ }
381
+ else {
382
+ console.error('Query error:', error);
383
+ }
384
+ process.exit(1);
385
+ }
386
+ });
387
+ /**
388
+ * Query: blocked - Find blocked tasks with impact analysis
389
+ */
390
+ query
391
+ .command('blocked')
392
+ .description('Find all blocked nodes with dependency chains and impact scoring')
393
+ .argument('<ir-file>', 'IR JSON file')
394
+ .option('-s, --since <date>', 'Filter by blocked since date (YYYY-MM-DD)')
395
+ .option('-f, --format <format>', 'Output format: detailed|summary', 'detailed')
396
+ .addHelpText('after', `
397
+ Examples:
398
+ $ flowscript query blocked examples/decision.json
399
+ $ flowscript query blocked output.json --since=2025-10-01
400
+ $ flowscript query blocked output.json --format=summary`)
401
+ .action((irFile, options) => {
402
+ try {
403
+ const ir = loadIR(irFile);
404
+ const engine = new query_engine_1.FlowScriptQueryEngine();
405
+ engine.load(ir);
406
+ const result = engine.blocked({
407
+ since: options.since,
408
+ format: options.format
409
+ });
410
+ console.log(JSON.stringify(result, null, 2));
411
+ process.exit(0);
412
+ }
413
+ catch (error) {
414
+ if (error instanceof Error) {
415
+ console.error(`Query error: ${error.message}`);
416
+ }
417
+ else {
418
+ console.error('Query error:', error);
419
+ }
420
+ process.exit(1);
421
+ }
422
+ });
423
+ /**
424
+ * Query: alternatives - Reconstruct decision from alternatives
425
+ */
426
+ query
427
+ .command('alternatives')
428
+ .description('Reconstruct decision rationale from alternative nodes')
429
+ .argument('<question-id>', 'Question node ID to analyze')
430
+ .argument('<ir-file>', 'IR JSON file')
431
+ .option('-f, --format <format>', 'Output format: comparison|simple', 'comparison')
432
+ .addHelpText('after', `
433
+ Examples:
434
+ $ flowscript query alternatives question-001 examples/decision.json
435
+ $ flowscript query alternatives node-123 output.json --format=simple`)
436
+ .action((questionId, irFile, options) => {
437
+ try {
438
+ const ir = loadIR(irFile);
439
+ const engine = new query_engine_1.FlowScriptQueryEngine();
440
+ engine.load(ir);
441
+ const result = engine.alternatives(questionId, {
442
+ format: options.format
443
+ });
444
+ console.log(JSON.stringify(result, null, 2));
445
+ process.exit(0);
446
+ }
447
+ catch (error) {
448
+ if (error instanceof Error) {
449
+ console.error(`Query error: ${error.message}`);
450
+ }
451
+ else {
452
+ console.error('Query error:', error);
453
+ }
454
+ process.exit(1);
455
+ }
456
+ });
457
+ // Parse arguments and run
458
+ program.parse(process.argv);
459
+ // Show help if no command provided
460
+ if (!process.argv.slice(2).length) {
461
+ program.outputHelp();
462
+ }
463
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,uCAAyB;AAEzB,qCAAkC;AAClC,qCAAkC;AAClC,yCAAwC;AAExC,iDAAuD;AACvD,6CAAyC;AAEzC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,2EAA2E,CAAC;KACxF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB;;GAEG;AACH,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,wCAAwC,CAAC;KACrD,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;KACpD,MAAM,CAAC,qBAAqB,EAAE,2CAA2C,CAAC;KAC1E,MAAM,CAAC,eAAe,EAAE,qCAAq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AO,EAAE,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,0BAA0B;AAC1B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Custom error class for indentation-related errors
3
+ *
4
+ * Thrown when indentation rules are violated (tabs, inconsistent spacing, etc.)
5
+ * Includes line number for helpful error messages
6
+ */
7
+ export declare class IndentationError extends Error {
8
+ readonly lineNumber: number;
9
+ constructor(message: string, lineNumber: number);
10
+ }
11
+ //# sourceMappingURL=indentation-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indentation-error.d.ts","sourceRoot":"","sources":["../../src/errors/indentation-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAUhD"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndentationError = void 0;
4
+ /**
5
+ * Custom error class for indentation-related errors
6
+ *
7
+ * Thrown when indentation rules are violated (tabs, inconsistent spacing, etc.)
8
+ * Includes line number for helpful error messages
9
+ */
10
+ class IndentationError extends Error {
11
+ constructor(message, lineNumber) {
12
+ super(`${message} (Line ${lineNumber})`);
13
+ this.name = 'IndentationError';
14
+ this.lineNumber = lineNumber;
15
+ // Maintains proper stack trace for where error was thrown (V8 engines)
16
+ if (Error.captureStackTrace) {
17
+ Error.captureStackTrace(this, IndentationError);
18
+ }
19
+ }
20
+ }
21
+ exports.IndentationError = IndentationError;
22
+ //# sourceMappingURL=indentation-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indentation-error.js","sourceRoot":"","sources":["../../src/errors/indentation-error.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IAGzC,YAAY,OAAe,EAAE,UAAkB;QAC7C,KAAK,CAAC,GAAG,OAAO,UAAU,UAAU,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,uEAAuE;QACvE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAbD,4CAaC"}
@@ -0,0 +1,132 @@
1
+ FlowScript {
2
+ // Document Structure
3
+ Document = Line*
4
+ Line = BlankLine | RelationshipExpression | Element
5
+
6
+ Element = Modifier* Content
7
+ Content = State | Insight | Question | Completion | Alternative | Block | Statement
8
+
9
+ BlankLine = space* "\n"
10
+ Statement = ~Modifier (~("\n" | "{" | "}") any)+ "\n"?
11
+
12
+ // Blocks (thought blocks / atomic processing units)
13
+ Block = "{" ws BlockContent? ws "}"
14
+ BlockContent = BlockLine (separator? BlockLine)* separator?
15
+ BlockLine = ws (ContinuationRel | RelationshipExpression | BlockElement)
16
+ BlockElement = Modifier* BlockContent_inner
17
+ BlockContent_inner = State | Insight | Question | Completion | Alternative | Block | BlockStatement
18
+ BlockStatement = ~Modifier (~("\n" | "{" | "}" | ";") any)+
19
+ separator = (space | "\n" | ";")+
20
+ ws = (space | "\n")*
21
+
22
+ // Relationship Expressions (must come before Statement in Line)
23
+ RelationshipExpression = RelNode RelOpNodePair+
24
+ RelOpNodePair = RelOp RelNode
25
+ RelNode = space* (Block | TypedRelTarget | NodeText) space*
26
+
27
+ // Typed targets in relationship expressions — like Insight/Question/Completion/Alternative
28
+ // but without RelOpNodePair* chaining (outer expression handles that)
29
+ TypedRelTarget = ThoughtTarget | ActionTarget | QuestionTarget | CompletionTarget | AlternativeTarget
30
+ ThoughtTarget = "thought:" space* thoughtText? Block?
31
+ ActionTarget = "action:" space* actionText? Block?
32
+ QuestionTarget = "?" space* questionText? Block?
33
+ CompletionTarget = "✓" space* completionText? Block?
34
+ AlternativeTarget = "||" space* alternativeText? Block?
35
+
36
+ // Continuation Relationship (only valid inside blocks)
37
+ ContinuationRel = RelOp space* RelNode
38
+
39
+ NodeText = ~insightPrefix ~"?" ~"✓" ~"||" (~("<->" | "->" | "<-" | "=>" | "><[" | "><" | "\n" | "{" | "}" | ";") any)+
40
+ insightPrefix = "thought:" | "action:"
41
+
42
+ RelOp = bidirectional | reverseCausal | causal | temporal | tensionWithAxis | tensionWithoutAxis
43
+
44
+ bidirectional = "<->"
45
+ reverseCausal = "<-"
46
+ causal = "->"
47
+ temporal = "=>"
48
+ tensionWithAxis = "><[" axisLabel "]"
49
+ tensionWithoutAxis = "><"
50
+
51
+ axisLabel = (~"]" any)+
52
+
53
+ // Modifiers (highest precedence)
54
+ Modifier = urgent | strongPositive | highConfidence | lowConfidence
55
+
56
+ urgent = "!"
57
+ strongPositive = "++"
58
+ highConfidence = "*"
59
+ lowConfidence = "~"
60
+
61
+ // State markers
62
+ State = decidedWithFields | decidedWithoutFields
63
+ | blockedWithFields | blockedWithoutFields
64
+ | parkingWithFields | parkingWithoutFields
65
+ | exploring
66
+
67
+ decidedWithFields = "[decided(" decidedFields? ")]"
68
+ decidedFields = decidedField (space* "," space* decidedField)*
69
+ decidedField = rationalField | onField
70
+ rationalField = "rationale:" space* string
71
+ onField = "on:" space* dateString
72
+
73
+ decidedWithoutFields = "[decided]"
74
+
75
+ blockedWithFields = "[blocked(" blockedFields? ")]"
76
+ blockedFields = blockedField (space* "," space* blockedField)*
77
+ blockedField = reasonField | sinceField
78
+ reasonField = "reason:" space* string
79
+ sinceField = "since:" space* dateString
80
+
81
+ blockedWithoutFields = "[blocked]"
82
+
83
+ parkingWithFields = "[parking(" parkingFields? ")]"
84
+ parkingFields = parkingField (space* "," space* parkingField)*
85
+ parkingField = whyField | untilField
86
+ whyField = "why:" space* string
87
+ untilField = "until:" space* string
88
+
89
+ parkingWithoutFields = "[parking]"
90
+
91
+ exploring = "[exploring]"
92
+
93
+ // Insights, Questions, Commands
94
+ Insight = Thought | Action
95
+
96
+ // Insights can have optional relationship chains, or blocks
97
+ // Supports: text+block, just block, or just text
98
+ Thought = "thought:" space* thoughtText? Block? RelOpNodePair* "\n"?
99
+ Action = "action:" space* actionText? Block? RelOpNodePair* "\n"?
100
+
101
+ // Content excludes relationship operators and block delimiters (they're in RelOpNodePair)
102
+ // For text+block pattern, exclude { as well
103
+ // Exclude ; to allow semicolons as separators in horizontal syntax
104
+ thoughtText = (~("\n" | "}" | "{" | ";" | "->" | "<-" | "<=>" | "=>" | "><[" | "><") any)+
105
+ actionText = (~("\n" | "}" | "{" | ";" | "->" | "<-" | "<=>" | "=>" | "><[" | "><") any)+
106
+
107
+ Question = "?" space* questionText? Block? "\n"?
108
+ questionText = (~("\n" | "}" | "{" | ";") any)+
109
+
110
+ Completion = "✓" space* completionText? Block? "\n"?
111
+ completionText = (~("\n" | "}" | "{" | ";") any)+
112
+
113
+ // Alternatives
114
+ Alternative = "||" space* alternativeText? Block? "\n"?
115
+ alternativeText = (~("\n" | "}" | "{" | ";") any)+
116
+
117
+ // Lexical elements
118
+ string = "\"" stringChar* "\""
119
+ stringChar = ~("\"" | "\\") any
120
+ | escapeSequence
121
+
122
+ escapeSequence = "\\" ("\"" | "\\" | "n" | "t" | "r")
123
+
124
+ dateString = "\"" isoDate "\""
125
+ isoDate = digit digit digit digit "-" digit digit "-" digit digit
126
+ ("T" digit digit ":" digit digit ":" digit digit "Z")?
127
+
128
+ identifier = letter (letter | digit | "_" | "-")*
129
+
130
+ // Lexical rules (whitespace handling)
131
+ space := " " | "\t" | "\r"
132
+ }
package/dist/hash.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * FlowScript Content Hashing
3
+ *
4
+ * Generates deterministic SHA-256 content hashes for nodes, relationships, and states.
5
+ * Enables automatic deduplication: same semantic content = same ID.
6
+ */
7
+ /**
8
+ * Generate a SHA-256 content hash for any data object.
9
+ *
10
+ * The hash is deterministic - same input always produces same hash.
11
+ * This enables automatic deduplication in the IR graph.
12
+ *
13
+ * @param data - Any object to hash
14
+ * @returns 64-character lowercase hex string (SHA-256 hash)
15
+ *
16
+ * @example
17
+ * hashContent({ type: 'statement', content: 'Test' })
18
+ * // => 'a7f2c8d1b4e9f6a3c5d8e2b7f1a4c9d6e3b8a2f7c1d5e9b4a8f2c6d1e5a9b3f7'
19
+ */
20
+ export declare function hashContent(data: any): string;
21
+ //# sourceMappingURL=hash.d.ts.map