@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,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
printCleanupResults,
|
|
4
|
+
removable
|
|
5
|
+
} from "./chunk-ABQYKTG4.js";
|
|
6
|
+
import {
|
|
7
|
+
defaultCleanupDeps
|
|
8
|
+
} from "./chunk-YLG6DO5Y.js";
|
|
9
|
+
import "./chunk-CXEC5W5V.js";
|
|
10
|
+
import "./chunk-PZ4RG6EW.js";
|
|
11
|
+
import {
|
|
12
|
+
applyCleanup,
|
|
13
|
+
scanCleanup
|
|
14
|
+
} from "./chunk-AKMPF72Y.js";
|
|
15
|
+
import "./chunk-CLGVSX36.js";
|
|
16
|
+
import "./chunk-O3QTWVSK.js";
|
|
17
|
+
import "./chunk-ZJN5RWZD.js";
|
|
18
|
+
import "./chunk-QBAZG4CY.js";
|
|
19
|
+
import "./chunk-6H3MLDGG.js";
|
|
20
|
+
import "./chunk-FR3EWVXI.js";
|
|
21
|
+
import "./chunk-7OLPI334.js";
|
|
22
|
+
import "./chunk-H5LKMR45.js";
|
|
23
|
+
import "./chunk-SOCPIHCS.js";
|
|
24
|
+
import "./chunk-WF5SBVPZ.js";
|
|
25
|
+
import "./chunk-ZSHWP2VS.js";
|
|
26
|
+
import "./chunk-5QK7GB5K.js";
|
|
27
|
+
import "./chunk-HUXS3VAI.js";
|
|
28
|
+
import "./chunk-7NAXFBFI.js";
|
|
29
|
+
import "./chunk-NDWSLQPB.js";
|
|
30
|
+
import "./chunk-ZXPYWZL5.js";
|
|
31
|
+
import "./chunk-M4FVCAT6.js";
|
|
32
|
+
import "./chunk-7NCW3LUT.js";
|
|
33
|
+
import "./chunk-PN44M5EE.js";
|
|
34
|
+
import "./chunk-RCYI7SRA.js";
|
|
35
|
+
import "./chunk-DW4JPVXB.js";
|
|
36
|
+
import "./chunk-N4EYQKSM.js";
|
|
37
|
+
import {
|
|
38
|
+
ensureConfig
|
|
39
|
+
} from "./chunk-7HEB6SQS.js";
|
|
40
|
+
|
|
41
|
+
// src/commands/sync.ts
|
|
42
|
+
import chalk from "chalk";
|
|
43
|
+
var syncCommand = {
|
|
44
|
+
command: "sync",
|
|
45
|
+
describe: "Fetch all repos and remove merged worktrees (non-interactive)",
|
|
46
|
+
builder: (yargs) => yargs.option("dry-run", {
|
|
47
|
+
describe: "Show what would be removed without removing anything",
|
|
48
|
+
type: "boolean",
|
|
49
|
+
default: false
|
|
50
|
+
}).option("force", {
|
|
51
|
+
describe: "Also remove merged worktrees that have uncommitted changes (those changes are lost). A worktree with commits the main branch lacks is never removed.",
|
|
52
|
+
type: "boolean",
|
|
53
|
+
default: false
|
|
54
|
+
}).option("include-squash", {
|
|
55
|
+
describe: "Also remove branches detected as squash-merged (default: false \u2014 unattended sync requires a true merge)",
|
|
56
|
+
type: "boolean",
|
|
57
|
+
default: false
|
|
58
|
+
}),
|
|
59
|
+
handler: async (argv) => {
|
|
60
|
+
const dryRun = argv["dryRun"];
|
|
61
|
+
const force = argv["force"];
|
|
62
|
+
const includeSquash = argv["includeSquash"];
|
|
63
|
+
ensureConfig();
|
|
64
|
+
const deps = defaultCleanupDeps();
|
|
65
|
+
console.log(chalk.gray("Fetching all repos and checking worktrees\u2026\n"));
|
|
66
|
+
const scan = await scanCleanup(deps);
|
|
67
|
+
for (const f of scan.fetchFailed)
|
|
68
|
+
console.log(chalk.yellow(` Warning: fetch failed for ${f.alias} \u2014 skipping it (refs may be stale): ${f.error}`));
|
|
69
|
+
const chosen = removable(scan.candidates, { includeSquash, dirtyToo: force });
|
|
70
|
+
const skippedDirty = removable(scan.candidates, { includeSquash, dirtyToo: true }).length - chosen.length;
|
|
71
|
+
if (chosen.length === 0) {
|
|
72
|
+
console.log(chalk.green("No merged worktrees to remove. Everything is in sync."));
|
|
73
|
+
if (skippedDirty > 0) console.log(chalk.yellow(`Skipped ${skippedDirty} merged worktree(s) with local changes (use --force).`));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.log(chalk.cyan(`${dryRun ? "Would remove" : "Removing"} ${chosen.length} merged worktree(s):`));
|
|
77
|
+
for (const c of chosen) console.log(` ${c.target}: ${c.branch}${c.isGroup ? " [group]" : ""} \u2014 ${c.reason}`);
|
|
78
|
+
console.log("");
|
|
79
|
+
if (dryRun) {
|
|
80
|
+
console.log(chalk.yellow(`Dry run: nothing removed.`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const results = await applyCleanup(
|
|
84
|
+
deps,
|
|
85
|
+
chosen.map((c) => ({ sessionId: c.sessionId, action: c.verdict === "gone" ? "forget" : "delete" })),
|
|
86
|
+
{ force }
|
|
87
|
+
);
|
|
88
|
+
printCleanupResults(chosen, results);
|
|
89
|
+
if (skippedDirty > 0) console.log(chalk.yellow(`Skipped ${skippedDirty} merged worktree(s) with local changes (use --force).`));
|
|
90
|
+
if (results.some((r) => !r.ok && r.message.startsWith("git refused"))) process.exitCode = 1;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
syncCommand
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=sync-3CTAXM6J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/sync.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CommandModule } from 'yargs';\nimport { ensureConfig } from '../core/platform/config.js';\nimport { applyCleanup, scanCleanup } from '../core/cleanup/cleanup.js';\nimport { defaultCleanupDeps } from '../core/cleanup/cleanup-deps.js';\nimport { printCleanupResults, removable } from './shared/cleanup-print.js';\n\nexport const syncCommand: CommandModule = {\n command: 'sync',\n describe: 'Fetch all repos and remove merged worktrees (non-interactive)',\n builder: (yargs) =>\n yargs\n .option('dry-run', {\n describe: 'Show what would be removed without removing anything',\n type: 'boolean',\n default: false,\n })\n .option('force', {\n describe:\n 'Also remove merged worktrees that have uncommitted changes (those changes are lost). ' +\n 'A worktree with commits the main branch lacks is never removed.',\n type: 'boolean',\n default: false,\n })\n .option('include-squash', {\n describe: 'Also remove branches detected as squash-merged ' + '(default: false — unattended sync requires a true merge)',\n type: 'boolean',\n default: false,\n }),\n handler: async (argv) => {\n const dryRun = argv['dryRun'] as boolean;\n const force = argv['force'] as boolean;\n const includeSquash = argv['includeSquash'] as boolean;\n ensureConfig();\n const deps = defaultCleanupDeps();\n\n console.log(chalk.gray('Fetching all repos and checking worktrees…\\n'));\n const scan = await scanCleanup(deps);\n // A repo whose fetch failed has stale refs: its worktrees were not judged.\n for (const f of scan.fetchFailed)\n console.log(chalk.yellow(` Warning: fetch failed for ${f.alias} — skipping it (refs may be stale): ${f.error}`));\n\n const chosen = removable(scan.candidates, { includeSquash, dirtyToo: force });\n const skippedDirty = removable(scan.candidates, { includeSquash, dirtyToo: true }).length - chosen.length;\n if (chosen.length === 0) {\n console.log(chalk.green('No merged worktrees to remove. Everything is in sync.'));\n if (skippedDirty > 0) console.log(chalk.yellow(`Skipped ${skippedDirty} merged worktree(s) with local changes (use --force).`));\n return;\n }\n console.log(chalk.cyan(`${dryRun ? 'Would remove' : 'Removing'} ${chosen.length} merged worktree(s):`));\n for (const c of chosen) console.log(` ${c.target}: ${c.branch}${c.isGroup ? ' [group]' : ''} — ${c.reason}`);\n console.log('');\n if (dryRun) {\n console.log(chalk.yellow(`Dry run: nothing removed.`));\n return;\n }\n const results = await applyCleanup(\n deps,\n chosen.map((c) => ({ sessionId: c.sessionId, action: c.verdict === 'gone' ? ('forget' as const) : ('delete' as const) })),\n { force },\n );\n printCleanupResults(chosen, results);\n if (skippedDirty > 0) console.log(chalk.yellow(`Skipped ${skippedDirty} merged worktree(s) with local changes (use --force).`));\n // A removal that git refused is a failure for scripts; \"changed since the\n // scan\" is a safe skip, counted in the summary above.\n if (results.some((r) => !r.ok && r.message.startsWith('git refused'))) process.exitCode = 1;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAOX,IAAM,cAA6B;AAAA,EACxC,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UACR,MACG,OAAO,WAAW;AAAA,IACjB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,EACX,CAAC,EACA,OAAO,SAAS;AAAA,IACf,UACE;AAAA,IAEF,MAAM;AAAA,IACN,SAAS;AAAA,EACX,CAAC,EACA,OAAO,kBAAkB;AAAA,IACxB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,EACX,CAAC;AAAA,EACL,SAAS,OAAO,SAAS;AACvB,UAAM,SAAS,KAAK,QAAQ;AAC5B,UAAM,QAAQ,KAAK,OAAO;AAC1B,UAAM,gBAAgB,KAAK,eAAe;AAC1C,iBAAa;AACb,UAAM,OAAO,mBAAmB;AAEhC,YAAQ,IAAI,MAAM,KAAK,mDAA8C,CAAC;AACtE,UAAM,OAAO,MAAM,YAAY,IAAI;AAEnC,eAAW,KAAK,KAAK;AACnB,cAAQ,IA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WorkDay,
|
|
5
|
+
loggedDays,
|
|
6
|
+
sessionWorkTime,
|
|
7
|
+
worklogSettings
|
|
8
|
+
} from "./chunk-YKODIG22.js";
|
|
9
|
+
import {
|
|
10
|
+
sessionFromArgs,
|
|
11
|
+
sessionPositionals
|
|
12
|
+
} from "./chunk-HSICXDMZ.js";
|
|
13
|
+
import "./chunk-6AQRYLOB.js";
|
|
14
|
+
import "./chunk-WF5SBVPZ.js";
|
|
15
|
+
import "./chunk-ZSHWP2VS.js";
|
|
16
|
+
import "./chunk-5QK7GB5K.js";
|
|
17
|
+
import "./chunk-HUXS3VAI.js";
|
|
18
|
+
import {
|
|
19
|
+
dayKey,
|
|
20
|
+
formatWorked,
|
|
21
|
+
loadHistory,
|
|
22
|
+
worklogTime
|
|
23
|
+
} from "./chunk-M4FVCAT6.js";
|
|
24
|
+
import {
|
|
25
|
+
sessionIdFor
|
|
26
|
+
} from "./chunk-7NCW3LUT.js";
|
|
27
|
+
import "./chunk-PN44M5EE.js";
|
|
28
|
+
import "./chunk-RCYI7SRA.js";
|
|
29
|
+
import "./chunk-DW4JPVXB.js";
|
|
30
|
+
import "./chunk-N4EYQKSM.js";
|
|
31
|
+
import {
|
|
32
|
+
loadConfig
|
|
33
|
+
} from "./chunk-7HEB6SQS.js";
|
|
34
|
+
|
|
35
|
+
// src/commands/time.ts
|
|
36
|
+
import chalk from "chalk";
|
|
37
|
+
var timeCommand = {
|
|
38
|
+
command: "time [target] [branch]",
|
|
39
|
+
describe: "How long sessions' Claude worked: one session per day, or --all (a weekly report); --log writes it to Jira",
|
|
40
|
+
builder: (yargs) => sessionPositionals(yargs).option("all", { type: "boolean", describe: "Every session, the last --days days (default 7)" }).option("days", { type: "number", default: 7, describe: "With --all: how many days back" }).option("log", { type: "boolean", describe: "Write a day's work to the session's Jira issue as a worklog (what isn't logged yet)" }).option("day", { type: "string", describe: "With --log: which day (YYYY-MM-DD; default: the latest it worked)" }).conflicts("all", "log"),
|
|
41
|
+
handler: async (argv) => {
|
|
42
|
+
if (argv.all) {
|
|
43
|
+
const days = Math.max(1, Math.min(31, Number(argv.days) || 7));
|
|
44
|
+
const since = dayKey(Date.now() - (days - 1) * 864e5);
|
|
45
|
+
const rows = [];
|
|
46
|
+
for (const s2 of loadHistory()) {
|
|
47
|
+
const t = await sessionWorkTime(s2);
|
|
48
|
+
const ms = t.byDay.filter((d) => d.day >= since).reduce((n, d) => n + d.ms, 0);
|
|
49
|
+
if (ms >= 6e4)
|
|
50
|
+
rows.push({ name: `${s2.target} \xB7 ${s2.title ? s2.title : s2.branch}`, ms, ...s2.jiraKey ? { jira: s2.jiraKey } : {} });
|
|
51
|
+
}
|
|
52
|
+
rows.sort((a, b) => b.ms - a.ms);
|
|
53
|
+
if (rows.length === 0) console.log(chalk.gray(`No Claude work in the last ${days} days.`));
|
|
54
|
+
for (const r of rows) console.log(`${formatWorked(r.ms).padStart(7)} ${r.name}${r.jira ? chalk.gray(` ${r.jira}`) : ""}`);
|
|
55
|
+
if (rows.length) console.log(chalk.bold(`${formatWorked(rows.reduce((n, r) => n + r.ms, 0)).padStart(7)} in all (since ${since})`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const s = sessionFromArgs(argv);
|
|
59
|
+
if (!s) return;
|
|
60
|
+
const id = sessionIdFor(s);
|
|
61
|
+
const time = await sessionWorkTime(s);
|
|
62
|
+
if (argv.log) {
|
|
63
|
+
const settings = worklogSettings(loadConfig());
|
|
64
|
+
if (!settings) {
|
|
65
|
+
console.error(
|
|
66
|
+
chalk.red(
|
|
67
|
+
"Jira worklogs are not set up: add jiraWorklog { site, email } to ~/.work/config.json and put an API token in JIRA_API_TOKEN."
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
process.exitCode = 1;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!s.jiraKey) {
|
|
74
|
+
console.error(chalk.red("This session has no Jira issue (work tree \u2026 --jira-key KEY)."));
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const day = typeof argv.day === "string" ? time.byDay.find((d) => d.day === argv.day) : time.byDay[0];
|
|
79
|
+
if (!day) {
|
|
80
|
+
console.error(chalk.red("No work that day to log."));
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const r = await logWorkDay(id, s.jiraKey, day.day, day.ms, jiraWorklogPoster(settings));
|
|
85
|
+
if (!r.ok) {
|
|
86
|
+
console.error(chalk.red(r.error));
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log(chalk.green(r.text));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const logged = loggedDays(id);
|
|
94
|
+
console.log(
|
|
95
|
+
chalk.bold(
|
|
96
|
+
`${s.target} \xB7 ${s.branch}: about ${formatWorked(time.workedMs)} of Claude work over ${time.prompts} prompt${time.prompts === 1 ? "" : "s"}`
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
for (const d of time.byDay) {
|
|
100
|
+
const l = logged[d.day];
|
|
101
|
+
console.log(
|
|
102
|
+
` ${d.day} ${formatWorked(d.ms).padStart(7)}${l ? chalk.gray(` logged ${worklogTime(l.seconds * 1e3)} on ${l.issueKey}`) : ""}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
console.log(chalk.gray(" (the time between its steps, at most 15 minutes each: your reading and typing is not counted)"));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
timeCommand
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=time-GN6B4QD6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/time.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CommandModule } from 'yargs';\nimport { loadConfig } from '../core/platform/config.js';\nimport { loadHistory } from '../core/sessions/history.js';\nimport { jiraWorklogPoster, loggedDays, logWorkDay, worklogSettings } from '../core/jira/jira-worklog.js';\nimport { sessionIdFor } from '../core/sessions/session-id.js';\nimport { sessionWorkTime } from '../core/conversations/work-time-source.js';\nimport { dayKey, formatWorked, worklogTime } from '../core/conversations/work-time-view.js';\nimport { sessionFromArgs, sessionPositionals } from './shared/session-arg.js';\n\n/**\n * `work time` — how long a session's Claude worked (work-time.ts), per day;\n * `--all` this week (or `--days N`) across every session; `--log` writes a\n * day of it to the session's Jira issue as a worklog (jira-worklog.ts).\n */\nexport const timeCommand: CommandModule = {\n command: 'time [target] [branch]',\n describe: \"How long sessions' Claude worked: one session per day, or --all (a weekly report); --log writes it to Jira\",\n builder: (yargs) =>\n sessionPositionals(yargs)\n .option('all', { type: 'boolean', describe: 'Every session, the last --days days (default 7)' })\n .option('days', { type: 'number', default: 7, describe: 'With --all: how many days back' })\n .option('log', { type: 'boolean', describe: \"Write a day's work to the session's Jira issue as a worklog (what isn't logged yet)\" })\n .option('day', { type: 'string', describe: 'With --log: which day (YYYY-MM-DD; default: the latest it worked)' })\n .conflicts('all', 'log'),\n handler: async (argv) => {\n if (argv.all) {\n const days = Math.max(1, Math.min(31, Number(argv.days) || 7));\n const since = dayKey(Date.now() - (days - 1) * 86_400_000);\n const rows: Array<{ name: string; ms: number; jira?: string }> = [];\n for (const s of loadHistory()) {\n const t = await sessionWorkTime(s);\n const ms = t.byDay.filter((d) => d.day >= since).reduce((n, d) => n + d.ms, 0);\n if (ms >= 60_000)\n rows.push({ name: `${s.target} · ${s.title ? s.title : s.branch}`, ms, ...(s.jiraKey ? { jira: s.jiraKey } : {}) });\n }\n rows.sort((a, b) => b.ms - a.ms);\n if (rows.length === 0) console.log(chalk.gray(`No Claude work in the last ${days} days.`));\n for (const r of rows) console.log(`${formatWorked(r.ms).padStart(7)} ${r.name}${r.jira ? chalk.gray(` ${r.jira}`) : ''}`);\n if (rows.length) console.log(chalk.bold(`${formatWorked(rows.reduce((n, r) => n + r.ms, 0)).padStart(7)} in all (since ${since})`));\n return;\n }\n const s = sessionFromArgs(argv);\n if (!s) return;\n const id = sessionIdFor(s);\n const time = await sessionWorkTime(s);\n if (argv.log) {\n const settings = worklogSettings(loadConfig());\n if (!settings) {\n console.error(\n chalk.red(\n 'Jira worklogs are not set up: add jiraWorklog { site, email } to ~/.work/config.json and put an API token in JIRA_API_TOKEN.',\n ),\n );\n process.exitCode = 1;\n return;\n }\n if (!s.jiraKey) {\n console.error(chalk.red('This session has no Jira issue (work tree … --jira-key KEY).'));\n process.exitCode = 1;\n return;\n }\n const day = typeof argv.day === 'string' ? time.byDay.find((d) => d.day === argv.day) : time.byDay[0];\n if (!day) {\n console.error(chalk.red('No work that day to log.'));\n process.exitCode = 1;\n return;\n }\n const r = await logWorkDay(id, s.jiraKey, day.day, day.ms, jiraWorklogPoster(settings));\n if (!r.ok) {\n console.error(chalk.red(r.error));\n process.exitCode = 1;\n return;\n }\n console.log(chalk.green(r.text));\n return;\n }\n const logged = loggedDays(id);\n console.log(\n chalk.bold(\n `${s.target} · ${s.branch}: about ${formatWorked(time.workedMs)} of Claude work over ${time.prompts} prompt${time.prompts === 1 ? '' : 's'}`,\n ),\n );\n for (const d of time.byDay) {\n const l = logged[d.day];\n console.log(\n ` ${d.day} ${formatWorked(d.ms).padStart(7)}${l ? chalk.gray(` logged ${worklogTime(l.seconds * 1000)} on ${l.issueKey}`) : ''}`,\n );\n }\n console.log(chalk.gray(' (the time between its steps, at most 15 minutes each: your reading and typing is not counted)'));\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAeX,IAAM,cAA6B;AAAA,EACxC,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UACR,mBAAmB,KAAK,EACrB,OAAO,OAAO,EAAE,MAAM,WAAW,UAAU,kDAAkD,CAAC,EAC9F,OAAO,QAAQ,EAAE,MAAM,UAAU,SAAS,GAAG,UAAU,iCAAiC,CAAC,EACzF,OAAO,OAAO,EAAE,M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E,GAAG;AACtB,cAAQ;AAAA,QACN,KAAK,EAAE,GAAG,KAAK,aAAa,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,MAAM,KAAK,YAAY,YAAY,EAAE,UAAU,GAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;AAAA,MACnI;AAAA,IACF;AACA,YAAQ,IAAI,MAAM,KAAK,iGAAiG,CAAC;AAAA,EAC3H;AACF;","names":["s"]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
addTask,
|
|
4
|
+
completeTask,
|
|
5
|
+
editTask,
|
|
6
|
+
getTasks,
|
|
7
|
+
removeTask,
|
|
8
|
+
uncompleteTask
|
|
9
|
+
} from "./chunk-UFY7C5PP.js";
|
|
10
|
+
import "./chunk-7NCW3LUT.js";
|
|
11
|
+
import "./chunk-DW4JPVXB.js";
|
|
12
|
+
import "./chunk-N4EYQKSM.js";
|
|
13
|
+
import "./chunk-7HEB6SQS.js";
|
|
14
|
+
|
|
15
|
+
// src/commands/todo.ts
|
|
16
|
+
import chalk from "chalk";
|
|
17
|
+
var todoCommand = {
|
|
18
|
+
command: "todo [action]",
|
|
19
|
+
describe: "Manage tasks",
|
|
20
|
+
builder: (yargs) => yargs.positional("action", {
|
|
21
|
+
describe: "Action: add, done, undo, rm, edit (omit to list)",
|
|
22
|
+
type: "string"
|
|
23
|
+
}).option("all", {
|
|
24
|
+
describe: "Show completed tasks too",
|
|
25
|
+
type: "boolean",
|
|
26
|
+
default: false,
|
|
27
|
+
alias: "a"
|
|
28
|
+
}).strict(false),
|
|
29
|
+
handler: async (argv) => {
|
|
30
|
+
const action = argv.action;
|
|
31
|
+
const rest = argv._.slice(1);
|
|
32
|
+
if (!action || action === "list") {
|
|
33
|
+
const showAll = argv.all;
|
|
34
|
+
const tasks = getTasks();
|
|
35
|
+
const filtered = showAll ? tasks : tasks.filter((t) => !t.done);
|
|
36
|
+
if (filtered.length === 0) {
|
|
37
|
+
console.log(chalk.gray(showAll ? "No tasks." : "No open tasks. Use --all to show completed."));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
for (const t of filtered) {
|
|
41
|
+
const check = t.done ? chalk.green("\u2713") : chalk.gray("\u25CB");
|
|
42
|
+
const text = t.done ? chalk.strikethrough.gray(t.text) : t.text;
|
|
43
|
+
const link = t.link ? chalk.blue(` [${t.link}]`) : "";
|
|
44
|
+
console.log(` ${check} ${chalk.gray(`#${t.id}`)} ${text}${link}`);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (action === "add") {
|
|
49
|
+
const text = rest.join(" ");
|
|
50
|
+
if (!text) {
|
|
51
|
+
console.error("Usage: work todo add <text>");
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const task = await addTask(text);
|
|
56
|
+
console.log(chalk.green(`Added #${task.id}: ${task.text}`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (action === "done") {
|
|
60
|
+
if (!/^\d+$/.test(rest[0] ?? "")) {
|
|
61
|
+
console.error("Invalid task id");
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const id = parseInt(rest[0], 10);
|
|
66
|
+
if (isNaN(id)) {
|
|
67
|
+
console.error("Usage: work todo done <id>");
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const task = await completeTask(id);
|
|
72
|
+
if (!task) {
|
|
73
|
+
console.error(`Task #${id} not found`);
|
|
74
|
+
process.exitCode = 1;
|
|
75
|
+
} else {
|
|
76
|
+
console.log(chalk.green(`\u2713 #${id}: ${task.text}`));
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (action === "undo") {
|
|
81
|
+
if (!/^\d+$/.test(rest[0] ?? "")) {
|
|
82
|
+
console.error("Invalid task id");
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const id = parseInt(rest[0], 10);
|
|
87
|
+
if (isNaN(id)) {
|
|
88
|
+
console.error("Usage: work todo undo <id>");
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const task = await uncompleteTask(id);
|
|
93
|
+
if (!task) {
|
|
94
|
+
console.error(`Task #${id} not found`);
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
} else {
|
|
97
|
+
console.log(chalk.yellow(`\u25CB #${id}: ${task.text}`));
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (action === "rm") {
|
|
102
|
+
if (!/^\d+$/.test(rest[0] ?? "")) {
|
|
103
|
+
console.error("Invalid task id");
|
|
104
|
+
process.exitCode = 1;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const id = parseInt(rest[0], 10);
|
|
108
|
+
if (isNaN(id)) {
|
|
109
|
+
console.error("Usage: work todo rm <id>");
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const task = await removeTask(id);
|
|
114
|
+
if (!task) {
|
|
115
|
+
console.error(`Task #${id} not found`);
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
} else {
|
|
118
|
+
console.log(chalk.red(`Removed #${id}: ${task.text}`));
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (action === "edit") {
|
|
123
|
+
if (!/^\d+$/.test(rest[0] ?? "")) {
|
|
124
|
+
console.error("Invalid task id");
|
|
125
|
+
process.exitCode = 1;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const id = parseInt(rest[0], 10);
|
|
129
|
+
const text = rest.slice(1).join(" ");
|
|
130
|
+
if (isNaN(id) || !text) {
|
|
131
|
+
console.error("Usage: work todo edit <id> <new text>");
|
|
132
|
+
process.exitCode = 1;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const task = await editTask(id, text);
|
|
136
|
+
if (!task) {
|
|
137
|
+
console.error(`Task #${id} not found`);
|
|
138
|
+
process.exitCode = 1;
|
|
139
|
+
} else {
|
|
140
|
+
console.log(chalk.cyan(`Updated #${id}: ${task.text}`));
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
console.error(`Unknown action: ${action}`);
|
|
145
|
+
console.log(chalk.yellow("Actions: add, done, undo, rm, edit"));
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
todoCommand
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=todo-LWMQY6XW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/todo.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CommandModule } from 'yargs';\nimport { getTasks, addTask, completeTask, uncompleteTask, removeTask, editTask } from '../core/tasks.js';\n\nexport const todoCommand: CommandModule = {\n command: 'todo [action]',\n describe: 'Manage tasks',\n builder: (yargs) =>\n yargs\n .positional('action', {\n describe: 'Action: add, done, undo, rm, edit (omit to list)',\n type: 'string',\n })\n .option('all', {\n describe: 'Show completed tasks too',\n type: 'boolean',\n default: false,\n alias: 'a',\n })\n .strict(false),\n handler: async (argv) => {\n const action = argv.action as string | undefined;\n const rest = (argv._ as string[]).slice(1);\n\n if (!action || action === 'list') {\n const showAll = argv.all as boolean;\n const tasks = getTasks();\n const filtered = showAll ? tasks : tasks.filter((t) => !t.done);\n if (filtered.length === 0) {\n console.log(chalk.gray(showAll ? 'No tasks.' : 'No open tasks. Use --all to show completed.'));\n return;\n }\n for (const t of filtered) {\n const check = t.done ? chalk.green('✓') : chalk.gray('○');\n const text = t.done ? chalk.strikethrough.gray(t.text) : t.text;\n const link = t.link ? chalk.blue(` [${t.link}]`) : '';\n console.log(` ${check} ${chalk.gray(`#${t.id}`)} ${text}${link}`);\n }\n return;\n }\n\n if (action === 'add') {\n const text = rest.join(' ');\n if (!text) {\n console.error('Usage: work todo add <text>');\n process.exitCode = 1;\n return;\n }\n const task = await addTask(text);\n console.log(chalk.green(`Added #${task.id}: ${task.text}`));\n return;\n }\n\n if (action === 'done') {\n if (!/^\\d+$/.test(rest[0] ?? '')) {\n console.error('Invalid task id');\n process.exitCode = 1;\n return;\n }\n const id = parseInt(rest[0], 10);\n if (isNaN(id)) {\n console.error('Usage: work todo done <id>');\n process.exitCode = 1;\n return;\n }\n const task = await completeTask(id);\n if (!task) {\n console.error(`Task #${id} not found`);\n process.exitCode = 1;\n } else {\n console.log(chalk.green(`✓ #${id}: ${task.text}`));\n }\n return;\n }\n\n if (action === 'undo') {\n if (!/^\\d+$/.test(rest[0] ?? '')) {\n console.error('Invalid task id');\n process.exitCode = 1;\n return;\n }\n const id = parseInt(rest[0], 10);\n if (isNaN(id)) {\n console.error('Usage: work todo undo <id>');\n process.exitCode = 1;\n return;\n }\n const task = await uncompleteTask(id);\n if (!task) {\n console.error(`Task #${id} not found`);\n process.exitCode = 1;\n } else {\n console.log(chalk.yellow(`○ #${id}: ${task.text}`));\n }\n return;\n }\n\n if (action === 'rm') {\n if (!/^\\d+$/.test(rest[0] ?? '')) {\n console.error('Invalid task id');\n process.exitCode = 1;\n return;\n }\n const id = parseInt(rest[0], 10);\n if (isNaN(id)) {\n console.error('Usage: work todo rm <id>');\n process.exitCode = 1;\n return;\n }\n const task = await removeTask(id);\n if (!task) {\n console.error(`Task #${id} not found`);\n process.exitCode = 1;\n } else {\n console.log(chalk.red(`Removed #${id}: ${task.text}`));\n }\n return;\n }\n\n if (action === 'edit') {\n if (!/^\\d+$/.test(rest[0] ?? '')) {\n console.error('Invalid task id');\n process.exitCode = 1;\n return;\n }\n const id = parseInt(rest[0], 10);\n const text = rest.slice(1).join(' ');\n if (isNaN(id) || !text) {\n console.error('Usage: work todo edit <id> <new text>');\n process.exitCode = 1;\n return;\n }\n const task = await editTask(id, text);\n if (!task) {\n console.error(`Task #${id} not found`);\n process.exitCode = 1;\n } else {\n console.log(chalk.cyan(`Updated #${id}: ${task.text}`));\n }\n return;\n }\n\n console.error(`Unknown action: ${action}`);\n console.log(chalk.yellow('Actions: add, done, undo, rm, edit'));\n process.exitCode = 1;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAIX,IAAM,cAA6B;AAAA,EACxC,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UACR,MACG,WAAW,UAAU;AAAA,IACpB,UAAU;AAAA,IACV,MAAM;AAAA,EACR,CAAC,EACA,OAAO,OAAO;AAAA,IACb,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EACT,CAAC,EACA,OAAO,KAAK;AAAA,EACjB,SAAS,OAAO,SAAS;AACvB,UAAM,SAAS,KAAK;AACpB,UAAM,OAAQ,KAAK,EAAe,MAAM,CAAC;AAEzC,QAAI,CAAC,UAAU,WAAW,QAAQ;AAChC,YAAM,UAAU,KAAK;AACrB,YAAM,QAAQ,SAAS;AACvB,YAAM,WAAW,UAAU,QAAQ,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI;AAC9D,UAAI,SAAS,WAAW,GAAG;AACzB,gBAAQ,IAAI,MAAM,KAAK,UAAU,cAAc,6CAA6C,CAAC;AAC7F;AAAA,MACF;AACA,iBAAW,KAAK,UAAU;AACxB,cAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,QAAG,IAAI,MAAM,KAAK,QAAG;AACxD,cAAM,OAAO,EAAE,OAAO,MAAM,cAAc,KAAK,EAAE,IAAI,IAAI,EAAE;AAC3D,cAAM,OAAO,EAAE,OAAO,MAAM,KAAK,KAAK,EAAE,IAAI,GAAG,IAAI;AACnD,gBAAQ,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE,EAAE,CAA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,IAAI,MAAM,KAAK,YAAY,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC;AAAA,MACxD;AACA;AAAA,IACF;AAEA,YAAQ,MAAM,mBAAmB,MAAM,EAAE;AACzC,YAAQ,IAAI,MAAM,OAAO,oCAAoC,CAAC;AAC9D,YAAQ,WAAW;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
attachSession
|
|
4
|
+
} from "./chunk-6FTIY5M6.js";
|
|
5
|
+
import "./chunk-AH5TM3NB.js";
|
|
6
|
+
import {
|
|
7
|
+
BaseSpecError,
|
|
8
|
+
isEmptyBaseSpec,
|
|
9
|
+
openBaseCheckout,
|
|
10
|
+
parseBaseSpec,
|
|
11
|
+
setupWorktree
|
|
12
|
+
} from "./chunk-CLGVSX36.js";
|
|
13
|
+
import "./chunk-O3QTWVSK.js";
|
|
14
|
+
import "./chunk-ZJN5RWZD.js";
|
|
15
|
+
import "./chunk-QBAZG4CY.js";
|
|
16
|
+
import {
|
|
17
|
+
getAllTargetNames,
|
|
18
|
+
resolveFromCwd,
|
|
19
|
+
resolveProjectTarget
|
|
20
|
+
} from "./chunk-H5LKMR45.js";
|
|
21
|
+
import "./chunk-SOCPIHCS.js";
|
|
22
|
+
import "./chunk-7NAXFBFI.js";
|
|
23
|
+
import {
|
|
24
|
+
launchAi,
|
|
25
|
+
openVSCode
|
|
26
|
+
} from "./chunk-P3BL4EOP.js";
|
|
27
|
+
import {
|
|
28
|
+
findSession,
|
|
29
|
+
loadHistory,
|
|
30
|
+
recordLaunch
|
|
31
|
+
} from "./chunk-M4FVCAT6.js";
|
|
32
|
+
import "./chunk-7NCW3LUT.js";
|
|
33
|
+
import {
|
|
34
|
+
agentFor
|
|
35
|
+
} from "./chunk-PN44M5EE.js";
|
|
36
|
+
import "./chunk-RCYI7SRA.js";
|
|
37
|
+
import "./chunk-DW4JPVXB.js";
|
|
38
|
+
import "./chunk-N4EYQKSM.js";
|
|
39
|
+
import {
|
|
40
|
+
ensureConfig
|
|
41
|
+
} from "./chunk-7HEB6SQS.js";
|
|
42
|
+
|
|
43
|
+
// src/commands/tree.ts
|
|
44
|
+
import fs from "fs";
|
|
45
|
+
import chalk from "chalk";
|
|
46
|
+
var treeCommand = {
|
|
47
|
+
command: ["tree [target] [branch]", "t [target] [branch]"],
|
|
48
|
+
describe: "Create or switch to a worktree and launch the configured AI tool",
|
|
49
|
+
builder: (yargs) => yargs.showHelpOnFail(true).positional("target", {
|
|
50
|
+
describe: "Project alias or group name",
|
|
51
|
+
type: "string"
|
|
52
|
+
}).positional("branch", {
|
|
53
|
+
describe: "Branch name (e.g., feature/login). Omit to work on the base repo.",
|
|
54
|
+
type: "string"
|
|
55
|
+
}).option("here", {
|
|
56
|
+
describe: "Infer target and branch from the current worktree directory",
|
|
57
|
+
type: "boolean",
|
|
58
|
+
default: false
|
|
59
|
+
}).option("open", {
|
|
60
|
+
describe: "Open VS Code in the worktree after creation",
|
|
61
|
+
type: "boolean",
|
|
62
|
+
default: false
|
|
63
|
+
}).option("unsafe", {
|
|
64
|
+
describe: "Launch the AI tool with its skip-permissions flag (default: --dangerously-skip-permissions)",
|
|
65
|
+
type: "boolean",
|
|
66
|
+
default: false
|
|
67
|
+
}).option("pull", {
|
|
68
|
+
describe: "Pull latest changes when switching into an existing worktree or the base repo. Use --no-pull to skip.",
|
|
69
|
+
type: "boolean",
|
|
70
|
+
default: true
|
|
71
|
+
}).option("host", {
|
|
72
|
+
describe: "Run the AI session in the PTY host and attach this terminal to it (the default): it survives closing the tab, shows in `work web` \u2014 the same screen there and here \u2014 and restores after a reboot. Ctrl+] detaches. --no-host (or config `launchViaHost: false`) launches directly in this terminal instead.",
|
|
73
|
+
type: "boolean"
|
|
74
|
+
}).option("fresh", {
|
|
75
|
+
describe: "Start a new AI conversation instead of continuing the previous one for this directory",
|
|
76
|
+
type: "boolean",
|
|
77
|
+
default: false
|
|
78
|
+
}).option("base", {
|
|
79
|
+
describe: "Base branch to fork from instead of HEAD. Repeatable. Use a bare branch (--base dev) for all repos, or alias=branch (--base backend=dev --base frontend=feat/x) for per-repo bases in a group.",
|
|
80
|
+
type: "string"
|
|
81
|
+
}).option("prompt", {
|
|
82
|
+
describe: "Initial prompt to send to the AI tool on startup",
|
|
83
|
+
type: "string"
|
|
84
|
+
}).option("prompt-file", {
|
|
85
|
+
describe: "File containing the initial prompt (deleted after reading)",
|
|
86
|
+
type: "string"
|
|
87
|
+
}).option("name", {
|
|
88
|
+
describe: "Name the session (shown instead of the branch; rename later with F2 in the dashboard)",
|
|
89
|
+
type: "string"
|
|
90
|
+
}).option("jira-key", {
|
|
91
|
+
describe: "Link a Jira issue key to this worktree session",
|
|
92
|
+
type: "string",
|
|
93
|
+
hidden: true
|
|
94
|
+
}).option("setup-only", {
|
|
95
|
+
describe: "Create worktree without launching the AI tool (used by dashboard)",
|
|
96
|
+
type: "boolean",
|
|
97
|
+
default: false,
|
|
98
|
+
hidden: true
|
|
99
|
+
}),
|
|
100
|
+
handler: async (argv) => {
|
|
101
|
+
let targetName = argv.target;
|
|
102
|
+
let branchName = argv.branch;
|
|
103
|
+
const here = argv.here;
|
|
104
|
+
const open = argv.open;
|
|
105
|
+
const unsafe = argv.unsafe;
|
|
106
|
+
const pull = argv.pull;
|
|
107
|
+
const fresh = argv.fresh;
|
|
108
|
+
const setupOnly = argv["setup-only"];
|
|
109
|
+
let baseSpec;
|
|
110
|
+
try {
|
|
111
|
+
baseSpec = parseBaseSpec(argv.base);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (err instanceof BaseSpecError) {
|
|
114
|
+
console.error(err.message);
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
const jiraKey = argv["jira-key"];
|
|
121
|
+
const promptFile = argv["prompt-file"];
|
|
122
|
+
let initialPrompt = argv.prompt;
|
|
123
|
+
if (promptFile) {
|
|
124
|
+
try {
|
|
125
|
+
initialPrompt = fs.readFileSync(promptFile, "utf-8");
|
|
126
|
+
fs.unlinkSync(promptFile);
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const config = ensureConfig();
|
|
131
|
+
const viaHost = argv.host ?? config.launchViaHost ?? true;
|
|
132
|
+
const launchTool = async (dir, port, sessionKey) => {
|
|
133
|
+
recordLaunch(sessionKey.target, sessionKey.branch, { unsafe: !!unsafe });
|
|
134
|
+
if (viaHost) {
|
|
135
|
+
const session = findSession(loadHistory(), sessionKey.target, sessionKey.branch);
|
|
136
|
+
if (session) {
|
|
137
|
+
process.exitCode = await attachSession(session, {
|
|
138
|
+
unsafe,
|
|
139
|
+
fresh,
|
|
140
|
+
initialPrompt,
|
|
141
|
+
forwardEnv: true
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
console.log(chalk.yellow("Session not found in history \u2014 launching directly instead of via the PTY host."));
|
|
146
|
+
}
|
|
147
|
+
const agent = agentFor(config, findSession(loadHistory(), sessionKey.target, sessionKey.branch));
|
|
148
|
+
const tool = agent.launch.tool(config);
|
|
149
|
+
const resume = !fresh && agent.launch.canResume(dir);
|
|
150
|
+
if (resume) {
|
|
151
|
+
console.log(chalk.gray(`Continuing the previous ${tool.cmd} conversation (--fresh starts a new one).`));
|
|
152
|
+
}
|
|
153
|
+
console.log(`Starting ${tool.cmd}...`);
|
|
154
|
+
launchAi(dir, tool, { unsafe, initialPrompt, resume }, port);
|
|
155
|
+
};
|
|
156
|
+
if (here) {
|
|
157
|
+
if (targetName) {
|
|
158
|
+
console.error("Cannot combine --here with an explicit target.");
|
|
159
|
+
process.exitCode = 1;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const inferred = resolveFromCwd(config, process.cwd());
|
|
163
|
+
if ("error" in inferred) {
|
|
164
|
+
console.error(inferred.error);
|
|
165
|
+
process.exitCode = 1;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
targetName = inferred.target;
|
|
169
|
+
branchName = inferred.isBaseRepo ? void 0 : inferred.branch;
|
|
170
|
+
console.log(chalk.cyan(`Resolved from current directory: ${targetName}${branchName ? " @ " + branchName : " (base repo)"}`));
|
|
171
|
+
} else if (!targetName) {
|
|
172
|
+
console.error("Specify a target, or use --here to infer it from the current directory.");
|
|
173
|
+
process.exitCode = 1;
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!isEmptyBaseSpec(baseSpec) && !branchName) {
|
|
177
|
+
console.error("--base requires a branch name");
|
|
178
|
+
console.log(chalk.yellow(`Usage: work tree ${targetName} <branch> --base <base>`));
|
|
179
|
+
process.exitCode = 1;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const target = resolveProjectTarget(targetName, config);
|
|
183
|
+
if (!target) {
|
|
184
|
+
const allNames = getAllTargetNames(config);
|
|
185
|
+
console.error(`Project or group not found: ${targetName}`);
|
|
186
|
+
console.log(chalk.yellow(`Available: ${allNames.join(", ")}`));
|
|
187
|
+
console.log(chalk.yellow("Add a new project with: work config add <alias> <path>"));
|
|
188
|
+
process.exitCode = 1;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!branchName) {
|
|
192
|
+
if (target.isGroup) {
|
|
193
|
+
console.error("Branch is required for group targets.");
|
|
194
|
+
console.log(chalk.yellow(`Usage: work tree ${targetName} <branch>`));
|
|
195
|
+
process.exitCode = 1;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
console.log(chalk.cyan(`Working on base repo: ${targetName}`));
|
|
199
|
+
const opened = await openBaseCheckout(targetName, config, {
|
|
200
|
+
pull,
|
|
201
|
+
jiraKey,
|
|
202
|
+
name: typeof argv.name === "string" ? argv.name : void 0
|
|
203
|
+
});
|
|
204
|
+
if (!opened.ok) {
|
|
205
|
+
console.error(opened.error);
|
|
206
|
+
process.exitCode = 1;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const { repoPath, branch: currentBranch } = opened;
|
|
210
|
+
console.log(`Repo path: ${repoPath}`);
|
|
211
|
+
if (opened.dropped.length) console.log(chalk.gray(`Replaced older entries for this checkout: ${opened.dropped.join(", ")}`));
|
|
212
|
+
if (open) openVSCode(repoPath);
|
|
213
|
+
if (!setupOnly) await launchTool(repoPath, void 0, { target: targetName, branch: currentBranch });
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const result = await setupWorktree(targetName, branchName, config, baseSpec, jiraKey, { pull, name: argv.name });
|
|
217
|
+
if (!result) {
|
|
218
|
+
process.exitCode = 1;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (open) {
|
|
222
|
+
for (const p of result.paths) {
|
|
223
|
+
openVSCode(p);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
console.log(`Worktree path: ${result.launchDir}`);
|
|
227
|
+
if (!setupOnly) {
|
|
228
|
+
await launchTool(result.launchDir, result.port, { target: targetName, branch: branchName });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
export {
|
|
233
|
+
treeCommand
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=tree-7BMORJ6J.js.map
|