fmind 3.0.2__tar.gz → 3.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.
- fmind-3.0.4/PKG-INFO +130 -0
- fmind-3.0.4/README.md +102 -0
- {fmind-3.0.2 → fmind-3.0.4}/pyproject.toml +4 -5
- {fmind-3.0.2 → fmind-3.0.4}/pyproject.toml.orig +4 -5
- fmind-3.0.4/src/fmind/__init__.py +24 -0
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/api.py +185 -15
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/articles.py +3 -2
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/cli.py +88 -33
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/mcp.py +21 -15
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/news.py +5 -3
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/render.py +32 -23
- fmind-3.0.2/PKG-INFO +0 -186
- fmind-3.0.2/README.md +0 -158
- fmind-3.0.2/src/fmind/__init__.py +0 -11
- {fmind-3.0.2 → fmind-3.0.4}/LICENSE +0 -0
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/__main__.py +0 -0
- {fmind-3.0.2 → fmind-3.0.4}/src/fmind/py.typed +0 -0
fmind-3.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fmind
|
|
3
|
+
Version: 3.0.4
|
|
4
|
+
Summary: Read Médéric Hurier's (Fmind) portfolio and daily news from the terminal.
|
|
5
|
+
Keywords: portfolio,cli,fmind,resume,articles,news,mcp
|
|
6
|
+
Author: Médéric Hurier
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
14
|
+
Classifier: Topic :: Utilities
|
|
15
|
+
Requires-Dist: typer>=0.26
|
|
16
|
+
Requires-Dist: rich>=13.9
|
|
17
|
+
Requires-Dist: httpx2>=2.12,<3 ; extra == 'mcp'
|
|
18
|
+
Requires-Dist: mcp>=2.2,<3 ; extra == 'mcp'
|
|
19
|
+
Requires-Dist: mcp-types>=2.2,<3 ; extra == 'mcp'
|
|
20
|
+
Requires-Python: >=3.14
|
|
21
|
+
Project-URL: Homepage, https://www.fmind.dev/
|
|
22
|
+
Project-URL: Repository, https://github.com/fmind/cli
|
|
23
|
+
Project-URL: Changelog, https://github.com/fmind/cli/blob/main/CHANGELOG.md
|
|
24
|
+
Project-URL: Issues, https://github.com/fmind/cli/issues
|
|
25
|
+
Project-URL: Security, https://github.com/fmind/cli/security/policy
|
|
26
|
+
Provides-Extra: mcp
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# fmind
|
|
30
|
+
|
|
31
|
+
Read [Médéric Hurier's (Fmind)](https://www.fmind.dev/) portfolio and daily tech news from the terminal, or bridge its `/mcp` server over stdio.
|
|
32
|
+
|
|
33
|
+
[](https://github.com/fmind/cli/actions/workflows/ci.yml) [](https://pypi.org/project/fmind/) [](https://pypi.org/project/fmind/) [](https://github.com/fmind/cli/blob/main/LICENSE)
|
|
34
|
+
|
|
35
|
+
<a href="https://raw.githubusercontent.com/fmind/cli/main/docs/assets/overview.svg">
|
|
36
|
+
<img
|
|
37
|
+
src="https://raw.githubusercontent.com/fmind/cli/main/docs/assets/overview.svg"
|
|
38
|
+
alt="fmind overview: live endpoints on www.fmind.dev flow through the stateless fmind CLI to Rich terminal cards, JSON pipelines, and MCP over stdio."
|
|
39
|
+
width="960"
|
|
40
|
+
>
|
|
41
|
+
</a>
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
Requires Python 3.14+ and HTTPS access to `www.fmind.dev`. Run with [uv](https://docs.astral.sh/uv/) (which provisions Python 3.14+ automatically) or install persistently:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uvx fmind # run once (shows whoami)
|
|
49
|
+
uv tool install fmind # install portfolio and news commands
|
|
50
|
+
uv tool install 'fmind[mcp]' # include the stdio MCP bridge
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
Running `fmind` with no subcommand shows `whoami`. Commands mirror the website's `/api/profile` and `/api/news` sections:
|
|
56
|
+
|
|
57
|
+
| Command | Shows |
|
|
58
|
+
| ----------------------------------------------------- | --------------------------------------------------------- |
|
|
59
|
+
| `fmind whoami` | Name, headline, location, experience, availability, links |
|
|
60
|
+
| `fmind about` | Biography |
|
|
61
|
+
| `fmind skills` | Core expertise |
|
|
62
|
+
| `fmind experiences` | Engagements in website order |
|
|
63
|
+
| `fmind certifications` | Certifications, PhD, and specializations |
|
|
64
|
+
| `fmind community` | Ambassador and advisory roles |
|
|
65
|
+
| `fmind papers` | Doctorate and peer-reviewed papers, with code links |
|
|
66
|
+
| `fmind projects [--limit <n>]` | Open-source projects and video series, with code links |
|
|
67
|
+
| `fmind sites` | Interactive tools published alongside the writing |
|
|
68
|
+
| `fmind articles [--limit <n>]` | Recent articles |
|
|
69
|
+
| `fmind search [query...] [--tag <tag>] [--limit <n>]` | Articles matching all terms, newest first |
|
|
70
|
+
| `fmind read <slug> [--raw]` | Article rendered in the terminal (or raw Markdown) |
|
|
71
|
+
| `fmind tags` | Article tags with counts and `search --tag` hints |
|
|
72
|
+
| `fmind news [query...] [--limit <n>]` | Daily curated links, newest edition first |
|
|
73
|
+
| `fmind hire` | Services available to book |
|
|
74
|
+
| `fmind mcp` | Stdio MCP bridge to `www.fmind.dev/mcp` (`fmind[mcp]`) |
|
|
75
|
+
|
|
76
|
+
- `--limit` (`1`–`200`) bounds `articles` (`6`), `search` (`10`), `news` editions (`1`, or `10` with terms), and each `projects` list (`6`).
|
|
77
|
+
- `--json` works on bare `fmind` and before or after every command except `mcp`; it overrides `read --raw`.
|
|
78
|
+
- Global `--color` / `--no-color` (respects `NO_COLOR`) and `--version` go before the command; `-h` / `--help` works everywhere.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
`search` and `news` AND-match terms case-insensitively (`search --tag` validates against `fmind tags`; `news` also matches dates like `2026-11-06`). `read` accepts an exact or unique partial slug and pages via `$PAGER` (set `PAGER=cat` to disable).
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
fmind search agent security --tag MLOps --limit 3
|
|
86
|
+
fmind read "$(fmind articles --limit 1 --json | jq -r '.[0].slug')" --raw | glow -
|
|
87
|
+
fmind news --limit 7
|
|
88
|
+
fmind news agent security
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Piping
|
|
92
|
+
|
|
93
|
+
`--json` writes raw JSON to stdout and errors to stderr:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
fmind articles --limit 20 --json | jq -r '.[] | "\(.date[:10]) \(.title)"'
|
|
97
|
+
fmind news --limit 7 --json | jq -r '.[].items[] | "\(.domain) \(.title)"'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Grouped JSON keys: `whoami` (`metadata`, `experience`, `services`), `certifications` (`certifications`, `thesis`, `specializations`), `papers` (`thesis`, `papers`), `projects` (`open_source`, `youtube_series`), `news` (editions with matching `items`), and `read` (article metadata plus `slug` and `markdown`).
|
|
101
|
+
|
|
102
|
+
## MCP over stdio
|
|
103
|
+
|
|
104
|
+
Portfolio commands depend only on Typer and Rich. The optional `mcp` extra adds the [official MCP Python SDK](https://py.sdk.modelcontextprotocol.io/) to bridge `https://www.fmind.dev/mcp` over protocol-only stdio:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"mcpServers": {
|
|
109
|
+
"fmind": {
|
|
110
|
+
"command": "uvx",
|
|
111
|
+
"args": ["--from", "fmind[mcp]", "fmind", "mcp"]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Forwards read-only tools, resources, and prompts with no local cache (`--json` rejected) and a 15s / 8 MiB limit per call.
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
mise install && mise run install # toolchain, locked venv, and git hooks
|
|
123
|
+
mise run all # check, test, and build (CI gate)
|
|
124
|
+
mise run format # format Python, JSON, Markdown, TOML, YAML
|
|
125
|
+
mise run smoke # live API, article, and MCP check
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Set `FMIND_PROFILE_URL` to target another origin for all endpoints (e.g., `FMIND_PROFILE_URL=http://127.0.0.1:8080/api/profile fmind whoami`). See [AGENTS.md](https://github.com/fmind/cli/blob/main/AGENTS.md) for invariants and release details.
|
|
129
|
+
|
|
130
|
+
[Changelog](https://github.com/fmind/cli/blob/main/CHANGELOG.md) · [Issues](https://github.com/fmind/cli/issues) · [Security](https://github.com/fmind/cli/security/policy) · [MIT License](https://github.com/fmind/cli/blob/main/LICENSE)
|
fmind-3.0.4/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# fmind
|
|
2
|
+
|
|
3
|
+
Read [Médéric Hurier's (Fmind)](https://www.fmind.dev/) portfolio and daily tech news from the terminal, or bridge its `/mcp` server over stdio.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/fmind/cli/actions/workflows/ci.yml) [](https://pypi.org/project/fmind/) [](https://pypi.org/project/fmind/) [](https://github.com/fmind/cli/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
<a href="https://raw.githubusercontent.com/fmind/cli/main/docs/assets/overview.svg">
|
|
8
|
+
<img
|
|
9
|
+
src="https://raw.githubusercontent.com/fmind/cli/main/docs/assets/overview.svg"
|
|
10
|
+
alt="fmind overview: live endpoints on www.fmind.dev flow through the stateless fmind CLI to Rich terminal cards, JSON pipelines, and MCP over stdio."
|
|
11
|
+
width="960"
|
|
12
|
+
>
|
|
13
|
+
</a>
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
Requires Python 3.14+ and HTTPS access to `www.fmind.dev`. Run with [uv](https://docs.astral.sh/uv/) (which provisions Python 3.14+ automatically) or install persistently:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uvx fmind # run once (shows whoami)
|
|
21
|
+
uv tool install fmind # install portfolio and news commands
|
|
22
|
+
uv tool install 'fmind[mcp]' # include the stdio MCP bridge
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
|
|
27
|
+
Running `fmind` with no subcommand shows `whoami`. Commands mirror the website's `/api/profile` and `/api/news` sections:
|
|
28
|
+
|
|
29
|
+
| Command | Shows |
|
|
30
|
+
| ----------------------------------------------------- | --------------------------------------------------------- |
|
|
31
|
+
| `fmind whoami` | Name, headline, location, experience, availability, links |
|
|
32
|
+
| `fmind about` | Biography |
|
|
33
|
+
| `fmind skills` | Core expertise |
|
|
34
|
+
| `fmind experiences` | Engagements in website order |
|
|
35
|
+
| `fmind certifications` | Certifications, PhD, and specializations |
|
|
36
|
+
| `fmind community` | Ambassador and advisory roles |
|
|
37
|
+
| `fmind papers` | Doctorate and peer-reviewed papers, with code links |
|
|
38
|
+
| `fmind projects [--limit <n>]` | Open-source projects and video series, with code links |
|
|
39
|
+
| `fmind sites` | Interactive tools published alongside the writing |
|
|
40
|
+
| `fmind articles [--limit <n>]` | Recent articles |
|
|
41
|
+
| `fmind search [query...] [--tag <tag>] [--limit <n>]` | Articles matching all terms, newest first |
|
|
42
|
+
| `fmind read <slug> [--raw]` | Article rendered in the terminal (or raw Markdown) |
|
|
43
|
+
| `fmind tags` | Article tags with counts and `search --tag` hints |
|
|
44
|
+
| `fmind news [query...] [--limit <n>]` | Daily curated links, newest edition first |
|
|
45
|
+
| `fmind hire` | Services available to book |
|
|
46
|
+
| `fmind mcp` | Stdio MCP bridge to `www.fmind.dev/mcp` (`fmind[mcp]`) |
|
|
47
|
+
|
|
48
|
+
- `--limit` (`1`–`200`) bounds `articles` (`6`), `search` (`10`), `news` editions (`1`, or `10` with terms), and each `projects` list (`6`).
|
|
49
|
+
- `--json` works on bare `fmind` and before or after every command except `mcp`; it overrides `read --raw`.
|
|
50
|
+
- Global `--color` / `--no-color` (respects `NO_COLOR`) and `--version` go before the command; `-h` / `--help` works everywhere.
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
`search` and `news` AND-match terms case-insensitively (`search --tag` validates against `fmind tags`; `news` also matches dates like `2026-11-06`). `read` accepts an exact or unique partial slug and pages via `$PAGER` (set `PAGER=cat` to disable).
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
fmind search agent security --tag MLOps --limit 3
|
|
58
|
+
fmind read "$(fmind articles --limit 1 --json | jq -r '.[0].slug')" --raw | glow -
|
|
59
|
+
fmind news --limit 7
|
|
60
|
+
fmind news agent security
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Piping
|
|
64
|
+
|
|
65
|
+
`--json` writes raw JSON to stdout and errors to stderr:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
fmind articles --limit 20 --json | jq -r '.[] | "\(.date[:10]) \(.title)"'
|
|
69
|
+
fmind news --limit 7 --json | jq -r '.[].items[] | "\(.domain) \(.title)"'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Grouped JSON keys: `whoami` (`metadata`, `experience`, `services`), `certifications` (`certifications`, `thesis`, `specializations`), `papers` (`thesis`, `papers`), `projects` (`open_source`, `youtube_series`), `news` (editions with matching `items`), and `read` (article metadata plus `slug` and `markdown`).
|
|
73
|
+
|
|
74
|
+
## MCP over stdio
|
|
75
|
+
|
|
76
|
+
Portfolio commands depend only on Typer and Rich. The optional `mcp` extra adds the [official MCP Python SDK](https://py.sdk.modelcontextprotocol.io/) to bridge `https://www.fmind.dev/mcp` over protocol-only stdio:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"fmind": {
|
|
82
|
+
"command": "uvx",
|
|
83
|
+
"args": ["--from", "fmind[mcp]", "fmind", "mcp"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Forwards read-only tools, resources, and prompts with no local cache (`--json` rejected) and a 15s / 8 MiB limit per call.
|
|
90
|
+
|
|
91
|
+
## Development
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
mise install && mise run install # toolchain, locked venv, and git hooks
|
|
95
|
+
mise run all # check, test, and build (CI gate)
|
|
96
|
+
mise run format # format Python, JSON, Markdown, TOML, YAML
|
|
97
|
+
mise run smoke # live API, article, and MCP check
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Set `FMIND_PROFILE_URL` to target another origin for all endpoints (e.g., `FMIND_PROFILE_URL=http://127.0.0.1:8080/api/profile fmind whoami`). See [AGENTS.md](https://github.com/fmind/cli/blob/main/AGENTS.md) for invariants and release details.
|
|
101
|
+
|
|
102
|
+
[Changelog](https://github.com/fmind/cli/blob/main/CHANGELOG.md) · [Issues](https://github.com/fmind/cli/issues) · [Security](https://github.com/fmind/cli/security/policy) · [MIT License](https://github.com/fmind/cli/blob/main/LICENSE)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fmind"
|
|
3
|
-
version = "3.0.
|
|
3
|
+
version = "3.0.4"
|
|
4
4
|
description = "Read Médéric Hurier's (Fmind) portfolio and daily news from the terminal."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -65,10 +65,6 @@ dev = [
|
|
|
65
65
|
requires = ["uv_build>=0.13.9,<0.14"]
|
|
66
66
|
build-backend = "uv_build"
|
|
67
67
|
|
|
68
|
-
[tool.uv.build-backend]
|
|
69
|
-
module-name = "fmind"
|
|
70
|
-
module-root = "src"
|
|
71
|
-
|
|
72
68
|
[tool.ruff]
|
|
73
69
|
line-length = 120
|
|
74
70
|
extend-exclude = ["*.md"]
|
|
@@ -137,6 +133,8 @@ known_first_party = ["fmind"]
|
|
|
137
133
|
|
|
138
134
|
[tool.ty.rules]
|
|
139
135
|
blanket-ignore-comment = "error"
|
|
136
|
+
unused-ignore-comment = "error"
|
|
137
|
+
unused-type-ignore-comment = "error"
|
|
140
138
|
|
|
141
139
|
[tool.pytest]
|
|
142
140
|
testpaths = ["tests"]
|
|
@@ -151,6 +149,7 @@ timeout = "60"
|
|
|
151
149
|
|
|
152
150
|
[tool.coverage.run]
|
|
153
151
|
branch = true
|
|
152
|
+
patch = ["subprocess"]
|
|
154
153
|
source = ["fmind"]
|
|
155
154
|
|
|
156
155
|
[tool.coverage.report]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Docs: https://packaging.python.org/en/latest/specifications/pyproject-toml/
|
|
2
2
|
[project]
|
|
3
3
|
name = "fmind"
|
|
4
|
-
version = "3.0.
|
|
4
|
+
version = "3.0.4"
|
|
5
5
|
description = "Read Médéric Hurier's (Fmind) portfolio and daily news from the terminal."
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = "MIT"
|
|
@@ -53,10 +53,6 @@ dev = [
|
|
|
53
53
|
requires = ["uv_build>=0.13.9,<0.14"]
|
|
54
54
|
build-backend = "uv_build"
|
|
55
55
|
|
|
56
|
-
[tool.uv.build-backend]
|
|
57
|
-
module-name = "fmind"
|
|
58
|
-
module-root = "src"
|
|
59
|
-
|
|
60
56
|
[tool.ruff]
|
|
61
57
|
line-length = 120
|
|
62
58
|
extend-exclude = ["*.md"] # dprint owns Markdown, including its Python blocks
|
|
@@ -116,6 +112,8 @@ known_first_party = ["fmind"]
|
|
|
116
112
|
|
|
117
113
|
[tool.ty.rules]
|
|
118
114
|
blanket-ignore-comment = "error"
|
|
115
|
+
unused-ignore-comment = "error"
|
|
116
|
+
unused-type-ignore-comment = "error"
|
|
119
117
|
|
|
120
118
|
[tool.pytest]
|
|
121
119
|
testpaths = ["tests"]
|
|
@@ -127,6 +125,7 @@ timeout = "60"
|
|
|
127
125
|
|
|
128
126
|
[tool.coverage.run]
|
|
129
127
|
branch = true
|
|
128
|
+
patch = ["subprocess"]
|
|
130
129
|
source = ["fmind"]
|
|
131
130
|
|
|
132
131
|
[tool.coverage.report]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Read Médéric Hurier's (Fmind) portfolio and daily news from the terminal.
|
|
2
|
+
|
|
3
|
+
Every command renders live documents published by https://www.fmind.dev, so this
|
|
4
|
+
package carries no copy of its own and needs no release when the content changes.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
__all__ = ["__version__"]
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
__version__: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def __getattr__(name: str) -> str:
|
|
16
|
+
"""Resolve package version lazily so importing `fmind` skips `importlib.metadata`."""
|
|
17
|
+
if name == "__version__":
|
|
18
|
+
from importlib.metadata import version
|
|
19
|
+
|
|
20
|
+
value = version("fmind")
|
|
21
|
+
globals()["__version__"] = value
|
|
22
|
+
return value
|
|
23
|
+
msg = f"module {__name__!r} has no attribute {name!r}"
|
|
24
|
+
raise AttributeError(msg)
|
|
@@ -11,9 +11,7 @@ import time
|
|
|
11
11
|
import urllib.error
|
|
12
12
|
import urllib.parse
|
|
13
13
|
import urllib.request
|
|
14
|
-
from typing import IO, Any
|
|
15
|
-
|
|
16
|
-
from fmind import __version__
|
|
14
|
+
from typing import IO, Any, NotRequired, TypedDict, cast
|
|
17
15
|
|
|
18
16
|
PROFILE_URL = "https://www.fmind.dev/api/profile"
|
|
19
17
|
NEWS_PATH = "/api/news"
|
|
@@ -23,11 +21,175 @@ MAX_BYTES = 8 * 1024 * 1024
|
|
|
23
21
|
# `--json` re-indents forwarded fields, so output grows with the square of their
|
|
24
22
|
# nesting; the published profile nests four levels.
|
|
25
23
|
MAX_DEPTH = 32
|
|
26
|
-
USER_AGENT = f"fmind/{__version__} (+https://github.com/fmind/cli)"
|
|
27
24
|
# Slugs reach a URL, so only the shape the site actually mints is accepted.
|
|
28
25
|
SLUG_PATTERN = re.compile(r"[a-z0-9]+(?:-[a-z0-9]+)*\Z")
|
|
29
|
-
# Keep tabs, LF, and CRLF, but never let website text issue terminal commands
|
|
30
|
-
CONTROL_PATTERN = re.compile(
|
|
26
|
+
# Keep tabs, LF, and CRLF, but never let website text issue terminal commands, bare CR overwrites, or bidi spoofing.
|
|
27
|
+
CONTROL_PATTERN = re.compile(
|
|
28
|
+
r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]|\r(?!\n)"
|
|
29
|
+
)
|
|
30
|
+
_SENSITIVE_REDIRECT_HEADERS = frozenset({"authorization", "proxy-authorization", "cookie"})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Social(TypedDict):
|
|
34
|
+
name: str
|
|
35
|
+
url: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Metadata(TypedDict):
|
|
39
|
+
name: str
|
|
40
|
+
alternate_name: str
|
|
41
|
+
job_title: str
|
|
42
|
+
headline_primary: str
|
|
43
|
+
headline_secondary: str
|
|
44
|
+
work_location: str
|
|
45
|
+
email: str
|
|
46
|
+
site_url: str
|
|
47
|
+
socials: list[Social]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Expertise(TypedDict):
|
|
51
|
+
title: str
|
|
52
|
+
description: str
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Experience(TypedDict):
|
|
56
|
+
company: str
|
|
57
|
+
title: str
|
|
58
|
+
description: str
|
|
59
|
+
tags: list[str]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Leadership(TypedDict):
|
|
63
|
+
organization: str
|
|
64
|
+
role: str
|
|
65
|
+
description: str
|
|
66
|
+
url: str
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class Certification(TypedDict):
|
|
70
|
+
title: str
|
|
71
|
+
issuer: str
|
|
72
|
+
active: bool
|
|
73
|
+
url: str
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Specialization(TypedDict):
|
|
77
|
+
title: str
|
|
78
|
+
issuer_details: str
|
|
79
|
+
url: str
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class ThesisLink(TypedDict):
|
|
83
|
+
label: str
|
|
84
|
+
url: str
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Thesis(TypedDict):
|
|
88
|
+
title: str
|
|
89
|
+
institution_details: str
|
|
90
|
+
description: str
|
|
91
|
+
url: str
|
|
92
|
+
links: NotRequired[list[ThesisLink] | None]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Paper(TypedDict):
|
|
96
|
+
title: str
|
|
97
|
+
venue: str
|
|
98
|
+
url: str
|
|
99
|
+
code: str
|
|
100
|
+
code_label: str
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class OpenSourceProject(TypedDict):
|
|
104
|
+
title: str
|
|
105
|
+
description: str
|
|
106
|
+
href: str
|
|
107
|
+
repo: NotRequired[str | None]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class YoutubeSeries(TypedDict):
|
|
111
|
+
title: str
|
|
112
|
+
description: str
|
|
113
|
+
url: str
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class SitePage(TypedDict):
|
|
117
|
+
title: str
|
|
118
|
+
description: str
|
|
119
|
+
audience: str
|
|
120
|
+
url: str
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class Article(TypedDict):
|
|
124
|
+
title: str
|
|
125
|
+
description: str
|
|
126
|
+
slug: str
|
|
127
|
+
date: str
|
|
128
|
+
tags: list[str]
|
|
129
|
+
reading_minutes: int
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class Service(TypedDict):
|
|
133
|
+
title: str
|
|
134
|
+
description: str
|
|
135
|
+
badge: str
|
|
136
|
+
cta_url: str
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class Tag(TypedDict):
|
|
140
|
+
name: str
|
|
141
|
+
description: str
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class ProjectsPayload(TypedDict):
|
|
145
|
+
open_source: list[OpenSourceProject]
|
|
146
|
+
youtube_series: list[YoutubeSeries]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class Profile(TypedDict):
|
|
150
|
+
metadata: Metadata
|
|
151
|
+
biography: list[str]
|
|
152
|
+
expertise: list[Expertise]
|
|
153
|
+
experience: list[Experience]
|
|
154
|
+
leadership: list[Leadership]
|
|
155
|
+
certifications: list[Certification]
|
|
156
|
+
specializations: list[Specialization]
|
|
157
|
+
thesis: Thesis
|
|
158
|
+
papers: list[Paper]
|
|
159
|
+
open_source: list[OpenSourceProject]
|
|
160
|
+
youtube_series: list[YoutubeSeries]
|
|
161
|
+
site_pages: list[SitePage]
|
|
162
|
+
articles: list[Article]
|
|
163
|
+
services: list[Service]
|
|
164
|
+
tags: list[Tag]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class NewsItem(TypedDict):
|
|
168
|
+
title: str
|
|
169
|
+
url: str
|
|
170
|
+
domain: str
|
|
171
|
+
description: str
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class NewsEdition(TypedDict):
|
|
175
|
+
slug: str
|
|
176
|
+
date: str
|
|
177
|
+
title: str
|
|
178
|
+
url: str
|
|
179
|
+
items: list[NewsItem]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class NewsArchive(TypedDict):
|
|
183
|
+
url: str
|
|
184
|
+
editions: list[NewsEdition]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def user_agent() -> str:
|
|
188
|
+
"""Return the HTTP User-Agent string without importing package metadata at module import time."""
|
|
189
|
+
from fmind import __version__
|
|
190
|
+
|
|
191
|
+
return f"fmind/{__version__} (+https://github.com/fmind/cli)"
|
|
192
|
+
|
|
31
193
|
|
|
32
194
|
# Only fields consumed by this CLI are required; new website fields pass through.
|
|
33
195
|
PROFILE_SHAPE = {
|
|
@@ -189,21 +351,29 @@ class _RedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
|
189
351
|
if source.scheme == "https" and target.scheme != "https":
|
|
190
352
|
fp.close()
|
|
191
353
|
raise FmindError("the website redirected from HTTPS to plain HTTP")
|
|
192
|
-
|
|
354
|
+
redirected = super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
355
|
+
# Drop credentials on redirects so Proxy-Authorization/Authorization/Cookie
|
|
356
|
+
# never leak across origins or when a redirect bypasses an authenticated proxy.
|
|
357
|
+
for header_map in (getattr(redirected, "headers", {}), getattr(redirected, "unredirected_hdrs", {})):
|
|
358
|
+
for key in [k for k in header_map if k.lower() in _SENSITIVE_REDIRECT_HEADERS]:
|
|
359
|
+
del header_map[key]
|
|
360
|
+
return redirected
|
|
193
361
|
|
|
194
362
|
|
|
195
|
-
|
|
363
|
+
def _open(request: urllib.request.Request, *, timeout: float) -> Any:
|
|
364
|
+
"""Open a request with a fresh opener so proxy environment changes apply at call time."""
|
|
365
|
+
return urllib.request.build_opener(_RedirectHandler()).open(request, timeout=timeout)
|
|
196
366
|
|
|
197
367
|
|
|
198
368
|
def _fetch(url: str, accept: str, deadline: float) -> bytes:
|
|
199
369
|
"""Perform bounded I/O; never print or mutate caller state from the worker."""
|
|
200
370
|
# Ask intermediary HTTP caches to revalidate too; no local copy is kept.
|
|
201
|
-
headers = {"User-Agent":
|
|
371
|
+
headers = {"User-Agent": user_agent(), "Accept": accept, "Cache-Control": "no-cache"}
|
|
202
372
|
try:
|
|
203
373
|
if time.monotonic() >= deadline:
|
|
204
374
|
raise TimeoutError("website request deadline exceeded")
|
|
205
375
|
request = urllib.request.Request(url, headers=headers) # noqa: S310
|
|
206
|
-
with
|
|
376
|
+
with _open(request, timeout=TIMEOUT_SECONDS) as response:
|
|
207
377
|
length = response.headers.get("Content-Length")
|
|
208
378
|
expected = int(length) if length is not None else None
|
|
209
379
|
if expected is not None and expected < 0:
|
|
@@ -293,7 +463,7 @@ def _parse_json(payload: bytes, shape: object, name: str) -> dict[str, Any]:
|
|
|
293
463
|
return document
|
|
294
464
|
|
|
295
465
|
|
|
296
|
-
def _parse_profile(payload: bytes) ->
|
|
466
|
+
def _parse_profile(payload: bytes) -> Profile:
|
|
297
467
|
"""Decode the portfolio document behind every section command."""
|
|
298
468
|
document = _parse_json(payload, PROFILE_SHAPE, "profile")
|
|
299
469
|
links = document["thesis"].get("links")
|
|
@@ -303,7 +473,7 @@ def _parse_profile(payload: bytes) -> dict[str, Any]:
|
|
|
303
473
|
repo = project.get("repo")
|
|
304
474
|
if repo is not None:
|
|
305
475
|
_validate(repo, str, f"profile.open_source[{index}].repo")
|
|
306
|
-
return document
|
|
476
|
+
return cast(Profile, document)
|
|
307
477
|
|
|
308
478
|
|
|
309
479
|
def _parse_markdown(payload: bytes) -> str:
|
|
@@ -319,14 +489,14 @@ def _parse_markdown(payload: bytes) -> str:
|
|
|
319
489
|
return text
|
|
320
490
|
|
|
321
491
|
|
|
322
|
-
def load_profile() ->
|
|
492
|
+
def load_profile() -> Profile:
|
|
323
493
|
"""Return the portfolio document behind every section command."""
|
|
324
494
|
return _parse_profile(_download(_profile_url()))
|
|
325
495
|
|
|
326
496
|
|
|
327
|
-
def load_news() ->
|
|
497
|
+
def load_news() -> NewsArchive:
|
|
328
498
|
"""Return the daily news archive, on the same origin as the profile."""
|
|
329
|
-
return _parse_json(_download(origin_url(NEWS_PATH)), NEWS_SHAPE, "news")
|
|
499
|
+
return cast(NewsArchive, _parse_json(_download(origin_url(NEWS_PATH)), NEWS_SHAPE, "news"))
|
|
330
500
|
|
|
331
501
|
|
|
332
502
|
def load_article(slug: str) -> str:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"""Select articles from the profile document: newest, matching, or named."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Sequence
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from fmind.api import Article
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def latest(articles: Sequence[Article], *, limit: int) -> list[Article]:
|