awesome-agents 0.1.5 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/source.js CHANGED
@@ -90,6 +90,7 @@ export function normalizeGithubUrl(source) {
90
90
  export async function materializeSource(sourceInput, options = {}) {
91
91
  const home = options.home ?? os.homedir();
92
92
  const source = sourceInput;
93
+ const requireAgentProfileLayout = options.requireAgentProfileLayout ?? true;
93
94
 
94
95
  if (!source) {
95
96
  throw new Error("Specify a source. Use a local path, owner/repo, or GitHub URL.");
@@ -97,7 +98,9 @@ export async function materializeSource(sourceInput, options = {}) {
97
98
 
98
99
  if (isLocalSource(source, home)) {
99
100
  const sourcePath = path.resolve(expandHome(source, home));
100
- await assertAgentProfileLayout(sourcePath);
101
+ if (requireAgentProfileLayout) {
102
+ await assertAgentProfileLayout(sourcePath);
103
+ }
101
104
  return {
102
105
  kind: "local",
103
106
  source: sourcePath,
@@ -106,14 +109,20 @@ export async function materializeSource(sourceInput, options = {}) {
106
109
  };
107
110
  }
108
111
 
109
- const gitUrl = normalizeGithubUrl(source);
112
+ const { sourceWithoutRef, ref } = splitGitRef(source);
113
+ const gitUrl = normalizeGithubUrl(sourceWithoutRef);
110
114
  if (!gitUrl) {
111
115
  throw new Error(`Unsupported source "${source}". Use a local path, owner/repo, or GitHub URL.`);
112
116
  }
113
117
 
114
118
  const tmpRoot = options.tmpRoot ?? os.tmpdir();
115
119
  const cloneDir = await fs.mkdtemp(path.join(tmpRoot, "awesome-agents-source-"));
116
- const clone = spawnSync("git", ["clone", "--depth=1", gitUrl, cloneDir], {
120
+ const cloneArgs = ["clone", "--depth=1"];
121
+ if (ref) {
122
+ cloneArgs.push("--branch", ref);
123
+ }
124
+ cloneArgs.push(gitUrl, cloneDir);
125
+ const clone = spawnSync("git", cloneArgs, {
117
126
  encoding: "utf8"
118
127
  });
119
128
 
@@ -123,7 +132,9 @@ export async function materializeSource(sourceInput, options = {}) {
123
132
  throw new Error(`Could not clone ${source}: ${detail}`);
124
133
  }
125
134
 
126
- await assertAgentProfileLayout(cloneDir);
135
+ if (requireAgentProfileLayout) {
136
+ await assertAgentProfileLayout(cloneDir);
137
+ }
127
138
 
128
139
  return {
129
140
  kind: "git",
@@ -136,6 +147,17 @@ export async function materializeSource(sourceInput, options = {}) {
136
147
  };
137
148
  }
138
149
 
150
+ function splitGitRef(source) {
151
+ const hashIndex = source.lastIndexOf("#");
152
+ if (hashIndex <= 0 || hashIndex === source.length - 1) {
153
+ return { sourceWithoutRef: source, ref: undefined };
154
+ }
155
+ return {
156
+ sourceWithoutRef: source.slice(0, hashIndex),
157
+ ref: source.slice(hashIndex + 1)
158
+ };
159
+ }
160
+
139
161
  async function assertAgentProfileLayout(sourcePath) {
140
162
  const entries = await discoverProfileEntries(sourcePath);
141
163
  if (entries.length === 0) {