AS AgentScopeAPI 手册 / API Reference

GitSkillRepository

public class GitSkillRepository implements AgentSkillRepository
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:101–804

Git 技能仓库,负责持久化与读取数据。位于 io.agentscope.core.skill.repository 包,实现 AgentSkillRepository。核心成员包括 getSkill、getAllSkillNames、getAllSkills、skillExists、sync、save。

Git-based read-only implementation of AgentSkillRepository.

This repository clones a remote Git repository to a local temporary directory and accesses skills directly from the file system. Synchronization is triggered on read operations (#getSkill(String), #getAllSkillNames(), #getAllSkills(), #skillExists(String)).

Each read performs a lightweight remote reference check; a pull is only executed when the remote HEAD changes, keeping freshness with minimal network overhead.

Auto-sync can be disabled via constructors that accept autoSync=false. When disabled, call #sync() to initialize and refresh before read operations.

Features:

  • Read-only access to Git repositories

  • Automatic synchronization on each read operation

  • Support for both HTTPS and SSH URLs

  • Branch selection support

  • Progress logging for Git operations

  • Automatic cleanup of temporary directories

Authentication: This implementation relies on system-level Git configuration for authentication:

  • HTTPS: Uses credentials from ~/.gitconfig or credential helpers

  • SSH: Uses SSH keys from ~/.ssh/ and ssh-agent

Usage Examples:

`// Public repository with default branch
GitSkillRepository repo = new GitSkillRepository(
"https://github.com/agentscope/skills.git"
);
AgentSkill skill = repo.getSkill("calculator");
repo.close();

// Specify a branch
GitSkillRepository repo = new GitSkillRepository(
"https://github.com/agentscope/skills.git",
"develop"
);

// Private repository (requires system Git credentials)
GitSkillRepository repo = new GitSkillRepository(
"git@github.com:myorg/private-skills.git"
);
`

Temporary Directory: Uses Files#createTempDirectory(String, java.nio.file.attribute.FileAttribute[]) to create a temporary directory. The directory is automatically cleaned up on JVM shutdown or when #close() is called.

构造器摘要Constructor Summary

构造器Constructor说明Description
public GitSkillRepository(String remoteUrl)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL using the default branch.
public GitSkillRepository(String remoteUrl, Path localPath)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL and local path.
public GitSkillRepository(String remoteUrl, String branch)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL and branch.
public GitSkillRepository(String remoteUrl, Path localPath, String source)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL, local path, and source.
public GitSkillRepository(String remoteUrl, String branch, Path localPath)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL, branch, and local path.
public GitSkillRepository(String remoteUrl, boolean autoSync)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL and auto-update option.
public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL, branch, local path, and source.
public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source, boolean autoSync)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with the specified remote URL, branch, local path, source, and auto-update option.
public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source, boolean autoSync, String skillsRoot)
初始化 `GitSkillRepository` 实例。
Creates a GitSkillRepository with an explicit in-repo skills root directory.

方法摘要Method Summary

方法Method说明Description
public AgentSkill getSkill(String name)
获取技能。
Returns the skill.
public List<String> getAllSkillNames()
获取 `getAllSkillNames`。
Returns the all skill names.
public List<AgentSkill> getAllSkills()
获取所有技能。
Returns the all skills.
public boolean skillExists(String skillName)
设置该参数。
Performs the skill exists operation.
public void sync()
执行同步相关操作。
Triggers a manual synchronization of the repository.
public boolean save(List<AgentSkill> skills, boolean force)
保存数据到持久化存储。
Performs the save operation.
public boolean delete(String skillName)
删除数据。
Performs the delete operation.
public void setWriteable(boolean writeable)
设置 `setWriteable`。
Sets the writeable.
public boolean isWriteable()
判断是否 `isWriteable`。
Returns whether the writeable.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
public AgentSkillRepositoryInfo getRepositoryInfo()
获取仓库信息。
Returns the repository info.
public String getSource()
获取来源。
Returns the source.

构造器详情Constructor Detail

GitSkillRepository

public GitSkillRepository(String remoteUrl)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL using the default branch.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:123–125

GitSkillRepository

public GitSkillRepository(String remoteUrl, Path localPath)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL and local path.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:135–137

GitSkillRepository

public GitSkillRepository(String remoteUrl, String branch)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL and branch.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
branchStringbranch(类型 `String`)。The branch name to clone (null for remote default branch)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:147–149

GitSkillRepository

public GitSkillRepository(String remoteUrl, Path localPath, String source)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL, local path, and source.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:160–162

GitSkillRepository

public GitSkillRepository(String remoteUrl, String branch, Path localPath)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL, branch, and local path.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
branchStringbranch(类型 `String`)。The branch name to clone (null for remote default branch)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:173–175

GitSkillRepository

public GitSkillRepository(String remoteUrl, boolean autoSync)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL and auto-update option.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
autoSyncbooleanauto 同步(类型 `boolean`)。Whether to auto-sync on read operations
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:185–187

GitSkillRepository

public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL, branch, local path, and source.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
branchStringbranch(类型 `String`)。The branch name to clone (null for remote default branch)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:199–201

GitSkillRepository

public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source, boolean autoSync)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with the specified remote URL, branch, local path, source, and auto-update option.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
branchStringbranch(类型 `String`)。The branch name to clone (null for remote default branch)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
autoSyncbooleanauto 同步(类型 `boolean`)。Whether to auto-sync on read operations
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if remoteUrl is null or empty
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:215–218

GitSkillRepository

public GitSkillRepository(String remoteUrl, String branch, Path localPath, String source, boolean autoSync, String skillsRoot)

初始化 GitSkillRepository 实例。

Creates a GitSkillRepository with an explicit in-repo skills root directory.

参数Parameters
名称Name类型Type说明Description
remoteUrlString远程 URL(类型 `String`)。The Git repository URL (HTTPS or SSH)
branchStringbranch(类型 `String`)。The branch name to clone (null for remote default branch)
localPathPath本地路径(类型 `Path`)。The local path to clone the repository (null to use temporary directory)
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
autoSyncbooleanauto 同步(类型 `boolean`)。Whether to auto-sync on read operations
skillsRootString技能根(类型 `String`)。Optional in-repo subdirectory containing skill folders
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if `remoteUrl` is blank, or `skillsRoot` is absolute / contains a `..` segment / would escape the repo root
  • RuntimeException 可能抛出 `RuntimeException`。if temporary directory creation fails
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:239–275

方法详情Method Detail

getSkill

public AgentSkill getSkill(String name)

获取技能。

Returns the skill.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
返回Returns AgentSkill
返回AgentSkill。Returns agent skill.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:277–281

getAllSkillNames

public List<String> getAllSkillNames()

获取 getAllSkillNames。

Returns the all skill names.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:283–287

getAllSkills

public List<AgentSkill> getAllSkills()

获取所有技能。

Returns the all skills.

返回Returns List<AgentSkill>
返回列出。Returns list.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:289–293

skillExists

public boolean skillExists(String skillName)

设置该参数。

Performs the skill exists operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:295–299

sync

public void sync()

执行同步相关操作。

Triggers a manual synchronization of the repository.

源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:304–306

save

public boolean save(List<AgentSkill> skills, boolean force)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
skillsList<AgentSkill>技能(类型 `List`)。The skills.
forcebooleanforce(类型 `boolean`)。The force.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:308–312

delete

public boolean delete(String skillName)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:314–318

setWriteable

public void setWriteable(boolean writeable)

设置 setWriteable。

Sets the writeable.

参数Parameters
名称Name类型Type说明Description
writeablebooleanwriteable(类型 `boolean`)。The writeable.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:320–323

isWriteable

public boolean isWriteable()

判断是否 isWriteable。

Returns whether the writeable.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:325–328

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:330–355

getRepositoryInfo

public AgentSkillRepositoryInfo getRepositoryInfo()

获取仓库信息。

Returns the repository info.

返回Returns AgentSkillRepositoryInfo
返回AgentSkillRepositoryInfo。Returns agent skill repository info.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:357–360

getSource

public String getSource()

获取来源。

Returns the source.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/skill/repository/GitSkillRepository.java:362–365
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.