@lensmcp/protocol-types 1.26.37 → 1.26.38
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/index.d.ts +4 -0
- package/index.js +1 -1
- package/lib/account-drain.js +1 -1
- package/lib/ai-cache-facts.js +1 -1
- package/lib/ai-cache-verdict.js +1 -1
- package/lib/ai-cache.js +3 -3
- package/lib/ai-call-groups.js +2 -2
- package/lib/ai-call-row.js +3 -3
- package/lib/ai-call.js +9 -9
- package/lib/ai-compare.js +3 -3
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +9 -9
- package/lib/ai-together.js +5 -5
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/canvas-attachments.js +1 -1
- package/lib/canvas-catalog.d.ts +10 -5
- package/lib/canvas-catalog.js +1 -1
- package/lib/canvas-chat.js +2 -2
- package/lib/canvas-diagram.d.ts +130 -0
- package/lib/canvas-diagram.js +8 -0
- package/lib/canvas-editing.js +4 -4
- package/lib/canvas-frame-policy.js +1 -1
- package/lib/canvas-hub.js +1 -1
- package/lib/canvas.d.ts +9 -5
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/delivery-actions.d.ts +25 -2
- package/lib/delivery-actions.js +1 -1
- package/lib/delivery-status.d.ts +8 -1
- package/lib/docker-errors.js +1 -1
- package/lib/docker-jobs.js +1 -1
- package/lib/docker-report.js +2 -2
- package/lib/docker-runs.js +3 -3
- package/lib/error-cause.js +6 -6
- package/lib/error-dismissal.js +1 -1
- package/lib/error-verdict.js +3 -3
- package/lib/event-loop.js +1 -1
- package/lib/expected-failure.js +2 -2
- package/lib/finding-proof.js +1 -1
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/goal-main-follow.d.ts +103 -0
- package/lib/goal-main-follow.js +1 -0
- package/lib/goal-number.js +1 -1
- package/lib/goal-process.d.ts +8 -0
- package/lib/goal-review.d.ts +126 -0
- package/lib/goal-review.js +6 -0
- package/lib/host-agents.js +1 -1
- package/lib/lens-hosts.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/lint-ignores.js +2 -2
- package/lib/log-query.js +1 -1
- package/lib/metrics-reset.js +1 -1
- package/lib/overseer-findings.js +1 -1
- package/lib/peers.d.ts +30 -30
- package/lib/peers.js +1 -1
- package/lib/perf-rules.js +1 -1
- package/lib/pod-memory.js +1 -1
- package/lib/producer-health.js +1 -1
- package/lib/pull-requests.d.ts +33 -2
- package/lib/remote-instances.js +1 -1
- package/lib/source.d.ts +414 -0
- package/lib/source.js +1 -0
- package/lib/sources.js +1 -1
- package/lib/static-checks.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team-decide.js +1 -1
- package/lib/team.d.ts +9 -2
- package/lib/team.js +1 -1
- package/package.json +1 -1
package/lib/expected-failure.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty;var h=(t,e)=>z(t,"name",{value:e,configurable:!0});var K=Object.defineProperty,c=h((t,e)=>K(t,"name",{value:e,configurable:!0}),"d");import{LENS_EVENT_SOURCE as W}from"./error-dismissal.js";export const EXPECTED_RULE_SET="expected-rule-set",EXPECTED_RULE_REMOVED="expected-rule-removed";const k=new Set(["dashboard","cli","agent"]),m=60*6e4;export const EXPECTED_RULE_DEFAULT_TTL_MS=168*m,EXPECTED_RULE_MAX_TTL_MS=720*m,EXPECTED_RULE_MIN_REASON_CHARS=8,MAX_EXPECTED_REASON_CHARS=500;const A=300,G=300,P=120,J=200,H=20,l=c(t=>!!t&&typeof t=="object"&&!Array.isArray(t),"isObj"),g=c((t,e)=>typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0,"text"),R=c(t=>!!t&&t.replace(/[*?\s/:.#_-]/g,"").length>=2,"meaningful");export const EXPECTED_SCOPE_FIELDS=["route","span","flow"],EXPECTED_OUTCOME_FIELDS=["status","error","message"];export function checkExpectedMatch(t){if(!l(t))return{error:"a rule needs a match: a flow scope (route, span or flow) and an outcome (status, error or message)"};const e={};for(const r of["service","route","span","flow","error","message"]){const o=t[r];if(o==null||o==="")continue;if(typeof o!="string")return{error:`\`${r}\` must be text`};const i=o.trim();if(i.length>A)return{error:`\`${r}\` is longer than ${A} characters`};i&&(e[r]=i)}if(t.status!==void 0&&t.status!==null&&t.status!==""){const r=typeof t.status=="string"?Number(t.status):t.status;if(typeof r!="number"||!Number.isInteger(r)||r<100||r>599)return{error:"`status` must be an HTTP status (100\u2013599)"};e.status=r}const s=t.attribute;if(s!=null){const r=l(s)?g(s.name,100):void 0,o=l(s)?typeof s.value=="number"?String(s.value):g(s.value,A):void 0;if(!r||!o)return{error:"`attribute` needs a `name` and a `value` (one attribute of the flow, such as a tenant id)"};e.attribute={name:r,value:o}}return EXPECTED_SCOPE_FIELDS.some(r=>R(e[r]))?e.status===void 0&&!R(e.error)&&!R(e.message)?{error:"a rule needs an outcome \u2014 a `status`, an `error` key or a `message` pattern \u2014 saying WHICH failure is expected in that flow"}:{match:e}:{error:`a rule needs a flow scope \u2014 a \`route\`, a \`span\` or a \`flow\` \u2014 not only ${e.service?`the service \xAB${e.service}\xBB`:"an outcome"}: \xABeverything in a service\xBB is not expected, it is unwatched`}}h(checkExpectedMatch,"checkExpectedMatch"),c(checkExpectedMatch,"checkExpectedMatch");export function describeExpectedMatch(t){return[t.service,t.route,t.span,t.flow?`flow ${t.flow}`:void 0,t.status!==void 0?String(t.status):void 0,t.error,t.message?`\xAB${t.message}\xBB`:void 0,t.attribute?`${t.attribute.name}=${t.attribute.value}`:void 0].filter(Boolean).join(" \xB7 ")}h(describeExpectedMatch,"describeExpectedMatch"),c(describeExpectedMatch,"describeExpectedMatch");export function readExpectedRule(t){if(t.source!==W||!l(t.raw))return;const e=t.raw,s=g(e.id,P);if(!s)return;if(e.kind===EXPECTED_RULE_REMOVED)return{kind:EXPECTED_RULE_REMOVED,id:s,...k.has(e.by)?{by:e.by}:{}};if(e.kind!==EXPECTED_RULE_SET||!k.has(e.by))return;const r=g(e.reason,MAX_EXPECTED_REASON_CHARS);if(!r)return;const o=checkExpectedMatch(e.match);if("error"in o)return;const i=Math.min(typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:t.timestamp,t.timestamp),u=typeof e.expiresAt=="number"&&Number.isFinite(e.expiresAt)?e.expiresAt:i+EXPECTED_RULE_DEFAULT_TTL_MS,a=g(e.title,G);return{kind:EXPECTED_RULE_SET,id:s,match:o.match,reason:r,by:e.by,createdAt:i,expiresAt:Math.min(u,i+EXPECTED_RULE_MAX_TTL_MS),...a?{title:a}:{}}}h(readExpectedRule,"readExpectedRule"),c(readExpectedRule,"readExpectedRule");export function expectedRuleTtlMs(t){return t===void 0||!Number.isFinite(t)||t<=0?EXPECTED_RULE_DEFAULT_TTL_MS:Math.min(Math.round(t*m),EXPECTED_RULE_MAX_TTL_MS)}h(expectedRuleTtlMs,"expectedRuleTtlMs"),c(expectedRuleTtlMs,"expectedRuleTtlMs");function F(t){let e=2166136261;for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return(e>>>0).toString(36)}h(F,"z"),c(F,"hashOf");export function readRepositoryExpectedRules(t,e){const s=[],r=[];return t==null?{rules:s,problems:r}:Array.isArray(t)?(t.forEach((o,i)=>{if(!l(o))return void r.push(`expectedFailures[${i}] is not an object`);const u=checkExpectedMatch(l(o.match)?o.match:o);if("error"in u)return void r.push(`expectedFailures[${i}]: ${u.error}`);const a=g(o.reason,MAX_EXPECTED_REASON_CHARS);if(!a)return void r.push(`expectedFailures[${i}] has no reason \u2014 say why it is expected`);const d=`repository:${g(o.id,P)??F(JSON.stringify(u.match))}`;if(s.some(p=>p.id===d))return void r.push(`expectedFailures[${i}] repeats the id ${d}`);s.push({id:d,match:u.match,reason:a,by:"repository",createdAt:e})}),{rules:s,problems:r}):{rules:s,problems:["expectedFailures is not a list \u2014 no repository rule is read"]}}h(readRepositoryExpectedRules,"readRepositoryExpectedRules"),c(readRepositoryExpectedRules,"readRepositoryExpectedRules");const n=c(t=>typeof t=="string"&&t?t:void 0,"str"),$=c(t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,"num"),B=c(t=>{const e=t.split(/[?#]/)[0]??t,s=/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/.*)?$/i.exec(e);return s?s[1]??"/":e},"pathOf"),V=new Set(["sessionId","flowId","requestId","parentRequestId","runId","traceparent","originNodeId","causedByNodeId","userActionId","browserContextId","frameId","tabId","url","route","projectName"]),_=24;export function eventAttributes(t){let e;const s=c((a,d)=>{if(e&&Object.keys(e).length>=_)return;const p=typeof d=="string"?d:typeof d=="number"||typeof d=="boolean"?String(d):void 0;p===void 0||p.length>A||((e??={})[a]=p)},"put"),r=t.context??{};for(const a of Object.keys(r))V.has(a)||s(a,r[a]);const o=l(t.raw)?t.raw:void 0;if(!o)return e;const i=l(o.span)?o.span:void 0,u=l(o.request)?o.request:void 0;for(const a of[o.attributes,i?.attributes,u?.attributes,o.data,Array.isArray(i?.args)?i?.args[0]:i?.args])if(l(a))for(const d of Object.keys(a))s(d,a[d]);return e}h(eventAttributes,"eventAttributes"),c(eventAttributes,"eventAttributes");export function failureFacts(t){const e=l(t.raw)?t.raw:{},s=t.context??{},r=l(e.request)?e.request:{},o=l(e.span)?e.span:{},i=l(r.error)?r.error:{},u=l(o.error)?o.error:{},a=l(e.error)?e.error:{},d=n(e.kind),p=[],b=n(r.route)??(d==="egress"?n(e.path):void 0);b&&p.push(b);const y=n(e.url)??n(r.url);y&&p.push(B(y)),d!=="server-request"&&n(s.route)&&p.push(n(s.route));const f=[];if(d==="queue-failed"||d==="queue-enqueued"){const w=n(e.queue),E=e.jobId===void 0||e.jobId===null?void 0:String(e.jobId);w&&f.push(`job:${w}`),E&&f.push(`job:${E}`),w&&E&&f.push(`job:${w}#${E}`),n(e.name)&&f.push(`job:${n(e.name)}`)}const x=[i.errorKey,u.errorKey,a.errorKey,e.errorKey,i.reason,u.reason].map(n).filter(w=>!!w),S=n(i.message)??n(t.message)??n(u.message)??n(a.message)??n(e.failedReason)??n(e.error)??n(e.message)??n(t.title),C=$(r.status)??$(e.status),T=n(s.flowId)??n(o.flowId)??n(r.flowId),N=n(s.requestId)??n(r.requestId)??n(o.requestId),O=eventAttributes(t);return{...n(e.project)??n(s.projectName)?{service:n(e.project)??n(s.projectName)}:{},...n(r.method)??n(e.method)?{method:n(r.method)??n(e.method)}:{},...p.length?{routes:p}:{},...n(o.name)?{span:n(o.name)}:{},...T?{flowId:T}:{},...f.length?{flowNames:f}:{},...C!==void 0?{status:C}:{},...n(i.name)??n(u.name)??n(a.name)?{errorName:n(i.name)??n(u.name)??n(a.name)}:{},...x.length?{errorKeys:x}:{},...S?{message:S}:{},...O?{attributes:O}:{},...N?{requestId:N}:{}}}h(failureFacts,"failureFacts"),c(failureFacts,"failureFacts");export class FailureContextIndex{static{h(this,"FailureContextIndex")}static{c(this,"FailureContextIndex")}constructor(e=5e3,s=2e3){this.maxRequests=e,this.maxFlows=s,this.requests=new Map,this.flows=new Map}observe(e){const s=l(e.raw)?e.raw:void 0,r=e.context??{},o=n(r.flowId);if(o&&(s?.attributes!==void 0||l(s?.span)||r.tenantIdHash!==void 0||r.userIdHash!==void 0||s?.data!==void 0)){const y=eventAttributes(e);if(y){const f=this.flows.get(o);this.flows.delete(o);const x={...f??{},...y};this.flows.set(o,Object.keys(x).length>_?Object.fromEntries(Object.entries(x).slice(-_)):x),this.flows.size>this.maxFlows&&this.flows.delete(this.flows.keys().next().value)}}const i=n(s?.kind);if(!s||i!=="server-request"&&i!=="gateway-request")return;const u=l(s.request)?s.request:s,a=n(r.requestId)??n(u.requestId);if(!a)return;const d=this.requests.get(a)??{},p=n(u.url),b={...d,...n(s.project)&&(i==="server-request"||!d.service)?{service:n(s.project)}:{},...n(u.method)?{method:n(u.method)}:{},...i==="server-request"&&n(u.route)?{route:n(u.route)}:{},...p?{path:B(p)}:{},...$(u.status)!==void 0&&(i==="server-request"||d.status===void 0)?{status:$(u.status)}:{}};return this.requests.delete(a),this.requests.set(a,b),this.requests.size>this.maxRequests&&this.requests.delete(this.requests.keys().next().value),i==="server-request"?a:void 0}request(e){return e?this.requests.get(e):void 0}enrich(e){const s=this.request(e.requestId),r=e.flowId?this.flows.get(e.flowId):void 0;if(!s&&!r)return e;const o=[...e.routes??[],...s?.route?[s.route]:[],...s?.path?[s.path]:[]];return{...e,...e.service??s?.service?{service:e.service??s?.service}:{},...e.method??s?.method?{method:e.method??s?.method}:{},...o.length?{routes:[...new Set(o)]}:{},...e.status??s?.status!==void 0?{status:e.status??s?.status}:{},...r||e.attributes?{attributes:{...r??{},...e.attributes??{}}}:{}}}}const I=new Map,j=c((t,e)=>t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,e).replace(/\?/g,"."),"globBody");function M(t,e="whole"){const s=`${e}\0${t}`;let r=I.get(s);return r||(r=e==="whole"?new RegExp(`^${j(t,"[\\s\\S]*")}$`,"i"):e==="anywhere"?new RegExp(j(t,"[\\s\\S]*"),"i"):new RegExp(`(?:^|[^\\w.])${j(t,"[\\w.]*")}(?:$|[^\\w.])`,"i"),I.size>1e3&&I.clear(),I.set(s,r)),r}h(M,"S"),c(M,"globRe");const v=c((t,e)=>e!==void 0&&M(t).test(e),"glob");function D(t,e){const s=e.routes??[],r=/^([A-Za-z]+)\s+(\S.*)$/.exec(t);return r&&/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|\*)$/i.test(r[1])?r[1]!=="*"&&(e.method??"").toUpperCase()!==r[1].toUpperCase()?!1:s.some(o=>v(r[2],o)):s.some(o=>v(t,o))}h(D,"B"),c(D,"routeMatches");function L(t,e){const s=[e.flowId,...e.flowNames??[]].filter(o=>!!o),r=t.endsWith(":")?`${t}*`:t;return s.some(o=>v(r,o))}h(L,"G"),c(L,"flowMatches");function U(t,e){return v(t,e.errorName)||(e.errorKeys??[]).some(s=>v(t,s))?!0:e.message!==void 0&&M(t,"word").test(e.message)}h(U,"W"),c(U,"errorMatches");export function expectedMatches(t,e){return!(t.service!==void 0&&!v(t.service,e.service)||t.route!==void 0&&!D(t.route,e)||t.span!==void 0&&!v(t.span,e.span)||t.flow!==void 0&&!L(t.flow,e)||t.status!==void 0&&e.status!==t.status||t.error!==void 0&&!U(t.error,e)||t.message!==void 0&&!(e.message!==void 0&&M(t.message,"anywhere").test(e.message))||t.attribute!==void 0&&!v(t.attribute.value,e.attributes?.[t.attribute.name]))}h(expectedMatches,"expectedMatches"),c(expectedMatches,"expectedMatches");export function expectedMatchIsPerOccurrence(t){return t.flow!==void 0||t.attribute!==void 0||t.message!==void 0&&/\d/.test(t.message)}h(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),c(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence");export function suggestExpectedMatch(t){const e=t.routes?.find(a=>a.startsWith("/")),s=t.flowNames?.find(a=>a.startsWith("job:")&&!a.includes("#"))??(t.flowId?`${t.flowId.split(":")[0]}:`:void 0),r=e?{route:t.method?`${t.method.toUpperCase()} ${e}`:e}:t.span?{span:t.span}:s?{flow:s}:{},o=t.message?.split(`
|
|
2
|
-
`)[0]?.replace(/\d+/g,"*").replace(/\*+/g,"*").slice(0,120).trim(),i=t.status!==void 0?{status:t.status}:t.errorName&&t.errorName!=="Error"?{error:t.errorName}:o?{message:o}:{},u=checkExpectedMatch({...t.service?{service:t.service}:{},...r,...i});return"match"in u?u.match:void 0}h(suggestExpectedMatch,"suggestExpectedMatch"),c(suggestExpectedMatch,"suggestExpectedMatch");export const EXPECTED_SURGE_FACTOR=10,EXPECTED_SURGE_MIN_PER_HOUR=20;const
|
|
1
|
+
"use strict";var K=Object.defineProperty;var h=(t,e)=>K(t,"name",{value:e,configurable:!0});var W=Object.defineProperty,l=h((t,e)=>W(t,"name",{value:e,configurable:!0}),"h"),G=Object.defineProperty,c=l((t,e)=>G(t,"name",{value:e,configurable:!0}),"d");import{LENS_EVENT_SOURCE as J}from"./error-dismissal.js";export const EXPECTED_RULE_SET="expected-rule-set",EXPECTED_RULE_REMOVED="expected-rule-removed";const L=new Set(["dashboard","cli","agent"]),f=60*6e4;export const EXPECTED_RULE_DEFAULT_TTL_MS=168*f,EXPECTED_RULE_MAX_TTL_MS=720*f,EXPECTED_RULE_MIN_REASON_CHARS=8,MAX_EXPECTED_REASON_CHARS=500;const $=300,V=300,D=120,Z=200,U=20,p=c(t=>!!t&&typeof t=="object"&&!Array.isArray(t),"isObj"),x=c((t,e)=>typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0,"text"),_=c(t=>!!t&&t.replace(/[*?\s/:.#_-]/g,"").length>=2,"meaningful");export const EXPECTED_SCOPE_FIELDS=["route","span","flow"],EXPECTED_OUTCOME_FIELDS=["status","error","message"];export function checkExpectedMatch(t){if(!p(t))return{error:"a rule needs a match: a flow scope (route, span or flow) and an outcome (status, error or message)"};const e={};for(const r of["service","route","span","flow","error","message"]){const o=t[r];if(o==null||o==="")continue;if(typeof o!="string")return{error:`\`${r}\` must be text`};const i=o.trim();if(i.length>$)return{error:`\`${r}\` is longer than ${$} characters`};i&&(e[r]=i)}if(t.status!==void 0&&t.status!==null&&t.status!==""){const r=typeof t.status=="string"?Number(t.status):t.status;if(typeof r!="number"||!Number.isInteger(r)||r<100||r>599)return{error:"`status` must be an HTTP status (100\u2013599)"};e.status=r}const s=t.attribute;if(s!=null){const r=p(s)?x(s.name,100):void 0,o=p(s)?typeof s.value=="number"?String(s.value):x(s.value,$):void 0;if(!r||!o)return{error:"`attribute` needs a `name` and a `value` (one attribute of the flow, such as a tenant id)"};e.attribute={name:r,value:o}}return EXPECTED_SCOPE_FIELDS.some(r=>_(e[r]))?e.status===void 0&&!_(e.error)&&!_(e.message)?{error:"a rule needs an outcome \u2014 a `status`, an `error` key or a `message` pattern \u2014 saying WHICH failure is expected in that flow"}:{match:e}:{error:`a rule needs a flow scope \u2014 a \`route\`, a \`span\` or a \`flow\` \u2014 not only ${e.service?`the service \xAB${e.service}\xBB`:"an outcome"}: \xABeverything in a service\xBB is not expected, it is unwatched`}}h(checkExpectedMatch,"checkExpectedMatch"),l(checkExpectedMatch,"checkExpectedMatch"),c(checkExpectedMatch,"checkExpectedMatch");export function describeExpectedMatch(t){return[t.service,t.route,t.span,t.flow?`flow ${t.flow}`:void 0,t.status!==void 0?String(t.status):void 0,t.error,t.message?`\xAB${t.message}\xBB`:void 0,t.attribute?`${t.attribute.name}=${t.attribute.value}`:void 0].filter(Boolean).join(" \xB7 ")}h(describeExpectedMatch,"describeExpectedMatch"),l(describeExpectedMatch,"describeExpectedMatch"),c(describeExpectedMatch,"describeExpectedMatch");export function readExpectedRule(t){if(t.source!==J||!p(t.raw))return;const e=t.raw,s=x(e.id,D);if(!s)return;if(e.kind===EXPECTED_RULE_REMOVED)return{kind:EXPECTED_RULE_REMOVED,id:s,...L.has(e.by)?{by:e.by}:{}};if(e.kind!==EXPECTED_RULE_SET||!L.has(e.by))return;const r=x(e.reason,MAX_EXPECTED_REASON_CHARS);if(!r)return;const o=checkExpectedMatch(e.match);if("error"in o)return;const i=Math.min(typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:t.timestamp,t.timestamp),u=typeof e.expiresAt=="number"&&Number.isFinite(e.expiresAt)?e.expiresAt:i+EXPECTED_RULE_DEFAULT_TTL_MS,a=x(e.title,V);return{kind:EXPECTED_RULE_SET,id:s,match:o.match,reason:r,by:e.by,createdAt:i,expiresAt:Math.min(u,i+EXPECTED_RULE_MAX_TTL_MS),...a?{title:a}:{}}}h(readExpectedRule,"readExpectedRule"),l(readExpectedRule,"readExpectedRule"),c(readExpectedRule,"readExpectedRule");export function expectedRuleTtlMs(t){return t===void 0||!Number.isFinite(t)||t<=0?EXPECTED_RULE_DEFAULT_TTL_MS:Math.min(Math.round(t*f),EXPECTED_RULE_MAX_TTL_MS)}h(expectedRuleTtlMs,"expectedRuleTtlMs"),l(expectedRuleTtlMs,"expectedRuleTtlMs"),c(expectedRuleTtlMs,"expectedRuleTtlMs");function j(t){let e=2166136261;for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return(e>>>0).toString(36)}h(j,"F"),l(j,"z"),c(j,"hashOf");export function readRepositoryExpectedRules(t,e){const s=[],r=[];return t==null?{rules:s,problems:r}:Array.isArray(t)?(t.forEach((o,i)=>{if(!p(o))return void r.push(`expectedFailures[${i}] is not an object`);const u=checkExpectedMatch(p(o.match)?o.match:o);if("error"in u)return void r.push(`expectedFailures[${i}]: ${u.error}`);const a=x(o.reason,MAX_EXPECTED_REASON_CHARS);if(!a)return void r.push(`expectedFailures[${i}] has no reason \u2014 say why it is expected`);const d=`repository:${x(o.id,D)??j(JSON.stringify(u.match))}`;if(s.some(m=>m.id===d))return void r.push(`expectedFailures[${i}] repeats the id ${d}`);s.push({id:d,match:u.match,reason:a,by:"repository",createdAt:e})}),{rules:s,problems:r}):{rules:s,problems:["expectedFailures is not a list \u2014 no repository rule is read"]}}h(readRepositoryExpectedRules,"readRepositoryExpectedRules"),l(readRepositoryExpectedRules,"readRepositoryExpectedRules"),c(readRepositoryExpectedRules,"readRepositoryExpectedRules");const n=c(t=>typeof t=="string"&&t?t:void 0,"str"),I=c(t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,"num"),z=c(t=>{const e=t.split(/[?#]/)[0]??t,s=/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/.*)?$/i.exec(e);return s?s[1]??"/":e},"pathOf"),Q=new Set(["sessionId","flowId","requestId","parentRequestId","runId","traceparent","originNodeId","causedByNodeId","userActionId","browserContextId","frameId","tabId","url","route","projectName"]),S=24;export function eventAttributes(t){let e;const s=c((a,d)=>{if(e&&Object.keys(e).length>=S)return;const m=typeof d=="string"?d:typeof d=="number"||typeof d=="boolean"?String(d):void 0;m===void 0||m.length>$||((e??={})[a]=m)},"put"),r=t.context??{};for(const a of Object.keys(r))Q.has(a)||s(a,r[a]);const o=p(t.raw)?t.raw:void 0;if(!o)return e;const i=p(o.span)?o.span:void 0,u=p(o.request)?o.request:void 0;for(const a of[o.attributes,i?.attributes,u?.attributes,o.data,Array.isArray(i?.args)?i?.args[0]:i?.args])if(p(a))for(const d of Object.keys(a))s(d,a[d]);return e}h(eventAttributes,"eventAttributes"),l(eventAttributes,"eventAttributes"),c(eventAttributes,"eventAttributes");export function failureFacts(t){const e=p(t.raw)?t.raw:{},s=t.context??{},r=p(e.request)?e.request:{},o=p(e.span)?e.span:{},i=p(r.error)?r.error:{},u=p(o.error)?o.error:{},a=p(e.error)?e.error:{},d=n(e.kind),m=[],A=n(r.route)??(d==="egress"?n(e.path):void 0);A&&m.push(A);const y=n(e.url)??n(r.url);y&&m.push(z(y)),d!=="server-request"&&n(s.route)&&m.push(n(s.route));const v=[];if(d==="queue-failed"||d==="queue-enqueued"){const w=n(e.queue),M=e.jobId===void 0||e.jobId===null?void 0:String(e.jobId);w&&v.push(`job:${w}`),M&&v.push(`job:${M}`),w&&M&&v.push(`job:${w}#${M}`),n(e.name)&&v.push(`job:${n(e.name)}`)}const b=[i.errorKey,u.errorKey,a.errorKey,e.errorKey,i.reason,u.reason].map(n).filter(w=>!!w),k=n(i.message)??n(t.message)??n(u.message)??n(a.message)??n(e.failedReason)??n(e.error)??n(e.message)??n(t.title),P=I(r.status)??I(e.status),B=n(s.flowId)??n(o.flowId)??n(r.flowId),F=n(s.requestId)??n(r.requestId)??n(o.requestId),H=eventAttributes(t);return{...n(e.project)??n(s.projectName)?{service:n(e.project)??n(s.projectName)}:{},...n(r.method)??n(e.method)?{method:n(r.method)??n(e.method)}:{},...m.length?{routes:m}:{},...n(o.name)?{span:n(o.name)}:{},...B?{flowId:B}:{},...v.length?{flowNames:v}:{},...P!==void 0?{status:P}:{},...n(i.name)??n(u.name)??n(a.name)?{errorName:n(i.name)??n(u.name)??n(a.name)}:{},...b.length?{errorKeys:b}:{},...k?{message:k}:{},...H?{attributes:H}:{},...F?{requestId:F}:{}}}h(failureFacts,"failureFacts"),l(failureFacts,"failureFacts"),c(failureFacts,"failureFacts");export class FailureContextIndex{static{h(this,"FailureContextIndex")}static{l(this,"FailureContextIndex")}static{c(this,"FailureContextIndex")}constructor(e=5e3,s=2e3){this.maxRequests=e,this.maxFlows=s,this.requests=new Map,this.flows=new Map}observe(e){const s=p(e.raw)?e.raw:void 0,r=e.context??{},o=n(r.flowId);if(o&&(s?.attributes!==void 0||p(s?.span)||r.tenantIdHash!==void 0||r.userIdHash!==void 0||s?.data!==void 0)){const y=eventAttributes(e);if(y){const v=this.flows.get(o);this.flows.delete(o);const b={...v??{},...y};this.flows.set(o,Object.keys(b).length>S?Object.fromEntries(Object.entries(b).slice(-S)):b),this.flows.size>this.maxFlows&&this.flows.delete(this.flows.keys().next().value)}}const i=n(s?.kind);if(!s||i!=="server-request"&&i!=="gateway-request")return;const u=p(s.request)?s.request:s,a=n(r.requestId)??n(u.requestId);if(!a)return;const d=this.requests.get(a)??{},m=n(u.url),A={...d,...n(s.project)&&(i==="server-request"||!d.service)?{service:n(s.project)}:{},...n(u.method)?{method:n(u.method)}:{},...i==="server-request"&&n(u.route)?{route:n(u.route)}:{},...m?{path:z(m)}:{},...I(u.status)!==void 0&&(i==="server-request"||d.status===void 0)?{status:I(u.status)}:{}};return this.requests.delete(a),this.requests.set(a,A),this.requests.size>this.maxRequests&&this.requests.delete(this.requests.keys().next().value),i==="server-request"?a:void 0}request(e){return e?this.requests.get(e):void 0}enrich(e){const s=this.request(e.requestId),r=e.flowId?this.flows.get(e.flowId):void 0;if(!s&&!r)return e;const o=[...e.routes??[],...s?.route?[s.route]:[],...s?.path?[s.path]:[]];return{...e,...e.service??s?.service?{service:e.service??s?.service}:{},...e.method??s?.method?{method:e.method??s?.method}:{},...o.length?{routes:[...new Set(o)]}:{},...e.status??s?.status!==void 0?{status:e.status??s?.status}:{},...r||e.attributes?{attributes:{...r??{},...e.attributes??{}}}:{}}}}const R=new Map,C=c((t,e)=>t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,e).replace(/\?/g,"."),"globBody");function E(t,e="whole"){const s=`${e}\0${t}`;let r=R.get(s);return r||(r=e==="whole"?new RegExp(`^${C(t,"[\\s\\S]*")}$`,"i"):e==="anywhere"?new RegExp(C(t,"[\\s\\S]*"),"i"):new RegExp(`(?:^|[^\\w.])${C(t,"[\\w.]*")}(?:$|[^\\w.])`,"i"),R.size>1e3&&R.clear(),R.set(s,r)),r}h(E,"M"),l(E,"S"),c(E,"globRe");const g=c((t,e)=>e!==void 0&&E(t).test(e),"glob");function T(t,e){const s=e.routes??[],r=/^([A-Za-z]+)\s+(\S.*)$/.exec(t);return r&&/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|\*)$/i.test(r[1])?r[1]!=="*"&&(e.method??"").toUpperCase()!==r[1].toUpperCase()?!1:s.some(o=>g(r[2],o)):s.some(o=>g(t,o))}h(T,"D"),l(T,"B"),c(T,"routeMatches");function O(t,e){const s=[e.flowId,...e.flowNames??[]].filter(o=>!!o),r=t.endsWith(":")?`${t}*`:t;return s.some(o=>g(r,o))}h(O,"L"),l(O,"G"),c(O,"flowMatches");function N(t,e){return g(t,e.errorName)||(e.errorKeys??[]).some(s=>g(t,s))?!0:e.message!==void 0&&E(t,"word").test(e.message)}h(N,"U"),l(N,"W"),c(N,"errorMatches");export function expectedMatches(t,e){return!(t.service!==void 0&&!g(t.service,e.service)||t.route!==void 0&&!T(t.route,e)||t.span!==void 0&&!g(t.span,e.span)||t.flow!==void 0&&!O(t.flow,e)||t.status!==void 0&&e.status!==t.status||t.error!==void 0&&!N(t.error,e)||t.message!==void 0&&!(e.message!==void 0&&E(t.message,"anywhere").test(e.message))||t.attribute!==void 0&&!g(t.attribute.value,e.attributes?.[t.attribute.name]))}h(expectedMatches,"expectedMatches"),l(expectedMatches,"expectedMatches"),c(expectedMatches,"expectedMatches");export function expectedMatchIsPerOccurrence(t){return t.flow!==void 0||t.attribute!==void 0||t.message!==void 0&&/\d/.test(t.message)}h(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),l(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),c(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence");export function suggestExpectedMatch(t){const e=t.routes?.find(a=>a.startsWith("/")),s=t.flowNames?.find(a=>a.startsWith("job:")&&!a.includes("#"))??(t.flowId?`${t.flowId.split(":")[0]}:`:void 0),r=e?{route:t.method?`${t.method.toUpperCase()} ${e}`:e}:t.span?{span:t.span}:s?{flow:s}:{},o=t.message?.split(`
|
|
2
|
+
`)[0]?.replace(/\d+/g,"*").replace(/\*+/g,"*").slice(0,120).trim(),i=t.status!==void 0?{status:t.status}:t.errorName&&t.errorName!=="Error"?{error:t.errorName}:o?{message:o}:{},u=checkExpectedMatch({...t.service?{service:t.service}:{},...r,...i});return"match"in u?u.match:void 0}h(suggestExpectedMatch,"suggestExpectedMatch"),l(suggestExpectedMatch,"suggestExpectedMatch"),c(suggestExpectedMatch,"suggestExpectedMatch");export const EXPECTED_SURGE_FACTOR=10,EXPECTED_SURGE_MIN_PER_HOUR=20;const Y=2*f,X=24*f,q=6e4;export class ExpectedRuleBook{static{h(this,"ExpectedRuleBook")}static{l(this,"ExpectedRuleBook")}static{c(this,"ExpectedRuleBook")}constructor(e=Date.now()){this.startedAt=e,this.runtime=new Map,this.repository=[],this.repositoryKey="",this.stats=new Map,this.ended=[],this.version=0}apply(e,s){const r=readExpectedRule(e);if(!r)return!1;const o=this.runtime.get(r.id);if(this.runtime.delete(r.id),r.kind===EXPECTED_RULE_REMOVED)o&&this.end(o,s,"removed",r.by);else{const{kind:i,...u}=r;if(this.runtime.set(u.id,u),this.stats.has(u.id)||this.stats.set(u.id,{hits:0,minutes:new Map,since:Math.max(u.createdAt,this.startedAt)}),this.runtime.size>Z){const a=this.runtime.keys().next().value,d=this.runtime.get(a);this.runtime.delete(a),this.end(d,s,"expired")}}return this.version++,!0}setRepository(e,s){const r=JSON.stringify(e.map(i=>[i.id,i.match,i.reason]));if(r===this.repositoryKey)return!1;const o=new Set(e.map(i=>i.id));for(const i of this.repository)o.has(i.id)||this.end(i,s,"dropped from lensmcp.json");this.repository=e.slice(),this.repositoryKey=r;for(const i of e)this.stats.has(i.id)||this.stats.set(i.id,{hits:0,minutes:new Map,since:Math.max(this.startedAt,Math.min(i.createdAt,s))});return this.version++,!0}expire(e){let s=!1;for(const[r,o]of this.runtime)o.expiresAt===void 0||o.expiresAt>e||(this.runtime.delete(r),this.end(o,o.expiresAt,"expired"),s=!0);return s&&this.version++,s}end(e,s,r,o){this.ended.unshift({...e,endedAt:s,why:r,...o?{removedBy:o}:{}}),this.ended.length>U&&(this.ended.length=U)}active(e){return[...this.repository,...[...this.runtime.values()].filter(s=>s.expiresAt===void 0||s.expiresAt>e)]}get(e){return this.runtime.get(e)??this.repository.find(s=>s.id===e)}isActive(e,s){const r=this.get(e);return!!r&&(r.expiresAt===void 0||r.expiresAt>s)}get size(){return this.runtime.size+this.repository.length}holderOf(e,s){if(this.size!==0)return this.active(s).find(r=>expectedMatches(r.match,e))}count(e,s,r=1){const o=this.stats.get(e);if(!o||r<=0||(o.hits+=r,s===void 0))return;o.lastHitAt=Math.max(o.lastHitAt??0,s);const i=Math.floor(s/q);if(o.minutes.set(i,(o.minutes.get(i)??0)+r),o.minutes.size>1600){const u=i-(X+f)/q;for(const a of o.minutes.keys())a<u&&o.minutes.delete(a)}}windowCount(e,s,r){let o=0;for(const[i,u]of e.minutes)i*q>=s&&i*q<r&&(o+=u);return o}judge(e,s){const r=this.windowCount(e,s-f,s+1),o=Math.max(e.since,s-f-X),i=s-f-o;if(i<Y)return e.surge=void 0;const u=this.windowCount(e,o,s-f)/(i/f),a=Math.max(EXPECTED_SURGE_MIN_PER_HOUR,EXPECTED_SURGE_FACTOR*u);return e.surge?r<a/3?e.surge=void 0:e.surge={...e.surge,lastHour:r}:r>=a&&(e.surge={since:s,lastHour:r,usualPerHour:Math.round(u*10)/10}),e.surge}list(e){return this.active(e).map(s=>{const r=this.stats.get(s.id),o=r?this.judge(r,e):void 0;return{...s,hits:r?.hits??0,...r?.lastHitAt!==void 0?{lastHitAt:r.lastHitAt}:{},lastHour:r?this.windowCount(r,e-f,e+1):0,...o?{surge:o}:{}}}).sort((s,r)=>+(s.by==="repository")-+(r.by==="repository")||r.createdAt-s.createdAt)}endedRules(){return this.ended.slice()}}export function heldBackLine(t,e,s=""){return`${t} rule${t===1?"":"s"} held back ${e} occurrence${e===1?"":"s"}${s?` ${s}`:""}`}h(heldBackLine,"heldBackLine"),l(heldBackLine,"heldBackLine"),c(heldBackLine,"heldBackLine");export function surgeLine(t){const e=t.surge;return`this expected failure is now happening much more often: ${describeExpectedMatch(t.match)} \u2014 ${e?`${e.lastHour} in the last hour, usually ${e.usualPerHour} an hour`:"its rate jumped"} (expected because: ${t.reason})`}h(surgeLine,"surgeLine"),l(surgeLine,"surgeLine"),c(surgeLine,"surgeLine");
|
package/lib/finding-proof.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var a=(e,t)=>o(e,"name",{value:t,configurable:!0});var r=Object.defineProperty,s=a((e,t)=>r(e,"name",{value:t,configurable:!0}),"a"),n=Object.defineProperty,d=s((e,t)=>n(e,"name",{value:t,configurable:!0}),"s");export const FINDING_RISK_CLASSES=["same-bytes","after-the-model","moved-content","less-text-or-schema","new-mechanism"],FINDING_RISK_CLASS={"same-bytes":{label:"Same bytes",reads:"the model reads the same bytes",example:"breakpoints, a prewarm, the order requests are sent",proof:"a byte-identity spec (the new request, joined, is the old one byte for byte) and a cost measurement"},"after-the-model":{label:"After the model",reads:"the model reads the same bytes; code after it changes",example:"dropping a finding that code adds to the answer",proof:"a free replay: the same recorded answers through the old and the new code, everything else byte-equal"},"moved-content":{label:"Moved content",reads:"the model reads the same content in another place or order",example:"cache levels, moving a section",proof:"a paired comparison: before and after side by side, in one session, more than one run a side"},"less-text-or-schema":{label:"Less text or a new schema",reads:"the model reads less text, or a changed schema or instruction",example:"shorter rows, field order, a fact stated once",proof:"the full accuracy comparison"},"new-mechanism":{label:"New mechanism",reads:"the model is asked in a new way",example:"grouping products in one call",proof:"a design first"}};const m={"same-bytes":"same-bytes","same-bytes-read":"same-bytes","byte-identical":"same-bytes","after-the-model":"after-the-model","after-model":"after-the-model","code-after-the-model":"after-the-model","code-after-model":"after-the-model","moved-content":"moved-content",moved:"moved-content","same-content-moved":"moved-content","less-text-or-schema":"less-text-or-schema","less-text":"less-text-or-schema","changed-schema":"less-text-or-schema","less-text-or-a-changed-schema":"less-text-or-schema","new-mechanism":"new-mechanism",new:"new-mechanism"};export function readRiskClass(e){if(typeof e!="string")return;const t=e.trim().toLowerCase().replace(/[\s_]+/g,"-");return m[t]}a(readRiskClass,"readRiskClass"),s(readRiskClass,"readRiskClass"),d(readRiskClass,"readRiskClass");export const FINDING_PROOF_ASK=[`"riskClass": one of ${FINDING_RISK_CLASSES.map(e=>`"${e}"`).join(" | ")} \u2014 what the model reads after the change (${FINDING_RISK_CLASSES.map(e=>`${e}: ${FINDING_RISK_CLASS[e].reads}`).join("; ")}); in doubt, the riskier`,`"proofOwed": "what must be shown before it ships \u2014 its class's proof (${FINDING_RISK_CLASSES.map(e=>`${e}: ${FINDING_RISK_CLASS[e].proof}`).join("; ")}), made concrete for this change: which spec, which calls, how many runs a side"`,`"saving": { "amount": "what it saves, with its unit and per what ('$0.18 per run', '12,000 input tokens a call', '120 s off the stage')", "arithmetic": "the formula with the evidence's numbers and the prices it used", "kind": "estimate" | "measured" (measured only when the evidence holds calls from before and after the change) } or null when it saves nothing countable`];
|
package/lib/flood-guard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var i=(t,
|
|
1
|
+
"use strict";var S=Object.defineProperty;var i=(t,s)=>S(t,"name",{value:s,configurable:!0});var A=Object.defineProperty,f=i((t,s)=>A(t,"name",{value:s,configurable:!0}),"i"),k=Object.defineProperty,u=f((t,s)=>k(t,"name",{value:s,configurable:!0}),"o");function l(){const t=typeof process<"u"?process.env?.LENSMCP_EVENT_MAX_EPS:void 0;if(t===void 0||t==="")return;if(t==="off")return"off";const s=Number(t);if(Number.isFinite(s))return s<=0?"off":s}i(l,"d"),f(l,"S"),u(l,"envPerSec");export function createEventFloodGuard(t){const s=t?.envOverride===!1?void 0:l();if(s==="off")return{admit:u(()=>({ok:!0,suppressed:0}),"admit")};const c=s??t?.perSec??5,d=Math.max(1,t?.burst??Math.max(30,c*4)),p=t?.maxKeys??2048,n=new Map,v=u(o=>{for(const[r,e]of n)o-e.lastSeenAt>6e4&&n.delete(r);if(n.size>p){const r=[...n.entries()].sort((e,a)=>e[1].lastSeenAt-a[1].lastSeenAt);for(let e=0;e<r.length>>1;e++)n.delete(r[e][0])}},"evictStale");return{admit(o){const r=Date.now();let e=n.get(o);e||(n.size>=p&&v(r),e={tokens:d,lastRefillAt:r,suppressed:0,lastSeenAt:r},n.set(o,e)),e.lastSeenAt=r;const a=r-e.lastRefillAt;if(a>0&&(e.tokens=Math.min(d,e.tokens+a/1e3*c),e.lastRefillAt=r),e.tokens>=1){e.tokens-=1;const m=e.suppressed;return e.suppressed=0,{ok:!0,suppressed:m}}return e.suppressed+=1,{ok:!1,suppressed:0}}}}i(createEventFloodGuard,"createEventFloodGuard"),f(createEventFloodGuard,"createEventFloodGuard"),u(createEventFloodGuard,"createEventFloodGuard");
|
package/lib/goal-design.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var r=(e,n)=>o(e,"name",{value:n,configurable:!0});var s=Object.defineProperty,a=r((e,n)=>s(e,"name",{value:n,configurable:!0}),"r"),l=Object.defineProperty,i=a((e,n)=>l(e,"name",{value:n,configurable:!0}),"r");export const DESIGN_TYPES=["bug","investigation","performance","reliability","feature","architecture","maintenance"],DESIGN_CONCERNS=["security","data","api","ui","integration","operations"],DESIGN_TYPE_INFO={bug:{label:"Bug",when:"Something works wrong, and the cause is known or can be found by reading the code."},investigation:{label:"Investigation",when:"Symptoms without a known cause: research first, and the goal ends in a decision or a fix."},performance:{label:"Performance",when:"Something is measurably slow, heavy or costly: a baseline the lens measured and a target."},reliability:{label:"Reliability",when:"Crashes, stalls, flaky tests, lost work, CI or the machine: how it fails and how often."},feature:{label:"Feature",when:"Someone can do something they cannot do now."},architecture:{label:"Architecture",when:"Boundaries, contracts or structure change, in steps that each ship."},maintenance:{label:"Maintenance",when:"Upgrades, moves, tooling and cleanup: no new behaviour, and nothing breaks."}},DESIGN_CONCERN_INFO={security:{label:"Security",when:"Auth, permissions, secrets, input from outside, or anything an attacker would read."},data:{label:"Data",when:"Schema, migrations, backfills, or data already stored."},api:{label:"API",when:"A request or response other code or other people depend on."},ui:{label:"UI",when:"Screens, flows or what a person sees."},integration:{label:"Integration",when:"A service outside the repository: its API, keys, limits and failures."},operations:{label:"Operations",when:"How it deploys, runs, is watched and is rolled back."}},DESIGN_STAGES=["proposed","requested","drafting","waiting","changes","approved","declined"],designOptionId=i(e=>`o${e}`,"designOptionId");export function designOptionOf(e){const n=typeof e=="string"?/^o([1-9])$/.exec(e):null;return n?Number(n[1]):void 0}r(designOptionOf,"designOptionOf"),a(designOptionOf,"designOptionOf"),i(designOptionOf,"designOptionOf");export function designWriter(e){if(e.writer)return e.writer;if(e.by==="user")return{kind:"person"};if(e.by==="lensmcp")return{kind:"lensmcp",...e.byName?{name:e.byName}:{}}}r(designWriter,"designWriter"),a(designWriter,"designWriter"),i(designWriter,"designWriter");const d={claude:"Claude Code",codex:"Codex"};export function designWriterText(e){const n=designWriter(e);if(!n)return"who handed it in was not recorded";const t=n.client?d[n.client]:void 0;switch(n.kind){case"person":return"written by the person";case"lensmcp":return"written by LensMCP's own run";case"terminal":return"handed in from a terminal, as the overseer";case"session":return`handed in by ${t?`a ${t}`:"an agent's"} session${n.role?`, the team's ${n.role}`:" with no role on this team"}`;case"launch":return n.purpose==="design"?`written by a design launch${t?` on ${t}`:""}`:`handed in by the overseer's ${n.purpose==="inbox"?"inbox launch":n.purpose==="round"?"round":"launch"}${t?` on ${t}`:""}`}}r(designWriterText,"designWriterText"),a(designWriterText,"designWriterText"),i(designWriterText,"designWriterText");
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A goal's branch follows main, and its pull request merges by itself (issues/closed/hub-19). The owner,
|
|
3
|
+
* 2026-11-25: «need to a way to make agents understand that they need to always update the worktree local branches and
|
|
4
|
+
* pull from main so the pr are always up to date to merge», «the prs is actually must be merged directly after finish
|
|
5
|
+
* all the checks and it will be auto merged», and «after goal finish and open the pr, it will add task to a pr merger
|
|
6
|
+
* that will check every x what is going on in the prs and merge and update from main».
|
|
7
|
+
*
|
|
8
|
+
* follow the dashboard's minute compares each live goal's branch with origin's main as last fetched — once per
|
|
9
|
+
* origin commit and branch tip — and tells its manager, once per origin commit, how to merge main in
|
|
10
|
+
* auto-merge a goal's pull request that is ready, green and holds origin's main is merged by LensMCP's own minute
|
|
11
|
+
* (Delivery's «Merge» action: `gh pr merge --match-head-commit`); what it waits on is said
|
|
12
|
+
* merger after the goal completed, its open pull request is a `merge` task of the repository's ONE PR merger:
|
|
13
|
+
* it keeps the branch on main in a worktree of its own, fixes what is small, and LensMCP merges it
|
|
14
|
+
*/
|
|
15
|
+
/** A goal's branch against origin's main, as LensMCP's minute last compared them. */
|
|
16
|
+
export interface DashGoalMainFollow {
|
|
17
|
+
/** origin's main as last fetched. */
|
|
18
|
+
origin: string;
|
|
19
|
+
/** The goal branch's tip compared. */
|
|
20
|
+
tip: string;
|
|
21
|
+
/** Commits origin's main has that the branch lacks — 0: the branch holds origin's main. */
|
|
22
|
+
behind: number;
|
|
23
|
+
/** How many files main changed since the branch forked that the goal changed too — the conflict risk. */
|
|
24
|
+
touching: number;
|
|
25
|
+
/** The first of them. */
|
|
26
|
+
files?: string[];
|
|
27
|
+
at: number;
|
|
28
|
+
/** When it was told of this origin commit: its manager or, once it completed, the PR merger (a message) — none live: the goal's log. */
|
|
29
|
+
told?: {
|
|
30
|
+
at: number;
|
|
31
|
+
to: 'manager' | 'merger' | 'log';
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** What LensMCP's auto-merge of a goal's pull request waits on, as its minute last read GitHub. */
|
|
35
|
+
export interface DashGoalAutoMerge {
|
|
36
|
+
/** Each reason in words: «2 checks still running», «a review is required». None: nothing waits. */
|
|
37
|
+
waits?: string[];
|
|
38
|
+
at: number;
|
|
39
|
+
/** The merge LensMCP ran: the head it matched, when, how it ended. */
|
|
40
|
+
merged?: {
|
|
41
|
+
head: string;
|
|
42
|
+
at: number;
|
|
43
|
+
ok: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** A merge task's pull request as LensMCP last read it (the merger's queue). */
|
|
48
|
+
export interface DashMergeOf {
|
|
49
|
+
goalId: string;
|
|
50
|
+
goalNumber?: number;
|
|
51
|
+
goalTitle: string;
|
|
52
|
+
/** The pull request. */
|
|
53
|
+
number: number;
|
|
54
|
+
url?: string;
|
|
55
|
+
/** Its head branch (the goal's) and base. */
|
|
56
|
+
head: string;
|
|
57
|
+
base?: string;
|
|
58
|
+
/** What it waits on now: behind main, conflicts, a failing check, checks running, a review. None: nothing — it merges. */
|
|
59
|
+
waits?: string[];
|
|
60
|
+
/** The merger's worktree for it (`m-<number>`), kept after the goal's own is cleaned up. */
|
|
61
|
+
worktree?: {
|
|
62
|
+
name: string;
|
|
63
|
+
root?: string;
|
|
64
|
+
branch?: string;
|
|
65
|
+
};
|
|
66
|
+
/** LensMCP's newest step on it, in words. */
|
|
67
|
+
last?: {
|
|
68
|
+
at: number;
|
|
69
|
+
text: string;
|
|
70
|
+
};
|
|
71
|
+
/** Merged on GitHub: the commit, when — then the main checkout's local main brought up to date, or why not. */
|
|
72
|
+
merged?: {
|
|
73
|
+
sha: string;
|
|
74
|
+
at: number;
|
|
75
|
+
};
|
|
76
|
+
local?: {
|
|
77
|
+
at: number;
|
|
78
|
+
pulled: boolean;
|
|
79
|
+
text: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** One pull request in the PR merger's queue (Delivery). */
|
|
83
|
+
export interface DashMergeQueueItem extends DashMergeOf {
|
|
84
|
+
taskId: string;
|
|
85
|
+
state: 'open' | 'claimed' | 'recovery' | 'completed' | 'cancelled' | 'design';
|
|
86
|
+
/** The merger session holding it. */
|
|
87
|
+
holder?: string;
|
|
88
|
+
}
|
|
89
|
+
/** The repository's PR merger (Delivery): its switch, the agent running, its queue. */
|
|
90
|
+
export interface DashPrMerger {
|
|
91
|
+
on: boolean;
|
|
92
|
+
/** Why it is on or off, in words. */
|
|
93
|
+
why: string;
|
|
94
|
+
/** The merger agent live now, or the launch on its way. */
|
|
95
|
+
running?: {
|
|
96
|
+
name?: string;
|
|
97
|
+
session?: string;
|
|
98
|
+
launch?: string;
|
|
99
|
+
since?: number;
|
|
100
|
+
};
|
|
101
|
+
/** The merge tasks not finished, then the newest finished ones. */
|
|
102
|
+
queue: DashMergeQueueItem[];
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{};
|
package/lib/goal-number.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var o=(e,r)=>a(e,"name",{value:r,configurable:!0});var f=Object.defineProperty,t=o((e,r)=>f(e,"name",{value:r,configurable:!0}),"o"),m=Object.defineProperty,n=t((e,r)=>m(e,"name",{value:r,configurable:!0}),"r");export const GOAL_NUMBER_MAX=999999999;const b=/^\s*g-?0*(\d{1,9})\s*$/i;export function parseGoalNumber(e){if(typeof e!="string")return;const r=b.exec(e);if(!r)return;const u=Number(r[1]);return Number.isSafeInteger(u)&&u>0&&u<=999999999?u:void 0}o(parseGoalNumber,"parseGoalNumber"),t(parseGoalNumber,"parseGoalNumber"),n(parseGoalNumber,"parseGoalNumber");export function isGoalNumberRef(e){return parseGoalNumber(e)!==void 0}o(isGoalNumberRef,"isGoalNumberRef"),t(isGoalNumberRef,"isGoalNumberRef"),n(isGoalNumberRef,"isGoalNumberRef");export function formatGoalNumber(e){return`G-${e}`}o(formatGoalNumber,"formatGoalNumber"),t(formatGoalNumber,"formatGoalNumber"),n(formatGoalNumber,"formatGoalNumber");export function goalNumberOf(e){const r=e?.number;return typeof r=="number"&&Number.isSafeInteger(r)&&r>0?formatGoalNumber(r):void 0}o(goalNumberOf,"goalNumberOf"),t(goalNumberOf,"goalNumberOf"),n(goalNumberOf,"goalNumberOf");
|
package/lib/goal-process.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { DashGoalReview } from './goal-review.js';
|
|
1
2
|
import type { DashGoalCleanup, DashGoalLanding } from './delivery-status.js';
|
|
3
|
+
import type { DashMergeQueueItem } from './goal-main-follow.js';
|
|
2
4
|
import type { TaskTiming } from './task-timing.js';
|
|
3
5
|
import type { DashTeamStep, DashTeamWorktreeState } from './team.js';
|
|
4
6
|
/**
|
|
@@ -104,6 +106,10 @@ export interface DashGoalProcess {
|
|
|
104
106
|
others: DashProcessTask[];
|
|
105
107
|
othersMore?: number;
|
|
106
108
|
landing: DashProcessLanding;
|
|
109
|
+
/** Its pull request with the PR merger once the goal completed (issues/closed/hub-19): the merge task, and it in words. */
|
|
110
|
+
merge?: DashMergeQueueItem & {
|
|
111
|
+
text: string;
|
|
112
|
+
};
|
|
107
113
|
mainQa: DashProcessMainQa;
|
|
108
114
|
flags: DashProcessFlag[];
|
|
109
115
|
/** What a live goal waits on right now, and since when — none once it ended (hub-10 «Now»). */
|
|
@@ -164,6 +170,8 @@ export interface DashProcessGoal {
|
|
|
164
170
|
until?: number;
|
|
165
171
|
machine?: boolean;
|
|
166
172
|
}>;
|
|
173
|
+
/** Its review canvas — what the person reviews, before and after (issues/closed/hub-18); none: not made yet. */
|
|
174
|
+
review?: DashGoalReview;
|
|
167
175
|
}
|
|
168
176
|
export interface DashProcessWorktree {
|
|
169
177
|
path: string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A goal's review canvas (issues/closed/hub-18): what the person reviews of a finished goal — what it was before
|
|
3
|
+
* and what it is after, in their product's data rather than its code. The owner, 2026-11-25: «i also want to have a good
|
|
4
|
+
* canvas related to each goal and pr so it can be used to see what it was and what is after the pr … so the final canvas
|
|
5
|
+
* will actually be my data to review and not code to review».
|
|
6
|
+
*
|
|
7
|
+
* LensMCP writes its skeleton when the goal's QA passes (apps/canvas review-canvas.ts), and tells the goal's manager in
|
|
8
|
+
* the message that wakes it. The manager fills it before it completes the goal — a goal with a design completes only
|
|
9
|
+
* once every section here is filled ({@link reviewCanvasGaps}). It never holds the merge: the goal's pull request merges
|
|
10
|
+
* on its checks, and what the person finds wrong on the canvas becomes a follow-up goal («Something's wrong»).
|
|
11
|
+
*/
|
|
12
|
+
/** LensMCP's label on a goal's review canvas: the Canvases page and the canvas page know it by it. */
|
|
13
|
+
export declare const REVIEW_CANVAS_TAG = "goal-review";
|
|
14
|
+
/** What a section of the review canvas asks for — its heading, and the prompt the skeleton puts under it. */
|
|
15
|
+
export interface ReviewSection {
|
|
16
|
+
key: 'was' | 'now' | 'diagram' | 'check' | 'shots' | 'proven' | 'left';
|
|
17
|
+
heading: string;
|
|
18
|
+
ask: string;
|
|
19
|
+
/** It may say «none: <why>» — a docs-only goal, or one with no app behaviour. */
|
|
20
|
+
none?: true;
|
|
21
|
+
/** It holds a ```diagram fence of kind before-after. */
|
|
22
|
+
diagram?: true;
|
|
23
|
+
}
|
|
24
|
+
/** The sections, top to bottom, in the person's words. Code appears only under {@link REVIEW_FILES_HEADING}, at the end. */
|
|
25
|
+
export declare const REVIEW_SECTIONS: readonly ReviewSection[];
|
|
26
|
+
/** The last section: the changed files, collapsed — the only code on the canvas. */
|
|
27
|
+
export declare const REVIEW_FILES_HEADING = "Files changed";
|
|
28
|
+
/** The words that open each of the skeleton's prompts: a blockquote that begins with them is still to fill. */
|
|
29
|
+
export declare const REVIEW_TO_FILL = "**To fill \u2014**";
|
|
30
|
+
export type ReviewGapProblem = 'missing' | 'empty' | 'prompt' | 'none-why' | 'no-diagram' | 'not-before-after' | 'files-not-last' | 'files-open';
|
|
31
|
+
/** One thing the review canvas still lacks, with the words a refusal says. */
|
|
32
|
+
export interface ReviewGap {
|
|
33
|
+
/** The section's key, or `files` for «Files changed», `canvas` for the whole. */
|
|
34
|
+
key: ReviewSection['key'] | 'files' | 'canvas';
|
|
35
|
+
heading: string;
|
|
36
|
+
problem: ReviewGapProblem;
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
/** A heading as the rules compare it: lower case, «->» an arrow, its punctuation and spaces folded. */
|
|
40
|
+
export declare function reviewHeadingKey(heading: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* What the review canvas still lacks — none: it is filled. The rules, in order:
|
|
43
|
+
*
|
|
44
|
+
* 1. every section of {@link REVIEW_SECTIONS} is there, as a `##` heading (in any order);
|
|
45
|
+
* 2. each holds words of its own — the skeleton's «To fill» prompt, comments and blank lines are not words;
|
|
46
|
+
* 3. «What you can check yourself» and «Screenshots» may say «none: <why>» — never a bare «none»;
|
|
47
|
+
* 4. «Before → after» holds a ```diagram fence of `kind: before-after`;
|
|
48
|
+
* 5. no «To fill» prompt is left anywhere, «Files changed» included;
|
|
49
|
+
* 6. «Files changed», when there, is the last section, inside `<Details>` — the only code is collapsed, at the end.
|
|
50
|
+
*
|
|
51
|
+
* The canvas checker (it draws, apps/canvas review-canvas.ts) is the other half of the gate.
|
|
52
|
+
*/
|
|
53
|
+
export declare function reviewCanvasGaps(mdx: string): ReviewGap[];
|
|
54
|
+
/** The gaps as one refusal's text: each on its own line. */
|
|
55
|
+
export declare function reviewGapsText(gaps: readonly ReviewGap[], max?: number): string;
|
|
56
|
+
/** The person's word on a review canvas: the goal looks right, or something is wrong — a follow-up goal. */
|
|
57
|
+
export declare const GOAL_REVIEW_VERDICTS: readonly ["looks-right", "something-wrong"];
|
|
58
|
+
export type GoalReviewVerdictKind = (typeof GOAL_REVIEW_VERDICTS)[number];
|
|
59
|
+
/** «Something's wrong»'s one line: what the person found. */
|
|
60
|
+
export declare const GOAL_REVIEW_NOTE_MAX = 300;
|
|
61
|
+
/** A goal a review's «Something's wrong» made. */
|
|
62
|
+
export interface DashGoalReviewFollowUp {
|
|
63
|
+
id: string;
|
|
64
|
+
number?: number;
|
|
65
|
+
title: string;
|
|
66
|
+
state?: string;
|
|
67
|
+
}
|
|
68
|
+
/** The person's newest word on the review. */
|
|
69
|
+
export interface DashGoalReviewVerdict {
|
|
70
|
+
kind: GoalReviewVerdictKind;
|
|
71
|
+
at: number;
|
|
72
|
+
note?: string;
|
|
73
|
+
/** «Something's wrong»: the follow-up goal it made. */
|
|
74
|
+
followUp?: DashGoalReviewFollowUp;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A goal's review canvas as the dashboard shows it — Team › Process, the goal's drawer, Delivery's row, the canvas page's
|
|
78
|
+
* dock (`GET /api/team/goal-review?goal=`).
|
|
79
|
+
*/
|
|
80
|
+
export interface DashGoalReview {
|
|
81
|
+
canvasId: string;
|
|
82
|
+
/** When LensMCP made its skeleton, and who (`lensmcp`). */
|
|
83
|
+
at: number;
|
|
84
|
+
by: string;
|
|
85
|
+
/** Where the person opens it: the canvas's own link. */
|
|
86
|
+
url?: string;
|
|
87
|
+
/**
|
|
88
|
+
* `filled`: every section says what it should, and it draws; `unfilled`: what it lacks is in `gaps`; `gone`: the canvas
|
|
89
|
+
* is not in this machine's canvas store; `unread`: not read now.
|
|
90
|
+
*/
|
|
91
|
+
state: 'filled' | 'unfilled' | 'gone' | 'unread';
|
|
92
|
+
/** What it lacks, each in a line (the gate's words). */
|
|
93
|
+
gaps?: string[];
|
|
94
|
+
/** The version the person sees. */
|
|
95
|
+
version?: number;
|
|
96
|
+
verdict?: DashGoalReviewVerdict;
|
|
97
|
+
/** Every follow-up goal its «Something's wrong» made, oldest first. */
|
|
98
|
+
followUps?: DashGoalReviewFollowUp[];
|
|
99
|
+
}
|
|
100
|
+
/** `GET /api/team/goal-review?goal=`: the goal, whether it has a design (the gate holds its completion), and its review. */
|
|
101
|
+
export interface DashGoalReviewAnswer {
|
|
102
|
+
goal: {
|
|
103
|
+
id: string;
|
|
104
|
+
number?: number;
|
|
105
|
+
title: string;
|
|
106
|
+
state: string;
|
|
107
|
+
hasDesign: boolean;
|
|
108
|
+
};
|
|
109
|
+
review?: DashGoalReview;
|
|
110
|
+
/** No review canvas yet: why, in words — it is made when the goal's QA passes. */
|
|
111
|
+
why?: string;
|
|
112
|
+
}
|
|
113
|
+
/** `POST /api/team/goal-review`: the person's «Looks right» or «Something's wrong» (with its one line). */
|
|
114
|
+
export interface DashGoalReviewVerdictRequest {
|
|
115
|
+
goal: string;
|
|
116
|
+
verdict: GoalReviewVerdictKind;
|
|
117
|
+
note?: string;
|
|
118
|
+
}
|
|
119
|
+
/** A goal's review as Delivery's row shows it: where it is, and the person's word. */
|
|
120
|
+
export interface DashGoalReviewBrief {
|
|
121
|
+
canvasId: string;
|
|
122
|
+
url?: string;
|
|
123
|
+
verdict?: GoalReviewVerdictKind;
|
|
124
|
+
at?: number;
|
|
125
|
+
followUp?: DashGoalReviewFollowUp;
|
|
126
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var l=(r,s)=>y(r,"name",{value:s,configurable:!0});var k=Object.defineProperty,c=l((r,s)=>k(r,"name",{value:s,configurable:!0}),"l");export const REVIEW_CANVAS_TAG="goal-review",REVIEW_SECTIONS=[{key:"was",heading:"What it was",ask:"today's behaviour, in the product's terms and data: what the person sees and does now. A goal that is docs-only, or has no app behaviour, says so here."},{key:"now",heading:"What it is now",ask:"the same, after this goal: what the person sees and does now, in the same terms."},{key:"diagram",heading:"Before \u2192 after",ask:"a `diagram` fence of kind before-after: the flow today and after this goal, in the product's words \u2014 never code.",diagram:!0},{key:"check",heading:"What you can check yourself",ask:"the pages and flows to open in the goal's running app, each a link to its host, and the data rows or answers that changed \u2014 before/after tables of the real values QA read. If there is none, say \xABnone:\xBB and why.",none:!0},{key:"shots",heading:"Screenshots",ask:"before and after, when the goal has a UI. If there is none, say \xABnone:\xBB and why.",none:!0},{key:"proven",heading:"What was proven",ask:"each Done line with its evidence \u2014 QA's steps, runs, stories \u2014 and anything waived: who waived it, and why."},{key:"left",heading:"What it did not change, and risks",ask:"what is left, the risks, and the follow-ups."}],REVIEW_FILES_HEADING="Files changed",REVIEW_TO_FILL="**To fill \u2014**";const x=/^\s{0,3}(`{3,}|~{3,})\s*([A-Za-z0-9_-]*)/,b=/^\s{0,3}##\s+(.+?)\s*#*\s*$/;export function reviewHeadingKey(r){return r.toLowerCase().replace(/->|=>/g,"\u2192").replace(/[*_`«»"'.:]/g,"").replace(/\s+/g," ").trim()}l(reviewHeadingKey,"reviewHeadingKey"),c(reviewHeadingKey,"reviewHeadingKey");function w(r){const s=r.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`);let h=0;if(s[0]?.trim()==="---"){const t=s.findIndex((e,a)=>a>0&&e.trim()==="---");t>0&&(h=t+1)}const n=[];let i,o;for(;h<s.length;h++){const t=s[h],e=x.exec(t);if(o){e&&e[1].startsWith(o.mark[0])&&e[1].length>=o.mark.length&&!t.trim().slice(e[1].length).trim()?(i?.fences.push({info:o.info,body:o.body.join(`
|
|
4
|
+
`)}),i?.lines.push(t),o=void 0):(o.body.push(t),i?.lines.push(t));continue}if(e){o={mark:e[1],info:(e[2]??"").toLowerCase(),body:[]},i?.lines.push(t);continue}const a=b.exec(t);if(a){i={heading:a[1],at:n.length,lines:[],fences:[]},n.push(i);continue}i?.lines.push(t)}return o&&i&&i.fences.push({info:o.info,body:o.body.join(`
|
|
5
|
+
`)}),n}l(w,"k"),c(w,"partsOf");function f(r){const s=[];let h=0,n=!1,i=!1;for(const o of r){const t=o.trim();if(i){(t.includes("*/}")||t.includes("-->"))&&(i=!1);continue}if(/^\{\/\*/.test(t)||t.startsWith("<!--")){!t.includes("*/}")&&!t.includes("-->")&&(i=!0);continue}if(t.startsWith(">")){if(t.replace(/^>\s?/,"").trim().startsWith(REVIEW_TO_FILL)){h++,n=!0;continue}if(n)continue}else n=!1;!t||/^<\/?Details\b[^>]*>$/.test(t)||s.push(t)}return{words:s,prompts:h}}l(f,"p"),c(f,"wordsOf");const B=/^(?:\*\*|_)?none(?:\*\*|_)?\s*(?:[:—–-]\s*)?(.*)$/i;export function reviewCanvasGaps(r){const s=w(r),h=new Map;for(const e of s)h.has(reviewHeadingKey(e.heading))||h.set(reviewHeadingKey(e.heading),e);const n=[],i=c(e=>{const a=reviewHeadingKey(e);return h.get(a)??s.find(d=>reviewHeadingKey(d.heading).startsWith(`${a} `))},"find");for(const e of REVIEW_SECTIONS){const a=i(e.heading),d=`\xAB${e.heading}\xBB`;if(!a){n.push({key:e.key,heading:e.heading,problem:"missing",text:`${d} is missing \u2014 add it as \`## ${e.heading}\`: ${e.ask}`});continue}const{words:g,prompts:u}=f(a.lines),m=a.fences.filter(p=>p.info==="diagram");if(!g.length&&!m.length){n.push({key:e.key,heading:e.heading,problem:u?"prompt":"empty",text:`${d} is ${u?"still the skeleton's prompt":"empty"} \u2014 ${e.ask}`});continue}if(u&&n.push({key:e.key,heading:e.heading,problem:"prompt",text:`${d} still holds the skeleton's \xABTo fill\xBB prompt \u2014 take it out once the section says it`}),e.none&&g.length===1){const p=B.exec(g[0]);p&&!p[1].replace(/[.\s*_]/g,"")&&n.push({key:e.key,heading:e.heading,problem:"none-why",text:`${d} says \xABnone\xBB with no why \u2014 write \xABnone: <why>\xBB (docs-only, no app behaviour, no UI)`})}e.diagram&&(m.length?m.some(p=>/^\s*kind\s*:\s*['"]?before-after['"]?\s*(?:#.*)?$/m.test(p.body))||n.push({key:e.key,heading:e.heading,problem:"not-before-after",text:`${d}'s \`\`\`diagram is not \`kind: before-after\` \u2014 this section shows what it was and what it is now side by side`}):n.push({key:e.key,heading:e.heading,problem:"no-diagram",text:`${d} has no \`\`\`diagram fence \u2014 draw the flow before and after as \`kind: before-after\`, with \`before\` and \`after\` nodes in the product's words`}))}const o=i(REVIEW_FILES_HEADING);if(o){const{prompts:e}=f(o.lines);e&&n.push({key:"files",heading:REVIEW_FILES_HEADING,problem:"prompt",text:`\xAB${REVIEW_FILES_HEADING}\xBB is still the skeleton's prompt \u2014 list the changed files, or take the section out`}),o.at!==s.length-1&&n.push({key:"files",heading:REVIEW_FILES_HEADING,problem:"files-not-last",text:`\xAB${REVIEW_FILES_HEADING}\xBB is not the last section \u2014 the code comes last, after what the person reviews`}),f(o.lines).words.length&&!o.lines.some(a=>/^\s*<Details\b/.test(a))&&n.push({key:"files",heading:REVIEW_FILES_HEADING,problem:"files-open",text:`\xAB${REVIEW_FILES_HEADING}\xBB is not collapsed \u2014 put its list inside \`<Details summary="Files changed">\``})}const t=new Set([...REVIEW_SECTIONS.map(e=>e.heading),REVIEW_FILES_HEADING].map(reviewHeadingKey));for(const e of s){const a=reviewHeadingKey(e.heading);t.has(a)||[...t].some(d=>a.startsWith(`${d} `))||f(e.lines).prompts&&n.push({key:"canvas",heading:e.heading,problem:"prompt",text:`\xAB${e.heading}\xBB still holds a \xABTo fill\xBB prompt`})}return n}l(reviewCanvasGaps,"reviewCanvasGaps"),c(reviewCanvasGaps,"reviewCanvasGaps");export function reviewGapsText(r,s=12){return[...r.slice(0,s).map(h=>`- ${h.text}`),...r.length>s?[`- and ${r.length-s} more`]:[]].join(`
|
|
6
|
+
`)}l(reviewGapsText,"reviewGapsText"),c(reviewGapsText,"reviewGapsText");export const GOAL_REVIEW_VERDICTS=["looks-right","something-wrong"],GOAL_REVIEW_NOTE_MAX=300;
|
package/lib/host-agents.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});var u=Object.defineProperty,n=o((t,e)=>u(t,"name",{value:e,configurable:!0}),"s"),i=Object.defineProperty,s=n((t,e)=>i(t,"name",{value:e,configurable:!0}),"o");export const HOST_AGENT_CLIENTS=["claude","codex"],HOST_AGENTS_FILES={agents:"host-agents.json",ceilings:"host-ceilings.json"},HOST_AGENTS_LIMITS={accounts:32,windows:6,label:60,why:300,plan:40,name:40,agents:64},HOST_ACCOUNT_ID=/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const r=[/\bsk-[A-Za-z0-9_-]{16,}/,/\b[rs]k_(?:live|test)_[A-Za-z0-9]{12,}/,/\bgh[pousr]_[A-Za-z0-9]{20,}|\bgithub_pat_[A-Za-z0-9_]{20,}/,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bxox[abposr]-[A-Za-z0-9-]{10,}/,/\bAIza[0-9A-Za-z_-]{30,}/,/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}/,/-----BEGIN [A-Z ]*(?:PRIVATE KEY|CERTIFICATE)-----/,/\bbearer\s+[A-Za-z0-9._~+/=-]{12,}/i],A=/[A-Za-z0-9+/_=-]{32,}/g;export function tokenShaped(t){if(r.some(e=>e.test(t)))return!0;for(const e of t.match(A)??[])if(/\d/.test(e)&&/[A-Za-z]/.test(e))return!0;return!1}o(tokenShaped,"tokenShaped"),n(tokenShaped,"tokenShaped"),s(tokenShaped,"tokenShaped");export function withoutTokens(t){let e=t;for(const a of r)e=e.replace(new RegExp(a.source,a.flags.includes("g")?a.flags:`${a.flags}g`),"\u2026");return e.replace(A,a=>/\d/.test(a)&&/[A-Za-z]/.test(a)?"\u2026":a)}o(withoutTokens,"withoutTokens"),n(withoutTokens,"withoutTokens"),s(withoutTokens,"withoutTokens");
|
package/lib/lens-hosts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var r=(e,n)=>c(e,"name",{value:n,configurable:!0});var i=Object.defineProperty,t=r((e,n)=>i(e,"name",{value:n,configurable:!0}),"t"),u=Object.defineProperty,o=t((e,n)=>u(e,"name",{value:n,configurable:!0}),"r");export const LENS_HOST="lensmcp.localhost",LEGACY_LENS_HOST="lensmcp.local",CANVAS_LINK_PATH="/canvas";export function lensOrigin(e={}){const n=e.port!==void 0&&e.port!==443?`:${e.port}`:"";return`https://${e.host||LENS_HOST}${n}`}r(lensOrigin,"lensOrigin"),t(lensOrigin,"lensOrigin"),o(lensOrigin,"lensOrigin");export function dashboardLink(e,n="",a={}){const s=e.replace(/\/+$/,"");return`${lensOrigin(a)}${s}/${n.replace(/^\/+/,"")}`}r(dashboardLink,"dashboardLink"),t(dashboardLink,"dashboardLink"),o(dashboardLink,"dashboardLink");export function canvasKeyFreeLink(e,n={}){return`${lensOrigin(n)}${CANVAS_LINK_PATH}/${e}`}r(canvasKeyFreeLink,"canvasKeyFreeLink"),t(canvasKeyFreeLink,"canvasKeyFreeLink"),o(canvasKeyFreeLink,"canvasKeyFreeLink");export function gatewayPortFromEnv(e){const n=Number((e.LENSMCP_GATEWAY_PORTS??"").split(",")[0]);return Number.isInteger(n)&&n>0&&n<65536?n:void 0}r(gatewayPortFromEnv,"gatewayPortFromEnv"),t(gatewayPortFromEnv,"gatewayPortFromEnv"),o(gatewayPortFromEnv,"gatewayPortFromEnv");export function currentLensHost(e){return e.trim().toLowerCase()===LEGACY_LENS_HOST?LENS_HOST:e}r(currentLensHost,"currentLensHost"),t(currentLensHost,"currentLensHost"),o(currentLensHost,"currentLensHost");
|
package/lib/lint-coverage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var p=(e,r)=>C(e,"name",{value:r,configurable:!0});var k=Object.defineProperty,h=p((e,r)=>k(e,"name",{value:r,configurable:!0}),"g"),A=Object.defineProperty,d=h((e,r)=>A(e,"name",{value:r,configurable:!0}),"i");import{TRUNCATION_MARKER_KEY as j}from"./bounded-clone.js";export const LINT_COVER_KIND="lint-cover",MAX_LINT_UNCOMMITTED=500;const L=["tree","paths","changed","incremental"],m=d(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.length>0):[],"strings"),i=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,"count"),l=d(e=>typeof e=="string"&&e?e:void 0,"text");export function readLintCoverage(e){if(!e||typeof e!="object"||e[j])return;const r=e.coverage;if(!r||typeof r!="object")return;const t=r,n=t.kind,a=t.root;if(!L.includes(n)||typeof a!="string"||!a)return;const u=m(t.dirs),o=m(t.files),g=m(t.gone),$=i(t.notLinted),y=i(t.untracked),s=t.base&&typeof t.base=="object"?t.base:void 0,v=s&&l(s.sha)&&l(s.run)?{from:s.from==="main"?"main":"own",sha:s.sha,run:s.run}:void 0,b=Array.isArray(t.inputs)?t.inputs.flatMap(f=>Array.isArray(f)&&typeof f[0]=="string"&&typeof f[1]=="string"?[[f[0],f[1]]]:[]):void 0;return{kind:n,root:a,dirs:u,files:o,gone:g,fileCount:i(t.fileCount)??o.length,goneCount:i(t.goneCount)??g.length,linted:i(t.linted)??0,...i(t.dirCount)!==void 0?{dirCount:i(t.dirCount)}:{},...$?{notLinted:$}:{},...y?{untracked:y}:{},...l(t.since)?{since:t.since}:{},...l(t.head)?{head:t.head}:{},...typeof t.dirty=="boolean"?{dirty:t.dirty}:{},...Array.isArray(t.uncommitted)?{uncommitted:m(t.uncommitted)}:{},...t.uncommittedMore===!0?{uncommittedMore:!0}:{},...b?{inputs:b}:{},...l(t.folder)?{folder:t.folder}:{},...t.projects===!0?{projects:!0}:{},...v?{base:v}:{},...t.fromZero===!0?{fromZero:!0}:{},...t.narrowed===!0?{narrowed:!0}:{}}}p(readLintCoverage,"readLintCoverage"),h(readLintCoverage,"readLintCoverage"),d(readLintCoverage,"readLintCoverage");const c=d((e,r)=>`${e} ${r}${e===1?"":"s"}`,"some");export function lintCoverageLabel(e,r={}){const t=e.files??0,n=e.gone??0;if(e.kind==="changed"){const o=`since ${e.since??"HEAD"}`;if(!t)return`${c(n,"deleted file")} ${o}`;const g=r.untracked&&e.untracked?` (${e.untracked} untracked)`:"";return`${c(t,"changed file")} ${o}${g}${n?`, ${n} deleted`:""}`}if(e.kind==="incremental"){const o=e.since?` since ${e.since.slice(0,7)}`:"";return!t&&!n?`nothing changed${o}`:t?`${c(t,"file")} changed${o}${n?`, ${n} deleted`:""}`:`${c(n,"file")} deleted${o}`}if(e.kind==="tree"&&e.projects)return`the workspace\u2019s ${c(e.projects,"project")}`;if(e.kind==="tree"&&e.paths[0]===".")return"whole checkout";if(e.narrowed)return`${c(t,"file")} ESLint linted with the caller\u2019s arguments`;const a=e.paths.slice(0,3).join(", "),u=(e.more??0)+Math.max(0,e.paths.length-3);return u?`${a} +${u} more`:a}p(lintCoverageLabel,"lintCoverageLabel"),h(lintCoverageLabel,"lintCoverageLabel"),d(lintCoverageLabel,"lintCoverageLabel");
|
package/lib/lint-ignores.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var u=(r
|
|
2
|
-
`}u(lintIgnoresText,"lintIgnoresText"),
|
|
1
|
+
"use strict";var $=Object.defineProperty;var u=(e,r)=>$(e,"name",{value:r,configurable:!0});var w=Object.defineProperty,c=u((e,r)=>w(e,"name",{value:r,configurable:!0}),"u"),x=Object.defineProperty,l=c((e,r)=>x(e,"name",{value:r,configurable:!0}),"l");export const LINT_IGNORES_FILE=".lensmcp/lint/ignores.json",LINT_IGNORE_LIMITS={rule:200,project:200,reason:500,evidence:1e3,by:80,ignores:500},LINT_IGNORED_RULES_SAID=50,LINT_IGNORED_NOTE="The person ignored these lints in the repository (each a rule in a project, with why): they are left out of the counts, the verdict and the status \u2014 do not fix them, and do not edit the ESLint config or this file for them. ESLint itself (`nx lint`) still reports them. To ask for another, `lint_ignore_propose`; only the person accepts.";const j=l(e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,"obj"),h=l(e=>typeof e=="string"&&e.trim()?e.replace(/\s+/g," ").trim():void 0,"text");export function lintIgnoreKey(e,r){return`${r}\0${e}`}u(lintIgnoreKey,"lintIgnoreKey"),c(lintIgnoreKey,"lintIgnoreKey"),l(lintIgnoreKey,"lintIgnoreKey");export function checkLintIgnore(e){const r=h(e.rule),o=h(e.project),t=h(e.reason),n=LINT_IGNORE_LIMITS;return r?r==="fatal"?{problem:"a file ESLint could not parse is never ignored \u2014 fix it"}:r.length>n.rule?{problem:`the rule is at most ${n.rule} characters`}:o?o.length>n.project?{problem:`the project is at most ${n.project} characters`}:t?t.length>n.reason?{problem:`the reason is at most ${n.reason} characters`}:{rule:r,project:o,reason:t}:{problem:"say why it is not to be fixed \u2014 the reason is what a teammate and an agent read"}:{problem:"name the project that owns the files"}:{problem:"name the rule (ESLint\u2019s rule id, as the finding names it)"}}u(checkLintIgnore,"checkLintIgnore"),c(checkLintIgnore,"checkLintIgnore"),l(checkLintIgnore,"checkLintIgnore");export function parseLintIgnores(e){if(e===void 0||!e.trim())return{ignores:[],problems:[]};let r;try{r=JSON.parse(e)}catch(s){return{ignores:[],problems:[`${LINT_IGNORES_FILE} is not JSON (${s instanceof Error?s.message:String(s)}) \u2014 no lint is ignored until it is`]}}const o=j(r),t=o?o.ignores:void 0;if(!o||!Array.isArray(t))return{ignores:[],problems:[`${LINT_IGNORES_FILE} holds no "ignores" list \u2014 no lint is ignored until it does`]};const n=[],a=[],i=new Set;return t.forEach((s,p)=>{const f=j(s);if(!f){a.push(`ignores[${p}] is not an object`);return}const g=checkLintIgnore(f);if("problem"in g){a.push(`ignores[${p}]: ${g.problem}`);return}const d=lintIgnoreKey(g.rule,g.project);if(i.has(d)){a.push(`ignores[${p}]: ${g.rule} in ${g.project} is ignored above already \u2014 the first stands`);return}if(n.length>=LINT_IGNORE_LIMITS.ignores){a.push(`ignores[${p}]: past ${LINT_IGNORE_LIMITS.ignores} ignores \u2014 the rest are not read`);return}i.add(d);const b=h(f.by)?.slice(0,LINT_IGNORE_LIMITS.by),m=h(f.at),y=h(f.proposal);n.push({...g,...b?{by:b}:{},...m&&!Number.isNaN(Date.parse(m))?{at:m}:{},...y?{proposal:y.slice(0,40)}:{}})}),{ignores:n,problems:a}}u(parseLintIgnores,"parseLintIgnores"),c(parseLintIgnores,"parseLintIgnores"),l(parseLintIgnores,"parseLintIgnores");export function lintIgnoresText(e){const r=[...e].sort((t,n)=>t.project<n.project?-1:t.project>n.project?1:t.rule<n.rule?-1:t.rule>n.rule?1:0),o=l(t=>({rule:t.rule,project:t.project,reason:t.reason,...t.by?{by:t.by}:{},...t.at?{at:t.at}:{},...t.proposal?{proposal:t.proposal}:{}}),"entry");return`${JSON.stringify({version:1,ignores:r.map(o)},null,2)}
|
|
2
|
+
`}u(lintIgnoresText,"lintIgnoresText"),c(lintIgnoresText,"lintIgnoresText"),l(lintIgnoresText,"lintIgnoresText");export function withLintIgnore(e,r){const o=lintIgnoreKey(r.rule,r.project);return[...e.filter(t=>lintIgnoreKey(t.rule,t.project)!==o),r]}u(withLintIgnore,"withLintIgnore"),c(withLintIgnore,"withLintIgnore"),l(withLintIgnore,"withLintIgnore");export function withoutLintIgnore(e,r,o){const t=lintIgnoreKey(r,o);return e.filter(n=>lintIgnoreKey(n.rule,n.project)!==t)}u(withoutLintIgnore,"withoutLintIgnore"),c(withoutLintIgnore,"withoutLintIgnore"),l(withoutLintIgnore,"withoutLintIgnore");export function lintIgnoreMatcher(e){if(!e.length)return()=>{};const r=new Map(e.map(o=>[lintIgnoreKey(o.rule,o.project),o]));return({rule:o,project:t,scope:n})=>{if(!o||o==="fatal")return;const a=t??n;return a===void 0?void 0:r.get(lintIgnoreKey(o,a))}}u(lintIgnoreMatcher,"lintIgnoreMatcher"),c(lintIgnoreMatcher,"lintIgnoreMatcher"),l(lintIgnoreMatcher,"lintIgnoreMatcher");export function lintIgnoredSummary(e,r){if(!e.ignores.length&&!e.problems.length)return;let o=0,t=0;const n=e.ignores.map(i=>{const s=r.get(lintIgnoreKey(i.rule,i.project))??{errors:0,warnings:0};return o+=s.errors,t+=s.warnings,{rule:i.rule,project:i.project,reason:i.reason,...i.by?{by:i.by}:{},...i.at?{at:i.at}:{},errors:s.errors,warnings:s.warnings}}).map((i,s)=>({r:i,i:s})).sort((i,s)=>s.r.errors-i.r.errors||s.r.warnings-i.r.warnings||i.i-s.i).map(({r:i})=>i),a=n.length-LINT_IGNORED_RULES_SAID;return{file:LINT_IGNORES_FILE,errors:o,warnings:t,rules:n.slice(0,LINT_IGNORED_RULES_SAID),...a>0?{moreRules:a}:{},...e.problems.length?{problems:e.problems.slice(0,10)}:{},note:LINT_IGNORED_NOTE}}u(lintIgnoredSummary,"lintIgnoredSummary"),c(lintIgnoredSummary,"lintIgnoredSummary"),l(lintIgnoredSummary,"lintIgnoredSummary");export function lintIgnoreTally(e){const r=lintIgnoreMatcher(e.ignores),o=new Map;return{hides(t,n,a=1){const i=r(t);if(!i)return;const s=lintIgnoreKey(i.rule,i.project),p=o.get(s)??{errors:0,warnings:0};return n==="error"?p.errors+=a:p.warnings+=a,o.set(s,p),i},summary:l(()=>lintIgnoredSummary(e,o),"summary")}}u(lintIgnoreTally,"lintIgnoreTally"),c(lintIgnoreTally,"lintIgnoreTally"),l(lintIgnoreTally,"lintIgnoreTally");const I=10,L=l((e,r)=>`${e} ${r}${e===1?"":"s"}`,"counted");export function lintIgnoredLines(e){if(!e)return[];const r=[],o=e.rules.filter(n=>n.errors||n.warnings),t=[e.errors?L(e.errors,"error"):"",e.warnings?L(e.warnings,"warning"):""].filter(Boolean).join(", ");t&&r.push(` ignored (${e.file}): ${t} left out \u2014 not counted, not to be fixed`);for(const n of o.slice(0,I))r.push(` ${n.rule} in ${n.project} \u2014 ${n.reason}`);o.length>I&&r.push(` and ${o.length-I} more (--json lists them)`);for(const n of e.problems??[])r.push(` ${e.file}: ${n}`);return r}u(lintIgnoredLines,"lintIgnoredLines"),c(lintIgnoredLines,"lintIgnoredLines"),l(lintIgnoredLines,"lintIgnoredLines");export const LINT_IGNORE_PROPOSAL_LIMITS={open:30,kept:200,requestId:200};
|
package/lib/log-query.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var L=Object.defineProperty;var a=(e,t)=>L(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,c=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"a"),h=Object.defineProperty,u=c((e,t)=>h(e,"name",{value:t,configurable:!0}),"c");const p={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},C={warn:"warning",err:"error"},k=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const t=[],r=[];for(const s of e.matchAll(k)){const[o,n,g,y,w]=s,i=(y??w??"").trim(),l=g?p[g.toLowerCase()]:void 0;if(l&&i){const m=l==="level"?C[i.toLowerCase()]??i.toLowerCase():i;t.push({key:l,value:m,negate:n==="-"})}else o.trim()&&r.push(o.trim())}return{tokens:t,text:r.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery"),u(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const t=u(r=>/\s/.test(r)?`"${r}"`:r,"quote");return[...e.tokens.map(r=>`${r.negate?"-":""}${r.key}:${t(r.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery"),u(formatLogQuery,"formatLogQuery");function v(e,t){if(e===void 0)return!1;const r=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(t);if(!r)return!1;const s=Number(r[2]);switch(r[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(v,"v"),c(v,"h"),u(v,"msMatches");function f(e,t){const r=t.value.toLowerCase();switch(t.key){case"level":return e.severity.toLowerCase()===r;case"service":return e.source.toLowerCase()===r;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(r);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(r);case"category":return e.category.toLowerCase()===r;case"ms":return v(e.durationMs,t.value)}}a(f,"l"),c(f,"i"),u(f,"tokenMatches");export function matchesLogQuery(e,t,r){const s=new Map;for(const o of t.tokens){if(o.negate){if(f(e,o))return!1;continue}const n=s.get(o.key);n?n.push(o):s.set(o.key,[o])}for(const o of s.values())if(!o.some(n=>f(e,n)))return!1;if(t.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return r?r(o):o.toLowerCase().includes(t.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery"),u(matchesLogQuery,"matchesLogQuery");
|
package/lib/metrics-reset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var i=(e,t)=>l(e,"name",{value:t,configurable:!0});var f=Object.defineProperty,a=i((e,t)=>f(e,"name",{value:t,configurable:!0}),"i"),u=Object.defineProperty,c=a((e,t)=>u(e,"name",{value:t,configurable:!0}),"s");import{LENS_EVENT_SOURCE as S}from"./error-dismissal.js";export const METRICS_RESET="metrics-reset",METRICS_RESTORED="metrics-restored",METRICS_SCOPES=["sql","external"],MAX_METRICS_RESET_IDS=500,MAX_METRICS_RESET_ID_LENGTH=512,METRICS_RESET_IDS_PER_EVENT=64;const d=16*1024,p=c(e=>e==="sql"||e==="external","isScope"),E=c(e=>typeof e=="string"&&e.length>0&&e.length<=MAX_METRICS_RESET_ID_LENGTH,"isId");export function readMetricsReset(e){if(e.source!==S||!e.raw||typeof e.raw!="object")return;const t=e.raw,r=t.kind;if(r!==METRICS_RESET&&r!==METRICS_RESTORED)return;const n=t.scope;if(!p(n))return;let s;if(t.ids!==void 0&&(!Array.isArray(t.ids)||(s=[...new Set(t.ids.filter(E))].slice(0,METRICS_RESET_IDS_PER_EVENT),!s.length)))return;if(r===METRICS_RESTORED)return{kind:r,scope:n,...s?{ids:s}:{}};const o=t.at;if(!(typeof o!="number"||!Number.isFinite(o)))return{kind:r,scope:n,at:Math.min(o,e.timestamp),...s?{ids:s}:{}}}i(readMetricsReset,"readMetricsReset"),a(readMetricsReset,"readMetricsReset"),c(readMetricsReset,"readMetricsReset");export function metricsIdBatches(e){const t=[];let r=[],n=0;for(const s of new Set(e.filter(E)))r.length&&(r.length>=METRICS_RESET_IDS_PER_EVENT||n+s.length+3>d)&&(t.push(r),r=[],n=0),r.push(s),n+=s.length+3;return r.length&&t.push(r),t}i(metricsIdBatches,"metricsIdBatches"),a(metricsIdBatches,"metricsIdBatches"),c(metricsIdBatches,"metricsIdBatches");
|
package/lib/overseer-findings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var s=(n,e)=>u(n,"name",{value:e,configurable:!0});var l=Object.defineProperty,c=s((n,e)=>l(n,"name",{value:e,configurable:!0}),"s"),f=Object.defineProperty,r=c((n,e)=>f(n,"name",{value:e,configurable:!0}),"s");import{systemValue as a}from"./system-report.js";export const FINDING_RUN_KINDS=["operate","stop-launch","close-session","role","role-off","check","rule","flow","lesson"];export function findingSightingValue(n,e){const i=a(n.value,n.check?n.unit:e.unit);if(!n.check||e.checks.length<=1)return i;const t=n.check.slice(n.check.lastIndexOf("/")+1),o=t.slice(t.lastIndexOf(".")+1);return i.startsWith(`${o} `)?`${t}${i.slice(o.length)}`:`${t} ${i}`}s(findingSightingValue,"findingSightingValue"),c(findingSightingValue,"findingSightingValue"),r(findingSightingValue,"findingSightingValue");export function findingLive(n){return n.state==="open"||n.state==="proposed"||n.state==="applied"}s(findingLive,"findingLive"),c(findingLive,"findingLive"),r(findingLive,"findingLive");export function findingRunsActions(n,e={}){return n.actions.some(i=>FINDING_RUN_KINDS.includes(i.kind)||i.kind==="issue"&&e.issuesFolder===!0)}s(findingRunsActions,"findingRunsActions"),c(findingRunsActions,"findingRunsActions"),r(findingRunsActions,"findingRunsActions");export function findingsForCheck(n,e,i){const t=`repo:${e}/team.${i}`;return n.filter(o=>findingLive(o)&&o.checks.includes(t))}s(findingsForCheck,"findingsForCheck"),c(findingsForCheck,"findingsForCheck"),r(findingsForCheck,"findingsForCheck");
|