@radnine/claude-session-daemon 0.6.8 → 0.7.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/package.json
CHANGED
package/src/claude-process.js
CHANGED
|
@@ -30,6 +30,7 @@ class ClaudeProcess extends EventEmitter {
|
|
|
30
30
|
* @param {boolean} [options.skipPermissions] - Pass --dangerously-skip-permissions (only safe in Docker)
|
|
31
31
|
* @param {Function} [options._spawnFn] - For testing: replacement for child_process.spawn
|
|
32
32
|
* @param {object} [options.sessionEnv] - Extra env vars to inject into the spawned process
|
|
33
|
+
* @param {string} [options.systemPrompt] - Appended to Claude's default system prompt at spawn time via --append-system-prompt
|
|
33
34
|
*/
|
|
34
35
|
constructor(sessionId, options = {}) {
|
|
35
36
|
super();
|
|
@@ -44,6 +45,7 @@ class ClaudeProcess extends EventEmitter {
|
|
|
44
45
|
this._permissionPort = options.permissionPort || null;
|
|
45
46
|
this._spawnFn = options._spawnFn || defaultSpawn;
|
|
46
47
|
this._sessionEnv = options.sessionEnv || {};
|
|
48
|
+
this._systemPrompt = options.systemPrompt || null;
|
|
47
49
|
|
|
48
50
|
this._state = 'idle';
|
|
49
51
|
this._child = null;
|
|
@@ -87,6 +89,10 @@ class ClaudeProcess extends EventEmitter {
|
|
|
87
89
|
|
|
88
90
|
args.push('--replay-user-messages');
|
|
89
91
|
|
|
92
|
+
if (this._systemPrompt) {
|
|
93
|
+
args.push('--append-system-prompt', this._systemPrompt);
|
|
94
|
+
}
|
|
95
|
+
|
|
90
96
|
if (this._skipPermissions) {
|
|
91
97
|
args.push('--dangerously-skip-permissions');
|
|
92
98
|
}
|
|
@@ -631,14 +631,16 @@ class ActionCableClient extends BaseConnection {
|
|
|
631
631
|
const userId = message.user_id;
|
|
632
632
|
const claudeSessionId = message.claude_session_id || undefined;
|
|
633
633
|
const resetGit = !!message.reset_git_state;
|
|
634
|
+
const systemPrompt = message.system_prompt || undefined;
|
|
634
635
|
|
|
635
|
-
this._logger.info('Received session_activate', { sessionId, userId, claudeSessionId, resetGit });
|
|
636
|
+
this._logger.info('Received session_activate', { sessionId, userId, claudeSessionId, resetGit, hasSystemPrompt: !!systemPrompt });
|
|
636
637
|
|
|
637
638
|
try {
|
|
638
639
|
const proc = await this._daemon.activateSession(sessionId, {
|
|
639
640
|
workingDir: this._config.workingDir,
|
|
640
641
|
claudeSessionId,
|
|
641
642
|
resetGit,
|
|
643
|
+
systemPrompt,
|
|
642
644
|
});
|
|
643
645
|
|
|
644
646
|
this.sendDaemonMessage({
|
package/src/daemon.js
CHANGED
|
@@ -125,11 +125,16 @@ class Daemon extends EventEmitter {
|
|
|
125
125
|
* @param {object} [options]
|
|
126
126
|
* @param {string} [options.workingDir]
|
|
127
127
|
* @param {string} [options.claudeSessionId]
|
|
128
|
+
* @param {string} [options.systemPrompt] - Forwarded to ClaudeProcess; appended to default system prompt at spawn
|
|
128
129
|
* @returns {Promise<ClaudeProcess>}
|
|
129
130
|
*/
|
|
130
131
|
async activateSession(sessionId, options = {}) {
|
|
131
132
|
sessionId = String(sessionId); // Normalize — Rails sends integers, Map keys must match
|
|
132
|
-
// If process exists and alive, return it
|
|
133
|
+
// If process exists and alive, return it. Note: any updated options on this
|
|
134
|
+
// call (including systemPrompt) are intentionally ignored — the Claude CLI's
|
|
135
|
+
// system prompt is immutable post-spawn, so we'd be silently lying if we
|
|
136
|
+
// pretended otherwise. To apply a new systemPrompt, terminate the session
|
|
137
|
+
// first; the next activate will spawn fresh with the updated value.
|
|
133
138
|
const existing = this._processes.get(sessionId);
|
|
134
139
|
if (existing && existing.isAlive()) {
|
|
135
140
|
this._logger.debug('Reusing existing session', { sessionId });
|
|
@@ -174,6 +179,7 @@ class Daemon extends EventEmitter {
|
|
|
174
179
|
skipPermissions: this._config.skipPermissions,
|
|
175
180
|
permissionPort: this._permissionPort || null,
|
|
176
181
|
sessionEnv: options.sessionEnv || {},
|
|
182
|
+
systemPrompt: options.systemPrompt,
|
|
177
183
|
logger: this._logger.child(`Session:${sessionId}`),
|
|
178
184
|
});
|
|
179
185
|
|
package/src/git-reset.js
CHANGED
|
@@ -25,9 +25,12 @@ const EXEC_TIMEOUT = 15000; // 15 seconds per git command
|
|
|
25
25
|
async function resetGitState(workingDir, logger) {
|
|
26
26
|
const results = { stash: false, checkout: false, pull: false };
|
|
27
27
|
|
|
28
|
-
// Step 1: stash
|
|
28
|
+
// Step 1: stash TRACKED changes only. We deliberately avoid --include-untracked:
|
|
29
|
+
// vault-style repos (Obsidian notebooks, etc.) routinely hold valuable
|
|
30
|
+
// uncommitted markdown that would otherwise be swept away. If an operator
|
|
31
|
+
// needs a full sweep they can opt out of safe_working_tree per pilot.
|
|
29
32
|
try {
|
|
30
|
-
const { stdout } = await execFileAsync('git', ['stash'
|
|
33
|
+
const { stdout } = await execFileAsync('git', ['stash'], {
|
|
31
34
|
cwd: workingDir,
|
|
32
35
|
timeout: EXEC_TIMEOUT,
|
|
33
36
|
encoding: 'utf8',
|