@svara/work3 0.0.0 → 0.3.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 +5 -3
- package/dist/cli.js +37 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://bun.sh)
|
|
9
9
|
[](https://www.typescriptlang.org)
|
|
10
10
|
[](https://claude.com/claude-code)
|
|
11
|
-
[](https://www.npmjs.com/package/work3)
|
|
11
|
+
[](https://www.npmjs.com/package/@svara/work3)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
|
|
14
14
|
<img src="docs/hero.png" alt="Six Claude Code sessions running side by side, each in its own work3 worktree" width="100%">
|
|
@@ -49,11 +49,11 @@ work3 open feat/login
|
|
|
49
49
|
Requires [Bun](https://bun.sh) 1.2.21 or newer, git, and [Claude Code](https://claude.com/claude-code) on your `PATH` (unless you always pass `--no-claude`).
|
|
50
50
|
|
|
51
51
|
```shell
|
|
52
|
-
bun add -g work3
|
|
52
|
+
bun add -g @svara/work3
|
|
53
53
|
work3 --help
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
Or run it without installing: `bunx work3 open feat/login`.
|
|
56
|
+
The package is scoped, the command is `work3`. Or run it without installing: `bunx @svara/work3 open feat/login`.
|
|
57
57
|
|
|
58
58
|
## Quick start
|
|
59
59
|
|
|
@@ -187,6 +187,8 @@ bun test
|
|
|
187
187
|
bun run typecheck
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
Releases are automatic and follow [Conventional Commits](https://www.conventionalcommits.org): `!` or `BREAKING CHANGE:` bumps the major, anything else the minor. Pushing to `main` tags `vX.Y.Z`, publishes to npm as `latest` and creates a GitHub release with the changelog, pushing to `stage` publishes a `X.Y.Z-rcN` release candidate under the `rc` tag (`bun add -g @svara/work3@rc`).
|
|
191
|
+
|
|
190
192
|
## Todo
|
|
191
193
|
|
|
192
194
|
- Spawn new agents from Claude
|
package/dist/cli.js
CHANGED
|
@@ -3744,7 +3744,7 @@ var version = /* @__PURE__ */ defineExtension(VERSION).factory((extension, value
|
|
|
3744
3744
|
// package.json
|
|
3745
3745
|
var package_default = {
|
|
3746
3746
|
name: "@svara/work3",
|
|
3747
|
-
version: "0.
|
|
3747
|
+
version: "0.3.0",
|
|
3748
3748
|
description: "Run a fleet of Claude Code agents in parallel, each on its own branch, in its own fully set up git worktree",
|
|
3749
3749
|
keywords: [
|
|
3750
3750
|
"git",
|
|
@@ -9012,9 +9012,20 @@ async function isIgnored(path, cwd) {
|
|
|
9012
9012
|
async function isDirty(cwd) {
|
|
9013
9013
|
return await git(["status", "--porcelain"], cwd) !== "";
|
|
9014
9014
|
}
|
|
9015
|
+
async function trackedLinks(cwd) {
|
|
9016
|
+
const out = await git(["ls-files", "-s", "-z"], cwd);
|
|
9017
|
+
const links = new Set;
|
|
9018
|
+
for (const entry of out.split("\x00")) {
|
|
9019
|
+
const [meta, path] = entry.split("\t");
|
|
9020
|
+
if (path && meta?.startsWith("120000 "))
|
|
9021
|
+
links.add(path);
|
|
9022
|
+
}
|
|
9023
|
+
return links;
|
|
9024
|
+
}
|
|
9015
9025
|
|
|
9016
9026
|
// src/worktree.ts
|
|
9017
|
-
import {
|
|
9027
|
+
import { readdirSync, unlinkSync } from "fs";
|
|
9028
|
+
import { basename, isAbsolute, join as join2, relative, resolve as resolve2 } from "path";
|
|
9018
9029
|
function safeName(branch) {
|
|
9019
9030
|
return branch.replace(/[\\/]/g, "--");
|
|
9020
9031
|
}
|
|
@@ -9036,6 +9047,25 @@ function samePath(a, b) {
|
|
|
9036
9047
|
const right = resolve2(b);
|
|
9037
9048
|
return process.platform === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
9038
9049
|
}
|
|
9050
|
+
function unlinkLinks(dir, keep = new Set) {
|
|
9051
|
+
const removed = [];
|
|
9052
|
+
const walk = (current) => {
|
|
9053
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
9054
|
+
const path = join2(current, entry.name);
|
|
9055
|
+
if (entry.isSymbolicLink()) {
|
|
9056
|
+
const rel = relative(dir, path).replaceAll("\\", "/");
|
|
9057
|
+
if (keep.has(rel))
|
|
9058
|
+
continue;
|
|
9059
|
+
unlinkSync(path);
|
|
9060
|
+
removed.push(rel);
|
|
9061
|
+
} else if (entry.isDirectory()) {
|
|
9062
|
+
walk(path);
|
|
9063
|
+
}
|
|
9064
|
+
}
|
|
9065
|
+
};
|
|
9066
|
+
walk(dir);
|
|
9067
|
+
return removed;
|
|
9068
|
+
}
|
|
9039
9069
|
|
|
9040
9070
|
// src/commands/remove.ts
|
|
9041
9071
|
init_dist();
|
|
@@ -9075,6 +9105,8 @@ async function removeWorktree(cwd, branch, options) {
|
|
|
9075
9105
|
throw new Error(`${dir} has uncommitted or untracked changes, use --force to remove anyway`);
|
|
9076
9106
|
}
|
|
9077
9107
|
await runTasks(config.destroy, { root, path: dir, branch }, { continueOnError: options.force });
|
|
9108
|
+
for (const link of unlinkLinks(dir, await trackedLinks(dir)))
|
|
9109
|
+
console.log(`Unlinked ${link}`);
|
|
9078
9110
|
} else {
|
|
9079
9111
|
console.warn(`warning: ${dir} is missing, skipping destroy tasks`);
|
|
9080
9112
|
}
|
|
@@ -9166,7 +9198,7 @@ var foldCommand = defineCommand("fold", { description: "Fast-forward the base br
|
|
|
9166
9198
|
// src/commands/init.ts
|
|
9167
9199
|
init_dist();
|
|
9168
9200
|
import { existsSync as existsSync4, readFileSync, writeFileSync, appendFileSync } from "fs";
|
|
9169
|
-
import { join as
|
|
9201
|
+
import { join as join3, relative as relative2, resolve as resolve3 } from "path";
|
|
9170
9202
|
var LOCATION = "worktrees";
|
|
9171
9203
|
function renderConfig(base, yaml) {
|
|
9172
9204
|
if (yaml) {
|
|
@@ -9186,7 +9218,7 @@ async function ensureIgnored(root, location) {
|
|
|
9186
9218
|
const rel = relative2(root, dir).replace(/\\/g, "/");
|
|
9187
9219
|
if (await isIgnored(`${rel}/`, root))
|
|
9188
9220
|
return false;
|
|
9189
|
-
const file =
|
|
9221
|
+
const file = join3(root, ".gitignore");
|
|
9190
9222
|
const current = existsSync4(file) ? readFileSync(file, "utf8") : "";
|
|
9191
9223
|
const prefix = current && !current.endsWith(`
|
|
9192
9224
|
`) ? `
|
|
@@ -9202,7 +9234,7 @@ async function initRepo(cwd, yaml) {
|
|
|
9202
9234
|
throw new Error(`Config already exists: ${existing.join(", ")}`);
|
|
9203
9235
|
}
|
|
9204
9236
|
const base = await branchExists("main", root) ? "main" : await currentBranch(root) || "main";
|
|
9205
|
-
const file =
|
|
9237
|
+
const file = join3(root, yaml ? "worktree.yaml" : "worktree.json");
|
|
9206
9238
|
writeFileSync(file, renderConfig(base, yaml));
|
|
9207
9239
|
console.log(`Created ${file} (base: ${base})`);
|
|
9208
9240
|
if (await ensureIgnored(root, LOCATION)) {
|