@misterhuydo/sentinel 1.4.9 → 1.4.11
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/views/fb78ac_upgrade.js +100 -0
- package/lib/generate.js +2 -2
- package/lib/upgrade.js +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
function ensureClaudePermissions() {
|
|
2
|
+
const settingsPath = require('path').join(require('os').homedir(), '.claude', 'settings.json');
|
|
3
|
+
const required = ['Read(**)', 'Write(**)', 'Edit(**)', 'Bash(**)'];
|
|
4
|
+
let settings = {};
|
|
5
|
+
try {
|
|
6
|
+
if (fs.existsSync(settingsPath)) {
|
|
7
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
8
|
+
}
|
|
9
|
+
} catch (e) {
|
|
10
|
+
warn('Could not read ' + settingsPath + ': ' + e.message);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!settings.permissions) settings.permissions = {};
|
|
14
|
+
if (!Array.isArray(settings.permissions.allow)) settings.permissions.allow = [];
|
|
15
|
+
const existing = new Set(settings.permissions.allow);
|
|
16
|
+
const added = [];
|
|
17
|
+
for (const perm of required) {
|
|
18
|
+
if (!existing.has(perm)) {
|
|
19
|
+
settings.permissions.allow.push(perm);
|
|
20
|
+
added.push(perm);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (added.length === 0) {
|
|
24
|
+
ok('Claude Code permissions already configured');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const path = require('path');
|
|
29
|
+
fs.ensureDirSync(path.dirname(settingsPath));
|
|
30
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
31
|
+
ok('Claude Code permissions patched: ' + added.join(', '));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
warn('Could not write ' + settingsPath + ': ' + e.message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
'use strict';
|
|
37
|
+
const fs = require('fs-extra');
|
|
38
|
+
const path = require('path');
|
|
39
|
+
const os = require('os');
|
|
40
|
+
const { execSync, spawnSync } = require('child_process');
|
|
41
|
+
const chalk = require('chalk');
|
|
42
|
+
const ok = msg => console.log(chalk.green(' ✔'), msg);
|
|
43
|
+
const info = msg => console.log(chalk.cyan(' →'), msg);
|
|
44
|
+
const warn = msg => console.log(chalk.yellow(' ⚠'), msg);
|
|
45
|
+
module.exports = async function upgrade() {
|
|
46
|
+
const { version: current } = require('../package.json');
|
|
47
|
+
const defaultWorkspace = path.join(os.homedir(), 'sentinel');
|
|
48
|
+
const codeDir = path.join(defaultWorkspace, 'code');
|
|
49
|
+
if (!fs.existsSync(codeDir)) {
|
|
50
|
+
console.error(chalk.red(' ✖ Sentinel code directory not found at ' + codeDir));
|
|
51
|
+
console.error(' Run: sentinel init');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
info(`Current version: ${current}`);
|
|
55
|
+
info('Installing latest @misterhuydo/sentinel...');
|
|
56
|
+
const install = spawnSync('npm', ['install', '-g', '@misterhuydo/sentinel@latest', '--prefer-online'], { stdio: 'inherit' });
|
|
57
|
+
if (install.status !== 0) {
|
|
58
|
+
console.error(chalk.red(' ✖ npm install failed'));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
info('Upgrading @misterhuydo/cairn-mcp...');
|
|
62
|
+
spawnSync('npm', ['install', '-g', '@misterhuydo/cairn-mcp@latest', '--prefer-online'], { stdio: 'inherit' });
|
|
63
|
+
ok('@misterhuydo/cairn-mcp upgraded');
|
|
64
|
+
info('Upgrading @anthropic-ai/claude-code...');
|
|
65
|
+
spawnSync('npm', ['install', '-g', '@anthropic-ai/claude-code@latest', '--prefer-online'], { stdio: 'inherit' });
|
|
66
|
+
ok('@anthropic-ai/claude-code upgraded');
|
|
67
|
+
const npmRoot = execSync('npm root -g', { encoding: 'utf8' }).trim();
|
|
68
|
+
const pkgDir = path.join(npmRoot, '@misterhuydo', 'sentinel');
|
|
69
|
+
const src = path.join(pkgDir, 'python');
|
|
70
|
+
if (!fs.existsSync(src)) {
|
|
71
|
+
console.error(chalk.red(' ✖ Bundled Python source not found in installed package'));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
info('Deploying Python source...');
|
|
75
|
+
fs.copySync(src, codeDir, { overwrite: true });
|
|
76
|
+
const { execSync: _exec } = require('child_process');
|
|
77
|
+
try { _exec(`find "${codeDir}" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true`); } catch (_) {}
|
|
78
|
+
const scriptsDir = path.join(codeDir, 'scripts');
|
|
79
|
+
if (fs.existsSync(scriptsDir)) {
|
|
80
|
+
const shFiles = fs.readdirSync(scriptsDir)
|
|
81
|
+
.filter(f => f.endsWith('.sh'))
|
|
82
|
+
.map(f => path.join(scriptsDir, f));
|
|
83
|
+
if (shFiles.length) spawnSync('chmod', ['+x', ...shFiles], { stdio: 'inherit' });
|
|
84
|
+
}
|
|
85
|
+
ok('Python source updated');
|
|
86
|
+
info('Patching Claude Code permissions…');
|
|
87
|
+
ensureClaudePermissions();
|
|
88
|
+
const { version: latest } = require(path.join(pkgDir, 'package.json'));
|
|
89
|
+
ok(`Upgraded: ${current} → ${latest}`);
|
|
90
|
+
const startAll = path.join(defaultWorkspace, 'startAll.sh');
|
|
91
|
+
const stopAll = path.join(defaultWorkspace, 'stopAll.sh');
|
|
92
|
+
if (fs.existsSync(stopAll) && fs.existsSync(startAll)) {
|
|
93
|
+
info('Restarting Sentinel...');
|
|
94
|
+
spawnSync('bash', [stopAll], { stdio: 'inherit' });
|
|
95
|
+
spawnSync('bash', [startAll], { stdio: 'inherit' });
|
|
96
|
+
ok('Sentinel restarted');
|
|
97
|
+
} else {
|
|
98
|
+
warn('No startAll.sh found — restart manually');
|
|
99
|
+
}
|
|
100
|
+
};
|
package/lib/generate.js
CHANGED
|
@@ -55,7 +55,7 @@ WORKSPACE="$(dirname "$DIR")"
|
|
|
55
55
|
_claude_pro=true
|
|
56
56
|
for _conf in "$WORKSPACE/sentinel.properties" "$DIR/config/sentinel.properties"; do
|
|
57
57
|
if [[ -f "$_conf" ]]; then
|
|
58
|
-
_val=$(grep -iE "^CLAUDE_PRO_FOR_TASKS[[:space:]]*=" "$_conf" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d ' ' | tr '[:upper:]' '[:lower:]')
|
|
58
|
+
_val=$(grep -iE "^CLAUDE_PRO_FOR_TASKS[[:space:]]*=" "$_conf" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d ' ' | tr '[:upper:]' '[:lower:]' || true)
|
|
59
59
|
[[ -n "$_val" ]] && _claude_pro="$_val"
|
|
60
60
|
fi
|
|
61
61
|
done
|
|
@@ -195,7 +195,7 @@ WORKSPACE="$(dirname "$DIR")"
|
|
|
195
195
|
_claude_pro=true
|
|
196
196
|
for _conf in "$WORKSPACE/sentinel.properties" "$DIR/config/sentinel.properties"; do
|
|
197
197
|
if [[ -f "$_conf" ]]; then
|
|
198
|
-
_val=$(grep -iE "^CLAUDE_PRO_FOR_TASKS[[:space:]]*=" "$_conf" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d ' ' | tr '[:upper:]' '[:lower:]')
|
|
198
|
+
_val=$(grep -iE "^CLAUDE_PRO_FOR_TASKS[[:space:]]*=" "$_conf" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d ' ' | tr '[:upper:]' '[:lower:]' || true)
|
|
199
199
|
[[ -n "$_val" ]] && _claude_pro="$_val"
|
|
200
200
|
fi
|
|
201
201
|
done
|
package/lib/upgrade.js
CHANGED
|
@@ -97,6 +97,25 @@ module.exports = async function upgrade() {
|
|
|
97
97
|
const { version: latest } = require(path.join(pkgDir, 'package.json'));
|
|
98
98
|
ok(`Upgraded: ${current} → ${latest}`);
|
|
99
99
|
|
|
100
|
+
// Regenerate start.sh / stop.sh for all existing projects so they pick up template changes
|
|
101
|
+
info('Regenerating project scripts...');
|
|
102
|
+
const { generateProjectScripts } = require('./generate');
|
|
103
|
+
const pythonBin = fs.existsSync('/usr/bin/python3') ? '/usr/bin/python3' : 'python3';
|
|
104
|
+
let regenerated = 0;
|
|
105
|
+
try {
|
|
106
|
+
const entries = fs.readdirSync(defaultWorkspace, { withFileTypes: true });
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
if (!entry.isDirectory()) continue;
|
|
109
|
+
const projectDir = path.join(defaultWorkspace, entry.name);
|
|
110
|
+
if (!fs.existsSync(path.join(projectDir, 'config', 'sentinel.properties'))) continue;
|
|
111
|
+
generateProjectScripts(projectDir, codeDir, pythonBin);
|
|
112
|
+
regenerated++;
|
|
113
|
+
}
|
|
114
|
+
ok(`Project scripts regenerated (${regenerated} project(s))`);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
warn('Could not regenerate project scripts: ' + e.message);
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
const startAll = path.join(defaultWorkspace, 'startAll.sh');
|
|
101
120
|
const stopAll = path.join(defaultWorkspace, 'stopAll.sh');
|
|
102
121
|
if (fs.existsSync(stopAll) && fs.existsSync(startAll)) {
|