@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.
- package/bin/crewx +2 -0
- package/dist/bootstrap/crewx-cli.d.ts +11 -0
- package/dist/bootstrap/crewx-cli.js +31 -0
- package/dist/builtin.d.ts +15 -0
- package/dist/{cli/builtin.handler.js → builtin.js} +21 -7
- package/dist/commands/agent.d.ts +12 -0
- package/dist/commands/agent.js +246 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.js +190 -0
- package/dist/commands/execute.d.ts +21 -0
- package/dist/commands/execute.js +117 -0
- package/dist/commands/hook/install.d.ts +21 -0
- package/dist/commands/hook/install.js +175 -0
- package/dist/commands/hook/paths.d.ts +19 -0
- package/dist/commands/hook/paths.js +94 -0
- package/dist/commands/hook/status.d.ts +7 -0
- package/dist/commands/hook/status.js +86 -0
- package/dist/commands/hook/uninstall.d.ts +8 -0
- package/dist/commands/hook/uninstall.js +71 -0
- package/dist/commands/hook-dispatch.d.ts +15 -0
- package/dist/commands/hook-dispatch.js +180 -0
- package/dist/commands/init.d.ts +24 -0
- package/dist/commands/init.js +133 -0
- package/dist/commands/kill.d.ts +12 -0
- package/dist/commands/kill.js +49 -0
- package/dist/commands/log.d.ts +13 -0
- package/dist/commands/log.js +97 -0
- package/dist/commands/parse-agent-message.d.ts +31 -0
- package/dist/commands/parse-agent-message.js +52 -0
- package/dist/commands/parse-common-flags.d.ts +36 -0
- package/dist/commands/parse-common-flags.js +105 -0
- package/dist/commands/ps.d.ts +12 -0
- package/dist/commands/ps.js +71 -0
- package/dist/commands/query.d.ts +21 -0
- package/dist/commands/query.js +117 -0
- package/dist/commands/result.d.ts +13 -0
- package/dist/commands/result.js +73 -0
- package/dist/commands/slack.d.ts +12 -0
- package/dist/commands/slack.js +559 -0
- package/dist/commands/task-db.d.ts +33 -0
- package/dist/commands/task-db.js +107 -0
- package/dist/examples/deny-secrets-plugin.d.ts +22 -0
- package/dist/examples/deny-secrets-plugin.js +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/logging.d.ts +21 -0
- package/dist/logging.js +86 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +246 -256
- package/dist/plugins/examples/echo-hook.d.ts +24 -0
- package/dist/plugins/examples/echo-hook.js +60 -0
- package/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
- package/dist/plugins/examples/verify-echo-hook.js +47 -0
- package/dist/plugins/sqlite-tracing.d.ts +13 -0
- package/dist/plugins/sqlite-tracing.js +20 -0
- package/dist/register-builtin-tools.d.ts +5 -0
- package/dist/register-builtin-tools.js +9 -0
- package/dist/slack/file-download.d.ts +17 -0
- package/dist/slack/file-download.js +134 -0
- package/dist/slack/markdown.d.ts +5 -0
- package/dist/slack/markdown.js +33 -0
- package/dist/utils/env-defaults.d.ts +5 -0
- package/dist/utils/env-defaults.js +10 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +28 -0
- package/package.json +32 -115
- package/README.md +0 -663
- package/dist/ai-provider.service.d.ts +0 -36
- package/dist/ai-provider.service.js +0 -315
- package/dist/ai-provider.service.js.map +0 -1
- package/dist/ai.service.d.ts +0 -17
- package/dist/ai.service.js +0 -51
- package/dist/ai.service.js.map +0 -1
- package/dist/app.module.d.ts +0 -5
- package/dist/app.module.js +0 -165
- package/dist/app.module.js.map +0 -1
- package/dist/cli/agent.handler.d.ts +0 -2
- package/dist/cli/agent.handler.js +0 -186
- package/dist/cli/agent.handler.js.map +0 -1
- package/dist/cli/builtin.handler.d.ts +0 -3
- package/dist/cli/builtin.handler.js.map +0 -1
- package/dist/cli/chat.handler.d.ts +0 -20
- package/dist/cli/chat.handler.js +0 -446
- package/dist/cli/chat.handler.js.map +0 -1
- package/dist/cli/cli.handler.d.ts +0 -4
- package/dist/cli/cli.handler.js +0 -119
- package/dist/cli/cli.handler.js.map +0 -1
- package/dist/cli/doctor.handler.d.ts +0 -38
- package/dist/cli/doctor.handler.js +0 -495
- package/dist/cli/doctor.handler.js.map +0 -1
- package/dist/cli/execute.handler.d.ts +0 -2
- package/dist/cli/execute.handler.js +0 -376
- package/dist/cli/execute.handler.js.map +0 -1
- package/dist/cli/help.handler.d.ts +0 -2
- package/dist/cli/help.handler.js +0 -10
- package/dist/cli/help.handler.js.map +0 -1
- package/dist/cli/init.handler.d.ts +0 -26
- package/dist/cli/init.handler.js +0 -450
- package/dist/cli/init.handler.js.map +0 -1
- package/dist/cli/log.handler.d.ts +0 -2
- package/dist/cli/log.handler.js +0 -69
- package/dist/cli/log.handler.js.map +0 -1
- package/dist/cli/mcp.handler.d.ts +0 -3
- package/dist/cli/mcp.handler.js +0 -121
- package/dist/cli/mcp.handler.js.map +0 -1
- package/dist/cli/query.handler.d.ts +0 -2
- package/dist/cli/query.handler.js +0 -392
- package/dist/cli/query.handler.js.map +0 -1
- package/dist/cli/skill.handler.d.ts +0 -2
- package/dist/cli/skill.handler.js +0 -252
- package/dist/cli/skill.handler.js.map +0 -1
- package/dist/cli/slack-files.handler.d.ts +0 -2
- package/dist/cli/slack-files.handler.js +0 -291
- package/dist/cli/slack-files.handler.js.map +0 -1
- package/dist/cli/template.handler.d.ts +0 -2
- package/dist/cli/template.handler.js +0 -188
- package/dist/cli/template.handler.js.map +0 -1
- package/dist/cli/templates.handler.d.ts +0 -2
- package/dist/cli/templates.handler.js +0 -100
- package/dist/cli/templates.handler.js.map +0 -1
- package/dist/cli-options.d.ts +0 -40
- package/dist/cli-options.js +0 -371
- package/dist/cli-options.js.map +0 -1
- package/dist/config/timeout.config.d.ts +0 -14
- package/dist/config/timeout.config.js +0 -34
- package/dist/config/timeout.config.js.map +0 -1
- package/dist/conversation/base-conversation-history.provider.d.ts +0 -12
- package/dist/conversation/base-conversation-history.provider.js +0 -45
- package/dist/conversation/base-conversation-history.provider.js.map +0 -1
- package/dist/conversation/cli-box-reader.adapter.d.ts +0 -6
- package/dist/conversation/cli-box-reader.adapter.js +0 -10
- package/dist/conversation/cli-box-reader.adapter.js.map +0 -1
- package/dist/conversation/cli-conversation-history.provider.d.ts +0 -16
- package/dist/conversation/cli-conversation-history.provider.js +0 -112
- package/dist/conversation/cli-conversation-history.provider.js.map +0 -1
- package/dist/conversation/cli-task-reader.adapter.d.ts +0 -6
- package/dist/conversation/cli-task-reader.adapter.js +0 -25
- package/dist/conversation/cli-task-reader.adapter.js.map +0 -1
- package/dist/conversation/conversation-provider.factory.d.ts +0 -10
- package/dist/conversation/conversation-provider.factory.js +0 -50
- package/dist/conversation/conversation-provider.factory.js.map +0 -1
- package/dist/conversation/index.d.ts +0 -8
- package/dist/conversation/index.js +0 -29
- package/dist/conversation/index.js.map +0 -1
- package/dist/conversation/slack-conversation-history.provider.d.ts +0 -29
- package/dist/conversation/slack-conversation-history.provider.js +0 -302
- package/dist/conversation/slack-conversation-history.provider.js.map +0 -1
- package/dist/crewx.tool.d.ts +0 -360
- package/dist/crewx.tool.js +0 -2531
- package/dist/crewx.tool.js.map +0 -1
- package/dist/crewx.tool.spec.d.ts +0 -1
- package/dist/crewx.tool.spec.js +0 -222
- package/dist/crewx.tool.spec.js.map +0 -1
- package/dist/guards/bearer-auth.guard.d.ts +0 -7
- package/dist/guards/bearer-auth.guard.js +0 -44
- package/dist/guards/bearer-auth.guard.js.map +0 -1
- package/dist/health.controller.d.ts +0 -6
- package/dist/health.controller.js +0 -32
- package/dist/health.controller.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/mcp.controller.d.ts +0 -8
- package/dist/mcp.controller.js +0 -62
- package/dist/mcp.controller.js.map +0 -1
- package/dist/package.json +0 -3
- package/dist/providers/dynamic-provider.factory.d.ts +0 -17
- package/dist/providers/dynamic-provider.factory.js +0 -138
- package/dist/providers/dynamic-provider.factory.js.map +0 -1
- package/dist/providers/logger.adapter.d.ts +0 -7
- package/dist/providers/logger.adapter.js +0 -107
- package/dist/providers/logger.adapter.js.map +0 -1
- package/dist/services/agent-loader.service.d.ts +0 -35
- package/dist/services/agent-loader.service.js +0 -623
- package/dist/services/agent-loader.service.js.map +0 -1
- package/dist/services/auth.service.d.ts +0 -9
- package/dist/services/auth.service.js +0 -47
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/config-validator.service.d.ts +0 -29
- package/dist/services/config-validator.service.js +0 -483
- package/dist/services/config-validator.service.js.map +0 -1
- package/dist/services/config.service.d.ts +0 -45
- package/dist/services/config.service.js +0 -352
- package/dist/services/config.service.js.map +0 -1
- package/dist/services/document-loader.service.d.ts +0 -26
- package/dist/services/document-loader.service.js +0 -186
- package/dist/services/document-loader.service.js.map +0 -1
- package/dist/services/help.service.d.ts +0 -5
- package/dist/services/help.service.js +0 -139
- package/dist/services/help.service.js.map +0 -1
- package/dist/services/intelligent-compression.service.d.ts +0 -20
- package/dist/services/intelligent-compression.service.js +0 -179
- package/dist/services/intelligent-compression.service.js.map +0 -1
- package/dist/services/mcp-client.service.d.ts +0 -26
- package/dist/services/mcp-client.service.js +0 -81
- package/dist/services/mcp-client.service.js.map +0 -1
- package/dist/services/parallel-processing.service.d.ts +0 -108
- package/dist/services/parallel-processing.service.js +0 -333
- package/dist/services/parallel-processing.service.js.map +0 -1
- package/dist/services/provider-bridge.service.d.ts +0 -35
- package/dist/services/provider-bridge.service.js +0 -224
- package/dist/services/provider-bridge.service.js.map +0 -1
- package/dist/services/remote-agent.service.d.ts +0 -50
- package/dist/services/remote-agent.service.js +0 -171
- package/dist/services/remote-agent.service.js.map +0 -1
- package/dist/services/result-formatter.service.d.ts +0 -27
- package/dist/services/result-formatter.service.js +0 -126
- package/dist/services/result-formatter.service.js.map +0 -1
- package/dist/services/skill-loader.service.d.ts +0 -15
- package/dist/services/skill-loader.service.js +0 -278
- package/dist/services/skill-loader.service.js.map +0 -1
- package/dist/services/skill.service.d.ts +0 -69
- package/dist/services/skill.service.js +0 -779
- package/dist/services/skill.service.js.map +0 -1
- package/dist/services/skill.service.spec.d.ts +0 -1
- package/dist/services/skill.service.spec.js +0 -168
- package/dist/services/skill.service.spec.js.map +0 -1
- package/dist/services/task-management.service.d.ts +0 -71
- package/dist/services/task-management.service.js +0 -324
- package/dist/services/task-management.service.js.map +0 -1
- package/dist/services/template.service.d.ts +0 -61
- package/dist/services/template.service.js +0 -416
- package/dist/services/template.service.js.map +0 -1
- package/dist/services/tool-call.service.d.ts +0 -16
- package/dist/services/tool-call.service.js +0 -302
- package/dist/services/tool-call.service.js.map +0 -1
- package/dist/services/tracing.service.d.ts +0 -197
- package/dist/services/tracing.service.js +0 -1267
- package/dist/services/tracing.service.js.map +0 -1
- package/dist/slack/formatters/message.formatter.d.ts +0 -43
- package/dist/slack/formatters/message.formatter.js +0 -505
- package/dist/slack/formatters/message.formatter.js.map +0 -1
- package/dist/slack/services/slack-file-download.service.d.ts +0 -58
- package/dist/slack/services/slack-file-download.service.js +0 -558
- package/dist/slack/services/slack-file-download.service.js.map +0 -1
- package/dist/slack/slack-bot.d.ts +0 -33
- package/dist/slack/slack-bot.js +0 -568
- package/dist/slack/slack-bot.js.map +0 -1
- package/dist/stderr.logger.d.ts +0 -8
- package/dist/stderr.logger.js +0 -26
- package/dist/stderr.logger.js.map +0 -1
- package/dist/types/usage.types.d.ts +0 -107
- package/dist/types/usage.types.js +0 -3
- package/dist/types/usage.types.js.map +0 -1
- package/dist/utils/config-utils.d.ts +0 -15
- package/dist/utils/config-utils.js +0 -69
- package/dist/utils/config-utils.js.map +0 -1
- package/dist/utils/extract-text.d.ts +0 -1
- package/dist/utils/extract-text.js +0 -15
- package/dist/utils/extract-text.js.map +0 -1
- package/dist/utils/mcp-installer.d.ts +0 -20
- package/dist/utils/mcp-installer.js +0 -199
- package/dist/utils/mcp-installer.js.map +0 -1
- package/dist/utils/project-hash.d.ts +0 -6
- package/dist/utils/project-hash.js +0 -70
- package/dist/utils/project-hash.js.map +0 -1
- package/dist/utils/simple-security.d.ts +0 -3
- package/dist/utils/simple-security.js +0 -20
- package/dist/utils/simple-security.js.map +0 -1
- package/dist/utils/stdin-utils.d.ts +0 -6
- package/dist/utils/stdin-utils.js +0 -109
- package/dist/utils/stdin-utils.js.map +0 -1
- package/dist/utils/template-processor.d.ts +0 -27
- package/dist/utils/template-processor.js +0 -395
- package/dist/utils/template-processor.js.map +0 -1
- package/dist/utils/terminal-message-formatter.d.ts +0 -23
- package/dist/utils/terminal-message-formatter.js +0 -136
- package/dist/utils/terminal-message-formatter.js.map +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -17
- package/dist/version.js.map +0 -1
- package/dist/workspace.service.d.ts +0 -44
- package/dist/workspace.service.js +0 -299
- package/dist/workspace.service.js.map +0 -1
- package/scripts/backfill-tokens.js +0 -218
- package/scripts/postbuild-cli.mjs +0 -88
- package/scripts/postinstall-cli.mjs +0 -30
- package/templates/agents/default.yaml +0 -490
- package/templates/agents/minimal.yaml +0 -16
- package/templates/documents/conversation-history-default.hbs +0 -17
- package/templates/documents/crewx-manual.md +0 -2278
- package/templates/documents/crewx-quick-guide.md +0 -147
- package/templates/versions.json +0 -19
package/dist/main.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* CrewX CLI entry point.
|
|
5
|
+
* Dispatches commands to the appropriate handler.
|
|
6
|
+
*
|
|
7
|
+
* Boot sequence:
|
|
8
|
+
* 1. Inject CREWX_CLI / CREWX_WORKSPACE env defaults (must be first)
|
|
9
|
+
* 2. Parse command
|
|
10
|
+
* 3. Dispatch to handler
|
|
11
|
+
*/
|
|
3
12
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
13
|
if (k2 === undefined) k2 = k;
|
|
5
14
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -34,278 +43,259 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
43
|
};
|
|
35
44
|
})();
|
|
36
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
// ─── P0-1: Env Bootstrap ─────────────────────────────────────────────────────
|
|
47
|
+
// Must run before any other code that might use process.env.CREWX_CLI.
|
|
48
|
+
const env_defaults_1 = require("./utils/env-defaults");
|
|
49
|
+
process.env.CREWX_CLI ??= (0, env_defaults_1.resolveCrewxCli)();
|
|
50
|
+
process.env.CREWX_WORKSPACE ??= (0, env_defaults_1.resolveCrewxWorkspace)();
|
|
51
|
+
// ─── Command Imports ──────────────────────────────────────────────────────────
|
|
52
|
+
const query_1 = require("./commands/query");
|
|
53
|
+
const execute_1 = require("./commands/execute");
|
|
54
|
+
const agent_1 = require("./commands/agent");
|
|
55
|
+
const ps_1 = require("./commands/ps");
|
|
56
|
+
const kill_1 = require("./commands/kill");
|
|
57
|
+
const result_1 = require("./commands/result");
|
|
58
|
+
const log_1 = require("./commands/log");
|
|
59
|
+
const doctor_1 = require("./commands/doctor");
|
|
60
|
+
const init_1 = require("./commands/init");
|
|
61
|
+
const builtin_1 = require("./builtin");
|
|
62
|
+
const slack_1 = require("./commands/slack");
|
|
63
|
+
const install_1 = require("./commands/hook/install");
|
|
64
|
+
const uninstall_1 = require("./commands/hook/uninstall");
|
|
65
|
+
const status_1 = require("./commands/hook/status");
|
|
66
|
+
const hook_dispatch_1 = require("./commands/hook-dispatch");
|
|
67
|
+
const version_1 = require("./utils/version");
|
|
68
|
+
// Commands deferred to future rounds
|
|
69
|
+
const NOT_YET_MIGRATED = new Set([
|
|
70
|
+
'template',
|
|
71
|
+
'templates',
|
|
72
|
+
'chat',
|
|
73
|
+
'mcp',
|
|
74
|
+
]);
|
|
75
|
+
async function main() {
|
|
76
|
+
const args = process.argv.slice(2);
|
|
77
|
+
const command = args[0];
|
|
78
|
+
if (!command) {
|
|
79
|
+
printHelp();
|
|
80
|
+
process.exit(0);
|
|
62
81
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
// Built-in tools: memory, search, doc, wbs, cron, workflow
|
|
83
|
+
if (builtin_1.BUILTIN_COMMANDS.has(command)) {
|
|
84
|
+
await (0, builtin_1.handleBuiltin)(command, args.slice(1));
|
|
66
85
|
return;
|
|
67
86
|
}
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
!['list', 'ls', 'info'].includes(args.skillAction);
|
|
73
|
-
const isBuiltinCommand = ['memory', 'search', 'doc', 'wbs', 'cron', 'workflow'].includes(args.command);
|
|
74
|
-
if (!isSkillExecution && !isBuiltinCommand) {
|
|
75
|
-
args.command = 'help';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function cli() {
|
|
79
|
-
try {
|
|
80
|
-
if (args.install) {
|
|
81
|
-
logger.log('Installation mode - CrewX MCP Server setup');
|
|
82
|
-
const app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule.forRoot(args), {
|
|
83
|
-
logger: args.log ? new stderr_logger_1.StderrLogger('CrewXInstall', { timestamp: true }) : false,
|
|
84
|
-
});
|
|
85
|
-
console.log(`
|
|
86
|
-
=================================
|
|
87
|
-
CrewX MCP Server Setup
|
|
88
|
-
=================================
|
|
89
|
-
|
|
90
|
-
This MCP server provides AI-powered code analysis tools using Claude CLI and Gemini CLI.
|
|
91
|
-
|
|
92
|
-
Prerequisites:
|
|
93
|
-
- Install Claude CLI: Follow the official installation guide for claude-cli
|
|
94
|
-
- Install Gemini CLI: Follow the official installation guide for gemini-cli
|
|
95
|
-
|
|
96
|
-
MCP Server Configuration:
|
|
97
|
-
Add this to your MCP client configuration:
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
"mcpServers": {
|
|
101
|
-
"${sdk_1.SERVER_NAME}": {
|
|
102
|
-
"command": "npx",
|
|
103
|
-
"args": ["@sowonlabs/crewx"]
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Available Tools:
|
|
109
|
-
- analyzeProject: AI-powered project analysis
|
|
110
|
-
- reviewCode: Code review with AI
|
|
111
|
-
- exploreCodebase: Codebase exploration and analysis
|
|
112
|
-
- checkAIProviders: Check AI CLI tool availability
|
|
113
|
-
|
|
114
|
-
Environment Variables (optional):
|
|
115
|
-
- Set working directory and other preferences as needed
|
|
116
|
-
|
|
117
|
-
Setup completed successfully!
|
|
118
|
-
=================================
|
|
119
|
-
`);
|
|
120
|
-
await app.close();
|
|
121
|
-
process.exit(0);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
logger.error(`Installation failed: ${(0, sdk_1.getErrorMessage)(error)}`, (0, sdk_1.getErrorStack)(error));
|
|
126
|
-
process.exit(1);
|
|
87
|
+
// P2: skill routing — pass through to @crewx/skill binary
|
|
88
|
+
if (command === 'skill') {
|
|
89
|
+
await runSkill(args.slice(1));
|
|
90
|
+
return;
|
|
127
91
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
92
|
+
// Core commands
|
|
93
|
+
switch (command) {
|
|
94
|
+
// P0-2: q/x aliases
|
|
95
|
+
case 'q':
|
|
96
|
+
case 'query':
|
|
97
|
+
await (0, query_1.handleQuery)(args.slice(1));
|
|
98
|
+
return;
|
|
99
|
+
case 'x':
|
|
100
|
+
case 'execute':
|
|
101
|
+
await (0, execute_1.handleExecute)(args.slice(1));
|
|
102
|
+
return;
|
|
103
|
+
case 'agent':
|
|
104
|
+
await (0, agent_1.handleAgent)(args.slice(1));
|
|
105
|
+
return;
|
|
106
|
+
// P0-4: ps
|
|
107
|
+
case 'ps':
|
|
108
|
+
await (0, ps_1.handlePs)(args.slice(1));
|
|
109
|
+
return;
|
|
110
|
+
// P0-5: kill
|
|
111
|
+
case 'kill':
|
|
112
|
+
await (0, kill_1.handleKill)(args.slice(1));
|
|
113
|
+
return;
|
|
114
|
+
// P0-6: result
|
|
115
|
+
case 'result':
|
|
116
|
+
await (0, result_1.handleResult)(args.slice(1));
|
|
117
|
+
return;
|
|
118
|
+
// P1-1: log
|
|
119
|
+
case 'log':
|
|
120
|
+
await (0, log_1.handleLog)(args.slice(1));
|
|
121
|
+
return;
|
|
122
|
+
// P1-1: doctor
|
|
123
|
+
case 'doctor':
|
|
124
|
+
await (0, doctor_1.handleDoctor)(args.slice(1));
|
|
125
|
+
return;
|
|
126
|
+
// P1-1: init
|
|
127
|
+
case 'init': {
|
|
128
|
+
const initArgs = args.slice(1);
|
|
129
|
+
const force = initArgs.includes('--force') || initArgs.includes('-f');
|
|
130
|
+
try {
|
|
131
|
+
const r = await (0, init_1.handleInit)({ path: process.cwd(), force });
|
|
132
|
+
if (r.skippedReason === 'yaml-exists') {
|
|
133
|
+
console.log('✓ crewx.yaml already exists (use --force to overwrite)');
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.log(r.yamlCreated ? '✓ crewx.yaml created' : '✓ yaml skipped');
|
|
137
|
+
console.log(r.hookInstalled ? '✓ hook installed' : '⚠ hook skipped');
|
|
138
|
+
if (r.errors.length > 0)
|
|
139
|
+
console.warn('Warnings:', r.errors.join('; '));
|
|
140
|
+
}
|
|
141
|
+
console.log('✓ done');
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
console.error('✗ init failed:', e.message);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
return;
|
|
149
148
|
}
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
// SDK-009: slack / slack:files
|
|
150
|
+
case 'slack':
|
|
151
|
+
case 'slack:files':
|
|
152
|
+
await (0, slack_1.handleSlack)(args.slice(1));
|
|
153
|
+
return;
|
|
154
|
+
// Hook Platform (Phase 0)
|
|
155
|
+
case 'hook-dispatch':
|
|
156
|
+
await (0, hook_dispatch_1.handleHookDispatch)(args.slice(1));
|
|
157
|
+
return;
|
|
158
|
+
case 'help':
|
|
159
|
+
case '--help':
|
|
160
|
+
case '-h':
|
|
161
|
+
printHelp();
|
|
162
|
+
return;
|
|
163
|
+
case '--version':
|
|
164
|
+
case '-v': {
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
166
|
+
const pkg = require('../package.json');
|
|
167
|
+
console.log(pkg.version);
|
|
168
|
+
return;
|
|
152
169
|
}
|
|
153
|
-
process.on('uncaughtException', (err) => {
|
|
154
|
-
logger.error('Unexpected error occurred:', err);
|
|
155
|
-
});
|
|
156
|
-
const cleanup = async () => {
|
|
157
|
-
await app.close();
|
|
158
|
-
if (adapter) {
|
|
159
|
-
await adapter.close();
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
process.on('SIGTERM', async () => {
|
|
163
|
-
logger.log('Shutting down application...');
|
|
164
|
-
await cleanup();
|
|
165
|
-
process.exit(0);
|
|
166
|
-
});
|
|
167
|
-
process.on('SIGINT', async () => {
|
|
168
|
-
logger.log('Shutting down application...');
|
|
169
|
-
await cleanup();
|
|
170
|
-
process.exit(0);
|
|
171
|
-
});
|
|
172
|
-
logger.log('Code CLI MCP Server initialized successfully');
|
|
173
|
-
return app;
|
|
174
170
|
}
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
// Not yet migrated commands (SDK-009)
|
|
172
|
+
if (NOT_YET_MIGRATED.has(command)) {
|
|
173
|
+
console.error(`Command '${command}' is not yet migrated in SDK refactor round. ` +
|
|
174
|
+
'See packages/cli-bak for reference.');
|
|
177
175
|
process.exit(1);
|
|
178
176
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (args.config) {
|
|
187
|
-
const configService = app.get(config_service_1.ConfigService);
|
|
188
|
-
const aiProviderService = app.get(ai_provider_service_1.AIProviderService);
|
|
189
|
-
configService.setConfigPath(args.config);
|
|
190
|
-
configService.loadAgentConfigs();
|
|
191
|
-
await aiProviderService.reloadPluginProviders();
|
|
192
|
-
}
|
|
193
|
-
const cleanup = async () => {
|
|
194
|
-
await app.close();
|
|
195
|
-
process.exit(0);
|
|
196
|
-
};
|
|
197
|
-
process.on('SIGTERM', cleanup);
|
|
198
|
-
process.on('SIGINT', cleanup);
|
|
199
|
-
const cliHandler = new cli_handler_1.CLIHandler();
|
|
200
|
-
await cliHandler.handleCommand(app, effectiveArgs);
|
|
201
|
-
}
|
|
202
|
-
async function runSlackBot() {
|
|
203
|
-
try {
|
|
204
|
-
logger.log('Starting Slack Bot mode...');
|
|
205
|
-
process.stdout.on('error', (err) => {
|
|
206
|
-
if (err.code === 'EPIPE') {
|
|
207
|
-
logger.warn('EPIPE on stdout - ignoring (broken pipe)');
|
|
177
|
+
// Hook subcommands: crewx hook install/uninstall/status
|
|
178
|
+
if (command === 'hook') {
|
|
179
|
+
const subcommand = args[1];
|
|
180
|
+
const subArgs = args.slice(2);
|
|
181
|
+
switch (subcommand) {
|
|
182
|
+
case 'install':
|
|
183
|
+
await (0, install_1.handleHookInstall)(subArgs);
|
|
208
184
|
return;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
process.stderr.on('error', (err) => {
|
|
213
|
-
if (err.code === 'EPIPE') {
|
|
214
|
-
logger.warn('EPIPE on stderr - ignoring (broken pipe)');
|
|
185
|
+
case 'uninstall':
|
|
186
|
+
await (0, uninstall_1.handleHookUninstall)(subArgs);
|
|
215
187
|
return;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
process.on('uncaughtException', (err) => {
|
|
220
|
-
if (err.code === 'EPIPE') {
|
|
221
|
-
logger.warn('Uncaught EPIPE exception - ignoring');
|
|
188
|
+
case 'status':
|
|
189
|
+
await (0, status_1.handleHookStatus)(subArgs);
|
|
222
190
|
return;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (!process.env.SLACK_BOT_TOKEN) {
|
|
228
|
-
throw new Error('SLACK_BOT_TOKEN environment variable is required');
|
|
229
|
-
}
|
|
230
|
-
if (!process.env.SLACK_APP_TOKEN) {
|
|
231
|
-
throw new Error('SLACK_APP_TOKEN environment variable is required');
|
|
232
|
-
}
|
|
233
|
-
if (!process.env.SLACK_SIGNING_SECRET) {
|
|
234
|
-
throw new Error('SLACK_SIGNING_SECRET environment variable is required');
|
|
191
|
+
default:
|
|
192
|
+
console.error(`Unknown hook subcommand: ${subcommand ?? '(none)'}`);
|
|
193
|
+
console.error('Usage: crewx hook install|uninstall|status');
|
|
194
|
+
process.exit(1);
|
|
235
195
|
}
|
|
236
|
-
const app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule.forRoot(args), {
|
|
237
|
-
logger: args.log ? new stderr_logger_1.StderrLogger('CrewXSlack', { timestamp: true }) : false,
|
|
238
|
-
});
|
|
239
|
-
const crewXTool = app.get(crewx_tool_1.CrewXTool);
|
|
240
|
-
const configService = app.get(config_service_1.ConfigService);
|
|
241
|
-
const aiProviderService = app.get(ai_provider_service_1.AIProviderService);
|
|
242
|
-
const defaultAgent = args.slackAgent || 'claude';
|
|
243
|
-
const mode = args.slackMode || 'query';
|
|
244
|
-
const mentionOnly = args.slackMentionOnly || false;
|
|
245
|
-
logger.log(`Using default agent for Slack: ${defaultAgent}`);
|
|
246
|
-
logger.log(`Slack bot mode: ${mode}`);
|
|
247
|
-
logger.log(`Mention-only mode: ${mentionOnly ? 'enabled' : 'disabled'}`);
|
|
248
|
-
const slackBot = new slack_bot_1.SlackBot(crewXTool, configService, aiProviderService, defaultAgent, mode, mentionOnly);
|
|
249
|
-
await slackBot.start();
|
|
250
|
-
const cleanup = async () => {
|
|
251
|
-
logger.log('Shutting down Slack Bot...');
|
|
252
|
-
await slackBot.stop();
|
|
253
|
-
await app.close();
|
|
254
|
-
process.exit(0);
|
|
255
|
-
};
|
|
256
|
-
process.on('SIGTERM', cleanup);
|
|
257
|
-
process.on('SIGINT', cleanup);
|
|
258
|
-
}
|
|
259
|
-
catch (error) {
|
|
260
|
-
logger.error(`Slack Bot failed: ${(0, sdk_1.getErrorMessage)(error)}`, (0, sdk_1.getErrorStack)(error));
|
|
261
|
-
process.exit(1);
|
|
262
196
|
}
|
|
197
|
+
// Unknown command
|
|
198
|
+
console.error(`Unknown command: ${command}`);
|
|
199
|
+
console.error('Run `crewx --help` for usage.');
|
|
200
|
+
process.exit(1);
|
|
263
201
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
202
|
+
/**
|
|
203
|
+
* P2: Route `crewx skill ...` to the @crewx/skill CLI.
|
|
204
|
+
* Uses `node <skill-cli-path>` to avoid symlink exec permission issues.
|
|
205
|
+
* Falls back to spawning 'skill' on PATH if the local binary is not found.
|
|
206
|
+
*/
|
|
207
|
+
async function runSkill(skillArgs) {
|
|
208
|
+
const { spawn } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
209
|
+
const { resolve } = await Promise.resolve().then(() => __importStar(require('path')));
|
|
210
|
+
const { existsSync } = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
211
|
+
// Resolve the @crewx/skill CLI entry point directly (monorepo root)
|
|
212
|
+
const skillCliJs = resolve(__dirname, '../../../node_modules/@crewx/skill/dist/cli.js');
|
|
213
|
+
await new Promise((res, rej) => {
|
|
214
|
+
// Prefer: node <skill-cli.js> (avoids symlink exec issues on macOS)
|
|
215
|
+
const [cmd, args] = existsSync(skillCliJs)
|
|
216
|
+
? ['node', [skillCliJs, ...skillArgs]]
|
|
217
|
+
: ['skill', skillArgs];
|
|
218
|
+
const proc = spawn(cmd, args, { stdio: 'inherit' });
|
|
219
|
+
proc.on('close', (code) => {
|
|
220
|
+
process.exitCode = code ?? 0;
|
|
221
|
+
res();
|
|
222
|
+
});
|
|
223
|
+
proc.on('error', (spawnErr) => {
|
|
224
|
+
if (cmd === 'node') {
|
|
225
|
+
// Fallback: try 'skill' on PATH
|
|
226
|
+
const fallback = spawn('skill', skillArgs, { stdio: 'inherit' });
|
|
227
|
+
fallback.on('close', (c) => { process.exitCode = c ?? 0; res(); });
|
|
228
|
+
fallback.on('error', rej);
|
|
281
229
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
230
|
+
else {
|
|
231
|
+
rej(spawnErr);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function printHelp() {
|
|
237
|
+
console.log(`
|
|
238
|
+
CrewX CLI v${version_1.CLI_VERSION}
|
|
239
|
+
|
|
240
|
+
Usage:
|
|
241
|
+
crewx <command> [options]
|
|
242
|
+
|
|
243
|
+
Query / Execute:
|
|
244
|
+
q|query [@agent] <message> Query an agent (read-only)
|
|
245
|
+
x|execute [@agent] <task> Execute a task with an agent (write-capable)
|
|
246
|
+
|
|
247
|
+
@agent is optional — defaults to @crewx when omitted.
|
|
248
|
+
|
|
249
|
+
Common flags:
|
|
250
|
+
--thread <name> Conversation thread
|
|
251
|
+
--provider <cli/xxx> Provider override
|
|
252
|
+
--metadata <json> Extra metadata (JSON object, double-quoted). Propagated to events/hooks/tracing.
|
|
253
|
+
Invalid JSON aborts with exit code 2.
|
|
254
|
+
e.g. --metadata='{"workflow_id":"wf-1"}'
|
|
255
|
+
--verbose Debug output mode (default: raw response only)
|
|
256
|
+
--config/-c <path> Config file path (default: CREWX_CONFIG or crewx.yaml)
|
|
257
|
+
--output-format <fmt> Output format (json|text|stream-json)
|
|
258
|
+
--effort <level> Model effort (high|medium|low)
|
|
259
|
+
|
|
260
|
+
Agent Management:
|
|
261
|
+
agent ls [options] List configured agents
|
|
262
|
+
--role <value> Filter by role (comma-separated for OR match)
|
|
263
|
+
--team <value> Filter by team (comma-separated for OR match)
|
|
264
|
+
--provider <value> Filter by provider (comma-separated for OR match)
|
|
265
|
+
agent prompt <@id> Show rendered system prompt for an agent
|
|
266
|
+
|
|
267
|
+
Task Management:
|
|
268
|
+
ps List running tasks
|
|
269
|
+
kill <task-id> Kill a running task
|
|
270
|
+
kill --all Kill all running tasks
|
|
271
|
+
result [task-id] Get task result (or list recent tasks)
|
|
272
|
+
|
|
273
|
+
Logs & Diagnostics:
|
|
274
|
+
log [ls|<task-id>] View task logs
|
|
275
|
+
doctor [--config <path>] Run system diagnosis
|
|
276
|
+
init [--force] [--config <p>] Initialize crewx.yaml
|
|
277
|
+
|
|
278
|
+
Built-in Tools:
|
|
279
|
+
memory <args> Memory tool
|
|
280
|
+
search <args> Search tool
|
|
281
|
+
doc <args> Doc tool
|
|
282
|
+
wbs <args> WBS tool
|
|
283
|
+
cron <args> Cron tool
|
|
284
|
+
workflow <args> Workflow tool
|
|
285
|
+
skill <args> Skill tool
|
|
286
|
+
|
|
287
|
+
Hook Platform:
|
|
288
|
+
hook install [--yes] Install PreToolUse hook in .claude/settings.json
|
|
289
|
+
hook uninstall Remove crewx hook from .claude/settings.json
|
|
290
|
+
hook status Show hook installation status and plugins
|
|
291
|
+
hook-dispatch Internal: IPC router called by Claude (stdin→stdout)
|
|
292
|
+
|
|
293
|
+
Global Options:
|
|
294
|
+
--help, -h Show this help
|
|
295
|
+
--version, -v Show version
|
|
296
|
+
`.trim());
|
|
306
297
|
}
|
|
307
|
-
main().catch(err => {
|
|
308
|
-
|
|
298
|
+
main().catch((err) => {
|
|
299
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
309
300
|
process.exit(1);
|
|
310
301
|
});
|
|
311
|
-
//# sourceMappingURL=main.js.map
|
|
@@ -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;
|