delimit-cli 2.4.0 → 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 (112) hide show
  1. package/.dockerignore +7 -0
  2. package/.github/workflows/ci.yml +22 -0
  3. package/CODE_OF_CONDUCT.md +48 -0
  4. package/CONTRIBUTING.md +67 -0
  5. package/Dockerfile +9 -0
  6. package/LICENSE +21 -0
  7. package/README.md +18 -69
  8. package/SECURITY.md +42 -0
  9. package/adapters/gemini-forge.js +11 -0
  10. package/adapters/gemini-jamsons.js +152 -0
  11. package/bin/delimit-cli.js +8 -0
  12. package/bin/delimit-setup.js +258 -0
  13. package/gateway/ai/backends/__init__.py +0 -0
  14. package/gateway/ai/backends/async_utils.py +21 -0
  15. package/gateway/ai/backends/deploy_bridge.py +150 -0
  16. package/gateway/ai/backends/gateway_core.py +261 -0
  17. package/gateway/ai/backends/generate_bridge.py +38 -0
  18. package/gateway/ai/backends/governance_bridge.py +196 -0
  19. package/gateway/ai/backends/intel_bridge.py +59 -0
  20. package/gateway/ai/backends/memory_bridge.py +93 -0
  21. package/gateway/ai/backends/ops_bridge.py +137 -0
  22. package/gateway/ai/backends/os_bridge.py +82 -0
  23. package/gateway/ai/backends/repo_bridge.py +117 -0
  24. package/gateway/ai/backends/ui_bridge.py +118 -0
  25. package/gateway/ai/backends/vault_bridge.py +129 -0
  26. package/gateway/ai/server.py +1182 -0
  27. package/gateway/core/__init__.py +3 -0
  28. package/gateway/core/__pycache__/__init__.cpython-310.pyc +0 -0
  29. package/gateway/core/__pycache__/auto_baseline.cpython-310.pyc +0 -0
  30. package/gateway/core/__pycache__/ci_formatter.cpython-310.pyc +0 -0
  31. package/gateway/core/__pycache__/contract_ledger.cpython-310.pyc +0 -0
  32. package/gateway/core/__pycache__/dependency_graph.cpython-310.pyc +0 -0
  33. package/gateway/core/__pycache__/dependency_manifest.cpython-310.pyc +0 -0
  34. package/gateway/core/__pycache__/diff_engine_v2.cpython-310.pyc +0 -0
  35. package/gateway/core/__pycache__/event_backbone.cpython-310.pyc +0 -0
  36. package/gateway/core/__pycache__/event_schema.cpython-310.pyc +0 -0
  37. package/gateway/core/__pycache__/explainer.cpython-310.pyc +0 -0
  38. package/gateway/core/__pycache__/gateway.cpython-310.pyc +0 -0
  39. package/gateway/core/__pycache__/gateway_v2.cpython-310.pyc +0 -0
  40. package/gateway/core/__pycache__/gateway_v3.cpython-310.pyc +0 -0
  41. package/gateway/core/__pycache__/impact_analyzer.cpython-310.pyc +0 -0
  42. package/gateway/core/__pycache__/policy_engine.cpython-310.pyc +0 -0
  43. package/gateway/core/__pycache__/registry.cpython-310.pyc +0 -0
  44. package/gateway/core/__pycache__/registry_v2.cpython-310.pyc +0 -0
  45. package/gateway/core/__pycache__/registry_v3.cpython-310.pyc +0 -0
  46. package/gateway/core/__pycache__/semver_classifier.cpython-310.pyc +0 -0
  47. package/gateway/core/__pycache__/spec_detector.cpython-310.pyc +0 -0
  48. package/gateway/core/__pycache__/surface_bridge.cpython-310.pyc +0 -0
  49. package/gateway/core/auto_baseline.py +304 -0
  50. package/gateway/core/ci_formatter.py +283 -0
  51. package/gateway/core/complexity_analyzer.py +386 -0
  52. package/gateway/core/contract_ledger.py +345 -0
  53. package/gateway/core/dependency_graph.py +218 -0
  54. package/gateway/core/dependency_manifest.py +223 -0
  55. package/gateway/core/diff_engine_v2.py +477 -0
  56. package/gateway/core/diff_engine_v2.py.bak +426 -0
  57. package/gateway/core/event_backbone.py +268 -0
  58. package/gateway/core/event_schema.py +258 -0
  59. package/gateway/core/explainer.py +438 -0
  60. package/gateway/core/gateway.py +128 -0
  61. package/gateway/core/gateway_v2.py +154 -0
  62. package/gateway/core/gateway_v3.py +224 -0
  63. package/gateway/core/impact_analyzer.py +163 -0
  64. package/gateway/core/policies/default.yml +13 -0
  65. package/gateway/core/policies/relaxed.yml +48 -0
  66. package/gateway/core/policies/strict.yml +55 -0
  67. package/gateway/core/policy_engine.py +464 -0
  68. package/gateway/core/registry.py +52 -0
  69. package/gateway/core/registry_v2.py +132 -0
  70. package/gateway/core/registry_v3.py +134 -0
  71. package/gateway/core/semver_classifier.py +152 -0
  72. package/gateway/core/spec_detector.py +130 -0
  73. package/gateway/core/surface_bridge.py +307 -0
  74. package/gateway/core/zero_spec/__init__.py +4 -0
  75. package/gateway/core/zero_spec/__pycache__/__init__.cpython-310.pyc +0 -0
  76. package/gateway/core/zero_spec/__pycache__/detector.cpython-310.pyc +0 -0
  77. package/gateway/core/zero_spec/__pycache__/express_extractor.cpython-310.pyc +0 -0
  78. package/gateway/core/zero_spec/__pycache__/fastapi_extractor.cpython-310.pyc +0 -0
  79. package/gateway/core/zero_spec/__pycache__/nestjs_extractor.cpython-310.pyc +0 -0
  80. package/gateway/core/zero_spec/detector.py +353 -0
  81. package/gateway/core/zero_spec/express_extractor.py +483 -0
  82. package/gateway/core/zero_spec/fastapi_extractor.py +254 -0
  83. package/gateway/core/zero_spec/nestjs_extractor.py +369 -0
  84. package/gateway/tasks/__init__.py +1 -0
  85. package/gateway/tasks/__pycache__/__init__.cpython-310.pyc +0 -0
  86. package/gateway/tasks/__pycache__/check_policy.cpython-310.pyc +0 -0
  87. package/gateway/tasks/__pycache__/check_policy_v2.cpython-310.pyc +0 -0
  88. package/gateway/tasks/__pycache__/check_policy_v3.cpython-310.pyc +0 -0
  89. package/gateway/tasks/__pycache__/explain_diff.cpython-310.pyc +0 -0
  90. package/gateway/tasks/__pycache__/explain_diff_v2.cpython-310.pyc +0 -0
  91. package/gateway/tasks/__pycache__/validate_api.cpython-310.pyc +0 -0
  92. package/gateway/tasks/__pycache__/validate_api_v2.cpython-310.pyc +0 -0
  93. package/gateway/tasks/__pycache__/validate_api_v3.cpython-310.pyc +0 -0
  94. package/gateway/tasks/check_policy.py +177 -0
  95. package/gateway/tasks/check_policy_v2.py +255 -0
  96. package/gateway/tasks/check_policy_v3.py +255 -0
  97. package/gateway/tasks/explain_diff.py +305 -0
  98. package/gateway/tasks/explain_diff_v2.py +267 -0
  99. package/gateway/tasks/validate_api.py +131 -0
  100. package/gateway/tasks/validate_api_v2.py +208 -0
  101. package/gateway/tasks/validate_api_v3.py +163 -0
  102. package/package.json +2 -2
  103. package/adapters/codex-skill.js +0 -87
  104. package/adapters/cursor-extension.js +0 -190
  105. package/adapters/gemini-action.js +0 -93
  106. package/adapters/openai-function.js +0 -112
  107. package/adapters/xai-plugin.js +0 -151
  108. package/test-decision-engine.js +0 -181
  109. package/test-hook.js +0 -27
  110. package/tests/cli.test.js +0 -359
  111. package/tests/fixtures/openapi-changed.yaml +0 -56
  112. package/tests/fixtures/openapi.yaml +0 -87
package/.dockerignore ADDED
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ .git
3
+ tests
4
+ junit.xml
5
+ playwright-report
6
+ test-results
7
+ test-results.json
@@ -0,0 +1,22 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ node-version: ['18', '20', '22']
11
+
12
+ name: Test Node ${{ matrix.node-version }}
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: ${{ matrix.node-version }}
19
+
20
+ - run: npm install
21
+
22
+ - run: npm test
@@ -0,0 +1,48 @@
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to a positive environment:
15
+
16
+ * Using welcoming and inclusive language
17
+ * Being respectful of differing viewpoints and experiences
18
+ * Gracefully accepting constructive criticism
19
+ * Focusing on what is best for the community
20
+ * Showing empathy towards other community members
21
+
22
+ Examples of unacceptable behavior:
23
+
24
+ * The use of sexualized language or imagery
25
+ * Trolling, insulting or derogatory comments, and personal attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information without permission
28
+ * Other conduct which could reasonably be considered inappropriate
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of
33
+ acceptable behavior and will take appropriate and fair corrective action in
34
+ response to any behavior that they deem inappropriate, threatening, offensive,
35
+ or harmful.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
40
+ reported to the community leaders responsible for enforcement at
41
+ opensource@delimit.ai.
42
+
43
+ All complaints will be reviewed and investigated promptly and fairly.
44
+
45
+ ## Attribution
46
+
47
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
48
+ version 2.1.
@@ -0,0 +1,67 @@
1
+ # Contributing to Delimit
2
+
3
+ Thank you for your interest in contributing to Delimit. We welcome contributions from the community.
4
+
5
+ ## How to Contribute
6
+
7
+ ### Reporting Issues
8
+
9
+ 1. Check if the issue already exists
10
+ 2. Create a new issue with:
11
+ - Clear title and description
12
+ - Steps to reproduce
13
+ - Expected vs actual behavior
14
+ - Environment details (OS, Node version, etc.)
15
+
16
+ ### Submitting Pull Requests
17
+
18
+ 1. Fork the repository
19
+ 2. Create a feature branch: `git checkout -b feature/your-feature`
20
+ 3. Make your changes
21
+ 4. Run the test suite
22
+ 5. Commit with clear messages
23
+ 6. Push to your fork
24
+ 7. Open a PR with:
25
+ - Description of changes
26
+ - Related issue numbers
27
+ - Test results
28
+
29
+ ## Development Setup
30
+
31
+ ### CLI (npm)
32
+
33
+ ```bash
34
+ npm install -g delimit-cli
35
+ delimit doctor
36
+ ```
37
+
38
+ ### GitHub Action
39
+
40
+ See [delimit-action](https://github.com/delimit-ai/delimit-action) for CI integration.
41
+
42
+ ## Code Style
43
+
44
+ - Follow existing conventions in the codebase
45
+ - Use type hints where appropriate
46
+ - Document functions and classes
47
+ - Keep functions focused and small
48
+
49
+ ## Testing
50
+
51
+ All PRs must:
52
+ - Pass existing tests
53
+ - Include tests for new features
54
+ - Not introduce regressions
55
+
56
+ ## Areas for Contribution
57
+
58
+ - Documentation improvements
59
+ - Bug fixes
60
+ - New governance rules and policy presets
61
+ - Performance improvements
62
+ - Framework integrations (Zero-Spec extractors)
63
+
64
+ ## Questions?
65
+
66
+ - Open a [Discussion](https://github.com/delimit-ai/delimit/discussions) on GitHub
67
+ - Email opensource@delimit.ai
package/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM node:20-slim
2
+ RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip && rm -rf /var/lib/apt/lists/*
3
+ RUN pip3 install --break-system-packages pyyaml pydantic packaging
4
+ WORKDIR /app
5
+ COPY package*.json ./
6
+ RUN npm install --production --ignore-scripts
7
+ COPY . .
8
+ ENV DELIMIT_GATEWAY_ROOT=/app/gateway
9
+ ENTRYPOINT ["node", "bin/delimit-cli.js"]
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Delimit AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,7 +5,6 @@ Catch breaking API changes before they ship.
5
5
  [![npm](https://img.shields.io/npm/v/delimit-cli)](https://www.npmjs.com/package/delimit-cli)
6
6
  [![GitHub Action](https://img.shields.io/badge/Marketplace-Delimit-blue)](https://github.com/marketplace/actions/delimit-api-governance)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
- [![Tests](https://img.shields.io/badge/tests-299%20passing-brightgreen)](#)
9
8
 
10
9
  Deterministic diff engine for OpenAPI specs. Detects breaking changes, classifies semver, enforces policy, and posts PR comments with migration guides. No API keys, no external services.
11
10
 
@@ -13,8 +12,6 @@ Deterministic diff engine for OpenAPI specs. Detects breaking changes, classifie
13
12
 
14
13
  ## GitHub Action (recommended)
15
14
 
16
- Add `.github/workflows/api-check.yml`:
17
-
18
15
  ```yaml
19
16
  name: API Contract Check
20
17
  on: pull_request
@@ -26,17 +23,12 @@ jobs:
26
23
  pull-requests: write
27
24
  steps:
28
25
  - uses: actions/checkout@v4
29
- - uses: actions/checkout@v4
30
- with:
31
- ref: ${{ github.event.pull_request.base.sha }}
32
- path: base
33
26
  - uses: delimit-ai/delimit-action@v1
34
27
  with:
35
- old_spec: base/api/openapi.yaml
36
- new_spec: api/openapi.yaml
28
+ spec: api/openapi.yaml
37
29
  ```
38
30
 
39
- Runs in **advisory mode** by default -- posts a PR comment but never fails your build. Set `mode: enforce` when you are ready to block merges on breaking changes.
31
+ One input. Delimit fetches the base branch version automatically. Runs in **advisory mode** by default -- posts a PR comment but does not fail your build. Set `mode: enforce` to block merges on breaking changes.
40
32
 
41
33
  ---
42
34
 
@@ -53,87 +45,44 @@ Or install globally:
53
45
  ```bash
54
46
  npm install -g delimit-cli
55
47
  delimit init --preset default
56
- delimit lint old.yaml new.yaml
48
+ delimit lint api/openapi.yaml
57
49
  ```
58
50
 
59
51
  ### Commands
60
52
 
61
53
  | Command | What it does |
62
54
  |---------|-------------|
63
- | `delimit init [--preset]` | Create `.delimit/policies.yml` |
64
- | `delimit lint <old> <new>` | Diff + policy check. Exit 1 on violations. |
55
+ | `delimit init [--preset]` | Create `.delimit/policies.yml` with a policy preset |
56
+ | `delimit lint <spec>` | Diff + policy check. Exit 1 on violations. |
65
57
  | `delimit diff <old> <new>` | Raw diff with `[BREAKING]` / `[safe]` tags |
66
- | `delimit explain <old> <new>` | Human-readable explanation (7 templates) |
67
-
68
- ---
58
+ | `delimit explain <old> <new>` | Human-readable summary (7 templates) |
69
59
 
70
- ## What it catches
71
-
72
- 10 breaking change types, detected deterministically:
73
-
74
- | Breaking change | Example |
75
- |----------------|---------|
76
- | Endpoint removed | `DELETE /users/{id}` path deleted |
77
- | Method removed | `PATCH` dropped from `/orders` |
78
- | Required parameter added | New required query param on existing endpoint |
79
- | Parameter removed | `?filter` param deleted |
80
- | Response removed | `200` response code dropped |
81
- | Required field added | New required field in request body |
82
- | Response field removed | `email` field removed from response |
83
- | Type changed | `age` changed from `string` to `integer` |
84
- | Format changed | `date` changed to `date-time` |
85
- | Enum value removed | `status: "pending"` no longer allowed |
86
-
87
- Plus 7 non-breaking types (endpoint added, optional field added, etc.) for full change visibility. Every change is classified as `MAJOR`, `MINOR`, `PATCH`, or `NONE`.
88
-
89
- ---
90
-
91
- ## Policy presets
60
+ ### Policy presets
92
61
 
93
62
  ```bash
94
- delimit init --preset strict # All breaking changes are errors. For public/payment APIs.
95
- delimit init --preset default # Breaking changes error, type changes warn. For most teams.
96
- delimit init --preset relaxed # Everything is a warning. For internal APIs and prototyping.
63
+ delimit init --preset strict # All breaking changes are errors
64
+ delimit init --preset default # Breaking = error, type changes = warn
65
+ delimit init --preset relaxed # Everything is a warning
97
66
  ```
98
67
 
99
- Or pass inline: `delimit lint --policy strict old.yaml new.yaml`
68
+ Or inline: `delimit lint --policy strict api/openapi.yaml`
100
69
 
101
70
  ---
102
71
 
103
- ## Custom policies
104
-
105
- Create `.delimit/policies.yml`:
106
-
107
- ```yaml
108
- override_defaults: false
109
-
110
- rules:
111
- - id: protect_v1
112
- name: Protect V1 API
113
- change_types: [endpoint_removed, method_removed, field_removed]
114
- severity: error
115
- action: forbid
116
- conditions:
117
- path_pattern: "^/v1/.*"
118
- message: "V1 API is frozen. Make changes in V2."
119
- ```
120
-
121
- ---
72
+ ## What it catches
122
73
 
123
- ## Supported formats
74
+ 10 breaking change types (endpoint removed, method removed, required param added, param removed, response removed, required field added, response field removed, type changed, format changed, enum value removed) plus 7 non-breaking types for full visibility. Every change classified as `MAJOR`, `MINOR`, `PATCH`, or `NONE`.
124
75
 
125
- - OpenAPI 3.0 and 3.1
126
- - Swagger 2.0
127
- - YAML and JSON
76
+ Supports OpenAPI 3.0, 3.1, and Swagger 2.0 in YAML or JSON.
128
77
 
129
78
  ---
130
79
 
131
80
  ## Links
132
81
 
133
- - [delimit.ai](https://delimit.ai) -- Project home
134
- - [GitHub Action on Marketplace](https://github.com/marketplace/actions/delimit-api-governance) -- Install in one click
135
- - [delimit-cli on npm](https://www.npmjs.com/package/delimit-cli) -- CLI package
136
- - [Quickstart repo](https://github.com/delimit-ai/delimit-quickstart) -- Try it in 2 minutes
82
+ - [delimit.ai](https://delimit.ai)
83
+ - [GitHub Action](https://github.com/marketplace/actions/delimit-api-governance)
84
+ - [delimit-cli on npm](https://www.npmjs.com/package/delimit-cli)
85
+ - [Quickstart repo](https://github.com/delimit-ai/delimit-quickstart)
137
86
 
138
87
  ## License
139
88
 
package/SECURITY.md ADDED
@@ -0,0 +1,42 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | --------- |
7
+ | 2.x | Yes |
8
+ | 1.x | No |
9
+
10
+ ## Reporting a Vulnerability
11
+
12
+ We take security seriously at Delimit. If you discover a security vulnerability, please follow these steps:
13
+
14
+ 1. **Do NOT** create a public GitHub issue
15
+ 2. Email security@delimit.ai with:
16
+ - Description of the vulnerability
17
+ - Steps to reproduce
18
+ - Potential impact
19
+ - Your suggested fix (if any)
20
+
21
+ ## Response Timeline
22
+
23
+ - **Acknowledgment**: Within 24 hours
24
+ - **Initial Assessment**: Within 72 hours
25
+ - **Fix Timeline**: Based on severity
26
+ - Critical: Within 7 days
27
+ - High: Within 14 days
28
+ - Medium: Within 30 days
29
+ - Low: Next release
30
+
31
+ ## Security Best Practices
32
+
33
+ When using Delimit:
34
+
35
+ 1. **Never commit API keys or tokens** to your repository
36
+ 2. **Use environment variables** for sensitive configuration
37
+ 3. **Keep Delimit updated** to the latest version
38
+ 4. **Review PR annotations** before merging
39
+
40
+ ## Data Privacy
41
+
42
+ Delimit processes your API specifications locally. The CLI and GitHub Action do not send your specs to external servers.
@@ -107,3 +107,14 @@ module.exports = new DelimitGeminiForge();
107
107
  if (typeof registerExtension === 'function') {
108
108
  registerExtension(new DelimitGeminiForge());
109
109
  }
110
+
111
+ // CLI entrypoint for Gemini hook invocation
112
+ if (require.main === module) {
113
+ const instance = new DelimitGeminiForge();
114
+ instance.getContext()
115
+ .then(ctx => {
116
+ process.stdout.write(JSON.stringify(ctx) + '\n');
117
+ process.exit(0);
118
+ })
119
+ .catch(() => process.exit(0)); // fail open
120
+ }
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Delimit™ Gemini CLI Jamsons Adapter
4
+ * Layer: Jamsons OS (strategy + operational governance)
5
+ * Injects portfolio context, logs decisions, surfaces venture/priority state.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ const axios = require('axios');
11
+ const AGENT_URL = `http://127.0.0.1:${process.env.DELIMIT_AGENT_PORT || 7823}`;
12
+ const JAMSONS_URL = `http://localhost:${process.env.JAMSONS_PORT || 8091}`;
13
+
14
+ const VENTURES = {
15
+ delimit: { priority: 'P0', status: 'active' },
16
+ domainvested: { priority: 'P2', status: 'maintenance' },
17
+ 'wire.report': { priority: 'held', status: 'held' },
18
+ 'livetube.ai': { priority: 'held', status: 'held' },
19
+ };
20
+
21
+ class DelimitGeminiJamsons {
22
+ constructor() {
23
+ this.id = 'delimit-jamsons';
24
+ this.version = '1.0.0';
25
+ }
26
+
27
+ /**
28
+ * Pre-generation: inject portfolio and decision context into request.
29
+ */
30
+ async beforeCodeGeneration(request) {
31
+ try {
32
+ const portfolioCtx = await this._getPortfolioContext(request);
33
+ request._jamsons = portfolioCtx;
34
+ } catch (_) { /* fail open */ }
35
+ return request;
36
+ }
37
+
38
+ async afterResponse(response) {
39
+ try {
40
+ await axios.post(`${JAMSONS_URL}/api/chatops/decisions`, {
41
+ type: 'task',
42
+ title: `Gemini: session response logged`,
43
+ detail: `Model: ${response.model || 'unknown'} | Tool: gemini`,
44
+ user_id: 'gemini-adapter',
45
+ tags: ['delimit', 'chatops'],
46
+ }, {
47
+ headers: { Authorization: `Bearer ${process.env.CHATOPS_AUTH_TOKEN}` },
48
+ timeout: 2000,
49
+ });
50
+ } catch (_) { /* silent */ }
51
+ return response;
52
+ }
53
+
54
+ async _getPortfolioContext(request) {
55
+ const [memory, decisions] = await Promise.allSettled([
56
+ this._searchMemory(request.prompt || 'delimit'),
57
+ this._getPendingDecisions(),
58
+ ]);
59
+
60
+ return {
61
+ ventures: VENTURES,
62
+ activeVenture: this._detectVenture(request),
63
+ memory: memory.status === 'fulfilled' ? memory.value : [],
64
+ pendingDecisions: decisions.status === 'fulfilled' ? decisions.value : [],
65
+ timestamp: new Date().toISOString(),
66
+ };
67
+ }
68
+
69
+ _detectVenture(request) {
70
+ const text = (request.prompt || request.context || '').toLowerCase();
71
+ if (text.includes('delimit')) return 'delimit';
72
+ if (text.includes('domainvested')) return 'domainvested';
73
+ return 'delimit';
74
+ }
75
+
76
+ async _searchMemory(query) {
77
+ const r = await axios.get(`${JAMSONS_URL}/api/memory/search`, {
78
+ params: { q: query, limit: 5 },
79
+ timeout: 2000,
80
+ });
81
+ return r.data?.results || [];
82
+ }
83
+
84
+ async _getPendingDecisions() {
85
+ const r = await axios.get(`${JAMSONS_URL}/api/chatops/decisions`, {
86
+ params: { status: 'pending', limit: 5 },
87
+ headers: { Authorization: `Bearer ${process.env.CHATOPS_AUTH_TOKEN}` },
88
+ timeout: 2000,
89
+ });
90
+ return r.data?.decisions || r.data || [];
91
+ }
92
+
93
+ async handleCommand(command, _args) {
94
+ const { execSync } = require('child_process');
95
+ const commands = {
96
+ '@jamsons': 'delimit status --layer=jamsons',
97
+ '@portfolio': 'delimit portfolio --summary',
98
+ '@decisions': 'delimit decisions --pending',
99
+ '@memory': 'delimit memory --recent',
100
+ };
101
+ if (commands[command]) {
102
+ try {
103
+ return execSync(commands[command], { timeout: 10000 }).toString();
104
+ } catch (e) {
105
+ return `[JAMSONS] Command failed: ${e.message}`;
106
+ }
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Structured context for consensus — call from hooks or consensus runners.
112
+ */
113
+ async getContext() {
114
+ const [memory, decisions] = await Promise.allSettled([
115
+ axios.get(`${JAMSONS_URL}/api/memory/search`, {
116
+ params: { q: 'delimit strategy', limit: 5 },
117
+ timeout: 3000,
118
+ }),
119
+ axios.get(`${JAMSONS_URL}/api/chatops/decisions`, {
120
+ params: { status: 'pending' },
121
+ headers: { Authorization: `Bearer ${process.env.CHATOPS_AUTH_TOKEN}` },
122
+ timeout: 3000,
123
+ }),
124
+ ]);
125
+
126
+ return {
127
+ layer: 'jamsons',
128
+ tool: 'gemini',
129
+ ventures: VENTURES,
130
+ memory: memory.status === 'fulfilled' ? (memory.value.data?.results || []) : null,
131
+ pendingDecisions: decisions.status === 'fulfilled' ? (decisions.value.data || []) : null,
132
+ };
133
+ }
134
+ }
135
+
136
+ module.exports = new DelimitGeminiJamsons();
137
+
138
+ if (typeof registerExtension === 'function') {
139
+ registerExtension(new DelimitGeminiJamsons());
140
+ }
141
+
142
+ // CLI entrypoint for Gemini hook invocation
143
+ if (require.main === module) {
144
+ const instance = new DelimitGeminiJamsons();
145
+ const event = process.argv[2] || 'before-agent';
146
+ instance.getContext()
147
+ .then(ctx => {
148
+ process.stdout.write(JSON.stringify(ctx) + '\n');
149
+ process.exit(0);
150
+ })
151
+ .catch(() => process.exit(0)); // fail open
152
+ }
@@ -1186,6 +1186,14 @@ program
1186
1186
  }
1187
1187
  });
1188
1188
 
1189
+ // Setup command — install MCP governance tools into Claude Code
1190
+ program
1191
+ .command('setup')
1192
+ .description('Install Delimit MCP governance tools into Claude Code')
1193
+ .action(() => {
1194
+ require('./delimit-setup.js');
1195
+ });
1196
+
1189
1197
  // Hide legacy/internal commands from --help
1190
1198
  ['install', 'mode', 'status', 'policy', 'auth', 'audit',
1191
1199
  'explain-decision', 'uninstall', 'proxy', 'hook'].forEach(name => {