@skillstech/thunderlang 0.5.10 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +450 -0
  2. package/dist/core.cjs +30434 -7577
  3. package/dist/index.cjs +28576 -5328
  4. package/dist/learn.cjs +24201 -5367
  5. package/package.json +12 -3
  6. package/src/bicep.mjs +167 -0
  7. package/src/cli.mjs +169 -3
  8. package/src/commands.mjs +464 -0
  9. package/src/core.d.ts +12 -4
  10. package/src/core.mjs +12 -4
  11. package/src/emit.mjs +1 -1
  12. package/src/executed.d.mts +53 -0
  13. package/src/executed.mjs +465 -0
  14. package/src/faithful.mjs +137 -0
  15. package/src/file-formats.mjs +35 -0
  16. package/src/hcl.mjs +94 -0
  17. package/src/index.d.ts +7 -1
  18. package/src/index.mjs +6 -1
  19. package/src/infra-bicep.mjs +312 -0
  20. package/src/infra-cloud.mjs +348 -0
  21. package/src/infra-compose.mjs +315 -0
  22. package/src/infra-containers.mjs +100 -0
  23. package/src/infra-docker.mjs +267 -0
  24. package/src/infra-expr.mjs +509 -0
  25. package/src/infra-gha.mjs +350 -0
  26. package/src/infra-k8s.mjs +657 -0
  27. package/src/infra-terraform.mjs +499 -0
  28. package/src/infra-words.mjs +811 -0
  29. package/src/libraries.mjs +202 -0
  30. package/src/lift.mjs +49 -6
  31. package/src/meaning.d.mts +89 -0
  32. package/src/meaning.mjs +2544 -0
  33. package/src/model.d.mts +65 -14
  34. package/src/model.mjs +496 -80
  35. package/src/powershell.mjs +1361 -0
  36. package/src/read-repo-fs.mjs +29 -7
  37. package/src/read-repo.d.mts +5 -1
  38. package/src/read-repo.mjs +33 -7
  39. package/src/read.d.mts +21 -1
  40. package/src/read.mjs +1017 -42
  41. package/src/review.d.mts +35 -0
  42. package/src/review.mjs +671 -0
  43. package/src/rlang.mjs +1084 -0
  44. package/src/round-trip.d.mts +12 -0
  45. package/src/round-trip.mjs +174 -0
  46. package/src/runners/thunder-generate.mjs +56 -0
  47. package/src/runners/thunder-trace.cjs +284 -0
  48. package/src/runners/thunder_trace.py +599 -0
  49. package/src/running.d.mts +104 -0
  50. package/src/running.mjs +787 -0
  51. package/src/same.d.mts +1 -0
  52. package/src/same.mjs +24 -3
  53. package/src/shell.mjs +1212 -0
  54. package/src/sql.mjs +3 -2
  55. package/src/steps.d.mts +6 -1
  56. package/src/steps.mjs +1448 -86
  57. package/src/system.d.mts +12 -0
  58. package/src/system.mjs +845 -0
  59. package/src/things-langs.mjs +275 -0
  60. package/src/thunderize.mjs +3 -3
  61. package/src/visual.d.mts +5 -5
  62. package/src/visual.mjs +24 -3
  63. package/src/write-steps.d.mts +64 -0
  64. package/src/write-steps.mjs +1608 -0
  65. package/src/write.mjs +2 -1
  66. package/src/yaml.mjs +403 -0
@@ -0,0 +1,104 @@
1
+ // The running system (see src/running.mjs): evidence of what ran, placed on Thunder's flows.
2
+ import type { ThunderModel, FlowNode, When } from './model.d.mts';
3
+ import type { Trace } from './executed.d.mts';
4
+
5
+ export const RUNNING_SCHEMA: 'thunder-running-v1';
6
+
7
+ /** One piece of evidence. Every adapter (fromTrace, fromStack, fromLogs, fromOtlp) gives these. */
8
+ export interface RunEvent {
9
+ source: 'trace' | 'stack' | 'logs' | 'otlp' | string;
10
+ kind: 'decision' | 'return' | 'raise' | 'call' | 'line';
11
+ file: string | null;
12
+ line: number | null;
13
+ /** decision: 'held' | 'not held' (the code's condition), 'yes' | 'no', 'case:<line>', 'each' | 'done', 'handled'. */
14
+ side?: string;
15
+ error?: string;
16
+ message?: string;
17
+ /** return: the values given back (as the recorder wrote them). */
18
+ value?: string[];
19
+ durationMs?: number;
20
+ count?: number;
21
+ function?: string | null;
22
+ /** call: how many of these calls ended with an error. */
23
+ failed?: number;
24
+ /** raise: the stack's frames, innermost first; placed on the first frame in code Thunder read. */
25
+ frames?: { file: string | null; line: number | null; function?: string; internal?: boolean }[];
26
+ /** raise: this error ended the call (an uncaught stack trace), so it counts as a failure of the member. */
27
+ ends?: boolean;
28
+ /** A recorder's event: the first line of the function it was recorded in. */
29
+ fnLine?: number;
30
+ /** Evidence that names no place in the code: why. Listed under notMatched. */
31
+ unplaced?: string;
32
+ [k: string]: unknown;
33
+ }
34
+
35
+ export interface NodeRun {
36
+ id: string; kind: FlowNode['kind']; text: string; line: number | null;
37
+ /** Times seen: a question asked, a Stop or ending reached, a logged step. Absent when no evidence says. */
38
+ ran?: number;
39
+ /** A question: times each side was taken ("Yes", "No", a case's label, "For each", "Done"). */
40
+ sides?: Record<string, number>;
41
+ /** A Stop: the errors seen there. */
42
+ errors?: { error: string; message?: string; count: number }[];
43
+ /** A step: the errors it failed with. */
44
+ failed?: { error: string; message?: string; count: number }[];
45
+ /** A logged step: log lines by level. */
46
+ levels?: Record<string, number>;
47
+ values?: string[];
48
+ /** The evidence named a line inside this step (a statement over several lines). */
49
+ approximate?: true;
50
+ }
51
+
52
+ export interface MemberRun {
53
+ id: string; name: string; label: string; file: string; lines: [number, number];
54
+ calls: number; failures: number;
55
+ timing?: { count: number; avgMs: number; maxMs: number };
56
+ errors?: { error: string; message?: string; count: number }[];
57
+ logged?: number;
58
+ nodes: Record<string, NodeRun>;
59
+ /** The most-taken way through the flow: at each question the side seen most. Empty without questions. */
60
+ hotPath: { id: string; text: string; side?: string; count: number }[];
61
+ /** The Details sentence: "Ran 1,204 times; stopped with NotFound 37 times (3%), when Is user set? was No." */
62
+ says: string;
63
+ sources: string[];
64
+ }
65
+
66
+ export interface RuntimeOverlay {
67
+ schema: 'thunder-running-v1';
68
+ members: Record<string, MemberRun>;
69
+ notMatched: { source: string; kind: string; file: string | null; line: number | null; function?: string; what: string; reason: string; count: number }[];
70
+ sources: Record<string, number>;
71
+ summary: { members: number; events: number; notMatched: number };
72
+ }
73
+
74
+ export interface ParsedStack {
75
+ language: 'python' | 'javascript' | 'java' | 'csharp' | 'go';
76
+ error: string; message: string;
77
+ /** Innermost (where it failed) first. */
78
+ frames: { file: string | null; line: number | null; function?: string; internal?: boolean; className?: string }[];
79
+ causes?: { error: string; message: string }[];
80
+ wrappedIn?: { error: string; message: string }[];
81
+ }
82
+
83
+ export interface ErrorExplanation {
84
+ matched: boolean; text: string; reason?: string;
85
+ error?: string; message?: string; language?: string; file?: string; line?: number;
86
+ member?: { id: string; label: string; name: string };
87
+ step?: { id: string; text: string; kind: string; line: number | null; approximate?: true } | null;
88
+ /** The answers that lead to the step in the flow as drawn; null when the flow does not show them. */
89
+ path?: When[] | null;
90
+ calledFrom?: { member: { id: string; label: string }; step: { id: string; text: string; line?: number } | null; line: number; file: string }[];
91
+ raisedInside?: string[];
92
+ }
93
+
94
+ export function countWords(n: number): string;
95
+ export function fromTrace(trace: Trace): RunEvent[];
96
+ export function parseStack(text: string): ParsedStack | null;
97
+ export function parseStacks(text: string): ParsedStack[];
98
+ export function fromStack(text: string, options?: { count?: number }): RunEvent[];
99
+ export function fromLogs(text: string): RunEvent[];
100
+ export function fromOtlp(input: string | object): RunEvent[];
101
+ export function runtimeOverlay(model: ThunderModel, evidence: RunEvent[]): RuntimeOverlay;
102
+ export function explainError(model: ThunderModel, stack: string | ParsedStack): ErrorExplanation;
103
+ export function nodeNote(run: NodeRun | undefined): string;
104
+ export function runtimeText(model: ThunderModel, overlay: RuntimeOverlay, options?: { member?: string | null; top?: number }): string;