@hagicode/skillsbase 0.1.0-dev.3.1.9e38d4f → 0.1.0-dev.6.1.7f41ada

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) for (const originalName of source.include ?? []) {
304
- const targetName = `${source.targetPrefix ?? ""}${originalName}`;
305
- entries.push({
306
- sourceKey: source.key,
307
- sourceLabel: source.label,
308
- sourceKind: source.kind,
309
- sourceRoot: source.root,
310
- sourcePath: path.join(source.root, originalName),
311
- originalName,
312
- targetName,
313
- targetPath: path.join(repoPath, manifest.skillsRoot, targetName),
314
- targetPathRelative: toPosix(path.join(manifest.skillsRoot, targetName))
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: entry.sourcePath
415
+ installReference
389
416
  };
390
417
  try {
391
418
  await execFile$1("npx", buildNpxArgs(manifest, "add", [
392
- entry.sourcePath,
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: entry.sourcePath,
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 (!await pathExists(entry.sourceRoot)) {
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.sourceRoot}`
558
+ reason: `missing source root: ${entry.resolvedSourceRoot}`
531
559
  };
532
- throw new CliError(`Managed source root does not exist: ${entry.sourceRoot}`, { details: ["Use `skillsbase sync --allow-missing-sources` to skip missing roots."] });
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.sourcePath)) throw new CliError(`Managed skill is missing from source root: ${entry.sourcePath}`, { details: [`source: ${entry.sourceKey}`, `skill: ${entry.originalName}`] });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/skillsbase",
3
- "version": "0.1.0-dev.3.1.9e38d4f",
3
+ "version": "0.1.0-dev.6.1.7f41ada",
4
4
  "description": "Managed skills repository CLI",
5
5
  "homepage": "https://github.com/HagiCode-org/skillsbase#readme",
6
6
  "bugs": {
@@ -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: node ./bin/skillsbase.mjs sync --check
40
+ run: skillsbase sync --check --repo .
@@ -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: node ./bin/skillsbase.mjs sync --check
42
+ run: skillsbase sync --check --repo .