@zeph-to/hook-sdk 1.3.1 → 1.4.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 +15 -0
- package/dist/cli.js +18 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -1
- package/dist/installer.js +5 -5
- package/dist/zeph-hook.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,21 @@ zeph notify --title "Hello" --json
|
|
|
83
83
|
| `--json` | Output JSON format |
|
|
84
84
|
| `--version` | Print version |
|
|
85
85
|
|
|
86
|
+
### Mute
|
|
87
|
+
|
|
88
|
+
Notifications are silently skipped when a mute file exists for the current project:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Mute (created by /zeph-mute in Claude Code plugin)
|
|
92
|
+
HASH=$(echo -n "$PROJECT_DIR" | cksum | cut -d' ' -f1)
|
|
93
|
+
touch /tmp/zeph-muted-$HASH
|
|
94
|
+
|
|
95
|
+
# Unmute
|
|
96
|
+
rm /tmp/zeph-muted-$HASH
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The CLI checks `CLAUDE_PROJECT_DIR`, `CURSOR_PROJECT_DIR`, `WINDSURF_PROJECT_DIR`, and falls back to `cwd`.
|
|
100
|
+
|
|
86
101
|
### Exit Codes
|
|
87
102
|
|
|
88
103
|
| Code | Meaning |
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
4
6
|
const zeph_hook_js_1 = require("./zeph-hook.js");
|
|
5
7
|
const errors_js_1 = require("./errors.js");
|
|
6
8
|
const installer_js_1 = require("./installer.js");
|
|
7
9
|
const config_js_1 = require("./config.js");
|
|
10
|
+
const PROJECT_DIR_VARS = ['CLAUDE_PROJECT_DIR', 'CURSOR_PROJECT_DIR', 'WINDSURF_PROJECT_DIR'];
|
|
11
|
+
const isMuted = () => {
|
|
12
|
+
try {
|
|
13
|
+
const dir = PROJECT_DIR_VARS.reduce((found, key) => found || process.env[key], undefined) ?? process.cwd();
|
|
14
|
+
const raw = (0, child_process_1.execFileSync)('cksum', { input: dir, encoding: 'utf-8' });
|
|
15
|
+
const hash = raw.split(' ')[0];
|
|
16
|
+
return (0, fs_1.existsSync)(`/tmp/zeph-muted-${hash}`);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
8
22
|
// ── Arg Parser ──────────────────────────────────────────────────
|
|
9
23
|
const parseArgs = (argv) => {
|
|
10
24
|
const result = {};
|
|
@@ -85,13 +99,13 @@ const printJson = (data) => {
|
|
|
85
99
|
// ── Commands ────────────────────────────────────────────────────
|
|
86
100
|
const createHook = (args) => {
|
|
87
101
|
const config = (0, config_js_1.loadConfig)();
|
|
88
|
-
const apiKey = args.key ||
|
|
102
|
+
const apiKey = args.key || (0, config_js_1.resolvedEnv)('ZEPH_API_KEY') || config.apiKey;
|
|
89
103
|
const isJson = args.json === true;
|
|
90
104
|
if (!apiKey) {
|
|
91
105
|
printError('API key required. Run "zeph install" or set ZEPH_API_KEY', isJson);
|
|
92
106
|
return null;
|
|
93
107
|
}
|
|
94
|
-
const baseUrl = args['base-url'] ||
|
|
108
|
+
const baseUrl = args['base-url'] || (0, config_js_1.resolvedEnv)('ZEPH_BASE_URL') || config.baseUrl;
|
|
95
109
|
return new zeph_hook_js_1.ZephHook({
|
|
96
110
|
apiKey,
|
|
97
111
|
...(baseUrl && { baseUrl }),
|
|
@@ -99,6 +113,8 @@ const createHook = (args) => {
|
|
|
99
113
|
};
|
|
100
114
|
const handleNotify = async (args) => {
|
|
101
115
|
const isJson = args.json === true;
|
|
116
|
+
if (isMuted())
|
|
117
|
+
return 0;
|
|
102
118
|
const hook = createHook(args);
|
|
103
119
|
if (!hook)
|
|
104
120
|
return 3;
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface ZephConfig {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
deviceId?: string;
|
|
8
8
|
}
|
|
9
|
+
export declare const resolvedEnv: (key: string) => string | undefined;
|
|
9
10
|
export declare const loadConfig: () => ZephConfig;
|
|
10
11
|
export declare const saveConfig: (config: ZephConfig) => void;
|
|
11
12
|
export declare const VERSION: string;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAAyC,CAAC;AACjE,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,QAAO,UAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,UAAU,KAAG,IAG/C,CAAC;AAEF,eAAO,MAAM,OAAO,QAOhB,CAAC"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAAyC,CAAC;AACjE,eAAO,MAAM,WAAW,QAAkC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAGlD,CAAC;AAEF,eAAO,MAAM,UAAU,QAAO,UAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,UAAU,KAAG,IAG/C,CAAC;AAEF,eAAO,MAAM,OAAO,QAOhB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VERSION = exports.saveConfig = exports.loadConfig = exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
|
|
3
|
+
exports.VERSION = exports.saveConfig = exports.loadConfig = exports.resolvedEnv = exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
exports.CONFIG_DIR = (0, path_1.join)(process.env.HOME ?? '~', '.zeph');
|
|
7
7
|
exports.CONFIG_FILE = (0, path_1.join)(exports.CONFIG_DIR, 'config.json');
|
|
8
|
+
const resolvedEnv = (key) => {
|
|
9
|
+
const val = process.env[key];
|
|
10
|
+
return val && !val.startsWith('${') ? val : undefined;
|
|
11
|
+
};
|
|
12
|
+
exports.resolvedEnv = resolvedEnv;
|
|
8
13
|
const loadConfig = () => {
|
|
9
14
|
try {
|
|
10
15
|
return JSON.parse((0, fs_1.readFileSync)(exports.CONFIG_FILE, 'utf-8'));
|
package/dist/installer.js
CHANGED
|
@@ -218,19 +218,19 @@ const handleInstall = async (args) => {
|
|
|
218
218
|
let hookId;
|
|
219
219
|
let baseUrl;
|
|
220
220
|
if (nonInteractive) {
|
|
221
|
-
apiKey = installArgs.key ||
|
|
222
|
-
hookId = installArgs.hook === 'none' ? undefined : (installArgs.hook ||
|
|
223
|
-
baseUrl = installArgs['base-url'] ||
|
|
221
|
+
apiKey = installArgs.key || (0, config_js_1.resolvedEnv)('ZEPH_API_KEY') || existing.apiKey;
|
|
222
|
+
hookId = installArgs.hook === 'none' ? undefined : (installArgs.hook || (0, config_js_1.resolvedEnv)('ZEPH_HOOK_ID') || existing.hookId);
|
|
223
|
+
baseUrl = installArgs['base-url'] || (0, config_js_1.resolvedEnv)('ZEPH_BASE_URL') || existing.baseUrl;
|
|
224
224
|
}
|
|
225
225
|
else {
|
|
226
226
|
console.log('');
|
|
227
|
-
const currentKey =
|
|
227
|
+
const currentKey = (0, config_js_1.resolvedEnv)('ZEPH_API_KEY') || existing.apiKey;
|
|
228
228
|
if (currentKey) {
|
|
229
229
|
console.log(` Current API Key: ${currentKey.slice(0, 12)}...`);
|
|
230
230
|
}
|
|
231
231
|
const keyInput = await promptInput(currentKey ? ' New API Key (Enter to keep): ' : ' API Key (from app > Settings > API Keys): ');
|
|
232
232
|
apiKey = keyInput || currentKey;
|
|
233
|
-
const currentHook =
|
|
233
|
+
const currentHook = (0, config_js_1.resolvedEnv)('ZEPH_HOOK_ID') || existing.hookId;
|
|
234
234
|
if (currentHook) {
|
|
235
235
|
console.log(` Current Hook ID: ${currentHook}`);
|
|
236
236
|
}
|
package/dist/zeph-hook.js
CHANGED
|
@@ -46,7 +46,7 @@ class ZephHook {
|
|
|
46
46
|
const json = await this.request('POST', '/pushes/send', {
|
|
47
47
|
...payload,
|
|
48
48
|
body: preview,
|
|
49
|
-
type: 'file',
|
|
49
|
+
type: payload.type ?? 'file',
|
|
50
50
|
files: [{ fileKey: upload.fileKey, fileName, fileSize, fileType }],
|
|
51
51
|
});
|
|
52
52
|
const pushId = json.data?.pushId;
|