create-cofounder 0.1.2 → 0.1.3
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 +2 -0
- package/index.js +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ npm create cofounder@latest -- --template worktree --setup-codex --yes
|
|
|
9
9
|
|
|
10
10
|
This creates a `.cofounder/` skeleton in the current project and can optionally install the Codex MCP entry.
|
|
11
11
|
|
|
12
|
+
The `worktree` template requires a Git repository with at least one commit before delegated tasks can run in isolated worktrees.
|
|
13
|
+
|
|
12
14
|
`npm create` does not install a persistent `cofounder` shell command. For one-off runtime commands:
|
|
13
15
|
|
|
14
16
|
```bash
|
package/index.js
CHANGED
|
@@ -13,6 +13,9 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
13
13
|
const template = answers.template ?? "default";
|
|
14
14
|
|
|
15
15
|
await runCofounder(["init", "--template", template], { inherit: true });
|
|
16
|
+
if (template === "worktree" && !(await hasGitHead())) {
|
|
17
|
+
printWorktreePrerequisiteWarning();
|
|
18
|
+
}
|
|
16
19
|
|
|
17
20
|
if (answers.setupCodex) {
|
|
18
21
|
await runCofounder(["setup", "codex", "--install"], { inherit: true });
|
|
@@ -122,6 +125,36 @@ function formatCofounderCommand(args) {
|
|
|
122
125
|
return ["npx", ...resolveNpxCofounderArgs(args)].map(quoteShellArg).join(" ");
|
|
123
126
|
}
|
|
124
127
|
|
|
128
|
+
async function hasGitHead() {
|
|
129
|
+
return commandSucceeds("git", ["rev-parse", "--verify", "HEAD"]);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function commandSucceeds(bin, args) {
|
|
133
|
+
return new Promise((resolve) => {
|
|
134
|
+
const child = spawn(bin, args, {
|
|
135
|
+
cwd: process.cwd(),
|
|
136
|
+
env: process.env,
|
|
137
|
+
stdio: "ignore"
|
|
138
|
+
});
|
|
139
|
+
child.on("error", () => resolve(false));
|
|
140
|
+
child.on("close", (code) => resolve(code === 0));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function printWorktreePrerequisiteWarning() {
|
|
145
|
+
console.log("");
|
|
146
|
+
console.log("Warning:");
|
|
147
|
+
console.log(" worktree template needs a Git repository with at least one commit before delegation.");
|
|
148
|
+
console.log(" Worktrees are created from HEAD, so commit the baseline delegated agents should see.");
|
|
149
|
+
console.log("");
|
|
150
|
+
console.log(" For a scratch test:");
|
|
151
|
+
console.log(" git init");
|
|
152
|
+
console.log(" git add .");
|
|
153
|
+
console.log(' git commit -m "chore: initial commit"');
|
|
154
|
+
console.log("");
|
|
155
|
+
console.log(' Or use direct mode by setting mode = "direct" under [write] in .cofounder/members/backend/settings.toml.');
|
|
156
|
+
}
|
|
157
|
+
|
|
125
158
|
function quoteShellArg(value) {
|
|
126
159
|
if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value)) {
|
|
127
160
|
return value;
|