crewx 0.8.1 → 0.8.2-rc.1

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 (106) 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-Dwsg6K-B.js → MarketPage-njRHlSSN.js} +1 -1
  9. package/dist/assets/{PromptTab-DVKc7hJY.js → PromptTab-CNyClpEe.js} +1 -1
  10. package/dist/assets/{_baseUniq-wjlVo2E6.js → _baseUniq-CGNNUfN7.js} +1 -1
  11. package/dist/assets/{arc-BfPgRtzW.js → arc-BEN-1A69.js} +1 -1
  12. package/dist/assets/{architectureDiagram-Q4EWVU46-ewcueFAG.js → architectureDiagram-Q4EWVU46-fAPvGzXk.js} +1 -1
  13. package/dist/assets/{blockDiagram-DXYQGD6D-TxlbbvKn.js → blockDiagram-DXYQGD6D-BWrb7uua.js} +1 -1
  14. package/dist/assets/{c4Diagram-AHTNJAMY-C1lT_bl_.js → c4Diagram-AHTNJAMY-CbnLz81q.js} +1 -1
  15. package/dist/assets/channel-uEnl63Ym.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-BopMVv1Q.js} +1 -1
  19. package/dist/assets/{chunk-4TB4RGXK-HNNsUbz0.js → chunk-4TB4RGXK-Axjc-DMR.js} +1 -1
  20. package/dist/assets/{chunk-55IACEB6-qtCgO0r2.js → chunk-55IACEB6-BVzu25a2.js} +1 -1
  21. package/dist/assets/{chunk-EDXVE4YY-BSnDYtsd.js → chunk-EDXVE4YY-Csh0IKkY.js} +1 -1
  22. package/dist/assets/{chunk-FMBD7UC4-DyHRLQqX.js → chunk-FMBD7UC4-D3yW6Ykv.js} +1 -1
  23. package/dist/assets/{chunk-OYMX7WX6-CCjfi6WS.js → chunk-OYMX7WX6-CDzLbKmY.js} +1 -1
  24. package/dist/assets/{chunk-QZHKN3VN-COLty8kd.js → chunk-QZHKN3VN-CqYP7txP.js} +1 -1
  25. package/dist/assets/{chunk-YZCP3GAM-CHUUnGeN.js → chunk-YZCP3GAM-CIz2ApJG.js} +1 -1
  26. package/dist/assets/classDiagram-6PBFFD2Q-CU98S3yn.js +1 -0
  27. package/dist/assets/classDiagram-v2-HSJHXN6E-CU98S3yn.js +1 -0
  28. package/dist/assets/clone-D3Eqsbb8.js +1 -0
  29. package/dist/assets/{cose-bilkent-S5V4N54A-CSip-V2g.js → cose-bilkent-S5V4N54A-DgVG9_nb.js} +1 -1
  30. package/dist/assets/{dagre-KV5264BT-DkdpnWhv.js → dagre-KV5264BT-DnNIMI1A.js} +1 -1
  31. package/dist/assets/{diagram-5BDNPKRD-PH4qc6PV.js → diagram-5BDNPKRD-asGr2q6a.js} +1 -1
  32. package/dist/assets/{diagram-G4DWMVQ6-Cg5xZcjx.js → diagram-G4DWMVQ6-hwyZkwNx.js} +1 -1
  33. package/dist/assets/{diagram-MMDJMWI5-soKmeTCW.js → diagram-MMDJMWI5-BJbIxezj.js} +1 -1
  34. package/dist/assets/{diagram-TYMM5635-Daq5Mihu.js → diagram-TYMM5635-JB2YJBVu.js} +1 -1
  35. package/dist/assets/{erDiagram-SMLLAGMA-kr2OtY0Y.js → erDiagram-SMLLAGMA-i1KkUgG6.js} +1 -1
  36. package/dist/assets/{flowDiagram-DWJPFMVM-DQZCb8gm.js → flowDiagram-DWJPFMVM-62cwXjLB.js} +1 -1
  37. package/dist/assets/{ganttDiagram-T4ZO3ILL-BHkn485T.js → ganttDiagram-T4ZO3ILL-BDhku_zz.js} +1 -1
  38. package/dist/assets/{gitGraphDiagram-UUTBAWPF-FaCyYFmC.js → gitGraphDiagram-UUTBAWPF-DkHe0Kwk.js} +1 -1
  39. package/dist/assets/{graph-BVJlrP6V.js → graph-BnMMHCuQ.js} +1 -1
  40. package/dist/assets/{infoDiagram-42DDH7IO-DJOWkKdM.js → infoDiagram-42DDH7IO-V7zg8GAV.js} +1 -1
  41. package/dist/assets/{ishikawaDiagram-UXIWVN3A-VfpvNaIf.js → ishikawaDiagram-UXIWVN3A-CTtEO2wl.js} +1 -1
  42. package/dist/assets/{journeyDiagram-VCZTEJTY-CPzsak-v.js → journeyDiagram-VCZTEJTY-NxQMTN2m.js} +1 -1
  43. package/dist/assets/{kanban-definition-6JOO6SKY-DFqLDBU0.js → kanban-definition-6JOO6SKY-BHBrmGg3.js} +1 -1
  44. package/dist/assets/{layout-CCSbNPHm.js → layout-DutU1eng.js} +1 -1
  45. package/dist/assets/{linear-C4T7PCKE.js → linear-Czvrvocq.js} +1 -1
  46. package/dist/assets/{main-CELBpK6r.js → main-D0PuDE6-.js} +230 -226
  47. package/dist/assets/{min-CGQNEYGh.js → min-CI38XtLs.js} +1 -1
  48. package/dist/assets/{mindmap-definition-QFDTVHPH-AuU1EqwS.js → mindmap-definition-QFDTVHPH-CbFeHoxp.js} +1 -1
  49. package/dist/assets/{pieDiagram-DEJITSTG-CopkCZwp.js → pieDiagram-DEJITSTG-MV4uB5yA.js} +1 -1
  50. package/dist/assets/{quadrantDiagram-34T5L4WZ-lMKrSv_t.js → quadrantDiagram-34T5L4WZ-D0a8e2mx.js} +1 -1
  51. package/dist/assets/{requirementDiagram-MS252O5E-dWUpHOFb.js → requirementDiagram-MS252O5E-CeTlv4na.js} +1 -1
  52. package/dist/assets/{sankeyDiagram-XADWPNL6-C8UQx9Bb.js → sankeyDiagram-XADWPNL6-D1E3xq9q.js} +1 -1
  53. package/dist/assets/{sequenceDiagram-FGHM5R23-CUVNIItJ.js → sequenceDiagram-FGHM5R23-BO1RXtYs.js} +1 -1
  54. package/dist/assets/{stateDiagram-FHFEXIEX-Ct0GamGl.js → stateDiagram-FHFEXIEX-AhFKkuPE.js} +1 -1
  55. package/dist/assets/stateDiagram-v2-QKLJ7IA2-gv2g1MYi.js +1 -0
  56. package/dist/assets/{timeline-definition-GMOUNBTQ-ul8Po7f7.js → timeline-definition-GMOUNBTQ-BMVxUhID.js} +1 -1
  57. package/dist/assets/{vennDiagram-DHZGUBPP-B4AOWQnP.js → vennDiagram-DHZGUBPP-YFiJZns6.js} +1 -1
  58. package/dist/assets/{wardley-RL74JXVD-Dr7Wp3AJ.js → wardley-RL74JXVD-JlCdJekg.js} +1 -1
  59. package/dist/assets/{wardleyDiagram-NUSXRM2D-Ck70faXX.js → wardleyDiagram-NUSXRM2D-BLn2PZq9.js} +1 -1
  60. package/dist/assets/{xychartDiagram-5P7HB3ND-Bsy5-cNt.js → xychartDiagram-5P7HB3ND-DNOUK9or.js} +1 -1
  61. package/dist/index.html +12 -12
  62. package/dist-electron/main.js +153 -116
  63. package/dist-electron/overlay.js +102 -65
  64. package/dist-electron/package.json +1 -0
  65. package/dist-electron/preload.js +8 -8
  66. package/dist-server/bootstrap/crewx-server.js +19 -10
  67. package/dist-server/repository/box.repository.js +20 -20
  68. package/dist-server/repository/project.repository.js +13 -13
  69. package/dist-server/repository/request-log.repository.js +10 -10
  70. package/dist-server/repository/task.repository.js +72 -72
  71. package/dist-server/repository/thread.repository.js +57 -57
  72. package/package.json +6 -6
  73. package/packages/cli/dist/bootstrap/crewx-cli.js +12 -0
  74. package/packages/cli/dist/commands/agent.js +23 -23
  75. package/packages/cli/dist/commands/init.js +19 -19
  76. package/packages/cli/dist/commands/parse-common-flags.d.ts +19 -3
  77. package/packages/cli/dist/commands/parse-common-flags.js +46 -6
  78. package/packages/cli/dist/commands/registry.d.ts +13 -0
  79. package/packages/cli/dist/commands/registry.js +29 -0
  80. package/packages/cli/dist/commands/task-db.js +7 -7
  81. package/packages/cli/dist/examples/deny-secrets-plugin.d.ts +22 -0
  82. package/packages/cli/dist/examples/deny-secrets-plugin.js +40 -0
  83. package/packages/cli/dist/main.js +134 -68
  84. package/packages/cli/dist/plugins/examples/echo-hook.d.ts +24 -0
  85. package/packages/cli/dist/plugins/examples/echo-hook.js +60 -0
  86. package/packages/cli/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
  87. package/packages/cli/dist/plugins/examples/verify-echo-hook.js +47 -0
  88. package/packages/cli/dist/plugins/sqlite-tracing.d.ts +11 -0
  89. package/packages/cli/dist/plugins/sqlite-tracing.js +19 -0
  90. package/packages/cli/dist/schema/tasks.d.ts +7 -0
  91. package/packages/cli/dist/schema/tasks.js +48 -0
  92. package/packages/cli/package.json +52 -52
  93. package/scripts/build-manual.mjs +266 -266
  94. package/scripts/emit-dist-server-package-json.mjs +7 -7
  95. package/scripts/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  96. package/scripts/postinstall.mjs +44 -44
  97. package/scripts/smoke-tarball.mjs +285 -285
  98. package/scripts/snapshot-msg-list.sh +52 -52
  99. package/server.js +167 -164
  100. package/dist/assets/channel-BP4PNMmz.js +0 -1
  101. package/dist/assets/classDiagram-6PBFFD2Q-Upr3UAcM.js +0 -1
  102. package/dist/assets/classDiagram-v2-HSJHXN6E-Upr3UAcM.js +0 -1
  103. package/dist/assets/clone-B8BP7ReZ.js +0 -1
  104. package/dist/assets/stateDiagram-v2-QKLJ7IA2-CFBLQDEx.js +0 -1
  105. package/dist-server/domain/task/dto/project-usage.dto.js +0 -38
  106. package/dist-server/domain/thread/dto/send-message.dto.js +0 -10
@@ -3,7 +3,11 @@
3
3
  *
4
4
  * Supports both `--flag=value` and `--flag value` forms.
5
5
  * Handles: --thread, --provider, --metadata, --verbose, --config/-c,
6
- * --output-format, --effort.
6
+ * --output-format, --effort, --prompt-file/-f.
7
+ *
8
+ * Strict mode: unknown --xxx tokens after known flags are consumed throw an
9
+ * error instead of silently leaking into the message prompt.
10
+ * Use `--` sentinel to pass literal flag-like tokens as positional args.
7
11
  */
8
12
  export interface CommonFlags {
9
13
  /** Thread name for conversation continuity. */
@@ -22,12 +26,24 @@ export interface CommonFlags {
22
26
  effort?: string;
23
27
  /** Path to a file whose content is used as the prompt body (-f/--prompt-file). */
24
28
  promptFile?: string;
25
- /** Remaining non-flag arguments. */
29
+ /** Remaining non-flag positional arguments. */
26
30
  rest: string[];
27
31
  }
32
+ /**
33
+ * Thrown by parseCommonFlags when an unrecognized --xxx flag is encountered.
34
+ * Callers can distinguish this from other errors to map to exit code 2.
35
+ */
36
+ export declare class UnknownOptionError extends Error {
37
+ constructor(message: string);
38
+ }
28
39
  /**
29
40
  * Parse common CLI flags from an args array.
30
- * Returns parsed flags and remaining positional arguments.
41
+ *
42
+ * Strict mode: any unconsumed `--xxx` token (outside a `--` escape block)
43
+ * throws `UnknownOptionError: Unknown option: --xxx.`
44
+ *
45
+ * Tokens after `--` are treated as positional and included in `rest` as-is.
46
+ * The `--` sentinel itself is NOT included in `rest`.
31
47
  */
32
48
  export declare function parseCommonFlags(args: string[]): CommonFlags;
33
49
  /**
@@ -4,9 +4,14 @@
4
4
  *
5
5
  * Supports both `--flag=value` and `--flag value` forms.
6
6
  * Handles: --thread, --provider, --metadata, --verbose, --config/-c,
7
- * --output-format, --effort.
7
+ * --output-format, --effort, --prompt-file/-f.
8
+ *
9
+ * Strict mode: unknown --xxx tokens after known flags are consumed throw an
10
+ * error instead of silently leaking into the message prompt.
11
+ * Use `--` sentinel to pass literal flag-like tokens as positional args.
8
12
  */
9
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.UnknownOptionError = void 0;
10
15
  exports.parseCommonFlags = parseCommonFlags;
11
16
  exports.parseMetadata = parseMetadata;
12
17
  /**
@@ -35,9 +40,25 @@ function parseFlag(args, ...names) {
35
40
  function hasFlag(args, ...names) {
36
41
  return names.some(name => args.includes(name));
37
42
  }
43
+ /**
44
+ * Thrown by parseCommonFlags when an unrecognized --xxx flag is encountered.
45
+ * Callers can distinguish this from other errors to map to exit code 2.
46
+ */
47
+ class UnknownOptionError extends Error {
48
+ constructor(message) {
49
+ super(message);
50
+ this.name = 'UnknownOptionError';
51
+ }
52
+ }
53
+ exports.UnknownOptionError = UnknownOptionError;
38
54
  /**
39
55
  * Parse common CLI flags from an args array.
40
- * Returns parsed flags and remaining positional arguments.
56
+ *
57
+ * Strict mode: any unconsumed `--xxx` token (outside a `--` escape block)
58
+ * throws `UnknownOptionError: Unknown option: --xxx.`
59
+ *
60
+ * Tokens after `--` are treated as positional and included in `rest` as-is.
61
+ * The `--` sentinel itself is NOT included in `rest`.
41
62
  */
42
63
  function parseCommonFlags(args) {
43
64
  const thread = parseFlag(args, '--thread');
@@ -48,7 +69,7 @@ function parseCommonFlags(args) {
48
69
  const effort = parseFlag(args, '--effort');
49
70
  const promptFile = parseFlag(args, '--prompt-file', '-f');
50
71
  const verbose = hasFlag(args, '--verbose');
51
- // Collect the set of consumed positions
72
+ // Collect consumed positions for known flags
52
73
  const consumed = new Set();
53
74
  const flagPairs = [
54
75
  { names: ['--thread'] },
@@ -61,12 +82,10 @@ function parseCommonFlags(args) {
61
82
  ];
62
83
  for (let i = 0; i < args.length; i++) {
63
84
  const arg = args[i];
64
- // Boolean flags
65
85
  if (arg === '--verbose') {
66
86
  consumed.add(i);
67
87
  continue;
68
88
  }
69
- // Value flags
70
89
  for (const { names } of flagPairs) {
71
90
  for (const name of names) {
72
91
  if (arg.startsWith(`${name}=`)) {
@@ -80,7 +99,28 @@ function parseCommonFlags(args) {
80
99
  }
81
100
  }
82
101
  }
83
- const rest = args.filter((_, i) => !consumed.has(i));
102
+ // Build rest with strict unknown-flag detection and -- escape support
103
+ const rest = [];
104
+ let escapeMode = false;
105
+ for (let i = 0; i < args.length; i++) {
106
+ if (consumed.has(i))
107
+ continue;
108
+ const token = args[i];
109
+ if (!escapeMode && token === '--') {
110
+ escapeMode = true; // consume -- sentinel; everything after is positional
111
+ continue;
112
+ }
113
+ if (!escapeMode && token.startsWith('--')) {
114
+ throw new UnknownOptionError(`Unknown option: ${token}. Use "--" to pass literal flag-like tokens as message.\n` +
115
+ ` Did you mean: crewx serve ${token}\n` +
116
+ ` or: crewx q -- ${token} <message> (to include in message)`);
117
+ }
118
+ // Reject short -x flags that are not numeric (e.g. -f was consumed above)
119
+ if (!escapeMode && token.startsWith('-') && token.length > 1 && !/^-?\d/.test(token)) {
120
+ throw new UnknownOptionError(`Unknown option: ${token}`);
121
+ }
122
+ rest.push(token);
123
+ }
84
124
  return { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, rest };
85
125
  }
86
126
  /**
@@ -0,0 +1,13 @@
1
+ /**
2
+ * CLI command registry — SSOT for commands handled by the CLI engine.
3
+ *
4
+ * Consumed by:
5
+ * - main.ts dispatch (to avoid switch/case literal drift)
6
+ * - bin/__tests__/crewx-entrypoint.test.ts (SSOT assertion vs CLI_SUBCOMMANDS)
7
+ */
8
+ /** Core commands handled by the main.ts switch/case or hook routing. */
9
+ export declare const KNOWN_COMMANDS: Set<string>;
10
+ /** Built-in tool commands routed via handleBuiltin(). */
11
+ export declare const BUILTIN_COMMAND_NAMES: Set<string>;
12
+ /** Commands not yet migrated from cli-bak — show a migration message. */
13
+ export declare const NOT_YET_MIGRATED: Set<string>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * CLI command registry — SSOT for commands handled by the CLI engine.
4
+ *
5
+ * Consumed by:
6
+ * - main.ts dispatch (to avoid switch/case literal drift)
7
+ * - bin/__tests__/crewx-entrypoint.test.ts (SSOT assertion vs CLI_SUBCOMMANDS)
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.NOT_YET_MIGRATED = exports.BUILTIN_COMMAND_NAMES = exports.KNOWN_COMMANDS = void 0;
11
+ /** Core commands handled by the main.ts switch/case or hook routing. */
12
+ exports.KNOWN_COMMANDS = new Set([
13
+ 'q', 'query',
14
+ 'x', 'execute',
15
+ 'agent',
16
+ 'ps', 'kill', 'result', 'log',
17
+ 'doctor', 'init',
18
+ 'help',
19
+ 'slack', 'slack:files',
20
+ 'hook', 'hook-dispatch',
21
+ ]);
22
+ /** Built-in tool commands routed via handleBuiltin(). */
23
+ exports.BUILTIN_COMMAND_NAMES = new Set([
24
+ 'memory', 'search', 'doc', 'wbs', 'cron', 'workflow', 'skill',
25
+ ]);
26
+ /** Commands not yet migrated from cli-bak — show a migration message. */
27
+ exports.NOT_YET_MIGRATED = new Set([
28
+ 'template', 'templates', 'chat', 'mcp',
29
+ ]);
@@ -33,8 +33,8 @@ function getRunningTasks(dbRoot) {
33
33
  if (!db)
34
34
  return [];
35
35
  try {
36
- return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
37
- result, error, duration_ms
36
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
37
+ result, error, duration_ms
38
38
  FROM tasks WHERE status = 'running' ORDER BY started_at DESC`).all();
39
39
  }
40
40
  finally {
@@ -47,8 +47,8 @@ function getAllTasks(dbRoot) {
47
47
  if (!db)
48
48
  return [];
49
49
  try {
50
- return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
51
- result, error, duration_ms
50
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
51
+ result, error, duration_ms
52
52
  FROM tasks ORDER BY started_at DESC`).all();
53
53
  }
54
54
  finally {
@@ -61,8 +61,8 @@ function getTask(id, dbRoot) {
61
61
  if (!db)
62
62
  return undefined;
63
63
  try {
64
- return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
65
- result, error, duration_ms
64
+ return db.prepare(`SELECT id, agent_id, prompt, mode, status, pid, started_at, completed_at,
65
+ result, error, duration_ms
66
66
  FROM tasks WHERE id = ?`).get(id);
67
67
  }
68
68
  finally {
@@ -97,7 +97,7 @@ function killTask(id, dbRoot) {
97
97
  // ESRCH = process already gone — still clean up the record
98
98
  }
99
99
  }
100
- db.prepare(`UPDATE tasks SET status='failed', error='killed by user',
100
+ db.prepare(`UPDATE tasks SET status='failed', error='killed by user',
101
101
  completed_at=?, pid=NULL WHERE id=?`).run(new Date().toISOString(), id);
102
102
  return { ok: true, message: `Killed task ${id}${task.pid ? ` (PID: ${task.pid})` : ''}` };
103
103
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
3
+ *
4
+ * Denies Bash tool calls whose command string contains ".env".
5
+ * Pure string matching — trivially bypassable (see README).
6
+ *
7
+ * SECURITY NOTE:
8
+ * Do NOT include tool.input content in deny reasons.
9
+ * Use static messages only to prevent prompt injection.
10
+ * ✅ return ctx.deny('Secrets-related command');
11
+ * ❌ return ctx.deny(`Blocked: ${cmd}`);
12
+ */
13
+ import { HookPlugin } from '@crewx/sdk/hooks';
14
+ import type { HookContext, HookResult } from '@crewx/sdk/hooks';
15
+ export declare class DenyIfTouchesSecretsPlugin extends HookPlugin {
16
+ readonly name = "deny-secrets";
17
+ readonly version = "0.1.0";
18
+ readonly capabilities: {
19
+ required: readonly ["deny"];
20
+ };
21
+ run(ctx: HookContext): Promise<HookResult>;
22
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * DenyIfTouchesSecretsPlugin — Phase 0 demo HookPlugin.
4
+ *
5
+ * Denies Bash tool calls whose command string contains ".env".
6
+ * Pure string matching — trivially bypassable (see README).
7
+ *
8
+ * SECURITY NOTE:
9
+ * Do NOT include tool.input content in deny reasons.
10
+ * Use static messages only to prevent prompt injection.
11
+ * ✅ return ctx.deny('Secrets-related command');
12
+ * ❌ return ctx.deny(`Blocked: ${cmd}`);
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DenyIfTouchesSecretsPlugin = void 0;
16
+ const hooks_1 = require("@crewx/sdk/hooks");
17
+ const SECRET_PATTERNS = ['.env', 'credentials.json', 'service-account-key.json'];
18
+ const SHELL_TOOL_NAMES = new Set(['Bash', 'shell', 'local_shell']);
19
+ class DenyIfTouchesSecretsPlugin extends hooks_1.HookPlugin {
20
+ name = 'deny-secrets';
21
+ version = '0.1.0';
22
+ capabilities = { required: ['deny'] };
23
+ async run(ctx) {
24
+ if (!SHELL_TOOL_NAMES.has(ctx.tool.rawName) && ctx.tool.name !== 'shell') {
25
+ return ctx.pass();
26
+ }
27
+ const input = ctx.tool.input;
28
+ const command = input?.command;
29
+ if (typeof command !== 'string') {
30
+ return ctx.pass();
31
+ }
32
+ for (const pattern of SECRET_PATTERNS) {
33
+ if (command.includes(pattern)) {
34
+ return ctx.deny('Secrets-related command');
35
+ }
36
+ }
37
+ return ctx.pass();
38
+ }
39
+ }
40
+ exports.DenyIfTouchesSecretsPlugin = DenyIfTouchesSecretsPlugin;
@@ -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 {};