@isl-lang/repl 0.1.0 → 0.1.1

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/dist/index.d.cts CHANGED
@@ -49,6 +49,12 @@ declare class Session {
49
49
  private loadedFiles;
50
50
  /** Session configuration */
51
51
  private config;
52
+ /** Evaluation context (set by .context command) */
53
+ private evalContext;
54
+ /** Pre-state context for old() expressions */
55
+ private preContext;
56
+ /** Loaded domain AST (from real parser) */
57
+ private domainAST;
52
58
  constructor(config?: SessionConfig);
53
59
  /**
54
60
  * Define a new intent
@@ -128,6 +134,51 @@ declare class Session {
128
134
  success: boolean;
129
135
  error?: string;
130
136
  }>;
137
+ /**
138
+ * Set evaluation context from JSON string
139
+ */
140
+ setEvalContext(json: string): {
141
+ success: boolean;
142
+ count: number;
143
+ error?: string;
144
+ };
145
+ /**
146
+ * Set pre-state context for old() expressions
147
+ */
148
+ setPreContext(json: string): {
149
+ success: boolean;
150
+ error?: string;
151
+ };
152
+ /**
153
+ * Get evaluation context
154
+ */
155
+ getEvalContext(): Record<string, unknown>;
156
+ /**
157
+ * Get pre-state context
158
+ */
159
+ getPreContext(): Record<string, unknown> | null;
160
+ /**
161
+ * Resolve a dot-path against the evaluation context
162
+ */
163
+ resolveValue(dotPath: string): {
164
+ found: boolean;
165
+ value: unknown;
166
+ };
167
+ /**
168
+ * Resolve a dot-path against the pre-state context
169
+ */
170
+ resolvePreValue(dotPath: string): {
171
+ found: boolean;
172
+ value: unknown;
173
+ };
174
+ /**
175
+ * Set domain AST (from real parser)
176
+ */
177
+ setDomainAST(ast: unknown): void;
178
+ /**
179
+ * Get domain AST
180
+ */
181
+ getDomainAST(): unknown;
131
182
  /**
132
183
  * Clear all session state
133
184
  */
@@ -248,6 +299,12 @@ interface REPLOptions {
248
299
  colors?: boolean;
249
300
  verbose?: boolean;
250
301
  historyFile?: string;
302
+ /** Load an ISL file on startup */
303
+ load?: string;
304
+ /** Set initial evaluation context (JSON string) */
305
+ context?: string;
306
+ /** Parse-only mode (non-interactive, for piped input) */
307
+ parseOnly?: boolean;
251
308
  }
252
309
  /**
253
310
  * ISL REPL - Interactive Read-Eval-Print Loop
@@ -266,6 +323,14 @@ declare class ISLREPL {
266
323
  * Start the REPL
267
324
  */
268
325
  start(): void;
326
+ /**
327
+ * Apply startup options (--load, --context)
328
+ */
329
+ private applyStartupOptions;
330
+ /**
331
+ * Run in pipe mode (read all stdin, parse, and output)
332
+ */
333
+ private runPipeMode;
269
334
  /**
270
335
  * Print the welcome banner
271
336
  */
@@ -273,27 +338,19 @@ declare class ISLREPL {
273
338
  /**
274
339
  * Handle a line of input
275
340
  */
276
- private handleLine;
341
+ handleLine(line: string): void;
277
342
  /**
278
- * Handle a meta command (. prefix)
343
+ * Handle a dot command (. prefix)
279
344
  */
280
- private handleMetaCommand;
345
+ private handleDotCommand;
281
346
  /**
282
- * Handle an ISL command (: prefix)
283
- */
284
- private handleISLCommand;
285
- /**
286
- * Evaluate ISL code
347
+ * Evaluate ISL code (multi-line input or bare expressions)
287
348
  */
288
349
  private evaluate;
289
350
  /**
290
351
  * Evaluate an intent definition
291
352
  */
292
353
  private evaluateIntent;
293
- /**
294
- * Print a parse error with location info
295
- */
296
- private printParseError;
297
354
  /**
298
355
  * Print an error
299
356
  */
@@ -345,22 +402,13 @@ interface MetaCommand {
345
402
  usage: string;
346
403
  handler: (args: string[], session: Session, repl: REPL) => CommandResult;
347
404
  }
348
- /**
349
- * ISL command definition (: prefix)
350
- */
351
- interface ISLCommand {
352
- name: string;
353
- aliases: string[];
354
- description: string;
355
- usage: string;
356
- handler: (args: string[], session: Session, repl: REPL) => CommandResult;
357
- }
405
+ type ISLCommand = MetaCommand;
358
406
  declare const metaCommands: MetaCommand[];
359
407
  declare const islCommands: ISLCommand[];
360
408
  /**
361
409
  * Find a similar command name
362
410
  */
363
- declare function findSimilarCommand(input: string, type: 'meta' | 'isl'): string | null;
411
+ declare function findSimilarCommand(input: string, _type?: 'meta' | 'isl'): string | null;
364
412
 
365
413
  /**
366
414
  * Completion item
@@ -379,7 +427,7 @@ declare const KEYWORDS: CompletionItem[];
379
427
  */
380
428
  declare const META_COMMANDS: CompletionItem[];
381
429
  /**
382
- * ISL commands (: prefix)
430
+ * ISL commands (kept empty for backward compat — all commands use . prefix)
383
431
  */
384
432
  declare const ISL_COMMANDS: CompletionItem[];
385
433
  /**
@@ -533,4 +581,9 @@ declare function wrapText(text: string, maxWidth: number): string;
533
581
  */
534
582
  declare function drawBox(lines: string[], title?: string): string;
535
583
 
536
- export { COMMANDS, type CommandResult, type CompletionItem, CompletionProvider, type Condition, History, type ISLCommand, ISLREPL, ISL_COMMANDS, type Intent, KEYWORDS, META_COMMANDS, MemoryHistory, type MetaCommand, type REPLOptions, type Scenario, Session, type SessionConfig, colors, createCompleter, createSession, drawBox, findSimilarCommand, formatCondition, formatError, formatInfo, formatIntent, formatParseError, formatSuccess, formatTable, formatTypeError, formatValue, formatWarning, highlightExpression, highlightISL, islCommands, metaCommands, startREPL, stripColors, wrapText };
584
+ /**
585
+ * Main entry point
586
+ */
587
+ declare function main(): void;
588
+
589
+ export { COMMANDS, type CommandResult, type CompletionItem, CompletionProvider, type Condition, History, type ISLCommand, ISLREPL, ISL_COMMANDS, type Intent, KEYWORDS, META_COMMANDS, MemoryHistory, type MetaCommand, type REPLOptions, type Scenario, Session, type SessionConfig, colors, createCompleter, createSession, drawBox, findSimilarCommand, formatCondition, formatError, formatInfo, formatIntent, formatParseError, formatSuccess, formatTable, formatTypeError, formatValue, formatWarning, highlightExpression, highlightISL, islCommands, main, metaCommands, startREPL, stripColors, wrapText };
package/dist/index.d.ts CHANGED
@@ -49,6 +49,12 @@ declare class Session {
49
49
  private loadedFiles;
50
50
  /** Session configuration */
51
51
  private config;
52
+ /** Evaluation context (set by .context command) */
53
+ private evalContext;
54
+ /** Pre-state context for old() expressions */
55
+ private preContext;
56
+ /** Loaded domain AST (from real parser) */
57
+ private domainAST;
52
58
  constructor(config?: SessionConfig);
53
59
  /**
54
60
  * Define a new intent
@@ -128,6 +134,51 @@ declare class Session {
128
134
  success: boolean;
129
135
  error?: string;
130
136
  }>;
137
+ /**
138
+ * Set evaluation context from JSON string
139
+ */
140
+ setEvalContext(json: string): {
141
+ success: boolean;
142
+ count: number;
143
+ error?: string;
144
+ };
145
+ /**
146
+ * Set pre-state context for old() expressions
147
+ */
148
+ setPreContext(json: string): {
149
+ success: boolean;
150
+ error?: string;
151
+ };
152
+ /**
153
+ * Get evaluation context
154
+ */
155
+ getEvalContext(): Record<string, unknown>;
156
+ /**
157
+ * Get pre-state context
158
+ */
159
+ getPreContext(): Record<string, unknown> | null;
160
+ /**
161
+ * Resolve a dot-path against the evaluation context
162
+ */
163
+ resolveValue(dotPath: string): {
164
+ found: boolean;
165
+ value: unknown;
166
+ };
167
+ /**
168
+ * Resolve a dot-path against the pre-state context
169
+ */
170
+ resolvePreValue(dotPath: string): {
171
+ found: boolean;
172
+ value: unknown;
173
+ };
174
+ /**
175
+ * Set domain AST (from real parser)
176
+ */
177
+ setDomainAST(ast: unknown): void;
178
+ /**
179
+ * Get domain AST
180
+ */
181
+ getDomainAST(): unknown;
131
182
  /**
132
183
  * Clear all session state
133
184
  */
@@ -248,6 +299,12 @@ interface REPLOptions {
248
299
  colors?: boolean;
249
300
  verbose?: boolean;
250
301
  historyFile?: string;
302
+ /** Load an ISL file on startup */
303
+ load?: string;
304
+ /** Set initial evaluation context (JSON string) */
305
+ context?: string;
306
+ /** Parse-only mode (non-interactive, for piped input) */
307
+ parseOnly?: boolean;
251
308
  }
252
309
  /**
253
310
  * ISL REPL - Interactive Read-Eval-Print Loop
@@ -266,6 +323,14 @@ declare class ISLREPL {
266
323
  * Start the REPL
267
324
  */
268
325
  start(): void;
326
+ /**
327
+ * Apply startup options (--load, --context)
328
+ */
329
+ private applyStartupOptions;
330
+ /**
331
+ * Run in pipe mode (read all stdin, parse, and output)
332
+ */
333
+ private runPipeMode;
269
334
  /**
270
335
  * Print the welcome banner
271
336
  */
@@ -273,27 +338,19 @@ declare class ISLREPL {
273
338
  /**
274
339
  * Handle a line of input
275
340
  */
276
- private handleLine;
341
+ handleLine(line: string): void;
277
342
  /**
278
- * Handle a meta command (. prefix)
343
+ * Handle a dot command (. prefix)
279
344
  */
280
- private handleMetaCommand;
345
+ private handleDotCommand;
281
346
  /**
282
- * Handle an ISL command (: prefix)
283
- */
284
- private handleISLCommand;
285
- /**
286
- * Evaluate ISL code
347
+ * Evaluate ISL code (multi-line input or bare expressions)
287
348
  */
288
349
  private evaluate;
289
350
  /**
290
351
  * Evaluate an intent definition
291
352
  */
292
353
  private evaluateIntent;
293
- /**
294
- * Print a parse error with location info
295
- */
296
- private printParseError;
297
354
  /**
298
355
  * Print an error
299
356
  */
@@ -345,22 +402,13 @@ interface MetaCommand {
345
402
  usage: string;
346
403
  handler: (args: string[], session: Session, repl: REPL) => CommandResult;
347
404
  }
348
- /**
349
- * ISL command definition (: prefix)
350
- */
351
- interface ISLCommand {
352
- name: string;
353
- aliases: string[];
354
- description: string;
355
- usage: string;
356
- handler: (args: string[], session: Session, repl: REPL) => CommandResult;
357
- }
405
+ type ISLCommand = MetaCommand;
358
406
  declare const metaCommands: MetaCommand[];
359
407
  declare const islCommands: ISLCommand[];
360
408
  /**
361
409
  * Find a similar command name
362
410
  */
363
- declare function findSimilarCommand(input: string, type: 'meta' | 'isl'): string | null;
411
+ declare function findSimilarCommand(input: string, _type?: 'meta' | 'isl'): string | null;
364
412
 
365
413
  /**
366
414
  * Completion item
@@ -379,7 +427,7 @@ declare const KEYWORDS: CompletionItem[];
379
427
  */
380
428
  declare const META_COMMANDS: CompletionItem[];
381
429
  /**
382
- * ISL commands (: prefix)
430
+ * ISL commands (kept empty for backward compat — all commands use . prefix)
383
431
  */
384
432
  declare const ISL_COMMANDS: CompletionItem[];
385
433
  /**
@@ -533,4 +581,9 @@ declare function wrapText(text: string, maxWidth: number): string;
533
581
  */
534
582
  declare function drawBox(lines: string[], title?: string): string;
535
583
 
536
- export { COMMANDS, type CommandResult, type CompletionItem, CompletionProvider, type Condition, History, type ISLCommand, ISLREPL, ISL_COMMANDS, type Intent, KEYWORDS, META_COMMANDS, MemoryHistory, type MetaCommand, type REPLOptions, type Scenario, Session, type SessionConfig, colors, createCompleter, createSession, drawBox, findSimilarCommand, formatCondition, formatError, formatInfo, formatIntent, formatParseError, formatSuccess, formatTable, formatTypeError, formatValue, formatWarning, highlightExpression, highlightISL, islCommands, metaCommands, startREPL, stripColors, wrapText };
584
+ /**
585
+ * Main entry point
586
+ */
587
+ declare function main(): void;
588
+
589
+ export { COMMANDS, type CommandResult, type CompletionItem, CompletionProvider, type Condition, History, type ISLCommand, ISLREPL, ISL_COMMANDS, type Intent, KEYWORDS, META_COMMANDS, MemoryHistory, type MetaCommand, type REPLOptions, type Scenario, Session, type SessionConfig, colors, createCompleter, createSession, drawBox, findSimilarCommand, formatCondition, formatError, formatInfo, formatIntent, formatParseError, formatSuccess, formatTable, formatTypeError, formatValue, formatWarning, highlightExpression, highlightISL, islCommands, main, metaCommands, startREPL, stripColors, wrapText };