@moberg_hr/work-tree 1.15.0 → 2.0.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 +56 -142
- package/dist/answer-2J4XLIP7.js +63 -0
- package/dist/answer-2J4XLIP7.js.map +1 -0
- package/dist/attach-CZKRNPAJ.js +59 -0
- package/dist/attach-CZKRNPAJ.js.map +1 -0
- package/dist/bin.js +26 -11892
- package/dist/bin.js.map +1 -1
- package/dist/block-RAIDCJ4F.js +84 -0
- package/dist/block-RAIDCJ4F.js.map +1 -0
- package/dist/broadcast-BSI5NDDB.js +104 -0
- package/dist/broadcast-BSI5NDDB.js.map +1 -0
- package/dist/catchup-VVOPL2S5.js +51 -0
- package/dist/catchup-VVOPL2S5.js.map +1 -0
- package/dist/chunk-3JWTO5VZ.js +135 -0
- package/dist/chunk-3JWTO5VZ.js.map +1 -0
- package/dist/chunk-4BOK2GXL.js +210 -0
- package/dist/chunk-4BOK2GXL.js.map +1 -0
- package/dist/chunk-5QK7GB5K.js +112 -0
- package/dist/chunk-5QK7GB5K.js.map +1 -0
- package/dist/chunk-6AQRYLOB.js +16 -0
- package/dist/chunk-6AQRYLOB.js.map +1 -0
- package/dist/chunk-6FTIY5M6.js +120 -0
- package/dist/chunk-6FTIY5M6.js.map +1 -0
- package/dist/chunk-6H3MLDGG.js +48 -0
- package/dist/chunk-6H3MLDGG.js.map +1 -0
- package/dist/chunk-77XFJQGC.js +103 -0
- package/dist/chunk-77XFJQGC.js.map +1 -0
- package/dist/chunk-7H4BJ2YA.js +308 -0
- package/dist/chunk-7H4BJ2YA.js.map +1 -0
- package/dist/chunk-7HEB6SQS.js +257 -0
- package/dist/chunk-7HEB6SQS.js.map +1 -0
- package/dist/chunk-7NAXFBFI.js +206 -0
- package/dist/chunk-7NAXFBFI.js.map +1 -0
- package/dist/chunk-7NCW3LUT.js +358 -0
- package/dist/chunk-7NCW3LUT.js.map +1 -0
- package/dist/chunk-7OLPI334.js +537 -0
- package/dist/chunk-7OLPI334.js.map +1 -0
- package/dist/chunk-ABQYKTG4.js +38 -0
- package/dist/chunk-ABQYKTG4.js.map +1 -0
- package/dist/chunk-AH5TM3NB.js +21 -0
- package/dist/chunk-AH5TM3NB.js.map +1 -0
- package/dist/chunk-AKMPF72Y.js +274 -0
- package/dist/chunk-AKMPF72Y.js.map +1 -0
- package/dist/chunk-C2BK6EBN.js +162 -0
- package/dist/chunk-C2BK6EBN.js.map +1 -0
- package/dist/chunk-C2THFSXA.js +37 -0
- package/dist/chunk-C2THFSXA.js.map +1 -0
- package/dist/chunk-CLGVSX36.js +668 -0
- package/dist/chunk-CLGVSX36.js.map +1 -0
- package/dist/chunk-CXEC5W5V.js +267 -0
- package/dist/chunk-CXEC5W5V.js.map +1 -0
- package/dist/chunk-DW4JPVXB.js +41 -0
- package/dist/chunk-DW4JPVXB.js.map +1 -0
- package/dist/chunk-FR3EWVXI.js +188 -0
- package/dist/chunk-FR3EWVXI.js.map +1 -0
- package/dist/chunk-H5LKMR45.js +117 -0
- package/dist/chunk-H5LKMR45.js.map +1 -0
- package/dist/chunk-HSICXDMZ.js +41 -0
- package/dist/chunk-HSICXDMZ.js.map +1 -0
- package/dist/chunk-HUXS3VAI.js +90 -0
- package/dist/chunk-HUXS3VAI.js.map +1 -0
- package/dist/chunk-HWUINPIL.js +151 -0
- package/dist/chunk-HWUINPIL.js.map +1 -0
- package/dist/chunk-IXKVCR4Y.js +487 -0
- package/dist/chunk-IXKVCR4Y.js.map +1 -0
- package/dist/chunk-JNBYNRFS.js +54 -0
- package/dist/chunk-JNBYNRFS.js.map +1 -0
- package/dist/chunk-JYTMT5DF.js +421 -0
- package/dist/chunk-JYTMT5DF.js.map +1 -0
- package/dist/chunk-KA4JVX5U.js +295 -0
- package/dist/chunk-KA4JVX5U.js.map +1 -0
- package/dist/chunk-KGZ6OZ2T.js +102 -0
- package/dist/chunk-KGZ6OZ2T.js.map +1 -0
- package/dist/chunk-LNHSBM4L.js +26 -0
- package/dist/chunk-LNHSBM4L.js.map +1 -0
- package/dist/chunk-M4FVCAT6.js +2406 -0
- package/dist/chunk-M4FVCAT6.js.map +1 -0
- package/dist/chunk-MAGGGRSB.js +9 -0
- package/dist/chunk-MAGGGRSB.js.map +1 -0
- package/dist/chunk-N4EYQKSM.js +104 -0
- package/dist/chunk-N4EYQKSM.js.map +1 -0
- package/dist/chunk-NDWSLQPB.js +112 -0
- package/dist/chunk-NDWSLQPB.js.map +1 -0
- package/dist/chunk-O3QTWVSK.js +323 -0
- package/dist/chunk-O3QTWVSK.js.map +1 -0
- package/dist/chunk-P3BL4EOP.js +37 -0
- package/dist/chunk-P3BL4EOP.js.map +1 -0
- package/dist/chunk-PN44M5EE.js +887 -0
- package/dist/chunk-PN44M5EE.js.map +1 -0
- package/dist/chunk-PZ4RG6EW.js +132 -0
- package/dist/chunk-PZ4RG6EW.js.map +1 -0
- package/dist/chunk-Q6WZCO45.js +47 -0
- package/dist/chunk-Q6WZCO45.js.map +1 -0
- package/dist/chunk-QBAZG4CY.js +230 -0
- package/dist/chunk-QBAZG4CY.js.map +1 -0
- package/dist/chunk-R2LN3JJJ.js +132 -0
- package/dist/chunk-R2LN3JJJ.js.map +1 -0
- package/dist/chunk-RCYI7SRA.js +15 -0
- package/dist/chunk-RCYI7SRA.js.map +1 -0
- package/dist/chunk-RYNBBSLY.js +67 -0
- package/dist/chunk-RYNBBSLY.js.map +1 -0
- package/dist/chunk-S5HJT7CM.js +30 -0
- package/dist/chunk-S5HJT7CM.js.map +1 -0
- package/dist/chunk-SNAQOHNL.js +285 -0
- package/dist/chunk-SNAQOHNL.js.map +1 -0
- package/dist/chunk-SOCPIHCS.js +181 -0
- package/dist/chunk-SOCPIHCS.js.map +1 -0
- package/dist/chunk-TUC4QY4O.js +147 -0
- package/dist/chunk-TUC4QY4O.js.map +1 -0
- package/dist/chunk-TUFQJXXO.js +19 -0
- package/dist/chunk-TUFQJXXO.js.map +1 -0
- package/dist/chunk-UFY7C5PP.js +90 -0
- package/dist/chunk-UFY7C5PP.js.map +1 -0
- package/dist/chunk-UQ35KLHH.js +34 -0
- package/dist/chunk-UQ35KLHH.js.map +1 -0
- package/dist/chunk-VJ7SVDED.js +177 -0
- package/dist/chunk-VJ7SVDED.js.map +1 -0
- package/dist/chunk-VJNSIDOA.js +23 -0
- package/dist/chunk-VJNSIDOA.js.map +1 -0
- package/dist/chunk-WF5SBVPZ.js +190 -0
- package/dist/chunk-WF5SBVPZ.js.map +1 -0
- package/dist/chunk-WMJIU3YW.js +29 -0
- package/dist/chunk-WMJIU3YW.js.map +1 -0
- package/dist/chunk-XJDEROHY.js +19 -0
- package/dist/chunk-XJDEROHY.js.map +1 -0
- package/dist/chunk-YKODIG22.js +221 -0
- package/dist/chunk-YKODIG22.js.map +1 -0
- package/dist/chunk-YLG6DO5Y.js +162 -0
- package/dist/chunk-YLG6DO5Y.js.map +1 -0
- package/dist/chunk-YNKWLC45.js +122 -0
- package/dist/chunk-YNKWLC45.js.map +1 -0
- package/dist/chunk-YZDD5YGE.js +165 -0
- package/dist/chunk-YZDD5YGE.js.map +1 -0
- package/dist/chunk-YZWADOEW.js +151 -0
- package/dist/chunk-YZWADOEW.js.map +1 -0
- package/dist/chunk-ZJN5RWZD.js +76 -0
- package/dist/chunk-ZJN5RWZD.js.map +1 -0
- package/dist/chunk-ZSHWP2VS.js +22 -0
- package/dist/chunk-ZSHWP2VS.js.map +1 -0
- package/dist/chunk-ZXPYWZL5.js +307 -0
- package/dist/chunk-ZXPYWZL5.js.map +1 -0
- package/dist/cleanup-X45MA74G.js +192 -0
- package/dist/cleanup-X45MA74G.js.map +1 -0
- package/dist/cli-52VWEHIQ.js +18 -0
- package/dist/cli-52VWEHIQ.js.map +1 -0
- package/dist/command-hook-installer-SGEJTZ2Y.js +204 -0
- package/dist/command-hook-installer-SGEJTZ2Y.js.map +1 -0
- package/dist/completion-MXX5TRIV.js +118 -0
- package/dist/completion-MXX5TRIV.js.map +1 -0
- package/dist/config-IEIU7A66.js +410 -0
- package/dist/config-IEIU7A66.js.map +1 -0
- package/dist/console-reporter-XU6VFUZE.js +10 -0
- package/dist/console-reporter-XU6VFUZE.js.map +1 -0
- package/dist/diff-K47HB6SA.js +582 -0
- package/dist/diff-K47HB6SA.js.map +1 -0
- package/dist/digest-FBZTBXQO.js +100 -0
- package/dist/digest-FBZTBXQO.js.map +1 -0
- package/dist/fork-BKI5UNNS.js +120 -0
- package/dist/fork-BKI5UNNS.js.map +1 -0
- package/dist/hook-SLMZT5OV.js +220 -0
- package/dist/hook-SLMZT5OV.js.map +1 -0
- package/dist/hydrate-Y2AAMZTA.js +121 -0
- package/dist/hydrate-Y2AAMZTA.js.map +1 -0
- package/dist/init-7ESFTYZC.js +187 -0
- package/dist/init-7ESFTYZC.js.map +1 -0
- package/dist/install-skills-O34BHFHD.js +14 -0
- package/dist/install-skills-O34BHFHD.js.map +1 -0
- package/dist/install-skills-bin.js +12 -0
- package/dist/install-skills-bin.js.map +1 -0
- package/dist/list-KEF73NLQ.js +126 -0
- package/dist/list-KEF73NLQ.js.map +1 -0
- package/dist/move-FKT2P5LY.js +313 -0
- package/dist/move-FKT2P5LY.js.map +1 -0
- package/dist/note-WGM6LCP2.js +78 -0
- package/dist/note-WGM6LCP2.js.map +1 -0
- package/dist/overlaps-FRLMMIGC.js +56 -0
- package/dist/overlaps-FRLMMIGC.js.map +1 -0
- package/dist/pin-MQ5ZE37R.js +45 -0
- package/dist/pin-MQ5ZE37R.js.map +1 -0
- package/dist/pr-YU3NOW6G.js +118 -0
- package/dist/pr-YU3NOW6G.js.map +1 -0
- package/dist/prune-26FYYFTO.js +92 -0
- package/dist/prune-26FYYFTO.js.map +1 -0
- package/dist/pty-host-RWIS55N4.js +826 -0
- package/dist/pty-host-RWIS55N4.js.map +1 -0
- package/dist/read-AP6T3ZGN.js +57 -0
- package/dist/read-AP6T3ZGN.js.map +1 -0
- package/dist/recent-IE3LYQ65.js +111 -0
- package/dist/recent-IE3LYQ65.js.map +1 -0
- package/dist/remove-2UHJQ4DY.js +108 -0
- package/dist/remove-2UHJQ4DY.js.map +1 -0
- package/dist/report-KM4OZCZB.js +16 -0
- package/dist/report-KM4OZCZB.js.map +1 -0
- package/dist/resume-UUP6R2IE.js +81 -0
- package/dist/resume-UUP6R2IE.js.map +1 -0
- package/dist/run-V4755W7C.js +263 -0
- package/dist/run-V4755W7C.js.map +1 -0
- package/dist/screen-DNX4K23V.js +58 -0
- package/dist/screen-DNX4K23V.js.map +1 -0
- package/dist/search-3JZXLCR2.js +46 -0
- package/dist/search-3JZXLCR2.js.map +1 -0
- package/dist/section-TXLC5XO3.js +79 -0
- package/dist/section-TXLC5XO3.js.map +1 -0
- package/dist/send-6X46WZLC.js +87 -0
- package/dist/send-6X46WZLC.js.map +1 -0
- package/dist/sessions-T3QDTNP7.js +135 -0
- package/dist/sessions-T3QDTNP7.js.map +1 -0
- package/dist/snooze-KYSFXLPY.js +65 -0
- package/dist/snooze-KYSFXLPY.js.map +1 -0
- package/dist/start-SQSDQK4F.js +56 -0
- package/dist/start-SQSDQK4F.js.map +1 -0
- package/dist/state-4DFV6SHG.js +147 -0
- package/dist/state-4DFV6SHG.js.map +1 -0
- package/dist/status-H5OW4LYE.js +118 -0
- package/dist/status-H5OW4LYE.js.map +1 -0
- package/dist/stop-HC7XPSSP.js +45 -0
- package/dist/stop-HC7XPSSP.js.map +1 -0
- package/dist/sync-3CTAXM6J.js +96 -0
- package/dist/sync-3CTAXM6J.js.map +1 -0
- package/dist/time-GN6B4QD6.js +111 -0
- package/dist/time-GN6B4QD6.js.map +1 -0
- package/dist/todo-LWMQY6XW.js +152 -0
- package/dist/todo-LWMQY6XW.js.map +1 -0
- package/dist/tree-7BMORJ6J.js +235 -0
- package/dist/tree-7BMORJ6J.js.map +1 -0
- package/dist/update-6LQNLRA4.js +57 -0
- package/dist/update-6LQNLRA4.js.map +1 -0
- package/dist/wait-MZOZQ3CI.js +57 -0
- package/dist/wait-MZOZQ3CI.js.map +1 -0
- package/dist/wd-bin.js +21 -11880
- package/dist/wd-bin.js.map +1 -1
- package/dist/web/assets/PtyView-BrP-ENHg.css +1 -0
- package/dist/web/assets/PtyView-M4b0GFVs.js +90 -0
- package/dist/web/assets/PtyView-M4b0GFVs.js.map +1 -0
- package/dist/web/assets/index-5hi1kMKy.js +116 -0
- package/dist/web/assets/index-5hi1kMKy.js.map +1 -0
- package/dist/web/assets/index-L8mjakHP.css +1 -0
- package/dist/web/index.html +3 -5
- package/dist/web-BI3MRQEM.js +7662 -0
- package/dist/web-BI3MRQEM.js.map +1 -0
- package/npm-shrinkwrap.json +6947 -0
- package/package.json +52 -34
- package/plugins/work-tree/.claude-plugin/plugin.json +1 -1
- package/plugins/work-tree/skills/wd-review/SKILL.md +4 -4
- package/plugins/work-tree/skills/work-sessions/SKILL.md +62 -0
- package/scripts/postinstall.mjs +15 -45
- package/dist/web/assets/index-BgVq8Uj_.js +0 -107
- package/dist/web/assets/index-BgVq8Uj_.js.map +0 -1
- package/dist/web/assets/index-ubbitWeW.css +0 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
VERSION
|
|
4
|
+
} from "./chunk-MAGGGRSB.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveProjectTarget
|
|
7
|
+
} from "./chunk-H5LKMR45.js";
|
|
8
|
+
import {
|
|
9
|
+
getCurrentBranch,
|
|
10
|
+
parseWorktreeList
|
|
11
|
+
} from "./chunk-7NAXFBFI.js";
|
|
12
|
+
import {
|
|
13
|
+
loadConfig
|
|
14
|
+
} from "./chunk-7HEB6SQS.js";
|
|
15
|
+
|
|
16
|
+
// src/cli.ts
|
|
17
|
+
import chalk from "chalk";
|
|
18
|
+
import yargs from "yargs";
|
|
19
|
+
|
|
20
|
+
// src/completions/index.ts
|
|
21
|
+
import fs from "fs";
|
|
22
|
+
import path from "path";
|
|
23
|
+
function completionHandler(current, argv, done) {
|
|
24
|
+
const rawArgs = argv._;
|
|
25
|
+
const args = rawArgs.slice(1, -1);
|
|
26
|
+
const command = args[0];
|
|
27
|
+
const config = loadConfig();
|
|
28
|
+
if (!config) {
|
|
29
|
+
done([]);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!command) {
|
|
33
|
+
done(
|
|
34
|
+
[
|
|
35
|
+
"tree",
|
|
36
|
+
"t",
|
|
37
|
+
"remove",
|
|
38
|
+
"list",
|
|
39
|
+
"status",
|
|
40
|
+
"recent",
|
|
41
|
+
"resume",
|
|
42
|
+
"prune",
|
|
43
|
+
"todo",
|
|
44
|
+
"attach",
|
|
45
|
+
"hydrate",
|
|
46
|
+
"diff",
|
|
47
|
+
"web",
|
|
48
|
+
"init",
|
|
49
|
+
"config",
|
|
50
|
+
"completion"
|
|
51
|
+
].filter((c) => c.startsWith(current))
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
switch (command) {
|
|
56
|
+
case "config":
|
|
57
|
+
completeConfig(args, current, config, done);
|
|
58
|
+
return;
|
|
59
|
+
case "tree":
|
|
60
|
+
case "t":
|
|
61
|
+
case "remove":
|
|
62
|
+
case "list":
|
|
63
|
+
case "status":
|
|
64
|
+
completeTreeRemoveList(command, args, current, config, done);
|
|
65
|
+
return;
|
|
66
|
+
default:
|
|
67
|
+
done([]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function completeConfig(args, current, config, done) {
|
|
71
|
+
const subAction = args[1];
|
|
72
|
+
if (!subAction) {
|
|
73
|
+
const actions = ["add", "remove", "list", "group", "show", "edit"];
|
|
74
|
+
done(actions.filter((a) => a.startsWith(current)));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (subAction === "remove" && args.length === 2) {
|
|
78
|
+
const aliases = Object.keys(config.repos);
|
|
79
|
+
done(aliases.filter((a) => a.startsWith(current)));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (subAction === "group") {
|
|
83
|
+
const groupSub = args[2];
|
|
84
|
+
if (!groupSub) {
|
|
85
|
+
const subs = ["add", "remove", "regen"];
|
|
86
|
+
done(subs.filter((s) => s.startsWith(current)));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if ((groupSub === "remove" || groupSub === "regen") && args.length === 3) {
|
|
90
|
+
const groups = Object.keys(config.groups);
|
|
91
|
+
done(groups.filter((g) => g.startsWith(current)));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (groupSub === "add" && args.length >= 4) {
|
|
95
|
+
const alreadyUsed = args.slice(3);
|
|
96
|
+
const aliases = Object.keys(config.repos).filter((a) => !alreadyUsed.includes(a));
|
|
97
|
+
done(aliases.filter((a) => a.startsWith(current)));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
done([]);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
done([]);
|
|
104
|
+
}
|
|
105
|
+
function completeTreeRemoveList(command, args, current, config, done) {
|
|
106
|
+
const targetName = args[1];
|
|
107
|
+
if (!targetName) {
|
|
108
|
+
const names = [...Object.keys(config.repos), ...Object.keys(config.groups)];
|
|
109
|
+
done(names.filter((n) => n.startsWith(current)));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (args.length === 2) {
|
|
113
|
+
const target = resolveProjectTarget(targetName, config);
|
|
114
|
+
if (!target) {
|
|
115
|
+
done([]);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (target.isGroup) {
|
|
119
|
+
completeGroupBranches(target.name, target.repoAliases, current, config, done);
|
|
120
|
+
} else {
|
|
121
|
+
completeRepoBranches(targetName, current, config, done);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
done([]);
|
|
126
|
+
}
|
|
127
|
+
function completeRepoBranches(alias, current, config, done) {
|
|
128
|
+
const repoPath = config.repos[alias];
|
|
129
|
+
if (!repoPath || !fs.existsSync(repoPath)) {
|
|
130
|
+
done([]);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const worktrees = parseWorktreeList(repoPath);
|
|
134
|
+
const branches = worktrees.map((wt) => wt.branch).filter((b) => !!b && b.startsWith(current));
|
|
135
|
+
done(branches);
|
|
136
|
+
}
|
|
137
|
+
function completeGroupBranches(groupName, repoAliases, current, config, done) {
|
|
138
|
+
const groupDir = path.join(config.worktreesRoot, groupName);
|
|
139
|
+
if (!fs.existsSync(groupDir)) {
|
|
140
|
+
done([]);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const branchDirs = fs.readdirSync(groupDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
|
|
145
|
+
const bdPath = path.join(groupDir, d.name);
|
|
146
|
+
for (const alias of repoAliases) {
|
|
147
|
+
const repoPath = config.repos[alias];
|
|
148
|
+
if (!repoPath) continue;
|
|
149
|
+
const subPath = path.join(bdPath, path.basename(repoPath));
|
|
150
|
+
if (fs.existsSync(subPath)) {
|
|
151
|
+
const branch = getCurrentBranch(subPath);
|
|
152
|
+
if (branch) return branch;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return d.name;
|
|
156
|
+
});
|
|
157
|
+
done(branchDirs.filter((b) => b.startsWith(current)));
|
|
158
|
+
} catch {
|
|
159
|
+
done([]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/cli.ts
|
|
164
|
+
var COMMANDS = [
|
|
165
|
+
{ names: ["init"], load: async () => (await import("./init-7ESFTYZC.js")).initCommand },
|
|
166
|
+
{ names: ["config"], load: async () => (await import("./config-IEIU7A66.js")).configCommand },
|
|
167
|
+
{ names: ["tree", "t"], load: async () => (await import("./tree-7BMORJ6J.js")).treeCommand },
|
|
168
|
+
{ names: ["remove"], load: async () => (await import("./remove-2UHJQ4DY.js")).removeCommand },
|
|
169
|
+
{ names: ["fork"], load: async () => (await import("./fork-BKI5UNNS.js")).forkCommand },
|
|
170
|
+
{ names: ["update"], load: async () => (await import("./update-6LQNLRA4.js")).updateCommand },
|
|
171
|
+
{ names: ["catchup"], load: async () => (await import("./catchup-VVOPL2S5.js")).catchupCommand },
|
|
172
|
+
{ names: ["snooze"], load: async () => (await import("./snooze-KYSFXLPY.js")).snoozeCommand },
|
|
173
|
+
{ names: ["pin"], load: async () => (await import("./pin-MQ5ZE37R.js")).pinCommand },
|
|
174
|
+
{ names: ["section"], load: async () => (await import("./section-TXLC5XO3.js")).sectionCommand },
|
|
175
|
+
{ names: ["note"], load: async () => (await import("./note-WGM6LCP2.js")).noteCommand },
|
|
176
|
+
{ names: ["block"], load: async () => (await import("./block-RAIDCJ4F.js")).blockCommand },
|
|
177
|
+
{ names: ["time"], load: async () => (await import("./time-GN6B4QD6.js")).timeCommand },
|
|
178
|
+
{ names: ["read"], load: async () => (await import("./read-AP6T3ZGN.js")).readCommand },
|
|
179
|
+
{ names: ["screen"], load: async () => (await import("./screen-DNX4K23V.js")).screenCommand },
|
|
180
|
+
{ names: ["send"], load: async () => (await import("./send-6X46WZLC.js")).sendCommand },
|
|
181
|
+
{ names: ["wait"], load: async () => (await import("./wait-MZOZQ3CI.js")).waitCommand },
|
|
182
|
+
{ names: ["start"], load: async () => (await import("./start-SQSDQK4F.js")).startCommand },
|
|
183
|
+
{ names: ["stop"], load: async () => (await import("./stop-HC7XPSSP.js")).stopCommand },
|
|
184
|
+
{ names: ["answer"], load: async () => (await import("./answer-2J4XLIP7.js")).answerCommand },
|
|
185
|
+
{ names: ["list"], load: async () => (await import("./list-KEF73NLQ.js")).listCommand },
|
|
186
|
+
{ names: ["status"], load: async () => (await import("./status-H5OW4LYE.js")).statusCommand },
|
|
187
|
+
{ names: ["recent"], load: async () => (await import("./recent-IE3LYQ65.js")).recentCommand },
|
|
188
|
+
{ names: ["resume"], load: async () => (await import("./resume-UUP6R2IE.js")).resumeCommand },
|
|
189
|
+
{ names: ["sessions"], load: async () => (await import("./sessions-T3QDTNP7.js")).sessionsCommand },
|
|
190
|
+
{ names: ["digest"], load: async () => (await import("./digest-FBZTBXQO.js")).digestCommand },
|
|
191
|
+
{ names: ["cleanup"], load: async () => (await import("./cleanup-X45MA74G.js")).cleanupCommand },
|
|
192
|
+
{ names: ["overlaps"], load: async () => (await import("./overlaps-FRLMMIGC.js")).overlapsCommand },
|
|
193
|
+
{ names: ["search"], load: async () => (await import("./search-3JZXLCR2.js")).searchCommand },
|
|
194
|
+
{ names: ["pr"], load: async () => (await import("./pr-YU3NOW6G.js")).prCommand },
|
|
195
|
+
{ names: ["prune"], load: async () => (await import("./prune-26FYYFTO.js")).pruneCommand },
|
|
196
|
+
{ names: ["sync"], load: async () => (await import("./sync-3CTAXM6J.js")).syncCommand },
|
|
197
|
+
{ names: ["todo"], load: async () => (await import("./todo-LWMQY6XW.js")).todoCommand },
|
|
198
|
+
{ names: ["hydrate"], load: async () => (await import("./hydrate-Y2AAMZTA.js")).hydrateCommand },
|
|
199
|
+
{ names: ["diff"], load: async () => (await import("./diff-K47HB6SA.js")).diffCommand },
|
|
200
|
+
{ names: ["web"], load: async () => (await import("./web-BI3MRQEM.js")).webCommand },
|
|
201
|
+
{ names: ["hook"], load: async () => (await import("./hook-SLMZT5OV.js")).hookCommand },
|
|
202
|
+
{ names: ["run"], load: async () => (await import("./run-V4755W7C.js")).runCommand },
|
|
203
|
+
{ names: ["broadcast"], load: async () => (await import("./broadcast-BSI5NDDB.js")).broadcastCommand },
|
|
204
|
+
{ names: ["attach", "a"], load: async () => (await import("./attach-CZKRNPAJ.js")).attachCommand },
|
|
205
|
+
{ names: ["pty-host"], load: async () => (await import("./pty-host-RWIS55N4.js")).ptyHostCommand },
|
|
206
|
+
{ names: ["state"], load: async () => (await import("./state-4DFV6SHG.js")).stateCommand },
|
|
207
|
+
{ names: ["move"], load: async () => (await import("./move-FKT2P5LY.js")).moveCommand },
|
|
208
|
+
{ names: ["install-skills"], load: async () => (await import("./install-skills-O34BHFHD.js")).installSkillsCommand },
|
|
209
|
+
{ names: ["completion"], load: async () => (await import("./completion-MXX5TRIV.js")).completionCommand }
|
|
210
|
+
];
|
|
211
|
+
async function commandsFor(argv) {
|
|
212
|
+
const one = COMMANDS.find((c) => c.names.includes(argv[0] ?? ""));
|
|
213
|
+
return Promise.all((one ? [one] : COMMANDS).map((c) => c.load()));
|
|
214
|
+
}
|
|
215
|
+
function showHelp() {
|
|
216
|
+
console.log("");
|
|
217
|
+
console.log(chalk.cyan(`Work - Git Worktree Manager ${chalk.gray(`v${VERSION}`)}`));
|
|
218
|
+
console.log(chalk.cyan("============================"));
|
|
219
|
+
console.log("");
|
|
220
|
+
console.log(chalk.green("Usage:"));
|
|
221
|
+
console.log(" work init - Set up configuration");
|
|
222
|
+
console.log(" work config <action> - Manage configuration");
|
|
223
|
+
console.log(" work list [project|group] - List all worktrees");
|
|
224
|
+
console.log(" work tree|t <project|group> <branch> - Create/switch to worktree");
|
|
225
|
+
console.log(" work tree <project|group> <branch> --base <branch> - Create from a specific base branch");
|
|
226
|
+
console.log(" work tree <project|group> <branch> --open - Also open VS Code");
|
|
227
|
+
console.log(" work tree <project|group> <branch> --unsafe - Skip AI tool permission checks");
|
|
228
|
+
console.log(" work remove <project|group> <branch> - Remove worktree");
|
|
229
|
+
console.log(" work remove <project|group> <branch> --force - Force remove worktree");
|
|
230
|
+
console.log(" work status [project|group] [branch] - Show worktree status");
|
|
231
|
+
console.log(" work status --prune - Remove stale entries");
|
|
232
|
+
console.log(" work recent [count] - List recent sessions");
|
|
233
|
+
console.log(" work resume - Resume a recent session");
|
|
234
|
+
console.log(" work sessions [project] [--json] [--changes] - Every session with its status, as the dashboard shows it");
|
|
235
|
+
console.log(" work digest [--since today|yesterday|week] - What each session did (Markdown for a standup; --json)");
|
|
236
|
+
console.log(" work overlaps [--json] - Live sessions changing the same files");
|
|
237
|
+
console.log(" work cleanup [--json] - Which worktrees can go, and why");
|
|
238
|
+
console.log(" work cleanup --apply <id...> [--action \u2026] - Remove / archive / forget them, after a fresh check");
|
|
239
|
+
console.log(" work web - Browser dashboard (one tab, every session)");
|
|
240
|
+
console.log(" work prune - Remove merged worktrees");
|
|
241
|
+
console.log(" work prune --force - Remove all merged (no prompt)");
|
|
242
|
+
console.log(" work sync - Fetch all repos and prune merged (non-interactive)");
|
|
243
|
+
console.log(" work sync --dry-run - Show what sync would prune, remove nothing");
|
|
244
|
+
console.log(" work sync --force - Also remove merged worktrees with uncommitted changes");
|
|
245
|
+
console.log(" work sync --include-squash - Also prune squash-merged branches (lower confidence)");
|
|
246
|
+
console.log(" work hydrate - Seed history from worktrees on disk");
|
|
247
|
+
console.log(" work diff [base] - Open a GitHub-PR-style diff in your browser");
|
|
248
|
+
console.log(" work run <cmd...> - Run a command in every worktree");
|
|
249
|
+
console.log(" work run <cmd...> --target <alias> --parallel - Filter + run concurrently");
|
|
250
|
+
console.log(" work broadcast <prompt> - Queue a prompt to every live session");
|
|
251
|
+
console.log(" work attach [target] [branch] - Attach this terminal to a session (Ctrl+] detaches)");
|
|
252
|
+
console.log(" work todo - List tasks");
|
|
253
|
+
console.log(" work todo add <text> - Add a task");
|
|
254
|
+
console.log(" work todo done <id> - Mark task complete");
|
|
255
|
+
console.log(" work todo rm <id> - Remove a task");
|
|
256
|
+
console.log(" work completion --install - Install shell completions");
|
|
257
|
+
console.log("");
|
|
258
|
+
console.log(chalk.green("Config Actions:"));
|
|
259
|
+
console.log(" work config add <alias> <path> - Add a repository");
|
|
260
|
+
console.log(" work config remove <alias> - Remove a repository");
|
|
261
|
+
console.log(" work config list - List repos and groups");
|
|
262
|
+
console.log(" work config group add <name> <alias1> <alias2> ... - Create a repository group");
|
|
263
|
+
console.log(" work config group remove <name> - Remove a repository group");
|
|
264
|
+
console.log(" work config group regen <name> - Regenerate group CLAUDE.md");
|
|
265
|
+
console.log("");
|
|
266
|
+
console.log(chalk.green("Examples:"));
|
|
267
|
+
console.log(" work init");
|
|
268
|
+
console.log(" work list");
|
|
269
|
+
console.log(" work list ai");
|
|
270
|
+
console.log(" work tree ai feature/login");
|
|
271
|
+
console.log(" work tree frontend feature/login --open");
|
|
272
|
+
console.log(" work tree ai feature/hotfix --unsafe");
|
|
273
|
+
console.log(" work remove ai feature/login");
|
|
274
|
+
console.log("");
|
|
275
|
+
console.log(chalk.gray(" # Groups (multi-repo worktrees):"));
|
|
276
|
+
console.log(" work config group add fullstack api frontend");
|
|
277
|
+
console.log(" work tree fullstack feature/login");
|
|
278
|
+
console.log(" work remove fullstack feature/login");
|
|
279
|
+
console.log("");
|
|
280
|
+
}
|
|
281
|
+
async function run(argv) {
|
|
282
|
+
if (argv.length === 0) {
|
|
283
|
+
showHelp();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
let cli = yargs(argv).scriptName("work").usage("$0 <command> [options]");
|
|
287
|
+
for (const c of await commandsFor(argv)) cli = cli.command(c);
|
|
288
|
+
cli = cli.completion("__completions", false, completionHandler).demandCommand(1, "You need to specify a command. Run work --help for usage.").strict().fail((msg, err, yargs2) => {
|
|
289
|
+
if (err?.name === "ExitPromptError") {
|
|
290
|
+
console.log("\nCancelled.");
|
|
291
|
+
process.exit(0);
|
|
292
|
+
}
|
|
293
|
+
if (msg) {
|
|
294
|
+
yargs2.showHelp();
|
|
295
|
+
console.error("\n" + msg);
|
|
296
|
+
}
|
|
297
|
+
if (err) console.error(err);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}).help().alias("h", "help").version(VERSION).alias("v", "version").wrap(Math.min(100, process.stdout.columns || 80));
|
|
300
|
+
void cli.parse();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export {
|
|
304
|
+
COMMANDS,
|
|
305
|
+
commandsFor,
|
|
306
|
+
run
|
|
307
|
+
};
|
|
308
|
+
//# sourceMappingURL=chunk-7H4BJ2YA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/completions/index.ts"],"sourcesContent":["import chalk from 'chalk';\nimport yargs from 'yargs';\nimport type { CommandModule } from 'yargs';\nimport { completionHandler } from './completions/index.js';\nimport { VERSION } from './version.js';\n\n/**\n * Every command, in the order `work --help` lists them, by the words that\n * run it. `work <verb>` imports only that verb's module: loading all of them\n * (node-pty, the servers, SQLite, the prompts) made every command — and\n * Claude's `work sessions --json` — start in ~430 ms. Help, completion and\n * anything unknown load them all. A test keeps the words equal to the\n * commands' own names and aliases.\n */\nexport const COMMANDS: Array<{ names: string[]; load: () => Promise<CommandModule> }> = [\n { names: ['init'], load: async () => (await import('./commands/init.js')).initCommand },\n { names: ['config'], load: async () => (await import('./commands/config.js')).configCommand },\n { names: ['tree', 't'], load: async () => (await import('./commands/tree.js')).treeCommand },\n { names: ['remove'], load: async () => (await import('./commands/remove.js')).removeCommand },\n { names: ['fork'], load: async () => (await import('./commands/fork.js')).forkCommand },\n { names: ['update'], load: async () => (await import('./commands/update.js')).updateCommand },\n { names: ['catchup'], load: async () => (await import('./commands/catchup.js')).catchupCommand },\n { names: ['snooze'], load: async () => (await import('./commands/snooze.js')).snoozeCommand },\n { names: ['pin'], load: async () => (await import('./commands/pin.js')).pinCommand },\n { names: ['section'], load: async () => (await import('./commands/section.js')).sectionCommand },\n { names: ['note'], load: async () => (await import('./commands/note.js')).noteCommand },\n { names: ['block'], load: async () => (await import('./commands/block.js')).blockCommand },\n { names: ['time'], load: async () => (await import('./commands/time.js')).timeCommand },\n { names: ['read'], load: async () => (await import('./commands/read.js')).readCommand },\n { names: ['screen'], load: async () => (await import('./commands/screen.js')).screenCommand },\n { names: ['send'], load: async () => (await import('./commands/send.js')).sendCommand },\n { names: ['wait'], load: async () => (await import('./commands/wait.js')).waitCommand },\n { names: ['start'], load: async () => (await import('./commands/start.js')).startCommand },\n { names: ['stop'], load: async () => (await import('./commands/stop.js')).stopCommand },\n { names: ['answer'], load: async () => (await import('./commands/answer.js')).answerCommand },\n { names: ['list'], load: async () => (await import('./commands/list.js')).listCommand },\n { names: ['status'], load: async () => (await import('./commands/status.js')).statusCommand },\n { names: ['recent'], load: async () => (await import('./commands/recent.js')).recentCommand },\n { names: ['resume'], load: async () => (await import('./commands/resume.js')).resumeCommand },\n { names: ['sessions'], load: async () => (await import('./commands/sessions.js')).sessionsCommand },\n { names: ['digest'], load: async () => (await import('./commands/digest.js')).digestCommand },\n { names: ['cleanup'], load: async () => (await import('./commands/cleanup.js')).cleanupCommand },\n { names: ['overlaps'], load: async () => (await import('./commands/overlaps.js')).overlapsCommand },\n { names: ['search'], load: async () => (await import('./commands/search.js')).searchCommand },\n { names: ['pr'], load: async () => (await import('./commands/pr.js')).prCommand },\n { names: ['prune'], load: async () => (await import('./commands/prune.js')).pruneCommand },\n { names: ['sync'], load: async () => (await import('./commands/sync.js')).syncCommand },\n { names: ['todo'], load: async () => (await import('./commands/todo.js')).todoCommand },\n { names: ['hydrate'], load: async () => (await import('./commands/hydrate.js')).hydrateCommand },\n { names: ['diff'], load: async () => (await import('./commands/diff.js')).diffCommand },\n { names: ['web'], load: async () => (await import('./commands/web.js')).webCommand },\n { names: ['hook'], load: async () => (await import('./commands/hook.js')).hookCommand },\n { names: ['run'], load: async () => (await import('./commands/run.js')).runCommand },\n { names: ['broadcast'], load: async () => (await import('./commands/broadcast.js')).broadcastCommand },\n { names: ['attach', 'a'], load: async () => (await import('./commands/attach.js')).attachCommand },\n { names: ['pty-host'], load: async () => (await import('./commands/pty-host.js')).ptyHostCommand },\n { names: ['state'], load: async () => (await import('./commands/state.js')).stateCommand },\n { names: ['move'], load: async () => (await import('./commands/move.js')).moveCommand },\n { names: ['install-skills'], load: async () => (await import('./commands/install-skills.js')).installSkillsCommand },\n { names: ['completion'], load: async () => (await import('./commands/completion.js')).completionCommand },\n];\n\n/** The commands to register for these arguments: the one named, else all. */\nexport async function commandsFor(argv: string[]): Promise<CommandModule[]> {\n const one = COMMANDS.find((c) => c.names.includes(argv[0] ?? ''));\n return Promise.all((one ? [one] : COMMANDS).map((c) => c.load()));\n}\n\nfunction showHelp() {\n console.log('');\n console.log(chalk.cyan(`Work - Git Worktree Manager ${chalk.gray(`v${VERSION}`)}`));\n console.log(chalk.cyan('============================'));\n console.log('');\n console.log(chalk.green('Usage:'));\n console.log(' work init - Set up configuration');\n console.log(' work config <action> - Manage configuration');\n console.log(' work list [project|group] - List all worktrees');\n console.log(' work tree|t <project|group> <branch> - Create/switch to worktree');\n console.log(' work tree <project|group> <branch> --base <branch> - Create from a specific base branch');\n console.log(' work tree <project|group> <branch> --open - Also open VS Code');\n console.log(' work tree <project|group> <branch> --unsafe - Skip AI tool permission checks');\n console.log(' work remove <project|group> <branch> - Remove worktree');\n console.log(' work remove <project|group> <branch> --force - Force remove worktree');\n console.log(' work status [project|group] [branch] - Show worktree status');\n console.log(' work status --prune - Remove stale entries');\n console.log(' work recent [count] - List recent sessions');\n console.log(' work resume - Resume a recent session');\n console.log(' work sessions [project] [--json] [--changes] - Every session with its status, as the dashboard shows it');\n console.log(' work digest [--since today|yesterday|week] - What each session did (Markdown for a standup; --json)');\n console.log(' work overlaps [--json] - Live sessions changing the same files');\n console.log(' work cleanup [--json] - Which worktrees can go, and why');\n console.log(' work cleanup --apply <id...> [--action …] - Remove / archive / forget them, after a fresh check');\n console.log(' work web - Browser dashboard (one tab, every session)');\n console.log(' work prune - Remove merged worktrees');\n console.log(' work prune --force - Remove all merged (no prompt)');\n console.log(' work sync - Fetch all repos and prune merged (non-interactive)');\n console.log(' work sync --dry-run - Show what sync would prune, remove nothing');\n console.log(' work sync --force - Also remove merged worktrees with uncommitted changes');\n console.log(' work sync --include-squash - Also prune squash-merged branches (lower confidence)');\n console.log(' work hydrate - Seed history from worktrees on disk');\n console.log(' work diff [base] - Open a GitHub-PR-style diff in your browser');\n console.log(' work run <cmd...> - Run a command in every worktree');\n console.log(' work run <cmd...> --target <alias> --parallel - Filter + run concurrently');\n console.log(' work broadcast <prompt> - Queue a prompt to every live session');\n console.log(' work attach [target] [branch] - Attach this terminal to a session (Ctrl+] detaches)');\n console.log(' work todo - List tasks');\n console.log(' work todo add <text> - Add a task');\n console.log(' work todo done <id> - Mark task complete');\n console.log(' work todo rm <id> - Remove a task');\n console.log(' work completion --install - Install shell completions');\n console.log('');\n console.log(chalk.green('Config Actions:'));\n console.log(' work config add <alias> <path> - Add a repository');\n console.log(' work config remove <alias> - Remove a repository');\n console.log(' work config list - List repos and groups');\n console.log(' work config group add <name> <alias1> <alias2> ... - Create a repository group');\n console.log(' work config group remove <name> - Remove a repository group');\n console.log(' work config group regen <name> - Regenerate group CLAUDE.md');\n console.log('');\n console.log(chalk.green('Examples:'));\n console.log(' work init');\n console.log(' work list');\n console.log(' work list ai');\n console.log(' work tree ai feature/login');\n console.log(' work tree frontend feature/login --open');\n console.log(' work tree ai feature/hotfix --unsafe');\n console.log(' work remove ai feature/login');\n console.log('');\n console.log(chalk.gray(' # Groups (multi-repo worktrees):'));\n console.log(' work config group add fullstack api frontend');\n console.log(' work tree fullstack feature/login');\n console.log(' work remove fullstack feature/login');\n console.log('');\n}\n\nexport async function run(argv: string[]): Promise<void> {\n // Show custom colored help when no args given\n if (argv.length === 0) {\n showHelp();\n return;\n }\n\n let cli = yargs(argv).scriptName('work').usage('$0 <command> [options]');\n for (const c of await commandsFor(argv)) cli = cli.command(c);\n cli = cli\n // Hidden: yargs uses this internally for --get-yargs-completions\n .completion('__completions', false, completionHandler)\n .demandCommand(1, 'You need to specify a command. Run work --help for usage.')\n .strict()\n .fail((msg, err, yargs) => {\n if (err?.name === 'ExitPromptError') {\n console.log('\\nCancelled.');\n process.exit(0);\n }\n if (msg) {\n yargs.showHelp();\n console.error('\\n' + msg);\n }\n if (err) console.error(err);\n process.exit(1);\n })\n .help()\n .alias('h', 'help')\n .version(VERSION)\n .alias('v', 'version')\n .wrap(Math.min(100, process.stdout.columns || 80));\n\n // Async handlers' failures land in .fail() above (and the fatal handlers in bin.ts).\n void cli.parse();\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { loadConfig } from '../core/platform/config.js';\nimport { parseWorktreeList, getCurrentBranch } from '../core/git/git.js';\nimport { resolveProjectTarget } from '../core/worktree/resolve.js';\n\ntype Done = (completions: string[]) => void;\n\n/**\n * Dynamic completion handler for yargs.\n * Called when the user presses TAB (via --get-yargs-completions).\n *\n * argv._ = ['<scriptName>', '<command>', '<arg1>', ...., '<current>']\n * We skip the script name and the trailing current word to get the \"completed\" args.\n */\nexport function completionHandler(current: string, argv: Record<string, unknown>, done: Done): void {\n const rawArgs = argv._ as string[];\n\n // Skip the script name (first element) and the trailing current word (last element)\n const args = rawArgs.slice(1, -1);\n const command = args[0] as string | undefined;\n\n const config = loadConfig();\n if (!config) {\n done([]);\n return;\n }\n\n if (!command) {\n done(\n [\n 'tree',\n 't',\n 'remove',\n 'list',\n 'status',\n 'recent',\n 'resume',\n 'prune',\n 'todo',\n 'attach',\n 'hydrate',\n 'diff',\n 'web',\n 'init',\n 'config',\n 'completion',\n ].filter((c) => c.startsWith(current)),\n );\n return;\n }\n\n switch (command) {\n case 'config':\n completeConfig(args, current, config, done);\n return;\n\n case 'tree':\n case 't':\n case 'remove':\n case 'list':\n case 'status':\n completeTreeRemoveList(command, args, current, config, done);\n return;\n\n default:\n done([]);\n }\n}\n\nfunction completeConfig(args: string[], current: string, config: NonNullable<ReturnType<typeof loadConfig>>, done: Done): void {\n const subAction = args[1] as string | undefined;\n\n if (!subAction) {\n const actions = ['add', 'remove', 'list', 'group', 'show', 'edit'];\n done(actions.filter((a) => a.startsWith(current)));\n return;\n }\n\n if (subAction === 'remove' && args.length === 2) {\n const aliases = Object.keys(config.repos);\n done(aliases.filter((a) => a.startsWith(current)));\n return;\n }\n\n if (subAction === 'group') {\n const groupSub = args[2] as string | undefined;\n\n if (!groupSub) {\n const subs = ['add', 'remove', 'regen'];\n done(subs.filter((s) => s.startsWith(current)));\n return;\n }\n\n if ((groupSub === 'remove' || groupSub === 'regen') && args.length === 3) {\n const groups = Object.keys(config.groups);\n done(groups.filter((g) => g.startsWith(current)));\n return;\n }\n\n if (groupSub === 'add' && args.length >= 4) {\n const alreadyUsed = args.slice(3);\n const aliases = Object.keys(config.repos).filter((a) => !alreadyUsed.includes(a));\n done(aliases.filter((a) => a.startsWith(current)));\n return;\n }\n\n done([]);\n return;\n }\n\n done([]);\n}\n\nfunction completeTreeRemoveList(\n command: string,\n args: string[],\n current: string,\n config: NonNullable<ReturnType<typeof loadConfig>>,\n done: Done,\n): void {\n const targetName = args[1] as string | undefined;\n\n if (!targetName) {\n const names = [...Object.keys(config.repos), ...Object.keys(config.groups)];\n done(names.filter((n) => n.startsWith(current)));\n return;\n }\n\n if (args.length === 2) {\n const target = resolveProjectTarget(targetName, config);\n if (!target) {\n done([]);\n return;\n }\n\n if (target.isGroup) {\n completeGroupBranches(target.name, target.repoAliases, current, config, done);\n } else {\n completeRepoBranches(targetName, current, config, done);\n }\n return;\n }\n\n done([]);\n}\n\nfunction completeRepoBranches(alias: string, current: string, config: NonNullable<ReturnType<typeof loadConfig>>, done: Done): void {\n const repoPath = config.repos[alias];\n if (!repoPath || !fs.existsSync(repoPath)) {\n done([]);\n return;\n }\n\n const worktrees = parseWorktreeList(repoPath);\n const branches = worktrees.map((wt) => wt.branch).filter((b): b is string => !!b && b.startsWith(current));\n done(branches);\n}\n\nfunction completeGroupBranches(\n groupName: string,\n repoAliases: string[],\n current: string,\n config: NonNullable<ReturnType<typeof loadConfig>>,\n done: Done,\n): void {\n const groupDir = path.join(config.worktreesRoot, groupName);\n if (!fs.existsSync(groupDir)) {\n done([]);\n return;\n }\n\n try {\n const branchDirs = fs\n .readdirSync(groupDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => {\n const bdPath = path.join(groupDir, d.name);\n for (const alias of repoAliases) {\n const repoPath = config.repos[alias];\n if (!repoPath) continue;\n const subPath = path.join(bdPath, path.basename(repoPath));\n if (fs.existsSync(subPath)) {\n const branch = getCurrentBranch(subPath);\n if (branch) return branch;\n }\n }\n return d.name;\n });\n\n done(branchDirs.filter((b) => b.startsWith(current)));\n } catch {\n done([]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAA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,IAAI,uCAAuC;AACnD,UAAQ,IAAI,EAAE;AAChB;AAEA,eAAsB,IAAI,MAA+B;AAEvD,MAAI,KAAK,WAAW,GAAG;AACrB,aAAS;AACT;AAAA,EACF;AAEA,MAAI,MAAM,MAAM,IAAI,EAAE,WAAW,MAAM,EAAE,MAAM,wBAAwB;AACvE,aAAW,KAAK,MAAM,YAAY,IAAI,EAAG,OAAM,IAAI,QAAQ,CAAC;AAC5D,QAAM,IAEH,WAAW,iBAAiB,OAAO,iBAAiB,EACpD,cAAc,GAAG,2DAA2D,EAC5E,OAAO,EACP,KAAK,CAAC,KAAK,KAAKA,WAAU;AACzB,QAAI,KAAK,SAAS,mBAAmB;AACnC,cAAQ,IAAI,cAAc;AAC1B,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,QAAI,KAAK;AACP,MAAAA,OAAM,SAAS;AACf,cAAQ,MAAM,OAAO,GAAG;AAAA,IAC1B;AACA,QAAI,IAAK,SAAQ,MAAM,GAAG;AAC1B,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC,EACA,KAAK,EACL,MAAM,KAAK,MAAM,EACjB,QAAQ,OAAO,EACf,MAAM,KAAK,SAAS,EACpB,KAAK,KAAK,IAAI,KAAK,QAAQ,OAAO,WAAW,EAAE,CAAC;AAGnD,OAAK,IAAI,MAAM;AACjB;","names":["yargs"]}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/platform/fs-safe.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
var lockfileModule = null;
|
|
8
|
+
var lockfile = () => lockfileModule ??= createRequire(import.meta.url)("proper-lockfile");
|
|
9
|
+
function resolveLinkTarget(filePath) {
|
|
10
|
+
let current = filePath;
|
|
11
|
+
const seen = /* @__PURE__ */ new Set([current]);
|
|
12
|
+
for (let i = 0; i < 32; i++) {
|
|
13
|
+
let stat;
|
|
14
|
+
try {
|
|
15
|
+
stat = fs.lstatSync(current);
|
|
16
|
+
} catch {
|
|
17
|
+
return current;
|
|
18
|
+
}
|
|
19
|
+
if (!stat.isSymbolicLink()) return current;
|
|
20
|
+
const next = path.resolve(path.dirname(current), fs.readlinkSync(current));
|
|
21
|
+
if (seen.has(next)) return filePath;
|
|
22
|
+
seen.add(next);
|
|
23
|
+
current = next;
|
|
24
|
+
}
|
|
25
|
+
return filePath;
|
|
26
|
+
}
|
|
27
|
+
function atomicWriteFile(filePath, content, renameSync = fs.renameSync) {
|
|
28
|
+
const target = resolveLinkTarget(filePath);
|
|
29
|
+
const tmpPath = `${target}.tmp-${process.pid}`;
|
|
30
|
+
fs.writeFileSync(tmpPath, content, "utf-8");
|
|
31
|
+
try {
|
|
32
|
+
fs.chmodSync(tmpPath, fs.statSync(target).mode & 511);
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
for (let attempt = 0; ; attempt++) {
|
|
36
|
+
try {
|
|
37
|
+
renameSync(tmpPath, target);
|
|
38
|
+
return;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
const code = err.code;
|
|
41
|
+
if ((code === "EPERM" || code === "EACCES" || code === "EBUSY") && attempt < 12) {
|
|
42
|
+
sleepSync(Math.min(20 * 2 ** attempt, 400));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
fs.unlinkSync(tmpPath);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function ensureFile(filePath, initialContent) {
|
|
54
|
+
if (!fs.existsSync(filePath)) {
|
|
55
|
+
fs.writeFileSync(filePath, initialContent, "utf-8");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function withFileLock(filePath, fn) {
|
|
59
|
+
const release = await lockfile().lock(filePath, {
|
|
60
|
+
retries: { retries: 20, minTimeout: 25, maxTimeout: 500, factor: 2 },
|
|
61
|
+
stale: 1e4
|
|
62
|
+
});
|
|
63
|
+
try {
|
|
64
|
+
return await fn();
|
|
65
|
+
} finally {
|
|
66
|
+
await release();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function withFileLockSync(filePath, fn) {
|
|
70
|
+
const maxAttempts = 30;
|
|
71
|
+
let release;
|
|
72
|
+
for (let attempt = 0; ; attempt++) {
|
|
73
|
+
try {
|
|
74
|
+
release = lockfile().lockSync(filePath, { stale: 1e4 });
|
|
75
|
+
break;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
const code = err.code;
|
|
78
|
+
if (code !== "ELOCKED" || attempt >= maxAttempts) throw err;
|
|
79
|
+
sleepSync(Math.min(25 * 2 ** Math.min(attempt, 4), 500));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return fn();
|
|
84
|
+
} finally {
|
|
85
|
+
release();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function sleepSync(ms) {
|
|
89
|
+
const shared = new Int32Array(new SharedArrayBuffer(4));
|
|
90
|
+
Atomics.wait(shared, 0, 0, ms);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/core/platform/config.ts
|
|
94
|
+
import fs2 from "fs";
|
|
95
|
+
import path2 from "path";
|
|
96
|
+
import os from "os";
|
|
97
|
+
|
|
98
|
+
// src/core/sessions/saved-prompts.ts
|
|
99
|
+
var DEFAULT_PROMPTS = [
|
|
100
|
+
{
|
|
101
|
+
label: "Review your changes",
|
|
102
|
+
prompt: "Review the changes on this branch as a strict reviewer would: bugs, missing edge cases, missing tests, leftovers (debug output, TODOs, dead code). Fix what you find, then tell me briefly what you changed."
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: "Add tests",
|
|
106
|
+
prompt: "Add tests for what changed on this branch, following the existing test patterns in this repo. Run them and fix anything that fails."
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: "Run checks and fix",
|
|
110
|
+
prompt: "Run this repo's type check, lint and tests (whatever it has). Fix what fails, and tell me if something is failing for a reason outside this change."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: "Commit",
|
|
114
|
+
prompt: "Commit the current changes with a clear message in this repo's commit style. Don't push."
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: "Open a pull request",
|
|
118
|
+
prompt: "Push this branch and open a pull request for it with `gh pr create`. Write the title and description yourself from what we did in this conversation: what changed and why, how it was tested, anything a reviewer should look at first. Put the Jira key in the title if the branch or our conversation has one. Open it ready for review, not as a draft, and give me its link."
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: "Rebase on the default branch",
|
|
122
|
+
prompt: "Fetch, then rebase this branch on origin's default branch. Resolve conflicts keeping both sides' intent, run the tests, and tell me about any conflict you weren't sure of."
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
var MAX_PROMPT = 2e4;
|
|
126
|
+
function validatePrompts(raw) {
|
|
127
|
+
if (!Array.isArray(raw)) return void 0;
|
|
128
|
+
const out = [];
|
|
129
|
+
for (const p of raw) {
|
|
130
|
+
if (!p || typeof p !== "object") continue;
|
|
131
|
+
const { label, prompt, repos } = p;
|
|
132
|
+
if (typeof label !== "string" || !label.trim() || typeof prompt !== "string" || !prompt.trim()) continue;
|
|
133
|
+
const item = { label: label.trim(), prompt: prompt.trim().slice(0, MAX_PROMPT) };
|
|
134
|
+
if (Array.isArray(repos)) {
|
|
135
|
+
const names = repos.filter((r) => typeof r === "string" && r.length > 0);
|
|
136
|
+
if (names.length) item.repos = names;
|
|
137
|
+
}
|
|
138
|
+
out.push(item);
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/core/platform/config.ts
|
|
144
|
+
var MIN_PORT = 1024;
|
|
145
|
+
var MAX_PORT = 65535;
|
|
146
|
+
function validatePortRange(value) {
|
|
147
|
+
if (!value || typeof value !== "object") return void 0;
|
|
148
|
+
const { start, end } = value;
|
|
149
|
+
if (typeof start !== "number" || typeof end !== "number") return void 0;
|
|
150
|
+
if (!Number.isInteger(start) || !Number.isInteger(end)) return void 0;
|
|
151
|
+
if (start < MIN_PORT || end > MAX_PORT) return void 0;
|
|
152
|
+
if (start > end) return void 0;
|
|
153
|
+
return { start, end };
|
|
154
|
+
}
|
|
155
|
+
function getConfigDir() {
|
|
156
|
+
const dir = path2.join(os.homedir(), ".work");
|
|
157
|
+
if (!fs2.existsSync(dir)) {
|
|
158
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
159
|
+
}
|
|
160
|
+
return dir;
|
|
161
|
+
}
|
|
162
|
+
function isAgentId(v) {
|
|
163
|
+
return typeof v === "string" && /^[\w.-]+$/.test(v);
|
|
164
|
+
}
|
|
165
|
+
function getConfigPath() {
|
|
166
|
+
return path2.join(getConfigDir(), "config.json");
|
|
167
|
+
}
|
|
168
|
+
function validateDevCommands(raw) {
|
|
169
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
170
|
+
const out = {};
|
|
171
|
+
for (const [alias, cmd] of Object.entries(raw)) if (typeof cmd === "string" && cmd.trim()) out[alias] = cmd;
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
function stringList(raw) {
|
|
175
|
+
return Array.isArray(raw) ? raw.filter((x) => typeof x === "string" && x.trim().length > 0) : void 0;
|
|
176
|
+
}
|
|
177
|
+
function loadConfig() {
|
|
178
|
+
const configPath = getConfigPath();
|
|
179
|
+
if (!fs2.existsSync(configPath)) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const raw = fs2.readFileSync(configPath, "utf-8");
|
|
184
|
+
const parsed = JSON.parse(raw);
|
|
185
|
+
return {
|
|
186
|
+
worktreesRoot: parsed.worktreesRoot ?? "",
|
|
187
|
+
repos: parsed.repos ?? {},
|
|
188
|
+
groups: parsed.groups ?? {},
|
|
189
|
+
copyFiles: parsed.copyFiles ?? [],
|
|
190
|
+
scanRoots: stringList(parsed.scanRoots),
|
|
191
|
+
ignoredRepos: stringList(parsed.ignoredRepos),
|
|
192
|
+
aiCommand: parsed.aiCommand,
|
|
193
|
+
aiCommandFlags: parsed.aiCommandFlags,
|
|
194
|
+
editor: parsed.editor,
|
|
195
|
+
portRange: validatePortRange(parsed.portRange),
|
|
196
|
+
notifications: parsed.notifications === true,
|
|
197
|
+
statusHooks: Array.isArray(parsed.statusHooks) ? parsed.statusHooks : [],
|
|
198
|
+
launchViaHost: typeof parsed.launchViaHost === "boolean" ? parsed.launchViaHost : void 0,
|
|
199
|
+
devCommands: validateDevCommands(parsed.devCommands),
|
|
200
|
+
sleepIdleAfterMinutes: typeof parsed.sleepIdleAfterMinutes === "number" && parsed.sleepIdleAfterMinutes >= 0 ? parsed.sleepIdleAfterMinutes : void 0,
|
|
201
|
+
prompts: validatePrompts(parsed.prompts),
|
|
202
|
+
archive: parsed.archive && typeof parsed.archive === "object" ? {
|
|
203
|
+
...typeof parsed.archive.compressAfterDays === "number" && parsed.archive.compressAfterDays >= 0 ? { compressAfterDays: parsed.archive.compressAfterDays } : {},
|
|
204
|
+
...typeof parsed.archive.dropTranscriptsAfterDays === "number" && parsed.archive.dropTranscriptsAfterDays >= 0 ? { dropTranscriptsAfterDays: parsed.archive.dropTranscriptsAfterDays } : {}
|
|
205
|
+
} : void 0,
|
|
206
|
+
stacks: parsed.stacks && typeof parsed.stacks === "object" ? { autoUpdate: parsed.stacks.autoUpdate !== false } : void 0,
|
|
207
|
+
internalAgent: isAgentId(parsed.internalAgent) ? parsed.internalAgent : void 0,
|
|
208
|
+
assistantAgent: isAgentId(parsed.assistantAgent) ? parsed.assistantAgent : void 0,
|
|
209
|
+
hostEnv: Array.isArray(parsed.hostEnv) ? parsed.hostEnv.filter((n) => typeof n === "string" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(n)) : void 0,
|
|
210
|
+
jiraWorklog: parsed.jiraWorklog && typeof parsed.jiraWorklog === "object" && typeof parsed.jiraWorklog.site === "string" && typeof parsed.jiraWorklog.email === "string" ? {
|
|
211
|
+
site: parsed.jiraWorklog.site,
|
|
212
|
+
email: parsed.jiraWorklog.email,
|
|
213
|
+
...typeof parsed.jiraWorklog.tokenEnv === "string" ? { tokenEnv: parsed.jiraWorklog.tokenEnv } : {},
|
|
214
|
+
...typeof parsed.jiraWorklog.token === "string" ? { token: parsed.jiraWorklog.token } : {}
|
|
215
|
+
} : void 0,
|
|
216
|
+
prWatch: parsed.prWatch && typeof parsed.prWatch === "object" ? {
|
|
217
|
+
autoArchive: parsed.prWatch.autoArchive !== false,
|
|
218
|
+
fixCi: parsed.prWatch.fixCi !== false,
|
|
219
|
+
reviewComments: parsed.prWatch.reviewComments !== false,
|
|
220
|
+
...Array.isArray(parsed.prWatch.trustedBots) ? {
|
|
221
|
+
trustedBots: parsed.prWatch.trustedBots.filter(
|
|
222
|
+
(b) => typeof b === "string" && b.trim().length > 0
|
|
223
|
+
)
|
|
224
|
+
} : {},
|
|
225
|
+
wakeClaude: parsed.prWatch.wakeClaude !== false
|
|
226
|
+
} : void 0
|
|
227
|
+
};
|
|
228
|
+
} catch {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function saveConfig(config) {
|
|
233
|
+
atomicWriteFile(getConfigPath(), JSON.stringify(config, null, 2));
|
|
234
|
+
}
|
|
235
|
+
function ensureConfig() {
|
|
236
|
+
const config = loadConfig();
|
|
237
|
+
if (!config) {
|
|
238
|
+
throw new Error('Configuration not found. Run "work init" to set up.');
|
|
239
|
+
}
|
|
240
|
+
return config;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
resolveLinkTarget,
|
|
245
|
+
atomicWriteFile,
|
|
246
|
+
ensureFile,
|
|
247
|
+
withFileLock,
|
|
248
|
+
withFileLockSync,
|
|
249
|
+
DEFAULT_PROMPTS,
|
|
250
|
+
getConfigDir,
|
|
251
|
+
isAgentId,
|
|
252
|
+
getConfigPath,
|
|
253
|
+
loadConfig,
|
|
254
|
+
saveConfig,
|
|
255
|
+
ensureConfig
|
|
256
|
+
};
|
|
257
|
+
//# sourceMappingURL=chunk-7HEB6SQS.js.map
|