@zenera/cli 1.1.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/LICENSE +21 -0
  2. package/README.md +239 -0
  3. package/dist/args.d.ts +40 -0
  4. package/dist/args.js +99 -0
  5. package/dist/audit.d.ts +53 -0
  6. package/dist/audit.js +144 -0
  7. package/dist/banner.d.ts +13 -0
  8. package/dist/banner.js +103 -0
  9. package/dist/command.d.ts +14 -0
  10. package/dist/command.js +12 -0
  11. package/dist/commands/check.d.ts +3 -0
  12. package/dist/commands/check.js +287 -0
  13. package/dist/commands/index.d.ts +22 -0
  14. package/dist/commands/index.js +56 -0
  15. package/dist/commands/init.d.ts +3 -0
  16. package/dist/commands/init.js +157 -0
  17. package/dist/commands/inspect.d.ts +3 -0
  18. package/dist/commands/inspect.js +158 -0
  19. package/dist/commands/key.d.ts +3 -0
  20. package/dist/commands/key.js +335 -0
  21. package/dist/commands/list.d.ts +3 -0
  22. package/dist/commands/list.js +101 -0
  23. package/dist/commands/models.d.ts +9 -0
  24. package/dist/commands/models.js +120 -0
  25. package/dist/commands/open.d.ts +9 -0
  26. package/dist/commands/open.js +270 -0
  27. package/dist/commands/run.d.ts +3 -0
  28. package/dist/commands/run.js +167 -0
  29. package/dist/commands/sandbox.d.ts +3 -0
  30. package/dist/commands/sandbox.js +112 -0
  31. package/dist/commands/version.d.ts +6 -0
  32. package/dist/commands/version.js +39 -0
  33. package/dist/engine.d.ts +49 -0
  34. package/dist/engine.js +208 -0
  35. package/dist/external.d.ts +10 -0
  36. package/dist/external.js +56 -0
  37. package/dist/home.d.ts +31 -0
  38. package/dist/home.js +108 -0
  39. package/dist/ids.d.ts +12 -0
  40. package/dist/ids.js +44 -0
  41. package/dist/keys.d.ts +124 -0
  42. package/dist/keys.js +309 -0
  43. package/dist/lib.d.ts +9 -0
  44. package/dist/lib.js +31 -0
  45. package/dist/liveness.d.ts +23 -0
  46. package/dist/liveness.js +221 -0
  47. package/dist/main.d.ts +3 -0
  48. package/dist/main.js +155 -0
  49. package/dist/narrate.d.ts +19 -0
  50. package/dist/narrate.js +124 -0
  51. package/dist/podman.d.ts +46 -0
  52. package/dist/podman.js +254 -0
  53. package/dist/projects.d.ts +70 -0
  54. package/dist/projects.js +232 -0
  55. package/dist/resolve.d.ts +27 -0
  56. package/dist/resolve.js +138 -0
  57. package/dist/sandbox.d.ts +36 -0
  58. package/dist/sandbox.js +104 -0
  59. package/dist/scaffold.d.ts +29 -0
  60. package/dist/scaffold.js +220 -0
  61. package/dist/session.d.ts +77 -0
  62. package/dist/session.js +156 -0
  63. package/dist/term.d.ts +69 -0
  64. package/dist/term.js +242 -0
  65. package/dist/tui/app.d.ts +8 -0
  66. package/dist/tui/app.js +257 -0
  67. package/dist/tui/theme.d.ts +23 -0
  68. package/dist/tui/theme.js +134 -0
  69. package/dist/tui/wrap.d.ts +12 -0
  70. package/dist/tui/wrap.js +62 -0
  71. package/dist/validate.d.ts +145 -0
  72. package/dist/validate.js +959 -0
  73. package/package.json +76 -0
  74. package/templates/.github/copilot-instructions.md +1579 -0
  75. package/templates/.github/prompts/new-agent.prompt.md +38 -0
  76. package/templates/.github/prompts/new-skill.prompt.md +37 -0
  77. package/templates/.github/prompts/review-project.prompt.md +31 -0
  78. package/templates/.github/skills/zen-cli/SKILL.md +110 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ mode: agent
3
+ description: Add an agent to agents.yaml, with its prompt, tools and handoffs.
4
+ ---
5
+
6
+ Add an agent to this project. Ask for the one sentence that states its job
7
+ before writing anything; if I have already given it, do not ask again.
8
+
9
+ First, argue against it. An agent is worth adding only when one of these is
10
+ true, and you should say which:
11
+
12
+ - it needs a **different model tier** from every existing agent
13
+ - it needs a **different tool set**, and the difference is a permission
14
+ - its instructions **contradict** an existing agent's rather than extend them
15
+ - it is a **parallel branch** target for a `fork:`
16
+
17
+ If none holds, propose the smaller change instead — a skill, a prompt line, a
18
+ tool grant — and stop. Adding an agent to solve a prompt problem is the failure
19
+ mode this project cares most about.
20
+
21
+ If it is warranted:
22
+
23
+ 1. Pick a name matching `^[a-z0-9]+(?:[-_][a-z0-9]+)*$`. It reaches the model as
24
+ `transfer_to_<name>`, so the name is part of the routing surface.
25
+ 2. Write `agents/prompts/<name>.md`: one sentence of identity, a short procedure
26
+ or three to five rules, then what it must **not** do — especially the
27
+ neighbouring agent's job. Second person, imperative, failure paths stated.
28
+ No frontmatter, no meta-talk about the runtime.
29
+ 3. Add the `agents.yaml` entry. `description:` is written **for the model** — it
30
+ is the whole of what a sibling sees when deciding to hand off. Grant the
31
+ narrowest `tools:` the job needs.
32
+ 4. Wire the handoffs in both directions only if both directions are real.
33
+ Specialists handing back to a router is ping-pong; prefer terminating.
34
+ 5. Add a one-line comment above the entry saying why this agent exists — its
35
+ job or its tier, not what the keys mean.
36
+
37
+ Then run `zen check` and report what it said. If it fails, fix the file it
38
+ named rather than working around it.
@@ -0,0 +1,37 @@
1
+ ---
2
+ mode: agent
3
+ description: Add a skill under agents/skills, with a description that routes.
4
+ ---
5
+
6
+ Add a skill to this project. A skill is curated instruction content — and
7
+ optionally tools — loaded on demand instead of sitting in every system prompt.
8
+ Reach for one whenever a rule applies only sometimes, or holds a fact that will
9
+ change without the prompt changing.
10
+
11
+ Ask what the skill must say and when it applies, if I have not already said.
12
+
13
+ 1. Choose the layout. A flat `agents/skills/<name>.md` for text alone; a folder
14
+ `agents/skills/<name>/SKILL.md` when it needs companions — a rate table, an
15
+ example letter, a schema. Siblings of `SKILL.md` become readable resources.
16
+ 2. Write the `description`. This is the routing key and the only thing the model
17
+ sees before deciding to load the skill, so write it as **the condition under
18
+ which the skill is needed**, not as a title. `Water policy` is a title;
19
+ `Escape of water from plumbing and tanks — and the freezing exclusion` is a
20
+ condition. If two skills could both match a case, sharpen both until they
21
+ cannot.
22
+ 3. Write the body as instructions the model can act on: thresholds, exact
23
+ wording, the boundaries of the rule, and what to do when the case falls
24
+ outside it. Put the facts here rather than in a prompt — that is the point of
25
+ the file.
26
+ 4. Declare `tools:` in the frontmatter only for tools that must not run until
27
+ this skill is active. They are advertised from turn 0 and refuse to execute
28
+ while the skill is dormant, which is how gating happens without breaking the
29
+ prompt cache.
30
+ 5. Leave `name` out unless it must differ from the file or folder name, and
31
+ leave `version`/`tags` out unless something uses them.
32
+
33
+ Do not `preload:` it unless every case genuinely needs it — a preloaded skill is
34
+ a longer prompt, paid for on every call. Bind it under `agents[].skills.allow`
35
+ if the agent's catalog is restricted.
36
+
37
+ Then run `zen check` and report what it said.
@@ -0,0 +1,31 @@
1
+ ---
2
+ mode: agent
3
+ description: Review the project against the checklist before committing.
4
+ ---
5
+
6
+ Review this project the way a maintainer would, then report. Read
7
+ `agents.yaml`, `INSTRUCTIONS.md`, every file under `agents/prompts/` and the
8
+ skill descriptions under `agents/skills/` before saying anything.
9
+
10
+ Work the checklist in §9 of the copilot instructions. In particular:
11
+
12
+ - **Loads.** Run `zen check`. Nothing else in this review matters if it fails.
13
+ - **One job each.** Can you state every agent's job in one sentence? If not,
14
+ say which agent and what the two jobs are.
15
+ - **Prompts.** Second person, imperative, failure paths stated, no hedging, no
16
+ politeness padding, no meta-talk about the runtime. Nothing in
17
+ `INSTRUCTIONS.md` that is true of only one agent.
18
+ - **Facts.** Any number, threshold, fee or date living in a prompt is in the
19
+ wrong file. Name it and say which skill it belongs in.
20
+ - **Skill descriptions.** Each one a condition, not a title; no two overlapping.
21
+ - **Tools.** Every grant justified by the agent's job; nothing mutating held by
22
+ an agent that only reads; every granted tool mentioned by the prompt.
23
+ - **Routing.** Handoff targets have descriptions written for the model. No
24
+ ping-pong edges. No router that answers.
25
+ - **Models.** Each agent on the cheapest tier that is right, not the safest.
26
+ - **Cache.** Nothing volatile — dates, ids, counts — in the stable prefix.
27
+ - **Secrets.** No key inlined anywhere; `.env` ignored, `sessions/` ignored.
28
+
29
+ Report as a list of findings, each naming the file and the line, ordered by how
30
+ much it will cost to leave. Say plainly if you find nothing worth changing.
31
+ Do not edit anything unless I ask.
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: zen-cli
3
+ description: How to drive this project from the terminal with `zen` — running it, validating it, credentials, the sandbox and run reports.
4
+ ---
5
+
6
+ # The `zen` command line
7
+
8
+ Everything here operates on a project directory. The project is resolved from
9
+ the working directory, or by name from the registry `zen init` wrote to, or
10
+ explicitly with `--project <name|dir>`. Every command takes `--json` and prints
11
+ a machine-readable answer instead of a rendered one.
12
+
13
+ ## Running
14
+
15
+ ```
16
+ zen run [project] [prompt] [options]
17
+ ```
18
+
19
+ On a terminal with no prompt it opens the TUI; with a prompt, or without a tty,
20
+ it answers once on stdout. The first word is the project when it names one, and
21
+ the first word of the prompt when it does not — `--project` settles it.
22
+
23
+ | Flag | What it does |
24
+ | ----------------------- | -------------------------------------------- |
25
+ | `--project <name\|dir>` | Which project. Inferred from the directory |
26
+ | `--session <id>` | Continue a particular session |
27
+ | `--new` | Start a fresh one |
28
+ | `--workspace <dir>` | What the agent may read and write |
29
+ | `--model <ref>` | Override the default model for this run |
30
+ | `--image <ref>` | Override the container commands run in |
31
+ | `--read-only` | Withhold every tool that can write |
32
+ | `--quiet` | The answer only; no narration |
33
+ | `--plain` | One shot, even on a terminal |
34
+ | `--out <file>` | Write the answer to a file as well as stdout |
35
+ | `--yes` | Accept the questions it would otherwise ask |
36
+
37
+ Flags always win over the file: the repository states intent, the invocation
38
+ overrides it. There is no `resume` — a session continues itself, because its
39
+ state is what it is.
40
+
41
+ With a prompt on the command line nothing is asked: a fresh session, the current
42
+ directory as the workspace, writable.
43
+
44
+ ## Validating
45
+
46
+ ```
47
+ zen check [dir] [--strict] [--quiet] everything agents.yaml names
48
+ zen models [--project <name|dir>] providers, models and embeddings resolved
49
+ ```
50
+
51
+ `zen check` reads the project the way `zen run` does and reports in full without
52
+ calling a model — a missing prompt file, an unknown tool, a handoff to nobody, a
53
+ model alias on an undeclared provider. `zen models` answers the narrower
54
+ question of what each agent would actually talk to, and which credential it
55
+ needs. Run `zen check` after any edit to `agents.yaml`, a prompt or a skill; it
56
+ is the cheapest possible test.
57
+
58
+ ## Credentials
59
+
60
+ ```
61
+ zen key ls [--check] what is on the keyring, and whether it works
62
+ zen key add <provider>[/name] add one — never on the command line
63
+ zen key use <provider>/<name> choose the active key for a provider
64
+ zen key check [provider[/name]] a round trip per key
65
+ zen key show <provider>[/name] masked, or --reveal for the secret itself
66
+ zen key rm <provider>/<name> forget it
67
+ zen key env [provider …] `eval "$(zen key env)"` for other tools
68
+ ```
69
+
70
+ The secret never comes from argv — a command line lands in `ps`, in shell
71
+ history and in CI logs. `zen key add` takes it from piped stdin or an echo-off
72
+ prompt, and nowhere else. Real environment variables win over the keyring, so
73
+ `.env` still decides inside a run.
74
+
75
+ ## The sandbox
76
+
77
+ ```
78
+ zen sandbox status is a container runtime there, is the image pulled
79
+ zen sandbox up start it
80
+ zen sandbox pull fetch the image ahead of the first run
81
+ zen sandbox clean throw away persisted containers
82
+ ```
83
+
84
+ Shell commands run in a container over the session workspace, not on the host.
85
+ If runs begin by installing a toolchain, set `sandbox.image` to one that already
86
+ has it, or `sandbox.persist: true`, rather than paying for it every run.
87
+
88
+ ## Reports and sessions
89
+
90
+ ```
91
+ zen list [--sessions] [--prune] every known project
92
+ zen inspect [run] [--session <id>] [--open] [--serve] a run's report.html
93
+ zen open [project] [--editor <cmd>] [--wait] open it in an editor
94
+ zen version CLI, library and Node
95
+ ```
96
+
97
+ `zen inspect` renders the trajectory of a run — every message, tool call, skill
98
+ activation and handoff, in order, with what each one cost. It is the first place
99
+ to look when behaviour is wrong and the prompt looks right: it shows what the
100
+ model was actually given, which is rarely what you assumed.
101
+
102
+ Sessions live under `sessions/` and hold run state, memory, blobs and whatever
103
+ the agent wrote. None of it is source and none of it is committed.
104
+
105
+ ## Exit codes
106
+
107
+ Non-zero on failure, with the offending key or file named in the message. A load
108
+ error names the exact path — `agents.yaml: agents[1].skills.discovery — …` — so
109
+ read it rather than guessing; the loader is strict on purpose and an unknown key
110
+ is an error, not a value quietly ignored.