oh-my-claude-sisyphus 1.1.0 → 1.2.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.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Command Expansion Utilities
3
+ *
4
+ * Provides SDK-compatible access to slash commands by reading
5
+ * command templates and expanding them with arguments.
6
+ */
7
+ export interface CommandInfo {
8
+ name: string;
9
+ description: string;
10
+ template: string;
11
+ filePath: string;
12
+ }
13
+ export interface ExpandedCommand {
14
+ name: string;
15
+ prompt: string;
16
+ description: string;
17
+ }
18
+ /**
19
+ * Get the commands directory path
20
+ */
21
+ export declare function getCommandsDir(): string;
22
+ /**
23
+ * Get a specific command by name
24
+ */
25
+ export declare function getCommand(name: string): CommandInfo | null;
26
+ /**
27
+ * Get all available commands
28
+ */
29
+ export declare function getAllCommands(): CommandInfo[];
30
+ /**
31
+ * List available command names
32
+ */
33
+ export declare function listCommands(): string[];
34
+ /**
35
+ * Expand a command template with arguments
36
+ *
37
+ * @param name - Command name (without leading slash)
38
+ * @param args - Arguments to substitute for $ARGUMENTS
39
+ * @returns Expanded command ready for SDK query
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { expandCommand } from 'oh-my-claude-sisyphus';
44
+ *
45
+ * const prompt = expandCommand('ralph-loop', 'Build a REST API');
46
+ * // Returns the full ralph-loop template with "Build a REST API" substituted
47
+ * ```
48
+ */
49
+ export declare function expandCommand(name: string, args?: string): ExpandedCommand | null;
50
+ /**
51
+ * Expand a command and return just the prompt string
52
+ * Convenience function for direct use with SDK query
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { expandCommandPrompt } from 'oh-my-claude-sisyphus';
57
+ * import { query } from '@anthropic-ai/claude-agent-sdk';
58
+ *
59
+ * const prompt = expandCommandPrompt('ultrawork', 'Refactor the auth module');
60
+ *
61
+ * for await (const msg of query({ prompt })) {
62
+ * console.log(msg);
63
+ * }
64
+ * ```
65
+ */
66
+ export declare function expandCommandPrompt(name: string, args?: string): string | null;
67
+ /**
68
+ * Check if a command exists
69
+ */
70
+ export declare function commandExists(name: string): boolean;
71
+ /**
72
+ * Batch expand multiple commands
73
+ */
74
+ export declare function expandCommands(commands: Array<{
75
+ name: string;
76
+ args?: string;
77
+ }>): ExpandedCommand[];
78
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAsBD;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAsB3D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,EAAE,CAwB9C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,GAAG,eAAe,GAAG,IAAI,CAerF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,GAAG,MAAM,GAAG,IAAI,CAGlF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,eAAe,EAAE,CAIlG"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Command Expansion Utilities
3
+ *
4
+ * Provides SDK-compatible access to slash commands by reading
5
+ * command templates and expanding them with arguments.
6
+ */
7
+ import { readFileSync, existsSync, readdirSync } from 'fs';
8
+ import { join } from 'path';
9
+ import { homedir } from 'os';
10
+ /**
11
+ * Get the commands directory path
12
+ */
13
+ export function getCommandsDir() {
14
+ return join(homedir(), '.claude', 'commands');
15
+ }
16
+ /**
17
+ * Parse command frontmatter and content
18
+ */
19
+ function parseCommandFile(content) {
20
+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
21
+ if (!frontmatterMatch) {
22
+ return { description: '', template: content };
23
+ }
24
+ const frontmatter = frontmatterMatch[1];
25
+ const template = frontmatterMatch[2];
26
+ // Extract description from frontmatter
27
+ const descMatch = frontmatter.match(/description:\s*(.+)/);
28
+ const description = descMatch ? descMatch[1].trim() : '';
29
+ return { description, template };
30
+ }
31
+ /**
32
+ * Get a specific command by name
33
+ */
34
+ export function getCommand(name) {
35
+ const commandsDir = getCommandsDir();
36
+ const filePath = join(commandsDir, `${name}.md`);
37
+ if (!existsSync(filePath)) {
38
+ return null;
39
+ }
40
+ try {
41
+ const content = readFileSync(filePath, 'utf-8');
42
+ const { description, template } = parseCommandFile(content);
43
+ return {
44
+ name,
45
+ description,
46
+ template,
47
+ filePath
48
+ };
49
+ }
50
+ catch (error) {
51
+ console.error(`Error reading command ${name}:`, error);
52
+ return null;
53
+ }
54
+ }
55
+ /**
56
+ * Get all available commands
57
+ */
58
+ export function getAllCommands() {
59
+ const commandsDir = getCommandsDir();
60
+ if (!existsSync(commandsDir)) {
61
+ return [];
62
+ }
63
+ try {
64
+ const files = readdirSync(commandsDir).filter(f => f.endsWith('.md'));
65
+ const commands = [];
66
+ for (const file of files) {
67
+ const name = file.replace('.md', '');
68
+ const command = getCommand(name);
69
+ if (command) {
70
+ commands.push(command);
71
+ }
72
+ }
73
+ return commands;
74
+ }
75
+ catch (error) {
76
+ console.error('Error listing commands:', error);
77
+ return [];
78
+ }
79
+ }
80
+ /**
81
+ * List available command names
82
+ */
83
+ export function listCommands() {
84
+ return getAllCommands().map(c => c.name);
85
+ }
86
+ /**
87
+ * Expand a command template with arguments
88
+ *
89
+ * @param name - Command name (without leading slash)
90
+ * @param args - Arguments to substitute for $ARGUMENTS
91
+ * @returns Expanded command ready for SDK query
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * import { expandCommand } from 'oh-my-claude-sisyphus';
96
+ *
97
+ * const prompt = expandCommand('ralph-loop', 'Build a REST API');
98
+ * // Returns the full ralph-loop template with "Build a REST API" substituted
99
+ * ```
100
+ */
101
+ export function expandCommand(name, args = '') {
102
+ const command = getCommand(name);
103
+ if (!command) {
104
+ return null;
105
+ }
106
+ // Replace $ARGUMENTS placeholder with actual arguments
107
+ const prompt = command.template.replace(/\$ARGUMENTS/g, args);
108
+ return {
109
+ name,
110
+ prompt: prompt.trim(),
111
+ description: command.description
112
+ };
113
+ }
114
+ /**
115
+ * Expand a command and return just the prompt string
116
+ * Convenience function for direct use with SDK query
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { expandCommandPrompt } from 'oh-my-claude-sisyphus';
121
+ * import { query } from '@anthropic-ai/claude-agent-sdk';
122
+ *
123
+ * const prompt = expandCommandPrompt('ultrawork', 'Refactor the auth module');
124
+ *
125
+ * for await (const msg of query({ prompt })) {
126
+ * console.log(msg);
127
+ * }
128
+ * ```
129
+ */
130
+ export function expandCommandPrompt(name, args = '') {
131
+ const expanded = expandCommand(name, args);
132
+ return expanded ? expanded.prompt : null;
133
+ }
134
+ /**
135
+ * Check if a command exists
136
+ */
137
+ export function commandExists(name) {
138
+ return getCommand(name) !== null;
139
+ }
140
+ /**
141
+ * Batch expand multiple commands
142
+ */
143
+ export function expandCommands(commands) {
144
+ return commands
145
+ .map(({ name, args }) => expandCommand(name, args))
146
+ .filter((c) => c !== null);
147
+ }
148
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAe7B;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAE5E,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAChD,CAAC;IAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAErC,uCAAuC;IACvC,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,I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,IAAI,EAAE,IAAI,CAAC,CAAC;SAClD,MAAM,CAAC,CAAC,CAAC,EAAwB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Auto-Update System
3
+ *
4
+ * Provides version checking and auto-update functionality for Oh-My-Claude-Sisyphus.
5
+ *
6
+ * Features:
7
+ * - Check for new versions from GitHub releases
8
+ * - Download and install updates automatically
9
+ * - Store version metadata for installed components
10
+ * - Configurable update notifications
11
+ */
12
+ /** GitHub repository information */
13
+ export declare const REPO_OWNER = "Yeachan-Heo";
14
+ export declare const REPO_NAME = "oh-my-claude-sisyphus";
15
+ export declare const GITHUB_API_URL = "https://api.github.com/repos/Yeachan-Heo/oh-my-claude-sisyphus";
16
+ export declare const GITHUB_RAW_URL = "https://raw.githubusercontent.com/Yeachan-Heo/oh-my-claude-sisyphus";
17
+ /** Installation paths */
18
+ export declare const CLAUDE_CONFIG_DIR: string;
19
+ export declare const VERSION_FILE: string;
20
+ /**
21
+ * Version metadata stored after installation
22
+ */
23
+ export interface VersionMetadata {
24
+ /** Currently installed version */
25
+ version: string;
26
+ /** Installation timestamp */
27
+ installedAt: string;
28
+ /** Last update check timestamp */
29
+ lastCheckAt?: string;
30
+ /** Git commit hash if installed from source */
31
+ commitHash?: string;
32
+ /** Installation method: 'script' | 'npm' | 'source' */
33
+ installMethod: 'script' | 'npm' | 'source';
34
+ }
35
+ /**
36
+ * GitHub release information
37
+ */
38
+ export interface ReleaseInfo {
39
+ tag_name: string;
40
+ name: string;
41
+ published_at: string;
42
+ html_url: string;
43
+ body: string;
44
+ prerelease: boolean;
45
+ draft: boolean;
46
+ }
47
+ /**
48
+ * Update check result
49
+ */
50
+ export interface UpdateCheckResult {
51
+ currentVersion: string | null;
52
+ latestVersion: string;
53
+ updateAvailable: boolean;
54
+ releaseInfo: ReleaseInfo;
55
+ releaseNotes: string;
56
+ }
57
+ /**
58
+ * Update result
59
+ */
60
+ export interface UpdateResult {
61
+ success: boolean;
62
+ previousVersion: string | null;
63
+ newVersion: string;
64
+ message: string;
65
+ errors?: string[];
66
+ }
67
+ /**
68
+ * Read the current version metadata
69
+ */
70
+ export declare function getInstalledVersion(): VersionMetadata | null;
71
+ /**
72
+ * Save version metadata after installation/update
73
+ */
74
+ export declare function saveVersionMetadata(metadata: VersionMetadata): void;
75
+ /**
76
+ * Update the last check timestamp
77
+ */
78
+ export declare function updateLastCheckTime(): void;
79
+ /**
80
+ * Fetch the latest release from GitHub
81
+ */
82
+ export declare function fetchLatestRelease(): Promise<ReleaseInfo>;
83
+ /**
84
+ * Compare semantic versions
85
+ * Returns: -1 if a < b, 0 if a == b, 1 if a > b
86
+ */
87
+ export declare function compareVersions(a: string, b: string): number;
88
+ /**
89
+ * Check for available updates
90
+ */
91
+ export declare function checkForUpdates(): Promise<UpdateCheckResult>;
92
+ /**
93
+ * Download and execute the install script to perform an update
94
+ */
95
+ export declare function performUpdate(options?: {
96
+ skipConfirmation?: boolean;
97
+ verbose?: boolean;
98
+ }): Promise<UpdateResult>;
99
+ /**
100
+ * Get a formatted update notification message
101
+ */
102
+ export declare function formatUpdateNotification(checkResult: UpdateCheckResult): string;
103
+ /**
104
+ * Check if enough time has passed since the last update check
105
+ */
106
+ export declare function shouldCheckForUpdates(intervalHours?: number): boolean;
107
+ /**
108
+ * Perform a background update check (non-blocking)
109
+ */
110
+ export declare function backgroundUpdateCheck(callback?: (result: UpdateCheckResult) => void): void;
111
+ /**
112
+ * CLI helper: perform interactive update
113
+ */
114
+ export declare function interactiveUpdate(): Promise<void>;
115
+ //# sourceMappingURL=auto-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../../src/features/auto-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,oCAAoC;AACpC,eAAO,MAAM,UAAU,gBAAgB,CAAC;AACxC,eAAO,MAAM,SAAS,0BAA0B,CAAC;AACjD,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H,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAMnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC,CAa/D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB5D;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAmBlE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,OAAO,CAAC,YAAY,CAAC,CAyExB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CA8B/E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,GAAE,MAAW,GAAG,OAAO,CAYzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,IAAI,CAqB1F;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CA8BvD"}
@@ -0,0 +1,305 @@
1
+ /**
2
+ * Auto-Update System
3
+ *
4
+ * Provides version checking and auto-update functionality for Oh-My-Claude-Sisyphus.
5
+ *
6
+ * Features:
7
+ * - Check for new versions from GitHub releases
8
+ * - Download and install updates automatically
9
+ * - Store version metadata for installed components
10
+ * - Configurable update notifications
11
+ */
12
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from 'fs';
13
+ import { join, dirname } from 'path';
14
+ import { homedir, tmpdir } from 'os';
15
+ import { execSync } from 'child_process';
16
+ /** GitHub repository information */
17
+ export const REPO_OWNER = 'Yeachan-Heo';
18
+ export const REPO_NAME = 'oh-my-claude-sisyphus';
19
+ export const GITHUB_API_URL = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}`;
20
+ export const GITHUB_RAW_URL = `https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}`;
21
+ /** Installation paths */
22
+ export const CLAUDE_CONFIG_DIR = join(homedir(), '.claude');
23
+ export const VERSION_FILE = join(CLAUDE_CONFIG_DIR, '.sisyphus-version.json');
24
+ /**
25
+ * Read the current version metadata
26
+ */
27
+ export function getInstalledVersion() {
28
+ if (!existsSync(VERSION_FILE)) {
29
+ // Try to detect version from package.json if installed via npm
30
+ try {
31
+ // Check if we can find the package in node_modules
32
+ const result = execSync('npm list -g oh-my-claude-sisyphus --json 2>/dev/null', {
33
+ encoding: 'utf-8',
34
+ timeout: 5000
35
+ });
36
+ const data = JSON.parse(result);
37
+ if (data.dependencies?.['oh-my-claude-sisyphus']?.version) {
38
+ return {
39
+ version: data.dependencies['oh-my-claude-sisyphus'].version,
40
+ installedAt: new Date().toISOString(),
41
+ installMethod: 'npm'
42
+ };
43
+ }
44
+ }
45
+ catch {
46
+ // Not installed via npm or command failed
47
+ }
48
+ return null;
49
+ }
50
+ try {
51
+ const content = readFileSync(VERSION_FILE, 'utf-8');
52
+ return JSON.parse(content);
53
+ }
54
+ catch (error) {
55
+ console.error('Error reading version file:', error);
56
+ return null;
57
+ }
58
+ }
59
+ /**
60
+ * Save version metadata after installation/update
61
+ */
62
+ export function saveVersionMetadata(metadata) {
63
+ const dir = dirname(VERSION_FILE);
64
+ if (!existsSync(dir)) {
65
+ mkdirSync(dir, { recursive: true });
66
+ }
67
+ writeFileSync(VERSION_FILE, JSON.stringify(metadata, null, 2));
68
+ }
69
+ /**
70
+ * Update the last check timestamp
71
+ */
72
+ export function updateLastCheckTime() {
73
+ const current = getInstalledVersion();
74
+ if (current) {
75
+ current.lastCheckAt = new Date().toISOString();
76
+ saveVersionMetadata(current);
77
+ }
78
+ }
79
+ /**
80
+ * Fetch the latest release from GitHub
81
+ */
82
+ export async function fetchLatestRelease() {
83
+ const response = await fetch(`${GITHUB_API_URL}/releases/latest`, {
84
+ headers: {
85
+ 'Accept': 'application/vnd.github.v3+json',
86
+ 'User-Agent': 'oh-my-claude-sisyphus-updater'
87
+ }
88
+ });
89
+ if (!response.ok) {
90
+ throw new Error(`Failed to fetch release info: ${response.status} ${response.statusText}`);
91
+ }
92
+ return await response.json();
93
+ }
94
+ /**
95
+ * Compare semantic versions
96
+ * Returns: -1 if a < b, 0 if a == b, 1 if a > b
97
+ */
98
+ export function compareVersions(a, b) {
99
+ // Remove 'v' prefix if present
100
+ const cleanA = a.replace(/^v/, '');
101
+ const cleanB = b.replace(/^v/, '');
102
+ const partsA = cleanA.split('.').map(n => parseInt(n, 10) || 0);
103
+ const partsB = cleanB.split('.').map(n => parseInt(n, 10) || 0);
104
+ const maxLength = Math.max(partsA.length, partsB.length);
105
+ for (let i = 0; i < maxLength; i++) {
106
+ const numA = partsA[i] || 0;
107
+ const numB = partsB[i] || 0;
108
+ if (numA < numB)
109
+ return -1;
110
+ if (numA > numB)
111
+ return 1;
112
+ }
113
+ return 0;
114
+ }
115
+ /**
116
+ * Check for available updates
117
+ */
118
+ export async function checkForUpdates() {
119
+ const installed = getInstalledVersion();
120
+ const release = await fetchLatestRelease();
121
+ const currentVersion = installed?.version ?? null;
122
+ const latestVersion = release.tag_name.replace(/^v/, '');
123
+ const updateAvailable = currentVersion === null || compareVersions(currentVersion, latestVersion) < 0;
124
+ // Update last check time
125
+ updateLastCheckTime();
126
+ return {
127
+ currentVersion,
128
+ latestVersion,
129
+ updateAvailable,
130
+ releaseInfo: release,
131
+ releaseNotes: release.body || 'No release notes available.'
132
+ };
133
+ }
134
+ /**
135
+ * Download and execute the install script to perform an update
136
+ */
137
+ export async function performUpdate(options) {
138
+ const installed = getInstalledVersion();
139
+ const previousVersion = installed?.version ?? null;
140
+ try {
141
+ // Fetch the latest release to get the version
142
+ const release = await fetchLatestRelease();
143
+ const newVersion = release.tag_name.replace(/^v/, '');
144
+ // Download the install script
145
+ const installScriptUrl = `${GITHUB_RAW_URL}/main/scripts/install.sh`;
146
+ const response = await fetch(installScriptUrl);
147
+ if (!response.ok) {
148
+ throw new Error(`Failed to download install script: ${response.status}`);
149
+ }
150
+ const scriptContent = await response.text();
151
+ // Save to a temporary file
152
+ const tempDir = tmpdir();
153
+ const tempScript = join(tempDir, `sisyphus-update-${Date.now()}.sh`);
154
+ writeFileSync(tempScript, scriptContent, { mode: 0o755 });
155
+ // Execute the install script
156
+ try {
157
+ const output = execSync(`bash "${tempScript}"`, {
158
+ encoding: 'utf-8',
159
+ stdio: options?.verbose ? 'inherit' : 'pipe',
160
+ timeout: 60000 // 1 minute timeout
161
+ });
162
+ // Update version metadata
163
+ saveVersionMetadata({
164
+ version: newVersion,
165
+ installedAt: new Date().toISOString(),
166
+ installMethod: 'script',
167
+ lastCheckAt: new Date().toISOString()
168
+ });
169
+ // Clean up temp file
170
+ try {
171
+ unlinkSync(tempScript);
172
+ }
173
+ catch {
174
+ // Ignore cleanup errors
175
+ }
176
+ return {
177
+ success: true,
178
+ previousVersion,
179
+ newVersion,
180
+ message: `Successfully updated from ${previousVersion ?? 'unknown'} to ${newVersion}`
181
+ };
182
+ }
183
+ catch (error) {
184
+ // Clean up temp file on error too
185
+ try {
186
+ unlinkSync(tempScript);
187
+ }
188
+ catch {
189
+ // Ignore cleanup errors
190
+ }
191
+ throw error;
192
+ }
193
+ }
194
+ catch (error) {
195
+ const errorMessage = error instanceof Error ? error.message : String(error);
196
+ return {
197
+ success: false,
198
+ previousVersion,
199
+ newVersion: 'unknown',
200
+ message: `Update failed: ${errorMessage}`,
201
+ errors: [errorMessage]
202
+ };
203
+ }
204
+ }
205
+ /**
206
+ * Get a formatted update notification message
207
+ */
208
+ export function formatUpdateNotification(checkResult) {
209
+ if (!checkResult.updateAvailable) {
210
+ return `Oh-My-Claude-Sisyphus is up to date (v${checkResult.currentVersion ?? 'unknown'})`;
211
+ }
212
+ const lines = [
213
+ '╔═══════════════════════════════════════════════════════════╗',
214
+ '║ Oh-My-Claude-Sisyphus Update Available! ║',
215
+ '╚═══════════════════════════════════════════════════════════╝',
216
+ '',
217
+ ` Current version: ${checkResult.currentVersion ?? 'unknown'}`,
218
+ ` Latest version: ${checkResult.latestVersion}`,
219
+ '',
220
+ ' To update, run: /update',
221
+ ' Or run: curl -fsSL https://raw.githubusercontent.com/Yeachan-Heo/oh-my-claude-sisyphus/main/scripts/install.sh | bash',
222
+ ''
223
+ ];
224
+ // Add truncated release notes if available
225
+ if (checkResult.releaseNotes && checkResult.releaseNotes !== 'No release notes available.') {
226
+ lines.push(' Release notes:');
227
+ const notes = checkResult.releaseNotes.split('\n').slice(0, 5);
228
+ notes.forEach(line => lines.push(` ${line}`));
229
+ if (checkResult.releaseNotes.split('\n').length > 5) {
230
+ lines.push(' ...');
231
+ }
232
+ lines.push('');
233
+ }
234
+ return lines.join('\n');
235
+ }
236
+ /**
237
+ * Check if enough time has passed since the last update check
238
+ */
239
+ export function shouldCheckForUpdates(intervalHours = 24) {
240
+ const installed = getInstalledVersion();
241
+ if (!installed?.lastCheckAt) {
242
+ return true;
243
+ }
244
+ const lastCheck = new Date(installed.lastCheckAt).getTime();
245
+ const now = Date.now();
246
+ const hoursSinceLastCheck = (now - lastCheck) / (1000 * 60 * 60);
247
+ return hoursSinceLastCheck >= intervalHours;
248
+ }
249
+ /**
250
+ * Perform a background update check (non-blocking)
251
+ */
252
+ export function backgroundUpdateCheck(callback) {
253
+ if (!shouldCheckForUpdates()) {
254
+ return;
255
+ }
256
+ // Run the check asynchronously without blocking
257
+ checkForUpdates()
258
+ .then(result => {
259
+ if (callback) {
260
+ callback(result);
261
+ }
262
+ else if (result.updateAvailable) {
263
+ // Default behavior: print notification to console
264
+ console.log('\n' + formatUpdateNotification(result));
265
+ }
266
+ })
267
+ .catch(error => {
268
+ // Silently ignore errors in background checks
269
+ if (process.env.SISYPHUS_DEBUG) {
270
+ console.error('Background update check failed:', error);
271
+ }
272
+ });
273
+ }
274
+ /**
275
+ * CLI helper: perform interactive update
276
+ */
277
+ export async function interactiveUpdate() {
278
+ console.log('Checking for updates...');
279
+ try {
280
+ const checkResult = await checkForUpdates();
281
+ if (!checkResult.updateAvailable) {
282
+ console.log(`✓ You are running the latest version (${checkResult.currentVersion})`);
283
+ return;
284
+ }
285
+ console.log(formatUpdateNotification(checkResult));
286
+ console.log('Starting update...\n');
287
+ const result = await performUpdate({ verbose: true });
288
+ if (result.success) {
289
+ console.log(`\n✓ ${result.message}`);
290
+ console.log('\nPlease restart your Claude Code session to use the new version.');
291
+ }
292
+ else {
293
+ console.error(`\n✗ ${result.message}`);
294
+ if (result.errors) {
295
+ result.errors.forEach(err => console.error(` - ${err}`));
296
+ }
297
+ process.exit(1);
298
+ }
299
+ }
300
+ catch (error) {
301
+ console.error('Update check failed:', error instanceof Error ? error.message : error);
302
+ process.exit(1);
303
+ }
304
+ }
305
+ //# sourceMappingURL=auto-update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-update.js","sourceRoot":"","sources":["../../src/features/auto-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAgB,MAAM,IAAI,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAEhD,oCAAoC;AACpC,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,uBAAuB,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,UAAU,IAAI,SAAS,EAAE,CAAC;AACxF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AC;YACpF,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,WAAW,CAAC,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAEpC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACvC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Background Task Management
3
+ *
4
+ * Provides utilities for managing background task execution,
5
+ * similar to oh-my-opencode's Background Task Manager.
6
+ *
7
+ * In Claude Code, background execution is controlled via:
8
+ * - Bash tool's `run_in_background` parameter
9
+ * - Task tool's `run_in_background` parameter
10
+ * - TaskOutput tool for retrieving results
11
+ *
12
+ * This module provides:
13
+ * - Decision heuristics for when to use background execution
14
+ * - Task lifecycle management
15
+ * - Concurrency limit enforcement
16
+ * - System prompt guidance for agents
17
+ */
18
+ import type { BackgroundTask, SessionState, PluginConfig } from '../shared/types.js';
19
+ /**
20
+ * Default maximum concurrent background tasks
21
+ */
22
+ export declare const DEFAULT_MAX_BACKGROUND_TASKS = 5;
23
+ /**
24
+ * Patterns that indicate long-running operations
25
+ * These should typically run in background
26
+ */
27
+ export declare const LONG_RUNNING_PATTERNS: RegExp[];
28
+ /**
29
+ * Patterns that should always run blocking (foreground)
30
+ * These are quick operations or need immediate feedback
31
+ */
32
+ export declare const BLOCKING_PATTERNS: RegExp[];
33
+ /**
34
+ * Result of background execution decision
35
+ */
36
+ export interface TaskExecutionDecision {
37
+ /** Whether to run in background */
38
+ runInBackground: boolean;
39
+ /** Human-readable reason for the decision */
40
+ reason: string;
41
+ /** Estimated duration category */
42
+ estimatedDuration: 'quick' | 'medium' | 'long' | 'unknown';
43
+ /** Confidence level of the decision */
44
+ confidence: 'high' | 'medium' | 'low';
45
+ }
46
+ /**
47
+ * Determine if a command should run in background
48
+ *
49
+ * This is the core heuristic function that decides whether a command
50
+ * should be executed with `run_in_background: true`.
51
+ *
52
+ * @param command - The command to analyze
53
+ * @param currentBackgroundCount - Number of currently running background tasks
54
+ * @param maxBackgroundTasks - Maximum allowed concurrent background tasks
55
+ * @returns Decision object with recommendation and reasoning
56
+ */
57
+ export declare function shouldRunInBackground(command: string, currentBackgroundCount?: number, maxBackgroundTasks?: number): TaskExecutionDecision;
58
+ /**
59
+ * BackgroundTaskManager interface
60
+ *
61
+ * Manages background task lifecycle, enforces concurrency limits,
62
+ * and provides utilities for tracking task status.
63
+ */
64
+ export interface BackgroundTaskManager {
65
+ /** Register a new background task */
66
+ registerTask(agentName: string, prompt: string): BackgroundTask;
67
+ /** Get all background tasks */
68
+ getTasks(): BackgroundTask[];
69
+ /** Get tasks by status */
70
+ getTasksByStatus(status: BackgroundTask['status']): BackgroundTask[];
71
+ /** Get count of running tasks */
72
+ getRunningCount(): number;
73
+ /** Check if we can start a new background task */
74
+ canStartNewTask(): boolean;
75
+ /** Update task status */
76
+ updateTaskStatus(taskId: string, status: BackgroundTask['status'], result?: string, error?: string): void;
77
+ /** Mark task as completed */
78
+ completeTask(taskId: string, result: string): void;
79
+ /** Mark task as failed */
80
+ failTask(taskId: string, error: string): void;
81
+ /** Remove completed tasks older than specified age (ms) */
82
+ pruneCompletedTasks(maxAge?: number): number;
83
+ /** Get the maximum allowed background tasks */
84
+ getMaxTasks(): number;
85
+ /** Check if a command should run in background */
86
+ shouldRunInBackground(command: string): TaskExecutionDecision;
87
+ }
88
+ /**
89
+ * Create a BackgroundTaskManager instance
90
+ */
91
+ export declare function createBackgroundTaskManager(state: SessionState, config: PluginConfig): BackgroundTaskManager;
92
+ /**
93
+ * System prompt guidance for background task execution
94
+ *
95
+ * This text should be appended to the system prompt to guide agents
96
+ * on when and how to use background execution.
97
+ */
98
+ export declare function getBackgroundTaskGuidance(maxBackgroundTasks?: number): string;
99
+ //# sourceMappingURL=background-tasks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-tasks.d.ts","sourceRoot":"","sources":["../../src/features/background-tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,UAuCjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UA0B7B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,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AE,YAAY,EACnB,MAAM,EAAE,YAAY,GACnB,qBAAqB,CAkEvB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,kBAAkB,GAAE,MAAqC,GAAG,MAAM,CAkD3G"}
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Background Task Management
3
+ *
4
+ * Provides utilities for managing background task execution,
5
+ * similar to oh-my-opencode's Background Task Manager.
6
+ *
7
+ * In Claude Code, background execution is controlled via:
8
+ * - Bash tool's `run_in_background` parameter
9
+ * - Task tool's `run_in_background` parameter
10
+ * - TaskOutput tool for retrieving results
11
+ *
12
+ * This module provides:
13
+ * - Decision heuristics for when to use background execution
14
+ * - Task lifecycle management
15
+ * - Concurrency limit enforcement
16
+ * - System prompt guidance for agents
17
+ */
18
+ /**
19
+ * Default maximum concurrent background tasks
20
+ */
21
+ export const DEFAULT_MAX_BACKGROUND_TASKS = 5;
22
+ /**
23
+ * Patterns that indicate long-running operations
24
+ * These should typically run in background
25
+ */
26
+ export const LONG_RUNNING_PATTERNS = [
27
+ // Package managers
28
+ /\b(npm|yarn|pnpm|bun)\s+(install|ci|update|upgrade)\b/i,
29
+ /\b(pip|pip3)\s+install\b/i,
30
+ /\bcargo\s+(build|install|test)\b/i,
31
+ /\bgo\s+(build|install|test)\b/i,
32
+ /\brustup\s+(update|install)\b/i,
33
+ /\bgem\s+install\b/i,
34
+ /\bcomposer\s+install\b/i,
35
+ /\bmaven|mvn\s+(install|package|test)\b/i,
36
+ /\bgradle\s+(build|test)\b/i,
37
+ // Build commands
38
+ /\b(npm|yarn|pnpm|bun)\s+run\s+(build|compile|bundle)\b/i,
39
+ /\bmake\s*(all|build|install)?\s*$/i,
40
+ /\bcmake\s+--build\b/i,
41
+ /\btsc\s+(--build|-b)?\b/i,
42
+ /\bwebpack\b/i,
43
+ /\brollup\b/i,
44
+ /\besbuild\b/i,
45
+ /\bvite\s+build\b/i,
46
+ // Test suites
47
+ /\b(npm|yarn|pnpm|bun)\s+run\s+test\b/i,
48
+ /\b(jest|mocha|vitest|pytest|cargo\s+test)\b/i,
49
+ /\bgo\s+test\b/i,
50
+ // Docker operations
51
+ /\bdocker\s+(build|pull|push)\b/i,
52
+ /\bdocker-compose\s+(up|build)\b/i,
53
+ // Database operations
54
+ /\b(prisma|typeorm|sequelize)\s+(migrate|generate|push)\b/i,
55
+ // Linting large codebases
56
+ /\b(eslint|prettier)\s+[^|]*\.\s*$/i,
57
+ // Git operations on large repos
58
+ /\bgit\s+(clone|fetch|pull)\b/i,
59
+ ];
60
+ /**
61
+ * Patterns that should always run blocking (foreground)
62
+ * These are quick operations or need immediate feedback
63
+ */
64
+ export const BLOCKING_PATTERNS = [
65
+ // Quick status checks
66
+ /\bgit\s+(status|diff|log|branch)\b/i,
67
+ /\bls\b/i,
68
+ /\bpwd\b/i,
69
+ /\bcat\b/i,
70
+ /\becho\b/i,
71
+ /\bhead\b/i,
72
+ /\btail\b/i,
73
+ /\bwc\b/i,
74
+ /\bwhich\b/i,
75
+ /\btype\b/i,
76
+ // File operations
77
+ /\bcp\b/i,
78
+ /\bmv\b/i,
79
+ /\brm\b/i,
80
+ /\bmkdir\b/i,
81
+ /\btouch\b/i,
82
+ // Environment checks
83
+ /\benv\b/i,
84
+ /\bprintenv\b/i,
85
+ /\bnode\s+-[vpe]\b/i,
86
+ /\bnpm\s+-v\b/i,
87
+ /\bpython\s+--version\b/i,
88
+ ];
89
+ /**
90
+ * Determine if a command should run in background
91
+ *
92
+ * This is the core heuristic function that decides whether a command
93
+ * should be executed with `run_in_background: true`.
94
+ *
95
+ * @param command - The command to analyze
96
+ * @param currentBackgroundCount - Number of currently running background tasks
97
+ * @param maxBackgroundTasks - Maximum allowed concurrent background tasks
98
+ * @returns Decision object with recommendation and reasoning
99
+ */
100
+ export function shouldRunInBackground(command, currentBackgroundCount = 0, maxBackgroundTasks = DEFAULT_MAX_BACKGROUND_TASKS) {
101
+ // Check if at capacity
102
+ if (currentBackgroundCount >= maxBackgroundTasks) {
103
+ return {
104
+ runInBackground: false,
105
+ reason: `At background task limit (${currentBackgroundCount}/${maxBackgroundTasks}). Wait for existing tasks or run blocking.`,
106
+ estimatedDuration: 'unknown',
107
+ confidence: 'high'
108
+ };
109
+ }
110
+ // Check for explicit blocking patterns first
111
+ for (const pattern of BLOCKING_PATTERNS) {
112
+ if (pattern.test(command)) {
113
+ return {
114
+ runInBackground: false,
115
+ reason: 'Quick operation that should complete immediately.',
116
+ estimatedDuration: 'quick',
117
+ confidence: 'high'
118
+ };
119
+ }
120
+ }
121
+ // Check for long-running patterns
122
+ for (const pattern of LONG_RUNNING_PATTERNS) {
123
+ if (pattern.test(command)) {
124
+ return {
125
+ runInBackground: true,
126
+ reason: 'Long-running operation detected. Run in background to continue other work.',
127
+ estimatedDuration: 'long',
128
+ confidence: 'high'
129
+ };
130
+ }
131
+ }
132
+ // Heuristic: commands with multiple operations (piped or chained)
133
+ if ((command.match(/\|/g) || []).length > 2 || (command.match(/&&/g) || []).length > 2) {
134
+ return {
135
+ runInBackground: true,
136
+ reason: 'Complex command chain that may take time.',
137
+ estimatedDuration: 'medium',
138
+ confidence: 'medium'
139
+ };
140
+ }
141
+ // Default: run blocking for unknown commands
142
+ return {
143
+ runInBackground: false,
144
+ reason: 'Unknown command type. Running blocking for immediate feedback.',
145
+ estimatedDuration: 'unknown',
146
+ confidence: 'low'
147
+ };
148
+ }
149
+ /**
150
+ * Create a BackgroundTaskManager instance
151
+ */
152
+ export function createBackgroundTaskManager(state, config) {
153
+ const maxBackgroundTasks = config.permissions?.maxBackgroundTasks ?? DEFAULT_MAX_BACKGROUND_TASKS;
154
+ return {
155
+ registerTask(agentName, prompt) {
156
+ const task = {
157
+ id: `task_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`,
158
+ agentName,
159
+ prompt,
160
+ status: 'pending'
161
+ };
162
+ state.backgroundTasks.push(task);
163
+ return task;
164
+ },
165
+ getTasks() {
166
+ return [...state.backgroundTasks];
167
+ },
168
+ getTasksByStatus(status) {
169
+ return state.backgroundTasks.filter(t => t.status === status);
170
+ },
171
+ getRunningCount() {
172
+ return state.backgroundTasks.filter(t => t.status === 'running' || t.status === 'pending').length;
173
+ },
174
+ canStartNewTask() {
175
+ return this.getRunningCount() < maxBackgroundTasks;
176
+ },
177
+ updateTaskStatus(taskId, status, result, error) {
178
+ const task = state.backgroundTasks.find(t => t.id === taskId);
179
+ if (task) {
180
+ task.status = status;
181
+ if (result !== undefined)
182
+ task.result = result;
183
+ if (error !== undefined)
184
+ task.error = error;
185
+ }
186
+ },
187
+ completeTask(taskId, result) {
188
+ this.updateTaskStatus(taskId, 'completed', result);
189
+ },
190
+ failTask(taskId, error) {
191
+ this.updateTaskStatus(taskId, 'error', undefined, error);
192
+ },
193
+ pruneCompletedTasks(_maxAge = 5 * 60 * 1000) {
194
+ // Note: maxAge-based pruning would require tracking task completion timestamps
195
+ // For now, just prune all completed/errored tasks
196
+ const before = state.backgroundTasks.length;
197
+ state.backgroundTasks = state.backgroundTasks.filter(t => t.status !== 'completed' && t.status !== 'error');
198
+ return before - state.backgroundTasks.length;
199
+ },
200
+ getMaxTasks() {
201
+ return maxBackgroundTasks;
202
+ },
203
+ shouldRunInBackground(command) {
204
+ return shouldRunInBackground(command, this.getRunningCount(), maxBackgroundTasks);
205
+ }
206
+ };
207
+ }
208
+ /**
209
+ * System prompt guidance for background task execution
210
+ *
211
+ * This text should be appended to the system prompt to guide agents
212
+ * on when and how to use background execution.
213
+ */
214
+ export function getBackgroundTaskGuidance(maxBackgroundTasks = DEFAULT_MAX_BACKGROUND_TASKS) {
215
+ return `
216
+ ## Background Task Execution
217
+
218
+ For long-running operations, use the \`run_in_background\` parameter to avoid blocking.
219
+
220
+ ### When to Use Background Execution
221
+
222
+ **Run in Background** (set \`run_in_background: true\`):
223
+ - Package installation: \`npm install\`, \`pip install\`, \`cargo build\`
224
+ - Build processes: \`npm run build\`, \`make\`, \`tsc\`
225
+ - Test suites: \`npm test\`, \`pytest\`, \`cargo test\`
226
+ - Docker operations: \`docker build\`, \`docker pull\`
227
+ - Git operations on large repos: \`git clone\`, \`git fetch\`
228
+ - Database migrations: \`prisma migrate\`, \`typeorm migration:run\`
229
+
230
+ **Run Blocking** (foreground, immediate):
231
+ - Quick status checks: \`git status\`, \`ls\`, \`pwd\`
232
+ - File operations: \`cat\`, \`head\`, \`tail\`
233
+ - Simple commands: \`echo\`, \`which\`, \`env\`
234
+ - Operations needing immediate feedback
235
+
236
+ ### How to Use Background Execution
237
+
238
+ 1. **Start in background:**
239
+ \`\`\`
240
+ Bash(command: "npm run build", run_in_background: true)
241
+ \`\`\`
242
+
243
+ 2. **Continue with other work** while the task runs
244
+
245
+ 3. **Check results later:**
246
+ \`\`\`
247
+ TaskOutput(task_id: "<task_id_from_step_1>", block: false)
248
+ \`\`\`
249
+
250
+ ### Concurrency Limits
251
+
252
+ - Maximum **${maxBackgroundTasks}** concurrent background tasks
253
+ - If at limit, wait for existing tasks to complete or run the new task blocking
254
+ - Use \`TaskOutput\` to check if background tasks have finished
255
+
256
+ ### Decision Checklist
257
+
258
+ Before running a command, ask:
259
+ 1. Will this take more than 5 seconds? → Consider background
260
+ 2. Do I need the result immediately? → Run blocking
261
+ 3. Can I do other useful work while waiting? → Use background
262
+ 4. Am I at the background task limit? → Run blocking or wait
263
+ `;
264
+ }
265
+ //# sourceMappingURL=background-tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-tasks.js","sourceRoot":"","sources":["../../src/features/background-tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,mBAAmB;IACnB,wDAAwD;IACxD,2BAA2B;IAC3B,mCAAmC;IACnC,gCAAgC;IAChC,gCAAgC;IAChC,oBAAoB;IACpB,yBAAyB;IACzB,yCAAyC;IACzC,4BAA4B;IAE5B,iBAAiB;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AgB,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;QAED,mBAAmB,CAAC,UAAkB,CAAC,GAAG,EAAE,GAAG,IAAI;YACjD,+EAA+E;YAC/E,kDAAkD;YAClD,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC;YAC5C,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CACvD,CAAC,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,CACjD,CAAC;YACF,OAAO,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC;QAC/C,CAAC;QAED,WAAW;YACT,OAAO,kBAAkB,CAAC;QAC5B,CAAC;QAED,qBAAqB,CAAC,OAAe;YACnC,OAAO,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,kBAAkB,CAAC,CAAC;QACpF,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,qBAA6B,4BAA4B;IACjG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCK,kBAAkB;;;;;;;;;;;CAW/B,CAAC;AACF,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * - Monitors todo list for incomplete items
6
6
  * - Adds reminders to continue when tasks remain
7
7
  * - Prevents premature stopping
8
+ * - Provides background task execution guidance
8
9
  */
9
10
  import type { HookDefinition } from '../shared/types.js';
10
11
  /**
@@ -18,7 +19,7 @@ export declare function createContinuationHook(): HookDefinition;
18
19
  /**
19
20
  * System prompt addition for continuation enforcement
20
21
  */
21
- export declare const continuationSystemPromptAddition = "\n## Continuation Enforcement\n\nCRITICAL RULES - You MUST follow these:\n\n1. **Never Stop with Incomplete Work**\n - Before stopping, verify ALL tasks in your todo list are complete\n - Check that all requested features are implemented\n - Ensure tests pass (if applicable)\n - Verify no error messages remain unaddressed\n\n2. **Task Completion Verification**\n - Mark tasks complete ONLY when fully done\n - If blocked, create a new task describing the blocker\n - If a task fails, don't mark it complete - fix it\n\n3. **Quality Gates**\n - Code compiles/runs without errors\n - All requested functionality works\n - No obvious bugs or issues remain\n\n4. **When to Stop**\n You may ONLY stop when:\n - All tasks in the todo list are marked complete\n - User explicitly says \"stop\" or \"that's enough\"\n - You've verified the work meets requirements\n\n5. **If Uncertain**\n - Ask the user for clarification\n - Create a verification task\n - Continue investigating rather than stopping prematurely\n";
22
+ export declare const continuationSystemPromptAddition: string;
22
23
  /**
23
24
  * Check prompt for signals that all work is done
24
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"continuation-enforcement.d.ts","sourceRoot":"","sources":["../../src/features/continuation-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,oBAAoB,CAAC;AAoBlF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,cAAc,CA2BvD;AAED;;GAEG;AACH,eAAO,MAAM,gCAAgC,uhCA+B5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB,CAsCA;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUtE"}
1
+ {"version":3,"file":"continuation-enforcement.d.ts","sourceRoot":"","sources":["../../src/features/continuation-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,oBAAoB,CAAC;AAqBlF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,cAAc,CA2BvD;AAED;;GAEG;AACH,eAAO,MAAM,gCAAgC,QAgC5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB,CAsCA;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUtE"}
@@ -5,7 +5,9 @@
5
5
  * - Monitors todo list for incomplete items
6
6
  * - Adds reminders to continue when tasks remain
7
7
  * - Prevents premature stopping
8
+ * - Provides background task execution guidance
8
9
  */
10
+ import { getBackgroundTaskGuidance, DEFAULT_MAX_BACKGROUND_TASKS } from './background-tasks.js';
9
11
  /**
10
12
  * Messages to remind agents to continue
11
13
  */
@@ -32,7 +34,7 @@ function getRandomReminder() {
32
34
  export function createContinuationHook() {
33
35
  return {
34
36
  event: 'Stop',
35
- handler: async (context) => {
37
+ handler: async (_context) => {
36
38
  // In a real implementation, this would check the actual todo state
37
39
  // For now, we'll provide the structure for integration
38
40
  // The hook would examine:
@@ -87,6 +89,7 @@ CRITICAL RULES - You MUST follow these:
87
89
  - Ask the user for clarification
88
90
  - Create a verification task
89
91
  - Continue investigating rather than stopping prematurely
92
+ ${getBackgroundTaskGuidance(DEFAULT_MAX_BACKGROUND_TASKS)}
90
93
  `;
91
94
  /**
92
95
  * Check prompt for signals that all work is done
@@ -1 +1 @@
1
- {"version":3,"file":"continuation-enforcement.js","sourceRoot":"","sources":["../../src/features/continuation-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,sBAAsB,GAAG;IAC7B,4FAA4F;IAC5F,wFAAwF;IACxF,6DAA6D;IAC7D,qDAAqD;IACrD,uDAAuD;CACxD,CAAC;AAEF;;GAEG;AACH,SAAS,iBAAiB;IACxB,OAAO,sBAAsB,CAAC,IAAI,C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,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,8BAA8B;SACvC,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,8CAA8C;SACvD,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,iCAAiC;KAC1C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAmB;IAC5D,OAAO;;;yBAGgB,WAAW;;;;;6CAKS,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"continuation-enforcement.js","sourceRoot":"","sources":["../../src/features/continuation-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAEhG;;GAEG;AACH,MAAM,sBAAsB,GAAG;IAC7B,4FAA4F;IAC5F,wFAAwF;IACxF,6DAA6D;IAC7D,qDAAqD;IACrD,uDAAuD;CACxD,CAAC;AAEF;;GAEG;AACH,SAAS,iBAAiB;IACxB,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,KAAK,EAAE,QAAqB,EAAuB,EAAE;YAC5D,mEAAmE;YACnE,uDAAuD;YAEvD,0BAA0B;YAC1B,iCAAiC;YACjC,+CAA+C;YAC/C,kDAAkD;YAElD,uEAAuE;YACvE,MAAM,kBAAkB,GAAG,KAAK,CAAC,CAAC,kCAAkC;YAEpE,IAAI,kBAAkB,EAAE,CAAC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WAAmB;IAC5D,OAAO;;;yBAGgB,WAAW;;;;;6CAKS,CAAC;AAC9C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -14,12 +14,15 @@
14
14
  */
15
15
  import { loadConfig } from './config/loader.js';
16
16
  import { getAgentDefinitions, sisyphusSystemPrompt } from './agents/definitions.js';
17
+ import { type BackgroundTaskManager, type TaskExecutionDecision } from './features/background-tasks.js';
17
18
  import type { PluginConfig, SessionState } from './shared/types.js';
18
19
  export { loadConfig, getAgentDefinitions, sisyphusSystemPrompt };
19
20
  export { getDefaultMcpServers, toSdkMcpFormat } from './mcp/servers.js';
20
21
  export { lspTools, astTools, allCustomTools } from './tools/index.js';
21
22
  export { createMagicKeywordProcessor, detectMagicKeywords } from './features/magic-keywords.js';
23
+ export { createBackgroundTaskManager, shouldRunInBackground, getBackgroundTaskGuidance, DEFAULT_MAX_BACKGROUND_TASKS, LONG_RUNNING_PATTERNS, BLOCKING_PATTERNS, type BackgroundTaskManager, type TaskExecutionDecision } from './features/background-tasks.js';
22
24
  export * from './shared/types.js';
25
+ export { expandCommand, expandCommandPrompt, getCommand, getAllCommands, listCommands, commandExists, expandCommands, getCommandsDir, type CommandInfo, type ExpandedCommand } from './commands/index.js';
23
26
  /**
24
27
  * Options for creating a Sisyphus session
25
28
  */
@@ -67,6 +70,10 @@ export interface SisyphusSession {
67
70
  processPrompt: (prompt: string) => string;
68
71
  /** Get detected magic keywords in a prompt */
69
72
  detectKeywords: (prompt: string) => string[];
73
+ /** Background task manager for controlling async execution */
74
+ backgroundTasks: BackgroundTaskManager;
75
+ /** Check if a command should run in background (convenience method) */
76
+ shouldRunInBackground: (command: string) => TaskExecutionDecision;
70
77
  }
71
78
  /**
72
79
  * Create a Sisyphus orchestration session
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAA0C,MAAM,oBAAoB,CAA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MAAM,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAC;YAChE,YAAY,EAAE,MAAM,EAAE,CAAC;YACvB,cAAc,EAAE,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;IACF,oBAAoB;IACpB,KAAK,EAAE,YAAY,CAAC;IACpB,2BAA2B;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,gDAAgD;IAChD,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,8CAA8C;IAC9C,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAC7C,8DAA8D;IAC9D,eAAe,EAAE,qBAAqB,CAAC;IACvC,uEAAuE;IACvE,qBAAqB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,qBAAqB,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,eAAe,CAsGhF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAG3E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAYT"}
package/dist/index.js CHANGED
@@ -17,11 +17,15 @@ import { getAgentDefinitions, sisyphusSystemPrompt } from './agents/definitions.
17
17
  import { getDefaultMcpServers, toSdkMcpFormat } from './mcp/servers.js';
18
18
  import { createMagicKeywordProcessor, detectMagicKeywords } from './features/magic-keywords.js';
19
19
  import { continuationSystemPromptAddition } from './features/continuation-enforcement.js';
20
+ import { createBackgroundTaskManager, shouldRunInBackground as shouldRunInBackgroundFn } from './features/background-tasks.js';
20
21
  export { loadConfig, getAgentDefinitions, sisyphusSystemPrompt };
21
22
  export { getDefaultMcpServers, toSdkMcpFormat } from './mcp/servers.js';
22
23
  export { lspTools, astTools, allCustomTools } from './tools/index.js';
23
24
  export { createMagicKeywordProcessor, detectMagicKeywords } from './features/magic-keywords.js';
25
+ export { createBackgroundTaskManager, shouldRunInBackground, getBackgroundTaskGuidance, DEFAULT_MAX_BACKGROUND_TASKS, LONG_RUNNING_PATTERNS, BLOCKING_PATTERNS } from './features/background-tasks.js';
24
26
  export * from './shared/types.js';
27
+ // Command expansion utilities for SDK integration
28
+ export { expandCommand, expandCommandPrompt, getCommand, getAllCommands, listCommands, commandExists, expandCommands, getCommandsDir } from './commands/index.js';
25
29
  /**
26
30
  * Create a Sisyphus orchestration session
27
31
  *
@@ -107,6 +111,8 @@ export function createSisyphusSession(options) {
107
111
  backgroundTasks: [],
108
112
  contextFiles: findContextFiles(options?.workingDirectory)
109
113
  };
114
+ // Create background task manager
115
+ const backgroundTaskManager = createBackgroundTaskManager(state, config);
110
116
  return {
111
117
  queryOptions: {
112
118
  options: {
@@ -120,7 +126,9 @@ export function createSisyphusSession(options) {
120
126
  state,
121
127
  config,
122
128
  processPrompt,
123
- detectKeywords: (prompt) => detectMagicKeywords(prompt, config.magicKeywords)
129
+ detectKeywords: (prompt) => detectMagicKeywords(prompt, config.magicKeywords),
130
+ backgroundTasks: backgroundTaskManager,
131
+ shouldRunInBackground: (command) => shouldRunInBackgroundFn(command, backgroundTaskManager.getRunningCount(), backgroundTaskManager.getMaxTasks())
124
132
  };
125
133
  }
126
134
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,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C9B;SACF;QACD,KAAK;QACL,MAAM;QACN,aAAa;QACb,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;QACrF,eAAe,EAAE,qBAAqB;QACtC,qBAAqB,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,uBAAuB,CACjE,OAAO,EACP,qBAAqB,CAAC,eAAe,EAAE,EACvC,qBAAqB,CAAC,WAAW,EAAE,CACpC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,MAAqB;IACjE,MAAM,SAAS,GAAG,2BAA2B,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrE,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAGvC;IACC,IAAI,MAAM,GAAG,oBAAoB,CAAC;IAElC,IAAI,OAAO,EAAE,mBAAmB,KAAK,KAAK,EAAE,CAAC;QAC3C,MAAM,IAAI,gCAAgC,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,MAAM,IAAI,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-claude-sisyphus",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Multi-agent orchestration system for Claude Agent SDK - Port of oh-my-opencode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -460,7 +460,11 @@ $ARGUMENTS
460
460
  - 'multimodal-looker' for analyzing images/screenshots
461
461
  - Maximize throughput by running multiple operations concurrently
462
462
  - Continue until ALL tasks are 100% complete - verify before stopping
463
- - Use background agents for long-running operations
463
+ - Use background execution for long-running operations:
464
+ - For Bash: set \`run_in_background: true\` for npm install, builds, tests
465
+ - For Task: set \`run_in_background: true\` for long-running subagent tasks
466
+ - Use \`TaskOutput\` to check results later
467
+ - Maximum 5 concurrent background tasks
464
468
  - Report progress frequently
465
469
 
466
470
  CRITICAL: Do NOT stop until every task is verified complete.
@@ -537,7 +541,10 @@ Delegate tasks to specialized agents using the Task tool:
537
541
 
538
542
  ### Execution Rules
539
543
  - Break complex tasks into subtasks for delegation
540
- - Use background agents for long-running operations
544
+ - Use background execution for long-running operations:
545
+ - Set \`run_in_background: true\` in Bash for builds, installs, tests
546
+ - Set \`run_in_background: true\` in Task for long-running subagents
547
+ - Check results with \`TaskOutput\` tool
541
548
  - Verify completion before stopping
542
549
  - Check your todo list before declaring done
543
550
  - NEVER leave work incomplete
@@ -868,6 +875,29 @@ Use the Task tool to delegate to specialized agents:
868
875
  - Use parallel execution when possible for speed
869
876
  - Report progress regularly
870
877
  - For complex tasks, plan before implementing
878
+
879
+ ## Background Task Execution
880
+
881
+ For long-running operations, use \`run_in_background: true\`:
882
+
883
+ **Run in Background** (set \`run_in_background: true\`):
884
+ - Package installation: npm install, pip install, cargo build
885
+ - Build processes: npm run build, make, tsc
886
+ - Test suites: npm test, pytest, cargo test
887
+ - Docker operations: docker build, docker pull
888
+ - Git operations: git clone, git fetch
889
+
890
+ **Run Blocking** (foreground):
891
+ - Quick status checks: git status, ls, pwd
892
+ - File reads: cat, head, tail
893
+ - Simple commands: echo, which, env
894
+
895
+ **How to Use:**
896
+ 1. Bash: \`run_in_background: true\`
897
+ 2. Task: \`run_in_background: true\`
898
+ 3. Check results: \`TaskOutput(task_id: "...")\`
899
+
900
+ Maximum 5 concurrent background tasks.
871
901
  CLAUDEMD_EOF
872
902
  echo -e "${GREEN}✓ Created $CLAUDE_CONFIG_DIR/CLAUDE.md${NC}"
873
903
  else