Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix: persist session state in CLI mode and handle quoted text in REPL

sehawq08f6eb5e61b4
diff --git a/gimp/agent-harness/cli_anything/gimp/gimp_cli.py b/gimp/agent-harness/cli_anything/gimp/gimp_cli.py
index 0e5fdfe98..1ad650119 100644
--- a/gimp/agent-harness/cli_anything/gimp/gimp_cli.py
+++ b/gimp/agent-harness/cli_anything/gimp/gimp_cli.py
@@ -18,6 +18,7 @@ Usage:
import sys
import os
import json
+import shlex
import click
from typing import Optional
@@ -136,6 +137,15 @@ def cli(ctx, use_json, project_path):
ctx.invoke(repl, project_path=None)
+def auto_save_on_cli(result, **kwargs):
+ """Auto-save project after CLI commands when --project is specified."""
+ if not _repl_mode:
+ sess = get_session()
+ if sess.has_project() and sess._modified and sess.project_path:
+ proj_mod.save_project(sess.get_project(), sess.project_path)
+
+
# ── Project Commands ─────────────────────────────────────────────
@cli.group()
def project():
@@ -761,8 +771,11 @@ def repl(project_path):
skin.help(_repl_commands)
continue
- # Parse and execute command
- args = line.split()
+ # Parse and execute command (shlex handles quoted strings with spaces)
+ try:
+ args = shlex.split(line)
+ except ValueError:
+ args = line.split()
try:
cli.main(args, standalone_mode=False)
except SystemExit: