@open-tomato/rafa 0.45.0 → 0.47.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 (144) hide show
  1. package/README.md +285 -23
  2. package/dist/PROMPT.md +18 -1
  3. package/dist/adapters/logger/settings.d.ts +132 -0
  4. package/dist/bugs/closest.d.ts +19 -0
  5. package/dist/bugs/fenced.d.ts +8 -0
  6. package/dist/bugs/places.d.ts +20 -0
  7. package/dist/bugs/record.d.ts +145 -0
  8. package/dist/bugs/title.d.ts +83 -0
  9. package/dist/bundled/agents/doc-updater.md +17 -3
  10. package/dist/bundled/agents/loop-implementer.md +14 -2
  11. package/dist/bundled/operators/skills/rafa-stretch-pit-stop/SKILL.md +10 -3
  12. package/dist/bundled/operators/skills/rafa-stretch-sweep/SKILL.md +5 -0
  13. package/dist/bundled/skills/dev-planner/SKILL.md +101 -18
  14. package/dist/cli.js +76536 -64285
  15. package/dist/config/entry.d.ts +119 -0
  16. package/dist/config/index.d.ts +41 -0
  17. package/dist/config/index.js +54 -0
  18. package/dist/config/shape.d.ts +235 -0
  19. package/dist/config/templates.d.ts +64 -0
  20. package/dist/config-registry.d.ts +136 -0
  21. package/dist/config-schema-board-project.d.ts +157 -0
  22. package/dist/config-schema-bugs.d.ts +71 -0
  23. package/dist/config-schema-checks.d.ts +114 -0
  24. package/dist/config-schema-errors.d.ts +54 -0
  25. package/dist/config-schema-features.d.ts +64 -0
  26. package/dist/config-schema-hub.d.ts +152 -0
  27. package/dist/config-schema-issues.d.ts +95 -0
  28. package/dist/config-schema-logger.d.ts +91 -0
  29. package/dist/config-schema-loop-continue.d.ts +122 -0
  30. package/dist/config-schema-loop-retries.d.ts +94 -0
  31. package/dist/config-schema-release.d.ts +306 -0
  32. package/dist/config-schema-tests.d.ts +178 -0
  33. package/dist/config-schema-triage.d.ts +142 -0
  34. package/dist/config-schema-wrap-up.d.ts +96 -0
  35. package/dist/core/command/command.d.ts +228 -0
  36. package/dist/core/command/confirm.d.ts +73 -0
  37. package/dist/core/command/index.d.ts +130 -0
  38. package/dist/core/command/lazy.d.ts +54 -0
  39. package/dist/core/command/registry-types.d.ts +96 -0
  40. package/dist/core/command/running.d.ts +96 -0
  41. package/dist/core/command/shared-flags.d.ts +40 -0
  42. package/dist/core/command/spends.d.ts +39 -0
  43. package/dist/core/command/types.d.ts +92 -0
  44. package/dist/core/command/version.d.ts +4 -0
  45. package/dist/core/config/branch-template.d.ts +20 -0
  46. package/dist/core/config/config-items.d.ts +86 -0
  47. package/dist/core/config/config-load-module.d.ts +43 -0
  48. package/dist/core/config/config-load.d.ts +78 -0
  49. package/dist/core/config/config-origins.d.ts +58 -0
  50. package/dist/core/config/config-readers.d.ts +167 -0
  51. package/dist/core/config/config-schema.d.ts +212 -0
  52. package/dist/core/config/config-sections.d.ts +493 -0
  53. package/dist/core/config/config.d.ts +385 -0
  54. package/dist/core/config/core-section.d.ts +39 -0
  55. package/dist/core/config/dangerous.d.ts +58 -0
  56. package/dist/core/config/default-routing.d.ts +16 -0
  57. package/dist/core/config/index.d.ts +145 -0
  58. package/dist/core/config/merge-method.d.ts +40 -0
  59. package/dist/core/config/scope.d.ts +42 -0
  60. package/dist/core/config/section.d.ts +286 -0
  61. package/dist/core/config/sections.d.ts +53 -0
  62. package/dist/core/config/standard-schema.d.ts +27 -0
  63. package/dist/core/git/commit.d.ts +232 -0
  64. package/dist/core/git/gh-runner.d.ts +24 -0
  65. package/dist/core/git/git.d.ts +22 -0
  66. package/dist/core/git/index.d.ts +85 -0
  67. package/dist/core/loop/claude.d.ts +388 -0
  68. package/dist/core/loop/hop-record.d.ts +52 -0
  69. package/dist/core/loop/index.d.ts +179 -0
  70. package/dist/core/loop/session-env.d.ts +20 -0
  71. package/dist/core/loop/session-record-parse.d.ts +70 -0
  72. package/dist/core/loop/sessions.d.ts +420 -0
  73. package/dist/core/loop/suite-failure.d.ts +25 -0
  74. package/dist/core/output/active.d.ts +100 -0
  75. package/dist/core/output/stream.d.ts +20 -0
  76. package/dist/core/output/text.d.ts +55 -0
  77. package/dist/core/plan/block-reader.d.ts +46 -0
  78. package/dist/core/plan/blocks.d.ts +139 -0
  79. package/dist/core/plan/declaration.d.ts +366 -0
  80. package/dist/core/plan/plan-stamp.d.ts +75 -0
  81. package/dist/core/runtime/identity.d.ts +21 -0
  82. package/dist/core/runtime/index.d.ts +46 -0
  83. package/dist/effort/store/bring-forward.d.ts +131 -0
  84. package/dist/effort/store/check-rows.d.ts +31 -0
  85. package/dist/effort/store/commit-stats.d.ts +42 -0
  86. package/dist/effort/store/copy.d.ts +35 -0
  87. package/dist/effort/store/development-build.d.ts +105 -0
  88. package/dist/effort/store/effort-levels.d.ts +13 -0
  89. package/dist/effort/store/findings.d.ts +214 -0
  90. package/dist/effort/store/fix-schema.d.ts +184 -0
  91. package/dist/effort/store/index.js +10 -7
  92. package/dist/effort/store/location.d.ts +44 -0
  93. package/dist/effort/store/merge-commit-gaps.d.ts +68 -0
  94. package/dist/effort/store/merge-conflicts.d.ts +91 -0
  95. package/dist/effort/store/merge-rules.d.ts +82 -0
  96. package/dist/effort/store/merge-store.d.ts +211 -0
  97. package/dist/effort/store/merge-union.d.ts +92 -0
  98. package/dist/effort/store/migrate.d.ts +146 -0
  99. package/dist/effort/store/migrations.d.ts +92 -0
  100. package/dist/effort/store/ndjson-files.d.ts +114 -0
  101. package/dist/effort/store/origins.d.ts +116 -0
  102. package/dist/effort/store/plan-stubs.d.ts +79 -0
  103. package/dist/effort/store/rebuild-aside.d.ts +172 -0
  104. package/dist/effort/store/schema-plan.d.ts +102 -0
  105. package/dist/effort/store/session-row-types.d.ts +64 -0
  106. package/dist/effort/store/settings.d.ts +13 -0
  107. package/dist/effort/store/sqlite.d.ts +340 -0
  108. package/dist/effort/store/store-generation.d.ts +17 -0
  109. package/dist/effort/store/store-identity.d.ts +220 -0
  110. package/dist/effort/store/store-meta.d.ts +305 -0
  111. package/dist/effort/store/store-replaced.d.ts +72 -0
  112. package/dist/effort/store/types.d.ts +223 -0
  113. package/dist/errors/codes.d.ts +56 -0
  114. package/dist/errors/rafa-codes.d.ts +36 -0
  115. package/dist/{index-nv34ptht.js → index-38ktnyvz.js} +14 -9
  116. package/dist/index-3mwsr6wg.js +1070 -0
  117. package/dist/index-7dgc5g1t.js +13480 -0
  118. package/dist/index-cbqvgda6.js +766 -0
  119. package/dist/index-eay1bd2w.js +2632 -0
  120. package/dist/index-f1y86zbb.js +125 -0
  121. package/dist/index-n3e31fmw.js +1041 -0
  122. package/dist/{index-r28fzsvc.js → index-nwzx41g1.js} +351 -166
  123. package/dist/index-pzpb1rf7.js +153 -0
  124. package/dist/{index-mgh2s9bj.js → index-r5q2pdky.js} +65 -457
  125. package/dist/index-z1w83f81.js +4 -0
  126. package/dist/index.js +17592 -24119
  127. package/dist/learning/index.js +5 -6
  128. package/dist/plan/index.js +12 -11
  129. package/dist/plan-prompt.md +3 -1
  130. package/dist/ports/index.d.ts +732 -0
  131. package/dist/ports/learning.d.ts +101 -0
  132. package/dist/ports/log-level.d.ts +13 -0
  133. package/dist/ports/spec-review.d.ts +66 -0
  134. package/dist/ready-6p40c3gw.js +2007 -0
  135. package/dist/release-templates/release-bot-fragment.yml +153 -0
  136. package/dist/release-templates/release-publish.yml +110 -0
  137. package/dist/release-templates/release-settle.yml +122 -0
  138. package/dist/release-templates/release-tag.yml +102 -0
  139. package/dist/report/parse.d.ts +415 -0
  140. package/dist/schema/project-id.d.ts +79 -0
  141. package/dist/schema/tiers.d.ts +107 -0
  142. package/package.json +62 -3
  143. package/dist/index-hf2k497d.js +0 -16
  144. package/dist/index-nsr78ct2.js +0 -8219
@@ -0,0 +1,119 @@
1
+ /**
2
+ * One config entry and the list of them a config module exports:
3
+ * {@link ConfigEntry}, rafa's own deep partial of the nested file shape
4
+ * `ConfigShape` (`shape.ts`), {@link Config}, {@link defineConfig}, and
5
+ * {@link entryOf}, which nests dotted keys into an entry.
6
+ *
7
+ * ## What an entry may hold
8
+ *
9
+ * An entry holds any part of the shape, every key at every depth
10
+ * optional, and two more forms the merge reads:
11
+ *
12
+ * - `false` at an id of a keyed map (`routing`, `tiers.skills`,
13
+ * `tiers.agents`, `logger.modules`) overrides what an earlier entry
14
+ * gave that id, so `{ logger: { modules: { board: false } } }` drops
15
+ * what an earlier entry gave `board`. Where the map takes `false` as a
16
+ * value (`routing`, the `tiers` pins) the loader keeps it as one, so it
17
+ * also shadows a lower layer's row, as in a YAML file; where it does
18
+ * not (`logger.modules`) the id is removed (`config-load.ts` in
19
+ * `packages/rafa/src/core/config/`). A named key takes `false` only where its own
20
+ * value does (`loop.retries`), never to remove it.
21
+ * - `{ $replace: true, …rest }` at any mapping below the top replaces
22
+ * that mapping whole with `rest`, discarding what earlier entries put
23
+ * there. On a scalar or a list it is a type error, since a later
24
+ * entry's list replaces an earlier one whole already. Inside `rest`
25
+ * neither form is read again: `rest` is a plain deep partial.
26
+ *
27
+ * These are the rules `@open-tomato/define-config`'s `merge` reads and
28
+ * its own `ConfigEntry` types. The type is declared here rather than
29
+ * imported so the `./config` subpath's declaration names nothing outside
30
+ * rafa. Its shapes follow that package's: one mapped type over every key
31
+ * with `$replace` beside them, never the named keys intersected with a
32
+ * keyed map's index signature, which that package's notes give as
33
+ * letting a stray `true` past at a map id.
34
+ *
35
+ * ## Values
36
+ *
37
+ * {@link defineConfig} is the identity: it answers the very list it is
38
+ * given and exists for its parameter type, so an editor flags a wrong
39
+ * key or value as the file is written. {@link entryOf} builds an entry
40
+ * from dotted keys, as `index.ts`'s `defaults` is built.
41
+ */
42
+ import type { ConfigShape } from './shape.js';
43
+ /** A value an entry never descends into: a scalar, or a list, which replaces whole. */
44
+ type EntryLeaf = string | number | boolean | bigint | symbol | null | undefined | readonly unknown[];
45
+ /** True when `K` is an index signature's key, an id of a keyed map, rather than a named key. */
46
+ type IsMapId<K> = string extends K ? true : number extends K ? true : false;
47
+ /** The value type of `T`'s string index signature, or `never` when it has none. */
48
+ type MapValue<T> = string extends keyof T ? T extends {
49
+ readonly [id: string]: infer V;
50
+ } ? V : never : never;
51
+ /** Every key of `T`, optional, its index signature included: the skeleton the shapes below map over. */
52
+ type Keys<T> = {
53
+ [K in keyof T]?: 0;
54
+ };
55
+ /** `T` with every key at every depth optional, leaves whole: what `rest` of a `$replace` holds. */
56
+ type PartialOf<T> = T extends EntryLeaf ? T : T extends object ? {
57
+ [K in keyof T]?: PartialOf<T[K]>;
58
+ } : T;
59
+ /** Maps skeleton `S` to a replacing mapping: `$replace` itself, then a deep partial of each key. */
60
+ type ReplaceShape<S, T> = {
61
+ [K in keyof S]: K extends '$replace' ? true : IsMapId<K> extends true ? PartialOf<MapValue<T>> | true | undefined : PartialOf<T[K & keyof T]>;
62
+ };
63
+ /**
64
+ * `{ $replace: true, …rest }` standing in for a mapping of type `T`;
65
+ * `never` for a leaf, so a `$replace` on a scalar or a list is refused.
66
+ * Over a keyed map the index signature admits `true` beside each id's
67
+ * value, since `$replace` is checked against it too.
68
+ */
69
+ type Replace<T> = T extends EntryLeaf ? never : T extends object ? ReplaceShape<{
70
+ $replace: 0;
71
+ } & Keys<T>, T> : never;
72
+ /** What an entry may set at key `K` of a mapping of type `T`. */
73
+ type EntryAt<T, K> = IsMapId<K> extends true ? EntryOf<MapValue<T>> | Replace<MapValue<T>> | false | undefined : EntryOf<T[K & keyof T]> | Replace<T[K & keyof T]>;
74
+ /** Maps skeleton `S`, with its modifiers, to the values an entry sets. */
75
+ type EntryShape<S, T> = {
76
+ [K in keyof S]: EntryAt<T, K>;
77
+ };
78
+ /**
79
+ * An entry for a value of type `T`: a leaf whole, a mapping key by key
80
+ * with `false` at a map id and `$replace` below it; see the module note.
81
+ *
82
+ * @typeParam T - The shape, or any part of it.
83
+ */
84
+ export type EntryOf<T> = T extends EntryLeaf ? T : T extends object ? EntryShape<Keys<T>, T> : T;
85
+ /** One config entry: a deep partial of {@link ConfigShape}; see the module note. */
86
+ export type ConfigEntry = EntryOf<ConfigShape>;
87
+ /** A config module's default export: its entries, applied in order over rafa's defaults. */
88
+ export type Config = readonly ConfigEntry[];
89
+ /**
90
+ * Declares a config's entries. At run time the identity: it answers the
91
+ * very list it is given, unchanged.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * export default defineConfig([{ naming: { branch: 'work/{stub}' } }]);
96
+ * ```
97
+ *
98
+ * @param entries - The entries, in the order they apply.
99
+ * @returns `entries`, the same list.
100
+ */
101
+ export declare function defineConfig(entries: Config): Config;
102
+ /**
103
+ * Nests dotted keys into one entry: `[['plan.inject', 'task']]` into
104
+ * `{ plan: { inject: 'task' } }`, every mapping frozen, keys in the
105
+ * order first named. The values are taken as given, already in the
106
+ * file's spelling. Throws on an empty key or segment, on a key given
107
+ * twice, and on a key that is both a value and a mapping (`a` beside
108
+ * `a.b`).
109
+ *
110
+ * The answer is typed {@link ConfigEntry} on the caller's word:
111
+ * nothing here checks a key against the shape. `index.ts`'s `defaults`
112
+ * is built from the registry's own keys, and `index.test.ts` reads each
113
+ * value back through its setting's reader.
114
+ *
115
+ * @param pairs - Each dotted key with its value.
116
+ * @returns A new frozen entry.
117
+ */
118
+ export declare function entryOf(pairs: readonly (readonly [key: string, value: unknown])[]): ConfigEntry;
119
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `./config` subpath, `@open-tomato/rafa/config`: what a
3
+ * `rafa.config.ts` or `rafa.config.mjs` imports to type its entries.
4
+ *
5
+ * - `Config`, the list of entries a config module exports, each a
6
+ * `ConfigEntry`, rafa's deep partial of the nested file shape
7
+ * `ConfigShape` (`entry.ts`, `shape.ts`).
8
+ * - `defineConfig`, the identity, typed for its parameter.
9
+ * - {@link defaults}, the one entry holding every setting's default.
10
+ * - `templates`, the config templates by name (`templates.ts`), each a
11
+ * frozen `ConfigEntry`, for a project that installs rafa to spread by
12
+ * value into its own entries, as `templates.escalation`. A YAML file
13
+ * names one with its `templates` key instead.
14
+ *
15
+ * ## The defaults entry
16
+ *
17
+ * {@link defaults} is built from the registry (`src/config-registry.ts`):
18
+ * each setting's file key, nested, holding its value from
19
+ * `CONFIG_DEFAULTS` in the file's spelling ({@link fileValueOf}). A
20
+ * setting whose default is null (`pr.base`, `hub.url`) is left out: no
21
+ * reader accepts null, and an absent key is what null stands for.
22
+ * `index.test.ts` reads every value back through its setting's reader
23
+ * to the default it came from.
24
+ *
25
+ * Importing this module imports the registry, so the sections are
26
+ * registered with core as `src/rafa.ts` and `src/index.ts` register
27
+ * them. `ConfigShape` does not lean on that import for its keys:
28
+ * `shape.ts` composes it from each section's exported interface by
29
+ * `import type`, so the declaration emitted for `shape.ts` imports every
30
+ * section's emitted `.d.ts` and `ConfigShape` names every section's keys
31
+ * in the published declarations as in a program built from source
32
+ * (`shape.test.ts` reads `ConfigShape['hub']['url']` as `string` from
33
+ * declarations emitted over this file).
34
+ */
35
+ import type { ConfigEntry } from './entry.js';
36
+ export type { Config, ConfigEntry } from './entry.js';
37
+ export type { ConfigShape } from './shape.js';
38
+ export { defineConfig } from './entry.js';
39
+ export { CONFIG_TEMPLATES as templates } from './templates.js';
40
+ /** Every setting's default, as one entry; see the module note. */
41
+ export declare const defaults: ConfigEntry;
@@ -0,0 +1,54 @@
1
+ // @bun
2
+ import {
3
+ CONFIG_DEFAULTS,
4
+ CONFIG_TEMPLATES,
5
+ SETTINGS,
6
+ SETTING_NAMES
7
+ } from "../index-n3e31fmw.js";
8
+ import"../index-pzpb1rf7.js";
9
+ import"../index-cbqvgda6.js";
10
+ import"../index-r5q2pdky.js";
11
+ import"../index-z1w83f81.js";
12
+
13
+ // src/config/entry.ts
14
+ function defineConfig(entries) {
15
+ return entries;
16
+ }
17
+ function nest(placed, above) {
18
+ const heads = [...new Set(placed.map(([[head]]) => head ?? ""))];
19
+ return Object.freeze(Object.fromEntries(heads.map((head) => {
20
+ const key = above === "" ? head : `${above}.${head}`;
21
+ const under = placed.filter(([[first]]) => first === head);
22
+ const [leaf, ...more] = under.filter(([path]) => path.length === 1);
23
+ if (leaf === undefined)
24
+ return [head, nest(under.map(([path, value]) => [path.slice(1), value]), key)];
25
+ if (more.length > 0 || under.length > 1)
26
+ throw new Error(`rafa config: ${key} is given twice, or as a value and a mapping`);
27
+ return [head, leaf[1]];
28
+ })));
29
+ }
30
+ function entryOf(pairs) {
31
+ const placed = pairs.map(([key, value]) => {
32
+ const path = key.split(".");
33
+ if (path.some((segment) => segment === ""))
34
+ throw new Error(`rafa config: ${JSON.stringify(key)} is no dotted key`);
35
+ return [path, value];
36
+ });
37
+ return nest(placed, "");
38
+ }
39
+
40
+ // src/config/index.ts
41
+ var COMMA_SEPARATED = new Set(["settingSources"]);
42
+ function fileValueOf(setting, value) {
43
+ if (value instanceof Map)
44
+ return Object.freeze(Object.fromEntries(value));
45
+ if (COMMA_SEPARATED.has(setting) && Array.isArray(value))
46
+ return value.join(",");
47
+ return value;
48
+ }
49
+ var defaults = entryOf(SETTING_NAMES.filter((setting) => CONFIG_DEFAULTS[setting] !== null).map((setting) => [SETTINGS[setting].key, fileValueOf(setting, CONFIG_DEFAULTS[setting])]));
50
+ export {
51
+ CONFIG_TEMPLATES as templates,
52
+ defineConfig,
53
+ defaults
54
+ };
@@ -0,0 +1,235 @@
1
+ /**
2
+ * The nested file shape: {@link ConfigShape}, every key a config file
3
+ * writes, nested as the file nests it (`plan: { inject: 'stage' }` for
4
+ * `plan.inject`), each leaf typed as the file spells it. It is the type a
5
+ * `rafa.config.ts` entry is a deep partial of (`entry.ts`), and the
6
+ * `./config` subpath (`index.ts`) publishes it.
7
+ *
8
+ * ## The file's spelling, not the resolved value
9
+ *
10
+ * A leaf holds what the setting's reader accepts, which is not always
11
+ * what `RafaConfig` resolves it to. A map (`routing`, `tiers.skills`,
12
+ * `tiers.agents`, `logger.modules`) is a plain object here and a
13
+ * `ReadonlyMap` there; `loop.settingSources` is the comma-separated
14
+ * string the file writes (`project,local`) and a list there; an item of
15
+ * `prerequisites.required` or `modules` names its kind by its key
16
+ * (`{ tool: 'bun' }`, `{ npm: 'rafa-board' }`) where the resolved item
17
+ * carries `kind` and `name`; and a setting whose default is null
18
+ * (`pr.base`, `hub.url`) takes no null, since no reader accepts one.
19
+ *
20
+ * ## Who declares what
21
+ *
22
+ * This module declares core's own top-level keys, the keys of
23
+ * `packages/rafa/src/core/config/core-section.ts`, and composes {@link ConfigShape}
24
+ * from them and the interface each of the thirteen section files
25
+ * (`src/config-schema-*.ts`) exports for the keys it writes: `HubShape`
26
+ * for `hub`, `ReleaseShape` for `pr` and `release`, and so on, each
27
+ * extended by {@link ConfigShape}. A namespace two packages share is a
28
+ * named interface here holding core's keys and extending the part each
29
+ * section exports as an interface of its own: {@link LoopShape} extends
30
+ * `LoopRetriesShape`, `LoopContinueShape` and `WrapUpShape`,
31
+ * {@link BoardProjectShape} extends `BoardProjectLimitsShape`, and
32
+ * {@link DangerousShape} extends `ReleaseDangerousShape`.
33
+ *
34
+ * The composition is written out, not merged into this file by a
35
+ * section's `declare module`, so the declaration emitted for this file
36
+ * imports each section's emitted declaration and a reader of the
37
+ * `./config` subpath's `.d.ts` files alone sees every key.
38
+ * `shape.test.ts` emits the declarations in memory over
39
+ * `src/config/index.ts` and reads `ConfigShape['hub']['url']` as
40
+ * `string` from them.
41
+ *
42
+ * `shape.test.ts` reads every leaf back as a setting's key and every
43
+ * setting's key as a leaf, so a key added to a section without its leaf
44
+ * here, or the other way round, fails there.
45
+ *
46
+ * Every type is `import type`, so this module loads nothing.
47
+ */
48
+ import type { BoardProjectLimitsShape } from '../config-schema-board-project.js';
49
+ import type { ChecksShape } from '../config-schema-checks.js';
50
+ import type { HubShape } from '../config-schema-hub.js';
51
+ import type { IssuesShape } from '../config-schema-issues.js';
52
+ import type { LoopContinueShape } from '../config-schema-loop-continue.js';
53
+ import type { LoopRetriesShape } from '../config-schema-loop-retries.js';
54
+ import type { ReleaseDangerousShape, ReleaseShape } from '../config-schema-release.js';
55
+ import type { TestsShape } from '../config-schema-tests.js';
56
+ import type { TriageShape } from '../config-schema-triage.js';
57
+ import type { WrapUpShape } from '../config-schema-wrap-up.js';
58
+ import type { BugsShape } from '@open-tomato/rafa/config-schema-bugs';
59
+ import type { ErrorsShape } from '@open-tomato/rafa/config-schema-errors';
60
+ import type { FeaturesShape } from '@open-tomato/rafa/config-schema-features';
61
+ import type { LoggerShape } from '@open-tomato/rafa/config-schema-logger';
62
+ import type { ModuleSourceKind, PrerequisiteKind } from '@open-tomato/rafa/core/config';
63
+ import type { BoardRelationshipMode, ClaimsAhead, ClaimsStaleAfter, ConfigVersion, DuplicatesLevel, InjectMode, LessonSwitch, OutputMode, RouteTarget, SkillResolverName, StoreBackend, SyncStrategy, TierPin, TierSwitch } from '@open-tomato/rafa/core/config/sections';
64
+ /**
65
+ * An item keyed by its kind: one of `K` as its key, naming the item.
66
+ * `KindKeyed<'tool' | 'env'>` is `{ tool: string } | { env: string }`.
67
+ */
68
+ type KindKeyed<K extends string> = {
69
+ readonly [P in K]: {
70
+ readonly [Q in P]: string;
71
+ };
72
+ }[K];
73
+ /** One `prerequisites.required` item as a file writes it: `{ tool: 'bun', probe: 'bun --version' }`. */
74
+ export type PrerequisiteFileItem = KindKeyed<PrerequisiteKind> & {
75
+ /** The command that proves the item; left out or null to check presence alone. */
76
+ readonly probe?: string | null;
77
+ };
78
+ /** One `prerequisites.optional` item as a file writes it: a required item's keys and `reason`. */
79
+ export type OptionalPrerequisiteFileItem = PrerequisiteFileItem & {
80
+ /** Why the item helps, for the line naming it missing. */
81
+ readonly reason?: string | null;
82
+ };
83
+ /**
84
+ * One `modules` entry as a file writes it: `{ npm: 'rafa-board' }`,
85
+ * `{ path: '../board' }`, or `{ github: 'owner/repo', ref: 'v1' }`.
86
+ */
87
+ export type ModuleFileItem = KindKeyed<Exclude<ModuleSourceKind, 'github'>> | {
88
+ /** The `owner/repo` the module is cloned from. */
89
+ readonly github: string;
90
+ /** The git ref to check out; left out or null for the default branch. */
91
+ readonly ref?: string | null;
92
+ };
93
+ /**
94
+ * The `loop` namespace: core's two keys, and the keys the
95
+ * `loop-retries`, `loop-continue` and `wrap-up` sections write.
96
+ */
97
+ export interface LoopShape extends LoopRetriesShape, LoopContinueShape, WrapUpShape {
98
+ /** `loop.settingSources`: a comma-separated subset of `user`, `project`, `local`. */
99
+ readonly settingSources: string;
100
+ /** `loop.worktreeDir`: where the loop's worktrees are made. */
101
+ readonly worktreeDir: string;
102
+ }
103
+ /** The `board.project` namespace: core's two keys and the `board-project` section's limits. */
104
+ export interface BoardProjectShape extends BoardProjectLimitsShape {
105
+ /** `board.project.template`: the project board copied for a new board. */
106
+ readonly template: string;
107
+ /** `board.project.number`: the project board this repository's issues go on. */
108
+ readonly number: number;
109
+ }
110
+ /** The `board` namespace, core's, with the shared {@link BoardProjectShape} under `project`. */
111
+ export interface BoardShape {
112
+ /** `board.trustedAuthors`: the GitHub logins whose board items are read without a prompt. */
113
+ readonly trustedAuthors: readonly string[];
114
+ /** `board.relationships`: how a parent and its children are linked. */
115
+ readonly relationships: BoardRelationshipMode;
116
+ /** The `board.project` keys. */
117
+ readonly project: BoardProjectShape;
118
+ }
119
+ /**
120
+ * The `dangerous` namespace: each key a person's consent to a step rafa
121
+ * otherwise refuses. Core's two, and the one the `release` section writes.
122
+ */
123
+ export interface DangerousShape extends ReleaseDangerousShape {
124
+ /** `dangerous.acceptStaleRefs`. */
125
+ readonly acceptStaleRefs: boolean;
126
+ /** `dangerous.selfUpdateDuringLoop`. */
127
+ readonly selfUpdateDuringLoop: boolean;
128
+ }
129
+ /** The nested file shape: core's keys, and each section's; see the module note. */
130
+ export interface ConfigShape extends BugsShape, ChecksShape, ErrorsShape, FeaturesShape, HubShape, IssuesShape, LoggerShape, ReleaseShape, TestsShape, TriageShape {
131
+ /** `version`: the config format's version. */
132
+ readonly version: ConfigVersion;
133
+ /** `store`: the effort store's backend. */
134
+ readonly store: StoreBackend;
135
+ /** The `effort` keys. */
136
+ readonly effort: {
137
+ readonly busyTimeoutMs: number;
138
+ readonly sync: SyncStrategy;
139
+ };
140
+ /** The `plan` keys. */
141
+ readonly plan: {
142
+ readonly inject: InjectMode;
143
+ readonly dir: string;
144
+ };
145
+ /** The `specs` keys. */
146
+ readonly specs: {
147
+ readonly dir: string;
148
+ };
149
+ /** The `tracker` keys. */
150
+ readonly tracker: {
151
+ readonly default: string;
152
+ readonly fallback: readonly string[];
153
+ };
154
+ /** The `learning` keys. */
155
+ readonly learning: {
156
+ readonly adapter: string;
157
+ readonly bless: {
158
+ readonly minConfidence: number;
159
+ };
160
+ readonly promote: {
161
+ readonly after: number;
162
+ readonly minConfidence: number;
163
+ };
164
+ };
165
+ /** The `output` keys. */
166
+ readonly output: {
167
+ readonly mode: OutputMode;
168
+ };
169
+ /** The `prerequisites` keys. */
170
+ readonly prerequisites: {
171
+ readonly required: readonly PrerequisiteFileItem[];
172
+ readonly optional: readonly OptionalPrerequisiteFileItem[];
173
+ };
174
+ /** The `tracking` keys. */
175
+ readonly tracking: {
176
+ readonly specs: boolean;
177
+ readonly plans: boolean;
178
+ readonly all: boolean;
179
+ };
180
+ /** `modules`: where each module is installed from. */
181
+ readonly modules: readonly ModuleFileItem[];
182
+ /** `allowList`. */
183
+ readonly allowList: readonly string[];
184
+ /** The `loop` keys. */
185
+ readonly loop: LoopShape;
186
+ /** The `board` keys. */
187
+ readonly board: BoardShape;
188
+ /** The `roadmap` keys. */
189
+ readonly roadmap: {
190
+ readonly issue: number;
191
+ };
192
+ /** The `claims` keys. */
193
+ readonly claims: {
194
+ readonly staleAfter: ClaimsStaleAfter;
195
+ readonly ahead: ClaimsAhead;
196
+ };
197
+ /** The `cleanup` keys. */
198
+ readonly cleanup: {
199
+ readonly staleDays: number;
200
+ readonly worktreeIdleDays: number;
201
+ readonly keep: readonly string[];
202
+ };
203
+ /** The `dangerous` keys. */
204
+ readonly dangerous: DangerousShape;
205
+ /** The `status` keys. */
206
+ readonly status: {
207
+ readonly notice: boolean;
208
+ };
209
+ /** The `tiers` keys, each map a name to `false` or a tier. */
210
+ readonly tiers: {
211
+ readonly rafa: TierSwitch;
212
+ readonly skills: Readonly<Record<string, TierPin>>;
213
+ readonly agents: Readonly<Record<string, TierPin>>;
214
+ };
215
+ /** `routing`: a task shape to an agent, or `false`. */
216
+ readonly routing: Readonly<Record<string, RouteTarget>>;
217
+ /** The `task` keys. */
218
+ readonly task: {
219
+ readonly skills: SkillResolverName;
220
+ readonly lessons: LessonSwitch;
221
+ };
222
+ /** The `merge` keys. */
223
+ readonly merge: {
224
+ /** `merge.duplicates`: how two entries of one file setting one key are reported. */
225
+ readonly duplicates: DuplicatesLevel;
226
+ };
227
+ /** The `naming` keys. */
228
+ readonly naming: {
229
+ /** `naming.branch`: the template the branch `loop start` creates is named from, holding `{stub}` once. */
230
+ readonly branch: string;
231
+ };
232
+ /** `templates`: the config templates this file adopts, by name. */
233
+ readonly templates: readonly string[];
234
+ }
235
+ export {};
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The config templates: {@link CONFIG_TEMPLATES}, each a named
3
+ * `ConfigEntry` a file adopts with its `templates` key, {@link TEMPLATE_NAMES}
4
+ * and {@link templateEntry}, the lookup by name.
5
+ *
6
+ * ## The one template
7
+ *
8
+ * `escalation` holds the values a project that runs its tests in rings
9
+ * writes: the five files whose change runs the full suite
10
+ * (`tests.fullSuiteTriggers`), the four spellings of an integration test
11
+ * (`tests.integration`), the one of a contract test (`tests.contract`),
12
+ * and three check points, `checks.task: [affected]`,
13
+ * `checks.stage: [related, integration]` and `checks.loop: [full]`. The
14
+ * other four check points it leaves unnamed, so they keep their empty
15
+ * default.
16
+ *
17
+ * Values are spelled as a file writes them, so `templates.test.ts` reads
18
+ * each back through its setting's reader to the value written here.
19
+ *
20
+ * ## How core reaches it
21
+ *
22
+ * Core imports nothing from this module: `registerCoreConfigSections`
23
+ * in `src/config-registry.ts` sets {@link templateEntry} as core's template
24
+ * hook (`setConfigTemplateHook` in `packages/rafa/src/core/config/section.ts`),
25
+ * and the loader calls the active hook by name. A project that installs
26
+ * rafa can also take the map by value as `templates` from
27
+ * `@open-tomato/rafa/config` and spread an entry into its own
28
+ * `rafa.config.ts`.
29
+ *
30
+ * {@link templateEntry} carries {@link TEMPLATE_NAMES} as its `names`, so
31
+ * the loader can list them when a file names a template none holds.
32
+ *
33
+ * Every mapping and list is frozen, and a name is looked up with
34
+ * `Object.hasOwn`, so `constructor` or `__proto__` answers null rather
35
+ * than something off `Object.prototype`.
36
+ */
37
+ import type { ConfigEntry } from './entry.js';
38
+ /** The name of a config template: one of {@link TEMPLATE_NAMES}. */
39
+ export type TemplateName = 'escalation';
40
+ /** Every config template, by name, each a frozen `ConfigEntry`. */
41
+ export declare const CONFIG_TEMPLATES: Readonly<Record<TemplateName, ConfigEntry>>;
42
+ /** The name of every template in {@link CONFIG_TEMPLATES}, in the order it lists them. */
43
+ export declare const TEMPLATE_NAMES: readonly TemplateName[];
44
+ /** The lookup {@link templateEntry} is: a template's entry by name, and every name it knows. */
45
+ export interface TemplateLookup {
46
+ /**
47
+ * The entry a template's name stands for, or null for a name
48
+ * {@link CONFIG_TEMPLATES} does not hold.
49
+ *
50
+ * @param name - The name a file's `templates` key gives.
51
+ * @returns The template's frozen entry, or null.
52
+ */
53
+ (name: string): ConfigEntry | null;
54
+ /** {@link TEMPLATE_NAMES}, which the loader lists when it refuses a name. */
55
+ readonly names: readonly TemplateName[];
56
+ }
57
+ /**
58
+ * The entry a template's name stands for, or null for a name
59
+ * {@link CONFIG_TEMPLATES} does not hold, carrying {@link TEMPLATE_NAMES}
60
+ * as its `names`. Set as core's template hook by
61
+ * `registerCoreConfigSections`, so a file naming a template no entry
62
+ * holds is refused with the names this lookup knows.
63
+ */
64
+ export declare const templateEntry: TemplateLookup;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The registry: the fifteen sections of the config schema, handed to
3
+ * core when {@link registerCoreConfigSections} is called, and the merged schema read off
4
+ * them, {@link SETTINGS}, {@link CONFIG_DEFAULTS}, {@link SETTING_NAMES},
5
+ * {@link SETTING_BY_KEY}, {@link SECTIONS} and {@link knownKeysAbove}.
6
+ *
7
+ * Core declares the section contract (`packages/rafa/src/core/config/section.ts`) and
8
+ * names no section. This module, outside `packages/rafa/src/core/`, is the one place
9
+ * the fifteen are listed, {@link CONFIG_SECTIONS}: core's own
10
+ * (`CORE_SECTION`) and the fourteen files `config-schema-*.ts` that
11
+ * each export one, under `src/` (ten) or, for four, under `packages/rafa/src/`.
12
+ *
13
+ * Importing it registers nothing. {@link registerCoreConfigSections}
14
+ * calls `registerConfigSections` once, with that list cut into the runs
15
+ * {@link SETTINGS} holds (see the order below), so `activeSettings()`
16
+ * and `activeDefaults()` answer every setting; a registration core
17
+ * refuses throws from the call, naming what it refused. The root is
18
+ * called, never imported for its effect: under `"sideEffects": false`
19
+ * in a manifest, `bun build` drops an import kept for its effect alone.
20
+ * The root manifest declares no such field today, since bun 1.3.14's
21
+ * split build breaks under it (#1213).
22
+ * `src/rafa.ts` and `src/index.ts` call it as they load, after their
23
+ * imports, ahead of `registerCoreAdapters` and before anything that
24
+ * loads a config; core never imports this module. Until something calls
25
+ * it, `loadConfig` refuses, naming this module. `bun test` calls it once
26
+ * for the test process, from `src/tests/preload.ts`; a child process a
27
+ * test spawns runs no preload, and calls the root itself. A second call
28
+ * finds every setting registered already and registers nothing.
29
+ *
30
+ * The call also sets core's load hook (`setConfigLoadHook` in
31
+ * `packages/rafa/src/core/config/section.ts`) to {@link handConfigToLogger}, so every
32
+ * config `loadConfig` resolves hands the logger its `logger` settings
33
+ * without core importing the logger's section file. It sets core's
34
+ * template hook too (`setConfigTemplateHook`, same file) to
35
+ * `templateEntry` from `src/config/templates.ts`, so the loader reads a
36
+ * template a file names by calling the active hook, and core imports no
37
+ * template file.
38
+ *
39
+ * ## The order
40
+ *
41
+ * {@link SETTINGS} keeps the order the schema has always reported
42
+ * problems in, which is not the order of the list: core's settings are
43
+ * taken in runs, and each section's settings are spread whole between
44
+ * two of them, so `hub.url` follows `effort.sync` and the `board.project`
45
+ * limits follow `board.project.number`. The `release` section is spread
46
+ * in three parts, its `pr`, `release` and `dangerous.` keys, each where
47
+ * its keys have always stood.
48
+ *
49
+ * Core reads every setting in the order it was registered: a layer, a
50
+ * resolution, and the keys a warning about an unknown key lists. So the
51
+ * sections are registered cut into the runs {@link SETTINGS} holds them
52
+ * in (`inSettingOrder`), each cut under its section's package and a
53
+ * section's checks on its first cut, and core's registry holds every
54
+ * setting in this order. Registering the list whole would put core's
55
+ * forty-five first, and the warning recorded in
56
+ * `src/tests/fixtures/config-parity/` would list `hub` after `task`.
57
+ * `config-registry.test.ts` holds that the registry holds the same
58
+ * settings, in the same order, as the same specs, and the same defaults,
59
+ * as the same values.
60
+ *
61
+ * ## The closed set
62
+ *
63
+ * {@link SETTINGS} is a mapped record over `ConfigSetting` built from
64
+ * each section file's typed settings, so a field added to `RafaConfig`
65
+ * without a spec in some section does not compile. The indexes are all
66
+ * read off it. Keys are looked up in a `Map`, never with `in` or an
67
+ * object index: `Bun.YAML.parse` returns a key spelled `constructor` or
68
+ * `__proto__` as an ordinary own key, and an object lookup would match
69
+ * it against `Object.prototype` instead.
70
+ *
71
+ * ## Beside core
72
+ *
73
+ * This module is the one place the six names are built: the core barrel
74
+ * `packages/rafa/src/core/config/index.ts` exports none of them, and a file outside
75
+ * `packages/rafa/src/core/` imports them from here. A feature file reads
76
+ * the whole {@link SETTINGS} or {@link CONFIG_DEFAULTS} record off the
77
+ * registration instead, through core's `registeredSettings()` and
78
+ * `registeredDefaults()`, so it imports nothing of the root.
79
+ * Core reads the registered
80
+ * settings and defaults through `activeSettings()` and
81
+ * `activeDefaults()`, and the key indexes through `activeSettingByKey()`,
82
+ * `activeSectionPaths()` and `activeKnownKeysAbove()`, all in
83
+ * `packages/rafa/src/core/config/section.ts`. Those follow registration order, which
84
+ * is the order here, so they answer what {@link SETTING_BY_KEY},
85
+ * {@link SECTIONS} and {@link knownKeysAbove} answer.
86
+ * `src/index.ts` publishes this module's {@link CONFIG_DEFAULTS}.
87
+ */
88
+ import type { ConfigSection, ConfigSetting, RafaConfig, SettingSpec } from '@open-tomato/rafa/core/config';
89
+ /** The fifteen sections, core's first, in the order they are registered. */
90
+ export declare const CONFIG_SECTIONS: readonly ConfigSection[];
91
+ /**
92
+ * The hook `loadConfig` calls with every config it resolves: it hands
93
+ * the logger its `logger` settings, read through the logger section's
94
+ * `loggerSettingsOf`. Set by {@link registerCoreConfigSections}, beside
95
+ * the registration.
96
+ */
97
+ export declare function handConfigToLogger(config: Readonly<RafaConfig>): void;
98
+ /** What every setting resolves to when no layer names it. */
99
+ export declare const CONFIG_DEFAULTS: Readonly<RafaConfig>;
100
+ /**
101
+ * Every setting, by name, in the order problems are reported.
102
+ *
103
+ * A mapped record rather than a list so the set is closed: a field
104
+ * added to `RafaConfig` without an entry here does not compile.
105
+ */
106
+ export declare const SETTINGS: {
107
+ readonly [K in ConfigSetting]: SettingSpec<K>;
108
+ };
109
+ /** Every setting name, read off the closed record above. */
110
+ export declare const SETTING_NAMES: readonly ConfigSetting[];
111
+ /**
112
+ * Registers {@link CONFIG_SECTIONS} with core, cut into the runs
113
+ * {@link SETTINGS} holds them in, sets core's load hook to
114
+ * {@link handConfigToLogger}, and sets core's template hook to
115
+ * `templateEntry` (`src/config/templates.ts`).
116
+ *
117
+ * When core's registry holds every setting already, each as the same
118
+ * spec, it registers nothing and leaves both hooks as they are, so the
119
+ * preload and an entry may both call it in one process. Throws what
120
+ * `registerConfigSections` throws on a section core refuses, such as a
121
+ * setting another package registered first, leaving the registry and
122
+ * both hooks as they were.
123
+ */
124
+ export declare function registerCoreConfigSections(): void;
125
+ /** Setting names by the dotted key the file spells them with. */
126
+ export declare const SETTING_BY_KEY: ReadonlyMap<string, ConfigSetting>;
127
+ /** Every dotted prefix a setting sits under: the sections a file opens. */
128
+ export declare const SECTIONS: ReadonlySet<string>;
129
+ /**
130
+ * The nearest path above `key` with known keys, and those keys. An
131
+ * item path such as `modules[0]` looks up `modules[]`.
132
+ *
133
+ * @param key - A dotted key a file spelled, `modules[0].kind` included.
134
+ * @returns The path the keys sit under, `''` for the top, and the keys.
135
+ */
136
+ export declare function knownKeysAbove(key: string): [string, readonly string[]];