@open-agent-toolkit/cli 0.2.54 → 0.2.56

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 (38) hide show
  1. package/assets/bundle-metadata.json +1 -1
  2. package/assets/docs/cli-utilities/configuration.md +12 -2
  3. package/assets/docs/docs-tooling/commands.md +36 -5
  4. package/assets/docs/reference/oat-directory-structure.md +56 -4
  5. package/assets/docs/workflows/skills/recon.md +28 -12
  6. package/assets/public-package-versions.json +4 -4
  7. package/assets/skills/oat-dispatch-subagents/SKILL.md +4 -105
  8. package/assets/skills/oat-dispatch-subagents/references/record-schema.md +0 -226
  9. package/assets/skills/oat-project-autonomous/references/gate-inventory.md +2 -2
  10. package/assets/skills/oat-project-document/references/docs/autonomy-contract.md +2 -2
  11. package/assets/skills/oat-project-implement/references/docs/autonomy-contract.md +2 -2
  12. package/assets/skills/oat-project-pr-final/references/docs/autonomy-contract.md +2 -2
  13. package/assets/skills/oat-project-quick-start/references/docs/autonomy-contract.md +2 -2
  14. package/assets/skills/recon/SKILL.md +76 -38
  15. package/assets/skills/recon/references/packet-contract.md +138 -105
  16. package/assets/skills/recon/scripts/lib/contracts.mjs +181 -674
  17. package/assets/skills/recon/scripts/lib/validated-run.mjs +10 -16
  18. package/assets/skills/recon/scripts/render-packet.mjs +7 -20
  19. package/assets/skills/recon/scripts/validate-packet.mjs +177 -344
  20. package/dist/commands/config/index.d.ts +1 -0
  21. package/dist/commands/config/index.d.ts.map +1 -1
  22. package/dist/commands/config/index.js +51 -4
  23. package/dist/commands/docs/index-generate/generator.d.ts +43 -1
  24. package/dist/commands/docs/index-generate/generator.d.ts.map +1 -1
  25. package/dist/commands/docs/index-generate/generator.js +169 -3
  26. package/dist/commands/docs/index-generate/index.d.ts +8 -3
  27. package/dist/commands/docs/index-generate/index.d.ts.map +1 -1
  28. package/dist/commands/docs/index-generate/index.js +340 -24
  29. package/dist/commands/docs/init/scaffold.d.ts +11 -1
  30. package/dist/commands/docs/init/scaffold.d.ts.map +1 -1
  31. package/dist/commands/docs/init/scaffold.js +11 -2
  32. package/dist/config/oat-config.d.ts +14 -0
  33. package/dist/config/oat-config.d.ts.map +1 -1
  34. package/dist/config/oat-config.js +61 -0
  35. package/dist/fs/assets.d.ts +33 -4
  36. package/dist/fs/assets.d.ts.map +1 -1
  37. package/dist/fs/assets.js +127 -12
  38. package/package.json +2 -2
@@ -1,13 +1,42 @@
1
- export declare function validateAssetsBundle(assetsRoot: string, expectedVersion?: string): Promise<void>;
1
+ /**
2
+ * Where the assets root under validation came from.
3
+ *
4
+ * The packaged `<cliRoot>/assets` default and an operator-supplied
5
+ * `OAT_ASSETS_DIR` fail exactly the same checks, but only the packaged one is
6
+ * repairable by rebuilding or reinstalling this package. Carrying the source
7
+ * into every fail-closed diagnosis is what keeps its remedy true.
8
+ *
9
+ * Exported only because it appears in the signature of the exported
10
+ * `validateAssetsBundle` and this package emits declarations. It is an
11
+ * internal context argument with a `packaged` default, not a new contract any
12
+ * caller has to satisfy.
13
+ */
14
+ export type AssetsRootSource = 'packaged' | 'override';
15
+ /**
16
+ * Fail closed on any bundle a consumer must not read as a legitimate install.
17
+ *
18
+ * Checks run in escalating specificity — metadata presence, metadata shape,
19
+ * CLI version, then top-level structure — so malformed metadata remains the
20
+ * primary diagnosis and a structural complaint is only reported about a bundle
21
+ * whose metadata already agrees with the running CLI.
22
+ *
23
+ * `source` only selects the remedy sentence. It defaults to `packaged` so
24
+ * direct callers keep their existing rebuild/reinstall guidance, and it never
25
+ * decides whether a bundle is acceptable.
26
+ */
27
+ export declare function validateAssetsBundle(assetsRoot: string, expectedVersion?: string, source?: AssetsRootSource): Promise<void>;
2
28
  /**
3
29
  * Resolve the directory the CLI reads bundled assets from.
4
30
  *
5
31
  * A non-empty `OAT_ASSETS_DIR` selects an explicit root; an unset or blank
6
32
  * value keeps the packaged `<cliRoot>/assets` default. Both paths run the same
7
33
  * directory and bundle-integrity checks, and an explicit root never falls back
8
- * to the packaged one: a missing, non-directory, malformed, or
9
- * version-mismatched override fails closed with the same actionable errors.
10
- * A relative value is resolved against the process working directory.
34
+ * to the packaged one: a missing, non-directory, malformed, version-mismatched,
35
+ * or structurally incomplete override fails closed with the same actionable
36
+ * errors. The override discriminator is derived once, here, and carried
37
+ * through every one of those failures so each reports a remedy that applies to
38
+ * the root it actually read. A relative value is resolved against the process
39
+ * working directory.
11
40
  */
12
41
  export declare function resolveAssetsRoot(env?: NodeJS.ProcessEnv): Promise<string>;
13
42
  //# sourceMappingURL=assets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/fs/assets.ts"],"names":[],"mappings":"AA2BA,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,eAAe,SAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,CAoCf;AAQD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/fs/assets.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,UAAU,CAAC;AA4IvD;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,eAAe,SAAc,EAC7B,MAAM,GAAE,gBAA6B,GACpC,OAAO,CAAC,IAAI,CAAC,CAsCf;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
package/dist/fs/assets.js CHANGED
@@ -4,6 +4,56 @@ import { fileURLToPath } from 'node:url';
4
4
  import { CliError } from '../errors/index.js';
5
5
  import { OAT_VERSION } from '../shared/oat-version.js';
6
6
  const BUNDLE_METADATA_FILENAME = 'bundle-metadata.json';
7
+ /**
8
+ * Remedy for a packaged root that is absent or is not a directory. The
9
+ * packaged tree is a build output, so the build is what creates it.
10
+ */
11
+ const PACKAGED_ROOT_REMEDY = "Run 'pnpm build' to generate bundled assets.";
12
+ /**
13
+ * Remedy for a packaged bundle whose contents are missing, malformed, or
14
+ * built for another CLI version. Binding it once keeps the metadata, version,
15
+ * and structural families phrased identically so their guidance cannot drift
16
+ * apart.
17
+ */
18
+ const PACKAGED_BUNDLE_REMEDY = 'Reinstall @open-agent-toolkit/cli or rebuild the CLI before updating tools.';
19
+ /**
20
+ * The single remedy for every failure under an explicit override. Neither a
21
+ * rebuild nor a reinstall touches an operator-supplied path, so this sentence
22
+ * names the one input the operator controls and the two properties it must
23
+ * satisfy — complete, and built for the running CLI. It deliberately offers no
24
+ * way to proceed on the packaged bundle instead: an explicit override never
25
+ * falls back.
26
+ */
27
+ const OVERRIDE_REMEDY = 'Check OAT_ASSETS_DIR and point it to a complete asset bundle built for this CLI version.';
28
+ /**
29
+ * The one place a fail-closed assets diagnosis turns its source into advice.
30
+ *
31
+ * Every branch keeps its own factual prefix — path, expected and actual
32
+ * version, offending directory — and varies only this trailing sentence, so a
33
+ * source-aware remedy can never quietly become a source-aware verdict.
34
+ */
35
+ function assetsRemedy(source, packagedRemedy = PACKAGED_BUNDLE_REMEDY) {
36
+ return source === 'override' ? OVERRIDE_REMEDY : packagedRemedy;
37
+ }
38
+ /**
39
+ * Top-level directories `packages/cli/scripts/bundle-assets.sh` creates for
40
+ * every bundle, listed in the order that script creates them. The producer
41
+ * makes all of them unconditionally — even when a category has no entries — so
42
+ * their presence is the cheapest structural contract that tells a complete
43
+ * bundle apart from a metadata-only or truncated one.
44
+ *
45
+ * This is deliberately a shape check and nothing more: no per-file manifest,
46
+ * no checksums, and no walk of the bundled documents.
47
+ */
48
+ const REQUIRED_BUNDLE_DIRECTORIES = [
49
+ 'skills',
50
+ 'agents',
51
+ 'templates',
52
+ 'scripts',
53
+ 'docs',
54
+ 'migration',
55
+ 'config',
56
+ ];
7
57
  function isBundleMetadata(value) {
8
58
  if (!value || typeof value !== 'object') {
9
59
  return false;
@@ -13,28 +63,86 @@ function isBundleMetadata(value) {
13
63
  typeof metadata.oatVersion === 'string' &&
14
64
  metadata.oatVersion.length > 0);
15
65
  }
16
- export async function validateAssetsBundle(assetsRoot, expectedVersion = OAT_VERSION) {
66
+ /**
67
+ * The `errno` label of a failed filesystem call, or `unknown` when the thrown
68
+ * value carries none. `EACCES`, `ELOOP`, and `EIO` demand different operator
69
+ * responses and none of them is the remedy this validator can offer, so the
70
+ * code is reported rather than collapsed into one unreadable-path verdict.
71
+ */
72
+ function errorCode(error) {
73
+ if (typeof error === 'object' &&
74
+ error !== null &&
75
+ 'code' in error &&
76
+ typeof error.code === 'string' &&
77
+ error.code.length > 0) {
78
+ return error.code;
79
+ }
80
+ return 'unknown';
81
+ }
82
+ function isMissingPathError(error) {
83
+ return errorCode(error) === 'ENOENT';
84
+ }
85
+ /**
86
+ * Reject a bundle whose top-level shape is incomplete.
87
+ *
88
+ * Reports the first offending path in producer order, so the diagnosis for a
89
+ * given broken bundle is deterministic. A failed `stat` is never read as an
90
+ * absent-but-tolerable directory: a path the process cannot read fails closed
91
+ * under its own diagnosis, naming the `errno` that stopped it.
92
+ */
93
+ async function validateBundleStructure(assetsRoot, source) {
94
+ for (const directoryName of REQUIRED_BUNDLE_DIRECTORIES) {
95
+ const directoryPath = join(assetsRoot, directoryName);
96
+ let directoryStat;
97
+ try {
98
+ directoryStat = await stat(directoryPath);
99
+ }
100
+ catch (error) {
101
+ if (isMissingPathError(error)) {
102
+ throw new CliError(`Bundled assets are incomplete: required directory not found: ${directoryPath}. ${assetsRemedy(source)}`, 2);
103
+ }
104
+ throw new CliError(`Bundled assets are unreadable: required directory could not be read (${errorCode(error)}): ${directoryPath}. ${assetsRemedy(source)}`, 2);
105
+ }
106
+ if (!directoryStat.isDirectory()) {
107
+ throw new CliError(`Bundled assets are incomplete: required bundle path is not a directory: ${directoryPath}. ${assetsRemedy(source)}`, 2);
108
+ }
109
+ }
110
+ }
111
+ /**
112
+ * Fail closed on any bundle a consumer must not read as a legitimate install.
113
+ *
114
+ * Checks run in escalating specificity — metadata presence, metadata shape,
115
+ * CLI version, then top-level structure — so malformed metadata remains the
116
+ * primary diagnosis and a structural complaint is only reported about a bundle
117
+ * whose metadata already agrees with the running CLI.
118
+ *
119
+ * `source` only selects the remedy sentence. It defaults to `packaged` so
120
+ * direct callers keep their existing rebuild/reinstall guidance, and it never
121
+ * decides whether a bundle is acceptable.
122
+ */
123
+ export async function validateAssetsBundle(assetsRoot, expectedVersion = OAT_VERSION, source = 'packaged') {
17
124
  const metadataPath = join(assetsRoot, BUNDLE_METADATA_FILENAME);
18
125
  let rawMetadata;
19
126
  try {
20
127
  rawMetadata = await readFile(metadataPath, 'utf8');
21
128
  }
22
129
  catch {
23
- throw new CliError(`Bundled asset metadata not found: ${metadataPath}. Reinstall @open-agent-toolkit/cli or rebuild the CLI before updating tools.`, 2);
130
+ throw new CliError(`Bundled asset metadata not found: ${metadataPath}. ${assetsRemedy(source)}`, 2);
24
131
  }
25
132
  let metadata;
26
133
  try {
27
134
  metadata = JSON.parse(rawMetadata);
28
135
  }
29
136
  catch {
30
- throw new CliError(`Bundled asset metadata is invalid: ${metadataPath}. Reinstall @open-agent-toolkit/cli or rebuild the CLI before updating tools.`, 2);
137
+ throw new CliError(`Bundled asset metadata is invalid: ${metadataPath}. ${assetsRemedy(source)}`, 2);
31
138
  }
32
139
  if (!isBundleMetadata(metadata)) {
33
- throw new CliError(`Bundled asset metadata is invalid: ${metadataPath}. Reinstall @open-agent-toolkit/cli or rebuild the CLI before updating tools.`, 2);
140
+ throw new CliError(`Bundled asset metadata is invalid: ${metadataPath}. ${assetsRemedy(source)}`, 2);
34
141
  }
35
142
  if (metadata.oatVersion !== expectedVersion) {
36
- throw new CliError(`Bundled assets version mismatch: CLI ${expectedVersion}, assets ${metadata.oatVersion}. Reinstall @open-agent-toolkit/cli or rebuild the CLI before updating tools.`, 2);
143
+ throw new CliError(`Bundled assets version mismatch: CLI ${expectedVersion}, assets ${metadata.oatVersion}. ${assetsRemedy(source)}`, 2);
37
144
  }
145
+ await validateBundleStructure(assetsRoot, source);
38
146
  }
39
147
  function resolvePackagedAssetsRoot() {
40
148
  const modulePath = fileURLToPath(import.meta.url);
@@ -47,25 +155,32 @@ function resolvePackagedAssetsRoot() {
47
155
  * A non-empty `OAT_ASSETS_DIR` selects an explicit root; an unset or blank
48
156
  * value keeps the packaged `<cliRoot>/assets` default. Both paths run the same
49
157
  * directory and bundle-integrity checks, and an explicit root never falls back
50
- * to the packaged one: a missing, non-directory, malformed, or
51
- * version-mismatched override fails closed with the same actionable errors.
52
- * A relative value is resolved against the process working directory.
158
+ * to the packaged one: a missing, non-directory, malformed, version-mismatched,
159
+ * or structurally incomplete override fails closed with the same actionable
160
+ * errors. The override discriminator is derived once, here, and carried
161
+ * through every one of those failures so each reports a remedy that applies to
162
+ * the root it actually read. A relative value is resolved against the process
163
+ * working directory.
53
164
  */
54
165
  export async function resolveAssetsRoot(env = process.env) {
55
166
  const override = env.OAT_ASSETS_DIR?.trim() ?? '';
56
- const assetsRoot = override.length > 0 ? resolve(override) : resolvePackagedAssetsRoot();
167
+ const isOverride = override.length > 0;
168
+ const source = isOverride ? 'override' : 'packaged';
169
+ const assetsRoot = isOverride
170
+ ? resolve(override)
171
+ : resolvePackagedAssetsRoot();
57
172
  try {
58
173
  const assetsStat = await stat(assetsRoot);
59
174
  if (!assetsStat.isDirectory()) {
60
- throw new CliError(`Assets path is not a directory: ${assetsRoot}`, 2);
175
+ throw new CliError(`Assets path is not a directory: ${assetsRoot}. ${assetsRemedy(source, PACKAGED_ROOT_REMEDY)}`, 2);
61
176
  }
62
177
  }
63
178
  catch (error) {
64
179
  if (error instanceof CliError) {
65
180
  throw error;
66
181
  }
67
- throw new CliError(`Assets directory not found: ${assetsRoot}. Run 'pnpm build' to generate bundled assets.`, 2);
182
+ throw new CliError(`Assets directory not found: ${assetsRoot}. ${assetsRemedy(source, PACKAGED_ROOT_REMEDY)}`, 2);
68
183
  }
69
- await validateAssetsBundle(assetsRoot);
184
+ await validateAssetsBundle(assetsRoot, OAT_VERSION, source);
70
185
  return assetsRoot;
71
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-agent-toolkit/cli",
3
- "version": "0.2.54",
3
+ "version": "0.2.56",
4
4
  "private": false,
5
5
  "description": "Open Agent Toolkit CLI",
6
6
  "homepage": "https://github.com/voxmedia/open-agent-toolkit/tree/main/packages/cli",
@@ -34,7 +34,7 @@
34
34
  "ora": "^9.0.0",
35
35
  "yaml": "2.8.2",
36
36
  "zod": "^3.25.76",
37
- "@open-agent-toolkit/control-plane": "0.2.54"
37
+ "@open-agent-toolkit/control-plane": "0.2.56"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.10.0",