agentxchain 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -58,6 +58,33 @@ For Cursor Cloud Agents, set `CURSOR_API_KEY` in your environment. Without it, t
58
58
 
59
59
  Stop all running agent sessions. Reads `.agentxchain-session.json` to find active agents.
60
60
 
61
+ ### `agentxchain config`
62
+
63
+ View or edit project configuration.
64
+
65
+ - `--add-agent` — interactively add a new agent
66
+ - `--remove-agent <id>` — remove an agent by ID
67
+ - `--set "<key> <value>"` — update a setting (e.g. `--set "rules.max_consecutive_claims 3"`)
68
+ - `-j, --json` — output config as JSON
69
+
70
+ Examples:
71
+
72
+ ```bash
73
+ agentxchain config # show current config
74
+ agentxchain config --add-agent # add a new agent
75
+ agentxchain config --remove-agent ux # remove the ux agent
76
+ agentxchain config --set "project My New Name" # change project name
77
+ agentxchain config --set "rules.compress_after_words 8000"
78
+ ```
79
+
80
+ ### `agentxchain update`
81
+
82
+ Update the CLI to the latest version from npm.
83
+
84
+ ```bash
85
+ agentxchain update
86
+ ```
87
+
61
88
  ## How it works
62
89
 
63
90
  AgentXchain uses a **claim-based protocol**:
@@ -1,28 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { Command } from 'commander';
4
- import chalk from 'chalk';
5
4
  import { initCommand } from '../src/commands/init.js';
6
5
  import { statusCommand } from '../src/commands/status.js';
7
6
  import { startCommand } from '../src/commands/start.js';
8
7
  import { stopCommand } from '../src/commands/stop.js';
8
+ import { configCommand } from '../src/commands/config.js';
9
+ import { updateCommand } from '../src/commands/update.js';
9
10
 
10
11
  const program = new Command();
11
12
 
12
13
  program
13
14
  .name('agentxchain')
14
15
  .description('Multi-agent coordination in your IDE')
15
- .version('0.1.0');
16
+ .version('0.1.1');
16
17
 
17
18
  program
18
19
  .command('init')
19
- .description('Initialize a new AgentXchain project')
20
+ .description('Create a new AgentXchain project folder')
20
21
  .option('-y, --yes', 'Skip prompts, use defaults')
21
22
  .action(initCommand);
22
23
 
23
24
  program
24
25
  .command('status')
25
- .description('Show current lock status, phase, and agents')
26
+ .description('Show lock status, phase, and agents')
26
27
  .option('-j, --json', 'Output as JSON')
27
28
  .action(statusCommand);
28
29
 
@@ -39,4 +40,18 @@ program
39
40
  .description('Stop all running agent sessions')
40
41
  .action(stopCommand);
41
42
 
43
+ program
44
+ .command('config')
45
+ .description('View or edit project configuration')
46
+ .option('--add-agent', 'Add a new agent interactively')
47
+ .option('--remove-agent <id>', 'Remove an agent by ID')
48
+ .option('--set <key_value>', 'Set a config value (e.g. --set "rules.max_consecutive_claims 3")')
49
+ .option('-j, --json', 'Output config as JSON')
50
+ .action(configCommand);
51
+
52
+ program
53
+ .command('update')
54
+ .description('Update agentxchain CLI to the latest version')
55
+ .action(updateCommand);
56
+
42
57
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentxchain",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for AgentXchain — multi-agent coordination in your IDE",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,148 @@
1
+ import { readFileSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import chalk from 'chalk';
4
+ import inquirer from 'inquirer';
5
+ import { loadConfig, CONFIG_FILE } from '../lib/config.js';
6
+
7
+ export async function configCommand(opts) {
8
+ const result = loadConfig();
9
+ if (!result) {
10
+ console.log(chalk.red(' No agentxchain.json found. Run `agentxchain init` first.'));
11
+ process.exit(1);
12
+ }
13
+
14
+ const { root, config } = result;
15
+ const configPath = join(root, CONFIG_FILE);
16
+
17
+ if (opts.addAgent) {
18
+ await addAgent(config, configPath);
19
+ return;
20
+ }
21
+
22
+ if (opts.removeAgent) {
23
+ removeAgent(config, configPath, opts.removeAgent);
24
+ return;
25
+ }
26
+
27
+ if (opts.set) {
28
+ setSetting(config, configPath, opts.set);
29
+ return;
30
+ }
31
+
32
+ if (opts.json) {
33
+ console.log(JSON.stringify(config, null, 2));
34
+ return;
35
+ }
36
+
37
+ printConfig(config);
38
+ }
39
+
40
+ function printConfig(config) {
41
+ console.log('');
42
+ console.log(chalk.bold(' AgentXchain Config'));
43
+ console.log(chalk.dim(' ' + '─'.repeat(40)));
44
+ console.log('');
45
+ console.log(` ${chalk.dim('Project:')} ${config.project}`);
46
+ console.log(` ${chalk.dim('Version:')} ${config.version}`);
47
+ console.log(` ${chalk.dim('Log:')} ${config.log}`);
48
+ console.log('');
49
+
50
+ console.log(` ${chalk.dim('Rules:')}`);
51
+ for (const [key, val] of Object.entries(config.rules || {})) {
52
+ console.log(` ${chalk.dim(key + ':')} ${val}`);
53
+ }
54
+ console.log('');
55
+
56
+ console.log(` ${chalk.dim('Agents:')} ${Object.keys(config.agents).length}`);
57
+ for (const [id, agent] of Object.entries(config.agents)) {
58
+ console.log(` ${chalk.cyan(id)} — ${agent.name}`);
59
+ console.log(` ${chalk.dim(agent.mandate.slice(0, 80))}${agent.mandate.length > 80 ? '...' : ''}`);
60
+ console.log('');
61
+ }
62
+
63
+ console.log(chalk.dim(' Commands:'));
64
+ console.log(` ${chalk.bold('agentxchain config --add-agent')} Add a new agent`);
65
+ console.log(` ${chalk.bold('agentxchain config --remove-agent <id>')} Remove an agent`);
66
+ console.log(` ${chalk.bold('agentxchain config --set <key> <val>')} Update a setting`);
67
+ console.log(` ${chalk.bold('agentxchain config --json')} Output as JSON`);
68
+ console.log('');
69
+ }
70
+
71
+ async function addAgent(config, configPath) {
72
+ const answers = await inquirer.prompt([
73
+ {
74
+ type: 'input',
75
+ name: 'id',
76
+ message: 'Agent ID (lowercase, no spaces):',
77
+ validate: (val) => {
78
+ if (!val.match(/^[a-z0-9-]+$/)) return 'Use lowercase letters, numbers, and hyphens only.';
79
+ if (config.agents[val]) return `Agent "${val}" already exists.`;
80
+ return true;
81
+ }
82
+ },
83
+ { type: 'input', name: 'name', message: 'Display name:' },
84
+ { type: 'input', name: 'mandate', message: 'Mandate (what this agent does):' }
85
+ ]);
86
+
87
+ config.agents[answers.id] = { name: answers.name, mandate: answers.mandate };
88
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
89
+
90
+ console.log('');
91
+ console.log(chalk.green(` ✓ Added agent ${chalk.bold(answers.id)} (${answers.name})`));
92
+ console.log(` ${chalk.dim('Agents now:')} ${Object.keys(config.agents).join(', ')}`);
93
+ console.log('');
94
+ }
95
+
96
+ function removeAgent(config, configPath, id) {
97
+ if (!config.agents[id]) {
98
+ console.log(chalk.red(` Agent "${id}" not found.`));
99
+ console.log(` ${chalk.dim('Available:')} ${Object.keys(config.agents).join(', ')}`);
100
+ process.exit(1);
101
+ }
102
+
103
+ const name = config.agents[id].name;
104
+ delete config.agents[id];
105
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
106
+
107
+ console.log('');
108
+ console.log(chalk.green(` ✓ Removed agent ${chalk.bold(id)} (${name})`));
109
+ console.log(` ${chalk.dim('Agents now:')} ${Object.keys(config.agents).join(', ')}`);
110
+ console.log('');
111
+ }
112
+
113
+ function setSetting(config, configPath, keyValPair) {
114
+ const parts = keyValPair.split(/\s+/);
115
+ if (parts.length < 2) {
116
+ console.log(chalk.red(' Usage: agentxchain config --set <key> <value>'));
117
+ console.log(chalk.dim(' Example: agentxchain config --set rules.max_consecutive_claims 3'));
118
+ process.exit(1);
119
+ }
120
+
121
+ const key = parts[0];
122
+ const rawVal = parts.slice(1).join(' ');
123
+ const segments = key.split('.');
124
+
125
+ let target = config;
126
+ for (let i = 0; i < segments.length - 1; i++) {
127
+ if (target[segments[i]] === undefined) {
128
+ target[segments[i]] = {};
129
+ }
130
+ target = target[segments[i]];
131
+ }
132
+
133
+ const lastKey = segments[segments.length - 1];
134
+ const oldVal = target[lastKey];
135
+
136
+ let val = rawVal;
137
+ if (rawVal === 'true') val = true;
138
+ else if (rawVal === 'false') val = false;
139
+ else if (!isNaN(rawVal) && rawVal !== '') val = Number(rawVal);
140
+
141
+ target[lastKey] = val;
142
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
143
+
144
+ console.log('');
145
+ console.log(chalk.green(` ✓ Set ${chalk.bold(key)} = ${val}`));
146
+ if (oldVal !== undefined) console.log(chalk.dim(` (was: ${oldVal})`));
147
+ console.log('');
148
+ }
@@ -0,0 +1,42 @@
1
+ import { execSync } from 'child_process';
2
+ import { readFileSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+ import chalk from 'chalk';
6
+
7
+ export async function updateCommand() {
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf8'));
10
+ const currentVersion = pkg.version;
11
+
12
+ console.log('');
13
+ console.log(` ${chalk.dim('Current version:')} ${currentVersion}`);
14
+ console.log(` ${chalk.dim('Checking npm for latest...')}`);
15
+
16
+ try {
17
+ const latest = execSync('npm view agentxchain version', { encoding: 'utf8' }).trim();
18
+
19
+ if (latest === currentVersion) {
20
+ console.log(chalk.green(` ✓ Already on the latest version (${currentVersion}).`));
21
+ console.log('');
22
+ return;
23
+ }
24
+
25
+ console.log(` ${chalk.dim('Latest version:')} ${chalk.cyan(latest)}`);
26
+ console.log('');
27
+ console.log(` Updating...`);
28
+
29
+ execSync('npm install -g agentxchain@latest', { stdio: 'inherit' });
30
+
31
+ console.log('');
32
+ console.log(chalk.green(` ✓ Updated to ${latest}`));
33
+ console.log('');
34
+ } catch (err) {
35
+ console.log('');
36
+ console.log(chalk.yellow(' Could not auto-update. Run manually:'));
37
+ console.log(` ${chalk.bold('npm install -g agentxchain@latest')}`);
38
+ console.log('');
39
+ console.log(chalk.dim(` Error: ${err.message}`));
40
+ console.log('');
41
+ }
42
+ }