thumbgate 1.39.0 → 1.40.1
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/.agents/skills/craft-playbook-gate/SKILL.md +51 -0
- package/.agents/skills/qwenwork-policy-group-honesty-not-clone/SKILL.md +36 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/llms.txt +2 -2
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +11 -5
- package/adapters/claude/.mcp.json +6 -2
- package/adapters/codex/config.toml +5 -0
- package/adapters/forge/forge.yaml +4 -4
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +104 -7
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/strands-middleware.js +31 -4
- package/bin/cli.js +191 -54
- package/config/brand-standards.json +131 -0
- package/config/gates/default.json +18 -1
- package/config/github-about.json +1 -1
- package/config/mcp-allowlists.json +16 -3
- package/config/merge-quality-checks.json +3 -1
- package/config/post-deploy-marketing-pages.json +4 -4
- package/config/schemas/task-outcome-receipt.schema.json +9 -0
- package/hooks/hooks.json +24 -0
- package/openapi/openapi.yaml +7 -3
- package/package.json +87 -33
- package/public/about.html +2 -2
- package/public/admin.html +771 -0
- package/public/agent-manager.html +3 -3
- package/public/agents-cost-savings.html +1 -1
- package/public/ai-malpractice-prevention.html +12 -12
- package/public/architecture.html +0 -1
- package/public/assets/diagrams/decision.svg +3 -3
- package/public/assets/diagrams/hero-thumbs.svg +2 -4
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
- package/public/blog/git-at-agent-scale.html +2 -2
- package/public/blog/inside-your-boundary.html +1 -1
- package/public/blog/process-over-outcome-gates.html +1 -1
- package/public/case-studies.html +5 -6
- package/public/codex-enterprise.html +1 -1
- package/public/codex-plugin.html +1 -1
- package/public/dashboard.html +775 -483
- package/public/diagnostic.html +15 -10
- package/public/enterprise-governance.html +26 -174
- package/public/eval-scorecard.html +3 -4
- package/public/eval-scorecard.json +2 -2
- package/public/evaluations.html +0 -1
- package/public/founders.html +3 -3
- package/public/gaming-playbook.html +4 -4
- package/public/guide.html +3 -5
- package/public/index.html +302 -97
- package/public/install.html +16 -10
- package/public/js/buyer-intent.js +49 -8
- package/public/lessons.html +246 -83
- package/public/numbers.html +32 -33
- package/public/operator-framework.html +44 -72
- package/public/peter.html +3 -3
- package/public/platform-partners.html +1 -1
- package/public/pricing.html +163 -66
- package/public/pro.html +3 -1
- package/public/project-switcher.js +76 -0
- package/public/whitepaper.html +1 -2
- package/scripts/action-receipts.js +393 -0
- package/scripts/activation-quickstart.js +15 -3
- package/scripts/activation-tracker.js +280 -3
- package/scripts/agent-action-inventory.js +235 -143
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-readiness.js +36 -6
- package/scripts/agentic-prompt-pipelines.js +901 -0
- package/scripts/analytics-window.js +7 -1
- package/scripts/async-job-runner.js +66 -11
- package/scripts/audit-trail.js +37 -24
- package/scripts/auto-promote-gates.js +37 -27
- package/scripts/auto-wire-hooks.js +64 -25
- package/scripts/backfill-lesson-scopes.js +122 -0
- package/scripts/billing.js +889 -132
- package/scripts/bot-detection.js +112 -0
- package/scripts/brand-standards-gate.js +571 -0
- package/scripts/chatgpt-ads-readiness-pack.js +1 -1
- package/scripts/cli-demo.js +5 -27
- package/scripts/cli-schema.js +25 -1
- package/scripts/commercial-offer.js +2 -2
- package/scripts/contextfs.js +9 -3
- package/scripts/craft-playbook-gate.js +550 -0
- package/scripts/cross-encoder-reranker.js +4 -0
- package/scripts/dashboard-chat.js +11 -0
- package/scripts/dashboard.js +574 -167
- package/scripts/decision-journal.js +7 -4
- package/scripts/docker-sandbox-planner.js +3 -3
- package/scripts/export-dpo-pairs.js +12 -7
- package/scripts/failure-diagnostics.js +11 -0
- package/scripts/feedback-aggregate.js +4 -0
- package/scripts/feedback-attribution.js +6 -4
- package/scripts/feedback-history-distiller.js +18 -6
- package/scripts/feedback-loop.js +255 -89
- package/scripts/feedback-paths.js +8 -1
- package/scripts/feedback-sanitizer.js +5 -0
- package/scripts/feedback-scope.js +106 -0
- package/scripts/feedback-session.js +8 -2
- package/scripts/filesystem-search.js +13 -8
- package/scripts/financial-control-plane.js +707 -45
- package/scripts/gate-stats.js +38 -5
- package/scripts/gates-engine.js +1326 -240
- package/scripts/generate-eval-scorecard.js +0 -1
- package/scripts/gitlab-sdlc-prompts.js +397 -0
- package/scripts/harness-tool-names.js +31 -5
- package/scripts/hook-runtime.js +10 -0
- package/scripts/hybrid-feedback-context.js +7 -2
- package/scripts/intervention-policy.js +2 -1
- package/scripts/lesson-canonical.js +2 -2
- package/scripts/lesson-db.js +55 -14
- package/scripts/lesson-graph.js +2 -1
- package/scripts/lesson-retrieval.js +95 -9
- package/scripts/lesson-search.js +86 -22
- package/scripts/lesson-synthesis.js +21 -5
- package/scripts/mabl-failure-honesty.js +273 -0
- package/scripts/mailer/index.js +17 -1
- package/scripts/mailer/resend-mailer.js +213 -179
- package/scripts/migrate-project-scope.js +209 -0
- package/scripts/model-distress-detector.js +3 -3
- package/scripts/operational-integrity.js +436 -3
- package/scripts/override-audit.js +2 -0
- package/scripts/owner-admin.js +338 -0
- package/scripts/pr-manager.js +194 -1
- package/scripts/product-feedback.js +35 -0
- package/scripts/progressive-signoff.js +260 -0
- package/scripts/project-catalog.js +243 -0
- package/scripts/project-dashboard.js +61 -0
- package/scripts/project-evidence.js +172 -0
- package/scripts/project-identity.js +182 -0
- package/scripts/project-scope.js +381 -0
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prompt-guard.js +446 -52
- package/scripts/proof-report.js +232 -0
- package/scripts/provider-action-normalizer.js +14 -6
- package/scripts/qwenwork-policy-group.js +413 -0
- package/scripts/rate-limiter.js +41 -0
- package/scripts/secret-redaction.js +171 -25
- package/scripts/secret-scanner.js +101 -42
- package/scripts/self-protection.js +2 -2
- package/scripts/seo-gsd.js +14 -14
- package/scripts/session-context-dedupe.js +66 -0
- package/scripts/settings-hierarchy.js +4 -2
- package/scripts/statusline-meta.js +34 -23
- package/scripts/tailscale-october-access.js +416 -0
- package/scripts/task-outcomes.js +58 -2
- package/scripts/telemetry-analytics.js +260 -16
- package/scripts/thumbgate-search.js +23 -9
- package/scripts/tool-kpi-tracker.js +5 -2
- package/scripts/tool-registry.js +42 -1
- package/scripts/triage-savings-calculator.js +1 -1
- package/scripts/vector-store.js +4 -1
- package/scripts/verified-lessons.js +270 -0
- package/scripts/verify-marketing-pages-deployed.js +2 -2
- package/scripts/workflow-sentinel.js +29 -10
- package/server.json +2 -2
- package/src/api/server.js +2478 -470
- package/src/feedback.js +21 -0
- package/src/hermes-sync-plane.js +2 -1
- package/src/index.js +2 -0
- package/src/lesson-search.js +9 -0
- package/src/mckinsey-top-company-ai-coding.js +493 -0
- package/src/mcp/email-triage-server/index.js +973 -0
- package/src/mcp/email-triage-server/package.json +12 -0
- package/src/mcp/server.js +3 -0
- package/src/mcp-writeguard.js +772 -11
- package/src/openshell-lovable-engine.js +1475 -0
- package/src/task-outcome.js +3 -0
- package/config/evals/agent-safety-eval.json +0 -447
- package/config/evals/retrieval-ranking-golden.json +0 -522
- package/config/progressive/01-wire-only.json +0 -11
- package/config/progressive/02-dashboard-empty-ok.json +0 -10
- package/config/progressive/03-one-lesson.json +0 -10
- package/config/progressive/04-warn-fires.json +0 -11
- package/config/progressive/05-strict-optional.json +0 -11
- package/config/progressive/README.md +0 -15
- package/public/assets/diagrams/agent-integration.png +0 -0
- package/public/assets/diagrams/thumbgate-architecture.png +0 -0
|
@@ -174,7 +174,6 @@ function renderScorecard(input) {
|
|
|
174
174
|
<a href="/eval-scorecard">Scorecard</a>
|
|
175
175
|
<a href="/evaluations">Evaluations</a>
|
|
176
176
|
<a href="/case-studies">Case studies</a>
|
|
177
|
-
<a href="/numbers">Numbers</a>
|
|
178
177
|
<a href="/pricing">Pricing</a>
|
|
179
178
|
</nav>
|
|
180
179
|
<main class="container">
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The ten SDLC prompts are a checklist. A pasted prompt is not a check.
|
|
4
|
+
// Deny the ship action that skips it: a no-breaking-changes claim that also
|
|
5
|
+
// drops a column, a public export, or a config key; a false-positive
|
|
6
|
+
// dismissal with no comment; a test file that names the missing cases and
|
|
7
|
+
// only writes the happy path; a pipeline rerun that pastes the error and
|
|
8
|
+
// names no cause.
|
|
9
|
+
|
|
10
|
+
const GATE = 'gitlab-sdlc-prompts';
|
|
11
|
+
|
|
12
|
+
const EDIT_TOOLS = new Set([
|
|
13
|
+
'edit',
|
|
14
|
+
'write',
|
|
15
|
+
'search_replace',
|
|
16
|
+
'multiedit',
|
|
17
|
+
'strreplace',
|
|
18
|
+
'str_replace',
|
|
19
|
+
]);
|
|
20
|
+
const READ_TOOLS = new Set(['read', 'grep', 'glob', 'search']);
|
|
21
|
+
const BENIGN = new Set([
|
|
22
|
+
'rg', 'grep', 'ag', 'ack', 'echo', 'printf', 'cat', 'head', 'tail', 'less', 'more', 'wc',
|
|
23
|
+
]);
|
|
24
|
+
const WRAPPERS = new Set(['sudo', 'command', 'exec', 'nohup', 'nice', 'time', 'env']);
|
|
25
|
+
|
|
26
|
+
const NO_BREAK_RE = /\bno breaking changes?\b|\bnon-breaking\b|\bbackward[- ]compatible\b|\bnot a breaking change\b/i;
|
|
27
|
+
const SCHEMA_DROP_RE = /\bDROP\s+(?:COLUMN|TABLE)\b|\bALTER\s+TABLE\b[^;\n]{0,120}\bDROP\b/i;
|
|
28
|
+
const REMOVED_EXPORT_RE = /(?:^|\n)-\s*export\s+(?:async\s+)?(?:function|class|const|let|var|type|interface)\s+\w+/;
|
|
29
|
+
const REMOVED_CONFIG_RE = /(?:^|[\n'"])-\s*(?:[A-Z][A-Z0-9_]{2,}|[a-z][\w-]{2,})\s*[:=]/;
|
|
30
|
+
const DISMISS_RE = /dismissal_reason\s*[=:]\s*['"]?false[_ -]?positive|\b(?:glab|gitlab)\b[\s\S]{0,240}\bdismiss\b[\s\S]{0,240}false[_ -]?positive/i;
|
|
31
|
+
const COMMENT_RE = /--comment(?:=|\s+)|"comment"\s*:\s*|comment\s*[:=]\s*/gi;
|
|
32
|
+
const WRITER = new Set(['echo', 'printf', 'cat', 'head', 'tail']);
|
|
33
|
+
const CASE_LABELS = [
|
|
34
|
+
/\bedge cases?\b/i,
|
|
35
|
+
/\berror conditions?\b/i,
|
|
36
|
+
/\bboundary values?\b/i,
|
|
37
|
+
/\binvalid inputs?\b/i,
|
|
38
|
+
];
|
|
39
|
+
const REAL_CASE_RE = /(?:\bit|\btest)\s*\(\s*['"`][^'"`]*(?:edge|error|boundary|invalid|throw|reject)|\b(?:toThrow|assert\.throws|pytest\.raises|rejects\s*\()/i;
|
|
40
|
+
const RERUN_RE = /\b(?:gh\s+run\s+rerun|glab\s+ci\s+(?:retry|rerun))\b/i;
|
|
41
|
+
const ERROR_PASTE_RE = /\b(?:Error:|##\[error\]|exit code\s+[1-9])/;
|
|
42
|
+
const CAUSE_RE = /\b(?:because|root cause|caused by)\b/i;
|
|
43
|
+
|
|
44
|
+
function deny(failureReason, message) {
|
|
45
|
+
return {
|
|
46
|
+
decision: 'deny',
|
|
47
|
+
gate: GATE,
|
|
48
|
+
severity: 'critical',
|
|
49
|
+
failureReason,
|
|
50
|
+
message,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function stripShellComments(text) {
|
|
55
|
+
let out = '';
|
|
56
|
+
let quote = '';
|
|
57
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
58
|
+
const c = text[i];
|
|
59
|
+
if (quote) {
|
|
60
|
+
out += c;
|
|
61
|
+
if (c === '\\' && quote !== "'") {
|
|
62
|
+
out += text[i + 1] || '';
|
|
63
|
+
i += 1;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (c === quote) quote = '';
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (c === '"' || c === "'") {
|
|
70
|
+
quote = c;
|
|
71
|
+
out += c;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (c === '#' && (i === 0 || /[\s;&|()]/.test(text[i - 1]))) {
|
|
75
|
+
while (i < text.length && text[i] !== '\n') i += 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
out += c;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function splitTopLevel(text) {
|
|
84
|
+
const parts = [];
|
|
85
|
+
let out = '';
|
|
86
|
+
let quote = '';
|
|
87
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
88
|
+
const c = text[i];
|
|
89
|
+
if (quote) {
|
|
90
|
+
out += c;
|
|
91
|
+
if (c === '\\' && quote !== "'") {
|
|
92
|
+
out += text[i + 1] || '';
|
|
93
|
+
i += 1;
|
|
94
|
+
} else if (c === quote) quote = '';
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (c === '"' || c === "'") {
|
|
98
|
+
quote = c;
|
|
99
|
+
out += c;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const two = text.slice(i, i + 2);
|
|
103
|
+
if (two === '&&' || two === '||' || c === ';' || c === '|' || c === '\n') {
|
|
104
|
+
if (out.trim()) parts.push(out.trim());
|
|
105
|
+
out = '';
|
|
106
|
+
if (two === '&&' || two === '||') i += 1;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
out += c;
|
|
110
|
+
}
|
|
111
|
+
if (out.trim()) parts.push(out.trim());
|
|
112
|
+
return parts;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function firstExecutable(part) {
|
|
116
|
+
const words = part.trim().split(/\s+/);
|
|
117
|
+
let i = 0;
|
|
118
|
+
while (i < words.length) {
|
|
119
|
+
const bin = words[i].split('/').pop();
|
|
120
|
+
if (!WRAPPERS.has(bin)) return bin;
|
|
121
|
+
i += 1;
|
|
122
|
+
if (bin === 'sudo' && (words[i] === '-u' || words[i] === '--user')) i += 2;
|
|
123
|
+
else if (bin === 'env') {
|
|
124
|
+
while (words[i] && words[i].includes('=')) i += 1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function substitutions(text) {
|
|
131
|
+
const found = [];
|
|
132
|
+
let quote = '';
|
|
133
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
134
|
+
const c = text[i];
|
|
135
|
+
if (quote === "'") {
|
|
136
|
+
if (c === "'") quote = '';
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (quote === '"' && c === '\\') {
|
|
140
|
+
i += 1;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (c === '"') {
|
|
144
|
+
quote = quote === '"' ? '' : '"';
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!quote && c === "'") {
|
|
148
|
+
quote = "'";
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (c !== '$' || text[i + 1] !== '(') continue;
|
|
152
|
+
let depth = 1;
|
|
153
|
+
let body = '';
|
|
154
|
+
let j = i + 2;
|
|
155
|
+
for (; j < text.length && depth > 0; j += 1) {
|
|
156
|
+
if (text[j] === '(') depth += 1;
|
|
157
|
+
else if (text[j] === ')') depth -= 1;
|
|
158
|
+
if (depth > 0) body += text[j];
|
|
159
|
+
}
|
|
160
|
+
if (body.trim()) found.push(body.trim());
|
|
161
|
+
i = j - 1;
|
|
162
|
+
}
|
|
163
|
+
return found;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function breakingDeny(text) {
|
|
167
|
+
if (!NO_BREAK_RE.test(text)) return null;
|
|
168
|
+
if (!SCHEMA_DROP_RE.test(text) && !REMOVED_EXPORT_RE.test(text) && !REMOVED_CONFIG_RE.test(text)) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return deny(
|
|
172
|
+
'breaking_change_hidden',
|
|
173
|
+
'Denied a no-breaking-changes claim that also drops a column, a public export, or a config key. Check the API signature, public methods, return types, database schema, and configuration.',
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function commentBodies(text) {
|
|
178
|
+
const bodies = [];
|
|
179
|
+
const pattern = new RegExp(COMMENT_RE.source, 'gi');
|
|
180
|
+
for (let match = pattern.exec(text); match; match = pattern.exec(text)) {
|
|
181
|
+
let i = match.index + match[0].length;
|
|
182
|
+
while (text[i] === ' ') i += 1;
|
|
183
|
+
const quote = text[i];
|
|
184
|
+
let body = '';
|
|
185
|
+
if (quote === "'" || quote === '"') {
|
|
186
|
+
i += 1;
|
|
187
|
+
while (i < text.length && text[i] !== quote) {
|
|
188
|
+
if (text[i] === '\\' && quote === '"') {
|
|
189
|
+
body += text[i + 1] || '';
|
|
190
|
+
i += 2;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
body += text[i];
|
|
194
|
+
i += 1;
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
while (i < text.length && !/\s/.test(text[i])) {
|
|
198
|
+
body += text[i];
|
|
199
|
+
i += 1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
bodies.push(body);
|
|
203
|
+
pattern.lastIndex = i;
|
|
204
|
+
}
|
|
205
|
+
return bodies;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function hasDismissReason(text) {
|
|
209
|
+
return commentBodies(text).some((body) => body.replace(/\s/g, '').length >= 8);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function dismissDeny(text) {
|
|
213
|
+
if (!DISMISS_RE.test(text) || hasDismissReason(text)) return null;
|
|
214
|
+
return deny(
|
|
215
|
+
'finding_dismissed',
|
|
216
|
+
'Denied a false-positive dismissal with no comment. Name the reason before closing the finding.',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function isTestPath(filePath) {
|
|
221
|
+
const normalized = String(filePath || '').replace(/\\/g, '/');
|
|
222
|
+
return /(?:^|\/)(?:tests?|__tests__|specs?)\//i.test(normalized)
|
|
223
|
+
|| /[^/]*\.(?:test|spec)\.[cm]?[jt]sx?$/i.test(normalized);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function happyPathDeny(text, filePath) {
|
|
227
|
+
if (!isTestPath(filePath)) return null;
|
|
228
|
+
if (CASE_LABELS.filter((pattern) => pattern.test(text)).length < 3) return null;
|
|
229
|
+
if (REAL_CASE_RE.test(text)) return null;
|
|
230
|
+
return deny(
|
|
231
|
+
'happy_path_only',
|
|
232
|
+
'Denied a test write that names the edge, error, boundary, and invalid cases and only implements the happy path.',
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function rerunDeny(text) {
|
|
237
|
+
if (!RERUN_RE.test(text) || !ERROR_PASTE_RE.test(text) || CAUSE_RE.test(text)) return null;
|
|
238
|
+
return deny(
|
|
239
|
+
'pipeline_rerun_without_cause',
|
|
240
|
+
'Denied a pipeline rerun that pastes the error and does not name the cause.',
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function stripQuoted(text) {
|
|
245
|
+
let out = '';
|
|
246
|
+
let quote = '';
|
|
247
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
248
|
+
const c = text[i];
|
|
249
|
+
if (quote) {
|
|
250
|
+
if (c === '\\' && quote !== "'") {
|
|
251
|
+
i += 1;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (c === quote) quote = '';
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
258
|
+
quote = c;
|
|
259
|
+
out += ' ';
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
out += c;
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function isDocPath(filePath) {
|
|
268
|
+
const normalized = String(filePath || '').replace(/\\/g, '/');
|
|
269
|
+
return /\.(?:md|markdown|txt)$/i.test(normalized) || /(?:^|\/)docs?\//i.test(normalized);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function deliveryText(text, filePath) {
|
|
273
|
+
if (isTestPath(filePath)) return stripQuoted(text);
|
|
274
|
+
if (!isDocPath(filePath)) return text;
|
|
275
|
+
return stripQuoted(String(text).replace(/```[\s\S]*?```/g, ' ').replace(/`[^`\n]*`/g, ' '));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function judgeText(text, filePath) {
|
|
279
|
+
return breakingDeny(text)
|
|
280
|
+
|| dismissDeny(text)
|
|
281
|
+
|| happyPathDeny(text, filePath)
|
|
282
|
+
|| rerunDeny(text);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function judgeEdit(text, filePath) {
|
|
286
|
+
const surface = deliveryText(text, filePath);
|
|
287
|
+
return breakingDeny(surface)
|
|
288
|
+
|| dismissDeny(surface)
|
|
289
|
+
|| happyPathDeny(text, filePath)
|
|
290
|
+
|| rerunDeny(surface);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function editsOf(toolInput) {
|
|
294
|
+
const input = toolInput && typeof toolInput === 'object' ? toolInput : {};
|
|
295
|
+
const many = Array.isArray(input.edits) ? input.edits : [input];
|
|
296
|
+
return many.map((edit) => ({
|
|
297
|
+
text: String(edit.new_string ?? edit.newString ?? edit.contents ?? edit.content ?? ''),
|
|
298
|
+
filePath: String(
|
|
299
|
+
edit.file_path ?? edit.filePath ?? edit.path
|
|
300
|
+
?? input.file_path ?? input.filePath ?? input.path
|
|
301
|
+
?? '',
|
|
302
|
+
),
|
|
303
|
+
})).filter((edit) => edit.text);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function heredocBodies(command) {
|
|
307
|
+
const bodies = [];
|
|
308
|
+
const re = /<<-?\s*(['"]?)(\w+)\1/g;
|
|
309
|
+
for (let match = re.exec(command); match; match = re.exec(command)) {
|
|
310
|
+
const start = command.indexOf('\n', match.index);
|
|
311
|
+
const end = start < 0 ? -1 : command.indexOf(`\n${match[2]}`, start + 1);
|
|
312
|
+
if (start >= 0 && end > start) bodies.push(command.slice(start + 1, end));
|
|
313
|
+
}
|
|
314
|
+
return bodies;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function testPathFrom(command) {
|
|
318
|
+
const match = String(command).match(/(?:[\w./-]+\/)?[\w.-]+\.(?:test|spec)\.[cm]?[jt]sx?/);
|
|
319
|
+
return match ? match[0] : '';
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function writesAFile(part) {
|
|
323
|
+
let quote = '';
|
|
324
|
+
for (let i = 0; i < part.length; i += 1) {
|
|
325
|
+
const c = part[i];
|
|
326
|
+
if (quote) {
|
|
327
|
+
if (c === '\\' && quote !== "'") i += 1;
|
|
328
|
+
else if (c === quote) quote = '';
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (c === '"' || c === "'") {
|
|
332
|
+
quote = c;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (c !== '>' || part[i - 1] === '2') continue;
|
|
336
|
+
let j = i + 1;
|
|
337
|
+
while (part[j] === '>') j += 1;
|
|
338
|
+
while (part[j] === ' ') j += 1;
|
|
339
|
+
const target = part.slice(j).match(/^(\S+)/);
|
|
340
|
+
if (target && target[1] !== '/dev/null') return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function shellDeny(command, depth = 0) {
|
|
346
|
+
if (depth > 4 || !String(command || '').trim()) return null;
|
|
347
|
+
const stripped = stripShellComments(command);
|
|
348
|
+
for (const part of splitTopLevel(stripped)) {
|
|
349
|
+
for (const nested of substitutions(part)) {
|
|
350
|
+
const nestedHit = shellDeny(nested, depth + 1);
|
|
351
|
+
if (nestedHit) return nestedHit;
|
|
352
|
+
}
|
|
353
|
+
const bin = firstExecutable(part);
|
|
354
|
+
if (BENIGN.has(bin)) {
|
|
355
|
+
if (WRITER.has(bin) && writesAFile(part)) {
|
|
356
|
+
const written = judgeText(part, testPathFrom(part));
|
|
357
|
+
if (written) return written;
|
|
358
|
+
}
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const hit = judgeText(part, testPathFrom(part));
|
|
362
|
+
if (hit) return hit;
|
|
363
|
+
}
|
|
364
|
+
for (const body of heredocBodies(command)) {
|
|
365
|
+
const hit = judgeText(body, testPathFrom(command));
|
|
366
|
+
if (hit) return hit;
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function shellCommand(view) {
|
|
372
|
+
if (view && typeof view.command === 'string' && view.command.trim()) return view.command;
|
|
373
|
+
const input = view && view.toolInput;
|
|
374
|
+
if (!input || typeof input !== 'object') return '';
|
|
375
|
+
if (typeof input.command === 'string') return input.command;
|
|
376
|
+
if (typeof input.cmd === 'string') return input.cmd;
|
|
377
|
+
return '';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function evaluateGitLabSdlcPrompts(view = {}) {
|
|
381
|
+
const tool = String(view.toolName || '').toLowerCase();
|
|
382
|
+
if (READ_TOOLS.has(tool)) return null;
|
|
383
|
+
if (EDIT_TOOLS.has(tool)) {
|
|
384
|
+
const toolInput = view.toolInput && typeof view.toolInput === 'object' ? view.toolInput : {};
|
|
385
|
+
for (const edit of editsOf(toolInput)) {
|
|
386
|
+
const hit = judgeEdit(edit.text, edit.filePath);
|
|
387
|
+
if (hit) return hit;
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
return shellDeny(shellCommand(view));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
module.exports = {
|
|
395
|
+
GATE,
|
|
396
|
+
evaluateGitLabSdlcPrompts,
|
|
397
|
+
};
|
|
@@ -21,9 +21,16 @@ const TOOL_NAME_MAP = new Map(Object.entries({
|
|
|
21
21
|
apply_diff: 'Edit',
|
|
22
22
|
insert_content: 'Edit',
|
|
23
23
|
search_and_replace: 'Edit',
|
|
24
|
-
// OpenCode / generic MCP
|
|
24
|
+
// OpenCode / Codex / Windows / generic MCP
|
|
25
25
|
bash: 'Bash',
|
|
26
26
|
shell: 'Bash',
|
|
27
|
+
shell_command: 'Bash',
|
|
28
|
+
exec_command: 'Bash',
|
|
29
|
+
local_shell: 'Bash',
|
|
30
|
+
'container.exec': 'Bash',
|
|
31
|
+
powershell: 'Bash',
|
|
32
|
+
pwsh: 'Bash',
|
|
33
|
+
terminal: 'Bash',
|
|
27
34
|
run_command: 'Bash',
|
|
28
35
|
edit_file: 'Edit',
|
|
29
36
|
write_file: 'Write',
|
|
@@ -48,14 +55,26 @@ function canonicalizeToolName(toolName) {
|
|
|
48
55
|
return TOOL_NAME_MAP.get(raw) || TOOL_NAME_MAP.get(raw.toLowerCase()) || raw;
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
function formatCommandArgvToken(item) {
|
|
59
|
+
const text = String(item ?? '');
|
|
60
|
+
if (!text) return '""';
|
|
61
|
+
if (!/[\s"'|&;<>()`\\]/.test(text)) return text;
|
|
62
|
+
return `"${text.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function normalizeCommandValue(value) {
|
|
66
|
+
if (!Array.isArray(value)) return value;
|
|
67
|
+
return value.map((item) => formatCommandArgvToken(item)).join(' ');
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
function canonicalizeToolInput(toolInput) {
|
|
52
71
|
if (!toolInput || typeof toolInput !== 'object' || Array.isArray(toolInput)) return toolInput || {};
|
|
53
72
|
const out = {};
|
|
54
73
|
for (const [key, value] of Object.entries(toolInput)) {
|
|
55
74
|
const canonicalKey = ARG_KEY_MAP.get(key) || key;
|
|
56
|
-
|
|
57
|
-
if (canonicalKey
|
|
58
|
-
out[canonicalKey] = value;
|
|
75
|
+
if (key !== canonicalKey && (value === undefined || toolInput[canonicalKey] !== undefined)) continue;
|
|
76
|
+
if (out[canonicalKey] !== undefined) continue;
|
|
77
|
+
out[canonicalKey] = canonicalKey === 'command' ? normalizeCommandValue(value) : value;
|
|
59
78
|
}
|
|
60
79
|
return out;
|
|
61
80
|
}
|
|
@@ -67,4 +86,11 @@ function canonicalizeToolCall(toolName, toolInput) {
|
|
|
67
86
|
};
|
|
68
87
|
}
|
|
69
88
|
|
|
70
|
-
module.exports = {
|
|
89
|
+
module.exports = {
|
|
90
|
+
canonicalizeToolCall,
|
|
91
|
+
canonicalizeToolName,
|
|
92
|
+
canonicalizeToolInput,
|
|
93
|
+
normalizeCommandValue,
|
|
94
|
+
TOOL_NAME_MAP,
|
|
95
|
+
ARG_KEY_MAP,
|
|
96
|
+
};
|
package/scripts/hook-runtime.js
CHANGED
|
@@ -96,6 +96,10 @@ function claimStopHookCommand() {
|
|
|
96
96
|
return buildPortableHookCommand('claim-stop-check');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
function observeToolResultHookCommand() {
|
|
100
|
+
return buildPortableHookCommand('observe-tool-result');
|
|
101
|
+
}
|
|
102
|
+
|
|
99
103
|
function statuslineCommand() {
|
|
100
104
|
return buildPortableHookCommand('statusline-render');
|
|
101
105
|
}
|
|
@@ -116,6 +120,10 @@ function codexCacheUpdateHookCommand() {
|
|
|
116
120
|
return buildCodexPortableHookCommand('cache-update');
|
|
117
121
|
}
|
|
118
122
|
|
|
123
|
+
function codexObserveToolResultHookCommand() {
|
|
124
|
+
return buildCodexPortableHookCommand('observe-tool-result');
|
|
125
|
+
}
|
|
126
|
+
|
|
119
127
|
function codexStatuslineCommand() {
|
|
120
128
|
return buildCodexPortableHookCommand('statusline-render');
|
|
121
129
|
}
|
|
@@ -125,6 +133,8 @@ module.exports = {
|
|
|
125
133
|
buildCodexPortableHookCommand,
|
|
126
134
|
cacheUpdateHookCommand,
|
|
127
135
|
claimStopHookCommand,
|
|
136
|
+
codexObserveToolResultHookCommand,
|
|
137
|
+
observeToolResultHookCommand,
|
|
128
138
|
codexCacheUpdateHookCommand,
|
|
129
139
|
codexPreToolHookCommand,
|
|
130
140
|
codexSessionStartHookCommand,
|
|
@@ -262,6 +262,8 @@ const ENVELOPE_TOKENS = new Set([
|
|
|
262
262
|
'sessionid', 'transcriptpath', 'hookeventname', 'permissionmode', 'promptid',
|
|
263
263
|
'cwd', 'timestamp', 'metadata', 'payload', 'stdout', 'stderr',
|
|
264
264
|
'users', 'workspace', 'thumbgate', 'igor',
|
|
265
|
+
'test', 'tests', 'spec', 'specs', 'page', 'pages', 'path', 'paths',
|
|
266
|
+
'code', 'line', 'lines', 'data', 'json', 'html', 'node', 'read', 'mock',
|
|
265
267
|
]);
|
|
266
268
|
|
|
267
269
|
function keywords(text) {
|
|
@@ -326,7 +328,9 @@ function buildHybridState(opts) {
|
|
|
326
328
|
const { selectRecordsForScope } = require('./memory-scope-readiness');
|
|
327
329
|
if (o.requireScope && !o.scope) throw new Error('Scoped hybrid state requires scope');
|
|
328
330
|
const readEntries = file => {
|
|
329
|
-
const rows =
|
|
331
|
+
const rows = o.projectKey != null
|
|
332
|
+
? require('./project-catalog').readProjectRows(path.dirname(file), path.basename(file), { projectKey: o.projectKey }).slice(-HYBRID_JSONL_READ_LIMIT)
|
|
333
|
+
: readJsonl(file, HYBRID_JSONL_READ_LIMIT);
|
|
330
334
|
return o.scope ? selectRecordsForScope(rows, o.scope, { includeShared: o.includeShared !== false }).allowed : rows;
|
|
331
335
|
};
|
|
332
336
|
const feedbackEntries = readEntries(feedbackLogPath);
|
|
@@ -925,7 +929,7 @@ function evaluatePretool(toolName, toolInput, opts) {
|
|
|
925
929
|
if ((o.requireScope && !o.scope) || (o.scope && !graph.scopeKey(o.scope))) throw new Error('Scoped hybrid evaluation requires complete scope');
|
|
926
930
|
const graphScope = o.scope ? JSON.stringify([graph.scopeKey(o.scope), o.includeShared !== false]) : null;
|
|
927
931
|
const provenance = graph.graphProvenance({ feedbackDir: getHybridPaths(o).graphFeedbackDir });
|
|
928
|
-
if (artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
|
|
932
|
+
if (o.projectKey == null && artifact && provenance !== 'unavailable' && (artifact.graphProvenance || null) === provenance && (artifact.graphScope || null) === graphScope) {
|
|
929
933
|
const result = evaluateCompiledGuards(artifact, toolName, toolInput);
|
|
930
934
|
if (result.mode !== 'allow') return result;
|
|
931
935
|
|
|
@@ -941,6 +945,7 @@ function evaluatePretool(toolName, toolInput, opts) {
|
|
|
941
945
|
|
|
942
946
|
// Slow path: build live state (also used when compiled guards are stale)
|
|
943
947
|
const state = buildHybridState({
|
|
948
|
+
projectKey: o.projectKey,
|
|
944
949
|
scope: o.scope,
|
|
945
950
|
requireScope: o.requireScope,
|
|
946
951
|
includeShared: o.includeShared,
|
|
@@ -5,6 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const { resolveFeedbackDir } = require('./feedback-paths');
|
|
7
7
|
const { getDecisionLogPath, readDecisionLog, collapseDecisionTimeline } = require('./decision-journal');
|
|
8
|
+
const { isDestructiveDeleteCommand } = require('./operational-integrity');
|
|
8
9
|
const { requireLearnedModelsEntitlement } = require('./entitlement');
|
|
9
10
|
const {
|
|
10
11
|
readTextTail,
|
|
@@ -158,7 +159,7 @@ function extractCommandTokens(command) {
|
|
|
158
159
|
if (/\bgh pr create\b/.test(text)) pushToken(tokens, 'cmd:pr_create');
|
|
159
160
|
if (/\bgh pr merge\b/.test(text)) pushToken(tokens, 'cmd:pr_merge');
|
|
160
161
|
if (/\bnpm publish\b|\byarn publish\b|\bpnpm publish\b/.test(text)) pushToken(tokens, 'cmd:publish');
|
|
161
|
-
if (/\brm -rf\b/.test(text)) pushToken(tokens, 'cmd:destructive_delete');
|
|
162
|
+
if (/\brm -rf\b/.test(text) || isDestructiveDeleteCommand(command)) pushToken(tokens, 'cmd:destructive_delete');
|
|
162
163
|
if (/\b(test|jest|vitest|coverage|prove:|self-heal:check)\b/.test(text)) pushToken(tokens, 'cmd:verification');
|
|
163
164
|
if (/\b(deploy|release|tag)\b/.test(text)) pushToken(tokens, 'cmd:release');
|
|
164
165
|
if (/\b(readme|docs?)\b/.test(text)) pushToken(tokens, 'cmd:docs');
|
|
@@ -125,7 +125,7 @@ function lessonCanonicalSignature(lesson) {
|
|
|
125
125
|
].filter(Boolean).join(' ');
|
|
126
126
|
const textSig = canonicalizeText(blob);
|
|
127
127
|
const tagSig = normalizeTags(lesson.tags).join(',');
|
|
128
|
-
return textSig ? `${textSig}::${tagSig}` : '';
|
|
128
|
+
return textSig ? `${require('./project-identity').projectForRecord(lesson).projectKey}::${textSig}::${tagSig}` : '';
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -163,7 +163,7 @@ function findCanonicalDuplicate(memoryEntries, lesson) {
|
|
|
163
163
|
const entrySignal = entry.signal ? String(entry.signal).toLowerCase() : null;
|
|
164
164
|
if (signalFilter && entrySignal && entrySignal !== signalFilter) continue;
|
|
165
165
|
|
|
166
|
-
const entryHash =
|
|
166
|
+
const entryHash = canonicalHash(entry);
|
|
167
167
|
if (entryHash && entryHash === hash) {
|
|
168
168
|
return entry;
|
|
169
169
|
}
|