Create a new StateManager instance.
When true, state is held only in memory and never read from or written to disk. Useful for unit tests that need isolated state without side effects. Defaults to false (normal persistent mode).
Add closed PRs to storage, deduplicating by URL.
Closed PRs to add (duplicates by URL are ignored)
Track a new issue. No-op if the issue URL is already tracked.
The issue to track
Add merged PRs to storage, deduplicating by URL.
Merged PRs to add (duplicates by URL are ignored)
Add a repository to the trusted projects list. No-op if already trusted.
Repository in "owner/repo" format
Append a new event to the event log and auto-persist. Events are capped at 1000 to prevent unbounded growth.
The event type identifier
Arbitrary event payload
Execute multiple mutations as a single batch, deferring disk I/O until the
batch completes. Nested batch() calls are flattened — only the outermost saves.
The function containing mutations to batch
Remove excluded repos/orgs from trusted projects.
Repository names to exclude
Organization names to exclude
Remove a manual status override for a PR.
The PR URL
true if an override was removed, false if none existed
Dismiss an issue's notifications. Auto-resurfaces on new activity.
The issue URL to dismiss
ISO timestamp of dismissal
true if newly dismissed, false if already dismissed
Returns all stored closed-without-merge PRs (sorted by close date descending via addClosedPRs).
Returns the most recent close date, used as a watermark for incremental fetching.
Filter events by type.
The event type to filter by
Events matching the given type
Filter events within a date range.
Start of range (inclusive)
End of range (inclusive), defaults to now
Events within the date range
Returns repos above the score threshold.
OptionalminScore: numberMinimum score (default: config.minRepoScoreThreshold)
Get the timestamp when an issue was dismissed, or undefined if not dismissed.
The issue URL to check
Returns repos below the score threshold.
OptionalmaxScore: numberMaximum score (default: config.minRepoScoreThreshold)
Returns all stored merged PRs (sorted by merge date descending via addMergedPRs).
Returns the most recent merge date, used as a watermark for incremental fetching.
Get the score record for a repository.
Repository in "owner/repo" format
Read-only score record, or undefined if not tracked
Returns repository names that have at least one merged PR.
Returns repository names with open PRs but no merged PRs yet.
Returns cached starred repository names.
Get the current state as a read-only snapshot.
Returns aggregate contribution statistics (merge rate, PR counts, repo breakdown).
Get the status override for a PR, auto-clearing if new activity has occurred.
The PR URL
OptionalcurrentUpdatedAt: stringPR's current updatedAt timestamp for staleness check
The override if still valid, undefined otherwise
Increment the closed-without-merge PR count.
Repository in "owner/repo" format
Increment the merged PR count for a repository.
Repository in "owner/repo" format
Initialize state with sensible defaults for zero-config onboarding. No-op if setup is already complete.
Check if a PR is currently shelved.
The PR URL to check
true if the PR is shelved
Check if initial setup has been completed.
Returns true if starred repos cache is older than 24 hours.
Mark a repository as hostile (score zeroed).
Repository in "owner/repo" format
Mark setup as complete and record the completion timestamp.
Re-read state from disk if the file has been modified since the last load/save. Returns true if state was reloaded, false if unchanged or in-memory mode.
Persist the current state to disk, creating a timestamped backup of the previous
state file first. In in-memory mode, only updates lastRunAt without any file I/O.
Update daily activity counts for dashboard display.
Daily activity counts keyed by YYYY-MM-DD
Store the latest daily digest and update the digest timestamp.
The daily digest to store
Update the local repository cache.
Local repository cache mapping repo names to paths
Update monthly closed PR counts for dashboard display.
Monthly closed PR counts keyed by YYYY-MM
Update monthly merged PR counts for dashboard display.
Monthly merged PR counts keyed by YYYY-MM
Update monthly opened PR counts for dashboard display.
Monthly opened PR counts keyed by YYYY-MM
Update the cached starred repositories and timestamp.
Repository names in "owner/repo" format
Set a manual status override for a PR. Auto-clears when the PR has new activity.
The PR URL
The overridden status
ISO timestamp of PR's last activity when override was set
Shelve a PR URL, hiding it from daily digest and capacity.
The PR URL to shelve
true if newly shelved, false if already shelved
Restore a dismissed issue to notifications.
The issue URL to undismiss
true if undismissed, false if not currently dismissed
Unshelve a PR URL, restoring it to daily digest.
The PR URL to unshelve
true if removed from shelf, false if not shelved
Merge partial config updates into the current configuration.
Partial config object to merge
Update scoring data for a repository.
Repository in "owner/repo" format
Partial score fields to merge
Singleton manager for persistent agent state stored in ~/.oss-autopilot/state.json.
Delegates file I/O to state-persistence.ts and scoring logic to repo-score-manager.ts. Retains lightweight CRUD operations for config, events, issues, shelving, dismissal, and status overrides.