yaicli 0.0.2__tar.gz → 0.0.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,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.0.2
2
+ current_version = 0.0.4
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -0,0 +1,33 @@
1
+
2
+ ---
3
+ ## [0.0.3](https://github.com/belingud/yaicli/compare/v0.0.2..v0.0.3) - 2025-04-02
4
+
5
+ ### 🚜 Refactor
6
+
7
+ - **(changelog)** switch from git log to git cliff for changelog generation - ([242a51d](https://github.com/belingud/yaicli/commit/242a51d93a25675041a7fe19c4a0db1c7c12a663)) - Belingud
8
+ - update CLI assistant description and error handling - ([1a8bcdc](https://github.com/belingud/yaicli/commit/1a8bcdc86c72a75259d266291bc9e5350fc81f61)) - Belingud
9
+ - fix spacing in clean target and simplify build target - ([2a1050e](https://github.com/belingud/yaicli/commit/2a1050e7a9eea8753c164553b13796e5510b7965)) - Belingud
10
+
11
+
12
+ ---
13
+ ## [0.0.2] - 2025-04-02
14
+
15
+ ### ⛰️ Features
16
+
17
+ - enhance OS detection and LLM API request handling - ([8c00de0](https://github.com/belingud/yaicli/commit/8c00de099e1c75fedcdd33e9d7e0443818538059)) - Belingud
18
+ - add new dependencies and configurable API paths - ([3be3f67](https://github.com/belingud/yaicli/commit/3be3f67b3bd9645a9a8c9909be0e5542612c1c71)) - Belingud
19
+
20
+ ### 🚜 Refactor
21
+
22
+ - **(config)** migrate config from JSON to INI format and enhance error handling - ([f556872](https://github.com/belingud/yaicli/commit/f556872fdb521adf8e20da6498fdaac26998a5b7)) - Belingud
23
+ - update config path to reflect project name change - ([e6bf761](https://github.com/belingud/yaicli/commit/e6bf761aa0fae20b643848c586c6dc55d6f324fb)) - Belingud
24
+ - rename project from llmcli to yaicli and update related files - ([cdb5a97](https://github.com/belingud/yaicli/commit/cdb5a97d06c9f042c1c8731c8f11a4a7284783f0)) - Belingud
25
+ - rename project from shellai to llmcli and update related files - ([db4ecb8](https://github.com/belingud/yaicli/commit/db4ecb85236b72fd7536c99b21d210037c09889e)) - Belingud
26
+ - reorganize imports and improve code readability - ([0f52c05](https://github.com/belingud/yaicli/commit/0f52c05918d177d4623ff2f07aff2fc2e3aa9e91)) - Belingud
27
+ - migrate llmcli to class-based ShellAI implementation - ([2509cba](https://github.com/belingud/yaicli/commit/2509cba5cad7c8626f794d88d971fff7eea9a404)) - Belingud
28
+
29
+ ### Build
30
+
31
+ - add bump2version for version management - ([de287f1](https://github.com/belingud/yaicli/commit/de287f1262eae64ae5fd0cb634dea93762a17282)) - Belingud
32
+
33
+
@@ -17,8 +17,9 @@ test:
17
17
  @pytest tests/
18
18
 
19
19
  # Build package with hatch (runs clean first)
20
- build: clean
20
+ build:
21
21
  @echo "Building package..."
22
+ @rm -rf dist/
22
23
  @uv build
23
24
 
24
25
  # Install package in editable mode
@@ -29,4 +30,4 @@ install:
29
30
  # Generate changelog from git log
30
31
  changelog:
31
32
  @echo "Generating changelog..."
32
- @git log --oneline --decorate --graph > CHANGELOG.md
33
+ @git cliff -l --prepend CHANGELOG.md
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yaicli
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: A simple CLI tool to interact with LLM
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.8
@@ -0,0 +1,90 @@
1
+ # git-cliff ~ configuration file
2
+ # https://git-cliff.org/docs/configuration
3
+
4
+ [changelog]
5
+ # template for the changelog header
6
+ header = """"""
7
+ # template for the changelog body
8
+ # https://keats.github.io/tera/docs/#introduction
9
+ body = """
10
+ ---
11
+ {% if version %}\
12
+ {% if previous.version %}\
13
+ ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
14
+ {% else %}\
15
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
16
+ {% endif %}\
17
+ {% else %}\
18
+ ## [unreleased]
19
+ {% endif %}\
20
+ {% for group, commits in commits | group_by(attribute="group") %}
21
+ ### {{ group | striptags | trim | upper_first }}
22
+ {% for commit in commits
23
+ | filter(attribute="scope")
24
+ | sort(attribute="scope") %}
25
+ - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \
26
+ {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
27
+ {%- endfor -%}
28
+ {% raw %}\n{% endraw %}\
29
+ {%- for commit in commits %}
30
+ {%- if commit.scope -%}
31
+ {% else -%}
32
+ - {% if commit.breaking %} [**breaking**]{% endif %}\
33
+ {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
34
+ {% endif -%}
35
+ {% endfor -%}
36
+ {% endfor %}\n
37
+ """
38
+ # template for the changelog footer
39
+ footer = """"""
40
+ # remove the leading and trailing whitespace from the templates
41
+ trim = true
42
+ # postprocessors
43
+ postprocessors = [
44
+ { pattern = '\$REPO', replace = "https://github.com/belingud/yaicli" }, # replace repository URL
45
+ ]
46
+
47
+ [git]
48
+ # parse the commits based on https://www.conventionalcommits.org
49
+ conventional_commits = true
50
+ # filter out the commits that are not conventional
51
+ filter_unconventional = true
52
+ # process each line of a commit as an individual commit
53
+ split_commits = false
54
+ # regex for preprocessing the commit messages
55
+ commit_preprocessors = [
56
+ # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers
57
+ ]
58
+ # regex for parsing and grouping commits
59
+ commit_parsers = [
60
+ { message = "^feat", group = "<!-- 0 -->⛰️ Features" },
61
+ { message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
62
+ { message = "^doc", group = "<!-- 3 -->📚 Documentation" },
63
+ { message = "^perf", group = "<!-- 4 -->⚡ Performance" },
64
+ { message = "^refactor\\(clippy\\)", skip = true },
65
+ { message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
66
+ { message = "^style", group = "<!-- 5 -->🎨 Styling" },
67
+ { message = "^test", group = "<!-- 6 -->🧪 Testing" },
68
+ { message = "^chore\\(release\\): prepare for", skip = true },
69
+ { message = "^chore\\(deps.*\\)", skip = true },
70
+ { message = "^chore\\(pr\\)", skip = true },
71
+ { message = "^chore\\(pull\\)", skip = true },
72
+ { message = "^chore\\(npm\\).*yarn\\.lock", skip = true },
73
+ { message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
74
+ { body = ".*security", group = "<!-- 8 -->🛡️ Security" },
75
+ { message = "^revert", group = "<!-- 9 -->◀️ Revert" },
76
+ ]
77
+ # protect breaking changes from being skipped due to matching a skipping commit_parser
78
+ protect_breaking_commits = false
79
+ # filter out the commits that are not matched by commit parsers
80
+ filter_commits = false
81
+ # regex for matching git tags
82
+ tag_pattern = "v[0-9].*"
83
+ # regex for skipping tags
84
+ skip_tags = "beta|alpha"
85
+ # regex for ignoring tags
86
+ ignore_tags = "rc|beta"
87
+ # sort the tags topologically
88
+ topo_order = false
89
+ # sort the commits inside sections by oldest/newest order
90
+ sort_commits = "newest"
yaicli-0.0.4/debug.py ADDED
@@ -0,0 +1,22 @@
1
+ import typer
2
+
3
+ app = typer.Typer()
4
+
5
+
6
+ @app.command()
7
+ def run(name: str):
8
+ """
9
+ 这是 run 命令的简短描述。
10
+
11
+ 这是详细的帮助信息,同样可以写多行。
12
+ 这个命令会运行主要的任务。
13
+ """
14
+ print(f"正在为 {name} 运行任务...")
15
+
16
+
17
+ # 注意:如果这是唯一的命令,它的帮助信息会比较突出。
18
+ # 如果还有其他命令,这只是 'run' 命令的帮助。
19
+ # 应用的总体帮助需要通过 Typer(help=...) 设置。
20
+
21
+ if __name__ == "__main__":
22
+ app()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yaicli"
3
- version = "0.0.2"
3
+ version = "0.0.4"
4
4
  description = "A simple CLI tool to interact with LLM"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.8"
@@ -416,7 +416,7 @@ wheels = [
416
416
 
417
417
  [[package]]
418
418
  name = "yaicli"
419
- version = "0.0.1"
419
+ version = "0.0.4"
420
420
  source = { editable = "." }
421
421
  dependencies = [
422
422
  { name = "distro" },
@@ -79,9 +79,7 @@ STREAM=true"""
79
79
  @self.bindings.add(Keys.ControlI) # Bind Ctrl+I to switch modes
80
80
  def _(event: KeyPressEvent):
81
81
  self.current_mode = (
82
- ModeEnum.CHAT.value
83
- if self.current_mode == ModeEnum.EXECUTE.value
84
- else ModeEnum.EXECUTE.value
82
+ ModeEnum.CHAT.value if self.current_mode == ModeEnum.EXECUTE.value else ModeEnum.EXECUTE.value
85
83
  )
86
84
 
87
85
  def detect_os(self):
@@ -126,9 +124,8 @@ Rules:
126
124
  _os = self.detect_os()
127
125
  _shell = self.detect_shell()
128
126
  return (
129
- "You are a system and code assistant, "
130
- f"focusing on {_os} and {_shell}. "
131
- "Assist with system management, script writing, and coding tasks. "
127
+ "You are yaili, a system management and programing assistant, "
128
+ f"You are managing {_os} operating system with {_shell} shell. "
132
129
  "Your responses should be concise and use Markdown format, "
133
130
  "unless the user explicitly requests more details."
134
131
  )
@@ -235,6 +232,8 @@ Rules:
235
232
  response = self._call_api(url, headers, data)
236
233
  except requests.exceptions.RequestException as e:
237
234
  self.console.print(f"[red]Error calling API: {e}[/red]")
235
+ if self.verbose and e.response:
236
+ self.console.print(f"{e.response.text}")
238
237
  raise typer.Exit(code=1) from None
239
238
  if not response:
240
239
  raise typer.Exit(code=1)
@@ -271,9 +270,7 @@ Rules:
271
270
  self.console.print(f"\n[bold green]Executing command: [/bold green] {command}\n")
272
271
  result = subprocess.run(command, shell=True)
273
272
  if result.returncode != 0:
274
- self.console.print(
275
- f"\n[bold red]Command failed with return code: {result.returncode}[/bold red]"
276
- )
273
+ self.console.print(f"\n[bold red]Command failed with return code: {result.returncode}[/bold red]")
277
274
 
278
275
  def get_prompt_tokens(self):
279
276
  """Get prompt tokens based on current mode"""
@@ -382,9 +379,7 @@ Rules:
382
379
  # Load configuration
383
380
  self.config = self.load_config()
384
381
  if not self.config.get("API_KEY", None):
385
- self.console.print(
386
- "[red]API key not found. Please set it in the configuration file.[/red]"
387
- )
382
+ self.console.print("[red]API key not found. Please set it in the configuration file.[/red]")
388
383
  return
389
384
 
390
385
  # Set initial mode
@@ -417,10 +412,10 @@ CONTEXT_SETTINGS = {
417
412
  }
418
413
 
419
414
  app = typer.Typer(
420
- name="ShellAI",
415
+ name="yaicli",
421
416
  context_settings=CONTEXT_SETTINGS,
422
417
  pretty_exceptions_enable=False,
423
- short_help="ShellAI Command Line Tool",
418
+ short_help="yaicli. Your AI interface in cli.",
424
419
  no_args_is_help=True,
425
420
  invoke_without_command=True,
426
421
  )
@@ -428,17 +423,18 @@ app = typer.Typer(
428
423
 
429
424
  @app.command()
430
425
  def main(
431
- prompt: Annotated[str, typer.Argument(show_default=False, help="The prompt send to the LLM")],
432
- verbose: Annotated[
433
- bool, typer.Option("--verbose", "-V", help="Show verbose information")
434
- ] = False,
426
+ ctx: typer.Context,
427
+ prompt: Annotated[str, typer.Argument(show_default=False, help="The prompt send to the LLM")] = "",
428
+ verbose: Annotated[bool, typer.Option("--verbose", "-V", help="Show verbose information")] = False,
435
429
  chat: Annotated[bool, typer.Option("--chat", "-c", help="Start in chat mode")] = False,
436
- shell: Annotated[
437
- bool, typer.Option("--shell", "-s", help="Generate and execute shell command")
438
- ] = False,
430
+ shell: Annotated[bool, typer.Option("--shell", "-s", help="Generate and execute shell command")] = False,
439
431
  ):
440
- """LLM CLI Tool"""
441
- cli = ShellAI()
432
+ """yaicli. Your AI interface in cli."""
433
+ if not prompt and not chat:
434
+ typer.echo(ctx.get_help())
435
+ raise typer.Exit()
436
+
437
+ cli = ShellAI(verbose=verbose)
442
438
  cli.run(chat=chat, shell=shell, prompt=prompt)
443
439
 
444
440
 
yaicli-0.0.2/debug.py DELETED
@@ -1,12 +0,0 @@
1
- from yaicli import ShellAI
2
-
3
-
4
- def main():
5
- ai = ShellAI()
6
- ai.load_config()
7
- r = ai.get_command_from_llm("列出当前目录中所有的文件,包含隐藏文件")
8
- print(r)
9
-
10
-
11
- if __name__ == "__main__":
12
- main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes