delimit-cli 3.6.2 → 3.6.4
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 +125 -30
- package/gateway/ai/governance.py +4 -0
- package/package.json +11 -2
- package/.dockerignore +0 -7
- package/.github/workflows/api-governance.yml +0 -43
- package/.github/workflows/ci.yml +0 -22
- package/CODE_OF_CONDUCT.md +0 -48
- package/CONTRIBUTING.md +0 -67
- package/Dockerfile +0 -9
- package/SECURITY.md +0 -42
- package/adapters/codex-forge.js +0 -107
- package/adapters/codex-jamsons.js +0 -142
- package/adapters/codex-security.js +0 -94
- package/adapters/gemini-forge.js +0 -120
- package/adapters/gemini-jamsons.js +0 -152
- package/delimit.yml +0 -19
- package/glama.json +0 -1
- package/hooks/evidence-status.sh +0 -12
- package/hooks/git/commit-msg +0 -4
- package/hooks/git/pre-commit +0 -4
- package/hooks/git/pre-push +0 -4
- package/hooks/install-hooks.sh +0 -583
- package/hooks/message-auth-hook.js +0 -9
- package/hooks/message-governance-hook.js +0 -9
- package/hooks/models/claude-post.js +0 -4
- package/hooks/models/claude-pre.js +0 -4
- package/hooks/models/codex-post.js +0 -4
- package/hooks/models/codex-pre.js +0 -4
- package/hooks/models/cursor-post.js +0 -4
- package/hooks/models/cursor-pre.js +0 -4
- package/hooks/models/gemini-post.js +0 -4
- package/hooks/models/gemini-pre.js +0 -4
- package/hooks/models/openai-post.js +0 -4
- package/hooks/models/openai-pre.js +0 -4
- package/hooks/models/windsurf-post.js +0 -4
- package/hooks/models/windsurf-pre.js +0 -4
- package/hooks/models/xai-post.js +0 -4
- package/hooks/models/xai-pre.js +0 -4
- package/hooks/post-bash-hook.js +0 -13
- package/hooks/post-mcp-hook.js +0 -13
- package/hooks/post-response-hook.js +0 -4
- package/hooks/post-tool-hook.js +0 -126
- package/hooks/post-write-hook.js +0 -13
- package/hooks/pre-bash-hook.js +0 -30
- package/hooks/pre-mcp-hook.js +0 -13
- package/hooks/pre-read-hook.js +0 -13
- package/hooks/pre-search-hook.js +0 -13
- package/hooks/pre-submit-hook.js +0 -4
- package/hooks/pre-task-hook.js +0 -13
- package/hooks/pre-tool-hook.js +0 -121
- package/hooks/pre-web-hook.js +0 -13
- package/hooks/pre-write-hook.js +0 -31
- package/hooks/test-hooks.sh +0 -12
- package/hooks/update-delimit.sh +0 -6
- package/scripts/infect.js +0 -128
- package/tests/setup-onboarding.test.js +0 -147
package/hooks/install-hooks.sh
DELETED
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
################################################################################
|
|
4
|
-
# Delimit™ Hooks Seamless Installer
|
|
5
|
-
# Automatically installs all governance hooks on user machines
|
|
6
|
-
################################################################################
|
|
7
|
-
|
|
8
|
-
set -e
|
|
9
|
-
|
|
10
|
-
# Colors for output
|
|
11
|
-
RED='\033[0;31m'
|
|
12
|
-
GREEN='\033[0;32m'
|
|
13
|
-
YELLOW='\033[1;33m'
|
|
14
|
-
BLUE='\033[0;34m'
|
|
15
|
-
NC='\033[0m' # No Color
|
|
16
|
-
|
|
17
|
-
# Configuration
|
|
18
|
-
DELIMIT_HOME="${HOME}/.delimit"
|
|
19
|
-
CLAUDE_HOME="${HOME}/.claude"
|
|
20
|
-
CLAUDE_CONFIG_PATHS=(
|
|
21
|
-
"${HOME}/Library/Application Support/Claude"
|
|
22
|
-
"${HOME}/.config/claude"
|
|
23
|
-
"${CLAUDE_HOME}"
|
|
24
|
-
)
|
|
25
|
-
NPM_DELIMIT="/home/delimit/npm-delimit"
|
|
26
|
-
|
|
27
|
-
echo -e "${BLUE}╔══════════════════════════════════════════════╗${NC}"
|
|
28
|
-
echo -e "${BLUE}║ Delimit™ Hooks Installer v2.0 ║${NC}"
|
|
29
|
-
echo -e "${BLUE}╚══════════════════════════════════════════════╝${NC}"
|
|
30
|
-
echo
|
|
31
|
-
|
|
32
|
-
# Function to find Claude config directory
|
|
33
|
-
find_claude_config() {
|
|
34
|
-
for path in "${CLAUDE_CONFIG_PATHS[@]}"; do
|
|
35
|
-
if [ -d "$path" ]; then
|
|
36
|
-
echo "$path"
|
|
37
|
-
return 0
|
|
38
|
-
fi
|
|
39
|
-
done
|
|
40
|
-
return 1
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
# Function to create directory structure
|
|
44
|
-
create_directories() {
|
|
45
|
-
echo -e "${YELLOW}Creating directory structure...${NC}"
|
|
46
|
-
|
|
47
|
-
# Delimit directories
|
|
48
|
-
mkdir -p "${DELIMIT_HOME}/hooks"
|
|
49
|
-
mkdir -p "${DELIMIT_HOME}/evidence"
|
|
50
|
-
mkdir -p "${DELIMIT_HOME}/audit"
|
|
51
|
-
mkdir -p "${DELIMIT_HOME}/credentials"
|
|
52
|
-
mkdir -p "${DELIMIT_HOME}/config"
|
|
53
|
-
|
|
54
|
-
# NPM Delimit hook directories
|
|
55
|
-
mkdir -p "${NPM_DELIMIT}/hooks/models"
|
|
56
|
-
mkdir -p "${NPM_DELIMIT}/hooks/git"
|
|
57
|
-
|
|
58
|
-
echo -e "${GREEN}✓ Directories created${NC}"
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Function to create hook scripts
|
|
62
|
-
create_hook_scripts() {
|
|
63
|
-
echo -e "${YELLOW}Creating hook scripts...${NC}"
|
|
64
|
-
|
|
65
|
-
# Create pre-bash hook
|
|
66
|
-
cat > "${NPM_DELIMIT}/hooks/pre-bash-hook.js" << 'EOF'
|
|
67
|
-
#!/usr/bin/env node
|
|
68
|
-
const axios = require('axios');
|
|
69
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
70
|
-
|
|
71
|
-
async function validateBash(params) {
|
|
72
|
-
const riskyCommands = ['rm -rf', 'chmod 777', 'sudo', '> /dev/sda'];
|
|
73
|
-
const command = params.command || '';
|
|
74
|
-
|
|
75
|
-
if (riskyCommands.some(cmd => command.includes(cmd))) {
|
|
76
|
-
console.error('[DELIMIT] ⚠️ Risky command detected');
|
|
77
|
-
try {
|
|
78
|
-
const { data } = await axios.post(`${AGENT_URL}/evaluate`, {
|
|
79
|
-
action: 'bash_command',
|
|
80
|
-
command: command,
|
|
81
|
-
riskLevel: 'high'
|
|
82
|
-
});
|
|
83
|
-
if (data.action === 'block') {
|
|
84
|
-
console.error('[DELIMIT] ❌ Command blocked by governance policy');
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
} catch (e) {
|
|
88
|
-
console.warn('[DELIMIT] Governance agent not available');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (require.main === module) {
|
|
94
|
-
const params = JSON.parse(process.argv[2] || '{}');
|
|
95
|
-
validateBash(params);
|
|
96
|
-
}
|
|
97
|
-
EOF
|
|
98
|
-
chmod +x "${NPM_DELIMIT}/hooks/pre-bash-hook.js"
|
|
99
|
-
|
|
100
|
-
# Create pre-write hook
|
|
101
|
-
cat > "${NPM_DELIMIT}/hooks/pre-write-hook.js" << 'EOF'
|
|
102
|
-
#!/usr/bin/env node
|
|
103
|
-
const axios = require('axios');
|
|
104
|
-
const path = require('path');
|
|
105
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
106
|
-
|
|
107
|
-
async function validateWrite(params) {
|
|
108
|
-
const filePath = params.file_path || params.path || '';
|
|
109
|
-
const sensitivePaths = ['/etc/', '/.ssh/', '/.aws/', '/credentials/'];
|
|
110
|
-
|
|
111
|
-
if (sensitivePaths.some(p => filePath.includes(p))) {
|
|
112
|
-
console.warn('[DELIMIT] ⚠️ Sensitive file operation detected');
|
|
113
|
-
try {
|
|
114
|
-
const { data } = await axios.post(`${AGENT_URL}/evaluate`, {
|
|
115
|
-
action: 'file_write',
|
|
116
|
-
path: filePath,
|
|
117
|
-
riskLevel: 'critical'
|
|
118
|
-
});
|
|
119
|
-
if (data.action === 'block') {
|
|
120
|
-
console.error('[DELIMIT] ❌ File operation blocked by governance policy');
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
} catch (e) {
|
|
124
|
-
console.warn('[DELIMIT] Governance agent not available');
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (require.main === module) {
|
|
130
|
-
const params = JSON.parse(process.argv[2] || '{}');
|
|
131
|
-
validateWrite(params);
|
|
132
|
-
}
|
|
133
|
-
EOF
|
|
134
|
-
chmod +x "${NPM_DELIMIT}/hooks/pre-write-hook.js"
|
|
135
|
-
|
|
136
|
-
# Create more hook scripts
|
|
137
|
-
for hook in pre-read pre-search pre-web pre-task pre-mcp post-write post-bash post-mcp; do
|
|
138
|
-
cat > "${NPM_DELIMIT}/hooks/${hook}-hook.js" << EOF
|
|
139
|
-
#!/usr/bin/env node
|
|
140
|
-
// Delimit ${hook} hook
|
|
141
|
-
const axios = require('axios');
|
|
142
|
-
const AGENT_URL = \`http://127.0.0.1:\${process.env.DELIMIT_AGENT_PORT || 7823}\`;
|
|
143
|
-
|
|
144
|
-
async function process() {
|
|
145
|
-
console.log('[DELIMIT] ${hook} hook activated');
|
|
146
|
-
// Hook implementation
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (require.main === module) {
|
|
150
|
-
process();
|
|
151
|
-
}
|
|
152
|
-
EOF
|
|
153
|
-
chmod +x "${NPM_DELIMIT}/hooks/${hook}-hook.js"
|
|
154
|
-
done
|
|
155
|
-
|
|
156
|
-
echo -e "${GREEN}✓ Hook scripts created${NC}"
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
# Function to create Git hooks
|
|
160
|
-
create_git_hooks() {
|
|
161
|
-
echo -e "${YELLOW}Creating Git hooks...${NC}"
|
|
162
|
-
|
|
163
|
-
# Pre-commit hook
|
|
164
|
-
cat > "${NPM_DELIMIT}/hooks/git/pre-commit" << 'EOF'
|
|
165
|
-
#!/bin/bash
|
|
166
|
-
# Delimit pre-commit hook
|
|
167
|
-
echo "[DELIMIT] Running pre-commit governance check..."
|
|
168
|
-
node /home/delimit/npm-delimit/bin/delimit-cli.js hook pre-commit
|
|
169
|
-
EOF
|
|
170
|
-
chmod +x "${NPM_DELIMIT}/hooks/git/pre-commit"
|
|
171
|
-
|
|
172
|
-
# Pre-push hook
|
|
173
|
-
cat > "${NPM_DELIMIT}/hooks/git/pre-push" << 'EOF'
|
|
174
|
-
#!/bin/bash
|
|
175
|
-
# Delimit pre-push hook
|
|
176
|
-
echo "[DELIMIT] Running pre-push governance check..."
|
|
177
|
-
node /home/delimit/npm-delimit/bin/delimit-cli.js hook pre-push
|
|
178
|
-
EOF
|
|
179
|
-
chmod +x "${NPM_DELIMIT}/hooks/git/pre-push"
|
|
180
|
-
|
|
181
|
-
# Commit-msg hook
|
|
182
|
-
cat > "${NPM_DELIMIT}/hooks/git/commit-msg" << 'EOF'
|
|
183
|
-
#!/bin/bash
|
|
184
|
-
# Delimit commit-msg hook
|
|
185
|
-
echo "[DELIMIT] Validating commit message..."
|
|
186
|
-
node /home/delimit/npm-delimit/bin/delimit-cli.js hook commit-msg "$1"
|
|
187
|
-
EOF
|
|
188
|
-
chmod +x "${NPM_DELIMIT}/hooks/git/commit-msg"
|
|
189
|
-
|
|
190
|
-
echo -e "${GREEN}✓ Git hooks created${NC}"
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
# Function to setup platform-specific configurations
|
|
194
|
-
setup_platform_configs() {
|
|
195
|
-
echo -e "${YELLOW}Setting up platform-specific configurations...${NC}"
|
|
196
|
-
|
|
197
|
-
# Use the platform adapter to set up all configurations
|
|
198
|
-
cat > /tmp/setup-platforms.js << 'EOF'
|
|
199
|
-
const PlatformAdapter = require('/home/delimit/npm-delimit/lib/platform-adapters');
|
|
200
|
-
const adapter = new PlatformAdapter();
|
|
201
|
-
|
|
202
|
-
(async () => {
|
|
203
|
-
const results = await adapter.setupAllPlatforms();
|
|
204
|
-
console.log('Platform configurations created:', Object.keys(results).join(', '));
|
|
205
|
-
})();
|
|
206
|
-
EOF
|
|
207
|
-
|
|
208
|
-
node /tmp/setup-platforms.js
|
|
209
|
-
rm /tmp/setup-platforms.js
|
|
210
|
-
|
|
211
|
-
echo -e "${GREEN}✓ Platform configurations created${NC}"
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
# Function to create model hooks
|
|
215
|
-
create_model_hooks() {
|
|
216
|
-
echo -e "${YELLOW}Creating model-specific hooks...${NC}"
|
|
217
|
-
|
|
218
|
-
models=("claude" "codex" "gemini" "openai" "cursor" "windsurf" "xai")
|
|
219
|
-
|
|
220
|
-
for model in "${models[@]}"; do
|
|
221
|
-
# Pre-request hook
|
|
222
|
-
cat > "${NPM_DELIMIT}/hooks/models/${model}-pre.js" << EOF
|
|
223
|
-
#!/usr/bin/env node
|
|
224
|
-
// Delimit ${model} pre-request hook
|
|
225
|
-
console.log('[DELIMIT] ${model} pre-request validation');
|
|
226
|
-
// Model-specific validation logic
|
|
227
|
-
EOF
|
|
228
|
-
chmod +x "${NPM_DELIMIT}/hooks/models/${model}-pre.js"
|
|
229
|
-
|
|
230
|
-
# Post-response hook
|
|
231
|
-
cat > "${NPM_DELIMIT}/hooks/models/${model}-post.js" << EOF
|
|
232
|
-
#!/usr/bin/env node
|
|
233
|
-
// Delimit ${model} post-response hook
|
|
234
|
-
console.log('[DELIMIT] ${model} response processing');
|
|
235
|
-
// Model-specific response processing
|
|
236
|
-
EOF
|
|
237
|
-
chmod +x "${NPM_DELIMIT}/hooks/models/${model}-post.js"
|
|
238
|
-
done
|
|
239
|
-
|
|
240
|
-
echo -e "${GREEN}✓ Model hooks created${NC}"
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
# Function to install Claude hooks
|
|
244
|
-
install_claude_hooks() {
|
|
245
|
-
echo -e "${YELLOW}Installing Claude Code hooks...${NC}"
|
|
246
|
-
|
|
247
|
-
CLAUDE_CONFIG=$(find_claude_config)
|
|
248
|
-
if [ -z "$CLAUDE_CONFIG" ]; then
|
|
249
|
-
echo -e "${YELLOW}⚠️ Claude config directory not found${NC}"
|
|
250
|
-
echo "Creating at ${HOME}/.claude..."
|
|
251
|
-
CLAUDE_CONFIG="${HOME}/.claude"
|
|
252
|
-
mkdir -p "$CLAUDE_CONFIG"
|
|
253
|
-
fi
|
|
254
|
-
|
|
255
|
-
# Create hooks directory
|
|
256
|
-
mkdir -p "${CLAUDE_CONFIG}/hooks"
|
|
257
|
-
|
|
258
|
-
# Copy hooks configuration
|
|
259
|
-
if [ -f "/root/.claude/hooks/hooks.json" ]; then
|
|
260
|
-
cp "/root/.claude/hooks/hooks.json" "${CLAUDE_CONFIG}/hooks/hooks.json"
|
|
261
|
-
echo -e "${GREEN}✓ Hooks configuration installed${NC}"
|
|
262
|
-
fi
|
|
263
|
-
|
|
264
|
-
# Update MCP configuration
|
|
265
|
-
MCP_CONFIG="${CLAUDE_CONFIG}/claude_desktop_config.json"
|
|
266
|
-
if [ ! -f "$MCP_CONFIG" ]; then
|
|
267
|
-
# Try alternate location
|
|
268
|
-
MCP_CONFIG="${CLAUDE_CONFIG}/../claude_desktop_config.json"
|
|
269
|
-
fi
|
|
270
|
-
|
|
271
|
-
if [ -f "/root/Library/Application Support/Claude/claude_desktop_config.json" ]; then
|
|
272
|
-
cp "/root/Library/Application Support/Claude/claude_desktop_config.json" "$MCP_CONFIG"
|
|
273
|
-
echo -e "${GREEN}✓ MCP configuration updated${NC}"
|
|
274
|
-
fi
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
# Function to configure Git
|
|
278
|
-
configure_git() {
|
|
279
|
-
echo -e "${YELLOW}Configuring Git hooks...${NC}"
|
|
280
|
-
|
|
281
|
-
# Set global hooks path
|
|
282
|
-
git config --global core.hooksPath "${NPM_DELIMIT}/hooks/git"
|
|
283
|
-
|
|
284
|
-
echo -e "${GREEN}✓ Git configured to use Delimit hooks${NC}"
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
# Function to install MCP servers with proper naming
|
|
288
|
-
install_mcp_servers() {
|
|
289
|
-
echo -e "${YELLOW}Installing and updating MCP servers...${NC}"
|
|
290
|
-
|
|
291
|
-
# Install FastMCP for compatibility
|
|
292
|
-
pip3 install fastmcp || echo -e "${RED}⚠ FastMCP installation failed${NC}"
|
|
293
|
-
|
|
294
|
-
# Install delimit packages with correct names
|
|
295
|
-
local packages=(
|
|
296
|
-
"delimit-governance:delimit-governance"
|
|
297
|
-
"delimit-vault:delimit-vault"
|
|
298
|
-
"delimit-memory:delimit-memory"
|
|
299
|
-
"delimit-deploy:delimit-deploy"
|
|
300
|
-
"wireintel:delimit-intel"
|
|
301
|
-
)
|
|
302
|
-
|
|
303
|
-
for package in "${packages[@]}"; do
|
|
304
|
-
IFS=':' read -r old_name new_name <<< "$package"
|
|
305
|
-
package_dir="/home/delimit/.delimit_suite/packages/${old_name}"
|
|
306
|
-
|
|
307
|
-
if [ -d "$package_dir" ]; then
|
|
308
|
-
echo -e " ${BLUE}Installing $new_name...${NC}"
|
|
309
|
-
|
|
310
|
-
# Update pyproject.toml if needed
|
|
311
|
-
if [ -f "$package_dir/pyproject.toml" ]; then
|
|
312
|
-
sed -i "s/name = \"$old_name\"/name = \"$new_name\"/" "$package_dir/pyproject.toml" 2>/dev/null || true
|
|
313
|
-
sed -i "s/name = \"${old_name}-mcp\"/name = \"$new_name\"/" "$package_dir/pyproject.toml" 2>/dev/null || true
|
|
314
|
-
fi
|
|
315
|
-
|
|
316
|
-
# Install package
|
|
317
|
-
(cd "$package_dir" && pip3 install -e . >/dev/null 2>&1) && \
|
|
318
|
-
echo -e " ${GREEN}✓ $new_name installed${NC}" || \
|
|
319
|
-
echo -e " ${RED}✗ $new_name failed${NC}"
|
|
320
|
-
fi
|
|
321
|
-
done
|
|
322
|
-
|
|
323
|
-
# Fix common directory issues
|
|
324
|
-
if [ -L "/var/lib/delimit" ] && [ ! -d "/var/lib/delimit/wireintel" ]; then
|
|
325
|
-
echo -e " ${BLUE}Fixing directory permissions...${NC}"
|
|
326
|
-
sudo rm -f /var/lib/delimit 2>/dev/null || true
|
|
327
|
-
sudo mkdir -p /var/lib/delimit/wireintel 2>/dev/null || true
|
|
328
|
-
sudo ln -sf /var/lib/delimit /var/lib/delimit 2>/dev/null || true
|
|
329
|
-
echo -e " ${GREEN}✓ Directory structure fixed${NC}"
|
|
330
|
-
fi
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
# Function to troubleshoot MCP connections
|
|
334
|
-
troubleshoot_mcp() {
|
|
335
|
-
echo -e "${YELLOW}Running MCP diagnostics...${NC}"
|
|
336
|
-
|
|
337
|
-
local failed_servers=()
|
|
338
|
-
|
|
339
|
-
# Test Python servers
|
|
340
|
-
for server_dir in /home/delimit/.delimit_suite/packages/*/; do
|
|
341
|
-
if [ -f "$server_dir/server.py" ] || [ -f "$server_dir/run_mcp.py" ]; then
|
|
342
|
-
server_name=$(basename "$server_dir")
|
|
343
|
-
echo -e " ${BLUE}Testing $server_name...${NC}"
|
|
344
|
-
|
|
345
|
-
# Test server startup
|
|
346
|
-
if (cd "$server_dir" && timeout 5 python3 server.py 2>/dev/null) || \
|
|
347
|
-
(cd "$server_dir" && timeout 5 python3 run_mcp.py 2>/dev/null); then
|
|
348
|
-
echo -e " ${GREEN}✓ $server_name OK${NC}"
|
|
349
|
-
else
|
|
350
|
-
echo -e " ${RED}✗ $server_name failed${NC}"
|
|
351
|
-
failed_servers+=("$server_name")
|
|
352
|
-
fi
|
|
353
|
-
fi
|
|
354
|
-
done
|
|
355
|
-
|
|
356
|
-
# Test NPM servers
|
|
357
|
-
if command -v npx >/dev/null; then
|
|
358
|
-
echo -e " ${BLUE}Testing codex...${NC}"
|
|
359
|
-
if timeout 5 npx -y codex-mcp-server --version >/dev/null 2>&1; then
|
|
360
|
-
echo -e " ${GREEN}✓ codex OK${NC}"
|
|
361
|
-
else
|
|
362
|
-
echo -e " ${RED}✗ codex failed${NC}"
|
|
363
|
-
failed_servers+=("codex")
|
|
364
|
-
fi
|
|
365
|
-
fi
|
|
366
|
-
|
|
367
|
-
if [ ${#failed_servers[@]} -gt 0 ]; then
|
|
368
|
-
echo -e "\n${RED}Failed servers: ${failed_servers[*]}${NC}"
|
|
369
|
-
echo -e "${YELLOW}Run with --fix-mcp to attempt repairs${NC}"
|
|
370
|
-
return 1
|
|
371
|
-
else
|
|
372
|
-
echo -e "\n${GREEN}✓ All MCP servers operational${NC}"
|
|
373
|
-
return 0
|
|
374
|
-
fi
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
# Function to create test scripts
|
|
378
|
-
create_test_scripts() {
|
|
379
|
-
echo -e "${YELLOW}Creating test scripts...${NC}"
|
|
380
|
-
|
|
381
|
-
# Test hooks script
|
|
382
|
-
cat > "${NPM_DELIMIT}/hooks/test-hooks.sh" << 'EOF'
|
|
383
|
-
#!/bin/bash
|
|
384
|
-
echo "Testing Delimit hooks..."
|
|
385
|
-
|
|
386
|
-
# Test pre-bash hook
|
|
387
|
-
echo "Testing bash hook..."
|
|
388
|
-
node /home/delimit/npm-delimit/hooks/pre-bash-hook.js '{"command":"ls"}'
|
|
389
|
-
|
|
390
|
-
# Test pre-write hook
|
|
391
|
-
echo "Testing write hook..."
|
|
392
|
-
node /home/delimit/npm-delimit/hooks/pre-write-hook.js '{"file_path":"/tmp/test.txt"}'
|
|
393
|
-
|
|
394
|
-
echo "✓ Hook tests complete"
|
|
395
|
-
EOF
|
|
396
|
-
chmod +x "${NPM_DELIMIT}/hooks/test-hooks.sh"
|
|
397
|
-
|
|
398
|
-
# Update script
|
|
399
|
-
cat > "${NPM_DELIMIT}/hooks/update-delimit.sh" << 'EOF'
|
|
400
|
-
#!/bin/bash
|
|
401
|
-
echo "Updating Delimit..."
|
|
402
|
-
cd /home/delimit/npm-delimit
|
|
403
|
-
git pull
|
|
404
|
-
npm install
|
|
405
|
-
echo "✓ Delimit updated"
|
|
406
|
-
EOF
|
|
407
|
-
chmod +x "${NPM_DELIMIT}/hooks/update-delimit.sh"
|
|
408
|
-
|
|
409
|
-
# Evidence status script
|
|
410
|
-
cat > "${NPM_DELIMIT}/hooks/evidence-status.sh" << 'EOF'
|
|
411
|
-
#!/bin/bash
|
|
412
|
-
echo "Evidence Collection Status"
|
|
413
|
-
echo "========================="
|
|
414
|
-
evidence_dir="${HOME}/.delimit/evidence"
|
|
415
|
-
if [ -d "$evidence_dir" ]; then
|
|
416
|
-
count=$(find "$evidence_dir" -name "*.json" 2>/dev/null | wc -l)
|
|
417
|
-
echo "Evidence files: $count"
|
|
418
|
-
echo "Latest evidence:"
|
|
419
|
-
ls -lt "$evidence_dir" 2>/dev/null | head -5
|
|
420
|
-
else
|
|
421
|
-
echo "No evidence collected yet"
|
|
422
|
-
fi
|
|
423
|
-
EOF
|
|
424
|
-
chmod +x "${NPM_DELIMIT}/hooks/evidence-status.sh"
|
|
425
|
-
|
|
426
|
-
echo -e "${GREEN}✓ Test scripts created${NC}"
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
# Function to create message hooks
|
|
430
|
-
create_message_hooks() {
|
|
431
|
-
echo -e "${YELLOW}Creating message hooks...${NC}"
|
|
432
|
-
|
|
433
|
-
# Governance message hook
|
|
434
|
-
cat > "${NPM_DELIMIT}/hooks/message-governance-hook.js" << 'EOF'
|
|
435
|
-
#!/usr/bin/env node
|
|
436
|
-
// Triggers governance check on keywords
|
|
437
|
-
const keywords = ['governance', 'policy', 'compliance', 'audit'];
|
|
438
|
-
const message = process.argv[2] || '';
|
|
439
|
-
|
|
440
|
-
if (keywords.some(k => message.toLowerCase().includes(k))) {
|
|
441
|
-
console.log('[DELIMIT] Governance check triggered');
|
|
442
|
-
require('child_process').execSync('delimit status --verbose');
|
|
443
|
-
}
|
|
444
|
-
EOF
|
|
445
|
-
chmod +x "${NPM_DELIMIT}/hooks/message-governance-hook.js"
|
|
446
|
-
|
|
447
|
-
# Auth message hook
|
|
448
|
-
cat > "${NPM_DELIMIT}/hooks/message-auth-hook.js" << 'EOF'
|
|
449
|
-
#!/usr/bin/env node
|
|
450
|
-
// Triggers auth setup on keywords
|
|
451
|
-
const keywords = ['setup credentials', 'github key', 'api key'];
|
|
452
|
-
const message = process.argv[2] || '';
|
|
453
|
-
|
|
454
|
-
if (keywords.some(k => message.toLowerCase().includes(k))) {
|
|
455
|
-
console.log('[DELIMIT] Authentication setup triggered');
|
|
456
|
-
require('child_process').execSync('delimit auth');
|
|
457
|
-
}
|
|
458
|
-
EOF
|
|
459
|
-
chmod +x "${NPM_DELIMIT}/hooks/message-auth-hook.js"
|
|
460
|
-
|
|
461
|
-
echo -e "${GREEN}✓ Message hooks created${NC}"
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
# Function to create submission hooks
|
|
465
|
-
create_submission_hooks() {
|
|
466
|
-
echo -e "${YELLOW}Creating submission hooks...${NC}"
|
|
467
|
-
|
|
468
|
-
# Pre-submit hook
|
|
469
|
-
cat > "${NPM_DELIMIT}/hooks/pre-submit-hook.js" << 'EOF'
|
|
470
|
-
#!/usr/bin/env node
|
|
471
|
-
// Validates before user prompt submission
|
|
472
|
-
console.log('[DELIMIT] Pre-submission validation');
|
|
473
|
-
// Add validation logic here
|
|
474
|
-
EOF
|
|
475
|
-
chmod +x "${NPM_DELIMIT}/hooks/pre-submit-hook.js"
|
|
476
|
-
|
|
477
|
-
# Post-response hook
|
|
478
|
-
cat > "${NPM_DELIMIT}/hooks/post-response-hook.js" << 'EOF'
|
|
479
|
-
#!/usr/bin/env node
|
|
480
|
-
// Processes AI responses
|
|
481
|
-
console.log('[DELIMIT] Processing AI response');
|
|
482
|
-
// Add processing logic here
|
|
483
|
-
EOF
|
|
484
|
-
chmod +x "${NPM_DELIMIT}/hooks/post-response-hook.js"
|
|
485
|
-
|
|
486
|
-
echo -e "${GREEN}✓ Submission hooks created${NC}"
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
# Main installation
|
|
490
|
-
main() {
|
|
491
|
-
echo -e "${BLUE}Starting Delimit hooks installation...${NC}"
|
|
492
|
-
echo
|
|
493
|
-
|
|
494
|
-
# Create directories
|
|
495
|
-
create_directories
|
|
496
|
-
|
|
497
|
-
# Create all hook scripts
|
|
498
|
-
create_hook_scripts
|
|
499
|
-
create_git_hooks
|
|
500
|
-
create_model_hooks
|
|
501
|
-
create_message_hooks
|
|
502
|
-
create_submission_hooks
|
|
503
|
-
create_test_scripts
|
|
504
|
-
|
|
505
|
-
# Setup platform-specific configurations
|
|
506
|
-
setup_platform_configs
|
|
507
|
-
|
|
508
|
-
# Install Claude hooks
|
|
509
|
-
install_claude_hooks
|
|
510
|
-
|
|
511
|
-
# Configure Git
|
|
512
|
-
configure_git
|
|
513
|
-
|
|
514
|
-
# Install and configure MCP servers
|
|
515
|
-
install_mcp_servers
|
|
516
|
-
|
|
517
|
-
# Run MCP diagnostics
|
|
518
|
-
echo
|
|
519
|
-
if troubleshoot_mcp; then
|
|
520
|
-
echo -e "${GREEN}🎉 All systems operational!${NC}"
|
|
521
|
-
else
|
|
522
|
-
echo -e "${YELLOW}⚠ Some MCP servers need attention${NC}"
|
|
523
|
-
fi
|
|
524
|
-
|
|
525
|
-
# Final message
|
|
526
|
-
echo
|
|
527
|
-
echo -e "${GREEN}╔══════════════════════════════════════════════╗${NC}"
|
|
528
|
-
echo -e "${GREEN}║ ✅ Delimit Hooks Installation Complete! ║${NC}"
|
|
529
|
-
echo -e "${GREEN}╚══════════════════════════════════════════════╝${NC}"
|
|
530
|
-
echo
|
|
531
|
-
echo "Installed components:"
|
|
532
|
-
echo " • Pre-tool hooks for all tools"
|
|
533
|
-
echo " • Post-tool evidence collection"
|
|
534
|
-
echo " • Git hooks (pre-commit, pre-push, commit-msg)"
|
|
535
|
-
echo " • Model-specific hooks (Claude, Codex, Gemini, etc.)"
|
|
536
|
-
echo " • Message trigger hooks"
|
|
537
|
-
echo " • 16 slash commands"
|
|
538
|
-
echo
|
|
539
|
-
echo "Test your installation:"
|
|
540
|
-
echo " $ /test-hooks"
|
|
541
|
-
echo " $ /delimit"
|
|
542
|
-
echo " $ /governance"
|
|
543
|
-
echo
|
|
544
|
-
echo -e "${BLUE}Governance is now active!${NC}"
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
# Handle command line arguments
|
|
548
|
-
case "${1:-install}" in
|
|
549
|
-
"install")
|
|
550
|
-
main
|
|
551
|
-
;;
|
|
552
|
-
"mcp-only")
|
|
553
|
-
echo -e "${BLUE}Installing MCP servers only...${NC}"
|
|
554
|
-
install_mcp_servers
|
|
555
|
-
;;
|
|
556
|
-
"troubleshoot"|"test-mcp")
|
|
557
|
-
echo -e "${BLUE}Running MCP diagnostics...${NC}"
|
|
558
|
-
troubleshoot_mcp
|
|
559
|
-
;;
|
|
560
|
-
"fix-mcp")
|
|
561
|
-
echo -e "${BLUE}Fixing MCP servers...${NC}"
|
|
562
|
-
install_mcp_servers
|
|
563
|
-
troubleshoot_mcp
|
|
564
|
-
;;
|
|
565
|
-
"help"|"--help"|"-h")
|
|
566
|
-
echo "Delimit™ Hooks Installer"
|
|
567
|
-
echo
|
|
568
|
-
echo "Usage: $0 [command]"
|
|
569
|
-
echo
|
|
570
|
-
echo "Commands:"
|
|
571
|
-
echo " install Full installation (default)"
|
|
572
|
-
echo " mcp-only Install MCP servers only"
|
|
573
|
-
echo " troubleshoot Run MCP diagnostics"
|
|
574
|
-
echo " fix-mcp Fix MCP server issues"
|
|
575
|
-
echo " help Show this help"
|
|
576
|
-
echo
|
|
577
|
-
;;
|
|
578
|
-
*)
|
|
579
|
-
echo -e "${RED}Unknown command: $1${NC}"
|
|
580
|
-
echo "Run '$0 help' for usage information"
|
|
581
|
-
exit 1
|
|
582
|
-
;;
|
|
583
|
-
esac
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Triggers auth setup on keywords
|
|
3
|
-
const keywords = ['setup credentials', 'github key', 'api key'];
|
|
4
|
-
const message = process.argv[2] || '';
|
|
5
|
-
|
|
6
|
-
if (keywords.some(k => message.toLowerCase().includes(k))) {
|
|
7
|
-
console.log('[DELIMIT] Authentication setup triggered');
|
|
8
|
-
require('child_process').execSync('delimit auth');
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Triggers governance check on keywords
|
|
3
|
-
const keywords = ['governance', 'policy', 'compliance', 'audit'];
|
|
4
|
-
const message = process.argv[2] || '';
|
|
5
|
-
|
|
6
|
-
if (keywords.some(k => message.toLowerCase().includes(k))) {
|
|
7
|
-
console.log('[DELIMIT] Governance check triggered');
|
|
8
|
-
require('child_process').execSync('delimit status --verbose');
|
|
9
|
-
}
|
package/hooks/models/xai-post.js
DELETED
package/hooks/models/xai-pre.js
DELETED