balladeer 1.0.15 → 1.0.17

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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/behavior-map-schema.d.ts +107 -0
  3. package/dist/behavior-map-schema.js +232 -0
  4. package/dist/cli.d.ts +6 -1
  5. package/dist/cli.js +74 -6
  6. package/dist/commands/guidance.d.ts +2 -1
  7. package/dist/commands/guidance.js +55 -0
  8. package/dist/commands/judge.d.ts +430 -0
  9. package/dist/commands/judge.js +1713 -0
  10. package/dist/commands/map.d.ts +164 -0
  11. package/dist/commands/map.js +838 -0
  12. package/dist/commands/mcp.js +2 -2
  13. package/dist/commands/offers.d.ts +265 -0
  14. package/dist/commands/offers.js +801 -0
  15. package/dist/commands/risk.d.ts +29 -0
  16. package/dist/commands/risk.js +133 -0
  17. package/dist/copy.d.ts +24 -1
  18. package/dist/copy.js +91 -0
  19. package/dist/guidance-hook.mjs +348 -94
  20. package/dist/headless-agent.d.ts +166 -0
  21. package/dist/headless-agent.js +416 -0
  22. package/dist/hook-trust.d.ts +41 -9
  23. package/dist/hook-trust.js +98 -16
  24. package/dist/judge-brief.d.ts +48 -0
  25. package/dist/judge-brief.js +102 -0
  26. package/dist/judge-hook.d.ts +258 -0
  27. package/dist/judge-hook.js +1278 -0
  28. package/dist/judge-said.d.ts +52 -0
  29. package/dist/judge-said.js +181 -0
  30. package/dist/map-brief.d.ts +16 -0
  31. package/dist/map-brief.js +41 -0
  32. package/dist/offer-brief.d.ts +95 -0
  33. package/dist/offer-brief.js +217 -0
  34. package/dist/owned-process.d.ts +65 -0
  35. package/dist/owned-process.js +146 -0
  36. package/dist/promise-meaning.d.ts +134 -0
  37. package/dist/promise-meaning.js +300 -0
  38. package/dist/relay.d.ts +71 -0
  39. package/dist/relay.js +193 -0
  40. package/dist/remove-earlier.js +4 -2
  41. package/dist/risk/contract.d.ts +145 -0
  42. package/dist/risk/contract.js +74 -0
  43. package/dist/risk/describe.d.ts +7 -0
  44. package/dist/risk/describe.js +45 -0
  45. package/dist/risk/diff.d.ts +26 -0
  46. package/dist/risk/diff.js +174 -0
  47. package/dist/risk/extract.d.ts +43 -0
  48. package/dist/risk/extract.js +336 -0
  49. package/dist/risk/git.d.ts +30 -0
  50. package/dist/risk/git.js +118 -0
  51. package/dist/risk/import-graph.d.ts +41 -0
  52. package/dist/risk/import-graph.js +487 -0
  53. package/dist/risk/index.d.ts +20 -0
  54. package/dist/risk/index.js +20 -0
  55. package/dist/risk/paths.d.ts +16 -0
  56. package/dist/risk/paths.js +73 -0
  57. package/dist/risk/pipeline.d.ts +47 -0
  58. package/dist/risk/pipeline.js +121 -0
  59. package/dist/risk/priors.d.ts +18 -0
  60. package/dist/risk/priors.js +86 -0
  61. package/dist/risk/resources.d.ts +56 -0
  62. package/dist/risk/resources.js +374 -0
  63. package/dist/risk/score.d.ts +95 -0
  64. package/dist/risk/score.js +552 -0
  65. package/dist/risk/symbols.d.ts +35 -0
  66. package/dist/risk/symbols.js +348 -0
  67. package/dist/risk/text.d.ts +43 -0
  68. package/dist/risk/text.js +277 -0
  69. package/dist/risk/validate.d.ts +19 -0
  70. package/dist/risk/validate.js +154 -0
  71. package/dist/scratch-worktree.d.ts +55 -0
  72. package/dist/scratch-worktree.js +160 -0
  73. package/dist/user-scope.d.ts +74 -3
  74. package/dist/user-scope.js +270 -9
  75. package/dist/wire.d.ts +52 -3
  76. package/dist/wire.js +2 -2
  77. package/package.json +1 -1
@@ -0,0 +1,164 @@
1
+ import { type BehaviorMap, type BehaviorMapLinkedTest } from "../behavior-map-schema.js";
2
+ import { type HeadlessAgentOptions, type HeadlessAgentResult, type HeadlessClient, type LoginCheck } from "../headless-agent.js";
3
+ import { type PromiseDocument, type PromiseReader } from "../promise-meaning.js";
4
+ /** Tools a map builder or a judge may use, and the ones refused whatever else is allowed. */
5
+ export declare const AGENT_TOOLS: readonly ["Read", "Grep", "Glob", "Bash"];
6
+ export declare const REFUSED_TOOL_RULES: readonly ["Bash(git push:*)", "Bash(gh:*)"];
7
+ export type MapArguments = Readonly<{
8
+ promiseId?: string;
9
+ all: boolean;
10
+ check: boolean;
11
+ stale: boolean;
12
+ fromFile?: string;
13
+ repo?: string;
14
+ out?: string;
15
+ client: HeadlessClient | "auto";
16
+ timeoutMs: number;
17
+ json: boolean;
18
+ repository?: string;
19
+ controlPlane: string;
20
+ /** `--link-test`: add one test to a promise's map, with no model and no server. */
21
+ linkTest?: Readonly<{
22
+ promiseId: string;
23
+ file: string;
24
+ name: string;
25
+ cases: string[];
26
+ }>;
27
+ }>;
28
+ export declare const MAP_USAGE = " npx -y balladeer@latest map <promise id> | --all | --check | --stale\n [--from-file <promise.json>] [--repo <root>] [--out <dir>]\n [--client auto|claude|codex] [--timeout <seconds>] [--json]\n npx -y balladeer@latest map --link-test <promise id> <test file>\n [--name <test name>] [--case <case id>]... [--repo <root>] [--json]\n Build a behavior map for a promise with your own coding agent: where its\n behavior starts, the code on its path, what it depends on, the tests that\n exercise it and where each failing case would show. The agent works in a\n throwaway read-only checkout, on the Claude Code or Codex login already on\n this machine, and the map is written to .continuity/behavior-maps/<id>.json\n for your team to commit. It never leaves this machine. --all maps every\n agreed promise; --check reports maps whose code or meaning has moved\n (exit 1 when any has) and --stale prints just their ids, both without a\n model. --from-file reads the promise from a file instead of Balladeer.\n --link-test adds a test in this repository to a promise's existing map,\n naming the cases it covers (passing-1, failing-2), so later judges run it\n and a change to it counts as risk to the promise. It changes nothing else\n in the map, calls no model and sends nothing anywhere.\n";
29
+ export declare function parseMapArguments(argv: readonly string[]): MapArguments;
30
+ export type MapDependencies = Readonly<{
31
+ runAgent?: (options: HeadlessAgentOptions) => Promise<HeadlessAgentResult>;
32
+ /** `null` means "no connection", without looking for one. */
33
+ reader?: PromiseReader | null;
34
+ now?: () => Date;
35
+ login?: LoginCheck;
36
+ }>;
37
+ export type BuildMapInput = Readonly<{
38
+ root: string;
39
+ promise: PromiseDocument;
40
+ client: HeadlessClient | "auto";
41
+ env: NodeJS.ProcessEnv;
42
+ timeoutMs: number;
43
+ prefer?: HeadlessClient;
44
+ login?: LoginCheck;
45
+ scratch?: string;
46
+ now?: () => Date;
47
+ runAgent?: (options: HeadlessAgentOptions) => Promise<HeadlessAgentResult>;
48
+ }>;
49
+ export type BuildMapResult = Readonly<{
50
+ ok: true;
51
+ map: BehaviorMap;
52
+ agent: HeadlessAgentResult;
53
+ dropped: string[];
54
+ /** Closed-list fields the agent filled with a word the contract does not have, read as the nearest allowed one. */
55
+ coerced: string[];
56
+ }> | Readonly<{
57
+ ok: false;
58
+ reason: string;
59
+ agent?: HeadlessAgentResult;
60
+ errors?: string[];
61
+ }>;
62
+ /**
63
+ * One promise's behavior map, built by the person's own agent from the code at
64
+ * HEAD, in a disposable checkout, and checked against the contract before it is
65
+ * returned. Nothing is written here; the caller decides where the map goes.
66
+ */
67
+ export declare function buildBehaviorMap(input: BuildMapInput): Promise<BuildMapResult>;
68
+ export declare function agentFailure(agent: HeadlessAgentResult): string;
69
+ /**
70
+ * The agent's answer made into a map: the runner's own fields filled in, paths
71
+ * made repository-relative, and every entry whose file does not exist at the
72
+ * mapped commit dropped and named, because a map pointing at nothing reads as
73
+ * stale forever. The meaning excerpt is taken from the promise itself rather
74
+ * than from the agent's copy, so a transcription slip cannot change it.
75
+ */
76
+ export declare function mapFromAgent(json: Record<string, unknown>, context: Readonly<{
77
+ promise: PromiseDocument;
78
+ sha: string;
79
+ client: HeadlessClient;
80
+ model: string;
81
+ at: string;
82
+ tree: string;
83
+ }>): {
84
+ map: unknown;
85
+ dropped: string[];
86
+ coerced: string[];
87
+ };
88
+ export type Staleness = Readonly<{
89
+ stale: boolean;
90
+ reasons: string[];
91
+ /** False when no current digest was available, so meaning drift is unanswered. */
92
+ digestChecked: boolean;
93
+ }>;
94
+ /**
95
+ * Whether a map still points at real code, answered without a model.
96
+ *
97
+ * Stale when a mapped symbol is no longer in its file (a plain search for its
98
+ * name, the way a person would grep for it), when a mapped file is gone, or,
99
+ * when the current digest is known, when the promise's meaning has moved on
100
+ * since the map was built.
101
+ */
102
+ export declare function mapStaleness(root: string, map: BehaviorMap, currentDigest?: string): Staleness;
103
+ export type StoredMap = Readonly<{
104
+ promiseId: string;
105
+ path: string;
106
+ map?: BehaviorMap;
107
+ errors?: string[];
108
+ }>;
109
+ /** Every map in a directory, read and checked; an unreadable one is listed with why. */
110
+ export declare function readBehaviorMaps(directory: string): StoredMap[];
111
+ export declare function readBehaviorMap(root: string, promiseId: string): BehaviorMap | undefined;
112
+ export type LinkTestResult = Readonly<{
113
+ ok: true;
114
+ changed: boolean;
115
+ path: string;
116
+ entry: BehaviorMapLinkedTest;
117
+ }> | Readonly<{
118
+ ok: false;
119
+ reason: string;
120
+ message: string;
121
+ }>;
122
+ /**
123
+ * The map's text with one entry added at the end of its top-level
124
+ * `linkedTests` list, and every other character left where it was, so the
125
+ * change a reviewer reads is the new entry and one comma. The entry is written
126
+ * the way this repository's formatter writes JSON: an object per line group,
127
+ * two-space indents, and the case list on one line while it fits in a
128
+ * hundred columns. Undefined when the list cannot be found.
129
+ */
130
+ export declare function insertLinkedTest(text: string, entry: BehaviorMapLinkedTest): string | undefined;
131
+ /**
132
+ * Link one test in this repository to a promise's behavior map, the way a
133
+ * person would by hand, without a model: the test is appended to the map's
134
+ * `linkedTests` unless an equal entry is already there, and nothing else in
135
+ * the map changes. The map must already exist, the file must exist inside this
136
+ * repository and not be ignored by git (a test git ignores never reaches the
137
+ * repository's suite), the list must have room, and the result must pass the
138
+ * map checker. The map is written beside itself and renamed into place.
139
+ */
140
+ export declare function linkTestToMap(input: Readonly<{
141
+ root: string;
142
+ directory: string;
143
+ cwd: string;
144
+ promiseId: string;
145
+ file: string;
146
+ name: string;
147
+ cases: readonly string[];
148
+ }>): Promise<LinkTestResult>;
149
+ export type MapOptions = Readonly<{
150
+ args: MapArguments;
151
+ cwd: string;
152
+ environment: NodeJS.ProcessEnv;
153
+ write: (text: string) => void;
154
+ deps?: MapDependencies;
155
+ }>;
156
+ /** `balladeer map`, from arguments already parsed. */
157
+ export declare function runMap(options: MapOptions): Promise<number>;
158
+ /** `balladeer map ...` from raw arguments, as `cli.ts` hands them over. */
159
+ export declare function mapCommand(argv: readonly string[], io: Readonly<{
160
+ cwd: string;
161
+ environment: NodeJS.ProcessEnv;
162
+ write: (text: string) => void;
163
+ error: (text: string) => void;
164
+ }>): Promise<number>;