@tjdals12/agent-bolt 1.3.0 → 1.4.0-next.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 (125) hide show
  1. package/README.ko.md +99 -17
  2. package/README.md +99 -17
  3. package/dist/catalog/commands/add-item.d.ts +14 -0
  4. package/dist/catalog/commands/add-item.d.ts.map +1 -1
  5. package/dist/catalog/commands/add-item.js +23 -0
  6. package/dist/catalog/commands/add-item.js.map +1 -1
  7. package/dist/catalog/commands/add-pack.d.ts +10 -0
  8. package/dist/catalog/commands/add-pack.d.ts.map +1 -1
  9. package/dist/catalog/commands/add-pack.js +16 -0
  10. package/dist/catalog/commands/add-pack.js.map +1 -1
  11. package/dist/catalog/commands/catalog/init-catalog.d.ts +6 -0
  12. package/dist/catalog/commands/catalog/init-catalog.d.ts.map +1 -1
  13. package/dist/catalog/commands/catalog/init-catalog.js +4 -0
  14. package/dist/catalog/commands/catalog/init-catalog.js.map +1 -1
  15. package/dist/catalog/commands/catalog/new/new-item.d.ts +9 -0
  16. package/dist/catalog/commands/catalog/new/new-item.d.ts.map +1 -1
  17. package/dist/catalog/commands/catalog/new/new-item.js +4 -0
  18. package/dist/catalog/commands/catalog/new/new-item.js.map +1 -1
  19. package/dist/catalog/commands/catalog/new-pack.d.ts +6 -0
  20. package/dist/catalog/commands/catalog/new-pack.d.ts.map +1 -1
  21. package/dist/catalog/commands/catalog/new-pack.js +4 -0
  22. package/dist/catalog/commands/catalog/new-pack.js.map +1 -1
  23. package/dist/catalog/commands/catalog/validate-catalog.d.ts +9 -0
  24. package/dist/catalog/commands/catalog/validate-catalog.d.ts.map +1 -1
  25. package/dist/catalog/commands/catalog/validate-catalog.js +10 -0
  26. package/dist/catalog/commands/catalog/validate-catalog.js.map +1 -1
  27. package/dist/catalog/commands/check.d.ts +19 -0
  28. package/dist/catalog/commands/check.d.ts.map +1 -1
  29. package/dist/catalog/commands/check.js +15 -0
  30. package/dist/catalog/commands/check.js.map +1 -1
  31. package/dist/catalog/commands/init.d.ts +16 -0
  32. package/dist/catalog/commands/init.d.ts.map +1 -1
  33. package/dist/catalog/commands/init.js +14 -0
  34. package/dist/catalog/commands/init.js.map +1 -1
  35. package/dist/catalog/commands/list-items.d.ts +9 -0
  36. package/dist/catalog/commands/list-items.d.ts.map +1 -1
  37. package/dist/catalog/commands/list-items.js +7 -0
  38. package/dist/catalog/commands/list-items.js.map +1 -1
  39. package/dist/catalog/commands/list-packs.d.ts +8 -0
  40. package/dist/catalog/commands/list-packs.d.ts.map +1 -1
  41. package/dist/catalog/commands/list-packs.js +7 -0
  42. package/dist/catalog/commands/list-packs.js.map +1 -1
  43. package/dist/catalog/commands/remove-item.d.ts +14 -0
  44. package/dist/catalog/commands/remove-item.d.ts.map +1 -1
  45. package/dist/catalog/commands/remove-item.js +23 -0
  46. package/dist/catalog/commands/remove-item.js.map +1 -1
  47. package/dist/catalog/commands/remove-pack.d.ts +10 -0
  48. package/dist/catalog/commands/remove-pack.d.ts.map +1 -1
  49. package/dist/catalog/commands/remove-pack.js +15 -0
  50. package/dist/catalog/commands/remove-pack.js.map +1 -1
  51. package/dist/catalog/commands/show-item.d.ts +46 -0
  52. package/dist/catalog/commands/show-item.d.ts.map +1 -1
  53. package/dist/catalog/commands/show-item.js +46 -0
  54. package/dist/catalog/commands/show-item.js.map +1 -1
  55. package/dist/catalog/commands/skill-install.d.ts +11 -0
  56. package/dist/catalog/commands/skill-install.d.ts.map +1 -0
  57. package/dist/catalog/commands/skill-install.js +22 -0
  58. package/dist/catalog/commands/skill-install.js.map +1 -0
  59. package/dist/catalog/commands/sync.d.ts +11 -0
  60. package/dist/catalog/commands/sync.d.ts.map +1 -1
  61. package/dist/catalog/commands/sync.js +5 -0
  62. package/dist/catalog/commands/sync.js.map +1 -1
  63. package/dist/catalog/content/item/find-detail.d.ts.map +1 -1
  64. package/dist/catalog/content/item/find-detail.js +3 -0
  65. package/dist/catalog/content/item/find-detail.js.map +1 -1
  66. package/dist/catalog/content/item/model.d.ts +3 -0
  67. package/dist/catalog/content/item/model.d.ts.map +1 -1
  68. package/dist/catalog/install/adapters/adapter.d.ts +3 -0
  69. package/dist/catalog/install/adapters/adapter.d.ts.map +1 -1
  70. package/dist/catalog/install/adapters/adapter.js +6 -1
  71. package/dist/catalog/install/adapters/adapter.js.map +1 -1
  72. package/dist/catalog/install/adapters/claude.adapter.d.ts +0 -1
  73. package/dist/catalog/install/adapters/claude.adapter.d.ts.map +1 -1
  74. package/dist/catalog/install/adapters/claude.adapter.js +4 -2
  75. package/dist/catalog/install/adapters/claude.adapter.js.map +1 -1
  76. package/dist/catalog/install/adapters/codex.adapter.d.ts +0 -1
  77. package/dist/catalog/install/adapters/codex.adapter.d.ts.map +1 -1
  78. package/dist/catalog/install/adapters/codex.adapter.js +5 -3
  79. package/dist/catalog/install/adapters/codex.adapter.js.map +1 -1
  80. package/dist/catalog/install/adapters/copilot.adapter.d.ts +0 -1
  81. package/dist/catalog/install/adapters/copilot.adapter.d.ts.map +1 -1
  82. package/dist/catalog/install/adapters/copilot.adapter.js +4 -2
  83. package/dist/catalog/install/adapters/copilot.adapter.js.map +1 -1
  84. package/dist/catalog/install/adapters/cursor.adapter.d.ts +0 -1
  85. package/dist/catalog/install/adapters/cursor.adapter.d.ts.map +1 -1
  86. package/dist/catalog/install/adapters/cursor.adapter.js +4 -2
  87. package/dist/catalog/install/adapters/cursor.adapter.js.map +1 -1
  88. package/dist/catalog/install/adapters/opencode.adapter.d.ts +0 -1
  89. package/dist/catalog/install/adapters/opencode.adapter.d.ts.map +1 -1
  90. package/dist/catalog/install/adapters/opencode.adapter.js +5 -3
  91. package/dist/catalog/install/adapters/opencode.adapter.js.map +1 -1
  92. package/dist/catalog/install/apply.d.ts.map +1 -1
  93. package/dist/catalog/install/apply.js +12 -6
  94. package/dist/catalog/install/apply.js.map +1 -1
  95. package/dist/catalog/install/diff.d.ts.map +1 -1
  96. package/dist/catalog/install/diff.js +12 -4
  97. package/dist/catalog/install/diff.js.map +1 -1
  98. package/dist/catalog/install/model.d.ts +5 -0
  99. package/dist/catalog/install/model.d.ts.map +1 -1
  100. package/dist/catalog/skill/install.d.ts +14 -0
  101. package/dist/catalog/skill/install.d.ts.map +1 -0
  102. package/dist/catalog/skill/install.js +39 -0
  103. package/dist/catalog/skill/install.js.map +1 -0
  104. package/dist/cli/index.js +182 -159
  105. package/dist/cli/index.js.map +1 -1
  106. package/dist/cli/json.d.ts +3 -0
  107. package/dist/cli/json.d.ts.map +1 -0
  108. package/dist/cli/json.js +8 -0
  109. package/dist/cli/json.js.map +1 -0
  110. package/dist/cli/views/shared/banner.d.ts +3 -0
  111. package/dist/cli/views/shared/banner.d.ts.map +1 -1
  112. package/dist/cli/views/shared/banner.js +5 -0
  113. package/dist/cli/views/shared/banner.js.map +1 -1
  114. package/dist/cli/views/skill-install.d.ts +3 -0
  115. package/dist/cli/views/skill-install.d.ts.map +1 -0
  116. package/dist/cli/views/skill-install.js +15 -0
  117. package/dist/cli/views/skill-install.js.map +1 -0
  118. package/dist/core/progress.d.ts +3 -1
  119. package/dist/core/progress.d.ts.map +1 -1
  120. package/dist/core/progress.js +4 -1
  121. package/dist/core/progress.js.map +1 -1
  122. package/package.json +3 -2
  123. package/skills/agent-bolt/SKILL.md +720 -0
  124. package/skills/agent-bolt/references/catalog-config-schema.md +102 -0
  125. package/skills/agent-bolt/references/json-responses.md +387 -0
@@ -0,0 +1,39 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createRequire } from 'node:module';
4
+ import { getAdapters } from '#catalog/install/adapters/registry.js';
5
+ const SKILL_ENTRY_FILENAME = 'SKILL.md';
6
+ export function resolveBundledSkillDir(name) {
7
+ const require = createRequire(import.meta.url);
8
+ const packageJsonPath = require.resolve('../../../package.json');
9
+ const skillDir = path.join(path.dirname(packageJsonPath), 'skills', name);
10
+ if (!fs.existsSync(path.join(skillDir, SKILL_ENTRY_FILENAME))) {
11
+ throw new Error(`Bundled skill '${name}' not found at ${skillDir}. Reinstall @tjdals12/agent-bolt.`);
12
+ }
13
+ return skillDir;
14
+ }
15
+ export function installBundledSkill(args) {
16
+ const { projectPath, toolIds, name, version } = args;
17
+ const skillDir = resolveBundledSkillDir(name);
18
+ const adapters = getAdapters(toolIds);
19
+ const installs = [];
20
+ for (const adapter of adapters) {
21
+ const { id, skillsDir } = adapter;
22
+ const installPath = path.join(skillsDir, name);
23
+ const targetDir = path.join(projectPath, installPath);
24
+ const status = fs.existsSync(targetDir) ? 'updated' : 'installed';
25
+ fs.rmSync(targetDir, { recursive: true, force: true });
26
+ fs.cpSync(skillDir, targetDir, { recursive: true });
27
+ stampVersion(path.join(targetDir, SKILL_ENTRY_FILENAME), version);
28
+ installs.push({ tool: id, path: installPath, status });
29
+ }
30
+ return installs;
31
+ }
32
+ function stampVersion(skillFilePath, version) {
33
+ const content = fs.readFileSync(skillFilePath, 'utf-8');
34
+ if (!content.startsWith('---\n')) {
35
+ return;
36
+ }
37
+ fs.writeFileSync(skillFilePath, content.replace('---\n', `---\nversion: ${version}\n`), 'utf-8');
38
+ }
39
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/catalog/skill/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAQxC,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE1E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,kBAAkB,QAAQ,mCAAmC,CACpF,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAKnC;IACC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAErD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAuB,EAAE,CAAC;IAExC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAElC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;QAElE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC;QAElE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CAAC,aAAqB,EAAE,OAAe;IAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IACD,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;AACnG,CAAC"}
package/dist/cli/index.js CHANGED
@@ -16,12 +16,14 @@ import { renderCheckResult } from './views/check.js';
16
16
  import { renderAddItemResult } from './views/add-item.js';
17
17
  import { renderRemoveItemResult } from './views/remove-item.js';
18
18
  import { renderShowItemResult } from './views/show-item.js';
19
+ import { renderSkillInstallResult } from './views/skill-install.js';
19
20
  import { renderValidateCatalogResult } from './views/catalog/validate-catalog.js';
20
21
  import { renderInitCatalogResult } from './views/catalog/init-catalog.js';
21
22
  import { renderNewPackResult } from './views/catalog/new-pack.js';
22
23
  import { renderNewSkillResult } from './views/catalog/new/new-skill.js';
23
24
  import { renderNewAgentResult } from './views/catalog/new/new-agent.js';
24
25
  import { renderNewGuidelineResult } from './views/catalog/new/new-guideline.js';
26
+ import { printJson, printJsonError } from './json.js';
25
27
  const program = new Command();
26
28
  const require = createRequire(import.meta.url);
27
29
  const { version } = require('../../package.json');
@@ -32,6 +34,7 @@ program
32
34
  .option('--tools <list>', 'codex,claude,cursor,copilot,opencode (omit to pick interactively)')
33
35
  .option('--source <spec>', 'Catalog source as <alias>=<type>:<location> (repeatable). e.g. team=git:https://github.com/acme/catalog.git', collect, [])
34
36
  .option('--force', 'Overwrite an existing config.yml', false)
37
+ .option('--json', 'Print the result as JSON', false)
35
38
  .addHelpText('after', dedent `
36
39
  Examples:
37
40
  $ agent-bolt init
@@ -42,16 +45,14 @@ program
42
45
  `)
43
46
  .action(async (options) => {
44
47
  const projectPath = process.cwd();
45
- try {
46
- const { InitCommand } = await import('#catalog/commands/init.js');
47
- const command = new InitCommand(options);
48
- const result = await command.execute(projectPath);
49
- renderInitResult(result, projectPath);
48
+ const { InitCommand } = await import('#catalog/commands/init.js');
49
+ const command = new InitCommand(options);
50
+ const result = await command.execute(projectPath);
51
+ if (options.json) {
52
+ printJson(command.toJson(result));
50
53
  }
51
- catch (e) {
52
- const message = e instanceof Error ? e.message : String(e);
53
- ConsoleOutput.error(message);
54
- process.exit(1);
54
+ else {
55
+ renderInitResult(result, projectPath);
55
56
  }
56
57
  });
57
58
  program
@@ -59,6 +60,7 @@ program
59
60
  .description('List the packs provided by the configured sources')
60
61
  .option('--source <alias>', 'Filter to a specific source (default: all sources)')
61
62
  .option('--no-pager', 'Print directly without the pager')
63
+ .option('--json', 'Print the result as JSON', false)
62
64
  .addHelpText('after', dedent `
63
65
  Examples:
64
66
  $ agent-bolt list-packs
@@ -66,18 +68,16 @@ program
66
68
  `)
67
69
  .action(async (options) => {
68
70
  const projectPath = process.cwd();
69
- try {
70
- const { ListPacksCommand } = await import('#catalog/commands/list-packs.js');
71
- const reporter = ProgressReporter.create();
72
- const command = new ListPacksCommand(options);
73
- const result = command.execute(projectPath, reporter);
71
+ const { ListPacksCommand } = await import('#catalog/commands/list-packs.js');
72
+ const reporter = ProgressReporter.create({ silent: options.json });
73
+ const command = new ListPacksCommand(options);
74
+ const result = command.execute(projectPath, reporter);
75
+ if (options.json) {
76
+ printJson(command.toJson(result));
77
+ }
78
+ else {
74
79
  withPager(() => renderListPacksResult(result), options.pager);
75
80
  }
76
- catch (e) {
77
- const message = e instanceof Error ? e.message : String(e);
78
- ConsoleOutput.error(message);
79
- process.exit(1);
80
- }
81
81
  });
82
82
  program
83
83
  .command('list-items')
@@ -85,6 +85,7 @@ program
85
85
  .option('--source <alias>', 'Filter to a specific source (default: all sources)')
86
86
  .option('--packs <list>', 'Filter to specific packs by name (comma separated)')
87
87
  .option('--no-pager', 'Print directly without the pager')
88
+ .option('--json', 'Print the result as JSON', false)
88
89
  .addHelpText('after', dedent `
89
90
  Examples:
90
91
  $ agent-bolt list-items
@@ -94,16 +95,14 @@ program
94
95
  `)
95
96
  .action(async (options) => {
96
97
  const projectPath = process.cwd();
97
- try {
98
- const { ListItemsCommand } = await import('#catalog/commands/list-items.js');
99
- const command = new ListItemsCommand(options);
100
- const result = command.execute(projectPath);
101
- withPager(() => renderListItemsResult(result), options.pager);
98
+ const { ListItemsCommand } = await import('#catalog/commands/list-items.js');
99
+ const command = new ListItemsCommand(options);
100
+ const result = command.execute(projectPath);
101
+ if (options.json) {
102
+ printJson(command.toJson(result));
102
103
  }
103
- catch (e) {
104
- const message = e instanceof Error ? e.message : String(e);
105
- ConsoleOutput.error(message);
106
- process.exit(1);
104
+ else {
105
+ withPager(() => renderListItemsResult(result), options.pager);
107
106
  }
108
107
  });
109
108
  program
@@ -113,22 +112,21 @@ program
113
112
  .requiredOption('--pack <name>', 'Pack name the item belongs to (required)')
114
113
  .requiredOption('--item <name>', 'Item name to show (required)')
115
114
  .option('--no-pager', 'Print directly without the pager')
115
+ .option('--json', 'Print the result as JSON', false)
116
116
  .addHelpText('after', dedent `
117
117
  Examples:
118
118
  $ agent-bolt show-item --source=common --pack=git-workflow --item=create-commit
119
119
  `)
120
120
  .action(async (options) => {
121
121
  const projectPath = process.cwd();
122
- try {
123
- const { ShowItemCommand } = await import('#catalog/commands/show-item.js');
124
- const command = new ShowItemCommand(options);
125
- const result = command.execute(projectPath);
126
- withPager(() => renderShowItemResult(result), options.pager);
122
+ const { ShowItemCommand } = await import('#catalog/commands/show-item.js');
123
+ const command = new ShowItemCommand(options);
124
+ const result = command.execute(projectPath);
125
+ if (options.json) {
126
+ printJson(command.toJson(result));
127
127
  }
128
- catch (e) {
129
- const message = e instanceof Error ? e.message : String(e);
130
- ConsoleOutput.error(message);
131
- process.exit(1);
128
+ else {
129
+ withPager(() => renderShowItemResult(result), options.pager);
132
130
  }
133
131
  });
134
132
  program
@@ -136,6 +134,7 @@ program
136
134
  .description('Add whole packs from a source to the config (all items included)')
137
135
  .option('--source <alias>', 'Target source to add the packs to. Omit to pick interactively')
138
136
  .option('--packs <list>', 'Pack names to add (comma separated). Omit to pick interactively')
137
+ .option('--json', 'Print the result as JSON', false)
139
138
  .addHelpText('after', dedent `
140
139
  Examples:
141
140
  $ agent-bolt add-pack # pick a source, then packs, interactively
@@ -145,24 +144,23 @@ program
145
144
  `)
146
145
  .action(async (options) => {
147
146
  const projectPath = process.cwd();
148
- try {
149
- const { AddPackCommand } = await import('#catalog/commands/add-pack.js');
150
- const reporter = ProgressReporter.create();
151
- const command = new AddPackCommand(options);
152
- const result = await command.execute(projectPath, reporter);
147
+ const { AddPackCommand } = await import('#catalog/commands/add-pack.js');
148
+ const reporter = ProgressReporter.create({ silent: options.json });
149
+ const command = new AddPackCommand(options);
150
+ const result = await command.execute(projectPath, reporter);
151
+ if (options.json) {
152
+ printJson(command.toJson(result));
153
+ }
154
+ else {
153
155
  renderAddPackResult(result);
154
156
  }
155
- catch (e) {
156
- const message = e instanceof Error ? e.message : String(e);
157
- ConsoleOutput.error(message);
158
- process.exit(1);
159
- }
160
157
  });
161
158
  program
162
159
  .command('remove-pack')
163
160
  .description('Remove whole packs from a source in the config')
164
161
  .option('--source <alias>', 'Target source to remove the packs from. Omit to pick interactively')
165
162
  .option('--packs <list>', 'Pack names to remove (comma separated). Omit to pick interactively')
163
+ .option('--json', 'Print the result as JSON', false)
166
164
  .addHelpText('after', dedent `
167
165
  Examples:
168
166
  $ agent-bolt remove-pack # pick a source, then packs, interactively
@@ -172,16 +170,14 @@ program
172
170
  `)
173
171
  .action(async (options) => {
174
172
  const projectPath = process.cwd();
175
- try {
176
- const { RemovePackCommand } = await import('#catalog/commands/remove-pack.js');
177
- const command = new RemovePackCommand(options);
178
- const result = await command.execute(projectPath);
179
- renderRemovePackResult(result);
173
+ const { RemovePackCommand } = await import('#catalog/commands/remove-pack.js');
174
+ const command = new RemovePackCommand(options);
175
+ const result = await command.execute(projectPath);
176
+ if (options.json) {
177
+ printJson(command.toJson(result));
180
178
  }
181
- catch (e) {
182
- const message = e instanceof Error ? e.message : String(e);
183
- ConsoleOutput.error(message);
184
- process.exit(1);
179
+ else {
180
+ renderRemovePackResult(result);
185
181
  }
186
182
  });
187
183
  program
@@ -192,6 +188,7 @@ program
192
188
  .option('--skills <list>', 'Skill names to add (comma separated)')
193
189
  .option('--agents <list>', 'Agent names to add (comma separated)')
194
190
  .option('--guidelines <list>', 'Guideline names to add (comma separated)')
191
+ .option('--json', 'Print the result as JSON', false)
195
192
  .addHelpText('after', dedent `
196
193
  Examples:
197
194
  $ agent-bolt add-item # pick a source, then packs and items, interactively
@@ -202,18 +199,16 @@ program
202
199
  `)
203
200
  .action(async (options) => {
204
201
  const projectPath = process.cwd();
205
- try {
206
- const { AddItemCommand } = await import('#catalog/commands/add-item.js');
207
- const reporter = ProgressReporter.create();
208
- const command = new AddItemCommand(options);
209
- const result = await command.execute(projectPath, reporter);
202
+ const { AddItemCommand } = await import('#catalog/commands/add-item.js');
203
+ const reporter = ProgressReporter.create({ silent: options.json });
204
+ const command = new AddItemCommand(options);
205
+ const result = await command.execute(projectPath, reporter);
206
+ if (options.json) {
207
+ printJson(command.toJson(result));
208
+ }
209
+ else {
210
210
  renderAddItemResult(result);
211
211
  }
212
- catch (e) {
213
- const message = e instanceof Error ? e.message : String(e);
214
- ConsoleOutput.error(message);
215
- process.exit(1);
216
- }
217
212
  });
218
213
  program
219
214
  .command('remove-item')
@@ -223,6 +218,7 @@ program
223
218
  .option('--skills <list>', 'Skill names to remove (comma separated)')
224
219
  .option('--agents <list>', 'Agent names to remove (comma separated)')
225
220
  .option('--guidelines <list>', 'Guideline names to remove (comma separated)')
221
+ .option('--json', 'Print the result as JSON', false)
226
222
  .addHelpText('after', dedent `
227
223
  Examples:
228
224
  $ agent-bolt remove-item # pick a source, then packs and items, interactively
@@ -233,61 +229,78 @@ program
233
229
  `)
234
230
  .action(async (options) => {
235
231
  const projectPath = process.cwd();
236
- try {
237
- const { RemoveItemCommand } = await import('#catalog/commands/remove-item.js');
238
- const command = new RemoveItemCommand(options);
239
- const result = await command.execute(projectPath);
240
- renderRemoveItemResult(result);
232
+ const { RemoveItemCommand } = await import('#catalog/commands/remove-item.js');
233
+ const command = new RemoveItemCommand(options);
234
+ const result = await command.execute(projectPath);
235
+ if (options.json) {
236
+ printJson(command.toJson(result));
241
237
  }
242
- catch (e) {
243
- const message = e instanceof Error ? e.message : String(e);
244
- ConsoleOutput.error(message);
245
- process.exit(1);
238
+ else {
239
+ renderRemoveItemResult(result);
246
240
  }
247
241
  });
248
242
  program
249
243
  .command('sync')
250
244
  .description('Install configured tools into each selected tool')
245
+ .option('--json', 'Print the result as JSON', false)
251
246
  .addHelpText('after', dedent `
252
247
  Examples:
253
248
  $ agent-bolt sync
254
249
  `)
255
- .action(async () => {
250
+ .action(async (option) => {
256
251
  const projectPath = process.cwd();
257
- try {
258
- const { SyncCommand } = await import('#catalog/commands/sync.js');
259
- const command = new SyncCommand();
260
- const result = command.execute(projectPath);
261
- renderSyncResult(result);
252
+ const { SyncCommand } = await import('#catalog/commands/sync.js');
253
+ const command = new SyncCommand();
254
+ const result = command.execute(projectPath);
255
+ if (option.json) {
256
+ printJson(command.toJson(result));
262
257
  }
263
- catch (e) {
264
- const message = e instanceof Error ? e.message : String(e);
265
- ConsoleOutput.error(message);
266
- process.exit(1);
258
+ else {
259
+ renderSyncResult(result);
267
260
  }
268
261
  });
269
262
  program
270
263
  .command('check')
271
264
  .description('Check whether installed tools have drifted from the config')
265
+ .option('--json', 'Print the result as JSON', false)
272
266
  .addHelpText('after', dedent `
273
267
  Examples:
274
268
  $ agent-bolt check
275
269
  `)
276
- .action(async () => {
270
+ .action(async (options) => {
277
271
  const projectPath = process.cwd();
278
- try {
279
- const { CheckCommand } = await import('#catalog/commands/check.js');
280
- const command = new CheckCommand();
281
- const { checkResult, drifted } = command.execute(projectPath);
272
+ const { CheckCommand } = await import('#catalog/commands/check.js');
273
+ const command = new CheckCommand();
274
+ const { checkResult, drifted } = command.execute(projectPath);
275
+ if (options.json) {
276
+ printJson(command.toJson({ checkResult, drifted }));
277
+ }
278
+ else {
282
279
  renderCheckResult(checkResult);
283
- if (drifted) {
284
- process.exitCode = 1;
285
- }
286
280
  }
287
- catch (e) {
288
- const message = e instanceof Error ? e.message : String(e);
289
- ConsoleOutput.error(message);
290
- process.exit(1);
281
+ if (drifted) {
282
+ process.exitCode = 1;
283
+ }
284
+ });
285
+ const skill = program.command('skill').description('Manage the agent-bolt skill (install)');
286
+ skill
287
+ .command('install')
288
+ .description('Install the agent-bolt skill into each selected tool')
289
+ .option('--json', 'Print the result as JSON', false)
290
+ .addHelpText('after', dedent `
291
+ Examples:
292
+ $ agent-bolt skill install
293
+ `)
294
+ .action(async (options) => {
295
+ const projectPath = process.cwd();
296
+ const { SkillInstallCommand } = await import('#catalog/commands/skill-install.js');
297
+ const command = new SkillInstallCommand();
298
+ const result = command.execute(projectPath, version);
299
+ if (options.json) {
300
+ printJson(command.toJson(result));
301
+ }
302
+ else {
303
+ renderSkillInstallResult(result);
291
304
  }
292
305
  });
293
306
  const catalog = program
@@ -297,6 +310,7 @@ catalog
297
310
  .command('validate')
298
311
  .description('Validate a catalog directory (structure, manifests, integrity)')
299
312
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
313
+ .option('--json', 'Print the result as JSON', false)
300
314
  .addHelpText('after', dedent `
301
315
  Examples:
302
316
  $ agent-bolt catalog validate
@@ -306,19 +320,17 @@ catalog
306
320
  const { dir } = options;
307
321
  const projectPath = process.cwd();
308
322
  const catalogDirPath = dir ? path.resolve(projectPath, dir) : projectPath;
309
- try {
310
- const { ValidateCatalogCommand } = await import('#catalog/commands/catalog/validate-catalog.js');
311
- const command = new ValidateCatalogCommand();
312
- const { validateCatalogResult, invalid } = command.execute(catalogDirPath);
323
+ const { ValidateCatalogCommand } = await import('#catalog/commands/catalog/validate-catalog.js');
324
+ const command = new ValidateCatalogCommand();
325
+ const { validateCatalogResult, invalid } = command.execute(catalogDirPath);
326
+ if (options.json) {
327
+ printJson(command.toJson({ validateCatalogResult, invalid }));
328
+ }
329
+ else {
313
330
  renderValidateCatalogResult(validateCatalogResult);
314
- if (invalid) {
315
- process.exitCode = 1;
316
- }
317
331
  }
318
- catch (e) {
319
- const message = e instanceof Error ? e.message : String(e);
320
- ConsoleOutput.error(message);
321
- process.exit(1);
332
+ if (invalid) {
333
+ process.exitCode = 1;
322
334
  }
323
335
  });
324
336
  catalog
@@ -327,6 +339,7 @@ catalog
327
339
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
328
340
  .option('--name <name>', 'Catalog name (default: target directory name)')
329
341
  .option('--description <text>', 'Catalog description (default: a TODO placeholder)')
342
+ .option('--json', 'Print the result as JSON', false)
330
343
  .addHelpText('after', dedent `
331
344
  Examples:
332
345
  $ agent-bolt catalog init
@@ -336,16 +349,14 @@ catalog
336
349
  const { dir, name, description } = options;
337
350
  const projectPath = process.cwd();
338
351
  const catalogDir = dir ? path.resolve(projectPath, dir) : projectPath;
339
- try {
340
- const { InitCatalogCommand } = await import('#catalog/commands/catalog/init-catalog.js');
341
- const command = new InitCatalogCommand({ name, description });
342
- const result = command.execute(catalogDir);
343
- renderInitCatalogResult(result, projectPath);
352
+ const { InitCatalogCommand } = await import('#catalog/commands/catalog/init-catalog.js');
353
+ const command = new InitCatalogCommand({ name, description });
354
+ const result = command.execute(catalogDir);
355
+ if (options.json) {
356
+ printJson(command.toJson(result));
344
357
  }
345
- catch (e) {
346
- const message = e instanceof Error ? e.message : String(e);
347
- ConsoleOutput.error(message);
348
- process.exit(1);
358
+ else {
359
+ renderInitCatalogResult(result, projectPath);
349
360
  }
350
361
  });
351
362
  catalog
@@ -353,6 +364,7 @@ catalog
353
364
  .description('Create a new pack skeleton (packs/<name>/pack.json)')
354
365
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
355
366
  .option('--description <text>', 'Pack description (default: a TODO placeholder)')
367
+ .option('--json', 'Print the result as JSON', false)
356
368
  .addHelpText('after', dedent `
357
369
  Examples:
358
370
  $ agent-bolt catalog new-pack git-workflow
@@ -363,20 +375,18 @@ catalog
363
375
  const { dir, description } = options;
364
376
  const projectPath = process.cwd();
365
377
  const catalogDir = dir ? path.resolve(projectPath, dir) : projectPath;
366
- try {
367
- const { NewPackCommand } = await import('#catalog/commands/catalog/new-pack.js');
368
- const command = new NewPackCommand({
369
- name,
370
- description,
371
- });
372
- const result = command.execute(catalogDir);
378
+ const { NewPackCommand } = await import('#catalog/commands/catalog/new-pack.js');
379
+ const command = new NewPackCommand({
380
+ name,
381
+ description,
382
+ });
383
+ const result = command.execute(catalogDir);
384
+ if (options.json) {
385
+ printJson(command.toJson(result));
386
+ }
387
+ else {
373
388
  renderNewPackResult(result, projectPath);
374
389
  }
375
- catch (e) {
376
- const message = e instanceof Error ? e.message : String(e);
377
- ConsoleOutput.error(message);
378
- process.exit(1);
379
- }
380
390
  });
381
391
  catalog
382
392
  .command('new-skill <name>')
@@ -384,6 +394,7 @@ catalog
384
394
  .requiredOption('--pack <name>', 'Parent pack the skill belongs to (required)')
385
395
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
386
396
  .option('--description <text>', 'Skill description (default: a TODO placeholder)')
397
+ .option('--json', 'Print the result as JSON', false)
387
398
  .addHelpText('after', dedent `
388
399
  Name:
389
400
  Lowercase letters, digits, and hyphens (kebab-case), e.g. create-commit.
@@ -397,21 +408,19 @@ catalog
397
408
  const { pack, dir, description } = options;
398
409
  const projectPath = process.cwd();
399
410
  const catalogDir = dir ? path.resolve(projectPath, dir) : projectPath;
400
- try {
401
- const { NewSkillCommand } = await import('#catalog/commands/catalog/new/new-skill.js');
402
- const command = new NewSkillCommand({
403
- pack,
404
- name,
405
- description,
406
- });
407
- const result = command.execute(catalogDir);
411
+ const { NewSkillCommand } = await import('#catalog/commands/catalog/new/new-skill.js');
412
+ const command = new NewSkillCommand({
413
+ pack,
414
+ name,
415
+ description,
416
+ });
417
+ const result = command.execute(catalogDir);
418
+ if (options.json) {
419
+ printJson(command.toJson(result));
420
+ }
421
+ else {
408
422
  renderNewSkillResult(result, projectPath);
409
423
  }
410
- catch (e) {
411
- const message = e instanceof Error ? e.message : String(e);
412
- ConsoleOutput.error(message);
413
- process.exit(1);
414
- }
415
424
  });
416
425
  catalog
417
426
  .command('new-agent <name>')
@@ -419,6 +428,7 @@ catalog
419
428
  .requiredOption('--pack <name>', 'Parent pack the agent belongs to (required)')
420
429
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
421
430
  .option('--description <text>', 'Agent description (default: a TODO placeholder)')
431
+ .option('--json', 'Print the result as JSON', false)
422
432
  .addHelpText('after', dedent `
423
433
  Name:
424
434
  Lowercase letters, digits, and hyphens (kebab-case), e.g. code-reviewer.
@@ -431,16 +441,14 @@ catalog
431
441
  const { pack, dir, description } = options;
432
442
  const projectPath = process.cwd();
433
443
  const catalogDir = dir ? path.resolve(projectPath, dir) : projectPath;
434
- try {
435
- const { NewAgentCommand } = await import('#catalog/commands/catalog/new/new-agent.js');
436
- const command = new NewAgentCommand({ pack, name, description });
437
- const result = command.execute(catalogDir);
438
- renderNewAgentResult(result, projectPath);
444
+ const { NewAgentCommand } = await import('#catalog/commands/catalog/new/new-agent.js');
445
+ const command = new NewAgentCommand({ pack, name, description });
446
+ const result = command.execute(catalogDir);
447
+ if (options.json) {
448
+ printJson(command.toJson(result));
439
449
  }
440
- catch (e) {
441
- const message = e instanceof Error ? e.message : String(e);
442
- ConsoleOutput.error(message);
443
- process.exit(1);
450
+ else {
451
+ renderNewAgentResult(result, projectPath);
444
452
  }
445
453
  });
446
454
  catalog
@@ -449,6 +457,7 @@ catalog
449
457
  .requiredOption('--pack <name>', 'Parent pack the guideline belongs to (required)')
450
458
  .option('--dir <dir>', 'Catalog directory (default: current directory)')
451
459
  .option('--description <text>', 'Guideline description (default: a TODO placeholder)')
460
+ .option('--json', 'Print the result as JSON', false)
452
461
  .addHelpText('after', dedent `
453
462
  Name:
454
463
  Lowercase letters, digits, and hyphens (kebab-case), e.g. commit-rules.
@@ -461,17 +470,31 @@ catalog
461
470
  const { pack, dir, description } = options;
462
471
  const projectPath = process.cwd();
463
472
  const catalogDir = dir ? path.resolve(projectPath, dir) : projectPath;
464
- try {
465
- const { NewGuidelineCommand } = await import('#catalog/commands/catalog/new/new-guideline.js');
466
- const command = new NewGuidelineCommand({ pack, name, description });
467
- const result = command.execute(catalogDir);
473
+ const { NewGuidelineCommand } = await import('#catalog/commands/catalog/new/new-guideline.js');
474
+ const command = new NewGuidelineCommand({ pack, name, description });
475
+ const result = command.execute(catalogDir);
476
+ if (options.json) {
477
+ printJson(command.toJson(result));
478
+ }
479
+ else {
468
480
  renderNewGuidelineResult(result, projectPath);
469
481
  }
470
- catch (e) {
482
+ });
483
+ let jsonMode = false;
484
+ program.hook('preAction', (_thisCommand, actionCommand) => {
485
+ jsonMode = actionCommand.opts().json ?? false;
486
+ });
487
+ try {
488
+ await program.parseAsync();
489
+ }
490
+ catch (e) {
491
+ if (jsonMode) {
492
+ printJsonError(e);
493
+ }
494
+ else {
471
495
  const message = e instanceof Error ? e.message : String(e);
472
496
  ConsoleOutput.error(message);
473
- process.exit(1);
474
497
  }
475
- });
476
- program.parse();
498
+ process.exitCode = 1;
499
+ }
477
500
  //# sourceMappingURL=index.js.map