Skip to content

Commit 122ed49

Browse files
committed
feat(primer): RFC-0004 full implementation with value-based selection
## Added - Full RFC-0004 primer implementation with value-based section selection - 4-phase selection algorithm: required β†’ conditional β†’ safety β†’ value-optimized - Multi-dimensional scoring (safety, efficiency, accuracy, base) - 37 sections across 6 categories from primer.defaults.json - New CLI options: --format, --preset, --include, --exclude, --categories - Introspection: --list-sections, --list-presets, --preview, --explain - Dynamic sections from cache (constraints, domains, hacks, attempts) - Project customization via .acp/primer.json - MCP/shell capability filtering ## Changed - Primer tier names: survival, essential, operational, informed, complete, expert - Value-per-token optimization replaces fixed tier system ## Fixed - acp constraints β†’ acp check in primer.defaults.json (4 locations) - MCP capability filtering now properly excludes shell-only sections ## Infrastructure - New src/primer/ module (8 files, ~2000 LOC) - 20 primer-specific tests - Updated README.md and cli.md documentation BREAKING CHANGE: None - backward compatible with existing primer API
1 parent 866e44c commit 122ed49

16 files changed

Lines changed: 2403 additions & 434 deletions

File tree

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- **RFC-0004: Full primer implementation** with value-based section selection
12+
- 4-phase selection algorithm: required β†’ conditional β†’ safety β†’ value-optimized
13+
- Multi-dimensional value scoring (safety, efficiency, accuracy, base)
14+
- 37 sections across 6 categories from `primer.defaults.json`
15+
- New primer CLI options:
16+
- `-b, --budget` β€” Token budget (shorthand)
17+
- `-f, --format` β€” Output format (markdown, compact, json, text)
18+
- `-p, --preset` β€” Weight presets (safe, efficient, accurate, balanced)
19+
- `--include`, `--exclude` β€” Section inclusion/exclusion
20+
- `--categories` β€” Category filtering
21+
- `--no-dynamic` β€” Disable dynamic value modifiers
22+
- `--explain` β€” Show selection reasoning
23+
- `--list-sections` β€” List available sections
24+
- `--list-presets` β€” List weight presets
25+
- `--preview` β€” Preview selection without rendering
26+
- `--primer-config` β€” Custom primer configuration file
27+
- Dynamic sections populated from cache (protected files, domains, hacks, attempts)
28+
- Project customization via `.acp/primer.json`
29+
- MCP/shell capability filtering
30+
31+
### Changed
32+
- Primer tier names: survival, essential, operational, informed, complete, expert
33+
- Primer now uses value-per-token optimization instead of fixed tier system
34+
35+
### Fixed
36+
- `acp constraints` β†’ `acp check` in primer.defaults.json (4 locations)
37+
- MCP capability filtering now properly excludes shell-only sections
38+
1039
## [0.4.2] - 2025-12-30
1140

1241
### Fixed

β€ŽCargo.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# @acp:summary "Package metadata and publishing information"
88
[package]
99
name = "acp-protocol"
10-
version = "0.4.2"
10+
version = "0.5.0"
1111
edition = "2021"
1212
authors = ["ACP Contributors"]
1313
description = "AI Context Protocol - Token-efficient and context enhancing code documentation for AI systems"

β€ŽREADME.mdβ€Ž

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -609,45 +609,80 @@ acp validate .acp/acp.vars.json
609609
610610
### `acp primer`
611611
612-
Generate AI bootstrap primers with tiered content selection.
612+
Generate AI bootstrap primers with value-based section selection (RFC-0004).
613613
614614
```bash
615615
acp primer [OPTIONS]
616616
617-
Options:
618-
--budget <N> Token budget [default: 200]
619-
--capabilities <caps> Capabilities filter (comma-separated: shell,mcp)
617+
Core Options:
618+
-b, --budget <N> Token budget [default: 200]
619+
--capabilities <caps> Filter by capabilities (shell, mcp, editor)
620+
-f, --format <type> Output format: markdown, compact, json, text [default: markdown]
620621
--json Output as JSON with metadata
621-
-c, --cache <path> Cache file for project warnings [default: .acp/acp.cache.json]
622+
623+
Selection Options:
624+
-p, --preset <name> Weight preset: safe, efficient, accurate, balanced [default: balanced]
625+
--include <ids> Force include section IDs (comma-separated)
626+
--exclude <ids> Exclude section IDs (comma-separated)
627+
--categories <ids> Filter by category IDs
628+
--no-dynamic Disable dynamic value modifiers
629+
630+
Introspection:
631+
--list-sections List all available sections (37 sections)
632+
--list-presets List weight presets with dimension weights
633+
--preview Preview selection without rendering
634+
--explain Show selection reasoning
635+
636+
Configuration:
637+
--primer-config <path> Custom primer config [default: .acp/primer.json]
638+
--cache <path> Cache file for project state [default: .acp/acp.cache.json]
622639
```
623640
624-
**Tier Selection:**
641+
**Weight Presets:**
625642
626-
| Remaining Budget | Tier | Content Depth |
627-
|------------------|------|---------------|
628-
| <80 tokens | minimal | Command + one-line purpose |
629-
| 80-299 tokens | standard | + options, usage |
630-
| 300+ tokens | full | + examples, patterns |
643+
| Preset | Safety | Efficiency | Accuracy | Use Case |
644+
|--------|--------|------------|----------|----------|
645+
| `safe` | 2.5 | 0.8 | 1.0 | Security-critical projects |
646+
| `efficient` | 1.2 | 2.0 | 0.9 | Fast iteration, prototyping |
647+
| `accurate` | 1.2 | 0.9 | 2.0 | Precision-critical work |
648+
| `balanced` | 1.5 | 1.0 | 1.0 | Default, general use |
631649
632650
**Examples:**
633651
634652
```bash
635653
# Standard primer (200 tokens)
636654
acp primer
637655
638-
# Minimal primer
639-
acp primer --budget 60
656+
# Minimal primer for small context windows
657+
acp primer -b 100
640658
641-
# Full primer with project warnings
642-
acp primer --budget 500
659+
# Full primer with selection reasoning
660+
acp primer -b 500 --explain
643661
644-
# JSON output with metadata
645-
acp primer --budget 200 --json
662+
# MCP-only primer with safe preset
663+
acp primer -b 300 --capabilities mcp --preset safe
664+
665+
# List available sections
666+
acp primer --list-sections
646667
647-
# Filter by capability
648-
acp primer --capabilities shell
668+
# Preview what would be selected
669+
acp primer -b 400 --preview
670+
671+
# Exclude specific sections
672+
acp primer --exclude cli-overview,annotation-syntax
673+
674+
# JSON output with metadata
675+
acp primer --json
649676
```
650677
678+
**Customization:**
679+
680+
Create `.acp/primer.json` to customize:
681+
- Section weights and priorities
682+
- Add project-specific sections
683+
- Disable default sections
684+
- Override templates
685+
651686
---
652687
653688
## Configuration

β€Žsrc/commands/mod.rsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub use migrate::{execute_migrate, DirectiveDefaults, MigrateOptions, MigrationS
4444
pub use output::{
4545
format_constraint_level, format_symbol_ref, format_symbol_ref_range, TreeRenderer,
4646
};
47-
pub use primer::{execute_primer, PrimerFormat, PrimerOptions};
47+
pub use primer::{execute_primer, PrimerOptions};
4848
pub use query::{execute_query, ConfidenceFilter, QueryOptions, QuerySubcommand};
4949
pub use revert::{execute_revert, RevertOptions};
5050
pub use review::{execute_review, ReviewOptions, ReviewSubcommand};

0 commit comments

Comments
Β (0)