Repository navigation
Commit 0c60897
feat(cli): os skills install, update and status at the server's version, with or without a project (#35060)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBQ3DFv6XZAspQRYGQoEWhr8)_
Fixes #34773
Clause-②: yes (widening: a new published CLI command group, `os skills
install | update | status`)
Metadata-protocol: none
## 维护者速读
- 改了什么:新增 `os skills install / update / status` 三个命令,在有或没有项目的目录里,把已发布的
`@objectstack/skills` 按服务器版本装进 `.claude/skills/`,并能更新和核对;MCP
开放服务的安装提示改为这条命令。
- 为什么改:只连了 MCP 客户端的用户没有办法装技能,有项目的用户升级后也没有命令刷新技能,本地知识会悄悄落后于服务器。
- 风险与回滚:新增命令,不改已有命令;`update` 只动自己装过的技能,用户自己的技能目录从不触碰;回滚即撤销本 PR。
-
先看:`packages/cli/src/utils/skills-command.ts`(拒绝条件与写入顺序)、`packages/cli/src/utils/skills-install-state.ts`(`planSkillsWrite`
的归属判断)、`packages/cli/src/utils/skills-catalog.ts`(`npm pack` 读取与 tar
解包)。
- 两分钟验证:在空目录运行 `node packages/cli/bin/run.js skills install --version
18.5.0`,预期装入 11 个技能并写出 `.claude/skills/.objectstack-skills.json`;再运行
`skills status --version 18.6.0 --check`,预期退出码 1 并提示版本不一致。
- 需要你做的:无,席位落地。
## What changes
- **`os skills install`** copies the published `@objectstack/skills`
catalog at one version into the agent's skills directory
(`.claude/skills/` under the current directory, `--dir` overrides). It
works in an empty directory with no `package.json`, and in a project; it
reads and writes no `package.json`.
- Version, in order, and the output names which: `--version V` (exact;
ranges and tags refused), else `--target T` (a target environment URL or
a restriction profile file, read by the same `loadRestrictionProfile` as
`os validate --target`, taking `versions.skills`), else the CLI's own
version. `@objectstack/skills` and `@objectstack/cli` are in one `fixed`
group of `.changeset/config.json`, so the CLI's version names the
catalog written for it.
- Source: the tarball at exactly that version, read with `npm pack` in
the current directory, so the user's `.npmrc` files and `npm_config_*`
variables (registry, scope mapping, credentials, proxy) apply; there was
no existing registry helper to reuse. No third-party installer. The
tarball is unpacked in process (`readTarGz`: ustar, prefix, pax `path`,
GNU long name, checksum checked), and only `package/dist/skills/NAME/**`
for each NAME holding a `SKILL.md` is kept. The tarball must declare
`@objectstack/skills` at the requested version; a link, a path leaving
the tree, or an empty catalog is refused. A version the registry does
not publish is refused with a sentence naming it.
- What was written is recorded in `.objectstack-skills.json` beside the
skills: package, version, every file of every catalog skill with its
SHA-256.
- An existing recorded catalog is refused (names `os skills update`). A
same-named directory the record does not name (for example one `skills
experimental_sync` copied) is refused, naming it; `--force` replaces it
("adopted" in the output).
- **`os skills update`** moves the recorded catalog to the resolved
version: replaces each recorded skill, removes recorded skills the new
version dropped, adds new ones. A skill directory the record does not
name is never written, replaced or removed: a new catalog skill whose
name collides with one is refused even under `--force`. A recorded skill
changed locally is refused, naming the files, unless `--force`. No
record: refused, naming `os skills install`.
- **`os skills status`** reports installed versus expected version (same
order), `missing`, `modified` (changed / removed / added files) and
`extra` (directories the record does not name: listed, never judged).
Mismatch = no record, another version, or any missing or modified skill.
Exits 0; with `--check`, 1 on a mismatch. The registry is not read. All
three commands take `--json` (one document on stdout).
- **`@objectstack/mcp`**: the open server's `initialize` skills install
line now reads `... install that version into the agent's skills
directory with the ObjectStack CLI, with or without a project: os skills
install --version VERSION (where the CLI is not installed: npx -p
@objectstack/cli@VERSION os skills install --version VERSION).` instead
of `pnpm add -D @objectstack/skills@VERSION`, which needed a project.
The README describes the new line. The #34686 line is not yet on npm
(`@objectstack/mcp` 18.5.0 tarball carries no `Published skills` text,
published 2026-11-15), so the pending #34686 changeset is corrected to
name the new command (see DELIBERATE CORRECTION below) rather than this
changeset declaring a same-release supersession.
- Registration: the `skills` topic in `packages/cli/package.json`
`oclif.topics`.
- Docs: `content/docs/deployment/cli.mdx` gains a `### Skills` section
(all three commands, flags table); `content/docs/ai/skills.mdx` leads
its install section with `os skills` for users with and without a
project, keeps the `experimental_sync` path, and names `install --force`
to move a synced project over; `content/docs/ai/connect-mcp.mdx`
describes the new install line and the MCP-only path.
- Changeset `.changeset/34773-os-skills-install.md`: `@objectstack/cli`
and `@objectstack/mcp` `patch` (Metadata-protocol `none` takes `patch`,
per the Check Changeset level axis).
## Tests
- `packages/cli/test/skills-commands.test.ts` (unit tier), 22 tests.
Seams: `skillsRegistry.fetchTarball` (the registry, answering tarballs
the test builds or "not published") and `fetch` (the target's published
restriction profile). No network.
- Done when: in an empty directory with no `package.json`, `install
--target URL` installs the server's version; after the server's profile
moves to 18.6.0, `status --target URL --check --json` exits 1 with
`installedVersion 18.5.0, expectedVersion 18.6.0, mismatch true`.
- Install into an empty dir (files land, the catalog README does not,
record names version and every file); `--dir`; version order
(`--version`, target URL, target file, CLI fallback, and `--version`
with `--target` refused); unknown version refused and nothing written;
non-exact version refused before the registry is asked; install over a
record refused; conflict refused then `--force` adopts.
- Update: replaces, removes dropped, adds new, leaves `my-own`
untouched; a new catalog skill colliding with a user directory refused
even with `--force`; local edit refused unless `--force`; no record
refused.
- Status: match, version mismatch (0 by default, 1 with `--check`),
missing/modified/extra with only missing and modified counting, nothing
installed.
- Tarball reader: long path via ustar prefix, other-version refusal,
link and traversal refusal, empty catalog refusal.
- `packages/mcp/src/initialize-selection-rule-34686.test.ts`: new case
pins `os skills install --version OWN_VERSION`, the `npx -p
@objectstack/cli@OWN_VERSION` form and no `pnpm add`. Red first against
the old line, then green.
<details><summary>Run readings (head bec9bdc)</summary>
- `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2 test/skills-commands.test.ts`: Test Files 1 passed, Tests
22 passed (VERDICT command-exit 0).
- Red first, MCP pin before the line changed: `× names os skills install
--version at that version, and no project-only install` —
`AssertionError: expected 'ObjectStack MCP Server. The tools thi…' to
contain 'os skills install --version 18.5.0'`, Tests 1 failed / 7
passed. After the change: 8 passed.
- `pnpm --filter @objectstack/mcp test && pnpm --filter @objectstack/mcp
typecheck`: Test Files 71 passed, Tests 1254 passed;
`check:test-typecheck: OK`; VERDICT command-exit 0.
- `pnpm --filter @objectstack/cli typecheck`: `check:test-typecheck: OK
— @objectstack/cli's test layer compiles`; VERDICT command-exit 0.
- `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2`: Test Files 427 passed (427), Tests 6085 passed (6085);
VERDICT command-exit 0. The `integration` tier is declared to CI: the
diff touches no integration-tier file, no `bin/` entry and no
`test/helpers/serve-process.ts`.
- Ablation A1 (update ownership): `planSkillsWrite`'s conflict branch
replaced with `else if (false) conflicts.push(name); /* ABLATION-A1 */`
via `scripts/ablation-replace.mjs` (anchor 1 → 0, blob 0b64350 →
9c901ed004bf). Red: `install refuses a same-named directory it did not
install, and --force adopts it`, `update never touches a directory it
did not install`; Tests 2 failed / 20 passed. Restored: blob == HEAD,
`git diff HEAD` empty. A first A1 attempt replaced the line with an
`else` that left a dangling `else` (transform error, "no tests"): a
vacuous run, discarded and rerun as above.
- Ablation A2 (status mismatch): `mismatch: !versionMatches ||
missing.length > 0` → `mismatch: /* ABLATION-A2 */ missing.length > 0`
(blob f1cef08 → a70e150850d1). Red: the Done-when test, `status: a
version mismatch exits 0 by default and 1 with --check`, `status with
nothing installed`; Tests 3 failed / 19 passed. Restored: blob == HEAD,
`git diff HEAD` empty.
- Live, against the real registry (not a test): in an empty scratch
directory, `node packages/cli/bin/run.js skills install --version
18.5.0` installed 11 skills (`objectstack-data` byte-identical, `diff
-r`, to the `npm pack` tarball's `dist/skills/objectstack-data`);
`status --version 18.5.0 --check` exit 0; `status --check` (CLI fallback
18.5.0) exit 0; `update --version 99.0.0` exit 1, `@objectstack/skills
99.0.0 is not published on the npm registry this environment uses (npm
pack @objectstack/skills@99.0.0: No matching version found for
@objectstack/skills@99.0.0.). Nothing was written.`; `update --version
18.4.0` exit 0, then `status --check` exit 1, `The catalog is 18.4.0,
not 18.5.0`.
</details>
## Review round (S1, S2, S3, N1)
- **S1, paths stay under the skills directory.** A tarball path segment,
a recorded skill name and a recorded file path are refused when a
segment is empty, `.`, `..`, or holds a backslash or a colon
(`isSafePathSegment`, `skills-catalog.ts`). `applySkillsWrite` resolves
every target (dropped skills, skill roots, files) and refuses any that
does not lie strictly under the skills root, before the first write.
- **S2, malformed records are refused whole.** `readSkillsManifest`
validates recorded skill names with the catalog's own `SKILL_NAME` rule
and recorded file paths with the S1 segment rule, so an empty name can
no longer make `update --force` remove the skills directory itself.
- **S3, Windows `npm pack`.** The invocation is built by
`npmPackInvocation`; under `shell: true` (win32) the
`--pack-destination` path is quoted, so a temp path with a space stays
one argument.
- Red first: commit e5b66d7 adds the pins and moves the invocation
into `npmPackInvocation` with behaviour unchanged;
`test/skills-commands.test.ts` then reads 5 failed / 25 passed: `refuses
a Windows separator or a drive letter in a path segment`, `refuses a
catalog file whose target resolves outside the skills directory, and
writes nothing there`, `refuses a record naming a skill or a file with a
Windows separator or a drive letter`, `on Windows runs through a shell
and quotes the destination, so a path with a space stays one argument`,
`a malformed record is refused whole > an empty skill name` (the `..`
and backslash-name rows were already refused and stay as controls).
Commit bbb4b55 fixes them: 30 passed; `pnpm --filter @objectstack/cli
typecheck` exit 0.
## DELIBERATE CORRECTION
`.changeset/34686-initialize-selection-rule.md` is a pending release
note (not yet on npm: the `@objectstack/mcp` 18.5.0 tarball carries no
`Published skills` text) that this PR makes false, so it is corrected
here and `check-empty-changeset` stays red on it by design. Its
install-line bullet now reads: "**The skills install line**: `Published
skills: @objectstack/skills <version>` with the command that installs it
into the agent's skills directory, with or without a project, `os skills
install --version <version>`, at this package's own version (released
together with `@objectstack/skills`), not the `version` option." The
sentence in `.changeset/34773-os-skills-install.md` that said this PR
supersedes the `pnpm add -D` wording in the same release is removed,
since that wording no longer ships.
## Acceptance notes
- **"Active target".** `os validate --target` has no default target, so
there is no implicit active target to reuse; the order is `--version`,
`--target`, the CLI's version. Not invented here.
- **An open-source server does not publish its skills version over
HTTP.** `RESTRICTION_PROFILE_ROUTE`
(`/api/v1/discovery/restriction-profile`) is served by cloud only (its
docblock in `restriction-profile.ts`), so `--target
http://localhost:3000` against `os dev` is refused by the validate
reader's own 404 sentence. For an open server the version reaches the
user through the MCP `initialize` line, which now carries `--version
VERSION`. Noted, not filed: it is the reader's existing behaviour.
- **`/mcp/skill` carries no install line.** The order said the install
line rides `initialize` and `/mcp/skill`; on `a841e26b23` only
`skillsInstallLine` in `mcp-server-runtime.ts` (the `initialize` text)
carries it (`git grep "Published skills"`: one source hit). Only that
one changed.
- The `skills-reference.mdx` page and `packages/skills/README.md` still
document the `pnpm add -D` plus `experimental_sync` path, which keeps
working; `skills.mdx` now leads with `os skills`. Left for the skills
lane.
<details><summary>Verification (local gate subset, head
bec9bdc)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 118 families derived from
`objectstack-ai/objectstack` at `bec9bdc5cb`. All 118 run, exit codes
captured before any pipe; `--ran` reconciliation: `118 derived, 115 run,
3 NOT-MEASURED, 0 UNRUN`.
- NOT MEASURED (exit 3, prerequisite not met, left to CI):
`check:skill-examples` (needs `@objectstack/client-react` built),
`check:dual-build-cjs-loads` (needs a full build), `check:i18n-coverage`
(`examples/app-showcase` config failed to lint without a full build).
- Every other derived family exit 0, including `check:cli-command-ids`
(`1401 command-id literal(s) across 461 file(s) outside packages/cli all
resolve`, 115 ids derived), `check:cli-examples-parity`,
`check:cli-test-child-env`, `check:doc-anchors`, `check:doc-authoring`,
`check:docs-transcript-drift`, `check:nul-bytes`,
`check:published-files`, `check:changeset-fixed`,
`check-empty-changeset`, `check-changeset-no-major` (base axis),
`check:test-source-alias`, `check:cross-package-test-inputs`.
- `node scripts/pm/overlap-check.mjs
--branch=claude/issue-34773-os-skills-install`: `VERDICT clean exit 0`
(origin/main merges cleanly; #34717 and #33849 share
`packages/cli/package.json`, both merge cleanly).
- `node scripts/pm/check-governed-merges.mjs --branch
claude/issue-34773-os-skills-install`: `0 of 15 path(s) hit the
register`, NOT governed; 1518 changed lines.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzgNCAXyGfBQFZBwixH -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 59defa0 commit 0c60897
16 files changed
Lines changed: 1605 additions & 14 deletions
File tree
- .changeset
- content/docs
- ai
- deployment
- packages
- cli
- src
- commands/skills
- utils
- test
- mcp
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
306 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
30 | 44 | | |
31 | 45 | | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
36 | 50 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3679 | 3679 | | |
3680 | 3680 | | |
3681 | 3681 | | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
3682 | 3765 | | |
3683 | 3766 | | |
3684 | 3767 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments