agentxchain 0.1.0 → 0.1.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 (2) hide show
  1. package/package.json +12 -2
  2. package/src/commands/init.js +66 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentxchain",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI for AgentXchain — multi-agent coordination in your IDE",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,7 +16,17 @@
16
16
  "build:macos": "bun build bin/agentxchain.js --compile --target=bun-darwin-arm64 --outfile=dist/agentxchain-macos-arm64",
17
17
  "build:linux": "bun build bin/agentxchain.js --compile --target=bun-linux-x64 --outfile=dist/agentxchain-linux-x64"
18
18
  },
19
- "keywords": ["ai", "agents", "multi-agent", "coordination", "sdlc", "cursor", "vscode", "claude-code", "agentxchain"],
19
+ "keywords": [
20
+ "ai",
21
+ "agents",
22
+ "multi-agent",
23
+ "coordination",
24
+ "sdlc",
25
+ "cursor",
26
+ "vscode",
27
+ "claude-code",
28
+ "agentxchain"
29
+ ],
20
30
  "author": "shivamtiwari93",
21
31
  "license": "MIT",
22
32
  "repository": {
@@ -1,5 +1,5 @@
1
1
  import { writeFileSync, existsSync, mkdirSync } from 'fs';
2
- import { join } from 'path';
2
+ import { join, resolve } from 'path';
3
3
  import chalk from 'chalk';
4
4
  import inquirer from 'inquirer';
5
5
  import { CONFIG_FILE, LOCK_FILE, STATE_FILE } from '../lib/config.js';
@@ -23,46 +23,48 @@ const DEFAULT_AGENTS = {
23
23
  }
24
24
  };
25
25
 
26
- export async function initCommand(opts) {
27
- const dir = process.cwd();
28
-
29
- if (existsSync(join(dir, CONFIG_FILE)) && !opts.yes) {
30
- const { overwrite } = await inquirer.prompt([{
31
- type: 'confirm',
32
- name: 'overwrite',
33
- message: `${CONFIG_FILE} already exists. Overwrite?`,
34
- default: false
35
- }]);
36
- if (!overwrite) {
37
- console.log(chalk.yellow('Aborted.'));
38
- return;
39
- }
40
- }
26
+ function slugify(name) {
27
+ return name
28
+ .toLowerCase()
29
+ .replace(/[^a-z0-9]+/g, '-')
30
+ .replace(/^-|-$/g, '');
31
+ }
41
32
 
42
- let project, agents;
33
+ export async function initCommand(opts) {
34
+ let project, agents, folderName;
43
35
 
44
36
  if (opts.yes) {
45
37
  project = 'My AgentXchain project';
46
38
  agents = DEFAULT_AGENTS;
39
+ folderName = slugify(project);
47
40
  } else {
48
- const answers = await inquirer.prompt([
49
- {
50
- type: 'input',
51
- name: 'project',
52
- message: 'Project name (one line):',
53
- default: 'My AgentXchain project'
54
- },
55
- {
56
- type: 'confirm',
57
- name: 'useDefaults',
58
- message: `Use default agents (pm, dev, qa, ux)?`,
59
- default: true
60
- }
61
- ]);
41
+ const nameAnswer = await inquirer.prompt([{
42
+ type: 'input',
43
+ name: 'project',
44
+ message: 'Project name:',
45
+ default: 'My AgentXchain project'
46
+ }]);
47
+
48
+ project = nameAnswer.project;
49
+ folderName = slugify(project);
50
+
51
+ const folderAnswer = await inquirer.prompt([{
52
+ type: 'input',
53
+ name: 'folder',
54
+ message: 'Folder name:',
55
+ default: folderName
56
+ }]);
62
57
 
63
- project = answers.project;
58
+ folderName = folderAnswer.folder;
64
59
 
65
- if (answers.useDefaults) {
60
+ const agentAnswer = await inquirer.prompt([{
61
+ type: 'confirm',
62
+ name: 'useDefaults',
63
+ message: 'Use default agents (pm, dev, qa, ux)?',
64
+ default: true
65
+ }]);
66
+
67
+ if (agentAnswer.useDefaults) {
66
68
  agents = DEFAULT_AGENTS;
67
69
  } else {
68
70
  agents = {};
@@ -80,6 +82,27 @@ export async function initCommand(opts) {
80
82
  }
81
83
  }
82
84
 
85
+ const dir = resolve(process.cwd(), folderName);
86
+
87
+ if (existsSync(dir)) {
88
+ if (existsSync(join(dir, CONFIG_FILE))) {
89
+ if (!opts.yes) {
90
+ const { overwrite } = await inquirer.prompt([{
91
+ type: 'confirm',
92
+ name: 'overwrite',
93
+ message: `${folderName}/ already has an agentxchain.json. Overwrite?`,
94
+ default: false
95
+ }]);
96
+ if (!overwrite) {
97
+ console.log(chalk.yellow(' Aborted.'));
98
+ return;
99
+ }
100
+ }
101
+ }
102
+ } else {
103
+ mkdirSync(dir, { recursive: true });
104
+ }
105
+
83
106
  const config = {
84
107
  version: 3,
85
108
  project,
@@ -109,27 +132,20 @@ export async function initCommand(opts) {
109
132
  writeFileSync(join(dir, CONFIG_FILE), JSON.stringify(config, null, 2) + '\n');
110
133
  writeFileSync(join(dir, LOCK_FILE), JSON.stringify(lock, null, 2) + '\n');
111
134
  writeFileSync(join(dir, STATE_FILE), JSON.stringify(state, null, 2) + '\n');
112
-
113
- const logFile = config.log;
114
- if (!existsSync(join(dir, logFile))) {
115
- writeFileSync(join(dir, logFile), `# ${project} — Agent Log\n\n## COMPRESSED CONTEXT\n\n(No compressed context yet.)\n\n## MESSAGE LOG\n\n(Agents append messages below this line.)\n`);
116
- }
117
-
118
- if (!existsSync(join(dir, 'HUMAN_TASKS.md'))) {
119
- writeFileSync(join(dir, 'HUMAN_TASKS.md'), '# Human Tasks\n\n(Agents append tasks here when they need human action.)\n');
120
- }
135
+ writeFileSync(join(dir, config.log), `# ${project} — Agent Log\n\n## COMPRESSED CONTEXT\n\n(No compressed context yet.)\n\n## MESSAGE LOG\n\n(Agents append messages below this line.)\n`);
136
+ writeFileSync(join(dir, 'HUMAN_TASKS.md'), '# Human Tasks\n\n(Agents append tasks here when they need human action.)\n');
121
137
 
122
138
  console.log('');
123
- console.log(chalk.green(' AgentXchain project initialized.'));
139
+ console.log(chalk.green(` Created ${chalk.bold(folderName)}/`));
124
140
  console.log('');
125
- console.log(` ${chalk.dim('Config:')} ${CONFIG_FILE}`);
126
- console.log(` ${chalk.dim('Lock:')} ${LOCK_FILE}`);
127
- console.log(` ${chalk.dim('State:')} ${STATE_FILE}`);
128
- console.log(` ${chalk.dim('Log:')} ${logFile}`);
129
- console.log(` ${chalk.dim('Tasks:')} HUMAN_TASKS.md`);
141
+ console.log(` ${chalk.dim('├──')} ${CONFIG_FILE}`);
142
+ console.log(` ${chalk.dim('├──')} ${LOCK_FILE}`);
143
+ console.log(` ${chalk.dim('├──')} ${STATE_FILE}`);
144
+ console.log(` ${chalk.dim('├──')} ${config.log}`);
145
+ console.log(` ${chalk.dim('└──')} HUMAN_TASKS.md`);
130
146
  console.log('');
131
- console.log(` ${chalk.dim('Agents:')} ${Object.keys(agents).join(', ')}`);
147
+ console.log(` ${chalk.dim('Agents:')} ${Object.keys(agents).join(', ')}`);
132
148
  console.log('');
133
- console.log(` ${chalk.cyan('Next:')} Run ${chalk.bold('agentxchain start')} to launch agents in your IDE.`);
149
+ console.log(` ${chalk.cyan('Next:')} ${chalk.bold(`cd ${folderName}`)} && ${chalk.bold('agentxchain start')}`);
134
150
  console.log('');
135
151
  }