imap-agent-cli 0.1.0__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.
- imap_agent_cli-0.1.0/.github/workflows/publish.yml +34 -0
- imap_agent_cli-0.1.0/.gitignore +12 -0
- imap_agent_cli-0.1.0/LICENSE +21 -0
- imap_agent_cli-0.1.0/PKG-INFO +164 -0
- imap_agent_cli-0.1.0/README.md +131 -0
- imap_agent_cli-0.1.0/imap_agent_cli.py +30 -0
- imap_agent_cli-0.1.0/pyproject.toml +52 -0
- imap_agent_cli-0.1.0/spec.md +791 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/__init__.py +3 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/cli.py +406 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/config.py +310 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/errors.py +18 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/imap_client.py +303 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/mime.py +319 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/models.py +50 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/render.py +39 -0
- imap_agent_cli-0.1.0/src/imap_agent_cli/search.py +30 -0
- imap_agent_cli-0.1.0/tests/__init__.py +1 -0
- imap_agent_cli-0.1.0/tests/_bootstrap.py +10 -0
- imap_agent_cli-0.1.0/tests/pymap_server_runner.py +22 -0
- imap_agent_cli-0.1.0/tests/test_cli.py +52 -0
- imap_agent_cli-0.1.0/tests/test_config.py +87 -0
- imap_agent_cli-0.1.0/tests/test_mime.py +76 -0
- imap_agent_cli-0.1.0/tests/test_pymap_integration.py +129 -0
- imap_agent_cli-0.1.0/tests/test_search.py +34 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distributions
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: astral-sh/setup-uv@v5
|
|
15
|
+
- name: Build
|
|
16
|
+
run: uv build --no-sources
|
|
17
|
+
- uses: actions/upload-artifact@v4
|
|
18
|
+
with:
|
|
19
|
+
name: dist
|
|
20
|
+
path: dist/
|
|
21
|
+
|
|
22
|
+
publish:
|
|
23
|
+
name: Publish distributions to PyPI
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment: pypi
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/download-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paul
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: imap-agent-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agent-first IMAP CLI for safe email search, read, attachment download, and draft creation
|
|
5
|
+
Project-URL: Homepage, https://github.com/pseudosavant/imap-agent-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/pseudosavant/imap-agent-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/pseudosavant/imap-agent-cli/issues
|
|
8
|
+
Author: Paul
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,cli,drafts,email,imap
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Communications :: Email
|
|
22
|
+
Classifier: Topic :: Communications :: Email :: Post-Office :: IMAP
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
26
|
+
Requires-Dist: bleach>=6.2.0
|
|
27
|
+
Requires-Dist: imapclient>=3.0.0
|
|
28
|
+
Requires-Dist: markdownify>=0.14.0
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: pymap>=0.36.0; extra == 'test'
|
|
31
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# imap-agent-cli
|
|
35
|
+
|
|
36
|
+
`imap-agent-cli` is an agent-first IMAP CLI for safe email search, read, attachment download, and draft creation.
|
|
37
|
+
|
|
38
|
+
It can inspect mailboxes and append messages to Drafts. It cannot send email, delete messages, move messages, archive messages, change labels, alter flags, or mark messages read/unread.
|
|
39
|
+
|
|
40
|
+
## Status
|
|
41
|
+
|
|
42
|
+
This repo is under active development. The behavior target is defined in [`spec.md`](./spec.md).
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
Single-profile env-var setup:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
IMAP_AGENT_CLI_HOST=imap.example.com
|
|
50
|
+
IMAP_AGENT_CLI_PORT=993
|
|
51
|
+
IMAP_AGENT_CLI_USERNAME=me@example.com
|
|
52
|
+
IMAP_AGENT_CLI_PASSWORD=...
|
|
53
|
+
IMAP_AGENT_CLI_TLS=true
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Local development:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
uv run ./imap_agent_cli.py --help
|
|
60
|
+
uv run ./imap_agent_cli.py folders
|
|
61
|
+
uv run ./imap_agent_cli.py search --subject invoice
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Packaged execution:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
uvx imap-agent-cli --help
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
imap-agent-cli folders
|
|
74
|
+
imap-agent-cli search --folder INBOX --subject "invoice" --max-results 10
|
|
75
|
+
imap-agent-cli read --folder INBOX --uid 12345 --body-format html
|
|
76
|
+
imap-agent-cli attachments --folder INBOX --uid 12345
|
|
77
|
+
imap-agent-cli attachments download --folder INBOX --uid 12345 --part-id 2 --output-dir C:\tmp\email-attachments
|
|
78
|
+
imap-agent-cli draft create --to person@example.com --subject "Hello" --body "Draft only."
|
|
79
|
+
imap-agent-cli draft reply --folder INBOX --uid 12345 --body "Thanks. I will review this."
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
All command payloads are JSON on stdout. Diagnostics and errors go to stderr.
|
|
83
|
+
|
|
84
|
+
## Config
|
|
85
|
+
|
|
86
|
+
Create a starter config:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
imap-agent-cli config init
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Add a named profile:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
imap-agent-cli config add-profile work --host imap.example.com --port 993 --username me@example.com --password-env IMAP_AGENT_CLI_WORK_PASSWORD
|
|
96
|
+
imap-agent-cli config set-default-profile work
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Config path:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
~/.imap-agent-cli/config.toml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Secrets should stay in environment variables, not the config file.
|
|
106
|
+
|
|
107
|
+
## Safety Boundary
|
|
108
|
+
|
|
109
|
+
Allowed:
|
|
110
|
+
|
|
111
|
+
- list folders
|
|
112
|
+
- search messages
|
|
113
|
+
- read messages with no-seen fetch behavior
|
|
114
|
+
- list/download attachments only when requested
|
|
115
|
+
- append new messages to Drafts
|
|
116
|
+
|
|
117
|
+
Not allowed:
|
|
118
|
+
|
|
119
|
+
- send
|
|
120
|
+
- delete
|
|
121
|
+
- move
|
|
122
|
+
- archive
|
|
123
|
+
- flag/star
|
|
124
|
+
- mark read/unread
|
|
125
|
+
- create/delete/rename folders
|
|
126
|
+
|
|
127
|
+
## Testing
|
|
128
|
+
|
|
129
|
+
No-network unit tests:
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
python -m unittest discover -v
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Package build:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
uv build --no-sources
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The spec targets `pymap` for future local IMAP integration tests on Windows without Docker.
|
|
142
|
+
|
|
143
|
+
Opt-in local IMAP integration test:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
$env:IMAP_AGENT_CLI_TEST_PYMAP = "1"
|
|
147
|
+
uv run --extra test python -m unittest tests.test_pymap_integration -v
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The integration test starts `pymap dict --demo-data` locally and logs in with `demouser` / `demopass`.
|
|
151
|
+
|
|
152
|
+
## Publishing
|
|
153
|
+
|
|
154
|
+
The GitHub Actions workflow is `.github/workflows/publish.yml`.
|
|
155
|
+
|
|
156
|
+
PyPI Trusted Publishing values:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
Project: imap-agent-cli
|
|
160
|
+
Owner: pseudosavant
|
|
161
|
+
Repository: imap-agent-cli
|
|
162
|
+
Workflow: publish.yml
|
|
163
|
+
Environment: pypi
|
|
164
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# imap-agent-cli
|
|
2
|
+
|
|
3
|
+
`imap-agent-cli` is an agent-first IMAP CLI for safe email search, read, attachment download, and draft creation.
|
|
4
|
+
|
|
5
|
+
It can inspect mailboxes and append messages to Drafts. It cannot send email, delete messages, move messages, archive messages, change labels, alter flags, or mark messages read/unread.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
This repo is under active development. The behavior target is defined in [`spec.md`](./spec.md).
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Single-profile env-var setup:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
IMAP_AGENT_CLI_HOST=imap.example.com
|
|
17
|
+
IMAP_AGENT_CLI_PORT=993
|
|
18
|
+
IMAP_AGENT_CLI_USERNAME=me@example.com
|
|
19
|
+
IMAP_AGENT_CLI_PASSWORD=...
|
|
20
|
+
IMAP_AGENT_CLI_TLS=true
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Local development:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
uv run ./imap_agent_cli.py --help
|
|
27
|
+
uv run ./imap_agent_cli.py folders
|
|
28
|
+
uv run ./imap_agent_cli.py search --subject invoice
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Packaged execution:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
uvx imap-agent-cli --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
imap-agent-cli folders
|
|
41
|
+
imap-agent-cli search --folder INBOX --subject "invoice" --max-results 10
|
|
42
|
+
imap-agent-cli read --folder INBOX --uid 12345 --body-format html
|
|
43
|
+
imap-agent-cli attachments --folder INBOX --uid 12345
|
|
44
|
+
imap-agent-cli attachments download --folder INBOX --uid 12345 --part-id 2 --output-dir C:\tmp\email-attachments
|
|
45
|
+
imap-agent-cli draft create --to person@example.com --subject "Hello" --body "Draft only."
|
|
46
|
+
imap-agent-cli draft reply --folder INBOX --uid 12345 --body "Thanks. I will review this."
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
All command payloads are JSON on stdout. Diagnostics and errors go to stderr.
|
|
50
|
+
|
|
51
|
+
## Config
|
|
52
|
+
|
|
53
|
+
Create a starter config:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
imap-agent-cli config init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Add a named profile:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
imap-agent-cli config add-profile work --host imap.example.com --port 993 --username me@example.com --password-env IMAP_AGENT_CLI_WORK_PASSWORD
|
|
63
|
+
imap-agent-cli config set-default-profile work
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Config path:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
~/.imap-agent-cli/config.toml
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Secrets should stay in environment variables, not the config file.
|
|
73
|
+
|
|
74
|
+
## Safety Boundary
|
|
75
|
+
|
|
76
|
+
Allowed:
|
|
77
|
+
|
|
78
|
+
- list folders
|
|
79
|
+
- search messages
|
|
80
|
+
- read messages with no-seen fetch behavior
|
|
81
|
+
- list/download attachments only when requested
|
|
82
|
+
- append new messages to Drafts
|
|
83
|
+
|
|
84
|
+
Not allowed:
|
|
85
|
+
|
|
86
|
+
- send
|
|
87
|
+
- delete
|
|
88
|
+
- move
|
|
89
|
+
- archive
|
|
90
|
+
- flag/star
|
|
91
|
+
- mark read/unread
|
|
92
|
+
- create/delete/rename folders
|
|
93
|
+
|
|
94
|
+
## Testing
|
|
95
|
+
|
|
96
|
+
No-network unit tests:
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
python -m unittest discover -v
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Package build:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
uv build --no-sources
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The spec targets `pymap` for future local IMAP integration tests on Windows without Docker.
|
|
109
|
+
|
|
110
|
+
Opt-in local IMAP integration test:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
$env:IMAP_AGENT_CLI_TEST_PYMAP = "1"
|
|
114
|
+
uv run --extra test python -m unittest tests.test_pymap_integration -v
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The integration test starts `pymap dict --demo-data` locally and logs in with `demouser` / `demopass`.
|
|
118
|
+
|
|
119
|
+
## Publishing
|
|
120
|
+
|
|
121
|
+
The GitHub Actions workflow is `.github/workflows/publish.yml`.
|
|
122
|
+
|
|
123
|
+
PyPI Trusted Publishing values:
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
Project: imap-agent-cli
|
|
127
|
+
Owner: pseudosavant
|
|
128
|
+
Repository: imap-agent-cli
|
|
129
|
+
Workflow: publish.yml
|
|
130
|
+
Environment: pypi
|
|
131
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# /// script
|
|
2
|
+
# requires-python = ">=3.11"
|
|
3
|
+
# dependencies = [
|
|
4
|
+
# "IMAPClient>=3.0.0",
|
|
5
|
+
# "beautifulsoup4>=4.12.0",
|
|
6
|
+
# "bleach>=6.2.0",
|
|
7
|
+
# "markdownify>=0.14.0",
|
|
8
|
+
# ]
|
|
9
|
+
# ///
|
|
10
|
+
"""Local development wrapper for imap-agent-cli."""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
ROOT = Path(__file__).resolve().parent
|
|
19
|
+
SRC = ROOT / "src"
|
|
20
|
+
if str(SRC) not in sys.path:
|
|
21
|
+
sys.path.insert(0, str(SRC))
|
|
22
|
+
shadow = sys.modules.get("imap_agent_cli")
|
|
23
|
+
if shadow is not None and not hasattr(shadow, "__path__"):
|
|
24
|
+
del sys.modules["imap_agent_cli"]
|
|
25
|
+
|
|
26
|
+
from imap_agent_cli.cli import main
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "imap-agent-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Agent-first IMAP CLI for safe email search, read, attachment download, and draft creation"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Paul" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["imap", "email", "cli", "agent", "drafts"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Communications :: Email",
|
|
27
|
+
"Topic :: Communications :: Email :: Post-Office :: IMAP",
|
|
28
|
+
"Topic :: Utilities",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"IMAPClient>=3.0.0",
|
|
32
|
+
"beautifulsoup4>=4.12.0",
|
|
33
|
+
"bleach>=6.2.0",
|
|
34
|
+
"markdownify>=0.14.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
test = [
|
|
39
|
+
"pymap>=0.36.0",
|
|
40
|
+
"pytest>=8.0.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/pseudosavant/imap-agent-cli"
|
|
45
|
+
Repository = "https://github.com/pseudosavant/imap-agent-cli"
|
|
46
|
+
Issues = "https://github.com/pseudosavant/imap-agent-cli/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
imap-agent-cli = "imap_agent_cli.cli:main"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["src/imap_agent_cli"]
|