@aiwg/cli 2026.7.21 → 2026.7.24

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 (32) hide show
  1. package/README.md +14 -3
  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 +2 -0
  5. package/dist/src/artifacts/index-builder.js +44 -8
  6. package/dist/src/artifacts/query-engine.js +1 -1
  7. package/dist/src/artifacts/types.js +1 -0
  8. package/dist/src/cli/handlers/index.js +5 -1
  9. package/dist/src/cli/handlers/sessions.js +339 -40
  10. package/dist/src/cli/handlers/setup-manifest.js +800 -0
  11. package/dist/src/cli/handlers/use.js +127 -17
  12. package/dist/src/config/aiwg-config.js +18 -2
  13. package/dist/src/config/cli.js +16 -3
  14. package/dist/src/extensions/commands/definitions.js +99 -0
  15. package/dist/src/security/threat-assessment-config.js +296 -0
  16. package/dist/src/serve/sandbox-registry.js +34 -0
  17. package/dist/src/sessions/adapters/claude.js +37 -9
  18. package/dist/src/sessions/adapters/codex.js +38 -11
  19. package/dist/src/sessions/adapters/cursor.js +166 -10
  20. package/dist/src/sessions/adapters/factory.js +50 -9
  21. package/dist/src/sessions/batch-contracts.js +121 -0
  22. package/dist/src/sessions/batch-import.js +265 -0
  23. package/dist/src/sessions/contracts.js +32 -5
  24. package/dist/src/sessions/import-lease.js +152 -0
  25. package/dist/src/sessions/importer.js +163 -14
  26. package/dist/src/sessions/index.js +6 -0
  27. package/dist/src/sessions/origin.js +117 -0
  28. package/dist/src/sessions/readers.js +1 -1
  29. package/dist/src/sessions/repository.js +354 -13
  30. package/dist/src/sessions/timeline.js +148 -0
  31. package/dist/src/sessions/workspace-discovery.js +319 -0
  32. package/package.json +1 -1
package/README.md CHANGED
@@ -10,10 +10,15 @@ AIWG skills and agents use this CLI to perform common operations with
10
10
  predictable, structured calls instead of spending context on shell discovery,
11
11
  filesystem traversal, command reconstruction, and repeated tool output.
12
12
 
13
- ```bash
14
- npm install --global @aiwg/cli
13
+ New to AIWG? Install the full `aiwg` package and let the agentic installer
14
+ connect the complete system. `@aiwg/cli` is the smaller execution layer for
15
+ agents, CI, and web-backed installations.
15
16
 
16
- aiwg doctor
17
+ ```text
18
+ Install or repair AIWG for this project by following
19
+ https://raw.githubusercontent.com/jmagly/aiwg/main/setup.aiwg.yaml
20
+ Explain the plan before changing anything, preserve my existing work, and ask
21
+ me only for choices you cannot safely determine.
17
22
  ```
18
23
 
19
24
  [![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)
@@ -209,6 +214,12 @@ execution layer and can obtain resources from the signed web release. Choose
209
214
  `aiwg` when local authoring, the full bundled corpus, or completely cold
210
215
  offline operation is required.
211
216
 
217
+ For a first installation, an uncertain environment, or a machine with an old
218
+ or broken AIWG setup, use the full `aiwg` package and the
219
+ [agentic installer manifest](https://raw.githubusercontent.com/jmagly/aiwg/main/setup.aiwg.yaml).
220
+ The flow detects development checkouts and preserves development mode unless
221
+ the user explicitly approves switching to the published package.
222
+
212
223
  Both CLI packages expose the same `aiwg` executable name. Install one globally
213
224
  at a time unless you deliberately manage separate npm prefixes.
214
225
 
@@ -8,4 +8,5 @@
8
8
  export { run } from '../cli/router.js';
9
9
  export * from '../resources/index.js';
10
10
  export * from '../sessions/index.js';
11
+ export * from '../security/threat-assessment-config.js';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -8,4 +8,5 @@
8
8
  export { run } from '../cli/router.js';
9
9
  export * from '../resources/index.js';
10
10
  export * from '../sessions/index.js';
11
+ export * from '../security/threat-assessment-config.js';
11
12
  //# sourceMappingURL=index.js.map
@@ -326,6 +326,8 @@ export function recordTypeForEntry(entry, schemaVersion) {
326
326
  return "aiwg.command";
327
327
  case "rule":
328
328
  return "aiwg.rule";
329
+ case "schema":
330
+ return "aiwg.schema";
329
331
  case "behavior":
330
332
  return "aiwg.behavior";
331
333
  case "flow":
@@ -132,6 +132,36 @@ function extractSummary(data, body) {
132
132
  const lines = body.split('\n').filter(l => l.trim() && !l.startsWith('#'));
133
133
  return lines.slice(0, 5).join(' ').slice(0, 500).trim();
134
134
  }
135
+ function parseSchemaDoc(content, relativePath) {
136
+ if (!/\.(json|ya?ml)$/i.test(relativePath))
137
+ return null;
138
+ let parsed;
139
+ try {
140
+ parsed = /\.json$/i.test(relativePath) ? JSON.parse(content) : loadYaml(content);
141
+ }
142
+ catch {
143
+ return null;
144
+ }
145
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
146
+ return null;
147
+ const schema = parsed;
148
+ const title = typeof schema.title === 'string' && schema.title.trim()
149
+ ? schema.title.trim()
150
+ : undefined;
151
+ const id = typeof schema.$id === 'string' && schema.$id.trim()
152
+ ? schema.$id.trim()
153
+ : undefined;
154
+ const description = typeof schema.description === 'string' && schema.description.trim()
155
+ ? schema.description.trim().slice(0, 240)
156
+ : undefined;
157
+ const filename = path.basename(relativePath, path.extname(relativePath)).replace(/\.schema$/i, '');
158
+ return {
159
+ title: title ?? filename,
160
+ name: filename,
161
+ capability: description ?? (id ? `Schema definition for ${title ?? filename}` : undefined),
162
+ searchTerms: [id, title, filename, 'schema'].filter((term) => Boolean(term)),
163
+ };
164
+ }
135
165
  /**
136
166
  * Determine SDLC phase from file path
137
167
  */
@@ -150,8 +180,6 @@ function inferPhase(filePath) {
150
180
  * always lands as `type: 'skill'` regardless of frontmatter.
151
181
  */
152
182
  function inferType(data, filePath) {
153
- if (typeof data.type === 'string')
154
- return data.type;
155
183
  // Normalize separators so matchers are cross-platform.
156
184
  const normalized = filePath.replace(/\\/g, '/');
157
185
  const basename = path.basename(filePath, path.extname(filePath)).toLowerCase();
@@ -179,7 +207,8 @@ function inferType(data, filePath) {
179
207
  const skipBasenames = new Set(['readme', 'rules-index', 'index']);
180
208
  const isMarkdown = /\.md$/i.test(filePath);
181
209
  const isTemplateAsset = TEMPLATE_INDEX_EXTENSIONS.some(ext => normalized.endsWith(ext));
182
- if (!skipBasenames.has(basename) && (isMarkdown || isTemplateAsset)) {
210
+ const isSchemaAsset = /\.(json|ya?ml|md)$/i.test(filePath);
211
+ if (!skipBasenames.has(basename) && (isMarkdown || isTemplateAsset || isSchemaAsset)) {
183
212
  // Look at directory segments only (exclude the file itself).
184
213
  for (let i = segments.length - 2; i >= 0; i--) {
185
214
  const seg = segments[i];
@@ -215,6 +244,10 @@ function inferType(data, filePath) {
215
244
  if (isMarkdown)
216
245
  return 'rule';
217
246
  break;
247
+ case 'schemas':
248
+ if (isSchemaAsset)
249
+ return 'schema';
250
+ break;
218
251
  case 'templates':
219
252
  return 'template';
220
253
  case 'behaviors':
@@ -228,6 +261,8 @@ function inferType(data, filePath) {
228
261
  }
229
262
  }
230
263
  }
264
+ if (typeof data.type === 'string')
265
+ return data.type;
231
266
  // Legacy SDLC artifact heuristics (existing behavior preserved).
232
267
  if (basename.startsWith('uc-') || basename.includes('use-case'))
233
268
  return 'use-case';
@@ -864,11 +899,12 @@ export async function buildIndex(cwd, options = {}) {
864
899
  const inferredType = inferType(data, relativePath);
865
900
  const physicalType = inferType({ ...data, type: undefined }, relativePath);
866
901
  const runbook = flow ? null : parseRunbookDoc(data, body, relativePath);
867
- const title = flow?.name ?? extractTitle(data, body);
902
+ const schemaDoc = inferredType === 'schema' ? parseSchemaDoc(content, relativePath) : null;
903
+ const title = flow?.name ?? schemaDoc?.title ?? extractTitle(data, body);
868
904
  const phase = typeof data.phase === 'string' ? data.phase : inferPhase(relativePath);
869
905
  const type = flow?.type ?? (runbook ? 'runbook' : inferredType);
870
906
  const tags = flow ? flow.tags : (Array.isArray(data.tags) ? data.tags.map(String) : []);
871
- const summary = flow?.description ?? runbook?.capability ?? extractSummary(data, body);
907
+ const summary = flow?.description ?? schemaDoc?.capability ?? runbook?.capability ?? extractSummary(data, body);
872
908
  const dependencies = extractMentions(content);
873
909
  // Discovery metadata (#1214, #1540, #1792) — meaningful for operational
874
910
  // AIWG artifact kinds. Kept undefined on document types so the index file
@@ -877,10 +913,10 @@ export async function buildIndex(cwd, options = {}) {
877
913
  // Declarative processes have no trigger phrases — they rely on their
878
914
  // capability and structure-aware search terms.
879
915
  const triggers = isDiscoverable && !flow ? extractTriggers(body, data) : undefined;
880
- const capability = flow?.capability ?? runbook?.capability ?? (isDiscoverable ? extractCapability(data, body) : undefined);
916
+ const capability = flow?.capability ?? schemaDoc?.capability ?? runbook?.capability ?? (isDiscoverable ? extractCapability(data, body) : undefined);
881
917
  const kind = flow?.kind ?? runbook?.kind;
882
918
  const sourceType = runbook && physicalType !== 'runbook' ? physicalType : undefined;
883
- const searchTerms = flow?.searchTerms ?? runbook?.searchTerms;
919
+ const searchTerms = flow?.searchTerms ?? schemaDoc?.searchTerms ?? runbook?.searchTerms;
884
920
  const kernel = data.kernel === true || data.kernel === 'true' ? true : undefined;
885
921
  // Script entrypoint metadata is meaningful for skills only (#1227).
886
922
  const script = type === 'skill' ? extractSkillScript(data) : undefined;
@@ -889,7 +925,7 @@ export async function buildIndex(cwd, options = {}) {
889
925
  // Canonical short name (#1233) — used by the scorer to floor exact-name
890
926
  // queries to 1.0 so hyphenated kernel-skill names like `aiwg-doctor`
891
927
  // remain searchable even when the rendered title strips the hyphen.
892
- const name = flow ? flow.name : (isDiscoverable ? extractCanonicalName(data, relativePath) : undefined);
928
+ const name = flow ? flow.name : schemaDoc?.name ?? (isDiscoverable ? extractCanonicalName(data, relativePath) : undefined);
893
929
  entry = {
894
930
  path: relativePath,
895
931
  type,
@@ -174,7 +174,7 @@ const SCORE_STOPWORDS = new Set([
174
174
  'handle', 'handles', 'handling',
175
175
  // AIWG meta-type nouns — zero discriminating signal in a discover query
176
176
  'aiwg', 'skill', 'skills', 'agent', 'agents', 'command', 'commands',
177
- 'rule', 'rules', 'flow', 'flows', 'workflow', 'workflows',
177
+ 'rule', 'rules', 'schema', 'schemas', 'flow', 'flows', 'workflow', 'workflows',
178
178
  ]);
179
179
  /**
180
180
  * Tokenize a query phrase into lowercased keywords for multi-word
@@ -24,6 +24,7 @@ export const OPERATIONAL_DISCOVERY_TYPES = [
24
24
  'agent',
25
25
  'command',
26
26
  'rule',
27
+ 'schema',
27
28
  'flow',
28
29
  'runbook',
29
30
  'template',
@@ -38,6 +38,7 @@ import { packagesHandler } from './packages.js';
38
38
  import { marketplaceHandler } from './marketplace.js';
39
39
  import { initHandler } from './init.js';
40
40
  import { setupHandler } from './setup.js';
41
+ import { setupGenerateHandler, setupRunHandler, setupValidateHandler } from './setup-manifest.js';
41
42
  import { runHandler } from './run.js';
42
43
  import { stewardHandler, stewardHandlers } from './steward.js';
43
44
  import { serveHandler } from './serve.js';
@@ -61,7 +62,7 @@ export {
61
62
  // Maintenance
62
63
  helpHandler, versionHandler, doctorHandler, updateHandler, refreshHandler, regenerateHandler, workspaceContextHandler,
63
64
  // Framework management
64
- useHandler, listHandler, removeHandler, promoteHandler, installHandler, packagesHandler, marketplaceHandler, initHandler, setupHandler, issueHandler, issueAuditHandler, runHandler,
65
+ useHandler, listHandler, removeHandler, promoteHandler, installHandler, packagesHandler, marketplaceHandler, initHandler, setupHandler, setupGenerateHandler, setupRunHandler, setupValidateHandler, issueHandler, issueAuditHandler, runHandler,
65
66
  // Project
66
67
  newBundleHandler, quickrefHandler, newProjectHandler, sessionHandler, sessionsHandler,
67
68
  // Workspace
@@ -132,6 +133,9 @@ export const allHandlers = [
132
133
  newProjectHandler,
133
134
  initHandler,
134
135
  setupHandler,
136
+ setupGenerateHandler,
137
+ setupRunHandler,
138
+ setupValidateHandler,
135
139
  issueHandler,
136
140
  issueAuditHandler,
137
141
  runHandler,