agency-lang 0.13.2 → 0.13.3

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 (80) hide show
  1. package/dist/lib/agents/agency-agent/agent.js +0 -4
  2. package/dist/lib/agents/agency-agent/prompts/codeSample.js +0 -4
  3. package/dist/lib/agents/eval/goalJudge.js +1 -5
  4. package/dist/lib/agents/policy/agent.js +0 -4
  5. package/dist/lib/agents/review/agent.js +0 -4
  6. package/dist/lib/backends/agencyGenerator.d.ts +2 -0
  7. package/dist/lib/backends/agencyGenerator.js +7 -1
  8. package/dist/lib/backends/typescriptBuilder.js +15 -11
  9. package/dist/lib/cli/commandLine.d.ts +62 -0
  10. package/dist/lib/cli/commandLine.js +178 -0
  11. package/dist/lib/cli/commands.d.ts +3 -2
  12. package/dist/lib/cli/commands.js +3 -2
  13. package/dist/lib/cli/doc.d.ts +24 -0
  14. package/dist/lib/cli/doc.js +262 -53
  15. package/dist/lib/cli/docLedger.d.ts +149 -0
  16. package/dist/lib/cli/docLedger.js +378 -0
  17. package/dist/lib/cli/help.js +2 -2
  18. package/dist/lib/cli/modelFlag.d.ts +16 -0
  19. package/dist/lib/cli/modelFlag.js +61 -0
  20. package/dist/lib/cli/remote/commands/spend.d.ts +8 -0
  21. package/dist/lib/cli/remote/commands/spend.js +51 -0
  22. package/dist/lib/cli/remote/commands/spendWindow.d.ts +10 -0
  23. package/dist/lib/cli/remote/commands/spendWindow.js +80 -0
  24. package/dist/lib/cli/remote/render.d.ts +7 -0
  25. package/dist/lib/cli/remote/render.js +229 -0
  26. package/dist/lib/cli/statelog/accountClient.d.ts +2 -0
  27. package/dist/lib/cli/statelog/accountClient.js +35 -11
  28. package/dist/lib/cli/statelog/projectClient.d.ts +2 -0
  29. package/dist/lib/cli/statelog/projectClient.js +31 -8
  30. package/dist/lib/cli/statelog/spendTypes.d.ts +206 -0
  31. package/dist/lib/cli/statelog/spendTypes.js +109 -0
  32. package/dist/lib/compiler/buildManifest.d.ts +23 -1
  33. package/dist/lib/compiler/buildManifest.js +46 -9
  34. package/dist/lib/compiler/buildSession.d.ts +2 -1
  35. package/dist/lib/compiler/buildSession.js +20 -11
  36. package/dist/lib/compiler/compileClosure.d.ts +3 -1
  37. package/dist/lib/compiler/compileClosure.js +11 -2
  38. package/dist/lib/compiler/depFingerprint.d.ts +30 -0
  39. package/dist/lib/compiler/depFingerprint.js +83 -0
  40. package/dist/lib/compiler/manifestTracker.d.ts +6 -3
  41. package/dist/lib/compiler/manifestTracker.js +11 -5
  42. package/dist/lib/config.d.ts +15 -0
  43. package/dist/lib/config.js +18 -0
  44. package/dist/lib/eval/grading/graders/builtinGraders.js +1 -14
  45. package/dist/lib/levenshtein.d.ts +2 -0
  46. package/dist/lib/levenshtein.js +14 -0
  47. package/dist/lib/runtime/cost.d.ts +5 -5
  48. package/dist/lib/runtime/cost.js +12 -9
  49. package/dist/lib/runtime/costTelemetry.d.ts +23 -29
  50. package/dist/lib/runtime/costTelemetry.js +53 -19
  51. package/dist/lib/runtime/deterministicClient.js +6 -1
  52. package/dist/lib/runtime/invocationUsage.d.ts +86 -43
  53. package/dist/lib/runtime/invocationUsage.js +332 -80
  54. package/dist/lib/runtime/ipc.d.ts +8 -7
  55. package/dist/lib/runtime/ipc.js +10 -17
  56. package/dist/lib/runtime/memory/manager.js +83 -41
  57. package/dist/lib/runtime/modelIdentity.d.ts +1 -0
  58. package/dist/lib/runtime/modelIdentity.js +10 -0
  59. package/dist/lib/runtime/prompt.js +5 -4
  60. package/dist/lib/runtime/recordPaidUsage.d.ts +28 -37
  61. package/dist/lib/runtime/recordPaidUsage.js +68 -49
  62. package/dist/lib/serve/testOutcome.js +7 -1
  63. package/dist/lib/stdlib/image.js +37 -20
  64. package/dist/scripts/agency.d.ts +0 -1
  65. package/dist/scripts/agency.js +125 -84
  66. package/dist/scripts/generateDiagnosticsDocs.js +2 -2
  67. package/package.json +1 -1
  68. package/stdlib/args.agency +25 -0
  69. package/stdlib/args.js +1 -1
  70. package/stdlib/docs/cli/run.md +126 -19
  71. package/stdlib/docs/cli/trace-and-bundle.md +1 -1
  72. package/stdlib/docs/guide/guards.md +1 -1
  73. package/stdlib/docs/guide/policies.md +3 -3
  74. package/stdlib/docs/stdlib/args.md +30 -5
  75. package/dist/lib/backends/typescriptBuilder/directRunArgsCheck.d.ts +0 -11
  76. package/dist/lib/backends/typescriptBuilder/directRunArgsCheck.js +0 -19
  77. package/dist/lib/templates/backends/typescriptGenerator/directRunArgsCheck.d.ts +0 -7
  78. package/dist/lib/templates/backends/typescriptGenerator/directRunArgsCheck.js +0 -13
  79. package/dist/scripts/stdlib-stamp.d.ts +0 -1
  80. package/dist/scripts/stdlib-stamp.js +0 -31
@@ -1594,10 +1594,6 @@ async function main({ messages, callbacks } = {}) {
1594
1594
  }
1595
1595
  const __mainNodeParams = [];
1596
1596
  if (__process.argv[1] === fileURLToPath(import.meta.url)) {
1597
- if (__process.argv.length > 2) {
1598
- console.error(`main() takes 0 argument(s) but got ${__process.argv.length - 2}; extra: ${__process.argv.slice(2).join(" ")}`);
1599
- __process.exit(1);
1600
- }
1601
1597
  try {
1602
1598
  const initialState = {
1603
1599
  messages: new ThreadStore(),
@@ -768,10 +768,6 @@ async function createMeals({ messages, callbacks } = {}) {
768
768
  }
769
769
  const __createMealsNodeParams = [];
770
770
  if (__process.argv[1] === fileURLToPath(import.meta.url)) {
771
- if (__process.argv.length > 2) {
772
- console.error(`main() takes 0 argument(s) but got ${__process.argv.length - 2}; extra: ${__process.argv.slice(2).join(" ")}`);
773
- __process.exit(1);
774
- }
775
771
  try {
776
772
  const initialState = {
777
773
  messages: new ThreadStore(),
@@ -320,16 +320,12 @@ async function main(goal, output, expected = ``, { messages, callbacks } = {}) {
320
320
  }
321
321
  const __mainNodeParams = ["goal", "output", "expected"];
322
322
  if (__process.argv[1] === fileURLToPath(import.meta.url)) {
323
- if (__process.argv.length > 5) {
324
- console.error(`main() takes 3 argument(s) but got ${__process.argv.length - 2}; extra: ${__process.argv.slice(5).join(" ")}`);
325
- __process.exit(1);
326
- }
327
323
  try {
328
324
  const initialState = {
329
325
  messages: new ThreadStore(),
330
326
  data: {}
331
327
  };
332
- const __result = await main(__process.argv[2], __process.argv[3], __process.argv[4], initialState);
328
+ const __result = await main(void 0, void 0, void 0, initialState);
333
329
  await resolveCliInterrupts(__result, respondToInterrupts);
334
330
  } catch (__error) {
335
331
  reportBudgetExceededAndExit(__error);
@@ -2073,10 +2073,6 @@ async function main({ messages, callbacks } = {}) {
2073
2073
  }
2074
2074
  const __mainNodeParams = [];
2075
2075
  if (__process.argv[1] === fileURLToPath(import.meta.url)) {
2076
- if (__process.argv.length > 2) {
2077
- console.error(`main() takes 0 argument(s) but got ${__process.argv.length - 2}; extra: ${__process.argv.slice(2).join(" ")}`);
2078
- __process.exit(1);
2079
- }
2080
2076
  try {
2081
2077
  const initialState = {
2082
2078
  messages: new ThreadStore(),
@@ -808,10 +808,6 @@ async function end({ messages, callbacks } = {}) {
808
808
  }
809
809
  const __endNodeParams = [];
810
810
  if (__process.argv[1] === fileURLToPath(import.meta.url)) {
811
- if (__process.argv.length > 2) {
812
- console.error(`main() takes 0 argument(s) but got ${__process.argv.length - 2}; extra: ${__process.argv.slice(2).join(" ")}`);
813
- __process.exit(1);
814
- }
815
811
  try {
816
812
  const initialState = {
817
813
  messages: new ThreadStore(),
@@ -76,6 +76,7 @@ export declare class AgencyGenerator {
76
76
  constructor(args?: {
77
77
  config?: AgencyConfig;
78
78
  preserveOrder?: boolean;
79
+ debug?: boolean;
79
80
  });
80
81
  protected trace(methodName: string, result: string): string;
81
82
  configDefaults(): Partial<AgencyConfig>;
@@ -344,6 +345,7 @@ export declare class AgencyGenerator {
344
345
  export declare function printCodeLiteralBody(node: CodeLiteral): string;
345
346
  export declare function generateAgency(program: AgencyProgram, opts?: {
346
347
  preserveOrder?: boolean;
348
+ debug?: boolean;
347
349
  }): string;
348
350
  /**
349
351
  * Formatter-exact source rendering of a single expression — the same
@@ -105,6 +105,9 @@ export class AgencyGenerator {
105
105
  constructor(args = {}) {
106
106
  this.agencyConfig = mergeDeep(this.configDefaults(), args.config || {});
107
107
  this.preserveOrder = args.preserveOrder ?? false;
108
+ // Explicit override for callers whose output must not vary with the
109
+ // environment (agency doc); default keeps the AGENCY_DEBUG behavior.
110
+ this.debug = args.debug ?? this.debug;
108
111
  if (this.agencyConfig.verbose) {
109
112
  console.log("Generator config:", this.agencyConfig);
110
113
  }
@@ -1861,7 +1864,10 @@ export function printCodeLiteralBody(node) {
1861
1864
  return generateAgency({ type: "agencyProgram", nodes: node.nodes }).trimEnd();
1862
1865
  }
1863
1866
  export function generateAgency(program, opts = {}) {
1864
- const generator = new AgencyGenerator({ preserveOrder: opts.preserveOrder });
1867
+ const generator = new AgencyGenerator({
1868
+ preserveOrder: opts.preserveOrder,
1869
+ debug: opts.debug,
1870
+ });
1865
1871
  return (generator
1866
1872
  .generate(program)
1867
1873
  .output.trim()
@@ -57,7 +57,6 @@ function coarseKindFor(typeHint) {
57
57
  }
58
58
  import { printTs } from "../ir/prettyPrint.js";
59
59
  import { SourceMapBuilder } from "./sourceMap.js";
60
- import { directRunExtraArgsCheck } from "./typescriptBuilder/directRunArgsCheck.js";
61
60
  import { nodeWrapperParams } from "./typescriptBuilder/nodeWrapperParams.js";
62
61
  import { ScopeManager } from "./typescriptBuilder/scopeManager.js";
63
62
  import { StepPathTracker } from "./typescriptBuilder/stepPathTracker.js";
@@ -3686,24 +3685,29 @@ export class TypeScriptBuilder {
3686
3685
  result.push(ts.export(ts.varDecl("const", `__${declaredName(node.nodeName)}NodeParams`, ts.arr(args.map((arg) => ts.str(arg.name))))));
3687
3686
  }
3688
3687
  if (this.compilationUnit.graphNodes.some((n) => n.nodeName === "main")) {
3689
- // Direct-run argv maps onto main's parameters positionally (argv[2]
3690
- // onward `agency run file.agency -- <args>` forwards them), and
3691
- // initialState is the OPTIONS argument after them. Before this,
3692
- // initialState was always the first argument: harmless when mains took
3693
- // no parameters (it landed in the options slot), wrong once entry
3694
- // nodes take parameters (#739) — the state object arrived as the
3695
- // first parameter's value. Absent argv entries are undefined, so
3696
- // parameter defaults apply.
3688
+ // The direct-run call reserves one slot per declared parameter and puts
3689
+ // initialState after them, in main's hidden OPTIONS argument.
3690
+ //
3691
+ // The reservation is what matters: initialState used to be the FIRST
3692
+ // argument, which was harmless while mains took no parameters (it landed
3693
+ // in the options slot) and wrong once they did (#739) — the state object
3694
+ // arrived as the first parameter's value. `undefined` in each slot keeps
3695
+ // it where it belongs, and JavaScript treats an explicit `undefined` and
3696
+ // an omitted argument alike, so parameter defaults still apply.
3697
+ //
3698
+ // The slots are filled with `undefined` rather than argv because a
3699
+ // program's command line belongs to the program. `agency run` forwards
3700
+ // trailing arguments to the child process, where `std::args` reads them;
3701
+ // the compiler does not read them on the entry node's behalf.
3697
3702
  const mainParamCount = this.compilationUnit.graphNodes.find((n) => n.nodeName === "main")
3698
3703
  ?.parameters.length ?? 0;
3699
3704
  const mainCallArgs = [
3700
- ...Array.from({ length: mainParamCount }, (_unused, i) => $(ts.id("__process")).prop("argv").index(ts.num(2 + i)).done()),
3705
+ ...Array.from({ length: mainParamCount }, () => ts.id("undefined")),
3701
3706
  ts.id("initialState"),
3702
3707
  ];
3703
3708
  result.push(ts.if(ts.binOp($(ts.id("__process")).prop("argv").index(ts.num(1)).done(), "===", ts.call(ts.id("fileURLToPath"), [
3704
3709
  $(ts.id("import")).prop("meta").prop("url").done(),
3705
3710
  ])), ts.statements([
3706
- directRunExtraArgsCheck(mainParamCount),
3707
3711
  ts.tryCatch(ts.statements([
3708
3712
  ts.varDecl("const", "initialState", ts.obj({
3709
3713
  messages: ts.newThreadStore(),
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Decides where agency's command line ends and the program's begins.
3
+ *
4
+ * `agency run --policy strict greet.agency --name alice` carries two command
5
+ * lines. The rule is position: agency's flags and its own positional arguments
6
+ * come first, and everything after them belongs to the program. Commander
7
+ * cannot express that — `passThroughOptions` would, but it requires positional
8
+ * parsing on the root command, which stops every nested command from seeing its
9
+ * parent's options (`agency label ingest --store x` fails outright).
10
+ *
11
+ * So the boundary is drawn before commander runs, by inserting `--`. Commander
12
+ * removes the separator itself, so the program never sees it.
13
+ *
14
+ * Three commands need this and differ only in their policy, which is why they
15
+ * share one walk rather than one each:
16
+ *
17
+ * run one owned positional (the filename); warns on a collision
18
+ * agent no owned positionals; forwards its own flags without comment
19
+ * shorthand `agency greet.agency` — run without the word `run`
20
+ */
21
+ export type Arity = "none" | "required" | "optional";
22
+ export type CliOption = {
23
+ short?: string;
24
+ long?: string;
25
+ arity: Arity;
26
+ };
27
+ export type Boundary = {
28
+ /** Subcommand this applies to, or null for the bare `agency greet.agency`
29
+ * form, which is whatever is left when the first word names no command. */
30
+ command: string | null;
31
+ /** Agency's own positional arguments, which sit before the program's. */
32
+ ownedPositionals: number;
33
+ /** Options agency parses before the boundary. */
34
+ options: CliOption[];
35
+ /** Whether to warn when one of `options` turns up after the boundary. */
36
+ warnOnCollision: boolean;
37
+ };
38
+ export type SplitCommandLine = {
39
+ /** argv with the separator inserted, ready for commander. */
40
+ argv: string[];
41
+ /** An agency flag that went to the program because of where it was written.
42
+ * Position still decides — this only says so out loud. */
43
+ warning?: string;
44
+ };
45
+ export declare function splitCommandLine(argv: string[], rootOptions: CliOption[], boundaries: Boundary[],
46
+ /** Every command and alias the CLI knows, so a filename can be told from a
47
+ * command name. Without it `agency compile a.agency b.agency` would look
48
+ * like the shorthand and have a separator pushed into its file list. */
49
+ commandNames?: string[]): SplitCommandLine;
50
+ export declare function misplacedFlagWarning(flag: string, input: string): string;
51
+ /**
52
+ * Walks past `node`, the script path, and agency's own top-level flags to find
53
+ * the subcommand. Returns -1 if there is none.
54
+ */
55
+ export declare function findSubcommandIndex(argv: string[], rootOptions: CliOption[]): number;
56
+ /**
57
+ * The agency options a token names. Commander accepts four spellings and a
58
+ * check that understands only the plainest one stays quiet for the rest:
59
+ *
60
+ * --policy strict --policy=strict -c file.json -cfile.json -iv
61
+ */
62
+ export declare function flagNamesIn(token: string, options: CliOption[]): string[];
@@ -0,0 +1,178 @@
1
+ export function splitCommandLine(argv, rootOptions, boundaries,
2
+ /** Every command and alias the CLI knows, so a filename can be told from a
3
+ * command name. Without it `agency compile a.agency b.agency` would look
4
+ * like the shorthand and have a separator pushed into its file list. */
5
+ commandNames = []) {
6
+ // The shorthand puts run's flags at the top level, so the scan for the
7
+ // subcommand has to recognize every flag agency owns anywhere — not just the
8
+ // root's. Otherwise `agency --policy strict greet.agency` stops on `strict`
9
+ // and treats it as the filename.
10
+ const subcommand = findSubcommandIndex(argv, [
11
+ ...rootOptions,
12
+ ...boundaries.flatMap((b) => b.options),
13
+ ]);
14
+ if (subcommand === -1)
15
+ return { argv };
16
+ const named = boundaries.find((b) => b.command === argv[subcommand]);
17
+ const boundary = named ??
18
+ (commandNames.includes(argv[subcommand])
19
+ ? undefined
20
+ : boundaries.find((b) => b.command === null));
21
+ if (boundary === undefined)
22
+ return { argv };
23
+ // Agency's flags come first, then its own positionals. Anything after that
24
+ // is the program's, flags included — which is what the position rule means.
25
+ // The shorthand has no command word to step over, so its walk starts on the
26
+ // filename itself.
27
+ let i = subcommand + (boundary.command === null ? 0 : 1);
28
+ while (isFlag(argv[i])) {
29
+ // The user drew the line themselves.
30
+ if (argv[i] === "--")
31
+ return { argv };
32
+ const consumed = ownedFlagTokens(argv[i], argv[i + 1], boundary.options);
33
+ // A flag agency does not own is already the program's.
34
+ if (consumed === undefined)
35
+ break;
36
+ i += consumed;
37
+ }
38
+ if (argv[i] === "--")
39
+ return { argv };
40
+ let input;
41
+ for (let n = 0; n < boundary.ownedPositionals; n += 1) {
42
+ // Agency's own positional is missing. Commander reports that better.
43
+ if (i >= argv.length || isFlag(argv[i]))
44
+ return { argv };
45
+ input = argv[i];
46
+ i += 1;
47
+ }
48
+ const rest = argv.slice(i);
49
+ if (rest.length === 0 || rest[0] === "--")
50
+ return { argv };
51
+ const claimed = boundary.warnOnCollision
52
+ ? rest.flatMap((token) => flagNamesIn(token, boundary.options)).find((name) => findOption(name, boundary.options) !== undefined)
53
+ : undefined;
54
+ return {
55
+ argv: [...argv.slice(0, i), "--", ...rest],
56
+ warning: claimed === undefined
57
+ ? undefined
58
+ : misplacedFlagWarning(claimed, input ?? "your-program.agency"),
59
+ };
60
+ }
61
+ export function misplacedFlagWarning(flag, input) {
62
+ return [
63
+ `Warning: ${flag} went to your program, not to agency.`,
64
+ ` Agency flags go before the filename: agency run ${flag} ... ${input}`,
65
+ ` Write -- before it to silence this: agency run ${input} -- ${flag} ...`,
66
+ ].join("\n");
67
+ }
68
+ /**
69
+ * Walks past `node`, the script path, and agency's own top-level flags to find
70
+ * the subcommand. Returns -1 if there is none.
71
+ */
72
+ export function findSubcommandIndex(argv, rootOptions) {
73
+ // argv[0] = node, argv[1] = script path. The search starts at 2.
74
+ let i = 2;
75
+ while (i < argv.length) {
76
+ const token = argv[i];
77
+ if (token === "--")
78
+ return -1;
79
+ if (!isFlag(token))
80
+ return i;
81
+ i += tokensConsumedBy(token, argv[i + 1], rootOptions);
82
+ }
83
+ return -1;
84
+ }
85
+ function isFlag(token) {
86
+ return token !== undefined && token.startsWith("-") && token !== "-";
87
+ }
88
+ function findOption(name, options) {
89
+ return options.find((o) => o.short === name || o.long === name);
90
+ }
91
+ /**
92
+ * The agency options a token names. Commander accepts four spellings and a
93
+ * check that understands only the plainest one stays quiet for the rest:
94
+ *
95
+ * --policy strict --policy=strict -c file.json -cfile.json -iv
96
+ */
97
+ export function flagNamesIn(token, options) {
98
+ if (!isFlag(token))
99
+ return [];
100
+ if (token.startsWith("--")) {
101
+ const equals = token.indexOf("=");
102
+ return [equals === -1 ? token : token.slice(0, equals)];
103
+ }
104
+ return parseShortToken(token, options).names;
105
+ }
106
+ /**
107
+ * Reads a short token left to right, the way commander does.
108
+ *
109
+ * The first letter decides whether the token is agency's at all: `-print` is a
110
+ * program's flag, not a bundle containing agency's `-i`, because `-p` is not an
111
+ * agency flag. Reading every letter instead would warn about it.
112
+ */
113
+ function parseShortToken(token, options) {
114
+ const letters = [...token.slice(1)];
115
+ const names = [];
116
+ for (const [index, letter] of letters.entries()) {
117
+ const option = findOption(`-${letter}`, options);
118
+ // Unknown first letter: the whole token belongs to the program. Unknown
119
+ // later: it is the attached value of the option before it.
120
+ if (option === undefined) {
121
+ return { names: index === 0 ? [] : names };
122
+ }
123
+ names.push(`-${letter}`);
124
+ // A value-taking option ends the bundle. Its value is the rest of the
125
+ // token, or the next word when it is the last letter.
126
+ if (option.arity !== "none") {
127
+ return index === letters.length - 1
128
+ ? { names, trailing: option }
129
+ : { names };
130
+ }
131
+ }
132
+ return { names };
133
+ }
134
+ /**
135
+ * How many tokens an agency flag covers, or undefined if it is not agency's.
136
+ *
137
+ * The next token is needed because commander treats the two value kinds
138
+ * differently. A required value takes whatever follows, even another flag:
139
+ * `--policy --verbose` gives policy="--verbose". An optional value steps over
140
+ * something that looks like a flag — `--trace --verbose` leaves trace bare —
141
+ * but still takes `-5`, because a digit after the dash reads as a negative
142
+ * number rather than a flag.
143
+ */
144
+ function ownedFlagTokens(token, next, options) {
145
+ if (token.startsWith("--")) {
146
+ const equals = token.indexOf("=");
147
+ const name = equals === -1 ? token : token.slice(0, equals);
148
+ const arity = findOption(name, options)?.arity;
149
+ if (arity === undefined)
150
+ return undefined;
151
+ if (equals !== -1)
152
+ return 1;
153
+ return tokensForValue(arity, next);
154
+ }
155
+ const short = parseShortToken(token, options);
156
+ if (short.names.length === 0)
157
+ return undefined;
158
+ if (short.trailing === undefined)
159
+ return 1;
160
+ return tokensForValue(short.trailing.arity, next);
161
+ }
162
+ function tokensForValue(arity, next) {
163
+ if (arity === "none")
164
+ return 1;
165
+ if (arity === "required")
166
+ return 2;
167
+ return next === undefined || looksLikeOption(next) ? 1 : 2;
168
+ }
169
+ /** Commander's own test for "this token is a flag, not a value". */
170
+ function looksLikeOption(token) {
171
+ return (token.length > 1 &&
172
+ token[0] === "-" &&
173
+ (token[1] === "-" || Number.isNaN(Number.parseFloat(token[1]))));
174
+ }
175
+ /** Root-flag walking, where an unknown flag simply covers itself. */
176
+ function tokensConsumedBy(token, next, options) {
177
+ return ownedFlagTokens(token, next, options) ?? 1;
178
+ }
@@ -49,6 +49,7 @@ export declare function run(config: AgencyConfig, inputFile: string, outputFile?
49
49
  maxCost?: string;
50
50
  maxTime?: string;
51
51
  },
52
- /** Forwarded to the compiled entry's argv (positions 2+), which the
53
- * direct-run block maps onto main's parameters positionally. */
52
+ /** Forwarded to the compiled program's argv (positions 2+), for the program
53
+ * itself to read `std::args` is how. They are NOT mapped onto the entry
54
+ * node's parameters, which receive `undefined` on this path. */
54
55
  nodeArgs?: string[]): void;
@@ -209,8 +209,9 @@ export async function formatFile(inputFile, inPlace = false, config = {}) {
209
209
  }
210
210
  }
211
211
  export function run(config, inputFile, outputFile, resumeFile, runPolicy, budget,
212
- /** Forwarded to the compiled entry's argv (positions 2+), which the
213
- * direct-run block maps onto main's parameters positionally. */
212
+ /** Forwarded to the compiled program's argv (positions 2+), for the program
213
+ * itself to read `std::args` is how. They are NOT mapped onto the entry
214
+ * node's parameters, which receive `undefined` on this path. */
214
215
  nodeArgs = []) {
215
216
  const output = compile(config, inputFile, outputFile, {
216
217
  importStrategy: new RunStrategy(),
@@ -1,3 +1,27 @@
1
+ import { SymbolTable } from "../symbolTable.js";
1
2
  import { AgencyConfig } from "../config.js";
3
+ import { AgencyProgram } from "../types.js";
4
+ import { VariableType } from "../types/typeHints.js";
5
+ type SymbolRegistry = Record<string, string>;
6
+ type DocContext = {
7
+ baseUrl?: string;
8
+ sourceRelPath?: string;
9
+ symbolRegistry: SymbolRegistry;
10
+ currentMdPath?: string;
11
+ config: AgencyConfig;
12
+ /** Built on first use, PER PAGE (each page gets a fresh DocContext). */
13
+ symbolTable?: SymbolTable;
14
+ /** When set, formatTypeLinked records every registry lookup it makes:
15
+ * name → target md path, or null for "rendered unlinked". This is the
16
+ * cache's evidence for re-checking links against next run's registry. */
17
+ linkRecorder?: Record<string, string | null>;
18
+ };
2
19
  export declare function generateDoc(config: AgencyConfig, inputPath: string, outputDir: string, ignoreDirs?: string[], baseUrlOverride?: string): void;
20
+ /** A file's pass-1 registry contributions. NOT "exported symbols": all
21
+ * function definitions (non-exported and underscore-prefixed included),
22
+ * node names, global-scope type aliases, and exported constants — the
23
+ * set link targets resolve against. Cached per page as
24
+ * `registrySymbols`, so an unchanged file costs no parse. */
25
+ export declare function extractRegistrySymbols(program: AgencyProgram): string[];
26
+ export declare function formatTypeLinked(type: VariableType | undefined | null, ctx: DocContext): string;
3
27
  export { extractSummaryOverride, firstParagraph, firstSentence, sanitizeDescription, moduleDescription, } from "../utils/moduleDoc.js";