@crewx/cli 0.8.4-rc.2 → 0.8.4-rc.4
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/dist/commands/execute.js +3 -1
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +1 -7
- package/dist/commands/parse-common-flags.d.ts +2 -0
- package/dist/commands/parse-common-flags.js +28 -1
- package/dist/commands/query.js +3 -1
- package/dist/main.js +1 -0
- package/package.json +5 -5
package/dist/commands/execute.js
CHANGED
|
@@ -33,7 +33,7 @@ const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
|
33
33
|
* --verbose: debug info written to stderr, response to stdout.
|
|
34
34
|
*/
|
|
35
35
|
async function handleExecute(args) {
|
|
36
|
-
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
36
|
+
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
37
37
|
const { agentRef: parsedAgentRef, message } = (0, parse_agent_message_1.parseAgentMessage)(rest);
|
|
38
38
|
// No @mention → default to @crewx agent (matches cli-bak behaviour)
|
|
39
39
|
const agentRef = parsedAgentRef || '@crewx';
|
|
@@ -63,6 +63,7 @@ async function handleExecute(args) {
|
|
|
63
63
|
console.error(' --output-format <fmt> Output format (json|text|stream-json)');
|
|
64
64
|
console.error(' --effort <level> Model effort (high|medium|low)');
|
|
65
65
|
console.error(' -f/--prompt-file <path> Read task body from file');
|
|
66
|
+
console.error(' --var key=value Template variable (repeatable)');
|
|
66
67
|
process.exit(1);
|
|
67
68
|
}
|
|
68
69
|
const configPath = config ?? process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
@@ -98,6 +99,7 @@ async function handleExecute(args) {
|
|
|
98
99
|
provider,
|
|
99
100
|
threadId: thread,
|
|
100
101
|
metadata: Object.keys(parsedMetadata).length > 0 ? parsedMetadata : undefined,
|
|
102
|
+
vars: Object.keys(vars).length > 0 ? vars : undefined,
|
|
101
103
|
});
|
|
102
104
|
if (!result.ok) {
|
|
103
105
|
const errMsg = result.error?.message ?? 'Execute failed';
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ export interface InitResult {
|
|
|
10
10
|
yamlCreated: boolean;
|
|
11
11
|
hookInstalled: boolean;
|
|
12
12
|
errors: string[];
|
|
13
|
-
skippedReason?: 'yaml-exists'
|
|
13
|
+
skippedReason?: 'yaml-exists';
|
|
14
14
|
workspaceId?: string;
|
|
15
15
|
slug?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Programmatic init — creates crewx.yaml, support dirs, and optionally installs hooks.
|
|
19
|
-
* Throws on unrecoverable errors (PATH_NOT_FOUND,
|
|
19
|
+
* Throws on unrecoverable errors (PATH_NOT_FOUND, YAML_CREATE_FAILED).
|
|
20
20
|
* Partial failures (hook install, mkdir, workspace registration) are collected in InitResult.errors.
|
|
21
21
|
* Workspace registration is always attempted (even when yaml already exists) so that CLI and
|
|
22
22
|
* server paths both produce a row in ~/.crewx/crewx.db.
|
package/dist/commands/init.js
CHANGED
|
@@ -13,7 +13,6 @@ const fs_1 = require("fs");
|
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const repository_1 = require("@crewx/sdk/repository");
|
|
15
15
|
const install_1 = require("./hook/install");
|
|
16
|
-
const paths_1 = require("./hook/paths");
|
|
17
16
|
const DEFAULT_AGENTS = [
|
|
18
17
|
{
|
|
19
18
|
id: 'planner',
|
|
@@ -90,7 +89,7 @@ ${agentBlocks}
|
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
91
|
* Programmatic init — creates crewx.yaml, support dirs, and optionally installs hooks.
|
|
93
|
-
* Throws on unrecoverable errors (PATH_NOT_FOUND,
|
|
92
|
+
* Throws on unrecoverable errors (PATH_NOT_FOUND, YAML_CREATE_FAILED).
|
|
94
93
|
* Partial failures (hook install, mkdir, workspace registration) are collected in InitResult.errors.
|
|
95
94
|
* Workspace registration is always attempted (even when yaml already exists) so that CLI and
|
|
96
95
|
* server paths both produce a row in ~/.crewx/crewx.db.
|
|
@@ -104,11 +103,6 @@ async function handleInit(opts) {
|
|
|
104
103
|
if (!(0, fs_1.existsSync)(target)) {
|
|
105
104
|
throw new Error(`PATH_NOT_FOUND: ${target}`);
|
|
106
105
|
}
|
|
107
|
-
// Reject if a parent directory already owns a crewx project
|
|
108
|
-
const parentRoot = (0, paths_1.findProjectRoot)((0, path_1.dirname)(target));
|
|
109
|
-
if (parentRoot && parentRoot !== target) {
|
|
110
|
-
throw new Error(`NESTED_CREWX_PROJECT: parent root at ${parentRoot}`);
|
|
111
|
-
}
|
|
112
106
|
const yamlPath = (0, path_1.join)(target, 'crewx.yaml');
|
|
113
107
|
const ymlPath = (0, path_1.join)(target, 'crewx.yml');
|
|
114
108
|
if ((0, fs_1.existsSync)(yamlPath) || (0, fs_1.existsSync)(ymlPath)) {
|
|
@@ -26,6 +26,8 @@ export interface CommonFlags {
|
|
|
26
26
|
effort?: string;
|
|
27
27
|
/** Path to a file whose content is used as the prompt body (-f/--prompt-file). */
|
|
28
28
|
promptFile?: string;
|
|
29
|
+
/** Template variables from --var key=value flags. */
|
|
30
|
+
vars: Record<string, string>;
|
|
29
31
|
/** Remaining non-flag positional arguments. */
|
|
30
32
|
rest: string[];
|
|
31
33
|
}
|
|
@@ -80,12 +80,39 @@ function parseCommonFlags(args) {
|
|
|
80
80
|
{ names: ['--effort'] },
|
|
81
81
|
{ names: ['--prompt-file', '-f'] },
|
|
82
82
|
];
|
|
83
|
+
// Parse --var key=value flags (multiple allowed; last value wins on duplicate keys)
|
|
84
|
+
const vars = {};
|
|
83
85
|
for (let i = 0; i < args.length; i++) {
|
|
84
86
|
const arg = args[i];
|
|
85
87
|
if (arg === '--verbose') {
|
|
86
88
|
consumed.add(i);
|
|
87
89
|
continue;
|
|
88
90
|
}
|
|
91
|
+
// --var=key=value or --var key=value
|
|
92
|
+
if (arg.startsWith('--var=') || arg === '--var') {
|
|
93
|
+
let kv;
|
|
94
|
+
if (arg.startsWith('--var=')) {
|
|
95
|
+
kv = arg.slice('--var='.length);
|
|
96
|
+
consumed.add(i);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
if (i + 1 >= args.length) {
|
|
100
|
+
throw new UnknownOptionError('--var requires a key=value argument');
|
|
101
|
+
}
|
|
102
|
+
kv = args[i + 1];
|
|
103
|
+
consumed.add(i);
|
|
104
|
+
consumed.add(i + 1);
|
|
105
|
+
i++; // skip the value token in the outer loop
|
|
106
|
+
}
|
|
107
|
+
const eqIdx = kv.indexOf('=');
|
|
108
|
+
if (eqIdx === -1) {
|
|
109
|
+
throw new UnknownOptionError(`--var requires key=value format. Got: ${kv}`);
|
|
110
|
+
}
|
|
111
|
+
const key = kv.slice(0, eqIdx);
|
|
112
|
+
const value = kv.slice(eqIdx + 1);
|
|
113
|
+
vars[key] = value;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
89
116
|
for (const { names } of flagPairs) {
|
|
90
117
|
for (const name of names) {
|
|
91
118
|
if (arg.startsWith(`${name}=`)) {
|
|
@@ -121,7 +148,7 @@ function parseCommonFlags(args) {
|
|
|
121
148
|
}
|
|
122
149
|
rest.push(token);
|
|
123
150
|
}
|
|
124
|
-
return { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, rest };
|
|
151
|
+
return { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest };
|
|
125
152
|
}
|
|
126
153
|
/**
|
|
127
154
|
* Parse metadata JSON string from --metadata flag.
|
package/dist/commands/query.js
CHANGED
|
@@ -33,7 +33,7 @@ const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
|
33
33
|
* --verbose: debug info written to stderr, response to stdout.
|
|
34
34
|
*/
|
|
35
35
|
async function handleQuery(args) {
|
|
36
|
-
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
36
|
+
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
37
37
|
const { agentRef: parsedAgentRef, message } = (0, parse_agent_message_1.parseAgentMessage)(rest);
|
|
38
38
|
// No @mention → default to @crewx agent (matches cli-bak behaviour)
|
|
39
39
|
const agentRef = parsedAgentRef || '@crewx';
|
|
@@ -63,6 +63,7 @@ async function handleQuery(args) {
|
|
|
63
63
|
console.error(' --output-format <fmt> Output format (json|text|stream-json)');
|
|
64
64
|
console.error(' --effort <level> Model effort (high|medium|low)');
|
|
65
65
|
console.error(' -f/--prompt-file <path> Read prompt body from file');
|
|
66
|
+
console.error(' --var key=value Template variable (repeatable)');
|
|
66
67
|
process.exit(1);
|
|
67
68
|
}
|
|
68
69
|
const configPath = config ?? process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
@@ -98,6 +99,7 @@ async function handleQuery(args) {
|
|
|
98
99
|
provider,
|
|
99
100
|
threadId: thread,
|
|
100
101
|
metadata: Object.keys(parsedMetadata).length > 0 ? parsedMetadata : undefined,
|
|
102
|
+
vars: Object.keys(vars).length > 0 ? vars : undefined,
|
|
101
103
|
});
|
|
102
104
|
if (!result.ok) {
|
|
103
105
|
const errMsg = result.error?.message ?? 'Query failed';
|
package/dist/main.js
CHANGED
|
@@ -251,6 +251,7 @@ Query / Execute:
|
|
|
251
251
|
--output-format <fmt> Output format (json|text|stream-json)
|
|
252
252
|
--effort <level> Model effort (high|medium|low)
|
|
253
253
|
-f/--prompt-file <path> Read task body from file (bypasses argv length limits)
|
|
254
|
+
--var key=value Template variable (repeatable). Accessible as {{key}} in agent prompt.
|
|
254
255
|
-- End of flags; remaining tokens treated as message text
|
|
255
256
|
e.g. crewx q "@agent label" -- --flag-in-message
|
|
256
257
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/cli",
|
|
3
|
-
"version": "0.8.4-rc.
|
|
3
|
+
"version": "0.8.4-rc.4",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@crewx/adapter-slack": "^0.1.4",
|
|
29
29
|
"better-sqlite3": "*",
|
|
30
|
-
"@crewx/sdk": "0.8.3-rc.12",
|
|
31
|
-
"@crewx/doc": "0.1.8",
|
|
32
|
-
"@crewx/search": "0.1.9",
|
|
33
30
|
"@crewx/memory": "0.1.10",
|
|
31
|
+
"@crewx/sdk": "0.8.4-rc.1",
|
|
32
|
+
"@crewx/search": "0.1.9",
|
|
33
|
+
"@crewx/doc": "0.1.8",
|
|
34
34
|
"@crewx/wbs": "0.1.9",
|
|
35
35
|
"@crewx/cron": "0.1.8",
|
|
36
|
+
"@crewx/workflow": "0.3.19",
|
|
36
37
|
"@crewx/shared": "0.0.5",
|
|
37
|
-
"@crewx/workflow": "0.3.17",
|
|
38
38
|
"@crewx/skill": "0.1.8"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|