@hagicode/skillsbase 0.1.1 → 0.1.2
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/dist/cli.mjs
CHANGED
|
@@ -168,6 +168,21 @@ function validateSource(source) {
|
|
|
168
168
|
include: [...source.include]
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
+
function isRemoteRepositorySource(source) {
|
|
172
|
+
return source.kind === "github-repository";
|
|
173
|
+
}
|
|
174
|
+
function buildSourcePath(source, originalName) {
|
|
175
|
+
if (isRemoteRepositorySource(source)) return `${source.root}@${originalName}`;
|
|
176
|
+
return path.join(source.root, originalName);
|
|
177
|
+
}
|
|
178
|
+
function resolveSourceRoot(repoPath, source) {
|
|
179
|
+
if (isRemoteRepositorySource(source) || path.isAbsolute(source.root)) return source.root;
|
|
180
|
+
return path.resolve(repoPath, source.root);
|
|
181
|
+
}
|
|
182
|
+
function resolveSourcePath(repoPath, source, originalName) {
|
|
183
|
+
if (isRemoteRepositorySource(source)) return buildSourcePath(source, originalName);
|
|
184
|
+
return path.join(resolveSourceRoot(repoPath, source), originalName);
|
|
185
|
+
}
|
|
171
186
|
function createManifest(repoPath, options = {}) {
|
|
172
187
|
return {
|
|
173
188
|
version: 1,
|
|
@@ -300,19 +315,25 @@ async function saveManifest(manifest) {
|
|
|
300
315
|
}
|
|
301
316
|
function buildManifestEntries(manifest, repoPath = manifest.repoPath) {
|
|
302
317
|
const entries = [];
|
|
303
|
-
for (const source of manifest.sources)
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
for (const source of manifest.sources) {
|
|
319
|
+
const resolvedSourceRoot = resolveSourceRoot(repoPath, source);
|
|
320
|
+
for (const originalName of source.include ?? []) {
|
|
321
|
+
const targetName = `${source.targetPrefix ?? ""}${originalName}`;
|
|
322
|
+
entries.push({
|
|
323
|
+
sourceKey: source.key,
|
|
324
|
+
sourceLabel: source.label,
|
|
325
|
+
sourceKind: source.kind,
|
|
326
|
+
remoteSource: isRemoteRepositorySource(source),
|
|
327
|
+
sourceRoot: source.root,
|
|
328
|
+
sourcePath: buildSourcePath(source, originalName),
|
|
329
|
+
resolvedSourceRoot,
|
|
330
|
+
resolvedSourcePath: resolveSourcePath(repoPath, source, originalName),
|
|
331
|
+
originalName,
|
|
332
|
+
targetName,
|
|
333
|
+
targetPath: path.join(repoPath, manifest.skillsRoot, targetName),
|
|
334
|
+
targetPathRelative: toPosix(path.join(manifest.skillsRoot, targetName))
|
|
335
|
+
});
|
|
336
|
+
}
|
|
316
337
|
}
|
|
317
338
|
const collisions = /* @__PURE__ */ new Map();
|
|
318
339
|
for (const entry of entries) {
|
|
@@ -362,6 +383,11 @@ function buildMetadata(manifest, entry, installRecord) {
|
|
|
362
383
|
//#endregion
|
|
363
384
|
//#region src/lib/installer.ts
|
|
364
385
|
var execFile$1 = promisify(execFile);
|
|
386
|
+
function toInstallReference(entry) {
|
|
387
|
+
if (entry.remoteSource) return entry.sourcePath;
|
|
388
|
+
if (path.isAbsolute(entry.sourcePath) || entry.sourcePath.startsWith(`.${path.sep}`) || entry.sourcePath === ".") return entry.sourcePath;
|
|
389
|
+
return `.${path.sep}${entry.sourcePath}`;
|
|
390
|
+
}
|
|
365
391
|
function buildNpxArgs(manifest, subcommand, extraArgs) {
|
|
366
392
|
return [
|
|
367
393
|
"--yes",
|
|
@@ -378,6 +404,7 @@ function renderExecFailure(error) {
|
|
|
378
404
|
return String(error);
|
|
379
405
|
}
|
|
380
406
|
async function installIntoCurrentRepository(repoPath, manifest, entry, options = {}) {
|
|
407
|
+
const installReference = toInstallReference(entry);
|
|
381
408
|
const installPath = path.join(repoPath, ".agents", "skills", entry.originalName);
|
|
382
409
|
const lockPath = path.join(repoPath, "skills-lock.json");
|
|
383
410
|
const snapshot = {
|
|
@@ -385,11 +412,11 @@ async function installIntoCurrentRepository(repoPath, manifest, entry, options =
|
|
|
385
412
|
lockPath,
|
|
386
413
|
installTree: await snapshotTree(installPath),
|
|
387
414
|
lockText: await readFileIfExists(lockPath),
|
|
388
|
-
installReference
|
|
415
|
+
installReference
|
|
389
416
|
};
|
|
390
417
|
try {
|
|
391
418
|
await execFile$1("npx", buildNpxArgs(manifest, "add", [
|
|
392
|
-
|
|
419
|
+
installReference,
|
|
393
420
|
"--agent",
|
|
394
421
|
manifest.installAgent,
|
|
395
422
|
"--copy",
|
|
@@ -407,7 +434,7 @@ async function installIntoCurrentRepository(repoPath, manifest, entry, options =
|
|
|
407
434
|
return {
|
|
408
435
|
installPath,
|
|
409
436
|
lockPath,
|
|
410
|
-
installReference
|
|
437
|
+
installReference,
|
|
411
438
|
snapshot
|
|
412
439
|
};
|
|
413
440
|
}
|
|
@@ -524,14 +551,15 @@ async function convertInstalledSkill(_manifest, entry, installState) {
|
|
|
524
551
|
//#endregion
|
|
525
552
|
//#region src/lib/sync-engine.ts
|
|
526
553
|
async function assertSourceState(entry, allowMissingSources) {
|
|
527
|
-
if (
|
|
554
|
+
if (entry.remoteSource) return { skip: false };
|
|
555
|
+
if (!await pathExists(entry.resolvedSourceRoot)) {
|
|
528
556
|
if (allowMissingSources) return {
|
|
529
557
|
skip: true,
|
|
530
|
-
reason: `missing source root: ${entry.
|
|
558
|
+
reason: `missing source root: ${entry.resolvedSourceRoot}`
|
|
531
559
|
};
|
|
532
|
-
throw new CliError(`Managed source root does not exist: ${entry.
|
|
560
|
+
throw new CliError(`Managed source root does not exist: ${entry.resolvedSourceRoot}`, { details: ["Use `skillsbase sync --allow-missing-sources` to skip missing roots."] });
|
|
533
561
|
}
|
|
534
|
-
if (!await pathExists(entry.
|
|
562
|
+
if (!await pathExists(entry.resolvedSourcePath)) throw new CliError(`Managed skill is missing from source root: ${entry.resolvedSourcePath}`, { details: [`source: ${entry.sourceKey}`, `skill: ${entry.originalName}`] });
|
|
535
563
|
return { skip: false };
|
|
536
564
|
}
|
|
537
565
|
async function assertManagedTargetWritable(manifest, entry) {
|
package/package.json
CHANGED
|
@@ -26,6 +26,10 @@ runs:
|
|
|
26
26
|
shell: bash
|
|
27
27
|
run: npm ci
|
|
28
28
|
|
|
29
|
+
- name: Install skillsbase
|
|
30
|
+
shell: bash
|
|
31
|
+
run: npm install --global @hagicode/skillsbase
|
|
32
|
+
|
|
29
33
|
- name: Run tests
|
|
30
34
|
if: ${{ inputs.run-tests == 'true' }}
|
|
31
35
|
shell: bash
|
|
@@ -33,4 +37,4 @@ runs:
|
|
|
33
37
|
|
|
34
38
|
- name: Run sync check
|
|
35
39
|
shell: bash
|
|
36
|
-
run:
|
|
40
|
+
run: skillsbase sync --check --repo .
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Maintainer Workflow
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The maintainer flow is `init -> add -> sync -> github_action`.
|
|
6
6
|
|
|
7
7
|
## Lifecycle
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
## Notes
|
|
15
15
|
|
|
16
|
-
- `sources.yaml`
|
|
17
|
-
- `skills/`
|
|
18
|
-
- `.skill-source.json`
|
|
19
|
-
- `skillsbase sync --check`
|
|
20
|
-
-
|
|
16
|
+
- `sources.yaml` is the single source of truth.
|
|
17
|
+
- `skills/` stores managed output only.
|
|
18
|
+
- `.skill-source.json` records source and conversion metadata.
|
|
19
|
+
- `skillsbase sync --check` validates drift without writing files.
|
|
20
|
+
- If a source root is unavailable, use `skillsbase sync --allow-missing-sources` to skip it.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Managed Skills
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This directory contains managed skill output only.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- Every skill directory must include `SKILL.md`
|
|
8
|
+
- Every managed directory must include `.skill-source.json`
|
|
9
|
+
- Do not edit managed files by hand; make changes in `sources.yaml` and the upstream source instead
|
|
@@ -32,8 +32,11 @@ jobs:
|
|
|
32
32
|
- name: Install dependencies
|
|
33
33
|
run: npm ci
|
|
34
34
|
|
|
35
|
+
- name: Install skillsbase
|
|
36
|
+
run: npm install --global @hagicode/skillsbase
|
|
37
|
+
|
|
35
38
|
- name: Run tests
|
|
36
39
|
run: npm test
|
|
37
40
|
|
|
38
41
|
- name: Validate managed repository state
|
|
39
|
-
run:
|
|
42
|
+
run: skillsbase sync --check --repo .
|