@avi2dg/subquo 0.0.0-stage → 0.1.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 (61) hide show
  1. package/.bun-version +1 -0
  2. package/.github/actions/setup/action.yml +21 -0
  3. package/.github/actions/setup/bun-without-unzip.sh +20 -0
  4. package/.github/workflows/ci.yml +177 -0
  5. package/.github/workflows/main.yml +108 -0
  6. package/.github/workflows/mutation.yml +106 -0
  7. package/.github/workflows/pr-title.yml +43 -0
  8. package/.github/workflows/release.yml +34 -0
  9. package/.jscpd.json +5 -0
  10. package/.no-mistakes.yaml +3 -0
  11. package/AGENTS.md +15 -0
  12. package/CHANGELOG.md +21 -0
  13. package/CLAUDE.md +2 -0
  14. package/LICENSE +21 -0
  15. package/README.md +79 -2
  16. package/VISION.md +39 -0
  17. package/bun.lock +909 -0
  18. package/bunfig.toml +3 -0
  19. package/checks.config.ts +7 -0
  20. package/docs/accounts.md +55 -0
  21. package/docs/design.md +122 -0
  22. package/docs/shadow-run.md +49 -0
  23. package/docs/stage-1-findings.md +65 -0
  24. package/knip.config.ts +3 -0
  25. package/oxlint.config.ts +3 -0
  26. package/package.json +47 -4
  27. package/scripts/release-assets.ts +28 -0
  28. package/src/accounts.ts +62 -0
  29. package/src/cli.ts +122 -0
  30. package/src/codex-credentials.ts +1 -0
  31. package/src/collect.ts +45 -0
  32. package/src/collectors.ts +210 -0
  33. package/src/index.ts +146 -0
  34. package/src/keychain.ts +25 -0
  35. package/src/launch.ts +21 -0
  36. package/src/pi-codex.ts +17 -0
  37. package/src/renewal.ts +158 -0
  38. package/src/storage.ts +48 -0
  39. package/src/usage.ts +400 -0
  40. package/stryker.conf.mjs +3 -0
  41. package/templates/adr.md +32 -0
  42. package/templates/agents.md +9 -0
  43. package/templates/changelog.md +39 -0
  44. package/templates/claude.md +2 -0
  45. package/templates/explanation.md +15 -0
  46. package/templates/how-to.md +33 -0
  47. package/templates/readme.md +48 -0
  48. package/templates/reference.md +15 -0
  49. package/templates/tutorial.md +31 -0
  50. package/templates/vision.md +16 -0
  51. package/tests/e2e/cli.test.ts +193 -0
  52. package/tests/e2e/npm-package.test.ts +30 -0
  53. package/tests/e2e/release-assets.test.ts +53 -0
  54. package/tests/fixtures/snapshots/fresh.json +54 -0
  55. package/tests/fixtures/snapshots/incomplete.json +66 -0
  56. package/tests/unit/collect.test.ts +51 -0
  57. package/tests/unit/collectors.test.ts +401 -0
  58. package/tests/unit/no-mistakes.test.ts +8 -0
  59. package/tests/unit/renewal.test.ts +17 -0
  60. package/tests/unit/snapshot.test.ts +169 -0
  61. package/tsconfig.json +46 -0
package/src/usage.ts ADDED
@@ -0,0 +1,400 @@
1
+ import { Option, Schema } from "effect";
2
+ import type { Reading } from "./collect";
3
+ import { parsePiCodexLogin } from "./pi-codex";
4
+ import type { CodexCredentials } from "./codex-credentials";
5
+ import { Windows, type QuotaWindow } from "./index";
6
+ const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
7
+ const decodeWindows = Schema.decodeUnknownOption(Windows);
8
+
9
+ export function parseJson(text: string): unknown {
10
+ const decoded = decodeJson(text);
11
+ return Option.isSome(decoded) ? decoded.value : undefined;
12
+ }
13
+
14
+ function isRecord(value: unknown): value is Record<string, unknown> {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+
18
+ function finitePercent(value: unknown): number | undefined {
19
+ if (typeof value !== "number" || !Number.isFinite(value)) return undefined;
20
+ if (value < 0 || value > 100) return undefined;
21
+ return value;
22
+ }
23
+
24
+ function isoOrNull(value: unknown): string | null | undefined {
25
+ if (value === undefined || value === null) return null;
26
+ if (typeof value !== "string") return undefined;
27
+ const time = Date.parse(value);
28
+ return Number.isFinite(time) ? new Date(time).toISOString() : undefined;
29
+ }
30
+
31
+ function epochOrIsoToIso(value: unknown): string | null | undefined {
32
+ if (value === undefined || value === null) return null;
33
+ if (typeof value === "string") return isoOrNull(value) ?? undefined;
34
+ if (typeof value === "number" && Number.isFinite(value)) {
35
+ const millis = value < 1000000000000 ? value * 1000 : value;
36
+ const date = new Date(millis);
37
+ return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
38
+ }
39
+ return undefined;
40
+ }
41
+
42
+ export function measuredAt(now: string, windows: readonly QuotaWindow[]): Reading {
43
+ const validated = decodeWindows(windows);
44
+ if (Option.isNone(validated)) return { code: "auth_unverified" };
45
+ return { observedAt: now, windows: validated.value };
46
+ }
47
+ function claudeWindow(used: unknown, resetsAt: unknown, id: QuotaWindow["id"], scope: QuotaWindow["scope"]): QuotaWindow | undefined {
48
+ const percent = finitePercent(used);
49
+ const reset = isoOrNull(resetsAt);
50
+ if (percent === undefined || reset === undefined) return undefined;
51
+ return { id, scope, percentLeft: 100 - percent, resetsAt: reset };
52
+ }
53
+
54
+ function claudeModelScope(name: string): Pick<QuotaWindow, "id" | "scope"> | undefined {
55
+ const families = name.toLowerCase().split(/[^a-z0-9]+/u);
56
+ const known = (["opus", "sonnet", "haiku", "fable"] as const).filter((family) => families.includes(family));
57
+ const [scope] = known;
58
+ return known.length === 1 ? { id: `${scope}-weekly`, scope } : undefined;
59
+ }
60
+
61
+ function claudeLimitIdentity(entry: Record<string, unknown>): Pick<QuotaWindow, "id" | "scope"> | "unrelated" | "unmapped" {
62
+ if (entry["kind"] === "session") return { id: "five-hour", scope: "all" };
63
+ if (entry["kind"] === "weekly_all") return { id: "weekly", scope: "all" };
64
+ if (entry["kind"] !== "weekly_scoped") return "unrelated";
65
+ const scope = entry["scope"];
66
+ if (!isRecord(scope) || !isRecord(scope["model"])) return "unmapped";
67
+ const name = scope["model"]["display_name"] ?? scope["model"]["id"];
68
+ return (typeof name === "string" ? claudeModelScope(name) : undefined) ?? "unmapped";
69
+ }
70
+
71
+ function addClaudeLegacyWindows(raw: Record<string, unknown>, windows: Map<string, QuotaWindow>): boolean {
72
+ const fields: Array<[string, QuotaWindow["id"], QuotaWindow["scope"]]> = [
73
+ ["five_hour", "five-hour", "all"],
74
+ ["seven_day", "weekly", "all"],
75
+ ["seven_day_opus", "opus-weekly", "opus"],
76
+ ["seven_day_sonnet", "sonnet-weekly", "sonnet"],
77
+ ];
78
+ for (const [field, id, scope] of fields) {
79
+ const entry = raw[field];
80
+ if (windows.has(id) || entry === undefined || entry === null) continue;
81
+ if (!isRecord(entry)) return false;
82
+ const window = claudeWindow(entry["utilization"], entry["resets_at"] ?? entry["reset_at"], id, scope);
83
+ if (!window) return false;
84
+ windows.set(id, window);
85
+ }
86
+ return true;
87
+ }
88
+
89
+ export function parseClaudeUsagePayload(raw: unknown): QuotaWindow[] | undefined {
90
+ if (!isRecord(raw)) return undefined;
91
+ const limits = raw["limits"] ?? [];
92
+ if (!Array.isArray(limits)) return undefined;
93
+ const windows = new Map<string, QuotaWindow>();
94
+ for (const entry of limits) {
95
+ if (!isRecord(entry)) return undefined;
96
+ const identity = claudeLimitIdentity(entry);
97
+ if (identity === "unrelated") continue;
98
+ if (identity === "unmapped") return undefined;
99
+ const window = claudeWindow(entry["percent"], entry["resets_at"] ?? entry["reset_at"], identity.id, identity.scope);
100
+ if (!window || windows.has(window.id)) return undefined;
101
+ windows.set(window.id, window);
102
+ }
103
+ if (!addClaudeLegacyWindows(raw, windows) || windows.size === 0) return undefined;
104
+ return [...windows.values()];
105
+ }
106
+ function relativeReset(value: unknown, now: number): string | null | undefined {
107
+ if (value === undefined || value === null) return null;
108
+ if (typeof value !== "number" || !Number.isFinite(value)) return undefined;
109
+ return new Date(now + value * 1000).toISOString();
110
+ }
111
+
112
+ function durationSeconds(raw: Record<string, unknown>): number | undefined {
113
+ const seconds = raw["limit_window_seconds"];
114
+ if (typeof seconds === "number" && Number.isFinite(seconds) && seconds >= 0 && Number.isInteger(seconds)) return seconds;
115
+ return undefined;
116
+ }
117
+
118
+ function codexId(
119
+ seconds: number | undefined,
120
+ positional: QuotaWindow["id"],
121
+ session: QuotaWindow["id"],
122
+ weekly: QuotaWindow["id"],
123
+ unfamiliar: (seconds: number) => QuotaWindow["id"],
124
+ ): QuotaWindow["id"] {
125
+ if (seconds === undefined) return positional;
126
+ if (seconds === 18_000) return session;
127
+ if (seconds === 604_800) return weekly;
128
+ return unfamiliar(seconds);
129
+ }
130
+
131
+ type CodexIdentities = {
132
+ readonly positional: QuotaWindow["id"];
133
+ readonly session: QuotaWindow["id"];
134
+ readonly weekly: QuotaWindow["id"];
135
+ readonly unfamiliar: (seconds: number) => QuotaWindow["id"];
136
+ };
137
+
138
+ function codexPairIdentities(
139
+ session: QuotaWindow["id"],
140
+ weekly: QuotaWindow["id"],
141
+ unfamiliar: (seconds: number) => QuotaWindow["id"],
142
+ ): readonly [CodexIdentities, CodexIdentities] {
143
+ return [
144
+ { positional: session, session, weekly, unfamiliar },
145
+ { positional: weekly, session, weekly, unfamiliar },
146
+ ];
147
+ }
148
+
149
+ function codexWindow(
150
+ raw: unknown,
151
+ scope: QuotaWindow["scope"],
152
+ now: number,
153
+ identities: CodexIdentities,
154
+ ): QuotaWindow | undefined {
155
+ if (!isRecord(raw)) return undefined;
156
+ const percent = finitePercent(raw["used_percent"]);
157
+ if (percent === undefined) return undefined;
158
+ const seconds = durationSeconds(raw);
159
+ const reset = epochOrIsoToIso(raw["reset_at"])
160
+ ?? relativeReset(raw["reset_after_seconds"], now);
161
+ if (reset === undefined) return undefined;
162
+ const id = codexId(seconds, identities.positional, identities.session, identities.weekly, identities.unfamiliar);
163
+ return { id, scope, percentLeft: 100 - percent, resetsAt: reset };
164
+ }
165
+
166
+ function codexPair(
167
+ container: Record<string, unknown>,
168
+ scope: QuotaWindow["scope"],
169
+ now: number,
170
+ primary: CodexIdentities,
171
+ secondary: CodexIdentities,
172
+ ): QuotaWindow[] | undefined {
173
+ const windows: QuotaWindow[] = [];
174
+ const rawPrimary = container["primary_window"];
175
+ if (rawPrimary !== undefined && rawPrimary !== null) {
176
+ const window = codexWindow(rawPrimary, scope, now, primary);
177
+ if (!window) return undefined;
178
+ windows.push(window);
179
+ }
180
+ const rawSecondary = container["secondary_window"];
181
+ if (rawSecondary !== undefined && rawSecondary !== null) {
182
+ const window = codexWindow(rawSecondary, scope, now, secondary);
183
+ if (!window) return undefined;
184
+ windows.push(window);
185
+ }
186
+ return windows;
187
+ }
188
+
189
+ function codexSlug(value: unknown): string | undefined {
190
+ if (typeof value !== "string") return undefined;
191
+ const slug = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
192
+ return slug.length > 0 ? slug.slice(0, 48) : undefined;
193
+ }
194
+
195
+ function codexNamedPair(
196
+ item: Record<string, unknown>,
197
+ slug: string,
198
+ now: number,
199
+ ): QuotaWindow[] | undefined {
200
+ const containerField = item["rate_limit"];
201
+ if (containerField === undefined || containerField === null) return [];
202
+ if (!isRecord(containerField)) return undefined;
203
+ const session = `model-${slug}-5h`;
204
+ const weekly = `model-${slug}-7d`;
205
+ const unfamiliar = (seconds: number): QuotaWindow["id"] => `model-${slug}-window-${seconds}s`;
206
+ const [primary, secondary] = codexPairIdentities(session, weekly, unfamiliar);
207
+ return codexPair(containerField, slug, now, primary, secondary);
208
+ }
209
+
210
+ function codexNamedWindows(raw: unknown, now: number): QuotaWindow[] | undefined {
211
+ if (!isRecord(raw)) return undefined;
212
+ const windows: QuotaWindow[] = [];
213
+ const additionalField = raw["additional_rate_limits"];
214
+ if (additionalField === undefined || additionalField === null) return windows;
215
+ if (!Array.isArray(additionalField)) return undefined;
216
+ for (const item of additionalField) {
217
+ if (item === null) continue;
218
+ if (!isRecord(item)) return undefined;
219
+ const slug = codexSlug(item["metered_feature"] ?? item["limit_name"]);
220
+ if (!slug) continue;
221
+ const pair = codexNamedPair(item, slug, now);
222
+ if (!pair) return undefined;
223
+ windows.push(...pair);
224
+ }
225
+ return windows;
226
+ }
227
+
228
+ export function parseCodexUsagePayload(raw: unknown, now: number): QuotaWindow[] | undefined {
229
+ if (!isRecord(raw)) return undefined;
230
+ const windows: QuotaWindow[] = [];
231
+ const rateLimitField = raw["rate_limit"];
232
+ if (rateLimitField !== undefined && rateLimitField !== null && !isRecord(rateLimitField)) return undefined;
233
+ const container = isRecord(rateLimitField) ? rateLimitField : undefined;
234
+ if (container) {
235
+ const [primary, secondary] = codexPairIdentities("five-hour", "weekly", (seconds) => `window-${seconds}s`);
236
+ const pair = codexPair(container, "all", now, primary, secondary);
237
+ if (!pair) return undefined;
238
+ windows.push(...pair);
239
+ }
240
+ const reviewField = raw["code_review_rate_limit"];
241
+ if (reviewField !== undefined && reviewField !== null && !isRecord(reviewField)) return undefined;
242
+ const review = isRecord(reviewField) ? reviewField : undefined;
243
+ if (review) {
244
+ const [primary, secondary] = codexPairIdentities("review-five-hour", "review-weekly", (seconds) => `review-window-${seconds}s`);
245
+ const pair = codexPair(review, "code-review", now, primary, secondary);
246
+ if (!pair) return undefined;
247
+ windows.push(...pair);
248
+ }
249
+ const named = codexNamedWindows(raw, now);
250
+ if (!named) return undefined;
251
+ windows.push(...named);
252
+ return windows.length > 0 ? windows : undefined;
253
+ }
254
+
255
+ function openCodeReset(raw: Record<string, unknown>, now: number): string | null | undefined {
256
+ const absolute = epochOrIsoToIso(raw["resetsAt"] ?? raw["resetAt"] ?? raw["reset_at"] ?? raw["nextResetTime"]);
257
+ if (absolute !== undefined && absolute !== null) return absolute;
258
+ const relative = raw["resetInSec"] ?? raw["reset_in_sec"];
259
+ if (relative === undefined || relative === null) return absolute ?? null;
260
+ if (typeof relative !== "number" || !Number.isFinite(relative) || relative < 0) return undefined;
261
+ return new Date(now + relative * 1000).toISOString();
262
+ }
263
+
264
+ function openCodeWindow(raw: unknown, id: QuotaWindow["id"], scope: QuotaWindow["scope"], now: number): QuotaWindow | undefined {
265
+ if (!isRecord(raw)) return undefined;
266
+ const remaining = raw["percentRemaining"] ?? raw["remainingPercent"];
267
+ const used = raw["percent"] ?? raw["percentUsed"] ?? raw["usedPercent"] ?? raw["usagePercent"];
268
+ let percentLeft: number | undefined;
269
+ if (remaining !== undefined) {
270
+ percentLeft = finitePercent(remaining);
271
+ } else if (used !== undefined) {
272
+ const usedPercent = finitePercent(used);
273
+ percentLeft = usedPercent === undefined ? undefined : 100 - usedPercent;
274
+ } else if (typeof raw["status"] === "string" && raw["status"].toLowerCase() === "rate-limited") {
275
+ percentLeft = 0;
276
+ }
277
+ if (percentLeft === undefined) return undefined;
278
+ const reset = openCodeReset(raw, now);
279
+ if (reset === undefined) return undefined;
280
+ return { id, scope, percentLeft, resetsAt: reset };
281
+ }
282
+
283
+ function openCodeDurationSeconds(raw: unknown): number | undefined {
284
+ if (!isRecord(raw)) return undefined;
285
+ const names = ["windowSeconds", "window_seconds", "cycleSeconds", "cycle_seconds", "durationSeconds", "duration_seconds", "periodSeconds", "period_seconds"];
286
+ for (const name of names) {
287
+ const value = raw[name];
288
+ if (typeof value === "number" && Number.isFinite(value) && value >= 0 && Number.isInteger(value)) return value;
289
+ }
290
+ return undefined;
291
+ }
292
+
293
+ export function parseOpenCodeUsagePayload(raw: unknown, now: number): QuotaWindow[] | undefined {
294
+ if (!isRecord(raw)) return undefined;
295
+ const usageField = raw["usage"];
296
+ if (usageField !== undefined && usageField !== null && !isRecord(usageField)) return undefined;
297
+ const nested = isRecord(usageField) ? usageField : undefined;
298
+ const bucket = (names: readonly string[]): Record<string, unknown> | null | undefined => {
299
+ for (const source of [nested, raw]) {
300
+ if (source === undefined) continue;
301
+ for (const name of names) {
302
+ const value = source[name];
303
+ if (value === undefined || value === null) continue;
304
+ if (!isRecord(value)) return null;
305
+ return value;
306
+ }
307
+ }
308
+ return undefined;
309
+ };
310
+ const rolling = bucket(["rollingUsage", "rolling"]);
311
+ if (rolling === null) return undefined;
312
+ const weekly = bucket(["weeklyUsage", "weekly"]);
313
+ if (weekly === null) return undefined;
314
+ const monthly = bucket(["monthlyUsage", "monthly"]);
315
+ if (monthly === null) return undefined;
316
+ const buckets: Array<[Record<string, unknown> | undefined, QuotaWindow["id"], QuotaWindow["scope"]]> = [
317
+ [rolling, openCodeDurationSeconds(rolling) === 18_000 ? "five-hour" : "rolling", "all"],
318
+ [weekly, "weekly", "all"],
319
+ [monthly, "monthly", "all"],
320
+ ];
321
+ const windows: QuotaWindow[] = [];
322
+ for (const [entry, id, scope] of buckets) {
323
+ if (entry === undefined) continue;
324
+ const window = openCodeWindow(entry, id, scope, now);
325
+ if (!window) return undefined;
326
+ windows.push(window);
327
+ }
328
+ return windows.length > 0 ? windows : undefined;
329
+ }
330
+ const ClaudeAccess = Schema.Struct({ accessToken: Schema.NonEmptyString, expiresAt: Schema.optionalKey(Schema.Finite) });
331
+ const earliestRefreshExpiry = Date.UTC(2020, 0, 1);
332
+ const latestDateValue = 8.64e15;
333
+ const RefreshExpiry = Schema.Struct({ refreshTokenExpiresAt: Schema.Int.check(Schema.isBetween({ maximum: latestDateValue, minimum: earliestRefreshExpiry })) });
334
+ type ClaudeAccess = typeof ClaudeAccess.Type;
335
+ export type ClaudeCredentials = ClaudeAccess & { readonly refreshExpiresAt?: number };
336
+ const decodeClaudeAccess = Schema.decodeUnknownOption(ClaudeAccess);
337
+ const decodeRefreshExpiry = Schema.decodeUnknownOption(RefreshExpiry);
338
+
339
+ function decodeJwtExp(token: string): number | undefined {
340
+ const payload = token.split(".")[1];
341
+ if (!payload || /[^A-Za-z0-9\-_]/.test(payload)) return undefined;
342
+ const normalized = payload.replace(/-/g, "+").replace(/_/g, "/");
343
+ const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=");
344
+ const decoded = parseJson(atob(padded));
345
+ if (!isRecord(decoded)) return undefined;
346
+ const exp = decoded["exp"];
347
+ if (typeof exp !== "number" || !Number.isFinite(exp)) return undefined;
348
+ return exp * 1000;
349
+ }
350
+
351
+ function claudeCredentialsFrom(value: unknown): ClaudeCredentials | undefined {
352
+ if (!isRecord(value)) return undefined;
353
+ const savedOAuth = value["claudeAiOauth"];
354
+ const oauth = isRecord(savedOAuth) ? savedOAuth : value;
355
+ const expiresAt = oauth["expiresAt"];
356
+ const access = decodeClaudeAccess({
357
+ accessToken: oauth["accessToken"] ?? oauth["access_token"],
358
+ ...(expiresAt === undefined ? {} : { expiresAt }),
359
+ });
360
+ if (Option.isNone(access)) return undefined;
361
+ const expiry = decodeRefreshExpiry(savedOAuth);
362
+ return Option.isSome(expiry)
363
+ ? { ...access.value, refreshExpiresAt: expiry.value.refreshTokenExpiresAt }
364
+ : access.value;
365
+ }
366
+
367
+ function codexCredentialsFrom(value: unknown): CodexCredentials | undefined {
368
+ if (!isRecord(value)) return undefined;
369
+ if (value["openai-codex"] !== undefined) return parsePiCodexLogin(value["openai-codex"]);
370
+ const tokens = isRecord(value["tokens"]) ? value["tokens"] : undefined;
371
+ if (!tokens) return undefined;
372
+ const token = tokens["access_token"] ?? tokens["accessToken"];
373
+ if (typeof token !== "string" || token.length === 0) return undefined;
374
+ const accountId = value["account_id"] ?? value["accountId"] ?? tokens["account_id"] ?? tokens["accountId"];
375
+ if (accountId !== undefined && (typeof accountId !== "string" || accountId.length === 0)) return undefined;
376
+ const expiresAt = decodeJwtExp(token);
377
+ if (typeof accountId === "string") {
378
+ return expiresAt === undefined ? { accessToken: token, accountId } : { accessToken: token, accountId, expiresAt };
379
+ }
380
+ return expiresAt === undefined ? { accessToken: token } : { accessToken: token, expiresAt };
381
+ }
382
+
383
+ export function parseClaudeCredentials(json: string): ClaudeCredentials | undefined {
384
+ return claudeCredentialsFrom(parseJson(json));
385
+ }
386
+
387
+ export function parseCodexCredentials(json: string): CodexCredentials | undefined {
388
+ return codexCredentialsFrom(parseJson(json));
389
+ }
390
+
391
+ export function parseOpenCodeKey(json: string): string | undefined {
392
+ const value = parseJson(json);
393
+ if (!isRecord(value)) return undefined;
394
+ const entry = value["opencode-go"];
395
+ if (!isRecord(entry)) return undefined;
396
+ const key = entry["key"] ?? entry["apiKey"] ?? entry["api_key"];
397
+ if (typeof key !== "string" || key.length === 0) return undefined;
398
+ if (/\s/u.test(key)) return undefined;
399
+ return key;
400
+ }
@@ -0,0 +1,3 @@
1
+ import preset from "@avi2dg/checks/stryker.preset.js";
2
+
3
+ export default { ...preset, mutate: ["src/**/*.{ts,tsx}", "!src/**/*.test.{ts,tsx}"] };
@@ -0,0 +1,32 @@
1
+ ---
2
+ governs: [<each path the record governs from the repository root>]
3
+ ---
4
+ # <number>. <The decision, as a sentence>
5
+
6
+ Date: <YYYY-MM-DD, the day the record was written>
7
+
8
+ ## Status
9
+
10
+ <Proposed, Accepted, Rejected, Deprecated, Superseded or Retired as its first word, then what it amends or what replaced it.>
11
+
12
+ ## Context
13
+
14
+ <What forced a decision, and what was true when it was made.>
15
+
16
+ ## <Another part of the record, such as What was considered and rejected>
17
+
18
+ <Leave this section out when the record needs no more.>
19
+
20
+ <A section like this may also follow any section below it.>
21
+
22
+ <Its text.>
23
+
24
+ ## Decision
25
+
26
+ <What was decided, stated as what now holds.>
27
+
28
+ ## Consequences
29
+
30
+ <Leave this section out when nothing follows from the decision but the decision.>
31
+
32
+ <What follows from the decision, its cost included.>
@@ -0,0 +1,9 @@
1
+ # Project agent memory
2
+
3
+ <What this repository is, in one sentence, and that README.md holds what a person reads.>
4
+
5
+ ## <A topic an agent needs>
6
+
7
+ <Leave this section out when the lead holds every constraint.>
8
+
9
+ - <A constraint an agent cannot infer from the code, and the file that holds its detail.>
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ Every release of <package>, newest first, written by the release from its conventional commits.
4
+
5
+ ## <version>
6
+
7
+ <Leave this section out when no release holds a conventional commit worth listing yet.>
8
+
9
+ Released <YYYY-MM-DD>.
10
+
11
+ ### Breaking changes
12
+
13
+ <Leave this section out when the release holds no such commit.>
14
+
15
+ - **<the commit's scope, when it has one>:** <its description>
16
+
17
+ ### Features
18
+
19
+ <Leave this section out when the release holds no such commit.>
20
+
21
+ - **<the commit's scope, when it has one>:** <its description>
22
+
23
+ ### Fixes
24
+
25
+ <Leave this section out when the release holds no such commit.>
26
+
27
+ - **<the commit's scope, when it has one>:** <its description>
28
+
29
+ ### Performance
30
+
31
+ <Leave this section out when the release holds no such commit.>
32
+
33
+ - **<the commit's scope, when it has one>:** <its description>
34
+
35
+ ### Reverts
36
+
37
+ <Leave this section out when the release holds no such commit.>
38
+
39
+ - **<the commit's scope, when it has one>:** <its description>
@@ -0,0 +1,2 @@
1
+ <!-- Points Claude at AGENTS.md via import; edit AGENTS.md, not this file. -->
2
+ @AGENTS.md
@@ -0,0 +1,15 @@
1
+ # <The idea this page explains, as a noun>
2
+
3
+ <The question this page answers, and the short answer.>
4
+
5
+ ## <One strand of the answer>
6
+
7
+ <Leave this section out when the lead holds the whole answer.>
8
+
9
+ <The reasoning, the alternatives, and why they lost.>
10
+
11
+ ## Related topics
12
+
13
+ <Leave this section out when there is no other page to send the reader to.>
14
+
15
+ - [<page title>](<path to the page>)
@@ -0,0 +1,33 @@
1
+ # <Task, verb first>
2
+
3
+ <Who does this, and when, in one or two sentences.>
4
+
5
+ ## Before you begin
6
+
7
+ <Leave this section out when the task needs nothing set up first.>
8
+
9
+ - <each prerequisite, naming the file that pins its version rather than the version>
10
+
11
+ ## <Part of the task, verb first>
12
+
13
+ <Leave this section out when the page is one task, whose steps then follow the lead.>
14
+
15
+ To <do the task>:
16
+
17
+ 1. <step>
18
+ 1. <step>
19
+
20
+ ## Troubleshooting
21
+
22
+ <Leave this section out when no reader has met a failure worth naming yet.>
23
+
24
+ ### <The symptom, or the error text>
25
+
26
+ <The cause.>
27
+ <The resolution.>
28
+
29
+ ## Related topics
30
+
31
+ <Leave this section out when there is no other page to send the reader to.>
32
+
33
+ - [<page title>](<path to the page>)
@@ -0,0 +1,48 @@
1
+ # <name>
2
+
3
+ <The concept in two to four sentences: what this is, who it is for, why you would use it.>
4
+
5
+ ## Before you begin
6
+
7
+ - <each prerequisite, naming the file that pins its version rather than the version>
8
+
9
+ ## Install
10
+
11
+ To install <name>:
12
+
13
+ 1. <step>
14
+ 1. <step>
15
+
16
+ <What you see when it worked, written only from what the source shows.>
17
+ <Leave this line out when the source shows nothing.>
18
+
19
+ ## <Everyday task, verb first, or what the reader looks up>
20
+
21
+ To <do the task>:
22
+
23
+ 1. <step>
24
+ 1. <step>
25
+
26
+ <Or, for what the reader looks up, a table or a list with no steps.>
27
+
28
+ ## Where things are
29
+
30
+ <Leave this section out when there is no path worth mapping yet.>
31
+
32
+ | Path | What it holds |
33
+ | --- | --- |
34
+
35
+ ## Troubleshooting
36
+
37
+ <Leave this section out when no reader has met a failure worth naming yet.>
38
+
39
+ ### <The symptom, or the error text>
40
+
41
+ <The cause.>
42
+ <The resolution.>
43
+
44
+ ## Related topics
45
+
46
+ <Leave this section out when there is no other page to send the reader to.>
47
+
48
+ - [<page title>](<path to the page>)
@@ -0,0 +1,15 @@
1
+ # <The thing this page describes, as a noun>
2
+
3
+ <What the thing is, in one sentence.>
4
+
5
+ ## <One part of it, as a noun>
6
+
7
+ <Leave this section out when the lead and one table describe all of it.>
8
+
9
+ <A table, a list or a short description, with no steps and no opinion.>
10
+
11
+ ## Related topics
12
+
13
+ <Leave this section out when there is no other page to send the reader to.>
14
+
15
+ - [<page title>](<path to the page>)
@@ -0,0 +1,31 @@
1
+ # Tutorial: <Verb and what the reader builds>
2
+
3
+ <What the reader builds, and what they learn on the way.>
4
+
5
+ ## Before you begin
6
+
7
+ - <each prerequisite, naming the file that pins its version rather than the version>
8
+
9
+ ## <Step, verb first>
10
+
11
+ To <do the task>:
12
+
13
+ 1. <step>
14
+ 1. <step>
15
+
16
+ <What the reader sees now.>
17
+
18
+ ## Troubleshooting
19
+
20
+ <Leave this section out when no reader has met a failure worth naming yet.>
21
+
22
+ ### <The symptom, or the error text>
23
+
24
+ <The cause.>
25
+ <The resolution.>
26
+
27
+ ## Related topics
28
+
29
+ <Leave this section out when there is no other page to send the reader to.>
30
+
31
+ - [<page title>](<path to the page>)
@@ -0,0 +1,16 @@
1
+ # Vision
2
+
3
+ <The outcome the repository exists for, in one line.>
4
+ <Who it serves, in one line.>
5
+ <The one thing it owns, in one line.>
6
+
7
+ ## <A stance it holds, one of three to six>
8
+
9
+ - <A rule naming what it allows, what it forbids and the trade it takes, in one line.>
10
+
11
+ ## Scope
12
+
13
+ - <What it refuses and which neighbour owns it, in one line.>
14
+
15
+ A change aligns when <what it deepens>.
16
+ A change should be resisted when <what it trades away>.