feat: The method to modify and update skills

This commit is contained in:
qcq01083097
2026-06-18 14:07:06 +08:00
parent 1d803bb4b9
commit 07dafc0fd4
3 changed files with 10 additions and 6 deletions
+7 -3
View File
@@ -5,7 +5,8 @@ import { defineCommand, getConfigDir } from "bailian-cli-core";
import { CLI_VERSION } from "../version.ts";
import { NPM_PACKAGE, fetchLatestVersion } from "../utils/update-checker.ts";
const SKILL_NAME = "bailian-cli";
const SKILL_SOURCE = "modelstudioai/cli";
const SKILL_INSTALL_CMD = `npx skills add ${SKILL_SOURCE} --all -g -y`;
/** Build the install command */
function detectInstallCommand(): { cmd: string; label: string } {
@@ -16,11 +17,13 @@ function updateAgentSkill(colors: { green: string; yellow: string; reset: string
const { green, yellow, reset } = colors;
process.stderr.write("\nUpdating agent skill...\n");
try {
execSync(`npx skills update ${SKILL_NAME} -g -y`, { stdio: "inherit" });
// Reinstall (not `skills update`) into ~/.agents/skills/ and sync to all agent apps.
// `--all` on `skills add` means --skill '*' --agent '*' -y (Cursor, Claude Code, etc.).
execSync(SKILL_INSTALL_CMD, { stdio: "inherit" });
process.stderr.write(`${green}\u2713 Agent skill updated.${reset}\n`);
} catch {
process.stderr.write(
`${yellow}Agent skill update skipped. Run manually: npx skills update ${SKILL_NAME} -g -y${reset}\n`,
`${yellow}Agent skill update skipped. Run manually: ${SKILL_INSTALL_CMD}${reset}\n`,
);
}
}
@@ -45,6 +48,7 @@ export default defineCommand({
if (latest && latest === CLI_VERSION) {
process.stderr.write(`${green}\u2713 Already up to date (${CLI_VERSION}).${reset}\n`);
updateAgentSkill({ green, yellow, reset });
return;
}
+1 -1
View File
@@ -114,7 +114,7 @@ Offer reporting when **none** of EXCLUDE applies **and** any of the following ho
### Before offering to report
1. Align versions: [SKILL.md → Version & updates](../SKILL.md#version--updates-agent--do-first) — run `bl update` and `npx skills update bailian-cli -g -y` if mismatched.
1. Align versions: [SKILL.md → Version & updates](../SKILL.md#version--updates-agent--do-first) — run `bl update` and `npx skills add modelstudioai/cli --all -g -y` if mismatched.
2. Confirm `bl auth status` is healthy (for commands that need auth).
3. Retry once with `--verbose` if stderr was thin.
+2 -2
View File
@@ -18,7 +18,7 @@ Run this flow **once per session**, before the first `bl` command.
2. **CLI version** — `bl --version` (output `bl X.Y.Z`; compare only `X.Y.Z`).
3. If the two strings **differ**, refresh the skill first:
```bash
npx skills update bailian-cli -g -y
npx skills add modelstudioai/cli --all -g -y
```
Do not trust a stale `reference/` when versions mismatch — flags may be wrong.
@@ -36,7 +36,7 @@ bl update
```
`bl update` upgrades `bailian-cli` via npm and, on success, also runs
`npx skills update bailian-cli -g -y` to keep the skill in lockstep.
`npx skills add modelstudioai/cli --all -g -y` to keep the skill in lockstep across all agent apps.
## 3. Update policy — always ask first