@xwss/agentbell 0.1.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +969 -0
- package/RELEASE.md +31 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +106 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.js +159 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/initHooks.d.ts +9 -0
- package/dist/commands/initHooks.js +455 -0
- package/dist/commands/initHooks.js.map +1 -0
- package/dist/commands/project.d.ts +14 -0
- package/dist/commands/project.js +62 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/send.d.ts +5 -0
- package/dist/commands/send.js +70 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/setup.d.ts +13 -0
- package/dist/commands/setup.js +270 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/test.d.ts +9 -0
- package/dist/commands/test.js +40 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/verify.d.ts +78 -0
- package/dist/commands/verify.js +725 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/config.d.ts +123 -0
- package/dist/config.js +72 -0
- package/dist/config.js.map +1 -0
- package/dist/hooks/claudeCode.d.ts +5 -0
- package/dist/hooks/claudeCode.js +88 -0
- package/dist/hooks/claudeCode.js.map +1 -0
- package/dist/hooks/codex.d.ts +4 -0
- package/dist/hooks/codex.js +74 -0
- package/dist/hooks/codex.js.map +1 -0
- package/dist/hooks/vscodeAgent.d.ts +3 -0
- package/dist/hooks/vscodeAgent.js +45 -0
- package/dist/hooks/vscodeAgent.js.map +1 -0
- package/dist/notify/index.d.ts +3 -0
- package/dist/notify/index.js +8 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/local.d.ts +2 -0
- package/dist/notify/local.js +34 -0
- package/dist/notify/local.js.map +1 -0
- package/dist/notify/ntfy.d.ts +10 -0
- package/dist/notify/ntfy.js +57 -0
- package/dist/notify/ntfy.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/context.d.ts +92 -0
- package/dist/utils/context.js +198 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.js +12 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mask.d.ts +1 -0
- package/dist/utils/mask.js +10 -0
- package/dist/utils/mask.js.map +1 -0
- package/dist/utils/paths.d.ts +16 -0
- package/dist/utils/paths.js +93 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.js +21 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/topic.d.ts +2 -0
- package/dist/utils/topic.js +20 -0
- package/dist/utils/topic.js.map +1 -0
- package/package.json +57 -0
package/RELEASE.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Release Checklist
|
|
2
|
+
|
|
3
|
+
Run these checks before publishing AgentBell to npm.
|
|
4
|
+
|
|
5
|
+
The npm package is scoped as `@xwss/agentbell`, while the installed CLI command remains `agentbell`.
|
|
6
|
+
|
|
7
|
+
1. `npm run build`
|
|
8
|
+
2. `npm test`
|
|
9
|
+
3. `npm run lint`
|
|
10
|
+
4. `npm run check:package`
|
|
11
|
+
5. `npm pack --dry-run`
|
|
12
|
+
6. Inspect package contents and confirm no token, topic, log, backup, hook wrapper, `.env`, or local test file is included.
|
|
13
|
+
7. `npm pack`
|
|
14
|
+
8. Install the tarball locally:
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g ./xwss-agentbell-0.1.0.tgz
|
|
17
|
+
```
|
|
18
|
+
9. Smoke test:
|
|
19
|
+
```bash
|
|
20
|
+
agentbell --help
|
|
21
|
+
agentbell setup --dry-run --yes --targets none --no-test
|
|
22
|
+
agentbell verify --dry-run --json
|
|
23
|
+
```
|
|
24
|
+
10. Publish only after the checks above pass:
|
|
25
|
+
```bash
|
|
26
|
+
npm publish --access public --tag beta
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Do not publish real ntfy topics, auth tokens, `.env` files, logs, backups, or generated local hook wrappers.
|
|
30
|
+
|
|
31
|
+
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { runDoctor } from './commands/doctor.js';
|
|
4
|
+
import { runInit } from './commands/init.js';
|
|
5
|
+
import { runInitHooks } from './commands/initHooks.js';
|
|
6
|
+
import { runProjectInit } from './commands/project.js';
|
|
7
|
+
import { runSend } from './commands/send.js';
|
|
8
|
+
import { runSetup } from './commands/setup.js';
|
|
9
|
+
import { runTest } from './commands/test.js';
|
|
10
|
+
import { runVerify } from './commands/verify.js';
|
|
11
|
+
import { logger } from './utils/logger.js';
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program
|
|
14
|
+
.name('agentbell')
|
|
15
|
+
.description('AgentBell: get notified when your AI coding agent finishes.')
|
|
16
|
+
.version('0.1.0');
|
|
17
|
+
program
|
|
18
|
+
.command('send')
|
|
19
|
+
.description('Send one notification. Intended for AI coding agent hooks.')
|
|
20
|
+
.option('--tool <tool>', 'AI coding tool name, e.g. claude-code/codex/vscode-agent/custom')
|
|
21
|
+
.option('--event <event>', 'Lifecycle event, e.g. stop/notification/error/permission/custom')
|
|
22
|
+
.option('--title <title>', 'Notification title')
|
|
23
|
+
.option('--message <message>', 'Notification message')
|
|
24
|
+
.option('--priority <priority>', 'ntfy priority, default comes from config')
|
|
25
|
+
.option('--tags <tags>', 'Comma-separated ntfy tags')
|
|
26
|
+
.option('--config <path>', 'Config file path')
|
|
27
|
+
.option('--project <name>', 'Project display name')
|
|
28
|
+
.option('--task <name>', 'Task name for notification context')
|
|
29
|
+
.option('--cwd <path>', 'Context working directory')
|
|
30
|
+
.option('--branch <branch>', 'Git branch for notification context')
|
|
31
|
+
.option('--template-title <template>', 'Temporary title template override')
|
|
32
|
+
.option('--template-message <template>', 'Temporary message template override')
|
|
33
|
+
.action((options) => runSend(options).catch(handleError));
|
|
34
|
+
program
|
|
35
|
+
.command('test')
|
|
36
|
+
.description('Send a test notification to your phone.')
|
|
37
|
+
.option('--config <path>', 'Config file path')
|
|
38
|
+
.option('--project <name>', 'Project display name')
|
|
39
|
+
.option('--task <name>', 'Task name for notification context')
|
|
40
|
+
.option('--cwd <path>', 'Context working directory')
|
|
41
|
+
.option('--branch <branch>', 'Git branch for notification context')
|
|
42
|
+
.action((options) => runTest(options).catch(handleError));
|
|
43
|
+
program
|
|
44
|
+
.command('doctor')
|
|
45
|
+
.description('Print diagnostics for AgentBell setup and hooks.')
|
|
46
|
+
.option('--config <path>', 'Config file path')
|
|
47
|
+
.option('--json', 'Output diagnostics as JSON')
|
|
48
|
+
.action((options) => runDoctor(options).catch(handleError));
|
|
49
|
+
program
|
|
50
|
+
.command('verify')
|
|
51
|
+
.description('Verify AgentBell config, hook files, wrappers, and notification chain.')
|
|
52
|
+
.option('--target <target>', 'codex, claude-code, vscode-agent, or all', 'all')
|
|
53
|
+
.option('--config <path>', 'Config file path')
|
|
54
|
+
.option('--send-test', 'Send a verify test notification')
|
|
55
|
+
.option('--run-wrapper', 'Run target wrapper commands')
|
|
56
|
+
.option('--dry-run', 'Only inspect files and config; do not send notifications or run wrappers')
|
|
57
|
+
.option('--json', 'Output verify report as JSON')
|
|
58
|
+
.action((options) => runVerify(options).catch(handleError));
|
|
59
|
+
program
|
|
60
|
+
.command('setup')
|
|
61
|
+
.description('Run the first-use setup wizard.')
|
|
62
|
+
.option('--config <path>', 'Config file path')
|
|
63
|
+
.option('--topic <topic>', 'Use a specific ntfy topic')
|
|
64
|
+
.option('--machine-name <name>', 'Machine display name for notifications')
|
|
65
|
+
.option('--server <url>', 'ntfy server URL')
|
|
66
|
+
.option('--targets <targets>', 'all, none, or comma-separated codex,claude-code,vscode-agent')
|
|
67
|
+
.option('--yes', 'Use defaults for prompts')
|
|
68
|
+
.option('--no-test', 'Skip setup test notification')
|
|
69
|
+
.option('--dry-run', 'Preview setup without writing files, sending notifications, or installing hooks')
|
|
70
|
+
.option('--init-project', 'Create .agentbell.json in the current project')
|
|
71
|
+
.option('--project-name <name>', 'Project name for .agentbell.json when --init-project is used')
|
|
72
|
+
.action((options) => runSetup({ ...options, noTest: options.test === false }).catch(handleError));
|
|
73
|
+
const project = program
|
|
74
|
+
.command('project')
|
|
75
|
+
.description('Manage project-level AgentBell config.');
|
|
76
|
+
project
|
|
77
|
+
.command('init')
|
|
78
|
+
.description('Create .agentbell.json in the current project.')
|
|
79
|
+
.option('--name <name>', 'Project display name')
|
|
80
|
+
.option('--task <task>', 'Default task name')
|
|
81
|
+
.option('--force', 'Overwrite an existing .agentbell.json after creating a backup')
|
|
82
|
+
.action((options) => runProjectInit(options).catch(handleError));
|
|
83
|
+
program
|
|
84
|
+
.command('init')
|
|
85
|
+
.description('Interactively create ~/.agentbell/config.json.')
|
|
86
|
+
.option('--config <path>', 'Config file path')
|
|
87
|
+
.action((options) => runInit(options).catch(handleError));
|
|
88
|
+
program
|
|
89
|
+
.command('init-hooks')
|
|
90
|
+
.description('Generate hook configuration templates.')
|
|
91
|
+
.requiredOption('--target <target>', 'claude-code, codex, vscode-agent, or all')
|
|
92
|
+
.option('--dry-run', 'Preview hook changes without writing files')
|
|
93
|
+
.action((options) => {
|
|
94
|
+
const allowed = ['claude-code', 'codex', 'vscode-agent', 'all'];
|
|
95
|
+
if (!allowed.includes(options.target)) {
|
|
96
|
+
handleError(new Error(`Invalid target: ${options.target}. Expected one of ${allowed.join(', ')}`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
runInitHooks(options).catch(handleError);
|
|
100
|
+
});
|
|
101
|
+
function handleError(error) {
|
|
102
|
+
logger.error(error.message);
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
}
|
|
105
|
+
await program.parseAsync(process.argv);
|
|
106
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAmB,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,6DAA6D,CAAC;KAC1E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4DAA4D,CAAC;KACzE,MAAM,CAAC,eAAe,EAAE,iEAAiE,CAAC;KAC1F,MAAM,CAAC,iBAAiB,EAAE,iEAAiE,CAAC;KAC5F,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;KAC/C,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CAAC;KACrD,MAAM,CAAC,uBAAuB,EAAE,0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AAC;AAEL,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { loadConfig, resolveConfigPath } from '../config.js';
|
|
4
|
+
import { currentCliInvocation } from '../utils/paths.js';
|
|
5
|
+
import { maskSecret } from '../utils/mask.js';
|
|
6
|
+
import { logger } from '../utils/logger.js';
|
|
7
|
+
import { commandExists } from '../utils/shell.js';
|
|
8
|
+
async function canAccess(url) {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(url, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
signal: AbortSignal.timeout(5000)
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
reachable: true,
|
|
16
|
+
detail: `${response.ok ? 'ok' : 'reachable'} (HTTP ${response.status})`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
reachable: false,
|
|
22
|
+
detail: `failed (${error.message})`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function localNotificationSupport() {
|
|
27
|
+
if (process.platform === 'darwin') {
|
|
28
|
+
return { supported: true, method: 'osascript display notification' };
|
|
29
|
+
}
|
|
30
|
+
if (process.platform === 'linux') {
|
|
31
|
+
if (await commandExists('notify-send')) {
|
|
32
|
+
return { supported: true, method: 'notify-send' };
|
|
33
|
+
}
|
|
34
|
+
return { supported: false, reason: 'notify-send was not found in PATH' };
|
|
35
|
+
}
|
|
36
|
+
if (process.platform === 'win32') {
|
|
37
|
+
return {
|
|
38
|
+
supported: false,
|
|
39
|
+
reason: 'Windows local toast is skipped in this MVP; ntfy phone push still works'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { supported: false, reason: `unsupported platform: ${process.platform}` };
|
|
43
|
+
}
|
|
44
|
+
async function fileExists(filePath) {
|
|
45
|
+
try {
|
|
46
|
+
await access(filePath);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function buildDoctorReport(configPathOption) {
|
|
54
|
+
const configPath = resolveConfigPath(configPathOption);
|
|
55
|
+
const warnings = [];
|
|
56
|
+
const errors = [];
|
|
57
|
+
const textDetails = [];
|
|
58
|
+
const cli = currentCliInvocation();
|
|
59
|
+
const report = {
|
|
60
|
+
platform: process.platform,
|
|
61
|
+
arch: process.arch,
|
|
62
|
+
nodeVersion: process.version,
|
|
63
|
+
hostname: os.hostname(),
|
|
64
|
+
username: os.userInfo().username,
|
|
65
|
+
cwd: process.cwd(),
|
|
66
|
+
executablePath: process.execPath,
|
|
67
|
+
configPath,
|
|
68
|
+
configExists: await fileExists(configPath),
|
|
69
|
+
localNotificationSupport: await localNotificationSupport(),
|
|
70
|
+
hookTargets: [
|
|
71
|
+
{ target: 'codex', command: `${cli} send --tool codex --event stop` },
|
|
72
|
+
{ target: 'claude-code', command: `${cli} send --tool claude-code --event stop` },
|
|
73
|
+
{ target: 'vscode-agent', command: `${cli} send --tool vscode-agent --event stop` }
|
|
74
|
+
],
|
|
75
|
+
warnings,
|
|
76
|
+
errors
|
|
77
|
+
};
|
|
78
|
+
if (!report.configExists) {
|
|
79
|
+
warnings.push('Config file does not exist. Run agentbell init.');
|
|
80
|
+
textDetails.push('config readable: no');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
textDetails.push('config readable: yes');
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const loaded = await loadConfig(configPathOption);
|
|
87
|
+
report.provider = loaded.config.provider;
|
|
88
|
+
textDetails.push(`provider: ${loaded.config.provider}`);
|
|
89
|
+
textDetails.push(`provider supported: ${loaded.config.provider === 'ntfy' ? 'yes' : 'no'}`);
|
|
90
|
+
textDetails.push(`ntfy server: ${loaded.config.ntfy.server}`);
|
|
91
|
+
textDetails.push(`ntfy topic present: ${loaded.config.ntfy.topic.trim() ? 'yes' : 'no'}`);
|
|
92
|
+
textDetails.push(`ntfy topic masked: ${maskSecret(loaded.config.ntfy.topic)}`);
|
|
93
|
+
if (!loaded.config.ntfy.topic.trim()) {
|
|
94
|
+
errors.push('ntfy topic is empty.');
|
|
95
|
+
}
|
|
96
|
+
const reachability = await canAccess(loaded.config.ntfy.server);
|
|
97
|
+
report.ntfyServerReachable = reachability.reachable;
|
|
98
|
+
textDetails.push(`ntfy server access: ${reachability.detail}`);
|
|
99
|
+
if (!reachability.reachable) {
|
|
100
|
+
warnings.push(`ntfy server is not reachable: ${reachability.detail}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
errors.push(`config valid: no (${error.message})`);
|
|
105
|
+
textDetails.push(`config valid: no (${error.message})`);
|
|
106
|
+
}
|
|
107
|
+
if (!report.localNotificationSupport.supported) {
|
|
108
|
+
warnings.push(`local desktop notification unsupported: ${report.localNotificationSupport.reason}`);
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
...report,
|
|
112
|
+
textDetails
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export async function runDoctor(options) {
|
|
116
|
+
const report = await buildDoctorReport(options.config);
|
|
117
|
+
if (options.json) {
|
|
118
|
+
const jsonReport = { ...report };
|
|
119
|
+
delete jsonReport.textDetails;
|
|
120
|
+
logger.info(JSON.stringify(jsonReport, null, 2));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const lines = ['AgentBell doctor', '================'];
|
|
124
|
+
lines.push(`platform: ${report.platform} ${os.release()}`);
|
|
125
|
+
lines.push(`arch: ${report.arch}`);
|
|
126
|
+
lines.push(`hostname: ${report.hostname}`);
|
|
127
|
+
lines.push(`username: ${report.username}`);
|
|
128
|
+
lines.push(`cwd: ${report.cwd}`);
|
|
129
|
+
lines.push(`node: ${report.nodeVersion}`);
|
|
130
|
+
lines.push(`executable path: ${report.executablePath}`);
|
|
131
|
+
lines.push(`cli invocation for hooks: ${currentCliInvocation()}`);
|
|
132
|
+
lines.push(`config path: ${report.configPath}`);
|
|
133
|
+
lines.push(...report.textDetails);
|
|
134
|
+
lines.push(`local notification support: ${report.localNotificationSupport.supported
|
|
135
|
+
? `yes (${report.localNotificationSupport.method})`
|
|
136
|
+
: `no (${report.localNotificationSupport.reason})`}`);
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push('Recommended hook command examples:');
|
|
139
|
+
for (const target of report.hookTargets) {
|
|
140
|
+
lines.push(`- ${target.target}:`);
|
|
141
|
+
lines.push(` ${target.command}`);
|
|
142
|
+
}
|
|
143
|
+
if (report.warnings.length > 0) {
|
|
144
|
+
lines.push('');
|
|
145
|
+
lines.push('Warnings:');
|
|
146
|
+
for (const warning of report.warnings) {
|
|
147
|
+
lines.push(`- ${warning}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (report.errors.length > 0) {
|
|
151
|
+
lines.push('');
|
|
152
|
+
lines.push('Errors:');
|
|
153
|
+
for (const error of report.errors) {
|
|
154
|
+
lines.push(`- ${error}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
logger.info(lines.join('\n'));
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAA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M,GAAG,CAAC,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline/promises';
|
|
2
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
3
|
+
import { agentBellConfigSchema, writeConfig } from '../config.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { runInitHooks } from './initHooks.js';
|
|
6
|
+
function yes(value, defaultValue) {
|
|
7
|
+
const normalized = value.trim().toLowerCase();
|
|
8
|
+
if (!normalized) {
|
|
9
|
+
return defaultValue;
|
|
10
|
+
}
|
|
11
|
+
return ['y', 'yes', 'true', '1'].includes(normalized);
|
|
12
|
+
}
|
|
13
|
+
async function readStdin() {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
for await (const chunk of input) {
|
|
16
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
17
|
+
}
|
|
18
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
19
|
+
}
|
|
20
|
+
async function createQuestioner() {
|
|
21
|
+
if (input.isTTY) {
|
|
22
|
+
const rl = createInterface({ input, output });
|
|
23
|
+
return {
|
|
24
|
+
question: (prompt) => rl.question(prompt),
|
|
25
|
+
close: () => rl.close()
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const answers = (await readStdin()).split(/\r?\n/);
|
|
29
|
+
let index = 0;
|
|
30
|
+
return {
|
|
31
|
+
async question(prompt) {
|
|
32
|
+
output.write(prompt);
|
|
33
|
+
const answer = answers[index] ?? '';
|
|
34
|
+
index += 1;
|
|
35
|
+
output.write(`${answer}\n`);
|
|
36
|
+
return answer;
|
|
37
|
+
},
|
|
38
|
+
close: () => undefined
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function runInit(options) {
|
|
42
|
+
const rl = await createQuestioner();
|
|
43
|
+
try {
|
|
44
|
+
const provider = (await rl.question('Notification provider [ntfy]: ')).trim() || 'ntfy';
|
|
45
|
+
if (provider !== 'ntfy') {
|
|
46
|
+
throw new Error('Only ntfy is supported in this MVP.');
|
|
47
|
+
}
|
|
48
|
+
const server = (await rl.question('ntfy server [https://ntfy.sh]: ')).trim() || 'https://ntfy.sh';
|
|
49
|
+
const topic = (await rl.question('ntfy topic (use a long random secret): ')).trim();
|
|
50
|
+
if (!topic) {
|
|
51
|
+
throw new Error('ntfy topic is required.');
|
|
52
|
+
}
|
|
53
|
+
const localEnabled = yes(await rl.question('Enable local desktop notification too? [y/N]: '), false);
|
|
54
|
+
const includeHostname = yes(await rl.question('Include hostname in notifications? [Y/n]: '), true);
|
|
55
|
+
const includeCwd = yes(await rl.question('Include cwd in notifications? [Y/n]: '), true);
|
|
56
|
+
const includeTimestamp = yes(await rl.question('Include timestamp in notifications? [Y/n]: '), true);
|
|
57
|
+
const config = agentBellConfigSchema.parse({
|
|
58
|
+
provider: 'ntfy',
|
|
59
|
+
ntfy: {
|
|
60
|
+
server,
|
|
61
|
+
topic,
|
|
62
|
+
priority: 'high',
|
|
63
|
+
tags: ['computer']
|
|
64
|
+
},
|
|
65
|
+
localNotification: {
|
|
66
|
+
enabled: localEnabled
|
|
67
|
+
},
|
|
68
|
+
includeContext: {
|
|
69
|
+
hostname: includeHostname,
|
|
70
|
+
cwd: includeCwd,
|
|
71
|
+
timestamp: includeTimestamp
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const configPath = await writeConfig(config, options.config);
|
|
75
|
+
logger.info(`Config written: ${configPath}`);
|
|
76
|
+
if (yes(await rl.question('Generate hook templates now? [y/N]: '), false)) {
|
|
77
|
+
const target = (await rl.question('Hook target (claude-code/codex/vscode-agent/all) [all]: ')).trim() ||
|
|
78
|
+
'all';
|
|
79
|
+
if (!['claude-code', 'codex', 'vscode-agent', 'all'].includes(target)) {
|
|
80
|
+
throw new Error(`Invalid hook target: ${target}`);
|
|
81
|
+
}
|
|
82
|
+
await runInitHooks({ target });
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
logger.info('Next: run agentbell test, then agentbell init-hooks --target codex');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
rl.close();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACl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CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HookInstallResult, HookPreviewResult } from '../types.js';
|
|
2
|
+
export type HookTarget = 'claude-code' | 'codex' | 'vscode-agent' | 'all';
|
|
3
|
+
export declare function mergeJson(base: unknown, addition: unknown): unknown;
|
|
4
|
+
export declare function installHookTarget(target: Exclude<HookTarget, 'all'>): Promise<HookInstallResult>;
|
|
5
|
+
export declare function previewHookTarget(target: Exclude<HookTarget, 'all'>): Promise<HookPreviewResult>;
|
|
6
|
+
export declare function runInitHooks(options: {
|
|
7
|
+
target: HookTarget;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
}): Promise<void>;
|