chatshelf 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
  **One place for your AI coding chats.**
6
6
  Browse, search and bookmark your history from Claude Code, Codex, Cursor and GitHub Copilot, and get Claude Code sessions back after you rename a project folder.
7
7
 
8
+ [![npm](https://img.shields.io/npm/v/chatshelf?color=E8590C)](https://www.npmjs.com/package/chatshelf)
9
+ [![npm downloads](https://img.shields.io/npm/dm/chatshelf?color=1C1917)](https://www.npmjs.com/package/chatshelf)
8
10
  [![GitHub stars](https://img.shields.io/github/stars/heyKhoaiz/chatshelf?style=flat&color=E8590C)](https://github.com/heyKhoaiz/chatshelf/stargazers)
9
11
  [![CI](https://github.com/heyKhoaiz/chatshelf/actions/workflows/ci.yml/badge.svg)](https://github.com/heyKhoaiz/chatshelf/actions/workflows/ci.yml)
10
12
  [![License: MIT](https://img.shields.io/badge/license-MIT-1C1917)](LICENSE)
@@ -46,7 +48,7 @@ Chatshelf reads all of it locally and puts it on one shelf.
46
48
  You need **Node.js 22.5 or newer**.
47
49
 
48
50
  ```bash
49
- npx chatshelf # opens http://127.0.0.1:4317
51
+ npx chatshelf # opens http://chatshelf.localhost:4317
50
52
  ```
51
53
 
52
54
  Or install it once and run `chatshelf` any time:
@@ -56,6 +58,23 @@ npm install -g chatshelf
56
58
  chatshelf
57
59
  ```
58
60
 
61
+ ### Open it
62
+
63
+ - Run `chatshelf` (or `npx chatshelf`). It opens **http://chatshelf.localhost:4317** in your browser.
64
+ - Already running? Running `chatshelf` again just opens the browser to it.
65
+ - Bookmark the address to get back in one click while it's running.
66
+ - Press **Ctrl+C** in the terminal to stop it. Run `chatshelf --help` to see every option.
67
+ - Just installed and your shell says `command not found`? Open a new terminal tab, or run `rehash` (zsh) or `hash -r` (bash).
68
+
69
+ Update to the latest version:
70
+
71
+ ```bash
72
+ npx chatshelf@latest # npx: always run the newest version
73
+ npm update -g chatshelf # if you installed it with -g
74
+ ```
75
+
76
+ Releases and notes: [GitHub releases](https://github.com/heyKhoaiz/chatshelf/releases) · [npm](https://www.npmjs.com/package/chatshelf).
77
+
59
78
  From source (no dependencies, no build step):
60
79
 
61
80
  ```bash
@@ -64,11 +83,15 @@ cd chatshelf
64
83
  npm start
65
84
  ```
66
85
 
86
+ The address works in Chrome, Edge, Firefox and Brave with no setup. If your browser can't open it (Safari on macOS, for example), use http://127.0.0.1:4317. Both always work.
87
+
67
88
  To look around without your own history, run `npm run demo`. It uses fake chats in a temporary folder.
68
89
 
69
90
  Options:
70
91
 
71
92
  ```bash
93
+ chatshelf --help # all options
94
+ chatshelf --version # installed version
72
95
  chatshelf --no-open # don't open the browser
73
96
  PORT=5000 chatshelf # use another port
74
97
  CHATSHELF_TERMINAL=kitty chatshelf # pick the terminal for "Open in terminal"
@@ -112,7 +135,7 @@ A move:
112
135
 
113
136
  ## Privacy and safety
114
137
 
115
- - It listens on `127.0.0.1` only and rejects requests with an unexpected `Host` header, which blocks DNS rebinding.
138
+ - It listens on `127.0.0.1` only and accepts only the `127.0.0.1`, `localhost` and `chatshelf.localhost` host names, which blocks DNS rebinding.
116
139
  - Every API call needs a random token that changes each time the server starts.
117
140
  - It reads other tools' files but never changes them. The only writes outside its own folders are moving or restoring Claude Code sessions, and only when you click **Move** or **Restore**.
118
141
  - One network request: the **Star on GitHub** button fetches the public star count from `api.github.com`, cached for 6 hours. Nothing about you or your chats is sent.
package/bin/chatshelf.mjs CHANGED
@@ -1,10 +1,45 @@
1
1
  #!/usr/bin/env node
2
2
  // Starts Chatshelf. Re-runs Node with the SQLite "experimental" warning hidden.
3
3
  import { spawn } from 'node:child_process';
4
+ import fs from 'node:fs';
4
5
  import path from 'node:path';
5
6
  import { fileURLToPath } from 'node:url';
6
7
 
7
- const server = path.join(path.dirname(path.dirname(fileURLToPath(import.meta.url))), 'server.mjs');
8
- const child = spawn(process.execPath, ['--disable-warning=ExperimentalWarning', server, ...process.argv.slice(2)], { stdio: 'inherit' });
8
+ const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
9
+ const args = process.argv.slice(2);
10
+ const { version } = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
11
+ const port = process.env.PORT || '4317';
12
+
13
+ if (args.includes('--version') || args.includes('-v')) {
14
+ console.log(version);
15
+ process.exit(0);
16
+ }
17
+ if (args.includes('--help') || args.includes('-h')) {
18
+ console.log(`Chatshelf ${version}: one place for your AI coding chats
19
+
20
+ Usage
21
+ chatshelf start and open http://chatshelf.localhost:${port}
22
+ (if it's already running, this just opens the browser)
23
+ chatshelf --no-open start without opening the browser
24
+ chatshelf --version print the version
25
+ chatshelf --help show this help
26
+
27
+ Settings (environment variables)
28
+ PORT=5000 use another port
29
+ CHATSHELF_TERMINAL=kitty terminal for "Open in terminal"
30
+
31
+ Stop it with Ctrl+C. If the address doesn't open in your browser, use http://127.0.0.1:${port}.
32
+ Docs: https://github.com/heyKhoaiz/chatshelf`);
33
+ process.exit(0);
34
+ }
35
+
36
+ const major = Number(process.versions.node.split('.')[0]);
37
+ const minor = Number(process.versions.node.split('.')[1]);
38
+ if (major < 22 || (major === 22 && minor < 5)) {
39
+ console.error(`Chatshelf needs Node.js 22.5 or newer. You have ${process.versions.node}. Get it at https://nodejs.org`);
40
+ process.exit(1);
41
+ }
42
+
43
+ const child = spawn(process.execPath, ['--disable-warning=ExperimentalWarning', path.join(root, 'server.mjs'), ...args], { stdio: 'inherit' });
9
44
  child.on('exit', (code) => process.exit(code ?? 0));
10
45
  for (const sig of ['SIGINT', 'SIGTERM']) process.on(sig, () => child.kill(sig));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatshelf",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "One place for your AI coding chats: browse, search and bookmark Claude Code, Codex, Cursor and Copilot history, and fix Claude Code sessions after renaming a folder. Local, no dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Shaikh khoaiz Ahmmed",
@@ -40,6 +40,7 @@
40
40
  "demo": "node scripts/demo.mjs",
41
41
  "test": "node test/smoke.mjs",
42
42
  "check": "node --check server.mjs && node --check sources.mjs && node --check public/app.js",
43
- "prepublishOnly": "npm run check && npm test"
43
+ "prepublishOnly": "npm run check && npm test",
44
+ "release": "node scripts/release.mjs"
44
45
  }
45
46
  }
package/server.mjs CHANGED
@@ -682,7 +682,7 @@ const TYPES = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; ch
682
682
  const server = http.createServer(async (req, res) => {
683
683
  try {
684
684
  const host = req.headers.host;
685
- if (host !== `${HOST}:${PORT}` && host !== `localhost:${PORT}`) return send(res, 403, { error: 'Bad host.' });
685
+ if (!ALLOWED_HOSTS.has(host)) return send(res, 403, { error: 'Bad host.' });
686
686
  const url = new URL(req.url, `http://${host}`);
687
687
  if (url.pathname.startsWith('/api/')) {
688
688
  if (req.headers['x-token'] !== TOKEN) return send(res, 403, { error: 'Session expired. Reload the page.' });
@@ -699,7 +699,14 @@ const server = http.createServer(async (req, res) => {
699
699
  }
700
700
  });
701
701
 
702
- const appUrl = `http://${HOST}:${PORT}/`;
702
+ // Browsers send any *.localhost name to this computer, so chatshelf.localhost needs no setup and,
703
+ // like 127.0.0.1, can never point anywhere else (which keeps the DNS-rebinding protection).
704
+ // Safari on macOS may not resolve *.localhost, so macOS opens 127.0.0.1; both always work.
705
+ const NICE_HOST = 'chatshelf.localhost';
706
+ const ALLOWED_HOSTS = new Set([`${HOST}:${PORT}`, `localhost:${PORT}`, `${NICE_HOST}:${PORT}`]);
707
+ const niceUrl = `http://${NICE_HOST}:${PORT}/`;
708
+ const ipUrl = `http://${HOST}:${PORT}/`;
709
+ const appUrl = process.platform === 'darwin' ? ipUrl : niceUrl;
703
710
  const open = () => {
704
711
  if (process.argv.includes('--no-open')) return;
705
712
  const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'explorer' : 'xdg-open';
@@ -708,7 +715,7 @@ const open = () => {
708
715
 
709
716
  server.on('error', (e) => {
710
717
  if (e.code === 'EADDRINUSE') {
711
- console.log(`Already running at ${appUrl}`);
718
+ console.log(`Chatshelf is already running at ${appUrl}`);
712
719
  open();
713
720
  process.exit(0);
714
721
  }
@@ -716,7 +723,8 @@ server.on('error', (e) => {
716
723
  });
717
724
 
718
725
  server.listen(PORT, HOST, () => {
719
- console.log(`Chatshelf: ${appUrl} (Ctrl+C to stop)`);
726
+ console.log(`Chatshelf is running at ${appUrl}`);
727
+ console.log(` also at ${appUrl === niceUrl ? ipUrl : niceUrl} (Ctrl+C to stop)`);
720
728
  console.log(`Reading sessions from ${ROOT}`);
721
729
  const t = Date.now();
722
730
  scan().then((p) => console.log(`Indexed ${p.reduce((n, x) => n + x.sessions.length, 0)} sessions in ${Date.now() - t} ms`));