@lousy-agents/cli 5.22.16 → 5.22.17

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.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@biomejs/biome": "2.5.15",
21
- "@lousy-agents/mcp": "5.22.15",
21
+ "@lousy-agents/mcp": "5.22.16",
22
22
  "@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
23
23
  "@testcontainers/postgresql": "12.2.1",
24
24
  "@types/node": "24.19.2",
@@ -958,9 +958,9 @@
958
958
  }
959
959
  },
960
960
  "node_modules/@lousy-agents/mcp": {
961
- "version": "5.22.15",
962
- "resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.22.15.tgz",
963
- "integrity": "sha512-ew1NbCMHNaupCB5tpils2bO5XnRS8TvvV5sxkHkZ2v+A8VyVtUWjNQ7uUiWfNAXMEh9MjYtL/A7pGeRnsr39qw==",
961
+ "version": "5.22.16",
962
+ "resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.22.16.tgz",
963
+ "integrity": "sha512-5tWj/Hcb1CIbaQ5+MMM1mQ6QQj+L12axG3Z5Curbta6vpOHFReEzrJjcyfeJh9uh1KkAaGcpjjnSGVxY/DCuxQ==",
964
964
  "dev": true,
965
965
  "license": "BSD-2-Clause-Patent",
966
966
  "dependencies": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@biomejs/biome": "2.5.15",
32
- "@lousy-agents/mcp": "5.22.15",
32
+ "@lousy-agents/mcp": "5.22.16",
33
33
  "@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
34
34
  "@testcontainers/postgresql": "12.2.1",
35
35
  "@types/node": "24.19.2",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@biomejs/biome": "2.5.15",
23
- "@lousy-agents/mcp": "5.22.15",
23
+ "@lousy-agents/mcp": "5.22.16",
24
24
  "@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
25
25
  "@types/node": "24.19.2",
26
26
  "chance": "1.1.13",
package/dist/index.js CHANGED
@@ -85192,8 +85192,12 @@ function encodeCharacterReference(code) {
85192
85192
 
85193
85193
  ;// CONCATENATED MODULE: ../../node_modules/unist-util-visit-parents/lib/color.node.js
85194
85194
  /**
85195
+ * Color a string.
85196
+ *
85195
85197
  * @param {string} d
85198
+ * Value.
85196
85199
  * @returns {string}
85200
+ * Colored value.
85197
85201
  */
85198
85202
  function color_node_color(d) {
85199
85203
  return '\u001B[33m' + d + '\u001B[39m'
@@ -85369,44 +85373,96 @@ function color_node_color(d) {
85369
85373
  * List with one or two values, the first an action, the second an index.
85370
85374
  *
85371
85375
  * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
85372
- * Any value that can be returned from a visitor.
85376
+ * Any value that can be returned from an enter visitor.
85377
+ *
85378
+ * Like `VisitorResultExit`,
85379
+ * but `SKIP` can also be returned,
85380
+ * to not walk the children of the node,
85381
+ * and `ActionTuple` can be used to combine an action with an index.
85382
+ *
85383
+ * @typedef {Index | boolean | null | undefined | void} VisitorResultExit
85384
+ * Any value that can be returned from an exit visitor.
85373
85385
  */
85374
85386
 
85375
85387
  /**
85376
85388
  * @callback Visitor
85377
- * Handle a node (matching `test`, if given).
85378
- *
85379
- * Visitors are free to transform `node`.
85380
- * They can also transform the parent of node (the last of `ancestors`).
85381
- *
85382
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
85383
- * descendants to be walked (which is a bug).
85384
- *
85385
- * When adding or removing previous siblings of `node` (or next siblings, in
85386
- * case of reverse), the `Visitor` should return a new `Index` to specify the
85387
- * sibling to traverse after `node` is traversed.
85388
- * Adding or removing next siblings of `node` (or previous siblings, in case
85389
- * of reverse) is handled as expected without needing to return a new `Index`.
85390
- *
85391
- * Removing the children property of an ancestor still results in them being
85392
- * traversed.
85389
+ * Handle a node (matching `test`, if given) before its children.
85390
+ *
85391
+ * Changes inside `node` are walked next.
85392
+ * Replacing or removing it is easier in `exit`.
85393
+ * When replacing or removing it here,
85394
+ * return `SKIP` (as otherwise its old children are walked),
85395
+ * or `[SKIP, index]` to continue with the node now at `index`.
85396
+ * Changing next siblings (in walk order) is fine;
85397
+ * changing previous siblings needs a new `Index`.
85398
+ * Removing an ancestor or changing its previous siblings is not supported.
85393
85399
  * @param {Visited} node
85394
85400
  * Found node.
85395
85401
  * @param {Array<VisitedParents>} ancestors
85396
85402
  * Ancestors of `node`.
85403
+ * @param {number | undefined} index
85404
+ * Index of `node` in its parent (the last of `ancestors`),
85405
+ * or `undefined` for the tree itself.
85397
85406
  * @returns {VisitorResult}
85398
85407
  * What to do next.
85399
85408
  *
85400
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
85401
- * An `Action` is treated as a tuple of `[Action]`.
85409
+ * Like `VisitorExit`,
85410
+ * but `SKIP` can also be returned,
85411
+ * to not walk the children of `node`.
85412
+ * Passing a tuple back (`ActionTuple`) only makes sense as `[SKIP, Index]`.
85413
+ * @template {UnistNode} [Visited=UnistNode]
85414
+ * Visited node type.
85415
+ * @template {UnistParent} [VisitedParents=UnistParent]
85416
+ * Ancestor type.
85417
+ */
85418
+
85419
+ /**
85420
+ * @callback VisitorExit
85421
+ * Handle a node (matching `test`, if given) after its children.
85422
+ *
85423
+ * Changes inside `node` are not walked,
85424
+ * which makes this a good place to change `node` based on its children,
85425
+ * or to replace or remove it.
85426
+ * When removing `node` or changing previous siblings (in walk order),
85427
+ * return a new `Index`.
85428
+ * Removing an ancestor or changing its previous siblings is not supported.
85429
+ * @param {Visited} node
85430
+ * Found node.
85431
+ * @param {Array<VisitedParents>} ancestors
85432
+ * Ancestors of `node`.
85433
+ * @param {number | undefined} index
85434
+ * Index of `node` in its parent (the last of `ancestors`),
85435
+ * or `undefined` for the tree itself.
85436
+ * @returns {VisitorResultExit}
85437
+ * What to do next.
85402
85438
  *
85403
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
85404
- * When the `Action` is `EXIT`, that action can be returned.
85405
- * When the `Action` is `CONTINUE`, `Index` can be returned.
85439
+ * `CONTINUE` (`true`, nothing) continues as normal,
85440
+ * `EXIT` (`false`) stops traversing,
85441
+ * and `Index` continues at that sibling.
85442
+ * @template {UnistNode} [Visited=UnistNode]
85443
+ * Visited node type.
85444
+ * @template {UnistParent} [VisitedParents=UnistParent]
85445
+ * Ancestor type.
85446
+ */
85447
+
85448
+ /**
85406
85449
  * @template {UnistNode} [Visited=UnistNode]
85407
85450
  * Visited node type.
85408
85451
  * @template {UnistParent} [VisitedParents=UnistParent]
85409
85452
  * Ancestor type.
85453
+ * @typedef Visitors
85454
+ * Handle nodes when entering and exiting them.
85455
+ * The `enter` visitor is optional while `exit` is required.
85456
+ *
85457
+ * Pass an `enter` visitor directly to only handle nodes when entering them.
85458
+ *
85459
+ * `enter` is called before children (if any) are walked and `exit` after that.
85460
+ * `exit` is still called when `enter` returns `SKIP`.
85461
+ * Both `enter` and `exit` are only called for nodes that match an optional `test`.
85462
+ * @property {Visitor<Visited, VisitedParents> | null | undefined} [enter]
85463
+ * Handle a node before its children (optional).
85464
+ * @property {VisitorExit<Visited, VisitedParents>} exit
85465
+ * Handle a node after its children.
85410
85466
  */
85411
85467
 
85412
85468
  /**
@@ -85420,6 +85476,17 @@ function color_node_color(d) {
85420
85476
  * Test type.
85421
85477
  */
85422
85478
 
85479
+ /**
85480
+ * @typedef {Visitors<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitors
85481
+ * Build typed `Visitors` from a tree and a test.
85482
+ *
85483
+ * It will infer which values are passed as `node` and which as `parents`.
85484
+ * @template {UnistNode} [Tree=UnistNode]
85485
+ * Tree type.
85486
+ * @template {Test} [Check=Test]
85487
+ * Test type.
85488
+ */
85489
+
85423
85490
 
85424
85491
 
85425
85492
 
@@ -85438,6 +85505,7 @@ const EXIT = false
85438
85505
 
85439
85506
  /**
85440
85507
  * Do not traverse this node’s children.
85508
+ * Only works when entering a node.
85441
85509
  */
85442
85510
  const SKIP = 'skip'
85443
85511
 
@@ -85445,10 +85513,13 @@ const SKIP = 'skip'
85445
85513
  * Visit nodes, with ancestral information.
85446
85514
  *
85447
85515
  * This algorithm performs *depth-first* *tree traversal* in *preorder*
85448
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
85516
+ * (**NLR**) or if `reverse` is given,
85517
+ * in *reverse preorder* (**NRL**).
85518
+ * An `exit` visitor is called in *postorder* (**LRN**)
85519
+ * or if `reverse` is given, in *reverse postorder* (**RLN**).
85449
85520
  *
85450
- * You can choose for which nodes `visitor` is called by passing a `test`.
85451
- * For complex tests, you should test yourself in `visitor`, as it will be
85521
+ * You can choose which nodes are visited by passing a `test`.
85522
+ * For complex tests, you should test yourself in a visitor, as it will be
85452
85523
  * faster and will have improved type information.
85453
85524
  *
85454
85525
  * Walking the tree is an intensive task.
@@ -85457,29 +85528,72 @@ const SKIP = 'skip'
85457
85528
  * to check if a node matches, and then perform different operations.
85458
85529
  *
85459
85530
  * You can change the tree.
85460
- * See `Visitor` for more info.
85531
+ * Changes inside a node made when entering it are walked,
85532
+ * changes made when exiting it are not.
85533
+ * See `Visitor` and `VisitorExit` for more info.
85534
+ *
85535
+ * @overload
85536
+ * @param {Tree} tree
85537
+ * Tree to traverse.
85538
+ * @param {Check} check
85539
+ * `unist-util-is`-compatible test.
85540
+ * @param {BuildVisitor<Tree, Check>} enter
85541
+ * Handle each node when entering it.
85542
+ * @param {boolean | null | undefined} [reverse]
85543
+ * Walk children from last to first;
85544
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85545
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85546
+ * @returns {undefined}
85547
+ * Nothing.
85461
85548
  *
85462
85549
  * @overload
85463
85550
  * @param {Tree} tree
85551
+ * Tree to traverse.
85464
85552
  * @param {Check} check
85465
- * @param {BuildVisitor<Tree, Check>} visitor
85553
+ * `unist-util-is`-compatible test.
85554
+ * @param {BuildVisitors<Tree, Check>} visitors
85555
+ * Handle each node when exiting it, and optionally when entering it.
85556
+ * @param {boolean | null | undefined} [reverse]
85557
+ * Walk children from last to first;
85558
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85559
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85560
+ * @returns {undefined}
85561
+ * Nothing.
85562
+ *
85563
+ * @overload
85564
+ * @param {Tree} tree
85565
+ * Tree to traverse.
85566
+ * @param {BuildVisitor<Tree>} enter
85567
+ * Handle each node when entering it.
85466
85568
  * @param {boolean | null | undefined} [reverse]
85569
+ * Walk children from last to first;
85570
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85571
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85467
85572
  * @returns {undefined}
85573
+ * Nothing.
85468
85574
  *
85469
85575
  * @overload
85470
85576
  * @param {Tree} tree
85471
- * @param {BuildVisitor<Tree>} visitor
85577
+ * Tree to traverse.
85578
+ * @param {BuildVisitors<Tree>} visitors
85579
+ * Handle each node when exiting it, and optionally when entering it.
85472
85580
  * @param {boolean | null | undefined} [reverse]
85581
+ * Walk children from last to first;
85582
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85583
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85473
85584
  * @returns {undefined}
85585
+ * Nothing.
85474
85586
  *
85475
85587
  * @param {UnistNode} tree
85476
85588
  * Tree to traverse.
85477
- * @param {Visitor | Test} test
85478
- * `unist-util-is`-compatible test
85479
- * @param {Visitor | boolean | null | undefined} [visitor]
85480
- * Handle each node.
85589
+ * @param {Visitor | Visitors | Test} testOrEnterOrVisitors
85590
+ * `unist-util-is`-compatible test, `enter`, or `visitors`.
85591
+ * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
85592
+ * `enter`, `visitors`, or `reverse` after a test.
85481
85593
  * @param {boolean | null | undefined} [reverse]
85482
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
85594
+ * Walk children from last to first;
85595
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85596
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85483
85597
  * @returns {undefined}
85484
85598
  * Nothing.
85485
85599
  *
@@ -85488,28 +85602,89 @@ const SKIP = 'skip'
85488
85602
  * @template {Test} Check
85489
85603
  * `unist-util-is`-compatible test.
85490
85604
  */
85491
- function visitParents(tree, test, visitor, reverse) {
85605
+ function visitParents(
85606
+ tree,
85607
+ testOrEnterOrVisitors,
85608
+ enterOrVisitorsOrReverse,
85609
+ reverse
85610
+ ) {
85611
+ if (!tree || typeof tree !== 'object') {
85612
+ throw new Error('Unexpected value `' + tree + '` for `tree`, expected node')
85613
+ }
85614
+
85615
+ let preorder = true
85492
85616
  /** @type {Test} */
85493
85617
  let check
85618
+ /** @type {Visitors | Visitor} */
85619
+ let visitors
85620
+ /** @type {Visitor | null | undefined} */
85621
+ let enter
85622
+ /** @type {VisitorExit | null | undefined} */
85623
+ let exit
85624
+
85625
+ // Third parameter is an enter visitor or a visitors object, so expect a `test` too.
85626
+ if (
85627
+ typeof enterOrVisitorsOrReverse === 'function' ||
85628
+ (enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
85629
+ ) {
85630
+ check = /** @type {Test} */ (testOrEnterOrVisitors)
85631
+ visitors = enterOrVisitorsOrReverse
85632
+ if (reverse) preorder = false
85633
+ }
85634
+ // Assume no test.
85635
+ else {
85636
+ visitors = /** @type {Visitors | Visitor} */ (testOrEnterOrVisitors)
85637
+ if (enterOrVisitorsOrReverse) preorder = false
85638
+ }
85639
+
85640
+ if (typeof visitors === 'function') {
85641
+ enter = visitors
85642
+ } else if (visitors && typeof visitors === 'object') {
85643
+ if (visitors.enter === null || visitors.enter === undefined) {
85644
+ // Empty.
85645
+ } else if (typeof visitors.enter === 'function') {
85646
+ enter = visitors.enter
85647
+ } else {
85648
+ throw new Error(
85649
+ 'Unexpected value `' +
85650
+ visitors.enter +
85651
+ '` for `visitors.enter`, expected optional visitor'
85652
+ )
85653
+ }
85494
85654
 
85495
- if (typeof test === 'function' && typeof visitor !== 'function') {
85496
- reverse = visitor
85497
- // @ts-expect-error no visitor given, so `visitor` is test.
85498
- visitor = test
85655
+ if (typeof visitors.exit === 'function') {
85656
+ exit = visitors.exit
85657
+ } else {
85658
+ throw new Error(
85659
+ 'Unexpected value `' +
85660
+ visitors.exit +
85661
+ '` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)'
85662
+ )
85663
+ }
85499
85664
  } else {
85500
- // @ts-expect-error visitor given, so `test` isn’t a visitor.
85501
- check = test
85665
+ throw new Error(
85666
+ 'Unexpected value `' +
85667
+ visitors +
85668
+ '` for `enter` or `visitors`, expected visitor or object with visitors'
85669
+ )
85502
85670
  }
85503
85671
 
85504
85672
  const is = convert(check)
85505
- const step = reverse ? -1 : 1
85673
+ const step = preorder ? 1 : -1
85506
85674
 
85507
85675
  factory(tree, undefined, [])()
85508
85676
 
85509
85677
  /**
85678
+ * Create a function to visit a node.
85679
+ *
85510
85680
  * @param {UnistNode} node
85681
+ * Node to visit.
85511
85682
  * @param {number | undefined} index
85683
+ * Index of `node` in its parent.
85512
85684
  * @param {Array<UnistParent>} parents
85685
+ * Ancestors of `node`.
85686
+ * @returns {() => Readonly<ActionTuple>}
85687
+ * Visit `node`.
85513
85688
  */
85514
85689
  function factory(node, index, parents) {
85515
85690
  const value = /** @type {Record<string, unknown>} */ (
@@ -85535,18 +85710,13 @@ function visitParents(tree, test, visitor, reverse) {
85535
85710
  return visit
85536
85711
 
85537
85712
  function visit() {
85713
+ const matches =
85714
+ !check || is(node, index, parents[parents.length - 1] || undefined)
85538
85715
  /** @type {Readonly<ActionTuple>} */
85539
85716
  let result = lib_empty
85540
- /** @type {Readonly<ActionTuple>} */
85541
- let subresult
85542
- /** @type {number} */
85543
- let offset
85544
- /** @type {Array<UnistParent>} */
85545
- let grandparents
85546
85717
 
85547
- if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
85548
- // @ts-expect-error: `visitor` is now a visitor.
85549
- result = lib_toResult(visitor(node, parents))
85718
+ if (enter && matches) {
85719
+ result = lib_toResult(enter(node, parents, index))
85550
85720
 
85551
85721
  if (result[0] === EXIT) {
85552
85722
  return result
@@ -85557,13 +85727,13 @@ function visitParents(tree, test, visitor, reverse) {
85557
85727
  const nodeAsParent = /** @type {UnistParent} */ (node)
85558
85728
 
85559
85729
  if (nodeAsParent.children && result[0] !== SKIP) {
85560
- offset = (reverse ? nodeAsParent.children.length : -1) + step
85561
- grandparents = parents.concat(nodeAsParent)
85730
+ let offset = (preorder ? -1 : nodeAsParent.children.length) + step
85731
+ const grandparents = [...parents, nodeAsParent]
85562
85732
 
85563
85733
  while (offset > -1 && offset < nodeAsParent.children.length) {
85564
85734
  const child = nodeAsParent.children[offset]
85565
85735
 
85566
- subresult = factory(child, offset, grandparents)()
85736
+ const subresult = factory(child, offset, grandparents)()
85567
85737
 
85568
85738
  if (subresult[0] === EXIT) {
85569
85739
  return subresult
@@ -85575,6 +85745,23 @@ function visitParents(tree, test, visitor, reverse) {
85575
85745
  }
85576
85746
  }
85577
85747
 
85748
+ if (exit && matches) {
85749
+ const exitResult = lib_toResult(exit(node, parents, index))
85750
+
85751
+ if (exitResult[0] === SKIP) {
85752
+ throw new Error(
85753
+ 'Unexpected value `' +
85754
+ exitResult[0] +
85755
+ '` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing'
85756
+ )
85757
+ }
85758
+
85759
+ // Prefer a result from `exit` over `enter`.
85760
+ if (exitResult[0] === EXIT || typeof exitResult[1] === 'number') {
85761
+ return exitResult
85762
+ }
85763
+ }
85764
+
85578
85765
  return result
85579
85766
  }
85580
85767
  }
@@ -85603,7 +85790,13 @@ function lib_toResult(value) {
85603
85790
  ;// CONCATENATED MODULE: ../../node_modules/unist-util-visit/lib/index.js
85604
85791
  /**
85605
85792
  * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
85606
- * @import {VisitorResult} from 'unist-util-visit-parents'
85793
+ * @import {
85794
+ * InclusiveDescendant,
85795
+ * Matches,
85796
+ * Visitors as ParentsVisitors,
85797
+ * VisitorResult,
85798
+ * VisitorResultExit
85799
+ * } from 'unist-util-visit-parents'
85607
85800
  */
85608
85801
 
85609
85802
  /**
@@ -85615,67 +85808,6 @@ function lib_toResult(value) {
85615
85808
  * which doesn’t work when publishing on npm.
85616
85809
  */
85617
85810
 
85618
- // To do: use types from `unist-util-visit-parents` when it’s released.
85619
-
85620
- /**
85621
- * @typedef {(
85622
- * Fn extends (value: any) => value is infer Thing
85623
- * ? Thing
85624
- * : Fallback
85625
- * )} Predicate
85626
- * Get the value of a type guard `Fn`.
85627
- * @template Fn
85628
- * Value; typically function that is a type guard (such as `(x): x is Y`).
85629
- * @template Fallback
85630
- * Value to yield if `Fn` is not a type guard.
85631
- */
85632
-
85633
- /**
85634
- * @typedef {(
85635
- * Check extends null | undefined // No test.
85636
- * ? Value
85637
- * : Value extends {type: Check} // String (type) test.
85638
- * ? Value
85639
- * : Value extends Check // Partial test.
85640
- * ? Value
85641
- * : Check extends Function // Function test.
85642
- * ? Predicate<Check, Value> extends Value
85643
- * ? Predicate<Check, Value>
85644
- * : never
85645
- * : never // Some other test?
85646
- * )} MatchesOne
85647
- * Check whether a node matches a primitive check in the type system.
85648
- * @template Value
85649
- * Value; typically unist `Node`.
85650
- * @template Check
85651
- * Value; typically `unist-util-is`-compatible test, but not arrays.
85652
- */
85653
-
85654
- /**
85655
- * @typedef {(
85656
- * Check extends ReadonlyArray<any>
85657
- * ? MatchesOne<Value, Check[number]>
85658
- * : MatchesOne<Value, Check>
85659
- * )} Matches
85660
- * Check whether a node matches a check in the type system.
85661
- * @template Value
85662
- * Value; typically unist `Node`.
85663
- * @template Check
85664
- * Value; typically `unist-util-is`-compatible test.
85665
- */
85666
-
85667
- /**
85668
- * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
85669
- * Number; capped reasonably.
85670
- */
85671
-
85672
- /**
85673
- * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
85674
- * Increment a number in the type system.
85675
- * @template {Uint} [I=0]
85676
- * Index.
85677
- */
85678
-
85679
85811
  /**
85680
85812
  * @typedef {(
85681
85813
  * Node extends UnistParent
@@ -85701,89 +85833,64 @@ function lib_toResult(value) {
85701
85833
  */
85702
85834
 
85703
85835
  /**
85704
- * @typedef {(
85705
- * Depth extends Max
85706
- * ? never
85707
- * :
85708
- * | InternalParent<Node, Child>
85709
- * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
85710
- * )} InternalAncestor
85711
- * Collect nodes in `Tree` that can be ancestors of `Child`.
85712
- * @template {UnistNode} Node
85713
- * All node types in a tree.
85714
- * @template {UnistNode} Child
85715
- * Node to search for.
85716
- * @template {Uint} [Max=10]
85717
- * Max; searches up to this depth.
85718
- * @template {Uint} [Depth=0]
85719
- * Current depth.
85720
- */
85721
-
85722
- /**
85723
- * @typedef {(
85724
- * Tree extends UnistParent
85725
- * ? Depth extends Max
85726
- * ? Tree
85727
- * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
85728
- * : Tree
85729
- * )} InclusiveDescendant
85730
- * Collect all (inclusive) descendants of `Tree`.
85836
+ * @callback Visitor
85837
+ * Handle a node (matching `test`, if given) before its children.
85731
85838
  *
85732
- * > 👉 **Note**: for performance reasons, this seems to be the fastest way to
85733
- * > recurse without actually running into an infinite loop, which the
85734
- * > previous version did.
85735
- * >
85736
- * > Practically, a max of `2` is typically enough assuming a `Root` is
85737
- * > passed, but it doesn’t improve performance.
85738
- * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
85739
- * > Using up to `10` doesn’t hurt or help either.
85740
- * @template {UnistNode} Tree
85741
- * Tree type.
85742
- * @template {Uint} [Max=10]
85743
- * Max; searches up to this depth.
85744
- * @template {Uint} [Depth=0]
85745
- * Current depth.
85839
+ * Like `Visitor` in `unist-util-visit-parents`,
85840
+ * but with `index` and `parent` instead of `parents`.
85841
+ * @param {Visited} node
85842
+ * Found node.
85843
+ * @param {Visited extends UnistNode ? number | undefined : never} index
85844
+ * Index of `node` in `parent`,
85845
+ * or `undefined` for the tree itself.
85846
+ * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
85847
+ * Parent of `node`,
85848
+ * or `undefined` for the tree itself.
85849
+ * @returns {VisitorResult}
85850
+ * What to do next.
85851
+ * @template {UnistNode} [Visited=UnistNode]
85852
+ * Visited node type.
85853
+ * @template {UnistParent} [Ancestor=UnistParent]
85854
+ * Ancestor type.
85746
85855
  */
85747
85856
 
85748
85857
  /**
85749
- * @callback Visitor
85750
- * Handle a node (matching `test`, if given).
85751
- *
85752
- * Visitors are free to transform `node`.
85753
- * They can also transform `parent`.
85754
- *
85755
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
85756
- * descendants to be walked (which is a bug).
85858
+ * @callback VisitorExit
85859
+ * Handle a node (matching `test`, if given) after its children.
85757
85860
  *
85758
- * When adding or removing previous siblings of `node` (or next siblings, in
85759
- * case of reverse), the `Visitor` should return a new `Index` to specify the
85760
- * sibling to traverse after `node` is traversed.
85761
- * Adding or removing next siblings of `node` (or previous siblings, in case
85762
- * of reverse) is handled as expected without needing to return a new `Index`.
85763
- *
85764
- * Removing the children property of `parent` still results in them being
85765
- * traversed.
85861
+ * Like `VisitorExit` in `unist-util-visit-parents`,
85862
+ * but with `index` and `parent` instead of `parents`.
85766
85863
  * @param {Visited} node
85767
85864
  * Found node.
85768
85865
  * @param {Visited extends UnistNode ? number | undefined : never} index
85769
- * Index of `node` in `parent`.
85866
+ * Index of `node` in `parent`,
85867
+ * or `undefined` for the tree itself.
85770
85868
  * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
85771
- * Parent of `node`.
85772
- * @returns {VisitorResult}
85869
+ * Parent of `node`,
85870
+ * or `undefined` for the tree itself.
85871
+ * @returns {VisitorResultExit}
85773
85872
  * What to do next.
85774
- *
85775
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
85776
- * An `Action` is treated as a tuple of `[Action]`.
85777
- *
85778
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
85779
- * When the `Action` is `EXIT`, that action can be returned.
85780
- * When the `Action` is `CONTINUE`, `Index` can be returned.
85781
85873
  * @template {UnistNode} [Visited=UnistNode]
85782
85874
  * Visited node type.
85783
85875
  * @template {UnistParent} [Ancestor=UnistParent]
85784
85876
  * Ancestor type.
85785
85877
  */
85786
85878
 
85879
+ /**
85880
+ * @template {UnistNode} [Visited=UnistNode]
85881
+ * Visited node type.
85882
+ * @template {UnistParent} [Ancestor=UnistParent]
85883
+ * Ancestor type.
85884
+ * @typedef Visitors
85885
+ * Handle nodes when entering and exiting them.
85886
+ *
85887
+ * Like `Visitors` in `unist-util-visit-parents`.
85888
+ * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
85889
+ * Handle a node before its children (optional).
85890
+ * @property {VisitorExit<Visited, Ancestor>} exit
85891
+ * Handle a node after its children.
85892
+ */
85893
+
85787
85894
  /**
85788
85895
  * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
85789
85896
  * Build a typed `Visitor` function from a node and all possible parents.
@@ -85827,6 +85934,25 @@ function lib_toResult(value) {
85827
85934
  * Test type.
85828
85935
  */
85829
85936
 
85937
+ /**
85938
+ * @typedef {(
85939
+ * Visitors<
85940
+ * Matches<InclusiveDescendant<Tree>, Check>,
85941
+ * Parent<
85942
+ * Extract<InclusiveDescendant<Tree>, UnistParent>,
85943
+ * Matches<InclusiveDescendant<Tree>, Check>
85944
+ * >
85945
+ * >
85946
+ * )} BuildVisitors
85947
+ * Build typed `Visitors` from a tree and a test.
85948
+ *
85949
+ * It will infer which values are passed as `node` and which as `parent`.
85950
+ * @template {UnistNode} [Tree=UnistNode]
85951
+ * Node type.
85952
+ * @template {Test} [Check=Test]
85953
+ * Test type.
85954
+ */
85955
+
85830
85956
 
85831
85957
 
85832
85958
 
@@ -85835,10 +85961,13 @@ function lib_toResult(value) {
85835
85961
  * Visit nodes.
85836
85962
  *
85837
85963
  * This algorithm performs *depth-first* *tree traversal* in *preorder*
85838
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
85964
+ * (**NLR**) or if `reverse` is given,
85965
+ * in *reverse preorder* (**NRL**).
85966
+ * An `exit` visitor is called in *postorder* (**LRN**)
85967
+ * or if `reverse` is given, in *reverse postorder* (**RLN**).
85839
85968
  *
85840
- * You can choose for which nodes `visitor` is called by passing a `test`.
85841
- * For complex tests, you should test yourself in `visitor`, as it will be
85969
+ * You can choose which nodes are visited by passing a `test`.
85970
+ * For complex tests, you should test yourself in a visitor, as it will be
85842
85971
  * faster and will have improved type information.
85843
85972
  *
85844
85973
  * Walking the tree is an intensive task.
@@ -85847,29 +85976,48 @@ function lib_toResult(value) {
85847
85976
  * to check if a node matches, and then perform different operations.
85848
85977
  *
85849
85978
  * You can change the tree.
85850
- * See `Visitor` for more info.
85979
+ * Changes inside a node made when entering it are walked,
85980
+ * changes made when exiting it are not.
85981
+ * See `Visitor` and `VisitorExit` for more info.
85851
85982
  *
85852
85983
  * @overload
85853
85984
  * @param {Tree} tree
85985
+ * Tree to traverse.
85854
85986
  * @param {Check} check
85855
- * @param {BuildVisitor<Tree, Check>} visitor
85987
+ * `unist-util-is`-compatible test.
85988
+ * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
85989
+ * Handle each node when entering it,
85990
+ * or `{enter, exit}` to also handle it when exiting it.
85856
85991
  * @param {boolean | null | undefined} [reverse]
85992
+ * Walk children from last to first;
85993
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
85994
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85857
85995
  * @returns {undefined}
85996
+ * Nothing.
85858
85997
  *
85859
85998
  * @overload
85860
85999
  * @param {Tree} tree
85861
- * @param {BuildVisitor<Tree>} visitor
86000
+ * Tree to traverse.
86001
+ * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
86002
+ * Handle each node when entering it,
86003
+ * or `{enter, exit}` to also handle it when exiting it.
85862
86004
  * @param {boolean | null | undefined} [reverse]
86005
+ * Walk children from last to first;
86006
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
86007
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85863
86008
  * @returns {undefined}
86009
+ * Nothing.
85864
86010
  *
85865
86011
  * @param {UnistNode} tree
85866
86012
  * Tree to traverse.
85867
- * @param {Visitor | Test} testOrVisitor
85868
- * `unist-util-is`-compatible test (optional, omit to pass a visitor).
85869
- * @param {Visitor | boolean | null | undefined} [visitorOrReverse]
85870
- * Handle each node (when test is omitted, pass `reverse`).
85871
- * @param {boolean | null | undefined} [maybeReverse=false]
85872
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
86013
+ * @param {Visitor | Visitors | Test} testOrEnterOrVisitors
86014
+ * `unist-util-is`-compatible test, `enter`, or `visitors`.
86015
+ * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
86016
+ * `enter`, `visitors`, or `reverse` after a test.
86017
+ * @param {boolean | null | undefined} [maybeReverse]
86018
+ * Walk children from last to first;
86019
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
86020
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
85873
86021
  * @returns {undefined}
85874
86022
  * Nothing.
85875
86023
  *
@@ -85878,39 +86026,90 @@ function lib_toResult(value) {
85878
86026
  * @template {Test} Check
85879
86027
  * `unist-util-is`-compatible test.
85880
86028
  */
85881
- function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
86029
+ function lib_visit(
86030
+ tree,
86031
+ testOrEnterOrVisitors,
86032
+ enterOrVisitorsOrReverse,
86033
+ maybeReverse
86034
+ ) {
86035
+ /** @type {Test} */
86036
+ let check
86037
+ /** @type {Visitor | Visitors} */
86038
+ let visitors
85882
86039
  /** @type {boolean | null | undefined} */
85883
86040
  let reverse
85884
- /** @type {Test} */
85885
- let test
85886
- /** @type {Visitor} */
85887
- let visitor
85888
86041
 
86042
+ // Third parameter is an enter visitor or a visitors object, so expect a `test` too.
85889
86043
  if (
85890
- typeof testOrVisitor === 'function' &&
85891
- typeof visitorOrReverse !== 'function'
86044
+ typeof enterOrVisitorsOrReverse === 'function' ||
86045
+ (enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
85892
86046
  ) {
85893
- test = undefined
85894
- visitor = testOrVisitor
85895
- reverse = visitorOrReverse
85896
- } else {
85897
- // @ts-expect-error: assume the overload with test was given.
85898
- test = testOrVisitor
85899
- // @ts-expect-error: assume the overload with test was given.
85900
- visitor = visitorOrReverse
86047
+ check = /** @type {Test} */ (testOrEnterOrVisitors)
86048
+ visitors = enterOrVisitorsOrReverse
85901
86049
  reverse = maybeReverse
85902
86050
  }
86051
+ // Assume no test.
86052
+ else {
86053
+ visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)
86054
+ reverse = enterOrVisitorsOrReverse
86055
+ }
85903
86056
 
85904
- visitParents(tree, test, overload, reverse)
86057
+ if (typeof visitors === 'function') {
86058
+ visitParents(tree, check, lib_wrap(visitors), reverse)
86059
+ } else {
86060
+ visitParents(tree, check, wrapVisitors(visitors), reverse)
86061
+ }
86062
+ }
86063
+
86064
+ /**
86065
+ * Turn `visit` visitors into `visitParents` visitors.
86066
+ *
86067
+ * @param {Visitors} visitors
86068
+ * Visitors for `visit`.
86069
+ * @returns {ParentsVisitors}
86070
+ * Visitors for `visitParents`.
86071
+ */
86072
+ function wrapVisitors(visitors) {
86073
+ // Pass anything else straight to `visitParents` to get its errors.
86074
+ if (!visitors || typeof visitors !== 'object') return visitors
86075
+
86076
+ return {
86077
+ enter:
86078
+ typeof visitors.enter === 'function'
86079
+ ? lib_wrap(visitors.enter)
86080
+ : visitors.enter,
86081
+ exit:
86082
+ typeof visitors.exit === 'function' ? lib_wrap(visitors.exit) : visitors.exit
86083
+ }
86084
+ }
86085
+
86086
+ /**
86087
+ * Turn a `visit` visitor into a `visitParents` one.
86088
+ *
86089
+ * @template {VisitorResult} Result
86090
+ * Result type.
86091
+ * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
86092
+ * Visitor for `visit`.
86093
+ * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
86094
+ * Visitor for `visitParents`.
86095
+ */
86096
+ function lib_wrap(visitor) {
86097
+ return overload
85905
86098
 
85906
86099
  /**
86100
+ * Call `visitor` with `index` and `parent` instead of `parents`.
86101
+ *
85907
86102
  * @param {UnistNode} node
86103
+ * Visited node.
85908
86104
  * @param {Array<UnistParent>} parents
86105
+ * Ancestors of `node`.
86106
+ * @param {number | undefined} index
86107
+ * Index of `node` in its parent.
86108
+ * @returns {Result}
86109
+ * What to do next.
85909
86110
  */
85910
- function overload(node, parents) {
85911
- const parent = parents[parents.length - 1]
85912
- const index = parent ? parent.children.indexOf(node) : undefined
85913
- return visitor(node, index, parent)
86111
+ function overload(node, parents, index) {
86112
+ return visitor(node, index, parents[parents.length - 1])
85914
86113
  }
85915
86114
  }
85916
86115
 
@@ -89233,7 +89432,7 @@ function trough() {
89233
89432
 
89234
89433
  // Next or done.
89235
89434
  if (fn) {
89236
- lib_wrap(fn, next)(...output)
89435
+ trough_lib_wrap(fn, next)(...output)
89237
89436
  } else {
89238
89437
  callback(null, ...output)
89239
89438
  }
@@ -89285,7 +89484,7 @@ function trough() {
89285
89484
  * @returns {Run}
89286
89485
  * Wrapped middleware.
89287
89486
  */
89288
- function lib_wrap(middleware, callback) {
89487
+ function trough_lib_wrap(middleware, callback) {
89289
89488
  /** @type {boolean} */
89290
89489
  let called
89291
89490
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/cli",
3
- "version": "5.22.16",
3
+ "version": "5.22.17",
4
4
  "description": "CLI scaffolding tool that sets up projects with structure, instructions, and feedback loops for AI coding assistants",
5
5
  "type": "module",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "devDependencies": {
24
24
  "@biomejs/biome": "2.5.15",
25
25
  "@eslint/eslintrc": "3.3.7",
26
- "@lousy-agents/mcp": "5.22.15",
26
+ "@lousy-agents/mcp": "5.22.16",
27
27
  "@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
28
28
  "@testing-library/jest-dom": "7.0.1",
29
29
  "@testing-library/react": "16.3.3",