@damper/cli 0.5.0 → 0.5.2
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 +33 -38
- 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.2';
|
|
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');
|
|
@@ -108,28 +109,6 @@ export async function launchClaude(options) {
|
|
|
108
109
|
console.log(pc.cyan('Mode: Plan (will ask for approval)'));
|
|
109
110
|
}
|
|
110
111
|
console.log();
|
|
111
|
-
// Build initial prompt
|
|
112
|
-
const planModeNote = yolo ? '' : `
|
|
113
|
-
You're in PLAN MODE. First, read TASK_CONTEXT.md and create an implementation plan.
|
|
114
|
-
Do NOT log anything to Damper (no add_commit, add_note) until your plan is approved.
|
|
115
|
-
Once approved, switch to implementation and start logging your work.
|
|
116
|
-
`;
|
|
117
|
-
const initialPrompt = [
|
|
118
|
-
`I'm working on task #${taskId}: ${taskTitle}`,
|
|
119
|
-
planModeNote,
|
|
120
|
-
'Please read TASK_CONTEXT.md for full context, critical rules, and the implementation plan.',
|
|
121
|
-
'',
|
|
122
|
-
'Task workflow (after plan approval):',
|
|
123
|
-
'1. Use `add_commit` after each git commit',
|
|
124
|
-
'2. Use `add_note` for important decisions',
|
|
125
|
-
'3. Call `complete_task` when done or `abandon_task` if stopping early',
|
|
126
|
-
'',
|
|
127
|
-
'About this session: You were launched by @damper/cli.',
|
|
128
|
-
'The CLI created this worktree, bootstrapped TASK_CONTEXT.md, and configured Damper MCP.',
|
|
129
|
-
'',
|
|
130
|
-
'Self-improvement: If you encounter friction, bugs, or have ideas to improve the CLI/workflow,',
|
|
131
|
-
'use `report_issue` to log them. Your feedback improves tooling for all future tasks.',
|
|
132
|
-
].join('\n');
|
|
133
112
|
// Write MCP config to a temp file (more reliable than passing JSON on command line)
|
|
134
113
|
const mcpConfigPath = path.join(os.tmpdir(), `damper-mcp-${taskId}.json`);
|
|
135
114
|
const mcpConfig = {
|
|
@@ -142,30 +121,46 @@ Once approved, switch to implementation and start logging your work.
|
|
|
142
121
|
},
|
|
143
122
|
};
|
|
144
123
|
fs.writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
|
|
145
|
-
// Build Claude args
|
|
124
|
+
// Build Claude args - keep it simple, context is in TASK_CONTEXT.md
|
|
125
|
+
const initialPrompt = `Read TASK_CONTEXT.md and work on task #${taskId}: ${taskTitle}`;
|
|
146
126
|
const claudeArgs = [
|
|
147
|
-
'--permission-mode', yolo ? 'acceptEdits' : 'plan',
|
|
148
127
|
'--mcp-config', mcpConfigPath,
|
|
149
128
|
initialPrompt,
|
|
150
129
|
];
|
|
130
|
+
// Debug: show what we're about to run
|
|
131
|
+
if (process.env.DEBUG) {
|
|
132
|
+
console.log(pc.dim(`Debug: claude ${claudeArgs.join(' ')}`));
|
|
133
|
+
console.log(pc.dim(`Debug: MCP config at ${mcpConfigPath}`));
|
|
134
|
+
}
|
|
151
135
|
// Launch Claude Code in interactive mode
|
|
152
136
|
try {
|
|
153
|
-
await
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
137
|
+
await new Promise((resolve, reject) => {
|
|
138
|
+
const child = spawn('claude', claudeArgs, {
|
|
139
|
+
cwd,
|
|
140
|
+
stdio: 'inherit',
|
|
141
|
+
shell: true, // Use shell to ensure proper TTY handling
|
|
142
|
+
env: {
|
|
143
|
+
...process.env,
|
|
144
|
+
DAMPER_API_KEY: apiKey,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
child.on('close', (code) => {
|
|
148
|
+
if (process.env.DEBUG) {
|
|
149
|
+
console.log(pc.dim(`Debug: Claude exited with code ${code}`));
|
|
150
|
+
}
|
|
151
|
+
resolve();
|
|
152
|
+
});
|
|
153
|
+
child.on('error', (err) => {
|
|
154
|
+
if (err.code === 'ENOENT') {
|
|
155
|
+
console.log(pc.red('\nError: Claude Code CLI not found.'));
|
|
156
|
+
console.log(pc.dim('Install it with: npm install -g @anthropic-ai/claude-code\n'));
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
reject(err);
|
|
160
|
+
});
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
|
-
catch
|
|
163
|
-
const error = err;
|
|
164
|
-
if (error.code === 'ENOENT') {
|
|
165
|
-
console.log(pc.red('\nError: Claude Code CLI not found.'));
|
|
166
|
-
console.log(pc.dim('Install it with: npm install -g @anthropic-ai/claude-code\n'));
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
163
|
+
catch {
|
|
169
164
|
// Claude exited with error - still continue to post-task flow
|
|
170
165
|
}
|
|
171
166
|
finally {
|