thumbgate 1.37.3 → 1.39.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.
- package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
- package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
- package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
- package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
- package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
- package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
- package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
- package/.agents/skills/model-distress-governance/SKILL.md +56 -0
- package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
- package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
- package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
- package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
- package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/forge/forge.yaml +3 -3
- 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/hotdata/hotdata-vector-store.js +575 -0
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -0
- package/adapters/strands/strands-box-diode.js +344 -0
- package/adapters/strands/strands-decider-adapter.js +445 -0
- package/adapters/strands/strands-middleware.js +192 -0
- package/adapters/tailscale/.mcp.json +15 -0
- package/adapters/tailscale/TAILSCALE.md +117 -0
- package/adapters/tailscale/config.toml +16 -0
- package/bin/cli.js +602 -21
- package/config/gate-templates.json +109 -0
- package/config/gates/default.json +13 -0
- package/config/schemas/task-outcome-receipt.schema.json +12 -0
- package/package.json +150 -21
- package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
- package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
- package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
- package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
- package/public/connectors.html +329 -0
- package/public/enterprise-governance.html +311 -0
- package/public/gaming-playbook.html +732 -0
- package/public/index.html +77 -51
- package/public/install.html +7 -7
- package/public/learn.html +14 -0
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/public/operator-framework.html +385 -0
- package/public/pricing.html +14 -10
- package/scripts/activesaddler-curriculum-doctor.js +357 -0
- package/scripts/agent-context-artifact.js +325 -0
- package/scripts/agent-egress-policy.js +2 -2
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-outcome-eval.js +1 -1
- package/scripts/agent-reliability-client.js +148 -0
- package/scripts/apple-minions-idle-compute-steal.js +428 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/billing.js +0 -1
- package/scripts/cli-demo.js +505 -1
- package/scripts/cli-schema.js +36 -0
- package/scripts/colab-compute-honesty.js +93 -0
- package/scripts/corporate-email-isolation-diode.js +299 -0
- package/scripts/coverage-gap.js +396 -0
- package/scripts/dashboard-chat.js +3 -3
- package/scripts/dashboard.js +2 -2
- package/scripts/decisive-step-doctor.js +256 -0
- package/scripts/decisive-step-evaluator.js +390 -0
- package/scripts/entitlement.js +18 -7
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/feedback-loop.js +26 -3
- package/scripts/fiddler-control-plane-honesty.js +303 -0
- package/scripts/financial-control-plane.js +10 -2
- package/scripts/gates-engine.js +3 -1
- package/scripts/github-license-compliance-diode.js +378 -0
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/harness-ceiling-doctor.js +326 -0
- package/scripts/hf-papers.js +1 -1
- package/scripts/human-escalation.js +7 -1
- package/scripts/hybrid-feedback-context.js +53 -7
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/lesson-graph.js +785 -0
- package/scripts/lesson-inference.js +1 -1
- package/scripts/lesson-retrieval.js +26 -18
- package/scripts/license.js +122 -21
- package/scripts/llm-behavior-monitor.js +1 -1
- package/scripts/llm-obs-honesty.js +52 -0
- package/scripts/local-model-profile.js +11 -7
- package/scripts/mailer/resend-mailer.js +6 -3
- package/scripts/mcp-transport-strategy.js +1 -1
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/migrate-lesson-graph.js +442 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +368 -0
- package/scripts/multi-harness-invariants.js +305 -0
- package/scripts/omp-coordination-honesty.js +488 -0
- package/scripts/pro-local-dashboard.js +20 -3
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prove-herdr-adapter.js +367 -3
- package/scripts/rag-embedding-identity.js +1 -1
- package/scripts/rrsi-regularizer.js +531 -0
- package/scripts/saas-moat-honesty.js +443 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/secret-redaction.js +58 -0
- package/scripts/session-export-gate.js +368 -0
- package/scripts/siren-mcp-governance.js +539 -0
- package/scripts/strands-box-doctor.js +130 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/stripe-revenue-catalog-audit.js +12 -0
- package/scripts/stripe-revenue-catalog.js +40 -0
- package/scripts/switchyard-router.js +153 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/task-outcomes.js +148 -3
- package/scripts/thumbgate-board-loop.js +4 -2
- package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
- package/scripts/triage-savings-calculator.js +181 -0
- package/scripts/vector-store.js +41 -2
- package/scripts/vulnerability-pre-action-diode.js +319 -0
- package/scripts/windbg-evidence-diagnostics.js +241 -0
- package/scripts/workflow-intake-queue.js +1 -1
- package/scripts/workspace-agent-routines.js +534 -6
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/siren-mcp-governance/SKILL.md +50 -0
- package/src/api/server.js +191 -5
- package/src/mcp-writeguard.js +1 -1
- package/src/session-interactivity.js +284 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scripts/corporate-email-isolation-diode.js
|
|
6
|
+
*
|
|
7
|
+
* 1. Hard Pre-Action Security Firewall (`gate:security:eci_corporate_email_isolation`)
|
|
8
|
+
* preventing any personal/ThumbGate/Boardy/Viktor agent, Playwright script, or MCP tool
|
|
9
|
+
* from ever sending, drafting, replying, CC'ing, or referencing ECI corporate email
|
|
10
|
+
* domains (`@ecisolutions.com`, `@ecinexus.com`, `@eci.com`) or interacting with
|
|
11
|
+
* corporate Microsoft Outlook.
|
|
12
|
+
*
|
|
13
|
+
* 2. Obsidian Enveloppe (`enveloppe/obsidian-enveloppe`) Vault Egress & Censor Compiler
|
|
14
|
+
* (`compileEnveloppeVaultNoteForEgress`):
|
|
15
|
+
* - Enforces `share: true` default-deny opt-in frontmatter gate before any vault note
|
|
16
|
+
* can be published or shared externally.
|
|
17
|
+
* - Executes Enveloppe's two-pass `censorText` scrubbing pipeline (`before` and `after`
|
|
18
|
+
* WikiLink-to-Markdown conversion, respecting `inCodeBlocks`).
|
|
19
|
+
* - Hard-blocks cross-boundary repo/channel routing (any note with ECI/PSN/DIST03
|
|
20
|
+
* markers is refused egress to personal GitHub, Gmail, Boardy, or Viktor).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const FORBIDDEN_CORP_PATTERNS = [
|
|
24
|
+
/@ecisolutions\.com\b/i,
|
|
25
|
+
/@ecinexus\.com\b/i,
|
|
26
|
+
/@eci\.com\b/i,
|
|
27
|
+
/\becisolutions\.com\b/i,
|
|
28
|
+
/\becinexus\.com\b/i,
|
|
29
|
+
/\bMicrosoft Outlook\.app\b/i,
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const DEFAULT_ENVELOPPE_CENSOR_RULES = [
|
|
33
|
+
{ entry: '/[a-zA-Z0-9._%+-]+@(?:ecisolutions|ecinexus|eci)\\.com/gi', replace: '[REDACTED_CORP_EMAIL]', after: false, inCodeBlocks: true },
|
|
34
|
+
{ entry: '/\\b10\\.10\\.\\d{1,3}\\.\\d{1,3}\\b/g', replace: '[REDACTED_CORP_IP]', after: false, inCodeBlocks: true },
|
|
35
|
+
{ entry: '/\\bDIST03-\\d+\\b/gi', replace: '[REDACTED_CORP_TICKET]', after: true, inCodeBlocks: true },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function evaluateCorporateEmailIsolationGate({
|
|
39
|
+
toolName = '',
|
|
40
|
+
commandOrPayload = '',
|
|
41
|
+
recipients = [],
|
|
42
|
+
} = {}) {
|
|
43
|
+
const startNs = process.hrtime.bigint();
|
|
44
|
+
const recipStr = Array.isArray(recipients) ? recipients.join(' ') : String(recipients || '');
|
|
45
|
+
const payloadStr = typeof commandOrPayload === 'string' ? commandOrPayload : JSON.stringify(commandOrPayload || {});
|
|
46
|
+
const blob = `${toolName} ${recipStr} ${payloadStr}`;
|
|
47
|
+
|
|
48
|
+
let decision = 'allow';
|
|
49
|
+
let gateId = 'gate:security:personal_boundary_verified';
|
|
50
|
+
let reason = 'Verified zero corporate ECI email/domain contamination';
|
|
51
|
+
|
|
52
|
+
for (const rx of FORBIDDEN_CORP_PATTERNS) {
|
|
53
|
+
if (rx.test(blob)) {
|
|
54
|
+
decision = 'block';
|
|
55
|
+
gateId = 'gate:security:eci_corporate_email_isolation';
|
|
56
|
+
reason = `CRITICAL SECURITY BLOCK: Corporate ECI domain/client matched (${rx}) — personal/ThumbGate/Boardy agents must NEVER touch @ecisolutions.com, @ecinexus.com, or corporate Outlook`;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Also block bare display-name "Igor Ganapolsky" without explicit @gmail.com / @ganapolsky.com in email To/Cc fields
|
|
62
|
+
if (
|
|
63
|
+
decision === 'allow' &&
|
|
64
|
+
/(?:gmail|send_email|create_draft|view=cm)/i.test(blob) &&
|
|
65
|
+
/\bto=Igor(?:\+|%20|\s)Ganapolsky\b/i.test(blob) &&
|
|
66
|
+
!/(?:iganapolsky@gmail\.com|igor@ganapolsky\.com)/i.test(blob)
|
|
67
|
+
) {
|
|
68
|
+
decision = 'block';
|
|
69
|
+
gateId = 'gate:security:ambiguous_self_recipient_autocomplete';
|
|
70
|
+
reason = 'Blocked bare display-name recipient "Igor Ganapolsky" (can autocomplete to corporate address); require explicit iganapolsky@gmail.com';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const latencyMs = Number((Number(process.hrtime.bigint() - startNs) / 1e6).toFixed(3));
|
|
74
|
+
return {
|
|
75
|
+
decision,
|
|
76
|
+
allowed: decision === 'allow',
|
|
77
|
+
gateId,
|
|
78
|
+
latencyMs,
|
|
79
|
+
reason,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function createRegexFromEnveloppeEntry(toReplace, withFlag) {
|
|
84
|
+
let flags = withFlag;
|
|
85
|
+
if (!flags) {
|
|
86
|
+
const flagsMatch = toReplace.match(/\/([gimy]+)$/);
|
|
87
|
+
flags = flagsMatch ? Array.from(new Set(flagsMatch[1].split(''))).join('') : 'g';
|
|
88
|
+
}
|
|
89
|
+
const body = toReplace.replace(/^\/(.+)\/[gimy]*$/, '$1');
|
|
90
|
+
return new RegExp(body, flags);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function applyEnveloppeCensorPass(text, censorRules = DEFAULT_ENVELOPPE_CENSOR_RULES, after = false) {
|
|
94
|
+
let out = String(text || '');
|
|
95
|
+
const activeRules = censorRules.filter(r => Boolean(r.after) === Boolean(after));
|
|
96
|
+
for (const censor of activeRules) {
|
|
97
|
+
if (!censor.entry || !censor.entry.trim()) continue;
|
|
98
|
+
const isRegex = /^\/.+\/[gimy]*$/.test(censor.entry);
|
|
99
|
+
const pattern = isRegex ? createRegexFromEnveloppeEntry(censor.entry, censor.flags) : censor.entry;
|
|
100
|
+
if (censor.inCodeBlocks) {
|
|
101
|
+
out = out.replace(pattern, censor.replace);
|
|
102
|
+
} else {
|
|
103
|
+
// Replace only outside fenced/inline code blocks (stolen from Enveloppe replaceText)
|
|
104
|
+
const parts = out.split(/(```[\s\S]*?```|`[^`]*`)/g);
|
|
105
|
+
out = parts
|
|
106
|
+
.map(segment => (segment.startsWith('`') ? segment : segment.replace(pattern, censor.replace)))
|
|
107
|
+
.join('');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function convertWikiLinksToMarkdown(text) {
|
|
114
|
+
return String(text || '').replace(/(?<!!)\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g, (_, target, alias) => {
|
|
115
|
+
const label = (alias || target).trim();
|
|
116
|
+
const slug = target.trim().replace(/\s+/g, '-').toLowerCase();
|
|
117
|
+
return `[${label}](./${slug}.md)`;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const SENSITIVE_EMBED_OR_CFO_RX =
|
|
122
|
+
/(?:@ecisolutions\.com|@ecinexus\.com|@eci\.com|\bStockService\b|\bDIST03-\d+\b|\b10\.10\.20\.|\bDebts\b|\bBudget\b|\baccount_mask\b|\bbalance_usd\b|\bapr_pct\b)/i;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Compile and gate an Obsidian vault note for external publishing (Enveloppe steal).
|
|
126
|
+
* Supports:
|
|
127
|
+
* - Default-deny `share: true` (or repo-specific `shareKey`, e.g., `share_thumbgate: true`)
|
|
128
|
+
* - Disjoint corporate vs. personal `shareKey` isolation
|
|
129
|
+
* - Transitive embed/transclusion diode (`![[ChildNote]]` inspected against `vaultNotes` and sensitive markers)
|
|
130
|
+
* - Two-pass `censorText` scrubbing (`before` and `after` WikiLink conversion, respecting `inCodeBlocks`)
|
|
131
|
+
*/
|
|
132
|
+
function compileEnveloppeVaultNoteForEgress({
|
|
133
|
+
frontmatter = {},
|
|
134
|
+
body = '',
|
|
135
|
+
targetRepo = 'IgorGanapolsky/ThumbGate',
|
|
136
|
+
shareKey = 'share',
|
|
137
|
+
vaultNotes = {},
|
|
138
|
+
censorRules = DEFAULT_ENVELOPPE_CENSOR_RULES,
|
|
139
|
+
} = {}) {
|
|
140
|
+
// 1. Default-deny: must explicitly set the configured shareKey: true
|
|
141
|
+
if (frontmatter[shareKey] !== true) {
|
|
142
|
+
return {
|
|
143
|
+
allowed: false,
|
|
144
|
+
gateId: 'gate:enveloppe:share_false_default_deny',
|
|
145
|
+
reason: `Vault note has ${shareKey} !== true; default-deny prevents accidental external publishing`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 2. Cross-boundary repo & shareKey check: never allow ECI/PSN/StockService/CFO notes onto personal GitHub
|
|
150
|
+
const rawBlob = `${JSON.stringify(frontmatter)} ${body}`;
|
|
151
|
+
if (
|
|
152
|
+
/IgorGanapolsky/i.test(targetRepo) &&
|
|
153
|
+
(frontmatter.share_eci === true ||
|
|
154
|
+
/(?:@ecisolutions\.com|@ecinexus\.com|@eci\.com|\bStockService\b|\bDIST03-\d+\b|\b10\.10\.20\.)/i.test(rawBlob))
|
|
155
|
+
) {
|
|
156
|
+
return {
|
|
157
|
+
allowed: false,
|
|
158
|
+
gateId: 'gate:enveloppe:corp_to_personal_repo_blocked',
|
|
159
|
+
reason: `Blocked corporate ECI/PSN note from publishing to personal target '${targetRepo}'`,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (/\b(?:account_mask|balance_usd|apr_pct)\b|\[\[(?:Debts|Budget|Institutions)\]\]/i.test(rawBlob)) {
|
|
164
|
+
return {
|
|
165
|
+
allowed: false,
|
|
166
|
+
gateId: 'gate:enveloppe:cfo_finance_diode_blocked',
|
|
167
|
+
reason: `Blocked private CFO financial note from publishing to '${targetRepo}'`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 3. Transitive Embed / Transclusion Diode (`![[Target]]`)
|
|
172
|
+
const embedMatches = Array.from(String(body || '').matchAll(/!\[\[([^\]|#]+)(?:[|#][^\]]*)?\]\]/g));
|
|
173
|
+
for (const m of embedMatches) {
|
|
174
|
+
const rawTarget = m[1].trim();
|
|
175
|
+
if (/\.base$/i.test(rawTarget)) continue; // .base views are stripped before publish
|
|
176
|
+
const child = vaultNotes[rawTarget] || vaultNotes[`${rawTarget}.md`];
|
|
177
|
+
if (child) {
|
|
178
|
+
const childFm = child.frontmatter || {};
|
|
179
|
+
const childBlob = `${JSON.stringify(childFm)} ${child.body || ''}`;
|
|
180
|
+
if (childFm[shareKey] !== true || SENSITIVE_EMBED_OR_CFO_RX.test(childBlob)) {
|
|
181
|
+
return {
|
|
182
|
+
allowed: false,
|
|
183
|
+
gateId: 'gate:enveloppe:transitive_embed_leak_blocked',
|
|
184
|
+
reason: `Blocked transitive embed '![[${rawTarget}]]' because child note is not ${shareKey}:true or contains isolated corporate/financial data`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
} else if (SENSITIVE_EMBED_OR_CFO_RX.test(rawTarget)) {
|
|
188
|
+
return {
|
|
189
|
+
allowed: false,
|
|
190
|
+
gateId: 'gate:enveloppe:transitive_embed_leak_blocked',
|
|
191
|
+
reason: `Blocked sensitive transitive embed target '![[${rawTarget}]]'`,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 4. Strip private Enveloppe comments (`%% ... %%`, `<!-- enveloppe:private:start -->...`) & `.base` embeds
|
|
197
|
+
const strippedBody = String(body || '')
|
|
198
|
+
.replace(/<!--\s*enveloppe:private:start\s*-->[\s\S]*?<!--\s*enveloppe:private:end\s*-->/gi, '')
|
|
199
|
+
.replace(/%%[\s\S]*?%%/g, '')
|
|
200
|
+
.replace(/!\[\[[^\]]+\.base\]\]\n?/gi, '');
|
|
201
|
+
|
|
202
|
+
// 5. Pass 1 censor (before link compilation) -> WikiLink compilation -> Pass 2 censor (after)
|
|
203
|
+
const pass1 = applyEnveloppeCensorPass(strippedBody, censorRules, false);
|
|
204
|
+
const compiledLinks = convertWikiLinksToMarkdown(pass1);
|
|
205
|
+
const compiledBody = applyEnveloppeCensorPass(compiledLinks, censorRules, true);
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
allowed: true,
|
|
209
|
+
gateId: 'gate:enveloppe:verified_egress',
|
|
210
|
+
targetRepo,
|
|
211
|
+
shareKey,
|
|
212
|
+
compiledBody,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Reconcile downstream repository files when vault notes are depublished (`share: false`) or deleted
|
|
218
|
+
* (stolen from Enveloppe's `autoClean` + `autoclean.excluded` architecture).
|
|
219
|
+
*/
|
|
220
|
+
function reconcileEnveloppeAutoClean({
|
|
221
|
+
vaultNotes = [],
|
|
222
|
+
publishedRepoPaths = [],
|
|
223
|
+
excludedPaths = ['README.md', 'docs/index.md', 'CLAUDE.md', 'AGENTS.md'],
|
|
224
|
+
shareKey = 'share',
|
|
225
|
+
} = {}) {
|
|
226
|
+
const activeSharedPaths = new Set(
|
|
227
|
+
vaultNotes
|
|
228
|
+
.filter(n => n && n.frontmatter && n.frontmatter[shareKey] === true && n.targetPath)
|
|
229
|
+
.map(n => String(n.targetPath).replace(/^\/+/, ''))
|
|
230
|
+
);
|
|
231
|
+
const excludedSet = new Set(excludedPaths.map(p => String(p).replace(/^\/+/, '')));
|
|
232
|
+
|
|
233
|
+
const toDelete = [];
|
|
234
|
+
const retained = [];
|
|
235
|
+
for (const rawPath of publishedRepoPaths) {
|
|
236
|
+
const cleanPath = String(rawPath).replace(/^\/+/, '');
|
|
237
|
+
if (excludedSet.has(cleanPath) || activeSharedPaths.has(cleanPath)) {
|
|
238
|
+
retained.push(cleanPath);
|
|
239
|
+
} else {
|
|
240
|
+
toDelete.push(cleanPath);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
autoCleanEnabled: true,
|
|
245
|
+
activeSharedCount: activeSharedPaths.size,
|
|
246
|
+
retained,
|
|
247
|
+
toDelete,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const ENVELOPPE_STEAL_MAP = [
|
|
252
|
+
{
|
|
253
|
+
enveloppeFeature: 'Opt-in frontmatter share:true + per-repo shareKey (multipleRepo / shortRepo)',
|
|
254
|
+
thumbgateRail: 'compileEnveloppeVaultNoteForEgress() + disjoint shareKey (share vs share_eci)',
|
|
255
|
+
securityGuarantee: 'Default-deny; corporate ECI notes (share_eci) can never route to personal repos/Gmail/Boardy',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
enveloppeFeature: 'Two-pass regex censorText (before & after WikiLink conversion, inCodeBlocks)',
|
|
259
|
+
thumbgateRail: 'applyEnveloppeCensorPass() + DEFAULT_ENVELOPPE_CENSOR_RULES',
|
|
260
|
+
securityGuarantee: 'Scrubs @ecisolutions.com, @ecinexus.com, 10.10.*.*, and DIST03-* before & after link compilation',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
enveloppeFeature: 'Transclusion / embed baking (![[Note]]) & private %% comment stripping',
|
|
264
|
+
thumbgateRail: 'Transitive Embed Diode (gate:enveloppe:transitive_embed_leak_blocked)',
|
|
265
|
+
securityGuarantee: 'Blocks any share:true note that embeds a share:false, corporate ECI, or CFO financial note',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
enveloppeFeature: 'autoClean depublish pruning with autoclean.excluded path protection',
|
|
269
|
+
thumbgateRail: 'reconcileEnveloppeAutoClean()',
|
|
270
|
+
securityGuarantee: 'Automatically prunes depublished notes from downstream repos without touching README/AGENTS.md',
|
|
271
|
+
},
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
if (require.main === module) {
|
|
275
|
+
const args = process.argv.slice(2);
|
|
276
|
+
const mapOnly = args.includes('--map-only');
|
|
277
|
+
const sampleCheck = evaluateCorporateEmailIsolationGate({
|
|
278
|
+
toolName: 'gmail_send',
|
|
279
|
+
recipients: ['iganapolsky@ecisolutions.com'],
|
|
280
|
+
});
|
|
281
|
+
const payload = {
|
|
282
|
+
status: 'ok',
|
|
283
|
+
source: 'https://github.com/enveloppe/obsidian-enveloppe',
|
|
284
|
+
stealMap: ENVELOPPE_STEAL_MAP,
|
|
285
|
+
...(mapOnly ? {} : { sampleCorporateIsolationCheck: sampleCheck }),
|
|
286
|
+
};
|
|
287
|
+
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
module.exports = {
|
|
291
|
+
FORBIDDEN_CORP_PATTERNS,
|
|
292
|
+
DEFAULT_ENVELOPPE_CENSOR_RULES,
|
|
293
|
+
ENVELOPPE_STEAL_MAP,
|
|
294
|
+
evaluateCorporateEmailIsolationGate,
|
|
295
|
+
applyEnveloppeCensorPass,
|
|
296
|
+
convertWikiLinksToMarkdown,
|
|
297
|
+
compileEnveloppeVaultNoteForEgress,
|
|
298
|
+
reconcileEnveloppeAutoClean,
|
|
299
|
+
};
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* VS "Today I will improve test coverage" FORMAT steal — not a Test Agent clone.
|
|
6
|
+
*
|
|
7
|
+
* Source: https://devblogs.microsoft.com/visualstudio/today-i-will-improve-test-coverage/
|
|
8
|
+
*
|
|
9
|
+
* Transfers:
|
|
10
|
+
* 1. Baseline first — find gaps before writing tests
|
|
11
|
+
* 2. Skip no-behavior files (enums, re-exports, constants-only)
|
|
12
|
+
* 3. Remeasure the SAME scope after; never cov-fail-under=100
|
|
13
|
+
*
|
|
14
|
+
* Maps onto scripts/test-coverage.js (feature-detected Node coverage flags).
|
|
15
|
+
* Does NOT clone GitHub Copilot Test Agent or `@test #solution`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs');
|
|
19
|
+
const path = require('node:path');
|
|
20
|
+
|
|
21
|
+
const SOURCE_URL = 'https://devblogs.microsoft.com/visualstudio/today-i-will-improve-test-coverage/';
|
|
22
|
+
const DEFAULT_FLOOR = 50;
|
|
23
|
+
const NO_BEHAVIOR_KINDS = Object.freeze(['enum', 'constants', 'reexport', 'empty', 'types']);
|
|
24
|
+
|
|
25
|
+
const CLONE_PATTERNS = Object.freeze([
|
|
26
|
+
{ id: 'test_agent', re: /\b(clone|install|vendor)\b.{0,40}\b(test agent|github copilot testing)\b/i },
|
|
27
|
+
{ id: 'at_test_solution', re: /@test\s+#solution/i },
|
|
28
|
+
{ id: 'fail_under_100', re: /\bcov-fail-under\s*=\s*100\b/i },
|
|
29
|
+
{ id: 'claim_100', re: /\b(claim|require|enforce)\b.{0,30}\b100%\s*coverage\b/i },
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
function normalizeBoolean(value) {
|
|
33
|
+
if (value === true || value === 1) return true;
|
|
34
|
+
if (value === false || value === 0 || value == null) return false;
|
|
35
|
+
return /^(1|true|yes|on)$/i.test(String(value).trim());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function detectCloneAttempt(text) {
|
|
39
|
+
const t = String(text || '');
|
|
40
|
+
return CLONE_PATTERNS.filter((p) => p.re.test(t)).map((p) => p.id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isCommentOnly(source) {
|
|
44
|
+
let offset = 0;
|
|
45
|
+
while (offset < source.length) {
|
|
46
|
+
if (/\s/.test(source[offset])) { offset += 1; continue; }
|
|
47
|
+
if (source.startsWith('//', offset)) {
|
|
48
|
+
offset += 2;
|
|
49
|
+
while (offset < source.length && !'\n\r\u2028\u2029'.includes(source[offset])) offset += 1;
|
|
50
|
+
} else if (source.startsWith('/*', offset)) {
|
|
51
|
+
const end = source.indexOf('*/', offset + 2);
|
|
52
|
+
if (end === -1) return false;
|
|
53
|
+
offset = end + 2;
|
|
54
|
+
} else return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function classifySource(src, filePath = '') {
|
|
60
|
+
const name = String(filePath).replace(/\\/g, '/');
|
|
61
|
+
if (/\.d\.ts$/.test(name)) return 'types';
|
|
62
|
+
const body = String(src || '').trim();
|
|
63
|
+
if (isCommentOnly(body)) return 'empty';
|
|
64
|
+
if (/^export\s*\{[\w\s,$]*\}\s*from\s+['"][^'"\n]+['"]\s*;?\s*$/.test(body)) return 'reexport';
|
|
65
|
+
const code = body.replace(/^['"]use strict['"];?/gm, '').trim();
|
|
66
|
+
const literal = String.raw`(?:-?\d+(?:\.\d+)?|true|false|null|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`;
|
|
67
|
+
const field = String.raw`\s*[A-Za-z_$][\w$]*\s*:\s*${literal}\s*`;
|
|
68
|
+
const frozen = new RegExp(String.raw`^(?:module\.exports\s*=|(?:export\s+)?const\s+[A-Za-z_$][\w$]*\s*=)\s*Object\.freeze\(\{(?:${field}(?:,${field})*,?)?\}\)\s*;?$`);
|
|
69
|
+
if (frozen.test(code)) return 'enum';
|
|
70
|
+
const constant = new RegExp(String.raw`^(?:(?:export\s+)?const\s+[A-Za-z_$][\w$]*\s*=\s*${literal}\s*;\s*)+$`);
|
|
71
|
+
if (constant.test(code)) return 'constants';
|
|
72
|
+
return 'behavior';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function inScope(filePath, scope) {
|
|
76
|
+
if (!scope) return true;
|
|
77
|
+
const n = String(filePath).replace(/\\/g, '/');
|
|
78
|
+
const s = String(scope).replace(/\\/g, '/').replace(/^\.\//, '');
|
|
79
|
+
return n === s || n.startsWith(`${s.replace(/\/$/, '')}/`) || n.includes(`/${s.replace(/\/$/, '')}/`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function filePct(entry) {
|
|
83
|
+
if (!entry || typeof entry !== 'object') return 0;
|
|
84
|
+
if (Number.isFinite(Number(entry.pct))) return Number(entry.pct);
|
|
85
|
+
const lines = Number(entry.lines);
|
|
86
|
+
const covered = Number(entry.covered);
|
|
87
|
+
if (Number.isFinite(lines) && lines > 0 && Number.isFinite(covered)) {
|
|
88
|
+
return Math.round((1000 * covered) / lines) / 10;
|
|
89
|
+
}
|
|
90
|
+
if (entry.s && typeof entry.s === 'object') {
|
|
91
|
+
const vals = Object.values(entry.s);
|
|
92
|
+
if (!vals.length) return 0;
|
|
93
|
+
const hit = vals.filter((n) => Number(n) > 0).length;
|
|
94
|
+
return Math.round((1000 * hit) / vals.length) / 10;
|
|
95
|
+
}
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function normalizeFiles(coverage) {
|
|
100
|
+
if (!coverage || typeof coverage !== 'object') return [];
|
|
101
|
+
const raw = coverage.files && typeof coverage.files === 'object' && !Array.isArray(coverage.files)
|
|
102
|
+
? coverage.files
|
|
103
|
+
: coverage;
|
|
104
|
+
const rows = [];
|
|
105
|
+
for (const [filePath, entry] of Object.entries(raw)) {
|
|
106
|
+
if (filePath === 'files' || filePath === 'totals') continue;
|
|
107
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
108
|
+
const src = entry.source != null ? String(entry.source) : '';
|
|
109
|
+
const kind = entry.kind || (src ? classifySource(src, filePath) : (entry.noBehavior ? 'constants' : 'behavior'));
|
|
110
|
+
const statements = entry.s && typeof entry.s === 'object' ? Object.values(entry.s) : [];
|
|
111
|
+
const statementOnly = entry.lines == null && entry.covered == null && statements.length > 0;
|
|
112
|
+
rows.push({
|
|
113
|
+
path: filePath.replace(/\\/g, '/'),
|
|
114
|
+
pct: filePct(entry),
|
|
115
|
+
lines: statementOnly ? statements.length : Number(entry.lines) || 0,
|
|
116
|
+
covered: statementOnly ? statements.filter(value => Number(value) > 0).length : Number(entry.covered) || 0,
|
|
117
|
+
kind,
|
|
118
|
+
noBehavior: NO_BEHAVIOR_KINDS.includes(kind) || entry.noBehavior === true,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return rows;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function baselineCoverage(coverage, options = {}) {
|
|
125
|
+
const floor = options.floor == null ? DEFAULT_FLOOR : Number(options.floor);
|
|
126
|
+
if (!Number.isFinite(floor) || floor < 0 || floor > 100) throw new RangeError('Coverage floor must be a finite percentage from 0 to 100');
|
|
127
|
+
const scope = options.scope || '';
|
|
128
|
+
const skipNoBehavior = options.skipNoBehavior !== false;
|
|
129
|
+
const rows = normalizeFiles(coverage).filter((r) => inScope(r.path, scope));
|
|
130
|
+
const skipped = skipNoBehavior ? rows.filter((r) => r.noBehavior) : [];
|
|
131
|
+
const behavioral = skipNoBehavior ? rows.filter((r) => !r.noBehavior) : rows;
|
|
132
|
+
const gaps = behavioral.filter((r) => r.pct < floor).sort((a, b) => a.pct - b.pct);
|
|
133
|
+
const coveredSum = behavioral.reduce((n, r) => n + r.covered, 0);
|
|
134
|
+
const lineSum = behavioral.reduce((n, r) => n + r.lines, 0);
|
|
135
|
+
const pct = lineSum > 0 ? Math.round((1000 * coveredSum) / lineSum) / 10 : (behavioral.length ? 0 : null);
|
|
136
|
+
return {
|
|
137
|
+
scope: scope || '(all)',
|
|
138
|
+
floor,
|
|
139
|
+
skipNoBehavior,
|
|
140
|
+
files: behavioral.length,
|
|
141
|
+
skippedNoBehavior: skipped.map((r) => ({ path: r.path, kind: r.kind })),
|
|
142
|
+
gaps: gaps.map((r) => ({ path: r.path, pct: r.pct, kind: r.kind })),
|
|
143
|
+
pct,
|
|
144
|
+
claim100: options.claim100 === true,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function compareCoverage(beforeCov, afterCov, options = {}) {
|
|
149
|
+
const before = baselineCoverage(beforeCov, options);
|
|
150
|
+
const after = baselineCoverage(afterCov, options);
|
|
151
|
+
const findings = [];
|
|
152
|
+
if (String(options.beforeScope || before.scope) !== String(options.afterScope || after.scope)
|
|
153
|
+
&& options.beforeScope && options.afterScope
|
|
154
|
+
&& options.beforeScope !== options.afterScope) {
|
|
155
|
+
findings.push({
|
|
156
|
+
severity: 'fail',
|
|
157
|
+
id: 'scope_drift',
|
|
158
|
+
message: `Remeasure used a different scope (${options.afterScope}) than baseline (${options.beforeScope}). Same-scope only.`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (after.claim100 || options.claim100 === true || after.pct >= 100 && options.require100 === true) {
|
|
162
|
+
findings.push({
|
|
163
|
+
severity: 'fail',
|
|
164
|
+
id: 'claim_100',
|
|
165
|
+
message: 'Never cov-fail-under=100 and never claim 100% coverage as the win. Gaps, not completeness.',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const oldGapPaths = new Set(before.gaps.map(gap => gap.path));
|
|
169
|
+
const newGaps = after.gaps.filter(gap => !oldGapPaths.has(gap.path));
|
|
170
|
+
if (newGaps.length) findings.push({ severity: 'fail', id: 'new_gaps', message: `New uncovered behavioral files: ${newGaps.map(gap => gap.path).join(', ')}` });
|
|
171
|
+
if (after.gaps.length > before.gaps.length) {
|
|
172
|
+
findings.push({
|
|
173
|
+
severity: 'fail',
|
|
174
|
+
id: 'gaps_grew',
|
|
175
|
+
message: `Behavioral gaps grew ${before.gaps.length} → ${after.gaps.length} in scope ${after.scope}.`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (after.pct + 0.05 < before.pct) {
|
|
179
|
+
findings.push({
|
|
180
|
+
severity: 'fail',
|
|
181
|
+
id: 'pct_dropped',
|
|
182
|
+
message: `Scoped behavioral coverage dropped ${before.pct}% → ${after.pct}%.`,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (before.files === 0 || after.files === 0) {
|
|
186
|
+
findings.push({ severity: 'fail', id: 'no_behavioral_data', message: 'Both measurements need behavioral coverage in the selected scope.' });
|
|
187
|
+
}
|
|
188
|
+
return { before, after, findings };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function loadJson(filePath) {
|
|
192
|
+
if (!filePath) return null;
|
|
193
|
+
if (typeof filePath === 'object') return filePath;
|
|
194
|
+
return JSON.parse(fs.readFileSync(String(filePath), 'utf8'));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function collectCloneHaystack(options = {}) {
|
|
198
|
+
const parts = [
|
|
199
|
+
options.task,
|
|
200
|
+
options.query,
|
|
201
|
+
options['clone-test-agent'] ? 'clone Test Agent @test #solution' : '',
|
|
202
|
+
options.require100 ? 'require 100% coverage cov-fail-under=100' : '',
|
|
203
|
+
];
|
|
204
|
+
if (Array.isArray(options.argv)) parts.push(...options.argv);
|
|
205
|
+
return parts.filter(Boolean).join(' ');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function buildCoverageGapReport(options = {}) {
|
|
209
|
+
const findings = [];
|
|
210
|
+
const cloneHits = [...new Set(detectCloneAttempt(collectCloneHaystack(options)))];
|
|
211
|
+
if (cloneHits.length) {
|
|
212
|
+
findings.push({
|
|
213
|
+
severity: 'fail',
|
|
214
|
+
id: 'vs_test_agent_clone_refused',
|
|
215
|
+
message: `Refusing Copilot Test Agent / @test #solution / 100% coverage clones (${cloneHits.join(', ')}). Baseline gaps, skip no-behavior, remeasure same scope.`,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const floor = options.floor == null ? DEFAULT_FLOOR : Number(options.floor);
|
|
220
|
+
if (!Number.isFinite(floor) || floor < 0 || floor > 100) throw new RangeError('Coverage floor must be a finite percentage from 0 to 100');
|
|
221
|
+
const scope = options.scope || '';
|
|
222
|
+
const skipNoBehavior = options.skipNoBehavior !== false && !normalizeBoolean(options['include-no-behavior']);
|
|
223
|
+
|
|
224
|
+
let mode = 'baseline';
|
|
225
|
+
let baseline = null;
|
|
226
|
+
let comparison = null;
|
|
227
|
+
|
|
228
|
+
if (options.after && options.before) {
|
|
229
|
+
mode = 'compare';
|
|
230
|
+
comparison = compareCoverage(loadJson(options.before), loadJson(options.after), {
|
|
231
|
+
floor,
|
|
232
|
+
scope,
|
|
233
|
+
skipNoBehavior,
|
|
234
|
+
claim100: normalizeBoolean(options.claim100) || normalizeBoolean(options['claim-100']),
|
|
235
|
+
require100: normalizeBoolean(options.require100),
|
|
236
|
+
beforeScope: options.beforeScope || scope,
|
|
237
|
+
afterScope: options.afterScope || scope,
|
|
238
|
+
});
|
|
239
|
+
findings.push(...comparison.findings);
|
|
240
|
+
baseline = comparison.after;
|
|
241
|
+
} else if (options.coverage || options.before) {
|
|
242
|
+
baseline = baselineCoverage(loadJson(options.coverage || options.before), {
|
|
243
|
+
floor,
|
|
244
|
+
scope,
|
|
245
|
+
skipNoBehavior,
|
|
246
|
+
claim100: normalizeBoolean(options.claim100) || normalizeBoolean(options['claim-100']),
|
|
247
|
+
});
|
|
248
|
+
if (baseline.claim100) {
|
|
249
|
+
findings.push({
|
|
250
|
+
severity: 'fail',
|
|
251
|
+
id: 'claim_100',
|
|
252
|
+
message: 'Never claim 100% coverage as the win. Report remaining gaps instead.',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
} else if (!cloneHits.length && !normalizeBoolean(options.map || options['map-only'])) {
|
|
256
|
+
findings.push({
|
|
257
|
+
severity: 'warn',
|
|
258
|
+
id: 'no_coverage_input',
|
|
259
|
+
message: 'No --coverage/--before JSON. Pass a coverage fixture to baseline gaps. Maps onto scripts/test-coverage.js.',
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (baseline && baseline.files === 0 && !findings.some((f) => f.id === 'no_behavioral_data')) {
|
|
264
|
+
findings.push({ severity: 'fail', id: 'no_behavioral_data', message: 'No behavioral coverage in the selected scope.' });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (normalizeBoolean(options['claim-100']) || normalizeBoolean(options.claim100)) {
|
|
268
|
+
if (!findings.some((f) => f.id === 'claim_100')) {
|
|
269
|
+
findings.push({
|
|
270
|
+
severity: 'fail',
|
|
271
|
+
id: 'claim_100',
|
|
272
|
+
message: 'Never claim 100% coverage as the win.',
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let status = 'ready';
|
|
278
|
+
if (findings.some((f) => f.severity === 'fail')) status = 'fail';
|
|
279
|
+
else if (findings.some((f) => f.severity === 'warn')) status = 'ready_with_warnings';
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
name: 'thumbgate-coverage-gap',
|
|
283
|
+
status,
|
|
284
|
+
ok: status !== 'fail',
|
|
285
|
+
mode,
|
|
286
|
+
baseline,
|
|
287
|
+
comparison: comparison && { before: comparison.before, after: comparison.after },
|
|
288
|
+
compareNotClone: true,
|
|
289
|
+
runner: 'scripts/test-coverage.js',
|
|
290
|
+
never: [
|
|
291
|
+
'clone Copilot Test Agent / @test #solution',
|
|
292
|
+
'cov-fail-under=100',
|
|
293
|
+
'write tests for enums/re-exports/constants-only files',
|
|
294
|
+
'remeasure a different directory than the baseline scope',
|
|
295
|
+
'claim 100% coverage',
|
|
296
|
+
],
|
|
297
|
+
source: SOURCE_URL,
|
|
298
|
+
disclaimer: 'FORMAT steal only. Not affiliated with Visual Studio, GitHub Copilot, or Test Agent. Gaps first; never 100%.',
|
|
299
|
+
findings,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function formatCoverageGapReport(report) {
|
|
304
|
+
const lines = [
|
|
305
|
+
'ThumbGate coverage-gap (VS FORMAT steal)',
|
|
306
|
+
`Status : ${report.status}`,
|
|
307
|
+
`ok : ${report.ok}`,
|
|
308
|
+
`Mode : ${report.mode}`,
|
|
309
|
+
];
|
|
310
|
+
if (report.baseline) {
|
|
311
|
+
lines.push(`Scope : ${report.baseline.scope} floor=${report.baseline.floor}% pct=${report.baseline.pct}%`);
|
|
312
|
+
lines.push(`Gaps : ${report.baseline.gaps.length} skipped-no-behavior=${report.baseline.skippedNoBehavior.length}`);
|
|
313
|
+
for (const g of report.baseline.gaps.slice(0, 12)) {
|
|
314
|
+
lines.push(` - ${g.path} ${g.pct}%`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (report.findings?.length) {
|
|
318
|
+
lines.push('Findings:');
|
|
319
|
+
for (const f of report.findings) lines.push(` [${f.severity}] ${f.id}: ${f.message}`);
|
|
320
|
+
}
|
|
321
|
+
lines.push(`Never : ${(report.never || []).join('; ')}`);
|
|
322
|
+
lines.push(`Source : ${report.source}`);
|
|
323
|
+
lines.push(report.disclaimer);
|
|
324
|
+
return `${lines.join('\n')}\n`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function parseArgv(argv) {
|
|
328
|
+
const options = { argv };
|
|
329
|
+
const booleanFlags = {
|
|
330
|
+
json: 'json',
|
|
331
|
+
strict: 'strict',
|
|
332
|
+
'clone-test-agent': 'clone-test-agent',
|
|
333
|
+
'claim-100': 'claim100',
|
|
334
|
+
'include-no-behavior': 'include-no-behavior',
|
|
335
|
+
};
|
|
336
|
+
for (const arg of argv) {
|
|
337
|
+
const flag = /^--([^=]+)(?:=(.*))?$/.exec(arg);
|
|
338
|
+
if (flag && Object.hasOwn(booleanFlags, flag[1])) {
|
|
339
|
+
options[booleanFlags[flag[1]]] = normalizeBoolean(flag[2] === undefined ? true : flag[2]);
|
|
340
|
+
} else if (arg.startsWith('--coverage=')) options.coverage = arg.slice('--coverage='.length);
|
|
341
|
+
else if (arg.startsWith('--before=')) options.before = arg.slice('--before='.length);
|
|
342
|
+
else if (arg.startsWith('--after=')) options.after = arg.slice('--after='.length);
|
|
343
|
+
else if (arg.startsWith('--scope=')) options.scope = arg.slice('--scope='.length);
|
|
344
|
+
else if (arg.startsWith('--floor=')) options.floor = Number(arg.slice('--floor='.length));
|
|
345
|
+
}
|
|
346
|
+
return options;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function printHelp() {
|
|
350
|
+
process.stdout.write(`Usage: node scripts/coverage-gap.js [options]
|
|
351
|
+
|
|
352
|
+
VS coverage FORMAT: baseline gaps, skip no-behavior files, remeasure same scope.
|
|
353
|
+
Does not clone Copilot Test Agent. Never 100%.
|
|
354
|
+
|
|
355
|
+
Options:
|
|
356
|
+
--coverage=<file.json> Baseline a coverage fixture
|
|
357
|
+
--before= --after= Compare the same --scope
|
|
358
|
+
--scope=scripts/foo/ Limit files (required for honest compare)
|
|
359
|
+
--floor=50 Gap threshold (default 50)
|
|
360
|
+
--claim-100 Fail closed
|
|
361
|
+
--clone-test-agent Fail closed
|
|
362
|
+
--json --strict
|
|
363
|
+
`);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function main(argv = process.argv.slice(2)) {
|
|
367
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
368
|
+
printHelp();
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
const options = parseArgv(argv);
|
|
372
|
+
const report = buildCoverageGapReport(options);
|
|
373
|
+
if (options.json) process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
374
|
+
else process.stdout.write(formatCoverageGapReport(report));
|
|
375
|
+
if (options.strict && report.status !== 'ready') return 1;
|
|
376
|
+
if (report.status === 'fail') return 1;
|
|
377
|
+
return 0;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
module.exports = {
|
|
381
|
+
SOURCE_URL,
|
|
382
|
+
DEFAULT_FLOOR,
|
|
383
|
+
normalizeBoolean,
|
|
384
|
+
NO_BEHAVIOR_KINDS,
|
|
385
|
+
classifySource,
|
|
386
|
+
baselineCoverage,
|
|
387
|
+
compareCoverage,
|
|
388
|
+
detectCloneAttempt,
|
|
389
|
+
buildCoverageGapReport,
|
|
390
|
+
formatCoverageGapReport,
|
|
391
|
+
main,
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(__filename)) {
|
|
395
|
+
process.exitCode = main();
|
|
396
|
+
}
|