From 6080accd3a0ddac79d85e890f31bf063f46b761c Mon Sep 17 00:00:00 2001 From: Xiaohan-Tian <157918347+Xiaohan-Tian@users.noreply.github.com> Date: Thu, 9 Apr 2026 22:17:20 -0700 Subject: [PATCH] feat: added `rm` opfs mock bash command --- src/core/KGDebugger.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/core/KGDebugger.ts b/src/core/KGDebugger.ts index 7d01253..40027c4 100644 --- a/src/core/KGDebugger.ts +++ b/src/core/KGDebugger.ts @@ -345,7 +345,7 @@ export class KGDebugger { console.log(" testExtractXMLFromString(input) - Test XML extraction from string"); console.log(" testToolCall(input) - Execute tool call(s) from JSON and show results"); console.log(" inputChatBox(content, interval?) - Type into ChatBox textarea and submit with Enter"); - console.log(" opfs(command) - OPFS file browser (pwd, ls, cd, cat, dl)"); + console.log(" opfs(command) - OPFS file browser (pwd, ls, cd, cat, dl, rm)"); console.log(" help() - Show this help"); console.log(""); console.log("💡 Usage tips:"); @@ -463,6 +463,7 @@ export class KGDebugger { * cd — change directory (supports .., /, relative, and quoted paths) * cat — print file contents * dl — download a file to your local machine + * rm — remove a file or directory (recursive) * * Usage in console: * await KGDebugger.opfs('pwd') @@ -498,9 +499,13 @@ export class KGDebugger { await this.opfsDl(arg) break + case 'rm': + await this.opfsRm(arg) + break + default: console.log(`opfs: command not found: ${cmd}`) - console.log('Available commands: pwd, ls, cd , cat , dl ') + console.log('Available commands: pwd, ls, cd , cat , dl , rm ') } } catch (error) { console.error(`opfs: ${error}`) @@ -660,4 +665,19 @@ export class KGDebugger { console.error(`opfs: dl: ${fileName}: No such file`) } } + + private async opfsRm(name: string): Promise { + if (!name) { + console.error('opfs: rm: missing file or directory name') + return + } + + const dir = await this.opfsResolveCwd() + try { + await dir.removeEntry(name, { recursive: true }) + console.log(`removed: ${name}`) + } catch { + console.error(`opfs: rm: ${name}: No such file or directory`) + } + } } \ No newline at end of file