@skillstech/thunderlang 0.5.11 → 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 +437 -0
  2. package/dist/core.cjs +30431 -7604
  3. package/dist/index.cjs +28577 -5331
  4. package/dist/learn.cjs +22676 -3870
  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 +48 -6
  31. package/src/meaning.d.mts +89 -0
  32. package/src/meaning.mjs +2544 -0
  33. package/src/model.d.mts +59 -12
  34. package/src/model.mjs +462 -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 +1015 -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
package/src/model.d.mts CHANGED
@@ -1,8 +1,13 @@
1
1
  // thunder-model-v1: the one meaning every Thunder view is drawn from (see src/model.mjs).
2
2
  import type { Does } from './visual.mjs';
3
+ import type { Expr } from './meaning.mjs';
3
4
  export const MODEL_SCHEMA: 'thunder-model-v1';
4
5
  export const THING_LANGUAGES: string[];
5
- export interface FlowNode { id: string; kind: 'start' | 'decision' | 'step' | 'loop' | 'stop' | 'end' | 'code'; text: string; line?: number; lane: number; row: number; does: Does; uses?: string; answer?: boolean; otherwise?: boolean; value?: string; code?: boolean; /** A decision with several cases (see FlowBlock.cases). */ cases?: true }
6
+ export interface FlowNode { id: string; kind: 'start' | 'decision' | 'step' | 'loop' | 'stop' | 'end' | 'code'; text: string; line?: number; lane: number; row: number; does: Does; uses?: string; /** Set when `uses` is a member in another file (calls across files). */ usesFile?: string; answer?: boolean; otherwise?: boolean; value?: string; code?: boolean; /** A decision with several cases (see FlowBlock.cases). */ cases?: true; /** On a code branch: the side the code takes when its condition holds. */ whenTrue?: 'yes' | 'no';
7
+ /** A yes/no question as a statement on each side, when it splits cleanly: { yes: "the x header is the KEY setting", no: "… is not …" }. */
8
+ holds?: { yes: string; no: string };
9
+ /** The step's full meaning (thunder-expr-v1). */ expr?: Expr;
10
+ /** What the short words leave out, one level down: "with: order, { validate: false }". Shown in Details and the full Thunder Text. */ detail?: string }
6
11
  export interface FlowEdge { from: string; to: string; label?: 'yes' | 'no' | 'each' | 'next' | 'done' | 'error' | 'case' | 'nested'; /** On a 'case' edge: the case it takes ("When it is from 90 to 100", "Otherwise", "None of these"). */ text?: string }
7
12
  export interface FlowBlock { id: string; yes?: FlowBlock[]; no?: FlowBlock[]; each?: FlowBlock[]; body?: FlowBlock[];
8
13
  /** A choice among several cases (switch, when, match, select): one side per case, in order. The decision node has `cases: true`. */
@@ -11,17 +16,52 @@ export interface FlowBlock { id: string; yes?: FlowBlock[]; no?: FlowBlock[]; ea
11
16
  nested?: true; handlers?: { id: string; blocks: FlowBlock[] }[]; always?: { id: string; blocks: FlowBlock[] } }
12
17
  /** nodes/edges: the flow as a graph. blocks: the same nodes as a tree, which views draw from. */
13
18
  export interface Flow { nodes: FlowNode[]; edges: FlowEdge[]; blocks: FlowBlock[] }
14
- export interface Thing { id: string; kind: 'thing' | 'record' | 'choices'; name: string; label: string; doc?: string; file: string; lines: [number, number]; knows: { name: string; label: string; kind: string | null; start: string | null; line: number | null }[]; choices: string[]; can: string[] }
15
- export interface Member { id: string; kind: 'action' | 'rule' | 'steps' | 'setup' | 'not-read'; name: string; label: string; owner?: string; file: string; language: string; lines: [number, number]; doc?: string; route?: string; youGive: string[]; youGetBack?: string; rule?: unknown; question?: string; yesNo?: boolean; flow: Flow }
16
- export interface ThunderModel { schema: 'thunder-model-v1'; name: string; files: { path: string; language: string; purpose?: string }[]; things: Thing[]; members: Member[]; links: { from: string; to: string; kind: 'uses'; node: string }[]; unknowns: { id?: string; file: string; line: number; why: string }[] }
19
+ export interface Thing { id: string; kind: 'thing' | 'record' | 'choices' | 'resource'; name: string; label: string; doc?: string; file: string; lines: [number, number];
20
+ knows: { name: string; label: string; kind: string | null; start: string | null; line: number | null; /** Worked out when it runs, is built, or is applied. */ computed?: true; /** A secret: named only, its value never shown. */ secret?: true; setting?: true }[]; choices: string[]; can: string[];
21
+ /** Resources (spec section 12): the type exactly as written ('docker-image', 'azurerm_storage_account'). */ resourceType?: string;
22
+ /** Resources: a stable address that matches the same resource across versions ('image:api/Dockerfile'). */ address?: string;
23
+ /** Resources: looked up, not made by this file (a Terraform data source, a Bicep `existing` resource). */ existing?: true }
24
+ /** Who can do what to which resource (spec section 12). `wide` and `why` are the compiler's call. */
25
+ export interface Permission { id: string; who: string; can: string; on: string; wide: boolean; why?: string; says?: string; /** The role it gives, when the file names it ('Owner', 'Storage Blob Data Reader', 'roles/editor'). */ role?: string; file: string; line: number }
26
+ /** A value the app or infrastructure is given, and where it comes from. Never a secret's value. */
27
+ export interface Setting { name: string; source: 'parameter' | 'variable' | 'secret' | 'literal' | 'computed'; secret: boolean; computed?: true; file: string; line: number;
28
+ /** Its default (or value) in words, when the file writes it; never for a secret. */ default?: string; /** Its type as written. */ type?: string; /** The author's description. */ doc?: string;
29
+ /** An output: a value the infrastructure gives back once applied. */ output?: true; /** What an output is worked out from, in words. */ from?: string[]; /** Values a parameter allows. */ allowed?: string[] }
30
+ /** What a file says, not advice; a tool decides how serious each one is. */
31
+ export interface Fact { id: string; kind: 'write-all-permissions' | 'untrusted-trigger-with-secrets' | 'action-pinned-by-tag' | 'image-not-pinned' | 'runs-as-root' | 'secret-in-plain-env' | 'public-ingress' | 'storage-public' | 'secret-in-plain-config' | 'encryption-off' | 'wide-permission' | 'privileged-container' | 'no-resource-limits'; says: string; file: string; line: number; /** action-pinned-by-tag: an action made by GitHub itself. */ firstParty?: boolean }
32
+ export type LinkKind = 'uses' | 'runs-in' | 'reads-from' | 'sends-to';
33
+ /**
34
+ * A link between two members, resources, or a member's flow node and another member. 'uses': a call (in the same file,
35
+ * or with `crossFile` through an import, a declared type, or the same package), or a resource that uses another.
36
+ * 'sends-to': an HTTP request to the route that handles its method and path (`method`, `path`, `route`), an event or
37
+ * queue message to its listener (`event`), a task to its worker (`task`), or a resource that sends to another.
38
+ * 'runs-in' and 'reads-from': infrastructure (spec section 12).
39
+ */
40
+ export interface Link { from: string; to: string; kind: LinkKind; node?: string; /** The target's file (calls), or the file that states the link (infrastructure). */ file?: string; /** The calling step's line, or the line that states the link. */ line?: number | null; crossFile?: true; method?: string; path?: string; route?: string; event?: string; task?: string }
41
+ /** The same as Link (the name the whole-system calls used). */
42
+ export type ModelLink = Link;
43
+ export interface Member { id: string; kind: 'action' | 'rule' | 'steps' | 'setup' | 'not-read' | 'pipeline' | 'image-build'; /** Pipelines: when it runs, in words. */ when?: string; name: string; label: string; owner?: string; file: string; language: string; lines: [number, number]; doc?: string; route?: string;
44
+ /** JS/TS: what the function is assigned to (`exports.normalizeType`, `View.prototype.lookup`, `res.json`). */ assignedTo?: string;
45
+ /** JS/TS: an anonymous function passed to a call (named `<parent> › callback at line N`); `passedTo` is the call. */ callback?: true; passedTo?: string; youGive: string[]; /** Each input's kind in words, by its label, when the code says it. */ inputKinds?: Record<string, string>; youGetBack?: string; rule?: unknown; question?: string; yesNo?: boolean; flow: Flow; /** Set by proof by running (executed.mjs markExecuted) only where a run proved the reading. */ completeness?: { level: 'executed'; reasons: string[] } }
46
+ export interface ThunderModel { schema: 'thunder-model-v1'; name: string; files: { path: string; language: string; purpose?: string; category: 'application' | 'infrastructure' | 'delivery'; /** Why this file could not be read. */ skipped?: string }[]; things: Thing[]; members: Member[]; links: Link[]; unknowns: { id?: string; file: string; line: number; why: string }[]; permissions: Permission[]; settings: Setting[]; facts: Fact[]; notLinked?: NotLinked[] }
47
+ /** A call, request, event, or import worth linking that was not linked, and why (dynamic import, computed URL, external package, two routes match, an interface). */
48
+ export interface NotLinked { from?: string; node?: string; file: string | null; line: number | null; call?: string; import?: string; why: string; /** For an external package: how many imports of it. */ files?: number }
49
+ /** Which areas (folders, two levels deep) call which, from cross-file and service links. */
50
+ export interface AreaCalls { from: string; to: string; calls: number; sends: number; examples: { from: string; to: string; says: string }[] }
51
+ /** Where a link goes, as views show it. */
52
+ export interface LinkFacts { kind?: 'sends-to'; file?: string; crossFile?: true; line?: number; service?: string; route?: string }
53
+ /** Files may include go.mod, package.json, and tsconfig/jsconfig.json: they say which imports are this repo's own. */
17
54
  export function thunderModel(files: { path: string; source: string }[], options?: { name?: string }): ThunderModel;
18
55
  export function flowOf(steps: unknown[], options?: { start?: string; memberIndex?: Map<string, string>; memberLabel?: Map<string, string> }): Flow;
19
56
  export function ruleFlow(item: unknown, start: string): Flow;
20
- export function askAsQuestion(step: { says: string; code?: string }, ruleLabel?: string): { text: string; flip: boolean };
57
+ export function askAsQuestion(step: { says: string; code?: string }, ruleLabel?: string): { text: string; flip: boolean; code?: true; holds?: { yes: string; no: string } };
21
58
  export function stepDoes(step: unknown): Does;
22
- export function modelText(model: ThunderModel, id: string): string;
59
+ /** Thunder Text for a Thing or a member. `note` adds words after a flow node (the running system's counts); `full` shows every argument and value after the short words. */
60
+ export function modelText(model: ThunderModel, id: string, options?: { note?: (node: FlowNode) => string | null | undefined; full?: boolean }): string;
61
+ /** Each node of a flow with the answers that lead to it, from the top (the same paths Details shows). */
62
+ export function pathsOf(flow: Flow): { node: FlowNode; when: When[] }[];
23
63
  /** One answer on the way to a step: the question, and Yes, No, For each, or Otherwise. */
24
- export interface When { question: string; answer: string }
64
+ export interface When { question: string; answer: string; /** What is true on this side, as a statement, when the question splits cleanly. */ says?: string }
25
65
  export type LevelId = 'big-picture' | 'flow' | 'details' | 'text' | 'original';
26
66
  export interface LevelItem { id: string; label: string; symbol: string; route?: string }
27
67
  export interface LevelView {
@@ -32,16 +72,23 @@ export interface LevelView {
32
72
  // Big Picture
33
73
  purpose?: string; things?: { id: string; label: string; doc?: string; knows: { label: string; start?: string }[]; can: LevelItem[] }[];
34
74
  data?: { id: string; label: string; symbol: string; choices?: string[]; knows: string[] }[];
75
+ /** Big Picture: the resources and how they connect; at app scope, the permissions, settings, and facts too. */
76
+ resources?: { id: string; label: string; symbol: 'resource'; resourceType?: string; address?: string; file: string; knows: { label: string; value: string | null; computed?: true; secret?: true; line: number | null }[]; links: { from: string; to: string; kind: LinkKind; line?: number }[] }[];
77
+ permissions?: Permission[]; settings?: Setting[]; facts?: Fact[];
35
78
  actions?: LevelItem[]; rules?: LevelItem[]; loose?: LevelItem[]; unknowns?: ThunderModel['unknowns'];
79
+ /** Big Picture, whole app: which areas call which (the app's map), and what could not be linked. */
80
+ calls?: AreaCalls[]; notLinked?: NotLinked[];
36
81
  route?: string; doc?: string; owner?: { id: string; label: string }; youGive?: string[]; youGetBack?: string;
37
- uses?: { id: string; label: string }[]; usedBy?: { id: string; label: string }[];
82
+ uses?: ({ id: string; label: string } & LinkFacts)[]; usedBy?: ({ id: string; label: string } & LinkFacts)[];
38
83
  // Flow
39
84
  flow?: Flow;
40
85
  // Details
41
- steps?: { id: string; text: string; does: Does; mark: string; line: number | null; depth: number; via?: string; notExplained?: true }[];
86
+ steps?: { id: string; text: string; does: Does; mark: string; line: number | null; depth: number; via?: string; notExplained?: true;
87
+ /** The step's full meaning tree. */ expr?: Expr;
88
+ /** What the short words leave out ("with: order, { validate: false }"), and the whole sentence ("Calls save — with: …"). */ detail?: string; full?: string }[];
42
89
  notExplained?: number; tryable?: boolean; rule?: unknown; source?: string;
43
90
  /** Details: what goes in, and the lines where each fact is used. */
44
- inputs?: { label: string; lines: number[] }[];
91
+ inputs?: { label: string; lines: number[]; /** Its kind in words when the code says it: "a number", "a PingResource". */ kind?: string }[];
45
92
  /** Details: the data it changes, what it saves or sends, and the answers that lead there. */
46
93
  changes?: { text: string; line: number | null; does: Does; when: When[] }[];
47
94
  /** Details: every way it can stop, with the error, the message people see, and the answers that lead there. */
@@ -49,7 +96,7 @@ export interface LevelView {
49
96
  /** Details: what it gives back, and when. */
50
97
  givesBack?: { text: string; line: number | null; when: When[] }[];
51
98
  /** Details: each action or rule it relies on, summarized. */
52
- reliesOn?: { id: string; label: string; symbol: string; says: string }[];
99
+ reliesOn?: ({ id: string; label: string; symbol: string; says: string } & LinkFacts)[];
53
100
  /** Details, for a rule: its answers in words, in order (the last may be "otherwise"). */
54
101
  answers?: { answer: string; when: string }[];
55
102
  /** Details, for a rule with one whole-number fact: its exact limits, found by running it. from/to null = "or less"/"or more". */
@@ -62,4 +109,4 @@ export interface LevelView {
62
109
  language?: string | null;
63
110
  }
64
111
  /** What one reading level (LEVELS) shows for the whole model, a Thing, or one action or rule. */
65
- export function readLevel(model: ThunderModel, level: LevelId, focus?: string): LevelView;
112
+ export function readLevel(model: ThunderModel, level: LevelId, focus?: string, options?: { full?: boolean }): LevelView;