@taurgis/bonsai 3.1.0 → 3.2.2

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 (164) hide show
  1. package/README.md +21 -4
  2. package/agents/agents/salesforce-docs-researcher.agent.md +14 -1
  3. package/agents/instructions/salesforce-research.instructions.md +2 -1
  4. package/bin/cli.mjs +9 -17
  5. package/dist/base-command.d.ts +37 -10
  6. package/dist/base-command.js +113 -46
  7. package/dist/commands/config/base.js +11 -2
  8. package/dist/commands/config/get.js +8 -12
  9. package/dist/commands/config/index.js +2 -2
  10. package/dist/commands/config/list.js +10 -16
  11. package/dist/commands/config/set.d.ts +2 -1
  12. package/dist/commands/config/set.js +34 -27
  13. package/dist/commands/config/unset.d.ts +2 -1
  14. package/dist/commands/config/unset.js +25 -24
  15. package/dist/commands/fetch.d.ts +7 -15
  16. package/dist/commands/fetch.js +58 -401
  17. package/dist/commands/import.d.ts +4 -9
  18. package/dist/commands/import.js +56 -280
  19. package/dist/commands/inspect.d.ts +7 -1
  20. package/dist/commands/inspect.js +103 -52
  21. package/dist/commands/list.d.ts +13 -1
  22. package/dist/commands/list.js +79 -32
  23. package/dist/commands/prune.d.ts +4 -1
  24. package/dist/commands/prune.js +56 -65
  25. package/dist/commands/status.d.ts +3 -2
  26. package/dist/commands/status.js +52 -79
  27. package/dist/hooks/command-not-found/suggest.d.ts +1 -0
  28. package/dist/hooks/command-not-found/suggest.js +66 -39
  29. package/dist/lib/argv.d.ts +24 -3
  30. package/dist/lib/argv.js +124 -53
  31. package/dist/lib/batch.d.ts +41 -0
  32. package/dist/lib/batch.js +39 -0
  33. package/dist/lib/cache-view.d.ts +21 -0
  34. package/dist/lib/cache-view.js +30 -0
  35. package/dist/lib/cli-emit.d.ts +28 -0
  36. package/dist/lib/cli-emit.js +44 -0
  37. package/dist/lib/cli-error-policy.d.ts +57 -0
  38. package/dist/lib/cli-error-policy.js +74 -0
  39. package/dist/lib/cli-flag-manifest.d.ts +5 -0
  40. package/dist/lib/cli-flag-manifest.js +8 -0
  41. package/dist/lib/cli-presentation.d.ts +39 -0
  42. package/dist/lib/cli-presentation.js +50 -0
  43. package/dist/lib/cli-result-types.d.ts +88 -0
  44. package/dist/lib/cli-result-types.js +2 -0
  45. package/dist/lib/config/index.d.ts +22 -4
  46. package/dist/lib/config/index.js +59 -4
  47. package/dist/lib/config/resolve.d.ts +21 -0
  48. package/dist/lib/config/resolve.js +55 -6
  49. package/dist/lib/config-persist.d.ts +28 -0
  50. package/dist/lib/config-persist.js +29 -0
  51. package/dist/lib/envelope.d.ts +41 -3
  52. package/dist/lib/envelope.js +147 -4
  53. package/dist/lib/help-preflight.d.ts +5 -8
  54. package/dist/lib/help-preflight.js +13 -32
  55. package/dist/lib/json-meta.d.ts +0 -2
  56. package/dist/lib/json-meta.js +21 -25
  57. package/dist/lib/limit-flag.d.ts +11 -1
  58. package/dist/lib/limit-flag.js +19 -6
  59. package/dist/lib/parse-error-ux.d.ts +5 -0
  60. package/dist/lib/parse-error-ux.js +73 -0
  61. package/dist/lib/prune-flags.d.ts +28 -0
  62. package/dist/lib/prune-flags.js +74 -0
  63. package/dist/lib/research/artifact-index.d.ts +11 -2
  64. package/dist/lib/research/artifact-index.js +7 -4
  65. package/dist/lib/research/browser.d.ts +41 -2
  66. package/dist/lib/research/browser.js +139 -50
  67. package/dist/lib/research/capture.d.ts +24 -2
  68. package/dist/lib/research/capture.js +24 -4
  69. package/dist/lib/research/cli-io.d.ts +33 -0
  70. package/dist/lib/research/cli-io.js +27 -0
  71. package/dist/lib/research/compress.d.ts +7 -0
  72. package/dist/lib/research/compress.js +7 -3
  73. package/dist/lib/research/docs/capabilities.d.ts +15 -0
  74. package/dist/lib/research/docs/capabilities.js +5 -0
  75. package/dist/lib/research/docs/clean-dom.d.ts +2 -0
  76. package/dist/lib/research/docs/clean-dom.js +2 -0
  77. package/dist/lib/research/docs/code-blocks.d.ts +2 -0
  78. package/dist/lib/research/docs/code-blocks.js +2 -0
  79. package/dist/lib/research/docs/detect.d.ts +4 -0
  80. package/dist/lib/research/docs/detect.js +4 -0
  81. package/dist/lib/research/docs/machine-readable.d.ts +18 -0
  82. package/dist/lib/research/docs/machine-readable.js +10 -0
  83. package/dist/lib/research/docs/markdown-source.d.ts +20 -0
  84. package/dist/lib/research/docs/markdown-source.js +19 -2
  85. package/dist/lib/research/docs/quality-gates.d.ts +5 -0
  86. package/dist/lib/research/docs/quality-gates.js +4 -0
  87. package/dist/lib/research/docs/rsc.d.ts +9 -2
  88. package/dist/lib/research/docs/rsc.js +5 -2
  89. package/dist/lib/research/docs/section-artifacts.d.ts +12 -0
  90. package/dist/lib/research/docs/section-artifacts.js +12 -0
  91. package/dist/lib/research/docs/sections.d.ts +18 -0
  92. package/dist/lib/research/docs/sections.js +17 -1
  93. package/dist/lib/research/docs/source-map.d.ts +28 -0
  94. package/dist/lib/research/docs/source-map.js +27 -0
  95. package/dist/lib/research/docs/validate.d.ts +35 -2
  96. package/dist/lib/research/docs/validate.js +47 -2
  97. package/dist/lib/research/extract.d.ts +16 -0
  98. package/dist/lib/research/extract.js +12 -1
  99. package/dist/lib/research/fetch-command-service.d.ts +36 -0
  100. package/dist/lib/research/fetch-command-service.js +310 -0
  101. package/dist/lib/research/fetch-result.d.ts +114 -0
  102. package/dist/lib/research/fetch-result.js +212 -0
  103. package/dist/lib/research/fetcher.d.ts +46 -8
  104. package/dist/lib/research/fetcher.js +58 -30
  105. package/dist/lib/research/freshness.d.ts +54 -11
  106. package/dist/lib/research/freshness.js +91 -31
  107. package/dist/lib/research/import-command-service.d.ts +56 -0
  108. package/dist/lib/research/import-command-service.js +381 -0
  109. package/dist/lib/research/keywords.js +5 -1
  110. package/dist/lib/research/markdown.d.ts +12 -1
  111. package/dist/lib/research/markdown.js +13 -5
  112. package/dist/lib/research/persist-artifact.d.ts +23 -0
  113. package/dist/lib/research/persist-artifact.js +27 -0
  114. package/dist/lib/research/prompt-injection.d.ts +8 -0
  115. package/dist/lib/research/prompt-injection.js +42 -13
  116. package/dist/lib/research/proxy.d.ts +14 -8
  117. package/dist/lib/research/proxy.js +14 -10
  118. package/dist/lib/research/revalidate.d.ts +49 -20
  119. package/dist/lib/research/revalidate.js +80 -15
  120. package/dist/lib/research/schema.d.ts +7 -0
  121. package/dist/lib/research/schema.js +2 -0
  122. package/dist/lib/research/secret-scan.d.ts +6 -0
  123. package/dist/lib/research/secret-scan.js +8 -0
  124. package/dist/lib/research/secure-write.d.ts +11 -1
  125. package/dist/lib/research/secure-write.js +38 -7
  126. package/dist/lib/research/storage.d.ts +5 -1
  127. package/dist/lib/research/storage.js +8 -3
  128. package/dist/lib/research/summarize.d.ts +15 -0
  129. package/dist/lib/research/summarize.js +11 -0
  130. package/dist/lib/research/url.d.ts +9 -6
  131. package/dist/lib/research/url.js +33 -21
  132. package/dist/lib/text.d.ts +7 -2
  133. package/dist/lib/text.js +13 -2
  134. package/dist/lib/value-flags.d.ts +14 -0
  135. package/dist/lib/value-flags.js +28 -0
  136. package/dist/sites/coveo.d.ts +10 -0
  137. package/dist/sites/coveo.js +10 -0
  138. package/dist/sites/index.d.ts +16 -0
  139. package/dist/sites/index.js +16 -4
  140. package/dist/sites/markdown-twin.d.ts +31 -0
  141. package/dist/sites/markdown-twin.js +56 -0
  142. package/dist/sites/salesforce/fetch-page.d.ts +8 -2
  143. package/dist/sites/salesforce/fetch-page.js +14 -3
  144. package/dist/sites/salesforce/help-tooling-markdown.d.ts +30 -0
  145. package/dist/sites/salesforce/help-tooling-markdown.js +74 -0
  146. package/dist/sites/salesforce/index.d.ts +1 -0
  147. package/dist/sites/salesforce/index.js +1 -0
  148. package/dist/sites/salesforce-developer/fetch-page.d.ts +6 -1
  149. package/dist/sites/salesforce-developer/fetch-page.js +6 -1
  150. package/dist/sites/salesforce-developer/index.d.ts +1 -0
  151. package/dist/sites/salesforce-developer/index.js +1 -0
  152. package/dist/sites/salesforce-developer/route-markdown.d.ts +18 -6
  153. package/dist/sites/salesforce-developer/route-markdown.js +29 -67
  154. package/dist/sites/salesforce-doc-fetch.d.ts +39 -5
  155. package/dist/sites/salesforce-doc-fetch.js +52 -7
  156. package/dist/sites/salesforce-dom-probe.d.ts +20 -2
  157. package/dist/sites/salesforce-dom-probe.js +20 -2
  158. package/dist/sites/types.d.ts +14 -8
  159. package/dist/sites/types.js +3 -0
  160. package/oclif.manifest.json +192 -87
  161. package/package.json +19 -7
  162. package/agents/agents/official-docs-researcher.agent.md +0 -87
  163. package/agents/instructions/web-research.instructions.md +0 -44
  164. package/agents/skills/web-research/SKILL.md +0 -118
@@ -1,18 +1,19 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { ConfigCommand, configScopeFlags } from './base.js';
3
- import { KEY_META, writeUserConfig, writeProjectConfig, validKeysHint, } from '../../lib/config/index.js';
3
+ import { KEY_META, validKeysHint } from '../../lib/config/index.js';
4
+ import { persistConfigPatch } from '../../lib/config-persist.js';
4
5
  export default class ConfigSet extends ConfigCommand {
5
6
  static id = 'config set';
6
- static summary = 'Set a research configuration key.';
7
- static description = 'Persist a configuration value. Writes user-level config by default; pass --local to write the project-level config (.bonsai.json in cwd).\n\n' +
7
+ static summary = 'Set a research configuration key';
8
+ static description = 'Persist a configuration value. Writes user-level config by default; pass --local for project-level config (.bonsai.json in cwd).\n\n' +
8
9
  `Valid keys: ${validKeysHint()}. The inline form \`<key>=<value>\` is also accepted.`;
9
10
  static examples = [
10
11
  {
11
- description: 'store research cache inside the current project',
12
+ description: 'store research cache in the current project',
12
13
  command: '<%= config.bin %> config set storage project --local',
13
14
  },
14
15
  {
15
- description: 'set the user-level default using the inline key=value form',
16
+ description: 'set the user-level default with key=value',
16
17
  command: '<%= config.bin %> config set storage=global',
17
18
  },
18
19
  ];
@@ -22,11 +23,11 @@ export default class ConfigSet extends ConfigCommand {
22
23
  };
23
24
  static flags = {
24
25
  ...configScopeFlags({
25
- global: 'Write to user-level config (default).',
26
- local: 'Write to project-level config (.bonsai.json in cwd).',
26
+ global: 'write user-level config (default)',
27
+ local: 'write project-level config (.bonsai.json in cwd)',
27
28
  }),
28
29
  'dry-run': Flags.boolean({
29
- description: 'show what would be written without saving',
30
+ description: 'preview write without saving',
30
31
  default: false,
31
32
  }),
32
33
  };
@@ -39,6 +40,11 @@ export default class ConfigSet extends ConfigCommand {
39
40
  this.error(`Missing required argument: value for key "${keyArg}"`, {
40
41
  exit: 2,
41
42
  code: 'MISSING_ARGUMENT',
43
+ suggestions: [
44
+ meta.values
45
+ ? `Use one of: ${meta.values.join(', ')}`
46
+ : `Provide a value for ${keyArg}: ${meta.description}`,
47
+ ],
42
48
  });
43
49
  }
44
50
  const parsed = meta.parseValue(valueArg);
@@ -47,35 +53,36 @@ export default class ConfigSet extends ConfigCommand {
47
53
  this.error(`Invalid value "${valueArg}" for "${keyArg}". ${guidance}`, {
48
54
  exit: 2,
49
55
  code: 'INVALID_VALUE',
56
+ suggestions: meta.values?.map((value) => `Set ${keyArg} to "${value}": ${this.config.bin} config set ${keyArg} ${value}`),
50
57
  });
51
58
  }
52
59
  const scope = this.writeScope(this.flags.local);
53
60
  const formatted = meta.format(parsed);
54
- if (this.flags['dry-run']) {
61
+ const dryRun = this.effectiveDryRun(this.flags['dry-run']);
62
+ if (dryRun) {
55
63
  if (!this.jsonEnabled())
56
64
  this.log(`[dry-run] Would set ${keyArg} = ${formatted} (${scope})`);
57
- return { key: keyArg, value: parsed, scope, dryRun: true };
65
+ return { key: keyArg, value: parsed, scope, dryRun: true, status: 'would_set' };
58
66
  }
59
- const patch = { [keyArg]: parsed };
60
- if (scope === 'project') {
61
- writeProjectConfig(process.cwd(), patch);
62
- }
63
- else {
64
- const configDir = this.config.configDir;
65
- if (!configDir) {
66
- this.error('Could not determine user config directory. Use --local to write project config.', {
67
- exit: 1,
68
- code: 'CONFIG_DIR_UNAVAILABLE',
69
- suggestions: [
70
- `Write project config instead: ${this.config.bin} config set <key> <value> --local`,
71
- ],
72
- });
73
- }
74
- writeUserConfig(configDir, patch);
67
+ const persisted = persistConfigPatch({
68
+ scope,
69
+ cwd: process.cwd(),
70
+ configDir: this.config.configDir,
71
+ patch: { [keyArg]: parsed },
72
+ action: 'set',
73
+ bin: this.config.bin,
74
+ key: keyArg,
75
+ });
76
+ if (!persisted.ok) {
77
+ this.error(persisted.message, {
78
+ exit: 1,
79
+ code: persisted.code,
80
+ suggestions: persisted.suggestions,
81
+ });
75
82
  }
76
83
  if (!this.jsonEnabled())
77
84
  this.log(`Set ${keyArg} = ${formatted} (${scope})`);
78
- return { key: keyArg, value: parsed, scope, dryRun: false };
85
+ return { key: keyArg, value: parsed, scope, dryRun: false, status: 'set' };
79
86
  }
80
87
  }
81
88
  /**
@@ -1,4 +1,5 @@
1
1
  import { ConfigCommand } from './base.js';
2
+ import type { ConfigWriteResult } from '../../lib/cli-result-types.js';
2
3
  export default class ConfigUnset extends ConfigCommand<typeof ConfigUnset> {
3
4
  static id: string;
4
5
  static summary: string;
@@ -16,5 +17,5 @@ export default class ConfigUnset extends ConfigCommand<typeof ConfigUnset> {
16
17
  local: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
18
  };
18
19
  static stdoutIsPrimaryData: boolean;
19
- run(): Promise<unknown>;
20
+ run(): Promise<ConfigWriteResult>;
20
21
  }
@@ -1,9 +1,10 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { ConfigCommand, configScopeFlags } from './base.js';
3
- import { writeUserConfig, writeProjectConfig, validKeysHint } from '../../lib/config/index.js';
3
+ import { validKeysHint } from '../../lib/config/index.js';
4
+ import { persistConfigPatch } from '../../lib/config-persist.js';
4
5
  export default class ConfigUnset extends ConfigCommand {
5
6
  static id = 'config unset';
6
- static summary = 'Remove a research configuration key.';
7
+ static summary = 'Remove a research configuration key';
7
8
  static description = `Delete a key from user-level config (default) or project-level config (--local), restoring the built-in default.\n\nValid keys: ${validKeysHint()}.`;
8
9
  static examples = [
9
10
  {
@@ -20,11 +21,11 @@ export default class ConfigUnset extends ConfigCommand {
20
21
  };
21
22
  static flags = {
22
23
  ...configScopeFlags({
23
- global: 'Remove from user-level config (default).',
24
- local: 'Remove from project-level config (.bonsai.json in cwd).',
24
+ global: 'remove from user-level config (default)',
25
+ local: 'remove from project-level config (.bonsai.json in cwd)',
25
26
  }),
26
27
  'dry-run': Flags.boolean({
27
- description: 'show what would be removed without saving',
28
+ description: 'preview removal without saving',
28
29
  default: false,
29
30
  }),
30
31
  };
@@ -33,30 +34,30 @@ export default class ConfigUnset extends ConfigCommand {
33
34
  const key = this.args.key;
34
35
  this.validateConfigKeyAndScope(key, this.flags.global, this.flags.local);
35
36
  const scope = this.writeScope(this.flags.local);
36
- if (this.flags['dry-run']) {
37
+ const dryRun = this.effectiveDryRun(this.flags['dry-run']);
38
+ if (dryRun) {
37
39
  if (!this.jsonEnabled())
38
40
  this.log(`[dry-run] Would unset ${key} (${scope})`);
39
- return { key, scope, dryRun: true };
41
+ return { key, scope, dryRun: true, status: 'would_unset' };
40
42
  }
41
- const patch = { [key]: undefined };
42
- if (scope === 'project') {
43
- writeProjectConfig(process.cwd(), patch);
44
- }
45
- else {
46
- const configDir = this.config.configDir;
47
- if (!configDir) {
48
- this.error('Could not determine user config directory. Use --local to remove project config.', {
49
- exit: 1,
50
- code: 'CONFIG_DIR_UNAVAILABLE',
51
- suggestions: [
52
- `Remove project config instead: ${this.config.bin} config unset ${key} --local`,
53
- ],
54
- });
55
- }
56
- writeUserConfig(configDir, patch);
43
+ const persisted = persistConfigPatch({
44
+ scope,
45
+ cwd: process.cwd(),
46
+ configDir: this.config.configDir,
47
+ patch: { [key]: undefined },
48
+ action: 'unset',
49
+ bin: this.config.bin,
50
+ key,
51
+ });
52
+ if (!persisted.ok) {
53
+ this.error(persisted.message, {
54
+ exit: 1,
55
+ code: persisted.code,
56
+ suggestions: persisted.suggestions,
57
+ });
57
58
  }
58
59
  if (!this.jsonEnabled())
59
60
  this.log(`Unset ${key} (${scope})`);
60
- return { key, scope, dryRun: false };
61
+ return { key, scope, dryRun: false, status: 'unset' };
61
62
  }
62
63
  }
@@ -1,4 +1,5 @@
1
1
  import { BaseCommand } from '../base-command.js';
2
+ /** Hidden named `fetch` command; usually invoked as `bonsai <url>`. */
2
3
  export default class FetchCommand extends BaseCommand<typeof FetchCommand> {
3
4
  static id: string;
4
5
  static hidden: boolean;
@@ -26,20 +27,11 @@ export default class FetchCommand extends BaseCommand<typeof FetchCommand> {
26
27
  storage: import("@oclif/core/interfaces").OptionFlag<"global" | "project" | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
28
  };
28
29
  static stdoutIsPrimaryData: boolean;
29
- protected envelopeCommandId(): string;
30
- private executeCacheHit;
31
- private executeCacheMiss;
32
- private buildResultData;
33
- private validateDurationFlags;
34
- private emitFetchError;
35
- private resolveArtifact;
36
- private persistFreshArtifact;
37
- private persistSectionsIfFresh;
30
+ /**
31
+ * When a multi-URL batch has any per-URL failure, keep the result array (including hits) and
32
+ * surface FETCH_FAILED on the envelope — same batch contract as status/inspect CACHE_MISS.
33
+ */
34
+ protected toSuccessJson(data: unknown): Record<string, unknown>;
35
+ private serviceFlags;
38
36
  run(): Promise<unknown>;
39
- private fetchSingleTarget;
40
37
  }
41
- export declare function describeError(err: unknown): string;
42
- export declare function fetchFailureGuidance(message: string, url: string): {
43
- suggestions: string[];
44
- ref?: string;
45
- } | undefined;