@open-tomato/rafa 0.41.0 → 0.43.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.
@@ -3,7 +3,7 @@ import {
3
3
  bless,
4
4
  merge,
5
5
  promotable
6
- } from "../index-d6d0942q.js";
6
+ } from "../index-nv34ptht.js";
7
7
  import {
8
8
  CONFIDENCE_MAX,
9
9
  CONFIDENCE_MIN,
@@ -11,7 +11,7 @@ import {
11
11
  SOURCE_STEP,
12
12
  actionHash,
13
13
  triggerKey
14
- } from "../index-wp8c28fd.js";
14
+ } from "../index-hf2k497d.js";
15
15
  export {
16
16
  triggerKey,
17
17
  promotable,
@@ -12,20 +12,18 @@ import {
12
12
  renderInjection,
13
13
  runPreflight,
14
14
  runShellProbe
15
- } from "../index-zg0qsb5b.js";
15
+ } from "../index-57mmzkcn.js";
16
16
  import {
17
17
  FINDING_KINDS,
18
18
  FINDING_SIGNALS,
19
+ INJECT_MODES,
19
20
  RAFA_BLOCK_KINDS,
20
21
  REPORT_STATUSES,
21
22
  isRafaBlockKind,
22
23
  parseReport,
23
24
  readRafaBlocks
24
- } from "../index-3jpz9nr3.js";
25
- import {
26
- INJECT_MODES
27
- } from "../index-m2ahxjw8.js";
28
- import"../index-wp8c28fd.js";
25
+ } from "../index-cknayrpc.js";
26
+ import"../index-hf2k497d.js";
29
27
  export {
30
28
  runShellProbe,
31
29
  runPreflight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tomato/rafa",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Alpha. Runs a plan through the ralph loop: one Claude Code session per task, one commit per task, then a pull request and a CI wait.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -1,14 +0,0 @@
1
- // @bun
2
- import {
3
- DESCRIBE_BINARY,
4
- DESCRIBE_SCHEMA_VERSION,
5
- describeRegistry
6
- } from "./index-eyjq63mx.js";
7
- import"./index-sr3kc4mf.js";
8
- import"./index-m2ahxjw8.js";
9
- import"./index-wp8c28fd.js";
10
- export {
11
- describeRegistry,
12
- DESCRIBE_SCHEMA_VERSION,
13
- DESCRIBE_BINARY
14
- };
@@ -1,243 +0,0 @@
1
- // @bun
2
- import {
3
- commandProblem,
4
- commandSpelling,
5
- isRoutingWord,
6
- isTopLevel
7
- } from "./index-sr3kc4mf.js";
8
- import {
9
- describeValue
10
- } from "./index-m2ahxjw8.js";
11
-
12
- // src/cli/registry.ts
13
- var REFUSAL = "command registry";
14
- var HELP_WORD = "help";
15
- function mountKey(name) {
16
- return `module/${name}`;
17
- }
18
- function pluralOf(name) {
19
- return `${name}s`;
20
- }
21
- function rosterOf(commands, options = {}) {
22
- return Object.freeze(options.includeHidden === true ? [...commands] : commands.filter((command) => command.hidden !== true));
23
- }
24
- function refuseHelpWord(word, as) {
25
- if (word === HELP_WORD)
26
- throw new Error(`${REFUSAL}: "${HELP_WORD}" is read as a help request, not ${as}`);
27
- }
28
- function indexSubjects(subjects) {
29
- const names = new Map;
30
- for (const subject of subjects) {
31
- if (!isRoutingWord(subject.name) || typeof subject.summary !== "string") {
32
- throw new TypeError(`${REFUSAL}: a subject has name ${describeValue(subject.name)} and summary ${describeValue(subject.summary)},` + " expected a word with no space, no slash and no leading dash, and a string");
33
- }
34
- refuseHelpWord(subject.name, "a subject");
35
- if (names.has(subject.name))
36
- throw new Error(`${REFUSAL}: subject "${subject.name}" is declared twice`);
37
- names.set(subject.name, subject);
38
- }
39
- const words = new Map(names);
40
- for (const subject of subjects) {
41
- const plural = pluralOf(subject.name);
42
- if (names.has(plural)) {
43
- throw new Error(`${REFUSAL}: subject "${plural}" is spelled as the plural of subject "${subject.name}"`);
44
- }
45
- words.set(plural, subject);
46
- }
47
- return words;
48
- }
49
- function indexCommands(commands, subjects) {
50
- const bySubject = new Map;
51
- for (const command of commands) {
52
- const problem = commandProblem(command);
53
- if (problem !== null)
54
- throw new TypeError(`${REFUSAL}: ${problem}`);
55
- const spelling = commandSpelling(command);
56
- if (isTopLevel(command)) {
57
- refuseHelpWord(command.subject, "a command");
58
- if (subjects.has(command.subject)) {
59
- throw new Error(`${REFUSAL}: top-level command "${spelling}" is spelled as a subject`);
60
- }
61
- } else if (subjects.get(command.subject)?.name !== command.subject) {
62
- throw new Error(`${REFUSAL}: command "${spelling}" is under subject "${command.subject}", which is not declared`);
63
- }
64
- const actions = bySubject.get(command.subject) ?? new Map;
65
- if (actions.has(command.action))
66
- throw new Error(`${REFUSAL}: command "${spelling}" is declared twice`);
67
- actions.set(command.action, command);
68
- bySubject.set(command.subject, actions);
69
- }
70
- return bySubject;
71
- }
72
- function topLevelOf(find, word) {
73
- const command = find(word, word);
74
- return command !== undefined && isTopLevel(command) ? command : undefined;
75
- }
76
- function shadowOf(words, find, subjects) {
77
- const [first = "", second] = words;
78
- if (words.length === 1)
79
- return topLevelOf(find, first);
80
- const subject = subjects.get(first);
81
- if (words.length !== 2 || subject === undefined || second === undefined)
82
- return;
83
- return find(subject.name, second);
84
- }
85
- function typedAlias(alias) {
86
- return alias.trim().split(/\s+/).join(" ");
87
- }
88
- function indexAliases(commands, find, subjects) {
89
- const claimed = new Map;
90
- const aliases = [];
91
- for (const command of commands) {
92
- const spelling = commandSpelling(command);
93
- const lasting = new Set((command.lastingAliases ?? []).map(typedAlias));
94
- for (const kept of lasting) {
95
- if (!(command.aliases ?? []).map(typedAlias).includes(kept)) {
96
- throw new Error(`${REFUSAL}: command "${spelling}" has lasting alias "${kept}", which is not one of its aliases`);
97
- }
98
- }
99
- for (const alias of command.aliases ?? []) {
100
- const typed = typedAlias(alias);
101
- const words = Object.freeze(typed.split(" "));
102
- if (!words.every(isRoutingWord)) {
103
- throw new Error(`${REFUSAL}: command "${spelling}" has alias ${describeValue(alias)},` + " expected words with no slash and no leading dash");
104
- }
105
- refuseHelpWord(words[0] ?? "", "the first word of an alias");
106
- const owner = claimed.get(typed);
107
- if (owner !== undefined) {
108
- throw new Error(`${REFUSAL}: alias "${typed}" is claimed by "${commandSpelling(owner)}" and by "${spelling}"`);
109
- }
110
- const shadow = shadowOf(words, find, subjects);
111
- if (shadow !== undefined) {
112
- throw new Error(`${REFUSAL}: alias "${typed}" of "${spelling}" is spelled as command "${commandSpelling(shadow)}"`);
113
- }
114
- claimed.set(typed, command);
115
- aliases.push(Object.freeze({ words, command, lasting: lasting.has(typed) }));
116
- }
117
- }
118
- return Object.freeze(aliases.sort((a, b) => b.words.length - a.words.length));
119
- }
120
- function checkMount(mount, held) {
121
- if (typeof mount.name !== "string" || !/^[^\s-]\S*$/.test(mount.name)) {
122
- throw new TypeError(`${REFUSAL}: a module is named ${describeValue(mount.name)}, expected a word with no leading dash`);
123
- }
124
- const label = `module "${mount.name}"`;
125
- if (held.some((other) => other.name === mount.name))
126
- throw new Error(`${REFUSAL}: ${label} is mounted twice`);
127
- if (!Array.isArray(mount.commands)) {
128
- throw new TypeError(`${REFUSAL}: ${label} has commands ${describeValue(mount.commands)}, expected a list`);
129
- }
130
- const actions = new Set;
131
- for (const command of mount.commands) {
132
- const problem = commandProblem(command);
133
- if (problem !== null)
134
- throw new TypeError(`${REFUSAL}: ${label}: ${problem}`);
135
- if (command.exec === true) {
136
- throw new Error(`${REFUSAL}: ${label}: action "${command.action}" declares exec, and a mounted action delegates to nothing`);
137
- }
138
- if (actions.has(command.action))
139
- throw new Error(`${REFUSAL}: ${label}: action "${command.action}" is declared twice`);
140
- actions.add(command.action);
141
- }
142
- }
143
- function build(subjectList, commands, mounts) {
144
- const subjects = indexSubjects(subjectList);
145
- const bySubject = indexCommands(commands, subjects);
146
- mounts.forEach((mount, index) => {
147
- checkMount(mount, mounts.slice(0, index));
148
- });
149
- const mountsByName = new Map(mounts.map((mount) => [mount.name, mount]));
150
- const mounted = new Map(mounts.map((mount) => [
151
- mountKey(mount.name),
152
- new Map(mount.commands.map((command) => [command.action, command]))
153
- ]));
154
- const find = (subject, action) => (bySubject.get(subject) ?? mounted.get(subject))?.get(action);
155
- const aliases = indexAliases(commands, find, subjects);
156
- const registry = {
157
- subjects: () => subjectList,
158
- subjectOf: (word) => subjects.get(word),
159
- commands: (options) => rosterOf(commands, options),
160
- actionsOf: (subject, options) => {
161
- const mountedActions = mounted.get(subject);
162
- if (mountedActions !== undefined)
163
- return rosterOf([...mountedActions.values()], options);
164
- const actions = [...bySubject.get(subject)?.values() ?? []].filter((command) => !isTopLevel(command));
165
- return rosterOf(actions, options);
166
- },
167
- find,
168
- topLevel: (word) => topLevelOf(find, word),
169
- aliases: () => aliases,
170
- mounts: () => mounts,
171
- mountOf: (name) => mountsByName.get(name),
172
- mount: (mount) => {
173
- checkMount(mount, mounts);
174
- return build(subjectList, commands, Object.freeze([
175
- ...mounts,
176
- Object.freeze({ name: mount.name, entry: mount.entry, commands: Object.freeze([...mount.commands]) })
177
- ]));
178
- }
179
- };
180
- return Object.freeze(registry);
181
- }
182
- function createCommandRegistry(input) {
183
- return build(Object.freeze([...input.subjects]), Object.freeze([...input.commands]), Object.freeze([]));
184
- }
185
-
186
- // src/cli/describe.ts
187
- var DESCRIBE_SCHEMA_VERSION = 2;
188
- var DESCRIBE_BINARY = "rafa";
189
- function describeArg(arg) {
190
- return {
191
- name: arg.name,
192
- description: arg.description,
193
- type: arg.type,
194
- required: arg.required === true,
195
- default: arg.default ?? null
196
- };
197
- }
198
- function describeFlag(flag) {
199
- return { ...describeArg(flag), aliases: [...flag.aliases ?? []] };
200
- }
201
- function typedAlias2(alias) {
202
- return alias.trim().split(/\s+/).join(" ");
203
- }
204
- function describeCommand(command, name, module) {
205
- const { deprecated, spends } = command;
206
- return {
207
- name,
208
- summary: command.summary,
209
- description: command.description,
210
- args: command.args.map(describeArg),
211
- flags: command.flags.map(describeFlag),
212
- examples: command.examples.map(({ cmd, note }) => ({ cmd, note })),
213
- outputs: [...command.outputs],
214
- aliases: module === null ? (command.aliases ?? []).map(typedAlias2) : [],
215
- deprecated: deprecated === undefined ? null : { since: deprecated.since, use: deprecated.use },
216
- module,
217
- spends: spends === undefined ? null : { ...spends }
218
- };
219
- }
220
- function mountedThrough(exec, registry) {
221
- return registry.mounts().flatMap((mount) => registry.actionsOf(mountKey(mount.name)).map((command) => describeCommand(command, `${exec.action} ${mount.name} ${command.action}`, mount.name)));
222
- }
223
- function describeRoster(commands, registry) {
224
- return [
225
- ...commands.map((command) => describeCommand(command, command.action, null)),
226
- ...commands.filter((command) => command.exec === true).flatMap((exec) => mountedThrough(exec, registry))
227
- ];
228
- }
229
- function describeRegistry(registry, version) {
230
- return {
231
- schemaVersion: DESCRIBE_SCHEMA_VERSION,
232
- binary: DESCRIBE_BINARY,
233
- version,
234
- subjects: registry.subjects().map((subject) => ({
235
- name: subject.name,
236
- summary: subject.summary,
237
- actions: describeRoster(registry.actionsOf(subject.name), registry)
238
- })),
239
- commands: describeRoster(registry.commands().filter(isTopLevel), registry)
240
- };
241
- }
242
-
243
- export { mountKey, pluralOf, createCommandRegistry, DESCRIBE_SCHEMA_VERSION, DESCRIBE_BINARY, describeRegistry };