clementine-agent 1.0.25 → 1.0.26

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.
@@ -964,12 +964,36 @@ export class Gateway {
964
964
  }
965
965
  }
966
966
  // ── Deep mode detection ─────────────────────────────────────
967
- // Agent proposes background execution for complex tasks
968
- const deepMatch = response?.match(/^\[DEEP_MODE:\s*(.+?)\]\s*/s);
967
+ // Agent proposes background execution for complex tasks.
968
+ //
969
+ // Syntax:
970
+ // [DEEP_MODE: task description]
971
+ // [DEEP_MODE(work_dir=/abs/path): task description] ← NEW
972
+ //
973
+ // The optional work_dir= parameter runs the unleashed task in a
974
+ // different project directory. Useful when the task belongs to
975
+ // a Claude Code project with its own CLAUDE.md / slash commands
976
+ // (e.g. the proposal-builder project for audit-queue approvals).
977
+ const deepMatch = response?.match(/^\[DEEP_MODE(?:\(([^)]+)\))?:\s*(.+?)\]\s*/s);
969
978
  if (deepMatch) {
970
- const taskDesc = deepMatch[1].trim() || text;
971
- const ack = response.replace(/^\[DEEP_MODE:[^\]]*\]\s*/s, '').trim();
979
+ const paramsStr = deepMatch[1] ?? '';
980
+ const taskDesc = deepMatch[2].trim() || text;
981
+ const ack = response.replace(/^\[DEEP_MODE(?:\([^)]*\))?:[^\]]*\]\s*/s, '').trim();
972
982
  logger.info({ sessionKey, task: taskDesc }, 'Deep mode triggered by agent');
983
+ // Parse optional work_dir parameter — strict: must be an absolute
984
+ // path and must exist. Anything else falls back to default.
985
+ let deepWorkDir;
986
+ const wdMatch = paramsStr.match(/work_dir=([^,\s]+)/);
987
+ if (wdMatch) {
988
+ const candidate = wdMatch[1].trim().replace(/^["']|["']$/g, '');
989
+ if (path.isAbsolute(candidate) && existsSync(candidate)) {
990
+ deepWorkDir = candidate;
991
+ logger.info({ sessionKey, workDir: deepWorkDir }, 'Deep mode using custom work_dir');
992
+ }
993
+ else {
994
+ logger.warn({ sessionKey, candidate }, 'Deep mode work_dir rejected (not absolute or does not exist)');
995
+ }
996
+ }
973
997
  const currentSess = this.getSession(sessionKey);
974
998
  const jobName = `deep-${Date.now()}`;
975
999
  currentSess.deepTask = { jobName, taskDesc, startedAt: new Date().toISOString() };
@@ -977,7 +1001,7 @@ export class Gateway {
977
1001
  this.assistant.runUnleashedTask(jobName, `${taskDesc}\n\nOriginal request: ${text}`, 2, // tier 2 (Bash/Write/Edit enabled)
978
1002
  undefined, // default maxTurns (75/phase)
979
1003
  undefined, // default model
980
- undefined, // default workDir
1004
+ deepWorkDir, // honors [DEEP_MODE(work_dir=...)] if provided
981
1005
  1).then(async (result) => {
982
1006
  logger.info({ sessionKey, jobName, resultLen: result?.length ?? 0 }, 'Deep mode task completed');
983
1007
  if (result && result !== '__NOTHING__') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clementine-agent",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Clementine — Personal AI Assistant (TypeScript)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",