Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
39 lines
1.3 KiB
Rust
39 lines
1.3 KiB
Rust
mod world_state;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use codex_extension_api::ContextContributor;
|
|
use codex_extension_api::ExtensionFuture;
|
|
use codex_extension_api::ExtensionRegistryBuilder;
|
|
use codex_extension_api::WorldStateContributionInput;
|
|
use codex_extension_api::WorldStateSectionContribution;
|
|
|
|
use crate::world_state::git_attribution_world_state_section;
|
|
|
|
/// Local default for commit and pull request attribution. aKode never fetches a
|
|
/// remote workspace policy, so attribution stays disabled.
|
|
const ATTRIBUTION_ENABLED_BY_DEFAULT: bool = false;
|
|
|
|
/// Contributes model instructions for agent-created git commits and pull requests.
|
|
#[derive(Clone)]
|
|
struct GitAttributionExtension {
|
|
enabled: bool,
|
|
}
|
|
|
|
impl ContextContributor for GitAttributionExtension {
|
|
fn contribute_world_state<'a>(
|
|
&'a self,
|
|
_input: WorldStateContributionInput<'a>,
|
|
) -> ExtensionFuture<'a, Vec<WorldStateSectionContribution>> {
|
|
let enabled = self.enabled;
|
|
Box::pin(async move { vec![git_attribution_world_state_section(enabled)] })
|
|
}
|
|
}
|
|
|
|
/// Installs the git-attribution contributor into the extension registry.
|
|
pub fn install<C: Sync>(registry: &mut ExtensionRegistryBuilder<C>) {
|
|
registry.prompt_contributor(Arc::new(GitAttributionExtension {
|
|
enabled: ATTRIBUTION_ENABLED_BY_DEFAULT,
|
|
}));
|
|
}
|