@kitman-sh/cli 0.44.0 → 0.46.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/dist/{chunk-gw0pc35c.js → chunk-0511zsxk.js} +430 -55
- package/dist/{chunk-5ccz7ghp.js → chunk-16wyj1eq.js} +42 -33
- package/dist/{chunk-3mbp8cse.js → chunk-2xeq2a7j.js} +31 -174
- package/dist/{chunk-9h16pekj.js → chunk-5tgpa02q.js} +1 -1
- package/dist/{chunk-134jdvs6.js → chunk-6evexbdx.js} +14 -60
- package/dist/{chunk-wh3pjr9r.js → chunk-7wq13jgx.js} +13 -13
- package/dist/{chunk-zvmdyf3v.js → chunk-8qbem52x.js} +39 -39
- package/dist/{chunk-ncp13gyf.js → chunk-9hqskzqc.js} +2 -2
- package/dist/{chunk-8a7337s1.js → chunk-apv9h5tz.js} +1 -1
- package/dist/{chunk-qkwkxn4d.js → chunk-bc40mcq9.js} +76 -76
- package/dist/{chunk-d0rx9esz.js → chunk-c6pnj2aj.js} +7 -7
- package/dist/{chunk-3zy2vbp0.js → chunk-e1v0c57f.js} +10 -10
- package/dist/{chunk-wkg1v0kd.js → chunk-j0b47jdz.js} +5 -5
- package/dist/{chunk-k2re3tp5.js → chunk-k1fdsn2c.js} +1 -1
- package/dist/{chunk-hmctc4eq.js → chunk-m5wqyzhk.js} +3 -3
- package/dist/{chunk-dp6v658s.js → chunk-mxy4wzhs.js} +4 -4
- package/dist/{chunk-zkvrxna8.js → chunk-n00cpb86.js} +2 -2
- package/dist/{chunk-x0ma41ys.js → chunk-n381rqax.js} +226 -40
- package/dist/{chunk-7rj9d0rp.js → chunk-nyagtr2t.js} +3 -3
- package/dist/{chunk-1k6z8q79.js → chunk-pty4b78m.js} +299 -117
- package/dist/{chunk-1c4wk9dr.js → chunk-qfwhsqej.js} +3 -3
- package/dist/{chunk-dre4f6s4.js → chunk-qy0enebe.js} +9 -9
- package/dist/{chunk-j60f2tr1.js → chunk-t2x4p5sp.js} +4 -4
- package/dist/{chunk-d2tpz1yp.js → chunk-tsw66qp3.js} +1 -1
- package/dist/{chunk-wvnsqt17.js → chunk-w0tzm3fg.js} +6 -6
- package/dist/{chunk-dj873p0e.js → chunk-x38fytew.js} +92 -26
- package/dist/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
decodeText,
|
|
4
|
-
mkString,
|
|
5
|
-
FileSystem,
|
|
6
|
-
Path,
|
|
7
|
-
withDefault,
|
|
8
|
-
String2
|
|
9
|
-
} from "./chunk-3mbp8cse.js";
|
|
10
2
|
import {
|
|
11
3
|
isString,
|
|
12
4
|
isObject,
|
|
@@ -43,7 +35,7 @@ import {
|
|
|
43
35
|
toCodecJson,
|
|
44
36
|
Json,
|
|
45
37
|
encodePrettyJsonString
|
|
46
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-n381rqax.js";
|
|
47
39
|
import {
|
|
48
40
|
SecureRandom,
|
|
49
41
|
layerWebCrypto,
|
|
@@ -60,26 +52,34 @@ import {
|
|
|
60
52
|
KitDeclarations,
|
|
61
53
|
kitmanMcpServer,
|
|
62
54
|
RunnerRpcProtocolVersion
|
|
63
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-pty4b78m.js";
|
|
56
|
+
import {
|
|
57
|
+
decodeText,
|
|
58
|
+
mkString,
|
|
59
|
+
FileSystem,
|
|
60
|
+
Path,
|
|
61
|
+
withDefault,
|
|
62
|
+
String2
|
|
63
|
+
} from "./chunk-2xeq2a7j.js";
|
|
64
64
|
import {
|
|
65
65
|
Packument,
|
|
66
66
|
tarballMatches
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-m5wqyzhk.js";
|
|
68
|
+
import {
|
|
69
|
+
ChildProcessSpawner,
|
|
70
|
+
make2
|
|
71
|
+
} from "./chunk-6evexbdx.js";
|
|
68
72
|
import {
|
|
69
73
|
stepDefinedTwice,
|
|
70
74
|
hostSteps,
|
|
71
75
|
exports_activities,
|
|
72
76
|
describeFlag,
|
|
73
77
|
Described
|
|
74
|
-
} from "./chunk-
|
|
75
|
-
import"./chunk-
|
|
76
|
-
import"./chunk-
|
|
77
|
-
import
|
|
78
|
-
|
|
79
|
-
make3
|
|
80
|
-
} from "./chunk-134jdvs6.js";
|
|
81
|
-
import"./chunk-wkg1v0kd.js";
|
|
82
|
-
import"./chunk-9h16pekj.js";
|
|
78
|
+
} from "./chunk-x38fytew.js";
|
|
79
|
+
import"./chunk-c6pnj2aj.js";
|
|
80
|
+
import"./chunk-k1fdsn2c.js";
|
|
81
|
+
import"./chunk-j0b47jdz.js";
|
|
82
|
+
import"./chunk-5tgpa02q.js";
|
|
83
83
|
|
|
84
84
|
// packages/sdk/src/build/outline/graph.ts
|
|
85
85
|
import {
|
|
@@ -485,6 +485,368 @@ var loadGraph = (root) => gen(function* () {
|
|
|
485
485
|
return { modules, entry };
|
|
486
486
|
});
|
|
487
487
|
|
|
488
|
+
// packages/sdk/src/build/outline/free-text.ts
|
|
489
|
+
var testedBy = new Set([
|
|
490
|
+
"endsWith",
|
|
491
|
+
"includes",
|
|
492
|
+
"indexOf",
|
|
493
|
+
"lastIndexOf",
|
|
494
|
+
"localeCompare",
|
|
495
|
+
"match",
|
|
496
|
+
"matchAll",
|
|
497
|
+
"search",
|
|
498
|
+
"startsWith"
|
|
499
|
+
]);
|
|
500
|
+
var lookingUp = new Set([...testedBy, "equals", "exec", "get", "has", "is", "test"]);
|
|
501
|
+
var comparisons = new Set(["===", "!==", "==", "!=", "<", ">", "<=", ">=", "in"]);
|
|
502
|
+
var successHandlers = new Set(["map", "flatMap", "andThen", "tap"]);
|
|
503
|
+
var elementHandlers = new Set([
|
|
504
|
+
"every",
|
|
505
|
+
"filter",
|
|
506
|
+
"find",
|
|
507
|
+
"findIndex",
|
|
508
|
+
"flatMap",
|
|
509
|
+
"forEach",
|
|
510
|
+
"map",
|
|
511
|
+
"some"
|
|
512
|
+
]);
|
|
513
|
+
var wordless = new Set(["blank", "length"]);
|
|
514
|
+
var unwrapped = new Set([
|
|
515
|
+
"AwaitExpression",
|
|
516
|
+
"ParenthesizedExpression",
|
|
517
|
+
"TSAsExpression",
|
|
518
|
+
"TSNonNullExpression",
|
|
519
|
+
"TSSatisfiesExpression",
|
|
520
|
+
"TSTypeAssertion",
|
|
521
|
+
"ChainExpression"
|
|
522
|
+
]);
|
|
523
|
+
var effectModules = new Set(["effect", "effect/Effect"]);
|
|
524
|
+
var maxDepth = 40;
|
|
525
|
+
var isFunction = (node) => node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression" || node?.type === "FunctionDeclaration";
|
|
526
|
+
var nameOf = (node) => node.type === "Identifier" ? node.name : node.type === "Literal" && isString(node.value) ? node.value : undefined;
|
|
527
|
+
var memberName = (node) => node.type !== "MemberExpression" ? undefined : node.computed ? node.property.type === "Literal" && isString(node.property.value) ? node.property.value : undefined : nameOf(node.property);
|
|
528
|
+
var nodesOf = (root) => {
|
|
529
|
+
const nodes = [];
|
|
530
|
+
const pending = [root];
|
|
531
|
+
for (let node = pending.pop();node !== undefined; node = pending.pop()) {
|
|
532
|
+
nodes.push(node);
|
|
533
|
+
pending.push(...childrenOf(node));
|
|
534
|
+
}
|
|
535
|
+
return nodes;
|
|
536
|
+
};
|
|
537
|
+
var freeTextComparisons = (graph) => {
|
|
538
|
+
const modules = [...graph.modules.values()].filter((module) => !module.sdk);
|
|
539
|
+
const nodes = new Map(modules.map((module) => [module, nodesOf(module.program)]));
|
|
540
|
+
const declarators = new Set;
|
|
541
|
+
const parameters = new Map;
|
|
542
|
+
const returning = new Set;
|
|
543
|
+
const resolveTarget = (target, name, depth) => {
|
|
544
|
+
if (depth > maxDepth)
|
|
545
|
+
return;
|
|
546
|
+
if (target.kind === "sdk")
|
|
547
|
+
return { kind: "sdk", name };
|
|
548
|
+
if (target.kind === "external")
|
|
549
|
+
return { kind: "external", specifier: target.specifier, name };
|
|
550
|
+
const module = graph.modules.get(target.path);
|
|
551
|
+
if (module === undefined || name === "*")
|
|
552
|
+
return;
|
|
553
|
+
if (module.sdk)
|
|
554
|
+
return { kind: "sdk", name };
|
|
555
|
+
const entry = module.exports.get(name);
|
|
556
|
+
if (entry === undefined) {
|
|
557
|
+
for (const star of module.stars) {
|
|
558
|
+
const found = resolveTarget(star, name, depth + 1);
|
|
559
|
+
if (found !== undefined)
|
|
560
|
+
return found;
|
|
561
|
+
}
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (entry.kind === "reexport")
|
|
565
|
+
return resolveTarget(entry.target, entry.imported, depth + 1);
|
|
566
|
+
return entry.kind === "local" ? resolveName(module, entry.name, module.program, depth + 1) : undefined;
|
|
567
|
+
};
|
|
568
|
+
const resolveName = (module, name, at, depth = 0) => {
|
|
569
|
+
const binding = lookup(module, name, at);
|
|
570
|
+
return binding?.kind === "import" ? resolveTarget(binding.target, binding.imported, depth) : binding;
|
|
571
|
+
};
|
|
572
|
+
const resolved = (module, node) => node.type === "Identifier" ? resolveName(module, node.name, node) : undefined;
|
|
573
|
+
const isEffect = (module, node) => {
|
|
574
|
+
const found = resolved(module, node);
|
|
575
|
+
return found?.kind === "external" && effectModules.has(found.specifier) && (found.name === "*" || found.name === "Effect");
|
|
576
|
+
};
|
|
577
|
+
const effectCall = (module, node) => node.type === "CallExpression" && node.callee.type === "MemberExpression" && isEffect(module, node.callee.object) ? memberName(node.callee) : undefined;
|
|
578
|
+
const isPipe = (module, node) => {
|
|
579
|
+
const found = resolved(module, node);
|
|
580
|
+
return found?.kind === "external" && found.name === "pipe";
|
|
581
|
+
};
|
|
582
|
+
const functionOf = (module, node) => {
|
|
583
|
+
if (node === undefined)
|
|
584
|
+
return;
|
|
585
|
+
if (isFunction(node))
|
|
586
|
+
return node;
|
|
587
|
+
const found = resolved(module, node);
|
|
588
|
+
if (found?.kind === "function")
|
|
589
|
+
return found.node;
|
|
590
|
+
const init = found?.kind === "declarator" ? found.declarator.init ?? undefined : undefined;
|
|
591
|
+
return isFunction(init) ? init : undefined;
|
|
592
|
+
};
|
|
593
|
+
const isSdkAsk = (module, call) => {
|
|
594
|
+
const { callee } = call;
|
|
595
|
+
if (callee.type === "MemberExpression") {
|
|
596
|
+
const namespace = resolved(module, callee.object);
|
|
597
|
+
return namespace?.kind === "sdk" && namespace.name === "*" && memberName(callee) === "ask";
|
|
598
|
+
}
|
|
599
|
+
const found = resolved(module, callee);
|
|
600
|
+
return found?.kind === "sdk" && found.name === "ask";
|
|
601
|
+
};
|
|
602
|
+
const decides = (module, node, depth) => {
|
|
603
|
+
if (node === undefined || depth > maxDepth)
|
|
604
|
+
return false;
|
|
605
|
+
if (unwrapped.has(node.type))
|
|
606
|
+
return childrenOf(node).some((child) => decides(module, child, depth + 1));
|
|
607
|
+
if (node.type === "Identifier") {
|
|
608
|
+
const found = resolved(module, node);
|
|
609
|
+
return found?.kind === "declarator" && decides(found.module, found.declarator.init ?? undefined, depth + 1);
|
|
610
|
+
}
|
|
611
|
+
if (node.type !== "ObjectExpression")
|
|
612
|
+
return false;
|
|
613
|
+
let decided = false;
|
|
614
|
+
for (const property of node.properties) {
|
|
615
|
+
if (property.type === "SpreadElement") {
|
|
616
|
+
decided ||= decides(module, property.argument, depth + 1);
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const key = property.computed ? undefined : nameOf(property.key);
|
|
620
|
+
if (key === "freeText")
|
|
621
|
+
return false;
|
|
622
|
+
if ((key === "options" || key === "answer") && !(property.value.type === "Identifier" && property.value.name === "undefined"))
|
|
623
|
+
decided = true;
|
|
624
|
+
}
|
|
625
|
+
return decided;
|
|
626
|
+
};
|
|
627
|
+
const returns = (module, node) => {
|
|
628
|
+
const fn = functionOf(module, node);
|
|
629
|
+
return fn !== undefined && returning.has(fn);
|
|
630
|
+
};
|
|
631
|
+
const piped = (module, held, operators, depth) => {
|
|
632
|
+
let holding = held;
|
|
633
|
+
for (const operator of operators) {
|
|
634
|
+
const method = effectCall(module, operator);
|
|
635
|
+
if (method === undefined || operator.type !== "CallExpression")
|
|
636
|
+
continue;
|
|
637
|
+
const [handler] = operator.arguments;
|
|
638
|
+
if (method === "as")
|
|
639
|
+
holding = handler !== undefined && holds(module, handler, depth + 1);
|
|
640
|
+
else if (successHandlers.has(method) && method !== "tap" && handler !== undefined)
|
|
641
|
+
holding = isFunction(handler) || functionOf(module, handler) !== undefined ? returns(module, handler) : holds(module, handler, depth + 1);
|
|
642
|
+
}
|
|
643
|
+
return holding;
|
|
644
|
+
};
|
|
645
|
+
const holdsCall = (module, node, depth) => {
|
|
646
|
+
if (isSdkAsk(module, node))
|
|
647
|
+
return !decides(module, node.arguments[1], 0);
|
|
648
|
+
const { callee } = node;
|
|
649
|
+
const args = node.arguments;
|
|
650
|
+
if (callee.type === "MemberExpression") {
|
|
651
|
+
if (memberName(callee) === "pipe")
|
|
652
|
+
return piped(module, holds(module, callee.object, depth + 1), args, depth);
|
|
653
|
+
const method = effectCall(module, node);
|
|
654
|
+
if (method !== undefined) {
|
|
655
|
+
if (args.length < 2 && method !== "succeed" && method !== "gen")
|
|
656
|
+
return false;
|
|
657
|
+
return args.some((arg) => isFunction(arg) ? returning.has(arg) : holds(module, arg, depth + 1) || returns(module, arg));
|
|
658
|
+
}
|
|
659
|
+
const name = memberName(callee);
|
|
660
|
+
return (name === undefined || !lookingUp.has(name)) && holds(module, callee.object, depth + 1);
|
|
661
|
+
}
|
|
662
|
+
if (callee.type === "Identifier" && callee.name === "String" && resolved(module, callee) === undefined)
|
|
663
|
+
return args.some((arg) => holds(module, arg, depth + 1));
|
|
664
|
+
if (isPipe(module, callee)) {
|
|
665
|
+
const [first, ...operators] = args;
|
|
666
|
+
return first !== undefined && piped(module, holds(module, first, depth + 1), operators, depth);
|
|
667
|
+
}
|
|
668
|
+
return returns(module, callee);
|
|
669
|
+
};
|
|
670
|
+
const holds = (module, node, depth = 0) => {
|
|
671
|
+
if (depth > maxDepth)
|
|
672
|
+
return false;
|
|
673
|
+
if (unwrapped.has(node.type))
|
|
674
|
+
return childrenOf(node).some((child) => holds(module, child, depth + 1));
|
|
675
|
+
switch (node.type) {
|
|
676
|
+
case "Identifier": {
|
|
677
|
+
const found = resolved(module, node);
|
|
678
|
+
if (found?.kind === "declarator")
|
|
679
|
+
return declarators.has(found.declarator);
|
|
680
|
+
if (found?.kind === "destructured")
|
|
681
|
+
return declarators.has(found.declarator) && !wordless.has(found.path.at(-1) ?? "");
|
|
682
|
+
return found?.kind === "param" && parameters.get(found.fn)?.has(found.index) === true && !wordless.has(found.path.at(-1) ?? "");
|
|
683
|
+
}
|
|
684
|
+
case "MemberExpression": {
|
|
685
|
+
const name = memberName(node);
|
|
686
|
+
if (name !== undefined && wordless.has(name))
|
|
687
|
+
return false;
|
|
688
|
+
const found = resolved(module, node.object);
|
|
689
|
+
const literal = found?.kind === "declarator" ? found.declarator.init : undefined;
|
|
690
|
+
if (literal?.type === "ObjectExpression" && found?.kind === "declarator") {
|
|
691
|
+
const property = literal.properties.find((entry) => entry.type === "Property" && !entry.computed && nameOf(entry.key) === name);
|
|
692
|
+
if (property?.type === "Property")
|
|
693
|
+
return holds(found.module, property.value, depth + 1);
|
|
694
|
+
}
|
|
695
|
+
return holds(module, node.object, depth + 1);
|
|
696
|
+
}
|
|
697
|
+
case "CallExpression":
|
|
698
|
+
return holdsCall(module, node, depth);
|
|
699
|
+
case "YieldExpression":
|
|
700
|
+
return node.argument !== null && holds(module, node.argument, depth + 1);
|
|
701
|
+
case "TemplateLiteral":
|
|
702
|
+
return node.expressions.some((expression) => holds(module, expression, depth + 1));
|
|
703
|
+
case "TaggedTemplateExpression":
|
|
704
|
+
return node.quasi.expressions.some((expression) => holds(module, expression, depth + 1));
|
|
705
|
+
case "BinaryExpression":
|
|
706
|
+
return node.operator === "+" && (holds(module, node.left, depth + 1) || holds(module, node.right, depth + 1));
|
|
707
|
+
case "LogicalExpression":
|
|
708
|
+
return holds(module, node.left, depth + 1) || holds(module, node.right, depth + 1);
|
|
709
|
+
case "ConditionalExpression":
|
|
710
|
+
return holds(module, node.consequent, depth + 1) || holds(module, node.alternate, depth + 1);
|
|
711
|
+
case "ArrayExpression":
|
|
712
|
+
return node.elements.some((element) => element !== null && holds(module, element.type === "SpreadElement" ? element.argument : element, depth + 1));
|
|
713
|
+
case "SequenceExpression": {
|
|
714
|
+
const last = node.expressions.at(-1);
|
|
715
|
+
return last !== undefined && holds(module, last, depth + 1);
|
|
716
|
+
}
|
|
717
|
+
case "AssignmentExpression":
|
|
718
|
+
return holds(module, node.right, depth + 1);
|
|
719
|
+
default:
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
const handOn = (module, handler, index) => {
|
|
724
|
+
const fn = functionOf(module, handler);
|
|
725
|
+
if (fn === undefined)
|
|
726
|
+
return false;
|
|
727
|
+
const known = parameters.get(fn) ?? new Set;
|
|
728
|
+
if (known.has(index))
|
|
729
|
+
return false;
|
|
730
|
+
parameters.set(fn, known.add(index));
|
|
731
|
+
return true;
|
|
732
|
+
};
|
|
733
|
+
const flow = (module, node) => {
|
|
734
|
+
switch (node.type) {
|
|
735
|
+
case "VariableDeclarator":
|
|
736
|
+
if (node.init === null || declarators.has(node) || !holds(module, node.init))
|
|
737
|
+
return false;
|
|
738
|
+
declarators.add(node);
|
|
739
|
+
return true;
|
|
740
|
+
case "AssignmentExpression": {
|
|
741
|
+
const found = resolved(module, node.left);
|
|
742
|
+
if (found?.kind !== "declarator" || declarators.has(found.declarator) || !holds(module, node.right))
|
|
743
|
+
return false;
|
|
744
|
+
declarators.add(found.declarator);
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
case "ReturnStatement": {
|
|
748
|
+
const fn = enclosingFunction(module, node);
|
|
749
|
+
if (fn === undefined || returning.has(fn) || node.argument === null || !holds(module, node.argument))
|
|
750
|
+
return false;
|
|
751
|
+
returning.add(fn);
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
case "ArrowFunctionExpression":
|
|
755
|
+
if (!node.expression || returning.has(node))
|
|
756
|
+
return false;
|
|
757
|
+
return holds(module, node.body) && returning.add(node).size > 0;
|
|
758
|
+
case "CallExpression":
|
|
759
|
+
return flowCall(module, node);
|
|
760
|
+
default:
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
const flowCall = (module, node) => {
|
|
765
|
+
const { callee } = node;
|
|
766
|
+
const args = node.arguments;
|
|
767
|
+
let changed = false;
|
|
768
|
+
const fn = functionOf(module, callee);
|
|
769
|
+
if (fn !== undefined) {
|
|
770
|
+
for (const [index, arg] of args.entries())
|
|
771
|
+
if (arg.type !== "SpreadElement" && holds(module, arg))
|
|
772
|
+
changed = handOn(module, fn, index) || changed;
|
|
773
|
+
}
|
|
774
|
+
const pipeline = (held, operators) => {
|
|
775
|
+
let holding = held;
|
|
776
|
+
for (const operator of operators) {
|
|
777
|
+
const method = effectCall(module, operator);
|
|
778
|
+
if (holding && method !== undefined && successHandlers.has(method) && operator.type === "CallExpression")
|
|
779
|
+
changed = handOn(module, operator.arguments[0], 0) || changed;
|
|
780
|
+
holding = piped(module, holding, [operator], 0);
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
if (callee.type === "MemberExpression") {
|
|
784
|
+
const method = memberName(callee);
|
|
785
|
+
if (method === "pipe")
|
|
786
|
+
pipeline(holds(module, callee.object), args);
|
|
787
|
+
else if (effectCall(module, node) !== undefined && method !== undefined) {
|
|
788
|
+
const [self, handler] = args;
|
|
789
|
+
if ((successHandlers.has(method) || method === "forEach") && self !== undefined && holds(module, self))
|
|
790
|
+
changed = handOn(module, handler, 0) || changed;
|
|
791
|
+
} else if (method !== undefined && holds(module, callee.object)) {
|
|
792
|
+
if (elementHandlers.has(method))
|
|
793
|
+
changed = handOn(module, args[0], 0) || changed;
|
|
794
|
+
if (method === "reduce")
|
|
795
|
+
changed = handOn(module, args[0], 1) || changed;
|
|
796
|
+
}
|
|
797
|
+
} else if (isPipe(module, callee)) {
|
|
798
|
+
const [first, ...operators] = args;
|
|
799
|
+
if (first !== undefined)
|
|
800
|
+
pipeline(holds(module, first), operators);
|
|
801
|
+
}
|
|
802
|
+
return changed;
|
|
803
|
+
};
|
|
804
|
+
for (let changed = true;changed; ) {
|
|
805
|
+
changed = false;
|
|
806
|
+
for (const [module, all] of nodes)
|
|
807
|
+
for (const node of all)
|
|
808
|
+
changed = flow(module, node) || changed;
|
|
809
|
+
}
|
|
810
|
+
const testHolds = (module, node) => {
|
|
811
|
+
if (unwrapped.has(node.type))
|
|
812
|
+
return childrenOf(node).some((child) => testHolds(module, child));
|
|
813
|
+
if (node.type === "UnaryExpression" && node.operator === "!")
|
|
814
|
+
return testHolds(module, node.argument);
|
|
815
|
+
if (node.type === "LogicalExpression")
|
|
816
|
+
return testHolds(module, node.left) || testHolds(module, node.right);
|
|
817
|
+
return holds(module, node);
|
|
818
|
+
};
|
|
819
|
+
const branchOnWords = (module, node) => {
|
|
820
|
+
switch (node.type) {
|
|
821
|
+
case "BinaryExpression":
|
|
822
|
+
return comparisons.has(node.operator) && (holds(module, node.left) || holds(module, node.right)) ? node : undefined;
|
|
823
|
+
case "SwitchStatement":
|
|
824
|
+
return holds(module, node.discriminant) || node.cases.some((entry) => entry.test !== null && holds(module, entry.test)) ? node : undefined;
|
|
825
|
+
case "IfStatement":
|
|
826
|
+
case "WhileStatement":
|
|
827
|
+
case "DoWhileStatement":
|
|
828
|
+
case "ConditionalExpression":
|
|
829
|
+
return testHolds(module, node.test) ? node.test : undefined;
|
|
830
|
+
case "ForStatement":
|
|
831
|
+
return node.test !== null && testHolds(module, node.test) ? node.test : undefined;
|
|
832
|
+
case "MemberExpression":
|
|
833
|
+
return node.computed && memberName(node) === undefined && holds(module, node.property) ? node : undefined;
|
|
834
|
+
case "CallExpression": {
|
|
835
|
+
const method = memberName(node.callee);
|
|
836
|
+
if (method === undefined || node.callee.type !== "MemberExpression")
|
|
837
|
+
return;
|
|
838
|
+
return testedBy.has(method) && holds(module, node.callee.object) || lookingUp.has(method) && node.arguments.some((arg) => arg.type !== "SpreadElement" && holds(module, arg)) ? node : undefined;
|
|
839
|
+
}
|
|
840
|
+
default:
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
return [...nodes].flatMap(([module, all]) => all.flatMap((node) => {
|
|
845
|
+
const branch = branchOnWords(module, node);
|
|
846
|
+
return branch === undefined ? [] : [branch];
|
|
847
|
+
}).sort((one, other) => one.start - other.start).map((node) => ({ at: located(module, node), comparison: textOf(module, node) })));
|
|
848
|
+
};
|
|
849
|
+
|
|
488
850
|
// packages/sdk/src/build/outline/sdk-steps.generated.ts
|
|
489
851
|
var sdkSteps = {
|
|
490
852
|
green: {
|
|
@@ -1669,7 +2031,7 @@ var checked = (results) => ({
|
|
|
1669
2031
|
...results,
|
|
1670
2032
|
values: results.values.map((result) => ({ ...result, checked: true }))
|
|
1671
2033
|
});
|
|
1672
|
-
var
|
|
2034
|
+
var maxDepth2 = 40;
|
|
1673
2035
|
var maxPatterns = 16;
|
|
1674
2036
|
var maxInlined = 24;
|
|
1675
2037
|
var effectMethods = {
|
|
@@ -1758,7 +2120,7 @@ var namesGiven = (node) => [
|
|
|
1758
2120
|
...childLists(node).flatMap((list) => list.flatMap(namesGiven))
|
|
1759
2121
|
];
|
|
1760
2122
|
var holdsEnd = (node, which) => node.kind === "end" ? which(node) : childLists(node).some((list) => list.some((inner) => holdsEnd(inner, which)));
|
|
1761
|
-
var
|
|
2123
|
+
var isFunction2 = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
|
|
1762
2124
|
var unwrap = (node) => {
|
|
1763
2125
|
let at = node;
|
|
1764
2126
|
while (at.type === "TSAsExpression" || at.type === "TSSatisfiesExpression" || at.type === "TSNonNullExpression" || at.type === "TSTypeAssertion" || at.type === "TSInstantiationExpression" || at.type === "ParenthesizedExpression" || at.type === "ChainExpression")
|
|
@@ -1776,7 +2138,7 @@ var keyName = (key, computed) => {
|
|
|
1776
2138
|
return key.name;
|
|
1777
2139
|
return stringLiteral(key);
|
|
1778
2140
|
};
|
|
1779
|
-
var
|
|
2141
|
+
var memberName2 = (node) => node.type === "MemberExpression" ? node.computed ? stringLiteral(node.property) : node.property.type === "Identifier" ? node.property.name : undefined : undefined;
|
|
1780
2142
|
var returnsOf = (() => {
|
|
1781
2143
|
const cache = new WeakMap;
|
|
1782
2144
|
return (fn) => {
|
|
@@ -1794,7 +2156,7 @@ var returnsOf = (() => {
|
|
|
1794
2156
|
if (node.type === "ReturnStatement" && node.argument !== null)
|
|
1795
2157
|
found.push(node.argument);
|
|
1796
2158
|
for (const child of childrenOf(node))
|
|
1797
|
-
if (!
|
|
2159
|
+
if (!isFunction2(child))
|
|
1798
2160
|
pending.push(child);
|
|
1799
2161
|
}
|
|
1800
2162
|
const ordered = found.toSorted((a, b) => a.start - b.start);
|
|
@@ -1816,7 +2178,7 @@ var returnsNothing = cached((fn) => {
|
|
|
1816
2178
|
if (node.type === "ReturnStatement" && node.argument === null)
|
|
1817
2179
|
return true;
|
|
1818
2180
|
for (const child of childrenOf(node))
|
|
1819
|
-
if (!
|
|
2181
|
+
if (!isFunction2(child))
|
|
1820
2182
|
pending.push(child);
|
|
1821
2183
|
}
|
|
1822
2184
|
return false;
|
|
@@ -1827,7 +2189,7 @@ var returnsIn = cached((node) => {
|
|
|
1827
2189
|
if (found.type === "ReturnStatement")
|
|
1828
2190
|
return true;
|
|
1829
2191
|
for (const child of childrenOf(found))
|
|
1830
|
-
if (!
|
|
2192
|
+
if (!isFunction2(child))
|
|
1831
2193
|
pending.push(child);
|
|
1832
2194
|
}
|
|
1833
2195
|
return false;
|
|
@@ -1860,12 +2222,12 @@ var isLoop = (node) => node.type === "WhileStatement" || node.type === "DoWhileS
|
|
|
1860
2222
|
var breaksOut = (node) => {
|
|
1861
2223
|
if (node.type === "BreakStatement")
|
|
1862
2224
|
return true;
|
|
1863
|
-
if (
|
|
2225
|
+
if (isFunction2(node))
|
|
1864
2226
|
return false;
|
|
1865
2227
|
const inner = node.type === "SwitchStatement" || isLoop(node);
|
|
1866
2228
|
return childrenOf(node).some((child) => inner ? breaksFurther(child) : breaksOut(child));
|
|
1867
2229
|
};
|
|
1868
|
-
var breaksFurther = (node) => node.type === "BreakStatement" ? node.label !== null : !
|
|
2230
|
+
var breaksFurther = (node) => node.type === "BreakStatement" ? node.label !== null : !isFunction2(node) && childrenOf(node).some(breaksFurther);
|
|
1869
2231
|
var isOptional = (node) => {
|
|
1870
2232
|
if (node.type === "MemberExpression")
|
|
1871
2233
|
return node.optional || isOptional(node.object);
|
|
@@ -1875,7 +2237,7 @@ var isOptional = (node) => {
|
|
|
1875
2237
|
};
|
|
1876
2238
|
var leaves = cached((node) => leavesBy(node, true, true));
|
|
1877
2239
|
var leavesBy = (node, breaks, continues) => {
|
|
1878
|
-
if (
|
|
2240
|
+
if (isFunction2(node))
|
|
1879
2241
|
return false;
|
|
1880
2242
|
if (node.type === "ReturnStatement" || node.type === "ThrowStatement")
|
|
1881
2243
|
return true;
|
|
@@ -2018,7 +2380,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2018
2380
|
const binding = lookup(module, node.name, node);
|
|
2019
2381
|
if (binding?.kind === "declarator" && binding.declarator.id !== node) {
|
|
2020
2382
|
const isYield = (at, argument) => at?.type === "YieldExpression" && at.delegate && at.argument === argument;
|
|
2021
|
-
const piped = parent?.type === "MemberExpression" && parent.object === node &&
|
|
2383
|
+
const piped = parent?.type === "MemberExpression" && parent.object === node && memberName2(parent) === "pipe" && call?.type === "CallExpression" && call.callee === parent && isYield(yielded, call);
|
|
2022
2384
|
uses.set(binding.declarator, (uses.get(binding.declarator) ?? true) && (isYield(parent, node) || piped));
|
|
2023
2385
|
}
|
|
2024
2386
|
}
|
|
@@ -2035,7 +2397,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2035
2397
|
};
|
|
2036
2398
|
const readingNow = new Set;
|
|
2037
2399
|
const exportedDeclarator = (module, name, depth) => {
|
|
2038
|
-
if (depth >
|
|
2400
|
+
if (depth > maxDepth2)
|
|
2039
2401
|
return;
|
|
2040
2402
|
const entry = module.exports.get(name);
|
|
2041
2403
|
if (entry === undefined) {
|
|
@@ -2104,7 +2466,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2104
2466
|
};
|
|
2105
2467
|
const sdkModule = (target) => target.path === undefined ? undefined : moduleAt(target.path);
|
|
2106
2468
|
const resolveExport = (module, name, depth) => {
|
|
2107
|
-
if (depth >
|
|
2469
|
+
if (depth > maxDepth2)
|
|
2108
2470
|
return unknown;
|
|
2109
2471
|
if (module.sdk && sdkNames.has(name))
|
|
2110
2472
|
return { kind: "sdk", name };
|
|
@@ -2187,7 +2549,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2187
2549
|
}
|
|
2188
2550
|
};
|
|
2189
2551
|
const propertyOf = (value, key, depth) => {
|
|
2190
|
-
if (value.kind !== "node" || depth >
|
|
2552
|
+
if (value.kind !== "node" || depth > maxDepth2)
|
|
2191
2553
|
return;
|
|
2192
2554
|
const object = unwrap(value.node);
|
|
2193
2555
|
if (object.type !== "ObjectExpression")
|
|
@@ -2223,7 +2585,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2223
2585
|
}
|
|
2224
2586
|
};
|
|
2225
2587
|
const resolveValue = (raw, place, depth = 0) => {
|
|
2226
|
-
if (depth >
|
|
2588
|
+
if (depth > maxDepth2)
|
|
2227
2589
|
return unknown;
|
|
2228
2590
|
const node = unwrap(raw);
|
|
2229
2591
|
switch (node.type) {
|
|
@@ -2234,7 +2596,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2234
2596
|
return binding === undefined ? unknown : valueOfBinding(binding, place, depth);
|
|
2235
2597
|
}
|
|
2236
2598
|
case "MemberExpression": {
|
|
2237
|
-
const key =
|
|
2599
|
+
const key = memberName2(node);
|
|
2238
2600
|
return key === undefined ? unknown : memberOf(resolveValue(node.object, place, depth + 1), key, depth);
|
|
2239
2601
|
}
|
|
2240
2602
|
case "CallExpression": {
|
|
@@ -2321,7 +2683,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2321
2683
|
}
|
|
2322
2684
|
};
|
|
2323
2685
|
const patternsOf = (raw, place, depth = 0) => {
|
|
2324
|
-
if (depth >
|
|
2686
|
+
if (depth > maxDepth2)
|
|
2325
2687
|
return;
|
|
2326
2688
|
const node = unwrap(raw);
|
|
2327
2689
|
const literal = stringLiteral(node);
|
|
@@ -2503,7 +2865,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2503
2865
|
}
|
|
2504
2866
|
};
|
|
2505
2867
|
const resultsOf = (raw, place, depth = 0, seen = new Set) => {
|
|
2506
|
-
if (depth >
|
|
2868
|
+
if (depth > maxDepth2 || seen.has(raw))
|
|
2507
2869
|
return unknownResults;
|
|
2508
2870
|
const node = unwrap(raw);
|
|
2509
2871
|
const next = new Set(seen).add(raw);
|
|
@@ -2548,7 +2910,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2548
2910
|
}
|
|
2549
2911
|
case "CallExpression": {
|
|
2550
2912
|
const callee = unwrap(node.callee);
|
|
2551
|
-
if (callee.type === "MemberExpression" &&
|
|
2913
|
+
if (callee.type === "MemberExpression" && memberName2(callee) === "pipe")
|
|
2552
2914
|
return pipeResults(node, callee.object, place, depth);
|
|
2553
2915
|
const value = resolveValue(callee, place, depth + 1);
|
|
2554
2916
|
const name = effectName(value);
|
|
@@ -2563,7 +2925,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2563
2925
|
const value = resolveValue(node, place, depth + 1);
|
|
2564
2926
|
if (value.kind === "external")
|
|
2565
2927
|
return externalResults(value);
|
|
2566
|
-
const key =
|
|
2928
|
+
const key = memberName2(node);
|
|
2567
2929
|
const objects = resultsOf(node.object, place, depth + 1, next);
|
|
2568
2930
|
const read = union([
|
|
2569
2931
|
{ values: [], unknown: objects.unknown },
|
|
@@ -2654,7 +3016,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2654
3016
|
for (const { name } of patternNames(node.id))
|
|
2655
3017
|
found.push(bindingName(name, module, node));
|
|
2656
3018
|
for (const child of childrenOf(node))
|
|
2657
|
-
if (!
|
|
3019
|
+
if (!isFunction2(child))
|
|
2658
3020
|
pending.push(child);
|
|
2659
3021
|
}
|
|
2660
3022
|
for (const statement of body.type === "BlockStatement" ? body.body : [body]) {
|
|
@@ -2671,7 +3033,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2671
3033
|
const tested = new Map;
|
|
2672
3034
|
const pending = [...conditions];
|
|
2673
3035
|
for (let node = pending.pop();node !== undefined; node = pending.pop()) {
|
|
2674
|
-
const object = node.type === "MemberExpression" &&
|
|
3036
|
+
const object = node.type === "MemberExpression" && memberName2(node) === "_tag" ? unwrap(node.object) : undefined;
|
|
2675
3037
|
const isTag = node.type === "Identifier" && node.name === "_tag";
|
|
2676
3038
|
const subject = object?.type === "Identifier" ? object : isTag ? node : undefined;
|
|
2677
3039
|
if (subject?.type === "Identifier") {
|
|
@@ -2692,7 +3054,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2692
3054
|
};
|
|
2693
3055
|
const heldBy = (raw, place, depth) => {
|
|
2694
3056
|
heldLeft -= 1;
|
|
2695
|
-
if (depth >
|
|
3057
|
+
if (depth > maxDepth2 || heldLeft < 0)
|
|
2696
3058
|
return holdsOther;
|
|
2697
3059
|
const node = unwrap(raw);
|
|
2698
3060
|
switch (node.type) {
|
|
@@ -2725,7 +3087,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
2725
3087
|
const heldByCall = (call, place, depth) => {
|
|
2726
3088
|
const callee = unwrap(call.callee);
|
|
2727
3089
|
const [first] = call.arguments;
|
|
2728
|
-
if (callee.type === "MemberExpression" &&
|
|
3090
|
+
if (callee.type === "MemberExpression" && memberName2(callee) === "pipe")
|
|
2729
3091
|
return call.arguments.reduce((held, raw) => {
|
|
2730
3092
|
const op = unwrap(raw);
|
|
2731
3093
|
const isCall = op.type === "CallExpression";
|
|
@@ -3004,7 +3366,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3004
3366
|
{ kind: "end", ...tag === undefined ? { fails: true } : { failure: tag }, at: located(walk.place.module, at) }
|
|
3005
3367
|
];
|
|
3006
3368
|
};
|
|
3007
|
-
const walkArguments = (args, walk) => args.flatMap((arg) =>
|
|
3369
|
+
const walkArguments = (args, walk) => args.flatMap((arg) => isFunction2(unwrap(arg)) ? [] : walkExpression(arg, inner(walk), false));
|
|
3008
3370
|
const unread = (fn, walk) => ({
|
|
3009
3371
|
kind: "runtime",
|
|
3010
3372
|
label: walk.stack.includes(fn.fn) ? "the same code again, by recursion" : "code nested too deep to read",
|
|
@@ -3065,7 +3427,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3065
3427
|
return [];
|
|
3066
3428
|
const callback = resolveValue(raw, walk.place);
|
|
3067
3429
|
if (callback.kind !== "fn")
|
|
3068
|
-
return
|
|
3430
|
+
return isFunction2(unwrap(raw)) ? [] : walkExpression(raw, inner(walk), yielded);
|
|
3069
3431
|
return ending ? endingFunction(callback, unboundFrame(callback), walk) : walkFunction(callback, unboundFrame(callback), walk, { ends: false, yielded });
|
|
3070
3432
|
};
|
|
3071
3433
|
const tapPaths = (name, args, walk, at) => {
|
|
@@ -3256,13 +3618,13 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3256
3618
|
const callbacks = [];
|
|
3257
3619
|
for (const raw of call.arguments) {
|
|
3258
3620
|
const arg = unwrap(raw);
|
|
3259
|
-
if (
|
|
3621
|
+
if (isFunction2(arg)) {
|
|
3260
3622
|
callbacks.push({ label: `#${callbacks.length + 1}`, nodes: walkCallback(arg, walk, false) });
|
|
3261
3623
|
continue;
|
|
3262
3624
|
}
|
|
3263
3625
|
if (arg.type === "ObjectExpression") {
|
|
3264
3626
|
for (const property of arg.properties)
|
|
3265
|
-
if (property.type === "Property" &&
|
|
3627
|
+
if (property.type === "Property" && isFunction2(unwrap(property.value)))
|
|
3266
3628
|
callbacks.push({
|
|
3267
3629
|
label: keyName(property.key, property.computed) ?? textOf(walk.place.module, property.key),
|
|
3268
3630
|
nodes: walkCallback(property.value, walk, false)
|
|
@@ -3271,7 +3633,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3271
3633
|
nodes.push(...walkExpression(arg, inner(walk), false));
|
|
3272
3634
|
}
|
|
3273
3635
|
const reached = callbacks.filter((path) => path.nodes.length > 0);
|
|
3274
|
-
const method =
|
|
3636
|
+
const method = memberName2(callee);
|
|
3275
3637
|
const at = located(walk.place.module, call);
|
|
3276
3638
|
if (reached.length === 1 && callee.type === "MemberExpression" && method !== undefined && arrayMethods.has(method))
|
|
3277
3639
|
return [
|
|
@@ -3417,7 +3779,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3417
3779
|
const { nodes: paths, order } = readInOrder(given, () => sideBySide(all, walk));
|
|
3418
3780
|
if (paths !== undefined)
|
|
3419
3781
|
return paths.every((path) => path.nodes.length === 0) ? [] : [{ kind: "all", ...order, paths, at }];
|
|
3420
|
-
const method = all.type === "CallExpression" ?
|
|
3782
|
+
const method = all.type === "CallExpression" ? memberName2(unwrap(all.callee)) ?? "" : "";
|
|
3421
3783
|
const { nodes: items, order: ofItems } = readInOrder(given, () => walkExpression(first, inner(walk), !arrayMethods.has(method)));
|
|
3422
3784
|
return allOf(items, method === "map", `Effect.all(${textOf(module, first)})`, ofItems, at);
|
|
3423
3785
|
}
|
|
@@ -3460,7 +3822,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3460
3822
|
const walkCall = (call, walk, yielded) => {
|
|
3461
3823
|
const callee = unwrap(call.callee);
|
|
3462
3824
|
const place = walk.place;
|
|
3463
|
-
if (callee.type === "MemberExpression" &&
|
|
3825
|
+
if (callee.type === "MemberExpression" && memberName2(callee) === "pipe") {
|
|
3464
3826
|
const reachedBefore = walk.reached.value;
|
|
3465
3827
|
let nodes = walkExpression(callee.object, walk, yielded);
|
|
3466
3828
|
const ending = walk.top && !reachedBefore && walk.reached.value;
|
|
@@ -3596,7 +3958,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3596
3958
|
case "ArrayExpression":
|
|
3597
3959
|
return node.elements.flatMap((element) => walkExpression(element, within, false));
|
|
3598
3960
|
case "ObjectExpression":
|
|
3599
|
-
return node.properties.flatMap((property) => property.type === "SpreadElement" ? walkExpression(property.argument, within, false) :
|
|
3961
|
+
return node.properties.flatMap((property) => property.type === "SpreadElement" ? walkExpression(property.argument, within, false) : isFunction2(unwrap(property.value)) ? [] : walkExpression(property.value, within, false));
|
|
3600
3962
|
case "TemplateLiteral":
|
|
3601
3963
|
return node.expressions.flatMap((part) => walkExpression(part, within, false));
|
|
3602
3964
|
case "TaggedTemplateExpression":
|
|
@@ -3750,7 +4112,7 @@ var outlineReader = (graph, sdkSteps2 = new Map(Object.entries(sdkSteps))) => {
|
|
|
3750
4112
|
const listOf = (found, depth = 0, missed = { value: false }) => {
|
|
3751
4113
|
if (found === undefined)
|
|
3752
4114
|
return [];
|
|
3753
|
-
const value = depth >
|
|
4115
|
+
const value = depth > maxDepth2 ? unknown : resolveValue(found.node, found.place);
|
|
3754
4116
|
const list = value.kind === "node" ? unwrap(value.node) : undefined;
|
|
3755
4117
|
if (value.kind !== "node" || list?.type !== "ArrayExpression") {
|
|
3756
4118
|
missed.value = true;
|
|
@@ -3832,8 +4194,17 @@ class OutlineUnread extends TaggedError2()("OutlineUnread", { reason: String4 })
|
|
|
3832
4194
|
}
|
|
3833
4195
|
}
|
|
3834
4196
|
var readGraph = (root, read) => loadGraph(root).pipe(map9(read), mapError2((error) => new OutlineUnread({ reason: error.message })));
|
|
4197
|
+
|
|
4198
|
+
class FreeTextCompared extends TaggedError2()("FreeTextCompared", {
|
|
4199
|
+
at: String4,
|
|
4200
|
+
comparison: String4
|
|
4201
|
+
}) {
|
|
4202
|
+
get message() {
|
|
4203
|
+
return `${this.at} branches on a free-text answer, in \`${this.comparison}\`. A Loop never branches on words: give the Question options, or declare the schema of its answer with \`answer\`, and Kitman checks the answer when it is given`;
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
var readKitsSource = (root) => readGraph(root, (graph) => ({ outlines: readKitOutlines(graph), freeText: freeTextComparisons(graph) }));
|
|
3835
4207
|
var readOutlines = (root) => readGraph(root, readLoopOutlines);
|
|
3836
|
-
var readKitsOutlines = (root) => readGraph(root, readKitOutlines);
|
|
3837
4208
|
var outlineSteps = (outline) => outline.flatMap((node) => {
|
|
3838
4209
|
switch (node.kind) {
|
|
3839
4210
|
case "step":
|
|
@@ -3891,7 +4262,7 @@ var ConfigAgents = Record(String4, Struct({
|
|
|
3891
4262
|
}));
|
|
3892
4263
|
var run = (command, args, cwd) => gen(function* () {
|
|
3893
4264
|
const spawner = yield* ChildProcessSpawner;
|
|
3894
|
-
const handle = yield* spawner.spawn(
|
|
4265
|
+
const handle = yield* spawner.spawn(make2(command, args, { cwd, stdin: "ignore" }));
|
|
3895
4266
|
const [stdout, stderr, exitCode] = yield* all3([
|
|
3896
4267
|
mkString(decodeText(handle.stdout)),
|
|
3897
4268
|
mkString(decodeText(handle.stderr)),
|
|
@@ -4264,7 +4635,10 @@ var buildKit = (directory, options = {}) => gen(function* () {
|
|
|
4264
4635
|
loops: kit.loops.map((loop) => loop.id),
|
|
4265
4636
|
agents: Object.keys(kit.agents)
|
|
4266
4637
|
}));
|
|
4267
|
-
const outlines = yield*
|
|
4638
|
+
const { outlines, freeText } = yield* readKitsSource(root);
|
|
4639
|
+
const [compared] = freeText;
|
|
4640
|
+
if (compared !== undefined)
|
|
4641
|
+
return yield* new FreeTextCompared(compared);
|
|
4268
4642
|
const readOf = (kit, index) => index === 0 ? outlines[0] : outlines.find((found) => found.kit === kit.name && (found.version ?? "0.0.0") === kit.version);
|
|
4269
4643
|
const unreadExtends = (kit) => winning.map(readOf).find((read, index) => read?.extendsUnread === true && winning[index]?.extends?.some((named) => named.name === kit.name && named.version === kit.version) === true)?.extendsAt;
|
|
4270
4644
|
const loops = winning.flatMap((kit, index) => {
|
|
@@ -4335,6 +4709,7 @@ export {
|
|
|
4335
4709
|
BundleFailed,
|
|
4336
4710
|
DeclarationsInvalid,
|
|
4337
4711
|
DependencyInstallFailed,
|
|
4712
|
+
FreeTextCompared,
|
|
4338
4713
|
GitSourceLocation,
|
|
4339
4714
|
OutlineUnread,
|
|
4340
4715
|
SourceFetchFailed,
|