@danielwyq/netchat 0.0.1
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 +53 -0
- package/bin/netchat.mjs +109 -0
- package/dist/apps/daemon/index.mjs +50136 -0
- package/dist/apps/local-app/index.mjs +553 -0
- package/dist/apps/server/index.mjs +50781 -0
- package/dist/web/assets/index-DLasjbgI.css +1 -0
- package/dist/web/assets/index-DXUzki47.js +87 -0
- package/dist/web/favicon.svg +1 -0
- package/dist/web/icons.svg +24 -0
- package/dist/web/index.html +14 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @danielwyq/netchat
|
|
2
|
+
|
|
3
|
+
Local-first graph chat interface for Claude Code.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
Use the latest stable release:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @danielwyq/netchat@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run daemon-only mode:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @danielwyq/netchat@latest daemon --server http://127.0.0.1:3001 --pair ABC123
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Show local help:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @danielwyq/netchat@latest --help
|
|
23
|
+
npx @danielwyq/netchat@latest local --help
|
|
24
|
+
npx @danielwyq/netchat@latest daemon --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Why `@latest`
|
|
28
|
+
|
|
29
|
+
If you update frequently, always documenting and using `@latest` helps avoid stale cached resolutions:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx @danielwyq/netchat@latest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If users still suspect cache issues, they can run:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm cache clean --force
|
|
39
|
+
npx @danielwyq/netchat@latest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Environment variables
|
|
43
|
+
|
|
44
|
+
- `PORT`: local controller port (default `3001`)
|
|
45
|
+
- `DAEMON_PORT`: local daemon port (default `4318`)
|
|
46
|
+
- `NETCHAT_NO_BROWSER=true`: do not auto-open browser
|
|
47
|
+
- `NETCHAT_SKIP_WEB_BUILD=true`: skip rebuilding web assets during local runs
|
|
48
|
+
- `NETCHAT_APP_DB_PATH`: custom SQLite path
|
|
49
|
+
- `NETCHAT_MACHINE_STATE_PATH`: custom machine state path
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- Node.js `>=20`
|
package/bin/netchat.mjs
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const tsxCliPath = path.join(packageRoot, "node_modules", "tsx", "dist", "cli.mjs");
|
|
10
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
const launchCwd = process.cwd();
|
|
13
|
+
|
|
14
|
+
if (argv[0] === "--help" || argv[0] === "-h") {
|
|
15
|
+
printHelp();
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (argv[0] === "--version" || argv[0] === "-v") {
|
|
20
|
+
printVersion();
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const subcommand = argv[0];
|
|
25
|
+
const isDaemonCommand = subcommand === "daemon";
|
|
26
|
+
const isLocalCommand = subcommand === "local";
|
|
27
|
+
const forwardedArgs = isDaemonCommand || isLocalCommand ? argv.slice(1) : argv;
|
|
28
|
+
const sourceLocalEntry = path.join(packageRoot, "apps", "server", "src", "local-app.ts");
|
|
29
|
+
const sourceDaemonEntry = path.join(packageRoot, "apps", "daemon", "src", "index.ts");
|
|
30
|
+
const distLocalEntry = path.join(packageRoot, "dist", "apps", "local-app", "index.mjs");
|
|
31
|
+
const distDaemonEntry = path.join(packageRoot, "dist", "apps", "daemon", "index.mjs");
|
|
32
|
+
const sourceMode = existsSync(tsxCliPath) && existsSync(sourceLocalEntry) && existsSync(sourceDaemonEntry);
|
|
33
|
+
const entryFile = isDaemonCommand
|
|
34
|
+
? sourceMode
|
|
35
|
+
? sourceDaemonEntry
|
|
36
|
+
: distDaemonEntry
|
|
37
|
+
: sourceMode
|
|
38
|
+
? sourceLocalEntry
|
|
39
|
+
: distLocalEntry;
|
|
40
|
+
|
|
41
|
+
if (!existsSync(entryFile)) {
|
|
42
|
+
console.error(`@danielwyq/netchat could not find its runtime entry at ${entryFile}.`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const childArgs = sourceMode ? [tsxCliPath, entryFile, ...forwardedArgs] : [entryFile, ...forwardedArgs];
|
|
47
|
+
const child = spawn(process.execPath, childArgs, {
|
|
48
|
+
cwd: packageRoot,
|
|
49
|
+
env: {
|
|
50
|
+
...process.env,
|
|
51
|
+
NETCHAT_LAUNCH_CWD: process.env.NETCHAT_LAUNCH_CWD ?? launchCwd,
|
|
52
|
+
CLAUDE_PROJECT_CWD: process.env.CLAUDE_PROJECT_CWD ?? launchCwd,
|
|
53
|
+
},
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const forwardSignal = (signal) => {
|
|
58
|
+
if (!child.killed) {
|
|
59
|
+
child.kill(signal);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
process.on("SIGINT", forwardSignal);
|
|
64
|
+
process.on("SIGTERM", forwardSignal);
|
|
65
|
+
|
|
66
|
+
child.on("exit", (code, signal) => {
|
|
67
|
+
process.off("SIGINT", forwardSignal);
|
|
68
|
+
process.off("SIGTERM", forwardSignal);
|
|
69
|
+
|
|
70
|
+
if (signal) {
|
|
71
|
+
process.exit(1);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
process.exit(code ?? 0);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
child.on("error", (error) => {
|
|
79
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
function printHelp() {
|
|
84
|
+
console.log(
|
|
85
|
+
[
|
|
86
|
+
"netchat",
|
|
87
|
+
"",
|
|
88
|
+
"Run the local-first app with sensible defaults.",
|
|
89
|
+
"",
|
|
90
|
+
"Usage:",
|
|
91
|
+
" npx @danielwyq/netchat@latest Start the controller, daemon, and local web UI",
|
|
92
|
+
" npx @danielwyq/netchat@latest daemon [...] Start only the daemon",
|
|
93
|
+
" npx @danielwyq/netchat@latest local [...] Explicitly start the full local app",
|
|
94
|
+
"",
|
|
95
|
+
"Examples:",
|
|
96
|
+
" npx @danielwyq/netchat@latest",
|
|
97
|
+
" npx @danielwyq/netchat@latest --no-browser",
|
|
98
|
+
" npx @danielwyq/netchat@latest --show-session-ids",
|
|
99
|
+
" npx @danielwyq/netchat@latest daemon --server http://127.0.0.1:3001 --pair ABC123",
|
|
100
|
+
"",
|
|
101
|
+
"Run `npx @danielwyq/netchat@latest local --help` or `npx @danielwyq/netchat@latest daemon --help` for command-specific options.",
|
|
102
|
+
].join("\n"),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function printVersion() {
|
|
107
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
108
|
+
console.log(typeof packageJson.version === "string" ? packageJson.version : "0.0.0");
|
|
109
|
+
}
|