Source

Struct Source 

Source
pub struct Source {
    pub name: String,
    pub url: String,
    pub description: Option<String>,
    pub enabled: bool,
    pub local_path: Option<PathBuf>,
}
Expand description

Represents a Git repository source containing Claude Code resources.

A Source defines a repository location and metadata for accessing Claude Code resources like agents and snippets. Sources can be remote repositories (GitHub, GitLab, etc.) or local file paths, and support various authentication mechanisms.

§Fields

  • name: Unique identifier for the source (used in manifests and commands)
  • url: Repository location (HTTPS, SSH, file://, or local path)
  • description: Optional human-readable description
  • enabled: Whether this source should be used for operations
  • local_path: Runtime cache location (not serialized, set during sync operations)

§Repository URL Formats

§Remote Repositories

  • HTTPS: https://github.com/owner/repo.git
  • SSH: git@github.com:owner/repo.git
  • HTTPS with auth: https://token@github.com/owner/repo.git

§Local Repositories

  • Absolute path: /path/to/repository
  • Relative path: ../relative/path or ./local-path
  • File URL: file:///absolute/path/to/repository

§Security Considerations

Authentication tokens should never be stored in Source instances that are serialized to project manifests. Use the global configuration for credentials.

§Examples

use agpm_cli::source::Source;

// Public repository
let source = Source::new(
    "community".to_string(),
    "https://github.com/example/agpm-community.git".to_string()
).with_description("Community resources".to_string());

// Local development repository
let local = Source::new(
    "local-dev".to_string(),
    "/path/to/local/repo".to_string()
);

Fields§

§name: String

Unique identifier for this source

§url: String

Repository URL or local path

§description: Option<String>

Optional human-readable description

§enabled: bool

Whether this source is enabled for operations

§local_path: Option<PathBuf>

Runtime path to cached repository (not serialized)

Implementations§

Source§

impl Source

Source

pub const fn new(name: String, url: String) -> Self

Creates a new source with the given name and URL.

The source is created with default settings:

  • No description
  • Enabled by default
  • No local path (will be set during sync operations)
§Arguments
  • name - Unique identifier for this source
  • url - Repository URL or local path
§Examples
use agpm_cli::source::Source;

let source = Source::new(
    "official".to_string(),
    "https://github.com/example/agpm-official.git".to_string()
);

assert_eq!(source.name, "official");
assert!(source.enabled);
assert!(source.description.is_none());
Source

pub fn with_description(self, desc: String) -> Self

Adds a human-readable description to this source.

This is a builder pattern method that consumes the source and returns it with the description field set. Descriptions help users understand the purpose and contents of each source.

§Arguments
  • desc - Human-readable description of the source
§Examples
use agpm_cli::source::Source;

let source = Source::new(
    "community".to_string(),
    "https://github.com/example/agpm-community.git".to_string()
).with_description("Community-contributed agents and snippets".to_string());

assert_eq!(source.description, Some("Community-contributed agents and snippets".to_string()));
Source

pub fn cache_dir(&self, base_dir: &Path) -> PathBuf

Generates the cache directory path for this source.

Creates a unique cache directory name based on the repository URL to avoid conflicts between sources. The directory name follows the pattern {owner}_{repo} parsed from the Git URL.

§Cache Directory Structure
  • For https://github.com/owner/repo.git{base_dir}/sources/owner_repo
  • For invalid URLs → {base_dir}/sources/unknown_{source_name}
§Arguments
  • base_dir - Base cache directory (typically ~/.agpm/cache)
§Returns

PathBuf pointing to the cache directory for this source

§Examples
use agpm_cli::source::Source;
use std::path::Path;

let source = Source::new(
    "community".to_string(),
    "https://github.com/example/agpm-community.git".to_string()
);

let base_dir = Path::new("/home/user/.agpm/cache");
let cache_dir = source.cache_dir(base_dir);

assert_eq!(
    cache_dir,
    Path::new("/home/user/.agpm/cache/sources/example_agpm-community")
);

Trait Implementations§

Source§

impl Clone for Source

Source§

fn clone(&self) -> Source

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Source

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Source

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Source

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Source

§

impl RefUnwindSafe for Source

§

impl Send for Source

§

impl Sync for Source

§

impl Unpin for Source

§

impl UnwindSafe for Source

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,