cofounder-crew 0.1.0
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 +206 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +249 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/codex.d.ts +8 -0
- package/dist/src/codex.js +335 -0
- package/dist/src/codex.js.map +1 -0
- package/dist/src/codexConfig.d.ts +10 -0
- package/dist/src/codexConfig.js +136 -0
- package/dist/src/codexConfig.js.map +1 -0
- package/dist/src/codexSessions.d.ts +5 -0
- package/dist/src/codexSessions.js +100 -0
- package/dist/src/codexSessions.js.map +1 -0
- package/dist/src/config.d.ts +14 -0
- package/dist/src/config.js +154 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/errors.d.ts +4 -0
- package/dist/src/errors.js +12 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/git.d.ts +15 -0
- package/dist/src/git.js +151 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/init.d.ts +8 -0
- package/dist/src/init.js +43 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/mcp.d.ts +4 -0
- package/dist/src/mcp.js +159 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/memberRuntime.d.ts +13 -0
- package/dist/src/memberRuntime.js +70 -0
- package/dist/src/memberRuntime.js.map +1 -0
- package/dist/src/paths.d.ts +7 -0
- package/dist/src/paths.js +36 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/prompt.d.ts +2 -0
- package/dist/src/prompt.js +59 -0
- package/dist/src/prompt.js.map +1 -0
- package/dist/src/runtime.d.ts +50 -0
- package/dist/src/runtime.js +362 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/setup.d.ts +6 -0
- package/dist/src/setup.js +48 -0
- package/dist/src/setup.js.map +1 -0
- package/dist/src/tasks.d.ts +10 -0
- package/dist/src/tasks.js +130 -0
- package/dist/src/tasks.js.map +1 -0
- package/dist/src/templates.d.ts +15 -0
- package/dist/src/templates.js +158 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/types.d.ts +141 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/worker.d.ts +2 -0
- package/dist/src/worker.js +17 -0
- package/dist/src/worker.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parse as parseToml } from "smol-toml";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
import { assertCondition, CofounderError } from "./errors.js";
|
|
6
|
+
import { configRoot, findProjectRoot, fromConfigRoot, pathExists } from "./paths.js";
|
|
7
|
+
export async function loadProject(startDir = process.cwd()) {
|
|
8
|
+
const projectRoot = await findProjectRoot(startDir);
|
|
9
|
+
assertCondition(projectRoot, `Missing .cofounder/team.yaml in ${path.resolve(startDir)} or its parents`);
|
|
10
|
+
const root = configRoot(projectRoot);
|
|
11
|
+
const teamPath = path.join(root, "team.yaml");
|
|
12
|
+
const raw = await readFile(teamPath, "utf8");
|
|
13
|
+
const parsed = YAML.parse(raw);
|
|
14
|
+
const team = normalizeTeamFile(parsed);
|
|
15
|
+
await validateMemberFiles(projectRoot, team);
|
|
16
|
+
return {
|
|
17
|
+
projectRoot,
|
|
18
|
+
configRoot: root,
|
|
19
|
+
team
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export async function loadMemberSettings(project, member) {
|
|
23
|
+
const settingsPath = fromConfigRoot(project.projectRoot, member.settings);
|
|
24
|
+
const raw = await readFile(settingsPath, "utf8");
|
|
25
|
+
return parseToml(raw);
|
|
26
|
+
}
|
|
27
|
+
export function getMemberPaths(project, member) {
|
|
28
|
+
const promptAbsolutePath = fromConfigRoot(project.projectRoot, member.prompt);
|
|
29
|
+
const settingsAbsolutePath = fromConfigRoot(project.projectRoot, member.settings);
|
|
30
|
+
const homeAbsolutePath = member.home ? fromConfigRoot(project.projectRoot, member.home) : null;
|
|
31
|
+
return {
|
|
32
|
+
promptPath: path.relative(project.projectRoot, promptAbsolutePath),
|
|
33
|
+
settingsPath: path.relative(project.projectRoot, settingsAbsolutePath),
|
|
34
|
+
homePath: homeAbsolutePath ? path.relative(project.projectRoot, homeAbsolutePath) : null,
|
|
35
|
+
promptAbsolutePath,
|
|
36
|
+
settingsAbsolutePath,
|
|
37
|
+
homeAbsolutePath
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function getMember(project, memberId) {
|
|
41
|
+
const member = project.team.members[memberId];
|
|
42
|
+
if (!member) {
|
|
43
|
+
throw new CofounderError(`Unknown team member: ${memberId}`);
|
|
44
|
+
}
|
|
45
|
+
return member;
|
|
46
|
+
}
|
|
47
|
+
export function assertCanCall(project, callerId, assigneeId) {
|
|
48
|
+
if (callerId === assigneeId) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const caller = getMember(project, callerId);
|
|
52
|
+
if (!caller.can_call.includes(assigneeId)) {
|
|
53
|
+
throw new CofounderError(`${callerId} is not allowed to call ${assigneeId}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function summarizeTeam(project) {
|
|
57
|
+
return Object.entries(project.team.members)
|
|
58
|
+
.map(([id, member]) => {
|
|
59
|
+
const responsibilities = member.responsibilities.map((item) => ` - ${item}`).join("\n");
|
|
60
|
+
const canCall = member.can_call.length > 0 ? member.can_call.join(", ") : "none";
|
|
61
|
+
return `- ${id}: ${member.title}\n Responsibilities:\n${responsibilities}\n Can call: ${canCall}`;
|
|
62
|
+
})
|
|
63
|
+
.join("\n\n");
|
|
64
|
+
}
|
|
65
|
+
function normalizeTeamFile(input) {
|
|
66
|
+
assertCondition(isRecord(input), "team.yaml must be a YAML object");
|
|
67
|
+
assertCondition(input.version === 1, "team.yaml version must be 1");
|
|
68
|
+
assertCondition(isRecord(input.members), "team.yaml must define members");
|
|
69
|
+
const defaults = isRecord(input.defaults) ? input.defaults : {};
|
|
70
|
+
const defaultRunner = normalizeRunner(defaults.runner ?? "codex");
|
|
71
|
+
const members = {};
|
|
72
|
+
for (const [id, rawMember] of Object.entries(input.members)) {
|
|
73
|
+
assertCondition(isRecord(rawMember), `Member ${id} must be an object`);
|
|
74
|
+
const runner = normalizeRunner(rawMember.runner ?? defaultRunner);
|
|
75
|
+
const title = stringField(rawMember, "title", id);
|
|
76
|
+
const prompt = stringField(rawMember, "prompt", id);
|
|
77
|
+
const settings = stringField(rawMember, "settings", id);
|
|
78
|
+
const responsibilities = stringListField(rawMember, "responsibilities", id);
|
|
79
|
+
const can_call = optionalStringListField(rawMember, "can_call", id);
|
|
80
|
+
const home = optionalStringField(rawMember, "home", id);
|
|
81
|
+
members[id] = {
|
|
82
|
+
id,
|
|
83
|
+
title,
|
|
84
|
+
runner,
|
|
85
|
+
prompt,
|
|
86
|
+
settings,
|
|
87
|
+
home,
|
|
88
|
+
responsibilities,
|
|
89
|
+
can_call
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
version: 1,
|
|
94
|
+
team: isRecord(input.team) ? {
|
|
95
|
+
id: optionalStringValue(input.team.id),
|
|
96
|
+
name: optionalStringValue(input.team.name)
|
|
97
|
+
} : undefined,
|
|
98
|
+
defaults: {
|
|
99
|
+
runner: defaultRunner,
|
|
100
|
+
cwd: defaults.cwd === "inherit" || defaults.cwd === undefined ? "inherit" : undefined,
|
|
101
|
+
run_mode: defaults.run_mode === "sync" || defaults.run_mode === "async" ? defaults.run_mode : undefined
|
|
102
|
+
},
|
|
103
|
+
members
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async function validateMemberFiles(projectRoot, team) {
|
|
107
|
+
for (const member of Object.values(team.members)) {
|
|
108
|
+
const promptPath = fromConfigRoot(projectRoot, member.prompt);
|
|
109
|
+
const settingsPath = fromConfigRoot(projectRoot, member.settings);
|
|
110
|
+
assertCondition(await pathExists(promptPath), `Prompt file missing for ${member.id}: ${member.prompt}`);
|
|
111
|
+
assertCondition(await pathExists(settingsPath), `Settings file missing for ${member.id}: ${member.settings}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function normalizeRunner(value) {
|
|
115
|
+
if (value !== "codex") {
|
|
116
|
+
throw new CofounderError(`Unsupported runner "${String(value)}"; MVP supports only "codex"`);
|
|
117
|
+
}
|
|
118
|
+
return "codex";
|
|
119
|
+
}
|
|
120
|
+
function stringField(record, field, memberId) {
|
|
121
|
+
const value = record[field];
|
|
122
|
+
assertCondition(typeof value === "string" && value.length > 0, `Member ${memberId} must define ${field}`);
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
function optionalStringField(record, field, memberId) {
|
|
126
|
+
const value = record[field];
|
|
127
|
+
if (value === undefined) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
assertCondition(typeof value === "string" && value.length > 0, `Member ${memberId} field ${field} must be a string`);
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
function stringListField(record, field, memberId) {
|
|
134
|
+
const value = record[field];
|
|
135
|
+
assertCondition(Array.isArray(value), `Member ${memberId} must define ${field} as a list`);
|
|
136
|
+
assertCondition(value.every((item) => typeof item === "string"), `Member ${memberId} field ${field} must contain only strings`);
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
function optionalStringListField(record, field, memberId) {
|
|
140
|
+
const value = record[field];
|
|
141
|
+
if (value === undefined) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
assertCondition(Array.isArray(value), `Member ${memberId} field ${field} must be a list`);
|
|
145
|
+
assertCondition(value.every((item) => typeof item === "string"), `Member ${memberId} field ${field} must contain only strings`);
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
function optionalStringValue(value) {
|
|
149
|
+
return typeof value === "string" ? value : undefined;
|
|
150
|
+
}
|
|
151
|
+
function isRecord(value) {
|
|
152
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
153
|
+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O,KAAK,CAAC;AACf,CAAC;AAED,SAAS,uBAAuB,CAAC,MAA+B,EAAE,KAAa,EAAE,QAAgB;IAC/F,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,UAAU,QAAQ,UAAU,KAAK,iBAAiB,CAAC,CAAC;IAC1F,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,UAAU,QAAQ,UAAU,KAAK,4BAA4B,CAAC,CAAC;IAChI,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class CofounderError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "CofounderError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function assertCondition(condition, message) {
|
|
8
|
+
if (!condition) {
|
|
9
|
+
throw new CofounderError(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,eAAe,CAAC,SAAkB,EAAE,OAAe;IACjE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GitSnapshot {
|
|
2
|
+
available: boolean;
|
|
3
|
+
files: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface GitPatch {
|
|
6
|
+
patch: string;
|
|
7
|
+
files: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function readGitSnapshot(cwd: string): Promise<GitSnapshot>;
|
|
10
|
+
export declare function createGitWorktree(projectRoot: string, worktreePath: string): Promise<void>;
|
|
11
|
+
export declare function createWorktreePatch(worktreePath: string): Promise<GitPatch>;
|
|
12
|
+
export declare function checkGitPatch(projectRoot: string, patch: string): Promise<void>;
|
|
13
|
+
export declare function applyGitPatch(projectRoot: string, patch: string): Promise<void>;
|
|
14
|
+
export declare function diffChangedFiles(before: string[], after: string[]): string[];
|
|
15
|
+
export declare function mergeFiles(...groups: string[][]): string[];
|
package/dist/src/git.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { CofounderError } from "./errors.js";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
export async function readGitSnapshot(cwd) {
|
|
8
|
+
try {
|
|
9
|
+
const { stdout } = await execFileAsync("git", ["status", "--porcelain=v1", "-z"], {
|
|
10
|
+
cwd,
|
|
11
|
+
maxBuffer: 10 * 1024 * 1024
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
available: true,
|
|
15
|
+
files: parsePorcelainFiles(stdout)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return {
|
|
20
|
+
available: false,
|
|
21
|
+
files: []
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function createGitWorktree(projectRoot, worktreePath) {
|
|
26
|
+
try {
|
|
27
|
+
await execFileAsync("git", ["rev-parse", "--verify", "HEAD"], {
|
|
28
|
+
cwd: projectRoot
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new CofounderError("worktree write mode requires a Git repository with at least one commit");
|
|
33
|
+
}
|
|
34
|
+
await mkdir(path.dirname(worktreePath), { recursive: true });
|
|
35
|
+
try {
|
|
36
|
+
await execFileAsync("git", ["worktree", "add", "--detach", worktreePath, "HEAD"], {
|
|
37
|
+
cwd: projectRoot,
|
|
38
|
+
maxBuffer: 10 * 1024 * 1024
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
43
|
+
throw new CofounderError(`failed to create git worktree: ${message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function createWorktreePatch(worktreePath) {
|
|
47
|
+
try {
|
|
48
|
+
await execFileAsync("git", ["add", "-N", "."], {
|
|
49
|
+
cwd: worktreePath,
|
|
50
|
+
maxBuffer: 10 * 1024 * 1024
|
|
51
|
+
});
|
|
52
|
+
const [{ stdout: patch }, { stdout: fileOutput }] = await Promise.all([
|
|
53
|
+
execFileAsync("git", ["diff", "--binary", "HEAD"], {
|
|
54
|
+
cwd: worktreePath,
|
|
55
|
+
maxBuffer: 50 * 1024 * 1024
|
|
56
|
+
}),
|
|
57
|
+
execFileAsync("git", ["diff", "--name-only", "-z", "HEAD"], {
|
|
58
|
+
cwd: worktreePath,
|
|
59
|
+
maxBuffer: 10 * 1024 * 1024
|
|
60
|
+
})
|
|
61
|
+
]);
|
|
62
|
+
return {
|
|
63
|
+
patch,
|
|
64
|
+
files: parseNulList(fileOutput)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
throw new CofounderError(`failed to create worktree patch: ${message}`);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
try {
|
|
73
|
+
await execFileAsync("git", ["reset", "-q"], {
|
|
74
|
+
cwd: worktreePath,
|
|
75
|
+
maxBuffer: 10 * 1024 * 1024
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Best-effort cleanup for intent-to-add index entries.
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export async function checkGitPatch(projectRoot, patch) {
|
|
84
|
+
await runGitWithInput(projectRoot, ["apply", "--check"], patch, "git apply --check");
|
|
85
|
+
}
|
|
86
|
+
export async function applyGitPatch(projectRoot, patch) {
|
|
87
|
+
await runGitWithInput(projectRoot, ["apply"], patch, "git apply");
|
|
88
|
+
}
|
|
89
|
+
export function diffChangedFiles(before, after) {
|
|
90
|
+
const beforeSet = new Set(before);
|
|
91
|
+
return after.filter((file) => !beforeSet.has(file)).sort();
|
|
92
|
+
}
|
|
93
|
+
export function mergeFiles(...groups) {
|
|
94
|
+
return [...new Set(groups.flat())].sort();
|
|
95
|
+
}
|
|
96
|
+
function parsePorcelainFiles(output) {
|
|
97
|
+
const entries = output.split("\0").filter(Boolean);
|
|
98
|
+
const files = [];
|
|
99
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
100
|
+
const entry = entries[index];
|
|
101
|
+
const status = entry.slice(0, 2);
|
|
102
|
+
const file = entry.slice(3);
|
|
103
|
+
if (!file) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (status.includes("R") || status.includes("C")) {
|
|
107
|
+
const target = entries[index + 1];
|
|
108
|
+
if (target) {
|
|
109
|
+
files.push(target);
|
|
110
|
+
index += 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
files.push(file);
|
|
115
|
+
}
|
|
116
|
+
return [...new Set(files)]
|
|
117
|
+
.filter((file) => !isCofounderRuntimeFile(file))
|
|
118
|
+
.sort();
|
|
119
|
+
}
|
|
120
|
+
function parseNulList(output) {
|
|
121
|
+
return output.split("\0")
|
|
122
|
+
.filter(Boolean)
|
|
123
|
+
.filter((file) => !isCofounderRuntimeFile(file))
|
|
124
|
+
.sort();
|
|
125
|
+
}
|
|
126
|
+
async function runGitWithInput(cwd, args, input, label) {
|
|
127
|
+
await new Promise((resolve, reject) => {
|
|
128
|
+
const child = spawn("git", args, {
|
|
129
|
+
cwd,
|
|
130
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
131
|
+
});
|
|
132
|
+
const stdout = [];
|
|
133
|
+
const stderr = [];
|
|
134
|
+
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
135
|
+
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
136
|
+
child.on("error", (error) => reject(new CofounderError(`${label} failed: ${error.message}`)));
|
|
137
|
+
child.on("close", (code) => {
|
|
138
|
+
if (code === 0) {
|
|
139
|
+
resolve();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const output = Buffer.concat(stderr).toString("utf8") || Buffer.concat(stdout).toString("utf8") || `exit code ${code ?? "unknown"}`;
|
|
143
|
+
reject(new CofounderError(`${label} failed: ${output.trim()}`));
|
|
144
|
+
});
|
|
145
|
+
child.stdin.end(input);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function isCofounderRuntimeFile(file) {
|
|
149
|
+
return file === ".cofounder" || file.startsWith(".cofounder/");
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"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AAC,MAAM,CAAC,IAAI,aAAa,IAAI,IAAI,SAAS,EAAE,CAAC;YACpI,MAAM,CAAC,IAAI,cAAc,CAAC,GAAG,KAAK,YAAY,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/src/init.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { CONFIG_DIR, pathExists } from "./paths.js";
|
|
4
|
+
import { getProjectTemplate } from "./templates.js";
|
|
5
|
+
export async function initProject(projectRoot = process.cwd(), options = {}) {
|
|
6
|
+
const root = path.resolve(projectRoot);
|
|
7
|
+
const template = getProjectTemplate(options.template);
|
|
8
|
+
const created = [];
|
|
9
|
+
const skipped = [];
|
|
10
|
+
async function ensureDir(relativePath) {
|
|
11
|
+
const absolutePath = path.join(root, relativePath);
|
|
12
|
+
if (await pathExists(absolutePath)) {
|
|
13
|
+
skipped.push(relativePath);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
await mkdir(absolutePath, { recursive: true });
|
|
17
|
+
created.push(relativePath);
|
|
18
|
+
}
|
|
19
|
+
async function ensureFile(relativePath, content) {
|
|
20
|
+
const absolutePath = path.join(root, relativePath);
|
|
21
|
+
await mkdir(path.dirname(absolutePath), { recursive: true });
|
|
22
|
+
if (await pathExists(absolutePath)) {
|
|
23
|
+
skipped.push(relativePath);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
await writeFile(absolutePath, content, "utf8");
|
|
27
|
+
created.push(relativePath);
|
|
28
|
+
}
|
|
29
|
+
await ensureDir(CONFIG_DIR);
|
|
30
|
+
await ensureDir(`${CONFIG_DIR}/runs`);
|
|
31
|
+
await ensureDir(`${CONFIG_DIR}/worktrees`);
|
|
32
|
+
await ensureDir(`${CONFIG_DIR}/memory/members`);
|
|
33
|
+
await ensureFile(`${CONFIG_DIR}/team.yaml`, template.teamYaml);
|
|
34
|
+
await ensureFile(`${CONFIG_DIR}/memory/project.md`, "# Project Memory\n\n");
|
|
35
|
+
for (const member of template.members) {
|
|
36
|
+
await ensureDir(`${CONFIG_DIR}/members/${member}/home`);
|
|
37
|
+
await ensureFile(`${CONFIG_DIR}/members/${member}/prompt.md`, template.prompts[member]);
|
|
38
|
+
await ensureFile(`${CONFIG_DIR}/members/${member}/settings.toml`, template.settings[member]);
|
|
39
|
+
await ensureFile(`${CONFIG_DIR}/memory/members/${member}.md`, `# ${member} Memory\n\n`);
|
|
40
|
+
}
|
|
41
|
+
return { created, skipped, template: template.name };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQpD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,UAAiC,EAAE;IAChG,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,OAAO,GAAa,EAAE,CAA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AG,UAAU,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;IAE5E,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,SAAS,CAAC,GAAG,UAAU,YAAY,MAAM,OAAO,CAAC,CAAC;QACxD,MAAM,UAAU,CAAC,GAAG,UAAU,YAAY,MAAM,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACxF,MAAM,UAAU,CAAC,GAAG,UAAU,YAAY,MAAM,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7F,MAAM,UAAU,CAAC,GAAG,UAAU,mBAAmB,MAAM,KAAK,EAAE,KAAK,MAAM,aAAa,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/src/mcp.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import { z } from "zod/v4";
|
|
7
|
+
import { CofounderError } from "./errors.js";
|
|
8
|
+
import { applyTaskPatch, cancelTask, delegateMember, formatLogEntry, formatTaskStatus, formatTeam, getCapabilities, getTask, interruptTask, listTeam, readTaskPatch, readTaskLogs } from "./runtime.js";
|
|
9
|
+
export function createCofounderMcpServer() {
|
|
10
|
+
const server = new McpServer({
|
|
11
|
+
name: "cofounder",
|
|
12
|
+
version: "0.1.0"
|
|
13
|
+
});
|
|
14
|
+
registerTools(server);
|
|
15
|
+
return server;
|
|
16
|
+
}
|
|
17
|
+
export async function startMcpServer() {
|
|
18
|
+
const server = createCofounderMcpServer();
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
function registerTools(server) {
|
|
23
|
+
server.registerTool("team.list", {
|
|
24
|
+
title: "List Cofounder team",
|
|
25
|
+
description: "List the project-local Cofounder team members and responsibilities.",
|
|
26
|
+
inputSchema: {}
|
|
27
|
+
}, async () => textResult(formatTeam(await listTeam())));
|
|
28
|
+
server.registerTool("team.delegate", {
|
|
29
|
+
title: "Delegate task",
|
|
30
|
+
description: "Delegate a task to a Codex-backed team member.",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
assignee: z.string().min(1),
|
|
33
|
+
task: z.string().min(1),
|
|
34
|
+
caller: z.string().min(1).optional()
|
|
35
|
+
}
|
|
36
|
+
}, async ({ assignee, task, caller }) => {
|
|
37
|
+
const record = await delegateMember(assignee, task, { caller });
|
|
38
|
+
return jsonTextResult({
|
|
39
|
+
task_id: record.id,
|
|
40
|
+
status: record.status,
|
|
41
|
+
assignee: record.assignee,
|
|
42
|
+
work_mode: record.work_mode,
|
|
43
|
+
worktree_path: record.worktree_path,
|
|
44
|
+
result_path: record.result_path,
|
|
45
|
+
events_path: record.events_path
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
server.registerTool("team.status", {
|
|
49
|
+
title: "Task status",
|
|
50
|
+
description: "Read the status of a delegated Cofounder task.",
|
|
51
|
+
inputSchema: {
|
|
52
|
+
task_id: z.string().min(1)
|
|
53
|
+
}
|
|
54
|
+
}, async ({ task_id }) => textResult(formatTaskStatus(await getTask(task_id))));
|
|
55
|
+
server.registerTool("team.logs", {
|
|
56
|
+
title: "Task logs",
|
|
57
|
+
description: "Read recent normalized events for a delegated Cofounder task.",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
task_id: z.string().min(1),
|
|
60
|
+
tail: z.number().int().positive().max(500).optional()
|
|
61
|
+
}
|
|
62
|
+
}, async ({ task_id, tail }) => {
|
|
63
|
+
const entries = await readTaskLogs(task_id, { tail });
|
|
64
|
+
return textResult(entries.map(formatLogEntry).join("\n") || "(no events)");
|
|
65
|
+
});
|
|
66
|
+
server.registerTool("team.diff", {
|
|
67
|
+
title: "Task worktree diff",
|
|
68
|
+
description: "Read the generated patch for a worktree-mode Cofounder task.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
task_id: z.string().min(1)
|
|
71
|
+
}
|
|
72
|
+
}, async ({ task_id }) => textResult(await readTaskPatch(task_id)));
|
|
73
|
+
server.registerTool("team.apply", {
|
|
74
|
+
title: "Apply worktree task",
|
|
75
|
+
description: "Apply changes from a worktree-mode Cofounder task to the main project working tree.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
task_id: z.string().min(1)
|
|
78
|
+
}
|
|
79
|
+
}, async ({ task_id }) => {
|
|
80
|
+
const result = await applyTaskPatch(task_id);
|
|
81
|
+
return jsonTextResult({
|
|
82
|
+
task_id: result.task.id,
|
|
83
|
+
applied_at: result.task.applied_at,
|
|
84
|
+
patch_path: result.patch_path,
|
|
85
|
+
files: result.files
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
server.registerTool("team.capabilities", {
|
|
89
|
+
title: "Runner capabilities",
|
|
90
|
+
description: "Show Cofounder runner capabilities, including interruption mode.",
|
|
91
|
+
inputSchema: {}
|
|
92
|
+
}, async () => jsonTextResult(getCapabilities()));
|
|
93
|
+
server.registerTool("team.cancel", {
|
|
94
|
+
title: "Cancel task",
|
|
95
|
+
description: "Cancel a running Cofounder task when possible.",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
task_id: z.string().min(1)
|
|
98
|
+
}
|
|
99
|
+
}, async ({ task_id }) => textResult(formatTaskStatus(await cancelTask(task_id))));
|
|
100
|
+
server.registerTool("team.interrupt", {
|
|
101
|
+
title: "Interrupt task",
|
|
102
|
+
description: "Cancel a running task and resume the same Codex session with revised instructions when possible.",
|
|
103
|
+
inputSchema: {
|
|
104
|
+
task_id: z.string().min(1),
|
|
105
|
+
message: z.string().min(1)
|
|
106
|
+
}
|
|
107
|
+
}, async ({ task_id, message }) => {
|
|
108
|
+
try {
|
|
109
|
+
const record = await interruptTask(task_id, message);
|
|
110
|
+
return jsonTextResult({
|
|
111
|
+
interrupted_task_id: task_id,
|
|
112
|
+
resumed_task_id: record.id,
|
|
113
|
+
status: record.status,
|
|
114
|
+
codex_resume_session_id: record.codex_resume_session_id,
|
|
115
|
+
result_path: record.result_path,
|
|
116
|
+
events_path: record.events_path
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
return errorResult(message);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function textResult(text) {
|
|
126
|
+
return {
|
|
127
|
+
content: [
|
|
128
|
+
{
|
|
129
|
+
type: "text",
|
|
130
|
+
text
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function jsonTextResult(value) {
|
|
136
|
+
return textResult(JSON.stringify(value, null, 2));
|
|
137
|
+
}
|
|
138
|
+
function errorResult(text) {
|
|
139
|
+
return {
|
|
140
|
+
isError: true,
|
|
141
|
+
content: [
|
|
142
|
+
{
|
|
143
|
+
type: "text",
|
|
144
|
+
text
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (isMainModule()) {
|
|
150
|
+
startMcpServer().catch((error) => {
|
|
151
|
+
const message = error instanceof CofounderError ? error.message : error instanceof Error ? error.message : String(error);
|
|
152
|
+
console.error(`error: ${message}`);
|
|
153
|
+
process.exitCode = 1;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function isMainModule() {
|
|
157
|
+
return process.argv[1] ? fileURLToPath(import.meta.url) === path.resolve(process.argv[1]) : false;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PreparedCodexConfig } from "./codexConfig.js";
|
|
2
|
+
import type { LoadedProject, MemberDefinition, MemberSettings } from "./types.js";
|
|
3
|
+
export interface PreparedMemberRuntime {
|
|
4
|
+
member: MemberDefinition;
|
|
5
|
+
settings: MemberSettings;
|
|
6
|
+
member_home_path: string | null;
|
|
7
|
+
member_prompt_path: string;
|
|
8
|
+
member_settings_path: string;
|
|
9
|
+
member_effective_config_path: string | null;
|
|
10
|
+
member_codex_config_path: string | null;
|
|
11
|
+
codex_config: PreparedCodexConfig;
|
|
12
|
+
}
|
|
13
|
+
export declare function prepareMemberRuntime(project: LoadedProject, member: MemberDefinition): Promise<PreparedMemberRuntime>;
|