@dawnswwwww/zhihu-cli 0.1.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.
Files changed (3) hide show
  1. package/README.md +102 -0
  2. package/bin/zhihu.js +24 -0
  3. package/package.json +26 -0
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # zhihu-cli
2
+
3
+ CLI for the [Zhihu Open Platform API](https://developer.zhihu.com).
4
+
5
+ Supports authentication, Zhihu search, global web search, and the Zhida chat completion API.
6
+
7
+ ## Installation
8
+
9
+ ### From npm (recommended for Agent environments)
10
+
11
+ ```bash
12
+ npm install -g @dawnswwwww/zhihu-cli
13
+ zhihu --help
14
+ ```
15
+
16
+ ### From Homebrew
17
+
18
+ ```bash
19
+ brew tap dawnswwwww/tap
20
+ brew install zhihu-cli
21
+ ```
22
+
23
+ ### From crates.io
24
+
25
+ ```bash
26
+ cargo install zhihu-cli
27
+ ```
28
+
29
+ ### From GitHub Releases
30
+
31
+ Download the prebuilt archive for your platform from the [Releases](https://github.com/dawnswwwww/zhihu-cli/releases) page, extract it, and place the `zhihu` binary in your `PATH`.
32
+
33
+ ## Quick start
34
+
35
+ ```bash
36
+ # Authenticate with your Access Secret
37
+ zhihu auth login
38
+
39
+ # Or set it directly
40
+ zhihu auth set-secret <YOUR_ACCESS_SECRET>
41
+
42
+ # Search Zhihu
43
+ zhihu search zhihu "Rust 入门" --count 5
44
+
45
+ # Search the whole web
46
+ zhihu search global "Rust 入门" --count 5
47
+
48
+ # Ask Zhida
49
+ zhihu ask "Rust 和 Go 怎么选?" --model thinking
50
+ ```
51
+
52
+ ## Commands
53
+
54
+ | Command | Description |
55
+ |---------|-------------|
56
+ | `zhihu auth login` | Interactive login (reads secret from stdin). |
57
+ | `zhihu auth set-secret <SECRET>` | Save Access Secret directly. |
58
+ | `zhihu auth status` | Show authentication status. |
59
+ | `zhihu search zhihu <QUERY>` | Search within Zhihu. |
60
+ | `zhihu search global <QUERY>` | Search the whole web. |
61
+ | `zhihu ask <QUERY>` | Ask Zhida. Use `--model fast/thinking/agent` and `--stream`. |
62
+
63
+ Run `zhihu --help` or `zhihu <command> --help` for details.
64
+
65
+ ## Configuration
66
+
67
+ The CLI stores configuration (including the Access Secret) under the user's config directory, typically:
68
+
69
+ - macOS/Linux: `~/.config/zhihu-cli/config.toml`
70
+ - Windows: `%APPDATA%\zhihu-cli\config.toml`
71
+
72
+ You can also override the secret at runtime with the `ZHIHU_ACCESS_SECRET` environment variable.
73
+
74
+ ## Development
75
+
76
+ ```bash
77
+ # Run tests
78
+ make test
79
+
80
+ # Lint
81
+ make lint
82
+
83
+ # Full local CI check
84
+ make check
85
+ ```
86
+
87
+ See [docs/development.md](docs/development.md) for the full workflow.
88
+
89
+ ## Release
90
+
91
+ Pushing a SemVer tag triggers the release workflow:
92
+
93
+ ```bash
94
+ git tag -a v0.1.1 -m "Release 0.1.1"
95
+ git push origin v0.1.1
96
+ ```
97
+
98
+ This builds cross-platform binaries, creates a GitHub Release, publishes `zhihu-cli` to npm, and updates the Homebrew tap.
99
+
100
+ ## License
101
+
102
+ [MIT](LICENSE)
package/bin/zhihu.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require('child_process');
3
+
4
+ const platform = process.platform;
5
+ const arch = process.arch;
6
+ const packageName = `@dawnswwwww/zhihu-cli-${platform}-${arch}`;
7
+
8
+ let binaryPath;
9
+ try {
10
+ binaryPath = require.resolve(`${packageName}/bin/zhihu${platform === 'win32' ? '.exe' : ''}`);
11
+ } catch (e) {
12
+ console.error(`zhihu-cli: unsupported platform ${platform}-${arch}`);
13
+ console.error('Supported platforms: darwin-x64, darwin-arm64, linux-x64, linux-arm64, win32-x64');
14
+ process.exit(1);
15
+ }
16
+
17
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
18
+ child.on('exit', (code, signal) => {
19
+ if (signal) {
20
+ process.kill(process.pid, signal);
21
+ } else {
22
+ process.exit(code ?? 0);
23
+ }
24
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@dawnswwwww/zhihu-cli",
3
+ "version": "0.1.1",
4
+ "description": "CLI for the Zhihu Open Platform API",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/dawnswwwww/zhihu-cli.git"
9
+ },
10
+ "bin": {
11
+ "zhihu": "bin/zhihu.js"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "README.md"
16
+ ],
17
+ "optionalDependencies": {
18
+ "@dawnswwwww/zhihu-cli-darwin-x64": "0.1.1",
19
+ "@dawnswwwww/zhihu-cli-darwin-arm64": "0.1.1",
20
+ "@dawnswwwww/zhihu-cli-linux-x64": "0.1.1",
21
+ "@dawnswwwww/zhihu-cli-linux-arm64": "0.1.1",
22
+ "@dawnswwwww/zhihu-cli-win32-x64": "0.1.1"
23
+ },
24
+ "os": ["darwin", "linux", "win32"],
25
+ "cpu": ["x64", "arm64"]
26
+ }