@memnexus-ai/mx-agent-cli 0.1.19 → 0.1.21
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__/project-config.test.d.ts +2 -0
- package/dist/__tests__/project-config.test.d.ts.map +1 -0
- package/dist/__tests__/project-config.test.js +133 -0
- package/dist/__tests__/project-config.test.js.map +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +10 -8
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/init.d.ts +26 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +120 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +4 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +18 -16
- package/dist/commands/start.js.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/catalog.d.ts +5 -5
- package/dist/lib/catalog.d.ts.map +1 -1
- package/dist/lib/catalog.js +11 -11
- package/dist/lib/catalog.js.map +1 -1
- package/dist/lib/claude.d.ts +16 -8
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +43 -27
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/project-config.d.ts +38 -0
- package/dist/lib/project-config.d.ts.map +1 -0
- package/dist/lib/project-config.js +90 -0
- package/dist/lib/project-config.js.map +1 -0
- package/dist/lib/templates.d.ts +24 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +88 -0
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/worktree.d.ts +5 -5
- package/dist/lib/worktree.d.ts.map +1 -1
- package/dist/lib/worktree.js +36 -30
- package/dist/lib/worktree.js.map +1 -1
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { runUsage } from './commands/usage.js';
|
|
|
23
23
|
import { runUpdate } from './commands/update.js';
|
|
24
24
|
import { runPager } from './commands/pager.js';
|
|
25
25
|
import { runConfig } from './commands/config.js';
|
|
26
|
+
import { runInit } from './commands/init.js';
|
|
26
27
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
27
28
|
const require = createRequire(import.meta.url);
|
|
28
29
|
const pkg = require(join(__dirname, '../package.json'));
|
|
@@ -31,6 +32,20 @@ program
|
|
|
31
32
|
.name('mx-agent')
|
|
32
33
|
.description('CLI for creating and managing AI agent teams')
|
|
33
34
|
.version(pkg.version);
|
|
35
|
+
// ── init ───────────────────────────────────────────────────────────────
|
|
36
|
+
program
|
|
37
|
+
.command('init')
|
|
38
|
+
.description('Scaffold mx-agent-system/ for a new project')
|
|
39
|
+
.option('--force', 'Overwrite existing mx-agent.config.json and config files')
|
|
40
|
+
.option('--base-branch <branch>', 'Base branch (default: main)')
|
|
41
|
+
.option('--worktree-dir <path>', 'Worktrees directory (default: .worktrees)')
|
|
42
|
+
.option('--config-source <path>', 'Agent config path (default: mx-agent-system/agent-config)')
|
|
43
|
+
.action((opts) => {
|
|
44
|
+
runInit(opts).catch((err) => {
|
|
45
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
34
49
|
// ── create ─────────────────────────────────────────────────────────────
|
|
35
50
|
program
|
|
36
51
|
.command('create')
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAA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AS;KACN,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,oBAAoB,CAAC;KACjC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE;IACtB,SAAS,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEL,SAAS;KACN,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,wBAAwB,CAAC;KACrC,MAAM,CAAC,GAAG,EAAE;IACX,SAAS,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEL,SAAS;KACN,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,uBAAuB,CAAC;KACpC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE;IACtB,SAAS,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/lib/catalog.d.ts
CHANGED
|
@@ -28,22 +28,22 @@ export declare function parseTeamEntry(filePath: string): TeamEntry | null;
|
|
|
28
28
|
/**
|
|
29
29
|
* Return the path to the teams catalog directory.
|
|
30
30
|
*/
|
|
31
|
-
export declare function getTeamsCatalogDir(projectRoot: string): string;
|
|
31
|
+
export declare function getTeamsCatalogDir(projectRoot: string, teamsDir?: string): string;
|
|
32
32
|
/**
|
|
33
33
|
* Return the path to a specific team's catalog file.
|
|
34
34
|
*/
|
|
35
|
-
export declare function getTeamCatalogPath(projectRoot: string, slug: string): string;
|
|
35
|
+
export declare function getTeamCatalogPath(projectRoot: string, slug: string, teamsDir?: string): string;
|
|
36
36
|
/**
|
|
37
37
|
* List all teams from the catalog directory.
|
|
38
38
|
* Skips README.md.
|
|
39
39
|
*/
|
|
40
|
-
export declare function listTeams(projectRoot: string): TeamEntry[];
|
|
40
|
+
export declare function listTeams(projectRoot: string, teamsDir?: string): TeamEntry[];
|
|
41
41
|
/**
|
|
42
42
|
* Look up a single team entry by slug.
|
|
43
43
|
*/
|
|
44
|
-
export declare function getTeam(projectRoot: string, slug: string): TeamEntry | null;
|
|
44
|
+
export declare function getTeam(projectRoot: string, slug: string, teamsDir?: string): TeamEntry | null;
|
|
45
45
|
/**
|
|
46
46
|
* Write a team catalog entry (creates the file).
|
|
47
47
|
*/
|
|
48
|
-
export declare function writeTeamCatalog(projectRoot: string, entry: TeamEntry): void;
|
|
48
|
+
export declare function writeTeamCatalog(projectRoot: string, entry: TeamEntry, teamsDir?: string): void;
|
|
49
49
|
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/lib/catalog.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AASD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAW3D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA+BjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/lib/catalog.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AASD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAW3D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA+BjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAgC,GAAG,MAAM,CAE1G;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAgC,GAAG,MAAM,CAExH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAgC,GAAG,SAAS,EAAE,CAWtG;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAgC,GAAG,SAAS,GAAG,IAAI,CAIvH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,GAAE,MAAgC,GAAG,IAAI,CAKxH"}
|
package/dist/lib/catalog.js
CHANGED
|
@@ -68,21 +68,21 @@ export function parseTeamEntry(filePath) {
|
|
|
68
68
|
/**
|
|
69
69
|
* Return the path to the teams catalog directory.
|
|
70
70
|
*/
|
|
71
|
-
export function getTeamsCatalogDir(projectRoot) {
|
|
72
|
-
return join(projectRoot,
|
|
71
|
+
export function getTeamsCatalogDir(projectRoot, teamsDir = 'mx-agent-system/teams') {
|
|
72
|
+
return join(projectRoot, teamsDir);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Return the path to a specific team's catalog file.
|
|
76
76
|
*/
|
|
77
|
-
export function getTeamCatalogPath(projectRoot, slug) {
|
|
78
|
-
return join(getTeamsCatalogDir(projectRoot), `${slug}.md`);
|
|
77
|
+
export function getTeamCatalogPath(projectRoot, slug, teamsDir = 'mx-agent-system/teams') {
|
|
78
|
+
return join(getTeamsCatalogDir(projectRoot, teamsDir), `${slug}.md`);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* List all teams from the catalog directory.
|
|
82
82
|
* Skips README.md.
|
|
83
83
|
*/
|
|
84
|
-
export function listTeams(projectRoot) {
|
|
85
|
-
const dir = getTeamsCatalogDir(projectRoot);
|
|
84
|
+
export function listTeams(projectRoot, teamsDir = 'mx-agent-system/teams') {
|
|
85
|
+
const dir = getTeamsCatalogDir(projectRoot, teamsDir);
|
|
86
86
|
if (!existsSync(dir))
|
|
87
87
|
return [];
|
|
88
88
|
const files = readdirSync(dir).filter((f) => f.endsWith('.md') && f.toLowerCase() !== 'readme.md');
|
|
@@ -93,8 +93,8 @@ export function listTeams(projectRoot) {
|
|
|
93
93
|
/**
|
|
94
94
|
* Look up a single team entry by slug.
|
|
95
95
|
*/
|
|
96
|
-
export function getTeam(projectRoot, slug) {
|
|
97
|
-
const path = getTeamCatalogPath(projectRoot, slug);
|
|
96
|
+
export function getTeam(projectRoot, slug, teamsDir = 'mx-agent-system/teams') {
|
|
97
|
+
const path = getTeamCatalogPath(projectRoot, slug, teamsDir);
|
|
98
98
|
if (!existsSync(path))
|
|
99
99
|
return null;
|
|
100
100
|
return parseTeamEntry(path);
|
|
@@ -102,11 +102,11 @@ export function getTeam(projectRoot, slug) {
|
|
|
102
102
|
/**
|
|
103
103
|
* Write a team catalog entry (creates the file).
|
|
104
104
|
*/
|
|
105
|
-
export function writeTeamCatalog(projectRoot, entry) {
|
|
106
|
-
const dir = getTeamsCatalogDir(projectRoot);
|
|
105
|
+
export function writeTeamCatalog(projectRoot, entry, teamsDir = 'mx-agent-system/teams') {
|
|
106
|
+
const dir = getTeamsCatalogDir(projectRoot, teamsDir);
|
|
107
107
|
if (!existsSync(dir))
|
|
108
108
|
mkdirSync(dir, { recursive: true });
|
|
109
|
-
const path = getTeamCatalogPath(projectRoot, entry.slug);
|
|
109
|
+
const path = getTeamCatalogPath(projectRoot, entry.slug, teamsDir);
|
|
110
110
|
writeFileSync(path, serializeTeamEntry(entry));
|
|
111
111
|
}
|
|
112
112
|
//# sourceMappingURL=catalog.js.map
|
package/dist/lib/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/lib/catalog.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAatC;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAgB;IACjD,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7E,OAAO,WA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AI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,KAAgB,EAAE,WAAmB,uBAAuB;IAChH,MAAM,GAAG,GAAG,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,kBAAkB,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnE,aAAa,CAAC,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/lib/claude.d.ts
CHANGED
|
@@ -9,10 +9,15 @@ export declare function logDim(msg: string): void;
|
|
|
9
9
|
* Deploy CLAUDE.md into the worktree from the template.
|
|
10
10
|
*
|
|
11
11
|
* Template resolution order:
|
|
12
|
-
* 1.
|
|
13
|
-
* 2. CLAUDE.md
|
|
12
|
+
* 1. origin/<baseBranch>:<configSource>/CLAUDE.md.template via git show
|
|
13
|
+
* 2. Local <configSource>/CLAUDE.md.template — offline fallback
|
|
14
|
+
* 3. Local dev-tools/worktree-cli/templates/CLAUDE.md.template — legacy fallback
|
|
15
|
+
* 4. Root CLAUDE.md
|
|
14
16
|
*/
|
|
15
|
-
export declare function deployClaudeMd(projectRoot: string, worktreePath: string
|
|
17
|
+
export declare function deployClaudeMd(projectRoot: string, worktreePath: string, opts?: {
|
|
18
|
+
baseBranch?: string;
|
|
19
|
+
configSource?: string;
|
|
20
|
+
}): void;
|
|
16
21
|
/**
|
|
17
22
|
* Write CLAUDE.local.md into the worktree with isolation context.
|
|
18
23
|
* Matches the format produced by writeWorktreeClaudeLocal in operations.ts.
|
|
@@ -29,15 +34,18 @@ export declare function writeClaudeLocal(opts: {
|
|
|
29
34
|
}): void;
|
|
30
35
|
/**
|
|
31
36
|
* Sync .claude/settings.json and .claude/hooks/worktree-guard.sh from the
|
|
32
|
-
* platform team's canonical source:
|
|
37
|
+
* platform team's canonical source: <configSource>/ on origin/<baseBranch>.
|
|
33
38
|
*
|
|
34
|
-
* Uses `git show origin
|
|
35
|
-
* remote object store — no checkout/unstage dance, no staged files left behind.
|
|
39
|
+
* Uses `git show origin/<baseBranch>:<path>` to read file content directly from
|
|
40
|
+
* the remote object store — no checkout/unstage dance, no staged files left behind.
|
|
36
41
|
*
|
|
37
|
-
* Source of truth for all agent configuration is
|
|
42
|
+
* Source of truth for all agent configuration is <configSource>/.
|
|
38
43
|
* Changes to agent permissions or hooks must go through a platform team PR.
|
|
39
44
|
*/
|
|
40
|
-
export declare function syncClaudeConfig(worktreePath: string
|
|
45
|
+
export declare function syncClaudeConfig(worktreePath: string, opts?: {
|
|
46
|
+
baseBranch?: string;
|
|
47
|
+
configSource?: string;
|
|
48
|
+
}): void;
|
|
41
49
|
/**
|
|
42
50
|
* Exec into a Claude session in the worktree with the given initial prompt.
|
|
43
51
|
* Uses spawnSync so Claude replaces the current process cleanly.
|
package/dist/lib/claude.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExC;AAID
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExC;AAID;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,IAAI,CAwEN;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,IAAI,CAmDP;AAID;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,IAAI,CAqDN;AAsDD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAoCP"}
|
package/dist/lib/claude.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* CLAUDE.md deployment, CLAUDE.local.md generation, and session start.
|
|
3
3
|
* Mirrors the patterns in dev-tools/worktree-cli/src/operations.ts.
|
|
4
4
|
*/
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import { execSync, spawnSync } from 'child_process';
|
|
8
8
|
import chalk from 'chalk';
|
|
@@ -21,10 +21,14 @@ export function logDim(msg) {
|
|
|
21
21
|
* Deploy CLAUDE.md into the worktree from the template.
|
|
22
22
|
*
|
|
23
23
|
* Template resolution order:
|
|
24
|
-
* 1.
|
|
25
|
-
* 2. CLAUDE.md
|
|
24
|
+
* 1. origin/<baseBranch>:<configSource>/CLAUDE.md.template via git show
|
|
25
|
+
* 2. Local <configSource>/CLAUDE.md.template — offline fallback
|
|
26
|
+
* 3. Local dev-tools/worktree-cli/templates/CLAUDE.md.template — legacy fallback
|
|
27
|
+
* 4. Root CLAUDE.md
|
|
26
28
|
*/
|
|
27
|
-
export function deployClaudeMd(projectRoot, worktreePath) {
|
|
29
|
+
export function deployClaudeMd(projectRoot, worktreePath, opts = {}) {
|
|
30
|
+
const baseBranch = opts.baseBranch ?? 'main';
|
|
31
|
+
const configSource = opts.configSource ?? 'mx-agent-system/agent-config';
|
|
28
32
|
const claudeMdPath = join(worktreePath, 'CLAUDE.md');
|
|
29
33
|
// Handle transition: untrack from git index if still tracked
|
|
30
34
|
try {
|
|
@@ -41,23 +45,21 @@ export function deployClaudeMd(projectRoot, worktreePath) {
|
|
|
41
45
|
catch {
|
|
42
46
|
// Not tracked or error — fine
|
|
43
47
|
}
|
|
44
|
-
// Template resolution order:
|
|
45
|
-
// 1. origin/main:mx-agent-system/agent-config/CLAUDE.md.template via git show
|
|
46
|
-
// — canonical remote source, immune to local filesystem tampering (SF-7 fix)
|
|
47
|
-
// 2. Local mx-agent-system/agent-config/CLAUDE.md.template — offline fallback
|
|
48
|
-
// 3. Local dev-tools/worktree-cli/templates/CLAUDE.md.template — legacy fallback
|
|
49
|
-
// 4. Root CLAUDE.md
|
|
50
48
|
let content = null;
|
|
51
|
-
// Prefer reading from origin
|
|
49
|
+
// Prefer reading from origin/<baseBranch> via git show to avoid local tampering
|
|
52
50
|
try {
|
|
53
|
-
|
|
51
|
+
const r = spawnSync('git', ['show', `origin/${baseBranch}:${configSource}/CLAUDE.md.template`], {
|
|
52
|
+
cwd: worktreePath, encoding: 'utf-8', stdio: 'pipe',
|
|
53
|
+
});
|
|
54
|
+
if (r.status === 0 && r.stdout)
|
|
55
|
+
content = r.stdout;
|
|
54
56
|
}
|
|
55
57
|
catch {
|
|
56
58
|
// git show failed (offline or path missing) — fall through to local paths
|
|
57
59
|
}
|
|
58
60
|
if (!content) {
|
|
59
61
|
const localCandidates = [
|
|
60
|
-
join(projectRoot, '
|
|
62
|
+
join(projectRoot, configSource, 'CLAUDE.md.template'),
|
|
61
63
|
join(projectRoot, 'dev-tools/worktree-cli/templates/CLAUDE.md.template'),
|
|
62
64
|
];
|
|
63
65
|
for (const templatePath of localCandidates) {
|
|
@@ -157,21 +159,25 @@ Today's date is ${new Date().toISOString().slice(0, 10)}.
|
|
|
157
159
|
// ── Claude config sync ────────────────────────────────────────────────
|
|
158
160
|
/**
|
|
159
161
|
* Sync .claude/settings.json and .claude/hooks/worktree-guard.sh from the
|
|
160
|
-
* platform team's canonical source:
|
|
162
|
+
* platform team's canonical source: <configSource>/ on origin/<baseBranch>.
|
|
161
163
|
*
|
|
162
|
-
* Uses `git show origin
|
|
163
|
-
* remote object store — no checkout/unstage dance, no staged files left behind.
|
|
164
|
+
* Uses `git show origin/<baseBranch>:<path>` to read file content directly from
|
|
165
|
+
* the remote object store — no checkout/unstage dance, no staged files left behind.
|
|
164
166
|
*
|
|
165
|
-
* Source of truth for all agent configuration is
|
|
167
|
+
* Source of truth for all agent configuration is <configSource>/.
|
|
166
168
|
* Changes to agent permissions or hooks must go through a platform team PR.
|
|
167
169
|
*/
|
|
168
|
-
export function syncClaudeConfig(worktreePath) {
|
|
169
|
-
|
|
170
|
+
export function syncClaudeConfig(worktreePath, opts = {}) {
|
|
171
|
+
const baseBranch = opts.baseBranch ?? 'main';
|
|
172
|
+
const configSource = opts.configSource ?? 'mx-agent-system/agent-config';
|
|
173
|
+
logDim(`Syncing agent config from ${configSource}/ (origin/${baseBranch})...`);
|
|
170
174
|
try {
|
|
171
|
-
|
|
175
|
+
const r = spawnSync('git', ['fetch', 'origin', baseBranch, '--quiet'], { cwd: worktreePath, stdio: 'pipe' });
|
|
176
|
+
if (r.status !== 0)
|
|
177
|
+
throw new Error('fetch failed');
|
|
172
178
|
}
|
|
173
179
|
catch {
|
|
174
|
-
logWarning(
|
|
180
|
+
logWarning(`Could not fetch origin/${baseBranch} — using existing agent config`);
|
|
175
181
|
return;
|
|
176
182
|
}
|
|
177
183
|
// Ensure .claude/hooks/ exists in the worktree
|
|
@@ -180,26 +186,36 @@ export function syncClaudeConfig(worktreePath) {
|
|
|
180
186
|
let synced = 0;
|
|
181
187
|
// settings.json
|
|
182
188
|
try {
|
|
183
|
-
const
|
|
189
|
+
const r = spawnSync('git', ['show', `origin/${baseBranch}:${configSource}/settings.json`], {
|
|
190
|
+
cwd: worktreePath, encoding: 'utf-8', stdio: 'pipe',
|
|
191
|
+
});
|
|
192
|
+
if (r.status !== 0 || !r.stdout)
|
|
193
|
+
throw new Error('git show failed');
|
|
194
|
+
const content = r.stdout;
|
|
184
195
|
writeFileSync(join(worktreePath, '.claude', 'settings.json'), content);
|
|
185
196
|
synced++;
|
|
186
197
|
}
|
|
187
198
|
catch {
|
|
188
|
-
logWarning(
|
|
199
|
+
logWarning(`Could not sync settings.json from ${configSource}/`);
|
|
189
200
|
}
|
|
190
201
|
// worktree-guard.sh
|
|
191
202
|
try {
|
|
192
|
-
const
|
|
203
|
+
const r = spawnSync('git', ['show', `origin/${baseBranch}:${configSource}/hooks/worktree-guard.sh`], {
|
|
204
|
+
cwd: worktreePath, encoding: 'utf-8', stdio: 'pipe',
|
|
205
|
+
});
|
|
206
|
+
if (r.status !== 0 || !r.stdout)
|
|
207
|
+
throw new Error('git show failed');
|
|
208
|
+
const content = r.stdout;
|
|
193
209
|
const guardPath = join(worktreePath, '.claude', 'hooks', 'worktree-guard.sh');
|
|
194
210
|
writeFileSync(guardPath, content);
|
|
195
|
-
|
|
211
|
+
chmodSync(guardPath, 0o755);
|
|
196
212
|
synced++;
|
|
197
213
|
}
|
|
198
214
|
catch {
|
|
199
|
-
logWarning(
|
|
215
|
+
logWarning(`Could not sync worktree-guard.sh from ${configSource}/`);
|
|
200
216
|
}
|
|
201
217
|
if (synced === 2) {
|
|
202
|
-
logSuccess(
|
|
218
|
+
logSuccess(`Agent config synced from ${configSource}/`);
|
|
203
219
|
}
|
|
204
220
|
else if (synced > 0) {
|
|
205
221
|
logWarning(`Partial sync: ${synced}/2 config files updated`);
|
package/dist/lib/claude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,yEAAyE;AAEzE,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;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. All fields are optional;
|
|
5
|
+
* absence of the file or any field falls back to the hardcoded defaults that
|
|
6
|
+
* match the existing MemNexus monorepo layout — zero behavioral change for
|
|
7
|
+
* projects that don't have a config file.
|
|
8
|
+
*/
|
|
9
|
+
export interface ProjectConfig {
|
|
10
|
+
/** Base branch for git operations (default: 'main') */
|
|
11
|
+
baseBranch?: string;
|
|
12
|
+
/** Directory under projectRoot where worktrees are stored (default: '.worktrees') */
|
|
13
|
+
worktreeDir?: string;
|
|
14
|
+
/** Path under projectRoot to the agent-config directory (default: 'mx-agent-system/agent-config') */
|
|
15
|
+
configSource?: string;
|
|
16
|
+
/** Path under projectRoot to the teams catalog directory (default: 'mx-agent-system/teams') */
|
|
17
|
+
teamsDir?: string;
|
|
18
|
+
/** Path under projectRoot to the roleguides directory (default: 'mx-agent-system/roleguides') */
|
|
19
|
+
roleguidesDir?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const PROJECT_CONFIG_DEFAULTS: Required<ProjectConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Read mx-agent.config.json from projectRoot.
|
|
24
|
+
*
|
|
25
|
+
* Returns null if the file is absent or cannot be parsed — never throws for
|
|
26
|
+
* parse errors. Validation errors (shell metacharacters, path traversal) are
|
|
27
|
+
* intentionally surfaced to the caller so malicious config values are visible.
|
|
28
|
+
* Unknown keys are silently ignored; only known ProjectConfig fields are returned.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadProjectConfig(projectRoot: string): ProjectConfig | null;
|
|
31
|
+
/**
|
|
32
|
+
* Merge a partial ProjectConfig over the defaults.
|
|
33
|
+
*
|
|
34
|
+
* This is the primary caller API — always returns a fully populated config
|
|
35
|
+
* with every field guaranteed to be a string.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveProjectConfig(c: ProjectConfig | null): Required<ProjectConfig>;
|
|
38
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,aAAa,CAM3D,CAAC;AA4BF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAoB3E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAQrF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project-level configuration for mx-agent.
|
|
3
|
+
*
|
|
4
|
+
* Reads mx-agent.config.json from the project root. All fields are optional;
|
|
5
|
+
* absence of the file or any field falls back to the hardcoded defaults that
|
|
6
|
+
* match the existing MemNexus monorepo layout — zero behavioral change for
|
|
7
|
+
* projects that don't have a config file.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readFileSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
export const PROJECT_CONFIG_DEFAULTS = {
|
|
12
|
+
baseBranch: 'main',
|
|
13
|
+
worktreeDir: '.worktrees',
|
|
14
|
+
configSource: 'mx-agent-system/agent-config',
|
|
15
|
+
teamsDir: 'mx-agent-system/teams',
|
|
16
|
+
roleguidesDir: 'mx-agent-system/roleguides',
|
|
17
|
+
};
|
|
18
|
+
/** Characters that must not appear in config values used in shell commands */
|
|
19
|
+
const SHELL_UNSAFE_RE = /[;|&`$(){}!#\\<>\n\r\x00]/;
|
|
20
|
+
/**
|
|
21
|
+
* Validate that config field values are safe for use in shell commands and path joins.
|
|
22
|
+
* Throws a descriptive error if any field contains disallowed characters.
|
|
23
|
+
* Called by loadProjectConfig before returning — never throws from outside this module.
|
|
24
|
+
*/
|
|
25
|
+
function validateProjectConfig(config) {
|
|
26
|
+
for (const [key, value] of Object.entries(config)) {
|
|
27
|
+
if (typeof value !== 'string')
|
|
28
|
+
continue;
|
|
29
|
+
if (SHELL_UNSAFE_RE.test(value)) {
|
|
30
|
+
throw new Error(`mx-agent.config.json: "${key}" contains disallowed characters. ` +
|
|
31
|
+
`Only alphanumeric characters, hyphens, underscores, dots, and forward slashes are permitted.`);
|
|
32
|
+
}
|
|
33
|
+
if (value.includes('..')) {
|
|
34
|
+
throw new Error(`mx-agent.config.json: "${key}" must not contain ".." (path traversal not allowed).`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read mx-agent.config.json from projectRoot.
|
|
41
|
+
*
|
|
42
|
+
* Returns null if the file is absent or cannot be parsed — never throws for
|
|
43
|
+
* parse errors. Validation errors (shell metacharacters, path traversal) are
|
|
44
|
+
* intentionally surfaced to the caller so malicious config values are visible.
|
|
45
|
+
* Unknown keys are silently ignored; only known ProjectConfig fields are returned.
|
|
46
|
+
*/
|
|
47
|
+
export function loadProjectConfig(projectRoot) {
|
|
48
|
+
const configPath = join(projectRoot, 'mx-agent.config.json');
|
|
49
|
+
if (!existsSync(configPath))
|
|
50
|
+
return null;
|
|
51
|
+
let config;
|
|
52
|
+
try {
|
|
53
|
+
const raw = readFileSync(configPath, 'utf-8');
|
|
54
|
+
const parsed = JSON.parse(raw);
|
|
55
|
+
config = {};
|
|
56
|
+
if (typeof parsed.baseBranch === 'string')
|
|
57
|
+
config.baseBranch = parsed.baseBranch;
|
|
58
|
+
if (typeof parsed.worktreeDir === 'string')
|
|
59
|
+
config.worktreeDir = parsed.worktreeDir;
|
|
60
|
+
if (typeof parsed.configSource === 'string')
|
|
61
|
+
config.configSource = parsed.configSource;
|
|
62
|
+
if (typeof parsed.teamsDir === 'string')
|
|
63
|
+
config.teamsDir = parsed.teamsDir;
|
|
64
|
+
if (typeof parsed.roleguidesDir === 'string')
|
|
65
|
+
config.roleguidesDir = parsed.roleguidesDir;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// Validation errors are intentionally NOT silenced — malicious config values should
|
|
71
|
+
// be surfaced to the user, not quietly ignored.
|
|
72
|
+
validateProjectConfig(config);
|
|
73
|
+
return config;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Merge a partial ProjectConfig over the defaults.
|
|
77
|
+
*
|
|
78
|
+
* This is the primary caller API — always returns a fully populated config
|
|
79
|
+
* with every field guaranteed to be a string.
|
|
80
|
+
*/
|
|
81
|
+
export function resolveProjectConfig(c) {
|
|
82
|
+
return {
|
|
83
|
+
baseBranch: c?.baseBranch ?? PROJECT_CONFIG_DEFAULTS.baseBranch,
|
|
84
|
+
worktreeDir: c?.worktreeDir ?? PROJECT_CONFIG_DEFAULTS.worktreeDir,
|
|
85
|
+
configSource: c?.configSource ?? PROJECT_CONFIG_DEFAULTS.configSource,
|
|
86
|
+
teamsDir: c?.teamsDir ?? PROJECT_CONFIG_DEFAULTS.teamsDir,
|
|
87
|
+
roleguidesDir: c?.roleguidesDir ?? PROJECT_CONFIG_DEFAULTS.roleguidesDir,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAA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C,UAAU,KAAK,QAAQ;YAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACjF,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;YAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACpF,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ;YAAE,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACvF,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;YAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC3E,IAAI,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;YAAE,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;IAC5F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,oFAAoF;IACpF,gDAAgD;IAChD,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,CAAuB;IAC1D,OAAO;QACL,UAAU,EAAE,CAAC,EAAE,UAAU,IAAI,uBAAuB,CAAC,UAAU;QAC/D,WAAW,EAAE,CAAC,EAAE,WAAW,IAAI,uBAAuB,CAAC,WAAW;QAClE,YAAY,EAAE,CAAC,EAAE,YAAY,IAAI,uBAAuB,CAAC,YAAY;QACrE,QAAQ,EAAE,CAAC,EAAE,QAAQ,IAAI,uBAAuB,CAAC,QAAQ;QACzD,aAAa,EAAE,CAAC,EAAE,aAAa,IAAI,uBAAuB,CAAC,aAAa;KACzE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded template strings used by `mx-agent init`.
|
|
3
|
+
*
|
|
4
|
+
* These are inline string constants — no file bundling, no network calls.
|
|
5
|
+
* They provide minimal-but-valid stubs that a user can customise after init.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Minimal settings.json for Claude Code agent permissions.
|
|
9
|
+
* Grants bash access and restricts to the worktree directory.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SETTINGS_JSON_TEMPLATE: string;
|
|
12
|
+
/**
|
|
13
|
+
* Stub worktree-guard.sh hook.
|
|
14
|
+
* Blocks branch switching to main and force-pushes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const WORKTREE_GUARD_SH_TEMPLATE = "#!/usr/bin/env bash\n# worktree-guard.sh \u2014 Claude Code PreToolUse hook\n# Blocks dangerous git operations in worktrees.\n# Customise this file for your project's safety requirements.\n\nset -euo pipefail\n\nTOOL_NAME=\"${CLAUDE_TOOL_NAME:-}\"\nTOOL_INPUT=\"${CLAUDE_TOOL_INPUT:-}\"\n\nif [[ \"$TOOL_NAME\" != \"Bash\" ]]; then\n exit 0\nfi\n\n# Block checkout/switch to base branch\nif echo \"$TOOL_INPUT\" | grep -qE 'git (checkout|switch) (main|master|develop)'; then\n echo \"Blocked: cannot switch to base branch from a worktree.\" >&2\n exit 1\nfi\n\n# Block force push to base branch\nif echo \"$TOOL_INPUT\" | grep -qE 'git push .*(--force|-f).*(main|master|develop)'; then\n echo \"Blocked: force push to base branch is not allowed.\" >&2\n exit 1\nfi\n\nexit 0\n";
|
|
17
|
+
/**
|
|
18
|
+
* Stub CLAUDE.md.template — the template that gets deployed into each worktree
|
|
19
|
+
* as CLAUDE.md when running mx-agent create / mx-agent start.
|
|
20
|
+
*
|
|
21
|
+
* Users should replace this with project-specific instructions.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CLAUDE_MD_TEMPLATE = "# Agent Instructions\n\nThis file is deployed automatically into each agent worktree by `mx-agent`.\nReplace the contents below with your project-specific agent instructions.\n\n## Project Overview\n\n<!-- Describe your project here -->\n\n## Workflow\n\n<!-- Describe the expected workflow for agents -->\n\n## Rules\n\n1. Stay within your worktree directory.\n2. Do not push to the base branch directly \u2014 create a PR.\n3. Follow the project's coding conventions.\n";
|
|
24
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAuBlC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,kxBA2BtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,4dAkB9B,CAAC"}
|