delimit-cli 2.3.2 → 3.0.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.
Files changed (113) hide show
  1. package/.dockerignore +7 -0
  2. package/.github/workflows/ci.yml +22 -0
  3. package/CHANGELOG.md +33 -0
  4. package/CODE_OF_CONDUCT.md +48 -0
  5. package/CONTRIBUTING.md +67 -0
  6. package/Dockerfile +9 -0
  7. package/LICENSE +21 -0
  8. package/README.md +51 -130
  9. package/SECURITY.md +42 -0
  10. package/adapters/codex-forge.js +107 -0
  11. package/adapters/codex-jamsons.js +142 -0
  12. package/adapters/codex-security.js +94 -0
  13. package/adapters/gemini-forge.js +120 -0
  14. package/adapters/gemini-jamsons.js +152 -0
  15. package/bin/delimit-cli.js +52 -2
  16. package/bin/delimit-setup.js +258 -0
  17. package/gateway/ai/backends/__init__.py +0 -0
  18. package/gateway/ai/backends/async_utils.py +21 -0
  19. package/gateway/ai/backends/deploy_bridge.py +150 -0
  20. package/gateway/ai/backends/gateway_core.py +261 -0
  21. package/gateway/ai/backends/generate_bridge.py +38 -0
  22. package/gateway/ai/backends/governance_bridge.py +196 -0
  23. package/gateway/ai/backends/intel_bridge.py +59 -0
  24. package/gateway/ai/backends/memory_bridge.py +93 -0
  25. package/gateway/ai/backends/ops_bridge.py +137 -0
  26. package/gateway/ai/backends/os_bridge.py +82 -0
  27. package/gateway/ai/backends/repo_bridge.py +117 -0
  28. package/gateway/ai/backends/ui_bridge.py +118 -0
  29. package/gateway/ai/backends/vault_bridge.py +129 -0
  30. package/gateway/ai/server.py +1182 -0
  31. package/gateway/core/__init__.py +3 -0
  32. package/gateway/core/__pycache__/__init__.cpython-310.pyc +0 -0
  33. package/gateway/core/__pycache__/auto_baseline.cpython-310.pyc +0 -0
  34. package/gateway/core/__pycache__/ci_formatter.cpython-310.pyc +0 -0
  35. package/gateway/core/__pycache__/contract_ledger.cpython-310.pyc +0 -0
  36. package/gateway/core/__pycache__/dependency_graph.cpython-310.pyc +0 -0
  37. package/gateway/core/__pycache__/dependency_manifest.cpython-310.pyc +0 -0
  38. package/gateway/core/__pycache__/diff_engine_v2.cpython-310.pyc +0 -0
  39. package/gateway/core/__pycache__/event_backbone.cpython-310.pyc +0 -0
  40. package/gateway/core/__pycache__/event_schema.cpython-310.pyc +0 -0
  41. package/gateway/core/__pycache__/explainer.cpython-310.pyc +0 -0
  42. package/gateway/core/__pycache__/gateway.cpython-310.pyc +0 -0
  43. package/gateway/core/__pycache__/gateway_v2.cpython-310.pyc +0 -0
  44. package/gateway/core/__pycache__/gateway_v3.cpython-310.pyc +0 -0
  45. package/gateway/core/__pycache__/impact_analyzer.cpython-310.pyc +0 -0
  46. package/gateway/core/__pycache__/policy_engine.cpython-310.pyc +0 -0
  47. package/gateway/core/__pycache__/registry.cpython-310.pyc +0 -0
  48. package/gateway/core/__pycache__/registry_v2.cpython-310.pyc +0 -0
  49. package/gateway/core/__pycache__/registry_v3.cpython-310.pyc +0 -0
  50. package/gateway/core/__pycache__/semver_classifier.cpython-310.pyc +0 -0
  51. package/gateway/core/__pycache__/spec_detector.cpython-310.pyc +0 -0
  52. package/gateway/core/__pycache__/surface_bridge.cpython-310.pyc +0 -0
  53. package/gateway/core/auto_baseline.py +304 -0
  54. package/gateway/core/ci_formatter.py +283 -0
  55. package/gateway/core/complexity_analyzer.py +386 -0
  56. package/gateway/core/contract_ledger.py +345 -0
  57. package/gateway/core/dependency_graph.py +218 -0
  58. package/gateway/core/dependency_manifest.py +223 -0
  59. package/gateway/core/diff_engine_v2.py +477 -0
  60. package/gateway/core/diff_engine_v2.py.bak +426 -0
  61. package/gateway/core/event_backbone.py +268 -0
  62. package/gateway/core/event_schema.py +258 -0
  63. package/gateway/core/explainer.py +438 -0
  64. package/gateway/core/gateway.py +128 -0
  65. package/gateway/core/gateway_v2.py +154 -0
  66. package/gateway/core/gateway_v3.py +224 -0
  67. package/gateway/core/impact_analyzer.py +163 -0
  68. package/gateway/core/policies/default.yml +13 -0
  69. package/gateway/core/policies/relaxed.yml +48 -0
  70. package/gateway/core/policies/strict.yml +55 -0
  71. package/gateway/core/policy_engine.py +464 -0
  72. package/gateway/core/registry.py +52 -0
  73. package/gateway/core/registry_v2.py +132 -0
  74. package/gateway/core/registry_v3.py +134 -0
  75. package/gateway/core/semver_classifier.py +152 -0
  76. package/gateway/core/spec_detector.py +130 -0
  77. package/gateway/core/surface_bridge.py +307 -0
  78. package/gateway/core/zero_spec/__init__.py +4 -0
  79. package/gateway/core/zero_spec/__pycache__/__init__.cpython-310.pyc +0 -0
  80. package/gateway/core/zero_spec/__pycache__/detector.cpython-310.pyc +0 -0
  81. package/gateway/core/zero_spec/__pycache__/express_extractor.cpython-310.pyc +0 -0
  82. package/gateway/core/zero_spec/__pycache__/fastapi_extractor.cpython-310.pyc +0 -0
  83. package/gateway/core/zero_spec/__pycache__/nestjs_extractor.cpython-310.pyc +0 -0
  84. package/gateway/core/zero_spec/detector.py +353 -0
  85. package/gateway/core/zero_spec/express_extractor.py +483 -0
  86. package/gateway/core/zero_spec/fastapi_extractor.py +254 -0
  87. package/gateway/core/zero_spec/nestjs_extractor.py +369 -0
  88. package/gateway/tasks/__init__.py +1 -0
  89. package/gateway/tasks/__pycache__/__init__.cpython-310.pyc +0 -0
  90. package/gateway/tasks/__pycache__/check_policy.cpython-310.pyc +0 -0
  91. package/gateway/tasks/__pycache__/check_policy_v2.cpython-310.pyc +0 -0
  92. package/gateway/tasks/__pycache__/check_policy_v3.cpython-310.pyc +0 -0
  93. package/gateway/tasks/__pycache__/explain_diff.cpython-310.pyc +0 -0
  94. package/gateway/tasks/__pycache__/explain_diff_v2.cpython-310.pyc +0 -0
  95. package/gateway/tasks/__pycache__/validate_api.cpython-310.pyc +0 -0
  96. package/gateway/tasks/__pycache__/validate_api_v2.cpython-310.pyc +0 -0
  97. package/gateway/tasks/__pycache__/validate_api_v3.cpython-310.pyc +0 -0
  98. package/gateway/tasks/check_policy.py +177 -0
  99. package/gateway/tasks/check_policy_v2.py +255 -0
  100. package/gateway/tasks/check_policy_v3.py +255 -0
  101. package/gateway/tasks/explain_diff.py +305 -0
  102. package/gateway/tasks/explain_diff_v2.py +267 -0
  103. package/gateway/tasks/validate_api.py +131 -0
  104. package/gateway/tasks/validate_api_v2.py +208 -0
  105. package/gateway/tasks/validate_api_v3.py +163 -0
  106. package/package.json +3 -3
  107. package/adapters/codex-skill.js +0 -87
  108. package/adapters/cursor-extension.js +0 -190
  109. package/adapters/gemini-action.js +0 -93
  110. package/adapters/openai-function.js +0 -112
  111. package/adapters/xai-plugin.js +0 -151
  112. package/test-decision-engine.js +0 -181
  113. package/test-hook.js +0 -27
@@ -1,181 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const DecisionEngine = require('./lib/decision-engine');
4
- const axios = require('axios');
5
-
6
- async function runTests() {
7
- console.log('=== DECISION ENGINE HOSTILE VERIFICATION ===\n');
8
-
9
- // First restore good policy and restart agent
10
- const fs = require('fs');
11
- const goodPolicy = `defaultMode: advisory
12
-
13
- rules:
14
- - name: "Production Protection"
15
- mode: enforce
16
- triggers:
17
- - gitBranch: [main, master, production]
18
-
19
- - name: "Payment Code Security"
20
- mode: enforce
21
- triggers:
22
- - path: "**/payment/**"
23
- - content: ["stripe", "payment", "billing"]
24
-
25
- - name: "Documentation Freedom"
26
- mode: advisory
27
- triggers:
28
- - path: "**/*.md"
29
- final: true`;
30
-
31
- fs.writeFileSync('delimit.yml', goodPolicy);
32
-
33
- // Kill existing agent
34
- try {
35
- require('child_process').execSync('pkill -f "node lib/agent.js"');
36
- } catch(e) {}
37
-
38
- // Start fresh agent
39
- const agent = require('child_process').spawn('node', ['lib/agent.js'], {
40
- detached: true,
41
- stdio: 'ignore'
42
- });
43
- agent.unref();
44
-
45
- // Wait for agent
46
- await new Promise(r => setTimeout(r, 2000));
47
-
48
- const tests = [
49
- {
50
- name: 'TEST 1: Documentation file -> Advisory',
51
- context: {
52
- command: 'pre-commit',
53
- pwd: '/test',
54
- gitBranch: 'feature',
55
- files: ['README.md', 'docs/api.md'],
56
- diff: 'documentation changes'
57
- },
58
- expected: 'advisory'
59
- },
60
- {
61
- name: 'TEST 2: Payment path -> Enforce',
62
- context: {
63
- command: 'pre-commit',
64
- pwd: '/test',
65
- gitBranch: 'feature',
66
- files: ['lib/payment/stripe.js'],
67
- diff: 'payment code changes'
68
- },
69
- expected: 'enforce'
70
- },
71
- {
72
- name: 'TEST 3: Main branch -> Enforce',
73
- context: {
74
- command: 'pre-commit',
75
- pwd: '/test',
76
- gitBranch: 'main',
77
- files: ['lib/utils.js'],
78
- diff: 'utility changes'
79
- },
80
- expected: 'enforce'
81
- },
82
- {
83
- name: 'TEST 4: No match -> Default advisory',
84
- context: {
85
- command: 'pre-commit',
86
- pwd: '/test',
87
- gitBranch: 'feature',
88
- files: ['lib/utils.js'],
89
- diff: 'regular code'
90
- },
91
- expected: 'advisory'
92
- },
93
- {
94
- name: 'TEST 5: Conflicting rules -> Stronger wins',
95
- context: {
96
- command: 'pre-commit',
97
- pwd: '/test',
98
- gitBranch: 'main',
99
- files: ['README.md'],
100
- diff: 'readme on main branch'
101
- },
102
- expected: 'enforce' // Production Protection should win over Documentation Freedom
103
- },
104
- {
105
- name: 'TEST 6: Determinism check (repeat test 2)',
106
- context: {
107
- command: 'pre-commit',
108
- pwd: '/test',
109
- gitBranch: 'feature',
110
- files: ['lib/payment/stripe.js'],
111
- diff: 'payment code changes'
112
- },
113
- expected: 'enforce'
114
- }
115
- ];
116
-
117
- const results = [];
118
- for (const test of tests) {
119
- try {
120
- const response = await axios.post('http://127.0.0.1:7823/evaluate', test.context);
121
- const decision = response.data;
122
-
123
- const result = {
124
- test: test.name,
125
- expected: test.expected,
126
- actual: decision.mode,
127
- action: decision.action,
128
- rule: decision.rule,
129
- pass: decision.mode === test.expected
130
- };
131
-
132
- results.push(result);
133
- console.log(`${test.name}`);
134
- console.log(` Expected: ${test.expected}, Actual: ${decision.mode}`);
135
- console.log(` Rule: ${decision.rule || 'none'}`);
136
- console.log(` Status: ${result.pass ? '✅ PASS' : '❌ FAIL'}\n`);
137
-
138
- // Get explanation for this decision
139
- const explainResponse = await axios.get('http://127.0.0.1:7823/explain/last');
140
- if (explainResponse.data.explanation) {
141
- console.log(' Explanation quality check:');
142
- const exp = explainResponse.data.explanation;
143
- console.log(` - Has decision ID: ${exp.includes('Decision ID:') ? '✓' : '✗'}`);
144
- console.log(` - Has effective mode: ${exp.includes('Effective:') ? '✓' : '✗'}`);
145
- console.log(` - Has matched rules: ${exp.includes('MATCHED RULES') || exp.includes('No matching rules') ? '✓' : '✗'}`);
146
- console.log(` - Has context: ${exp.includes('CONTEXT') ? '✓' : '✗'}\n`);
147
- }
148
-
149
- } catch (e) {
150
- results.push({
151
- test: test.name,
152
- expected: test.expected,
153
- actual: 'ERROR',
154
- error: e.message,
155
- pass: false
156
- });
157
- console.log(`${test.name}: ❌ ERROR - ${e.message}\n`);
158
- }
159
- }
160
-
161
- // Summary
162
- console.log('=== SUMMARY ===');
163
- const passed = results.filter(r => r.pass).length;
164
- console.log(`Passed: ${passed}/${results.length}`);
165
-
166
- // Check determinism
167
- if (results[1].actual === results[5].actual && results[1].rule === results[5].rule) {
168
- console.log('✅ DETERMINISM CHECK: Same input produced same output');
169
- } else {
170
- console.log('❌ DETERMINISM CHECK: Same input produced different outputs!');
171
- }
172
-
173
- // Kill agent
174
- try {
175
- require('child_process').execSync('pkill -f "node lib/agent.js"');
176
- } catch(e) {}
177
-
178
- process.exit(passed === results.length ? 0 : 1);
179
- }
180
-
181
- runTests().catch(console.error);
package/test-hook.js DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Test script to simulate a Git pre-commit hook
4
- const axios = require('axios');
5
-
6
- async function testHook() {
7
- const context = {
8
- command: 'pre-commit',
9
- pwd: '/home/delimit/npm-delimit',
10
- gitBranch: 'main',
11
- files: ['lib/payment/stripe.js', 'README.md'],
12
- diff: 'diff --git a/lib/payment/stripe.js\n+const stripe = require("stripe");'
13
- };
14
-
15
- try {
16
- const response = await axios.post('http://127.0.0.1:7823/evaluate', context);
17
- console.log('Decision:', response.data);
18
-
19
- // Now test the explain endpoint
20
- const explainResponse = await axios.get('http://127.0.0.1:7823/explain/last');
21
- console.log('\n' + explainResponse.data.explanation);
22
- } catch (e) {
23
- console.error('Error:', e.message);
24
- }
25
- }
26
-
27
- testHook();