hcli-hai 3.2.0__tar.gz → 3.3.1__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.
Files changed (48) hide show
  1. {hcli_hai-3.2.0/hcli_hai.egg-info → hcli_hai-3.3.1}/PKG-INFO +4 -2
  2. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/README.rst +3 -1
  3. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/ai.py +20 -0
  4. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/behavior.py +1 -0
  5. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/cli.py +3 -1
  6. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/context.py +31 -0
  7. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/runner.py +41 -23
  8. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/template.json +27 -0
  9. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/package.py +1 -1
  10. {hcli_hai-3.2.0 → hcli_hai-3.3.1/hcli_hai.egg-info}/PKG-INFO +4 -2
  11. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai.egg-info/SOURCES.txt +0 -13
  12. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/ai.cpython-311.pyc +0 -0
  13. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/behavior.cpython-311.pyc +0 -0
  14. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/cli.cpython-311.pyc +0 -0
  15. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/config.cpython-311.pyc +0 -0
  16. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/context.cpython-311.pyc +0 -0
  17. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/jobqueue.cpython-311.pyc +0 -0
  18. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/logger.cpython-311.pyc +0 -0
  19. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/model.cpython-311.pyc +0 -0
  20. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/runner.cpython-311.pyc +0 -0
  21. hcli_hai-3.2.0/hcli_hai/cli/__pycache__/service.cpython-311.pyc +0 -0
  22. hcli_hai-3.2.0/hcli_hai/cli/utils/__pycache__/formatting.cpython-311.pyc +0 -0
  23. hcli_hai-3.2.0/hcli_hai/cli/utils/__pycache__/hutils.cpython-311.pyc +0 -0
  24. hcli_hai-3.2.0/hcli_hai/cli/utils/__pycache__/summary.cpython-311.pyc +0 -0
  25. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/LICENSE.txt +0 -0
  26. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/MANIFEST.in +0 -0
  27. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/__init__.py +0 -0
  28. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/__main__.py +0 -0
  29. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/__init__.py +0 -0
  30. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/config.py +0 -0
  31. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/jobqueue.py +0 -0
  32. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/logger.py +0 -0
  33. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/model.py +0 -0
  34. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/service.py +0 -0
  35. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/utils/formatting.py +0 -0
  36. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/utils/hutils.py +0 -0
  37. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/cli/utils/summary.py +0 -0
  38. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/config.py +0 -0
  39. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/data/hcli_hai.1 +0 -0
  40. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai/hutils.py +0 -0
  41. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai.egg-info/dependency_links.txt +0 -0
  42. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai.egg-info/entry_points.txt +0 -0
  43. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai.egg-info/requires.txt +0 -0
  44. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/hcli_hai.egg-info/top_level.txt +0 -0
  45. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/pyproject.toml +0 -0
  46. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/requirements.txt +0 -0
  47. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/setup.cfg +0 -0
  48. {hcli_hai-3.2.0 → hcli_hai-3.3.1}/tests/test_hai.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hcli_hai
3
- Version: 3.2.0
3
+ Version: 3.3.1
4
4
  Summary: HCLI hai is a python package wrapper that contains an HCLI sample application (hai); hai is an HCLI for interacting with Anthropic's Claude or OpenAI's GPT AI models via terminal input and output streams.
5
5
  Author-email: Jeff Michaud <cometaj2@proton.me>
6
6
  License: MIT
@@ -99,11 +99,13 @@ To Do
99
99
  - Context blending to mary different contexts.
100
100
  - Automatic context compression to yield a more substantial memory footprint per context window.
101
101
  - A shell mode for the AI HCLI (hai) to enable shell CLI execution per sought goal.
102
+ - Changing context while vibing is tenuous and can be disgraceful. It should be thought about.
103
+ - Changing the vibing behavior should be made possible; it is currently locked in to HCLI integration and planning.
102
104
 
103
105
  Bugs
104
106
  ----
105
107
 
106
- Vibing thread stays tied to a single and context and won't budge if a different context is selected
108
+ TBD
107
109
 
108
110
  .. |build status| image:: https://circleci.com/gh/cometaj2/hcli_hai.svg?style=shield
109
111
  :target: https://circleci.com/gh/cometaj2/hcli_hai
@@ -76,11 +76,13 @@ To Do
76
76
  - Context blending to mary different contexts.
77
77
  - Automatic context compression to yield a more substantial memory footprint per context window.
78
78
  - A shell mode for the AI HCLI (hai) to enable shell CLI execution per sought goal.
79
+ - Changing context while vibing is tenuous and can be disgraceful. It should be thought about.
80
+ - Changing the vibing behavior should be made possible; it is currently locked in to HCLI integration and planning.
79
81
 
80
82
  Bugs
81
83
  ----
82
84
 
83
- Vibing thread stays tied to a single and context and won't budge if a different context is selected
85
+ TBD
84
86
 
85
87
  .. |build status| image:: https://circleci.com/gh/cometaj2/hcli_hai.svg?style=shield
86
88
  :target: https://circleci.com/gh/cometaj2/hcli_hai
@@ -40,6 +40,7 @@ class AI:
40
40
  self.contextmgr = c.ContextManager()
41
41
  logging.debug(f"[ hai ] AI initialization complete: config={bool(self.config)}, contextmgr={bool(self.contextmgr)}")
42
42
 
43
+ # add an additional message to the chat context and request a response for it with the LLM.
43
44
  def chat(self, inputstream):
44
45
  with self.rlock:
45
46
  if self.config.model is not None:
@@ -101,22 +102,27 @@ class AI:
101
102
  logging.warning(warning)
102
103
  return warning
103
104
 
105
+ # get the current context as json output
104
106
  def get_context(self):
105
107
  with self.rlock:
106
108
  return self.contextmgr.get_context()
107
109
 
110
+ # get the current context as text output
108
111
  def get_readable_context(self):
109
112
  with self.rlock:
110
113
  return self.contextmgr.get_readable_context()
111
114
 
115
+ # clear the current context (clean slate)
112
116
  def clear(self):
113
117
  with self.rlock:
114
118
  self.contextmgr.clear()
115
119
 
120
+ # set the persistent context behavior (system prompt)
116
121
  def behavior(self, inputstream):
117
122
  with self.rlock:
118
123
  self.contextmgr.behavior(inputstream)
119
124
 
125
+ # list all contexts
120
126
  def ls(self):
121
127
  with self.rlock:
122
128
  contexts = []
@@ -168,6 +174,7 @@ class AI:
168
174
 
169
175
  return sorted_contexts
170
176
 
177
+ # set the current context
171
178
  def set(self, context_id):
172
179
  with self.rlock:
173
180
  contexts = self.ls()
@@ -178,6 +185,7 @@ class AI:
178
185
  logging.warning(context_id)
179
186
  logging.warning("[ hai ] Provided context id is not found in available contexts.")
180
187
 
188
+ # create a new context
181
189
  def new(self):
182
190
  with self.rlock:
183
191
  if os.path.exists(self.config.dot_hai_config_file):
@@ -187,6 +195,7 @@ class AI:
187
195
 
188
196
  return self.current()
189
197
 
198
+ # delete the current context
190
199
  def rm(self, context_id):
191
200
  with self.rlock:
192
201
  context_folder = os.path.join(self.config.dot_hai_context, context_id)
@@ -194,28 +203,39 @@ class AI:
194
203
  shutil.rmtree(context_folder)
195
204
  logging.info("[ hai ] Removed " + context_folder)
196
205
 
206
+ # get the current context ID
197
207
  def current(self):
198
208
  with self.rlock:
199
209
  return self.config.context
200
210
 
211
+ # list available models
201
212
  def list_models(self):
202
213
  with self.rlock:
203
214
  return self.config.list_models()
204
215
 
216
+ # get the model to use
205
217
  def model(self):
206
218
  with self.rlock:
207
219
  return self.config.model
208
220
 
221
+ # set the model to use
209
222
  def set_model(self, model):
210
223
  with self.rlock:
211
224
  models = self.list_models()
212
225
  if model in models:
213
226
  self.config.model = model
214
227
 
228
+ # get the context name
215
229
  def name(self):
216
230
  with self.rlock:
217
231
  return self.contextmgr.name()
218
232
 
233
+ # set the context name
219
234
  def set_name(self, name):
220
235
  with self.rlock:
221
236
  self.contextmgr.set_name(name)
237
+
238
+ # output current plan as status
239
+ def status(self):
240
+ with self.rlock:
241
+ return self.contextmgr.status()
@@ -17,6 +17,7 @@ Create a detailed plan for the given task. Your plan should:
17
17
  - Ensure the plan is detailed enough to allow a person to do the task.
18
18
  - Include at most one hcli integration call to help trigger external tool use (only if needed).
19
19
  - If an HCLI service can't be navigated or isn't running, move on, DO NOT try to start nor configure it.
20
+ - If your task is accomplished per your original plan, STOP by no longer outputting a plan.
20
21
  - Be 100% correct and complete.
21
22
 
22
23
  Note: Focus solely on the technical implementation. Ignore any mentions of human tasks or non-technical aspects.
@@ -103,6 +103,8 @@ class CLI:
103
103
  if len(self.commands) == 3:
104
104
  if self.commands[2] == "start":
105
105
  self.service.vibe(True)
106
- if self.commands[2] == "stop":
106
+ elif self.commands[2] == "stop":
107
107
  self.service.vibe(False)
108
+ elif self.commands[2] == "status":
109
+ return io.BytesIO(self.ai.status().encode('utf-8'))
108
110
  return None
@@ -14,6 +14,28 @@ from utils import summary as s
14
14
  logging = logger.Logger()
15
15
 
16
16
 
17
+ # Singleton Plan class to hold the ephemeral plan
18
+ class Plan:
19
+ _instance = None
20
+ _rlock = threading.RLock()
21
+
22
+ def __new__(cls):
23
+ with cls._rlock:
24
+ if cls._instance is None:
25
+ cls._instance = super().__new__(cls)
26
+ cls._instance._plan = ""
27
+ return cls._instance
28
+
29
+ @property
30
+ def plan(self):
31
+ with self._rlock:
32
+ return self._plan
33
+
34
+ @plan.setter
35
+ def plan(self, value):
36
+ with self._rlock:
37
+ self._plan = value
38
+
17
39
  # We create a default context and allow for it to be initialized in a few different ways to facilitate initialization from file
18
40
  class Context:
19
41
 
@@ -122,6 +144,7 @@ class ContextManager:
122
144
  self.counter = TrimCounter()
123
145
  self.config = c.Config()
124
146
  self.context = self.get_context()
147
+ self.plan = Plan()
125
148
 
126
149
  def trim(self):
127
150
  self.counter.trim(self.context)
@@ -234,6 +257,14 @@ class ContextManager:
234
257
 
235
258
  return self.context.title
236
259
 
260
+ def set_status(self, plan):
261
+ with self.rlock:
262
+ self.plan.plan = plan
263
+
264
+ def status(self):
265
+ with self.rlock:
266
+ return self.plan.plan
267
+
237
268
  class TrimCounter:
238
269
  def __init__(self):
239
270
  self.encoding_base = "cl100k_base"
@@ -1,15 +1,15 @@
1
1
  import io
2
- import re
3
2
  import logger
4
3
  import threading
5
4
  import time
5
+ import re
6
6
  import behavior as b
7
7
  import ai
8
8
  from huckle import cli, stdin
9
+ import xml.etree.ElementTree as et
9
10
 
10
11
  logging = logger.Logger()
11
12
 
12
-
13
13
  # Singleton Runner
14
14
  class Runner:
15
15
  instance = None
@@ -31,37 +31,55 @@ class Runner:
31
31
  return self.instance
32
32
 
33
33
  def set_vibe(self, should_vibe):
34
+ self.is_vibing = should_vibe
34
35
  if should_vibe is True:
35
36
  self.ai.behavior(io.BytesIO(b.hcli_integration_behavior.encode('utf-8')))
36
- self.is_vibing = should_vibe
37
+ logging.info(f"[ hai ] Vibe runner started.")
38
+ else:
39
+ logging.info(f"[ hai ] Vibe runner stopped.")
37
40
 
38
41
  def get_plan(self):
39
42
  self.ai.contextmgr.get_context()
40
43
  messages = self.ai.contextmgr.messages()
41
44
  if messages:
42
-
43
- # Get the last item using negative indexing
44
45
  last_message = messages[-1]
45
46
  if last_message['role'] == "assistant":
46
-
47
- # First check if there's a plan tag
48
- plan_pattern = r"<plan>(.*?)</plan>"
49
- plan_matches = re.findall(plan_pattern, last_message['content'], re.DOTALL)
50
-
51
- matches = []
52
- if plan_matches:
53
- # Look for hcli tags within the first plan tag
54
- pattern = r"<hcli>(.*?)</hcli>"
55
- matches = re.findall(pattern, plan_matches[0], re.DOTALL)
56
-
57
- # Check if we have at least one match
58
- if matches:
59
- # Only execute the first match regardless of how many there are
60
- command = matches[0].strip() # Extract the first command inside hcli tags
61
- logging.info(f"[ hai ] returning hcli integration: {command}")
62
- return command
47
+ content = last_message['content']
48
+
49
+ # Use regex to extract the first <plan> element
50
+ plan_pattern = r'<plan>.*?</plan>'
51
+ match = re.search(plan_pattern, content, re.DOTALL)
52
+
53
+ if match:
54
+ plan_content = match.group(0)
55
+ try:
56
+ # Parse just the extracted plan with XML
57
+ plan_elem = et.fromstring(plan_content)
58
+
59
+ # Clear any unwanted text if needed (though regex should have isolated the plan)
60
+ if plan_elem.text and not plan_elem.text.strip():
61
+ plan_elem.text = None
62
+
63
+ plan_string = et.tostring(plan_elem, encoding='utf-8', method='xml')
64
+ self.ai.contextmgr.set_status(plan_string.decode())
65
+
66
+ # Look for hcli tags within the plan
67
+ hcli_elem = plan_elem.find('.//hcli[1]')
68
+ if hcli_elem is not None:
69
+ command = hcli_elem.text.strip() if hcli_elem.text else ""
70
+ logging.info(f"[ hai ] hcli integration: {command}")
71
+ return command
72
+ else:
73
+ logging.debug("[ hai ] Unable to vibe without a plan with hcli tags.")
74
+ self.ai.contextmgr.set_status("")
75
+ return ""
76
+ except et.ParseError as e:
77
+ logging.warning(f"[ hai ] Failed to parse XML plan: {e}")
78
+ self.ai.contextmgr.set_status("")
79
+ return ""
63
80
  else:
64
- logging.warning("[ hai ] I can't vibe without a plan and hcli tags.")
81
+ logging.debug("[ hai ] No plan found in the message content.")
82
+ self.ai.contextmgr.set_status("")
65
83
  return ""
66
84
  return ""
67
85
 
@@ -88,6 +88,10 @@
88
88
  {
89
89
  "command": "hai vibe stop",
90
90
  "http": "post"
91
+ },
92
+ {
93
+ "command": "hai vibe status",
94
+ "http": "get"
91
95
  }
92
96
  ],
93
97
  "cli": [
@@ -497,6 +501,11 @@
497
501
  "href": "haivibestop",
498
502
  "name": "stop",
499
503
  "description": "Stop vibing."
504
+ },
505
+ {
506
+ "href": "haivibestatus",
507
+ "name": "status",
508
+ "description": "Get vibing status and plan."
500
509
  }
501
510
  ]
502
511
  },
@@ -535,6 +544,24 @@
535
544
  "description": "The \"stop\" command allows you to revert your chat back to a static conversation context. The context, inclusing the system prompt, otherwise remains as it was at the time vibing stopped."
536
545
  }
537
546
  ]
547
+ },
548
+ {
549
+ "id": "haivibestatus",
550
+ "name": "status",
551
+ "section": [
552
+ {
553
+ "name": "name",
554
+ "description": "status - returns the current plan and vibing status."
555
+ },
556
+ {
557
+ "name": "synopsis",
558
+ "description": "hai vibe status"
559
+ },
560
+ {
561
+ "name": "description",
562
+ "description": "The \"status\" command allows you to retrieve the current vibing status and plan from the current conversation context."
563
+ }
564
+ ]
538
565
  }
539
566
  ]
540
567
  }
@@ -1,4 +1,4 @@
1
- __version__ = "3.2.0"
1
+ __version__ = "3.3.1"
2
2
  dependencies = ["tiktoken==0.9.0",
3
3
  "anthropic==0.49.0",
4
4
  "huckle>=5.6.0,<6.0.0",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hcli_hai
3
- Version: 3.2.0
3
+ Version: 3.3.1
4
4
  Summary: HCLI hai is a python package wrapper that contains an HCLI sample application (hai); hai is an HCLI for interacting with Anthropic's Claude or OpenAI's GPT AI models via terminal input and output streams.
5
5
  Author-email: Jeff Michaud <cometaj2@proton.me>
6
6
  License: MIT
@@ -99,11 +99,13 @@ To Do
99
99
  - Context blending to mary different contexts.
100
100
  - Automatic context compression to yield a more substantial memory footprint per context window.
101
101
  - A shell mode for the AI HCLI (hai) to enable shell CLI execution per sought goal.
102
+ - Changing context while vibing is tenuous and can be disgraceful. It should be thought about.
103
+ - Changing the vibing behavior should be made possible; it is currently locked in to HCLI integration and planning.
102
104
 
103
105
  Bugs
104
106
  ----
105
107
 
106
- Vibing thread stays tied to a single and context and won't budge if a different context is selected
108
+ TBD
107
109
 
108
110
  .. |build status| image:: https://circleci.com/gh/cometaj2/hcli_hai.svg?style=shield
109
111
  :target: https://circleci.com/gh/cometaj2/hcli_hai
@@ -27,21 +27,8 @@ hcli_hai/cli/model.py
27
27
  hcli_hai/cli/runner.py
28
28
  hcli_hai/cli/service.py
29
29
  hcli_hai/cli/template.json
30
- hcli_hai/cli/__pycache__/ai.cpython-311.pyc
31
- hcli_hai/cli/__pycache__/behavior.cpython-311.pyc
32
- hcli_hai/cli/__pycache__/cli.cpython-311.pyc
33
- hcli_hai/cli/__pycache__/config.cpython-311.pyc
34
- hcli_hai/cli/__pycache__/context.cpython-311.pyc
35
- hcli_hai/cli/__pycache__/jobqueue.cpython-311.pyc
36
- hcli_hai/cli/__pycache__/logger.cpython-311.pyc
37
- hcli_hai/cli/__pycache__/model.cpython-311.pyc
38
- hcli_hai/cli/__pycache__/runner.cpython-311.pyc
39
- hcli_hai/cli/__pycache__/service.cpython-311.pyc
40
30
  hcli_hai/cli/utils/formatting.py
41
31
  hcli_hai/cli/utils/hutils.py
42
32
  hcli_hai/cli/utils/summary.py
43
- hcli_hai/cli/utils/__pycache__/formatting.cpython-311.pyc
44
- hcli_hai/cli/utils/__pycache__/hutils.cpython-311.pyc
45
- hcli_hai/cli/utils/__pycache__/summary.cpython-311.pyc
46
33
  hcli_hai/data/hcli_hai.1
47
34
  tests/test_hai.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes