@aiwg/cli 2026.7.19 → 2026.7.21

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 (88) hide show
  1. package/README.md +397 -385
  2. package/dist/src/api/index.d.ts +1 -0
  3. package/dist/src/api/index.js +1 -0
  4. package/dist/src/artifacts/browser-export.js +7 -0
  5. package/dist/src/artifacts/citation-parser.js +96 -35
  6. package/dist/src/artifacts/cli.js +59 -5
  7. package/dist/src/artifacts/discover-facets.js +15 -0
  8. package/dist/src/artifacts/discovery-eval.js +290 -0
  9. package/dist/src/artifacts/fortemi-core-query-adapter.js +1 -1
  10. package/dist/src/artifacts/fortemi-shard-export.js +1 -1
  11. package/dist/src/artifacts/index-builder.js +54 -17
  12. package/dist/src/artifacts/query-engine.js +10 -6
  13. package/dist/src/artifacts/state-transfer.js +27 -0
  14. package/dist/src/artifacts/stats.js +8 -0
  15. package/dist/src/cli/cli-extension-loader.js +73 -0
  16. package/dist/src/cli/handlers/help.js +2 -1
  17. package/dist/src/cli/handlers/index.js +6 -2
  18. package/dist/src/cli/handlers/resource-versions.js +247 -0
  19. package/dist/src/cli/handlers/sessions.js +966 -0
  20. package/dist/src/cli/handlers/skill-lint.js +49 -45
  21. package/dist/src/cli/handlers/subcommands.js +55 -3
  22. package/dist/src/cli/handlers/use.js +154 -59
  23. package/dist/src/cli/handlers/utilities.js +49 -34
  24. package/dist/src/cli/skill-usage.js +146 -24
  25. package/dist/src/config/cli.js +13 -9
  26. package/dist/src/config/project-artifacts-runtime.mjs +68 -0
  27. package/dist/src/config/project-artifacts.js +1 -68
  28. package/dist/src/extensions/commands/definitions.js +65 -2
  29. package/dist/src/extensions/manifest.js +29 -0
  30. package/dist/src/extensions/project-local-discovery.js +86 -2
  31. package/dist/src/extensions/project-local-remove.js +52 -56
  32. package/dist/src/extensions/shadow-resolver.js +3 -1
  33. package/dist/src/plugins/standalone-packager.js +143 -0
  34. package/dist/src/resources/cache-cleanup.js +67 -0
  35. package/dist/src/resources/doctor.js +107 -0
  36. package/dist/src/resources/lockfile.js +125 -0
  37. package/dist/src/resources/resolver.js +133 -0
  38. package/dist/src/resources/web-release.d.ts +8 -0
  39. package/dist/src/resources/web-release.js +159 -1
  40. package/dist/src/sessions/adapters/claude.js +357 -0
  41. package/dist/src/sessions/adapters/codex.js +521 -0
  42. package/dist/src/sessions/adapters/copilot.js +226 -0
  43. package/dist/src/sessions/adapters/cursor.js +372 -0
  44. package/dist/src/sessions/adapters/factory.js +345 -0
  45. package/dist/src/sessions/adapters/generic.js +225 -0
  46. package/dist/src/sessions/adapters/hermes.js +341 -0
  47. package/dist/src/sessions/adapters/openclaw.js +381 -0
  48. package/dist/src/sessions/adapters/opencode.js +454 -0
  49. package/dist/src/sessions/adapters/openhuman.js +315 -0
  50. package/dist/src/sessions/adapters/warp.js +160 -0
  51. package/dist/src/sessions/adapters/windsurf.js +212 -0
  52. package/dist/src/sessions/candidates.js +210 -0
  53. package/dist/src/sessions/contracts.js +310 -0
  54. package/dist/src/sessions/discovery.js +51 -0
  55. package/dist/src/sessions/fixtures.js +12 -0
  56. package/dist/src/sessions/importer.js +315 -0
  57. package/dist/src/sessions/index.js +25 -0
  58. package/dist/src/sessions/knowledge-shard.js +61 -0
  59. package/dist/src/sessions/optional-backends.js +238 -0
  60. package/dist/src/sessions/policy.js +192 -0
  61. package/dist/src/sessions/ports.js +2 -0
  62. package/dist/src/sessions/promotion.js +367 -0
  63. package/dist/src/sessions/readers.js +176 -0
  64. package/dist/src/sessions/repository.js +1551 -0
  65. package/dist/src/skills/adapters/agent-skills.js +59 -0
  66. package/dist/src/skills/adapters/local.js +19 -1
  67. package/dist/src/skills/agent-skills.js +249 -0
  68. package/dist/src/skills/cli.js +463 -7
  69. package/dist/src/skills/deployer.js +554 -0
  70. package/dist/src/skills/doctor.js +105 -0
  71. package/dist/src/skills/exporter.js +382 -0
  72. package/dist/src/skills/importer.js +921 -0
  73. package/dist/src/skills/registry.js +19 -0
  74. package/dist/src/skills/validator.js +323 -0
  75. package/dist/src/smiths/context-pipeline/aiwg-md.js +5 -1
  76. package/dist/src/smiths/context-pipeline/claude-hook.js +21 -1
  77. package/dist/src/smiths/context-pipeline/finalization.js +5 -3
  78. package/dist/src/smiths/context-pipeline/generator.js +4 -1
  79. package/dist/src/smiths/context-pipeline/parallelism-section.js +34 -1
  80. package/dist/src/smiths/context-pipeline/workspace-context.js +15 -3
  81. package/dist/src/smiths/mcpsmith/example.js +3 -1
  82. package/dist/src/smiths/mcpsmith/generator.js +3 -1
  83. package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -1
  84. package/dist/src/storage/cli.js +3 -2
  85. package/dist/src/storage/subsystem-cli.js +7 -2
  86. package/dist/src/update/notifier.mjs +1 -1
  87. package/dist/src/update/service.mjs +123 -0
  88. package/package.json +3 -2
package/README.md CHANGED
@@ -4,16 +4,16 @@
4
4
 
5
5
  # @aiwg/cli
6
6
 
7
- **The lightweight, web-first AIWG command line**
7
+ **The agent-optimized execution layer for AIWG**
8
8
 
9
- Use signed, versioned AIWG skills, agents, commands, rules, and framework
10
- metadata without installing the full local resource corpus into every project.
9
+ AIWG skills and agents use this CLI to perform common operations with
10
+ predictable, structured calls instead of spending context on shell discovery,
11
+ filesystem traversal, command reconstruction, and repeated tool output.
11
12
 
12
13
  ```bash
13
14
  npm install --global @aiwg/cli
14
15
 
15
- aiwg discover "architecture evolution"
16
- aiwg show skill architecture-evolution
16
+ aiwg doctor
17
17
  ```
18
18
 
19
19
  [![npm version](https://img.shields.io/npm/v/%40aiwg%2Fcli/latest?label=%40aiwg%2Fcli&color=CB3837&logo=npm&style=flat-square)](https://www.npmjs.com/package/@aiwg/cli)
@@ -24,7 +24,7 @@ aiwg show skill architecture-evolution
24
24
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
25
25
  [![Signed Resources](https://img.shields.io/badge/resources-signed-00a67d?style=flat-square)](https://releases.aiwg.io/)
26
26
 
27
- [**Quick Start**](#quick-start) · [**How It Works**](#how-it-works) · [**CLI Guide**](#cli-guide) · [**JavaScript API**](#javascript-api) · [**Security**](#security-model) · [**Troubleshooting**](#installation-troubleshooting)
27
+ [**Quick Start**](#quick-start) · [**Agentic Model**](#the-agentic-use-model) · [**Token Economy**](#why-this-reduces-agent-token-use) · [**How It Works**](#how-it-works) · [**Security**](#security-model) · [**Troubleshooting**](#installation-troubleshooting)
28
28
 
29
29
  </div>
30
30
 
@@ -32,32 +32,167 @@ aiwg show skill architecture-evolution
32
32
 
33
33
  ## What This Package Is
34
34
 
35
- `@aiwg/cli` is the executable AIWG runtime without the bundled framework
36
- corpus. It is designed for operators, automation, and web-connected agentic
37
- systems that need to find and read AIWG resources without copying a large npm
38
- package or deploying framework files into every project.
35
+ `@aiwg/cli` is the small executable runtime beneath AIWG's skills, agents,
36
+ rules, and workflows. It is primarily an **agent tool**, even though an
37
+ operator can run it from a terminal.
38
+
39
+ The important product surface is not a long list of commands. The important
40
+ surface is the AIWG capability graph:
41
+
42
+ - skills carry task-specific instructions, gates, preservation logic, and
43
+ recovery guidance;
44
+ - agents supply roles, judgment, and orchestration;
45
+ - rules supply policy that remains in force across tasks;
46
+ - the CLI supplies deterministic lookup, validation, deployment, health,
47
+ indexing, configuration, and execution primitives;
48
+ - signed web releases let the runtime reach the capability graph without
49
+ bundling the complete corpus into this npm package.
50
+
51
+ An agent should normally enter through a skill or an AIWG agent and let that
52
+ resource call `aiwg` when an imperative operation is needed. This keeps the
53
+ reasoning layer focused on the user's objective while the CLI handles the
54
+ mechanical work.
55
+
56
+ The package includes the `aiwg` executable, its routing and validation runtime,
57
+ the Fortemi Core query client, signed web-release verification, verified
58
+ caching, and provider metadata needed by agentic integrations. It intentionally
59
+ does not carry the complete `agentic/code` source tree, project artifacts, or
60
+ Cockpit.
61
+
62
+ In practice, this means an agent can:
63
+
64
+ 1. identify the narrow AIWG capability that matches the request;
65
+ 2. retrieve only that skill or agent definition;
66
+ 3. follow its gates and call the CLI steps it specifies;
67
+ 4. consume stable structured output instead of parsing exploratory shell
68
+ transcripts;
69
+ 5. leave the project with fewer temporary files, copied resources, and
70
+ provider-specific assumptions.
39
71
 
40
- The package includes:
72
+ Signed resources are available from
73
+ [`releases.aiwg.io`](https://releases.aiwg.io/). A clean installation can use
74
+ the published capability graph without first copying the full framework corpus
75
+ into every project.
41
76
 
42
- - the `aiwg` executable;
43
- - the supported JavaScript API used by the executable;
44
- - signed web-release verification and cache logic;
45
- - the Fortemi Core query runtime;
46
- - provider capability and model metadata required by the CLI;
47
- - command routing, configuration, and runtime support code.
77
+ ## The Agentic Use Model
48
78
 
49
- The package does **not** include:
79
+ AIWG follows a skills-first hierarchy:
50
80
 
51
- - the full `agentic/code` framework corpus;
52
- - local framework templates and generated documentation;
53
- - precomputed project deployments;
54
- - Cockpit, which remains the separate `@aiwg/cockpit` package;
55
- - a project `.aiwg` directory.
81
+ ```text
82
+ user intent
83
+ |
84
+ v
85
+ AIWG skill or agent
86
+ | task knowledge, policy, gates, recovery
87
+ v
88
+ small CLI operation
89
+ | deterministic lookup, validation, mutation, or status
90
+ v
91
+ structured result
92
+ |
93
+ v
94
+ agent judgment and user-facing outcome
95
+ ```
96
+
97
+ The preferred routing order is:
98
+
99
+ 1. **Use an already available AIWG skill or agent.** This is the cheapest and
100
+ best-primed route. The resource already knows the relevant workflow and
101
+ calls the CLI only where needed.
102
+ 2. **Discover the right AIWG capability.** If the resource is not already in
103
+ context, the agent performs an indexed lookup and retrieves the single best
104
+ match. It does not recursively browse provider directories or read the
105
+ whole corpus.
106
+ 3. **Use a raw CLI command only for a basic operator operation, for discovery
107
+ and status, or as a step inside a skill.** Raw action commands lack the
108
+ task-specific priming carried by skills.
109
+
110
+ This distinction matters. Running an action command directly may perform the
111
+ mechanical operation, but the paired skill also explains preconditions,
112
+ preservation requirements, review gates, failure recovery, and what evidence
113
+ must be retained. The skill is the workflow; the CLI is its execution
114
+ substrate.
115
+
116
+ Examples of the intended pairing:
117
+
118
+ | Intent | Preferred agentic entry | CLI role |
119
+ |---|---|---|
120
+ | Deploy an AIWG framework | `use` skill | Calls `aiwg use` with validated provider and project context |
121
+ | Diagnose an installation | `aiwg-doctor` skill | Calls `aiwg doctor`, interprets failures, and guides remediation |
122
+ | Refresh an installation | `aiwg-refresh` skill | Previews and invokes refresh safely |
123
+ | Regenerate provider context | `aiwg-regenerate` skill family | Preserves operator content while invoking regeneration |
124
+ | Find a specialized workflow | AIWG capability discovery | Queries the precomputed index and retrieves one matching resource |
125
+ | Run an executable skill | The selected skill | Dispatches its declared script through the runtime registry |
126
+
127
+ Operators can still use `aiwg use` and `aiwg doctor` directly for basic setup
128
+ and diagnostics. Agentic systems should prefer the paired skills because they
129
+ carry the context that a bare command cannot.
130
+
131
+ ## Why This Reduces Agent Token Use
132
+
133
+ General-purpose shell access is flexible, but flexibility is expensive for an
134
+ agent. Without a purpose-built interface, a session often has to:
135
+
136
+ - determine where a package was installed;
137
+ - enumerate directories and guess which provider copy is authoritative;
138
+ - search hundreds or thousands of files;
139
+ - read several near-matching documents before finding the right one;
140
+ - reconstruct command syntax from help text;
141
+ - parse prose-oriented terminal output;
142
+ - rediscover safety checks and recovery steps;
143
+ - repeat the same investigation in every project or new session.
144
+
145
+ Each step adds tool calls and returns text that competes with the actual task
146
+ for context. Recursive listings and broad text searches are especially costly:
147
+ they describe the storage layout instead of answering the user's intent.
148
+
149
+ AIWG changes that interaction:
150
+
151
+ ```text
152
+ traditional shell-oriented path
153
+
154
+ locate install
155
+ -> list directories
156
+ -> search filenames
157
+ -> grep many documents
158
+ -> read several candidates
159
+ -> infer the workflow
160
+ -> reconstruct command flags
161
+ -> parse terminal output
162
+
163
+ AIWG agentic path
164
+
165
+ intent
166
+ -> indexed capability selection
167
+ -> one relevant skill or agent
168
+ -> bounded CLI operation
169
+ -> structured result
170
+ ```
56
171
 
57
- After installation, ordinary `discover` and `show` calls automatically use the
58
- signed `stable` resource channel at
59
- [`releases.aiwg.io`](https://releases.aiwg.io/). No source flag, project
60
- initialization, or framework deployment is required.
172
+ The token advantage comes from reducing irrelevant material, not from hiding
173
+ important instructions:
174
+
175
+ - **Precomputed indices replace broad filesystem searches.** The agent asks by
176
+ intent and receives ranked capability metadata.
177
+ - **Selective retrieval replaces corpus loading.** Only the chosen skill,
178
+ agent, command, or rule enters context.
179
+ - **Skills preserve procedural knowledge.** Sessions do not have to regenerate
180
+ the same checklist, safety gates, and recovery process from first
181
+ principles.
182
+ - **Structured output reduces parsing.** Machine-facing operations can return
183
+ stable fields rather than decorated terminal prose.
184
+ - **Stable identifiers reduce rediscovery.** Agents can pass capability IDs
185
+ and names between workers without passing installation-specific paths.
186
+ - **Provider abstraction reduces branching.** The runtime handles supported
187
+ provider paths and configuration so each skill does not need a separate
188
+ shell recipe for every agentic platform.
189
+ - **Signed web resources reduce setup narration.** An agent does not need to
190
+ clone or explain a large local corpus before it can retrieve guidance.
191
+
192
+ No fixed token-saving percentage is promised: savings depend on the task,
193
+ provider, and whether the needed skill is already loaded. The design goal is
194
+ measurable in simpler terms—fewer exploratory calls, less unrelated output,
195
+ smaller context payloads, and less duplicated procedural reasoning.
61
196
 
62
197
  ## Choose the Right AIWG Distribution
63
198
 
@@ -65,14 +200,14 @@ AIWG publishes three packages in exact CalVer lockstep:
65
200
 
66
201
  | Package | Best for | Resource model | Install |
67
202
  |---|---|---|---|
68
- | `@aiwg/cli` | Web-connected agents, CI, lightweight global use, read-only discovery | Signed release host by default | `npm i -g @aiwg/cli` |
203
+ | `@aiwg/cli` | Agentic runtimes, web-connected sessions, CI, and lightweight global use | Signed release host by default | `npm i -g @aiwg/cli` |
69
204
  | `aiwg` | Full local operation, framework deployment, authoring, offline-first projects | Bundled local corpus by default; web mode optional | `npm i -g aiwg` |
70
205
  | `@aiwg/cockpit` | Optional local control plane and operator UI | Installed separately or through the full CLI | `npm i -g @aiwg/cockpit` |
71
206
 
72
- Choose `@aiwg/cli` when you primarily need to search, inspect, route, or consume
73
- AIWG resources. Choose `aiwg` when you need to deploy frameworks into provider
74
- directories, author against the complete source corpus, or operate without a
75
- previously warmed web cache.
207
+ Choose `@aiwg/cli` when AIWG skills and agents need a small, globally available
208
+ execution layer and can obtain resources from the signed web release. Choose
209
+ `aiwg` when local authoring, the full bundled corpus, or completely cold
210
+ offline operation is required.
76
211
 
77
212
  Both CLI packages expose the same `aiwg` executable name. Install one globally
78
213
  at a time unless you deliberately manage separate npm prefixes.
@@ -84,6 +219,7 @@ at a time unless you deliberately manage separate npm prefixes.
84
219
  ```bash
85
220
  npm install --global @aiwg/cli
86
221
  aiwg --version
222
+ aiwg doctor
87
223
  ```
88
224
 
89
225
  AIWG uses npm-compatible Calendar Versioning:
@@ -95,76 +231,23 @@ YYYY.M.PATCH
95
231
  The lightweight package version always matches the corresponding full `aiwg`
96
232
  release exactly.
97
233
 
98
- ### Find a capability
99
-
100
- ```bash
101
- aiwg discover "architecture evolution"
102
- ```
103
-
104
- Discovery searches the precomputed Fortemi Core index published with the signed
105
- AIWG release. Results may include skills, agents, commands, rules, flows,
106
- templates, and supporting documentation.
107
-
108
- Use structured output for scripts or agent tooling:
109
-
110
- ```bash
111
- aiwg discover "release publication verification" \
112
- --format json \
113
- --pretty
114
- ```
115
-
116
- Limit or filter results:
117
-
118
- ```bash
119
- aiwg discover "incident response timeline" \
120
- --type skill,agent \
121
- --limit 5 \
122
- --format json
123
- ```
124
-
125
- ### Read a resource
126
-
127
- Take the type and name from discovery, then fetch the full verified body:
234
+ For a basic operator-managed framework deployment, invoke the `use` skill in
235
+ your agentic environment. It validates the target and calls the equivalent
236
+ `aiwg use` operation. If you are intentionally working at a terminal, the
237
+ direct form is:
128
238
 
129
239
  ```bash
130
- aiwg show skill architecture-evolution
240
+ aiwg use <framework-or-addon>
131
241
  ```
132
242
 
133
- Other examples:
243
+ Run `aiwg doctor` after installation or deployment. In an agent session,
244
+ prefer the `aiwg-doctor` skill so the result is interpreted and remediated
245
+ rather than merely printed.
134
246
 
135
- ```bash
136
- aiwg show agent architecture-designer
137
- aiwg show command issue-audit
138
- aiwg show rule ci-green-before-done
139
- ```
140
-
141
- The downloaded body is verified against the signed release manifest before it
142
- is returned or stored in the cache.
143
-
144
- ### Pin a release for one call
145
-
146
- ```bash
147
- aiwg discover "deployment rollback" --aiwg-version 2026.7.19
148
- aiwg show skill flow-deploy-to-production --aiwg-version 2026.7.19
149
- ```
150
-
151
- An exact version does not follow later channel updates. This is useful for
152
- reproducible automation, audits, and long-running agent sessions.
153
-
154
- ### Warm the cache, then work offline
155
-
156
- ```bash
157
- # Online: verifies and caches signed metadata, index, and the selected body.
158
- aiwg discover "architecture evolution"
159
- aiwg show skill architecture-evolution
160
-
161
- # Offline: performs no network fetch and fails closed if required bytes are absent.
162
- aiwg discover "architecture evolution" --offline
163
- aiwg show skill architecture-evolution --offline
164
- ```
165
-
166
- Offline mode is intentionally strict. It never treats an incomplete or corrupt
167
- cache as trusted data.
247
+ Agents do not need to memorize the remaining command surface. AIWG discovery
248
+ finds the relevant skill, and the skill supplies the right CLI step. Operators
249
+ who need the complete syntax and examples can use the
250
+ [AIWG CLI reference](https://github.com/jmagly/aiwg/blob/main/docs/agents/cli-reference.md).
168
251
 
169
252
  ## How It Works
170
253
 
@@ -232,275 +315,185 @@ This is not a hosted command-execution service. Search and resource delivery
232
315
  move to the web; project mutation and provider deployment remain local
233
316
  operations.
234
317
 
235
- ## CLI Guide
236
-
237
- ### `aiwg discover`
238
-
239
- Find resources by intent rather than filename:
240
-
241
- ```bash
242
- aiwg discover "<phrase>" [options]
243
- ```
244
-
245
- Common options:
246
-
247
- | Option | Meaning |
248
- |---|---|
249
- | `--type <kinds>` | Comma-separated result types such as `skill,agent,command,rule` |
250
- | `--limit <n>` | Maximum number of results |
251
- | `--format json\|text` | Machine-readable or human-readable output |
252
- | `--json` | JSON output shorthand |
253
- | `--pretty` / `--compact` | JSON presentation |
254
- | `--resource-source local\|web\|auto` | Override package-aware source selection |
255
- | `--aiwg-version <selector>` | Signed channel name or exact CalVer |
256
- | `--offline` | Read only previously verified cache content |
257
- | `--backend fortemi-core` | Explicitly select the web-compatible query backend |
258
-
259
- Examples:
260
-
261
- ```bash
262
- aiwg discover "requirements review"
263
- aiwg discover "forensics evidence preservation" --type skill,agent
264
- aiwg discover "marketing campaign intake" --limit 3 --json --pretty
265
- aiwg discover "release flow" --aiwg-version stable
266
- aiwg discover "release flow" --aiwg-version 2026.7.19
267
- ```
268
-
269
- ### `aiwg show`
270
-
271
- Stream the full body of a discovered resource:
272
-
273
- ```bash
274
- aiwg show <type> <name> [options]
275
- ```
276
-
277
- Examples:
278
-
279
- ```bash
280
- aiwg show skill release-publication-verify
281
- aiwg show agent security-architect
282
- aiwg show command address-issues
283
- aiwg show rule delivery-policy
284
- ```
285
-
286
- When names are ambiguous, use the stable identifier or exact path returned by
287
- JSON discovery:
288
-
289
- ```bash
290
- result=$(aiwg discover "deployment" --json --compact)
291
- echo "$result"
292
- aiwg show skill flow-deploy-to-production --json
293
- ```
318
+ ## How Skills and Agents Use the Runtime
294
319
 
295
- `show` will not fetch arbitrary URLs or filesystem paths in web mode. It can
296
- read only immutable `raw/` resources committed by the verified release
297
- manifest.
320
+ The CLI is deliberately narrow at the point where it meets an agent. A skill
321
+ should ask it to do one bounded thing, verify the result, and return control to
322
+ the reasoning layer.
298
323
 
299
- ### Resource source behavior
324
+ ### Capability selection
300
325
 
301
- The default depends on the installed package:
326
+ Most AIWG capabilities are not loaded into every prompt. Loading hundreds of
327
+ skills would consume context before the user's task even began. Instead, AIWG
328
+ keeps a small kernel available and retrieves specialized capabilities on
329
+ demand.
302
330
 
303
- | Installed package | Default source |
304
- |---|---|
305
- | `@aiwg/cli` | `web` |
306
- | `aiwg` | `local` |
331
+ The runtime queries a precomputed Fortemi Core index using the user's intent.
332
+ It returns ranked metadata rather than dumping files. The agent selects the
333
+ best candidate and retrieves that resource alone.
307
334
 
308
- Override the default for one command:
335
+ This mechanism is exposed through `discover` and `show`, but those names are
336
+ implementation details for most users. The practical behavior is:
309
337
 
310
- ```bash
311
- aiwg discover "architecture" --resource-source web
312
- aiwg discover "architecture" --resource-source local
313
- aiwg discover "architecture" --resource-source auto
338
+ ```text
339
+ "prepare a production rollback"
340
+ |
341
+ v
342
+ ranked AIWG capabilities
343
+ |
344
+ v
345
+ one selected deployment skill
346
+ |
347
+ v
348
+ skill-directed checks and execution
314
349
  ```
315
350
 
316
- `auto` may use available project and package context. Use an explicit source
317
- when reproducibility matters.
318
-
319
- Because `@aiwg/cli` intentionally contains no corpus, forcing `local` requires
320
- an independently configured local AIWG root. If none exists, use web mode or
321
- install the full `aiwg` package.
351
+ Stable IDs make the result portable between a conductor and sub-agents. A
352
+ worker receives the capability identity and body it needs, not a transcript of
353
+ the conductor's directory search.
322
354
 
323
- ### Version and channel selection
355
+ ### Execution through skills
324
356
 
325
- Selectors accept:
357
+ Skills use CLI operations for mechanics such as:
326
358
 
327
- - a signed channel, such as `stable` or `canary`;
328
- - an exact npm-compatible AIWG CalVer, such as `2026.7.19`.
359
+ - validating installation and workspace health;
360
+ - deploying a framework or addon to supported providers;
361
+ - resolving project and user configuration;
362
+ - maintaining indexes and normalized metadata;
363
+ - running a script declared by a skill;
364
+ - generating or refreshing provider adapters;
365
+ - moving or validating the configured AIWG data store;
366
+ - producing structured status and evidence;
367
+ - selecting a signed resource version for reproducible work.
329
368
 
330
- ```bash
331
- aiwg discover "test strategy" --aiwg-version stable
332
- aiwg discover "test strategy" --aiwg-version 2026.7.19
333
- ```
369
+ The skill remains responsible for sequencing and interpretation. For example,
370
+ a deployment skill may:
334
371
 
335
- Channel metadata is signed and sequence-numbered. The CLI rejects a channel
336
- sequence lower than the last verified sequence and rejects conflicting content
337
- for an already-seen sequence.
372
+ 1. inspect provider support;
373
+ 2. validate the requested framework;
374
+ 3. preview changes;
375
+ 4. call the deployment primitive;
376
+ 5. verify generated files;
377
+ 6. explain any provider-specific follow-up.
338
378
 
339
- ### Help, version, and diagnostics
340
-
341
- ```bash
342
- aiwg help
343
- aiwg --version
344
- aiwg version
345
- aiwg doctor
346
- aiwg runtime-info
347
- ```
379
+ A bare deployment command would perform only part of that workflow. Keeping the
380
+ orchestration in the skill makes behavior reviewable and lets AIWG improve the
381
+ workflow without teaching every agent a new shell recipe.
348
382
 
349
- The package contains the shared CLI runtime, so help lists the broader AIWG
350
- command surface. Commands that require the local framework corpus, templates,
351
- or deployment source files are not made web-capable merely by installing the
352
- lightweight package. See [Current Scope](#current-scope-and-limitations).
383
+ ### Structured subprocess behavior
353
384
 
354
- ## Search and Output
385
+ Agent integrations should prefer machine-readable output when they need to
386
+ consume results programmatically. Stable fields are cheaper and safer to parse
387
+ than ANSI-decorated tables or prose intended for a person.
355
388
 
356
- ### Human-readable use
389
+ Good agent-facing calls have these properties:
357
390
 
358
- ```bash
359
- aiwg discover "risk management"
360
- ```
391
+ - explicit working directory;
392
+ - bounded timeout or abort signal;
393
+ - nonzero exit treated as a failure;
394
+ - structured output where available;
395
+ - no shell interpolation of untrusted user text;
396
+ - exact resource version when reproducibility matters;
397
+ - the smallest output needed for the next decision.
361
398
 
362
- The text format is suited to interactive shell use. It shows ranked candidates
363
- and enough identity information to make the next `show` call.
399
+ The CLI's command router is also exported for integrations that need in-process
400
+ execution. That API exists to support agent runtimes and AIWG tooling; this
401
+ README intentionally does not duplicate the full programming reference.
364
402
 
365
- ### JSON use
403
+ ### Recovery and diagnosis
366
404
 
367
- ```bash
368
- aiwg discover "risk management" --format json --pretty
369
- ```
405
+ When an operation fails, the agent should not immediately improvise a sequence
406
+ of destructive shell commands. It should route through the relevant AIWG
407
+ health or recovery skill.
370
408
 
371
- JSON output includes query metadata, resolved source, selected release, and
372
- ranked results. Treat additive fields as forward-compatible. Scripts should
373
- select the fields they need instead of comparing complete serialized output.
409
+ The `aiwg-doctor` skill wraps `aiwg doctor` with interpretation and remediation
410
+ guidance. It can distinguish installation damage, missing package content,
411
+ provider deployment drift, bad configuration, and unavailable optional
412
+ features. That distinction prevents an agent from treating every missing file
413
+ as a reason to reinstall or overwrite project state.
374
414
 
375
- Example with `jq`:
415
+ Similarly, refresh and regeneration skills preserve operator-authored content
416
+ and use dry-run or transactional behavior where the workflow requires it.
417
+ Those safeguards live above the raw command and are a core reason to keep
418
+ agents skill-first.
376
419
 
377
- ```bash
378
- aiwg discover "risk management" --json --compact \
379
- | jq '.results[] | {type, name, path, score}'
380
- ```
420
+ ## When Direct CLI Use Is Appropriate
381
421
 
382
- Fetch the first discovered skill:
422
+ Direct CLI use remains useful in a few bounded situations:
383
423
 
384
- ```bash
385
- name=$(
386
- aiwg discover "risk management" --type skill --json --compact \
387
- | jq -r '.results[0].name'
388
- )
389
- aiwg show skill "$name"
390
- ```
424
+ - an operator is installing AIWG and runs `aiwg doctor`;
425
+ - an operator intentionally deploys a known framework with `aiwg use`;
426
+ - an agent performs capability discovery or retrieves a selected resource;
427
+ - a skill calls its documented CLI step;
428
+ - CI invokes a deterministic validation command;
429
+ - a maintainer is debugging the runtime itself.
391
430
 
392
- ### Exit behavior
431
+ Direct CLI use is usually the wrong starting point when the task is expressed
432
+ as a goal such as "review this architecture," "prepare a release," "investigate
433
+ this incident," or "build a research corpus." Those are capability requests.
434
+ The agent should select the corresponding AIWG skill or agent and let that
435
+ resource decide which CLI operations are needed.
393
436
 
394
- The CLI exits nonzero for invalid selectors, unavailable cold offline data,
395
- signature failures, digest mismatches, unsafe resource paths, unsupported
396
- source/backend combinations, and ordinary command errors. Automation should
397
- check the exit code before consuming output.
437
+ This README therefore documents the operating model, package boundary, trust
438
+ model, and troubleshooting path instead of duplicating every command and flag.
439
+ The complete operator reference is maintained at:
398
440
 
399
- ## JavaScript API
441
+ **[AIWG CLI Reference — every command and example](https://github.com/jmagly/aiwg/blob/main/docs/agents/cli-reference.md)**
400
442
 
401
- `@aiwg/cli` exports the supported command router and signed resource helpers.
402
- Do not import private `dist/` paths.
443
+ Keeping the command catalog in one canonical location prevents package
444
+ documentation from drifting as the runtime grows.
403
445
 
404
- ### Run CLI commands in process
446
+ ## Agent Integration Guidance
405
447
 
406
- ```js
407
- import { run } from '@aiwg/cli';
448
+ An agent harness integrating AIWG should establish a few simple policies.
408
449
 
409
- await run([
410
- 'discover',
411
- 'architecture evolution',
412
- '--format',
413
- 'json',
414
- '--pretty',
415
- ]);
416
- ```
450
+ ### Prefer semantic intent over filenames
417
451
 
418
- Supply a working directory or abort signal:
452
+ Ask for the capability in the user's language. Do not guess that a workflow
453
+ must live under a particular framework directory. The same intent may be
454
+ served by a framework skill, an addon skill, an agent, or a project-local
455
+ extension.
419
456
 
420
- ```js
421
- import { run } from '@aiwg/cli';
457
+ ### Load the minimum relevant resource
422
458
 
423
- const controller = new AbortController();
459
+ Retrieve the selected skill or agent body, plus any directly referenced rule
460
+ needed to execute it. Avoid loading an entire framework merely because one
461
+ skill belongs to it. This is the primary context-management advantage of the
462
+ web-first package.
424
463
 
425
- await run(
426
- ['show', 'skill', 'architecture-evolution'],
427
- {
428
- cwd: process.cwd(),
429
- signal: controller.signal,
430
- },
431
- );
432
- ```
464
+ ### Keep paths out of inter-agent contracts
433
465
 
434
- The exported router applies the same package-aware web default as the installed
435
- binary.
466
+ Pass stable capability IDs, names, release versions, and structured results.
467
+ Do not make one worker depend on another worker's npm prefix, home directory,
468
+ cache location, or provider deployment path.
436
469
 
437
- ### Resolve a signed release
470
+ ### Preserve skill priming
438
471
 
439
- ```js
440
- import { resolveWebRelease } from '@aiwg/cli/resources';
472
+ When forwarding work to a sub-agent, include the selected skill content or let
473
+ that worker retrieve it through AIWG. Passing only the final CLI command loses
474
+ the gates and reasoning instructions that made the operation safe.
441
475
 
442
- const release = await resolveWebRelease({
443
- selector: 'stable',
444
- });
476
+ ### Separate judgment from mechanics
445
477
 
446
- console.log({
447
- version: release.version,
448
- manifestDigest: release.manifestDigest,
449
- channelSequence: release.channelSequence,
450
- });
451
- ```
478
+ The agent decides what the user means, which capability applies, and whether
479
+ the result satisfies the objective. The CLI resolves paths, validates data,
480
+ executes bounded operations, and reports facts. This separation makes both
481
+ layers easier to test.
452
482
 
453
- Pin an exact release:
483
+ ### Fail closed on trust errors
454
484
 
455
- ```js
456
- const release = await resolveWebRelease({
457
- selector: '2026.7.19',
458
- });
459
- ```
485
+ Signature failures, digest mismatches, unsafe paths, incompatible release
486
+ metadata, and corrupt offline cache entries are not warnings to bypass. The
487
+ agent should stop, preserve useful evidence, and route through diagnosis or
488
+ security guidance.
460
489
 
461
- Use a previously cached generation without network access:
490
+ ### Avoid help-text ingestion
462
491
 
463
- ```js
464
- const release = await resolveWebRelease({
465
- selector: 'stable',
466
- offline: true,
467
- });
468
- ```
469
-
470
- ### Fetch a committed raw resource
471
-
472
- ```js
473
- import {
474
- fetchVerifiedRawResource,
475
- resolveWebRelease,
476
- } from '@aiwg/cli/resources';
477
-
478
- const release = await resolveWebRelease({ selector: 'stable' });
479
- const bytes = await fetchVerifiedRawResource(
480
- release,
481
- 'raw/agentic/code/frameworks/sdlc-complete/skills/architecture-evolution/SKILL.md',
482
- );
483
-
484
- process.stdout.write(bytes);
485
- ```
486
-
487
- The raw path must be safe, relative, begin with `raw/`, and exist in the signed
488
- release descriptor map.
489
-
490
- ### TypeScript
491
-
492
- The package ships declarations for:
493
-
494
- - the main `@aiwg/cli` entry point;
495
- - `@aiwg/cli/resources`;
496
- - signed web-release descriptors and options.
497
-
498
- ```ts
499
- import type {
500
- VerifiedWebRelease,
501
- WebReleaseOptions,
502
- } from '@aiwg/cli/resources';
503
- ```
492
+ Do not routinely call `aiwg help` and place the full output in the model
493
+ context. If a skill exists, use it. If a maintainer or operator needs an
494
+ unfamiliar command, link to the canonical
495
+ [CLI reference](https://github.com/jmagly/aiwg/blob/main/docs/agents/cli-reference.md) or retrieve only
496
+ the relevant section.
504
497
 
505
498
  ## Using AIWG from a Web-Connected Chat
506
499
 
@@ -694,97 +687,115 @@ Consumer verification guidance:
694
687
 
695
688
  ## Current Scope and Limitations
696
689
 
697
- The lightweight package provides production web parity for:
698
-
699
- - `aiwg discover`;
700
- - `aiwg show`;
701
- - the corresponding supported JavaScript API;
702
- - signed release selection, verification, caching, and offline reads.
690
+ The lightweight package is an agentic execution and resource-access layer. Its
691
+ web-backed path provides production support for capability selection, resource
692
+ retrieval, signed release selection, verification, caching, and warm offline
693
+ reads.
703
694
 
704
- The package ships the shared command runtime, so `aiwg help` exposes commands
705
- also used by the full distribution. Commands that need the local corpus or
706
- project templates—including framework deployment and regeneration workflows—
707
- are not automatically converted into remote mutation operations.
695
+ It does not turn every AIWG action into a hosted service. Operations that
696
+ modify a project still run locally under the operator's permissions. A skill
697
+ may direct the CLI to write project artifacts or provider adapters, but the
698
+ release host never receives authority to mutate the project.
708
699
 
709
- For these workflows, install the full package:
700
+ Some skills require the full local corpus, source templates, or authoring
701
+ assets. When a selected workflow reports that requirement, install the full
702
+ distribution:
710
703
 
711
704
  ```bash
712
705
  npm uninstall --global @aiwg/cli
713
706
  npm install --global aiwg
714
707
 
715
- aiwg use sdlc
716
- aiwg regenerate
708
+ aiwg doctor
717
709
  ```
718
710
 
719
- Web mode is intentionally a resource transport and discovery abstraction. It
720
- does not grant a remote service permission to modify your project.
711
+ The package exposes the shared runtime, so help output may mention operations
712
+ whose complete inputs exist only in the full distribution. Agents should treat
713
+ an explicit "local corpus required" result as a package-boundary signal, not as
714
+ an invitation to search random filesystem locations.
715
+
716
+ ## Common Agentic Patterns
717
+
718
+ ### Turn a broad request into one bounded workflow
719
+
720
+ A user may ask, "Can you prepare this service for production?" The agent should
721
+ not start by enumerating every deployment command. It should:
721
722
 
722
- ## Common Recipes
723
+ 1. classify the request as an SDLC/deployment capability;
724
+ 2. select the relevant AIWG skill;
725
+ 3. read the skill's prerequisites and evidence requirements;
726
+ 4. invoke only the CLI operations called for by that skill;
727
+ 5. return the outcome and unresolved gates to the user.
723
728
 
724
- ### Discover and fetch the best matching skill
729
+ This pattern keeps the conversation about production readiness rather than
730
+ about command syntax.
731
+
732
+ ### Hand work to a specialized agent
733
+
734
+ A conductor may discover that an architecture decision requires a security
735
+ review. It can pass the selected security skill and the relevant project
736
+ artifact to a security agent. It does not need to pass a recursive listing of
737
+ AIWG's security framework or explain where npm installed it.
738
+
739
+ The receiving agent works from the same signed capability identity and can use
740
+ the CLI for any deterministic checks specified by the skill.
741
+
742
+ ### Diagnose before repairing
743
+
744
+ When AIWG appears broken, invoke the `aiwg-doctor` skill. The skill runs the
745
+ health primitive, classifies the finding, and chooses a remediation path. This
746
+ is less error-prone than having every agent invent an npm reinstall, delete
747
+ provider directories, or rewrite configuration on the first failure.
748
+
749
+ For a person at a terminal, the basic entry remains:
725
750
 
726
751
  ```bash
727
- query="deploy production with rollback gates"
728
- name=$(
729
- aiwg discover "$query" --type skill --limit 1 --json --compact \
730
- | jq -r '.results[0].name'
731
- )
732
- aiwg show skill "$name"
752
+ aiwg doctor
733
753
  ```
734
754
 
735
- ### Pin an automation job
755
+ ### Deploy through the `use` skill
736
756
 
737
- ```bash
738
- AIWG_VERSION=2026.7.19
757
+ The `use` skill is the normal agentic entry for framework and addon deployment.
758
+ It knows how to validate the requested bundle and supported provider before
759
+ calling the CLI. A human who already knows the exact target may use:
739
760
 
740
- aiwg discover "release verification" \
741
- --aiwg-version "$AIWG_VERSION" \
742
- --format json \
743
- --compact
761
+ ```bash
762
+ aiwg use <framework-or-addon>
744
763
  ```
745
764
 
746
- ### Prewarm CI for offline execution
765
+ The skill-first route is preferred because deployment can involve provider
766
+ capabilities, project-local customizations, stale-file handling, and
767
+ post-deployment checks that are not conveyed by the command name alone.
747
768
 
748
- ```bash
749
- export AIWG_RESOURCE_CACHE_ROOT="$PWD/.cache/aiwg/resources"
769
+ ### Pin a capability graph for reproducible work
750
770
 
751
- aiwg discover "security review" --aiwg-version 2026.7.19
752
- aiwg show skill security-gate --aiwg-version 2026.7.19
771
+ Long-running missions, release audits, and regulated workflows may bind the
772
+ runtime to an exact AIWG CalVer. Every worker can then retrieve capabilities
773
+ from the same immutable release instead of following a channel that may move
774
+ during the job.
753
775
 
754
- # A later network-isolated step:
755
- aiwg discover "security review" --aiwg-version 2026.7.19 --offline
756
- ```
776
+ The version belongs in mission or CI configuration. Individual agents should
777
+ inherit it rather than independently selecting different versions.
757
778
 
758
- ### Compare stable with an exact release
779
+ ### Warm resources before network isolation
759
780
 
760
- ```bash
761
- aiwg discover "architecture evolution" \
762
- --aiwg-version stable \
763
- --json --pretty > stable.json
781
+ An online preparation step can retrieve the small set of skills, rules, and
782
+ indices needed by a later isolated job. Offline execution then uses only
783
+ previously verified cache generations and fails closed if required bytes are
784
+ missing.
764
785
 
765
- aiwg discover "architecture evolution" \
766
- --aiwg-version 2026.7.19 \
767
- --json --pretty > pinned.json
786
+ This is preferable to copying the entire framework corpus into every isolated
787
+ worker. It keeps the payload task-specific and leaves a clear record of which
788
+ AIWG release supplied the guidance.
768
789
 
769
- diff -u pinned.json stable.json
770
- ```
790
+ ### Use the web surface when the agent cannot run tools
771
791
 
772
- ### Use the lightweight API in a Node script
773
-
774
- ```js
775
- import { run } from '@aiwg/cli';
776
-
777
- await run([
778
- 'discover',
779
- 'incident evidence preservation',
780
- '--type',
781
- 'skill,agent',
782
- '--limit',
783
- '5',
784
- '--json',
785
- '--pretty',
786
- ]);
787
- ```
792
+ Browser-only chat agents can navigate the linked release manifests and HTML
793
+ fallback pages at `releases.aiwg.io`. Tool-capable agents should use the CLI
794
+ because it verifies signatures, digests, channel sequence, and cache state
795
+ automatically.
796
+
797
+ Both paths expose the same capability graph. The difference is the access
798
+ mechanism, not a separate set of AIWG instructions.
788
799
 
789
800
  ## Installation Troubleshooting
790
801
 
@@ -1009,9 +1020,10 @@ Package invariants include:
1009
1020
 
1010
1021
  ## Documentation
1011
1022
 
1023
+ - [Complete AIWG CLI reference](https://github.com/jmagly/aiwg/blob/main/docs/agents/cli-reference.md)
1024
+ - [AIWG documentation](https://docs.aiwg.io/)
1012
1025
  - [AIWG project README](https://github.com/jmagly/aiwg#readme)
1013
1026
  - [Web-backed resources guide](https://github.com/jmagly/aiwg/blob/main/docs/install/web-backed-resources.md)
1014
- - [CLI reference](https://github.com/jmagly/aiwg/blob/main/docs/cli-reference.md)
1015
1027
  - [Release verification](https://github.com/jmagly/aiwg/blob/main/docs/releases/verifying.md)
1016
1028
  - [Supply-chain overview](https://github.com/jmagly/aiwg/blob/main/docs/security/supply-chain-overview.md)
1017
1029
  - [Agentic install runbook](https://github.com/jmagly/aiwg/blob/main/docs/agentic-install-runbook.md)