agency-lang 0.12.0 → 0.13.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/lib/backends/agencyGenerator.d.ts +77 -5
- package/dist/lib/backends/agencyGenerator.js +324 -165
- package/dist/lib/backends/typescriptBuilder.js +16 -0
- package/dist/lib/backends/typescriptGenerator/typeToString.d.ts +6 -2
- package/dist/lib/backends/typescriptGenerator/typeToString.js +29 -22
- package/dist/lib/cli/budget.d.ts +2 -8
- package/dist/lib/cli/budget.js +6 -27
- package/dist/lib/cli/deploy/bundle.d.ts +13 -7
- package/dist/lib/cli/deploy/bundle.js +63 -40
- package/dist/lib/cli/deploy/curlExamples.d.ts +4 -5
- package/dist/lib/cli/deploy/curlExamples.js +3 -4
- package/dist/lib/cli/deploy/deploy.d.ts +2 -2
- package/dist/lib/cli/deploy/deploy.js +1 -1
- package/dist/lib/cli/deploy/render.js +1 -1
- package/dist/lib/cli/eval/label.d.ts +47 -0
- package/dist/lib/cli/eval/label.js +118 -0
- package/dist/lib/cli/remote/args.d.ts +5 -0
- package/dist/lib/cli/remote/args.js +45 -0
- package/dist/lib/cli/remote/binding.d.ts +10 -0
- package/dist/lib/cli/remote/binding.js +48 -0
- package/dist/lib/cli/remote/browser.d.ts +5 -0
- package/dist/lib/cli/remote/browser.js +24 -0
- package/dist/lib/cli/remote/commands/call.d.ts +11 -0
- package/dist/lib/cli/remote/commands/call.js +44 -0
- package/dist/lib/cli/remote/commands/deploy.d.ts +8 -0
- package/dist/lib/cli/remote/commands/deploy.js +47 -0
- package/dist/lib/cli/remote/commands/link.d.ts +4 -0
- package/dist/lib/cli/remote/commands/link.js +22 -0
- package/dist/lib/cli/remote/commands/ls.d.ts +4 -0
- package/dist/lib/cli/remote/commands/ls.js +18 -0
- package/dist/lib/cli/remote/commands/open.d.ts +2 -0
- package/dist/lib/cli/remote/commands/open.js +14 -0
- package/dist/lib/cli/remote/commands/util.d.ts +15 -0
- package/dist/lib/cli/remote/commands/util.js +20 -0
- package/dist/lib/cli/remote/confirmation.d.ts +6 -0
- package/dist/lib/cli/remote/confirmation.js +26 -0
- package/dist/lib/cli/remote/decision.d.ts +11 -0
- package/dist/lib/cli/remote/decision.js +24 -0
- package/dist/lib/cli/remote/exportedEndpoints.d.ts +6 -0
- package/dist/lib/cli/remote/exportedEndpoints.js +11 -0
- package/dist/lib/cli/remote/render.d.ts +5 -0
- package/dist/lib/cli/remote/render.js +36 -0
- package/dist/lib/cli/runPolicy.d.ts +9 -2
- package/dist/lib/cli/runPolicy.js +1 -1
- package/dist/lib/cli/statelog/serveClient.d.ts +33 -0
- package/dist/lib/cli/statelog/serveClient.js +174 -0
- package/dist/lib/cli/statelog/serveUrl.d.ts +29 -0
- package/dist/lib/cli/statelog/serveUrl.js +92 -0
- package/dist/lib/cli/{deploy → statelog}/uploadClient.d.ts +4 -14
- package/dist/lib/cli/{deploy → statelog}/uploadClient.js +26 -19
- package/dist/lib/config.d.ts +28 -0
- package/dist/lib/config.js +15 -0
- package/dist/lib/duration.d.ts +7 -0
- package/dist/lib/duration.js +29 -0
- package/dist/lib/eval/label/annotations.d.ts +53 -0
- package/dist/lib/eval/label/annotations.js +92 -0
- package/dist/lib/eval/label/capture.d.ts +45 -0
- package/dist/lib/eval/label/capture.js +219 -0
- package/dist/lib/eval/label/checklist.d.ts +107 -0
- package/dist/lib/eval/label/checklist.js +335 -0
- package/dist/lib/eval/label/controller.d.ts +36 -0
- package/dist/lib/eval/label/controller.js +488 -0
- package/dist/lib/eval/label/corpus.d.ts +7 -0
- package/dist/lib/eval/label/corpus.js +16 -0
- package/dist/lib/eval/label/draft.d.ts +148 -0
- package/dist/lib/eval/label/draft.js +103 -0
- package/dist/lib/eval/label/ids.d.ts +34 -0
- package/dist/lib/eval/label/ids.js +58 -0
- package/dist/lib/eval/label/jsonl.d.ts +53 -0
- package/dist/lib/eval/label/jsonl.js +187 -0
- package/dist/lib/eval/label/labelTui.d.ts +92 -0
- package/dist/lib/eval/label/labelTui.js +382 -0
- package/dist/lib/eval/label/lock.d.ts +27 -0
- package/dist/lib/eval/label/lock.js +122 -0
- package/dist/lib/eval/label/session.d.ts +130 -0
- package/dist/lib/eval/label/session.js +242 -0
- package/dist/lib/eval/label/store.d.ts +61 -0
- package/dist/lib/eval/label/store.js +268 -0
- package/dist/lib/eval/label/types.d.ts +169 -0
- package/dist/lib/eval/label/types.js +119 -0
- package/dist/lib/parser.js +5 -4
- package/dist/lib/parsers/parsers.d.ts +28 -2
- package/dist/lib/parsers/parsers.js +354 -49
- package/dist/lib/runtime/cliInterruptResolution.d.ts +16 -0
- package/dist/lib/runtime/cliInterruptResolution.js +41 -0
- package/dist/lib/runtime/configOverrides.d.ts +7 -0
- package/dist/lib/runtime/configOverrides.js +17 -0
- package/dist/lib/runtime/index.d.ts +1 -1
- package/dist/lib/runtime/index.js +1 -1
- package/dist/lib/runtime/interruptPrompts.d.ts +17 -0
- package/dist/lib/runtime/interruptPrompts.js +110 -0
- package/dist/lib/runtime/interruptResolution.d.ts +39 -0
- package/dist/lib/runtime/interruptResolution.js +68 -0
- package/dist/lib/runtime/interruptResponse.d.ts +11 -0
- package/dist/lib/runtime/interruptResponse.js +14 -0
- package/dist/lib/runtime/interrupts.d.ts +16 -10
- package/dist/lib/runtime/interrupts.js +47 -9
- package/dist/lib/runtime/node.js +1 -1
- package/dist/lib/runtime/rootBudget.d.ts +11 -2
- package/dist/lib/runtime/rootBudget.js +42 -18
- package/dist/lib/runtime/runPolicyHandler.d.ts +4 -22
- package/dist/lib/runtime/runPolicyHandler.js +16 -168
- package/dist/lib/runtime/state/context.d.ts +13 -0
- package/dist/lib/runtime/state/context.js +7 -0
- package/dist/lib/runtime/trace/canonicalize.d.ts +1 -1
- package/dist/lib/runtime/trace/canonicalize.js +5 -17
- package/dist/lib/serve/http/adapter.js +6 -2
- package/dist/lib/serve/metadata.d.ts +1 -0
- package/dist/lib/serve/metadata.js +6 -3
- package/dist/lib/stdlib/layout/ansi.js +35 -9
- package/dist/lib/tui/input/terminal.d.ts +8 -0
- package/dist/lib/tui/input/terminal.js +39 -2
- package/dist/lib/tui/screen.d.ts +3 -0
- package/dist/lib/tui/screen.js +6 -0
- package/dist/lib/tui/styleParser.js +15 -6
- package/dist/lib/typeChecker/diagnosticExplanations.js +5 -0
- package/dist/lib/typeChecker/diagnostics.d.ts +5 -0
- package/dist/lib/typeChecker/diagnostics.js +5 -0
- package/dist/lib/typeChecker/index.js +3 -0
- package/dist/lib/typeChecker/nameReferences.d.ts +37 -0
- package/dist/lib/typeChecker/nameReferences.js +69 -0
- package/dist/lib/typeChecker/templateNames.d.ts +31 -0
- package/dist/lib/typeChecker/templateNames.js +260 -0
- package/dist/lib/typeChecker/undefinedFunctionDiagnostic.js +10 -18
- package/dist/lib/typeChecker/undefinedVariableDiagnostic.js +7 -58
- package/dist/lib/types/access.d.ts +1 -1
- package/dist/lib/types/base.d.ts +10 -0
- package/dist/lib/types/dataStructures.d.ts +27 -7
- package/dist/lib/types/dataStructures.js +3 -1
- package/dist/lib/types/exportFromStatement.d.ts +3 -0
- package/dist/lib/types/function.d.ts +5 -0
- package/dist/lib/types/graphNode.d.ts +3 -0
- package/dist/lib/types/guardBlock.d.ts +3 -0
- package/dist/lib/types/hole.d.ts +2 -2
- package/dist/lib/types/importStatement.d.ts +5 -0
- package/dist/lib/types/interruptStatement.d.ts +3 -0
- package/dist/lib/types/matchBlock.d.ts +3 -1
- package/dist/lib/types/messageThread.d.ts +3 -0
- package/dist/lib/types/parallelBlock.d.ts +3 -0
- package/dist/lib/types/pattern.d.ts +5 -0
- package/dist/lib/types/typeHints.d.ts +3 -5
- package/dist/lib/utils/canonicalize.d.ts +14 -0
- package/dist/lib/utils/canonicalize.js +33 -0
- package/dist/lib/utils/termcolors.d.ts +2 -0
- package/dist/lib/utils/termcolors.js +1 -0
- package/dist/scripts/agency.js +66 -19
- package/package.json +1 -1
- package/stdlib/docs/cli/deploy.md +2 -2
- package/stdlib/docs/diagnostics/index.md +1 -0
- package/stdlib/docs/diagnostics/templates.md +12 -0
- package/stdlib/docs/guide/template-agency.md +34 -0
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import { AgencyComment, AgencyMultiLineComment, AgencyNode, AgencyProgram, Assignment, Comprehension, DebuggerStatement, Hole, InterruptStatement, Literal, NewLine,
|
|
1
|
+
import { AgencyComment, AgencyMultiLineComment, AgencyNode, AgencyProgram, Assignment, Comprehension, DebuggerStatement, Hole, InterruptStatement, Literal, NewLine, ParallelBlock, Scope, SeqBlock, TypeAlias, VariableType } from "../types.js";
|
|
2
|
+
import { LineComment } from "../types/base.js";
|
|
3
|
+
import { ListTrivia, TriviaNode } from "../types/dataStructures.js";
|
|
4
|
+
/** One rendered list item. `leadingLines` are whole lines that print above
|
|
5
|
+
* it (an object-type property's `@validate` tags); the shared renderer
|
|
6
|
+
* indents them, so callers hand back plain text. */
|
|
7
|
+
type RenderedListItem = {
|
|
8
|
+
leadingLines?: string[];
|
|
9
|
+
code: string;
|
|
10
|
+
};
|
|
11
|
+
type RenderListWithTriviaOptions<T> = {
|
|
12
|
+
items: T[];
|
|
13
|
+
trivia: ListTrivia[] | undefined;
|
|
14
|
+
open: string;
|
|
15
|
+
close: string;
|
|
16
|
+
renderItem: (item: T, index: number) => RenderedListItem;
|
|
17
|
+
separator: (index: number, itemCount: number) => string;
|
|
18
|
+
};
|
|
2
19
|
import { AccessChainElement, ValueAccess } from "../types/access.js";
|
|
3
20
|
import { CodeLiteral } from "../types/codeLiteral.js";
|
|
4
21
|
import { BlockArgument } from "../types/blockArgument.js";
|
|
5
|
-
import { AgencyArray, AgencyObject
|
|
22
|
+
import { AgencyArray, AgencyObject } from "../types/dataStructures.js";
|
|
6
23
|
import { FunctionCall, FunctionDefinition } from "../types/function.js";
|
|
7
24
|
import { GraphNodeDefinition } from "../types/graphNode.js";
|
|
8
25
|
import { IfElse } from "../types/ifElse.js";
|
|
@@ -25,6 +42,7 @@ import { GuardBlock } from "../types/guardBlock.js";
|
|
|
25
42
|
import { Tag } from "../types/tag.js";
|
|
26
43
|
import { NewExpression } from "../types/newExpression.js";
|
|
27
44
|
import { BindingPattern, MatchPattern } from "../types/pattern.js";
|
|
45
|
+
type TypeRenderPolicy = "source" | "display";
|
|
28
46
|
export declare function escapeStringText(s: string, delim: '"' | "'" | "`"): string;
|
|
29
47
|
export declare class AgencyGenerator {
|
|
30
48
|
protected graphNodes: GraphNodeDefinition[];
|
|
@@ -111,13 +129,34 @@ export declare class AgencyGenerator {
|
|
|
111
129
|
private increaseIndent;
|
|
112
130
|
private decreaseIndent;
|
|
113
131
|
private indentStr;
|
|
132
|
+
/** `renderItems` is a callback, not an array, because a multi-line item has
|
|
133
|
+
* to be built at the depth it will actually print at. Rewriting an
|
|
134
|
+
* already-rendered item's lines instead would reach inside triple-quoted
|
|
135
|
+
* strings, whose newlines are data rather than layout, and silently change
|
|
136
|
+
* the program. So the items are rendered once to measure, and rendered
|
|
137
|
+
* again after the indent increases if the list turns out to wrap. */
|
|
114
138
|
private wrapList;
|
|
115
139
|
private renderParams;
|
|
140
|
+
private renderTypeSource;
|
|
141
|
+
private renderTypeDisplay;
|
|
142
|
+
private objectTypeHasPropertyMetadata;
|
|
143
|
+
private renderType;
|
|
116
144
|
private stringifyProp;
|
|
117
|
-
|
|
118
|
-
protected
|
|
145
|
+
/** One trivia node as its own source line. */
|
|
146
|
+
protected renderTriviaNode(node: TriviaNode): string;
|
|
147
|
+
/** Comments that print on their own line ABOVE item `anchorIndex`. */
|
|
148
|
+
protected beforeTriviaAt(trivia: ListTrivia[] | undefined, anchorIndex: number): TriviaNode[];
|
|
149
|
+
/** Comments that print at the END of item `anchorIndex`'s line. */
|
|
150
|
+
protected trailingTriviaAt(trivia: ListTrivia[] | undefined, anchorIndex: number): LineComment[];
|
|
151
|
+
/** Render one multiline list, owning indentation and both comment
|
|
152
|
+
* placements. Callers supply how to render an item and where separators
|
|
153
|
+
* go; they must not place comments themselves. */
|
|
154
|
+
protected renderListWithTrivia<T>(args: RenderListWithTriviaOptions<T>): string;
|
|
155
|
+
protected aliasedTypeToString(aliasedType: VariableType, policy: TypeRenderPolicy): string;
|
|
156
|
+
private renderObjectTypeSource;
|
|
119
157
|
protected processEffectDeclaration(node: EffectDeclaration): string;
|
|
120
158
|
protected processTypeAlias(node: TypeAlias): string;
|
|
159
|
+
private composeTypeAliasAssignment;
|
|
121
160
|
/**
|
|
122
161
|
* Format the `<T, U = string, ...>` chunk of a generic alias declaration.
|
|
123
162
|
* Returns an empty string when there are no type params.
|
|
@@ -181,13 +220,32 @@ export declare class AgencyGenerator {
|
|
|
181
220
|
* node and stripping keywords, so all three kinds share one canonical
|
|
182
221
|
* signature path. */
|
|
183
222
|
signatureOf(node: FunctionDefinition | GraphNodeDefinition | TypeAlias): string;
|
|
223
|
+
/** Render the annotations that precede a type alias declaration. */
|
|
224
|
+
declarationAnnotationPrefixOf(node: TypeAlias): string;
|
|
184
225
|
protected processFunctionDefinition(node: FunctionDefinition): string;
|
|
185
226
|
protected processFunctionCall(node: FunctionCall): string;
|
|
186
227
|
protected renderArgs(args: FunctionCall["arguments"], block?: BlockArgument): string[];
|
|
187
|
-
|
|
228
|
+
/** A list of already-rendered items laid out across lines with its
|
|
229
|
+
* comments, or `undefined` when there are none. Callers keep their own
|
|
230
|
+
* inline or wrapping behavior for the no-comment case, so trivia-free
|
|
231
|
+
* output is untouched; a comment cannot share a line with what follows
|
|
232
|
+
* it, so its presence forces the multiline form. */
|
|
233
|
+
protected renderListIfTrivia(rendered: string[], trivia: ListTrivia[] | undefined, open: string, close: string): string | undefined;
|
|
234
|
+
/** The one way a parenthesized `( ... )` list is printed. Without trivia
|
|
235
|
+
* it keeps `wrapList`'s compact/wrapping behavior exactly; with trivia it
|
|
236
|
+
* goes multiline. `rendered` must already be in canonical print order —
|
|
237
|
+
* for a call that means `renderArgs` has appended any inline block last,
|
|
238
|
+
* matching how `extractInlineBlock` remapped the anchors. */
|
|
239
|
+
protected renderParenList(renderItems: () => string[], trivia: ListTrivia[] | undefined, prefix: string, suffix: string): string;
|
|
240
|
+
/** A parenthesized argument list that normally stays on one line
|
|
241
|
+
* (access chains, `interrupt`, `guard`). Trivia forces the multiline
|
|
242
|
+
* form, since a `//` comment cannot share a line with what follows it. */
|
|
243
|
+
protected renderArgList(args: FunctionCall["arguments"], block?: BlockArgument, trivia?: ListTrivia[]): string;
|
|
188
244
|
protected generateFunctionCallExpression(node: FunctionCall, context: "valueAccess" | "functionArg" | "topLevelStatement"): string;
|
|
189
245
|
protected processAgencyArray(node: AgencyArray): string;
|
|
246
|
+
private renderArrayItem;
|
|
190
247
|
protected processAgencyObject(node: AgencyObject): string;
|
|
248
|
+
private renderObjectEntry;
|
|
191
249
|
private addQuotesToKey;
|
|
192
250
|
protected processValueAccess(node: ValueAccess): string;
|
|
193
251
|
/** Print `[| ... |]`. An expr-kind body that fits one line prints
|
|
@@ -200,6 +258,10 @@ export declare class AgencyGenerator {
|
|
|
200
258
|
protected processCodeLiteral(node: CodeLiteral): string;
|
|
201
259
|
protected asyncAwaitPrefix(code: string, async?: boolean): string;
|
|
202
260
|
protected processMatchBlock(node: MatchBlock): string;
|
|
261
|
+
/** One arm, without its final newline — a complete construct an
|
|
262
|
+
* attached comment can follow. */
|
|
263
|
+
private renderInlineMatchArm;
|
|
264
|
+
private renderBlockMatchArm;
|
|
203
265
|
/** Whether a one-statement arm body may print inline (`=> stmt`)
|
|
204
266
|
* rather than as a `{ ... }` block.
|
|
205
267
|
*
|
|
@@ -223,12 +285,21 @@ export declare class AgencyGenerator {
|
|
|
223
285
|
protected formatIfExpression(node: IfElse): string;
|
|
224
286
|
protected processGotoStatement(node: GotoStatement): string;
|
|
225
287
|
protected processDebuggerStatement(node: DebuggerStatement): string;
|
|
288
|
+
/** The sole owner of line-comment source text. Do not rebuild
|
|
289
|
+
* `//${content}` anywhere else. */
|
|
290
|
+
protected commentText(comment: LineComment): string;
|
|
226
291
|
protected processComment(node: AgencyComment): string;
|
|
292
|
+
/** Place an attached comment after already-rendered code. Empty code has
|
|
293
|
+
* no construct to attach to, so the comment is left to its owner. */
|
|
294
|
+
protected appendTrailingComment(code: string, comment: LineComment | undefined): string;
|
|
227
295
|
protected processMultiLineComment(node: AgencyMultiLineComment): string;
|
|
228
296
|
protected formatDocComment(node: {
|
|
229
297
|
docComment?: AgencyMultiLineComment;
|
|
230
298
|
}): string;
|
|
231
299
|
protected processImportStatement(node: ImportStatement): string;
|
|
300
|
+
/** The names inside an import's `{ ... }`, with their aliases and
|
|
301
|
+
* retry-safety markers. Shared by the sole-named and mixed paths. */
|
|
302
|
+
private renderImportNames;
|
|
232
303
|
protected processImportNameType(node: ImportNameType): string;
|
|
233
304
|
/** Render an imported/re-exported name with its `destructive` or
|
|
234
305
|
* `idempotent` prefix. A name carries at most one marker. */
|
|
@@ -280,3 +351,4 @@ export declare function generateAgency(program: AgencyProgram, opts?: {
|
|
|
280
351
|
* NOT `expressionToString` (lib/utils/node.ts), which drops string quotes.
|
|
281
352
|
*/
|
|
282
353
|
export declare function generateExpression(expr: AgencyNode): string;
|
|
354
|
+
export {};
|