@damper/cli 0.5.14 → 0.5.16
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/dist/commands/start.js +3 -3
- package/dist/index.js +1 -1
- package/dist/services/claude.js +17 -20
- package/dist/services/worktree.d.ts +5 -0
- package/dist/services/worktree.js +30 -0
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { createDamperApi } from '../services/damper-api.js';
|
|
4
|
-
import { createWorktree,
|
|
4
|
+
import { createWorktree, getMainProjectRoot } from '../services/worktree.js';
|
|
5
5
|
import { bootstrapContext, refreshContext } from '../services/context-bootstrap.js';
|
|
6
6
|
import { pickTask } from '../ui/task-picker.js';
|
|
7
7
|
import { launchClaude, postTaskFlow, isClaudeInstalled, isDamperMcpConfigured, configureDamperMcp } from '../services/claude.js';
|
|
@@ -15,10 +15,10 @@ export async function startCommand(options) {
|
|
|
15
15
|
console.log(pc.dim('Install it with: npm install -g @anthropic-ai/claude-code\n'));
|
|
16
16
|
process.exit(1);
|
|
17
17
|
}
|
|
18
|
-
// Get project root (
|
|
18
|
+
// Get project root (main repo, not a worktree)
|
|
19
19
|
let projectRoot;
|
|
20
20
|
try {
|
|
21
|
-
projectRoot = await
|
|
21
|
+
projectRoot = await getMainProjectRoot(process.cwd());
|
|
22
22
|
}
|
|
23
23
|
catch {
|
|
24
24
|
console.log(pc.red('\nError: Not in a git repository.'));
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { statusCommand } from './commands/status.js';
|
|
|
5
5
|
import { cleanupCommand } from './commands/cleanup.js';
|
|
6
6
|
import { setupCommand } from './commands/setup.js';
|
|
7
7
|
import { releaseCommand } from './commands/release.js';
|
|
8
|
-
const VERSION = '0.5.
|
|
8
|
+
const VERSION = '0.5.16';
|
|
9
9
|
function showHelp() {
|
|
10
10
|
console.log(`
|
|
11
11
|
${pc.bold('@damper/cli')} - Agent orchestration for Damper tasks
|
package/dist/services/claude.js
CHANGED
|
@@ -274,26 +274,23 @@ export async function postTaskFlow(options) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
else if (taskStatus === 'in_progress') {
|
|
277
|
-
// Task not completed -
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
277
|
+
// Task not completed - always release the lock, optionally remove worktree
|
|
278
|
+
console.log(pc.dim('\nReleasing task lock...'));
|
|
279
|
+
try {
|
|
280
|
+
const api = createDamperApi(apiKey);
|
|
281
|
+
await api.abandonTask(taskId, 'Session ended via CLI');
|
|
282
|
+
console.log(pc.green(`✓ Task released back to planned status`));
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
const error = err;
|
|
286
|
+
console.log(pc.yellow(`Could not release task: ${error.message}`));
|
|
287
|
+
}
|
|
288
|
+
// Ask about worktree cleanup
|
|
289
|
+
const shouldRemove = await confirm({
|
|
290
|
+
message: 'Remove worktree and branch?',
|
|
291
|
+
default: false,
|
|
284
292
|
});
|
|
285
|
-
if (
|
|
286
|
-
// Release the task back to planned
|
|
287
|
-
try {
|
|
288
|
-
const api = createDamperApi(apiKey);
|
|
289
|
-
await api.abandonTask(taskId, 'Released via CLI');
|
|
290
|
-
console.log(pc.green(`✓ Task released back to planned status`));
|
|
291
|
-
}
|
|
292
|
-
catch (err) {
|
|
293
|
-
const error = err;
|
|
294
|
-
console.log(pc.yellow(`Could not release task: ${error.message}`));
|
|
295
|
-
}
|
|
296
|
-
// Remove worktree
|
|
293
|
+
if (shouldRemove) {
|
|
297
294
|
try {
|
|
298
295
|
await removeWorktreeDir(cwd, projectRoot);
|
|
299
296
|
console.log(pc.green('✓ Worktree and branch removed\n'));
|
|
@@ -304,7 +301,7 @@ export async function postTaskFlow(options) {
|
|
|
304
301
|
}
|
|
305
302
|
}
|
|
306
303
|
else {
|
|
307
|
-
console.log(pc.dim('\
|
|
304
|
+
console.log(pc.dim('\nWorktree kept. Run `npx @damper/cli cleanup` to remove later.\n'));
|
|
308
305
|
}
|
|
309
306
|
}
|
|
310
307
|
}
|
|
@@ -33,3 +33,8 @@ export declare function isInWorktree(dir: string): Promise<boolean>;
|
|
|
33
33
|
* Get the git root directory
|
|
34
34
|
*/
|
|
35
35
|
export declare function getGitRoot(dir: string): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the main project root (not a worktree).
|
|
38
|
+
* If we're in a worktree, this returns the main repo's path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getMainProjectRoot(dir: string): Promise<string>;
|
|
@@ -418,3 +418,33 @@ export async function getGitRoot(dir) {
|
|
|
418
418
|
});
|
|
419
419
|
return stdout.trim();
|
|
420
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Get the main project root (not a worktree).
|
|
423
|
+
* If we're in a worktree, this returns the main repo's path.
|
|
424
|
+
*/
|
|
425
|
+
export async function getMainProjectRoot(dir) {
|
|
426
|
+
// Get the common git directory (shared by all worktrees)
|
|
427
|
+
const { stdout: gitCommonDir } = await execa('git', ['rev-parse', '--git-common-dir'], {
|
|
428
|
+
cwd: dir,
|
|
429
|
+
stdio: 'pipe',
|
|
430
|
+
});
|
|
431
|
+
const commonDir = gitCommonDir.trim();
|
|
432
|
+
// If it's just '.git', we're in the main repo
|
|
433
|
+
if (commonDir === '.git') {
|
|
434
|
+
return getGitRoot(dir);
|
|
435
|
+
}
|
|
436
|
+
// Otherwise, the common dir is something like '/path/to/main-repo/.git'
|
|
437
|
+
// Strip the '/.git' to get the main repo path
|
|
438
|
+
if (commonDir.endsWith('/.git')) {
|
|
439
|
+
return commonDir.slice(0, -5);
|
|
440
|
+
}
|
|
441
|
+
// Fallback: resolve relative path
|
|
442
|
+
const gitRoot = await getGitRoot(dir);
|
|
443
|
+
const resolvedCommon = path.resolve(gitRoot, commonDir);
|
|
444
|
+
// Strip .git suffix
|
|
445
|
+
if (resolvedCommon.endsWith('.git')) {
|
|
446
|
+
return resolvedCommon.slice(0, -4);
|
|
447
|
+
}
|
|
448
|
+
// Last resort: just return git root
|
|
449
|
+
return gitRoot;
|
|
450
|
+
}
|