@hagicode/skillsbase 0.1.2 → 0.1.3
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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/bin/skillsbase.mjs +0 -0
- package/dist/cli.mjs +157 -45
- package/package.json +1 -1
- package/templates/actions/skillsbase-manage/action.yml +96 -0
- package/templates/actions/skillsbase-sync/action.yml +4 -0
- package/templates/docs/maintainer-workflow.md +14 -2
- package/templates/workflows/skills-manage.yml +54 -0
- package/templates/workflows/skills-sync.yml +3 -15
package/README.md
CHANGED
|
@@ -48,6 +48,12 @@ Add one skill and sync immediately:
|
|
|
48
48
|
skillsbase add documentation-writer --repo /path/to/target-repo
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
Remove one skill and sync immediately:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
skillsbase remove documentation-writer --repo /path/to/target-repo
|
|
55
|
+
```
|
|
56
|
+
|
|
51
57
|
Generate managed GitHub Actions assets:
|
|
52
58
|
|
|
53
59
|
```bash
|
|
@@ -62,6 +68,7 @@ skillsbase github_action --repo /path/to/target-repo --kind all
|
|
|
62
68
|
| `sync` | Reconcile managed skills from `sources.yaml`. | `skillsbase sync --repo ./my-skills-repo` |
|
|
63
69
|
| `sync --check` | Validate drift without writing files. | `skillsbase sync --check --repo ./my-skills-repo` |
|
|
64
70
|
| `add <skill-name>` | Add a skill to a source block, then run sync. | `skillsbase add documentation-writer --repo ./my-skills-repo` |
|
|
71
|
+
| `remove <skill-name>` | Remove a skill from a source block, then run sync. | `skillsbase remove documentation-writer --repo ./my-skills-repo` |
|
|
65
72
|
| `github_action` | Generate managed GitHub Actions workflow or action files. | `skillsbase github_action --repo ./my-skills-repo --kind workflow` |
|
|
66
73
|
|
|
67
74
|
Global options:
|
|
@@ -88,6 +95,8 @@ Global options:
|
|
|
88
95
|
- first-party: `$HOME/.agents/skills`
|
|
89
96
|
- system: `$HOME/.codex/skills/.system`
|
|
90
97
|
- `add` writes to the first declared source block unless `--source <key>` is provided.
|
|
98
|
+
- `remove` deletes from the only matching source block automatically; if multiple source blocks include the same skill, pass `--source <key>`.
|
|
99
|
+
- `add`, `remove`, and `sync` accept `--allow-missing-sources` to keep path-resolution behavior consistent in CI or repo-external execution.
|
|
91
100
|
- `github_action` defaults to `--kind workflow`.
|
|
92
101
|
- When the CLI does not have enough context to write safely, it fails with diagnostics instead of prompting interactively.
|
|
93
102
|
|
package/README.zh-CN.md
CHANGED
|
@@ -48,6 +48,12 @@ skillsbase sync --repo /path/to/target-repo
|
|
|
48
48
|
skillsbase add documentation-writer --repo /path/to/target-repo
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
删除单个技能并立即同步:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
skillsbase remove documentation-writer --repo /path/to/target-repo
|
|
55
|
+
```
|
|
56
|
+
|
|
51
57
|
生成受管 GitHub Actions 资产:
|
|
52
58
|
|
|
53
59
|
```bash
|
|
@@ -62,6 +68,7 @@ skillsbase github_action --repo /path/to/target-repo --kind all
|
|
|
62
68
|
| `sync` | 按 `sources.yaml` 对账并同步技能 | `skillsbase sync --repo ./my-skills-repo` |
|
|
63
69
|
| `sync --check` | 只校验漂移,不写文件 | `skillsbase sync --check --repo ./my-skills-repo` |
|
|
64
70
|
| `add <skill-name>` | 将技能写入 source block 后执行同步 | `skillsbase add documentation-writer --repo ./my-skills-repo` |
|
|
71
|
+
| `remove <skill-name>` | 从 source block 删除技能后执行同步 | `skillsbase remove documentation-writer --repo ./my-skills-repo` |
|
|
65
72
|
| `github_action` | 生成受管 GitHub Actions 工作流或 action 文件 | `skillsbase github_action --repo ./my-skills-repo --kind workflow` |
|
|
66
73
|
|
|
67
74
|
全局选项:
|
|
@@ -88,6 +95,8 @@ skillsbase github_action --repo /path/to/target-repo --kind all
|
|
|
88
95
|
- first-party:`$HOME/.agents/skills`
|
|
89
96
|
- system:`$HOME/.codex/skills/.system`
|
|
90
97
|
- `add` 默认写入第一个已声明的 source block;如需指定,传 `--source <key>`。
|
|
98
|
+
- `remove` 若仅命中一个 source block,会直接删除;若同名技能存在于多个 source block,必须显式传 `--source <key>`。
|
|
99
|
+
- `add`、`remove`、`sync` 均接受 `--allow-missing-sources`,以便在 CI 或仓库外 cwd 下保持一致的路径解析与失败语义。
|
|
91
100
|
- `github_action` 默认使用 `--kind workflow`。
|
|
92
101
|
- 若上下文不足以安全写入,CLI 会直接失败并输出诊断,不会进入交互提问。
|
|
93
102
|
|
package/bin/skillsbase.mjs
CHANGED
|
File without changes
|
package/dist/cli.mjs
CHANGED
|
@@ -25,12 +25,14 @@ function printCommandUsage(stdout) {
|
|
|
25
25
|
" init Create the managed repository baseline",
|
|
26
26
|
" sync Reconcile managed skills from sources.yaml",
|
|
27
27
|
" add Add a skill to a source block and sync",
|
|
28
|
+
" remove Remove a skill from a source block and sync",
|
|
28
29
|
" github_action Generate managed GitHub Actions assets",
|
|
29
30
|
"",
|
|
30
31
|
"Global Options:",
|
|
31
|
-
" --repo <path>
|
|
32
|
-
" --
|
|
33
|
-
" --
|
|
32
|
+
" --repo <path> Target repository path (default: current directory)",
|
|
33
|
+
" --allow-missing-sources Skip missing local source roots during sync/add/remove",
|
|
34
|
+
" --help, -h Show help",
|
|
35
|
+
" --version, -v Show version",
|
|
34
36
|
""
|
|
35
37
|
].join("\n"));
|
|
36
38
|
}
|
|
@@ -183,6 +185,41 @@ function resolveSourcePath(repoPath, source, originalName) {
|
|
|
183
185
|
if (isRemoteRepositorySource(source)) return buildSourcePath(source, originalName);
|
|
184
186
|
return path.join(resolveSourceRoot(repoPath, source), originalName);
|
|
185
187
|
}
|
|
188
|
+
function cloneSource(source) {
|
|
189
|
+
return {
|
|
190
|
+
...source,
|
|
191
|
+
include: [...source.include ?? []]
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function cloneManifestWithSources(manifest, sources) {
|
|
195
|
+
return {
|
|
196
|
+
...manifest,
|
|
197
|
+
sources: sources.map(cloneSource)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function sortInclude(include) {
|
|
201
|
+
return [...include].sort((left, right) => left.localeCompare(right));
|
|
202
|
+
}
|
|
203
|
+
function assertManifestHasSources(manifest) {
|
|
204
|
+
if (manifest.sources.length === 0) throw new CliError("Manifest does not declare any source blocks.", { details: ["Run `skillsbase init` first or add a source block to `sources.yaml`."] });
|
|
205
|
+
}
|
|
206
|
+
function getSourceKeys(manifest) {
|
|
207
|
+
return manifest.sources.map((source) => source.key).join(", ");
|
|
208
|
+
}
|
|
209
|
+
function findSourceByKey(manifest, sourceKey) {
|
|
210
|
+
const source = manifest.sources.find((candidate) => candidate.key === sourceKey);
|
|
211
|
+
if (!source) throw new CliError(`Unknown source key: ${sourceKey}`, { details: [`Declared sources: ${getSourceKeys(manifest)}`] });
|
|
212
|
+
return source;
|
|
213
|
+
}
|
|
214
|
+
function findSourcesBySkill(manifest, skillName) {
|
|
215
|
+
return manifest.sources.filter((source) => source.include.includes(skillName));
|
|
216
|
+
}
|
|
217
|
+
function buildMissingSkillError(skillName, options = {}) {
|
|
218
|
+
const matchingKeys = options.matchingKeys ?? [];
|
|
219
|
+
const details = options.sourceKey ? [`skill: ${skillName}`, `source: ${options.sourceKey}`] : [`skill: ${skillName}`];
|
|
220
|
+
if (matchingKeys.length > 0) details.push(`matching sources: ${matchingKeys.join(", ")}`);
|
|
221
|
+
return new CliError(options.sourceKey == null ? `Skill "${skillName}" is not declared in sources.yaml.` : `Skill "${skillName}" is not declared in source "${options.sourceKey}".`, { details });
|
|
222
|
+
}
|
|
186
223
|
function createManifest(repoPath, options = {}) {
|
|
187
224
|
return {
|
|
188
225
|
version: 1,
|
|
@@ -346,19 +383,49 @@ function buildManifestEntries(manifest, repoPath = manifest.repoPath) {
|
|
|
346
383
|
return entries.sort((left, right) => left.targetName.localeCompare(right.targetName));
|
|
347
384
|
}
|
|
348
385
|
function addSkillToManifest(manifest, skillName, options = {}) {
|
|
349
|
-
|
|
350
|
-
const selectedSource = options.sourceKey == null ? manifest.sources[0] : manifest
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
selectedSource.include = [...include].sort((left, right) => left.localeCompare(right));
|
|
355
|
-
return {
|
|
356
|
-
...manifest,
|
|
357
|
-
sources: manifest.sources.map((source) => source.key === selectedSource.key ? { ...selectedSource } : {
|
|
386
|
+
assertManifestHasSources(manifest);
|
|
387
|
+
const selectedSource = options.sourceKey == null ? manifest.sources[0] : findSourceByKey(manifest, options.sourceKey);
|
|
388
|
+
return cloneManifestWithSources(manifest, manifest.sources.map((source) => {
|
|
389
|
+
if (source.key !== selectedSource.key) return source;
|
|
390
|
+
return {
|
|
358
391
|
...source,
|
|
359
|
-
include:
|
|
360
|
-
}
|
|
361
|
-
};
|
|
392
|
+
include: sortInclude(new Set(source.include ?? []).add(skillName))
|
|
393
|
+
};
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
function removeSkillFromManifest(manifest, skillName, options = {}) {
|
|
397
|
+
assertManifestHasSources(manifest);
|
|
398
|
+
const selectedSource = options.sourceKey == null ? null : findSourceByKey(manifest, options.sourceKey);
|
|
399
|
+
if (selectedSource != null) {
|
|
400
|
+
if (!selectedSource.include.includes(skillName)) {
|
|
401
|
+
const matchingKeys = findSourcesBySkill(manifest, skillName).map((source) => source.key);
|
|
402
|
+
throw buildMissingSkillError(skillName, {
|
|
403
|
+
sourceKey: selectedSource.key,
|
|
404
|
+
matchingKeys
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return cloneManifestWithSources(manifest, manifest.sources.map((source) => {
|
|
408
|
+
if (source.key !== selectedSource.key) return source;
|
|
409
|
+
return {
|
|
410
|
+
...source,
|
|
411
|
+
include: sortInclude(source.include.filter((candidate) => candidate !== skillName))
|
|
412
|
+
};
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
const matchingSources = findSourcesBySkill(manifest, skillName);
|
|
416
|
+
if (matchingSources.length === 0) throw buildMissingSkillError(skillName);
|
|
417
|
+
if (matchingSources.length > 1) {
|
|
418
|
+
const matchingKeys = matchingSources.map((source) => source.key).sort((left, right) => left.localeCompare(right));
|
|
419
|
+
throw new CliError(`Skill "${skillName}" is declared in multiple sources.`, { details: [`matching sources: ${matchingKeys.join(", ")}`, `Use \`skillsbase remove ${skillName} --source <key>\` to disambiguate.`] });
|
|
420
|
+
}
|
|
421
|
+
const [uniqueSource] = matchingSources;
|
|
422
|
+
return cloneManifestWithSources(manifest, manifest.sources.map((source) => {
|
|
423
|
+
if (source.key !== uniqueSource.key) return source;
|
|
424
|
+
return {
|
|
425
|
+
...source,
|
|
426
|
+
include: sortInclude(source.include.filter((candidate) => candidate !== skillName))
|
|
427
|
+
};
|
|
428
|
+
}));
|
|
362
429
|
}
|
|
363
430
|
function buildMetadata(manifest, entry, installRecord) {
|
|
364
431
|
return {
|
|
@@ -383,6 +450,19 @@ function buildMetadata(manifest, entry, installRecord) {
|
|
|
383
450
|
//#endregion
|
|
384
451
|
//#region src/lib/installer.ts
|
|
385
452
|
var execFile$1 = promisify(execFile);
|
|
453
|
+
var INSTALL_TIMEOUT_MS = 18e4;
|
|
454
|
+
var REMOTE_INSTALL_RETRIES = 3;
|
|
455
|
+
var NPM_ENV_KEYS_TO_UNSET = [
|
|
456
|
+
"INIT_CWD",
|
|
457
|
+
"npm_command",
|
|
458
|
+
"npm_config_local_prefix",
|
|
459
|
+
"npm_config_prefix",
|
|
460
|
+
"npm_execpath",
|
|
461
|
+
"npm_lifecycle_event",
|
|
462
|
+
"npm_lifecycle_script",
|
|
463
|
+
"npm_package_json",
|
|
464
|
+
"npm_prefix"
|
|
465
|
+
];
|
|
386
466
|
function toInstallReference(entry) {
|
|
387
467
|
if (entry.remoteSource) return entry.sourcePath;
|
|
388
468
|
if (path.isAbsolute(entry.sourcePath) || entry.sourcePath.startsWith(`.${path.sep}`) || entry.sourcePath === ".") return entry.sourcePath;
|
|
@@ -403,6 +483,23 @@ function renderExecFailure(error) {
|
|
|
403
483
|
}
|
|
404
484
|
return String(error);
|
|
405
485
|
}
|
|
486
|
+
async function execSkillsAdd(repoPath, manifest, installReference, options) {
|
|
487
|
+
const childEnv = { ...options.env ?? process.env };
|
|
488
|
+
for (const key of NPM_ENV_KEYS_TO_UNSET) delete childEnv[key];
|
|
489
|
+
childEnv.INIT_CWD = repoPath;
|
|
490
|
+
await execFile$1("npx", buildNpxArgs(manifest, "add", [
|
|
491
|
+
installReference,
|
|
492
|
+
"--agent",
|
|
493
|
+
manifest.installAgent,
|
|
494
|
+
"--copy",
|
|
495
|
+
"-y"
|
|
496
|
+
]), {
|
|
497
|
+
cwd: repoPath,
|
|
498
|
+
env: childEnv,
|
|
499
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
500
|
+
timeout: INSTALL_TIMEOUT_MS
|
|
501
|
+
});
|
|
502
|
+
}
|
|
406
503
|
async function installIntoCurrentRepository(repoPath, manifest, entry, options = {}) {
|
|
407
504
|
const installReference = toInstallReference(entry);
|
|
408
505
|
const installPath = path.join(repoPath, ".agents", "skills", entry.originalName);
|
|
@@ -414,22 +511,18 @@ async function installIntoCurrentRepository(repoPath, manifest, entry, options =
|
|
|
414
511
|
lockText: await readFileIfExists(lockPath),
|
|
415
512
|
installReference
|
|
416
513
|
};
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"-y"
|
|
424
|
-
]), {
|
|
425
|
-
cwd: repoPath,
|
|
426
|
-
env: options.env,
|
|
427
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
428
|
-
timeout: 6e4
|
|
429
|
-
});
|
|
514
|
+
const attempts = entry.remoteSource ? REMOTE_INSTALL_RETRIES : 1;
|
|
515
|
+
const failures = [];
|
|
516
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) try {
|
|
517
|
+
await execSkillsAdd(repoPath, manifest, installReference, options);
|
|
518
|
+
failures.length = 0;
|
|
519
|
+
break;
|
|
430
520
|
} catch (error) {
|
|
431
|
-
|
|
521
|
+
failures.push(`attempt ${attempt}/${attempts}: ${renderExecFailure(error)}`);
|
|
522
|
+
await restoreSnapshot(snapshot);
|
|
523
|
+
if (attempt === attempts) break;
|
|
432
524
|
}
|
|
525
|
+
if (failures.length > 0) throw new CliError(`skills install failed for ${entry.originalName}.`, { details: failures });
|
|
433
526
|
if (!await pathExists(installPath)) throw new CliError(`skills install did not create ${path.relative(repoPath, installPath)}.`, { details: ["The `npx skills` install output was not in the expected current-repository shape."] });
|
|
434
527
|
return {
|
|
435
528
|
installPath,
|
|
@@ -438,26 +531,14 @@ async function installIntoCurrentRepository(repoPath, manifest, entry, options =
|
|
|
438
531
|
snapshot
|
|
439
532
|
};
|
|
440
533
|
}
|
|
441
|
-
async function cleanupInstalledSkill(repoPath,
|
|
442
|
-
let removeError = null;
|
|
443
|
-
try {
|
|
444
|
-
await execFile$1("npx", buildNpxArgs(manifest, "remove", [entry.originalName, "-y"]), {
|
|
445
|
-
cwd: repoPath,
|
|
446
|
-
env: options.env,
|
|
447
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
448
|
-
timeout: 6e4
|
|
449
|
-
});
|
|
450
|
-
} catch (error) {
|
|
451
|
-
removeError = error;
|
|
452
|
-
}
|
|
534
|
+
async function cleanupInstalledSkill(repoPath, _manifest, entry, installState, _options = {}) {
|
|
453
535
|
try {
|
|
454
536
|
await restoreSnapshot(installState.snapshot);
|
|
455
537
|
await removeIfEmptyUpward(path.join(repoPath, ".agents", "skills"), repoPath);
|
|
456
538
|
} catch (restoreError) {
|
|
457
539
|
const restoreMessage = restoreError instanceof Error ? restoreError.message : String(restoreError);
|
|
458
|
-
throw new CliError(`Cleanup failed for ${entry.originalName}.`, { details: [restoreMessage
|
|
540
|
+
throw new CliError(`Cleanup failed for ${entry.originalName}.`, { details: [restoreMessage] });
|
|
459
541
|
}
|
|
460
|
-
if (removeError) throw new CliError(`skills uninstall failed for ${entry.originalName}.`, { details: [renderExecFailure(removeError)] });
|
|
461
542
|
}
|
|
462
543
|
async function snapshotTree(rootPath) {
|
|
463
544
|
if (!await pathExists(rootPath)) return null;
|
|
@@ -741,10 +822,16 @@ async function writeGithubActions(repoPath, options = {}) {
|
|
|
741
822
|
if (kind === "workflow" || kind === "all") targets.push({
|
|
742
823
|
relativePath: path.join(".github", "workflows", "skills-sync.yml"),
|
|
743
824
|
template: path.join("workflows", "skills-sync.yml")
|
|
825
|
+
}, {
|
|
826
|
+
relativePath: path.join(".github", "workflows", "skills-manage.yml"),
|
|
827
|
+
template: path.join("workflows", "skills-manage.yml")
|
|
744
828
|
});
|
|
745
|
-
if (kind === "action" || kind === "all") targets.push({
|
|
829
|
+
if (kind === "workflow" || kind === "action" || kind === "all") targets.push({
|
|
746
830
|
relativePath: path.join(".github", "actions", "skillsbase-sync", "action.yml"),
|
|
747
831
|
template: path.join("actions", "skillsbase-sync", "action.yml")
|
|
832
|
+
}, {
|
|
833
|
+
relativePath: path.join(".github", "actions", "skillsbase-manage", "action.yml"),
|
|
834
|
+
template: path.join("actions", "skillsbase-manage", "action.yml")
|
|
748
835
|
});
|
|
749
836
|
if (targets.length === 0) throw new CliError(`Unsupported github_action kind: ${kind}`, { details: ["Supported values: workflow, action, all."] });
|
|
750
837
|
const items = [];
|
|
@@ -854,6 +941,30 @@ async function runInitCommand(context) {
|
|
|
854
941
|
});
|
|
855
942
|
}
|
|
856
943
|
//#endregion
|
|
944
|
+
//#region src/commands/remove.ts
|
|
945
|
+
async function runRemoveCommand(context) {
|
|
946
|
+
const repoFlag = typeof context.flags.repo === "string" ? context.flags.repo : void 0;
|
|
947
|
+
const sourceFlag = typeof context.flags.source === "string" ? context.flags.source : void 0;
|
|
948
|
+
const repoPath = path.resolve(repoFlag ?? context.cwd);
|
|
949
|
+
const skillName = context.args[0];
|
|
950
|
+
if (!skillName) throw new CliError("`skillsbase remove` requires a skill name.", { details: ["Usage: `skillsbase remove <skill-name> [--source <key>]`."] });
|
|
951
|
+
const nextManifest = removeSkillFromManifest(await loadManifest(repoPath), skillName, { sourceKey: sourceFlag });
|
|
952
|
+
await saveManifest(nextManifest);
|
|
953
|
+
const result = await executeSync({
|
|
954
|
+
repoPath,
|
|
955
|
+
manifest: nextManifest,
|
|
956
|
+
env: context.env,
|
|
957
|
+
check: false,
|
|
958
|
+
allowMissingSources: context.flags["allow-missing-sources"] === true
|
|
959
|
+
});
|
|
960
|
+
return {
|
|
961
|
+
...result,
|
|
962
|
+
command: "remove",
|
|
963
|
+
title: `skillsbase remove ${skillName}`,
|
|
964
|
+
items: [`manifest updated: ${path.relative(repoPath, nextManifest.manifestPath) || "sources.yaml"}`, ...result.items]
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
//#endregion
|
|
857
968
|
//#region src/commands/sync.ts
|
|
858
969
|
async function runSyncCommand(context) {
|
|
859
970
|
const repoFlag = typeof context.flags.repo === "string" ? context.flags.repo : void 0;
|
|
@@ -926,6 +1037,7 @@ var commandMap = new Map([
|
|
|
926
1037
|
["init", runInitCommand],
|
|
927
1038
|
["sync", runSyncCommand],
|
|
928
1039
|
["add", runAddCommand],
|
|
1040
|
+
["remove", runRemoveCommand],
|
|
929
1041
|
["github_action", runGithubActionCommand],
|
|
930
1042
|
["github-action", runGithubActionCommand]
|
|
931
1043
|
]);
|
|
@@ -993,5 +1105,5 @@ async function runCli(argv, environment = {}) {
|
|
|
993
1105
|
//#endregion
|
|
994
1106
|
//#region src/cli-entry.ts
|
|
995
1107
|
var exitCode = await runCli(process.argv.slice(2));
|
|
996
|
-
process.exitCode
|
|
1108
|
+
process.exit(exitCode);
|
|
997
1109
|
//#endregion
|
package/package.json
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Managed by skillsbase CLI.
|
|
2
|
+
|
|
3
|
+
name: skillsbase-manage
|
|
4
|
+
description: Run a managed add, remove, or sync operation for a skillsbase repository
|
|
5
|
+
|
|
6
|
+
inputs:
|
|
7
|
+
node-version:
|
|
8
|
+
description: Node.js version used for maintenance
|
|
9
|
+
required: false
|
|
10
|
+
default: "{{NODE_VERSION}}"
|
|
11
|
+
operation:
|
|
12
|
+
description: Maintenance operation to run (`add`, `remove`, or `sync`)
|
|
13
|
+
required: true
|
|
14
|
+
skill-name:
|
|
15
|
+
description: Skill name for `add` or `remove`
|
|
16
|
+
required: false
|
|
17
|
+
default: ""
|
|
18
|
+
source:
|
|
19
|
+
description: Optional source key for `add` or `remove`
|
|
20
|
+
required: false
|
|
21
|
+
default: ""
|
|
22
|
+
allow-missing-sources:
|
|
23
|
+
description: Skip missing local roots during the operation
|
|
24
|
+
required: false
|
|
25
|
+
default: "false"
|
|
26
|
+
run-tests:
|
|
27
|
+
description: Whether to run npm test after the maintenance command
|
|
28
|
+
required: false
|
|
29
|
+
default: "true"
|
|
30
|
+
|
|
31
|
+
runs:
|
|
32
|
+
using: composite
|
|
33
|
+
steps:
|
|
34
|
+
- name: Setup Node.js
|
|
35
|
+
uses: actions/setup-node@v4
|
|
36
|
+
with:
|
|
37
|
+
node-version: ${{ inputs.node-version }}
|
|
38
|
+
cache: npm
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
shell: bash
|
|
42
|
+
run: npm ci
|
|
43
|
+
|
|
44
|
+
- name: Upgrade npm
|
|
45
|
+
shell: bash
|
|
46
|
+
run: npm install --global npm@10.9.2
|
|
47
|
+
|
|
48
|
+
- name: Install skillsbase
|
|
49
|
+
shell: bash
|
|
50
|
+
run: npm install --global @hagicode/skillsbase
|
|
51
|
+
|
|
52
|
+
- name: Run maintenance command
|
|
53
|
+
shell: bash
|
|
54
|
+
env:
|
|
55
|
+
OPERATION: ${{ inputs.operation }}
|
|
56
|
+
SKILL_NAME: ${{ inputs.skill-name }}
|
|
57
|
+
SOURCE: ${{ inputs.source }}
|
|
58
|
+
ALLOW_MISSING_SOURCES: ${{ inputs.allow-missing-sources }}
|
|
59
|
+
run: |
|
|
60
|
+
set -euo pipefail
|
|
61
|
+
|
|
62
|
+
base_args=(--repo .)
|
|
63
|
+
if [[ "${ALLOW_MISSING_SOURCES}" == "true" ]]; then
|
|
64
|
+
base_args+=(--allow-missing-sources)
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
case "${OPERATION}" in
|
|
68
|
+
add|remove)
|
|
69
|
+
if [[ -z "${SKILL_NAME}" ]]; then
|
|
70
|
+
echo "::error::skill-name is required when operation=${OPERATION}."
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
command=(skillsbase "${OPERATION}" "${SKILL_NAME}" "${base_args[@]}")
|
|
75
|
+
if [[ -n "${SOURCE}" ]]; then
|
|
76
|
+
command+=(--source "${SOURCE}")
|
|
77
|
+
fi
|
|
78
|
+
;;
|
|
79
|
+
sync)
|
|
80
|
+
command=(skillsbase sync "${base_args[@]}")
|
|
81
|
+
;;
|
|
82
|
+
*)
|
|
83
|
+
echo "::error::Unsupported operation: ${OPERATION}."
|
|
84
|
+
exit 1
|
|
85
|
+
;;
|
|
86
|
+
esac
|
|
87
|
+
|
|
88
|
+
printf 'Running:'
|
|
89
|
+
printf ' %q' "${command[@]}"
|
|
90
|
+
printf '\n'
|
|
91
|
+
"${command[@]}"
|
|
92
|
+
|
|
93
|
+
- name: Run tests
|
|
94
|
+
if: ${{ inputs.run-tests == 'true' }}
|
|
95
|
+
shell: bash
|
|
96
|
+
run: npm test
|
|
@@ -2,15 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
# Maintainer Workflow
|
|
4
4
|
|
|
5
|
-
The maintainer flow is `init -> add -> sync -> github_action`.
|
|
5
|
+
The maintainer flow is `init -> add/remove -> sync -> github_action`.
|
|
6
6
|
|
|
7
7
|
## Lifecycle
|
|
8
8
|
|
|
9
9
|
1. `skillsbase init`
|
|
10
|
-
2. `skillsbase add <skill-name>`
|
|
10
|
+
2. `skillsbase add <skill-name>` or `skillsbase remove <skill-name>`
|
|
11
11
|
3. `skillsbase sync`
|
|
12
12
|
4. `skillsbase github_action --kind all`
|
|
13
13
|
|
|
14
|
+
## GitHub Maintenance Path
|
|
15
|
+
|
|
16
|
+
Use `.github/workflows/skills-manage.yml` only for explicit non-interactive maintenance from GitHub UI.
|
|
17
|
+
|
|
18
|
+
- `operation` chooses `add`, `remove`, or `sync`
|
|
19
|
+
- `skill-name` is required for `add` and `remove`
|
|
20
|
+
- `source` is optional and maps to `--source`
|
|
21
|
+
- `allow-missing-sources` maps to `--allow-missing-sources`
|
|
22
|
+
- `run-tests` controls the post-operation `npm test`
|
|
23
|
+
- The workflow does not commit, push, or open pull requests
|
|
24
|
+
|
|
14
25
|
## Notes
|
|
15
26
|
|
|
16
27
|
- `sources.yaml` is the single source of truth.
|
|
@@ -18,3 +29,4 @@ The maintainer flow is `init -> add -> sync -> github_action`.
|
|
|
18
29
|
- `.skill-source.json` records source and conversion metadata.
|
|
19
30
|
- `skillsbase sync --check` validates drift without writing files.
|
|
20
31
|
- If a source root is unavailable, use `skillsbase sync --allow-missing-sources` to skip it.
|
|
32
|
+
- Local CLI commands remain the primary maintainer path.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Managed by skillsbase CLI.
|
|
2
|
+
|
|
3
|
+
name: Skills Manage
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
operation:
|
|
9
|
+
description: Operation to run (`add`, `remove`, or `sync`)
|
|
10
|
+
required: true
|
|
11
|
+
type: choice
|
|
12
|
+
default: sync
|
|
13
|
+
options:
|
|
14
|
+
- add
|
|
15
|
+
- remove
|
|
16
|
+
- sync
|
|
17
|
+
skill-name:
|
|
18
|
+
description: Skill name for `add` or `remove`
|
|
19
|
+
required: false
|
|
20
|
+
type: string
|
|
21
|
+
source:
|
|
22
|
+
description: Optional source key for `add` or `remove`
|
|
23
|
+
required: false
|
|
24
|
+
type: string
|
|
25
|
+
allow-missing-sources:
|
|
26
|
+
description: Skip missing local roots during the operation
|
|
27
|
+
required: false
|
|
28
|
+
type: boolean
|
|
29
|
+
default: false
|
|
30
|
+
run-tests:
|
|
31
|
+
description: Run `npm test` after the maintenance command
|
|
32
|
+
required: false
|
|
33
|
+
type: boolean
|
|
34
|
+
default: true
|
|
35
|
+
|
|
36
|
+
permissions:
|
|
37
|
+
contents: read
|
|
38
|
+
|
|
39
|
+
jobs:
|
|
40
|
+
manage:
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout repository
|
|
44
|
+
uses: actions/checkout@v4
|
|
45
|
+
|
|
46
|
+
- name: Run skillsbase maintenance
|
|
47
|
+
uses: ./.github/actions/skillsbase-manage
|
|
48
|
+
with:
|
|
49
|
+
node-version: {{NODE_VERSION}}
|
|
50
|
+
operation: ${{ inputs.operation }}
|
|
51
|
+
skill-name: ${{ inputs.skill-name }}
|
|
52
|
+
source: ${{ inputs.source }}
|
|
53
|
+
allow-missing-sources: ${{ inputs.allow-missing-sources }}
|
|
54
|
+
run-tests: ${{ inputs.run-tests }}
|
|
@@ -23,20 +23,8 @@ jobs:
|
|
|
23
23
|
- name: Checkout repository
|
|
24
24
|
uses: actions/checkout@v4
|
|
25
25
|
|
|
26
|
-
- name:
|
|
27
|
-
uses: actions/
|
|
26
|
+
- name: Run skillsbase validation
|
|
27
|
+
uses: ./.github/actions/skillsbase-sync
|
|
28
28
|
with:
|
|
29
29
|
node-version: {{NODE_VERSION}}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- name: Install dependencies
|
|
33
|
-
run: npm ci
|
|
34
|
-
|
|
35
|
-
- name: Install skillsbase
|
|
36
|
-
run: npm install --global @hagicode/skillsbase
|
|
37
|
-
|
|
38
|
-
- name: Run tests
|
|
39
|
-
run: npm test
|
|
40
|
-
|
|
41
|
-
- name: Validate managed repository state
|
|
42
|
-
run: skillsbase sync --check --repo .
|
|
30
|
+
run-tests: "true"
|