genomic 5.4.0 → 5.6.0
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/esm/index.js +2 -0
- package/esm/skills/skill-installer.js +111 -0
- package/esm/skills/types.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +2 -2
- package/scaffolder/types.d.ts +16 -0
- package/skills/skill-installer.d.ts +37 -0
- package/skills/skill-installer.js +148 -0
- package/skills/types.d.ts +33 -0
- package/skills/types.js +2 -0
package/esm/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export * from './git/git-cloner';
|
|
|
13
13
|
export * from './git/types';
|
|
14
14
|
export * from './scaffolder/template-scaffolder';
|
|
15
15
|
export * from './scaffolder/types';
|
|
16
|
+
export * from './skills/skill-installer';
|
|
17
|
+
export * from './skills/types';
|
|
16
18
|
export * from './template/templatizer';
|
|
17
19
|
export * from './template/types';
|
|
18
20
|
export * from './utils/npm-version-check';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { CacheManager } from '../cache/cache-manager';
|
|
4
|
+
import { GitCloner } from '../git/git-cloner';
|
|
5
|
+
const DEFAULT_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
6
|
+
const SKILLS_DIR = path.join('.agents', 'skills');
|
|
7
|
+
/**
|
|
8
|
+
* Installs skills from git repositories using shallow clones.
|
|
9
|
+
*
|
|
10
|
+
* Much faster than `npx skills add` because it:
|
|
11
|
+
* - Clones with `--depth 1` (shallow)
|
|
12
|
+
* - Caches source repos (subsequent installs are instant)
|
|
13
|
+
* - Copies skill directories directly (no npm download)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const installer = new SkillInstaller({ toolName: 'pgpm' });
|
|
18
|
+
* const result = installer.install(
|
|
19
|
+
* [{ source: 'constructive-io/constructive', skills: ['pgpm'] }],
|
|
20
|
+
* '/path/to/workspace'
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class SkillInstaller {
|
|
25
|
+
gitCloner;
|
|
26
|
+
cacheManager;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.gitCloner = new GitCloner();
|
|
29
|
+
this.cacheManager = new CacheManager({
|
|
30
|
+
toolName: options?.toolName ?? 'genomic',
|
|
31
|
+
ttl: options?.cacheTtlMs ?? DEFAULT_TTL_MS,
|
|
32
|
+
baseDir: options?.cacheBaseDir,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Install skills from their source repositories into a target directory.
|
|
37
|
+
*
|
|
38
|
+
* For each skill entry, clones the source repo (shallow, cached) and
|
|
39
|
+
* copies `.agents/skills/<name>/` into `<targetDir>/.agents/skills/<name>/`.
|
|
40
|
+
*
|
|
41
|
+
* Non-fatal: failures are collected and returned, never thrown.
|
|
42
|
+
*/
|
|
43
|
+
install(skills, targetDir) {
|
|
44
|
+
const installed = [];
|
|
45
|
+
const failed = [];
|
|
46
|
+
// Group skills by source to avoid cloning the same repo multiple times
|
|
47
|
+
const bySource = new Map();
|
|
48
|
+
for (const entry of skills) {
|
|
49
|
+
const existing = bySource.get(entry.source) ?? [];
|
|
50
|
+
existing.push(...entry.skills);
|
|
51
|
+
bySource.set(entry.source, existing);
|
|
52
|
+
}
|
|
53
|
+
for (const [source, skillNames] of bySource) {
|
|
54
|
+
let repoDir;
|
|
55
|
+
try {
|
|
56
|
+
repoDir = this.ensureRepo(source);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
60
|
+
for (const skill of skillNames) {
|
|
61
|
+
failed.push({ skill, source, error: msg });
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
for (const skillName of skillNames) {
|
|
66
|
+
const sourcePath = path.join(repoDir, SKILLS_DIR, skillName);
|
|
67
|
+
if (!fs.existsSync(sourcePath)) {
|
|
68
|
+
failed.push({
|
|
69
|
+
skill: skillName,
|
|
70
|
+
source,
|
|
71
|
+
error: `Skill not found in source: ${SKILLS_DIR}/${skillName}`,
|
|
72
|
+
});
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const destPath = path.join(targetDir, SKILLS_DIR, skillName);
|
|
77
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
78
|
+
fs.cpSync(sourcePath, destPath, { recursive: true });
|
|
79
|
+
installed.push(skillName);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
83
|
+
failed.push({ skill: skillName, source, error: msg });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { installed, failed };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Clone (or retrieve from cache) a skill source repository.
|
|
91
|
+
*/
|
|
92
|
+
ensureRepo(source) {
|
|
93
|
+
const url = this.gitCloner.normalizeUrl(source);
|
|
94
|
+
const cacheKey = this.cacheManager.createKey(url);
|
|
95
|
+
const expiredMetadata = this.cacheManager.checkExpiration(cacheKey);
|
|
96
|
+
if (expiredMetadata) {
|
|
97
|
+
this.cacheManager.clear(cacheKey);
|
|
98
|
+
}
|
|
99
|
+
const cached = this.cacheManager.get(cacheKey);
|
|
100
|
+
if (cached && !expiredMetadata) {
|
|
101
|
+
return cached;
|
|
102
|
+
}
|
|
103
|
+
const dest = path.join(this.cacheManager.getReposDir(), cacheKey);
|
|
104
|
+
this.gitCloner.clone(url, dest, {
|
|
105
|
+
depth: 1,
|
|
106
|
+
singleBranch: true,
|
|
107
|
+
});
|
|
108
|
+
this.cacheManager.set(cacheKey, dest);
|
|
109
|
+
return dest;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './git/git-cloner';
|
|
|
8
8
|
export * from './git/types';
|
|
9
9
|
export * from './scaffolder/template-scaffolder';
|
|
10
10
|
export * from './scaffolder/types';
|
|
11
|
+
export * from './skills/skill-installer';
|
|
12
|
+
export * from './skills/types';
|
|
11
13
|
export * from './template/templatizer';
|
|
12
14
|
export * from './template/types';
|
|
13
15
|
export * from './utils/npm-version-check';
|
package/index.js
CHANGED
|
@@ -34,6 +34,8 @@ __exportStar(require("./git/git-cloner"), exports);
|
|
|
34
34
|
__exportStar(require("./git/types"), exports);
|
|
35
35
|
__exportStar(require("./scaffolder/template-scaffolder"), exports);
|
|
36
36
|
__exportStar(require("./scaffolder/types"), exports);
|
|
37
|
+
__exportStar(require("./skills/skill-installer"), exports);
|
|
38
|
+
__exportStar(require("./skills/types"), exports);
|
|
37
39
|
__exportStar(require("./template/templatizer"), exports);
|
|
38
40
|
__exportStar(require("./template/types"), exports);
|
|
39
41
|
__exportStar(require("./utils/npm-version-check"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genomic",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Clone and customize template repositories with variable replacement",
|
|
6
6
|
"main": "index.js",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"makage": "0.1.10"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "41f18174985956b7f62ecfaa999ec428299d9a84"
|
|
40
40
|
}
|
package/scaffolder/types.d.ts
CHANGED
|
@@ -117,6 +117,16 @@ export interface BoilerplatesConfig {
|
|
|
117
117
|
*/
|
|
118
118
|
dir?: string;
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Declares a skill to install after scaffolding completes.
|
|
122
|
+
* Used with the agentskills.io CLI (`npx skills add <source> --skill <name>`).
|
|
123
|
+
*/
|
|
124
|
+
export interface BoilerplateSkill {
|
|
125
|
+
/** GitHub repository in org/repo format, or a full URL */
|
|
126
|
+
source: string;
|
|
127
|
+
/** Skill name(s) to install from the source */
|
|
128
|
+
skills: string[];
|
|
129
|
+
}
|
|
120
130
|
/**
|
|
121
131
|
* Configuration for a single boilerplate template.
|
|
122
132
|
* Stored in `.boilerplate.json` within each template directory.
|
|
@@ -130,6 +140,12 @@ export interface BoilerplateConfig {
|
|
|
130
140
|
* Questions to prompt the user during scaffolding
|
|
131
141
|
*/
|
|
132
142
|
questions?: Question[];
|
|
143
|
+
/**
|
|
144
|
+
* Skills to install after scaffolding completes.
|
|
145
|
+
* Each entry specifies a source repository and skill names to install.
|
|
146
|
+
* Non-fatal: callers should handle install failures gracefully.
|
|
147
|
+
*/
|
|
148
|
+
skills?: BoilerplateSkill[];
|
|
133
149
|
}
|
|
134
150
|
/**
|
|
135
151
|
* Options for inspecting a template without scaffolding.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BoilerplateSkill } from '../scaffolder/types';
|
|
2
|
+
import { SkillInstallOptions, SkillInstallResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Installs skills from git repositories using shallow clones.
|
|
5
|
+
*
|
|
6
|
+
* Much faster than `npx skills add` because it:
|
|
7
|
+
* - Clones with `--depth 1` (shallow)
|
|
8
|
+
* - Caches source repos (subsequent installs are instant)
|
|
9
|
+
* - Copies skill directories directly (no npm download)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const installer = new SkillInstaller({ toolName: 'pgpm' });
|
|
14
|
+
* const result = installer.install(
|
|
15
|
+
* [{ source: 'constructive-io/constructive', skills: ['pgpm'] }],
|
|
16
|
+
* '/path/to/workspace'
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class SkillInstaller {
|
|
21
|
+
private gitCloner;
|
|
22
|
+
private cacheManager;
|
|
23
|
+
constructor(options?: SkillInstallOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Install skills from their source repositories into a target directory.
|
|
26
|
+
*
|
|
27
|
+
* For each skill entry, clones the source repo (shallow, cached) and
|
|
28
|
+
* copies `.agents/skills/<name>/` into `<targetDir>/.agents/skills/<name>/`.
|
|
29
|
+
*
|
|
30
|
+
* Non-fatal: failures are collected and returned, never thrown.
|
|
31
|
+
*/
|
|
32
|
+
install(skills: BoilerplateSkill[], targetDir: string): SkillInstallResult;
|
|
33
|
+
/**
|
|
34
|
+
* Clone (or retrieve from cache) a skill source repository.
|
|
35
|
+
*/
|
|
36
|
+
private ensureRepo;
|
|
37
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SkillInstaller = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const cache_manager_1 = require("../cache/cache-manager");
|
|
40
|
+
const git_cloner_1 = require("../git/git-cloner");
|
|
41
|
+
const DEFAULT_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
42
|
+
const SKILLS_DIR = path.join('.agents', 'skills');
|
|
43
|
+
/**
|
|
44
|
+
* Installs skills from git repositories using shallow clones.
|
|
45
|
+
*
|
|
46
|
+
* Much faster than `npx skills add` because it:
|
|
47
|
+
* - Clones with `--depth 1` (shallow)
|
|
48
|
+
* - Caches source repos (subsequent installs are instant)
|
|
49
|
+
* - Copies skill directories directly (no npm download)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const installer = new SkillInstaller({ toolName: 'pgpm' });
|
|
54
|
+
* const result = installer.install(
|
|
55
|
+
* [{ source: 'constructive-io/constructive', skills: ['pgpm'] }],
|
|
56
|
+
* '/path/to/workspace'
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
class SkillInstaller {
|
|
61
|
+
gitCloner;
|
|
62
|
+
cacheManager;
|
|
63
|
+
constructor(options) {
|
|
64
|
+
this.gitCloner = new git_cloner_1.GitCloner();
|
|
65
|
+
this.cacheManager = new cache_manager_1.CacheManager({
|
|
66
|
+
toolName: options?.toolName ?? 'genomic',
|
|
67
|
+
ttl: options?.cacheTtlMs ?? DEFAULT_TTL_MS,
|
|
68
|
+
baseDir: options?.cacheBaseDir,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Install skills from their source repositories into a target directory.
|
|
73
|
+
*
|
|
74
|
+
* For each skill entry, clones the source repo (shallow, cached) and
|
|
75
|
+
* copies `.agents/skills/<name>/` into `<targetDir>/.agents/skills/<name>/`.
|
|
76
|
+
*
|
|
77
|
+
* Non-fatal: failures are collected and returned, never thrown.
|
|
78
|
+
*/
|
|
79
|
+
install(skills, targetDir) {
|
|
80
|
+
const installed = [];
|
|
81
|
+
const failed = [];
|
|
82
|
+
// Group skills by source to avoid cloning the same repo multiple times
|
|
83
|
+
const bySource = new Map();
|
|
84
|
+
for (const entry of skills) {
|
|
85
|
+
const existing = bySource.get(entry.source) ?? [];
|
|
86
|
+
existing.push(...entry.skills);
|
|
87
|
+
bySource.set(entry.source, existing);
|
|
88
|
+
}
|
|
89
|
+
for (const [source, skillNames] of bySource) {
|
|
90
|
+
let repoDir;
|
|
91
|
+
try {
|
|
92
|
+
repoDir = this.ensureRepo(source);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
96
|
+
for (const skill of skillNames) {
|
|
97
|
+
failed.push({ skill, source, error: msg });
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
for (const skillName of skillNames) {
|
|
102
|
+
const sourcePath = path.join(repoDir, SKILLS_DIR, skillName);
|
|
103
|
+
if (!fs.existsSync(sourcePath)) {
|
|
104
|
+
failed.push({
|
|
105
|
+
skill: skillName,
|
|
106
|
+
source,
|
|
107
|
+
error: `Skill not found in source: ${SKILLS_DIR}/${skillName}`,
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const destPath = path.join(targetDir, SKILLS_DIR, skillName);
|
|
113
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
114
|
+
fs.cpSync(sourcePath, destPath, { recursive: true });
|
|
115
|
+
installed.push(skillName);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
119
|
+
failed.push({ skill: skillName, source, error: msg });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return { installed, failed };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Clone (or retrieve from cache) a skill source repository.
|
|
127
|
+
*/
|
|
128
|
+
ensureRepo(source) {
|
|
129
|
+
const url = this.gitCloner.normalizeUrl(source);
|
|
130
|
+
const cacheKey = this.cacheManager.createKey(url);
|
|
131
|
+
const expiredMetadata = this.cacheManager.checkExpiration(cacheKey);
|
|
132
|
+
if (expiredMetadata) {
|
|
133
|
+
this.cacheManager.clear(cacheKey);
|
|
134
|
+
}
|
|
135
|
+
const cached = this.cacheManager.get(cacheKey);
|
|
136
|
+
if (cached && !expiredMetadata) {
|
|
137
|
+
return cached;
|
|
138
|
+
}
|
|
139
|
+
const dest = path.join(this.cacheManager.getReposDir(), cacheKey);
|
|
140
|
+
this.gitCloner.clone(url, dest, {
|
|
141
|
+
depth: 1,
|
|
142
|
+
singleBranch: true,
|
|
143
|
+
});
|
|
144
|
+
this.cacheManager.set(cacheKey, dest);
|
|
145
|
+
return dest;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.SkillInstaller = SkillInstaller;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface SkillInstallOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Tool name for cache directory naming (e.g., 'pgpm' -> ~/.pgpm/cache).
|
|
4
|
+
* Sharing the same toolName as your TemplateScaffolder means skills
|
|
5
|
+
* and templates share the same cache directory.
|
|
6
|
+
* @default 'genomic'
|
|
7
|
+
*/
|
|
8
|
+
toolName?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Cache TTL in milliseconds for cloned skill source repos.
|
|
11
|
+
* @default 7 days
|
|
12
|
+
*/
|
|
13
|
+
cacheTtlMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Base directory for cache storage.
|
|
16
|
+
* Useful for tests to avoid touching the real home directory.
|
|
17
|
+
*/
|
|
18
|
+
cacheBaseDir?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SkillInstallResult {
|
|
21
|
+
/** Successfully installed skill names */
|
|
22
|
+
installed: string[];
|
|
23
|
+
/** Skills that failed to install */
|
|
24
|
+
failed: SkillInstallFailure[];
|
|
25
|
+
}
|
|
26
|
+
export interface SkillInstallFailure {
|
|
27
|
+
/** Skill name that failed */
|
|
28
|
+
skill: string;
|
|
29
|
+
/** Source repository */
|
|
30
|
+
source: string;
|
|
31
|
+
/** Error description */
|
|
32
|
+
error: string;
|
|
33
|
+
}
|
package/skills/types.js
ADDED