@zhigang1992/happy-cli 0.12.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 +60 -0
- package/bin/happy-mcp.mjs +32 -0
- package/bin/happy.mjs +35 -0
- package/dist/codex/happyMcpStdioBridge.cjs +80 -0
- package/dist/codex/happyMcpStdioBridge.d.cts +2 -0
- package/dist/codex/happyMcpStdioBridge.d.mts +2 -0
- package/dist/codex/happyMcpStdioBridge.mjs +78 -0
- package/dist/index-BOBrKhX5.cjs +6655 -0
- package/dist/index-DsHtmQqP.mjs +6624 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +39 -0
- package/dist/lib.cjs +31 -0
- package/dist/lib.d.cts +817 -0
- package/dist/lib.d.mts +817 -0
- package/dist/lib.mjs +21 -0
- package/dist/list-BW6QBLa1.cjs +328 -0
- package/dist/list-hET5tyMc.mjs +326 -0
- package/dist/prompt-DXkgjktW.cjs +203 -0
- package/dist/prompt-Dz7G8yGx.mjs +201 -0
- package/dist/runCodex-CLGYMNs2.mjs +1335 -0
- package/dist/runCodex-CylcX5Ug.cjs +1338 -0
- package/dist/types-BsjUgWOx.cjs +2264 -0
- package/dist/types-CGco5Y-r.mjs +2213 -0
- package/package.json +126 -0
- package/scripts/claude_local_launcher.cjs +98 -0
- package/scripts/claude_remote_launcher.cjs +13 -0
- package/scripts/ripgrep_launcher.cjs +33 -0
- package/scripts/unpack-tools.cjs +163 -0
- package/tools/archives/difftastic-LICENSE +21 -0
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-LICENSE +3 -0
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +21 -0
- package/tools/licenses/ripgrep-LICENSE +3 -0
- package/tools/unpacked/difft +0 -0
- package/tools/unpacked/rg +0 -0
- package/tools/unpacked/ripgrep.node +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Happy
|
|
2
|
+
|
|
3
|
+
Code on the go controlling claude code from your mobile device.
|
|
4
|
+
|
|
5
|
+
Free. Open source. Code anywhere.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g happy-coder
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
happy
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will:
|
|
20
|
+
1. Start a Claude Code session
|
|
21
|
+
2. Display a QR code to connect from your mobile device
|
|
22
|
+
3. Allow real-time session sharing between Claude Code and your mobile app
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
- `happy auth` – Manage authentication
|
|
27
|
+
- `happy codex` – Start Codex mode
|
|
28
|
+
- `happy connect` – Store AI vendor API keys in Happy cloud
|
|
29
|
+
- `happy notify` – Send a push notification to your devices
|
|
30
|
+
- `happy daemon` – Manage background service
|
|
31
|
+
- `happy doctor` – System diagnostics & troubleshooting
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
|
|
35
|
+
- `-h, --help` - Show help
|
|
36
|
+
- `-v, --version` - Show version
|
|
37
|
+
- `-m, --model <model>` - Claude model to use (default: sonnet)
|
|
38
|
+
- `-p, --permission-mode <mode>` - Permission mode: auto, default, or plan
|
|
39
|
+
- `--claude-env KEY=VALUE` - Set environment variable for Claude Code
|
|
40
|
+
- `--claude-arg ARG` - Pass additional argument to Claude CLI
|
|
41
|
+
|
|
42
|
+
## Environment Variables
|
|
43
|
+
|
|
44
|
+
- `HAPPY_SERVER_URL` - Custom server URL (default: https://api.cluster-fluster.com)
|
|
45
|
+
- `HAPPY_WEBAPP_URL` - Custom web app URL (default: https://app.happy.engineering)
|
|
46
|
+
- `HAPPY_HOME_DIR` - Custom home directory for Happy data (default: ~/.happy)
|
|
47
|
+
- `HAPPY_DISABLE_CAFFEINATE` - Disable macOS sleep prevention (set to `true`, `1`, or `yes`)
|
|
48
|
+
- `HAPPY_EXPERIMENTAL` - Enable experimental features (set to `true`, `1`, or `yes`)
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- Node.js >= 20.0.0
|
|
53
|
+
- Required by `eventsource-parser@3.0.5`, which is required by
|
|
54
|
+
`@modelcontextprotocol/sdk`, which we used to implement permission forwarding
|
|
55
|
+
to mobile app
|
|
56
|
+
- Claude CLI installed & logged in (`claude` command available in PATH)
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
|
|
7
|
+
// Ensure Node flags to reduce noisy warnings on stdout (which could interfere with MCP)
|
|
8
|
+
const hasNoWarnings = process.execArgv.includes('--no-warnings');
|
|
9
|
+
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
|
|
10
|
+
|
|
11
|
+
if (!hasNoWarnings || !hasNoDeprecation) {
|
|
12
|
+
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
13
|
+
const entrypoint = join(projectRoot, 'dist', 'codex', 'happyMcpStdioBridge.mjs');
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
execFileSync(process.execPath, [
|
|
17
|
+
'--no-warnings',
|
|
18
|
+
'--no-deprecation',
|
|
19
|
+
entrypoint,
|
|
20
|
+
...process.argv.slice(2)
|
|
21
|
+
], {
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
env: process.env
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
process.exit(error.status || 1);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
// Already have desired flags; import module directly
|
|
30
|
+
import('../dist/codex/happyMcpStdioBridge.mjs');
|
|
31
|
+
}
|
|
32
|
+
|
package/bin/happy.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
|
|
7
|
+
// Check if we're already running with the flags
|
|
8
|
+
const hasNoWarnings = process.execArgv.includes('--no-warnings');
|
|
9
|
+
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
|
|
10
|
+
|
|
11
|
+
if (!hasNoWarnings || !hasNoDeprecation) {
|
|
12
|
+
// Get path to the actual CLI entrypoint
|
|
13
|
+
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
14
|
+
const entrypoint = join(projectRoot, 'dist', 'index.mjs');
|
|
15
|
+
|
|
16
|
+
// Execute the actual CLI directly with the correct flags
|
|
17
|
+
try {
|
|
18
|
+
execFileSync(process.execPath, [
|
|
19
|
+
'--no-warnings',
|
|
20
|
+
'--no-deprecation',
|
|
21
|
+
entrypoint,
|
|
22
|
+
...process.argv.slice(2)
|
|
23
|
+
], {
|
|
24
|
+
stdio: 'inherit',
|
|
25
|
+
env: process.env
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// execFileSync throws if the process exits with non-zero
|
|
29
|
+
process.exit(error.status || 1);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
// We're running Node with the flags we wanted, import the CLI entrypoint
|
|
33
|
+
// module to avoid creating a new process.
|
|
34
|
+
import("../dist/index.mjs");
|
|
35
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
4
|
+
var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
5
|
+
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
6
|
+
var streamableHttp_js = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
7
|
+
var z = require('zod');
|
|
8
|
+
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
let url = null;
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const a = argv[i];
|
|
13
|
+
if (a === "--url" && i + 1 < argv.length) {
|
|
14
|
+
url = argv[i + 1];
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { url };
|
|
19
|
+
}
|
|
20
|
+
async function main() {
|
|
21
|
+
const { url: urlFromArgs } = parseArgs(process.argv.slice(2));
|
|
22
|
+
const baseUrl = urlFromArgs || process.env.HAPPY_HTTP_MCP_URL || "";
|
|
23
|
+
if (!baseUrl) {
|
|
24
|
+
process.stderr.write(
|
|
25
|
+
"[happy-mcp] Missing target URL. Set HAPPY_HTTP_MCP_URL or pass --url <http://127.0.0.1:PORT>\n"
|
|
26
|
+
);
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
let httpClient = null;
|
|
30
|
+
async function ensureHttpClient() {
|
|
31
|
+
if (httpClient) return httpClient;
|
|
32
|
+
const client = new index_js.Client(
|
|
33
|
+
{ name: "happy-stdio-bridge", version: "1.0.0" },
|
|
34
|
+
{ capabilities: { tools: {} } }
|
|
35
|
+
);
|
|
36
|
+
const transport = new streamableHttp_js.StreamableHTTPClientTransport(new URL(baseUrl));
|
|
37
|
+
await client.connect(transport);
|
|
38
|
+
httpClient = client;
|
|
39
|
+
return client;
|
|
40
|
+
}
|
|
41
|
+
const server = new mcp_js.McpServer({
|
|
42
|
+
name: "Happy MCP Bridge",
|
|
43
|
+
version: "1.0.0",
|
|
44
|
+
description: "STDIO bridge forwarding to Happy HTTP MCP"
|
|
45
|
+
});
|
|
46
|
+
server.registerTool(
|
|
47
|
+
"change_title",
|
|
48
|
+
{
|
|
49
|
+
description: "Change the title of the current chat session",
|
|
50
|
+
title: "Change Chat Title",
|
|
51
|
+
inputSchema: {
|
|
52
|
+
title: z.z.string().describe("The new title for the chat session")
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async (args) => {
|
|
56
|
+
try {
|
|
57
|
+
const client = await ensureHttpClient();
|
|
58
|
+
const response = await client.callTool({ name: "change_title", arguments: args });
|
|
59
|
+
return response;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{ type: "text", text: `Failed to change chat title: ${error instanceof Error ? error.message : String(error)}` }
|
|
64
|
+
],
|
|
65
|
+
isError: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
const stdio = new stdio_js.StdioServerTransport();
|
|
71
|
+
await server.connect(stdio);
|
|
72
|
+
}
|
|
73
|
+
main().catch((err) => {
|
|
74
|
+
try {
|
|
75
|
+
process.stderr.write(`[happy-mcp] Fatal: ${err instanceof Error ? err.message : String(err)}
|
|
76
|
+
`);
|
|
77
|
+
} finally {
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
function parseArgs(argv) {
|
|
8
|
+
let url = null;
|
|
9
|
+
for (let i = 0; i < argv.length; i++) {
|
|
10
|
+
const a = argv[i];
|
|
11
|
+
if (a === "--url" && i + 1 < argv.length) {
|
|
12
|
+
url = argv[i + 1];
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return { url };
|
|
17
|
+
}
|
|
18
|
+
async function main() {
|
|
19
|
+
const { url: urlFromArgs } = parseArgs(process.argv.slice(2));
|
|
20
|
+
const baseUrl = urlFromArgs || process.env.HAPPY_HTTP_MCP_URL || "";
|
|
21
|
+
if (!baseUrl) {
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
"[happy-mcp] Missing target URL. Set HAPPY_HTTP_MCP_URL or pass --url <http://127.0.0.1:PORT>\n"
|
|
24
|
+
);
|
|
25
|
+
process.exit(2);
|
|
26
|
+
}
|
|
27
|
+
let httpClient = null;
|
|
28
|
+
async function ensureHttpClient() {
|
|
29
|
+
if (httpClient) return httpClient;
|
|
30
|
+
const client = new Client(
|
|
31
|
+
{ name: "happy-stdio-bridge", version: "1.0.0" },
|
|
32
|
+
{ capabilities: { tools: {} } }
|
|
33
|
+
);
|
|
34
|
+
const transport = new StreamableHTTPClientTransport(new URL(baseUrl));
|
|
35
|
+
await client.connect(transport);
|
|
36
|
+
httpClient = client;
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
39
|
+
const server = new McpServer({
|
|
40
|
+
name: "Happy MCP Bridge",
|
|
41
|
+
version: "1.0.0",
|
|
42
|
+
description: "STDIO bridge forwarding to Happy HTTP MCP"
|
|
43
|
+
});
|
|
44
|
+
server.registerTool(
|
|
45
|
+
"change_title",
|
|
46
|
+
{
|
|
47
|
+
description: "Change the title of the current chat session",
|
|
48
|
+
title: "Change Chat Title",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
title: z.string().describe("The new title for the chat session")
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async (args) => {
|
|
54
|
+
try {
|
|
55
|
+
const client = await ensureHttpClient();
|
|
56
|
+
const response = await client.callTool({ name: "change_title", arguments: args });
|
|
57
|
+
return response;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{ type: "text", text: `Failed to change chat title: ${error instanceof Error ? error.message : String(error)}` }
|
|
62
|
+
],
|
|
63
|
+
isError: true
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
const stdio = new StdioServerTransport();
|
|
69
|
+
await server.connect(stdio);
|
|
70
|
+
}
|
|
71
|
+
main().catch((err) => {
|
|
72
|
+
try {
|
|
73
|
+
process.stderr.write(`[happy-mcp] Fatal: ${err instanceof Error ? err.message : String(err)}
|
|
74
|
+
`);
|
|
75
|
+
} finally {
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
});
|