deepharness 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.
Files changed (3) hide show
  1. package/README.md +59 -0
  2. package/bin/dh.js +76 -0
  3. package/package.json +37 -0
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # DeepHarness CLI
2
+
3
+ 本地优先的 AI 编码工作台,支持 Claude Code、OpenCode 等多种编码智能体。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g deepharness
9
+ ```
10
+
11
+ **依赖要求:**
12
+
13
+ - 已安装 DeepHarness Desktop 应用 或 `dh` 二进制在 PATH 中
14
+ - 若从源码编译:需要 Rust 工具链 (`cargo install --path apps/cli`)
15
+
16
+ ## 使用
17
+
18
+ ```bash
19
+ # 与 Claude Code 聊天
20
+ dh chat claude-code --interactive
21
+
22
+ # 与 OpenCode 聊天
23
+ dh chat opencode --interactive
24
+
25
+ # 启动网关
26
+ dh gwd start
27
+
28
+ # 查看网关状态
29
+ dh gwd status
30
+
31
+ # 停止网关
32
+ dh gwd stop
33
+
34
+ # 查看会话日志
35
+ dh gwd logs
36
+
37
+ # 查看会话详情
38
+ dh gwd session <session-id>
39
+
40
+ # 查看用量统计
41
+ dh gwd stats
42
+ ```
43
+
44
+ ## 开发
45
+
46
+ ```bash
47
+ # 从源码编译
48
+ cargo build --release -p deepharness-cli
49
+
50
+ # 本地链接测试
51
+ cd npm
52
+ npm link
53
+ ```
54
+
55
+ ## 安全说明
56
+
57
+ - 本 npm 包只提供轻量级 JS 包装器,不包含任何二进制或 API 密钥
58
+ - 所有 AI 调用和 API 密钥都由本地的 DeepHarness Desktop 或 Claude Code / OpenCode 自行管理
59
+ - 数据全部保存在本地,不会发送到第三方服务器
package/bin/dh.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ import { spawn, execSync } from 'child_process';
3
+ import { existsSync } from 'fs';
4
+ import { dirname, join, resolve } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { homedir } from 'os';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ function findProjectRoot() {
12
+ let current = __dirname;
13
+ while (true) {
14
+ if (existsSync(join(current, 'Cargo.toml')) && existsSync(join(current, 'package.json'))) {
15
+ return current;
16
+ }
17
+ const parent = dirname(current);
18
+ if (parent === current) {
19
+ return null;
20
+ }
21
+ current = parent;
22
+ }
23
+ }
24
+
25
+ function findDhBinary() {
26
+ const searchPaths = [];
27
+
28
+ try {
29
+ const projectRoot = findProjectRoot();
30
+ if (projectRoot) {
31
+ searchPaths.push(join(projectRoot, 'target', 'release', 'dh'));
32
+ searchPaths.push(join(projectRoot, 'target', 'debug', 'dh'));
33
+ }
34
+ } catch {}
35
+
36
+ searchPaths.push(
37
+ '/usr/local/bin/dh',
38
+ '/usr/bin/dh',
39
+ join(homedir(), '.local', 'bin', 'dh'),
40
+ join(homedir(), '.cargo', 'bin', 'dh'),
41
+ );
42
+
43
+ for (const p of searchPaths) {
44
+ if (existsSync(p)) return p;
45
+ }
46
+
47
+ try {
48
+ const which = execSync('which dh', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
49
+ if (which && existsSync(which)) return which;
50
+ } catch {}
51
+
52
+ return null;
53
+ }
54
+
55
+ let dhBin = findDhBinary();
56
+
57
+ if (!dhBin) {
58
+ console.error('Error: `dh` binary not found.');
59
+ console.error('');
60
+ console.error('Please install DeepHarness Desktop from: https://github.com/deepharness/deepharness-ent-desktop');
61
+ console.error('Or build from source: cargo install --path apps/cli');
62
+ process.exit(1);
63
+ }
64
+
65
+ const args = process.argv.slice(2);
66
+ const proc = spawn(dhBin, args, {
67
+ stdio: 'inherit',
68
+ cwd: process.cwd(),
69
+ env: { ...process.env, DH_NPM_WRAPPER: '1' },
70
+ });
71
+
72
+ proc.on('exit', (code) => process.exit(code));
73
+ proc.on('error', (err) => {
74
+ console.error('Failed to start dh:', err.message);
75
+ process.exit(1);
76
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "deepharness",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "DeepHarness CLI - Connect to AI coding agents with Claude Code, OpenCode, and more",
6
+ "bin": {
7
+ "dh": "bin/dh.js"
8
+ },
9
+ "scripts": {},
10
+ "keywords": [
11
+ "ai",
12
+ "coding",
13
+ "agent",
14
+ "claude",
15
+ "opencode",
16
+ "chat",
17
+ "cli",
18
+ "gateway",
19
+ "websocket"
20
+ ],
21
+ "author": "DeepHarness Team",
22
+ "license": "MIT",
23
+ "engines": {
24
+ "node": ">= 18"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/deepharness/deepharness-ent-desktop.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/deepharness/deepharness-ent-desktop/issues"
32
+ },
33
+ "homepage": "https://github.com/deepharness/deepharness-ent-desktop",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }