@duyquangnvx/agent-cli 0.23.0 → 0.24.0

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/agent-cli.js +16 -12
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/built-ins/commands.d.ts +2 -2
  5. package/dist/built-ins/commands.js +2 -2
  6. package/dist/built-ins/doctor.js +0 -2
  7. package/dist/built-ins/doctor.js.map +1 -1
  8. package/dist/built-ins/install/global-npm.d.ts +2 -0
  9. package/dist/built-ins/install/global-npm.js +7 -3
  10. package/dist/built-ins/install/global-npm.js.map +1 -1
  11. package/dist/built-ins/install/global.d.ts +1 -1
  12. package/dist/built-ins/install/global.js +9 -7
  13. package/dist/built-ins/install/global.js.map +1 -1
  14. package/dist/built-ins/install/install.d.ts +4 -2
  15. package/dist/built-ins/install/install.js.map +1 -1
  16. package/dist/built-ins/npm.d.ts +5 -3
  17. package/dist/built-ins/npm.js +7 -3
  18. package/dist/built-ins/npm.js.map +1 -1
  19. package/dist/built-ins/setup.d.ts +6 -0
  20. package/dist/built-ins/setup.js +168 -0
  21. package/dist/built-ins/setup.js.map +1 -0
  22. package/dist/built-ins/skill/home.d.ts +28 -0
  23. package/dist/built-ins/skill/home.js +116 -0
  24. package/dist/built-ins/skill/home.js.map +1 -0
  25. package/dist/built-ins/skill/install-command.d.ts +0 -13
  26. package/dist/built-ins/skill/install-command.js +7 -58
  27. package/dist/built-ins/skill/install-command.js.map +1 -1
  28. package/dist/built-ins/skill/project.d.ts +5 -0
  29. package/dist/built-ins/skill/project.js +46 -0
  30. package/dist/built-ins/skill/project.js.map +1 -0
  31. package/dist/built-ins/skill/skill.d.ts +7 -31
  32. package/dist/built-ins/skill/skill.js +18 -6
  33. package/dist/built-ins/skill/skill.js.map +1 -1
  34. package/dist/built-ins/skill/sync.d.ts +16 -0
  35. package/dist/built-ins/skill/sync.js +35 -0
  36. package/dist/built-ins/skill/sync.js.map +1 -0
  37. package/dist/built-ins/update.d.ts +2 -2
  38. package/dist/built-ins/update.js +23 -20
  39. package/dist/built-ins/update.js.map +1 -1
  40. package/dist/built-ins/upgrades.d.ts +1 -0
  41. package/dist/built-ins/upgrades.js +5 -0
  42. package/dist/built-ins/upgrades.js.map +1 -1
  43. package/dist/context/tools.d.ts +1 -0
  44. package/dist/context/tools.js +1 -1
  45. package/dist/context/tools.js.map +1 -1
  46. package/dist/define.d.ts +28 -34
  47. package/dist/define.js.map +1 -1
  48. package/dist/exit-classes.js +1 -0
  49. package/dist/exit-classes.js.map +1 -1
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/output.js +5 -3
  54. package/dist/output.js.map +1 -1
  55. package/dist/run-cli.js +2 -6
  56. package/dist/run-cli.js.map +1 -1
  57. package/dist/run-command.js +2 -7
  58. package/dist/run-command.js.map +1 -1
  59. package/dist/runtime-codes.d.ts +1 -0
  60. package/dist/runtime-codes.js +2 -0
  61. package/dist/runtime-codes.js.map +1 -1
  62. package/docs/README.md +1 -1
  63. package/docs/getting-started.md +6 -6
  64. package/docs/guides/doctor.md +3 -4
  65. package/docs/guides/errors.md +2 -0
  66. package/docs/guides/shipping.md +32 -24
  67. package/docs/principles.md +1 -1
  68. package/docs/reference.md +1 -0
  69. package/package.json +1 -1
  70. package/dist/built-ins/skill/hub.d.ts +0 -8
  71. package/dist/built-ins/skill/hub.js +0 -114
  72. package/dist/built-ins/skill/hub.js.map +0 -1
  73. package/dist/built-ins/skill/packaged.d.ts +0 -13
  74. package/dist/built-ins/skill/packaged.js +0 -97
  75. package/dist/built-ins/skill/packaged.js.map +0 -1
  76. package/dist/built-ins/skill/usage-hint.d.ts +0 -4
  77. package/dist/built-ins/skill/usage-hint.js +0 -28
  78. package/dist/built-ins/skill/usage-hint.js.map +0 -1
@@ -42,11 +42,10 @@ The Runtime's `secrets` row checks every Secret the CLI and its Commands declare
42
42
 
43
43
  The `install` and `registry` rows follow `defineCli({ install })`, and are `skipped` without it. Both are advisory: a project may stay on an older release on purpose.
44
44
 
45
- - **Global install:** `install` checks that the CLI runs from npm's global folder, else gives the global install line; `registry` compares the build with the registry's latest and gives `<cli> update`.
45
+ - **Global install:** `install` checks that the CLI runs from npm's global folder, else gives the `setup` line; `registry` compares the build with the registry's latest and gives `<cli> update`.
46
46
  - **Dependency install:** `install` checks that the copy that runs is the one the project at the working directory installed. It is `skipped` with `registry` when the CLI runs from source or the project links the package from its workspace, which decides its version. Otherwise another copy than the project's gets `<run-as> doctor`, which runs the project's copy; a project that has not installed the package gets its install line (`pnpm install`, `npm install`) when a `package.json` at or above the working directory lists it, else its add line, and a copy whose `package.json` is unreadable gets the install line too; yarn and bun get no line. With no copy installed, npx refuses before the CLI starts, so these fixes reach only a CLI run from another copy. `registry` compares the build with the latest release npm finds from the project root and gives `pnpm up --latest …` or `npm install …@latest`, naming the `lockstep` packages; for yarn and bun it names the version to move to instead.
47
47
 
48
48
  The `skill` row follows `defineCli({ skill })` ([`shipping.md`](shipping.md)):
49
49
 
50
- - **Skill Hub, `{ source }`:** the row is always ok and names every installed copy against the running CLI; its fix installs the skill from the hub. Without `skill` it gives `skills update` for an older copy and nothing to install a missing one.
51
- - **Skill Hub, `{ add }`:** as for `{ source }`, but the fix gives the declared line verbatim; what each copy gets is in the `skill` JSDoc of `defineCli`.
52
- - **Packaged skill, `{ packaged }`:** the row is advisory, and the Runtime also gives a Notice of its problem and, when it declares `agents`, an `agents` row; what each reports is in the `skill` JSDoc of `defineCli`. Do not check the Skill copy or the Agents section in your own rows or Notices.
50
+ - **No `skill`:** the row is skipped.
51
+ - **Declared:** the row is advisory, and looks for the copy where the Install puts it; a CLI that declares `agents` also has an `agents` row. What each reports is in the `skill` JSDoc of `defineCli`. Do not check the Skill copy or the Agents section in your own rows or Notices.
@@ -41,6 +41,8 @@ throw ctx.fail(
41
41
 
42
42
  The exit code is the failure's Exit class: 1 the caller, 2 the operator, 3 someone at the source, 75 nobody but time (wait, then run again), 70 a bug, 130 or 143 an interrupt by SIGINT or SIGTERM. A `UsageError` exits 1, for input your schemas could not reject: give it the code `INVALID_INPUT`.
43
43
 
44
+ When only the person can act, such as opening an approval link, say in the hint that they see only the agent's reply, not command output, so the agent writes the link or code in its reply first, then runs the Next step that waits. Told only to relay it, weaker models ran the wait without writing the link.
45
+
44
46
  A code missing from the table, and anything else thrown, is a bug, exit 70, unless it wraps a missed deadline (Wrapping a failure in [`long-runs.md`](long-runs.md)). Its hint says to rerun under `<NAME>_DEBUG=1` for the stack trace and its `cause` chain, and to report it at package.json's `bugs` when declared.
45
47
 
46
48
  Every Runtime code is on the exported `runtimeCodes`, such as `runtimeCodes.OUTPUT_EXISTS` or `runtimeCodes.TOOL_FAILED`: catch, return and assert codes through it. A Command throws a Runtime code only where it means what the Runtime means by it: `INVALID_INPUT`, a file code from `ctx.fileError`, `TOOL_MISSING` or `TOOL_FAILED`. The others, such as `UNKNOWN_COMMAND` or `DOCTOR_PROBLEMS`, name the Runtime's own checks, so a Command only catches or asserts them.
@@ -1,35 +1,41 @@
1
1
  # Shipping: install, the skill beside the CLI, release
2
2
 
3
- The Scaffolder writes the release setup: `install` in `defineCli`, `publishConfig.registry` in `package.json`, `CHANGELOG.md` with its format in its first paragraph, `scripts/release.ts`, and the CLI skill at `skills/<name>/SKILL.md` with its setup reference. These are the decisions it leaves to you.
3
+ The Scaffolder writes the release setup: `install` in `defineCli`, `publishConfig.registry` in `package.json`, `CHANGELOG.md` with its format in its first paragraph, `scripts/release.ts`, the CLI skill at `skills/<name>/SKILL.md`, and the CLI docs in `docs/cli/`, starting with `README.md` and `setup.md`. These are the decisions it leaves to you.
4
4
 
5
5
  ## How a user installs it
6
6
 
7
- `defineCli({ skill })` names where the CLI's skill comes from, and with it the `skill` row's fix:
7
+ Every CLI ships one kind of skill: a trigger that holds what stays true across releases, its description, the install line, and the injected `--version`, whose `docs <path>` line names the CLI docs. So updating the CLI needs no skill update. `defineCli({ docs: "docs/cli" })` declares that folder, which `package.json` `files` lists, so a repo's developer docs under `docs/` stay out of the package.
8
8
 
9
- - `{ source: "<git URL>" }`, a git Skill Hub: the skill arrives apart from the CLI and lives in the user's home, one copy for every project. The Scaffolder's `--skill-hub-git` sets it.
10
- - `{ add: "<command line>" }`, a Skill Hub whose install line the Runtime cannot build, such as an API Skill Hub that gives each user their own install URL: as for `{ source }`, but `doctor` gives that line verbatim. The Scaffolder's `--skill-hub-api` with `--skill-add` sets it.
11
- - `{ packaged: "skills/<name>" }`, a Packaged skill: the skill ships inside the CLI's package, so the copy always matches the CLI that installed it. It needs a CLI with several Commands, and leaves the name `skill` to the Runtime. The Scaffolder's `--dependency` sets it.
9
+ `defineCli({ skill: { folder: "skills/<name>" } })` declares that skill, which ships in the package, so list `skills` in `package.json` `files`: publishing the package publishes it. It needs a CLI with several Commands, since only those have Built-in Commands. The Install decides where its Skill copy goes.
12
10
 
13
- ### From a Skill Hub
11
+ ### With a Global install
14
12
 
15
- The CLI comes from the registry and its skill from a Skill Hub, so they arrive apart; the skill names the version it describes in `metadata.version`, which each release stamps, and `doctor`'s `skill` row compares every installed copy with the running CLI. The README gives both lines, the skill first, since the agent that loads it can then install the CLI: the skill's `references/setup.md` walks it through installing, checking and updating. The install line is the one fact the skill holds as text, since nothing runs before the CLI is installed. The Scaffolder writes it into the setup reference and the README, and the new CLI's `test/cli.test.ts` fails when either differs from what `doctor` gives as the `install` row's fix, or the README's skill line from the `skill` row's fix. Add to the setup reference what only your CLI needs before its first run, such as a sign-in, a key or a trial run.
13
+ Hand users one sentence to paste to their Coding agent, holding the line and their task, which the Scaffolder writes first in the README:
16
14
 
17
- - Each release puts the skill on the Skill Hub named as `skillHub` in `scripts/release.ts`: `{ git }`, the same git URL as `skill.source`, which it commits to, or `{ api }`, which it publishes to with the token in `SKILL_HUB_TOKEN`. `main` of the CLI's own repo may describe what is still unreleased.
18
- - `{ add }` is declared beside `skillHub: { api }`, never derived from it: a hub's install routes are its own.
19
- - A Coding agent's sandbox denies writes to the skills folders and to the global npm prefix, so the user types both lines, with `!` in Claude Code. `-y` is npx's own: with no terminal to answer on, npx cancels its download question.
20
- - Nothing prints at install or first run: package managers block install scripts, and a first-run line is noise on an agent's stderr.
15
+ > Run `npx -y <package>@latest setup`, then use `<name>` to `<task>`.
21
16
 
22
- ### A Packaged skill
17
+ The task is what carries the agent past the install; without it, the agent stops there ([ADR 0016](https://github.com/duyquangnvx/cli-for-agent/blob/main/docs/adr/0016-a-cli-installs-itself-and-its-skill-from-one-setup.md)). The Built-in `setup` runs from npx's copy, installs the latest release, copies the skill to `~/.claude/skills/<name>` and `~/.agents/skills/<name>`, and names the CLI docs, so the session goes on even when the new skill has not loaded. It takes no sign-in: the first Command that needs one asks for it.
23
18
 
24
- Choose it when projects pin different versions of the CLI, as with a Dependency install: each project then loads the skill of the version it pins, where one Skill Hub copy in home serves every project, which suits a Global install's one copy per machine.
19
+ - The line is what `setupLineOf` builds, with the registry's flag when the Install registry is not npmjs. The scaffolded `test/cli.test.ts` fails when the skill, the README or `docs/cli/setup.md` lack it, which it reads from `doctor`'s `install` row.
20
+ - `setup` is safe to run again. A Next step on its failure is the same line, since the CLI's own name may not run yet. A Coding agent's sandbox denies writes to the skills folders and the global npm prefix, so its user types that line, with `!` in Claude Code. `-y` is npx's own: with no terminal to answer on, npx cancels its download question.
21
+ - `setup` fails with `NOT_ON_PATH` when the global bin folder is off this shell's `PATH`, once the CLI and the skill are in place. It refuses an `npm link` at the global location.
22
+ - `update` makes the copies match the release it leaves installed, so a release that changes the skill asks nothing of its users.
23
+ - A Global install declares no `agents`: it has no repo to write to.
24
+ - `skill` and `skillHub` in `scripts/release.ts` stay optional: a Skill Hub helps people find the skill, and no install needs one. `{ git }` commits to a repo and `{ api }` publishes with the token in `SKILL_HUB_TOKEN`. A skill the Hub already holds skips the Hub, and a skill stating `metadata.version` is refused.
25
25
 
26
- The CLI comes first, then its Built-in `skill install` copies the skill into the project, so the README gives the CLI's install line, then `<run-as> skill install`, the `skill` row's fix, which the user types with `!` in Claude Code. List `skills` in `package.json` `files`: publishing the package publishes the skill, and each release stamps its `metadata.version` as for a hub. What `skill install` copies, refreshes and writes is in the `skill` JSDoc of `defineCli`.
26
+ ### With a Dependency install
27
+
28
+ The project carries the skill, so the repo's sessions load it without anyone installing it elsewhere. The CLI comes first, then its Built-in `skill install` copies the skill into the project, so the README gives the CLI's install line, then `<run-as> skill install`, the `skill` row's fix, which the user types with `!` in Claude Code. A release that changes the skill lists `<run-as> skill install` under `### Upgrade from`. What `skill install` copies and writes is in the `skill` JSDoc of `defineCli`.
29
+
30
+ ### Reading the CLI docs
31
+
32
+ The skill's `allowed-tools`, `Read(//**/node_modules/<package>/docs/cli/**)`, covers the turn that loads it. After that a read outside the working directory depends on the Coding agent: Claude Code asks in its default mode, and passes it in auto mode. No CLI writes settings.
27
33
 
28
34
  ## Global or Dependency install
29
35
 
30
- The Scaffolder declares a Global install, `install: "global"`: one copy per machine, which the Built-in `update` replaces with the latest release. Choose a Dependency install, `install: "dependency"`, or `{ mode: "dependency", lockstep }` with lockstep packages, when each project pins the CLI's version as a devDependency, as a CLI does when it shapes the project's own files. Either way the package is `manifest.name`, from the `package.json` given to `defineCli` as `manifest`, and a Global install's Install registry is its `publishConfig.registry`, without which `defineCli` throws. When users install from a mirror of the registry releases publish to, such as a public proxy of one behind a VPN, declare `{ mode: "global", registry }` with the mirror's URL; `publishConfig.registry` then serves only the release. The Scaffolder's `--dependency` starts one: `install: "dependency"` with a Packaged skill, every line it writes starting with the run-as, and `publishConfig` and `scripts/release.ts` as for a Global install, since publishing is the same.
36
+ The Scaffolder declares a Global install, `install: "global"`: one copy per machine, which the Built-in `setup` puts there and `update` replaces with the latest release. Choose a Dependency install, `install: "dependency"`, or `{ mode: "dependency", lockstep }` with lockstep packages, when each project pins the CLI's version as a devDependency, as a CLI does when it shapes the project's own files. Either way the package is `manifest.name`, from the `package.json` given to `defineCli` as `manifest`, and a Global install's Install registry is its `publishConfig.registry`, without which `defineCli` throws. When users install from a mirror of the registry releases publish to, such as a public proxy of one behind a VPN, declare `{ mode: "global", registry }` with the mirror's URL; `publishConfig.registry` then serves only the release. The Scaffolder's `--dependency` starts one: `install: "dependency"`, every line it writes starting with the run-as, and `publishConfig` and `scripts/release.ts` as for a Global install, since publishing is the same.
31
37
 
32
- A Global install of a CLI with several Commands runs a Release check: at most once a day, a run starts a detached `npm view` against the Install registry, and a later run gives a Notice such as ``tool 1.1.0 is out, this is 1.0.0; run `tool update` `` until `update` brings the CLI level. It only tells: an install it ran on its own would skip the release's Upgrade steps and leave the agent's loaded skill describing the old version. No run waits on the registry, and a failed check is retried the next day; `<NAME>_DEBUG=1` shows why it failed. It is off when `CI` is set, and for one CLI when the operator sets `<NAME>_NO_RELEASE_CHECK=1`; it writes its time and answer to `$XDG_CACHE_HOME/<name>/release-check.json`, by default under `~/.cache`.
38
+ A Global install of a CLI with several Commands runs a Release check: at most once a day, a run starts a detached `npm view` against the Install registry, and a later run gives a Notice such as ``tool 1.1.0 is out, this is 1.0.0; run `tool update` `` until `update` brings the CLI level. It only tells: an install it ran on its own would skip the release's Upgrade steps. No run waits on the registry, and a failed check is retried the next day; `<NAME>_DEBUG=1` shows why it failed. It is off when `CI` is set, and for one CLI when the operator sets `<NAME>_NO_RELEASE_CHECK=1`; it writes its time and answer to `$XDG_CACHE_HOME/<name>/release-check.json`, by default under `~/.cache`.
33
39
 
34
40
  A Dependency install:
35
41
 
@@ -37,9 +43,9 @@ A Dependency install:
37
43
  - The Runtime adds no `update`: the project's package manager moves the version, so the name stays free for a Command of the CLI's own.
38
44
  - It declares no registry: `doctor` runs npm at the project root, the nearest folder with a lockfile, so the project's `.npmrc` names the registry and its token.
39
45
  - List under `lockstep` the packages released at the CLI's version, such as a kit its Commands write code against, so `doctor`'s fix moves them together.
40
- - Declare a Packaged skill, so the skill a project loads matches the version it pins.
41
- - The README and the setup reference give the project's add line, `pnpm add -D <package> <lockstep…>`, then `<run-as> skill install`. The scaffolded test compares the add line with `doctor`'s `install` fix, which that row gives only in a project that neither installs nor lists the CLI, so the test runs `doctor` from a temporary one.
42
- - With no copy installed, npx refuses before the CLI starts, so `doctor` cannot guide a fresh checkout: the setup reference says to run the project's install when a `package.json` lists the package, else the add line.
46
+ - Declare a skill, so the repo carries a copy; the CLI docs match the version it pins, since they ship in the package.
47
+ - The README and the skill give the project's add line, `pnpm add -D <package> <lockstep…>`, then `<run-as> skill install`. The scaffolded test compares the add line with `doctor`'s `install` fix, which that row gives only in a project that neither installs nor lists the CLI, so the test runs `doctor` from a temporary one.
48
+ - With no copy installed, npx refuses before the CLI starts, so `doctor` cannot guide a fresh checkout: the skill says to run the project's install when a `package.json` lists the package, else the add line.
43
49
 
44
50
  ## Release
45
51
 
@@ -47,20 +53,22 @@ Log each change a caller would notice under `## Unreleased` in `CHANGELOG.md` as
47
53
 
48
54
  `update` shows the user each release between the version they leave and the one installed, oldest first. A CLI with local state, a daemon or an extension has releases that ask something of the user, such as a fetch after a store rebuild, and those steps get lost among the other entries. So a release that lists them under the `### Upgrade from` heading the CHANGELOG's first paragraph asks for shows only those steps, and nothing when they read `Nothing to do.`; a release without the heading shows its whole section.
49
55
 
50
- ## The CLI's own skill
56
+ ## The CLI docs
57
+
58
+ The skill's description says when to use the CLI and the nearby tasks it is not for, since the agent always sees it. Everything else about the work goes in the CLI docs, which have no required shape: an agent given the folder finds its way, so `README.md` is a help the Scaffolder starts, and each release checks only that the folder holds files.
51
59
 
52
- - **`--help` describes the tool; the skill describes the agent's work around it:** workflows naming Commands in order, and what to do for each error code that needs judgement beyond its hint. It names a flag only when a workflow needs one. When to use the CLI, and the nearby tasks it is not for, go in the description, which the agent always sees.
60
+ - **`--help` describes the tool; the CLI docs describe the agent's work around it:** workflows naming Commands in order, and what to do for each error code that needs judgement beyond its hint. They name a flag only when a workflow needs one.
53
61
  - **A line earns its place only when nothing the agent will see says it**: not `--help`, a Command's output, an error's hint, or a `doctor` row. The Runtime's conventions, such as `--json`, `--dry-run`, the error format and the exit codes, show themselves on first use. Keep what costs the agent turns to work out: a convention of the source, the reason behind a step, a trap, a step that needs the user's consent.
54
62
  - **A guardrail on a flag goes in the workflow step that passes it**, read before the run rather than after it fails.
55
- - **Its Recovering from errors table holds only the codes whose right move goes beyond the hint**; the exit codes are in `--help`. The Runtime's own hints already cover a Coding agent's sandbox refusing the registry with a 403, the `<NAME>_DEBUG` variable of an `INTERNAL` error, and a Skill copy of another version naming input the CLI does not know, so those need no row. It stays in `SKILL.md`, not under `references/`: it matters when the agent believes the hint is enough, which is when a pointer to it would not fire.
56
- - **Check it with a fresh subagent** given only the skill's path and a real task. Cut a sentence for a failure whose hint already says what to do.
63
+ - **List in a Recovering from errors table only the codes whose right move goes beyond the hint**; the exit codes are in `--help`. The Runtime's own hints already cover a Coding agent's sandbox refusing the registry with a 403 and the `<NAME>_DEBUG` variable of an `INTERNAL` error, so those need no row.
64
+ - **Check them with a fresh subagent** given only the skill's path and a real task. Cut a sentence for a failure whose hint already says what to do.
57
65
 
58
66
  ## An Agents section
59
67
 
60
68
  A CLI owns one Agents section in the repo's `AGENTS.md`, between `<!-- BEGIN:<name> -->` and `<!-- END:<name> -->`, rewritten between its markers and leaving the rest as it was. Claude Code reads `AGENTS.md` only through an `@AGENTS.md` line in `CLAUDE.md`, so whatever writes the section names that line as a hand edit; no CLI edits `CLAUDE.md`.
61
69
 
62
70
  - The section holds what every session in the repo needs even when it never calls the CLI, such as how to name what the CLI later finds by name, plus a line saying when to load the CLI's skill; how to use the CLI is the skill's. Every session reads it, so keep it short.
63
- - A Packaged skill declares its text as `skill: { packaged, agents }`, and `skill install` writes it verbatim between the markers; without `agents` it writes no section. Otherwise a Command of the CLI's own writes the section.
71
+ - A Dependency install's skill declares its text as `skill: { folder, agents }`, and `skill install` writes it verbatim between the markers; without `agents` it writes no section. Otherwise a Command of the CLI's own writes the section.
64
72
 
65
73
  ## What to build next
66
74
 
@@ -36,4 +36,4 @@ Files, programs, the environment, Secrets, the clock and remote services all rea
36
36
 
37
37
  ## The CLI keeps its own house
38
38
 
39
- `doctor` checks the build, the install, the registry, the tools, the Secrets and the skill, and gives the line that fixes each problem. `update` moves a Global install to the latest release. The CLI's skill describes the agent's work around the CLI, not its flags, and each release ships it beside the CLI ([`guides/shipping.md`](guides/shipping.md), [`guides/doctor.md`](guides/doctor.md)).
39
+ `doctor` checks the build, the install, the registry, the tools, the Secrets and the skill, and gives the line that fixes each problem. `setup` puts a Global install and its skill on a machine, and `update` moves both to the latest release. The CLI's skill describes the agent's work around the CLI, not its flags, and each release ships it inside the package ([`guides/shipping.md`](guides/shipping.md), [`guides/doctor.md`](guides/doctor.md)).
package/docs/reference.md CHANGED
@@ -19,6 +19,7 @@ The JSDoc in the package's `.d.ts` files is the API reference: every export and
19
19
  | `paginate`, `page`, `Page` | [`dist/list.d.ts`](../dist/list.d.ts) |
20
20
  | `NextStep`, `Rerun` | [`dist/next-step.d.ts`](../dist/next-step.d.ts) |
21
21
  | `runAsOf` | [`dist/built-ins/install/run-as.d.ts`](../dist/built-ins/install/run-as.d.ts) |
22
+ | `setupLineOf` | [`dist/built-ins/install/global-npm.d.ts`](../dist/built-ins/install/global-npm.d.ts) |
22
23
  | `runCli`, `RunOptions`, `RunResult` | [`dist/run-cli.d.ts`](../dist/run-cli.d.ts), [`dist/run-options.d.ts`](../dist/run-options.d.ts) |
23
24
  | `runProcess`, the bin's entry | [`dist/run-process.d.ts`](../dist/run-process.d.ts) |
24
25
  | `Style`, for `render` | [`dist/style.d.ts`](../dist/style.d.ts) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duyquangnvx/agent-cli",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Runtime for agent-first command-line tools: owns parsing, output, errors and exit codes.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1,8 +0,0 @@
1
- import type { Env } from "../../context.js";
2
- import type { HubSkillSource } from "../../define.js";
3
- import type { Skill, SkillCli } from "./skill.js";
4
- /** The version a SKILL.md's frontmatter `metadata.version` states. */
5
- export declare function skillVersionIn(skill: string): string | undefined;
6
- export declare function homeOf(env: Env): string;
7
- /** A skill on a Skill Hub, which `from` says how to install; without it, no line adds it. */
8
- export declare function hubSkill(cli: SkillCli, from: HubSkillSource | undefined): Skill;
@@ -1,114 +0,0 @@
1
- import { readFile, realpath } from "node:fs/promises";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
4
- import { isMissingFile } from "../../errors.js";
5
- import { isVersion, standingOf } from "../semver.js";
6
- // Everything here mirrors how the skills@1.7.2 installer (`npx skills`) behaves.
7
- const SKILL_DIRS = [
8
- [".claude", "skills"],
9
- [".agents", "skills"],
10
- ];
11
- const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---/;
12
- const METADATA_VERSION = /^metadata:[ \t]*\r?\n(?:[ \t]+.*\r?\n)*?[ \t]+version:[ \t]*["']?([^"'\s]+)["']?[ \t]*$/m;
13
- /** The version a SKILL.md's frontmatter `metadata.version` states. */
14
- export function skillVersionIn(skill) {
15
- const frontmatter = FRONTMATTER.exec(skill)?.[1];
16
- return frontmatter === undefined ? undefined : METADATA_VERSION.exec(`${frontmatter}\n`)?.[1];
17
- }
18
- export function homeOf(env) {
19
- return env.HOME ?? env.USERPROFILE ?? homedir();
20
- }
21
- async function copyAt(path, version) {
22
- let skill;
23
- try {
24
- skill = await readFile(join(path, "SKILL.md"), "utf8");
25
- }
26
- catch (error) {
27
- if (isMissingFile(error)) {
28
- return undefined;
29
- }
30
- return { path, version: undefined, state: "unreadable" };
31
- }
32
- const stated = skillVersionIn(skill);
33
- if (stated === undefined || !isVersion(stated) || !isVersion(version)) {
34
- return { path, version: stated, state: "unversioned" };
35
- }
36
- return { path, version: stated, state: standingOf(stated, version) };
37
- }
38
- async function skillCopies(cliName, version, { cwd, env }) {
39
- const roots = [cwd, homeOf(env)];
40
- const paths = roots.flatMap((root) => SKILL_DIRS.map((dir) => join(root, ...dir, cliName)));
41
- const seen = new Set();
42
- const copies = [];
43
- for (const path of paths) {
44
- const copy = await copyAt(path, version);
45
- // The project may be home itself, or one skill dir a link to the other.
46
- const real = copy === undefined ? undefined : await realpath(path);
47
- if (copy !== undefined && real !== undefined && !seen.has(real)) {
48
- seen.add(real);
49
- copies.push(copy);
50
- }
51
- }
52
- return copies;
53
- }
54
- const has = (copies, wanted) => copies.some(({ state }) => state === wanted);
55
- // `--skill` installs only this CLI's skill from a repo that holds several.
56
- function addLineOf(cliName, from) {
57
- return "add" in from ? from.add : `npx -y skills add ${from.source} --skill ${cliName} -g`;
58
- }
59
- // `skills update` skips a copy it did not install, which is how most unversioned copies got there.
60
- // A copy ahead gets no fix: doctor's registry row already says when the CLI itself is behind.
61
- function fixFor(cliName, copies, from) {
62
- const update = `npx -y skills update ${cliName}`;
63
- const add = from === undefined ? undefined : addLineOf(cliName, from);
64
- if (copies.length === 0) {
65
- return add;
66
- }
67
- if (has(copies, "unversioned") && add !== undefined) {
68
- return has(copies, "behind") ? `${update} && ${add}` : add;
69
- }
70
- return has(copies, "behind") || has(copies, "unversioned") ? update : undefined;
71
- }
72
- const SKILL_STATE_NOTES = {
73
- current: "the same as this build",
74
- behind: "older than this build",
75
- ahead: "newer than this build",
76
- unversioned: "states no metadata.version",
77
- unreadable: "could not be read",
78
- };
79
- function describeCopy({ path, version, state }) {
80
- return `${path}${version === undefined ? "" : ` ${version}`} (${SKILL_STATE_NOTES[state]})`;
81
- }
82
- /** A skill on a Skill Hub, which `from` says how to install; without it, no line adds it. */
83
- export function hubSkill(cli, from) {
84
- const findingOf = (copies) => {
85
- const fix = fixFor(cli.name, copies, from);
86
- const message = copies.length === 0
87
- ? `no copy of the ${cli.name} skill is installed`
88
- : copies.map(describeCopy).join("; ");
89
- return fix === undefined ? { state: "ok", message } : { state: "ok", message, fix };
90
- };
91
- return {
92
- kind: "hub",
93
- builtIns: {},
94
- rows: [
95
- {
96
- name: "skill",
97
- advisory: true,
98
- run: async (ctx) => findingOf(await skillCopies(cli.name, cli.version, ctx)),
99
- },
100
- ],
101
- notice: async () => { },
102
- differing: async (place) => (await skillCopies(cli.name, cli.version, place))
103
- .filter(({ state }) => state !== "current" && state !== "unreadable")
104
- .map(describeCopy),
105
- // `update` compares the copies with the latest release even when it installed nothing: the
106
- // installer gives that release's skill.
107
- nextAt: async (version, ctx) => {
108
- const copies = await skillCopies(cli.name, version, ctx);
109
- const fix = fixFor(cli.name, copies, from);
110
- return fix === undefined ? [] : [fix];
111
- },
112
- };
113
- }
114
- //# sourceMappingURL=hub.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hub.js","sourceRoot":"","sources":["../../../src/built-ins/skill/hub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAiB,UAAU,EAAE,MAAM,cAAc,CAAC;AAGpE,iFAAiF;AAEjF,MAAM,UAAU,GAAG;IACjB,CAAC,SAAS,EAAE,QAAQ,CAAC;IACrB,CAAC,SAAS,EAAE,QAAQ,CAAC;CACb,CAAC;AAUX,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,MAAM,gBAAgB,GACpB,0FAA0F,CAAC;AAE7F,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,WAAW,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChG,C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KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,13 +0,0 @@
1
- import * as z from "zod";
2
- import type { PackagedSkillSource } from "../../define.js";
3
- import type { Install } from "../install/install.js";
4
- import type { Skill, SkillCli } from "./skill.js";
5
- /** What the `skill` row of a Packaged skill carries under `--json` beside its message. */
6
- export declare const packagedSkillDetailsSchema: z.ZodObject<{
7
- copy: z.ZodString;
8
- copyVersion: z.ZodNullable<z.ZodString>;
9
- packageVersion: z.ZodNullable<z.ZodString>;
10
- home: z.ZodOptional<z.ZodString>;
11
- }, z.core.$strip>;
12
- /** A skill shipped in the package at `packaged`, which `skill install` copies to the project root. */
13
- export declare function packagedSkill(cli: SkillCli, { packaged: folder, agents: text }: PackagedSkillSource, install: Install): Skill;
@@ -1,97 +0,0 @@
1
- import { realpath } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import * as z from "zod";
4
- import { errnoOf, messageOf, orMissing } from "../../errors.js";
5
- import { agentsRow } from "../agents-md.js";
6
- import { homeOf } from "./hub.js";
7
- import { skillCopyOf, skillInstallCommand, skillVersionsOf } from "./install-command.js";
8
- // A project that is home itself has its copy under home, which shadows nothing.
9
- async function personalCopyOf(name, copy, ctx) {
10
- const home = join(homeOf(ctx.env), ".claude", "skills", name);
11
- const real = await orMissing(realpath(home));
12
- return real === undefined || real === (await orMissing(realpath(copy))) ? undefined : home;
13
- }
14
- /** What the `skill` row of a Packaged skill carries under `--json` beside its message. */
15
- export const packagedSkillDetailsSchema = z.object({
16
- copy: z.string(),
17
- copyVersion: z.string().nullable(),
18
- packageVersion: z.string().nullable(),
19
- /** A personal copy, which Claude Code prefers over the project's. */
20
- home: z.string().optional(),
21
- });
22
- function versionLabel(version) {
23
- return version ?? "(no metadata.version)";
24
- }
25
- function compared(name, { copy, copyVersion, packageVersion }, same) {
26
- const stated = `${copy} ${versionLabel(copyVersion)}`;
27
- return same
28
- ? `${stated}, the version ${name} ships`
29
- : `${stated} differs from the ${versionLabel(packageVersion)} that ${name} ships`;
30
- }
31
- /** The project root's copy against the package's, and any under home. */
32
- async function findingOf(cli, folder, install, ctx) {
33
- const { copy } = await skillCopyOf(cli, ctx.cwd);
34
- const versions = await skillVersionsOf(join(ctx.packageRoot, folder), copy);
35
- const { packageVersion } = versions;
36
- const copyVersion = versions.copyVersion ?? null;
37
- const home = await personalCopyOf(cli.name, copy, ctx);
38
- const skill = { copy, copyVersion, packageVersion, ...(home === undefined ? {} : { home }) };
39
- const head = versions.copyVersion === undefined
40
- ? `no copy of the ${cli.name} skill at ${copy}`
41
- : compared(cli.name, skill, versions.same);
42
- // Other projects may use the personal copy, so the row names it and gives no line removing it.
43
- const message = home === undefined
44
- ? head
45
- : `${head}; remove ${home}: Claude Code prefers a personal skill over the project's`;
46
- if (!versions.same) {
47
- return { state: "problem", message, fix: `${install.runAs} skill install`, skill };
48
- }
49
- return home === undefined
50
- ? { state: "ok", message, skill }
51
- : { state: "problem", message, skill };
52
- }
53
- async function notice(cli, folder, install, { builtIn, bin }, ctx) {
54
- // `doctor` and `skill install` report the copy themselves, and a one-Command CLI has no `skill install`. A run from source is the CLI's own repo, whose agent reads the source.
55
- if (builtIn || bin === undefined || cli.commands === undefined)
56
- return;
57
- let finding;
58
- try {
59
- finding = await findingOf(cli, folder, install, ctx);
60
- }
61
- catch (error) {
62
- // A file the Runtime cannot read must not stop the Command the Notice rides on; a bug still does.
63
- if (errnoOf(error) === undefined)
64
- throw error;
65
- ctx.notice(`could not check the ${cli.name} skill: ${messageOf(error)}`);
66
- return;
67
- }
68
- if (finding.state !== "problem")
69
- return;
70
- ctx.notice(finding.fix === undefined ? finding.message : `${finding.message}; run \`${finding.fix}\``);
71
- }
72
- /** A skill shipped in the package at `packaged`, which `skill install` copies to the project root. */
73
- export function packagedSkill(cli, { packaged: folder, agents: text }, install) {
74
- const agents = text === undefined ? undefined : { name: cli.name, text };
75
- return {
76
- kind: "packaged",
77
- builtIns: { skill: { install: skillInstallCommand(cli, folder, agents) } },
78
- rows: [
79
- { name: "skill", advisory: true, run: (ctx) => findingOf(cli, folder, install, ctx) },
80
- ...(agents === undefined ? [] : [agentsRow(agents, install)]),
81
- ],
82
- notice: (launch, ctx) => notice(cli, folder, install, launch, ctx),
83
- differing: async ({ cwd, packageRoot }) => {
84
- const { copy } = await skillCopyOf(cli, cwd);
85
- const { copyVersion, packageVersion, same } = await skillVersionsOf(join(packageRoot, folder), copy);
86
- return copyVersion === undefined || same
87
- ? []
88
- : [compared(cli.name, { copy, copyVersion, packageVersion }, false)];
89
- },
90
- // The copy is compared with the package on disk, whatever the version asked about.
91
- nextAt: async (_version, ctx) => {
92
- const { fix } = await findingOf(cli, folder, install, ctx);
93
- return fix === undefined ? [] : [fix];
94
- },
95
- };
96
- }
97
- //# sourceMappingURL=packaged.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packaged.js","sourceRoot":"","sources":["../../../src/built-ins/skill/packaged.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGzF,gFAAgF;AAChF,KAAK,UAAU,cAAc,CAC3B,IAAY,EACZ,IAAY,EACZ,GAAY;IAEZ,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,IA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,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Cli } from "../../define.js";
2
- import { type SkillPlace } from "./skill.js";
3
- /** A usage error whose hint names each Skill copy that differs from this build, since one may have named the input. */
4
- export declare function withDifferingSkill(error: unknown, cli: Cli, place: SkillPlace, runAs: string): Promise<unknown>;
@@ -1,28 +0,0 @@
1
- import { INVALID_INPUT, UNKNOWN_COMMAND, UNKNOWN_OPTION } from "../../command-line/usage.js";
2
- import { errnoOf, UsageError } from "../../errors.js";
3
- import { installOf } from "../install/install.js";
4
- import { skillOf } from "./skill.js";
5
- const SKILL_USAGE_CODES = new Set([UNKNOWN_OPTION, UNKNOWN_COMMAND, INVALID_INPUT]);
6
- /** A usage error whose hint names each Skill copy that differs from this build, since one may have named the input. */
7
- export async function withDifferingSkill(error, cli, place, runAs) {
8
- if (!(error instanceof UsageError) || !SKILL_USAGE_CODES.has(error.code))
9
- return error;
10
- let differing;
11
- try {
12
- differing = await skillOf(cli, installOf(cli)).differing(place);
13
- }
14
- catch (lookup) {
15
- // A skill the Runtime cannot read leaves the usage error as it was; a bug still surfaces.
16
- if (errnoOf(lookup) === undefined)
17
- throw lookup;
18
- return error;
19
- }
20
- if (differing.length === 0)
21
- return error;
22
- return new UsageError({
23
- code: error.code,
24
- message: error.message,
25
- hint: `${error.hint}; the ${cli.name} skill may name what this build does not know: ${differing.join("; ")}; run \`${runAs} doctor\` to see how to update it`,
26
- });
27
- }
28
- //# sourceMappingURL=usage-hint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage-hint.js","sourceRoot":"","sources":["../../../src/built-ins/skill/usage-hint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,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