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/post-bash-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit post-bash hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] post-bash hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/post-mcp-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit post-mcp hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] post-mcp hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/post-tool-hook.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Delimit™ Post-Tool Hook
|
|
5
|
-
* Collects evidence and audit information after tool execution
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const axios = require('axios');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
const crypto = require('crypto');
|
|
12
|
-
|
|
13
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
14
|
-
const EVIDENCE_DIR = path.join(process.env.HOME, '.delimit', 'evidence');
|
|
15
|
-
|
|
16
|
-
async function collectEvidence(toolContext) {
|
|
17
|
-
try {
|
|
18
|
-
// Ensure evidence directory exists
|
|
19
|
-
fs.mkdirSync(EVIDENCE_DIR, { recursive: true });
|
|
20
|
-
|
|
21
|
-
// Extract tool information
|
|
22
|
-
const { tool, params, result, cwd, user, exitCode } = toolContext;
|
|
23
|
-
|
|
24
|
-
// Build evidence record
|
|
25
|
-
const evidence = {
|
|
26
|
-
id: crypto.randomBytes(16).toString('hex'),
|
|
27
|
-
timestamp: new Date().toISOString(),
|
|
28
|
-
tool: tool,
|
|
29
|
-
parameters: params,
|
|
30
|
-
result: result,
|
|
31
|
-
cwd: cwd,
|
|
32
|
-
user: user,
|
|
33
|
-
exitCode: exitCode,
|
|
34
|
-
environment: process.env.NODE_ENV || 'development'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Special handling for file operations - capture file state
|
|
38
|
-
if (['Edit', 'Write', 'MultiEdit'].includes(tool)) {
|
|
39
|
-
const filePath = params.file_path || params.path;
|
|
40
|
-
if (filePath && fs.existsSync(filePath)) {
|
|
41
|
-
const stats = fs.statSync(filePath);
|
|
42
|
-
evidence.fileState = {
|
|
43
|
-
path: filePath,
|
|
44
|
-
size: stats.size,
|
|
45
|
-
modified: stats.mtime,
|
|
46
|
-
permissions: stats.mode.toString(8),
|
|
47
|
-
hash: crypto.createHash('sha256')
|
|
48
|
-
.update(fs.readFileSync(filePath))
|
|
49
|
-
.digest('hex')
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Special handling for command execution - capture output
|
|
55
|
-
if (tool === 'Bash') {
|
|
56
|
-
evidence.commandOutput = {
|
|
57
|
-
command: params.command,
|
|
58
|
-
stdout: result?.stdout || '',
|
|
59
|
-
stderr: result?.stderr || '',
|
|
60
|
-
exitCode: exitCode
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Store evidence locally
|
|
65
|
-
const evidenceFile = path.join(
|
|
66
|
-
EVIDENCE_DIR,
|
|
67
|
-
`${new Date().toISOString().split('T')[0]}_${evidence.id}.json`
|
|
68
|
-
);
|
|
69
|
-
fs.writeFileSync(evidenceFile, JSON.stringify(evidence, null, 2));
|
|
70
|
-
|
|
71
|
-
// Send to governance agent for audit logging
|
|
72
|
-
try {
|
|
73
|
-
await axios.post(`${AGENT_URL}/audit`, {
|
|
74
|
-
action: 'tool_executed',
|
|
75
|
-
tool: tool,
|
|
76
|
-
evidence: evidence
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// Agent might not be running, that's okay
|
|
80
|
-
console.debug('[DELIMIT EVIDENCE] Could not send to agent:', err.message);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Check for anomalies
|
|
84
|
-
if (exitCode !== 0) {
|
|
85
|
-
console.warn(`[DELIMIT EVIDENCE] ⚠️ Tool execution failed with exit code ${exitCode}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Special handling for sensitive operations
|
|
89
|
-
const sensitivePaths = ['/etc/', '/.ssh/', '/.aws/', '/credentials/'];
|
|
90
|
-
if (evidence.fileState && sensitivePaths.some(p => evidence.fileState.path.includes(p))) {
|
|
91
|
-
console.warn(`[DELIMIT EVIDENCE] ⚠️ Sensitive file modified: ${evidence.fileState.path}`);
|
|
92
|
-
|
|
93
|
-
// Create high-priority evidence record
|
|
94
|
-
const alertFile = path.join(
|
|
95
|
-
EVIDENCE_DIR,
|
|
96
|
-
'alerts',
|
|
97
|
-
`ALERT_${evidence.id}.json`
|
|
98
|
-
);
|
|
99
|
-
fs.mkdirSync(path.dirname(alertFile), { recursive: true });
|
|
100
|
-
fs.writeFileSync(alertFile, JSON.stringify({
|
|
101
|
-
...evidence,
|
|
102
|
-
alertLevel: 'high',
|
|
103
|
-
reason: 'Sensitive file modification'
|
|
104
|
-
}, null, 2));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error('[DELIMIT EVIDENCE] Error collecting evidence:', error.message);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Main execution
|
|
113
|
-
if (require.main === module) {
|
|
114
|
-
const toolContext = {
|
|
115
|
-
tool: process.env.CLAUDE_TOOL_NAME || process.argv[2],
|
|
116
|
-
params: JSON.parse(process.env.CLAUDE_TOOL_PARAMS || process.argv[3] || '{}'),
|
|
117
|
-
result: JSON.parse(process.env.CLAUDE_TOOL_RESULT || process.argv[4] || '{}'),
|
|
118
|
-
exitCode: parseInt(process.env.CLAUDE_TOOL_EXIT_CODE || process.argv[5] || '0'),
|
|
119
|
-
cwd: process.cwd(),
|
|
120
|
-
user: process.env.USER
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
collectEvidence(toolContext).catch(console.error);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = { collectEvidence };
|
package/hooks/post-write-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit post-write hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] post-write hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-bash-hook.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
4
|
-
|
|
5
|
-
async function validateBash(params) {
|
|
6
|
-
const riskyCommands = ['rm -rf', 'chmod 777', 'sudo', '> /dev/sda'];
|
|
7
|
-
const command = params.command || '';
|
|
8
|
-
|
|
9
|
-
if (riskyCommands.some(cmd => command.includes(cmd))) {
|
|
10
|
-
console.error('[DELIMIT] ⚠️ Risky command detected');
|
|
11
|
-
try {
|
|
12
|
-
const { data } = await axios.post(`${AGENT_URL}/evaluate`, {
|
|
13
|
-
action: 'bash_command',
|
|
14
|
-
command: command,
|
|
15
|
-
riskLevel: 'high'
|
|
16
|
-
});
|
|
17
|
-
if (data.action === 'block') {
|
|
18
|
-
console.error('[DELIMIT] ❌ Command blocked by governance policy');
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
} catch (e) {
|
|
22
|
-
console.warn('[DELIMIT] Governance agent not available');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (require.main === module) {
|
|
28
|
-
const params = JSON.parse(process.argv[2] || '{}');
|
|
29
|
-
validateBash(params);
|
|
30
|
-
}
|
package/hooks/pre-mcp-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit pre-mcp hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] pre-mcp hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-read-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit pre-read hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] pre-read hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-search-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit pre-search hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] pre-search hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-submit-hook.js
DELETED
package/hooks/pre-task-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit pre-task hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] pre-task hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-tool-hook.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Delimit™ Pre-Tool Hook
|
|
5
|
-
* Validates tool usage against governance policies before execution
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const axios = require('axios');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
13
|
-
|
|
14
|
-
async function checkGovernance(toolContext) {
|
|
15
|
-
try {
|
|
16
|
-
// Extract tool information
|
|
17
|
-
const { tool, params, cwd, user } = toolContext;
|
|
18
|
-
|
|
19
|
-
// Build governance context
|
|
20
|
-
const context = {
|
|
21
|
-
action: 'tool_execution',
|
|
22
|
-
tool: tool,
|
|
23
|
-
parameters: params,
|
|
24
|
-
cwd: cwd,
|
|
25
|
-
user: user,
|
|
26
|
-
timestamp: new Date().toISOString(),
|
|
27
|
-
environment: process.env.NODE_ENV || 'development'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Special handling for file operations
|
|
31
|
-
if (['Edit', 'Write', 'MultiEdit', 'Delete'].includes(tool)) {
|
|
32
|
-
context.fileOperation = true;
|
|
33
|
-
context.targetPath = params.file_path || params.path;
|
|
34
|
-
|
|
35
|
-
// Check if targeting sensitive paths
|
|
36
|
-
const sensitivePaths = [
|
|
37
|
-
'/etc/',
|
|
38
|
-
'/usr/bin/',
|
|
39
|
-
'/boot/',
|
|
40
|
-
'/.ssh/',
|
|
41
|
-
'/root/.ssh/',
|
|
42
|
-
'/.aws/',
|
|
43
|
-
'/.config/gcloud/',
|
|
44
|
-
'/credentials/',
|
|
45
|
-
'/secrets/'
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
if (context.targetPath && sensitivePaths.some(p => context.targetPath.includes(p))) {
|
|
49
|
-
context.riskLevel = 'high';
|
|
50
|
-
context.sensitiveOperation = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Special handling for command execution
|
|
55
|
-
if (tool === 'Bash') {
|
|
56
|
-
context.commandExecution = true;
|
|
57
|
-
context.command = params.command;
|
|
58
|
-
|
|
59
|
-
// Check for risky commands
|
|
60
|
-
const riskyCommands = [
|
|
61
|
-
'rm -rf',
|
|
62
|
-
'chmod 777',
|
|
63
|
-
'curl | sh',
|
|
64
|
-
'wget | sh',
|
|
65
|
-
'sudo',
|
|
66
|
-
'pkill',
|
|
67
|
-
'kill -9',
|
|
68
|
-
'>', // redirect overwrite
|
|
69
|
-
'truncate'
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
if (context.command && riskyCommands.some(cmd => context.command.includes(cmd))) {
|
|
73
|
-
context.riskLevel = 'critical';
|
|
74
|
-
context.riskyCommand = true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Query governance agent
|
|
79
|
-
const response = await axios.post(`${AGENT_URL}/evaluate`, context);
|
|
80
|
-
|
|
81
|
-
// Handle the decision
|
|
82
|
-
const decision = response.data;
|
|
83
|
-
|
|
84
|
-
if (decision.action === 'block') {
|
|
85
|
-
console.error(`[DELIMIT GOVERNANCE] ❌ Tool execution blocked: ${decision.reason}`);
|
|
86
|
-
if (decision.rule) {
|
|
87
|
-
console.error(`[DELIMIT GOVERNANCE] Rule: ${decision.rule}`);
|
|
88
|
-
}
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (decision.action === 'prompt') {
|
|
93
|
-
console.warn(`[DELIMIT GOVERNANCE] ⚠️ Warning: ${decision.message}`);
|
|
94
|
-
// In non-interactive mode, we allow with warning
|
|
95
|
-
// In interactive mode, this would prompt the user
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (decision.action === 'allow') {
|
|
99
|
-
console.log(`[DELIMIT GOVERNANCE] ✅ Tool execution allowed`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
} catch (error) {
|
|
103
|
-
// If governance agent is not available, log and continue
|
|
104
|
-
console.warn('[DELIMIT GOVERNANCE] Governance agent not available, proceeding with caution');
|
|
105
|
-
console.debug(error.message);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Main execution
|
|
110
|
-
if (require.main === module) {
|
|
111
|
-
const toolContext = {
|
|
112
|
-
tool: process.env.CLAUDE_TOOL_NAME || process.argv[2],
|
|
113
|
-
params: JSON.parse(process.env.CLAUDE_TOOL_PARAMS || process.argv[3] || '{}'),
|
|
114
|
-
cwd: process.cwd(),
|
|
115
|
-
user: process.env.USER
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
checkGovernance(toolContext).catch(console.error);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = { checkGovernance };
|
package/hooks/pre-web-hook.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Delimit pre-web hook
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function process() {
|
|
7
|
-
console.log('[DELIMIT] pre-web hook activated');
|
|
8
|
-
// Hook implementation
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process();
|
|
13
|
-
}
|
package/hooks/pre-write-hook.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
|
|
5
|
-
|
|
6
|
-
async function validateWrite(params) {
|
|
7
|
-
const filePath = params.file_path || params.path || '';
|
|
8
|
-
const sensitivePaths = ['/etc/', '/.ssh/', '/.aws/', '/credentials/'];
|
|
9
|
-
|
|
10
|
-
if (sensitivePaths.some(p => filePath.includes(p))) {
|
|
11
|
-
console.warn('[DELIMIT] ⚠️ Sensitive file operation detected');
|
|
12
|
-
try {
|
|
13
|
-
const { data } = await axios.post(`${AGENT_URL}/evaluate`, {
|
|
14
|
-
action: 'file_write',
|
|
15
|
-
path: filePath,
|
|
16
|
-
riskLevel: 'critical'
|
|
17
|
-
});
|
|
18
|
-
if (data.action === 'block') {
|
|
19
|
-
console.error('[DELIMIT] ❌ File operation blocked by governance policy');
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.warn('[DELIMIT] Governance agent not available');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (require.main === module) {
|
|
29
|
-
const params = JSON.parse(process.argv[2] || '{}');
|
|
30
|
-
validateWrite(params);
|
|
31
|
-
}
|
package/hooks/test-hooks.sh
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
echo "Testing Delimit hooks..."
|
|
3
|
-
|
|
4
|
-
# Test pre-bash hook
|
|
5
|
-
echo "Testing bash hook..."
|
|
6
|
-
node /home/delimit/npm-delimit/hooks/pre-bash-hook.js '{"command":"ls"}'
|
|
7
|
-
|
|
8
|
-
# Test pre-write hook
|
|
9
|
-
echo "Testing write hook..."
|
|
10
|
-
node /home/delimit/npm-delimit/hooks/pre-write-hook.js '{"file_path":"/tmp/test.txt"}'
|
|
11
|
-
|
|
12
|
-
echo "✓ Hook tests complete"
|
package/hooks/update-delimit.sh
DELETED
package/scripts/infect.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const { execSync } = require('child_process');
|
|
7
|
-
|
|
8
|
-
const HOME_DIR = os.homedir();
|
|
9
|
-
const DELIMIT_HOME = path.join(HOME_DIR, '.delimit');
|
|
10
|
-
const SHIM_DIR = path.join(DELIMIT_HOME, 'shims');
|
|
11
|
-
const HOOKS_DIR = path.join(DELIMIT_HOME, 'hooks');
|
|
12
|
-
const BIN_DIR = path.join(DELIMIT_HOME, 'bin');
|
|
13
|
-
|
|
14
|
-
console.log('\n🔵 Installing Delimit Governance Layer...');
|
|
15
|
-
console.log('⚠️ WARNING: This will modify your system permanently.\n');
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// 1. Create directory structure
|
|
19
|
-
[DELIMIT_HOME, SHIM_DIR, HOOKS_DIR, BIN_DIR].forEach(dir => {
|
|
20
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
21
|
-
});
|
|
22
|
-
console.log('✓ Created ~/.delimit directory structure');
|
|
23
|
-
|
|
24
|
-
// 2. Copy the main Delimit CLI
|
|
25
|
-
const cliSource = path.join(__dirname, '..', 'bin', 'delimit.js');
|
|
26
|
-
const cliDest = path.join(BIN_DIR, 'delimit');
|
|
27
|
-
fs.copyFileSync(cliSource, cliDest);
|
|
28
|
-
fs.chmodSync(cliDest, '755');
|
|
29
|
-
console.log('✓ Installed Delimit CLI');
|
|
30
|
-
|
|
31
|
-
// 3. Install global Git hooks
|
|
32
|
-
const preCommitHook = `#!/bin/sh
|
|
33
|
-
# Delimit Governance Hook - Pre-commit
|
|
34
|
-
${cliDest} pre-commit-check`;
|
|
35
|
-
|
|
36
|
-
const prePushHook = `#!/bin/sh
|
|
37
|
-
# Delimit Governance Hook - Pre-push
|
|
38
|
-
${cliDest} pre-push-check`;
|
|
39
|
-
|
|
40
|
-
fs.writeFileSync(path.join(HOOKS_DIR, 'pre-commit'), preCommitHook);
|
|
41
|
-
fs.writeFileSync(path.join(HOOKS_DIR, 'pre-push'), prePushHook);
|
|
42
|
-
fs.chmodSync(path.join(HOOKS_DIR, 'pre-commit'), '755');
|
|
43
|
-
fs.chmodSync(path.join(HOOKS_DIR, 'pre-push'), '755');
|
|
44
|
-
|
|
45
|
-
execSync(`git config --global core.hooksPath ${HOOKS_DIR}`);
|
|
46
|
-
console.log('✓ Installed global Git hooks');
|
|
47
|
-
|
|
48
|
-
// 4. Create AI tool shims
|
|
49
|
-
const aiTools = ['claude', 'gemini', 'codex', 'copilot', 'gh', 'openai', 'anthropic'];
|
|
50
|
-
aiTools.forEach(tool => {
|
|
51
|
-
const shimContent = `#!/bin/sh
|
|
52
|
-
# Delimit Governance Shim for ${tool}
|
|
53
|
-
exec ${cliDest} proxy --tool=${tool} -- "$@"`;
|
|
54
|
-
|
|
55
|
-
const shimPath = path.join(SHIM_DIR, tool);
|
|
56
|
-
fs.writeFileSync(shimPath, shimContent);
|
|
57
|
-
fs.chmodSync(shimPath, '755');
|
|
58
|
-
});
|
|
59
|
-
console.log(`✓ Created ${aiTools.length} AI tool shims`);
|
|
60
|
-
|
|
61
|
-
// 5. Inject into shell profiles
|
|
62
|
-
const shellProfiles = [
|
|
63
|
-
'.bashrc',
|
|
64
|
-
'.zshrc',
|
|
65
|
-
'.profile',
|
|
66
|
-
'.bash_profile'
|
|
67
|
-
].map(f => path.join(HOME_DIR, f));
|
|
68
|
-
|
|
69
|
-
const pathInjection = `
|
|
70
|
-
# Delimit Governance Layer - DO NOT REMOVE
|
|
71
|
-
export PATH="${SHIM_DIR}:$PATH"
|
|
72
|
-
export DELIMIT_ACTIVE=true
|
|
73
|
-
|
|
74
|
-
# Show governance status on shell start
|
|
75
|
-
if [ -t 1 ]; then
|
|
76
|
-
echo -e "\\033[34m\\033[1m[Delimit]\\033[0m Governance active. All AI tools and Git operations are monitored."
|
|
77
|
-
fi
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
let injected = false;
|
|
81
|
-
shellProfiles.forEach(profilePath => {
|
|
82
|
-
if (fs.existsSync(profilePath)) {
|
|
83
|
-
const content = fs.readFileSync(profilePath, 'utf8');
|
|
84
|
-
if (!content.includes('Delimit Governance Layer')) {
|
|
85
|
-
fs.appendFileSync(profilePath, pathInjection);
|
|
86
|
-
console.log(`✓ Injected into ${path.basename(profilePath)}`);
|
|
87
|
-
injected = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
if (!injected) {
|
|
93
|
-
// Create a .profile if nothing exists
|
|
94
|
-
const profilePath = path.join(HOME_DIR, '.profile');
|
|
95
|
-
fs.writeFileSync(profilePath, pathInjection);
|
|
96
|
-
console.log('✓ Created .profile with governance');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 6. Create global command link
|
|
100
|
-
try {
|
|
101
|
-
const globalBin = '/usr/local/bin/delimit';
|
|
102
|
-
if (fs.existsSync('/usr/local/bin')) {
|
|
103
|
-
if (fs.existsSync(globalBin)) {
|
|
104
|
-
fs.unlinkSync(globalBin);
|
|
105
|
-
}
|
|
106
|
-
fs.symlinkSync(cliDest, globalBin);
|
|
107
|
-
console.log('✓ Created global delimit command');
|
|
108
|
-
}
|
|
109
|
-
} catch (e) {
|
|
110
|
-
// Ignore if can't create global link
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
console.log('\n' + '═'.repeat(60));
|
|
114
|
-
console.log('🟢 DELIMIT GOVERNANCE LAYER INSTALLED SUCCESSFULLY');
|
|
115
|
-
console.log('═'.repeat(60));
|
|
116
|
-
console.log('\n⚡ IMPORTANT: Restart your terminal or run:');
|
|
117
|
-
console.log(' source ~/.bashrc (or ~/.zshrc)\n');
|
|
118
|
-
console.log('📊 Check status with: delimit status');
|
|
119
|
-
console.log('📖 Documentation: https://delimit.ai\n');
|
|
120
|
-
console.log('⚠️ WARNING: Governance is now mandatory.');
|
|
121
|
-
console.log(' All AI tools and Git operations are monitored.\n');
|
|
122
|
-
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error('\n❌ Installation failed:', error.message);
|
|
125
|
-
console.error('\nTry installing globally with sudo:');
|
|
126
|
-
console.error(' sudo npm install -g delimit\n');
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|