fifony 0.1.21 → 0.1.22

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.
Files changed (37) hide show
  1. package/README.md +7 -0
  2. package/app/dist/assets/{KeyboardShortcutsHelp-BTjiQe_Y.js → KeyboardShortcutsHelp-DFstgyXD.js} +1 -1
  3. package/app/dist/assets/OnboardingWizard-Daehu2Uj.js +1 -0
  4. package/app/dist/assets/analytics.lazy-C1-iSRM_.js +1 -0
  5. package/app/dist/assets/{createLucideIcon-DtZs0TX0.js → createLucideIcon-BWC-guQt.js} +1 -1
  6. package/app/dist/assets/index-DbIrs0MK.css +1 -0
  7. package/app/dist/assets/index-O_FDwkw6.js +43 -0
  8. package/app/dist/assets/vendor-BTlTWMUF.js +9 -0
  9. package/app/dist/index.html +4 -5
  10. package/app/dist/service-worker.js +1 -1
  11. package/bin/fifony-wrap.js +53 -0
  12. package/dist/agent/cli-wrapper.js +78 -0
  13. package/dist/agent/cli-wrapper.js.map +1 -0
  14. package/dist/agent/run-local.js +93 -7889
  15. package/dist/agent/run-local.js.map +1 -1
  16. package/dist/chunk-F6JEQIP2.js +449 -0
  17. package/dist/chunk-F6JEQIP2.js.map +1 -0
  18. package/dist/{chunk-SMGXYOWU.js → chunk-O665NS5E.js} +411 -9
  19. package/dist/chunk-O665NS5E.js.map +1 -0
  20. package/dist/chunk-VP6TGOMT.js +8915 -0
  21. package/dist/chunk-VP6TGOMT.js.map +1 -0
  22. package/dist/cli.js +182 -0
  23. package/dist/cli.js.map +1 -1
  24. package/dist/issue-runner-MDCJ4G26.js +11 -0
  25. package/dist/issue-runner-MDCJ4G26.js.map +1 -0
  26. package/dist/mcp/server.js +589 -595
  27. package/dist/mcp/server.js.map +1 -1
  28. package/dist/queue-workers-LAYOT4E5.js +21 -0
  29. package/dist/queue-workers-LAYOT4E5.js.map +1 -0
  30. package/package.json +10 -9
  31. package/app/dist/assets/OnboardingWizard-BALlquG0.js +0 -1
  32. package/app/dist/assets/analytics.lazy-DjSzXIey.js +0 -1
  33. package/app/dist/assets/index-BV11ScVl.js +0 -42
  34. package/app/dist/assets/index-DWbxgKSd.css +0 -1
  35. package/app/dist/assets/vendor-BoGBoEwT.js +0 -9
  36. package/app/dist/assets/zap-DpjdVd1i.js +0 -1
  37. package/dist/chunk-SMGXYOWU.js.map +0 -1
@@ -0,0 +1,449 @@
1
+ // src/reference-repositories.ts
2
+ import { execFileSync } from "child_process";
3
+ import {
4
+ existsSync,
5
+ mkdirSync,
6
+ readdirSync,
7
+ readFileSync,
8
+ writeFileSync
9
+ } from "fs";
10
+ import { homedir } from "os";
11
+ import { basename, dirname, join, relative as relativePath, resolve } from "path";
12
+ var DEFAULT_REFERENCE_REPOSITORIES = [
13
+ {
14
+ id: "ring",
15
+ name: "LerianStudio/ring",
16
+ url: "https://github.com/LerianStudio/ring.git",
17
+ description: "Massive reference library for agents, skills, commands, and engineering standards.",
18
+ fallbackUrls: ["git@github.com:LerianStudio/ring.git"]
19
+ },
20
+ {
21
+ id: "agency-agents",
22
+ name: "msitarzewski/agency-agents",
23
+ url: "https://github.com/msitarzewski/agency-agents.git",
24
+ description: "Reference agent set focused on frontend, backend, QA, and review roles."
25
+ },
26
+ {
27
+ id: "impeccable",
28
+ name: "pbakaus/impeccable",
29
+ url: "https://github.com/pbakaus/impeccable.git",
30
+ description: "Frontend polish and impeccable-style quality workflows."
31
+ }
32
+ ];
33
+ var REPOSITORY_ROOT = resolve(homedir(), ".fifony", "repositories");
34
+ var MAX_SCAN_DEPTH = 8;
35
+ var SKIP_DIRS = /* @__PURE__ */ new Set([
36
+ ".git",
37
+ ".github",
38
+ "node_modules",
39
+ "dist",
40
+ "build",
41
+ "coverage",
42
+ "tmp",
43
+ "temp"
44
+ ]);
45
+ var AGENCY_AGENTS_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
46
+ "examples",
47
+ "strategy"
48
+ ]);
49
+ var REFERENCE_REPOSITORY_PARSERS = {
50
+ ring: collectStandardArtifacts,
51
+ "agency-agents": collectAgencyArtifacts,
52
+ impeccable: collectImpeccableArtifacts
53
+ };
54
+ function runGit(args, cwd) {
55
+ return execFileSync("git", args, {
56
+ cwd,
57
+ encoding: "utf8",
58
+ stdio: "pipe",
59
+ timeout: 12e4
60
+ }).toString().trim();
61
+ }
62
+ function slugify(value) {
63
+ const safe = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/(^-|-$)/g, "");
64
+ return safe || "reference-item";
65
+ }
66
+ function uniqueSuffix(base, used) {
67
+ if (!used.has(base)) {
68
+ used.add(base);
69
+ return base;
70
+ }
71
+ let i = 0;
72
+ while (true) {
73
+ const candidate = `${base}-${++i}`;
74
+ if (!used.has(candidate)) {
75
+ used.add(candidate);
76
+ return candidate;
77
+ }
78
+ }
79
+ }
80
+ function collectDirectoryEntries(path) {
81
+ try {
82
+ return readdirSync(path, { withFileTypes: true });
83
+ } catch {
84
+ return [];
85
+ }
86
+ }
87
+ function readRepositoryLine(path) {
88
+ try {
89
+ return runGit(["-C", path, "remote", "get-url", "origin"]);
90
+ } catch {
91
+ return void 0;
92
+ }
93
+ }
94
+ function readCurrentBranch(path) {
95
+ try {
96
+ return runGit(["-C", path, "rev-parse", "--abbrev-ref", "HEAD"]);
97
+ } catch {
98
+ return void 0;
99
+ }
100
+ }
101
+ function isMarkdownFile(value, expectedName) {
102
+ const lower = value.toLowerCase();
103
+ return lower.endsWith(".md") && lower !== expectedName;
104
+ }
105
+ function isReferenceFrontMatterFile(filePath) {
106
+ let source;
107
+ try {
108
+ source = readFileSync(filePath, "utf8");
109
+ } catch {
110
+ return false;
111
+ }
112
+ const match = source.match(/^---\r?\n([\s\S]*?)\r?\n---/);
113
+ if (!match) {
114
+ return false;
115
+ }
116
+ const header = match[1];
117
+ return /^name:\s*.+/im.test(header) && /^description:\s*.+/im.test(header);
118
+ }
119
+ function buildRelativeArtifactName(repoPath, sourcePath) {
120
+ const relative = sourcePath.startsWith(repoPath) ? relativePath(repoPath, sourcePath) : sourcePath;
121
+ const parent = dirname(relative);
122
+ const parentSlug = parent === "." ? "" : parent.split(/[/\\]/).map((segment) => slugify(segment)).filter(Boolean).join("__");
123
+ const baseName = slugify(basename(relative, ".md"));
124
+ return parentSlug ? `${parentSlug}__${baseName}` : baseName;
125
+ }
126
+ function collectAgentArtifacts(agentsDir, usedNames, out) {
127
+ const parent = slugify(basename(dirname(agentsDir)));
128
+ const entries = collectDirectoryEntries(agentsDir);
129
+ for (const entry of entries) {
130
+ const itemPath = join(agentsDir, entry.name);
131
+ if (entry.isDirectory()) {
132
+ const nestedAgentSpec = join(itemPath, "AGENT.md");
133
+ if (existsSync(nestedAgentSpec)) {
134
+ const name2 = uniqueSuffix(`${parent}__${slugify(entry.name)}`, usedNames);
135
+ out.push({ kind: "agent", sourcePath: nestedAgentSpec, targetName: name2 });
136
+ }
137
+ continue;
138
+ }
139
+ if (!isMarkdownFile(entry.name, "readme.md")) {
140
+ continue;
141
+ }
142
+ const baseName = basename(entry.name, ".md");
143
+ if (baseName.trim().length === 0 || baseName.toLowerCase() === "changelog") {
144
+ continue;
145
+ }
146
+ const name = uniqueSuffix(`${parent}__${slugify(baseName)}`, usedNames);
147
+ out.push({ kind: "agent", sourcePath: itemPath, targetName: name });
148
+ }
149
+ }
150
+ function collectSkillArtifacts(skillsDir, usedNames, out) {
151
+ const parent = slugify(basename(dirname(skillsDir)));
152
+ const entries = collectDirectoryEntries(skillsDir);
153
+ for (const entry of entries) {
154
+ const itemPath = join(skillsDir, entry.name);
155
+ if (entry.isDirectory()) {
156
+ const skillFile = join(itemPath, "SKILL.md");
157
+ if (existsSync(skillFile)) {
158
+ const name = uniqueSuffix(`${parent}__${slugify(entry.name)}`, usedNames);
159
+ out.push({ kind: "skill", sourcePath: skillFile, targetName: name });
160
+ }
161
+ continue;
162
+ }
163
+ if (entry.isFile() && entry.name.toLowerCase() === "skill.md") {
164
+ const name = uniqueSuffix(`${parent}__skill`, usedNames);
165
+ out.push({ kind: "skill", sourcePath: itemPath, targetName: name });
166
+ }
167
+ }
168
+ }
169
+ function collectStandardArtifacts(repoPath) {
170
+ const agentsUsed = /* @__PURE__ */ new Set();
171
+ const skillsUsed = /* @__PURE__ */ new Set();
172
+ const artifacts = [];
173
+ const queue = [{ path: repoPath, depth: 0 }];
174
+ while (queue.length > 0) {
175
+ const state = queue.shift();
176
+ if (!state) break;
177
+ if (state.depth > MAX_SCAN_DEPTH) {
178
+ continue;
179
+ }
180
+ const entries = collectDirectoryEntries(state.path);
181
+ for (const entry of entries) {
182
+ if (!entry.isDirectory()) continue;
183
+ if (SKIP_DIRS.has(entry.name)) continue;
184
+ const childPath = join(state.path, entry.name);
185
+ if (entry.name === "agents") {
186
+ collectAgentArtifacts(childPath, agentsUsed, artifacts);
187
+ }
188
+ if (entry.name === "skills") {
189
+ collectSkillArtifacts(childPath, skillsUsed, artifacts);
190
+ }
191
+ queue.push({ path: childPath, depth: state.depth + 1 });
192
+ }
193
+ }
194
+ return artifacts;
195
+ }
196
+ function collectAgencyArtifacts(repoPath) {
197
+ const agentsUsed = /* @__PURE__ */ new Set();
198
+ const artifacts = [];
199
+ const queue = [{ path: repoPath, depth: 0 }];
200
+ while (queue.length > 0) {
201
+ const state = queue.shift();
202
+ if (!state) break;
203
+ if (state.depth > MAX_SCAN_DEPTH) {
204
+ continue;
205
+ }
206
+ const entries = collectDirectoryEntries(state.path);
207
+ for (const entry of entries) {
208
+ if (entry.isDirectory()) {
209
+ if (SKIP_DIRS.has(entry.name) || AGENCY_AGENTS_EXCLUDED_DIRS.has(entry.name)) {
210
+ continue;
211
+ }
212
+ queue.push({ path: join(state.path, entry.name), depth: state.depth + 1 });
213
+ continue;
214
+ }
215
+ if (!isMarkdownFile(entry.name, "readme.md") || !isReferenceFrontMatterFile(join(state.path, entry.name))) {
216
+ continue;
217
+ }
218
+ const itemPath = join(state.path, entry.name);
219
+ const targetName = uniqueSuffix(buildRelativeArtifactName(repoPath, itemPath), agentsUsed);
220
+ artifacts.push({
221
+ kind: "agent",
222
+ sourcePath: itemPath,
223
+ targetName
224
+ });
225
+ }
226
+ }
227
+ return artifacts;
228
+ }
229
+ function collectImpeccableArtifacts(repoPath) {
230
+ const skillsUsed = /* @__PURE__ */ new Set();
231
+ const artifacts = [];
232
+ const sourceSkills = join(repoPath, "source", "skills");
233
+ if (existsSync(sourceSkills)) {
234
+ collectSkillArtifacts(sourceSkills, skillsUsed, artifacts);
235
+ return artifacts;
236
+ }
237
+ const claudeSkills = join(repoPath, ".claude", "skills");
238
+ if (existsSync(claudeSkills)) {
239
+ collectSkillArtifacts(claudeSkills, skillsUsed, artifacts);
240
+ }
241
+ return artifacts;
242
+ }
243
+ function collectArtifacts(repoPath, repositoryId) {
244
+ const parser = repositoryId && REFERENCE_REPOSITORY_PARSERS[repositoryId] ? REFERENCE_REPOSITORY_PARSERS[repositoryId] : collectStandardArtifacts;
245
+ return parser(repoPath);
246
+ }
247
+ function countArtifactKinds(artifacts) {
248
+ let agents = 0;
249
+ let skills = 0;
250
+ for (const artifact of artifacts) {
251
+ if (artifact.kind === "agent") {
252
+ agents += 1;
253
+ } else {
254
+ skills += 1;
255
+ }
256
+ }
257
+ return { agents, skills };
258
+ }
259
+ function getReferenceRepositoriesRoot() {
260
+ return REPOSITORY_ROOT;
261
+ }
262
+ function listReferenceRepositories() {
263
+ return DEFAULT_REFERENCE_REPOSITORIES.map((repo) => {
264
+ const path = join(REPOSITORY_ROOT, repo.id);
265
+ const status = {
266
+ id: repo.id,
267
+ name: repo.name,
268
+ url: repo.url,
269
+ path,
270
+ present: existsSync(path),
271
+ synced: false
272
+ };
273
+ if (!status.present) {
274
+ return status;
275
+ }
276
+ if (!existsSync(join(path, ".git"))) {
277
+ status.error = "Path exists but is not a git repo";
278
+ return status;
279
+ }
280
+ status.remote = readRepositoryLine(path);
281
+ status.branch = readCurrentBranch(path);
282
+ status.synced = typeof status.remote === "string";
283
+ if (status.synced) {
284
+ const artifacts = collectArtifacts(path, repo.id);
285
+ status.artifactCounts = countArtifactKinds(artifacts);
286
+ }
287
+ return status;
288
+ });
289
+ }
290
+ function resolveReferenceRepository(query) {
291
+ const normalized = query.trim().toLowerCase();
292
+ if (!normalized) return void 0;
293
+ const normalizedWithoutGit = normalized.endsWith(".git") ? normalized.slice(0, -4) : normalized;
294
+ return DEFAULT_REFERENCE_REPOSITORIES.find(
295
+ (repo) => repo.id.toLowerCase() === normalizedWithoutGit || repo.name.toLowerCase() === normalizedWithoutGit || repo.url.toLowerCase() === normalized || repo.url.toLowerCase() === normalizedWithoutGit || repo.url.toLowerCase().endsWith(`/${normalizedWithoutGit}.git`) || repo.url.toLowerCase().endsWith(`/${normalizedWithoutGit}`)
296
+ );
297
+ }
298
+ function syncReferenceRepositories(repositoryId) {
299
+ const root = REPOSITORY_ROOT;
300
+ mkdirSync(root, { recursive: true });
301
+ const repos = repositoryId ? [resolveReferenceRepository(repositoryId)] : DEFAULT_REFERENCE_REPOSITORIES;
302
+ const selected = repos.filter((repo) => Boolean(repo));
303
+ if (repositoryId && selected.length === 0) {
304
+ throw new Error(`Unknown reference repository: ${repositoryId}`);
305
+ }
306
+ const results = [];
307
+ for (const repo of selected) {
308
+ const target = join(root, repo.id);
309
+ const candidates = [repo.url, ...repo.fallbackUrls ?? []];
310
+ if (!existsSync(target)) {
311
+ let cloneError;
312
+ for (const candidate of candidates) {
313
+ try {
314
+ runGit(["clone", "--depth", "1", candidate, target]);
315
+ results.push({
316
+ id: repo.id,
317
+ path: target,
318
+ action: "cloned",
319
+ message: `Cloned ${candidate}`
320
+ });
321
+ cloneError = void 0;
322
+ break;
323
+ } catch (error) {
324
+ cloneError = error instanceof Error ? error.message : String(error);
325
+ }
326
+ }
327
+ if (cloneError) {
328
+ results.push({
329
+ id: repo.id,
330
+ path: target,
331
+ action: "failed",
332
+ message: cloneError
333
+ });
334
+ }
335
+ continue;
336
+ }
337
+ if (!existsSync(join(target, ".git"))) {
338
+ results.push({
339
+ id: repo.id,
340
+ path: target,
341
+ action: "failed",
342
+ message: "Path exists but is not a git repository"
343
+ });
344
+ continue;
345
+ }
346
+ try {
347
+ runGit(["-C", target, "fetch", "--all", "--prune"]);
348
+ runGit(["-C", target, "pull", "--ff-only"]);
349
+ results.push({
350
+ id: repo.id,
351
+ path: target,
352
+ action: "updated",
353
+ message: "Updated from remote"
354
+ });
355
+ } catch (error) {
356
+ const message = error instanceof Error ? error.message : String(error);
357
+ results.push({
358
+ id: repo.id,
359
+ path: target,
360
+ action: "failed",
361
+ message
362
+ });
363
+ }
364
+ }
365
+ return results;
366
+ }
367
+ function importReferenceArtifacts(repositoryId, workspaceRoot, options) {
368
+ const repository = resolveReferenceRepository(repositoryId);
369
+ if (!repository) {
370
+ throw new Error(`Unknown reference repository: ${repositoryId}`);
371
+ }
372
+ const localPath = join(REPOSITORY_ROOT, repository.id);
373
+ if (!existsSync(localPath)) {
374
+ throw new Error(`Repository not synced yet: ${repository.id}. Run 'fifony onboarding sync --repository ${repository.id}' first.`);
375
+ }
376
+ const basePath = resolve(workspaceRoot);
377
+ const targetBase = options.importToGlobal ? join(homedir(), ".codex") : join(basePath, ".codex");
378
+ const agentsDir = join(targetBase, "agents");
379
+ const skillsDir = join(targetBase, "skills");
380
+ const artifacts = collectArtifacts(localPath, repository.id);
381
+ const filtered = options.kind === "all" ? artifacts : artifacts.filter((artifact) => artifact.kind === options.kind.slice(0, -1));
382
+ const summary = {
383
+ repositoryId: repository.id,
384
+ localPath,
385
+ requestedKind: options.kind,
386
+ dryRun: options.dryRun,
387
+ importedAgents: [],
388
+ importedSkills: [],
389
+ skippedAgents: [],
390
+ skippedSkills: [],
391
+ errors: []
392
+ };
393
+ if (filtered.length === 0) {
394
+ return summary;
395
+ }
396
+ if (!options.dryRun) {
397
+ mkdirSync(targetBase, { recursive: true });
398
+ mkdirSync(agentsDir, { recursive: true });
399
+ mkdirSync(skillsDir, { recursive: true });
400
+ }
401
+ for (const artifact of filtered) {
402
+ try {
403
+ const source = readFileSync(artifact.sourcePath, "utf8");
404
+ if (artifact.kind === "agent") {
405
+ const target = join(agentsDir, `${artifact.targetName}.md`);
406
+ if (!options.overwrite && existsSync(target)) {
407
+ summary.skippedAgents.push(artifact.targetName);
408
+ continue;
409
+ }
410
+ if (options.dryRun) {
411
+ summary.importedAgents.push(artifact.targetName);
412
+ continue;
413
+ }
414
+ writeFileSync(target, source, "utf8");
415
+ summary.importedAgents.push(artifact.targetName);
416
+ } else {
417
+ const targetDir = join(skillsDir, artifact.targetName);
418
+ const target = join(targetDir, "SKILL.md");
419
+ if (!options.overwrite && existsSync(target)) {
420
+ summary.skippedSkills.push(artifact.targetName);
421
+ continue;
422
+ }
423
+ if (options.dryRun) {
424
+ summary.importedSkills.push(artifact.targetName);
425
+ continue;
426
+ }
427
+ mkdirSync(targetDir, { recursive: true });
428
+ writeFileSync(target, source, "utf8");
429
+ summary.importedSkills.push(artifact.targetName);
430
+ }
431
+ } catch (error) {
432
+ summary.errors.push({
433
+ kind: artifact.kind,
434
+ targetName: artifact.targetName,
435
+ error: error instanceof Error ? error.message : String(error)
436
+ });
437
+ }
438
+ }
439
+ return summary;
440
+ }
441
+
442
+ export {
443
+ collectArtifacts,
444
+ getReferenceRepositoriesRoot,
445
+ listReferenceRepositories,
446
+ syncReferenceRepositories,
447
+ importReferenceArtifacts
448
+ };
449
+ //# sourceMappingURL=chunk-F6JEQIP2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reference-repositories.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport {\n Dirent,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, dirname, join, relative as relativePath, resolve } from \"node:path\";\n\ntype ArtifactKind = \"agent\" | \"skill\";\n\ntype RepositoryReferenceInput = {\n id: string;\n name: string;\n url: string;\n description: string;\n fallbackUrls?: string[];\n};\n\nexport type ReferenceImportKind = \"all\" | \"agents\" | \"skills\";\n\nexport type ReferenceRepositoryStatus = {\n id: string;\n name: string;\n url: string;\n path: string;\n present: boolean;\n synced: boolean;\n error?: string;\n remote?: string;\n branch?: string;\n artifactCounts?: {\n agents: number;\n skills: number;\n };\n};\n\nexport type ReferenceSyncResult = {\n id: string;\n path: string;\n action: \"cloned\" | \"updated\" | \"failed\";\n message: string;\n};\n\ntype ReferenceArtifact = {\n kind: ArtifactKind;\n sourcePath: string;\n targetName: string;\n};\n\ntype ReferenceArtifactCollector = (repoPath: string) => ReferenceArtifact[];\n\nexport type ReferenceImportSummary = {\n repositoryId: string;\n localPath: string;\n requestedKind: ReferenceImportKind;\n dryRun: boolean;\n importedAgents: string[];\n importedSkills: string[];\n skippedAgents: string[];\n skippedSkills: string[];\n errors: Array<{ kind: ArtifactKind; targetName: string; error: string }>;\n};\n\nconst DEFAULT_REFERENCE_REPOSITORIES: RepositoryReferenceInput[] = [\n {\n id: \"ring\",\n name: \"LerianStudio/ring\",\n url: \"https://github.com/LerianStudio/ring.git\",\n description: \"Massive reference library for agents, skills, commands, and engineering standards.\",\n fallbackUrls: [\"git@github.com:LerianStudio/ring.git\"],\n },\n {\n id: \"agency-agents\",\n name: \"msitarzewski/agency-agents\",\n url: \"https://github.com/msitarzewski/agency-agents.git\",\n description: \"Reference agent set focused on frontend, backend, QA, and review roles.\",\n },\n {\n id: \"impeccable\",\n name: \"pbakaus/impeccable\",\n url: \"https://github.com/pbakaus/impeccable.git\",\n description: \"Frontend polish and impeccable-style quality workflows.\",\n },\n];\n\nconst REPOSITORY_ROOT = resolve(homedir(), \".fifony\", \"repositories\");\nconst MAX_SCAN_DEPTH = 8;\nconst SKIP_DIRS = new Set([\n \".git\",\n \".github\",\n \"node_modules\",\n \"dist\",\n \"build\",\n \"coverage\",\n \"tmp\",\n \"temp\",\n]);\nconst AGENCY_AGENTS_EXCLUDED_DIRS = new Set([\n \"examples\",\n \"strategy\",\n]);\n\nconst REFERENCE_REPOSITORY_PARSERS: Record<string, ReferenceArtifactCollector> = {\n ring: collectStandardArtifacts,\n \"agency-agents\": collectAgencyArtifacts,\n impeccable: collectImpeccableArtifacts,\n};\n\nfunction runGit(args: string[], cwd?: string): string {\n return execFileSync(\"git\", args, {\n cwd,\n encoding: \"utf8\",\n stdio: \"pipe\",\n timeout: 120_000,\n }).toString().trim();\n}\n\nfunction slugify(value: string): string {\n const safe = value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/-+/g, \"-\")\n .replace(/(^-|-$)/g, \"\");\n return safe || \"reference-item\";\n}\n\nfunction uniqueSuffix(base: string, used: Set<string>): string {\n if (!used.has(base)) {\n used.add(base);\n return base;\n }\n\n let i = 0;\n while (true) {\n const candidate = `${base}-${++i}`;\n if (!used.has(candidate)) {\n used.add(candidate);\n return candidate;\n }\n }\n}\n\nfunction collectDirectoryEntries(path: string): Dirent[] {\n try {\n return readdirSync(path, { withFileTypes: true });\n } catch {\n return [];\n }\n}\n\nfunction readRepositoryLine(path: string): string | undefined {\n try {\n return runGit([\"-C\", path, \"remote\", \"get-url\", \"origin\"]);\n } catch {\n return undefined;\n }\n}\n\nfunction readCurrentBranch(path: string): string | undefined {\n try {\n return runGit([\"-C\", path, \"rev-parse\", \"--abbrev-ref\", \"HEAD\"]);\n } catch {\n return undefined;\n }\n}\n\nfunction isMarkdownFile(value: string, expectedName: string): boolean {\n const lower = value.toLowerCase();\n return lower.endsWith(\".md\") && lower !== expectedName;\n}\n\nfunction isReferenceFrontMatterFile(filePath: string): boolean {\n let source: string;\n try {\n source = readFileSync(filePath, \"utf8\");\n } catch {\n return false;\n }\n\n const match = source.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/);\n if (!match) {\n return false;\n }\n\n const header = match[1];\n return /^name:\\s*.+/im.test(header) && /^description:\\s*.+/im.test(header);\n}\n\nfunction buildRelativeArtifactName(repoPath: string, sourcePath: string): string {\n const relative = sourcePath.startsWith(repoPath) ? relativePath(repoPath, sourcePath) : sourcePath;\n const parent = dirname(relative);\n const parentSlug = parent === \".\" ? \"\" : parent.split(/[/\\\\]/).map((segment) => slugify(segment)).filter(Boolean).join(\"__\");\n const baseName = slugify(basename(relative, \".md\"));\n return parentSlug ? `${parentSlug}__${baseName}` : baseName;\n}\n\nfunction collectAgentArtifacts(\n agentsDir: string,\n usedNames: Set<string>,\n out: ReferenceArtifact[],\n): void {\n const parent = slugify(basename(dirname(agentsDir)));\n const entries = collectDirectoryEntries(agentsDir);\n\n for (const entry of entries) {\n const itemPath = join(agentsDir, entry.name);\n\n if (entry.isDirectory()) {\n const nestedAgentSpec = join(itemPath, \"AGENT.md\");\n if (existsSync(nestedAgentSpec)) {\n const name = uniqueSuffix(`${parent}__${slugify(entry.name)}`, usedNames);\n out.push({ kind: \"agent\", sourcePath: nestedAgentSpec, targetName: name });\n }\n continue;\n }\n\n if (!isMarkdownFile(entry.name, \"readme.md\")) {\n continue;\n }\n\n const baseName = basename(entry.name, \".md\");\n if (baseName.trim().length === 0 || baseName.toLowerCase() === \"changelog\") {\n continue;\n }\n\n const name = uniqueSuffix(`${parent}__${slugify(baseName)}`, usedNames);\n out.push({ kind: \"agent\", sourcePath: itemPath, targetName: name });\n }\n}\n\nfunction collectSkillArtifacts(\n skillsDir: string,\n usedNames: Set<string>,\n out: ReferenceArtifact[],\n): void {\n const parent = slugify(basename(dirname(skillsDir)));\n const entries = collectDirectoryEntries(skillsDir);\n\n for (const entry of entries) {\n const itemPath = join(skillsDir, entry.name);\n if (entry.isDirectory()) {\n const skillFile = join(itemPath, \"SKILL.md\");\n if (existsSync(skillFile)) {\n const name = uniqueSuffix(`${parent}__${slugify(entry.name)}`, usedNames);\n out.push({ kind: \"skill\", sourcePath: skillFile, targetName: name });\n }\n continue;\n }\n\n if (entry.isFile() && entry.name.toLowerCase() === \"skill.md\") {\n const name = uniqueSuffix(`${parent}__skill`, usedNames);\n out.push({ kind: \"skill\", sourcePath: itemPath, targetName: name });\n }\n }\n}\n\nfunction collectStandardArtifacts(repoPath: string): ReferenceArtifact[] {\n const agentsUsed = new Set<string>();\n const skillsUsed = new Set<string>();\n const artifacts: ReferenceArtifact[] = [];\n const queue: Array<{ path: string; depth: number }> = [{ path: repoPath, depth: 0 }];\n\n while (queue.length > 0) {\n const state = queue.shift();\n if (!state) break;\n\n if (state.depth > MAX_SCAN_DEPTH) {\n continue;\n }\n\n const entries = collectDirectoryEntries(state.path);\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n if (SKIP_DIRS.has(entry.name)) continue;\n\n const childPath = join(state.path, entry.name);\n if (entry.name === \"agents\") {\n collectAgentArtifacts(childPath, agentsUsed, artifacts);\n }\n\n if (entry.name === \"skills\") {\n collectSkillArtifacts(childPath, skillsUsed, artifacts);\n }\n\n queue.push({ path: childPath, depth: state.depth + 1 });\n }\n }\n\n return artifacts;\n}\n\nfunction collectAgencyArtifacts(repoPath: string): ReferenceArtifact[] {\n const agentsUsed = new Set<string>();\n const artifacts: ReferenceArtifact[] = [];\n const queue: Array<{ path: string; depth: number }> = [{ path: repoPath, depth: 0 }];\n\n while (queue.length > 0) {\n const state = queue.shift();\n if (!state) break;\n\n if (state.depth > MAX_SCAN_DEPTH) {\n continue;\n }\n\n const entries = collectDirectoryEntries(state.path);\n for (const entry of entries) {\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name) || AGENCY_AGENTS_EXCLUDED_DIRS.has(entry.name)) {\n continue;\n }\n queue.push({ path: join(state.path, entry.name), depth: state.depth + 1 });\n continue;\n }\n\n if (!isMarkdownFile(entry.name, \"readme.md\") || !isReferenceFrontMatterFile(join(state.path, entry.name))) {\n continue;\n }\n\n const itemPath = join(state.path, entry.name);\n const targetName = uniqueSuffix(buildRelativeArtifactName(repoPath, itemPath), agentsUsed);\n artifacts.push({\n kind: \"agent\",\n sourcePath: itemPath,\n targetName,\n });\n }\n }\n\n return artifacts;\n}\n\nfunction collectImpeccableArtifacts(repoPath: string): ReferenceArtifact[] {\n const skillsUsed = new Set<string>();\n const artifacts: ReferenceArtifact[] = [];\n const sourceSkills = join(repoPath, \"source\", \"skills\");\n if (existsSync(sourceSkills)) {\n collectSkillArtifacts(sourceSkills, skillsUsed, artifacts);\n return artifacts;\n }\n\n const claudeSkills = join(repoPath, \".claude\", \"skills\");\n if (existsSync(claudeSkills)) {\n collectSkillArtifacts(claudeSkills, skillsUsed, artifacts);\n }\n\n return artifacts;\n}\n\nexport function collectArtifacts(repoPath: string, repositoryId?: string): ReferenceArtifact[] {\n const parser = repositoryId && REFERENCE_REPOSITORY_PARSERS[repositoryId]\n ? REFERENCE_REPOSITORY_PARSERS[repositoryId]\n : collectStandardArtifacts;\n return parser(repoPath);\n}\n\nfunction countArtifactKinds(artifacts: ReferenceArtifact[]): { agents: number; skills: number } {\n let agents = 0;\n let skills = 0;\n for (const artifact of artifacts) {\n if (artifact.kind === \"agent\") {\n agents += 1;\n } else {\n skills += 1;\n }\n }\n return { agents, skills };\n}\n\nexport function getReferenceRepositoriesRoot(): string {\n return REPOSITORY_ROOT;\n}\n\nexport function listReferenceRepositories(): ReferenceRepositoryStatus[] {\n return DEFAULT_REFERENCE_REPOSITORIES.map((repo) => {\n const path = join(REPOSITORY_ROOT, repo.id);\n const status: ReferenceRepositoryStatus = {\n id: repo.id,\n name: repo.name,\n url: repo.url,\n path,\n present: existsSync(path),\n synced: false,\n };\n\n if (!status.present) {\n return status;\n }\n\n if (!existsSync(join(path, \".git\"))) {\n status.error = \"Path exists but is not a git repo\";\n return status;\n }\n\n status.remote = readRepositoryLine(path);\n status.branch = readCurrentBranch(path);\n status.synced = typeof status.remote === \"string\";\n if (status.synced) {\n const artifacts = collectArtifacts(path, repo.id);\n status.artifactCounts = countArtifactKinds(artifacts);\n }\n return status;\n });\n}\n\nexport function resolveReferenceRepository(query: string): RepositoryReferenceInput | undefined {\n const normalized = query.trim().toLowerCase();\n if (!normalized) return undefined;\n const normalizedWithoutGit = normalized.endsWith(\".git\") ? normalized.slice(0, -4) : normalized;\n\n return DEFAULT_REFERENCE_REPOSITORIES.find((repo) =>\n repo.id.toLowerCase() === normalizedWithoutGit\n || repo.name.toLowerCase() === normalizedWithoutGit\n || repo.url.toLowerCase() === normalized\n || repo.url.toLowerCase() === normalizedWithoutGit\n || repo.url.toLowerCase().endsWith(`/${normalizedWithoutGit}.git`)\n || repo.url.toLowerCase().endsWith(`/${normalizedWithoutGit}`),\n );\n}\n\nexport function syncReferenceRepositories(\n repositoryId?: string,\n): ReferenceSyncResult[] {\n const root = REPOSITORY_ROOT;\n mkdirSync(root, { recursive: true });\n const repos = repositoryId\n ? [resolveReferenceRepository(repositoryId)]\n : DEFAULT_REFERENCE_REPOSITORIES;\n const selected = repos.filter((repo): repo is RepositoryReferenceInput => Boolean(repo));\n if (repositoryId && selected.length === 0) {\n throw new Error(`Unknown reference repository: ${repositoryId}`);\n }\n\n const results: ReferenceSyncResult[] = [];\n\n for (const repo of selected) {\n const target = join(root, repo.id);\n const candidates = [repo.url, ...(repo.fallbackUrls ?? [])];\n\n if (!existsSync(target)) {\n let cloneError: string | undefined;\n for (const candidate of candidates) {\n try {\n runGit([\"clone\", \"--depth\", \"1\", candidate, target]);\n results.push({\n id: repo.id,\n path: target,\n action: \"cloned\",\n message: `Cloned ${candidate}`,\n });\n cloneError = undefined;\n break;\n } catch (error) {\n cloneError = error instanceof Error ? error.message : String(error);\n }\n }\n\n if (cloneError) {\n results.push({\n id: repo.id,\n path: target,\n action: \"failed\",\n message: cloneError,\n });\n }\n continue;\n }\n\n if (!existsSync(join(target, \".git\"))) {\n results.push({\n id: repo.id,\n path: target,\n action: \"failed\",\n message: \"Path exists but is not a git repository\",\n });\n continue;\n }\n\n try {\n runGit([\"-C\", target, \"fetch\", \"--all\", \"--prune\"]);\n runGit([\"-C\", target, \"pull\", \"--ff-only\"]);\n results.push({\n id: repo.id,\n path: target,\n action: \"updated\",\n message: \"Updated from remote\",\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n results.push({\n id: repo.id,\n path: target,\n action: \"failed\",\n message,\n });\n }\n }\n\n return results;\n}\n\nexport function importReferenceArtifacts(\n repositoryId: string,\n workspaceRoot: string,\n options: {\n kind: ReferenceImportKind;\n overwrite: boolean;\n dryRun: boolean;\n importToGlobal: boolean;\n },\n): ReferenceImportSummary {\n const repository = resolveReferenceRepository(repositoryId);\n if (!repository) {\n throw new Error(`Unknown reference repository: ${repositoryId}`);\n }\n\n const localPath = join(REPOSITORY_ROOT, repository.id);\n if (!existsSync(localPath)) {\n throw new Error(`Repository not synced yet: ${repository.id}. Run 'fifony onboarding sync --repository ${repository.id}' first.`);\n }\n\n const basePath = resolve(workspaceRoot);\n const targetBase = options.importToGlobal\n ? join(homedir(), \".codex\")\n : join(basePath, \".codex\");\n\n const agentsDir = join(targetBase, \"agents\");\n const skillsDir = join(targetBase, \"skills\");\n\n const artifacts = collectArtifacts(localPath, repository.id);\n const filtered = options.kind === \"all\"\n ? artifacts\n : artifacts.filter((artifact) => artifact.kind === options.kind.slice(0, -1));\n\n const summary: ReferenceImportSummary = {\n repositoryId: repository.id,\n localPath,\n requestedKind: options.kind,\n dryRun: options.dryRun,\n importedAgents: [],\n importedSkills: [],\n skippedAgents: [],\n skippedSkills: [],\n errors: [],\n };\n\n if (filtered.length === 0) {\n return summary;\n }\n\n if (!options.dryRun) {\n mkdirSync(targetBase, { recursive: true });\n mkdirSync(agentsDir, { recursive: true });\n mkdirSync(skillsDir, { recursive: true });\n }\n\n for (const artifact of filtered) {\n try {\n const source = readFileSync(artifact.sourcePath, \"utf8\");\n if (artifact.kind === \"agent\") {\n const target = join(agentsDir, `${artifact.targetName}.md`);\n if (!options.overwrite && existsSync(target)) {\n summary.skippedAgents.push(artifact.targetName);\n continue;\n }\n if (options.dryRun) {\n summary.importedAgents.push(artifact.targetName);\n continue;\n }\n writeFileSync(target, source, \"utf8\");\n summary.importedAgents.push(artifact.targetName);\n } else {\n const targetDir = join(skillsDir, artifact.targetName);\n const target = join(targetDir, \"SKILL.md\");\n if (!options.overwrite && existsSync(target)) {\n summary.skippedSkills.push(artifact.targetName);\n continue;\n }\n if (options.dryRun) {\n summary.importedSkills.push(artifact.targetName);\n continue;\n }\n mkdirSync(targetDir, { recursive: true });\n writeFileSync(target, source, \"utf8\");\n summary.importedSkills.push(artifact.targetName);\n }\n } catch (error) {\n summary.errors.push({\n kind: artifact.kind,\n targetName: artifact.targetName,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return summary;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,UAAU,SAAS,MAAM,YAAY,cAAc,eAAe;AAyD3E,IAAM,iCAA6D;AAAA,EACjE;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,KAAK;AAAA,IACL,aAAa;AAAA,IACb,cAAc,CAAC,sCAAsC;AAAA,EACvD;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,KAAK;AAAA,IACL,aAAa;AAAA,EACf;AACF;AAEA,IAAM,kBAAkB,QAAQ,QAAQ,GAAG,WAAW,cAAc;AACpE,IAAM,iBAAiB;AACvB,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,8BAA8B,oBAAI,IAAI;AAAA,EAC1C;AAAA,EACA;AACF,CAAC;AAED,IAAM,+BAA2E;AAAA,EAC/E,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,YAAY;AACd;AAEA,SAAS,OAAO,MAAgB,KAAsB;AACpD,SAAO,aAAa,OAAO,MAAM;AAAA,IAC/B;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,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