@damper/cli 0.5.16 → 0.5.17
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/index.js +1 -1
- package/dist/services/claude.js +35 -18
- package/package.json +1 -1
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.17';
|
|
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import * as os from 'node:os';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
4
5
|
import { execa } from 'execa';
|
|
5
6
|
import pc from 'picocolors';
|
|
6
7
|
const CLAUDE_SETTINGS_DIR = path.join(os.homedir(), '.claude');
|
|
@@ -110,26 +111,42 @@ export async function launchClaude(options) {
|
|
|
110
111
|
console.log();
|
|
111
112
|
// Build prompt - context is in TASK_CONTEXT.md, MCP is in .claude/settings.json
|
|
112
113
|
const initialPrompt = `Read TASK_CONTEXT.md and work on task #${taskId}: ${taskTitle}`;
|
|
113
|
-
// Launch Claude Code
|
|
114
|
-
const { spawnSync } = await import('node:child_process');
|
|
115
114
|
console.log(pc.dim(`Launching Claude in ${cwd}...`));
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
// Launch Claude Code with proper signal handling to prevent orphaned processes
|
|
116
|
+
await new Promise((resolve) => {
|
|
117
|
+
const child = spawn('claude', [initialPrompt], {
|
|
118
|
+
cwd,
|
|
119
|
+
stdio: 'inherit',
|
|
120
|
+
env: {
|
|
121
|
+
...process.env,
|
|
122
|
+
DAMPER_API_KEY: apiKey,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
// Forward signals to child process
|
|
126
|
+
const forwardSignal = (signal) => {
|
|
127
|
+
if (!child.killed) {
|
|
128
|
+
child.kill(signal);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
process.on('SIGINT', () => forwardSignal('SIGINT'));
|
|
132
|
+
process.on('SIGTERM', () => forwardSignal('SIGTERM'));
|
|
133
|
+
process.on('SIGHUP', () => forwardSignal('SIGHUP'));
|
|
134
|
+
child.on('error', (err) => {
|
|
135
|
+
if (err.code === 'ENOENT') {
|
|
136
|
+
console.log(pc.red('\nError: Claude Code CLI not found.'));
|
|
137
|
+
console.log(pc.dim('Install it with: npm install -g @anthropic-ai/claude-code\n'));
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
resolve();
|
|
141
|
+
});
|
|
142
|
+
child.on('close', () => {
|
|
143
|
+
// Clean up signal listeners
|
|
144
|
+
process.removeAllListeners('SIGINT');
|
|
145
|
+
process.removeAllListeners('SIGTERM');
|
|
146
|
+
process.removeAllListeners('SIGHUP');
|
|
147
|
+
resolve();
|
|
148
|
+
});
|
|
123
149
|
});
|
|
124
|
-
// Check for errors
|
|
125
|
-
if (result.error) {
|
|
126
|
-
const error = result.error;
|
|
127
|
-
if (error.code === 'ENOENT') {
|
|
128
|
-
console.log(pc.red('\nError: Claude Code CLI not found.'));
|
|
129
|
-
console.log(pc.dim('Install it with: npm install -g @anthropic-ai/claude-code\n'));
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
150
|
// Post-task flow
|
|
134
151
|
console.log(pc.dim('\n─────────────────────────────────────────'));
|
|
135
152
|
console.log(pc.bold('\nClaude session ended.\n'));
|