ostia 0.4.0 → 0.6.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.
Files changed (64) hide show
  1. package/README.md +31 -30
  2. package/docs/agent-protocol.md +13 -9
  3. package/docs/cli.md +174 -126
  4. package/docs/config.md +2 -2
  5. package/docs/document-schema.md +15 -12
  6. package/docs/library.md +32 -21
  7. package/docs/preload-recipes.md +4 -4
  8. package/docs/statistics.md +14 -13
  9. package/index.d.ts +202 -60
  10. package/package.json +1 -1
  11. package/src/ab/ab-runner.ts +6 -6
  12. package/src/ab/index.ts +56 -6
  13. package/src/ab/unpaired.ts +54 -0
  14. package/src/bench/index.ts +40 -3
  15. package/src/bench/registry.ts +6 -4
  16. package/src/bench/run-tasks.ts +16 -2
  17. package/src/bench/runner.ts +10 -3
  18. package/src/bench/support.ts +8 -4
  19. package/src/bench/sweep.ts +2 -2
  20. package/src/cache/fingerprint.ts +2 -2
  21. package/src/capture/bunflags.ts +2 -2
  22. package/src/capture/cpu.ts +2 -2
  23. package/src/capture/heap-parse.ts +2 -2
  24. package/src/ci/index.ts +39 -48
  25. package/src/cli/agent.ts +54 -0
  26. package/src/cli/flags.ts +58 -9
  27. package/src/cli/help.ts +670 -245
  28. package/src/cli/main.ts +2 -3
  29. package/src/cli/output.ts +17 -14
  30. package/src/cli/run.ts +317 -92
  31. package/src/compare/index.ts +4 -4
  32. package/src/config/index.ts +14 -10
  33. package/src/config/validate.ts +4 -4
  34. package/src/glob.ts +2 -2
  35. package/src/index.ts +3 -2
  36. package/src/ir/document.ts +2 -2
  37. package/src/ir/types.ts +49 -24
  38. package/src/measure/alloc.ts +2 -2
  39. package/src/measure/cpu.ts +2 -2
  40. package/src/measure/environment.ts +11 -6
  41. package/src/measure/inprocess.ts +14 -10
  42. package/src/measure/instructions.ts +2 -2
  43. package/src/measure/noise.ts +51 -13
  44. package/src/measure/paired.ts +2 -2
  45. package/src/measure/peak.ts +4 -4
  46. package/src/measure/timing.ts +27 -6
  47. package/src/profile.ts +6 -4
  48. package/src/renderers/collapsed.ts +2 -2
  49. package/src/renderers/concise.ts +148 -0
  50. package/src/renderers/format.ts +13 -4
  51. package/src/renderers/human.ts +402 -0
  52. package/src/renderers/index.ts +9 -2
  53. package/src/renderers/markdown.ts +2 -2
  54. package/src/renderers/mermaid.ts +2 -2
  55. package/src/renderers/minimal.ts +8 -7
  56. package/src/renderers/relative.ts +2 -2
  57. package/src/renderers/select.ts +2 -2
  58. package/src/renderers/terminal.ts +1178 -383
  59. package/src/renderers/types.ts +3 -0
  60. package/src/spawn/index.ts +47 -14
  61. package/src/stats/bootstrap.ts +2 -2
  62. package/src/stats/index.ts +2 -2
  63. package/src/terminal.ts +321 -0
  64. package/src/time.ts +124 -20
package/src/cli/flags.ts CHANGED
@@ -13,9 +13,18 @@ const DOCUMENT_FORMATS = [
13
13
  "json",
14
14
  "jsonl",
15
15
  "markdown",
16
- "minimal",
16
+ "events",
17
+ "concise",
17
18
  ] as const;
18
19
 
20
+ // The names a format went by, or shares with another tool: `minimal` was
21
+ // `events`' name until 0.5.0, and svelte-typecheck and svelte-lint call
22
+ // their agent format `agent`.
23
+ export const FORMAT_ALIASES: Readonly<Record<string, string>> = {
24
+ minimal: "events",
25
+ agent: "concise",
26
+ };
27
+
19
28
  export const VIZ_FORMATS = [
20
29
  "collapsed",
21
30
  "mermaid",
@@ -63,7 +72,12 @@ type FlagSpec =
63
72
  | { kind: "int"; min?: number; allowAuto?: boolean }
64
73
  | { kind: "number"; min: number }
65
74
  | { kind: "bool"; value: boolean }
66
- | { kind: "enum"; values: readonly string[] }
75
+ | {
76
+ kind: "enum";
77
+ values: readonly string[];
78
+ aliases?: Readonly<Record<string, string>>;
79
+ }
80
+ | { kind: "const"; value: string }
67
81
  | { kind: "list" }
68
82
  | { kind: "words" }
69
83
  | { kind: "exitCodes" };
@@ -85,8 +99,15 @@ export const flag = {
85
99
  def(dest, { kind: "number", min }),
86
100
  on: (dest: string): FlagDef => def(dest, { kind: "bool", value: true }),
87
101
  off: (dest: string): FlagDef => def(dest, { kind: "bool", value: false }),
88
- oneOf: (dest: string, values: readonly string[]): FlagDef =>
89
- def(dest, { kind: "enum", values }),
102
+ oneOf: (
103
+ dest: string,
104
+ values: readonly string[],
105
+ aliases?: Readonly<Record<string, string>>,
106
+ ): FlagDef =>
107
+ def(dest, { kind: "enum", values, ...(aliases && { aliases }) }),
108
+ /** Sets `dest` to `value`; `--flag=false` leaves it, as `--json=false`. */
109
+ is: (dest: string, value: string): FlagDef =>
110
+ def(dest, { kind: "const", value }),
90
111
  /** Repeatable; each occurrence appends one value. */
91
112
  list: (dest: string): FlagDef => def(dest, { kind: "list" }),
92
113
  /** Repeatable; each occurrence is whitespace-split and appended. */
@@ -100,10 +121,13 @@ export interface OutputArgs {
100
121
  format: FormatName;
101
122
  quiet: boolean;
102
123
  help: boolean;
124
+ /** `--color` or `--no-color`; absent, color follows the terminal. */
125
+ color?: boolean;
103
126
  }
104
127
 
105
128
  export interface RunArgs extends OutputArgs {
106
129
  noiseCheck: boolean;
130
+ noiseBudgetMs?: number;
107
131
  }
108
132
 
109
133
  export const OUTPUT_DEFAULTS = {
@@ -121,10 +145,17 @@ export const HELP_FLAGS: FlagTable = {
121
145
  "-h": flag.on("help"),
122
146
  };
123
147
 
148
+ export const COLOR_FLAGS: FlagTable = {
149
+ "--color": flag.on("color"),
150
+ "--no-color": flag.off("color"),
151
+ };
152
+
124
153
  export const OUTPUT_FLAGS: FlagTable = {
125
154
  ...HELP_FLAGS,
155
+ ...COLOR_FLAGS,
126
156
  "--export-json": flag.str("exportJson"),
127
- "--format": flag.oneOf("format", DOCUMENT_FORMATS),
157
+ "--format": flag.oneOf("format", DOCUMENT_FORMATS, FORMAT_ALIASES),
158
+ "--json": flag.is("format", "json"),
128
159
  "--quiet": flag.on("quiet"),
129
160
  };
130
161
 
@@ -132,6 +163,12 @@ export const NOISE_CHECK_FLAGS: FlagTable = {
132
163
  "--no-noise-check": flag.off("noiseCheck"),
133
164
  };
134
165
 
166
+ // Apart from NOISE_CHECK_FLAGS, since `ci` takes those but its noise
167
+ // check follows the config, so it must reject this one.
168
+ const NOISE_BUDGET_FLAGS: FlagTable = {
169
+ "--noise-budget": flag.int("noiseBudgetMs"),
170
+ };
171
+
135
172
  export const CONFIG_FLAGS: FlagTable = {
136
173
  "--config": flag.str("config"),
137
174
  };
@@ -145,6 +182,7 @@ export interface ConfigArgs {
145
182
  export const RUN_FLAGS: FlagTable = {
146
183
  ...OUTPUT_FLAGS,
147
184
  ...NOISE_CHECK_FLAGS,
185
+ ...NOISE_BUDGET_FLAGS,
148
186
  "--timeout": flag.int("timeoutMs"),
149
187
  "--out-dir": flag.str("outDir"),
150
188
  };
@@ -174,8 +212,8 @@ interface ParseSpec<T> {
174
212
  /** Receives each bare word; omitted, a bare word is an unknown-flag error. */
175
213
  positional?: (arg: string, args: T) => void;
176
214
  /**
177
- * Receives everything after a `--`, verbatim; omitted, `--` is an unknown
178
- * flag.
215
+ * Receives everything after a `--`, verbatim; omitted, `--` is an
216
+ * unknown flag.
179
217
  */
180
218
  rest?: (rest: string[], args: T) => void;
181
219
  }
@@ -249,12 +287,23 @@ export function parseFlags<T extends object>(
249
287
  break;
250
288
  case "enum": {
251
289
  const raw = value();
252
- if (!spec.values.includes(raw)) {
290
+ const resolved = spec.aliases?.[raw] ?? raw;
291
+ if (!spec.values.includes(resolved)) {
253
292
  throw new CliUsageError(
254
293
  `Invalid ${name} "${raw}": expected one of: ${spec.values.join(", ")}`,
255
294
  );
256
295
  }
257
- set(dest, raw);
296
+ set(dest, resolved);
297
+ break;
298
+ }
299
+ case "const": {
300
+ const raw = eq > 0 ? arg.slice(eq + 1) : "true";
301
+ if (raw !== "true" && raw !== "false") {
302
+ throw new CliUsageError(
303
+ `Invalid ${name} "${raw}": expected true or false`,
304
+ );
305
+ }
306
+ if (raw === "true") set(dest, spec.value);
258
307
  break;
259
308
  }
260
309
  }