@oss-autopilot/core 3.34.0 → 3.35.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.
- package/dist/cli.bundle.cjs +110 -110
- package/dist/commands/ledger-backfill.js +15 -9
- package/dist/core/close-reason.d.ts +11 -0
- package/dist/core/close-reason.js +29 -1
- package/dist/core/eval-report.js +3 -1
- package/dist/core/gist-state-store.js +4 -1
- package/dist/core/state-persistence.js +6 -2
- package/dist/core/state-schema.d.ts +273 -87
- package/dist/core/state-schema.js +82 -27
- package/dist/core/state.js +1 -0
- package/package.json +1 -1
|
@@ -6,10 +6,19 @@
|
|
|
6
6
|
* re-exported through types.ts.
|
|
7
7
|
*
|
|
8
8
|
* Schemas are defined bottom-up (leaf types first, composites last).
|
|
9
|
-
* Unknown keys are stripped by default (Zod 4 behavior)
|
|
9
|
+
* Unknown keys are stripped by default (Zod 4 behavior), EXCEPT on the schemas
|
|
10
|
+
* marked `.passthrough()` (#1831): see the note above AgentStateSchema.
|
|
10
11
|
*/
|
|
11
12
|
import { z } from 'zod';
|
|
12
|
-
import { CLOSE_REASONS } from './close-reason.js';
|
|
13
|
+
import { CLOSE_REASONS, SELF_CLOSE_REASONS } from './close-reason.js';
|
|
14
|
+
/**
|
|
15
|
+
* An enum that also accepts values it does not know (#1831): a newer release
|
|
16
|
+
* may add a value, and a strict enum would make this release reject the whole
|
|
17
|
+
* state. Known values keep editor completion; read sites must handle others.
|
|
18
|
+
*/
|
|
19
|
+
function openEnum(_values) {
|
|
20
|
+
return z.custom((v) => typeof v === 'string');
|
|
21
|
+
}
|
|
13
22
|
// ── 1. Enum / union schemas ───────────────────────────────────────────
|
|
14
23
|
export const IssueStatusSchema = z.enum(['candidate', 'claimed', 'in_progress', 'pr_submitted']);
|
|
15
24
|
export const FetchedPRStatusSchema = z.enum(['needs_addressing', 'waiting_on_maintainer']);
|
|
@@ -29,7 +38,8 @@ export const RepoSignalsSchema = z.object({
|
|
|
29
38
|
isResponsive: z.boolean(),
|
|
30
39
|
hasHostileComments: z.boolean(),
|
|
31
40
|
});
|
|
32
|
-
export const RepoScoreSchema = z
|
|
41
|
+
export const RepoScoreSchema = z
|
|
42
|
+
.object({
|
|
33
43
|
repo: z.string(),
|
|
34
44
|
score: z.number(),
|
|
35
45
|
mergedPRCount: z.number(),
|
|
@@ -40,24 +50,27 @@ export const RepoScoreSchema = z.object({
|
|
|
40
50
|
signals: RepoSignalsSchema,
|
|
41
51
|
stargazersCount: z.number().optional(),
|
|
42
52
|
language: z.string().nullable().optional(),
|
|
43
|
-
})
|
|
53
|
+
})
|
|
54
|
+
.passthrough();
|
|
44
55
|
/**
|
|
45
56
|
* What the tool predicted about an issue when it was vetted (#1824). Recorded
|
|
46
57
|
* by `vet` / `vet-list` keyed by issue URL, then copied onto the outcome
|
|
47
58
|
* ledger entry of the PR that closes that issue, so outcomes can be compared
|
|
48
59
|
* against the prediction that picked them (calibration).
|
|
49
60
|
*/
|
|
50
|
-
export const PickSnapshotSchema = z
|
|
61
|
+
export const PickSnapshotSchema = z
|
|
62
|
+
.object({
|
|
51
63
|
issueUrl: z.string(),
|
|
52
64
|
/** Success-likelihood grade (1-10) from issue-grading. */
|
|
53
65
|
grade: z.number(),
|
|
54
66
|
recommendation: z.string(),
|
|
55
67
|
stargazersCount: z.number().optional(),
|
|
56
68
|
/** `list`: the curated list's `**Tier (N/10)**` score, imported by ledger-backfill. */
|
|
57
|
-
source:
|
|
69
|
+
source: openEnum(['vet', 'vet-list', 'list']),
|
|
58
70
|
/** When the vet ran. Absent for `list` picks: the list does not record vet dates reliably. */
|
|
59
71
|
capturedAt: z.string().optional(),
|
|
60
|
-
})
|
|
72
|
+
})
|
|
73
|
+
.passthrough();
|
|
61
74
|
/**
|
|
62
75
|
* Outcome-ledger fields added by #1824, shared by merged and closed entries.
|
|
63
76
|
* All optional: entries written before #1824 have none of them.
|
|
@@ -74,7 +87,8 @@ const LedgerPredictionFields = {
|
|
|
74
87
|
/** When ledger-backfill got GitHub's answer for this PR; later runs skip it. */
|
|
75
88
|
backfilledAt: z.string().optional(),
|
|
76
89
|
};
|
|
77
|
-
export const StoredMergedPRSchema = z
|
|
90
|
+
export const StoredMergedPRSchema = z
|
|
91
|
+
.object({
|
|
78
92
|
url: z.string(),
|
|
79
93
|
title: z.string(),
|
|
80
94
|
mergedAt: z.string(),
|
|
@@ -99,8 +113,10 @@ export const StoredMergedPRSchema = z.object({
|
|
|
99
113
|
/** When the host last ran LLM extraction over this PR's comment bundle (#867). */
|
|
100
114
|
learningsExtractedAt: z.string().datetime().optional(),
|
|
101
115
|
...LedgerPredictionFields,
|
|
102
|
-
})
|
|
103
|
-
|
|
116
|
+
})
|
|
117
|
+
.passthrough();
|
|
118
|
+
export const StoredClosedPRSchema = z
|
|
119
|
+
.object({
|
|
104
120
|
url: z.string(),
|
|
105
121
|
title: z.string(),
|
|
106
122
|
closedAt: z.string(),
|
|
@@ -119,8 +135,11 @@ export const StoredClosedPRSchema = z.object({
|
|
|
119
135
|
learningsExtractedAt: z.string().datetime().optional(),
|
|
120
136
|
...LedgerPredictionFields,
|
|
121
137
|
/** Why it closed unmerged (#1824), set by ledger-backfill. */
|
|
122
|
-
closeReason:
|
|
123
|
-
|
|
138
|
+
closeReason: openEnum(CLOSE_REASONS).optional(),
|
|
139
|
+
/** For `self-closed`: superseded, no traction, after feedback, or no response (#1824). */
|
|
140
|
+
selfCloseReason: openEnum(SELF_CLOSE_REASONS).optional(),
|
|
141
|
+
})
|
|
142
|
+
.passthrough();
|
|
124
143
|
export const AnalyzedIssueConversationSchema = z.object({
|
|
125
144
|
url: z.string(),
|
|
126
145
|
repo: z.string(),
|
|
@@ -222,7 +241,8 @@ export const StatusOverrideSchema = z.object({
|
|
|
222
241
|
lastActivityAt: z.string(),
|
|
223
242
|
});
|
|
224
243
|
// ── 5. Config schema ─────────────────────────────────────────────────
|
|
225
|
-
export const AgentConfigSchema = z
|
|
244
|
+
export const AgentConfigSchema = z
|
|
245
|
+
.object({
|
|
226
246
|
setupComplete: z.boolean().default(false),
|
|
227
247
|
setupCompletedAt: z.string().optional(),
|
|
228
248
|
persistence: z.enum(['local', 'gist']).default('local'),
|
|
@@ -323,7 +343,11 @@ export const AgentConfigSchema = z.object({
|
|
|
323
343
|
* local network.
|
|
324
344
|
*/
|
|
325
345
|
slmTriageHost: z.string().default(''),
|
|
326
|
-
})
|
|
346
|
+
})
|
|
347
|
+
// Passthrough (#1831): a newer release's config fields survive this
|
|
348
|
+
// version's load/save. Retired fields must be dropped explicitly instead.
|
|
349
|
+
.passthrough()
|
|
350
|
+
.transform(({ snoozedPRs: _retired, ...config }) => config);
|
|
327
351
|
// ── 6. Cache schemas ─────────────────────────────────────────────────
|
|
328
352
|
export const LocalRepoCacheSchema = z.object({
|
|
329
353
|
repos: z.record(z.string(), z.object({
|
|
@@ -450,7 +474,8 @@ export const SearchSeenEntrySchema = z.object({
|
|
|
450
474
|
* run; `overnight push-prep` (#1698) may later stage it under `prep/*` on the
|
|
451
475
|
* user's fork and fills in `pushedRef`, `pushedAt` and `compareUrl`.
|
|
452
476
|
*/
|
|
453
|
-
export const OvernightPreparedSchema = z
|
|
477
|
+
export const OvernightPreparedSchema = z
|
|
478
|
+
.object({
|
|
454
479
|
url: z.string(),
|
|
455
480
|
branch: z.string(),
|
|
456
481
|
worktree: z.string().optional(),
|
|
@@ -463,20 +488,24 @@ export const OvernightPreparedSchema = z.object({
|
|
|
463
488
|
compareUrl: z.string().optional(),
|
|
464
489
|
/** Why the last `overnight push-prep` did not push this branch; cleared once it is pushed. */
|
|
465
490
|
pushProblem: z.string().optional(),
|
|
466
|
-
})
|
|
491
|
+
})
|
|
492
|
+
.passthrough();
|
|
467
493
|
/** The latest overnight run (#1574); `startup` surfaces its freshness. */
|
|
468
494
|
/**
|
|
469
495
|
* One list issue the overnight run tried to implement (#1715). Kept across
|
|
470
496
|
* runs so a blocked issue is not retried every night; cleared when the
|
|
471
497
|
* issue leaves the list.
|
|
472
498
|
*/
|
|
473
|
-
export const OvernightImplementAttemptSchema = z
|
|
499
|
+
export const OvernightImplementAttemptSchema = z
|
|
500
|
+
.object({
|
|
474
501
|
url: z.string(),
|
|
475
502
|
attemptedAt: z.string(),
|
|
476
503
|
outcome: z.enum(['prepared', 'blocked']),
|
|
477
504
|
note: z.string().optional(),
|
|
478
|
-
})
|
|
479
|
-
|
|
505
|
+
})
|
|
506
|
+
.passthrough();
|
|
507
|
+
export const OvernightRecordSchema = z
|
|
508
|
+
.object({
|
|
480
509
|
runAt: z.string(),
|
|
481
510
|
reportPath: z.string(),
|
|
482
511
|
prepareCount: z.number().int().nonnegative(),
|
|
@@ -485,23 +514,38 @@ export const OvernightRecordSchema = z.object({
|
|
|
485
514
|
/** The one curated-list issue picked for implementation this run, if any (#1715). */
|
|
486
515
|
implementUrl: z.string().optional(),
|
|
487
516
|
implementAttempts: z.array(OvernightImplementAttemptSchema).optional(),
|
|
488
|
-
})
|
|
517
|
+
})
|
|
518
|
+
.passthrough();
|
|
489
519
|
/**
|
|
490
520
|
* Mirrors oss-scout's `searchRotation`: the broad-phase language cursor, the
|
|
491
521
|
* repo-window cursors of the capped phases, and the round-robin strategy
|
|
492
|
-
* cursor (oss-scout 1.7.0).
|
|
493
|
-
*
|
|
494
|
-
*
|
|
522
|
+
* cursor (oss-scout 1.7.0). List every cursor so it gets its default;
|
|
523
|
+
* passthrough (#1831) keeps a cursor added by a newer bundled scout instead of
|
|
524
|
+
* resetting it to 0 on this release's next save.
|
|
495
525
|
*/
|
|
496
|
-
export const SearchRotationSchema = z
|
|
526
|
+
export const SearchRotationSchema = z
|
|
527
|
+
.object({
|
|
497
528
|
languageOffset: z.number().int().nonnegative().default(0),
|
|
498
529
|
phase0Offset: z.number().int().nonnegative().default(0),
|
|
499
530
|
starredOffset: z.number().int().nonnegative().default(0),
|
|
500
531
|
maintainedOffset: z.number().int().nonnegative().default(0),
|
|
501
532
|
strategyOffset: z.number().int().nonnegative().default(0),
|
|
502
533
|
lastRotatedAt: z.string().optional(),
|
|
503
|
-
})
|
|
504
|
-
|
|
534
|
+
})
|
|
535
|
+
.passthrough();
|
|
536
|
+
/**
|
|
537
|
+
* Forward compatibility (#1831). The state Gist is shared by clients on
|
|
538
|
+
* different releases, and a strict parse let an older client drop a newer
|
|
539
|
+
* release's fields on its next save. Schemas for data that is written once and
|
|
540
|
+
* kept (root, config, repoScores, the outcome ledger and pick snapshots,
|
|
541
|
+
* lastOvernight, searchRotation) are `.passthrough()`; schemas regenerated on
|
|
542
|
+
* every run (lastDigest) or rarely extended still strip. Persisted enums that
|
|
543
|
+
* grow (closeReason, pick source) accept unknown strings via {@link openEnum}.
|
|
544
|
+
* Inferred types drop the passthrough index signature ({@link KnownKeys}) so a
|
|
545
|
+
* misspelled key still fails to compile.
|
|
546
|
+
*/
|
|
547
|
+
export const AgentStateSchema = z
|
|
548
|
+
.object({
|
|
505
549
|
version: z.literal(4),
|
|
506
550
|
gistId: z.string().optional(),
|
|
507
551
|
repoScores: z.record(z.string(), RepoScoreSchema).default({}),
|
|
@@ -566,4 +610,15 @@ export const AgentStateSchema = z.object({
|
|
|
566
610
|
* here and fed into the next scout state. Absent until the first search.
|
|
567
611
|
*/
|
|
568
612
|
searchRotation: SearchRotationSchema.optional(),
|
|
569
|
-
})
|
|
613
|
+
})
|
|
614
|
+
.passthrough();
|
|
615
|
+
/** Top-level state keys this release does not know, i.e. written by another (usually newer) release (#1831). */
|
|
616
|
+
export function unknownStateKeys(raw) {
|
|
617
|
+
if (!raw || typeof raw !== 'object')
|
|
618
|
+
return [];
|
|
619
|
+
const known = new Set(Object.keys(AgentStateSchema.shape));
|
|
620
|
+
return Object.keys(raw).filter((k) => !known.has(k));
|
|
621
|
+
}
|
|
622
|
+
/** Warning tail for state written by a newer release (#1831), shared by the Gist and local loaders. */
|
|
623
|
+
export const NEWER_WRITER_HINT = 'was written by a different oss-autopilot release (usually a newer one); this version keeps those fields ' +
|
|
624
|
+
'but cannot use them. If you are not on the latest release, update with `claude plugin update oss-autopilot@oss-autopilot` and restart Claude Code.';
|
package/dist/core/state.js
CHANGED