diff --git a/CHANGELOG.md b/CHANGELOG.md index a9855f0..96b54a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ This changelog is automatically generated by AI when releases are published. ## [Unreleased] +## [3.12.0] - 2026-11-15 + +### Fixed + +- **Notes that spell the overwritten-line counter `overridden_lines` are read.** Schema 3.x shipped the counter as `overriden_lines` (a typo the spec records as erratum E-001). autter now reads either spelling, and a note that carries both, in prompt records, session stats and per-file stats; when both are present the corrected spelling wins. It still writes only `overriden_lines`, so notes are byte for byte what 3.11.0 wrote, every integrity stamp stays valid, and an older autter that rewrites a note (rebase, amend) keeps the count. A later release will write both keys once every reader in the field accepts the new one; schema 4 drops the old key. The spec's E-001 now says what readers and writers must do until then. The VS Code extension's type lists both keys. +- **`autter config telemetry_oss` reads the setting back.** `autter config set telemetry_oss on|off` worked, but reading it failed with "Unknown config key". It now prints `"on"` or `"off"` (off until you opt in), and `autter config` lists it. +- **Links to docs pages that do not exist.** The `untracked` link in `autter stats` now opens the commit stats page, the agent-format error links to the "Add your agent" guide, and the README, npm README, spec and `data-privacy.md` point at pages and anchors that exist on `autter.dev/docs` (`docs.autter.dev` does not resolve). +- **The IntelliJ plugin's install hint uses the real install URL** (`https://api.autter.dev/install.sh`). + ## [3.11.0] - 2026-11-15 ### Changed diff --git a/Cargo.lock b/Cargo.lock index db6c052..111d872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,7 +258,7 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "autter" -version = "3.11.0" +version = "3.12.0" dependencies = [ "autter", "base64", diff --git a/Cargo.toml b/Cargo.toml index ad9679e..fb35d3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "3" [package] name = "autter" -version = "3.11.0" +version = "3.12.0" edition = "2024" default-run = "autter" diff --git a/README.md b/README.md index f571b0a..5598a94 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ You can also disable it by setting `"telemetry_oss": "off"` in `~/.autter/config ![Junie](https://img.shields.io/badge/Junie-555?style=for-the-badge) ![Rovo Dev](https://img.shields.io/badge/Rovo_Dev-555?style=for-the-badge) ![Firebender](https://img.shields.io/badge/Firebender-555?style=for-the-badge) -[![+ Add an Agent](https://img.shields.io/badge/+_Add_an_Agent-1f6feb?style=for-the-badge)](https://autter.dev/docs/cli/add-your-agent) +[![+ Add an Agent](https://img.shields.io/badge/+_Add_an_Agent-1f6feb?style=for-the-badge)](https://autter.dev/docs/guides/add-your-agent) ## Why Autter @@ -175,14 +175,14 @@ Want a closer look? ### Documentation -- [CI Actions](https://autter.dev/docs/guides/ci-workflows) — preserve attribution through Rebase and Merge and Squash and Merge. +- [CI Actions](https://autter.dev/docs/cli/command-reference#ci) — preserve attribution through Rebase and Merge and Squash and Merge. - [How Autter Works](https://autter.dev/docs/cli/how-autter-works) - [Stats command](https://autter.dev/docs/cli/commit-stats) — aggregate % AI stats across commits. - [Scripting and CI](docs/scripting.md) — `--json` output, exit codes, `--strict`, and a GitHub Actions example. - [AI Blame](https://autter.dev/docs/cli/ai-blame) - [Config](https://autter.dev/docs/cli/configuration) - [Add support for an agent in Autter](https://autter.dev/docs/guides/add-your-agent) -- Install Autter in background agents: [Claude Web](https://autter.dev/docs/cli/claude-web), [Codex Cloud](https://autter.dev/docs/cli/codex-cloud), [Cursor Agent](https://autter.dev/docs/cli/cursor-agent), and [Devin](https://autter.dev/docs/cli/devin). +- Install Autter in background agents (Claude Code on the web, Codex Cloud, Cursor background agents, Devin): run the [install script](https://autter.dev/docs/cli/install) in the agent environment's setup step. There are no agent-specific guides yet. ## Attribution Stats @@ -193,7 +193,7 @@ autter stats --json autter stats .. --json ``` -It computes % AI code, AI lines generated vs committed, acceptance rates, and human overrides, broken down by tool and model. More in the [stats command reference](https://autter.dev/docs/cli/reference#stats). +It computes % AI code, AI lines generated vs committed, acceptance rates, and human overrides, broken down by tool and model. More in the [stats command reference](https://autter.dev/docs/cli/commit-stats). ### Scripting and CI @@ -361,7 +361,7 @@ Here is the full breakdown of what is supported today: | Edit / Write / Patch tools | ✅ | Line-level attribution recorded automatically. | | Files created via Bash | ✅ | May not work if the agent is not operating from the repository root. | | Git worktrees | ✅ | Attribution maintained across linked worktrees. | -| Background Agents | ✅ | See docs for [Claude Web](https://autter.dev/docs/cli/claude-web), [Codex Cloud](https://autter.dev/docs/cli/codex-cloud), [Cursor Agent](https://autter.dev/docs/cli/cursor-agent), and [Devin](https://autter.dev/docs/cli/devin). | +| Background Agents | ✅ | Run the [install script](https://autter.dev/docs/cli/install) in the agent environment's setup step. | | Attribute lines from multiple Agent Sessions in the same commit | ✅ | | | Record which lines a human overrode | ✅ | | | Attribute sessions that produced no code | ✅ | Records token usage and session activity even when no code is accepted. | @@ -396,8 +396,8 @@ GitHub, GitLab, Bitbucket, Azure DevOps: | Capability | Status | Notes | | --------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------- | -| Squash and Merge | ✅ | Requires [Autter for Teams](https://cal.com/sagnik-autter/15min) or [Open Source CI Actions](https://autter.dev/docs/guides/ci-workflows) to preserve attribution. | -| Rebase and Merge | ✅ | Requires [Autter for Teams](https://cal.com/sagnik-autter/15min) or [Open Source CI Actions](https://autter.dev/docs/guides/ci-workflows) to preserve attribution. | +| Squash and Merge | ✅ | Requires [Autter for Teams](https://cal.com/sagnik-autter/15min) or [Open Source CI Actions](https://autter.dev/docs/cli/command-reference#ci) to preserve attribution. | +| Rebase and Merge | ✅ | Requires [Autter for Teams](https://cal.com/sagnik-autter/15min) or [Open Source CI Actions](https://autter.dev/docs/cli/command-reference#ci) to preserve attribution. | ## Acknowledgments diff --git a/agent-support/intellij/src/main/kotlin/org/jetbrains/plugins/template/services/AutterService.kt b/agent-support/intellij/src/main/kotlin/org/jetbrains/plugins/template/services/AutterService.kt index 6e512de..c1be4bd 100644 --- a/agent-support/intellij/src/main/kotlin/org/jetbrains/plugins/template/services/AutterService.kt +++ b/agent-support/intellij/src/main/kotlin/org/jetbrains/plugins/template/services/AutterService.kt @@ -190,7 +190,7 @@ class AutterService { To fix: Install autter using one of these methods: - cargo install autter - - curl -fsSL https://install.autter.dev | sh + - curl -fsSL https://api.autter.dev/install.sh | bash - Or ensure autter is in your PATH """.trimIndent()) TelemetryService.getInstanceOrNull()?.reportAutterNotFound( diff --git a/agent-support/vscode/src/blame-service.ts b/agent-support/vscode/src/blame-service.ts index 00302c8..40bdd73 100644 --- a/agent-support/vscode/src/blame-service.ts +++ b/agent-support/vscode/src/blame-service.ts @@ -31,7 +31,10 @@ export interface PromptRecord { total_additions?: number; total_deletions?: number; accepted_lines?: number; + /** Schema 3.x spelling (erratum E-001); autter still writes this key. */ overriden_lines?: number; + /** Corrected spelling; later notes may carry it. Read it first: `overridden_lines ?? overriden_lines`. */ + overridden_lines?: number; other_files?: string[]; commits?: string[]; messages_url?: string; diff --git a/data-privacy.md b/data-privacy.md index c901d42..9c4430f 100644 --- a/data-privacy.md +++ b/data-privacy.md @@ -6,7 +6,7 @@ Unless you choose connected mode (`autter onboard --connect`, or "Connected" in Before you finish `autter onboard`, Autter does not read your AI agents' session history, and plain commands such as `autter status` or `autter doctor` do not start the background service. -The only other data Autter can send is anonymous error and usage telemetry. It is off until you opt in during `autter onboard` or with `autter telemetry on`, and you can turn it off at any time by setting `telemetry_oss` to `off`. See [configuration options](https://autter.dev/docs/cli/configuration#configuration-options) for details. +The only other data Autter can send is anonymous error and usage telemetry. It is off until you opt in during `autter onboard` or with `autter telemetry on`, and you can turn it off at any time by setting `telemetry_oss` to `off`. See [configuration options](https://autter.dev/docs/cli/configuration#storage-and-privacy-options) for details. ## Data @@ -24,7 +24,7 @@ AI attribution data is written to git notes and is readable by anyone with repo ### Telemetry -- **Error & exception telemetry** — off until you opt in during `autter onboard` (or with `autter telemetry on`), in local and connected mode alike. It never includes code or prompts. You can turn it off or redirect it to your own endpoint. See [configuration options](https://autter.dev/docs/cli/configuration#configuration-options). +- **Error & exception telemetry** — off until you opt in during `autter onboard` (or with `autter telemetry on`), in local and connected mode alike. It never includes code or prompts. You can turn it off or redirect it to your own endpoint. See [configuration options](https://autter.dev/docs/cli/configuration#storage-and-privacy-options). --- @@ -54,7 +54,7 @@ Teams and Enterprise deployments store additional data in the team instance: - **SCM PR data** from GitHub, Bitbucket, and GitLab - PR metadata: description, opener, reviewer, status - PR diffs — processed for computing % AI code, but not stored -- **Error & exception telemetry** — off until you opt in; you can turn it off or redirect it to your own endpoint at any time. See [configuration options](https://autter.dev/docs/cli/configuration#configuration-options). +- **Error & exception telemetry** — off until you opt in; you can turn it off or redirect it to your own endpoint at any time. See [configuration options](https://autter.dev/docs/cli/configuration#storage-and-privacy-options). For more information, see our [Trust Center](https://trust.autter.dev). diff --git a/docs/unsupported-agents.md b/docs/unsupported-agents.md index a1b05f4..5b19fc1 100644 --- a/docs/unsupported-agents.md +++ b/docs/unsupported-agents.md @@ -136,4 +136,4 @@ vendor's documentation. A miss only means no warning. | Aider | A hook around its edit step; today its commits arrive as ordinary git commits | To ask for an integration, or to contribute one, see -https://autter.dev/docs/cli/add-your-agent. +https://autter.dev/docs/guides/add-your-agent. diff --git a/npm/README.md b/npm/README.md index 2b6d393..74ce13e 100644 --- a/npm/README.md +++ b/npm/README.md @@ -2,7 +2,7 @@ **[Autter](https://autter.dev) is an open source git extension that records which lines of your code were written by AI** — tied to the agent, model, and prompt that produced them. -This package is a thin bootstrapper: it downloads the official native `autter` binary for your platform (macOS, Linux, or Windows; x64 or arm64) into `~/.autter/bin`, verifies its checksum against the GitHub release, and exposes the `autter` command through your npm global bin. The binary location is shared with the [shell installers](https://docs.autter.dev/cli/install), so hooks and the background service's self-updates keep working no matter how autter was installed. +This package is a thin bootstrapper: it downloads the official native `autter` binary for your platform (macOS, Linux, or Windows; x64 or arm64) into `~/.autter/bin`, verifies its checksum against the GitHub release, and exposes the `autter` command through your npm global bin. The binary location is shared with the [shell installers](https://autter.dev/docs/cli/install), so hooks and the background service's self-updates keep working no matter how autter was installed. ## Install @@ -38,6 +38,6 @@ If your package manager skips install scripts (`--ignore-scripts`, pnpm, or an n ## Links -- [Documentation](https://docs.autter.dev) +- [Documentation](https://autter.dev/docs) - [GitHub repository](https://github.com/Autter-dev/autter-cli) -- [Other install methods](https://docs.autter.dev/cli/install) (`curl`, PowerShell, Nix) +- [Other install methods](https://autter.dev/docs/cli/install) (`curl`, PowerShell, Nix) diff --git a/specs/autter_standard_v3.0.0.md b/specs/autter_standard_v3.0.0.md index 3daf1e8..a392d5f 100644 --- a/specs/autter_standard_v3.0.0.md +++ b/specs/autter_standard_v3.0.0.md @@ -8,7 +8,7 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S The [Autter project](https://github.com/autter-dev/autter-cli) is a full, production-ready implementation of this standard built as a Git extension. Another project would be considered compliant with this standard if it also attached AI Authorship Logs with Git Notes, even if it was implemented in another way. -If you are trying to add support for your Coding Agent to Autter format, that is best done by [integrating with published implementation](https://autter.dev/docs/cli/add-your-agent), not implementing this spec. +If you are trying to add support for your Coding Agent to Autter format, that is best done by [integrating with published implementation](https://autter.dev/docs/guides/add-your-agent), not implementing this spec. ## 1. Authorship Logs @@ -265,7 +265,7 @@ Each entry in the `prompts` object represents an AI session in the legacy format | `total_additions` | integer | REQUIRED | Total lines added by this session | | `total_deletions` | integer | REQUIRED | Total lines deleted by this session | | `accepted_lines` | integer | REQUIRED | Lines accepted in the final commit | -| `overriden_lines` | integer | REQUIRED | Lines that were later modified by human (see E-001) | +| `overriden_lines` | integer | REQUIRED | Lines that were later modified by human (see E-001; readers also accept `overridden_lines`) | | `custom_attributes` | object | OPTIONAL | User-defined key-value string pairs from configuration | **Deprecated:** The `messages` array field was removed as of v1.3.4 and MUST NOT appear in new notes. @@ -908,7 +908,12 @@ The length of IDs (currently 14 hex chars for each component, 16 total with pref ### Errata -E-001: The field name `overriden_lines` was introduced as a typographical error in v3.0.0 and shipped in the reference autter implementation, where it became canonical. In v4.x, this field WILL be renamed to `overridden_lines`. +E-001: The field name `overriden_lines` was introduced as a typographical error in v3.0.0 and shipped in the reference autter implementation, where it became canonical. In v4.x, this field WILL be renamed to `overridden_lines`. Until then, in every object that carries the counter (`prompts` entries, session `stats` and their per-file `files` entries): + +- Readers MUST accept both `overriden_lines` and `overridden_lines`. When both are present, readers MUST use `overridden_lines`. When neither is present, the count is 0. +- Readers MUST ignore members they do not recognise, so a note carrying both spellings stays readable. +- Writers of v3.x notes MUST emit `overriden_lines`. They MAY also emit `overridden_lines` with the same value; the reference implementation does not yet (it reads both from autter 3.12.0). Writers MUST NOT emit only `overridden_lines` in a v3.x note, because an older reader that rewrites the note would drop the count. +- Adding the second key does not change the schema version. E-002: The `messages` array field in prompt records was deprecated in v1.3.4 and removed. It MUST NOT appear in new notes. The optional `messages_url` field remains available in `prompts` for linking to externally-stored transcripts. Session records do not carry `messages_url` as session IDs map directly to agent conversation data. diff --git a/src/authorship/authorship_log.rs b/src/authorship/authorship_log.rs index 7bae6c6..c633e4f 100644 --- a/src/authorship/authorship_log.rs +++ b/src/authorship/authorship_log.rs @@ -202,7 +202,12 @@ pub struct HumanRecord { } /// Prompt session details stored in the top-level prompts map keyed by short hash (agent_id + tool) +/// +/// The overwritten-line counter is written as `overriden_lines` (the schema's +/// original spelling, see erratum E-001 in the spec) and read under either +/// spelling: see [`PromptRecordWire`]. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(from = "PromptRecordWire")] pub struct PromptRecord { pub agent_id: AgentId, pub human_author: Option, @@ -229,8 +234,10 @@ pub struct PromptRecord { /// `accepted_lines` is how many of the session's lines survived to the committed /// state; `overriden_lines` is how many of this session's lines were later overwritten /// (by a human or another session). Field name `overriden_lines` keeps the existing -/// (intentionally misspelled) schema convention used by [`PromptRecord`]. +/// (intentionally misspelled) schema convention used by [`PromptRecord`]; the +/// corrected `overridden_lines` is accepted when reading (see [`FileStatsWire`]). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)] +#[serde(from = "FileStatsWire")] pub struct FileStats { #[serde(default)] pub total_additions: u32, @@ -243,7 +250,9 @@ pub struct FileStats { } /// Aggregate line statistics for a session, plus a per-file breakdown. +/// Reads `overridden_lines` as well as `overriden_lines` (see [`SessionStatsWire`]). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)] +#[serde(from = "SessionStatsWire")] pub struct SessionStats { #[serde(default)] pub total_additions: u32, @@ -258,6 +267,115 @@ pub struct SessionStats { pub files: BTreeMap, } +// --------------------------------------------------------------------------- +// Reading the overwritten-line counter under either spelling +// --------------------------------------------------------------------------- +// +// Schema 3.x shipped the counter as `overriden_lines` (erratum E-001). Readers +// accept the corrected `overridden_lines` too, so a later release can write +// both keys and schema 4 can drop the old one without breaking this release. +// Writers keep emitting only `overriden_lines` for now: an older autter that +// rewrites a note (rebase, amend) re-serializes it from its own structs and +// would drop a key it does not know, silently zeroing the count. +// +// `#[serde(alias)]` is not enough: with an alias, a note that carries both +// keys fails with "duplicate field". These wire structs hold both spellings +// as separate optional fields instead. The corrected spelling wins when both +// are present. Reading changes no bytes of the note, so integrity stamps are +// unaffected. + +fn either_spelling(corrected: Option, original: Option) -> u32 { + corrected.or(original).unwrap_or(0) +} + +#[derive(Deserialize)] +struct PromptRecordWire { + agent_id: AgentId, + human_author: Option, + #[serde(default)] + messages_url: Option, + #[serde(default)] + total_additions: u32, + #[serde(default)] + total_deletions: u32, + #[serde(default)] + accepted_lines: u32, + #[serde(default)] + overriden_lines: Option, + #[serde(default)] + overridden_lines: Option, + #[serde(default)] + custom_attributes: Option>, +} + +impl From for PromptRecord { + fn from(w: PromptRecordWire) -> Self { + Self { + agent_id: w.agent_id, + human_author: w.human_author, + messages_url: w.messages_url, + total_additions: w.total_additions, + total_deletions: w.total_deletions, + accepted_lines: w.accepted_lines, + overriden_lines: either_spelling(w.overridden_lines, w.overriden_lines), + custom_attributes: w.custom_attributes, + } + } +} + +#[derive(Deserialize)] +struct FileStatsWire { + #[serde(default)] + total_additions: u32, + #[serde(default)] + total_deletions: u32, + #[serde(default)] + accepted_lines: u32, + #[serde(default)] + overriden_lines: Option, + #[serde(default)] + overridden_lines: Option, +} + +impl From for FileStats { + fn from(w: FileStatsWire) -> Self { + Self { + total_additions: w.total_additions, + total_deletions: w.total_deletions, + accepted_lines: w.accepted_lines, + overriden_lines: either_spelling(w.overridden_lines, w.overriden_lines), + } + } +} + +#[derive(Deserialize)] +struct SessionStatsWire { + #[serde(default)] + total_additions: u32, + #[serde(default)] + total_deletions: u32, + #[serde(default)] + accepted_lines: u32, + #[serde(default)] + overriden_lines: Option, + #[serde(default)] + overridden_lines: Option, + #[serde(default)] + files: BTreeMap, +} + +impl From for SessionStats { + fn from(w: SessionStatsWire) -> Self { + Self { + total_additions: w.total_additions, + total_deletions: w.total_deletions, + accepted_lines: w.accepted_lines, + overriden_lines: either_spelling(w.overridden_lines, w.overriden_lines), + files: w.files, + } + } +} + /// Session record for session tracking. `stats` carries the per-session (and /// per-file) line statistics consumed by the backend's AI Metrics view. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/src/authorship/authorship_log_serialization.rs b/src/authorship/authorship_log_serialization.rs index e8b7561..236cf61 100644 --- a/src/authorship/authorship_log_serialization.rs +++ b/src/authorship/authorship_log_serialization.rs @@ -1547,4 +1547,137 @@ mod tests { ); assert_eq!(parsed.serialize_to_string().unwrap(), one); } + + /// A note whose prompt, session and per-file counters are all 3, written + /// the way autter writes it today (`overriden_lines` everywhere). + fn note_with_overwritten_lines() -> String { + use crate::authorship::authorship_log::{ + FileStats, PromptRecord, SessionRecord, SessionStats, + }; + let agent_id = crate::authorship::working_log::AgentId { + tool: "cursor".to_string(), + id: "session_123".to_string(), + model: "claude-3-sonnet".to_string(), + }; + let mut log = AuthorshipLog::new(); + let hash = generate_short_hash(&agent_id.id, &agent_id.tool); + log.metadata.prompts.insert( + hash.clone(), + PromptRecord { + agent_id: agent_id.clone(), + human_author: None, + messages_url: None, + total_additions: 5, + total_deletions: 0, + accepted_lines: 2, + overriden_lines: 3, + custom_attributes: None, + }, + ); + log.metadata.sessions.insert( + "s_0123456789abcd".to_string(), + SessionRecord { + agent_id, + human_author: None, + messages_url: None, + stats: Some(SessionStats { + total_additions: 5, + total_deletions: 0, + accepted_lines: 2, + overriden_lines: 3, + files: BTreeMap::from([( + "src/main.rs".to_string(), + FileStats { + total_additions: 5, + total_deletions: 0, + accepted_lines: 2, + overriden_lines: 3, + }, + )]), + }), + custom_attributes: None, + }, + ); + let mut file = FileAttestation::new("src/main.rs".to_string()); + file.add_entry(AttestationEntry::new(hash, vec![LineRange::Range(1, 5)])); + log.attestations.push(file); + log.serialize_to_string().unwrap() + } + + /// The prompt, session and per-file counters of a parsed note. + fn overwritten_counts(note: &str) -> Vec { + let log = AuthorshipLog::deserialize_from_string(note).unwrap(); + let prompt = log.metadata.prompts.values().next().unwrap(); + let stats = log + .metadata + .sessions + .values() + .next() + .unwrap() + .stats + .as_ref() + .unwrap(); + vec![ + prompt.overriden_lines, + stats.overriden_lines, + stats.files["src/main.rs"].overriden_lines, + ] + } + + #[test] + fn overwritten_lines_are_written_under_the_original_key_only() { + let note = note_with_overwritten_lines(); + assert_eq!(note.matches("\"overriden_lines\": 3").count(), 3); + assert!(!note.contains("overridden_lines")); + } + + #[test] + fn overwritten_lines_read_under_the_original_key() { + let note = note_with_overwritten_lines(); + assert_eq!(overwritten_counts(¬e), vec![3, 3, 3]); + } + + #[test] + fn overwritten_lines_read_under_the_corrected_key() { + let note = + note_with_overwritten_lines().replace("\"overriden_lines\"", "\"overridden_lines\""); + assert!(!note.contains("overriden_lines")); + assert_eq!(overwritten_counts(¬e), vec![3, 3, 3]); + // Written back under the original key, so an older autter that + // rewrites the note still finds the count. + let rewritten = AuthorshipLog::deserialize_from_string(¬e) + .unwrap() + .serialize_to_string() + .unwrap(); + assert_eq!(rewritten, note_with_overwritten_lines()); + } + + #[test] + fn overwritten_lines_read_when_a_note_carries_both_keys() { + // Both keys with the same value (what a later dual-writing release + // will write). With `#[serde(alias)]` this would fail with + // "duplicate field". + let both = note_with_overwritten_lines().replace( + "\"overriden_lines\": 3", + "\"overriden_lines\": 3,\n \"overridden_lines\": 3", + ); + assert_eq!(both.matches("overridden_lines").count(), 3); + assert_eq!(overwritten_counts(&both), vec![3, 3, 3]); + + // Different values: the corrected key wins. + let differ = note_with_overwritten_lines().replace( + "\"overriden_lines\": 3", + "\"overriden_lines\": 1,\n \"overridden_lines\": 4", + ); + assert_eq!(overwritten_counts(&differ), vec![4, 4, 4]); + } + + #[test] + fn overwritten_lines_default_to_zero_when_absent() { + // Neither spelling (an unknown member in its place is ignored). + let none = + note_with_overwritten_lines().replace("\"overriden_lines\"", "\"unrelated_counter\""); + assert!(!none.contains("overriden_lines")); + assert_eq!(overwritten_counts(&none), vec![0, 0, 0]); + } } diff --git a/src/authorship/stats.rs b/src/authorship/stats.rs index 4ef80da..a124887 100644 --- a/src/authorship/stats.rs +++ b/src/authorship/stats.rs @@ -540,7 +540,7 @@ fn counts_line(stats: &CommitStats, unknown_lines: u32, colorize: bool) -> Strin let label = if category == LineCategory::Untracked && colorize && use_hyperlinks() { // OSC 8 link on terminals that render it; color alone isn't enough // (Windows ConHost with VT enabled prints OSC 8 literally). - "\x1b]8;;https://autter.dev/docs/cli/untracked\x1b\\\x1b[4muntracked\x1b[24m\x1b]8;;\x1b\\" + "\x1b]8;;https://autter.dev/docs/cli/commit-stats#untracked-and-unknown-lines\x1b\\\x1b[4muntracked\x1b[24m\x1b]8;;\x1b\\" .to_string() } else { category.label().to_string() diff --git a/src/commands/checkpoint_agent/presets/agent_v1.rs b/src/commands/checkpoint_agent/presets/agent_v1.rs index 127d2f6..2340d03 100644 --- a/src/commands/checkpoint_agent/presets/agent_v1.rs +++ b/src/commands/checkpoint_agent/presets/agent_v1.rs @@ -31,7 +31,7 @@ impl AgentPreset for AgentV1Preset { fn parse(&self, hook_input: &str, trace_id: &str) -> Result, AutterError> { let payload: AgentV1Payload = serde_json::from_str(hook_input).map_err(|e| { AutterError::PresetError(format!( - "Invalid AgentV1Input JSON. Format is documented here: https://autter.dev/docs/cli/add-your-agent: \n\n Error: {}", + "Invalid AgentV1Input JSON. Format is documented here: https://autter.dev/docs/guides/add-your-agent: \n\n Error: {}", e )) })?; diff --git a/src/commands/config.rs b/src/commands/config.rs index f2982a7..b3ddcf6 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -101,7 +101,7 @@ fn print_config_help() { println!(" exclude_prompts_in_repositories Repos to exclude prompts from (array)"); println!(" allow_repositories Allowed repos (array)"); println!(" exclude_repositories Excluded repos (array)"); - println!(" telemetry_oss OSS telemetry setting (on/off)"); + println!(" telemetry_oss Anonymous telemetry (on/off, off until you opt in)"); println!(" telemetry_enterprise_dsn Enterprise telemetry DSN"); println!(" disable_version_checks Disable version checks (bool)"); println!(" disable_auto_updates Disable auto updates (bool)"); @@ -280,6 +280,11 @@ fn show_all_config() -> Result<(), String> { effective_config.insert("exclude_repositories".to_string(), Value::Array(vec![])); } + effective_config.insert( + "telemetry_oss".to_string(), + Value::String(telemetry_oss_value(runtime_config).to_string()), + ); + // Booleans with runtime values effective_config.insert( "telemetry_oss_disabled".to_string(), @@ -379,6 +384,16 @@ fn show_all_config() -> Result<(), String> { Ok(()) } +/// `telemetry_oss` as `autter config set telemetry_oss` takes it: "on" only +/// after the user opted in, "off" otherwise (unset counts as off). +fn telemetry_oss_value(runtime_config: &crate::config::Config) -> &'static str { + if runtime_config.is_telemetry_oss_disabled() { + "off" + } else { + "on" + } +} + fn get_config_value(key: &str) -> Result<(), String> { let file_config = crate::config::load_file_config_public()?; let runtime_config = crate::config::Config::get(); @@ -410,6 +425,9 @@ fn get_config_value(key: &str) -> Result<(), String> { Value::Array(vec![]) } } + // The key `autter config set telemetry_oss on|off` writes. Reads + // back the effective setting: "off" until the user opts in. + "telemetry_oss" => Value::String(telemetry_oss_value(runtime_config).to_string()), "telemetry_oss_disabled" => Value::Bool(runtime_config.is_telemetry_oss_disabled()), "telemetry_enterprise_dsn" => { if let Some(ref dsn) = file_config.telemetry_enterprise_dsn { diff --git a/tests/integration/note_integrity_check.rs b/tests/integration/note_integrity_check.rs index b917ac9..24cc301 100644 --- a/tests/integration/note_integrity_check.rs +++ b/tests/integration/note_integrity_check.rs @@ -420,6 +420,86 @@ fn test_edit_with_recomputed_digest_still_verifies() { assert_status(&repo, &commit, "verified"); } +/// The overwritten-line counter of every prompt and session in `note`. +fn overwritten_counts(note: &str) -> Vec { + use autter::authorship::authorship_log_serialization::AuthorshipLog; + let log = AuthorshipLog::deserialize_from_string(&strip_integrity(note)) + .unwrap_or_else(|e| panic!("note should parse ({e}):\n{note}")); + let mut counts: Vec = log + .metadata + .prompts + .values() + .map(|p| p.overriden_lines) + .collect(); + for session in log.metadata.sessions.values() { + if let Some(stats) = &session.stats { + counts.push(stats.overriden_lines); + counts.extend(stats.files.values().map(|f| f.overriden_lines)); + } + } + counts +} + +/// Schema 3.x writes the overwritten-line counter as `overriden_lines` +/// (erratum E-001). A note that spells it `overridden_lines`, or carries both +/// spellings, as later releases will write, is read with the right count and +/// verifies once stamped; and a rewrite (amend) keeps the count, written back +/// under the original key. +#[test] +fn test_note_with_either_overwritten_lines_spelling_verifies() { + let shapes = [ + ("original key", "\"overriden_lines\": 2"), + ("corrected key", "\"overridden_lines\": 2"), + ( + "both keys", + "\"overriden_lines\": 2,\n \"overridden_lines\": 2", + ), + ]; + for (shape, replacement) in shapes { + let repo = TestRepo::new(); + let mut file = repo.filename("app.txt"); + file.set_contents(crate::lines!["human one", "ai one".ai()]); + let commit = repo.stage_all_and_commit("ai commit").unwrap().commit_sha; + + let note = raw_note(&repo, &commit); + let integrity = read_integrity(¬e).unwrap(); + let body = strip_integrity(¬e); + assert!( + body.contains("\"overriden_lines\": 0") && !body.contains("overridden_lines"), + "autter writes the original key only:\n{body}" + ); + let edited = body.replace("\"overriden_lines\": 0", replacement); + let stamped = seal_note(&edited, &integrity).unwrap(); + write_raw_note(&repo, &commit, &stamped); + + let counts = overwritten_counts(&raw_note(&repo, &commit)); + assert!(!counts.is_empty(), "{shape}: note has no counters"); + assert!( + counts.iter().all(|&c| c == 2), + "{shape}: counts read as {counts:?}" + ); + assert_status(&repo, &commit, "verified"); + file.assert_committed_lines(crate::lines!["human one".human(), "ai one".ai()]); + + // A rewrite re-serializes the note: the counts survive, + // under the original key, and the new note verifies. + repo.git(&["commit", "--amend", "-m", "reworded"]).unwrap(); + let amended = rev(&repo, "HEAD"); + assert_ne!(commit, amended); + let rewritten = raw_note(&repo, &amended); + assert!( + !rewritten.contains("overridden_lines"), + "{shape}: autter writes the original key only:\n{rewritten}" + ); + let rewritten_counts = overwritten_counts(&rewritten); + assert!( + !rewritten_counts.is_empty() && rewritten_counts.iter().all(|&c| c == 2), + "{shape}: counts after the rewrite read as {rewritten_counts:?}:\n{rewritten}" + ); + assert_status(&repo, &amended, "verified"); + } +} + // --------------------------------------------------------------------------- // Warnings // --------------------------------------------------------------------------- diff --git a/tests/integration/simple_additions.rs b/tests/integration/simple_additions.rs index 1f24121..5a8fecf 100644 --- a/tests/integration/simple_additions.rs +++ b/tests/integration/simple_additions.rs @@ -1959,6 +1959,34 @@ fn test_author_config_cli_set_get_unset() { assert_eq!(value.as_object().unwrap().len(), 0); } +/// What `autter config set telemetry_oss` writes, `autter config telemetry_oss` +/// reads back (it used to fail with "Unknown config key"). Unset reads as +/// "off": anonymous telemetry is off until the user opts in. +#[test] +fn test_telemetry_oss_config_reads_back() { + let repo = TestRepo::new(); + let read = |repo: &TestRepo| -> String { + repo.autter(&["config", "telemetry_oss"]) + .unwrap() + .trim() + .to_string() + }; + + repo.autter(&["config", "unset", "telemetry_oss"]).unwrap(); + assert_eq!(read(&repo), "\"off\""); + + repo.autter(&["config", "set", "telemetry_oss", "on"]) + .unwrap(); + assert_eq!(read(&repo), "\"on\""); + let all: serde_json::Value = + serde_json::from_str(repo.autter(&["config"]).unwrap().trim()).unwrap(); + assert_eq!(all["telemetry_oss"], "on"); + + repo.autter(&["config", "set", "telemetry_oss", "off"]) + .unwrap(); + assert_eq!(read(&repo), "\"off\""); +} + #[test] fn test_author_config_overrides_session_and_known_human_records() { let mut repo = TestRepo::new();