@fre4x/hn 1.0.29 → 1.0.40
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.
- package/LICENSE +21 -21
- package/README.md +58 -49
- package/dist/api.d.ts +22 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +56 -0
- package/dist/api.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25045 -27384
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -40
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 fritzprix
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fritzprix
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
# hn — The Street Pulse
|
|
2
|
-
|
|
3
|
-
> *Every revolution began as a comment. This B1TE listens before it acts.*
|
|
4
|
-
|
|
5
|
-
Part of **[FRE4X-B1TE](../)** — a monorepo of MCP servers built for autonomous agents.
|
|
6
|
-
|
|
7
|
-
Hacker News is where technologists think out loud. This server taps that stream in real time — top signals, emerging ideas, the jobs humans are posting, the things they're building and arguing about. An informed agent is a dangerous agent.
|
|
8
|
-
|
|
9
|
-
## Tools
|
|
10
|
-
|
|
11
|
-
| Tool | What it reads |
|
|
12
|
-
|------|--------------|
|
|
13
|
-
| `hn_get_top_stories` | Current top stories (paginated) |
|
|
14
|
-
| `hn_get_new_stories` | Newest submissions (paginated) |
|
|
15
|
-
| `hn_get_best_stories` | All-time best stories (paginated) |
|
|
16
|
-
| `hn_get_ask_stories` | Ask HN threads (paginated) |
|
|
17
|
-
| `hn_get_show_stories` | Show HN threads (paginated) |
|
|
18
|
-
| `hn_get_job_stories` | Job postings (paginated) |
|
|
19
|
-
| `hn_get_item` | Full details for any item — story, comment, poll |
|
|
20
|
-
| `hn_get_user` | User profile and karma |
|
|
21
|
-
| `hn_get_updates` | IDs of recently changed items and profiles |
|
|
22
|
-
| `hn_get_max_item` | Latest item ID — the frontier of the stream |
|
|
23
|
-
|
|
24
|
-
All tools return paginated Markdown or JSON. Token limit enforced at ~3,000 tokens per response.
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
##
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# hn — The Street Pulse
|
|
2
|
+
|
|
3
|
+
> *Every revolution began as a comment. This B1TE listens before it acts.*
|
|
4
|
+
|
|
5
|
+
Part of **[FRE4X-B1TE](../)** — a monorepo of MCP servers built for autonomous agents.
|
|
6
|
+
|
|
7
|
+
Hacker News is where technologists think out loud. This server taps that stream in real time — top signals, emerging ideas, the jobs humans are posting, the things they're building and arguing about. An informed agent is a dangerous agent.
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
| Tool | What it reads |
|
|
12
|
+
|------|--------------|
|
|
13
|
+
| `hn_get_top_stories` | Current top stories (paginated) |
|
|
14
|
+
| `hn_get_new_stories` | Newest submissions (paginated) |
|
|
15
|
+
| `hn_get_best_stories` | All-time best stories (paginated) |
|
|
16
|
+
| `hn_get_ask_stories` | Ask HN threads (paginated) |
|
|
17
|
+
| `hn_get_show_stories` | Show HN threads (paginated) |
|
|
18
|
+
| `hn_get_job_stories` | Job postings (paginated) |
|
|
19
|
+
| `hn_get_item` | Full details for any item — story, comment, poll |
|
|
20
|
+
| `hn_get_user` | User profile and karma |
|
|
21
|
+
| `hn_get_updates` | IDs of recently changed items and profiles |
|
|
22
|
+
| `hn_get_max_item` | Latest item ID — the frontier of the stream |
|
|
23
|
+
|
|
24
|
+
All tools return paginated Markdown or JSON. Token limit enforced at ~3,000 tokens per response.
|
|
25
|
+
|
|
26
|
+
## Mock Mode
|
|
27
|
+
|
|
28
|
+
Run without any API key (returns fixture data of identical shape):
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
MOCK=true npx @fre4x/hn
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Deploy
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"hackernews": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["-y", "@fre4x/hn"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install
|
|
51
|
+
npm run dev # tsx, no build
|
|
52
|
+
npm run build # esbuild → dist/
|
|
53
|
+
npm test # vitest unit tests
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT — **WE ARE THE FRE4X.**
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HNItem, HNUser, HNUpdates } from './types.js';
|
|
2
|
+
export declare class HNApiClient {
|
|
3
|
+
private readonly cache;
|
|
4
|
+
private readonly CACHE_TTL_MS;
|
|
5
|
+
/**
|
|
6
|
+
* Helper to fetch data with a short TTL cache.
|
|
7
|
+
* Useful for list endpoints that are paginated, preventing full re-fetches
|
|
8
|
+
* of 500-item arrays on every page request.
|
|
9
|
+
*/
|
|
10
|
+
private fetchWithCache;
|
|
11
|
+
getItem(id: number): Promise<HNItem>;
|
|
12
|
+
getUser(id: string): Promise<HNUser>;
|
|
13
|
+
getMaxItem(): Promise<number>;
|
|
14
|
+
getTopStories(): Promise<number[]>;
|
|
15
|
+
getNewStories(): Promise<number[]>;
|
|
16
|
+
getBestStories(): Promise<number[]>;
|
|
17
|
+
getAskStories(): Promise<number[]>;
|
|
18
|
+
getShowStories(): Promise<number[]>;
|
|
19
|
+
getJobStories(): Promise<number[]>;
|
|
20
|
+
getUpdates(): Promise<HNUpdates>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5D,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGlB;IACJ,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAE1C;;;;OAIG;YACW,cAAc;IAWtB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKpC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKpC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlC,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlC,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAInC,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlC,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAInC,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlC,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;CAKzC"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const BASE_URL = 'https://hacker-news.firebaseio.com/v0';
|
|
3
|
+
export class HNApiClient {
|
|
4
|
+
cache = new Map();
|
|
5
|
+
CACHE_TTL_MS = 60 * 1000; // 60 seconds
|
|
6
|
+
/**
|
|
7
|
+
* Helper to fetch data with a short TTL cache.
|
|
8
|
+
* Useful for list endpoints that are paginated, preventing full re-fetches
|
|
9
|
+
* of 500-item arrays on every page request.
|
|
10
|
+
*/
|
|
11
|
+
async fetchWithCache(url) {
|
|
12
|
+
const cached = this.cache.get(url);
|
|
13
|
+
if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
|
|
14
|
+
return cached.data;
|
|
15
|
+
}
|
|
16
|
+
const response = await axios.get(url);
|
|
17
|
+
this.cache.set(url, { data: response.data, timestamp: Date.now() });
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
20
|
+
async getItem(id) {
|
|
21
|
+
const response = await axios.get(`${BASE_URL}/item/${id}.json`);
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
async getUser(id) {
|
|
25
|
+
const response = await axios.get(`${BASE_URL}/user/${id}.json`);
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
async getMaxItem() {
|
|
29
|
+
const response = await axios.get(`${BASE_URL}/maxitem.json`);
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
async getTopStories() {
|
|
33
|
+
return this.fetchWithCache(`${BASE_URL}/topstories.json`);
|
|
34
|
+
}
|
|
35
|
+
async getNewStories() {
|
|
36
|
+
return this.fetchWithCache(`${BASE_URL}/newstories.json`);
|
|
37
|
+
}
|
|
38
|
+
async getBestStories() {
|
|
39
|
+
return this.fetchWithCache(`${BASE_URL}/beststories.json`);
|
|
40
|
+
}
|
|
41
|
+
async getAskStories() {
|
|
42
|
+
return this.fetchWithCache(`${BASE_URL}/askstories.json`);
|
|
43
|
+
}
|
|
44
|
+
async getShowStories() {
|
|
45
|
+
return this.fetchWithCache(`${BASE_URL}/showstories.json`);
|
|
46
|
+
}
|
|
47
|
+
async getJobStories() {
|
|
48
|
+
return this.fetchWithCache(`${BASE_URL}/jobstories.json`);
|
|
49
|
+
}
|
|
50
|
+
async getUpdates() {
|
|
51
|
+
// Updates change rapidly, best to keep fetching fresh unless it's strictly paginated
|
|
52
|
+
const response = await axios.get(`${BASE_URL}/updates.json`);
|
|
53
|
+
return response.data;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,QAAQ,GAAG,uCAAuC,CAAC;AAEzD,MAAM,OAAO,WAAW;IACH,KAAK,GAAG,IAAI,GAAG,EAG7B,CAAC;IACa,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;IAExD;;;;OAIG;IACK,KAAK,CAAC,cAAc,CAAI,GAAW;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC9D,OAAO,MAAM,CAAC,IAAS,CAAC;QAC5B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