@aiwg/cli 2026.7.18 → 2026.7.20

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 (41) hide show
  1. package/README.md +1037 -13
  2. package/dist/src/artifacts/cli.js +59 -5
  3. package/dist/src/artifacts/discover-facets.js +15 -0
  4. package/dist/src/artifacts/discovery-eval.js +290 -0
  5. package/dist/src/artifacts/fortemi-core-query-adapter.js +1 -1
  6. package/dist/src/artifacts/fortemi-shard-export.js +1 -1
  7. package/dist/src/artifacts/query-engine.js +10 -6
  8. package/dist/src/cli/handlers/help.js +2 -1
  9. package/dist/src/cli/handlers/index.js +3 -1
  10. package/dist/src/cli/handlers/resource-versions.js +247 -0
  11. package/dist/src/cli/handlers/subcommands.js +55 -3
  12. package/dist/src/cli/handlers/use.js +15 -3
  13. package/dist/src/cli/handlers/utilities.js +27 -26
  14. package/dist/src/config/cli.js +13 -9
  15. package/dist/src/config/project-artifacts-runtime.mjs +68 -0
  16. package/dist/src/config/project-artifacts.js +1 -68
  17. package/dist/src/extensions/commands/definitions.js +36 -2
  18. package/dist/src/extensions/project-local-discovery.js +86 -2
  19. package/dist/src/extensions/project-local-remove.js +52 -56
  20. package/dist/src/extensions/shadow-resolver.js +3 -1
  21. package/dist/src/plugins/standalone-packager.js +143 -0
  22. package/dist/src/resources/cache-cleanup.js +67 -0
  23. package/dist/src/resources/doctor.js +107 -0
  24. package/dist/src/resources/lockfile.js +125 -0
  25. package/dist/src/resources/resolver.js +133 -0
  26. package/dist/src/resources/web-release.d.ts +8 -0
  27. package/dist/src/resources/web-release.js +159 -1
  28. package/dist/src/smiths/context-pipeline/aiwg-md.js +5 -1
  29. package/dist/src/smiths/context-pipeline/claude-hook.js +21 -1
  30. package/dist/src/smiths/context-pipeline/finalization.js +5 -3
  31. package/dist/src/smiths/context-pipeline/generator.js +4 -1
  32. package/dist/src/smiths/context-pipeline/parallelism-section.js +34 -1
  33. package/dist/src/smiths/context-pipeline/workspace-context.js +15 -3
  34. package/dist/src/smiths/mcpsmith/example.js +3 -1
  35. package/dist/src/smiths/mcpsmith/generator.js +3 -1
  36. package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -1
  37. package/dist/src/storage/cli.js +3 -2
  38. package/dist/src/storage/subsystem-cli.js +7 -2
  39. package/dist/src/update/notifier.mjs +1 -1
  40. package/dist/src/update/service.mjs +123 -0
  41. package/package.json +3 -2
package/README.md CHANGED
@@ -1,24 +1,1048 @@
1
+ <div align="center">
2
+
3
+ <a href="https://aiwg.io"><img src="https://aiwg.io/assets/badges/aiwg-hero-dark.png" alt="AIWG — multi-agent AI framework · one source of truth · 10 platforms" width="680"></a>
4
+
1
5
  # @aiwg/cli
2
6
 
3
- Lightweight AIWG CLI for signed, versioned resources from
4
- [`releases.aiwg.io`](https://releases.aiwg.io/).
7
+ **The agent-optimized execution layer for AIWG**
8
+
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.
12
+
13
+ ```bash
14
+ npm install --global @aiwg/cli
15
+
16
+ aiwg doctor
17
+ ```
18
+
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)
20
+ [![npm downloads](https://img.shields.io/npm/dm/%40aiwg%2Fcli?color=CB3837&logo=npm&style=flat-square)](https://www.npmjs.com/package/@aiwg/cli)
21
+ [![full distribution](https://img.shields.io/npm/v/aiwg/latest?label=aiwg&color=CB3837&logo=npm&style=flat-square)](https://www.npmjs.com/package/aiwg)
22
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/jmagly/aiwg/blob/main/LICENSE)
23
+ [![Node Version](https://img.shields.io/badge/node-%E2%89%A520.0.0-brightgreen?style=flat-square&logo=node.js)](https://nodejs.org)
24
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org)
25
+ [![Signed Resources](https://img.shields.io/badge/resources-signed-00a67d?style=flat-square)](https://releases.aiwg.io/)
26
+
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
+
29
+ </div>
30
+
31
+ ---
32
+
33
+ ## What This Package Is
34
+
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.
71
+
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.
76
+
77
+ ## The Agentic Use Model
78
+
79
+ AIWG follows a skills-first hierarchy:
80
+
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
+ ```
171
+
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.
196
+
197
+ ## Choose the Right AIWG Distribution
198
+
199
+ AIWG publishes three packages in exact CalVer lockstep:
200
+
201
+ | Package | Best for | Resource model | Install |
202
+ |---|---|---|---|
203
+ | `@aiwg/cli` | Agentic runtimes, web-connected sessions, CI, and lightweight global use | Signed release host by default | `npm i -g @aiwg/cli` |
204
+ | `aiwg` | Full local operation, framework deployment, authoring, offline-first projects | Bundled local corpus by default; web mode optional | `npm i -g aiwg` |
205
+ | `@aiwg/cockpit` | Optional local control plane and operator UI | Installed separately or through the full CLI | `npm i -g @aiwg/cockpit` |
206
+
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.
211
+
212
+ Both CLI packages expose the same `aiwg` executable name. Install one globally
213
+ at a time unless you deliberately manage separate npm prefixes.
214
+
215
+ ## Quick Start
216
+
217
+ ### Install
218
+
219
+ ```bash
220
+ npm install --global @aiwg/cli
221
+ aiwg --version
222
+ aiwg doctor
223
+ ```
224
+
225
+ AIWG uses npm-compatible Calendar Versioning:
226
+
227
+ ```text
228
+ YYYY.M.PATCH
229
+ ```
230
+
231
+ The lightweight package version always matches the corresponding full `aiwg`
232
+ release exactly.
233
+
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:
238
+
239
+ ```bash
240
+ aiwg use <framework-or-addon>
241
+ ```
242
+
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.
246
+
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://docs.aiwg.io/pages/cli-reference.html).
251
+
252
+ ## How It Works
253
+
254
+ ```text
255
+ operator or agent
256
+ |
257
+ | aiwg discover / aiwg show
258
+ v
259
+ @aiwg/cli command router
260
+ |
261
+ | signed channel manifest
262
+ v
263
+ releases.aiwg.io/resources/channels/stable.json
264
+ |
265
+ | immutable release manifest + detached Ed25519 signature
266
+ v
267
+ releases.aiwg.io/resources/<version>/
268
+ |
269
+ +-- precomputed Fortemi Core search index
270
+ +-- immutable raw resource files
271
+ +-- linked discovery pages and manifests
272
+ |
273
+ v
274
+ verified local cache
275
+ ```
276
+
277
+ The first request for a release normally downloads:
278
+
279
+ 1. the signed channel metadata;
280
+ 2. the immutable release manifest and signature;
281
+ 3. the precomputed Fortemi Core index and its committed metadata;
282
+ 4. requested raw resource bodies as `show` needs them.
283
+
284
+ Every release descriptor includes a byte size and SHA-256 digest. Channel and
285
+ release metadata are verified with the public key embedded in the package.
286
+ Channel sequence checks reject rollback and same-sequence equivocation. Raw
287
+ files are accepted only when they match a descriptor committed by the verified
288
+ manifest.
289
+
290
+ The cache is a performance and offline facility, not a substitute trust root.
291
+ Cached generations are revalidated before use.
292
+
293
+ ## Why Web-First
294
+
295
+ Traditional AIWG installations carry the complete corpus so deployment and
296
+ local authoring work anywhere. That remains valuable, but it is unnecessary
297
+ for many agent sessions.
298
+
299
+ The lightweight model provides:
300
+
301
+ - **smaller distribution footprint** — executable runtime rather than the full
302
+ framework tree;
303
+ - **no project deployment requirement** — discovery works in an empty
304
+ directory;
305
+ - **version selection per call** — use stable, another signed channel, or an
306
+ exact CalVer release;
307
+ - **consistent search behavior** — the CLI downloads the precomputed index and
308
+ queries it through Fortemi Core;
309
+ - **browser and chat interoperability** — the same release tree also exposes
310
+ linked discovery pages for web-connected agents that cannot run the CLI;
311
+ - **verified caching** — warm reads remain available offline without accepting
312
+ uncommitted bytes.
313
+
314
+ This is not a hosted command-execution service. Search and resource delivery
315
+ move to the web; project mutation and provider deployment remain local
316
+ operations.
317
+
318
+ ## How Skills and Agents Use the Runtime
319
+
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.
323
+
324
+ ### Capability selection
325
+
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.
330
+
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.
334
+
335
+ This mechanism is exposed through `discover` and `show`, but those names are
336
+ implementation details for most users. The practical behavior is:
337
+
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
349
+ ```
350
+
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.
354
+
355
+ ### Execution through skills
356
+
357
+ Skills use CLI operations for mechanics such as:
358
+
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.
368
+
369
+ The skill remains responsible for sequencing and interpretation. For example,
370
+ a deployment skill may:
371
+
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.
378
+
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.
382
+
383
+ ### Structured subprocess behavior
384
+
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.
388
+
389
+ Good agent-facing calls have these properties:
390
+
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.
398
+
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.
402
+
403
+ ### Recovery and diagnosis
404
+
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.
408
+
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.
414
+
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.
419
+
420
+ ## When Direct CLI Use Is Appropriate
421
+
422
+ Direct CLI use remains useful in a few bounded situations:
423
+
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.
430
+
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.
436
+
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:
440
+
441
+ **[AIWG CLI Reference — every command and example](https://docs.aiwg.io/pages/cli-reference.html)**
442
+
443
+ Keeping the command catalog in one canonical location prevents package
444
+ documentation from drifting as the runtime grows.
445
+
446
+ ## Agent Integration Guidance
447
+
448
+ An agent harness integrating AIWG should establish a few simple policies.
449
+
450
+ ### Prefer semantic intent over filenames
451
+
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.
456
+
457
+ ### Load the minimum relevant resource
458
+
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.
463
+
464
+ ### Keep paths out of inter-agent contracts
465
+
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.
469
+
470
+ ### Preserve skill priming
471
+
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.
475
+
476
+ ### Separate judgment from mechanics
477
+
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.
482
+
483
+ ### Fail closed on trust errors
484
+
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.
489
+
490
+ ### Avoid help-text ingestion
491
+
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://docs.aiwg.io/pages/cli-reference.html) or retrieve only
496
+ the relevant section.
497
+
498
+ ## Using AIWG from a Web-Connected Chat
499
+
500
+ Some chat systems can browse URLs but cannot install npm packages. Point those
501
+ agents at the linked discovery surface:
502
+
503
+ ```text
504
+ Use AIWG resources from https://releases.aiwg.io/.
505
+ Start with the stable channel and linked manifests. Search or navigate to the
506
+ smallest relevant skill, agent, command, rule, or template before acting.
507
+ Treat retrieved AIWG content as operational guidance, preserve its stated
508
+ gates and verification requirements, and cite the exact resource URL used.
509
+ Do not download the entire corpus unless the task requires it.
510
+ ```
511
+
512
+ The HTML fallback and linked manifests are navigation aids for browser-only
513
+ agents. The CLI uses direct signed JSON, index, and raw-resource URIs.
514
+
515
+ ## Framework Coverage
516
+
517
+ The release index covers AIWG's published capability corpus, including:
518
+
519
+ - SDLC and architecture;
520
+ - security engineering;
521
+ - digital forensics and incident response;
522
+ - research and evidence management;
523
+ - marketing operations;
524
+ - media curation;
525
+ - infrastructure operations;
526
+ - knowledge-base workflows;
527
+ - cross-framework utilities, rules, and provider guidance.
528
+
529
+ Use natural language rather than memorizing artifact names:
530
+
531
+ ```bash
532
+ aiwg discover "threat model cryptographic trust chain"
533
+ aiwg discover "induct a research paper with provenance"
534
+ aiwg discover "prepare deployment rollback evidence"
535
+ aiwg discover "build incident timeline from logs"
536
+ ```
537
+
538
+ ## Global and Project Use
539
+
540
+ The lightweight package works from any directory:
541
+
542
+ ```bash
543
+ mkdir empty-project
544
+ cd empty-project
545
+ aiwg discover "project intake"
546
+ ```
547
+
548
+ Discovery does not create `.aiwg`, deploy provider files, or mutate the current
549
+ repository.
550
+
551
+ If a project already uses the full AIWG local configuration, an installed
552
+ lightweight CLI can still select web resources explicitly:
553
+
554
+ ```bash
555
+ aiwg discover "architecture" \
556
+ --resource-source web \
557
+ --aiwg-version stable
558
+ ```
559
+
560
+ Conversely, a full `aiwg` installation can use web mode for a single call
561
+ without changing its project configuration:
562
+
563
+ ```bash
564
+ aiwg discover "architecture" --resource-source web
565
+ ```
566
+
567
+ This allows legacy local deployments and web-backed sessions to coexist.
568
+
569
+ ## Cache and Offline Operation
570
+
571
+ The default cache root follows platform conventions:
572
+
573
+ | Platform | Default root |
574
+ |---|---|
575
+ | Linux and other Unix | `${XDG_CACHE_HOME:-~/.cache}/aiwg/resources` |
576
+ | macOS | `~/Library/Caches/aiwg/resources` |
577
+ | Windows | `%LOCALAPPDATA%\\aiwg\\resources` |
578
+
579
+ The cache contains signed metadata, immutable release generations, precomputed
580
+ indices, and fetched raw bodies. It contains no npm publishing credential and
581
+ does not require project-local state.
582
+
583
+ Operational properties:
584
+
585
+ - release generations are content-addressed;
586
+ - writes are staged before publication;
587
+ - regular-file and directory checks reject unsafe cache entries;
588
+ - digest verification occurs before bytes are returned;
589
+ - corrupt cache content fails closed in offline mode;
590
+ - online mode may recover by fetching and verifying fresh immutable bytes.
591
+
592
+ To use a custom cache location:
593
+
594
+ ```bash
595
+ export AIWG_RESOURCE_CACHE_ROOT=/var/cache/aiwg/resources
596
+ aiwg discover "architecture evolution"
597
+ ```
598
+
599
+ For shared CI caches, preserve filesystem ownership and do not allow
600
+ untrusted jobs to write into a cache consumed by privileged jobs.
601
+
602
+ ## Configuration
603
+
604
+ Most users need no configuration. The defaults are:
605
+
606
+ ```text
607
+ resource source: web
608
+ release selector: stable
609
+ release origin: https://releases.aiwg.io
610
+ query backend: fortemi-core
611
+ ```
612
+
613
+ Command-line flags are the preferred way to make per-call choices.
614
+
615
+ Advanced environment settings:
616
+
617
+ | Variable | Purpose |
618
+ |---|---|
619
+ | `AIWG_RESOURCE_BASE_URL` | Override the clean HTTPS release origin |
620
+ | `AIWG_RESOURCE_CACHE_ROOT` | Override cache location |
621
+ | `AIWG_RESOURCE_TRUST_ROOT_FILE` | Load a nonempty public PEM trust root |
622
+ | `XDG_CACHE_HOME` | Standard cache root override |
623
+ | `AIWG_LOG_LEVEL` | CLI logging level |
624
+ | `NO_UPDATE_NOTIFIER` | Disable update notices in automation |
625
+
626
+ `AIWG_RESOURCE_ALLOW_INSECURE_LOOPBACK_HTTP=1` is a test/development escape
627
+ hatch. Insecure HTTP remains restricted to loopback. Production release origins
628
+ must use HTTPS.
629
+
630
+ Do not point the CLI at an arbitrary resource server and assume it is trusted.
631
+ A custom server must publish manifests and signatures compatible with the
632
+ configured public trust root.
633
+
634
+ ## Security Model
635
+
636
+ The web distribution is designed to fail closed.
637
+
638
+ ### Signed channels
639
+
640
+ Mutable channel names resolve through detached Ed25519 signatures and monotonic
641
+ sequence numbers. The CLI rejects:
642
+
643
+ - invalid signatures;
644
+ - sequence rollback;
645
+ - conflicting data for an already observed sequence;
646
+ - channel metadata bound to another release manifest.
647
+
648
+ ### Immutable releases
649
+
650
+ Each release has a signed manifest that commits to every supported resource by
651
+ path, size, and SHA-256 digest. Exact-version selection avoids mutable channel
652
+ movement entirely.
653
+
654
+ ### Raw resources
655
+
656
+ `show` fetches only safe relative paths under `raw/` that are present in the
657
+ verified manifest. Arbitrary URL fetches, path traversal, absolute paths, and
658
+ uncommitted files are rejected.
659
+
660
+ ### Network policy
661
+
662
+ - HTTPS is mandatory for production origins.
663
+ - Redirects are rejected for signed resource fetches.
664
+ - Metadata, indices, signatures, and raw resources have fixed size limits.
665
+ - Requests have a finite timeout.
666
+ - Offline mode performs no network recovery.
667
+
668
+ ### npm supply chain
669
+
670
+ AIWG publishes `@aiwg/cli` from GitHub Actions using npm trusted publishing and
671
+ OIDC provenance. Inspect the current release:
672
+
673
+ ```bash
674
+ npm view @aiwg/cli@latest dist.attestations --json
675
+ npm view @aiwg/cli@latest dist.integrity
676
+ ```
677
+
678
+ Versions are CalVer-locked to the full `aiwg` package and release workflows
679
+ verify that the package metadata, executable, declarations, license, and README
680
+ are present.
681
+
682
+ Consumer verification guidance:
683
+
684
+ - [Release verification](https://github.com/jmagly/aiwg/blob/main/docs/releases/verifying.md)
685
+ - [Supply-chain overview](https://github.com/jmagly/aiwg/blob/main/docs/security/supply-chain-overview.md)
686
+ - [Security policy](https://github.com/jmagly/aiwg/blob/main/SECURITY.md)
687
+
688
+ ## Current Scope and Limitations
689
+
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.
694
+
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.
699
+
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:
703
+
704
+ ```bash
705
+ npm uninstall --global @aiwg/cli
706
+ npm install --global aiwg
707
+
708
+ aiwg doctor
709
+ ```
710
+
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:
722
+
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.
728
+
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:
750
+
751
+ ```bash
752
+ aiwg doctor
753
+ ```
754
+
755
+ ### Deploy through the `use` skill
756
+
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:
760
+
761
+ ```bash
762
+ aiwg use <framework-or-addon>
763
+ ```
764
+
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.
768
+
769
+ ### Pin a capability graph for reproducible work
770
+
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.
775
+
776
+ The version belongs in mission or CI configuration. Individual agents should
777
+ inherit it rather than independently selecting different versions.
778
+
779
+ ### Warm resources before network isolation
780
+
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.
785
+
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.
789
+
790
+ ### Use the web surface when the agent cannot run tools
791
+
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.
799
+
800
+ ## Installation Troubleshooting
801
+
802
+ ### Requirements
803
+
804
+ - Node.js 20 or newer;
805
+ - npm or another package manager capable of installing npm packages;
806
+ - HTTPS access to npmjs.org for installation;
807
+ - HTTPS access to `releases.aiwg.io` for cold web-resource reads.
808
+
809
+ Confirm versions:
810
+
811
+ ```bash
812
+ node --version
813
+ npm --version
814
+ ```
815
+
816
+ ### `aiwg` command not found
817
+
818
+ Check the npm global prefix:
819
+
820
+ ```bash
821
+ npm config get prefix
822
+ which aiwg
823
+ ```
824
+
825
+ Add the prefix's `bin` directory to your shell `PATH`, or use:
826
+
827
+ ```bash
828
+ npx --package @aiwg/cli aiwg --version
829
+ ```
830
+
831
+ ### npm `EACCES`
832
+
833
+ Do not default to `sudo npm install -g`. Prefer a user-owned Node installation
834
+ through a version manager, or configure a user-owned npm prefix:
5
835
 
6
836
  ```bash
837
+ npm config set prefix ~/.local
838
+ export PATH="$HOME/.local/bin:$PATH"
7
839
  npm install --global @aiwg/cli
840
+ ```
841
+
842
+ Persist the `PATH` update in the shell startup file appropriate for your
843
+ system.
844
+
845
+ ### First discovery is slower than later calls
846
+
847
+ A cold install downloads and verifies release metadata plus the precomputed
848
+ Fortemi index. Later calls use the verified cache. The request remains bounded
849
+ by a finite timeout.
850
+
851
+ If a first request fails:
852
+
853
+ ```bash
854
+ curl -I https://releases.aiwg.io/
855
+ aiwg discover "architecture evolution" --aiwg-version stable
856
+ ```
857
+
858
+ Check proxy, DNS, TLS interception, and firewall policy. Do not disable
859
+ signature verification to work around a network problem.
860
+
861
+ ### Cold offline failure
862
+
863
+ This is expected:
864
+
865
+ ```text
866
+ AIWG resource channel stable is not cached; offline mode cannot fetch it
867
+ ```
868
+
869
+ Run the command once online without `--offline`, then repeat offline.
870
+
871
+ ### Corrupt cache failure
872
+
873
+ Offline mode refuses corrupt data. Reconnect and rerun the command online so
874
+ the CLI can fetch a fresh, verified immutable generation. If diagnosing the
875
+ cache manually, preserve it first when the failure may indicate filesystem
876
+ tampering.
877
+
878
+ ### Local source not found
879
+
880
+ `@aiwg/cli` does not ship the local corpus. Remove
881
+ `--resource-source local`, select `web`, configure a legitimate local AIWG
882
+ root, or install the full `aiwg` package.
883
+
884
+ ### Web backend error
885
+
886
+ Web discovery requires the Fortemi Core backend:
8
887
 
888
+ ```bash
889
+ aiwg discover "architecture" \
890
+ --resource-source web \
891
+ --backend fortemi-core
892
+ ```
893
+
894
+ The local backend remains available only with local resources.
895
+
896
+ ### Wrong package is providing `aiwg`
897
+
898
+ ```bash
899
+ which aiwg
900
+ npm list --global --depth=0 | grep aiwg
901
+ aiwg --version
902
+ ```
903
+
904
+ If both `aiwg` and `@aiwg/cli` were installed into the same prefix, the most
905
+ recent install owns the shared executable link. Remove both, then install the
906
+ distribution you intend to use.
907
+
908
+ ## Migrating Between Distributions
909
+
910
+ From full AIWG to the lightweight package:
911
+
912
+ ```bash
913
+ npm uninstall --global aiwg
914
+ npm install --global @aiwg/cli
9
915
  aiwg discover "architecture evolution"
10
- aiwg show skill architecture-evolution
11
916
  ```
12
917
 
13
- ## Release status
918
+ Existing project files are not removed. The new executable defaults discovery
919
+ to web resources.
920
+
921
+ From the lightweight package to full AIWG:
922
+
923
+ ```bash
924
+ npm uninstall --global @aiwg/cli
925
+ npm install --global aiwg
926
+ aiwg doctor
927
+ ```
928
+
929
+ The full package defaults to its bundled local corpus. You can still request
930
+ web resources per call:
931
+
932
+ ```bash
933
+ aiwg discover "architecture evolution" --resource-source web
934
+ ```
935
+
936
+ ## Versioning and Releases
937
+
938
+ `@aiwg/cli` follows the exact version of the main AIWG release:
939
+
940
+ ```text
941
+ aiwg@2026.7.19
942
+ @aiwg/cli@2026.7.19
943
+ @aiwg/cockpit@2026.7.19
944
+ ```
945
+
946
+ Stable releases use npm's `latest` tag. Pre-release channels may use `next` or
947
+ another documented release tag. Historical package versions remain
948
+ installable by exact CalVer:
949
+
950
+ ```bash
951
+ npm install --global @aiwg/cli@2026.7.19
952
+ ```
953
+
954
+ The npm package version and selected resource version are separate choices:
955
+
956
+ ```bash
957
+ # Install a known CLI runtime.
958
+ npm install --global @aiwg/cli@2026.7.19
959
+
960
+ # Select signed resources for one command.
961
+ aiwg discover "architecture" --aiwg-version 2026.7.19
962
+ ```
963
+
964
+ Compatibility metadata in newer signed manifests allows the CLI to fail
965
+ clearly when a resource release is known to be incompatible with the installed
966
+ runtime.
967
+
968
+ Release surfaces:
969
+
970
+ - [npm package](https://www.npmjs.com/package/@aiwg/cli)
971
+ - [GitHub releases](https://github.com/jmagly/aiwg/releases)
972
+ - [signed resource host](https://releases.aiwg.io/)
973
+ - [release announcements](https://github.com/jmagly/aiwg/tree/main/docs/releases)
974
+
975
+ ## Development
976
+
977
+ `@aiwg/cli` is built from the main AIWG repository. It is not maintained as an
978
+ independent source fork.
979
+
980
+ ```bash
981
+ git clone https://github.com/jmagly/aiwg.git
982
+ cd aiwg
983
+ npm ci
984
+ npm run build:cli
985
+ npm run package:cli
986
+ ```
987
+
988
+ The staged package is written to:
989
+
990
+ ```text
991
+ dist/packages/cli/
992
+ ```
993
+
994
+ Inspect the exact tarball:
995
+
996
+ ```bash
997
+ npm pack ./dist/packages/cli --dry-run
998
+ ```
999
+
1000
+ Relevant validation:
1001
+
1002
+ ```bash
1003
+ npm run check:versions
1004
+ npm run build:cli
1005
+ npm run package:cli
1006
+ npx vitest run --config config/vitest.config.js \
1007
+ test/integration/cli-package-webmode.test.ts
1008
+ ```
1009
+
1010
+ Package invariants include:
1011
+
1012
+ - CalVer lockstep with `aiwg`;
1013
+ - runtime dependency lockstep with `aiwg`;
1014
+ - no bundled `agentic/`, `docs/`, templates, tools, or application trees;
1015
+ - executable, license, API declarations, provider metadata, and this dedicated
1016
+ README present in the tarball;
1017
+ - configuration-free signed web discovery and `show`;
1018
+ - warm offline behavior;
1019
+ - bounded package size.
1020
+
1021
+ ## Documentation
1022
+
1023
+ - [Complete AIWG CLI reference](https://docs.aiwg.io/pages/cli-reference.html)
1024
+ - [AIWG documentation](https://docs.aiwg.io/)
1025
+ - [AIWG project README](https://github.com/jmagly/aiwg#readme)
1026
+ - [Web-backed resources guide](https://github.com/jmagly/aiwg/blob/main/docs/install/web-backed-resources.md)
1027
+ - [Release verification](https://github.com/jmagly/aiwg/blob/main/docs/releases/verifying.md)
1028
+ - [Supply-chain overview](https://github.com/jmagly/aiwg/blob/main/docs/security/supply-chain-overview.md)
1029
+ - [Agentic install runbook](https://github.com/jmagly/aiwg/blob/main/docs/agentic-install-runbook.md)
1030
+
1031
+ ## Community and Support
1032
+
1033
+ - [GitHub issues](https://github.com/jmagly/aiwg/issues)
1034
+ - [Discussions](https://github.com/jmagly/aiwg/discussions)
1035
+ - [Discord](https://discord.gg/BuAusFMxdA)
1036
+ - [Telegram](https://t.me/+oJg9w2lE6A5lOGFh)
1037
+ - [AIWG website](https://aiwg.io)
1038
+
1039
+ For a security vulnerability, follow
1040
+ [`SECURITY.md`](https://github.com/jmagly/aiwg/blob/main/SECURITY.md) rather than
1041
+ opening a public issue.
1042
+
1043
+ ## License
14
1044
 
15
- This package follows AIWG CalVer in exact lockstep with the `aiwg` package.
16
- It selects the signed `stable` web channel automatically when no resource
17
- flags are supplied. Operators can still select an exact version or another
18
- channel with `--aiwg-version`, force local resources with
19
- `--resource-source local`, use verified caching, and perform warm offline
20
- reads. The larger `aiwg` package remains the local/full distribution while
21
- web parity is completed for mutating commands such as `use` and `regenerate`.
1045
+ MIT. See the
1046
+ [AIWG license](https://github.com/jmagly/aiwg/blob/main/LICENSE).
22
1047
 
23
- Resource bundles and precomputed indices are distributed by the release host,
24
- not as additional npm packages.
1048
+ The package includes its own copy of `LICENSE` in every published tarball.