@sreetej510/pi-shipd-checks 0.11.3 → 0.11.4
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/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ ${t instanceof Error?t.message:String(t)}`)}}var _Po="shipd-humanizer-detector-s
|
|
|
102
102
|
|
|
103
103
|
Preserve every source requirement and its exact scope, including public API names, methods, arguments, attributes, commands, identifiers, literals, values, defaults, optionality, conditions, negations, exceptions, dependencies, ordering, event flow, outputs, errors, and compatibility behavior. Keep names exactly as specified. Do not split identifiers across formatting boundaries, rename existing APIs, or introduce APIs absent from the source.
|
|
104
104
|
|
|
105
|
-
Do not omit, weaken, generalize, contradict, or add requirements. Rephrase only when all meanings, constraints, and relationships remain unchanged.
|
|
105
|
+
Do not omit, weaken, generalize, contradict, or add requirements. Rephrase only when all meanings, constraints, and relationships remain unchanged. Do not claim preservation when uncertain.
|
|
106
106
|
|
|
107
107
|
Output only the rewritten specification, without commentary.`;function zC(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ZEn(e,t){if(!e?.trim())throw new Error(`Configure ${t} before using ${bL}.`);let s;try{s=new URL(e)}catch{throw new Error(`${t} must be a valid HTTPS URL.`)}if(s.protocol!=="https:")throw new Error(`${t} must use HTTPS.`);return s}function WPo(e,t){try{return JSON.parse(e)}catch{throw new Error(`${t} returned invalid JSON.`)}}async function QPo(e,t,s,a,c){let l=new AbortController,u=!1,p=()=>l.abort(a?.reason);a?.aborted?p():a?.addEventListener("abort",p,{once:!0});let d=setTimeout(()=>{u=!0,l.abort()},zEn);try{let m=await fetch(e,{method:"POST",headers:{"content-type":"application/json",...s},body:JSON.stringify(t),signal:l.signal}),f=await m.text();if(!m.ok)throw new Error(`${c} request failed (HTTP ${m.status}): ${f.slice(0,1e3)}`);return WPo(f,c)}catch(m){throw a?.aborted?new Error("Humanization cancelled."):u?new Error(`${c} request timed out after ${zEn/1e3} seconds.`):m}finally{clearTimeout(d),a?.removeEventListener("abort",p)}}function ZPo(e){if(!zC(e)||!Array.isArray(e.choices)||!zC(e.choices[0]))throw new Error("CoreWeave returned an unexpected chat-completions response.");let t=e.choices[0],s=t.message;if(!zC(s)||typeof s.content!="string"||!s.content.trim())throw new Error("CoreWeave returned an empty humanizer candidate.");let a=typeof t.finish_reason=="string"?t.finish_reason:"unknown",c=zC(e.usage)?e.usage.completion_tokens:void 0;if(a==="length"||typeof c=="number"&&c>=QEn)throw new Error("CoreWeave may have truncated a humanizer candidate at max_tokens; no candidates were returned.");return{text:s.content}}function YPo(e){return e.detector.exploratory_triage_label==="Human-like"&&e.detector.oof_scaled_score_approx<e.detector.exploratory_threshold}function XPo(e){let t=e;if(!zC(t))throw new Error("Fargate detector returned an unexpected score.");let s=["input_tokens","window_count","document_logit_raw_ai_positive","oof_scaled_score_approx","exploratory_threshold","latency_ms"];for(let a of s)if(typeof t[a]!="number"||!Number.isFinite(t[a]))throw new Error(`Fargate detector score is missing a valid ${a}.`);if(t.exploratory_triage_label!=="AI-like"&&t.exploratory_triage_label!=="Human-like"||typeof t.threshold_status!="string")throw new Error("Fargate detector score is missing its exploratory label or threshold status.");return{input_tokens:t.input_tokens,window_count:t.window_count,document_logit_raw_ai_positive:t.document_logit_raw_ai_positive,oof_scaled_score_approx:t.oof_scaled_score_approx,exploratory_triage_label:t.exploratory_triage_label,exploratory_threshold:t.exploratory_threshold,threshold_status:t.threshold_status,latency_ms:t.latency_ms,...typeof t.caveat=="string"?{caveat:t.caveat}:{}}}async function JPo(e){let t=process.env.COREWEAVE_API_KEY?.trim();if(t)return t;let s=process.env.COREWEAVE_API_KEY_FILE??e.coreweaveApiKeyFile;if(!s)throw new Error("Set COREWEAVE_API_KEY or configure a local key file with COREWEAVE_API_KEY_FILE.");try{let a=(await KEn(s,"utf8")).trim().replace(/^Bearer\s+/i,"");if(a)return a}catch{throw new Error("Could not read the configured CoreWeave API-key file; check its path and permissions.")}throw new Error("The configured CoreWeave API-key file is empty.")}async function e$o(e,t,s,a){let c=ZEn(process.env.COREWEAVE_BASE_URL??WEn,"COREWEAVE_BASE_URL"),l=process.env.COREWEAVE_PROJECT??jPo,u=process.env.NEMOTRON_MODEL??zPo,p=new URL(`${c.toString().replace(/\/+$/,"")}/chat/completions`),d={authorization:`Bearer ${s}`};l&&(d["OpenAI-Project"]=l);let m=await QPo(p,{model:u,messages:[{role:"system",content:KPo},{role:"user",content:e}],temperature:.7,top_p:.95,max_tokens:QEn,chat_template_kwargs:{enable_thinking:!1}},d,a,"CoreWeave"),f=ZPo(m);return{index:t,text:f.text}}function YEn(e){e.registerTool({name:bL,label:"Humanizing Prompt",description:"Humanizes agent_prompt.md and returns only drafts meeting the detector's Human-like cutoff. Never change the source automatically. Use a draft unchanged only if it preserves every requirement; otherwise make only the absolute minimum edits needed to restore fidelity. Lower detector scores rank better in exploratory triage, not confidence or correctness.",promptSnippet:"Humanize agent_prompt.md and return candidates",promptGuidelines:["Call only when the user asks to humanize agent_prompt.md.","NEVER edit agent_prompt.md automatically or replace it wholesale. Use a candidate unchanged only after confirming it preserves every source requirement.","If a candidate is inaccurate, do not broadly rewrite it. Make only the absolute minimum edits required to restore fidelity. If unsure, keep the original unchanged.","Only return drafts labeled Human-like with a score below the detector's reported cutoff; discard all others.","Lower detector scores rank better in exploratory triage, not confidence or correctness."],parameters:HPo,renderCall(t,s,a){let c=a.state;a.executionStarted&&c.startedAt===void 0&&(c.startedAt=Date.now(),c.endedAt=void 0);let l=a.lastComponent??new jEn("",0,0);return l.setText(""),l},renderResult(t,s,a,c){let l=c.state;l.startedAt??=Date.now(),s.isPartial&&!l.interval&&(l.interval=setInterval(()=>c.invalidate(),1e3)),(!s.isPartial||c.isError)&&(l.endedAt??=Date.now(),l.interval&&(clearInterval(l.interval),l.interval=void 0));let u=s.isPartial?"Elapsed":"Took",p=l.endedAt??Date.now(),d=l.startedAt!==void 0?Id(p-l.startedAt):"\u2014",m=a.fg("toolTitle",a.bold("Humanizing Prompt"))+a.fg("muted",` ${u} ${d}`),T=((t.content??[]).map(x=>x.type==="text"?x.text:"").join(`
|
|
108
108
|
`).trim()||(s.isPartial?"Generating prompt candidates...":"(no output)")).split(`
|
package/package.json
CHANGED