dal-code 1.0.58 → 1.0.60
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/CHANGELOG.md +8 -0
- package/dist/bundle/chunks/{anthropic-messages-FOIJU7LX.js → anthropic-messages-XQHIW2F5.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-7NBJZKX5.js → azure-openai-responses-2STR7FU2.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-4PBY6OYS.js → chunk-2SQ577MS.js} +1 -1
- package/dist/bundle/chunks/{chunk-T5PI6B5P.js → chunk-2TJCPBNY.js} +1 -1
- package/dist/bundle/chunks/{chunk-QU2VEHMW.js → chunk-3KEFLXX2.js} +2 -2
- package/dist/bundle/chunks/{chunk-4BOWD7PQ.js → chunk-425HIJ4E.js} +1 -1
- package/dist/bundle/chunks/{chunk-5MF5GEDD.js → chunk-4KCKRVPN.js} +1 -1
- package/dist/bundle/chunks/{chunk-CCU76UL3.js → chunk-4TEICWYC.js} +7 -7
- package/dist/bundle/chunks/{chunk-HF334NQU.js → chunk-B66W54NL.js} +1 -1
- package/dist/bundle/chunks/{chunk-JK74OC6W.js → chunk-CIJDL6I3.js} +1 -1
- package/dist/bundle/chunks/{chunk-QFBU27TM.js → chunk-E6RWRE6C.js} +1 -1
- package/dist/bundle/chunks/chunk-EXWCUM6H.js +9 -0
- package/dist/bundle/chunks/{chunk-C5ELI234.js → chunk-H3KG4L7I.js} +1 -1
- package/dist/bundle/chunks/{chunk-B7KZDIWA.js → chunk-HZWPNFQO.js} +1 -1
- package/dist/bundle/chunks/{chunk-DVEPGKL5.js → chunk-KMTIPRJ5.js} +1 -1
- package/dist/bundle/chunks/{chunk-F5SIUTR7.js → chunk-LGD3AMTG.js} +1 -1
- package/dist/bundle/chunks/{chunk-AL3DFAIM.js → chunk-NRQYSXAU.js} +1 -1
- package/dist/bundle/chunks/{chunk-IONGABQF.js → chunk-O5BJV54H.js} +1 -1
- package/dist/bundle/chunks/chunk-P3KSBU23.js +17 -0
- package/dist/bundle/chunks/{chunk-R47JBGS3.js → chunk-QM5JU2GS.js} +1 -1
- package/dist/bundle/chunks/{chunk-LMZYTWXD.js → chunk-RNSD5PAD.js} +1 -1
- package/dist/bundle/chunks/{chunk-3QG7FIE4.js → chunk-RRLI6IMC.js} +1 -1
- package/dist/bundle/chunks/{chunk-PMFHJN7I.js → chunk-SI4QX273.js} +1 -1
- package/dist/bundle/chunks/{chunk-X7I3V6OA.js → chunk-THJSXCE4.js} +1 -1
- package/dist/bundle/chunks/{chunk-NYSVXLKF.js → chunk-X2O23QIN.js} +1 -1
- package/dist/bundle/chunks/{chunk-XQF5XDEM.js → chunk-XQ6Z77K4.js} +2 -2
- package/dist/bundle/chunks/{cli-NQ7B7BGV.js → cli-H3PJUN3W.js} +1 -1
- package/dist/bundle/chunks/{cli-RY666QAD.js → cli-OEEFOWRC.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-CFGOMWWZ.js → cloudflare-workers-ai-system-one-55VRUHTE.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-W2F3ROZ6.js → easter-egg-3d-JQUBBOXE.js} +1 -1
- package/dist/bundle/chunks/{execute-NJRE4WBO.js → execute-DAF3F222.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-ZA2RHPNE.js → google-generative-ai-BQMG6OLH.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-Y2GRWOK7.js → google-vertex-WUZF5EYV.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-G2JDOFHY.js → llama-cpp-classify-MADWJYHP.js} +1 -1
- package/dist/bundle/chunks/{mcp-45D7KCZZ.js → mcp-GYBI424O.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-MLV32BRV.js → mistral-conversations-GSSWAQLZ.js} +1 -1
- package/dist/bundle/chunks/{office-UBOUFRAU.js → office-OKOPPNJS.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-BDK3PY6G.js → openai-codex-responses-LJCENL64.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-BLXHKAB3.js → openai-completions-MT4XYSLH.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-IGVID576.js → openai-decisions-Y3TPPQUQ.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-KHZOEDF2.js → openai-responses-5EXHN2JI.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-SA6PUASF.js → openrouter-images-4YZGO774.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-3VAOLQ2Y.js → pi-messages-EGKKYUGE.js} +1 -1
- package/dist/bundle/chunks/{review-RZXLHPUZ.js → review-GXC4JNBH.js} +1 -1
- package/dist/bundle/chunks/{router-YBVXODIL.js → router-6IBMTBKX.js} +1 -1
- package/dist/bundle/chunks/{runtime-FNCZJKOC.js → runtime-MD23I2NI.js} +1 -1
- package/dist/bundle/chunks/{sdk-X6RX7FNE.js → sdk-Z2BPQBYQ.js} +1 -1
- package/dist/bundle/chunks/sync-Q7ZHP4AB.js +21 -0
- package/dist/bundle/chunks/{typesafe-system-one-ER3DLYNF.js → typesafe-system-one-ZIS4YIPV.js} +1 -1
- package/dist/bundle/chunks/{usage-LMRFS2HV.js → usage-WQOCA772.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-XIUNRFOZ.js → virtual-modules-SEIIF76E.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-guard/src/attribution.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
- package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -6
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +3 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/bundle/chunks/chunk-JXAFVEE4.js +0 -17
- package/dist/bundle/chunks/chunk-SCZEDPDC.js +0 -9
- package/dist/bundle/chunks/sync-CRV6BXXC.js +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
${s.rootCause??""}`:s.content);return e.length===s.risk.length&&e.every(n=>s.risk.includes(n))?s:e.some(n=>!s.risk.includes(n))&&s.status==="active"?{...s,risk:e,status:"awaiting_user"}:e.length===0&&s.status==="awaiting_user"?{...s,risk:e,status:"candidate"}:{...s,risk:e}}d(
|
|
3
|
-
${e.rootCause??""}`:e.content),sessions:[n],evidence:[a],...e.proof?{proof:{...e.proof,at:f(o),sessionId:n}}:{},helpful:0,harmful:0,feedback:[],created:f(o),updated:f(o)};return r=
|
|
4
|
-
`),ids:G,eligible:t,tokens:h}}d(
|
|
1
|
+
var _s=Object.defineProperty;var d=(s,e)=>_s(s,"name",{value:e,configurable:!0});var js=Object.defineProperty,u=d((s,e)=>js(s,"name",{value:e,configurable:!0}),"c");import{join as Ss}from"node:path";import{rejectLesson as Ls,riskOf as Y}from"./safety.js";import{codeFailed as Rs,commandIntent as Ts,failureReason as Bs,fixCommands as Ds,isUntellingReason as Fs,sameChecks as q}from"./signals.js";import{estimateTokens as L,num as b,readDoc as Ns,records as R,str as c,strList as T,updateDoc as Os}from"./store.js";const $s=["harmful","ineffective","unused","user","malformed","outdated"],K=2,W=60,Z=5,J=30,Q=700,B=6,ss=12,D=20,es=864e5,Ms=["candidate","active","awaiting_user","retired","undone","expired"],zs=["failure_then_fix","user_correction","repeated_detour","guard_denial","success_workflow","imported"],Hs=["helpful","harmful","neutral"],Us=["deletion","permissions","credentials","network","publishing","dependencies"];function y(s){return Ss(s,"lessons.json")}d(y,"K"),u(y,"lessonsPath");function ts(s){const e=c(s.id,16),n=c(s.content,400);if(!/^[lu]-\d{4,6}$/.test(e)||!n)return;const o=Ms.includes(s.status)?s.status:"candidate",t=s.fix,a=s.proof,r=s.origin;return{...s,id:e,scope:s.scope==="user"?"user":"project",section:c(s.section,40)||"general",content:n,rootCause:c(s.rootCause,400),...c(s.signature,300)?{signature:c(s.signature,300)}:{},...t&&typeof t.good=="string"?{fix:{intent:c(t.intent,20),bad:c(t.bad,200),good:c(t.good,200),...c(t.dir,200)?{dir:c(t.dir,200)}:{}}}:{},status:o,risk:T(s.risk,5,20).filter(i=>Us.includes(i)),sessions:T(s.sessions,ss,80),evidence:R(s.evidence).map(i=>({sessionId:c(i.sessionId,80),at:c(i.at,32),signal:zs.includes(i.signal)?i.signal:"user_correction",note:c(i.note,300)})).slice(-B),...a&&typeof a.at=="string"?{proof:{kind:a.kind==="outcome"?"outcome":"test",at:c(a.at,32),sessionId:c(a.sessionId,80),note:c(a.note,300)}}:{},helpful:b(s.helpful),harmful:b(s.harmful),...b(s.neutral)>0?{neutral:b(s.neutral)}:{},...b(s.injections)>0?{injections:b(s.injections)}:{},...c(s.lastInjectedAt,32)?{lastInjectedAt:c(s.lastInjectedAt,32)}:{},feedback:R(s.feedback).filter(i=>Hs.includes(i.tag)).map(i=>({sessionId:c(i.sessionId,80),tag:i.tag,at:c(i.at,32),why:c(i.why,200)})).slice(-D),created:c(s.created,32),updated:c(s.updated,32),...c(s.activatedAt,32)?{activatedAt:c(s.activatedAt,32)}:{},...["sessions","proof","user","import","trial"].includes(s.activatedBy)?{activatedBy:s.activatedBy}:{},...c(s.lastHelpfulAt,32)?{lastHelpfulAt:c(s.lastHelpfulAt,32)}:{},...c(s.retiredAt,32)?{retiredAt:c(s.retiredAt,32)}:{},...$s.includes(s.retiredReason)?{retiredReason:s.retiredReason}:{},...r&&r.kind==="desktop"?{origin:{kind:"desktop",projectId:c(r.projectId,32),ruleId:c(r.ruleId,16)}}:{}}}d(ts,"fe"),u(ts,"parseLesson");const I=u(s=>s.replace(/\s+/g," ").trim(),"fold");function F(s){if(!s.fix||!s.signature?.startsWith("fix:")||s.activatedBy==="user"||s.activatedBy==="import")return!1;const e=Ds(s.fix.bad,s.fix.good);return!e||I(e.bad)!==I(s.fix.bad)||I(e.good)!==I(s.fix.good)||Fs(s.rootCause)||s.rootCause.trim()&&!Bs(s.rootCause)||Rs(s.rootCause)?!0:Ls({content:s.content})!==void 0}d(F,"le"),u(F,"isMalformed");const ns=["candidate","active","awaiting_user"];function os(s){return!ns.includes(s.status)||!F(s)?s:{...s,status:"retired",retiredAt:s.updated||s.created,retiredReason:"malformed"}}d(os,"pe"),u(os,"retireMalformed");function as(s){if(s.activatedBy==="user"||s.activatedBy==="import")return s;const e=Y(s.fix?`${s.fix.good}
|
|
2
|
+
${s.rootCause??""}`:s.content);return e.length===s.risk.length&&e.every(n=>s.risk.includes(n))?s:e.some(n=>!s.risk.includes(n))&&s.status==="active"?{...s,risk:e,status:"awaiting_user"}:e.length===0&&s.status==="awaiting_user"?{...s,risk:e,status:"candidate"}:{...s,risk:e}}d(as,"ge"),u(as,"recheckRisk");function w(s){const e=R(s?.lessons).map(ts).filter(a=>a!==void 0).map(os).map(as),n=e.reduce((a,r)=>Math.max(a,Number(r.id.slice(2))),0),o={},t=s?.imported;if(t&&typeof t=="object"&&!Array.isArray(t))for(const[a,r]of Object.entries(t))o[a]=T(r,1e3,16);return{nextId:Math.max(b(s?.nextId),n+1,1),lessons:e,imported:o}}d(w,"z"),u(w,"parseLessonsDoc");function is(s){return Ns(y(s),w).value}d(is,"Me"),u(is,"readLessons");function rs(s,e){return Os(y(s),w,e)}d(rs,"Ke"),u(rs,"updateLessons");function C(s){return s.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,"")}d(C,"E"),u(C,"normalizeText");function N(s){const e=C(s),n=new Set;for(let o=0;o<e.length-1;o++)n.add(e.slice(o,o+2));return n}d(N,"P"),u(N,"bigrams");function O(s,e){const n=N(s),o=N(e);if(n.size===0||o.size===0)return C(s)===C(e)?1:0;let t=0;for(const a of n)o.has(a)&&t++;return 2*t/(n.size+o.size)}d(O,"me"),u(O,"similarity");const us=.72;function ds(s,e){return s.intent===e.intent&&(s.dir??".")===(e.dir??".")&&q(s.bad,e.bad)&&q(s.good,e.good)}d(ds,"xe"),u(ds,"sameFix");function $(s,e){const n=s.lessons.filter(r=>r.retiredReason!=="malformed");if(e.signature){const r=n.find(i=>i.signature===e.signature);if(r)return r}const{fix:o}=e;if(o){const r=n.find(i=>i.fix&&ds(i.fix,o));if(r)return r}let t,a=0;for(const r of n){if(o&&r.fix)continue;const i=O(r.content,e.content);i>a&&(t=r,a=i)}return a>=us?t:void 0}d($,"Le"),u($,"findMatch");function f(s){return new Date(s).toISOString()}d(f,"l"),u(f,"iso");function _(s,e){if(s.status!=="candidate")return s;const n=s.sessions.length>=K,o=s.proof!==void 0;return!n&&!o?s:s.risk.length>0?{...s,status:"awaiting_user",updated:f(e)}:{...s,status:"active",activatedAt:f(e),activatedBy:o&&!n?"proof":"sessions",updated:f(e)}}d(_,"T"),u(_,"promote");function cs(s,e,n,o){const t=(e.confirms?s.lessons.find(i=>i.id===e.confirms):void 0)??$(s,e),a={sessionId:n,at:f(o),signal:e.signal,note:e.note.slice(0,300)};if(t?.status==="retired"&&t.retiredReason==="outdated")return ls(s,t,e,a,n,o);if(t){if(t.status==="undone"||t.status==="retired")return{doc:s,outcome:{kind:"suppressed",lesson:t}};const i=!t.sessions.includes(n),h=t.status==="active"&&k(t)&&i&&e.proof!==void 0&&!t.feedback.some(E=>E.sessionId===n&&E.tag==="helpful");let p={...t,status:t.status==="expired"?"candidate":t.status,sessions:i?[...t.sessions,n].slice(-ss):t.sessions,evidence:[...t.evidence,a].slice(-B),...e.proof&&!t.proof?{proof:{...e.proof,at:f(o),sessionId:n}}:{},...h?{helpful:t.helpful+1,lastHelpfulAt:f(o),feedback:[...t.feedback,{sessionId:n,tag:"helpful",at:f(o),why:`proven again: ${e.note}`.slice(0,200)}].slice(-D)}:{},updated:f(o)};p=_(p,o);const v=s.lessons.map(E=>E.id===t.id?p:E);return{doc:{...s,lessons:v},outcome:{kind:i?"confirmed":"repeated",lesson:p},...t.status!==p.status?{transition:{lesson:p,from:t.status,to:p.status}}:{}}}let r={id:`${e.scope==="user"?"u":"l"}-${String(s.nextId).padStart(4,"0")}`,scope:e.scope,section:e.section||"general",content:e.content,rootCause:e.rootCause,...e.signature?{signature:e.signature}:{},...e.fix?{fix:e.fix}:{},status:"candidate",risk:Y(e.fix?`${e.fix.good}
|
|
3
|
+
${e.rootCause??""}`:e.content),sessions:[n],evidence:[a],...e.proof?{proof:{...e.proof,at:f(o),sessionId:n}}:{},helpful:0,harmful:0,feedback:[],created:f(o),updated:f(o)};return r=_(r,o),{doc:{...s,nextId:s.nextId+1,lessons:[...s.lessons,r]},outcome:{kind:"created",lesson:r},...r.status!=="candidate"?{transition:{lesson:r,from:"candidate",to:r.status}}:{}}}d(cs,"He"),u(cs,"proposeLesson");function ls(s,e,n,o,t,a){const{proof:r,retiredAt:i,retiredReason:h,...p}=e,v=_({...p,...n.fix?{fix:n.fix}:{},status:"candidate",sessions:[t],evidence:[...e.evidence,o].slice(-B),...n.proof?{proof:{...n.proof,at:f(a),sessionId:t}}:{},updated:f(a)},a);return{doc:{...s,lessons:s.lessons.map(E=>E.id===e.id?v:E)},outcome:{kind:"confirmed",lesson:v},transition:{lesson:v,from:e.status,to:v.status}}}d(ls,"be"),u(ls,"relearn");function fs(s,e,n){const o=s.lessons.find(a=>a.id===e);if(!o||o.status==="active")return{doc:s,lesson:o};const t={...o,status:"active",activatedAt:f(n),activatedBy:"user",updated:f(n)};return delete t.retiredAt,delete t.retiredReason,{doc:{...s,lessons:s.lessons.map(a=>a.id===e?t:a)},lesson:t}}d(fs,"ze"),u(fs,"approveLesson");function ps(s,e,n){const o=s.lessons.find(a=>a.id===e);if(!o||o.status==="undone")return{doc:s,lesson:o};const t={...o,status:"undone",retiredAt:f(n),retiredReason:"user",updated:f(n)};return{doc:{...s,lessons:s.lessons.map(a=>a.id===e?t:a)},lesson:t}}d(ps,"Pe"),u(ps,"undoLesson");function ms(s,e,n,o){let t=0;const a=s.lessons.map(r=>{let i=r;for(const h of e.filter(p=>p.id===r.id))i.feedback.some(p=>p.sessionId===n&&p.tag===h.tag)||(t++,i={...i,helpful:i.helpful+(h.tag==="helpful"?1:0),harmful:i.harmful+(h.tag==="harmful"?1:0),...h.tag==="neutral"?{neutral:(i.neutral??0)+1}:{},feedback:[...i.feedback,{sessionId:n,tag:h.tag,at:f(o),why:h.why.slice(0,200)}].slice(-D),...h.tag==="helpful"?{lastHelpfulAt:f(o)}:{},updated:f(o)});return i});return{doc:t>0?{...s,lessons:a}:s,changed:t}}d(ms,"Ue"),u(ms,"applyFeedback");function M(s){return s.harmful>=2&&s.harmful>s.helpful}d(M,"ke"),u(M,"isHarmful");function k(s){return s.harmful>=1&&s.harmful===s.helpful}d(k,"C"),u(k,"isContested");function hs(s){return s.status==="active"&&s.helpful>=1&&s.harmful===0}d(hs,"qe"),u(hs,"isTrusted");function z(s){return s.status==="candidate"&&s.risk.length===0&&s.helpful>=1&&s.harmful===0}d(z,"ye"),u(z,"provenOnTrial");function H(s){return s.helpful===0&&(s.neutral??0)>=Z}d(H,"Se"),u(H,"isIneffective");function A(s,e,n){return{...s,status:"retired",retiredAt:f(n),retiredReason:e,updated:f(n)}}d(A,"v"),u(A,"retired");function gs(s,e){const n=[],o=s.lessons.map(t=>{let a;const r=t.status==="active"||t.status==="candidate";if(r&&M(t))a=A(t,"harmful",e);else if(r&&H(t))a=A(t,"ineffective",e);else if(t.status==="candidate"&&z(t))a={...t,status:"active",activatedAt:f(e),activatedBy:"trial",updated:f(e)};else if(t.status==="candidate"){const i=Date.parse(t.updated||t.created);Number.isFinite(i)&&e-i>J*es&&(a={...t,status:"expired",updated:f(e)})}return a?(n.push({lesson:a,from:t.status,to:a.status}),a):t});return{doc:n.length>0?{...s,lessons:o}:s,transitions:n}}d(gs,"Ge"),u(gs,"retireLessons");function vs(s,e,n){const o=[],t=s.lessons.map(a=>{if(!ns.includes(a.status)||!a.fix?.bad||!e(a.fix))return a;const r=A(a,"outdated",n);return o.push({lesson:r,from:a.status,to:r.status}),r});return{doc:o.length>0?{...s,lessons:t}:s,transitions:o}}d(vs,"Xe"),u(vs,"retireOutdated");function Es(s,e,n,o){const t=[];let a=!1;const r=s.lessons.map(i=>{if(i.status!=="active")return i;if(e.includes(i.id))return a=!0,{...i,injections:(i.injections??0)+1,lastInjectedAt:f(o)};if(!n.includes(i.id))return i;const h=Math.max(...[i.lastInjectedAt,i.lastHelpfulAt,i.activatedAt??i.created].map(v=>v?Date.parse(v):Number.NaN).filter(Number.isFinite));if(!Number.isFinite(h)||o-h<=W*es)return i;a=!0;const p=A(i,"unused",o);return t.push({lesson:p,from:i.status,to:p.status}),p});return{doc:a?{...s,lessons:r}:s,transitions:t}}d(Es,"Ve"),u(Es,"recordInjection");const bs="Lessons learned from earlier sessions, applied automatically on evidence (two sessions or a passing check) or confirmed by the user. Apply one when the situation matches; the user's instructions and every protection come first. If a lesson is wrong here, say so and name its id. When a lesson contradicts what the repository or the user shows now, trust the repository and the user: the lesson is outdated.",ks=6,As=2,xs=2;function U(s){return(s.activatedBy==="proof"||s.activatedBy==="sessions"||s.activatedBy==="trial")&&s.helpful===0&&(s.neutral??0)>=xs}d(U,"_e"),u(U,"lacksEvidence");const Ps=new Set("the and for with this that these those from into when then than before after instead only each every use used using run runs running ran make makes made keep edit edits editing file files project projects here there what which while where your you our are was were has have had not but all any its one two fails fail failed failing passes pass passed should must can will just also more most first last same src lib test tests js mjs cjs ts tsx jsx json md py go rs txt yaml yml".split(" ")),Gs=new Set("\u672C\u9879 \u9879\u76EE \u76EE\u91CC \u6539\u7528 \u4F1A\u5931 \u5931\u8D25 \u4F7F\u7528 \u65F6\u5019 \u4E4B\u524D \u4E4B\u540E \u6587\u4EF6 \u8FD0\u884C \u4E00\u4E0B \u8FD9\u4E2A \u90A3\u4E2A \u53EF\u4EE5 \u9700\u8981 \u4E0D\u8981 \u5982\u679C \u7136\u540E \u73B0\u5728 \u5DF2\u7ECF \u6211\u4EEC \u4F60\u7684 \u4E00\u4E2A \u4EC0\u4E48 \u600E\u4E48 \u4E3A\u4EC0\u4E48 \u5E2E\u6211 \u770B\u770B \u95EE\u9898 \u4EE3\u7801".split(" "));function j(s){const e=new Set,n=s.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase();for(const o of n.match(/[a-z][a-z0-9_-]{2,}/g)??[])for(const t of[o,...o.split(/[-_]/)])t.length>=3&&!Ps.has(t)&&e.add(t);for(const o of s.match(new RegExp("\\p{Script=Han}{2,}","gu"))??[])for(let t=0;t<o.length-1;t++){const a=o.slice(t,t+2);Gs.has(a)||e.add(a)}return e}d(j,"j"),u(j,"termsOf");function ys(s){const e=new Set,n=u(o=>o.test(s),"has");if(n(/\b(?:fix|bug|broken|implement|add|change|update|refactor|rename|remove|support|migrate|make|failing|regression)\w*\b/i)||n(/修|改|实现|加上|增加|添加|支持|重构|迁移|报错|错误|不对|坏了/))for(const o of["test","build","typecheck"])e.add(o);return(n(/\b(?:tests?|specs?|ci)\b/i)||n(/测试|用例|单测/))&&e.add("test"),(n(/\b(?:build|compile|bundle|dist)\w*\b/i)||n(/构建|编译|打包/))&&e.add("build"),(n(/\b(?:lint|format)\w*\b/i)||n(/格式|规范/))&&e.add("lint"),(n(/\b(?:types?|typecheck|tsc)\b/i)||n(/类型/))&&e.add("typecheck"),(n(/\b(?:install|dependenc\w*|packages?|upgrade)\b/i)||n(/依赖|安装|升级/))&&e.add("install"),e}d(ys,"Ee"),u(ys,"impliedKinds");const Vs=new Set(["test","build","lint","typecheck","install"]);function Is(s){const e=new Set;s.fix?.intent&&e.add(s.fix.intent),Vs.has(s.section)&&e.add(s.section);for(const[,n]of s.content.matchAll(/`([^`]+)`/g)){const o=Ts(n);o&&e.add(o)}return e}d(Is,"Ce"),u(Is,"kindsOf");function S(s,e){const n=e.request?.trim()??"";if(!n)return 0;const o=j(n);for(const r of e.paths??[]){const i=j(r);if([...i].some(h=>o.has(h)))for(const h of i)o.add(h)}let t=0;for(const r of j(`${s.content} ${s.fix?.bad??""} ${s.fix?.good??""}`))o.has(r)&&(t+=1);const a=ys(n);return[...Is(s)].some(r=>a.has(r))&&(t+=1),t}d(S,"q"),u(S,"relevance");function ws(s){return s.helpful-s.harmful+(s.activatedBy==="user"?1:0)}d(ws,"je"),u(ws,"effect");function Cs(s,e={},n=Q){const o=!!e.request?.trim(),t=[],a=[],r=[];s.forEach((m,g)=>{for(const l of m.lessons){if(l.status==="candidate"){if(!o||l.risk.length>0||k(l)||l.section==="workflow")continue;const X=S(l,e);X>=1&&r.push({group:g,lesson:l,score:X});continue}if(l.status!=="active")continue;const x=l.scope==="user",V=o&&!x?S(l,e):0;o&&!x&&V<1||(t.push(l.id),!(U(l)||k(l))&&a.push({group:g,lesson:l,score:V+ws(l)}))}}),a.sort((m,g)=>m.group-g.group||g.score-m.score||m.lesson.id.localeCompare(g.lesson.id));const i=u(m=>`- [${m.id}] ${m.content.replace(/\s+/g," ")}`,"lineOf");let h=L(bs);const p=new Set,v=u(m=>[...p].some(g=>a.find(l=>l.lesson.id===g)?.group===m)?0:L(`${s[m].label}:`),"headerCost");r.sort((m,g)=>g.score-m.score||m.lesson.id.localeCompare(g.lesson.id));let E=0;for(const m of[...a,...r]){if(p.size>=ks)break;const g=m.lesson.status==="candidate";if(g&&E>=As)continue;const l=L(i(m.lesson))+1+v(m.group);h+l>n||(h+=l,p.add(m.lesson.id),g&&E++)}if(p.size===0)return{ids:[],eligible:t,tokens:0};const P=[bs],G=[];return s.forEach(m=>{const g=m.lessons.filter(l=>p.has(l.id)&&(l.status==="active"||l.status==="candidate")).sort((l,x)=>l.id.localeCompare(x.id));g.length!==0&&(P.push(`${m.label}:`,...g.map(i)),G.push(...g.map(l=>l.id)))}),{text:P.join(`
|
|
4
|
+
`),ids:G,eligible:t,tokens:h}}d(Cs,"Ye"),u(Cs,"renderLessonsSection");export{J as CANDIDATE_EXPIRE_DAYS,K as CONFIRMATIONS_TO_ACTIVATE,Q as LESSONS_TOKEN_BUDGET,ks as MAX_LESSONS_GIVEN,As as MAX_TRIAL_GIVEN,xs as NEUTRAL_HOLD_AFTER,Z as NEUTRAL_RETIRE_AFTER,us as SAME_LESSON_SIMILARITY,W as UNUSED_RETIRE_DAYS,ms as applyFeedback,fs as approveLesson,$ as findMatch,k as isContested,M as isHarmful,H as isIneffective,F as isMalformed,hs as isTrusted,U as lacksEvidence,y as lessonsPath,w as parseLessonsDoc,cs as proposeLesson,z as provenOnTrial,is as readLessons,Es as recordInjection,S as relevance,Cs as renderLessonsSection,gs as retireLessons,vs as retireOutdated,O as similarity,ps as undoLesson,rs as updateLessons};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),tokens:r,facts:n}}
|
|
1
|
+
var ts=Object.defineProperty;var d=(s,t)=>ts(s,"name",{value:t,configurable:!0});var es=Object.defineProperty,f=d((s,t)=>es(s,"name",{value:t,configurable:!0}),"f");import{createHash as as}from"node:crypto";import{readFileSync as ns,statSync as os}from"node:fs";import{isAbsolute as L,join as C,normalize as is,relative as rs,resolve as U,sep as cs}from"node:path";import{normalizeCommand as D}from"./extract.js";import{isSensitivePath as Y}from"./safety.js";import{isSearch as ls,passedLast as ds,sameChecks as H}from"./signals.js";import{estimateTokens as P,num as S,readDoc as ps,records as q,str as u,strList as E,updateDoc as fs}from"./store.js";const z=600,O=45,w=120,ms=864e5,us=40,hs=40,gs=30,As=12,V=["test","build","lint","typecheck","install"];function j(s){return C(s,"map.json")}d(j,"w"),f(j,"mapPath");function M(s){const t={},a=s?.managerVotes;if(a&&typeof a=="object"&&!Array.isArray(a))for(const[e,p]of Object.entries(a))/^(?:npm|pnpm|yarn|bun)$/.test(e)&&(t[e]=S(p));return{commands:q(s?.commands).filter(e=>V.includes(e.kind)&&typeof e.command=="string").map(e=>({...e,kind:e.kind,dir:u(e.dir,200)||".",command:u(e.command,200),successes:S(e.successes),failures:S(e.failures),sessions:E(e.sessions,10,80),lastOkAt:u(e.lastOkAt,32),...u(e.lastFailAt,32)?{lastFailAt:u(e.lastFailAt,32)}:{},...u(e.manifestHash,16)?{manifestHash:u(e.manifestHash,16)}:{}})),managerVotes:t,locations:q(s?.locations).filter(e=>typeof e.query=="string"&&typeof e.path=="string").map(e=>({...e,query:u(e.query,120),path:u(e.path,300),sessions:E(e.sessions,10,80),searches:S(e.searches),lastAt:u(e.lastAt,32)})),hotFiles:q(s?.hotFiles).filter(e=>typeof e.path=="string").map(e=>({...e,path:u(e.path,300),sessions:E(e.sessions,10,80),lastAt:u(e.lastAt,32)})),pitfalls:q(s?.pitfalls).filter(e=>typeof e.bad=="string"&&typeof e.good=="string").map(e=>({...e,bad:u(e.bad,200),good:u(e.good,200),reason:u(e.reason,160),lastAt:u(e.lastAt,32)}))}}d(M,"E"),f(M,"parseMap");function W(s){return ps(j(s),M).value}d(W,"ys"),f(W,"readMap");function F(s,t,a){const e=L(a)?a:U(t,a),p=rs(s,is(e));if(!(p.startsWith("..")||L(p)))return p.split(cs).join("/")||"."}d(F,"P"),f(F,"projectRelative");function _(s,t){for(const a of["package.json","pyproject.toml","Cargo.toml","go.mod","Makefile","pom.xml","build.gradle"])try{return as("sha256").update(ns(C(s,t,a))).digest("hex").slice(0,16)}catch{}}d(_,"R"),f(_,"manifestHash");function B(s){return/^(npm|pnpm|yarn|bun|npx|pnpx|bunx)\b/.exec(s)?.[1]?.replace(/^npx$/,"npm").replace(/^pnpx$/,"pnpm").replace(/^bunx$/,"bun")}d(B,"is"),f(B,"managerOf");function N(s){const t=s.args.path??s.args.file_path??s.args.file;return typeof t=="string"&&t?t:void 0}d(N,"v"),f(N,"pathArg");function G(s){const t=s.args.pattern??s.args.query??s.args.glob;if(typeof t=="string"&&t.trim())return t.trim().slice(0,120);if(s.command){const a=/(?:rg|grep|ag|git\s+grep)\s+(?:-[\w-]+\s+)*(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(s.command),e=a?.[1]??a?.[2]??a?.[3];if(e)return e.slice(0,120);const p=/\bfind\b.*-i?name\s+(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(s.command),h=p?.[1]??p?.[2]??p?.[3];if(h)return h.slice(0,120)}}d(G,"cs"),f(G,"queryOf");function I(s,t){return s.includes(t)?s:[...s,t].slice(-10)}d(I,"H"),f(I,"addSession");function K(s,t){const a=new Date(t.now).toISOString(),e=s.commands.map(n=>({...n})),p={...s.managerVotes};for(const n of t.steps){if(!n.intent||!n.command)continue;const o=n.cdDir?U(t.cwd,n.cdDir):t.cwd,i=F(t.root,t.cwd,o);if(!i)continue;const l=D(n.command);if(!l||/<secret>|<opaque>/.test(l))continue;const c=e.find(v=>v.kind===n.intent&&v.dir===i&&H(v.command,l));if(n.isError){c&&(c.failures++,c.lastFailAt=a);continue}const m=_(t.root,i),A=B(l);A&&(p[A]=(p[A]??0)+1),c?(c.successes++,c.lastOkAt=a,c.sessions=I(c.sessions,t.sessionId),m!==void 0?c.manifestHash=m:delete c.manifestHash):e.push({kind:n.intent,dir:i,command:l,successes:1,failures:0,sessions:[t.sessionId],lastOkAt:a,...m!==void 0?{manifestHash:m}:{}})}const h=s.locations.map(n=>({...n})),k=[];for(const n of t.steps){if(ls(n)&&!n.isError){const m=G(n);m&&k.push({query:m,output:n.output});continue}if(n.name!=="read"||n.isError)continue;const o=N(n);if(!o||Y(o))continue;const i=F(t.root,t.cwd,o);if(!i||i===".")continue;const l=i.split("/").at(-1)??i,c=k.filter(m=>m.output.includes(l)||m.output.includes(i));for(const m of c){const A=h.find(v=>v.query===m.query&&v.path===i);A?(A.searches++,A.sessions=I(A.sessions,t.sessionId),A.lastAt=a):h.push({query:m.query,path:i,sessions:[t.sessionId],searches:1,lastAt:a})}c.length>0&&(k.length=0)}const g=s.hotFiles.map(n=>({...n}));for(const n of t.steps){if(n.name!=="read"||n.isError)continue;const o=N(n);if(!o||Y(o))continue;const i=F(t.root,t.cwd,o);if(!i||i===".")continue;const l=g.find(c=>c.path===i);l?(l.sessions=I(l.sessions,t.sessionId),l.lastAt=a):g.push({path:i,sessions:[t.sessionId],lastAt:a})}const y=F(t.root,t.cwd,t.cwd),$=s.pitfalls.map(n=>({...n}));for(const n of t.fixes){const o=D(n.bad),i=D(n.good),l=$.find(c=>(c.dir??".")===(y||".")&&H(c.bad,o)&&H(c.good,i));l?l.lastAt=a:$.push({bad:o,good:i,reason:n.reason,lastAt:a,...y?{dir:y}:{}})}const r=$.filter(n=>!y||(n.dir??".")!==y||!ds(t.steps,n.bad));return J({commands:e,managerVotes:p,locations:h,hotFiles:g,pitfalls:r},t.now)}d(K,"xs"),f(K,"learnFromRun");function b(s,t){const a=Date.parse(s);return Number.isFinite(a)?(t-a)/ms:Number.POSITIVE_INFINITY}d(b,"x"),f(b,"age");function x(s,t){return(t.lastAt??t.lastOkAt??"").localeCompare(s.lastAt??s.lastOkAt??"")}d(x,"C"),f(x,"newestFirst");function J(s,t){return{commands:s.commands.filter(a=>b(a.lastOkAt,t)<=w).sort(x).slice(0,us),managerVotes:s.managerVotes,locations:s.locations.filter(a=>b(a.lastAt,t)<=w).sort(x).slice(0,hs),hotFiles:s.hotFiles.filter(a=>b(a.lastAt,t)<=w).sort(x).slice(0,gs),pitfalls:s.pitfalls.filter(a=>b(a.lastAt,t)<=w).sort(x).slice(0,As)}}d(J,"ls"),f(J,"prune");function Q(s,t){return fs(j(s),M,t)}d(Q,"Fs"),f(Q,"updateMap");function T(s,t,a){if(b(s.lastOkAt,a)>O)return"old";if(s.lastFailAt&&s.lastFailAt>s.lastOkAt)return"failed_since";if(s.manifestHash!==void 0){const e=_(t,s.dir);if(e===void 0)return"missing";if(e!==s.manifestHash)return"manifest_changed"}}d(T,"ds"),f(T,"commandStaleness");function R(s,t){try{return os(C(s,t)),!0}catch{return!1}}d(R,"N"),f(R,"exists");function X(s,t,a){const e=[],p=[];for(const r of s.commands){const n=T(r,t,a);n?e.push({fact:`${r.kind} ${r.dir}: ${r.command}`,reason:n}):p.push(r)}const h=s.locations.filter(r=>r.sessions.length<2&&r.searches<2||b(r.lastAt,a)>O?!1:R(t,r.path)?!0:(e.push({fact:`${r.query} \u2192 ${r.path}`,reason:"missing"}),!1)),k=s.hotFiles.filter(r=>r.sessions.length>=3&&b(r.lastAt,a)<=O&&R(t,r.path)),g=Object.entries(s.managerVotes).sort((r,n)=>n[1]-r[1]),y=g.length>0&&g[0][1]>=2&&(g[1]?.[1]??0)*3<=g[0][1]?g[0][0]:void 0,$=s.pitfalls.filter(r=>b(r.lastAt,a)<=O);return{commands:p,...y?{manager:y}:{},locations:h,hotFiles:k,pitfalls:$,stale:e}}d(X,"ks"),f(X,"viewMap");const Z="Project facts DAL verified in earlier sessions (commands that passed, where things live). Use them instead of searching again; if one turns out wrong, check and say so.";function ss(s,t=z){const a=[];s.manager&&a.push({header:"Package manager:",lines:[`- ${s.manager}`]});const e=[...s.commands].sort((o,i)=>V.indexOf(o.kind)-V.indexOf(i.kind)||o.dir.localeCompare(i.dir)||i.successes-o.successes),p=new Set,h=[];for(const o of e){const i=`${o.kind}:${o.dir}`;p.has(i)||(p.add(i),h.push(`- ${o.kind}${o.dir==="."?"":` (in ${o.dir})`}: \`${o.command}\``))}h.length>0&&a.push({header:"Commands that passed:",lines:h});const k=[...s.locations].sort((o,i)=>o.query.localeCompare(i.query)||o.path.localeCompare(i.path)).map(o=>`- "${o.query}" \u2192 ${o.path}`);k.length>0&&a.push({header:"Where things are:",lines:k});const g=[...s.hotFiles].sort((o,i)=>o.path.localeCompare(i.path)).map(o=>`- ${o.path}`);g.length>0&&a.push({header:"Files used most:",lines:g});const y=[...s.pitfalls].sort((o,i)=>o.bad.localeCompare(i.bad)).map(o=>`- \`${o.bad}\` fails${o.reason?` (${o.reason})`:""}; \`${o.good}\` works`);if(y.length>0&&a.push({header:"Pitfalls:",lines:y}),a.length===0)return{tokens:0,facts:0};const $=[Z];let r=P(Z),n=0;for(const o of a){const i=P(o.header)+1,l=[];let c=i;for(const m of o.lines){const A=P(m)+1;if(r+c+A>t)break;l.push(m),c+=A}l.length!==0&&($.push(o.header,...l),r+=c,n+=l.length)}return n===0?{tokens:0,facts:0}:{text:$.join(`
|
|
2
|
+
`),tokens:r,facts:n}}d(ss,"Ms"),f(ss,"renderMapSection");export{z as MAP_TOKEN_BUDGET,w as PRUNE_DAYS,O as STALE_DAYS,T as commandStaleness,K as learnFromRun,j as mapPath,M as parseMap,F as projectRelative,W as readMap,ss as renderMapSection,Q as updateMap,X as viewMap};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`):""}
|
|
3
|
-
`?l():(u==="&"||u==="|")&&e[d+1]===u?(l(),d++):u==="&"?l():u==="|"?r():s+=u}return l(),n}c(J,"W"),a(J,"splitStatements");function $(t){const e=[];let n=!1;for(const o of J(t)){const s=[...o];let i=!1;for(;s.length>1&&yt.test(s.at(-1));)$t.test(s.at(-1))&&(i=!0),s.pop();const r=s.join(" | ").replace(/\s+/g," ");/^cd\s/.test(r)?e.push(r):!wt.test(r)&&v(r)&&(e.push(r),i&&(n=!0))}for(;e.length&&/^cd\s/.test(e.at(-1));)e.pop();return{statements:e,selected:n}}c($,"E"),a($,"checkParts");function w(t){const{statements:e}=$(t);return e.length?e.join(" && "):void 0}c(w,"R"),a(w,"checkCommand");function A(t){return kt.some(e=>e.test(t))}c(A,"X"),a(A,"reportsPass");function K(t){return w(t)??t.replace(/\s+/g," ").trim()}c(K,"Ct"),a(K,"bareCommand");function O(t){return ht.some(e=>e.test(t))}c(O,"Y"),a(O,"reportsFailure");function v(t){for(const[e,n]of G)if(n.test(t))return e}c(v,"x"),a(v,"intentOf");function R(t){const e=w(t)?.split(" && ").filter(n=>!/^cd\s/.test(n))??[];for(const[n,o]of G)if(e.some(s=>o.test(s)))return n}c(R,"Z"),a(R,"commandIntent");function _(t){const e=new Map;for(const o of t)if(o?.role==="toolResult"&&typeof o.toolCallId=="string"){const s=y(o.content);e.set(o.toolCallId,{isError:o.isError===!0,output:s.slice(0,gt),failing:O(s),passing:A(s)})}const n=[];for(const o of t)if(!(o?.role!=="assistant"||!Array.isArray(o.content)))for(const s of o.content){if(s?.type!=="toolCall"||typeof s.name!="string")continue;const i=typeof s.id=="string"?s.id:"",r=s.arguments&&typeof s.arguments=="object"?s.arguments:{},l=e.get(i);if(!l)continue;const d={id:i,name:s.name,args:r,isError:l.isError,output:l.output};if(bt.has(s.name)&&typeof r.command=="string"){const u=T(r.command);d.command=u.command,u.cdDir&&(d.cdDir=u.cdDir);const m=R(u.command);m&&(d.intent=m),m&&it.has(m)&&!d.isError&&l.failing?(d.isError=!0,d.swallowedFailure=!0):m&&!d.isError&&!l.passing&&$(u.command).selected&&(d.unverifiedPass=!0)}n.push(d)}return n}c(_,"J"),a(_,"toolSteps");const X=120,H=/^(?:at\s|\S+\s\(\S+:\d+:\d+\)$|(?:file:\/\/)?\S+\.(?:[cm]?[jt]sx?|py|go|rs|rb|java|kt|php)(?::\d+){1,2}$|.*\bnode:internal\/|Node\.js v\d)/,Y=/^(?:>?\s*\d+\s*\|.*|[\s|]*\^+[\s^~]*|(?:if|else|for|while|switch|const|let|var|return|function|class|import|export|async|await|def|try|catch)\b.*|\}.*)$|\bthrow new\b|=>|[;{]$/,Q=/^(?:(?:duration_ms|type|location|failureType|code|stack|operator|expected|actual|generatedMessage|name):|\.{3}$|-{3}$|TAP version|Subtest:|1\.\.\d+$|(?:tests|suites|pass|fail|cancelled|skipped|todo|duration_ms)\s+\d|Command exited with code)/,vt=/^(?:E\s+)?(?:Uncaught\s+)?(?:[A-Z][\w.]*(?:Error|Exception)|Error|error(?: TS\d+|\[E\d+\])?)(?:\s*\[[\w-]+\])?:\s*\S|\berror TS\d+:\s*\S/,Et=/^(?:expected\b.*\b(?:received|to (?:be|equal)|but got)\b|(?:Expected|Received)(?: value)?:\s*\S|.+\s!==?\s.+)/i,St=/^(?:FAIL(?:ED)?\b|not ok \d+|[✖×✗]\s|--- FAIL:?)/,xt=/not found|no such|cannot|can't|unable|error|fail|missing|denied|unknown|invalid|找不到|不存在|失败|错误/i;function V(t){const e=t.trim().replace(/^#\s?/,"").trim();return e!==""&&(H.test(e)||Y.test(e)||Q.test(e))}c(V,"vt"),a(V,"isUntellingReason");function tt(t){const e=t.findIndex(s=>Et.test(s));if(e<0)return;const n=t[e],o=/^Expected(?: value)?:/i.test(n)?t.slice(e+1,e+4).find(s=>/^Received(?: value)?:/i.test(s)):void 0;return o?`${n}, ${o}`:n}c(tt,"nt"),a(tt,"comparison");function et(t){const e=b(t).replace(/\s+/g," ").trim();return e.length>X?`${e.slice(0,X-1)}\u2026`:e}c(et,"st"),a(et,"clipReason");function st(t){const e=[];for(let n=0;n<t.length;n++){const o=/^error:\s*(.*)$/.exec(t[n]);if(!o)continue;let s=o[1].replace(/^'(.*)'$/,"$1").replace(/^"(.*)"$/,"$1");if(/^\|-?$/.test(s)){const r=[];for(let l=n+1;l<t.length&&r.length<2&&!/^[a-z_]+:\s/i.test(t[l]);l++)r.push(t[l]);s=r.join(" ")}if(!s||s==="test failed")continue;let i="";for(let r=n+1;r<Math.min(t.length,n+12)&&!/^(?:\.{3}|not ok|ok)\b/.test(t[r]);r++){const l=/^name:\s*'?([\w.]+)'?$/.exec(t[r]);if(l){i=l[1];break}}e.push(i&&!s.startsWith(i)?`${i}: ${s}`:s)}return e}c(st,"ot"),a(st,"tapErrors");function L(t){const e=t.split(/\r?\n/).map(s=>s.trim().replace(/^#\s?/,"").trim()).filter(Boolean),n=e.filter(s=>!H.test(s)&&!Y.test(s)&&!Q.test(s)),o=st(e)[0]??n.find(s=>vt.test(s))??tt(n)??n.find(s=>St.test(s))??n.find(s=>xt.test(s))??"";return et(o)}c(L,"rt"),a(L,"failureReason");function h(t){let e="";const n=[];for(const o of $(t).statements){const s=/^cd\s+("[^"]+"|'[^']+'|\S+)$/.exec(o);if(s){const r=s[1].replace(/^["']|["']$/g,"");e=e&&!r.startsWith("/")?`${e}/${r}`:r;continue}const i=o.replace(/\s+/g," ").trim();n.some(r=>r.dir===e&&r.check===i)||n.push({dir:e,check:i,...v(i)?{intent:v(i)}:{}})}return n}c(h,"h"),a(h,"segmentsOf");function nt(t,e){return t===e||` ${t} `.includes(` ${e} `)||` ${e} `.includes(` ${t} `)}c(nt,"it"),a(nt,"overlaps");function F(t,e){const n=h(t),o=h(e),s=a((p,f)=>p.dir===f.dir&&p.check===f.check,"same"),i=n.filter(p=>!o.some(f=>s(p,f)));if(i.length===0)return;const r=new Set(i.map(p=>p.intent)),l=o.filter(p=>!n.some(f=>s(p,f))||r.has(p.intent)),d=i.filter(p=>l.some(f=>f.intent===p.intent));if(d.length===0||l.length===0||[...d,...l].some(p=>/^(?:\/|~|\$)/.test(p.dir))||d.some(p=>l.some(f=>f.dir===p.dir&&nt(p.check,f.check))))return;const u=a(p=>{const f=p[0].dir;if(p.some(j=>j.dir!==f))return;const Z=p.map(j=>j.check).join(" && ");return f?`cd ${f} && ${Z}`:Z},"joined"),m=u(d),C=u(l);if(!(!m||!C||m===C))return{bad:m,good:C}}c(F,"at"),a(F,"fixCommands");function E(t,e,n=!1){const o=h(t),s=h(e);if(s.length===0)return!1;const i=a((r,l)=>r.some(d=>d.dir===l.dir&&d.check===l.check),"has");return s.every(r=>i(o,r))&&(!n||o.every(r=>i(s,r)))}c(E,"_"),a(E,"runsChecks");function S(t){return t.cdDir?`cd ${t.cdDir} && ${t.command??""}`:t.command??""}c(S,"w"),a(S,"located");const Ct=/\|\||;|\n/;function ot(t,e){let n=!1;for(const o of t){if(!o.command)continue;const s=b(S(o));o.isError?E(s,e,!0)&&(n=!1):!o.unverifiedPass&&!Ct.test(o.command)&&E(s,e)&&(n=!0)}return n}c(ot,"At"),a(ot,"passedLast");const jt=/command not found|: not found|is not (?:set|defined)|Missing script|Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|ENOENT|No such file|unknown (?:option|command|script|flag)|not recognized as|No test files|No tests found|permission denied|EACCES|找不到|未设置|不存在|未找到/i,Tt=/AssertionError|^\s*(?:Expected|Received)(?: value)?:|\bexpected\b.*\b(?:received|to (?:be|equal)|but got)\b|\s!==?\s|^not ok \d+|^#\s*fail\s+[1-9]|^\s*\d+ (?:failing|failed)\b|Tests?:\s+\d+ failed|\berror TS\d+:|\d+ problems? \(\d+ errors?/im;function P(t){return Tt.test(t)&&!jt.test(t)}c(P,"ut"),a(P,"codeFailed");function D(t){const e=[],n=new Set;for(let o=0;o<t.length;o++){const s=t[o];if(!(!s.isError||!s.intent||!s.command||n.has(s.id))&&!P(s.output))for(let i=o+1;i<t.length;i++){const r=t[i];if(r.intent!==s.intent||!r.command||r.isError||r.unverifiedPass)continue;const l=F(S(s),S(r));if(!l)break;n.add(s.id),e.push({intent:s.intent,failed:s,fixed:r,...l,reason:L(s.output),proven:r.intent!=="install"});break}}return e}c(D,"ft"),a(D,"fixPairs");const At=/(?:^|[\s,.!?,。!?])(?:不对|不是这样|错了|搞错|弄错|别这样|不要这样|我说的是|我的意思是|应该是|你又|还是不行|还是错|并不是|别用|不要用|改用)|\b(?:that'?s (?:not|wrong)|not what I (?:asked|meant|said)|you (?:broke|missed|forgot)|wrong (?:file|approach|command)|I said|still (?:broken|failing|wrong)|don'?t use|use \S+ instead|try again)\b/iu;function I(t){return At.test(t)}c(I,"mt"),a(I,"isCorrection");const Ot=/dal-guard|safety.?net|blocked by|was blocked|refused by|not allowed by|用户已拒绝|已拦截|拦截了|需要交互式审批|已被拦下|保护拒绝/i;function N(t){return t.isError&&Ot.test(t.output)}c(N,"bt"),a(N,"isDenial");const Rt=new Set(["grep","find","ls","glob"]);function M(t){return Rt.has(t.name)?!0:!!t.command&&/^(?:rg|grep|ag|find|fd|ls|git\s+grep)\b/.test(t.command)}c(M,"yt"),a(M,"isSearch");function U(t){return`${t.name}:${JSON.stringify(t.args)}`}c(U,"O"),a(U,"callKey");function q(t){const e=new Map;for(const o of t)e.set(U(o),(e.get(U(o))??0)+1);if([...e.values()].some(o=>o>=3)||t.filter(o=>o.isError).length>=3)return!0;let n=0;for(const o of t)if(n=M(o)?n+1:0,n>=6)return!0;return!1}c(q,"St"),a(q,"isDetour");function rt(t,e){const n=t,o=y(n.find(r=>r?.role==="user")?.content),s=n.filter(r=>r?.role==="assistant").map(r=>y(r.content)).filter(Boolean).join(`
|
|
4
|
-
`),
|
|
5
|
-
`);for(;o.length>
|
|
6
|
-
`);return o.slice(0,
|
|
1
|
+
var At=Object.defineProperty;var l=(t,e)=>At(t,"name",{value:e,configurable:!0});var Ft=Object.defineProperty,i=l((t,e)=>Ft(t,"name",{value:e,configurable:!0}),"a");import{isSensitivePath as _t,redact as b}from"./safety.js";const Pt=new Set(["bash","powershell","shell"]),It=4e3;function E(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e=="object"&&e.type==="text").map(e=>e.text).join(`
|
|
2
|
+
`):""}l(E,"$"),i(E,"textOf");function F(t){let e=t.trim(),n;for(;;){const o=/^cd\s+("[^"]+"|'[^']+'|[^\s;&|]+)\s*(?:&&|;)\s*/.exec(e);if(o){const r=o[1].replace(/^["']|["']$/g,"");n=n&&!r.startsWith("/")?`${n}/${r}`:r,e=e.slice(o[0].length);continue}const s=/^(?:[A-Z_][A-Z0-9_]*=(?:"[^"]*"|'[^']*'|\S*)\s+)+/.exec(e);if(s){e=e.slice(s[0].length);continue}break}return{command:e,...n?{cdDir:n}:{}}}l(F,"V"),i(F,"splitCommand");function y(t){const e=String.raw`(?:\s+(?:-{1,2}[\w-]+(?:=\S+|\s+[^\s-]\S*)?|workspace\s+\S+|workspaces(?:\s+foreach)?))*`;return[String.raw`\b(?:npm|pnpm|yarn|bun)${e}\s+(?:run\s+)?(?:${t})\b`,String.raw`\bturbo\s+(?:run\s+)?(?:[^\s-]\S*\s+)*?(?:${t})(?![\w-])`,String.raw`\bnx\s+(?:run\s+\S+:|(?:run-many|affected)\b.*?(?:-t|--targets?)(?:=|\s+)(?:\S*,)?)?(?:${t})(?![\w-])`].join("|")}l(y,"w"),i(y,"scriptPattern");const Q=[["typecheck",new RegExp(String.raw`\btsc\b(?!.*--build)|\bmypy\b|\bpyright\b|${y("typecheck|type-check|check-types")}`)],["test",new RegExp(String.raw`\b(?:vitest|jest|mocha|ava|pytest|tox|rspec|phpunit)\b|${y("test")}|\bnode\s+--test\b|\b(?:go|cargo|dotnet|mix|deno)\s+test\b|\bmake\s+test\b|\bgradlew?\s+test\b|\bmvn\s+test\b`)],["lint",new RegExp(String.raw`\b(?:eslint|biome|ruff|flake8|pylint|golangci-lint|clippy|prettier\s+--check)\b|${y("lint|check")}`)],["build",new RegExp(String.raw`${y("build")}|\b(?:cargo|go|dotnet|swift)\s+build\b|\bmake\b(?!\s+test)|\bgradlew?\s+(?:build|assemble)\b|\bmvn\s+(?:package|install)\b|\btsc\s+--build\b|\bvite\s+build\b|\bwebpack\b`)],["install",/^(?:npm\s+(?:ci|install|i)|pnpm\s+(?:install|i)|yarn(?:\s+install)?|bun\s+install|pip3?\s+install\s+(?:-r|-e|\.)|poetry\s+install|uv\s+sync|bundle\s+install|composer\s+install|go\s+mod\s+download)(?:\s|$)/]],Lt=[/^# fail [1-9]/m,/^npm (?:ERR!|error) (?:code ELIFECYCLE|Lifecycle script|Test failed)/m,/^\s*Tests:\s+\d+ failed/m,/^\s*Test Files\s+\d+ failed/m,/^=+ .*\b\d+ (?:failed|errors?)\b.* =+$/m,/^\s+\d+ failing$/m,/^(?:FAIL|--- FAIL:?)\s/m,/test result: FAILED/,/^make(?:\[\d+\])?: \*\*\* .*Error \d+/m,/\berror TS\d+:/,/^Found \d+ errors? in \d+ files?/m,/^not ok \d+\b(?![^\n]*#\s*(?:TODO|SKIP)\b)/m],Dt=[/^# fail 0\b/m,/^\s*Tests:\s+(?:\d+ (?:skipped|todo), )*\d+ passed/m,/^\s*Test Files\s+\d+ passed/m,/^=+ .*\b\d+ passed\b.* =+$/m,/^\s+\d+ passing\b/m,/^ok\s+\S+\s+[\d.]+s$/m,/test result: ok\b/,/^Found 0 errors\b/m],Nt=/^(?:tail|head|grep|egrep|fgrep|cat|less|more|tee|wc|sort|uniq|cut|column|sed|awk|nl)\b/,Wt=/^(?:head|grep|egrep|fgrep|cut|sed|awk)\b/,Mt=/^(?:echo|printf|cat|ls|pwd|true|false|:|#|sed|awk|grep|rg|head|tail|wc|find|git\s+(?:diff|status|log|show|stash|add)|set|export|printenv|which|whereis|type|command\s+-v|test\s|\[|stat|file|(?:node|npm|pnpm|yarn|bun|npx)\s+(?:-v|--version)|(?:npm|pnpm|yarn)\s+(?:ls|list|view|info|bin|root|config|why))(?:\b|(?=\s|$))/;function V(t){const e=t.replace(/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n[ \t]*\2[ \t]*(?=\n|$)/g,"<<$2$3").replace(/\s*\d*>&\d+/g,""),n=[];let o=[],s="",r;const a=i(()=>{o.push(s.trim()),s=""},"endStage"),c=i(()=>{a();const u=o.filter(Boolean);u.length&&n.push(u),o=[]},"endStatement");for(let u=0;u<e.length;u++){const d=e[u];if(r){if(d==="\\"&&r==='"'){s+=d+(e[u+1]??""),u++;continue}d===r&&(r=void 0),s+=d;continue}d==="'"||d==='"'?(r=d,s+=d):d==="\\"?(s+=d+(e[u+1]??""),u++):d===";"||d===`
|
|
3
|
+
`?c():(d==="&"||d==="|")&&e[u+1]===d?(c(),u++):d==="&"?c():d==="|"?a():s+=d}return c(),n}l(V,"nt"),i(V,"splitStatements");function j(t){const e=[];let n=!1;for(const o of V(t)){const s=[...o];let r=!1;for(;s.length>1&&Nt.test(s.at(-1));)Wt.test(s.at(-1))&&(r=!0),s.pop();const a=s.join(" | ").replace(/\s+/g," ");/^cd\s/.test(a)?e.push(a):!Mt.test(a)&&I(a)&&(e.push(a),r&&(n=!0))}for(;e.length&&/^cd\s/.test(e.at(-1));)e.pop();return{statements:e,selected:n}}l(j,"T"),i(j,"checkParts");function C(t){const{statements:e}=j(t);return e.length?e.join(" && "):void 0}l(C,"I"),i(C,"checkCommand");function _(t){return Dt.some(e=>e.test(t))}l(_,"st"),i(_,"reportsPass");function Y(t){return C(t)??t.replace(/\s+/g," ").trim()}l(Y,"zt"),i(Y,"bareCommand");function P(t){return Lt.some(e=>e.test(t))}l(P,"rt"),i(P,"reportsFailure");function I(t){for(const[e,n]of Q)if(n.test(t))return e}l(I,"_"),i(I,"intentOf");function L(t){const e=C(t)?.split(" && ").filter(n=>!/^cd\s/.test(n))??[];for(const[n,o]of Q)if(e.some(s=>o.test(s)))return n}l(L,"ot"),i(L,"commandIntent");function D(t){const e=new Map;for(const o of t)if(o?.role==="toolResult"&&typeof o.toolCallId=="string"){const s=E(o.content);e.set(o.toolCallId,{isError:o.isError===!0,output:s.slice(0,It),failing:P(s),passing:_(s)})}const n=[];for(const o of t)if(!(o?.role!=="assistant"||!Array.isArray(o.content)))for(const s of o.content){if(s?.type!=="toolCall"||typeof s.name!="string")continue;const r=typeof s.id=="string"?s.id:"",a=s.arguments&&typeof s.arguments=="object"?s.arguments:{},c=e.get(r);if(!c)continue;const u={id:r,name:s.name,args:a,isError:c.isError,output:c.output};if(Pt.has(s.name)&&typeof a.command=="string"){const d=F(a.command);u.command=d.command,d.cdDir&&(u.cdDir=d.cdDir);const p=L(d.command);p&&(u.intent=p),p&&St.has(p)&&!u.isError&&c.failing?(u.isError=!0,u.swallowedFailure=!0):p&&!u.isError&&!c.passing&&j(d.command).selected&&(u.unverifiedPass=!0)}n.push(u)}return n}l(D,"it"),i(D,"toolSteps");const tt=120,et=/^(?:at\s|\S+\s\(\S+:\d+:\d+\)$|(?:file:\/\/)?\S+\.(?:[cm]?[jt]sx?|py|go|rs|rb|java|kt|php)(?::\d+){1,2}$|.*\bnode:internal\/|Node\.js v\d)/,st=/^(?:>?\s*\d+\s*\|.*|[\s|]*\^+[\s^~]*|(?:if|else|for|while|switch|const|let|var|return|function|class|import|export|async|await|def|try|catch)\b.*|\}.*)$|\bthrow new\b|=>|[;{]$/,nt=/^(?:(?:duration_ms|type|location|failureType|code|stack|operator|expected|actual|generatedMessage|name):|\.{3}$|-{3}$|TAP version|Subtest:|1\.\.\d+$|(?:tests|suites|pass|fail|cancelled|skipped|todo|duration_ms)\s+\d|Command exited with code)/,Ut=/^(?:E\s+)?(?:Uncaught\s+)?(?:[A-Z][\w.]*(?:Error|Exception)|Error|error(?: TS\d+|\[E\d+\])?)(?:\s*\[[\w-]+\])?:\s*\S|\berror TS\d+:\s*\S/,qt=/^(?:expected\b.*\b(?:received|to (?:be|equal)|but got)\b|(?:Expected|Received)(?: value)?:\s*\S|.+\s!==?\s.+)/i,zt=/^(?:FAIL(?:ED)?\b|not ok \d+|[✖×✗]\s|--- FAIL:?)/,Bt=/not found|no such|cannot|can't|unable|error|fail|missing|denied|unknown|invalid|找不到|不存在|失败|错误/i;function rt(t){const e=t.trim().replace(/^#\s?/,"").trim();return e!==""&&(et.test(e)||st.test(e)||nt.test(e))}l(rt,"Vt"),i(rt,"isUntellingReason");function ot(t){const e=t.findIndex(s=>qt.test(s));if(e<0)return;const n=t[e],o=/^Expected(?: value)?:/i.test(n)?t.slice(e+1,e+4).find(s=>/^Received(?: value)?:/i.test(s)):void 0;return o?`${n}, ${o}`:n}l(ot,"ut"),i(ot,"comparison");function at(t){const e=b(t).replace(/\s+/g," ").trim();return e.length>tt?`${e.slice(0,tt-1)}\u2026`:e}l(at,"ft"),i(at,"clipReason");function it(t){const e=[];for(let n=0;n<t.length;n++){const o=/^error:\s*(.*)$/.exec(t[n]);if(!o)continue;let s=o[1].replace(/^'(.*)'$/,"$1").replace(/^"(.*)"$/,"$1");if(/^\|-?$/.test(s)){const a=[];for(let c=n+1;c<t.length&&a.length<2&&!/^[a-z_]+:\s/i.test(t[c]);c++)a.push(t[c]);s=a.join(" ")}if(!s||s==="test failed")continue;let r="";for(let a=n+1;a<Math.min(t.length,n+12)&&!/^(?:\.{3}|not ok|ok)\b/.test(t[a]);a++){const c=/^name:\s*'?([\w.]+)'?$/.exec(t[a]);if(c){r=c[1];break}}e.push(r&&!s.startsWith(r)?`${r}: ${s}`:s)}return e}l(it,"pt"),i(it,"tapErrors");function N(t){const e=t.split(/\r?\n/).map(s=>s.trim().replace(/^#\s?/,"").trim()).filter(Boolean),n=e.filter(s=>!et.test(s)&&!st.test(s)&&!nt.test(s)),o=it(e)[0]??n.find(s=>Ut.test(s))??ot(n)??n.find(s=>zt.test(s))??n.find(s=>Bt.test(s))??"";return at(o)}l(N,"gt"),i(N,"failureReason");const k=i(t=>t,"asIs"),R=i(t=>`dir:${t.replace(/^\.\//,"").replace(/\/+$/,"")||"."}`,"dirTarget"),ct={pnpm:[{names:["-F","--filter","--filter-prod"],value:!0,target:k},{names:["-r","--recursive"],value:!1,target:i(()=>"*","target")},{names:["-C","--dir"],value:!0,target:R},{names:["-w","--workspace-root"],value:!1,target:i(()=>"root","target")}],npm:[{names:["-w","--workspace"],value:!0,target:k},{names:["-ws","--workspaces"],value:!1,target:i(()=>"*","target")},{names:["--prefix"],value:!0,target:R}],yarn:[{names:["--cwd"],value:!0,target:R}],bun:[{names:["-F","--filter"],value:!0,target:k},{names:["--cwd"],value:!0,target:R}]};function h(t,e,n){const o=t[e];for(const s of n)for(const r of s.names){if(s.value&&o.startsWith(`${r}=`))return{target:s.target(o.slice(r.length+1)),next:e+1};if(o!==r)continue;if(!s.value)return{target:s.target(""),next:e+1};const a=t[e+1];return a===void 0?void 0:{target:s.target(a),next:e+2}}}l(h,"b"),i(h,"targetOption");const Zt=/^(?:add|audit|bin|cache|ci|config|create|dedupe|deploy|dlx|env|exec|fetch|help|i|import|info|init|install|link|list|ls|login|logout|outdated|pack|patch|prune|publish|rebuild|remove|rm|root|set|setup|store|unlink|up|update|upgrade|version|view|why|x)$/;function lt(t,e){if(t==="npm")return/^(?:test|t|tst)$/.test(e)?"test":void 0;if(t!=="bun")return Zt.test(e)?void 0:e}l(lt,"ht"),i(lt,"scriptOf");function ut(t){const e=t[0],n=ct[e],o=[],s=[];let r=1;for(;r<t.length;){const p=t[r],g=h(t,r,n);if(g)o.push(g.target),r=g.next;else if(e==="yarn"&&p==="workspace"&&t[r+1])o.push(t[r+1]),r+=2;else if(e==="yarn"&&p==="workspaces")for(o.push("*"),r+=t[r+1]==="foreach"?2:1;t[r]?.startsWith("-");)s.push(t[r++]);else if(p.startsWith("-"))s.push(p),r++;else break}const a=t[r];if(!a)return;const c=a==="run"||a==="run-script",u=c?t[r+1]:lt(e,a);if(c&&!u)return;r+=c?2:1;const d=[];for(;r<t.length;){const p=e==="npm"&&t[r]!=="--"?h(t,r,n):void 0;if(t[r]==="--"){d.push(...t.slice(r));break}p?(o.push(p.target),r=p.next):d.push(t[r++])}return{base:[...u?[e,...s,"run",u]:[e,...s,a],...d].join(" "),targets:o}}l(ut,"bt"),i(ut,"packageShape");function dt(t,e){const n=[{names:["-F","--filter"],value:!0,target:k}],o=[],s=[],r=[];for(let a=e[0]==="run"?1:0;a<e.length;){const c=h(e,a,n);c?(o.push(c.target),a=c.next):e[a].startsWith("-")||r.length>0?r.push(e[a++]):s.push(e[a++])}return{base:[...t,"turbo","run",...s.sort(),...r].join(" "),targets:o}}l(dt,"St"),i(dt,"turboShape");const Gt=/^(?:add|connect|daemon|exec|format(?::\w+)?|g|generate|graph|init|list|migrate|release|repair|report|reset|show|sync|view-logs|watch)$/;function pt(t,e){const[n,o]=e;if(!n||Gt.test(n))return;const s=[...t,"nx"];if(n==="run-many"||n==="affected"){const a=[],c=[],u=[],d=[{names:["-p","--projects"],value:!0,target:k},{names:["-t","--target","--targets"],value:!0,target:i(p=>`task:${p}`,"target")}];for(let p=1;p<e.length;){const g=h(e,p,d);if(!g){u.push(e[p++]);continue}const v=g.target.replace(/^task:/,"").split(",").filter(Boolean);(g.target.startsWith("task:")?c:a).push(...v),p=g.next}return{base:[...s,n,...c.sort(),...u].join(" "),targets:a}}if(n==="run"){const a=o?.indexOf(":")??-1;return!o||a<0?void 0:{base:[...s,"run",o.slice(a),...e.slice(2)].join(" "),targets:a>0?[o.slice(0,a)]:[]}}const r=o&&!o.startsWith("-")?o:void 0;return{base:[...s,"run",`:${n}`,...e.slice(r?2:1)].join(" "),targets:r?[r]:[]}}l(pt,"xt"),i(pt,"nxShape");function ft(t){const e=[{names:["-p","--package"],value:!0,target:k}],n=[],o=[];for(let s=0;s<t.length;){const r=h(t,s,e);r?(n.push(r.target),s=r.next):o.push(t[s++])}return{base:o.join(" "),targets:n}}l(ft,"wt"),i(ft,"cargoShape");const mt=new Set(["-bench","-benchtime","-count","-coverpkg","-coverprofile","-covermode","-cpu","-exec","-o","-p","-parallel","-shuffle","-tags","-timeout","-vet"]);function gt(t){const e=[{names:["-run","--run"],value:!0,target:i(s=>`run:${s}`,"target")},{names:["-skip","--skip"],value:!0,target:i(s=>`skip:${s}`,"target")}],n=[],o=[];for(let s=2;s<t.length;){const r=t[s],a=h(t,s,e);a?(n.push(a.target),s=a.next):r.startsWith("-")?(o.push(mt.has(r)&&t[s+1]?`${r}=${t[s+1]}`:r),s+=mt.has(r)&&t[s+1]?2:1):(n.push(r),s++)}return{base:[...t.slice(0,2),...o].join(" "),targets:n}}l(gt,"kt"),i(gt,"goShape");const Jt=new Set(["-c","-n","-o","-p","-W","--basetemp","--cov","--cov-report","--deselect","--durations","--ignore","--junitxml","--log-level","--maxfail","--rootdir","--tb"]);function ht(t,e){const n=[{names:["-k"],value:!0,target:i(r=>`k:${r}`,"target")},{names:["-m"],value:!0,target:i(r=>`m:${r}`,"target")}],o=[],s=[];for(let r=0;r<e.length;){const a=e[r],c=h(e,r,n);c?(o.push(c.target),r=c.next):Jt.has(a)&&e[r+1]?(s.push(`${a}=${e[r+1]}`),r+=2):a.startsWith("-")?(s.push(a),r++):(o.push(a.replace(/^\.\//,"")),r++)}return{base:[...t,...s.sort()].join(" "),targets:o}}l(ht,"vt"),i(ht,"pytestShape");function bt(t){const e=[];let n="",o,s=!1;for(const r of t)if(o)r===o?o=void 0:n+=r;else if(r==="'"||r==='"')o=r,s=!0;else if(/\s/.test(r))s&&e.push(n),n="",s=!1;else{if(/[|<>`$()]/.test(r))return;n+=r,s=!0}if(!o)return s&&e.push(n),e}l(bt,"$t"),i(bt,"words");function kt(t){const e=bt(t),n={base:t,targets:[]};if(!e?.length)return n;const o=e.findIndex(s=>/^(?:turbo|nx|pytest|py\.test)$/.test(s));if(o>=0&&o<=3){const s=e.slice(0,o),r=e.slice(o+1);return e[o]==="turbo"?dt(s,r):e[o]==="nx"?pt(s,r)??n:ht([...s,"pytest"],r)}return ct[e[0]]?ut(e)??n:e[0]==="cargo"?ft(e):e[0]==="go"&&/^(?:test|build|vet)$/.test(e[1]??"")?gt(e):n}l(kt,"Tt"),i(kt,"shapeOf");function $(t){let e="";const n=[];for(const o of j(t).statements){const s=/^cd\s+("[^"]+"|'[^']+'|\S+)$/.exec(o);if(s){const p=s[1].replace(/^["']|["']$/g,"");e=e&&!p.startsWith("/")?`${e}/${p}`:p;continue}const r=o.replace(/\s+/g," ").trim(),a=kt(r),c=[...new Set(a.targets)].sort(),u=c.length?`${a.base} \u27E8${c.join(" ")}\u27E9`:a.base;if(n.some(p=>p.dir===e&&p.key===u))continue;const d=I(r);n.push({dir:e,check:r,base:a.base,targets:c,key:u,...d?{intent:d}:{}})}return n}l($,"E"),i($,"segmentsOf");function wt(t,e){const n=i((o,s)=>o.every(r=>s.includes(r)),"nested");return t.base===e.base&&(n(t.targets,e.targets)||n(e.targets,t.targets))?!0:t.check===e.check||` ${t.check} `.includes(` ${e.check} `)||` ${e.check} `.includes(` ${t.check} `)}l(wt,"Ct"),i(wt,"overlaps");const vt=/^(?:\/|~|\$)/;function W(t,e){const n=$(t),o=$(e),s=i((f,m)=>f.dir===m.dir&&f.key===m.key,"same"),r=n.filter(f=>!o.some(m=>s(f,m)));if(r.length===0)return;const a=new Set(r.map(f=>f.intent)),c=o.filter(f=>!n.some(m=>s(f,m))||a.has(f.intent)),u=r.filter(f=>c.some(m=>m.intent===f.intent));if(u.length===0||c.length===0)return;const d=i(f=>vt.test(f.dir)||f.targets.some(m=>m.startsWith("dir:")&&vt.test(m.slice(4))),"elsewhere");if([...u,...c].some(d)||u.some(f=>c.some(m=>m.dir===f.dir&&wt(f,m))))return;const p=i(f=>{const m=f[0].dir;if(f.some(A=>A.dir!==m))return;const X=f.map(A=>A.check).join(" && ");return m?`cd ${m} && ${X}`:X},"joined"),g=p(u),v=p(c);if(!g||!v||g===v)return;const Tt=c.every(f=>u.some(m=>m.dir===f.dir&&m.base===f.base));return{bad:g,good:v,...Tt?{retargeted:!0}:{}}}l(W,"Rt"),i(W,"fixCommands");function x(t,e,n=!1){const o=$(t),s=$(e);if(s.length===0)return!1;const r=i((a,c)=>a.some(u=>u.dir===c.dir&&u.key===c.key),"has");return s.every(a=>r(o,a))&&(!n||o.every(a=>r(s,a)))}l(x,"C"),i(x,"runsChecks");function yt(t,e){return t===e||x(t,e,!0)}l(yt,"Zt"),i(yt,"sameChecks");function O(t){return t.cdDir?`cd ${t.cdDir} && ${t.command??""}`:t.command??""}l(O,"R"),i(O,"located");const Kt=/\|\||;|\n/;function $t(t,e){let n=!1;for(const o of t){if(!o.command)continue;const s=b(O(o));o.isError?x(s,e,!0)&&(n=!1):!o.unverifiedPass&&!Kt.test(o.command)&&x(s,e)&&(n=!0)}return n}l($t,"Jt"),i($t,"passedLast");const Ht=/command not found|: not found|is not (?:set|defined)|Missing script|Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|ENOENT|No such file|unknown (?:option|command|script|flag)|not recognized as|No test files|No tests found|permission denied|EACCES|找不到|未设置|不存在|未找到/i,Xt=/AssertionError|^\s*(?:Expected|Received)(?: value)?:|\bexpected\b.*\b(?:received|to (?:be|equal)|but got)\b|\s!==?\s|^not ok \d+|^#\s*fail\s+[1-9]|^\s*\d+ (?:failing|failed)\b|Tests?:\s+\d+ failed|\berror TS\d+:|\d+ problems? \(\d+ errors?/im;function M(t){return Xt.test(t)&&!Ht.test(t)}l(M,"_t"),i(M,"codeFailed");const Qt=/No projects matched the filters|No (?:workspaces|packages?|projects?) (?:found|matched)|Unknown workspace|Couldn't find (?:a )?(?:workspace|package)|did not match any packages|package\(s\) .*not found|not found in (?:the )?workspace|matched no packages|no packages to test|cannot find package|file or directory not found|no tests ran|Cannot find (?:a )?project|Could not find project|No package found with name/i;function U(t){const e=[],n=new Set;for(let o=0;o<t.length;o++){const s=t[o];if(!(!s.isError||!s.intent||!s.command||n.has(s.id))&&!M(s.output))for(let r=o+1;r<t.length;r++){const a=t[r];if(a.intent!==s.intent||!a.command||a.isError||a.unverifiedPass)continue;const c=W(O(s),O(a));if(!c)break;if(!(c.retargeted&&!Qt.test(s.output))){n.add(s.id),e.push({intent:s.intent,failed:s,fixed:a,bad:c.bad,good:c.good,reason:N(s.output),proven:a.intent!=="install"});break}}}return e}l(U,"Nt"),i(U,"fixPairs");const Vt=/(?:^|[\s,.!?,。!?])(?:不对|不是这样|错了|搞错|弄错|别这样|不要这样|我说的是|我的意思是|应该是|你又|还是不行|还是错|并不是|别用|不要用|改用)|\b(?:that'?s (?:not|wrong)|not what I (?:asked|meant|said)|you (?:broke|missed|forgot)|wrong (?:file|approach|command)|I said|still (?:broken|failing|wrong)|don'?t use|use \S+ instead|try again)\b/iu;function q(t){return Vt.test(t)}l(q,"Ft"),i(q,"isCorrection");const Yt=/dal-guard|safety.?net|blocked by|was blocked|refused by|not allowed by|用户已拒绝|已拦截|拦截了|需要交互式审批|已被拦下|保护拒绝/i;function z(t){return t.isError&&Yt.test(t.output)}l(z,"Mt"),i(z,"isDenial");const te=new Set(["grep","find","ls","glob"]);function B(t){return te.has(t.name)?!0:!!t.command&&/^(?:rg|grep|ag|find|fd|ls|git\s+grep)\b/.test(t.command)}l(B,"Ut"),i(B,"isSearch");function Z(t){return`${t.name}:${JSON.stringify(t.args)}`}l(Z,"U"),i(Z,"callKey");function G(t){const e=new Map;for(const o of t)e.set(Z(o),(e.get(Z(o))??0)+1);if([...e.values()].some(o=>o>=3)||t.filter(o=>o.isError).length>=3)return!0;let n=0;for(const o of t)if(n=B(o)?n+1:0,n>=6)return!0;return!1}l(G,"Wt"),i(G,"isDetour");function xt(t,e){const n=t,o=E(n.find(a=>a?.role==="user")?.content),s=n.filter(a=>a?.role==="assistant").map(a=>E(a.content)).filter(Boolean).join(`
|
|
4
|
+
`),r=D(t);return{userPrompt:o,assistantText:s,steps:r,fixes:U(r),corrected:!!e?.trim()&&q(o),detour:G(r),denials:r.filter(z)}}l(xt,"Qt"),i(xt,"analyzeRun");function J(t){return t.corrected||t.detour||t.denials.length>0}l(J,"Gt"),i(J,"needsModel");const St=new Set(["test","build","lint","typecheck"]);function T(t){const e=t.findLast(n=>n.intent!==void 0&&St.has(n.intent));if(e)return e.isError?"failed":"passed"}l(T,"G"),i(T,"verifiedOutcome");function Et(t,e){return e.length>0&&T(t.steps)!==void 0}l(Et,"te"),i(Et,"needsReflection");const jt=25;function Ct(t){return t.steps.length>=jt&&T(t.steps)==="passed"&&!J(t)}l(Ct,"ee"),i(Ct,"longSuccess");const S={user:800,assistant:600,toolCall:300,toolOutput:400},K=12e3;function w(t,e){const n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e)}\u2026`:n}l(w,"x"),i(w,"clip");const ee=/(?:^|\/)(?:package\.json|package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|requirements[^/]*\.txt|pyproject\.toml|poetry\.lock|Pipfile(?:\.lock)?|Cargo\.(?:toml|lock)|go\.(?:mod|sum)|Gemfile(?:\.lock)?|composer\.(?:json|lock)|\.gitlab-ci\.yml|\.github\/workflows\/[^/]+)$/,se=/(?:^|[;&|]\s*)(?:npm\s+(?:i|install|add|uninstall|rm)\b(?=[^;&|]*\s[@a-z])|pnpm\s+(?:add|remove|i\s+\S|install\s+\S)|yarn\s+(?:add|remove)\b|bun\s+(?:add|remove)\b|pip3?\s+install\s+(?!-r\b|-e\b|\.)\S|poetry\s+add\b|cargo\s+add\b|go\s+get\b)/,ne=/(?:>>?|\btee\b|\bsed\s+-i\b|\bnpm\s+pkg\s+set\b)[^;&|]*(?:package\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|requirements[^/\s]*\.txt|pyproject\.toml|Cargo\.toml|go\.mod)/;function Rt(t){const e=new Set;for(const n of t){if(n.isError)continue;const o=H(n);o&&/^(?:edit|write|multiedit|apply_patch|str_replace)/i.test(n.name)&&ee.test(o.replace(/\\/g,"/"))&&e.add(o.split(/[\\/]/).at(-1));const s=n.command??(typeof n.args.command=="string"?n.args.command:"");if(!s)continue;se.test(s)&&e.add("dependencies");const r=ne.exec(s);r&&e.add(r[0].match(/[\w.-]+$/)?.[0]??"package.json")}return[...e]}l(Rt,"ne"),i(Rt,"protectedChanges");function H(t){const e=t.args.path??t.args.file_path??t.args.file;return typeof e=="string"?e:""}l(H,"K"),i(H,"pathArg");function Ot(t,e){const n=[];e&&n.push(`[previous answer] ${w(b(e),S.assistant)}`),n.push(`[user] ${w(b(t.userPrompt),S.user)}`);for(const s of t.steps){const r=s.command??JSON.stringify(s.args),a=_t(H(s))||(s.command?/\.env\b|auth\.json|id_rsa|\.pem\b/.test(s.command):!1);n.push(`[tool ${s.name}] ${w(b(r),S.toolCall)}`);const c=a?"(content of a sensitive file left out)":w(b(s.output),S.toolOutput);n.push(`[tool_output${s.isError?" \xB7 error":""}] ${c}`)}t.assistantText&&n.push(`[assistant] ${w(b(t.assistantText),S.assistant)}`);let o=n.join(`
|
|
5
|
+
`);for(;o.length>K&&n.length>3;)n.splice(e?2:1,1),o=n.join(`
|
|
6
|
+
`);return o.slice(0,K)}l(Ot,"se"),i(Ot,"buildExcerpt");export{jt as LONG_RUN_TOOL_CALLS,K as MAX_EXCERPT_CHARS,xt as analyzeRun,Y as bareCommand,Ot as buildExcerpt,C as checkCommand,M as codeFailed,L as commandIntent,N as failureReason,W as fixCommands,U as fixPairs,q as isCorrection,z as isDenial,G as isDetour,B as isSearch,rt as isUntellingReason,Ct as longSuccess,J as needsModel,Et as needsReflection,$t as passedLast,Rt as protectedChanges,P as reportsFailure,_ as reportsPass,x as runsChecks,yt as sameChecks,F as splitCommand,D as toolSteps,T as verifiedOutcome};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-lsp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-bridge": "1.0.
|
|
25
|
-
"@dalcode/dal-dap": "1.0.
|
|
26
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
24
|
+
"@dalcode/dal-bridge": "1.0.60",
|
|
25
|
+
"@dalcode/dal-dap": "1.0.60",
|
|
26
|
+
"@dalcode/dal-pi-kit": "1.0.60",
|
|
27
27
|
"cross-spawn": "7.0.6",
|
|
28
28
|
"typebox": "1.3.7",
|
|
29
29
|
"typescript": "5.9.3",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dalcode/dal-bridge": "1.0.
|
|
33
|
-
"@dalcode/dal-guard": "1.0.
|
|
34
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
35
|
-
"@dalcode/deepailab": "1.0.
|
|
36
|
-
"@earendil-works/pi-mcp": "1.0.
|
|
32
|
+
"@dalcode/dal-bridge": "1.0.60",
|
|
33
|
+
"@dalcode/dal-guard": "1.0.60",
|
|
34
|
+
"@dalcode/dal-pi-kit": "1.0.60",
|
|
35
|
+
"@dalcode/deepailab": "1.0.60",
|
|
36
|
+
"@earendil-works/pi-mcp": "1.0.60",
|
|
37
37
|
"cross-spawn": "7.0.6"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-office",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.60",
|
|
22
22
|
"docx": "9.7.1",
|
|
23
23
|
"echarts": "6.1.0",
|
|
24
24
|
"exceljs": "4.4.0",
|