@dallaylaen/ski-interpreter 2.6.3 → 2.8.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,50 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.8.0] - 2026-04-23
9
+
10
+ ### BREAKING CHANGES
11
+
12
+ - `parse()` no longer auto-inlines aliases unless they are redefined; known aliases are preserved by name.
13
+ - `toposort()` signature changed to use options object instead of positional parameters.
14
+
15
+ ### Added
16
+
17
+ - `Expr.declare()` — emits a complete, round-trippable declaration of an expression including its dependencies.
18
+ - `parse(..., { canonize: true })` — calculates properties of intermediate aliases during parsing.
19
+ - `annotate()` — public rename of the semi-official `_setup()` method, with added documentation.
20
+ - Quest UI: "reveal solution" button added.
21
+ - Quest UI: raw user input is now saved when a quest is solved.
22
+ - CLI (`bin/ski.js`): outputs full declarations instead of bare expressions.
23
+
24
+ ### Changed
25
+
26
+ - `toJSON()` now outputs back-parsable declaration instead of just string.
27
+ - `toposort` moved into `expr.ts`.
28
+ - `extras.ts` delegates to `Expr.declare()` instead of re-implementing the logic.
29
+ - Internal type `{ ... }` renamed to `Record<string, Named>` for clarity.
30
+
31
+ ### Fixed
32
+
33
+ - `Expr.toLambda` was incorrectly preparing term (#24).
34
+
35
+ ## [2.7.0] - 2026-04-03
36
+
37
+ ### BREAKING CHANGES
38
+
39
+ - Remove `SKI.schemas`.
40
+
41
+ ### Added
42
+
43
+ - `SKI.extras.checkFormatOptions` that returns { value: FormatOptions }
44
+ or { error: object } for validating format options.
45
+ - Rendered documentation at https://dallaylaen.github.io/ski-interpreter/man
46
+
47
+ ### Changed
48
+ - Way better core documentation
49
+ - Removed [zod](https://www.npmjs.com/package/zod) dependency
50
+ for good, seems like overkill here.
51
+
8
52
  ## [2.6.3] - 2026-03-30
9
53
 
10
54
  ### Added
package/README.md CHANGED
@@ -124,6 +124,8 @@ will start a node shell with the `SKI` class available as a global variable.
124
124
 
125
125
  # Usage
126
126
 
127
+ See the [complete API reference](https://dallaylaen.github.io/ski-interpreter/man/) for gory details.
128
+
127
129
  ## A minimal example
128
130
 
129
131
  ```javascript
package/bin/ski.js CHANGED
@@ -8,6 +8,7 @@ const { Quest } = SKI;
8
8
  const { version } = require('../package.json');
9
9
 
10
10
  const runOptions = {};
11
+ /** @type FormatOptions */
11
12
  let format = {};
12
13
  let verbose = false;
13
14
 
@@ -165,20 +166,17 @@ function processLine (source, ski, onErr) {
165
166
  return; // nothing to see here
166
167
 
167
168
  try {
168
- const expr = ski.parse(source);
169
+ const expr = ski.parse(source, { canonize: true });
170
+ if (expr instanceof SKI.classes.Alias)
171
+ ski.add(expr);
169
172
  const t0 = new Date();
170
- const isAlias = expr instanceof SKI.classes.Alias;
171
- const aliasName = isAlias ? expr.name : null;
172
173
 
173
174
  for (const state of expr.walk(runOptions)) {
174
- if (state.final)
175
+ if (state.final) {
175
176
  console.log(`// ${state.steps} step(s) in ${new Date() - t0}ms`);
176
-
177
- if (verbose || state.final)
178
- console.log(state.expr.format(format));
179
-
180
- if (state.final && isAlias && aliasName)
181
- ski.add(aliasName, state.expr);
177
+ console.log(state.expr.declare({ ...format, inventory: ski.getTerms() }));
178
+ } else if (verbose)
179
+ console.log(state.expr.format(format) + ';');
182
180
  }
183
181
  } catch (err) {
184
182
  onErr(err);
@@ -389,7 +387,10 @@ function handleCommand (input, ski) {
389
387
  }
390
388
 
391
389
  function setFormat (options) {
392
- format = SKI.schemas.FormatOptions.parse(JSON.parse(options));
390
+ const maybe = SKI.extras.checkFormatOptions(JSON.parse(options));
391
+ if (!maybe.value)
392
+ throw new Error('Invalid format options: ' + JSON.stringify(maybe.error));
393
+ format = maybe.value;
393
394
  }
394
395
 
395
396
  function toInt (comment) {