create-cofounder 0.1.1 → 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.
Files changed (3) hide show
  1. package/README.md +8 -0
  2. package/index.js +52 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,3 +8,11 @@ npm create cofounder@latest -- --template worktree --setup-codex --yes
8
8
  ```
9
9
 
10
10
  This creates a `.cofounder/` skeleton in the current project and can optionally install the Codex MCP entry.
11
+
12
+ The `worktree` template requires a Git repository with at least one commit before delegated tasks can run in isolated worktrees.
13
+
14
+ `npm create` does not install a persistent `cofounder` shell command. For one-off runtime commands:
15
+
16
+ ```bash
17
+ npx -y --package cofounder-crew -- cofounder team
18
+ ```
package/index.js CHANGED
@@ -13,15 +13,18 @@ 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 });
19
22
  } else {
20
23
  console.log("");
21
24
  console.log("Next:");
22
- console.log(" cofounder setup codex --install");
23
- console.log(" cofounder team");
24
- console.log(' cofounder delegate backend "inspect this repo and summarize the API boundaries"');
25
+ console.log(` ${formatCofounderCommand(["setup", "codex", "--install"])}`);
26
+ console.log(` ${formatCofounderCommand(["team"])}`);
27
+ console.log(` ${formatCofounderCommand(["delegate", "backend", "inspect this repo and summarize the API boundaries"])}`);
25
28
  }
26
29
  }
27
30
 
@@ -110,10 +113,55 @@ function resolveCofounderCommand(args) {
110
113
 
111
114
  return {
112
115
  bin: "npx",
113
- args: ["-y", "--package", PACKAGE_NAME, "--", "cofounder", ...args]
116
+ args: resolveNpxCofounderArgs(args)
114
117
  };
115
118
  }
116
119
 
120
+ function resolveNpxCofounderArgs(args) {
121
+ return ["-y", "--package", PACKAGE_NAME, "--", "cofounder", ...args];
122
+ }
123
+
124
+ function formatCofounderCommand(args) {
125
+ return ["npx", ...resolveNpxCofounderArgs(args)].map(quoteShellArg).join(" ");
126
+ }
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
+
158
+ function quoteShellArg(value) {
159
+ if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value)) {
160
+ return value;
161
+ }
162
+ return `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
163
+ }
164
+
117
165
  function validateTemplate(template) {
118
166
  if (!template) {
119
167
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cofounder",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Initializer for Cofounder Crew projects",
5
5
  "type": "module",
6
6
  "bin": {