set working dir

This commit is contained in:
Chris Lettieri 2026-02-24 21:25:04 -05:00
parent 3b49d555fe
commit 00086fe2fd
3 changed files with 17 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import { App, TFile, Notice } from 'obsidian';
import { App, TFile, Notice, FileSystemAdapter } from 'obsidian';
import { exec } from 'child_process';
import { promisify } from 'util';
import * as fs from 'fs';
@ -230,20 +230,30 @@ export class TaskDispatchService {
/**
* Resolve the working directory for a task session.
* Priority: `repo` frontmatter defaultWorkingDir setting home dir.
* Priority: `working_dir` frontmatter defaultWorkingDir setting home dir.
*/
private getWorkingDir(file: TFile): string {
const cache = this.app.metadataCache.getFileCache(file);
const fm = cache?.frontmatter;
const repo = fm?.['repo'];
if (repo && typeof repo === 'string') return repo;
const workingDir = fm?.['working_dir'] || fm?.['working-dir'];
// Absolute paths from frontmatter are used as-is
if (workingDir && typeof workingDir === 'string') {
return path.isAbsolute(workingDir) ? workingDir : this.resolveVaultPath(workingDir);
}
const defaultDir = this.settings.taskDispatch.defaultWorkingDir;
if (defaultDir) return defaultDir;
if (defaultDir) {
return path.isAbsolute(defaultDir) ? defaultDir : this.resolveVaultPath(defaultDir);
}
return process.env.HOME ?? '/tmp';
}
private resolveVaultPath(relative: string): string {
const adapter = this.app.vault.adapter as FileSystemAdapter;
return path.join(adapter.getBasePath(), relative);
}
private async assembleContext(file: TFile, taskId: string): Promise<string> {
// Read note body and strip frontmatter
const rawContent = await this.app.vault.read(file);

View file

@ -59,7 +59,7 @@ export const DEFAULT_SETTINGS: OpenAugiSettings = {
taskDispatch: {
terminalApp: 'iterm2',
tmuxPath: '',
defaultWorkingDir: '',
defaultWorkingDir: 'OpenAugi/Tasks',
agents: [
{
id: 'claude-code',

View file

@ -12,7 +12,7 @@ export type TerminalApp = 'iterm2' | 'terminal-app';
export interface TaskDispatchSettings {
terminalApp: TerminalApp;
tmuxPath: string; // absolute path to tmux binary; empty = auto-detect
defaultWorkingDir: string; // directory Claude launches in; overridden by `repo` frontmatter
defaultWorkingDir: string; // directory Claude launches in; overridden by `working_dir` frontmatter
agents: AgentConfig[];
defaultAgent: string;
contextTempDir: string;