@crewx/cli 0.8.0-rc.66 → 0.8.0-rc.82

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 (281) hide show
  1. package/bin/crewx +2 -0
  2. package/dist/bootstrap/crewx-cli.d.ts +11 -0
  3. package/dist/bootstrap/crewx-cli.js +31 -0
  4. package/dist/builtin.d.ts +15 -0
  5. package/dist/{cli/builtin.handler.js → builtin.js} +21 -7
  6. package/dist/commands/agent.d.ts +12 -0
  7. package/dist/commands/agent.js +246 -0
  8. package/dist/commands/doctor.d.ts +12 -0
  9. package/dist/commands/doctor.js +190 -0
  10. package/dist/commands/execute.d.ts +21 -0
  11. package/dist/commands/execute.js +117 -0
  12. package/dist/commands/hook/install.d.ts +21 -0
  13. package/dist/commands/hook/install.js +175 -0
  14. package/dist/commands/hook/paths.d.ts +19 -0
  15. package/dist/commands/hook/paths.js +94 -0
  16. package/dist/commands/hook/status.d.ts +7 -0
  17. package/dist/commands/hook/status.js +86 -0
  18. package/dist/commands/hook/uninstall.d.ts +8 -0
  19. package/dist/commands/hook/uninstall.js +71 -0
  20. package/dist/commands/hook-dispatch.d.ts +15 -0
  21. package/dist/commands/hook-dispatch.js +180 -0
  22. package/dist/commands/init.d.ts +24 -0
  23. package/dist/commands/init.js +133 -0
  24. package/dist/commands/kill.d.ts +12 -0
  25. package/dist/commands/kill.js +49 -0
  26. package/dist/commands/log.d.ts +13 -0
  27. package/dist/commands/log.js +97 -0
  28. package/dist/commands/parse-agent-message.d.ts +31 -0
  29. package/dist/commands/parse-agent-message.js +52 -0
  30. package/dist/commands/parse-common-flags.d.ts +36 -0
  31. package/dist/commands/parse-common-flags.js +105 -0
  32. package/dist/commands/ps.d.ts +12 -0
  33. package/dist/commands/ps.js +71 -0
  34. package/dist/commands/query.d.ts +21 -0
  35. package/dist/commands/query.js +117 -0
  36. package/dist/commands/result.d.ts +13 -0
  37. package/dist/commands/result.js +73 -0
  38. package/dist/commands/slack.d.ts +12 -0
  39. package/dist/commands/slack.js +559 -0
  40. package/dist/commands/task-db.d.ts +33 -0
  41. package/dist/commands/task-db.js +107 -0
  42. package/dist/examples/deny-secrets-plugin.d.ts +22 -0
  43. package/dist/examples/deny-secrets-plugin.js +40 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +5 -0
  46. package/dist/logging.d.ts +21 -0
  47. package/dist/logging.js +86 -0
  48. package/dist/main.d.ts +10 -0
  49. package/dist/main.js +246 -256
  50. package/dist/plugins/examples/echo-hook.d.ts +24 -0
  51. package/dist/plugins/examples/echo-hook.js +60 -0
  52. package/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
  53. package/dist/plugins/examples/verify-echo-hook.js +47 -0
  54. package/dist/plugins/sqlite-tracing.d.ts +13 -0
  55. package/dist/plugins/sqlite-tracing.js +20 -0
  56. package/dist/register-builtin-tools.d.ts +5 -0
  57. package/dist/register-builtin-tools.js +9 -0
  58. package/dist/slack/file-download.d.ts +17 -0
  59. package/dist/slack/file-download.js +134 -0
  60. package/dist/slack/markdown.d.ts +5 -0
  61. package/dist/slack/markdown.js +33 -0
  62. package/dist/utils/env-defaults.d.ts +5 -0
  63. package/dist/utils/env-defaults.js +10 -0
  64. package/dist/utils/version.d.ts +1 -0
  65. package/dist/utils/version.js +28 -0
  66. package/package.json +32 -115
  67. package/README.md +0 -663
  68. package/dist/ai-provider.service.d.ts +0 -36
  69. package/dist/ai-provider.service.js +0 -315
  70. package/dist/ai-provider.service.js.map +0 -1
  71. package/dist/ai.service.d.ts +0 -17
  72. package/dist/ai.service.js +0 -51
  73. package/dist/ai.service.js.map +0 -1
  74. package/dist/app.module.d.ts +0 -5
  75. package/dist/app.module.js +0 -165
  76. package/dist/app.module.js.map +0 -1
  77. package/dist/cli/agent.handler.d.ts +0 -2
  78. package/dist/cli/agent.handler.js +0 -186
  79. package/dist/cli/agent.handler.js.map +0 -1
  80. package/dist/cli/builtin.handler.d.ts +0 -3
  81. package/dist/cli/builtin.handler.js.map +0 -1
  82. package/dist/cli/chat.handler.d.ts +0 -20
  83. package/dist/cli/chat.handler.js +0 -446
  84. package/dist/cli/chat.handler.js.map +0 -1
  85. package/dist/cli/cli.handler.d.ts +0 -4
  86. package/dist/cli/cli.handler.js +0 -119
  87. package/dist/cli/cli.handler.js.map +0 -1
  88. package/dist/cli/doctor.handler.d.ts +0 -38
  89. package/dist/cli/doctor.handler.js +0 -495
  90. package/dist/cli/doctor.handler.js.map +0 -1
  91. package/dist/cli/execute.handler.d.ts +0 -2
  92. package/dist/cli/execute.handler.js +0 -376
  93. package/dist/cli/execute.handler.js.map +0 -1
  94. package/dist/cli/help.handler.d.ts +0 -2
  95. package/dist/cli/help.handler.js +0 -10
  96. package/dist/cli/help.handler.js.map +0 -1
  97. package/dist/cli/init.handler.d.ts +0 -26
  98. package/dist/cli/init.handler.js +0 -450
  99. package/dist/cli/init.handler.js.map +0 -1
  100. package/dist/cli/log.handler.d.ts +0 -2
  101. package/dist/cli/log.handler.js +0 -69
  102. package/dist/cli/log.handler.js.map +0 -1
  103. package/dist/cli/mcp.handler.d.ts +0 -3
  104. package/dist/cli/mcp.handler.js +0 -121
  105. package/dist/cli/mcp.handler.js.map +0 -1
  106. package/dist/cli/query.handler.d.ts +0 -2
  107. package/dist/cli/query.handler.js +0 -392
  108. package/dist/cli/query.handler.js.map +0 -1
  109. package/dist/cli/skill.handler.d.ts +0 -2
  110. package/dist/cli/skill.handler.js +0 -252
  111. package/dist/cli/skill.handler.js.map +0 -1
  112. package/dist/cli/slack-files.handler.d.ts +0 -2
  113. package/dist/cli/slack-files.handler.js +0 -291
  114. package/dist/cli/slack-files.handler.js.map +0 -1
  115. package/dist/cli/template.handler.d.ts +0 -2
  116. package/dist/cli/template.handler.js +0 -188
  117. package/dist/cli/template.handler.js.map +0 -1
  118. package/dist/cli/templates.handler.d.ts +0 -2
  119. package/dist/cli/templates.handler.js +0 -100
  120. package/dist/cli/templates.handler.js.map +0 -1
  121. package/dist/cli-options.d.ts +0 -40
  122. package/dist/cli-options.js +0 -371
  123. package/dist/cli-options.js.map +0 -1
  124. package/dist/config/timeout.config.d.ts +0 -14
  125. package/dist/config/timeout.config.js +0 -34
  126. package/dist/config/timeout.config.js.map +0 -1
  127. package/dist/conversation/base-conversation-history.provider.d.ts +0 -12
  128. package/dist/conversation/base-conversation-history.provider.js +0 -45
  129. package/dist/conversation/base-conversation-history.provider.js.map +0 -1
  130. package/dist/conversation/cli-box-reader.adapter.d.ts +0 -6
  131. package/dist/conversation/cli-box-reader.adapter.js +0 -10
  132. package/dist/conversation/cli-box-reader.adapter.js.map +0 -1
  133. package/dist/conversation/cli-conversation-history.provider.d.ts +0 -16
  134. package/dist/conversation/cli-conversation-history.provider.js +0 -112
  135. package/dist/conversation/cli-conversation-history.provider.js.map +0 -1
  136. package/dist/conversation/cli-task-reader.adapter.d.ts +0 -6
  137. package/dist/conversation/cli-task-reader.adapter.js +0 -25
  138. package/dist/conversation/cli-task-reader.adapter.js.map +0 -1
  139. package/dist/conversation/conversation-provider.factory.d.ts +0 -10
  140. package/dist/conversation/conversation-provider.factory.js +0 -50
  141. package/dist/conversation/conversation-provider.factory.js.map +0 -1
  142. package/dist/conversation/index.d.ts +0 -8
  143. package/dist/conversation/index.js +0 -29
  144. package/dist/conversation/index.js.map +0 -1
  145. package/dist/conversation/slack-conversation-history.provider.d.ts +0 -29
  146. package/dist/conversation/slack-conversation-history.provider.js +0 -302
  147. package/dist/conversation/slack-conversation-history.provider.js.map +0 -1
  148. package/dist/crewx.tool.d.ts +0 -360
  149. package/dist/crewx.tool.js +0 -2531
  150. package/dist/crewx.tool.js.map +0 -1
  151. package/dist/crewx.tool.spec.d.ts +0 -1
  152. package/dist/crewx.tool.spec.js +0 -222
  153. package/dist/crewx.tool.spec.js.map +0 -1
  154. package/dist/guards/bearer-auth.guard.d.ts +0 -7
  155. package/dist/guards/bearer-auth.guard.js +0 -44
  156. package/dist/guards/bearer-auth.guard.js.map +0 -1
  157. package/dist/health.controller.d.ts +0 -6
  158. package/dist/health.controller.js +0 -32
  159. package/dist/health.controller.js.map +0 -1
  160. package/dist/main.js.map +0 -1
  161. package/dist/mcp.controller.d.ts +0 -8
  162. package/dist/mcp.controller.js +0 -62
  163. package/dist/mcp.controller.js.map +0 -1
  164. package/dist/package.json +0 -3
  165. package/dist/providers/dynamic-provider.factory.d.ts +0 -17
  166. package/dist/providers/dynamic-provider.factory.js +0 -138
  167. package/dist/providers/dynamic-provider.factory.js.map +0 -1
  168. package/dist/providers/logger.adapter.d.ts +0 -7
  169. package/dist/providers/logger.adapter.js +0 -107
  170. package/dist/providers/logger.adapter.js.map +0 -1
  171. package/dist/services/agent-loader.service.d.ts +0 -35
  172. package/dist/services/agent-loader.service.js +0 -623
  173. package/dist/services/agent-loader.service.js.map +0 -1
  174. package/dist/services/auth.service.d.ts +0 -9
  175. package/dist/services/auth.service.js +0 -47
  176. package/dist/services/auth.service.js.map +0 -1
  177. package/dist/services/config-validator.service.d.ts +0 -29
  178. package/dist/services/config-validator.service.js +0 -483
  179. package/dist/services/config-validator.service.js.map +0 -1
  180. package/dist/services/config.service.d.ts +0 -45
  181. package/dist/services/config.service.js +0 -352
  182. package/dist/services/config.service.js.map +0 -1
  183. package/dist/services/document-loader.service.d.ts +0 -26
  184. package/dist/services/document-loader.service.js +0 -186
  185. package/dist/services/document-loader.service.js.map +0 -1
  186. package/dist/services/help.service.d.ts +0 -5
  187. package/dist/services/help.service.js +0 -139
  188. package/dist/services/help.service.js.map +0 -1
  189. package/dist/services/intelligent-compression.service.d.ts +0 -20
  190. package/dist/services/intelligent-compression.service.js +0 -179
  191. package/dist/services/intelligent-compression.service.js.map +0 -1
  192. package/dist/services/mcp-client.service.d.ts +0 -26
  193. package/dist/services/mcp-client.service.js +0 -81
  194. package/dist/services/mcp-client.service.js.map +0 -1
  195. package/dist/services/parallel-processing.service.d.ts +0 -108
  196. package/dist/services/parallel-processing.service.js +0 -333
  197. package/dist/services/parallel-processing.service.js.map +0 -1
  198. package/dist/services/provider-bridge.service.d.ts +0 -35
  199. package/dist/services/provider-bridge.service.js +0 -224
  200. package/dist/services/provider-bridge.service.js.map +0 -1
  201. package/dist/services/remote-agent.service.d.ts +0 -50
  202. package/dist/services/remote-agent.service.js +0 -171
  203. package/dist/services/remote-agent.service.js.map +0 -1
  204. package/dist/services/result-formatter.service.d.ts +0 -27
  205. package/dist/services/result-formatter.service.js +0 -126
  206. package/dist/services/result-formatter.service.js.map +0 -1
  207. package/dist/services/skill-loader.service.d.ts +0 -15
  208. package/dist/services/skill-loader.service.js +0 -278
  209. package/dist/services/skill-loader.service.js.map +0 -1
  210. package/dist/services/skill.service.d.ts +0 -69
  211. package/dist/services/skill.service.js +0 -779
  212. package/dist/services/skill.service.js.map +0 -1
  213. package/dist/services/skill.service.spec.d.ts +0 -1
  214. package/dist/services/skill.service.spec.js +0 -168
  215. package/dist/services/skill.service.spec.js.map +0 -1
  216. package/dist/services/task-management.service.d.ts +0 -71
  217. package/dist/services/task-management.service.js +0 -324
  218. package/dist/services/task-management.service.js.map +0 -1
  219. package/dist/services/template.service.d.ts +0 -61
  220. package/dist/services/template.service.js +0 -416
  221. package/dist/services/template.service.js.map +0 -1
  222. package/dist/services/tool-call.service.d.ts +0 -16
  223. package/dist/services/tool-call.service.js +0 -302
  224. package/dist/services/tool-call.service.js.map +0 -1
  225. package/dist/services/tracing.service.d.ts +0 -197
  226. package/dist/services/tracing.service.js +0 -1267
  227. package/dist/services/tracing.service.js.map +0 -1
  228. package/dist/slack/formatters/message.formatter.d.ts +0 -43
  229. package/dist/slack/formatters/message.formatter.js +0 -505
  230. package/dist/slack/formatters/message.formatter.js.map +0 -1
  231. package/dist/slack/services/slack-file-download.service.d.ts +0 -58
  232. package/dist/slack/services/slack-file-download.service.js +0 -558
  233. package/dist/slack/services/slack-file-download.service.js.map +0 -1
  234. package/dist/slack/slack-bot.d.ts +0 -33
  235. package/dist/slack/slack-bot.js +0 -568
  236. package/dist/slack/slack-bot.js.map +0 -1
  237. package/dist/stderr.logger.d.ts +0 -8
  238. package/dist/stderr.logger.js +0 -26
  239. package/dist/stderr.logger.js.map +0 -1
  240. package/dist/types/usage.types.d.ts +0 -107
  241. package/dist/types/usage.types.js +0 -3
  242. package/dist/types/usage.types.js.map +0 -1
  243. package/dist/utils/config-utils.d.ts +0 -15
  244. package/dist/utils/config-utils.js +0 -69
  245. package/dist/utils/config-utils.js.map +0 -1
  246. package/dist/utils/extract-text.d.ts +0 -1
  247. package/dist/utils/extract-text.js +0 -15
  248. package/dist/utils/extract-text.js.map +0 -1
  249. package/dist/utils/mcp-installer.d.ts +0 -20
  250. package/dist/utils/mcp-installer.js +0 -199
  251. package/dist/utils/mcp-installer.js.map +0 -1
  252. package/dist/utils/project-hash.d.ts +0 -6
  253. package/dist/utils/project-hash.js +0 -70
  254. package/dist/utils/project-hash.js.map +0 -1
  255. package/dist/utils/simple-security.d.ts +0 -3
  256. package/dist/utils/simple-security.js +0 -20
  257. package/dist/utils/simple-security.js.map +0 -1
  258. package/dist/utils/stdin-utils.d.ts +0 -6
  259. package/dist/utils/stdin-utils.js +0 -109
  260. package/dist/utils/stdin-utils.js.map +0 -1
  261. package/dist/utils/template-processor.d.ts +0 -27
  262. package/dist/utils/template-processor.js +0 -395
  263. package/dist/utils/template-processor.js.map +0 -1
  264. package/dist/utils/terminal-message-formatter.d.ts +0 -23
  265. package/dist/utils/terminal-message-formatter.js +0 -136
  266. package/dist/utils/terminal-message-formatter.js.map +0 -1
  267. package/dist/version.d.ts +0 -1
  268. package/dist/version.js +0 -17
  269. package/dist/version.js.map +0 -1
  270. package/dist/workspace.service.d.ts +0 -44
  271. package/dist/workspace.service.js +0 -299
  272. package/dist/workspace.service.js.map +0 -1
  273. package/scripts/backfill-tokens.js +0 -218
  274. package/scripts/postbuild-cli.mjs +0 -88
  275. package/scripts/postinstall-cli.mjs +0 -30
  276. package/templates/agents/default.yaml +0 -490
  277. package/templates/agents/minimal.yaml +0 -16
  278. package/templates/documents/conversation-history-default.hbs +0 -17
  279. package/templates/documents/crewx-manual.md +0 -2278
  280. package/templates/documents/crewx-quick-guide.md +0 -147
  281. package/templates/versions.json +0 -19
package/bin/crewx ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/main.js');
@@ -0,0 +1,11 @@
1
+ import { Crewx } from '@crewx/sdk';
2
+ /**
3
+ * Build a Crewx instance with CLI-standard plugins (FileLogger + SqliteTracing)
4
+ * and built-in tools registered. Use this from any CLI command that needs a
5
+ * Crewx instance — keeps environment consistent across query / execute / slack / agent.
6
+ *
7
+ * workspaceRoot (= dirname(configPath)) is passed to FileLoggerPlugin so that
8
+ * per-workspace logs land in {workspaceRoot}/.crewx/logs/. Critical for file://
9
+ * remote agent delegation (target Crewx must write logs into target workspace).
10
+ */
11
+ export declare function createCliCrewx(configPath?: string): Promise<Crewx>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCliCrewx = createCliCrewx;
4
+ const path_1 = require("path");
5
+ const sdk_1 = require("@crewx/sdk");
6
+ const plugins_1 = require("@crewx/sdk/plugins");
7
+ const register_builtin_tools_1 = require("../register-builtin-tools");
8
+ const version_1 = require("../utils/version");
9
+ /**
10
+ * Build a Crewx instance with CLI-standard plugins (FileLogger + SqliteTracing)
11
+ * and built-in tools registered. Use this from any CLI command that needs a
12
+ * Crewx instance — keeps environment consistent across query / execute / slack / agent.
13
+ *
14
+ * workspaceRoot (= dirname(configPath)) is passed to FileLoggerPlugin so that
15
+ * per-workspace logs land in {workspaceRoot}/.crewx/logs/. Critical for file://
16
+ * remote agent delegation (target Crewx must write logs into target workspace).
17
+ */
18
+ async function createCliCrewx(configPath = process.env.CREWX_CONFIG ?? 'crewx.yaml') {
19
+ const absConfigPath = (0, path_1.resolve)(configPath);
20
+ const workspaceRoot = (0, path_1.dirname)(absConfigPath);
21
+ // Pass ourselves back to the SDK: when this Crewx encounters a file:// remote
22
+ // agent, the SDK uses this factory to bootstrap the target Crewx instance
23
+ // with the same plugin set (FileLogger + SqliteTracing + built-in tools).
24
+ const crewx = await sdk_1.Crewx.loadYaml(absConfigPath, {
25
+ remoteFactory: createCliCrewx,
26
+ });
27
+ (0, register_builtin_tools_1.registerBuiltinToolsIfNeeded)(crewx);
28
+ await crewx.use(new plugins_1.FileLoggerPlugin({ version: version_1.CLI_VERSION, workspaceRoot }));
29
+ await crewx.use(new plugins_1.SqliteTracingPlugin({ version: version_1.CLI_VERSION }));
30
+ return crewx;
31
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Built-in tool router.
3
+ *
4
+ * Routes built-in commands (memory, search, doc, etc.) to their respective
5
+ * @crewx/* package CLI entry points.
6
+ *
7
+ * Copied and adapted from packages/cli-bak/src/cli/builtin.handler.ts.
8
+ */
9
+ export declare const BUILTIN_COMMANDS: Set<string>;
10
+ /**
11
+ * Wrap main() with tracer.run() if tracer is available.
12
+ * Falls back to direct main() call on any tracer failure.
13
+ */
14
+ export declare function wrapWithTracer(builtinName: string, main: (args?: string[]) => Promise<void>, args: string[]): Promise<void>;
15
+ export declare function handleBuiltin(builtinName: string, args: string[]): Promise<void>;
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
+ /**
3
+ * Built-in tool router.
4
+ *
5
+ * Routes built-in commands (memory, search, doc, etc.) to their respective
6
+ * @crewx/* package CLI entry points.
7
+ *
8
+ * Copied and adapted from packages/cli-bak/src/cli/builtin.handler.ts.
9
+ */
2
10
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
11
  if (k2 === undefined) k2 = k;
4
12
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -43,8 +51,10 @@ const BUILTIN_MAP = {
43
51
  wbs: () => Promise.resolve().then(() => __importStar(require('@crewx/wbs/cli'))),
44
52
  cron: () => Promise.resolve().then(() => __importStar(require('@crewx/cron/cli'))),
45
53
  workflow: () => Promise.resolve().then(() => __importStar(require('@crewx/workflow/cli'))),
54
+ // NOTE: @crewx/skill does not expose /cli module — handled separately in main.ts
46
55
  };
47
56
  exports.BUILTIN_COMMANDS = new Set(Object.keys(BUILTIN_MAP));
57
+ // Load skill-tracer for observability (graceful degradation if unavailable)
48
58
  async function loadTracer() {
49
59
  try {
50
60
  return await Promise.resolve().then(() => __importStar(require('@crewx/shared/skill-tracer')));
@@ -53,12 +63,17 @@ async function loadTracer() {
53
63
  return null;
54
64
  }
55
65
  }
66
+ /**
67
+ * Wrap main() with tracer.run() if tracer is available.
68
+ * Falls back to direct main() call on any tracer failure.
69
+ */
56
70
  async function wrapWithTracer(builtinName, main, args) {
57
71
  let tracer = null;
58
72
  try {
59
73
  tracer = await loadTracer();
60
74
  }
61
75
  catch {
76
+ // tracer unavailable — proceed without it
62
77
  }
63
78
  if (tracer) {
64
79
  let mainError = null;
@@ -76,13 +91,12 @@ async function wrapWithTracer(builtinName, main, args) {
76
91
  });
77
92
  return;
78
93
  }
79
- catch (err) {
80
- if (mainError) {
94
+ catch {
95
+ if (mainError)
81
96
  throw mainError;
82
- }
83
- if (mainCompleted) {
97
+ if (mainCompleted)
84
98
  return;
85
- }
99
+ // tracer setup error — fall back
86
100
  }
87
101
  }
88
102
  await main(args);
@@ -98,7 +112,8 @@ async function handleBuiltin(builtinName, args) {
98
112
  await wrapWithTracer(builtinName, mod.main.bind(mod), args);
99
113
  }
100
114
  catch (err) {
101
- if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND') {
115
+ const code = err.code;
116
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
102
117
  console.error(`\n Built-in tool '${builtinName}' is not installed.\n`);
103
118
  console.error(` Install it with:\n`);
104
119
  console.error(` npm install @crewx/${builtinName}\n`);
@@ -107,4 +122,3 @@ async function handleBuiltin(builtinName, args) {
107
122
  throw err;
108
123
  }
109
124
  }
110
- //# sourceMappingURL=builtin.handler.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * crewx agent handler.
3
+ * Dispatches `crewx agent ls` and `crewx agent prompt` subcommands.
4
+ */
5
+ /**
6
+ * Handle `crewx agent [subcommand] [options]`.
7
+ *
8
+ * Subcommands:
9
+ * ls | list | (none) — list agents (default)
10
+ * prompt <agentId> — print rendered system prompt
11
+ */
12
+ export declare function handleAgent(args: string[]): Promise<void>;
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ /**
3
+ * crewx agent handler.
4
+ * Dispatches `crewx agent ls` and `crewx agent prompt` subcommands.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.handleAgent = handleAgent;
41
+ const path = __importStar(require("path"));
42
+ const fs_1 = require("fs");
43
+ const crewx_cli_1 = require("../bootstrap/crewx-cli");
44
+ const sdk_1 = require("@crewx/sdk");
45
+ const skill_1 = require("@crewx/skill");
46
+ /**
47
+ * Parse a flag from args array.
48
+ * Supports both `--flag=value` and `--flag value` forms.
49
+ * Returns undefined if flag is not present.
50
+ */
51
+ function parseFlag(args, flag) {
52
+ const prefix = `--${flag}=`;
53
+ for (let i = 0; i < args.length; i++) {
54
+ if (args[i].startsWith(prefix)) {
55
+ return args[i].slice(prefix.length);
56
+ }
57
+ if (args[i] === `--${flag}` && i + 1 < args.length) {
58
+ return args[i + 1];
59
+ }
60
+ }
61
+ return undefined;
62
+ }
63
+ /**
64
+ * Format provider field for display.
65
+ */
66
+ function formatProvider(provider) {
67
+ return Array.isArray(provider) ? provider.join(', ') : provider;
68
+ }
69
+ /**
70
+ * Print the agent list.
71
+ */
72
+ function printAgentList(agents, total, isFiltered) {
73
+ const configPath = process.env.CREWX_CONFIG ?? null;
74
+ if (agents.length === 0) {
75
+ console.log('WARNING: No agents configured.');
76
+ if (!configPath) {
77
+ console.log('Set CREWX_CONFIG to point to your crewx.yaml configuration file.');
78
+ }
79
+ return;
80
+ }
81
+ const headerCount = isFiltered ? `${agents.length} / ${total}` : `${total}`;
82
+ console.log(`Available Agents (${headerCount})\n`);
83
+ agents.forEach((agent, index) => {
84
+ const headerParts = [`@${agent.id}`];
85
+ if (agent.name && agent.name !== agent.id) {
86
+ headerParts.push(agent.name);
87
+ }
88
+ console.log(`${index + 1}. ${headerParts.join(' - ')}`);
89
+ console.log(` Provider: ${formatProvider(agent.provider)}`);
90
+ const workDir = agent.working_directory ?? agent.workingDirectory ?? '.';
91
+ console.log(` Working Dir: ${workDir}`);
92
+ if (agent.role) {
93
+ console.log(` Role: ${agent.role}`);
94
+ }
95
+ if (agent.team) {
96
+ console.log(` Team: ${agent.team}`);
97
+ }
98
+ if (agent.description) {
99
+ console.log(` Description: ${agent.description}`);
100
+ }
101
+ if (index < agents.length - 1) {
102
+ console.log('');
103
+ }
104
+ });
105
+ const configSource = configPath ? 'External YAML file' : 'Default hardcoded values';
106
+ console.log(`\nConfiguration Source: ${configSource}`);
107
+ if (configPath) {
108
+ console.log(`Config Path: ${configPath}`);
109
+ }
110
+ else {
111
+ console.log('Tip: Set CREWX_CONFIG to point to your crewx.yaml file to customize agents.');
112
+ }
113
+ }
114
+ /**
115
+ * Handle `crewx agent ls` — list agents with optional filters.
116
+ */
117
+ async function handleAgentList(crewx, args) {
118
+ const role = parseFlag(args, 'role');
119
+ const team = parseFlag(args, 'team');
120
+ const provider = parseFlag(args, 'provider');
121
+ const isFiltered = !!(role || team || provider);
122
+ const total = crewx.agents.size;
123
+ const filtered = crewx.filterAgents({ role, team, provider });
124
+ printAgentList(filtered, total, isFiltered);
125
+ }
126
+ /**
127
+ * Handle `crewx agent prompt <agentId>` — print fully rendered system prompt.
128
+ * Renders Handlebars template variables via Crewx.renderAgentPromptFull().
129
+ */
130
+ async function handleAgentPrompt(crewx, args) {
131
+ // Find the agent id argument (first non-flag arg after 'prompt')
132
+ const agentIdRaw = args.find(a => !a.startsWith('--'));
133
+ if (!agentIdRaw) {
134
+ console.error('Missing agent ID. Usage: crewx agent prompt @agent_name');
135
+ process.exit(1);
136
+ }
137
+ try {
138
+ const skills = loadAgentSkills();
139
+ const rendered = await crewx.renderAgentPromptFull(agentIdRaw, {
140
+ env: process.env,
141
+ session: { mode: 'query', platform: 'cli' },
142
+ skills,
143
+ });
144
+ const displayId = agentIdRaw.startsWith('@') ? agentIdRaw.slice(1) : agentIdRaw;
145
+ console.log(`\n🤖 **Rendered Prompt for Agent: ${displayId}**\n`);
146
+ console.log('--- BEGIN PROMPT ---');
147
+ console.log(rendered);
148
+ console.log('--- END PROMPT ---');
149
+ }
150
+ catch (err) {
151
+ const message = err instanceof Error ? err.message : String(err);
152
+ console.error(`Failed to get agent prompt: ${message}`);
153
+ process.exit(1);
154
+ }
155
+ }
156
+ /**
157
+ * Handle `crewx agent [subcommand] [options]`.
158
+ *
159
+ * Subcommands:
160
+ * ls | list | (none) — list agents (default)
161
+ * prompt <agentId> — print rendered system prompt
162
+ */
163
+ async function handleAgent(args) {
164
+ const configPath = process.env.CREWX_CONFIG ?? 'crewx.yaml';
165
+ let crewx;
166
+ try {
167
+ crewx = await (0, crewx_cli_1.createCliCrewx)(configPath);
168
+ }
169
+ catch (err) {
170
+ if (err instanceof sdk_1.ConfigLoadError && !(0, fs_1.existsSync)(configPath)) {
171
+ const subcommand = (args[0] ?? '').toLowerCase();
172
+ if (!subcommand || subcommand === 'ls' || subcommand === 'list') {
173
+ console.log('WARNING: No agents configured.');
174
+ console.log(`No crewx.yaml found. Run 'crewx init' to create one.`);
175
+ return;
176
+ }
177
+ }
178
+ throw err;
179
+ }
180
+ const subcommand = (args[0] ?? '').toLowerCase();
181
+ switch (subcommand) {
182
+ case 'ls':
183
+ case 'list':
184
+ await handleAgentList(crewx, args.slice(1));
185
+ return;
186
+ case '':
187
+ // Default: no subcommand → ls
188
+ await handleAgentList(crewx, args.slice(1));
189
+ return;
190
+ case 'prompt':
191
+ case 'p':
192
+ await handleAgentPrompt(crewx, args.slice(1));
193
+ return;
194
+ default:
195
+ console.error(`Unknown agent subcommand: ${subcommand}`);
196
+ printAgentHelp();
197
+ process.exit(1);
198
+ }
199
+ }
200
+ /**
201
+ * Discover available skills and convert to SkillEntry format for template rendering.
202
+ * Searches skills/ and node_modules/@crewx directories.
203
+ */
204
+ function loadAgentSkills() {
205
+ try {
206
+ const engine = new skill_1.SkillEngine(process.cwd());
207
+ const discovered = engine.discover();
208
+ return discovered.map(s => ({
209
+ metadata: {
210
+ name: s.name,
211
+ version: s.version ?? '0.0.0',
212
+ description: s.description ?? '',
213
+ },
214
+ filePath: s.skillMdPath ?? path.join(s.dir, 'SKILL.md'),
215
+ }));
216
+ }
217
+ catch {
218
+ return [];
219
+ }
220
+ }
221
+ function printAgentHelp() {
222
+ console.log(`
223
+ CrewX Agent Management
224
+
225
+ Usage:
226
+ crewx agent # List configured agents (default)
227
+ crewx agent ls # List configured agents
228
+ crewx agent list # Alias for ls
229
+ crewx agent prompt <id> # Inspect rendered agent prompt
230
+
231
+ Filter Options (for agent ls):
232
+ --role <value> Filter by agent role (comma-separated for multiple: PM,Dev)
233
+ --team <value> Filter by agent team (comma-separated for multiple)
234
+ --provider <value> Filter by provider (comma-separated, partial match: claude)
235
+
236
+ Examples:
237
+ crewx agent
238
+ crewx agent ls
239
+ crewx agent ls --role=PM
240
+ crewx agent ls --team="CrewX Core 개발팀"
241
+ crewx agent ls --provider=claude
242
+ crewx agent ls --role=PM --provider=claude
243
+ crewx agent ls --role=PM,general
244
+ CREWX_CONFIG=./crewx.yaml crewx agent list
245
+ `.trim());
246
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * crewx doctor handler.
3
+ * Performs system diagnosis: checks config, CLI tools, and environment.
4
+ *
5
+ * Usage:
6
+ * crewx doctor Run full diagnosis
7
+ * crewx doctor --config <path> Use specific config file
8
+ */
9
+ /**
10
+ * Handle `crewx doctor` command.
11
+ */
12
+ export declare function handleDoctor(args: string[]): Promise<void>;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * crewx doctor handler.
4
+ * Performs system diagnosis: checks config, CLI tools, and environment.
5
+ *
6
+ * Usage:
7
+ * crewx doctor Run full diagnosis
8
+ * crewx doctor --config <path> Use specific config file
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.handleDoctor = handleDoctor;
12
+ const fs_1 = require("fs");
13
+ const path_1 = require("path");
14
+ const child_process_1 = require("child_process");
15
+ const sdk_1 = require("@crewx/sdk");
16
+ const parse_common_flags_1 = require("./parse-common-flags");
17
+ function statusIcon(status) {
18
+ switch (status) {
19
+ case 'success': return '✅';
20
+ case 'warning': return '⚠️ ';
21
+ case 'error': return '❌';
22
+ }
23
+ }
24
+ /**
25
+ * Check if a CLI command is available on PATH.
26
+ */
27
+ function isCommandAvailable(cmd) {
28
+ try {
29
+ (0, child_process_1.execSync)(`which ${cmd}`, { stdio: 'ignore' });
30
+ return true;
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /**
37
+ * Check crewx.yaml configuration file.
38
+ */
39
+ function checkConfig(configPath) {
40
+ if (!(0, fs_1.existsSync)(configPath)) {
41
+ return {
42
+ name: 'Configuration File',
43
+ status: 'error',
44
+ message: `Configuration file not found: ${configPath}`,
45
+ details: "Run 'crewx init' to create a default configuration file.",
46
+ };
47
+ }
48
+ try {
49
+ const raw = (0, sdk_1.loadYamlFile)(configPath);
50
+ const config = raw;
51
+ if (!config?.agents || !Array.isArray(config.agents)) {
52
+ return {
53
+ name: 'Configuration File',
54
+ status: 'error',
55
+ message: 'Invalid configuration format',
56
+ details: 'Configuration file exists but has invalid structure.',
57
+ };
58
+ }
59
+ if (config.agents.length === 0) {
60
+ return {
61
+ name: 'Configuration File',
62
+ status: 'warning',
63
+ message: 'No agents configured',
64
+ details: 'Add agent definitions to your crewx.yaml.',
65
+ };
66
+ }
67
+ return {
68
+ name: 'Configuration File',
69
+ status: 'success',
70
+ message: `Found ${config.agents.length} agent(s) in ${configPath}`,
71
+ };
72
+ }
73
+ catch (err) {
74
+ return {
75
+ name: 'Configuration File',
76
+ status: 'error',
77
+ message: 'Failed to parse configuration',
78
+ details: `Error: ${err instanceof Error ? err.message : String(err)}`,
79
+ };
80
+ }
81
+ }
82
+ /**
83
+ * Check .crewx/logs directory.
84
+ */
85
+ function checkLogsDir() {
86
+ const logsDir = (0, path_1.join)(process.cwd(), '.crewx', 'logs');
87
+ if (!(0, fs_1.existsSync)(logsDir)) {
88
+ return {
89
+ name: 'Logs Directory',
90
+ status: 'warning',
91
+ message: 'Logs directory not found',
92
+ details: `Will be created automatically at ${logsDir}`,
93
+ };
94
+ }
95
+ return {
96
+ name: 'Logs Directory',
97
+ status: 'success',
98
+ message: `Logs directory exists: ${logsDir}`,
99
+ };
100
+ }
101
+ /**
102
+ * Check CLI provider availability.
103
+ */
104
+ function checkCliProviders() {
105
+ const providers = [
106
+ { name: 'claude', cmd: 'claude', install: 'npm install -g @anthropic-ai/claude-code' },
107
+ { name: 'gemini', cmd: 'gemini', install: 'npm install -g @google/gemini-cli' },
108
+ { name: 'copilot (gh)', cmd: 'gh', install: 'brew install gh # or visit cli.github.com' },
109
+ ];
110
+ return providers.map(p => {
111
+ const available = isCommandAvailable(p.cmd);
112
+ return {
113
+ name: `${p.name.toUpperCase()} CLI`,
114
+ status: available ? 'success' : 'warning',
115
+ message: available ? 'Installed and available' : 'Not installed or not on PATH',
116
+ details: available ? undefined : `Install: ${p.install}`,
117
+ };
118
+ });
119
+ }
120
+ /**
121
+ * Check CREWX_CLI env var.
122
+ */
123
+ function checkEnvVars() {
124
+ const crewxCli = process.env.CREWX_CLI;
125
+ if (crewxCli) {
126
+ return {
127
+ name: 'CREWX_CLI',
128
+ status: 'success',
129
+ message: `Set to: ${crewxCli}`,
130
+ };
131
+ }
132
+ return {
133
+ name: 'CREWX_CLI',
134
+ status: 'warning',
135
+ message: 'Not set — defaulting to "npx crewx"',
136
+ details: 'This is auto-set at CLI startup; no action needed.',
137
+ };
138
+ }
139
+ /**
140
+ * Assess overall health.
141
+ */
142
+ function assessHealth(diagnostics) {
143
+ const errors = diagnostics.filter(d => d.status === 'error').length;
144
+ const warnings = diagnostics.filter(d => d.status === 'warning').length;
145
+ const successes = diagnostics.filter(d => d.status === 'success').length;
146
+ if (errors > 0) {
147
+ return { status: 'error', message: `System has ${errors} error(s) that need attention` };
148
+ }
149
+ if (warnings > 0) {
150
+ return { status: 'warning', message: `System is functional with ${warnings} warning(s)` };
151
+ }
152
+ return { status: 'success', message: `System is healthy — all ${successes} checks passed` };
153
+ }
154
+ /**
155
+ * Handle `crewx doctor` command.
156
+ */
157
+ async function handleDoctor(args) {
158
+ const { config } = (0, parse_common_flags_1.parseCommonFlags)(args);
159
+ const configPath = config ?? process.env.CREWX_CONFIG ?? (0, path_1.join)(process.cwd(), 'crewx.yaml');
160
+ console.log('🩺 Starting CrewX system diagnosis...\n');
161
+ const diagnostics = [
162
+ checkConfig(configPath),
163
+ checkLogsDir(),
164
+ checkEnvVars(),
165
+ ...checkCliProviders(),
166
+ ];
167
+ // Print diagnostics
168
+ diagnostics.forEach(d => {
169
+ const icon = statusIcon(d.status);
170
+ console.log(`${icon} ${d.name}: ${d.message}`);
171
+ if (d.details) {
172
+ console.log(` ${d.details}`);
173
+ }
174
+ });
175
+ const health = assessHealth(diagnostics);
176
+ const healthIcon = statusIcon(health.status);
177
+ console.log('');
178
+ console.log('─'.repeat(60));
179
+ console.log(`${healthIcon} Overall: ${health.message}`);
180
+ if (health.status === 'success') {
181
+ console.log('\nNext steps:');
182
+ console.log(' crewx query "@claude hello"');
183
+ }
184
+ else {
185
+ console.log('\nAddress the issues above, then run `crewx doctor` again.');
186
+ }
187
+ if (health.status === 'error') {
188
+ process.exit(1);
189
+ }
190
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * crewx execute handler.
3
+ * Parses args, loads config via Crewx SDK, and executes the task.
4
+ *
5
+ * Flags:
6
+ * --thread <name> Conversation thread name
7
+ * --provider <cli/xxx> Provider override
8
+ * --metadata <json> Extra metadata JSON (double-quoted object). Propagated to events/hooks/tracing.
9
+ * e.g. --metadata='{"workflow_id":"wf-1"}'
10
+ * --verbose Debug output mode (default: raw agent response only)
11
+ * --config/-c <path> Config file path override
12
+ * --output-format <fmt> Output format (json|text|stream-json)
13
+ * --effort <level> Model effort (high|medium|low)
14
+ */
15
+ /**
16
+ * Handle `crewx execute <agentRef> <message>` command.
17
+ *
18
+ * Default output: raw agent response only (stdout).
19
+ * --verbose: debug info written to stderr, response to stdout.
20
+ */
21
+ export declare function handleExecute(args: string[]): Promise<void>;