lemonpie-cli 0.3.2__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.
Files changed (76) hide show
  1. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/INDEX.md +15 -4
  2. lemonpie_cli-0.3.4/.agents/kb/topics/architecture/project-structure.md +67 -0
  3. lemonpie_cli-0.3.4/.agents/kb/topics/backend/_topic.md +6 -0
  4. lemonpie_cli-0.3.4/.agents/kb/topics/backend/client.md +84 -0
  5. lemonpie_cli-0.3.4/.agents/kb/topics/backend/error-handling.md +62 -0
  6. lemonpie_cli-0.3.4/.agents/kb/topics/cicd/_topic.md +8 -0
  7. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/topics/cicd/ci-workflow.md +8 -6
  8. lemonpie_cli-0.3.4/.agents/kb/topics/cicd/pr-labeling.md +51 -0
  9. lemonpie_cli-0.3.4/.agents/kb/topics/cicd/release-please-config.md +54 -0
  10. lemonpie_cli-0.3.4/.agents/kb/topics/cicd/release-workflow.md +74 -0
  11. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/topics/cli/_topic.md +1 -0
  12. lemonpie_cli-0.3.4/.agents/kb/topics/cli/cli-commands.md +131 -0
  13. lemonpie_cli-0.3.4/.agents/kb/topics/cli/init-wizard.md +55 -0
  14. lemonpie_cli-0.3.4/.agents/kb/topics/config/config-format.md +70 -0
  15. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/topics/config/config-paths.md +17 -5
  16. lemonpie_cli-0.3.4/.agents/kb/topics/sessions/_topic.md +5 -0
  17. lemonpie_cli-0.3.4/.agents/kb/topics/sessions/session-storage.md +97 -0
  18. lemonpie_cli-0.3.4/.agents/kb/topics/testing/_topic.md +5 -0
  19. lemonpie_cli-0.3.4/.agents/kb/topics/testing/test-suite.md +61 -0
  20. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.github/release.yml +0 -3
  21. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.github/workflows/ci.yml +1 -1
  22. lemonpie_cli-0.3.2/.github/workflows/pr-labler.yml → lemonpie_cli-0.3.4/.github/workflows/pr-auto-label.yml +1 -1
  23. lemonpie_cli-0.3.4/.release-please/config.json +18 -0
  24. lemonpie_cli-0.3.4/.release-please/manifest.json +3 -0
  25. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/CHANGELOG.md +24 -0
  26. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/PKG-INFO +10 -2
  27. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/README.md +9 -1
  28. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/usage/command-index.md +5 -2
  29. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/_version.py +2 -2
  30. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/cli/config_cmd.py +132 -25
  31. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/config.py +9 -1
  32. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/main.py +81 -23
  33. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/models.py +13 -5
  34. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/sessions/storage.py +15 -6
  35. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/tests/conftest.py +9 -2
  36. lemonpie_cli-0.3.4/tests/test_api_key.py +310 -0
  37. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/tests/test_config_cmd.py +10 -10
  38. lemonpie_cli-0.3.4/tests/test_dry_run.py +790 -0
  39. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/tests/test_sessions.py +13 -8
  40. lemonpie_cli-0.3.2/.agents/kb/topics/architecture/project-structure.md +0 -59
  41. lemonpie_cli-0.3.2/.agents/kb/topics/backend/_topic.md +0 -5
  42. lemonpie_cli-0.3.2/.agents/kb/topics/backend/client.md +0 -53
  43. lemonpie_cli-0.3.2/.agents/kb/topics/cicd/_topic.md +0 -6
  44. lemonpie_cli-0.3.2/.agents/kb/topics/cicd/release-workflow.md +0 -50
  45. lemonpie_cli-0.3.2/.agents/kb/topics/cli/cli-commands.md +0 -87
  46. lemonpie_cli-0.3.2/.agents/kb/topics/config/config-format.md +0 -55
  47. lemonpie_cli-0.3.2/.agents/kb/topics/sessions/_topic.md +0 -5
  48. lemonpie_cli-0.3.2/.agents/kb/topics/sessions/session-storage.md +0 -45
  49. lemonpie_cli-0.3.2/.release-please/config.json +0 -30
  50. lemonpie_cli-0.3.2/.release-please/manifest.json +0 -3
  51. lemonpie_cli-0.3.2/tests/test_dry_run.py +0 -233
  52. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/topics/architecture/_topic.md +0 -0
  53. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.agents/kb/topics/config/_topic.md +0 -0
  54. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.github/workflows/release.yml +0 -0
  55. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/.gitignore +0 -0
  56. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/AGENTS.md +0 -0
  57. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/LICENSE +0 -0
  58. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/SECURITY.md +0 -0
  59. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/ROADMAP.md +0 -0
  60. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/config.example.json +0 -0
  61. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/design/code-completion.md +0 -0
  62. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/design/feature-ideas.md +0 -0
  63. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/design/model-verification.md +0 -0
  64. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/docs/design/packaging.md +0 -0
  65. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/pyproject.toml +0 -0
  66. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/__init__.py +0 -0
  67. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/cli/__init__.py +0 -0
  68. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/cli/parser.py +0 -0
  69. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/cli/ui.py +0 -0
  70. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/client.py +0 -0
  71. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/paths.py +0 -0
  72. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/sessions/__init__.py +0 -0
  73. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/src/lemonpie/time_utils.py +0 -0
  74. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/tests/test_cli.py +0 -0
  75. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/tests/test_client.py +0 -0
  76. {lemonpie_cli-0.3.2 → lemonpie_cli-0.3.4}/uv.lock +0 -0
@@ -19,7 +19,7 @@
19
19
 
20
20
  ## Controlled tags
21
21
 
22
- `architecture`, `config`, `cli`, `sessions`, `backend`, `cicd`, `packaging`
22
+ `architecture`, `config`, `cli`, `sessions`, `backend`, `cicd`, `packaging`, `testing`
23
23
 
24
24
  ---
25
25
 
@@ -37,16 +37,27 @@
37
37
  ### cli
38
38
 
39
39
  - `20261117-cli-commands` — **CLI commands** — `topics/cli/cli-commands.md` — Full flag reference for lm/lemonpie and lmConfig — every flag, its effect, and usage examples.
40
+ - `20261129-init-wizard` — **lmConfig --init wizard** — `topics/cli/init-wizard.md` — How `lmConfig --init` walks through backend choice, server verification, API-key retry, model selection, and saving the config.
40
41
 
41
42
  ### sessions
42
43
 
43
- - `20261117-session-storage` — **Session storage** — `topics/sessions/session-storage.md` — How chat sessions are persisted locally — file location, write strategy, and history format.
44
+ - `20261117-session-storage` — **Session storage** — `topics/sessions/session-storage.md` — How chat sessions are persisted locally — files, ID format, record shape, write strategy, and the current-session pointer.
44
45
 
45
46
  ### backend
46
47
 
47
- - `20261117-http-client` — **HTTP backend client** — `topics/backend/client.md` — Unified OpenAI-compatible HTTP client (client.py) supporting Ollama, llama.cpp, LM Studio, vLLM, and hosted APIs.
48
+ - `20261117-http-client` — **HTTP backend client** — `topics/backend/client.md` — How lemonpie talks to AI backends — a unified OpenAI-compatible HTTP client (client.py) supporting Ollama, llama.cpp, LM Studio, vLLM, and hosted APIs.
49
+ - `20261129-error-handling` — **Error handling** — `topics/backend/error-handling.md` — Request timeouts, how connection failures are mapped to messages and hints, and what is saved when a request fails or is interrupted.
48
50
 
49
51
  ### cicd
50
52
 
51
53
  - `20261117-ci-workflow` — **CI workflow** — `topics/cicd/ci-workflow.md` — GitHub Actions CI pipeline — triggers, what it runs, and the tools it uses (uv, pytest).
52
- - `20261117-release-workflow` — **Release workflow** — `topics/cicd/release-workflow.md` — release-please manages the PR and tag, then PyPI publish uses OIDC trusted publishing.
54
+ - `20261117-release-workflow` — **Release workflow** — `topics/cicd/release-workflow.md` — GitHub Actions release pipeline — release-please manages the PR and tag, then PyPI publish uses OIDC trusted publishing.
55
+ - `20261129-release-please-config` — **release-please configuration** — `topics/cicd/release-please-config.md` — Settings in .release-please/config.json — prerelease versioning, tag format, draft releases, PR title, and changelog type.
56
+ - `20261129-pr-labeling` — **PR labeling and release notes** — `topics/cicd/pr-labeling.md` — How PRs are auto-labeled from conventional-commit titles and how .github/release.yml groups release notes by label.
57
+
58
+ ### testing
59
+
60
+ - `20261129-test-suite` — **Test suite** — `topics/testing/test-suite.md` — How the pytest suite isolates config/session paths, mocks I/O and the network, and what each test module covers.
61
+
62
+
63
+ ---
@@ -0,0 +1,67 @@
1
+ ---
2
+ id: 20261117-project-structure
3
+ title: Project structure
4
+ tags: [architecture]
5
+ created: 2026-11-17
6
+ updated: 2026-11-29
7
+ related: [20261117-http-client, 20261117-cli-commands, 20261117-session-storage, 20261117-config-paths, 20261129-test-suite]
8
+ summary: Source layout of the lemonpie package — what each module does and how they relate.
9
+ ---
10
+
11
+ # Project structure
12
+
13
+ > Summary: Source layout of the lemonpie package — what each module does and how they relate.
14
+
15
+ ## Context
16
+
17
+ LemonPie is packaged as `lemonpie-cli` on PyPI. The importable package lives under
18
+ `src/lemonpie/` and exposes three entry points: `lm`, `lemonpie` (both → `main:main`),
19
+ and `lmConfig` (→ `cli.config_cmd:main`). Runtime dependencies are deliberately just `httpx2`
20
+ and `platformdirs`.
21
+
22
+ ## Module map
23
+
24
+ ```
25
+ src/lemonpie/
26
+ main.py # CLI session manager — entry point for `lm` / `lemonpie`
27
+ config.py # Config load/save (atomic, 0600), env overrides (LEMONPIE_HOST, LEMONPIE_API_KEY),
28
+ # URL validation, request timeouts
29
+ paths.py # OS-appropriate config/data directories (via platformdirs); creates them at import
30
+ time_utils.py # ISO-8601 timestamp helpers (now_ts, short_date)
31
+ models.py # Model lookup by alias/name, resolution, mid-session model switch
32
+ client.py # OpenAI-compatible HTTP client — payload, streaming chat, error mapping
33
+ _version.py # Generated by hatch-vcs at build time; never edit
34
+ cli/
35
+ parser.py # Argument parsing for `lm`
36
+ ui.py # Terminal helpers — confirm(), session printing, StatusSpinner
37
+ config_cmd.py # Config manager and `--init` wizard — entry point for `lmConfig`
38
+ sessions/
39
+ storage.py # Session persistence — create/load/save/delete, current-session pointer
40
+ tests/ # pytest suite (see Test suite note)
41
+ ```
42
+
43
+ ## Key relationships
44
+
45
+ - `main.py` orchestrates: it uses `cli/parser.py` for args, `config.py` for settings,
46
+ `models.py` to resolve the target model, `client.py` to stream responses,
47
+ `cli/ui.py` for the spinner and session printing, and `sessions/storage.py` to persist history.
48
+ - `models.py` imports `sessions/storage.py` because switching a session's model saves the session.
49
+ - `paths.py` is the single place that knows OS-specific locations — both `config.py` and
50
+ `sessions/storage.py` import its values rather than duplicating platform logic. It reads
51
+ environment variables and creates directories at import time.
52
+ - `cli/config_cmd.py` is an independent entry point; it imports `config.py`, `models.py`,
53
+ `cli/ui.py`, and `client.py` (to probe the server in `--init`) but does not depend on `main.py`.
54
+
55
+ ## Build system
56
+
57
+ Built with **hatchling** + **hatch-vcs** (version derived from git tags).
58
+ Version is written to `src/lemonpie/_version.py` at build time. Requires Python `>=3.11`.
59
+ See `pyproject.toml` for the full build configuration.
60
+
61
+ ## Related
62
+
63
+ - [HTTP backend client](../backend/client.md) — supports: `main.py` calls into this for all LLM I/O.
64
+ - [CLI commands](../cli/cli-commands.md) — supports: `parser.py` and `config_cmd.py` define the user-facing API.
65
+ - [Session storage](../sessions/session-storage.md) — supports: `storage.py` handles all history persistence.
66
+ - [Config and data paths](../config/config-paths.md) — supports: what `paths.py` resolves and how to override it.
67
+ - [Test suite](../testing/test-suite.md) — see-also: how tests isolate the modules above.
@@ -0,0 +1,6 @@
1
+ # Backend
2
+
3
+ The OpenAI-compatible HTTP client, model resolution, and failure handling — how LemonPie talks to local and hosted AI backends.
4
+
5
+ - [HTTP backend client](client.md) — `client.py`: unified client, streaming, backend config, supported servers.
6
+ - [Error handling](error-handling.md) — timeouts, error-to-message mapping, and what a failed request leaves in the session.
@@ -0,0 +1,84 @@
1
+ ---
2
+ id: 20261117-http-client
3
+ title: HTTP backend client
4
+ tags: [backend]
5
+ created: 2026-11-17
6
+ updated: 2026-11-29
7
+ related: [20261117-project-structure, 20261117-config-format, 20261129-error-handling]
8
+ summary: How lemonpie talks to AI backends — a unified OpenAI-compatible HTTP client (client.py) supporting Ollama, llama.cpp, LM Studio, vLLM, and hosted APIs.
9
+ ---
10
+
11
+ # HTTP backend client
12
+
13
+ > Summary: How lemonpie talks to AI backends — a unified OpenAI-compatible HTTP client (`client.py`) supporting Ollama, llama.cpp, LM Studio, vLLM, and hosted APIs.
14
+
15
+ ## Context
16
+
17
+ All backend communication is encapsulated in `src/lemonpie/client.py` using `httpx2` (no vendor SDK).
18
+ There is no built-in default server: the URL comes from the config (or `LEMONPIE_HOST`).
19
+
20
+ ## Supported backends
21
+
22
+ Any server exposing the OpenAI-compatible `/v1/chat/completions` endpoint works:
23
+
24
+ - **Ollama** — the setup wizard proposes `http://localhost:11434`
25
+ - **llama.cpp** server — wizard proposes port `9931`
26
+ - **LM Studio** — wizard proposes port `1234`
27
+ - **vLLM** and other OpenAI-compatible servers — enter the URL manually
28
+ - Hosted OpenAI-compatible APIs — requires `api_key` in config
29
+
30
+ The `backend` field in `config.json` is recorded by `lmConfig --init` for identification only;
31
+ it does not change HTTP behavior.
32
+
33
+ ## Configuration
34
+
35
+ | Config field | Used for |
36
+ |---|---|
37
+ | `server` | Base URL — the client appends `/v1/chat/completions`. `LEMONPIE_HOST` overrides it at runtime |
38
+ | `api_key` | Bearer token; `null` for unauthenticated local servers. `LEMONPIE_API_KEY` overrides it at runtime |
39
+ | `backend` | Backend name (identification only; set by `lmConfig --init`) |
40
+
41
+ ## Client and payload
42
+
43
+ - `build_client(server_host, timeout, api_key)` returns an `httpx2.Client` with `base_url` set to the
44
+ server. When a key is set it sends `Authorization: Bearer <api_key>` on every request.
45
+ `main.py` resolves the key with `config.resolve_api_key`, so `LEMONPIE_API_KEY` wins over the
46
+ config value.
47
+ - `build_payload(model, messages, stream=True, **extra_params)` produces
48
+ `{"model", "messages", "stream"}` where each message is reduced to `role` and `content`
49
+ (the local `ts` field is dropped). Extra keyword params are merged into the body.
50
+
51
+ ## Streaming
52
+
53
+ `stream_chat(client, payload)` POSTs to `/v1/chat/completions` and is a generator yielding text
54
+ chunks, so tokens are printed as they arrive rather than after the full completion:
55
+
56
+ - calls `raise_for_status()` before reading, so HTTP errors surface on the first iteration;
57
+ - reads server-sent-event lines starting with `data: `, stops at `data: [DONE]`;
58
+ - takes `choices[0].delta.content` from each chunk and yields it when non-empty;
59
+ - silently skips lines that are not valid JSON or lack the expected keys.
60
+
61
+ ## Model resolution
62
+
63
+ The model sent in a request follows a priority order:
64
+
65
+ 1. The explicit `-m` flag (always applied)
66
+ 2. The session's stored `model` field (when `-m` was not given)
67
+ 3. The config `default` (when there is no session model)
68
+
69
+ If none of these is available, `main.py` prints `No default model configured.` and exits 1.
70
+ The `No default model configured.` error fires before any session is created.
71
+
72
+ `models.resolve_model` runs before any request and does no network I/O. For `-m <x>` it tries an
73
+ alias match, then a full-name match, and otherwise passes `<x>` through unchanged; without `-m`
74
+ (or with an empty string) it returns `None`.
75
+
76
+ - When sending a prompt, `main.py` exits with an error if the resolved name is not in the
77
+ config's `models` list. The error mentions the session id so the user knows where the model
78
+ came from (see [Error handling](error-handling.md)).
79
+
80
+ ## Related
81
+
82
+ - [Project structure](../architecture/project-structure.md) — see-also: `main.py` orchestrates calls into this module.
83
+ - [Config file format](../config/config-format.md) — prerequisite: `server`, `api_key`, and `backend` come from config.
84
+ - [Error handling](error-handling.md) — see-also: timeouts and how request failures become user-facing messages.
@@ -0,0 +1,62 @@
1
+ ---
2
+ id: 20261129-error-handling
3
+ title: Error handling
4
+ tags: [backend, sessions]
5
+ created: 2026-11-29
6
+ updated: 2026-11-29
7
+ related: [20261117-http-client, 20261117-session-storage, 20261129-init-wizard]
8
+ summary: Request timeouts, how connection failures are mapped to messages and hints, and what is saved when a request fails or is interrupted.
9
+ ---
10
+
11
+ # Error handling
12
+
13
+ > Summary: Request timeouts, how connection failures are mapped to messages and hints, and what is saved when a request fails or is interrupted.
14
+
15
+ ## Context
16
+
17
+ Failures while talking to the server are turned into a short title plus an optional hint by
18
+ `client.resolve_error`, and `main.py` prints them and exits with code 1. Timeouts come from
19
+ `config.build_timeout`.
20
+
21
+ ## Timeouts
22
+
23
+ `build_timeout()` returns `httpx2.Timeout(connect=5.0, read=600.0, write=30.0, pool=5.0)`. The long
24
+ read timeout lets slow local models pause between tokens. The `lmConfig --init` probe builds its
25
+ client with `timeout=5.0` instead.
26
+
27
+ ## Message mapping (`resolve_error`)
28
+
29
+ Matching on `ConnectError` is done on the lower-cased exception message.
30
+
31
+ | Exception | Title | Hint |
32
+ |---|---|---|
33
+ | `ConnectTimeout` | Failed to contact server: Connection timed out. | Server unreachable; check network and IP/port |
34
+ | other `TimeoutException` | Server did not respond in time: Request timed out. | Server accepted the connection but answered too slowly |
35
+ | `ConnectError`, refused (`errno 111/61/10061`, "connection refused", "actively refused it") | Server did not respond: Connection refused. | Server may not be running or not listening on that host |
36
+ | `ConnectError`, DNS (`errno -2/-3/8/11001`, "name or service not known", "getaddrinfo failed", …) | Failed to contact server: Could not resolve hostname. | Check the server URL in the config |
37
+ | `ConnectError`, TLS (`certificate_verify_failed`, `ssl:`) | Failed to contact server: SSL/TLS verification failed. | Self-signed certificate or wrong system clock |
38
+ | other `ConnectError` | Failed to contact server: <message> | Check network and that the host is reachable |
39
+ | `ProtocolError` | Failed to contact server: Invalid protocol response (…) | Host may not be speaking HTTP/HTTPS |
40
+ | `InvalidURL` | Invalid server URL: '<host>'. | Include the scheme (`http://` or `https://`) |
41
+ | anything else, including `HTTPStatusError` from `raise_for_status()` (e.g. 401, 500) | Failed to contact server: <message> | none |
42
+
43
+ ## What happens to the session
44
+
45
+ In `main.py`, for a prompt:
46
+
47
+ 1. The user turn is appended and the session is saved **before** any check or request.
48
+ 2. If the resolved model is not in the configured `models`, or no server is configured, it prints
49
+ a message that includes the session id so the user knows where the model came from, and exits 1 (the user turn stays saved).
50
+ 3. A `StatusSpinner` ("Connecting", …) runs until the first chunk arrives.
51
+ 4. On success the assistant turn is appended and saved. An empty reply prints
52
+ "No response from model." and adds no assistant turn.
53
+ 5. On `Ctrl-C` the stream is closed, `Interrupted by user.` is printed, and it exits 1.
54
+ 6. On `httpx2.HTTPError` the mapped title and hint are printed and it exits 1.
55
+
56
+ In cases 5 and 6 any partial assistant text is discarded; only the user turn is on disk.
57
+
58
+ ## Related
59
+
60
+ - [HTTP backend client](client.md) — prerequisite: where the exceptions are raised.
61
+ - [Session storage](../sessions/session-storage.md) — see-also: the on-disk effect of a failed or interrupted turn.
62
+ - [lmConfig --init wizard](../cli/init-wizard.md) — see-also: the wizard's server probe reuses `resolve_error` for its messages.
@@ -0,0 +1,8 @@
1
+ # CI/CD
2
+
3
+ GitHub Actions pipelines — continuous integration, release to PyPI, and release-note automation.
4
+
5
+ - [CI workflow](ci-workflow.md) — build verification and pytest on every push/PR to main.
6
+ - [Release workflow](release-workflow.md) — release-please PR management and OIDC PyPI publish.
7
+ - [release-please configuration](release-please-config.md) — versioning, tag format, and PR settings in `.release-please/config.json`.
8
+ - [PR labeling and release notes](pr-labeling.md) — auto-labeling PRs and grouping release notes by label.
@@ -3,8 +3,8 @@ id: 20261117-ci-workflow
3
3
  title: CI workflow
4
4
  tags: [cicd]
5
5
  created: 2026-11-17
6
- updated: 2026-11-17
7
- related: [20261117-release-workflow]
6
+ updated: 2026-11-29
7
+ related: [20261117-release-workflow, 20261129-test-suite]
8
8
  summary: GitHub Actions CI pipeline — triggers, what it runs, and the tools it uses (uv, pytest).
9
9
  ---
10
10
 
@@ -14,7 +14,8 @@ summary: GitHub Actions CI pipeline — triggers, what it runs, and the tools it
14
14
 
15
15
  ## Context
16
16
 
17
- Defined in `.github/workflows/ci.yml`. Runs on every push and pull request to `main`.
17
+ Defined in `.github/workflows/ci.yml` (workflow name `Build & Test`, single job
18
+ `Build & Check Package` on `ubuntu-latest`). Runs on every push and pull request to `main`.
18
19
 
19
20
  ## Triggers
20
21
 
@@ -36,10 +37,11 @@ on:
36
37
 
37
38
  ## Pinned actions
38
39
 
39
- All actions are pinned to a commit SHA for supply-chain safety:
40
- - `actions/checkout` → `3d3c42e...`
41
- - `astral-sh/setup-uv` → `c771a70...`
40
+ Both actions used here are pinned to a commit SHA, with the version in a trailing comment:
41
+ - `actions/checkout` → `3d3c42e...` (v7.0.1)
42
+ - `astral-sh/setup-uv` → `c771a70...` (v9.0.0)
42
43
 
43
44
  ## Related
44
45
 
45
46
  - [Release workflow](release-workflow.md) — see-also: release also runs pytest + build before publishing.
47
+ - [Test suite](../testing/test-suite.md) — see-also: what `uv run pytest` executes.
@@ -0,0 +1,51 @@
1
+ ---
2
+ id: 20261129-pr-labeling
3
+ title: PR labeling and release notes
4
+ tags: [cicd]
5
+ created: 2026-11-29
6
+ updated: 2026-11-29
7
+ related: [20261117-release-workflow, 20261129-release-please-config]
8
+ summary: How PRs are auto-labeled from conventional-commit titles and how .github/release.yml groups release notes by label.
9
+ ---
10
+
11
+ # PR labeling and release notes
12
+
13
+ > Summary: How PRs are auto-labeled from conventional-commit titles and how `.github/release.yml` groups release notes by label.
14
+
15
+ ## Context
16
+
17
+ Two files cooperate: a workflow that labels pull requests from their titles, and a GitHub release-notes
18
+ config that groups changelog entries by those labels. PR titles should therefore follow
19
+ Conventional Commits (`feat:`, `fix:`, `docs:`, …).
20
+
21
+ ## Auto-label workflow
22
+
23
+ Defined in `.github/workflows/pr-auto-label.yml` (workflow name `Auto Label PRs`).
24
+
25
+ - Trigger: `pull_request_target` on `opened` and `edited`.
26
+ - Permissions: `pull-requests: write`.
27
+ - Single job `label` on `ubuntu-latest` using `bcoe/conventional-release-labels`, pinned to a commit SHA.
28
+ - Config: `ignored_types: ["chore", "ci", "style", "refactor", "test"]` — PRs of those types get no label.
29
+
30
+ ## Release-notes categories (`.github/release.yml`)
31
+
32
+ Used by GitHub's generated release notes (the source of notes since release-please runs with
33
+ `changelog-type: github`). Those notes only pre-fill the draft release, which is edited by hand
34
+ before publishing.
35
+
36
+ | Section | Labels |
37
+ |---|---|
38
+ | Breaking Changes | `breaking` |
39
+ | New Features | `feature` |
40
+ | Bug Fixes | `fix` |
41
+ | Documentation | `documentation` |
42
+ | Other Changes | `*` (everything else) |
43
+
44
+ Excluded from the notes: PRs labeled `duplicate`, `invalid`, `question`, `wontfix`,
45
+ `ignore-for-release`, `autorelease: pending`, or `autorelease: tagged`, and PRs authored by
46
+ `dependabot` or `github-actions`.
47
+
48
+ ## Related
49
+
50
+ - [Release workflow](release-workflow.md) — see-also: the pipeline that produces the release these notes belong to.
51
+ - [release-please configuration](release-please-config.md) — prerequisite: `changelog-type: github` makes these categories apply.
@@ -0,0 +1,54 @@
1
+ ---
2
+ id: 20261129-release-please-config
3
+ title: release-please configuration
4
+ tags: [cicd, packaging]
5
+ created: 2026-11-29
6
+ updated: 2026-11-29
7
+ related: [20261117-release-workflow, 20261129-pr-labeling]
8
+ summary: Settings in .release-please/config.json — prerelease versioning, tag format, draft releases, PR title, and changelog type.
9
+ ---
10
+
11
+ # release-please configuration
12
+
13
+ > Summary: Settings in `.release-please/config.json` — prerelease versioning, tag format, draft releases, PR title, and changelog type.
14
+
15
+ ## Context
16
+
17
+ `googleapis/release-please-action` (see [Release workflow](release-workflow.md)) reads two files in
18
+ `.release-please/`: `config.json` (settings) and `manifest.json` (maps `"."` to the last released
19
+ version). Don't hand-edit the manifest; to force a version, put a `Release-As: <version>` trailer in
20
+ a commit message.
21
+
22
+ ## Settings in `config.json`
23
+
24
+ Top level:
25
+
26
+ | Key | Value | Effect |
27
+ |---|---|---|
28
+ | `release-type` | `python` | Python project handling |
29
+ | `changelog-type` | `github` | Release notes are generated by GitHub's API, grouped by PR label (see [PR labeling](pr-labeling.md)); they pre-fill the draft release, which is then edited by hand |
30
+ | `pull-request-title-pattern` | `chore(release): lemonpie-cli v${version}` | Title of the release PR |
31
+ | `pull-request-header` | "Release Summary" text | Intro shown at the top of the release PR |
32
+
33
+ Package `"."`:
34
+
35
+ | Key | Value | Effect |
36
+ |---|---|---|
37
+ | `package-name` | `lemonpie-cli` | PyPI distribution name |
38
+ | `bump-minor-pre-major` | `true` | Breaking changes bump the minor version while pre-1.0 |
39
+ | `bump-patch-for-minor-pre-major` | `true` | Features bump the patch version while pre-1.0 |
40
+ | `prerelease` | `true` | Releases are marked as prereleases |
41
+ | `versioning` | `prerelease` | Uses release-please's prerelease versioning strategy (suffixes such as `-alpha.N`, `-beta.N`, `-rc.N`) |
42
+ | `include-component-in-tag` | `false` | Tags are plain `v{version}`; hatch-vcs derives the package version from `v*` tags, so don't change this |
43
+ | `draft` | `true` | The GitHub release is created as a draft, so its notes can be written by hand before it goes public |
44
+ | `force-tag-creation` | `true` | Creates the git tag immediately. GitHub otherwise creates a draft release's tag only when the draft is published, which would leave hatch-vcs and release-please without the tag |
45
+
46
+ The `draft` + `force-tag-creation` pair is what makes release notes manual: the tag exists and
47
+ the action still reports a created release (`releases_created`), so the PyPI publish job is
48
+ expected to run as before, but the GitHub release stays unpublished until its notes are edited and
49
+ it is published from the GitHub UI.
50
+
51
+ ## Related
52
+
53
+ - [Release workflow](release-workflow.md) — prerequisite: the workflow that runs release-please and publishes.
54
+ - [PR labeling and release notes](pr-labeling.md) — see-also: how the generated changelog is categorized.
@@ -0,0 +1,74 @@
1
+ ---
2
+ id: 20261117-release-workflow
3
+ title: Release workflow
4
+ tags: [cicd, packaging]
5
+ created: 2026-11-17
6
+ updated: 2026-11-29
7
+ related: [20261117-ci-workflow, 20261129-release-please-config, 20261129-pr-labeling]
8
+ summary: GitHub Actions release pipeline — release-please manages the PR and tag, then PyPI publish uses OIDC trusted publishing.
9
+ ---
10
+
11
+ # Release workflow
12
+
13
+ > Summary: GitHub Actions release pipeline — release-please manages the PR and tag, then PyPI publish uses OIDC trusted publishing.
14
+
15
+ ## Context
16
+
17
+ Defined in `.github/workflows/release.yml` (workflow name `Release & Publish`). Runs on every push
18
+ to `main`. Two jobs: `release-please` and `pypi-publish` (the second runs only when a release is
19
+ created).
20
+
21
+ ## Job 1: release-please
22
+
23
+ - Uses `googleapis/release-please-action@v4`.
24
+ - Reads config from `.release-please/config.json` and `.release-please/manifest.json`
25
+ (see [release-please configuration](release-please-config.md)).
26
+ - Creates or updates a release PR; merging that PR is what triggers a release.
27
+ - On merge it creates the `v{version}` tag immediately and a **draft** GitHub release pre-filled with
28
+ generated notes (`draft` and `force-tag-creation` in the config). The draft stays private until
29
+ it is published by hand.
30
+ - Requires a `RELEASE_PLEASE_TOKEN` secret (so its PRs trigger CI; `GITHUB_TOKEN` would not).
31
+ - Exposes the job outputs `release_created` (mapped from the action's `releases_created`) and
32
+ `tag_name`.
33
+
34
+ ## Job 2: pypi-publish
35
+
36
+ Runs only when `needs.release-please.outputs.release_created == 'true'`, in the `pypi` environment.
37
+
38
+ Steps:
39
+ 1. Checkout with full history (`fetch-depth: 0`) — required for hatch-vcs to read the tag.
40
+ 2. **Tag reachability check** — verifies `github.sha` is an ancestor of `origin/main` before
41
+ publishing. Refuses (exit 1) if not.
42
+ 3. Install uv (pinned same as CI).
43
+ 4. Run `uv run pytest` — tests must pass before publish.
44
+ 5. `uv build` — produce wheel and sdist.
45
+ 6. `pypa/gh-action-pypi-publish@release/v1` — uploads via **Trusted Publisher** (OIDC, no API key needed).
46
+
47
+ ## Publishing the draft release
48
+
49
+ Nothing in the workflows publishes the GitHub release. After the pipeline runs, open the draft in
50
+ the GitHub Releases page, replace the generated notes with hand-written ones, and publish it. No
51
+ workflow triggers on `release` events, so publishing the draft starts nothing and can happen
52
+ before or after the PyPI upload.
53
+
54
+ ## Permissions
55
+
56
+ ```yaml
57
+ permissions: # workflow level
58
+ contents: write # create releases
59
+ pull-requests: write # manage release PR
60
+ id-token: write # OIDC for PyPI trusted publishing
61
+ ```
62
+
63
+ `pypi-publish` additionally declares its own `id-token: write` for the OIDC exchange.
64
+
65
+ ## Action pinning
66
+
67
+ `actions/checkout` and `astral-sh/setup-uv` are pinned to commit SHAs. `googleapis/release-please-action`
68
+ (`@v4`) and `pypa/gh-action-pypi-publish` (`@release/v1`) are referenced by tag/branch, not SHA.
69
+
70
+ ## Related
71
+
72
+ - [CI workflow](ci-workflow.md) — see-also: same test + build steps run in CI on every push.
73
+ - [release-please configuration](release-please-config.md) — prerequisite: versioning, tag format, and PR settings.
74
+ - [PR labeling and release notes](pr-labeling.md) — see-also: labels that group the generated release notes.
@@ -3,3 +3,4 @@
3
3
  User-facing commands — the `lm`/`lemonpie` session manager and `lmConfig`.
4
4
 
5
5
  - [CLI commands](cli-commands.md) — full flag reference for both entry points with examples.
6
+ - [lmConfig --init wizard](init-wizard.md) — the interactive setup flow, step by step.
@@ -0,0 +1,131 @@
1
+ ---
2
+ id: 20261117-cli-commands
3
+ title: CLI commands
4
+ tags: [cli]
5
+ created: 2026-11-17
6
+ updated: 2026-11-29
7
+ related: [20261117-config-format, 20261117-session-storage, 20261129-init-wizard]
8
+ summary: Full flag reference for lm/lemonpie and lmConfig — every flag, its effect, and usage examples.
9
+ ---
10
+
11
+ # CLI commands
12
+
13
+ > Summary: Full flag reference for `lm`/`lemonpie` and `lmConfig` — every flag, its effect, and usage examples.
14
+
15
+ ## Context
16
+
17
+ Two entry points are exposed: `lm` / `lemonpie` for chat sessions, and `lmConfig` for
18
+ managing the config file. Both are defined in `pyproject.toml` under `[project.scripts]`.
19
+ The code (`cli/parser.py`, `cli/config_cmd.py`, `main.py`) is the source of truth; a user-facing
20
+ reference lives in `docs/usage/command-index.md`.
21
+
22
+ ---
23
+
24
+ ## lmConfig
25
+
26
+ Manages `config.json`. Only one action runs per invocation: if several action flags are given,
27
+ the first in this order wins — `--init`, `--host`, `--default-model`, `--add-model`,
28
+ `--remove-model`, `--api-key`, `--remove-api-key`, `--list-models`, `--show`. With none, it prints help.
29
+
30
+ | Flag | Description |
31
+ |---|---|
32
+ | `--init` | Interactive setup wizard (see [lmConfig --init wizard](init-wizard.md)) |
33
+ | `--init --force` | Same as `--init` but skip server verification |
34
+ | `--host <url>` | Set server host URL (`http(s)://host:port`); an invalid URL exits 2 |
35
+ | `--default-model <name>` | Set default model using alias or full name (must exist in models list); stores the full name |
36
+ | `--add-model <alias> <model>` | Add a model mapping: alias → full model name. The first model added to an empty list also becomes the default |
37
+ | `--remove-model <identifier>` | By alias: clear that alias (model stays, reachable by full name). By full name: delete the model entry, and clear `default` if it pointed there. Both ask `(y/N)` first |
38
+ | `--list-models` | List configured models as `alias -> name`, with `*` marking the default |
39
+ | `--api-key [<key>]` | Set or update the API key. Omit `<key>` to be prompted without echo (keeps it out of shell history). Empty input exits 2 |
40
+ | `--remove-api-key` | Remove the API key from the config |
41
+ | `--show` | Print `config.json` with the API key masked (`****` plus its last 4 characters, or just `****` for short keys) |
42
+ | `--force` | On `--add-model`: reassign an alias or model that is already mapped, clearing the old alias. With `--init`: skip server verification |
43
+
44
+ `--api-key` and `--remove-api-key` print a note when `LEMONPIE_API_KEY` is set, since it overrides
45
+ the config value at runtime.
46
+
47
+ Exit codes: `0` success, `1` user aborted at a confirmation, `2` invalid input or not found.
48
+
49
+ ### Examples
50
+
51
+ ```bash
52
+ lmConfig --init
53
+ lmConfig --add-model qwen qwen2.5-coder:3b
54
+ lmConfig --list-models
55
+ lmConfig --remove-model qwen
56
+ lmConfig --host http://192.168.1.10:11434
57
+ lmConfig --default-model qwen
58
+ lmConfig --api-key # prompts without echo
59
+ lmConfig --remove-api-key
60
+ lmConfig --show
61
+ ```
62
+
63
+ ---
64
+
65
+ ## lm / lemonpie
66
+
67
+ ```
68
+ lm [FLAGS] [PROMPT]
69
+ ```
70
+
71
+ | Flag | Description |
72
+ |---|---|
73
+ | `-v, --version` | Show version |
74
+ | `-m, --model <name>` | Model alias or full name for this invocation |
75
+ | `-n, --new` | Start a new chat session |
76
+ | `-s, --session <id>` | Load an existing session by ID and make it current |
77
+ | `-l, --list` | List all chat sessions |
78
+ | `-d, --delete <id>` | Delete a session by ID (asks first) |
79
+ | `-t, --title <text>` | Set or update the current session title (max 50 characters) |
80
+ | `-c, --close` | Close the current session (clears the pointer; the file stays) |
81
+ | `-p, --print` | Print current session history |
82
+ | `--delete-all` | Delete all stored sessions (asks first) |
83
+ | `--dry-run` | Show what would happen without sending requests or modifying data |
84
+ | `prompt` | Prompt text (positional, words joined with spaces) |
85
+
86
+ Running `lm` with no arguments prints help and exits 1.
87
+
88
+ ### Behavior notes
89
+
90
+ - `-l`, `-p`, `-d`, `-c`, `--delete-all` act before any model is resolved, so they work without a
91
+ configured model or a reachable server.
92
+ - `-p` with no active session prints `No active session.`
93
+ - Without `-n` or `-s`, a prompt continues the current session, creating one if none exists
94
+ (see [Session storage](../sessions/session-storage.md)).
95
+ - `-m` with no prompt, no current session, and no `-n`/`-s` prints guidance and exits 0 rather
96
+ than creating a session.
97
+ - `-m` on an existing session whose model differs asks `Change session <id> model to "<name>"? (Y/n)`
98
+ (implemented in `models.handle_model_switch`). An unknown alias/name prints a warning and exits 0.
99
+ - `-t` with no current session asks whether to create one; without a prompt it exits after updating.
100
+ - Flags can be combined: `lm -m smollm:360m -n "Hello world"`.
101
+ - Ctrl-C is handled gracefully in both entry points.
102
+ - If no model can be resolved (no `-m`, no session model, no config default), it prints
103
+ `No default model configured.` and exits 1. This check fires **before** any session is
104
+ created, so a bare `lm "hi"` with no default never leaves an orphan session. The
105
+ resolution order is: `-m` → session-stored model → config default.
106
+
107
+ ### --dry-run
108
+
109
+ - With `-d`, `--delete-all`, or `-c` it prints `Would delete session <id>.`, `Would delete all sessions.`,
110
+ or `Would close the current session.` and exits 0 without acting.
111
+ - Otherwise it resolves the model the same way as a real request and builds the
112
+ `/v1/chat/completions` body, prints `=== Dry Run: HTTP Payload ===` followed by the JSON,
113
+ and exits 0. It creates no session and writes nothing; `-t` and the
114
+ model-switch prompt are not applied.
115
+ - `-n` → empty history, no stored model (the payload uses the default model or `-m`).
116
+ - `-s <id>` → loads that session's history and stored model.
117
+ - Unknown `-m` → prints a warning and exits 0; no payload is printed.
118
+ - When the stored model is not in the config, it prints the same model-not-found
119
+ message (including the session id) and exits 1, unless `-n` or a valid `-m`
120
+ overrides it.
121
+ - With no history and no prompt it prints `No messages to send. Provide a prompt or load a session.`
122
+ and exits 0.
123
+ - Read-only `-l` and `-p` still run normally.
124
+
125
+ ---
126
+
127
+ ## Related
128
+
129
+ - [Config file format](../config/config-format.md) — prerequisite: `lmConfig` reads and writes this file.
130
+ - [Session storage](../sessions/session-storage.md) — see-also: `-l`, `-p`, `-d`, `-c`, `-s` all interact with stored sessions.
131
+ - [lmConfig --init wizard](init-wizard.md) — see-also: step-by-step behavior of `--init`.