muse-cli 0.3.3__tar.gz → 0.3.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: muse-cli
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Command-line client for your personal muse.ai AI agent: chat, automate, and manage side chats, feed, goals, ideas, and sessions from the terminal. No browser needed.
5
5
  Project-URL: Homepage, https://github.com/nikships/muse-cli
6
6
  Project-URL: Documentation, https://github.com/nikships/muse-cli#readme
@@ -1,3 +1,3 @@
1
1
  """muse-cli: talk to your personal muse.ai AI agent from the terminal."""
2
2
 
3
- __version__ = "0.3.3"
3
+ __version__ = "0.3.4"
@@ -6,6 +6,13 @@ reader. Picks up the conversation you used last. Type /help for commands.
6
6
  import json
7
7
  import os
8
8
  import time
9
+ # Enable GNU readline / libedit for line editing, history, and proper
10
+ # CJK/wide-character deletion (wcwidth). It is a standard library C extension,
11
+ # but unavailable on native Windows or stripped/minimal Python installations.
12
+ try:
13
+ import readline
14
+ except ImportError:
15
+ readline = None
9
16
 
10
17
  from .cli import CONFIG_DIR, cmd_auth_export, connect, fmt_event, load_config
11
18
  from .gateway import AuthError, GatewayError
@@ -14,6 +21,7 @@ WAIT = 300 # seconds to wait for the first reply
14
21
  QUIET = 10 # seconds of silence after a reply before taking the next message
15
22
  POLL = 1 # seconds between history reads while waiting for a reply
16
23
  STATE = os.path.join(CONFIG_DIR, "chat.json")
24
+ HISTFILE = os.path.join(CONFIG_DIR, "chat_history")
17
25
 
18
26
  HELP = """Commands:
19
27
  /chats list your conversations
@@ -214,6 +222,11 @@ def start():
214
222
 
215
223
 
216
224
  def cmd_chat(_args):
225
+ if readline is not None:
226
+ try:
227
+ readline.read_history_file(HISTFILE)
228
+ except OSError:
229
+ pass
217
230
  chat = start()
218
231
  print(f"Muse chat, in: {chat.st['title']}. Type /help for commands, /exit to quit.")
219
232
  try:
@@ -255,5 +268,12 @@ def cmd_chat(_args):
255
268
  except KeyboardInterrupt:
256
269
  pass
257
270
  finally:
271
+ if readline is not None:
272
+ try:
273
+ os.makedirs(CONFIG_DIR, exist_ok=True)
274
+ readline.set_history_length(1000)
275
+ readline.write_history_file(HISTFILE)
276
+ except OSError:
277
+ pass
258
278
  chat.gw.close()
259
279
  print("\nBye.")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes