@memnexus-ai/mx-agent-cli 0.1.51 → 0.1.53
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/__tests__/claude-sync.test.js +20 -136
- package/dist/__tests__/claude-sync.test.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +18 -137
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/init.d.ts +2 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +21 -70
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +0 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +9 -39
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +21 -226
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +15 -28
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +1 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/claude.d.ts +4 -15
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +44 -331
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/memory.d.ts +6 -1
- package/dist/lib/memory.d.ts.map +1 -1
- package/dist/lib/memory.js +11 -8
- package/dist/lib/memory.js.map +1 -1
- package/dist/lib/project-config.d.ts +7 -7
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js +6 -3
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/templates.d.ts +1 -39
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +25 -1239
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/worktree.d.ts +1 -19
- package/dist/lib/worktree.d.ts.map +1 -1
- package/dist/lib/worktree.js +4 -55
- package/dist/lib/worktree.js.map +1 -1
- package/package.json +2 -3
- package/README.md +0 -104
- package/dist/commands/new.d.ts +0 -30
- package/dist/commands/new.d.ts.map +0 -1
- package/dist/commands/new.js +0 -150
- package/dist/commands/new.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAClD;IACE,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAClD;IACE,WAAW,EAAE;QACX,KAAK,EAAE;YACL,SAAS;YACT,SAAS;YACT,UAAU;YACV,SAAS;YACT,SAAS;YACT,SAAS;SACV;QACD,IAAI,EAAE;YACJ,yBAAyB;YACzB,2BAA2B;YAC3B,4BAA4B;YAC5B,8BAA8B;YAC9B,uBAAuB;YACvB,yBAAyB;SAC1B;KACF;CACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;CAkBjC,CAAC"}
|
package/dist/lib/worktree.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git worktree operations for the agent CLI.
|
|
3
|
-
*
|
|
3
|
+
* Borrowed and simplified from dev-tools/worktree-cli/src/git.ts and config.ts.
|
|
4
4
|
*/
|
|
5
5
|
export declare function findProjectRoot(): string;
|
|
6
6
|
type SlotMap = Record<string, number>;
|
|
7
7
|
export declare function loadSlots(projectRoot: string, worktreeDir?: string): SlotMap;
|
|
8
8
|
export declare function assignSlot(projectRoot: string, worktreeName: string, worktreeDir?: string, maxWorktrees?: number): number;
|
|
9
9
|
export declare function getSlot(projectRoot: string, worktreeName: string, worktreeDir?: string): number | null;
|
|
10
|
-
/**
|
|
11
|
-
* Ensure the `origin` remote is configured. If missing, attempt to
|
|
12
|
-
* auto-detect via `gh repo view` and add it.
|
|
13
|
-
*
|
|
14
|
-
* Returns true if origin is available after the call, false otherwise.
|
|
15
|
-
*/
|
|
16
|
-
export declare function ensureRemote(cwd: string): boolean;
|
|
17
10
|
export declare function getCurrentBranch(cwd: string): string | null;
|
|
18
11
|
export declare function fetchOrigin(cwd: string): void;
|
|
19
12
|
/**
|
|
@@ -45,16 +38,5 @@ export declare function generateWorktreeDirName(teamSlug: string): string;
|
|
|
45
38
|
* Looks for an exact match `<name>` or a prefix match `<name>-*` under worktreeDir/.
|
|
46
39
|
*/
|
|
47
40
|
export declare function findWorktreePath(projectRoot: string, teamName: string, worktreeDir?: string): string | null;
|
|
48
|
-
/**
|
|
49
|
-
* Stamp a worktree with a team-specific git identity so commits are
|
|
50
|
-
* attributable to the agent team that made them.
|
|
51
|
-
*
|
|
52
|
-
* Uses git's native per-worktree config (requires extensions.worktreeConfig).
|
|
53
|
-
* Commits from this worktree will show:
|
|
54
|
-
* Author: Agent: <teamName> <agent-<teamName>@agents.local>
|
|
55
|
-
*
|
|
56
|
-
* Idempotent — safe to call on every `mx-agent start`.
|
|
57
|
-
*/
|
|
58
|
-
export declare function setWorktreeGitIdentity(projectRoot: string, worktreePath: string, teamName: string): void;
|
|
59
41
|
export {};
|
|
60
42
|
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/lib/worktree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,wBAAgB,eAAe,IAAI,MAAM,CAwBxC;AAMD,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAMtC,wBAAgB,SAAS,CAAC,WA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M,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAUlF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAWhE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAE,MAAqB,GAAG,MAAM,GAAG,IAAI,CAyBzH"}
|
package/dist/lib/worktree.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git worktree operations for the agent CLI.
|
|
3
|
-
*
|
|
3
|
+
* Borrowed and simplified from dev-tools/worktree-cli/src/git.ts and config.ts.
|
|
4
4
|
*/
|
|
5
5
|
import { execSync, spawnSync } from 'child_process';
|
|
6
6
|
import { existsSync, readFileSync, readdirSync, writeFileSync, mkdirSync, statSync, symlinkSync } from 'fs';
|
|
@@ -51,7 +51,7 @@ export function findProjectRoot() {
|
|
|
51
51
|
return firstMainGit;
|
|
52
52
|
throw new Error('Could not find project root (no .git directory found)');
|
|
53
53
|
}
|
|
54
|
-
// ── Slot management
|
|
54
|
+
// ── Slot management (mirrors dev-tools/worktree-cli/src/ports.ts) ─────
|
|
55
55
|
const SLOTS_FILENAME = '.slots.json';
|
|
56
56
|
function getSlotsPath(projectRoot, worktreeDir = '.worktrees') {
|
|
57
57
|
return join(projectRoot, worktreeDir, SLOTS_FILENAME);
|
|
@@ -91,26 +91,6 @@ export function getSlot(projectRoot, worktreeName, worktreeDir = '.worktrees') {
|
|
|
91
91
|
const slots = loadSlots(projectRoot, worktreeDir);
|
|
92
92
|
return slots[worktreeName] ?? null;
|
|
93
93
|
}
|
|
94
|
-
// ── Remote management ─────────────────────────────────────────────────
|
|
95
|
-
/**
|
|
96
|
-
* Ensure the `origin` remote is configured. If missing, attempt to
|
|
97
|
-
* auto-detect via `gh repo view` and add it.
|
|
98
|
-
*
|
|
99
|
-
* Returns true if origin is available after the call, false otherwise.
|
|
100
|
-
*/
|
|
101
|
-
export function ensureRemote(cwd) {
|
|
102
|
-
const r = spawnSync('git', ['remote', 'get-url', 'origin'], { cwd, stdio: 'pipe', encoding: 'utf-8' });
|
|
103
|
-
if (r.status === 0)
|
|
104
|
-
return true; // already configured
|
|
105
|
-
// Try gh CLI auto-detection
|
|
106
|
-
const gh = spawnSync('gh', ['repo', 'view', '--json', 'url', '-q', '.url'], { cwd, stdio: 'pipe', encoding: 'utf-8' });
|
|
107
|
-
if (gh.status === 0 && gh.stdout.trim()) {
|
|
108
|
-
const url = gh.stdout.trim();
|
|
109
|
-
const add = spawnSync('git', ['remote', 'add', 'origin', url], { cwd, stdio: 'pipe' });
|
|
110
|
-
return add.status === 0;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
94
|
// ── Git helpers ───────────────────────────────────────────────────────
|
|
115
95
|
export function getCurrentBranch(cwd) {
|
|
116
96
|
try {
|
|
@@ -163,9 +143,7 @@ export function createGitWorktree(worktreePath, branch, baseBranch, cwd) {
|
|
|
163
143
|
}
|
|
164
144
|
else {
|
|
165
145
|
try {
|
|
166
|
-
|
|
167
|
-
// when origin doesn't exist (fresh local repo). Fallback handles it silently.
|
|
168
|
-
const r = spawnSync('git', ['worktree', 'add', worktreePath, '-b', branch, `origin/${baseBranch}`], { cwd, stdio: 'pipe' });
|
|
146
|
+
const r = spawnSync('git', ['worktree', 'add', worktreePath, '-b', branch, `origin/${baseBranch}`], { cwd, stdio: 'inherit' });
|
|
169
147
|
if (r.status !== 0)
|
|
170
148
|
throw new Error(`git worktree add failed with status ${r.status}`);
|
|
171
149
|
}
|
|
@@ -241,14 +219,10 @@ export function findWorktreePath(projectRoot, teamName, worktreeDir = '.worktree
|
|
|
241
219
|
if (existsSync(exact))
|
|
242
220
|
return exact;
|
|
243
221
|
// Prefix match: teamName-YYYYMMDD
|
|
244
|
-
// The suffix after the hyphen MUST start with a digit to avoid "mx-agent"
|
|
245
|
-
// matching "mx-agent-system-team-20260223" (which would double-count usage).
|
|
246
222
|
try {
|
|
247
223
|
const entries = readdirSync(worktreesDir);
|
|
248
224
|
for (const entry of entries) {
|
|
249
|
-
|
|
250
|
-
const isDateSuffixed = entry.startsWith(`${teamName}-`) && /^\d/.test(suffix);
|
|
251
|
-
if (entry === teamName || isDateSuffixed) {
|
|
225
|
+
if (entry === teamName || entry.startsWith(`${teamName}-`)) {
|
|
252
226
|
const candidate = join(worktreesDir, entry);
|
|
253
227
|
// Confirm it's actually a git worktree (has .git file)
|
|
254
228
|
if (existsSync(join(candidate, '.git'))) {
|
|
@@ -262,29 +236,4 @@ export function findWorktreePath(projectRoot, teamName, worktreeDir = '.worktree
|
|
|
262
236
|
}
|
|
263
237
|
return null;
|
|
264
238
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Stamp a worktree with a team-specific git identity so commits are
|
|
267
|
-
* attributable to the agent team that made them.
|
|
268
|
-
*
|
|
269
|
-
* Uses git's native per-worktree config (requires extensions.worktreeConfig).
|
|
270
|
-
* Commits from this worktree will show:
|
|
271
|
-
* Author: Agent: <teamName> <agent-<teamName>@agents.local>
|
|
272
|
-
*
|
|
273
|
-
* Idempotent — safe to call on every `mx-agent start`.
|
|
274
|
-
*/
|
|
275
|
-
export function setWorktreeGitIdentity(projectRoot, worktreePath, teamName) {
|
|
276
|
-
// Enable worktree-specific config on the main repo (idempotent).
|
|
277
|
-
// This creates per-worktree config files at .git/worktrees/<name>/config.worktree
|
|
278
|
-
spawnSync('git', ['config', 'extensions.worktreeConfig', 'true'], {
|
|
279
|
-
cwd: projectRoot, stdio: 'pipe',
|
|
280
|
-
});
|
|
281
|
-
// Set identity in this worktree's config only — does not affect other worktrees
|
|
282
|
-
// or the main repo's global/local identity.
|
|
283
|
-
spawnSync('git', ['config', '--worktree', 'user.name', `Agent: ${teamName}`], {
|
|
284
|
-
cwd: worktreePath, stdio: 'pipe',
|
|
285
|
-
});
|
|
286
|
-
spawnSync('git', ['config', '--worktree', 'user.email', `agent-${teamName}@agents.local`], {
|
|
287
|
-
cwd: worktreePath, stdio: 'pipe',
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
239
|
//# sourceMappingURL=worktree.js.map
|
package/dist/lib/worktree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../src/lib/worktree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC5G,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC,yEAAyE;AAEzE;;;;;;;;GAQG;AACH;;;;GAIG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE9B,0EAA0E;IAC1E,0EAA0E;IAC1E,+CAA+C;IAC/C,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,OAAO,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YAC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,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;oBACxC,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memnexus-ai/mx-agent-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
4
4
|
"description": "CLI for creating and managing AI agent teams",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"dev": "tsc --watch",
|
|
12
12
|
"start": "node dist/index.js",
|
|
13
13
|
"prepublishOnly": "npm run build",
|
|
14
|
-
"postpublish": "npm access set status=public @memnexus-ai/mx-agent-cli",
|
|
15
14
|
"test": "vitest run",
|
|
16
15
|
"test:watch": "vitest"
|
|
17
16
|
},
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
"directory": "mx-agent-system/cli"
|
|
34
33
|
},
|
|
35
34
|
"publishConfig": {
|
|
36
|
-
"access": "
|
|
35
|
+
"access": "restricted"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
38
|
"chalk": "^5.3.0",
|
package/README.md
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# @memnexus-ai/mx-agent-cli
|
|
2
|
-
|
|
3
|
-
`mx-agent` lets you run isolated AI agent teams on any git repository. Each team gets its own git worktree, a roleguide that defines its job, and named MemNexus memories that carry state across sessions — so you can run multiple focused agents in parallel without them stepping on each other.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- **Node 18+**
|
|
8
|
-
- **MemNexus access** — npm scope `@memnexus-ai` requires registry access; contact your MemNexus administrator
|
|
9
|
-
- **`mx` CLI installed** — required by `mx-agent status` and `mx-agent pager`; install from MemNexus
|
|
10
|
-
- **A git repository** — `mx-agent` must be run from inside a git repo
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
13
|
-
|
|
14
|
-
**1. Install**
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install -g @memnexus-ai/mx-agent-cli
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**2. Initialise your project**
|
|
21
|
-
|
|
22
|
-
Run this once from the root of your git repository:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
mx-agent init
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Creates `mx-agent.config.json` and the `mx-agent-system/` directory structure including agent permissions config and a `CLAUDE.md.template`.
|
|
29
|
-
|
|
30
|
-
**3. Write a roleguide**
|
|
31
|
-
|
|
32
|
-
A roleguide is a markdown file that acts as the agent's job description — what it works on, how it prioritises, and how it reports status. See [docs/adoption-guide.md](../docs/adoption-guide.md) for a full template and explanation.
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# Example: create your first roleguide
|
|
36
|
-
vim mx-agent-system/roleguides/my-team-leader.md
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**4. Create a team and start a session**
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
mx-agent create --roleguide mx-agent-system/roleguides/my-team-leader.md --name my-team
|
|
43
|
-
mx-agent start my-team
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Command Reference
|
|
49
|
-
|
|
50
|
-
| Command | Description | Key options |
|
|
51
|
-
|---------|-------------|-------------|
|
|
52
|
-
| `mx-agent init` | Scaffold `mx-agent-system/` for a new project | `--force`, `--base-branch <branch>`, `--worktree-dir <path>`, `--config-source <path>` |
|
|
53
|
-
| `mx-agent create` | Create a new agent team: worktree + memories + catalog entry | `--roleguide <path>` (required), `--name <slug>` |
|
|
54
|
-
| `mx-agent start <name>` | Start an isolated Claude session for a team | — |
|
|
55
|
-
| `mx-agent list` | List all teams and their worktree status | — |
|
|
56
|
-
| `mx-agent status <name>` | Show a team's current `{name}-leader-state` memory | — |
|
|
57
|
-
| `mx-agent usage [name]` | Show token usage and cost from Claude session logs, broken down by team | `--recent <period>` (default: `30d`; e.g. `7d`, `24h`) |
|
|
58
|
-
| `mx-agent pager` | Watch team states and post Slack alerts when operator attention is needed | `--webhook <url>`, `--interval <seconds>` (default: `300`), `--once` |
|
|
59
|
-
| `mx-agent update` | Update `mx-agent` to the latest version from npm | — |
|
|
60
|
-
| `mx-agent config set <key> <value>` | Set a persistent operator config value (e.g. `slack-webhook`) | — |
|
|
61
|
-
| `mx-agent config get <key>` | Get a config value | — |
|
|
62
|
-
| `mx-agent config list` | List all config values | — |
|
|
63
|
-
| `mx-agent config unset <key>` | Remove a config value | — |
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Configuration
|
|
68
|
-
|
|
69
|
-
`mx-agent.config.json` is written to your project root by `mx-agent init`. All fields are optional and fall back to the defaults shown below.
|
|
70
|
-
|
|
71
|
-
| Field | Type | Default | Description |
|
|
72
|
-
|-------|------|---------|-------------|
|
|
73
|
-
| `baseBranch` | `string` | `"main"` | Base branch for git operations. Change to `"develop"` if your default branch isn't `main`. |
|
|
74
|
-
| `worktreeDir` | `string` | `".worktrees"` | Directory under the project root where agent worktrees are stored. |
|
|
75
|
-
| `configSource` | `string` | `"mx-agent-system/agent-config"` | Path to the agent-config directory containing `settings.json`, `CLAUDE.md.template`, and hooks. |
|
|
76
|
-
| `teamsDir` | `string` | `"mx-agent-system/teams"` | Path to the teams catalog directory. |
|
|
77
|
-
| `roleguidesDir` | `string` | `"mx-agent-system/roleguides"` | Path to the roleguides directory. |
|
|
78
|
-
|
|
79
|
-
Values must contain only alphanumeric characters, hyphens, underscores, dots, and forward slashes. Path traversal (`..`) is not permitted.
|
|
80
|
-
|
|
81
|
-
**Example:**
|
|
82
|
-
|
|
83
|
-
```json
|
|
84
|
-
{
|
|
85
|
-
"baseBranch": "develop",
|
|
86
|
-
"worktreeDir": ".worktrees",
|
|
87
|
-
"configSource": "mx-agent-system/agent-config",
|
|
88
|
-
"teamsDir": "mx-agent-system/teams",
|
|
89
|
-
"roleguidesDir": "mx-agent-system/roleguides"
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## Further reading
|
|
96
|
-
|
|
97
|
-
See **[docs/adoption-guide.md](../docs/adoption-guide.md)** for:
|
|
98
|
-
|
|
99
|
-
- Core concepts explained
|
|
100
|
-
- Step-by-step setup walkthrough
|
|
101
|
-
- How to customise agent permissions and `CLAUDE.md.template`
|
|
102
|
-
- Operational workflows (monitoring, cost tracking, team status)
|
|
103
|
-
- Troubleshooting common errors
|
|
104
|
-
- Full roleguide template
|
package/dist/commands/new.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mx-agent new <project-name>
|
|
3
|
-
*
|
|
4
|
-
* Scaffolds a complete new project from scratch:
|
|
5
|
-
* <project-name>/
|
|
6
|
-
* .devcontainer/
|
|
7
|
-
* Dockerfile
|
|
8
|
-
* devcontainer.json
|
|
9
|
-
* post-create.sh
|
|
10
|
-
* post-start.sh
|
|
11
|
-
* mx-agent.config.json
|
|
12
|
-
* mx-agent-system/
|
|
13
|
-
* agent-config/
|
|
14
|
-
* CLAUDE.md.template
|
|
15
|
-
* settings.json
|
|
16
|
-
* hooks/
|
|
17
|
-
* worktree-guard.sh
|
|
18
|
-
* teams/
|
|
19
|
-
* roleguides/
|
|
20
|
-
* .gitignore
|
|
21
|
-
* (initial git commit)
|
|
22
|
-
*/
|
|
23
|
-
export interface NewOptions {
|
|
24
|
-
baseBranch?: string;
|
|
25
|
-
worktreeDir?: string;
|
|
26
|
-
configSource?: string;
|
|
27
|
-
dir?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function runNew(projectName: string, options: NewOptions): Promise<void>;
|
|
30
|
-
//# sourceMappingURL=new.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiBH,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4BD,wBAAsB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsHpF"}
|
package/dist/commands/new.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mx-agent new <project-name>
|
|
3
|
-
*
|
|
4
|
-
* Scaffolds a complete new project from scratch:
|
|
5
|
-
* <project-name>/
|
|
6
|
-
* .devcontainer/
|
|
7
|
-
* Dockerfile
|
|
8
|
-
* devcontainer.json
|
|
9
|
-
* post-create.sh
|
|
10
|
-
* post-start.sh
|
|
11
|
-
* mx-agent.config.json
|
|
12
|
-
* mx-agent-system/
|
|
13
|
-
* agent-config/
|
|
14
|
-
* CLAUDE.md.template
|
|
15
|
-
* settings.json
|
|
16
|
-
* hooks/
|
|
17
|
-
* worktree-guard.sh
|
|
18
|
-
* teams/
|
|
19
|
-
* roleguides/
|
|
20
|
-
* .gitignore
|
|
21
|
-
* (initial git commit)
|
|
22
|
-
*/
|
|
23
|
-
import { existsSync, mkdirSync, writeFileSync, chmodSync, readdirSync } from 'fs';
|
|
24
|
-
import { join, resolve } from 'path';
|
|
25
|
-
import { spawnSync } from 'child_process';
|
|
26
|
-
import chalk from 'chalk';
|
|
27
|
-
import { runInit } from './init.js';
|
|
28
|
-
import { PROJECT_CONFIG_DEFAULTS } from '../lib/project-config.js';
|
|
29
|
-
import { newProjectDockerfileTemplate, newProjectDevcontainerJsonTemplate, newProjectPostCreateShTemplate, newProjectPostStartShTemplate, newProjectGitignoreTemplate, teamBuilderRoleguideTemplate, } from '../lib/templates.js';
|
|
30
|
-
/** Validate project name: letters, digits, hyphens/underscores, 1-50 chars, must start with letter or digit */
|
|
31
|
-
function validateProjectName(name) {
|
|
32
|
-
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,49}$/.test(name)) {
|
|
33
|
-
throw new Error(`Invalid project name "${name}". Use letters, digits, hyphens, or underscores (1–50 chars, must start with a letter or digit).`);
|
|
34
|
-
}
|
|
35
|
-
// Belt-and-suspenders: explicitly reject shell metacharacters and path
|
|
36
|
-
// traversal even though the allowlist regex above already blocks them.
|
|
37
|
-
// This guard remains meaningful if the allowlist regex is ever relaxed.
|
|
38
|
-
if (/[;|&$`()><]/.test(name) || name.includes('..') || name.includes('/') || name.includes('\\')) {
|
|
39
|
-
throw new Error(`Project name "${name}" contains disallowed characters.`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function logCreated(path) {
|
|
43
|
-
console.log(chalk.green(' ✓ created ') + chalk.dim(path));
|
|
44
|
-
}
|
|
45
|
-
function writeFile(filePath, content) {
|
|
46
|
-
const dir = join(filePath, '..');
|
|
47
|
-
mkdirSync(dir, { recursive: true });
|
|
48
|
-
writeFileSync(filePath, content, 'utf-8');
|
|
49
|
-
logCreated(filePath);
|
|
50
|
-
}
|
|
51
|
-
export async function runNew(projectName, options) {
|
|
52
|
-
// 1. Validate name
|
|
53
|
-
validateProjectName(projectName);
|
|
54
|
-
// 2. Determine output directory
|
|
55
|
-
const outputDir = options.dir ? resolve(options.dir) : resolve(process.cwd(), projectName);
|
|
56
|
-
// 3. Check directory
|
|
57
|
-
if (existsSync(outputDir)) {
|
|
58
|
-
let entries = [];
|
|
59
|
-
try {
|
|
60
|
-
entries = readdirSync(outputDir);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
/* ignore */
|
|
64
|
-
}
|
|
65
|
-
if (entries.length > 0) {
|
|
66
|
-
console.error(chalk.red(`Error: Directory already exists and is not empty: ${outputDir}`));
|
|
67
|
-
console.error(chalk.dim('Use a different project name or remove the existing directory.'));
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
console.log();
|
|
72
|
-
console.log(chalk.cyan.bold('Creating new mx-agent project'));
|
|
73
|
-
console.log(chalk.dim('─'.repeat(50)));
|
|
74
|
-
console.log(` ${chalk.bold('Project name:')} ${projectName}`);
|
|
75
|
-
console.log(` ${chalk.bold('Directory:')} ${outputDir}`);
|
|
76
|
-
console.log();
|
|
77
|
-
// 4. Create directory
|
|
78
|
-
mkdirSync(outputDir, { recursive: true });
|
|
79
|
-
// 5. git init — force branch name to 'main' regardless of user's git.defaultBranch config.
|
|
80
|
-
// Using symbolic-ref after init is portable across all git versions (no -b flag needed).
|
|
81
|
-
console.log(chalk.dim(' Initialising git repository...'));
|
|
82
|
-
const gitInit = spawnSync('git', ['init', outputDir], { encoding: 'utf-8', stdio: 'pipe' });
|
|
83
|
-
if (gitInit.status !== 0) {
|
|
84
|
-
console.error(chalk.red(`Error: git init failed: ${gitInit.stderr}`));
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
// Rename default branch to 'main' before any commits so it matches mx-agent.config.json.
|
|
88
|
-
spawnSync('git', ['-C', outputDir, 'symbolic-ref', 'HEAD', 'refs/heads/main'], { stdio: 'pipe' });
|
|
89
|
-
console.log(chalk.green(' ✓ git init (branch: main)'));
|
|
90
|
-
// 6. .gitignore
|
|
91
|
-
writeFile(join(outputDir, '.gitignore'), newProjectGitignoreTemplate());
|
|
92
|
-
// 7. .devcontainer/
|
|
93
|
-
console.log();
|
|
94
|
-
console.log(chalk.dim(' Writing devcontainer...'));
|
|
95
|
-
writeFile(join(outputDir, '.devcontainer', 'Dockerfile'), newProjectDockerfileTemplate());
|
|
96
|
-
writeFile(join(outputDir, '.devcontainer', 'devcontainer.json'), newProjectDevcontainerJsonTemplate(projectName));
|
|
97
|
-
const postCreatePath = join(outputDir, '.devcontainer', 'post-create.sh');
|
|
98
|
-
writeFile(postCreatePath, newProjectPostCreateShTemplate(projectName));
|
|
99
|
-
try {
|
|
100
|
-
chmodSync(postCreatePath, 0o755);
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
/* non-fatal */
|
|
104
|
-
}
|
|
105
|
-
const postStartPath = join(outputDir, '.devcontainer', 'post-start.sh');
|
|
106
|
-
writeFile(postStartPath, newProjectPostStartShTemplate(projectName));
|
|
107
|
-
try {
|
|
108
|
-
chmodSync(postStartPath, 0o755);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
/* non-fatal */
|
|
112
|
-
}
|
|
113
|
-
// 8. mx-agent-system/ scaffold (reuse runInit with explicit projectRoot)
|
|
114
|
-
console.log();
|
|
115
|
-
console.log(chalk.dim(' Scaffolding mx-agent-system...'));
|
|
116
|
-
await runInit({
|
|
117
|
-
projectRoot: outputDir,
|
|
118
|
-
baseBranch: options.baseBranch,
|
|
119
|
-
worktreeDir: options.worktreeDir,
|
|
120
|
-
configSource: options.configSource,
|
|
121
|
-
force: false,
|
|
122
|
-
});
|
|
123
|
-
// 8b. Write team-builder roleguide so mx-agent start team-builder works out of the box
|
|
124
|
-
writeFile(join(outputDir, PROJECT_CONFIG_DEFAULTS.roleguidesDir, 'team-builder.md'), teamBuilderRoleguideTemplate());
|
|
125
|
-
// 9. Initial git commit
|
|
126
|
-
console.log();
|
|
127
|
-
console.log(chalk.dim(' Creating initial commit...'));
|
|
128
|
-
spawnSync('git', ['add', '-A'], { cwd: outputDir, stdio: 'pipe' });
|
|
129
|
-
const commit = spawnSync('git', ['commit', '-m', `feat: scaffold ${projectName} with mx-agent`], { cwd: outputDir, encoding: 'utf-8', stdio: 'pipe' });
|
|
130
|
-
if (commit.status === 0) {
|
|
131
|
-
console.log(chalk.green(' ✓ initial commit'));
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
console.log(chalk.yellow(' ⚠ initial commit skipped (git commit failed — set up git user config if needed)'));
|
|
135
|
-
}
|
|
136
|
-
// 10. Next steps
|
|
137
|
-
console.log();
|
|
138
|
-
console.log(chalk.green.bold('Project created!'));
|
|
139
|
-
console.log(chalk.dim('─'.repeat(50)));
|
|
140
|
-
console.log();
|
|
141
|
-
console.log(chalk.bold(' Next steps:'));
|
|
142
|
-
console.log(` 1. Open ${chalk.cyan(outputDir)} in VS Code`);
|
|
143
|
-
console.log(` 2. ${chalk.cyan('Dev Containers: Reopen in Container')} (or "Open Folder in Container")`);
|
|
144
|
-
console.log(` 3. Once the container has built, run:`);
|
|
145
|
-
console.log(` ${chalk.cyan('mx-agent start team-builder')}`);
|
|
146
|
-
console.log();
|
|
147
|
-
console.log(chalk.dim(' The team builder will guide you through creating your agent teams.'));
|
|
148
|
-
console.log();
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=new.js.map
|
package/dist/commands/new.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,EAClC,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,qBAAq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