@misterhuydo/sentinel 1.4.77 → 1.4.79

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/.cairn/.hint-lock CHANGED
@@ -1 +1 @@
1
- 2026-03-26T18:52:08.498Z
1
+ 2026-03-27T01:29:06.939Z
@@ -1,6 +1,6 @@
1
1
  {
2
- "message": "Auto-checkpoint at 2026-03-26T19:12:24.024Z",
3
- "checkpoint_at": "2026-03-26T19:12:24.038Z",
2
+ "message": "Auto-checkpoint at 2026-03-27T01:50:53.961Z",
3
+ "checkpoint_at": "2026-03-27T01:50:53.962Z",
4
4
  "active_files": [],
5
5
  "notes": [],
6
6
  "mtime_snapshot": {}
package/lib/init.js CHANGED
@@ -97,8 +97,8 @@ module.exports = async function init() {
97
97
  ], { onCancel: () => process.exit(0) });
98
98
 
99
99
  // ── Slack app creation helper (shown before token prompts) ───────────────────
100
- if (answers.setupSlack && !existing.SLACK_BOT_TOKEN) {
101
- printSlackSetupGuide();
100
+ if (answers.setupSlack) {
101
+ printSlackSetupGuide(!!existing.SLACK_BOT_TOKEN);
102
102
  }
103
103
 
104
104
  const tokenAnswers = await prompts([
@@ -457,17 +457,31 @@ function buildSlackManifest() {
457
457
  };
458
458
  }
459
459
 
460
- function printSlackSetupGuide() {
460
+ function printSlackSetupGuide(hasExisting) {
461
461
  const manifest = buildSlackManifest();
462
- const manifestJson = JSON.stringify(manifest);
463
- const encoded = encodeURIComponent(manifestJson);
464
- const createUrl = `https://api.slack.com/apps?new_app=1&manifest_json=${encoded}`;
462
+ const manifestJson = JSON.stringify(manifest, null, 2);
465
463
 
466
464
  step('Setting up Slack Bot (Sentinel Boss)…');
467
- console.log(`
465
+
466
+ if (hasExisting) {
467
+ console.log(`
468
+ ${chalk.bold('Update your existing Slack app manifest:')}
469
+
470
+ ${chalk.white('1.')} Open: ${chalk.cyan('https://api.slack.com/apps')} → select your Sentinel app
471
+ ${chalk.white('2.')} Click ${chalk.cyan('"App Manifest"')} in the left sidebar
472
+ ${chalk.white('3.')} Replace the entire manifest with:
473
+
474
+ ${manifestJson.split('\n').map(l => ' ' + l).join('\n')}
475
+
476
+ ${chalk.white('4.')} Click ${chalk.green('"Save Changes"')} → reinstall to workspace if prompted
477
+ ${chalk.white('5.')} Paste your tokens below ↓
478
+ `);
479
+ } else {
480
+ const createUrlEncoded = `https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(buildSlackManifest()))}`;
481
+ console.log(`
468
482
  ${chalk.bold('One-click Slack app setup:')}
469
483
 
470
- ${chalk.cyan(createUrl)}
484
+ ${chalk.cyan(createUrlEncoded)}
471
485
 
472
486
  ${chalk.bold('Steps after clicking the link:')}
473
487
  ${chalk.white('1.')} Slack opens with all permissions pre-filled → click ${chalk.green('"Create App"')}
@@ -478,17 +492,14 @@ function printSlackSetupGuide() {
478
492
  → Copy ${chalk.yellow('App-Level Token')} (xapp-...)
479
493
  ${chalk.white('5.')} Paste both tokens below ↓
480
494
  `);
481
-
482
- // Try to open in browser (Linux/Mac/WSL)
483
- try {
484
- const { execSync: _exec } = require('child_process');
485
- const opener = process.platform === 'darwin' ? 'open'
486
- : process.platform === 'win32' ? 'start'
487
- : 'xdg-open';
488
- _exec(`${opener} "${createUrl}"`, { stdio: 'ignore' });
489
- console.log(chalk.green(' ✔') + ' Opened in your browser\n');
490
- } catch (_) {
491
- // Silently ignore if browser open fails
495
+ try {
496
+ const { execSync: _exec } = require('child_process');
497
+ const opener = process.platform === 'darwin' ? 'open'
498
+ : process.platform === 'win32' ? 'start'
499
+ : 'xdg-open';
500
+ _exec(`${opener} "${createUrlEncoded}"`, { stdio: 'ignore' });
501
+ console.log(chalk.green(' ✔') + ' Opened in your browser\n');
502
+ } catch (_) {}
492
503
  }
493
504
  }
494
505
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterhuydo/sentinel",
3
- "version": "1.4.77",
3
+ "version": "1.4.79",
4
4
  "description": "Sentinel — Autonomous DevOps Agent installer and manager",
5
5
  "bin": {
6
6
  "sentinel": "./bin/sentinel.js"
@@ -1,372 +0,0 @@
1
- 'use strict';
2
- const fs = require('fs-extra');
3
- const path = require('path');
4
- const os = require('os');
5
- const { execSync, spawnSync } = require('child_process');
6
- const prompts = require('prompts');
7
- const chalk = require('chalk');
8
- const { generateProjectScripts, generateWorkspaceScripts, writeExampleProject } = require('./generate');
9
- const ok = msg => console.log(chalk.green(' ✔'), msg);
10
- const info = msg => console.log(chalk.cyan(' →'), msg);
11
- const warn = msg => console.log(chalk.yellow(' ⚠'), msg);
12
- const step = msg => console.log('\n' + chalk.bold.white(msg));
13
- module.exports = async function init() {
14
- const defaultWorkspace = path.join(os.homedir(), 'sentinel');
15
- const existing = readExistingConfig(defaultWorkspace);
16
- if (Object.keys(existing).length) {
17
- console.log(chalk.cyan('\n → Existing workspace config found — showing current values as defaults\n'));
18
- }
19
- const answers = await prompts([
20
- {
21
- type: 'text',
22
- name: 'workspace',
23
- message: 'Workspace directory (each project lives here as a subdirectory)',
24
- initial: path.join(os.homedir(), 'sentinel'),
25
- format: v => v.replace(/^~/, os.homedir()),
26
- },
27
- {
28
- type: 'select',
29
- name: 'authMode',
30
- message: 'Claude authentication strategy',
31
- hint: 'Boss = Slack AI; Fix Engine = autonomous code repair',
32
- choices: [
33
- {
34
- title: 'Both (RECOMMENDED) — API key for Boss, Claude Pro for Fix Engine',
35
- value: 'both',
36
- },
37
- {
38
- title: 'API key only — full Boss tools; Fix Engine billed per token',
39
- value: 'apikey',
40
- },
41
- {
42
- title: 'Claude Pro / OAuth only — run `claude login`; Boss has limited tools',
43
- value: 'oauth',
44
- },
45
- { title: 'Skip (configure manually in sentinel.properties)', value: 'skip' },
46
- ],
47
- },
48
- {
49
- type: prev => (prev === 'apikey' || prev === 'both') ? 'password' : null,
50
- name: 'anthropicKey',
51
- message: existing.ANTHROPIC_API_KEY
52
- ? 'Anthropic API key (press Enter to keep current)'
53
- : 'Anthropic API key (sk-ant-...)',
54
- validate: v => !v || v.startsWith('sk-ant-') ? true : 'Key should start with sk-ant-',
55
- },
56
- {
57
- type: 'confirm',
58
- name: 'example',
59
- message: 'Create an example project to show how to configure?',
60
- initial: true,
61
- },
62
- {
63
- type: 'confirm',
64
- name: 'systemd',
65
- message: 'Set up systemd service for auto-start on reboot?',
66
- initial: process.platform === 'linux',
67
- },
68
- {
69
- type: 'text',
70
- name: 'smtpUser',
71
- message: 'SMTP sender address',
72
- initial: existing.SMTP_USER || 'sentinel@yourdomain.com',
73
- },
74
- {
75
- type: prev => prev ? 'password' : null,
76
- name: 'smtpPassword',
77
- message: existing.SMTP_PASSWORD ? 'SMTP password / app password (press Enter to keep current)' : 'SMTP password / app password',
78
- },
79
- {
80
- type: prev => prev ? 'text' : null,
81
- name: 'smtpHost',
82
- message: 'SMTP host',
83
- initial: existing.SMTP_HOST || 'smtp.gmail.com',
84
- },
85
- {
86
- type: 'confirm',
87
- name: 'setupSlack',
88
- message: 'Set up Slack Bot (Sentinel Boss — conversational AI interface)?',
89
- initial: !!(existing.SLACK_BOT_TOKEN),
90
- },
91
- {
92
- type: prev => prev ? 'password' : null,
93
- name: 'slackBotToken',
94
- message: existing.SLACK_BOT_TOKEN ? 'Slack Bot Token (press Enter to keep current)' : 'Slack Bot Token (xoxb-...)',
95
- validate: v => !v || v.startsWith('xoxb-') ? true : 'Should start with xoxb-',
96
- },
97
- {
98
- type: (_, { setupSlack }) => setupSlack ? 'password' : null,
99
- name: 'slackAppToken',
100
- message: existing.SLACK_APP_TOKEN ? 'Slack App-Level Token (press Enter to keep current)' : 'Slack App-Level Token (xapp-...)',
101
- validate: v => !v || v.startsWith('xapp-') ? true : 'Should start with xapp-',
102
- },
103
- ], { onCancel: () => process.exit(0) });
104
- const { workspace, authMode, anthropicKey, example, systemd, smtpUser, smtpPassword, smtpHost, setupSlack, slackBotToken, slackAppToken } = answers;
105
- const effectiveAnthropicKey = anthropicKey || existing.ANTHROPIC_API_KEY || '';
106
- const effectiveSmtpPassword = smtpPassword || existing.SMTP_PASSWORD || '';
107
- const effectiveSlackBotToken = slackBotToken || existing.SLACK_BOT_TOKEN || '';
108
- const effectiveSlackAppToken = slackAppToken || existing.SLACK_APP_TOKEN || '';
109
- const codeDir = path.join(workspace, 'code');
110
- step('Checking npm permissions…');
111
- ensureNpmUserPrefix();
112
- step('Checking Python…');
113
- const python = findPython();
114
- if (!python) {
115
- console.error(chalk.red(' ✖ python3 not found. Install it first:'));
116
- console.error(' sudo apt-get install -y python3 python3-pip python3-venv');
117
- process.exit(1);
118
- }
119
- ok(`Python: ${run(python, ['--version']).trim()}`);
120
- step('Installing Sentinel code…');
121
- const bundledPython = path.join(__dirname, '..', 'python');
122
- if (!fs.existsSync(bundledPython)) {
123
- console.error(chalk.red(' ✖ Bundled Python source not found (run npm publish from the Sentinel repo)'));
124
- process.exit(1);
125
- }
126
- fs.ensureDirSync(codeDir);
127
- fs.copySync(bundledPython, codeDir, { overwrite: true });
128
- ok(`Sentinel code → ${codeDir}`);
129
- step('Setting up Python environment…');
130
- const venv = path.join(codeDir, '.venv');
131
- if (!fs.existsSync(venv)) {
132
- info('Creating virtual environment…');
133
- runLive(python, ['-m', 'venv', venv]);
134
- }
135
- const pip = path.join(venv, 'bin', 'pip3');
136
- const pythonBin = path.join(venv, 'bin', 'python3');
137
- info('Installing Python packages…');
138
- runLive(pip, ['install', '--quiet', '--upgrade', 'pip']);
139
- runLive(pip, ['install', '--quiet', '-r', path.join(codeDir, 'requirements.txt')]);
140
- ok('Python packages installed');
141
- step('Installing Node tools…');
142
- installNpmGlobal('@misterhuydo/cairn-mcp', 'cairn');
143
- step('Hooking Cairn MCP into Claude Code…');
144
- runLive('cairn', ['install']);
145
- ok('cairn install complete');
146
- installNpmGlobal('@anthropic-ai/claude-code', 'claude');
147
- step('Patching Claude Code permissions…');
148
- ensureClaudePermissions();
149
- step('Claude Code authentication…');
150
- if (authMode === 'both' && effectiveAnthropicKey) {
151
- ok('API key → Sentinel Boss (full tools, structured responses)');
152
- ok('Claude Pro → Fix Engine + Ask Codebase (heavy coding, Pro subscription)');
153
- info('Run `claude login` on this server now (or before starting projects)');
154
- info('CLAUDE_PRO_FOR_TASKS=true written to workspace sentinel.properties');
155
- } else if (authMode === 'apikey' && effectiveAnthropicKey) {
156
- ok('API key → all Claude usage (Boss + Fix Engine billed to your API quota)');
157
- info('CLAUDE_PRO_FOR_TASKS=false written — Fix Engine will use API key');
158
- warn('Heavy fix tasks will consume API tokens. Claude Pro is cheaper for those.');
159
- } else if (authMode === 'oauth') {
160
- ok('Claude Pro / OAuth → Fix Engine + Ask Codebase');
161
- warn('Boss will use CLI fallback — some tools unavailable without an API key');
162
- info('Run `claude login` on this server to authenticate');
163
- } else {
164
- warn('No auth configured — add ANTHROPIC_API_KEY or run `claude login` before starting');
165
- info('See: workspace sentinel.properties for full auth documentation');
166
- }
167
- if (effectiveSlackBotToken && effectiveSlackAppToken) {
168
- step('Slack Bot (Sentinel Boss)…');
169
- ok('Tokens will be written to workspace sentinel.properties');
170
- info('Sentinel Boss starts automatically when the project starts');
171
- } else if (setupSlack) {
172
- warn('Slack tokens not provided — add them to config/sentinel.properties later');
173
- }
174
- step('Creating workspace…');
175
- fs.ensureDirSync(workspace);
176
- ok(`Workspace: ${workspace}`);
177
- if (example) {
178
- step('Creating example project…');
179
- const exampleDir = path.join(workspace, 'my-project');
180
- writeExampleProject(exampleDir, codeDir, pythonBin, effectiveAnthropicKey, { botToken: effectiveSlackBotToken, appToken: effectiveSlackAppToken });
181
- ok(`Example project: ${exampleDir}`);
182
- }
183
- step('Generating scripts…');
184
- const authConfig = {};
185
- if (effectiveAnthropicKey) authConfig.apiKey = effectiveAnthropicKey;
186
- if (authMode === 'both' || authMode === 'oauth') authConfig.claudeProForTasks = true;
187
- if (authMode === 'apikey') authConfig.claudeProForTasks = false;
188
- generateWorkspaceScripts(workspace, { host: smtpHost, user: smtpUser, password: effectiveSmtpPassword }, { botToken: effectiveSlackBotToken, appToken: effectiveSlackAppToken }, authConfig);
189
- ok(`${workspace}/startAll.sh`);
190
- ok(`${workspace}/stopAll.sh`);
191
- if (systemd) {
192
- step('Setting up systemd…');
193
- setupSystemd(workspace);
194
- }
195
- console.log('\n' + chalk.bold.green('══ Done! ══') + '\n');
196
- console.log(`${chalk.bold('Next steps:')}`);
197
- if (example) {
198
- console.log(`
199
- 1. Configure your first project:
200
- ${chalk.cyan(`${workspace}/my-project/config/sentinel.properties`)}
201
- ${chalk.cyan(`${workspace}/my-project/config/log-configs/`)}
202
- ${chalk.cyan(`${workspace}/my-project/config/repo-configs/`)}
203
- 2. Start all projects (Sentinel clones repos, indexes, and monitors automatically):
204
- ${chalk.cyan(`${workspace}/startAll.sh`)}
205
- 3. Stop all projects:
206
- ${chalk.cyan(`${workspace}/stopAll.sh`)}
207
- `);
208
- }
209
- if (systemd) {
210
- console.log(` Auto-start is enabled. To manage:
211
- ${chalk.cyan('sudo systemctl start sentinel')}
212
- ${chalk.cyan('sudo systemctl status sentinel')}
213
- ${chalk.cyan('journalctl -u sentinel -f')}
214
- `);
215
- }
216
- console.log(` Add another project anytime:
217
- ${chalk.cyan('sentinel add <project-name>')}
218
- `);
219
- };
220
- function readExistingConfig(workspace) {
221
- const result = {};
222
- _parsePropsInto(path.join(workspace, 'sentinel.properties'), result);
223
- if (!result.SLACK_BOT_TOKEN || !result.SLACK_APP_TOKEN) {
224
- try {
225
- for (const entry of fs.readdirSync(workspace)) {
226
- const p = path.join(workspace, entry, 'config', 'sentinel.properties');
227
- const proj = {};
228
- _parsePropsInto(p, proj);
229
- if (!result.SLACK_BOT_TOKEN && proj.SLACK_BOT_TOKEN) result.SLACK_BOT_TOKEN = proj.SLACK_BOT_TOKEN;
230
- if (!result.SLACK_APP_TOKEN && proj.SLACK_APP_TOKEN) result.SLACK_APP_TOKEN = proj.SLACK_APP_TOKEN;
231
- if (result.SLACK_BOT_TOKEN && result.SLACK_APP_TOKEN) break;
232
- }
233
- } catch (_) {}
234
- }
235
- return result;
236
- }
237
- function _parsePropsInto(propsPath, result) {
238
- if (!fs.existsSync(propsPath)) return;
239
- try {
240
- const lines = fs.readFileSync(propsPath, 'utf8').split(/\r?\n/);
241
- for (const raw of lines) {
242
- const line = raw.trim();
243
- if (!line || line.startsWith('#')) continue;
244
- const idx = line.indexOf('=');
245
- if (idx === -1) continue;
246
- result[line.slice(0, idx).trim()] = line.slice(idx + 1).trim();
247
- }
248
- } catch (_) {}
249
- }
250
- function findPython() {
251
- for (const bin of ['python3', 'python']) {
252
- try {
253
- execSync(`${bin} --version`, { stdio: 'pipe' });
254
- return bin;
255
- } catch (_) {}
256
- }
257
- return null;
258
- }
259
- function run(bin, args) {
260
- const r = spawnSync(bin, args, { encoding: 'utf8' });
261
- return (r.stdout || '') + (r.stderr || '');
262
- }
263
- function runLive(bin, args) {
264
- const r = spawnSync(bin, args, { stdio: 'inherit' });
265
- if (r.status !== 0) {
266
- console.error(chalk.red(` ✖ Command failed: ${bin} ${args.join(' ')}`));
267
- process.exit(1);
268
- }
269
- }
270
- function installNpmGlobal(pkg, checkBin) {
271
- try {
272
- execSync(`${checkBin} --version`, { stdio: 'pipe' });
273
- ok(`${pkg} already installed`);
274
- } catch (_) {
275
- info(`Installing ${pkg}…`);
276
- runLive('npm', ['install', '-g', pkg]);
277
- ok(`${pkg} installed`);
278
- }
279
- }
280
- function ensureClaudePermissions() {
281
- const settingsPath = require('path').join(require('os').homedir(), '.claude', 'settings.json');
282
- const required = ['Read(**)', 'Write(**)', 'Edit(**)', 'Bash(**)'];
283
- let settings = {};
284
- try {
285
- if (fs.existsSync(settingsPath)) {
286
- settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
287
- }
288
- } catch (e) {
289
- warn('Could not read ' + settingsPath + ': ' + e.message);
290
- return;
291
- }
292
- if (!settings.permissions) settings.permissions = {};
293
- if (!Array.isArray(settings.permissions.allow)) settings.permissions.allow = [];
294
- const existing = new Set(settings.permissions.allow);
295
- const added = [];
296
- for (const perm of required) {
297
- if (!existing.has(perm)) {
298
- settings.permissions.allow.push(perm);
299
- added.push(perm);
300
- }
301
- }
302
- if (added.length === 0) {
303
- ok('Claude Code permissions already configured');
304
- return;
305
- }
306
- try {
307
- fs.ensureDirSync(require('path').dirname(settingsPath));
308
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
309
- ok('Claude Code permissions patched: ' + added.join(', '));
310
- } catch (e) {
311
- warn('Could not write ' + settingsPath + ': ' + e.message);
312
- }
313
- }
314
- function ensureNpmUserPrefix() {
315
- try {
316
- const currentPrefix = execSync('npm config get prefix', { encoding: 'utf8' }).trim();
317
- const homeDir = os.homedir();
318
- if (currentPrefix.startsWith(homeDir)) {
319
- ok(`npm prefix: ${currentPrefix} (user-owned, no sudo needed)`);
320
- return;
321
- }
322
- try { fs.accessSync(currentPrefix, fs.constants.W_OK); ok('npm prefix writable'); return; }
323
- catch (_) {}
324
- const userPrefix = path.join(homeDir, '.npm-global');
325
- fs.ensureDirSync(userPrefix);
326
- execSync(`npm config set prefix "${userPrefix}"`, { encoding: 'utf8' });
327
- ok(`npm prefix set to ${userPrefix} (no sudo needed for upgrades)`);
328
- const exportLine = `export PATH="${userPrefix}/bin:$PATH"`;
329
- for (const rc of ['.bashrc', '.profile', '.zshrc']) {
330
- const rcPath = path.join(homeDir, rc);
331
- if (!fs.existsSync(rcPath)) continue;
332
- const content = fs.readFileSync(rcPath, 'utf8');
333
- if (!content.includes(userPrefix)) {
334
- fs.appendFileSync(rcPath, `\n# Added by sentinel init\n${exportLine}\n`);
335
- ok(`PATH updated in ~/${rc}`);
336
- }
337
- }
338
- warn(`Run: export PATH="${userPrefix}/bin:$PATH" (or open a new shell)`);
339
- warn(`Then reinstall: npm install -g @misterhuydo/sentinel`);
340
- } catch (e) {
341
- warn(`Could not check npm prefix: ${e.message}`);
342
- }
343
- }
344
- function setupSystemd(workspace) {
345
- const user = os.userInfo().username;
346
- const svc = `/etc/systemd/system/sentinel.service`;
347
- const content = `[Unit]
348
- Description=Sentinel — Autonomous DevOps Agent
349
- After=network-online.target
350
- Wants=network-online.target
351
- [Service]
352
- Type=forking
353
- User=${user}
354
- WorkingDirectory=${workspace}
355
- ExecStart=${workspace}/startAll.sh
356
- ExecStop=${workspace}/stopAll.sh
357
- Restart=on-failure
358
- RestartSec=10
359
- [Install]
360
- WantedBy=multi-user.target
361
- `;
362
- try {
363
- fs.writeFileSync('/tmp/sentinel.service', content);
364
- execSync(`sudo mv /tmp/sentinel.service ${svc}`);
365
- execSync('sudo systemctl daemon-reload');
366
- execSync('sudo systemctl enable sentinel');
367
- ok('sentinel.service enabled');
368
- } catch (e) {
369
- warn(`Could not write systemd service (need sudo): ${e.message}`);
370
- warn(`Manually create ${svc} to auto-start on reboot`);
371
- }
372
- }