@zeph-to/hook-sdk 1.7.1 → 1.9.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/dist/verify.js ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleVerify = void 0;
4
+ const fs_1 = require("fs");
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ const agents_js_1 = require("./agents.js");
8
+ const config_js_1 = require("./config.js");
9
+ const zeph_hook_js_1 = require("./zeph-hook.js");
10
+ const HOME = (0, os_1.homedir)();
11
+ const pass = (msg) => console.log(` ✓ ${msg}`);
12
+ const warn = (msg) => console.log(` ! ${msg}`);
13
+ const failMsg = (msg) => console.log(` ✗ ${msg}`);
14
+ /** Does a shared rule file contain the Zeph managed block? */
15
+ const hasManagedBlock = (filePath) => {
16
+ try {
17
+ return (0, fs_1.readFileSync)(filePath, 'utf-8').includes('ZEPH:START');
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ };
23
+ // Per-agent: report whether the rule artifact Zeph installs is present.
24
+ const AGENT_RULE_PRESENT = {
25
+ claude: () => {
26
+ try {
27
+ return /zeph/.test((0, fs_1.readFileSync)((0, path_1.join)(HOME, '.claude.json'), 'utf-8'));
28
+ }
29
+ catch {
30
+ return (0, fs_1.existsSync)((0, path_1.join)(HOME, '.claude', 'plugins'));
31
+ }
32
+ },
33
+ cursor: () => (0, fs_1.existsSync)((0, path_1.join)(HOME, '.cursor', 'rules', 'zeph.mdc')),
34
+ windsurf: () => hasManagedBlock((0, path_1.join)(HOME, '.codeium', 'windsurf', 'memories', 'global_rules.md')),
35
+ gemini: () => hasManagedBlock((0, path_1.join)(HOME, '.gemini', 'GEMINI.md')),
36
+ codex: () => hasManagedBlock((0, path_1.join)(HOME, '.codex', 'AGENTS.md')),
37
+ copilot: () => (0, fs_1.existsSync)((0, path_1.join)(HOME, '.copilot', 'instructions', 'zeph.instructions.md')),
38
+ cline: () => (0, fs_1.existsSync)((0, path_1.join)(HOME, '.cline', 'rules', 'zeph.md')),
39
+ aider: () => (0, fs_1.existsSync)((0, path_1.join)(HOME, '.zeph', 'aider-conventions.md')),
40
+ };
41
+ const handleVerify = async (args) => {
42
+ const doPing = args.ping === true;
43
+ const checks = [];
44
+ const record = (label, state) => {
45
+ checks.push({ label, state });
46
+ if (state === 'pass')
47
+ pass(label);
48
+ else if (state === 'warn')
49
+ warn(label);
50
+ else
51
+ failMsg(label);
52
+ };
53
+ console.log(`\n Zeph verify — v${config_js_1.VERSION}\n`);
54
+ // ── Credentials ──────────────────────────────────────────────
55
+ console.log(' Credentials:');
56
+ const config = (0, config_js_1.loadConfig)();
57
+ const apiKey = (0, config_js_1.resolvedEnv)('ZEPH_API_KEY') || config.apiKey;
58
+ const hookId = (0, config_js_1.resolvedEnv)('ZEPH_HOOK_ID') || config.hookId;
59
+ record(apiKey ? 'ZEPH_API_KEY is set' : 'ZEPH_API_KEY not set (env or ~/.zeph/config.json)', apiKey ? 'pass' : 'fail');
60
+ record(hookId
61
+ ? 'ZEPH_HOOK_ID is set (two-way zeph_ask/prompt/input enabled)'
62
+ : 'ZEPH_HOOK_ID not set (notify-only — set it for remote control)', hookId ? 'pass' : 'warn');
63
+ // ── Runtime ──────────────────────────────────────────────────
64
+ console.log('\n Runtime:');
65
+ record((0, agents_js_1.hasCommand)('node') ? 'node available' : 'node not found', (0, agents_js_1.hasCommand)('node') ? 'pass' : 'fail');
66
+ record((0, agents_js_1.hasCommand)('npx') ? 'npx available (MCP server runs via npx)' : 'npx not found', (0, agents_js_1.hasCommand)('npx') ? 'pass' : 'fail');
67
+ record((0, agents_js_1.hasCommand)('zeph')
68
+ ? 'zeph CLI on PATH'
69
+ : 'zeph CLI not on PATH (hooks fall back to npx — slower first call)', (0, agents_js_1.hasCommand)('zeph') ? 'pass' : 'warn');
70
+ // ── Per-agent config ─────────────────────────────────────────
71
+ console.log('\n Agents:');
72
+ const detected = (0, agents_js_1.detectAgents)().filter((a) => a.detected);
73
+ if (detected.length === 0) {
74
+ warn('no supported agents detected');
75
+ }
76
+ for (const agent of detected) {
77
+ const present = AGENT_RULE_PRESENT[agent.id]?.() ?? false;
78
+ record(`${agent.name}: ${present ? 'Zeph rules installed' : 'Zeph rules NOT installed — run: zeph install'}`, present ? 'pass' : 'warn');
79
+ }
80
+ // ── Optional live API ping ───────────────────────────────────
81
+ if (doPing) {
82
+ console.log('\n API ping:');
83
+ if (!apiKey) {
84
+ record('skipped — no API key', 'warn');
85
+ }
86
+ else {
87
+ try {
88
+ const hook = new zeph_hook_js_1.ZephHook({ apiKey, ...(config.baseUrl && { baseUrl: config.baseUrl }) });
89
+ await hook.list({ limit: 1 });
90
+ record('API reachable, key accepted', 'pass');
91
+ }
92
+ catch (err) {
93
+ record(`API call failed: ${err instanceof Error ? err.message : 'unknown'}`, 'fail');
94
+ }
95
+ }
96
+ }
97
+ // ── Summary ──────────────────────────────────────────────────
98
+ const fails = checks.filter((c) => c.state === 'fail').length;
99
+ const warns = checks.filter((c) => c.state === 'warn').length;
100
+ console.log('');
101
+ if (fails === 0 && warns === 0) {
102
+ console.log(' ✓ All checks passed.\n');
103
+ }
104
+ else {
105
+ console.log(` ${fails} failed, ${warns} warnings.${doPing ? '' : ' (run with --ping to test the API)'}\n`);
106
+ }
107
+ return fails === 0 ? 0 : 1;
108
+ };
109
+ exports.handleVerify = handleVerify;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zeph-to/hook-sdk",
3
- "version": "1.7.1",
4
- "description": "Zeph push notification SDK + CLI zero dependencies",
3
+ "version": "1.9.0",
4
+ "description": "Zeph push notification SDK + CLI for AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -22,11 +22,14 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "tsc",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
25
27
  "prepublishOnly": "npm run build"
26
28
  },
27
29
  "devDependencies": {
30
+ "@types/node": "^22.0.0",
28
31
  "typescript": "^5.8.0",
29
- "@types/node": "^22.0.0"
32
+ "vitest": "^2.1.9"
30
33
  },
31
34
  "release": {
32
35
  "branches": [
@@ -59,5 +62,8 @@
59
62
  "claude",
60
63
  "devtools"
61
64
  ],
62
- "license": "Apache-2.0"
65
+ "license": "Apache-2.0",
66
+ "dependencies": {
67
+ "@inquirer/prompts": "^8.4.3"
68
+ }
63
69
  }