@open-tomato/rafa 0.19.0 → 0.20.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.
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  activeOutput,
4
4
  readRafaBlocks
5
- } from "./index-pqrpcfaz.js";
5
+ } from "./index-twbp38kz.js";
6
6
  import {
7
7
  messageOf,
8
8
  parseTaskDeclaration
9
- } from "./index-cedghpva.js";
9
+ } from "./index-pmkgvtfe.js";
10
10
  // src/preflight/prerequisites-md.ts
11
11
  import { basename, dirname, join } from "path";
12
12
  var SECTION_AUTO_RE = /\[auto\]/i;
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  describeValue
4
- } from "./index-cedghpva.js";
4
+ } from "./index-pmkgvtfe.js";
5
5
 
6
6
  // src/cli/spends.ts
7
7
  var SPENDS_GLYPH = "\uD83E\uDE99";
@@ -4,10 +4,10 @@ import {
4
4
  commandSpelling,
5
5
  isRoutingWord,
6
6
  isTopLevel
7
- } from "./index-vg7ycs94.js";
7
+ } from "./index-28jzpyks.js";
8
8
  import {
9
9
  describeValue
10
- } from "./index-cedghpva.js";
10
+ } from "./index-pmkgvtfe.js";
11
11
 
12
12
  // src/cli/registry.ts
13
13
  var REFUSAL = "command registry";
@@ -8,14 +8,14 @@ import {
8
8
  activeOutputMode,
9
9
  createTextOutput,
10
10
  readRafaBlocks
11
- } from "./index-pqrpcfaz.js";
11
+ } from "./index-twbp38kz.js";
12
12
  import {
13
13
  bless,
14
14
  merge
15
15
  } from "./index-d6d0942q.js";
16
16
  import {
17
17
  commandSpelling
18
- } from "./index-vg7ycs94.js";
18
+ } from "./index-28jzpyks.js";
19
19
  import {
20
20
  RAFA_INSTINCTS_PATH,
21
21
  STORE_BACKENDS,
@@ -25,7 +25,7 @@ import {
25
25
  messageOf,
26
26
  resolveInstinctScopes,
27
27
  tierExists
28
- } from "./index-cedghpva.js";
28
+ } from "./index-pmkgvtfe.js";
29
29
  import {
30
30
  actionHash,
31
31
  triggerKey
@@ -334,6 +334,27 @@ var SQLITE_MIGRATIONS = [
334
334
  `
335
335
  ALTER TABLE out_of_scope_bugs
336
336
  ADD COLUMN scope TEXT CHECK (scope IN ('machine', 'rafa'));
337
+ `,
338
+ `
339
+ ALTER TABLE dispatches
340
+ ADD COLUMN resolver TEXT CHECK (resolver IN ('planner', 'tag', 'none'));
341
+ ALTER TABLE dispatches
342
+ ADD COLUMN skills_offered TEXT CHECK (skills_offered IS NULL OR json_type(skills_offered) = 'array');
343
+ ALTER TABLE dispatches
344
+ ADD COLUMN lessons_offered TEXT CHECK (lessons_offered IS NULL OR json_type(lessons_offered) = 'array');
345
+ `,
346
+ `
347
+ CREATE TABLE skill_invocations (
348
+ seq INTEGER PRIMARY KEY,
349
+ session_id TEXT NOT NULL CHECK (session_id <> ''),
350
+ name TEXT CHECK (name <> ''),
351
+ sidechain INTEGER CHECK (sidechain IN (0, 1)),
352
+ count INTEGER CHECK (count IS NULL OR (typeof(count) = 'integer' AND count > 0)),
353
+ CHECK ((name IS NULL) = (count IS NULL) AND (name IS NULL) = (sidechain IS NULL))
354
+ );
355
+
356
+ CREATE UNIQUE INDEX skill_invocations_by_use
357
+ ON skill_invocations (session_id, ifnull(name, ''), ifnull(sidechain, -1));
337
358
  `
338
359
  ];
339
360
  var SQLITE_SCHEMA_VERSION = SQLITE_MIGRATIONS.length;
@@ -2822,4 +2843,4 @@ function selectEffortStore(repoRoot, config) {
2822
2843
  return adapter.create({ repoRoot });
2823
2844
  }
2824
2845
 
2825
- export { EFFORT_STORE_DIR, effortStorePath, EFFORT_KEY_PROJECTIONS, openNdjsonStore, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, SKILL_FILE, MARKDOWN_EXTENSION, scanLayout, declaredNameIssue, readFrontmatterDocument, readFrontmatter, renderFrontmatter, mergeFrontmatter, writeFrontmatter, normalizeRemote, gitRemoteUrl, ACTION_HEADING, CAUSE_HEADING, parseInstinct, writeInstinct, readScopes, allRecords, findRecords, instinctProject, toHeldRecords, sessionSpawnEnv, getClaudeUsagePercent, checkUsage, CLAUDE_BIN, claudeArgs, interruptClaudeSessions, runClaude, spawnClaudeCaptured, runClaudeCaptured, planFilePath, ClaudePlannerError, ISSUE_TYPES, ISSUE_PRIORITIES, ISSUE_STATES, GITHUB_LABELS, createGhRunner, typeOfLabels, moduleOfLabels, createLocalTracker, PORT_VERSIONS, createAdapterRegistry, CORE_ADAPTER_REGISTRY, selectEffortStore };
2846
+ export { EFFORT_STORE_DIR, effortStorePath, EFFORT_KEY_PROJECTIONS, openNdjsonStore, sqliteStorePath, SQLITE_MIGRATIONS, LONE_SURROGATE, migrateSchema, withSqliteStore, writeSqliteStore, openSqliteStore, SKILL_FILE, MARKDOWN_EXTENSION, scanLayout, declaredNameIssue, readFrontmatterDocument, readFrontmatter, renderFrontmatter, mergeFrontmatter, writeFrontmatter, normalizeRemote, gitRemoteUrl, ACTION_HEADING, CAUSE_HEADING, parseInstinct, writeInstinct, readScopes, allRecords, findRecords, instinctProject, toHeldRecords, sessionSpawnEnv, getClaudeUsagePercent, checkUsage, CLAUDE_BIN, claudeArgs, interruptClaudeSessions, runClaude, spawnClaudeCaptured, runClaudeCaptured, planFilePath, ClaudePlannerError, ISSUE_TYPES, ISSUE_PRIORITIES, ISSUE_STATES, GITHUB_LABELS, createGhRunner, typeOfLabels, moduleOfLabels, createLocalTracker, PORT_VERSIONS, createAdapterRegistry, CORE_ADAPTER_REGISTRY, selectEffortStore };
@@ -318,6 +318,8 @@ var CLAUDE_SETTING_SOURCES = ["user", "project", "local"];
318
318
  var PR_PROVIDERS = ["gh", "none"];
319
319
  var RELEASE_AUTO = "auto";
320
320
  var TIER_SWITCHES = ["on", "off"];
321
+ var SKILL_RESOLVERS = ["planner", "tag", "none"];
322
+ var LESSON_SWITCHES = ["on", "off"];
321
323
  function accepted(value) {
322
324
  return { value, problems: [], extras: [] };
323
325
  }
@@ -366,6 +368,8 @@ var tierPin = (raw, at) => {
366
368
  return tier === undefined ? refused(at, raw, `false or one of: ${SKILL_TIERS.join(", ")}`) : accepted(tier);
367
369
  };
368
370
  var routeTarget = (raw, at) => raw === false || typeof raw === "string" && raw.trim() !== "" ? accepted(raw) : refused(at, raw, "false or an agent name");
371
+ var skillResolverName = oneOf(SKILL_RESOLVERS);
372
+ var lessonSwitch = oneOf(LESSON_SWITCHES);
369
373
  var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9-]*(?:\[bot\])?$/;
370
374
  function isGitHubLogin(value) {
371
375
  return typeof value === "string" && GITHUB_LOGIN.test(value);
@@ -470,4 +474,4 @@ var moduleSource = (raw, at) => {
470
474
  }));
471
475
  };
472
476
 
473
- export { MERGE_METHODS, isMergeMethod, SKILL_TIERS, RAFA_INSTINCTS_PATH, BUNDLED_SKILLS_DIR, isSkillTier, realEntry, bundledBinDirectory, skillTierDirectory, resolveSkillTiers, resolveInstinctScopes, tierExists, isAgentName, BUDGET_FLAG, parseBudgetUsd, parseTaskDeclaration, stripTaskDeclaration, resolveDeclarationFlags, isMapping, describeValue, messageOf, CONFIG_VERSIONS, STORE_BACKENDS, INJECT_MODES, OUTPUT_MODES, CLAUDE_SETTING_SOURCES, PR_PROVIDERS, RELEASE_AUTO, oneOf, text, flag, mergeMethod, usdAmount, issueNumber, dayCount, confidence, recurrenceCount, releaseEnabled, tierSwitch, tierPin, routeTarget, isGitHubLogin, githubLogin, listOf, subsetOf, PREREQUISITE_KINDS, REQUIRED_ITEM_KEYS, OPTIONAL_ITEM_KEYS, requiredPrerequisite, optionalPrerequisite, MODULE_SOURCE_KINDS, MODULE_SOURCE_KEYS, moduleSource };
477
+ export { MERGE_METHODS, isMergeMethod, SKILL_TIERS, RAFA_INSTINCTS_PATH, BUNDLED_SKILLS_DIR, isSkillTier, realEntry, bundledBinDirectory, skillTierDirectory, resolveSkillTiers, resolveInstinctScopes, tierExists, isAgentName, BUDGET_FLAG, parseBudgetUsd, parseTaskDeclaration, stripTaskDeclaration, resolveDeclarationFlags, isMapping, describeValue, messageOf, CONFIG_VERSIONS, STORE_BACKENDS, INJECT_MODES, OUTPUT_MODES, CLAUDE_SETTING_SOURCES, PR_PROVIDERS, RELEASE_AUTO, SKILL_RESOLVERS, oneOf, text, flag, mergeMethod, usdAmount, issueNumber, dayCount, confidence, recurrenceCount, releaseEnabled, tierSwitch, tierPin, routeTarget, skillResolverName, lessonSwitch, isGitHubLogin, githubLogin, listOf, subsetOf, PREREQUISITE_KINDS, REQUIRED_ITEM_KEYS, OPTIONAL_ITEM_KEYS, requiredPrerequisite, optionalPrerequisite, MODULE_SOURCE_KINDS, MODULE_SOURCE_KEYS, moduleSource };
@@ -19,6 +19,7 @@ import {
19
19
  isMapping,
20
20
  isSkillTier,
21
21
  issueNumber,
22
+ lessonSwitch,
22
23
  listOf,
23
24
  mergeMethod,
24
25
  messageOf,
@@ -29,16 +30,50 @@ import {
29
30
  releaseEnabled,
30
31
  requiredPrerequisite,
31
32
  routeTarget,
33
+ skillResolverName,
32
34
  subsetOf,
33
35
  text,
34
36
  tierPin,
35
37
  tierSwitch,
36
38
  usdAmount
37
- } from "./index-cedghpva.js";
39
+ } from "./index-pmkgvtfe.js";
38
40
 
39
41
  // src/config-schema.ts
40
42
  import { join } from "path";
41
43
 
44
+ // src/config-readers.ts
45
+ function mapOf(value, expected) {
46
+ return (raw, at) => {
47
+ if (!isMapping(raw)) {
48
+ const problem = `${at.label} is ${describeValue(raw)}, expected a mapping of names to ${expected}`;
49
+ return { value: undefined, problems: [problem], extras: [] };
50
+ }
51
+ const readings = Object.entries(raw).map(([name, entry]) => [
52
+ name,
53
+ name.trim() === "" ? {
54
+ value: undefined,
55
+ problems: [`${at.label} names ${JSON.stringify(name)}, expected a non-empty name`],
56
+ extras: []
57
+ } : value(entry, { label: `${at.label}.${name}`, key: `${at.key}.${name}` })
58
+ ]);
59
+ const problems = readings.flatMap(([, reading]) => reading.problems);
60
+ const extras = readings.flatMap(([, reading]) => reading.extras);
61
+ if (problems.length > 0)
62
+ return { value: undefined, problems, extras };
63
+ const read = new Map;
64
+ for (const [name, reading] of readings) {
65
+ if (reading.value !== undefined)
66
+ read.set(name, reading.value);
67
+ }
68
+ return { value: read, problems, extras };
69
+ };
70
+ }
71
+ var directory = text("a directory path");
72
+ var trackerKind = text("a tracker kind name");
73
+ var releaseFile = text("a file path");
74
+ var tierPins = mapOf(tierPin, "false or a tier");
75
+ var routeTable = mapOf(routeTarget, "false or an agent name");
76
+
42
77
  // src/tiers/resolve.ts
43
78
  import { readFileSync } from "fs";
44
79
  var VENDORED_HEADER = /^<!-- vendored by rafa from .* on \d{4}-\d{2}-\d{2} -->$/;
@@ -205,32 +240,6 @@ var DEFAULT_ROUTING = new Map(DEFAULT_ROUTES);
205
240
 
206
241
  // src/config-schema.ts
207
242
  var CONFIG_FILE = join(".rafa", "config.yaml");
208
- function mapOf(value, expected) {
209
- return (raw, at) => {
210
- if (!isMapping(raw)) {
211
- const problem = `${at.label} is ${describeValue(raw)}, expected a mapping of names to ${expected}`;
212
- return { value: undefined, problems: [problem], extras: [] };
213
- }
214
- const readings = Object.entries(raw).map(([name, entry]) => [
215
- name,
216
- name.trim() === "" ? {
217
- value: undefined,
218
- problems: [`${at.label} names ${JSON.stringify(name)}, expected a non-empty name`],
219
- extras: []
220
- } : value(entry, { label: `${at.label}.${name}`, key: `${at.key}.${name}` })
221
- ]);
222
- const problems = readings.flatMap(([, reading]) => reading.problems);
223
- const extras = readings.flatMap(([, reading]) => reading.extras);
224
- if (problems.length > 0)
225
- return { value: undefined, problems, extras };
226
- const read = new Map;
227
- for (const [name, reading] of readings) {
228
- if (reading.value !== undefined)
229
- read.set(name, reading.value);
230
- }
231
- return { value: read, problems, extras };
232
- };
233
- }
234
243
  var CONFIG_DEFAULTS = Object.freeze({
235
244
  version: 1,
236
245
  store: "sqlite",
@@ -270,12 +279,10 @@ var CONFIG_DEFAULTS = Object.freeze({
270
279
  tiersRafa: "on",
271
280
  tiersSkills: new Map,
272
281
  tiersAgents: new Map,
273
- routing: DEFAULT_ROUTING
282
+ routing: DEFAULT_ROUTING,
283
+ taskSkills: "planner",
284
+ taskLessons: "on"
274
285
  });
275
- var directory = text("a directory path");
276
- var trackerKind = text("a tracker kind name");
277
- var releaseFile = text("a file path");
278
- var tierPins = mapOf(tierPin, "false or a tier");
279
286
  var SETTINGS = {
280
287
  version: { key: "version", read: oneOf(CONFIG_VERSIONS), cli: false },
281
288
  store: { key: "store", read: oneOf(STORE_BACKENDS), cli: true },
@@ -370,11 +377,9 @@ var SETTINGS = {
370
377
  tiersRafa: { key: "tiers.rafa", read: tierSwitch, cli: false },
371
378
  tiersSkills: { key: "tiers.skills", read: tierPins, cli: false },
372
379
  tiersAgents: { key: "tiers.agents", read: tierPins, cli: false },
373
- routing: {
374
- key: "routing",
375
- read: mapOf(routeTarget, "false or an agent name"),
376
- cli: false
377
- }
380
+ routing: { key: "routing", read: routeTable, cli: false },
381
+ taskSkills: { key: "task.skills", read: skillResolverName, cli: true },
382
+ taskLessons: { key: "task.lessons", read: lessonSwitch, cli: false }
378
383
  };
379
384
  var SETTING_NAMES = Object.keys(SETTINGS);
380
385
  var SETTING_BY_KEY = new Map(SETTING_NAMES.map((setting) => [
@@ -480,7 +485,9 @@ function readLayer(rawOf, atOf) {
480
485
  tiersRafa: read("tiersRafa"),
481
486
  tiersSkills: read("tiersSkills"),
482
487
  tiersAgents: read("tiersAgents"),
483
- routing: read("routing")
488
+ routing: read("routing"),
489
+ taskSkills: read("taskSkills"),
490
+ taskLessons: read("taskLessons")
484
491
  };
485
492
  return { layer, problems, extras };
486
493
  }