crewx 0.8.1 → 0.8.2-rc.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.md +268 -268
  2. package/bin/cli-commands.js +34 -0
  3. package/bin/crewx-lib.js +213 -108
  4. package/bin/crewx-ui.js +83 -83
  5. package/bin/crewx.js +219 -147
  6. package/bin/launcher-flags.js +29 -0
  7. package/bin/package.json +1 -1
  8. package/dist/assets/MarketPage-DptjaFpT.js +36 -0
  9. package/dist/assets/{PromptTab-DVKc7hJY.js → PromptTab-DZha2_v1.js} +1 -1
  10. package/dist/assets/{_baseUniq-wjlVo2E6.js → _baseUniq-jd6NubI3.js} +1 -1
  11. package/dist/assets/{arc-BfPgRtzW.js → arc-C2te3-8P.js} +1 -1
  12. package/dist/assets/{architectureDiagram-Q4EWVU46-ewcueFAG.js → architectureDiagram-Q4EWVU46-CbIQua02.js} +1 -1
  13. package/dist/assets/{blockDiagram-DXYQGD6D-TxlbbvKn.js → blockDiagram-DXYQGD6D-Cg7qkpSM.js} +1 -1
  14. package/dist/assets/{c4Diagram-AHTNJAMY-C1lT_bl_.js → c4Diagram-AHTNJAMY-BkffDY1F.js} +1 -1
  15. package/dist/assets/channel-beae0DeI.js +1 -0
  16. package/dist/assets/chatgpt-logo-dark.svg +15 -15
  17. package/dist/assets/chatgpt-logo.svg +15 -15
  18. package/dist/assets/{chunk-4BX2VUAB-C41j2mCL.js → chunk-4BX2VUAB-BxHe9wPE.js} +1 -1
  19. package/dist/assets/{chunk-4TB4RGXK-HNNsUbz0.js → chunk-4TB4RGXK--f1tN90O.js} +1 -1
  20. package/dist/assets/{chunk-55IACEB6-qtCgO0r2.js → chunk-55IACEB6-B5QXfPXQ.js} +1 -1
  21. package/dist/assets/{chunk-EDXVE4YY-BSnDYtsd.js → chunk-EDXVE4YY-DqKhblOg.js} +1 -1
  22. package/dist/assets/{chunk-FMBD7UC4-DyHRLQqX.js → chunk-FMBD7UC4-DZ1w_G02.js} +1 -1
  23. package/dist/assets/{chunk-OYMX7WX6-CCjfi6WS.js → chunk-OYMX7WX6-BqAgQpv8.js} +1 -1
  24. package/dist/assets/{chunk-QZHKN3VN-COLty8kd.js → chunk-QZHKN3VN-DPqnGqVi.js} +1 -1
  25. package/dist/assets/{chunk-YZCP3GAM-CHUUnGeN.js → chunk-YZCP3GAM-x-ZYSQLd.js} +1 -1
  26. package/dist/assets/classDiagram-6PBFFD2Q-BquWrs1y.js +1 -0
  27. package/dist/assets/classDiagram-v2-HSJHXN6E-BquWrs1y.js +1 -0
  28. package/dist/assets/clone-C9wSPtDN.js +1 -0
  29. package/dist/assets/{cose-bilkent-S5V4N54A-CSip-V2g.js → cose-bilkent-S5V4N54A-4VCNRP-E.js} +1 -1
  30. package/dist/assets/{dagre-KV5264BT-DkdpnWhv.js → dagre-KV5264BT-DucVi1QS.js} +1 -1
  31. package/dist/assets/{diagram-5BDNPKRD-PH4qc6PV.js → diagram-5BDNPKRD-ChdRA8bE.js} +1 -1
  32. package/dist/assets/{diagram-G4DWMVQ6-Cg5xZcjx.js → diagram-G4DWMVQ6-B1-97yHr.js} +1 -1
  33. package/dist/assets/{diagram-MMDJMWI5-soKmeTCW.js → diagram-MMDJMWI5-CQs3cO7G.js} +1 -1
  34. package/dist/assets/{diagram-TYMM5635-Daq5Mihu.js → diagram-TYMM5635-CuNCxDfO.js} +1 -1
  35. package/dist/assets/{erDiagram-SMLLAGMA-kr2OtY0Y.js → erDiagram-SMLLAGMA-DdR8v8g-.js} +1 -1
  36. package/dist/assets/{flowDiagram-DWJPFMVM-DQZCb8gm.js → flowDiagram-DWJPFMVM-Dt02upId.js} +1 -1
  37. package/dist/assets/{ganttDiagram-T4ZO3ILL-BHkn485T.js → ganttDiagram-T4ZO3ILL-cG_k9VOa.js} +1 -1
  38. package/dist/assets/{gitGraphDiagram-UUTBAWPF-FaCyYFmC.js → gitGraphDiagram-UUTBAWPF-Dz1DjhKq.js} +1 -1
  39. package/dist/assets/{graph-BVJlrP6V.js → graph-CF2NtM33.js} +1 -1
  40. package/dist/assets/{infoDiagram-42DDH7IO-DJOWkKdM.js → infoDiagram-42DDH7IO-tQWKrYM6.js} +1 -1
  41. package/dist/assets/{ishikawaDiagram-UXIWVN3A-VfpvNaIf.js → ishikawaDiagram-UXIWVN3A-CLuUMkF0.js} +1 -1
  42. package/dist/assets/{journeyDiagram-VCZTEJTY-CPzsak-v.js → journeyDiagram-VCZTEJTY-a6JenLCk.js} +1 -1
  43. package/dist/assets/{kanban-definition-6JOO6SKY-DFqLDBU0.js → kanban-definition-6JOO6SKY-rqOxTzYb.js} +1 -1
  44. package/dist/assets/{layout-CCSbNPHm.js → layout-Dvic1Hpy.js} +1 -1
  45. package/dist/assets/{linear-C4T7PCKE.js → linear-CfMV1S6a.js} +1 -1
  46. package/dist/assets/main-05K4ggqd.css +10 -0
  47. package/dist/assets/main-CCM1gtr8.js +1165 -0
  48. package/dist/assets/{min-CGQNEYGh.js → min-GpF3DZux.js} +1 -1
  49. package/dist/assets/{mindmap-definition-QFDTVHPH-AuU1EqwS.js → mindmap-definition-QFDTVHPH-Cg80z0Jx.js} +1 -1
  50. package/dist/assets/{pieDiagram-DEJITSTG-CopkCZwp.js → pieDiagram-DEJITSTG-BrtK7lAq.js} +1 -1
  51. package/dist/assets/{quadrantDiagram-34T5L4WZ-lMKrSv_t.js → quadrantDiagram-34T5L4WZ-BL2txAAS.js} +1 -1
  52. package/dist/assets/{requirementDiagram-MS252O5E-dWUpHOFb.js → requirementDiagram-MS252O5E-Co3wpBnu.js} +1 -1
  53. package/dist/assets/{sankeyDiagram-XADWPNL6-C8UQx9Bb.js → sankeyDiagram-XADWPNL6-B4KJXdQ4.js} +1 -1
  54. package/dist/assets/{sequenceDiagram-FGHM5R23-CUVNIItJ.js → sequenceDiagram-FGHM5R23-xs5OuzvV.js} +1 -1
  55. package/dist/assets/{stateDiagram-FHFEXIEX-Ct0GamGl.js → stateDiagram-FHFEXIEX-bbEP20JD.js} +1 -1
  56. package/dist/assets/stateDiagram-v2-QKLJ7IA2-XYh9U1A7.js +1 -0
  57. package/dist/assets/{timeline-definition-GMOUNBTQ-ul8Po7f7.js → timeline-definition-GMOUNBTQ-CTc2wVwC.js} +1 -1
  58. package/dist/assets/{vennDiagram-DHZGUBPP-B4AOWQnP.js → vennDiagram-DHZGUBPP-oJpXott7.js} +1 -1
  59. package/dist/assets/{wardley-RL74JXVD-Dr7Wp3AJ.js → wardley-RL74JXVD-aTmOXkKh.js} +1 -1
  60. package/dist/assets/{wardleyDiagram-NUSXRM2D-Ck70faXX.js → wardleyDiagram-NUSXRM2D-C83SOkig.js} +1 -1
  61. package/dist/assets/{xychartDiagram-5P7HB3ND-Bsy5-cNt.js → xychartDiagram-5P7HB3ND-BScws0tF.js} +1 -1
  62. package/dist/index.html +13 -13
  63. package/dist-electron/main.js +153 -116
  64. package/dist-electron/overlay.js +102 -65
  65. package/dist-electron/package.json +1 -0
  66. package/dist-electron/preload.js +8 -8
  67. package/dist-server/bootstrap/crewx-server.js +19 -10
  68. package/dist-server/domain/agent/agent.service.js +12 -0
  69. package/dist-server/domain/agent/dto/update-agent.dto.js +20 -1
  70. package/dist-server/domain/mcp/crewx-tool.factory.js +44 -113
  71. package/dist-server/domain/mcp/mcp.module.js +2 -0
  72. package/dist-server/domain/mcp/mcp.service.js +37 -12
  73. package/dist-server/domain/message/message.service.js +21 -13
  74. package/dist-server/domain/skill/skill.service.js +63 -43
  75. package/dist-server/domain/task/task.module.js +2 -0
  76. package/dist-server/domain/task/task.service.js +17 -10
  77. package/dist-server/domain/thread/dto/update-thread.dto.js +23 -0
  78. package/dist-server/domain/thread/thread.controller.js +16 -0
  79. package/dist-server/domain/thread/thread.service.js +9 -0
  80. package/dist-server/main.js +1 -1
  81. package/dist-server/modules/crewx.module.js +16 -1
  82. package/dist-server/repository/box.repository.js +20 -20
  83. package/dist-server/repository/project.repository.js +13 -13
  84. package/dist-server/repository/request-log.repository.js +10 -10
  85. package/dist-server/repository/task.repository.js +72 -72
  86. package/dist-server/repository/thread.repository.js +78 -58
  87. package/package.json +6 -6
  88. package/packages/cli/dist/bootstrap/crewx-cli.js +12 -0
  89. package/packages/cli/dist/commands/agent.js +23 -23
  90. package/packages/cli/dist/commands/init.js +19 -19
  91. package/packages/cli/dist/commands/parse-common-flags.d.ts +19 -3
  92. package/packages/cli/dist/commands/parse-common-flags.js +46 -6
  93. package/packages/cli/dist/commands/registry.d.ts +13 -0
  94. package/packages/cli/dist/commands/registry.js +29 -0
  95. package/packages/cli/dist/commands/task-db.js +7 -7
  96. package/packages/cli/dist/examples/deny-secrets-plugin.d.ts +22 -0
  97. package/packages/cli/dist/examples/deny-secrets-plugin.js +40 -0
  98. package/packages/cli/dist/main.js +134 -68
  99. package/packages/cli/dist/plugins/examples/echo-hook.d.ts +24 -0
  100. package/packages/cli/dist/plugins/examples/echo-hook.js +60 -0
  101. package/packages/cli/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
  102. package/packages/cli/dist/plugins/examples/verify-echo-hook.js +47 -0
  103. package/packages/cli/dist/plugins/sqlite-tracing.d.ts +11 -0
  104. package/packages/cli/dist/plugins/sqlite-tracing.js +19 -0
  105. package/packages/cli/dist/schema/tasks.d.ts +7 -0
  106. package/packages/cli/dist/schema/tasks.js +48 -0
  107. package/packages/cli/package.json +52 -52
  108. package/scripts/analyze-task-logs.mjs +569 -0
  109. package/scripts/build-manual.mjs +266 -266
  110. package/scripts/emit-dist-server-package-json.mjs +7 -7
  111. package/scripts/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  112. package/scripts/postinstall.mjs +44 -44
  113. package/scripts/smoke-tarball.mjs +285 -285
  114. package/scripts/snapshot-msg-list.sh +52 -52
  115. package/server.js +167 -164
  116. package/dist/assets/MarketPage-Dwsg6K-B.js +0 -31
  117. package/dist/assets/channel-BP4PNMmz.js +0 -1
  118. package/dist/assets/classDiagram-6PBFFD2Q-Upr3UAcM.js +0 -1
  119. package/dist/assets/classDiagram-v2-HSJHXN6E-Upr3UAcM.js +0 -1
  120. package/dist/assets/clone-B8BP7ReZ.js +0 -1
  121. package/dist/assets/main-CELBpK6r.js +0 -1166
  122. package/dist/assets/main-CmP-VosD.css +0 -10
  123. package/dist/assets/stateDiagram-v2-QKLJ7IA2-CFBLQDEx.js +0 -1
  124. package/dist-server/domain/task/dto/project-usage.dto.js +0 -38
  125. package/dist-server/domain/thread/dto/send-message.dto.js +0 -10
@@ -9,6 +9,39 @@
9
9
  * 2. Parse command
10
10
  * 3. Dispatch to handler
11
11
  */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
12
45
  Object.defineProperty(exports, "__esModule", { value: true });
13
46
  // ─── P0-1: Env Bootstrap ─────────────────────────────────────────────────────
14
47
  // Must run before any other code that might use process.env.CREWX_CLI.
@@ -31,15 +64,36 @@ const install_1 = require("./commands/hook/install");
31
64
  const uninstall_1 = require("./commands/hook/uninstall");
32
65
  const status_1 = require("./commands/hook/status");
33
66
  const hook_dispatch_1 = require("./commands/hook-dispatch");
67
+ const parse_common_flags_1 = require("./commands/parse-common-flags");
68
+ const registry_1 = require("./commands/registry");
34
69
  const version_1 = require("./utils/version");
35
- // Commands deferred to future rounds
36
- const NOT_YET_MIGRATED = new Set([
37
- 'template',
38
- 'templates',
39
- 'chat',
40
- 'mcp',
41
- ]);
70
+ /**
71
+ * Dev-only SSOT assertion: bin/cli-commands.js must be the exact union of
72
+ * KNOWN_COMMANDS ∪ BUILTIN_COMMAND_NAMES ∪ NOT_YET_MIGRATED from registry.ts.
73
+ * Throws on drift so the discrepancy is caught immediately during development.
74
+ */
75
+ async function assertSsotParity() {
76
+ const { join } = await Promise.resolve().then(() => __importStar(require('path')));
77
+ const { createRequire } = await Promise.resolve().then(() => __importStar(require('module')));
78
+ // Use createRequire(__filename) + plain path to avoid TypeScript compiling import() → require()
79
+ // in the CJS dist. Node.js 22.12+ supports require(esm), so this loads ESM cli-commands.js fine.
80
+ const req = createRequire(__filename);
81
+ const cliCommandsPath = join(__dirname, '../../../bin/cli-commands.js');
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ const { CLI_SUBCOMMANDS } = req(cliCommandsPath);
84
+ const union = new Set([...registry_1.KNOWN_COMMANDS, ...registry_1.BUILTIN_COMMAND_NAMES, ...registry_1.NOT_YET_MIGRATED]);
85
+ const missing = [...union].filter((c) => !CLI_SUBCOMMANDS.has(c));
86
+ const extra = [...CLI_SUBCOMMANDS].filter((c) => !union.has(c));
87
+ if (missing.length > 0 || extra.length > 0) {
88
+ throw new Error(`[crewx dev] SSOT drift detected!\n` +
89
+ (missing.length ? ` registry has, CLI_SUBCOMMANDS missing: ${missing.join(', ')}\n` : '') +
90
+ (extra.length ? ` CLI_SUBCOMMANDS has, registry missing: ${extra.join(', ')}` : ''));
91
+ }
92
+ }
42
93
  async function main() {
94
+ if (process.env['NODE_ENV'] === 'development') {
95
+ await assertSsotParity();
96
+ }
43
97
  const args = process.argv.slice(2);
44
98
  const command = args[0];
45
99
  if (!command) {
@@ -131,7 +185,7 @@ async function main() {
131
185
  }
132
186
  }
133
187
  // Not yet migrated commands (SDK-009)
134
- if (NOT_YET_MIGRATED.has(command)) {
188
+ if (registry_1.NOT_YET_MIGRATED.has(command)) {
135
189
  console.error(`Command '${command}' is not yet migrated in SDK refactor round. ` +
136
190
  'See packages/cli-bak for reference.');
137
191
  process.exit(1);
@@ -162,68 +216,80 @@ async function main() {
162
216
  process.exit(1);
163
217
  }
164
218
  function printHelp() {
165
- console.log(`
166
- CrewX CLI v${version_1.CLI_VERSION}
167
-
168
- Usage:
169
- crewx <command> [options]
170
-
171
- Query / Execute:
172
- q|query "@agent <message>" Query an agent (quoted single string)
173
- x|execute "@agent <task>" Execute a task with an agent (quoted single string)
174
-
175
- @agent is optional — defaults to @crewx when omitted.
176
-
177
- Common flags:
178
- --thread <name> Conversation thread
179
- --provider <cli/xxx> Provider override
180
- --metadata <json> Extra metadata (JSON object, double-quoted). Propagated to events/hooks/tracing.
181
- Invalid JSON aborts with exit code 2.
182
- e.g. --metadata='{"workflow_id":"wf-1"}'
183
- --verbose Debug output mode (default: raw response only)
184
- --config/-c <path> Config file path (default: CREWX_CONFIG or crewx.yaml)
185
- --output-format <fmt> Output format (json|text|stream-json)
186
- --effort <level> Model effort (high|medium|low)
187
-
188
- Agent Management:
189
- agent ls [options] List configured agents
190
- --role <value> Filter by role (comma-separated for OR match)
191
- --team <value> Filter by team (comma-separated for OR match)
192
- --provider <value> Filter by provider (comma-separated for OR match)
193
- agent prompt <@id> Show rendered system prompt for an agent
194
-
195
- Task Management:
196
- ps List running tasks
197
- kill <task-id> Kill a running task
198
- kill --all Kill all running tasks
199
- result [task-id] Get task result (or list recent tasks)
200
-
201
- Logs & Diagnostics:
202
- log [ls|<task-id>] View task logs
203
- doctor [--config <path>] Run system diagnosis
204
- init [--force] [--config <p>] Initialize crewx.yaml
205
-
206
- Built-in Tools:
207
- memory <args> Memory tool
208
- search <args> Search tool
209
- doc <args> Doc tool
210
- wbs <args> WBS tool
211
- cron <args> Cron tool
212
- workflow <args> Workflow tool
213
- skill <args> Skill tool
214
-
215
- Hook Platform:
216
- hook install [--yes] Install PreToolUse hook in .claude/settings.json
217
- hook uninstall Remove crewx hook from .claude/settings.json
218
- hook status Show hook installation status and plugins
219
- hook-dispatch Internal: IPC router called by Claude (stdin→stdout)
220
-
221
- Global Options:
222
- --help, -h Show this help
223
- --version, -v Show version
219
+ console.log(`
220
+ CrewX CLI v${version_1.CLI_VERSION}
221
+
222
+ Usage:
223
+ crewx Launch web dashboard + open browser (default)
224
+ crewx <command> [options]
225
+
226
+ UI Modes:
227
+ crewx Web dashboard (port 8150, random token, auto-open)
228
+ crewx serve [options] Web server (explicit)
229
+ --port <N> Port (default: 8150)
230
+ --token <T> MCP bearer token (⚠️ use --token-file in shared shells)
231
+ --token-file <PATH> Read bearer token from file
232
+ --no-open Do not auto-open browser
233
+ crewx electron [--overlay] Launch Electron (desktop or overlay window)
234
+
235
+ Query / Execute:
236
+ q|query "@agent <message>" Query an agent (quoted single string)
237
+ x|execute "@agent <task>" Execute a task with an agent (quoted single string)
238
+
239
+ @agent is optional — defaults to @crewx when omitted.
240
+
241
+ Common flags:
242
+ --thread <name> Conversation thread
243
+ --provider <cli/xxx> Provider override
244
+ --metadata <json> Extra metadata (JSON object, double-quoted). Propagated to events/hooks/tracing.
245
+ Invalid JSON aborts with exit code 2.
246
+ e.g. --metadata='{"workflow_id":"wf-1"}'
247
+ --verbose Debug output mode (default: raw response only)
248
+ --config/-c <path> Config file path (default: CREWX_CONFIG or crewx.yaml)
249
+ --output-format <fmt> Output format (json|text|stream-json)
250
+ --effort <level> Model effort (high|medium|low)
251
+ -- End of flags; remaining tokens treated as message text
252
+ e.g. crewx q "@agent label" -- --flag-in-message
253
+
254
+ Agent Management:
255
+ agent ls [options] List configured agents
256
+ --role <value> Filter by role (comma-separated for OR match)
257
+ --team <value> Filter by team (comma-separated for OR match)
258
+ --provider <value> Filter by provider (comma-separated for OR match)
259
+ agent prompt <@id> Show rendered system prompt for an agent
260
+
261
+ Task Management:
262
+ ps List running tasks
263
+ kill <task-id> Kill a running task
264
+ kill --all Kill all running tasks
265
+ result [task-id] Get task result (or list recent tasks)
266
+
267
+ Logs & Diagnostics:
268
+ log [ls|<task-id>] View task logs
269
+ doctor [--config <path>] Run system diagnosis
270
+ init [--force] [--config <p>] Initialize crewx.yaml
271
+
272
+ Built-in Tools:
273
+ memory <args> Memory tool
274
+ search <args> Search tool
275
+ doc <args> Doc tool
276
+ wbs <args> WBS tool
277
+ cron <args> Cron tool
278
+ workflow <args> Workflow tool
279
+ skill <args> Skill tool
280
+
281
+ Hook Platform:
282
+ hook install [--yes] Install PreToolUse hook in .claude/settings.json
283
+ hook uninstall Remove crewx hook from .claude/settings.json
284
+ hook status Show hook installation status and plugins
285
+ hook-dispatch Internal: IPC router called by Claude (stdin→stdout)
286
+
287
+ Global Options:
288
+ --help, -h Show this help
289
+ --version, -v Show version
224
290
  `.trim());
225
291
  }
226
292
  main().catch((err) => {
227
293
  console.error(err instanceof Error ? err.message : String(err));
228
- process.exit(1);
294
+ process.exit(err instanceof parse_common_flags_1.UnknownOptionError ? 2 : 1);
229
295
  });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * EchoObserverPlugin — Tool observer that echoes events to a JSONL log.
3
+ *
4
+ * Observes tool:before / tool:after events from the Crewx event bus
5
+ * and appends them as JSONL to ~/.crewx/logs/echo-hook.log.
6
+ * Pure observer — no flow control (deny/inject/modify not applicable).
7
+ */
8
+ import { ToolObserverPlugin } from '@crewx/sdk/hooks';
9
+ import type { ObserverContext, ObserverResult } from '@crewx/sdk/hooks';
10
+ export declare class EchoHookPlugin extends ToolObserverPlugin {
11
+ readonly name = "echo-hook";
12
+ readonly version = "0.0.1";
13
+ readonly on: {
14
+ beforeTool: true;
15
+ afterTool: true;
16
+ beforePrompt: true;
17
+ sessionStart: true;
18
+ };
19
+ private readonly logPath;
20
+ constructor(logDir?: string);
21
+ run(ctx: ObserverContext): Promise<ObserverResult>;
22
+ private ensureLogDir;
23
+ private echo;
24
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * EchoObserverPlugin — Tool observer that echoes events to a JSONL log.
4
+ *
5
+ * Observes tool:before / tool:after events from the Crewx event bus
6
+ * and appends them as JSONL to ~/.crewx/logs/echo-hook.log.
7
+ * Pure observer — no flow control (deny/inject/modify not applicable).
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EchoHookPlugin = void 0;
11
+ const fs_1 = require("fs");
12
+ const path_1 = require("path");
13
+ const os_1 = require("os");
14
+ const hooks_1 = require("@crewx/sdk/hooks");
15
+ class EchoHookPlugin extends hooks_1.ToolObserverPlugin {
16
+ name = 'echo-hook';
17
+ version = '0.0.1';
18
+ on = {
19
+ beforeTool: true,
20
+ afterTool: true,
21
+ beforePrompt: true,
22
+ sessionStart: true,
23
+ };
24
+ logPath;
25
+ constructor(logDir) {
26
+ super();
27
+ this.logPath = (0, path_1.join)(logDir ?? (0, os_1.homedir)(), '.crewx', 'logs', 'echo-hook.log');
28
+ this.ensureLogDir();
29
+ }
30
+ async run(ctx) {
31
+ this.echo(ctx);
32
+ return ctx.pass();
33
+ }
34
+ ensureLogDir() {
35
+ const dir = (0, path_1.dirname)(this.logPath);
36
+ if (!(0, fs_1.existsSync)(dir)) {
37
+ (0, fs_1.mkdirSync)(dir, { recursive: true, mode: 0o700 });
38
+ }
39
+ }
40
+ echo(ctx) {
41
+ try {
42
+ const line = JSON.stringify({
43
+ timestamp: new Date().toISOString(),
44
+ event: ctx.event,
45
+ traceId: ctx.traceId,
46
+ agent: ctx.agent,
47
+ provider: ctx.provider,
48
+ thread: ctx.thread,
49
+ tool: ctx.tool,
50
+ cwd: ctx.cwd,
51
+ sessionId: ctx.sessionId,
52
+ });
53
+ (0, fs_1.appendFileSync)(this.logPath, line + '\n', { encoding: 'utf8', mode: 0o600 });
54
+ }
55
+ catch {
56
+ // Non-fatal
57
+ }
58
+ }
59
+ }
60
+ exports.EchoHookPlugin = EchoHookPlugin;
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Phase 0 e2e verification — EchoHookPlugin logs Claude Code tool calls.
4
+ *
5
+ * Run: npx tsx packages/cli/src/plugins/examples/verify-echo-hook.ts
6
+ * Prereq: claude CLI installed, crewx.yaml with @claude agent
7
+ */
8
+ export {};
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env npx tsx
2
+ "use strict";
3
+ /**
4
+ * Phase 0 e2e verification — EchoHookPlugin logs Claude Code tool calls.
5
+ *
6
+ * Run: npx tsx packages/cli/src/plugins/examples/verify-echo-hook.ts
7
+ * Prereq: claude CLI installed, crewx.yaml with @claude agent
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const sdk_1 = require("@crewx/sdk");
11
+ const echo_hook_1 = require("./echo-hook");
12
+ const fs_1 = require("fs");
13
+ const path_1 = require("path");
14
+ const os_1 = require("os");
15
+ const LOG_PATH = (0, path_1.join)((0, os_1.homedir)(), '.crewx', 'logs', 'echo-hook.log');
16
+ async function main() {
17
+ if ((0, fs_1.existsSync)(LOG_PATH))
18
+ (0, fs_1.unlinkSync)(LOG_PATH);
19
+ const crewx = await sdk_1.Crewx.loadYaml('crewx.yaml');
20
+ await crewx.use(new echo_hook_1.EchoHookPlugin());
21
+ console.log('[verify] querying @claude with "ls"...');
22
+ await crewx.query('@claude', 'Run ls in the current directory. Use the Bash tool.');
23
+ await crewx.close();
24
+ if (!(0, fs_1.existsSync)(LOG_PATH)) {
25
+ console.error('[FAIL] echo-hook.log not created');
26
+ process.exit(1);
27
+ }
28
+ const lines = (0, fs_1.readFileSync)(LOG_PATH, 'utf8').trim().split('\n');
29
+ const entries = lines.map((l) => JSON.parse(l));
30
+ const hasBeforeTool = entries.some((e) => e.event === 'beforeTool');
31
+ const hasTraceId = entries.every((e) => e.traceId?.startsWith('tsk_'));
32
+ const hasToolName = entries
33
+ .filter((e) => e.event === 'beforeTool')
34
+ .every((e) => typeof e.tool?.rawName === 'string' && e.tool.rawName.length > 0);
35
+ console.log(`[verify] entries: ${entries.length}`);
36
+ console.log(`[verify] beforeTool: ${hasBeforeTool}`);
37
+ console.log(`[verify] traceId: ${hasTraceId}`);
38
+ console.log(`[verify] toolName: ${hasToolName}`);
39
+ if (hasBeforeTool && hasTraceId && hasToolName) {
40
+ console.log('[PASS] Phase 0 e2e verification passed');
41
+ }
42
+ else {
43
+ console.error('[FAIL] Some checks failed');
44
+ process.exit(1);
45
+ }
46
+ }
47
+ main().catch((err) => { console.error(err); process.exit(1); });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Re-export of SqliteTracingPlugin with a CLI-friendly constructor that
3
+ * accepts a plain dbRoot string (in addition to the SDK's options-object form).
4
+ */
5
+ import { SqliteTracingPlugin as SdkSqliteTracingPlugin } from '@crewx/sdk/plugins';
6
+ export declare class SqliteTracingPlugin extends SdkSqliteTracingPlugin {
7
+ constructor(dbRootOrOpts?: string | {
8
+ dbRoot?: string;
9
+ version?: string;
10
+ });
11
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqliteTracingPlugin = void 0;
4
+ /**
5
+ * Re-export of SqliteTracingPlugin with a CLI-friendly constructor that
6
+ * accepts a plain dbRoot string (in addition to the SDK's options-object form).
7
+ */
8
+ const plugins_1 = require("@crewx/sdk/plugins");
9
+ class SqliteTracingPlugin extends plugins_1.SqliteTracingPlugin {
10
+ constructor(dbRootOrOpts) {
11
+ if (typeof dbRootOrOpts === 'string') {
12
+ super({ dbRoot: dbRootOrOpts });
13
+ }
14
+ else {
15
+ super(dbRootOrOpts);
16
+ }
17
+ }
18
+ }
19
+ exports.SqliteTracingPlugin = SqliteTracingPlugin;
@@ -0,0 +1,7 @@
1
+ import type BetterSqlite3 from 'better-sqlite3';
2
+ /**
3
+ * Ensure the `tasks` table exists in the given database.
4
+ * Safe to call multiple times — CREATE TABLE IF NOT EXISTS is idempotent.
5
+ * Owns the canonical schema for the CLI-side tasks table.
6
+ */
7
+ export declare function ensureTasksSchema(db: InstanceType<typeof BetterSqlite3>): void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureTasksSchema = ensureTasksSchema;
4
+ /**
5
+ * Ensure the `tasks` table exists in the given database.
6
+ * Safe to call multiple times — CREATE TABLE IF NOT EXISTS is idempotent.
7
+ * Owns the canonical schema for the CLI-side tasks table.
8
+ */
9
+ function ensureTasksSchema(db) {
10
+ db.exec(`
11
+ CREATE TABLE IF NOT EXISTS tasks (
12
+ id TEXT PRIMARY KEY,
13
+ agent_id TEXT,
14
+ user_id TEXT,
15
+ prompt TEXT,
16
+ mode TEXT,
17
+ status TEXT NOT NULL,
18
+ result TEXT,
19
+ error TEXT,
20
+ started_at TEXT NOT NULL,
21
+ completed_at TEXT,
22
+ duration_ms INTEGER,
23
+ metadata TEXT,
24
+ project_id TEXT,
25
+ project_name TEXT,
26
+ trace_id TEXT,
27
+ parent_task_id TEXT,
28
+ caller_agent_id TEXT,
29
+ model TEXT,
30
+ platform TEXT,
31
+ crewx_version TEXT,
32
+ input_tokens INTEGER DEFAULT 0,
33
+ output_tokens INTEGER DEFAULT 0,
34
+ cost_usd REAL,
35
+ pid INTEGER,
36
+ rendered_prompt TEXT,
37
+ command TEXT,
38
+ coding_agent_command TEXT,
39
+ exit_code INTEGER,
40
+ logs TEXT,
41
+ thread_id TEXT,
42
+ project_ref TEXT,
43
+ workspace_id TEXT,
44
+ workspace_name TEXT,
45
+ cached_input_tokens INTEGER DEFAULT 0
46
+ )
47
+ `);
48
+ }
@@ -1,52 +1,52 @@
1
- {
2
- "name": "@crewx/cli",
3
- "version": "0.8.1",
4
- "license": "UNLICENSED",
5
- "engines": {
6
- "node": ">=20.19.0"
7
- },
8
- "description": "CrewX CLI — thin wrapper over @crewx/sdk",
9
- "type": "commonjs",
10
- "main": "dist/main.js",
11
- "types": "dist/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "require": "./dist/index.js",
15
- "import": "./dist/index.js",
16
- "types": "./dist/index.d.ts"
17
- }
18
- },
19
- "bin": {
20
- "crewx": "bin/crewx"
21
- },
22
- "files": [
23
- "dist",
24
- "bin",
25
- "README.md"
26
- ],
27
- "scripts": {
28
- "build": "tsc -p tsconfig.json",
29
- "test": "vitest run --config ./vitest.config.ts",
30
- "test:watch": "vitest --config ./vitest.config.ts",
31
- "lint": "echo 'CLI lint pending' && exit 0"
32
- },
33
- "dependencies": {
34
- "@crewx/sdk": "workspace:*",
35
- "@crewx/memory": "workspace:*",
36
- "@crewx/search": "workspace:*",
37
- "@crewx/doc": "workspace:*",
38
- "@crewx/wbs": "workspace:*",
39
- "@crewx/cron": "workspace:*",
40
- "@crewx/workflow": "workspace:*",
41
- "@crewx/skill": "workspace:*",
42
- "@crewx/shared": "workspace:*",
43
- "@crewx/adapter-slack": "^0.1.4",
44
- "better-sqlite3": "*"
45
- },
46
- "devDependencies": {
47
- "@types/better-sqlite3": "*",
48
- "@types/node": "^22.0.0",
49
- "typescript": "^5.4.0",
50
- "vitest": "^3.1.1"
51
- }
52
- }
1
+ {
2
+ "name": "@crewx/cli",
3
+ "version": "0.8.2-rc.2",
4
+ "license": "UNLICENSED",
5
+ "engines": {
6
+ "node": ">=20.19.0"
7
+ },
8
+ "description": "CrewX CLI — thin wrapper over @crewx/sdk",
9
+ "type": "commonjs",
10
+ "main": "dist/main.js",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "require": "./dist/index.js",
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ }
18
+ },
19
+ "bin": {
20
+ "crewx": "bin/crewx"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "bin",
25
+ "README.md"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "test": "vitest run --config ./vitest.config.ts",
30
+ "test:watch": "vitest --config ./vitest.config.ts",
31
+ "lint": "echo 'CLI lint pending' && exit 0"
32
+ },
33
+ "dependencies": {
34
+ "@crewx/sdk": "workspace:*",
35
+ "@crewx/memory": "workspace:*",
36
+ "@crewx/search": "workspace:*",
37
+ "@crewx/doc": "workspace:*",
38
+ "@crewx/wbs": "workspace:*",
39
+ "@crewx/cron": "workspace:*",
40
+ "@crewx/workflow": "workspace:*",
41
+ "@crewx/skill": "workspace:*",
42
+ "@crewx/shared": "workspace:*",
43
+ "@crewx/adapter-slack": "^0.1.4",
44
+ "better-sqlite3": "*"
45
+ },
46
+ "devDependencies": {
47
+ "@types/better-sqlite3": "*",
48
+ "@types/node": "^22.0.0",
49
+ "typescript": "^5.4.0",
50
+ "vitest": "^3.1.1"
51
+ }
52
+ }