Skip to content

[codex] add repository presets for contribution targeting#58

Merged
NianJiuZst merged 4 commits into
mainfrom
codex/repository-presets
Jun 10, 2026
Merged

[codex] add repository presets for contribution targeting#58
NianJiuZst merged 4 commits into
mainfrom
codex/repository-presets

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a reusable repository preset system for contribution targeting, so users can save fixed sets of GitHub repositories, mark one preset as active, and reuse that scope across scout, agent, and analyze without retyping repositories every time.

In addition to the new preset model and CLI surface, this PR also updates the runtime behavior so the active preset is automatically applied by default, while still preserving explicit overrides such as --repo, --preset, and --all-repos.

It also keeps the existing artifact publishing repository behavior intact, but renames the user-facing terminology from "target repository" to "artifact repository" to reduce ambiguity between publishing configuration and contribution exploration scope.
close: #27

What Changed

1. Added repository targeting config support

Introduced a new top-level repositoryTargeting config section with:

  • activePreset
  • presets: Record<string, { repos: string[] }>

This includes:

  • defaults for new configs
  • backward-compatible loading for existing configs
  • config normalization for preset names and repository entries
  • repo deduplication while preserving order
  • validation for 1 to 10 repositories per preset

2. Added openmeta preset management commands

Added a dedicated preset command group:

  • openmeta preset list
  • openmeta preset add <name> --repo ... [--activate]
  • openmeta preset use <name>
  • openmeta preset remove <name>

These commands are wired into the CLI and orchestration layers and persist their state through the existing config service.

3. Extended runtime commands with preset-aware targeting

Updated command surfaces for:

  • openmeta scout
  • openmeta agent
  • openmeta analyze

New options include:

  • --preset <name> for all three commands
  • --all-repos for scout and agent

Resolution precedence is now effectively:

  1. --all-repos bypasses preset targeting for scout and agent
  2. --repo overrides everything else
  3. --preset <name> selects that named preset
  4. otherwise the active preset is auto-applied if configured
  5. otherwise behavior falls back to the existing global or explicit-repo model

4. Added shared repository targeting service

Introduced a shared service to centralize:

  • preset name normalization
  • repo normalization
  • preset lookup
  • active preset lookup
  • active repo retrieval
  • target scope resolution
  • doctor validation

This keeps the targeting precedence and validation logic consistent across multiple commands.

5. Updated openmeta init, config view, and doctor

openmeta init now includes a repository preset setup step before artifact repository setup.

Behavior includes:

  • prompting for a first preset when none exists
  • default-friendly preset creation flow
  • optional activation during setup
  • summary/skip behavior when a valid active preset already exists

config view now surfaces:

  • active preset
  • saved preset count
  • active preset repo list

doctor now validates repository targeting state and distinguishes between:

  • no presets configured
  • presets configured with no active preset
  • invalid or missing active preset configuration

6. Added multi-repo preset behavior to analyze

analyze now supports:

  • explicit --repo
  • explicit --preset
  • implicit active preset application
  • multi-repo repository analysis for preset scopes

For preset-scoped analysis, the runtime now:

  • prepares a repository workspace per repo
  • loads repo memory per repo
  • runs llmService.analyzeRepository(...) per repo
  • flattens and globally ranks cross-repo suggestions by prPotentialScore
  • auto-selects the top candidate in headless mode
  • supports interactive cross-repo candidate selection when not headless
  • continues patch draft / PR draft generation only for the selected repository
  • renders repository analysis artifacts with grouped multi-repo output and selection context

7. Added preset-aware agent fallback flow

agent now understands preset scopes and uses them in a two-step strategy:

  1. issue-first scouting across the preset's repositories
  2. repository-analysis fallback when no issue clears automation.minMatchScore

This means the agent can still produce a contribution path even when preset-scoped issue discovery is not strong enough.

The fallback path reuses the same repository-analysis selection model and then continues through the normal patch draft, implementation, PR draft, artifact, inbox, and proof-of-work flow.

8. Added preset-aware scout

scout now:

  • auto-applies the active preset by default
  • supports explicit --preset
  • supports --all-repos to bypass preset targeting
  • aggregates repo-scoped issue discovery across preset repositories before ranking and display

9. Updated content rendering and docs

Repository analysis markdown output now supports grouped multi-repo rendering for preset-based analysis.

README/help-facing documentation was also updated to cover:

  • preset management
  • active preset default behavior
  • --all-repos
  • artifact repository terminology

Why This Change

Before this PR, users had to repeatedly pass repository targets at runtime, even when they were exploring the same set of repositories over and over.

That made the contribution loop more repetitive than it needed to be, especially for users who want a stable exploration lane such as:

  • a frontend stack shortlist
  • a docs-only contribution lane
  • a tooling-focused target set
  • a fixed set of repos for scheduled automation

This PR makes repository targeting a first-class saved configuration concept while preserving the existing explicit command overrides.

User Impact

With this change, users can now:

  • define named exploration target sets once
  • make one preset active and reuse it automatically
  • run scout, agent, and analyze against that preset by default
  • temporarily override with a different preset or a single repository
  • force global discovery again with --all-repos

This reduces repeated CLI input and makes scheduled or repeated open-source exploration much smoother.

Validation

Fresh verification run before publishing:

  • bunx tsc --noEmit
  • bun test test/agent-run.test.ts test/scout-targeting.test.ts test/content.test.ts test/config-orchestrator.test.ts test/doctor.test.ts test/init-orchestrator.test.ts test/preset-orchestrator.test.ts test/preset-command.test.ts test/targeting-commands.test.ts test/state-services.test.ts test/agent-orchestrator.test.ts test/scheduler.test.ts test/issue-ranking.test.ts

Result:

  • Typecheck passed
  • Test suite segment passed with 92 pass / 0 fail

Notes

This is intentionally a v1 preset system focused on fixed named repository sets.

It does not add:

  • dynamic query presets
  • tag-based preset selection
  • parallel patch generation for every analyzed repository in a preset

Those could be layered on later if we want to expand the exploration model.

@NianJiuZst NianJiuZst marked this pull request as ready for review June 7, 2026 16:13
@NianJiuZst NianJiuZst force-pushed the codex/repository-presets branch from dc449d7 to 4edc573 Compare June 7, 2026 16:28
@NianJiuZst NianJiuZst force-pushed the codex/repository-presets branch from 73df473 to 49d3dc7 Compare June 10, 2026 08:17
@NianJiuZst NianJiuZst merged commit 49d3dc7 into main Jun 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Hot Repository Boost for Personalized Issue Recommendation

1 participant