@willbooster/shared-lib 11.1.0 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ ---
2
+ purpose: WillBooster projects on any JavaScript runtime share one implementation of general-purpose code instead of each writing its own.
3
+ goals:
4
+ - The package runs on every JavaScript runtime WillBooster uses, with no runtime dependencies.
5
+ ---
6
+
1
7
  # @willbooster/shared-lib
2
8
 
3
9
  `recoverJson(response)` extracts JSON candidates from text and Markdown without runtime dependencies. It repairs common syntax errors and recovers partial strings and containers. Each candidate includes its parsed `value`, serialized `json`, original `start`/`end` offsets, and `repairs` with original UTF-16 offsets. The range includes consumed source, such as trailing whitespace and removed comments; use `json` or `value`, not the source slice, for parsing.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./appEnv.cjs"),t=require("./array.cjs"),n=require("./assert.cjs"),r=require("./concurrency.cjs"),i=require("./crypto.cjs"),a=require("./githubTemplates.cjs"),o=require("./sleep.cjs"),s=require("./error.cjs"),c=require("./filePath.cjs"),l=require("./formatIsoDate.cjs"),u=require("./github.cjs"),d=require("./http.cjs"),f=require("./foreignCjk.cjs"),p=require("./humanize.cjs"),m=require("./mail.cjs"),h=require("./object.cjs"),g=require("./markdown.cjs"),_=require("./parseIsoDate.cjs"),v=require("./parseCommandLineArgs.cjs"),y=require("./number.cjs"),b=require("./text.cjs"),x=require("./prompt.cjs"),S=require("./promptFormatters.cjs"),C=require("./shuffle.cjs"),w=require("./recoverJson.cjs"),T=require("./sqlite.cjs"),E=require("./testingRules.cjs"),D=require("./throttledFetch.cjs"),O=require("./timeout.cjs"),k=require("./url.cjs"),A=require("./yaml.cjs"),j=require("./zenkaku.cjs");exports.BUG_ISSUE_SECTIONS=a.BUG_ISSUE_SECTIONS,exports.CHANGE_ISSUE_SECTIONS=a.CHANGE_ISSUE_SECTIONS,exports.ISSUE_TEMPLATE_RULES=a.ISSUE_TEMPLATE_RULES,exports.PULL_REQUEST_BODY_RULES=a.PULL_REQUEST_BODY_RULES,exports.PULL_REQUEST_REQUIREMENTS_RULES=a.PULL_REQUEST_REQUIREMENTS_RULES,exports.PULL_REQUEST_SECTIONS=a.PULL_REQUEST_SECTIONS,exports.TEST_WRITING_RULES=E.TEST_WRITING_RULES,exports.chunk=t.chunk,exports.clamp=y.clamp,exports.createThrottledFetch=D.createThrottledFetch,exports.detectForeignCjkInJapanese=f.detectForeignCjkInJapanese,exports.ensureTruthy=n.ensureTruthy,exports.errorify=s.errorify,exports.escapeHtml=b.escapeHtml,exports.escapeLikePattern=T.escapeLikePattern,exports.escapePromptTag=x.escapePromptTag,exports.escapeRegExp=b.escapeRegExp,exports.extractCodeBlocks=g.extractCodeBlocks,exports.extractIfSingleOutermostCodeBlock=g.extractIfSingleOutermostCodeBlock,exports.extractSections=g.extractSections,exports.extractTaggedCodeBlock=g.extractTaggedCodeBlock,exports.findForeignCjkCharactersInJapanese=f.findForeignCjkCharactersInJapanese,exports.forEachConcurrently=r.forEachConcurrently,exports.formatDuration=p.formatDuration,exports.formatElapsedTimeInJapanese=p.formatElapsedTimeInJapanese,exports.formatFilesForPrompt=S.formatFilesForPrompt,exports.formatIsoDateInTimeZone=l.formatIsoDateInTimeZone,exports.formatMessagesForPrompt=S.formatMessagesForPrompt,exports.formatPrompt=x.formatPrompt,exports.getAppEnv=e.getAppEnv,exports.getConnectionLevelSqlitePragmas=T.getConnectionLevelSqlitePragmas,exports.getErrorMessage=s.getErrorMessage,exports.getFileExtension=c.getFileExtension,exports.getFormString=d.getFormString,exports.getPersistentSqlitePragmas=T.getPersistentSqlitePragmas,exports.getSafeRedirectPath=k.getSafeRedirectPath,exports.getTildeFence=b.getTildeFence,exports.hasErrorCode=s.hasErrorCode,exports.humanizeNumber=p.humanizeNumber,exports.ignoreEnoent=s.ignoreEnoent,exports.ignoreEnoentAsync=s.ignoreEnoentAsync,exports.ignoreError=s.ignoreError,exports.ignoreErrorAsync=s.ignoreErrorAsync,exports.isRecord=h.isRecord,exports.mailTemplates=m.mailTemplates,exports.mapConcurrently=r.mapConcurrently,exports.omitUndefined=h.omitUndefined,exports.parseBearerToken=d.parseBearerToken,exports.parseCommandLineArgs=v.parseCommandLineArgs,exports.parseGitHubRepositoryFullName=u.parseGitHubRepositoryFullName,exports.parseIsoDate=_.parseIsoDate,exports.parseMarkdownSections=g.parseMarkdownSections,exports.parsePositiveInteger=y.parsePositiveInteger,exports.quoteForShell=b.quoteForShell,exports.raceWithTimeout=O.raceWithTimeout,exports.recoverJson=w.recoverJson,exports.renderSectionChecklist=a.renderSectionChecklist,exports.renderSectionTemplate=a.renderSectionTemplate,exports.serializeForPrompt=x.serializeForPrompt,exports.serializeForPromptInTag=x.serializeForPromptInTag,exports.sha256HexAsync=i.sha256HexAsync,exports.shuffle=C.shuffle,exports.shuffleWithSeed=C.shuffleWithSeed,exports.sleep=o.sleep,exports.timingSafeEqualStringAsync=i.timingSafeEqualStringAsync,exports.toCodeBlock=b.toCodeBlock,exports.toTildeCodeBlock=b.toTildeCodeBlock,exports.truncate=b.truncate,exports.truncateForPrompt=x.truncateForPrompt,exports.unwrapFencedReply=b.unwrapFencedReply,exports.withRetry=s.withRetry,exports.yamlStringifyOptions=A.yamlStringifyOptions,exports.zenkakuAlphanumericalsToHankaku=j.zenkakuAlphanumericalsToHankaku;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./appEnv.cjs"),t=require("./array.cjs"),n=require("./assert.cjs"),r=require("./concurrency.cjs"),i=require("./crypto.cjs"),a=require("./githubTemplates.cjs"),o=require("./error.cjs"),s=require("./filePath.cjs"),c=require("./formatIsoDate.cjs"),l=require("./github.cjs"),u=require("./http.cjs"),d=require("./foreignCjk.cjs"),f=require("./humanize.cjs"),p=require("./mail.cjs"),m=require("./object.cjs"),h=require("./markdown.cjs"),g=require("./parseIsoDate.cjs"),_=require("./parseCommandLineArgs.cjs"),v=require("./number.cjs"),y=require("./prompt.cjs"),b=require("./promptFormatters.cjs"),x=require("./shuffle.cjs"),S=require("./recoverJson.cjs"),C=require("./sleep.cjs"),w=require("./sqlite.cjs"),T=require("./text.cjs"),E=require("./testingRules.cjs"),D=require("./throttledFetch.cjs"),O=require("./timeout.cjs"),k=require("./url.cjs"),A=require("./yaml.cjs"),j=require("./zenkaku.cjs");exports.BUG_ISSUE_SECTIONS=a.BUG_ISSUE_SECTIONS,exports.CHANGE_ISSUE_SECTIONS=a.CHANGE_ISSUE_SECTIONS,exports.ISSUE_TEMPLATE_RULES=a.ISSUE_TEMPLATE_RULES,exports.PULL_REQUEST_BODY_RULES=a.PULL_REQUEST_BODY_RULES,exports.PULL_REQUEST_REQUIREMENTS_RULES=a.PULL_REQUEST_REQUIREMENTS_RULES,exports.PULL_REQUEST_SECTIONS=a.PULL_REQUEST_SECTIONS,exports.TEST_WRITING_RULES=E.TEST_WRITING_RULES,exports.chunk=t.chunk,exports.clamp=v.clamp,exports.createThrottledFetch=D.createThrottledFetch,exports.detectForeignCjkInJapanese=d.detectForeignCjkInJapanese,exports.ensureTruthy=n.ensureTruthy,exports.errorify=o.errorify,exports.escapeHtml=T.escapeHtml,exports.escapeLikePattern=w.escapeLikePattern,exports.escapePromptTag=y.escapePromptTag,exports.escapeRegExp=T.escapeRegExp,exports.extractCodeBlocks=h.extractCodeBlocks,exports.extractIfSingleOutermostCodeBlock=h.extractIfSingleOutermostCodeBlock,exports.extractSections=h.extractSections,exports.extractTaggedCodeBlock=h.extractTaggedCodeBlock,exports.findForeignCjkCharactersInJapanese=d.findForeignCjkCharactersInJapanese,exports.forEachConcurrently=r.forEachConcurrently,exports.formatDuration=f.formatDuration,exports.formatElapsedTimeInJapanese=f.formatElapsedTimeInJapanese,exports.formatFilesForPrompt=b.formatFilesForPrompt,exports.formatIsoDateInTimeZone=c.formatIsoDateInTimeZone,exports.formatMessagesForPrompt=b.formatMessagesForPrompt,exports.formatPrompt=y.formatPrompt,exports.getAppEnv=e.getAppEnv,exports.getConnectionLevelSqlitePragmas=w.getConnectionLevelSqlitePragmas,exports.getErrorMessage=o.getErrorMessage,exports.getFileExtension=s.getFileExtension,exports.getFormString=u.getFormString,exports.getPersistentSqlitePragmas=w.getPersistentSqlitePragmas,exports.getSafeRedirectPath=k.getSafeRedirectPath,exports.getTildeFence=T.getTildeFence,exports.hasErrorCode=o.hasErrorCode,exports.humanizeNumber=f.humanizeNumber,exports.ignoreEnoent=o.ignoreEnoent,exports.ignoreEnoentAsync=o.ignoreEnoentAsync,exports.ignoreError=o.ignoreError,exports.ignoreErrorAsync=o.ignoreErrorAsync,exports.isRecord=m.isRecord,exports.mailTemplates=p.mailTemplates,exports.mapConcurrently=r.mapConcurrently,exports.omitUndefined=m.omitUndefined,exports.parseBearerToken=u.parseBearerToken,exports.parseCommandLineArgs=_.parseCommandLineArgs,exports.parseGitHubRepositoryFullName=l.parseGitHubRepositoryFullName,exports.parseIsoDate=g.parseIsoDate,exports.parseMarkdownSections=h.parseMarkdownSections,exports.parsePositiveInteger=v.parsePositiveInteger,exports.quoteForShell=T.quoteForShell,exports.raceWithTimeout=O.raceWithTimeout,exports.recoverJson=S.recoverJson,exports.renderSectionChecklist=a.renderSectionChecklist,exports.renderSectionTemplate=a.renderSectionTemplate,exports.serializeForPrompt=y.serializeForPrompt,exports.serializeForPromptInTag=y.serializeForPromptInTag,exports.sha256HexAsync=i.sha256HexAsync,exports.shuffle=x.shuffle,exports.shuffleWithSeed=x.shuffleWithSeed,exports.sleep=C.sleep,exports.timingSafeEqualStringAsync=i.timingSafeEqualStringAsync,exports.toCodeBlock=T.toCodeBlock,exports.toTildeCodeBlock=T.toTildeCodeBlock,exports.truncate=T.truncate,exports.truncateForPrompt=y.truncateForPrompt,exports.unwrapFencedReply=T.unwrapFencedReply,exports.withRetry=o.withRetry,exports.yamlStringifyOptions=A.yamlStringifyOptions,exports.zenkakuAlphanumericalsToHankaku=j.zenkakuAlphanumericalsToHankaku;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{getAppEnv as e}from"./appEnv.js";import{chunk as t}from"./array.js";import{ensureTruthy as n}from"./assert.js";import{forEachConcurrently as r,mapConcurrently as i}from"./concurrency.js";import{sha256HexAsync as a,timingSafeEqualStringAsync as o}from"./crypto.js";import{BUG_ISSUE_SECTIONS as s,CHANGE_ISSUE_SECTIONS as c,ISSUE_TEMPLATE_RULES as l,PULL_REQUEST_BODY_RULES as u,PULL_REQUEST_REQUIREMENTS_RULES as d,PULL_REQUEST_SECTIONS as f,renderSectionChecklist as p,renderSectionTemplate as m}from"./githubTemplates.js";import{sleep as h}from"./sleep.js";import{errorify as g,getErrorMessage as _,hasErrorCode as v,ignoreEnoent as y,ignoreEnoentAsync as b,ignoreError as x,ignoreErrorAsync as S,withRetry as C}from"./error.js";import{getFileExtension as w}from"./filePath.js";import{formatIsoDateInTimeZone as T}from"./formatIsoDate.js";import{parseGitHubRepositoryFullName as E}from"./github.js";import{getFormString as D,parseBearerToken as O}from"./http.js";import{detectForeignCjkInJapanese as k,findForeignCjkCharactersInJapanese as A}from"./foreignCjk.js";import{formatDuration as j,formatElapsedTimeInJapanese as M,humanizeNumber as N}from"./humanize.js";import{mailTemplates as P}from"./mail.js";import{isRecord as F,omitUndefined as I}from"./object.js";import{extractCodeBlocks as L,extractIfSingleOutermostCodeBlock as R,extractSections as z,extractTaggedCodeBlock as B,parseMarkdownSections as V}from"./markdown.js";import{parseIsoDate as H}from"./parseIsoDate.js";import{parseCommandLineArgs as U}from"./parseCommandLineArgs.js";import{clamp as W,parsePositiveInteger as G}from"./number.js";import{escapeHtml as K,escapeRegExp as q,getTildeFence as J,quoteForShell as Y,toCodeBlock as X,toTildeCodeBlock as Z,truncate as Q,unwrapFencedReply as $}from"./text.js";import{escapePromptTag as ee,formatPrompt as te,serializeForPrompt as ne,serializeForPromptInTag as re,truncateForPrompt as ie}from"./prompt.js";import{formatFilesForPrompt as ae,formatMessagesForPrompt as oe}from"./promptFormatters.js";import{shuffle as se,shuffleWithSeed as ce}from"./shuffle.js";import{recoverJson as le}from"./recoverJson.js";import{escapeLikePattern as ue,getConnectionLevelSqlitePragmas as de,getPersistentSqlitePragmas as fe}from"./sqlite.js";import{TEST_WRITING_RULES as pe}from"./testingRules.js";import{createThrottledFetch as me}from"./throttledFetch.js";import{raceWithTimeout as he}from"./timeout.js";import{getSafeRedirectPath as ge}from"./url.js";import{yamlStringifyOptions as _e}from"./yaml.js";import{zenkakuAlphanumericalsToHankaku as ve}from"./zenkaku.js";export{s as BUG_ISSUE_SECTIONS,c as CHANGE_ISSUE_SECTIONS,l as ISSUE_TEMPLATE_RULES,u as PULL_REQUEST_BODY_RULES,d as PULL_REQUEST_REQUIREMENTS_RULES,f as PULL_REQUEST_SECTIONS,pe as TEST_WRITING_RULES,t as chunk,W as clamp,me as createThrottledFetch,k as detectForeignCjkInJapanese,n as ensureTruthy,g as errorify,K as escapeHtml,ue as escapeLikePattern,ee as escapePromptTag,q as escapeRegExp,L as extractCodeBlocks,R as extractIfSingleOutermostCodeBlock,z as extractSections,B as extractTaggedCodeBlock,A as findForeignCjkCharactersInJapanese,r as forEachConcurrently,j as formatDuration,M as formatElapsedTimeInJapanese,ae as formatFilesForPrompt,T as formatIsoDateInTimeZone,oe as formatMessagesForPrompt,te as formatPrompt,e as getAppEnv,de as getConnectionLevelSqlitePragmas,_ as getErrorMessage,w as getFileExtension,D as getFormString,fe as getPersistentSqlitePragmas,ge as getSafeRedirectPath,J as getTildeFence,v as hasErrorCode,N as humanizeNumber,y as ignoreEnoent,b as ignoreEnoentAsync,x as ignoreError,S as ignoreErrorAsync,F as isRecord,P as mailTemplates,i as mapConcurrently,I as omitUndefined,O as parseBearerToken,U as parseCommandLineArgs,E as parseGitHubRepositoryFullName,H as parseIsoDate,V as parseMarkdownSections,G as parsePositiveInteger,Y as quoteForShell,he as raceWithTimeout,le as recoverJson,p as renderSectionChecklist,m as renderSectionTemplate,ne as serializeForPrompt,re as serializeForPromptInTag,a as sha256HexAsync,se as shuffle,ce as shuffleWithSeed,h as sleep,o as timingSafeEqualStringAsync,X as toCodeBlock,Z as toTildeCodeBlock,Q as truncate,ie as truncateForPrompt,$ as unwrapFencedReply,C as withRetry,_e as yamlStringifyOptions,ve as zenkakuAlphanumericalsToHankaku};
1
+ import{getAppEnv as e}from"./appEnv.js";import{chunk as t}from"./array.js";import{ensureTruthy as n}from"./assert.js";import{forEachConcurrently as r,mapConcurrently as i}from"./concurrency.js";import{sha256HexAsync as a,timingSafeEqualStringAsync as o}from"./crypto.js";import{BUG_ISSUE_SECTIONS as s,CHANGE_ISSUE_SECTIONS as c,ISSUE_TEMPLATE_RULES as l,PULL_REQUEST_BODY_RULES as u,PULL_REQUEST_REQUIREMENTS_RULES as d,PULL_REQUEST_SECTIONS as f,renderSectionChecklist as p,renderSectionTemplate as m}from"./githubTemplates.js";import{errorify as h,getErrorMessage as g,hasErrorCode as _,ignoreEnoent as v,ignoreEnoentAsync as y,ignoreError as b,ignoreErrorAsync as x,withRetry as S}from"./error.js";import{getFileExtension as C}from"./filePath.js";import{formatIsoDateInTimeZone as w}from"./formatIsoDate.js";import{parseGitHubRepositoryFullName as T}from"./github.js";import{getFormString as E,parseBearerToken as D}from"./http.js";import{detectForeignCjkInJapanese as O,findForeignCjkCharactersInJapanese as k}from"./foreignCjk.js";import{formatDuration as A,formatElapsedTimeInJapanese as j,humanizeNumber as M}from"./humanize.js";import{mailTemplates as N}from"./mail.js";import{isRecord as P,omitUndefined as F}from"./object.js";import{extractCodeBlocks as I,extractIfSingleOutermostCodeBlock as L,extractSections as R,extractTaggedCodeBlock as z,parseMarkdownSections as B}from"./markdown.js";import{parseIsoDate as V}from"./parseIsoDate.js";import{parseCommandLineArgs as H}from"./parseCommandLineArgs.js";import{clamp as U,parsePositiveInteger as W}from"./number.js";import{escapePromptTag as G,formatPrompt as K,serializeForPrompt as q,serializeForPromptInTag as J,truncateForPrompt as Y}from"./prompt.js";import{formatFilesForPrompt as X,formatMessagesForPrompt as Z}from"./promptFormatters.js";import{shuffle as Q,shuffleWithSeed as $}from"./shuffle.js";import{recoverJson as ee}from"./recoverJson.js";import{sleep as te}from"./sleep.js";import{escapeLikePattern as ne,getConnectionLevelSqlitePragmas as re,getPersistentSqlitePragmas as ie}from"./sqlite.js";import{escapeHtml as ae,escapeRegExp as oe,getTildeFence as se,quoteForShell as ce,toCodeBlock as le,toTildeCodeBlock as ue,truncate as de,unwrapFencedReply as fe}from"./text.js";import{TEST_WRITING_RULES as pe}from"./testingRules.js";import{createThrottledFetch as me}from"./throttledFetch.js";import{raceWithTimeout as he}from"./timeout.js";import{getSafeRedirectPath as ge}from"./url.js";import{yamlStringifyOptions as _e}from"./yaml.js";import{zenkakuAlphanumericalsToHankaku as ve}from"./zenkaku.js";export{s as BUG_ISSUE_SECTIONS,c as CHANGE_ISSUE_SECTIONS,l as ISSUE_TEMPLATE_RULES,u as PULL_REQUEST_BODY_RULES,d as PULL_REQUEST_REQUIREMENTS_RULES,f as PULL_REQUEST_SECTIONS,pe as TEST_WRITING_RULES,t as chunk,U as clamp,me as createThrottledFetch,O as detectForeignCjkInJapanese,n as ensureTruthy,h as errorify,ae as escapeHtml,ne as escapeLikePattern,G as escapePromptTag,oe as escapeRegExp,I as extractCodeBlocks,L as extractIfSingleOutermostCodeBlock,R as extractSections,z as extractTaggedCodeBlock,k as findForeignCjkCharactersInJapanese,r as forEachConcurrently,A as formatDuration,j as formatElapsedTimeInJapanese,X as formatFilesForPrompt,w as formatIsoDateInTimeZone,Z as formatMessagesForPrompt,K as formatPrompt,e as getAppEnv,re as getConnectionLevelSqlitePragmas,g as getErrorMessage,C as getFileExtension,E as getFormString,ie as getPersistentSqlitePragmas,ge as getSafeRedirectPath,se as getTildeFence,_ as hasErrorCode,M as humanizeNumber,v as ignoreEnoent,y as ignoreEnoentAsync,b as ignoreError,x as ignoreErrorAsync,P as isRecord,N as mailTemplates,i as mapConcurrently,F as omitUndefined,D as parseBearerToken,H as parseCommandLineArgs,T as parseGitHubRepositoryFullName,V as parseIsoDate,B as parseMarkdownSections,W as parsePositiveInteger,ce as quoteForShell,he as raceWithTimeout,ee as recoverJson,p as renderSectionChecklist,m as renderSectionTemplate,q as serializeForPrompt,J as serializeForPromptInTag,a as sha256HexAsync,Q as shuffle,$ as shuffleWithSeed,te as sleep,o as timingSafeEqualStringAsync,le as toCodeBlock,ue as toTildeCodeBlock,de as truncate,Y as truncateForPrompt,fe as unwrapFencedReply,S as withRetry,_e as yamlStringifyOptions,ve as zenkakuAlphanumericalsToHankaku};
@@ -1,7 +1,7 @@
1
- "use strict";const e=require("./text.cjs"),t=require("./prompt.cjs");function n(t,n=1){let i=`#`.repeat(n);return t.map(t=>`${i} ${r(t.path)}\n\n${e.toCodeBlock(t.data.replaceAll(/\r\n?/gu,`
1
+ "use strict";const e=require("./prompt.cjs"),t=require("./text.cjs");function n(e,n=1){let i=`#`.repeat(n);return e.map(e=>`${i} ${r(e.path)}\n\n${t.toCodeBlock(e.data.replaceAll(/\r\n?/gu,`
2
2
  `).trimEnd())}`).join(`
3
3
 
4
- `)}function r(e){let t=1;for(let n of e.matchAll(/`+/gu))t=Math.max(t,n[0].length+1);let n="`".repeat(t);return`${n} ${e} ${n}`}function i(e){let n=[.../* @__PURE__ */ new Set([`system`,`developer`,`user`,`assistant`,`tool`,...e.map(e=>e.role)])];return e.map(e=>{let r=e.content;for(let e of n)r=t.escapePromptTag(r,e);return`<${e.role}>\n${r}\n</${e.role}>`}).join(`
4
+ `)}function r(e){let t=1;for(let n of e.matchAll(/`+/gu))t=Math.max(t,n[0].length+1);let n="`".repeat(t);return`${n} ${e} ${n}`}function i(t){let n=[.../* @__PURE__ */ new Set([`system`,`developer`,`user`,`assistant`,`tool`,...t.map(e=>e.role)])];return t.map(t=>{let r=t.content;for(let t of n)r=e.escapePromptTag(r,t);return`<${t.role}>\n${r}\n</${t.role}>`}).join(`
5
5
 
6
6
  `)}exports.formatFilesForPrompt=n,exports.formatMessagesForPrompt=i;
7
7
  //# sourceMappingURL=promptFormatters.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"promptFormatters.cjs","names":["toCodeBlock","escapePromptTag","require_text","require_prompt","formatFilesForPrompt","headingMarker","headingLevel","files","formatPath","file","length","match","path","delimiter","formatMessagesForPrompt","roles","messages","message","content","role"],"sources":["../src/promptFormatters.ts"],"sourcesContent":["import { escapePromptTag } from './prompt.js';\nimport { toCodeBlock } from './text.js';\n\n/**\n * Renders files as Markdown sections for an LLM prompt: a heading holding the single-line path in inline code,\n * followed by the file contents in a code block whose fence the contents cannot close. Line endings are normalized\n * to LF and trailing whitespace is removed.\n * The output reads back with `extractSections` (keyed by path) and `extractIfSingleOutermostCodeBlock`, so an\n * LLM can be asked to answer in the same format.\n */\nexport function formatFilesForPrompt(files: readonly { path: string; data: string }[], headingLevel = 1): string {\n const headingMarker = '#'.repeat(headingLevel);\n return files\n .map(\n (file) =>\n `${headingMarker} ${formatPath(file.path)}\\n\\n${toCodeBlock(file.data.replaceAll(/\\r\\n?/gu, '\\n').trimEnd())}`\n )\n .join('\\n\\n');\n}\n\nfunction formatPath(path: string): string {\n let length = 1;\n for (const match of path.matchAll(/`+/gu)) length = Math.max(length, match[0].length + 1);\n const delimiter = '`'.repeat(length);\n return `${delimiter} ${path} ${delimiter}`;\n}\n\n/**\n * Renders chat messages as `<role>` elements separated by blank lines, e.g. to embed a conversation log in a prompt.\n * Escapes system, developer, user, assistant, tool, and every supplied role's tags in message contents.\n * Roles must be trusted literal tag names supplied by the caller. This preserves delimiters, not instruction priority.\n * To wrap the result in another element, escape that tag in the result with `escapePromptTag`.\n */\nexport function formatMessagesForPrompt(messages: readonly { role: string; content: string }[]): string {\n const roles = [\n ...new Set(['system', 'developer', 'user', 'assistant', 'tool', ...messages.map((message) => message.role)]),\n ];\n return messages\n .map((message) => {\n let content = message.content;\n for (const role of roles) content = escapePromptTag(content, role);\n return `<${message.role}>\\n${content}\\n</${message.role}>`;\n })\n .join('\\n\\n');\n}\n"],"mappings":"A,qEAUA,SAAgBI,EAAqB,EAAkD,EAAe,EAAW,CAC/G,IAAMC,EAAgB,IAAI,OAAOC,CAAY,EAC7C,OAAOC,EACJ,IACE,GACC,GAAGF,EAAc,GAAGG,EAAWC,EAAK,IAAI,EAAE,MAAMT,EAAAA,YAAYS,EAAK,KAAK,WAAW,UAAW;CAAI,CAAC,CAAC,QAAQ,CAAC,GAC/G,CAAC,CACA,KAAK;;CAAM,CAChB,CAEA,SAASD,EAAW,EAAsB,CACxC,IAAIE,EAAS,EACb,IAAK,IAAMC,KAASC,EAAK,SAAS,MAAM,EAAG,EAAS,KAAK,IAAIF,EAAQC,EAAM,EAAE,CAAC,OAAS,CAAC,EACxF,IAAME,EAAY,IAAI,OAAOH,CAAM,EACnC,MAAO,GAAGG,EAAU,GAAGD,EAAK,GAAGC,GACjC,CAQA,SAAgBC,EAAwB,EAAgE,CACtG,IAAMC,EAAQ,CACZ,mBAAG,IAAI,IAAI,CAAC,SAAU,YAAa,OAAQ,YAAa,OAAQ,GAAGC,EAAS,IAAK,GAAYC,EAAQ,IAAI,CAAC,CAAC,CAC7G,EACA,OAAOD,EACJ,IAAK,GAAY,CAChB,IAAIE,EAAUD,EAAQ,QACtB,IAAK,IAAME,KAAQJ,EAAO,EAAUd,EAAAA,gBAAgBiB,EAASC,CAAI,EACjE,MAAO,IAAIF,EAAQ,KAAK,KAAKC,EAAQ,MAAMD,EAAQ,KAAK,EAC1D,CAAC,CAAC,CACD,KAAK;;CAAM,CAChB,C"}
1
+ {"version":3,"file":"promptFormatters.cjs","names":["toCodeBlock","escapePromptTag","require_prompt","require_text","formatFilesForPrompt","headingMarker","headingLevel","files","formatPath","file","length","match","path","delimiter","formatMessagesForPrompt","roles","messages","message","content","role"],"sources":["../src/promptFormatters.ts"],"sourcesContent":["import { escapePromptTag } from './prompt.js';\nimport { toCodeBlock } from './text.js';\n\n/**\n * Renders files as Markdown sections for an LLM prompt: a heading holding the single-line path in inline code,\n * followed by the file contents in a code block whose fence the contents cannot close. Line endings are normalized\n * to LF and trailing whitespace is removed.\n * The output reads back with `extractSections` (keyed by path) and `extractIfSingleOutermostCodeBlock`, so an\n * LLM can be asked to answer in the same format.\n */\nexport function formatFilesForPrompt(files: readonly { path: string; data: string }[], headingLevel = 1): string {\n const headingMarker = '#'.repeat(headingLevel);\n return files\n .map(\n (file) =>\n `${headingMarker} ${formatPath(file.path)}\\n\\n${toCodeBlock(file.data.replaceAll(/\\r\\n?/gu, '\\n').trimEnd())}`\n )\n .join('\\n\\n');\n}\n\nfunction formatPath(path: string): string {\n let length = 1;\n for (const match of path.matchAll(/`+/gu)) length = Math.max(length, match[0].length + 1);\n const delimiter = '`'.repeat(length);\n return `${delimiter} ${path} ${delimiter}`;\n}\n\n/**\n * Renders chat messages as `<role>` elements separated by blank lines, e.g. to embed a conversation log in a prompt.\n * Escapes system, developer, user, assistant, tool, and every supplied role's tags in message contents.\n * Roles must be trusted literal tag names supplied by the caller. This preserves delimiters, not instruction priority.\n * To wrap the result in another element, escape that tag in the result with `escapePromptTag`.\n */\nexport function formatMessagesForPrompt(messages: readonly { role: string; content: string }[]): string {\n const roles = [\n ...new Set(['system', 'developer', 'user', 'assistant', 'tool', ...messages.map((message) => message.role)]),\n ];\n return messages\n .map((message) => {\n let content = message.content;\n for (const role of roles) content = escapePromptTag(content, role);\n return `<${message.role}>\\n${content}\\n</${message.role}>`;\n })\n .join('\\n\\n');\n}\n"],"mappings":"A,qEAUA,SAAgBI,EAAqB,EAAkD,EAAe,EAAW,CAC/G,IAAMC,EAAgB,IAAI,OAAOC,CAAY,EAC7C,OAAOC,EACJ,IACE,GACC,GAAGF,EAAc,GAAGG,EAAWC,EAAK,IAAI,EAAE,MAAMT,EAAAA,YAAYS,EAAK,KAAK,WAAW,UAAW;CAAI,CAAC,CAAC,QAAQ,CAAC,GAC/G,CAAC,CACA,KAAK;;CAAM,CAChB,CAEA,SAASD,EAAW,EAAsB,CACxC,IAAIE,EAAS,EACb,IAAK,IAAMC,KAASC,EAAK,SAAS,MAAM,EAAG,EAAS,KAAK,IAAIF,EAAQC,EAAM,EAAE,CAAC,OAAS,CAAC,EACxF,IAAME,EAAY,IAAI,OAAOH,CAAM,EACnC,MAAO,GAAGG,EAAU,GAAGD,EAAK,GAAGC,GACjC,CAQA,SAAgBC,EAAwB,EAAgE,CACtG,IAAMC,EAAQ,CACZ,mBAAG,IAAI,IAAI,CAAC,SAAU,YAAa,OAAQ,YAAa,OAAQ,GAAGC,EAAS,IAAK,GAAYC,EAAQ,IAAI,CAAC,CAAC,CAC7G,EACA,OAAOD,EACJ,IAAK,GAAY,CAChB,IAAIE,EAAUD,EAAQ,QACtB,IAAK,IAAME,KAAQJ,EAAO,EAAUd,EAAAA,gBAAgBiB,EAASC,CAAI,EACjE,MAAO,IAAIF,EAAQ,KAAK,KAAKC,EAAQ,MAAMD,EAAQ,KAAK,EAC1D,CAAC,CAAC,CACD,KAAK;;CAAM,CAChB,C"}
@@ -1,7 +1,7 @@
1
- import{toCodeBlock as e}from"./text.js";import{escapePromptTag as t}from"./prompt.js";function n(t,n=1){let i=`#`.repeat(n);return t.map(t=>`${i} ${r(t.path)}\n\n${e(t.data.replaceAll(/\r\n?/gu,`
1
+ import{escapePromptTag as e}from"./prompt.js";import{toCodeBlock as t}from"./text.js";function n(e,n=1){let i=`#`.repeat(n);return e.map(e=>`${i} ${r(e.path)}\n\n${t(e.data.replaceAll(/\r\n?/gu,`
2
2
  `).trimEnd())}`).join(`
3
3
 
4
- `)}function r(e){let t=1;for(let n of e.matchAll(/`+/gu))t=Math.max(t,n[0].length+1);let n="`".repeat(t);return`${n} ${e} ${n}`}function i(e){let n=[.../* @__PURE__ */ new Set([`system`,`developer`,`user`,`assistant`,`tool`,...e.map(e=>e.role)])];return e.map(e=>{let r=e.content;for(let e of n)r=t(r,e);return`<${e.role}>\n${r}\n</${e.role}>`}).join(`
4
+ `)}function r(e){let t=1;for(let n of e.matchAll(/`+/gu))t=Math.max(t,n[0].length+1);let n="`".repeat(t);return`${n} ${e} ${n}`}function i(t){let n=[.../* @__PURE__ */ new Set([`system`,`developer`,`user`,`assistant`,`tool`,...t.map(e=>e.role)])];return t.map(t=>{let r=t.content;for(let t of n)r=e(r,t);return`<${t.role}>\n${r}\n</${t.role}>`}).join(`
5
5
 
6
6
  `)}export{n as formatFilesForPrompt,i as formatMessagesForPrompt};
7
7
  //# sourceMappingURL=promptFormatters.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/shared-lib",
3
- "version": "11.1.0",
3
+ "version": "11.1.1",
4
4
  "description": "Shared library for WillBooster projects",
5
5
  "license": "Apache-2.0",
6
6
  "author": "WillBooster Inc.",
@@ -51,12 +51,12 @@
51
51
  "@tsconfig/node-lts": "24.0.1",
52
52
  "@tsconfig/node-ts": "23.6.4",
53
53
  "@types/bun": "1.4.4",
54
- "@types/node": "26.6.5",
54
+ "@types/node": "26.6.6",
55
55
  "@willbooster/oxlint-config": "1.4.9",
56
- "@willbooster/wb": "23.0.2",
57
- "build-ts": "21.0.29",
58
- "oxlint": "1.89.0",
59
- "oxlint-tsgolint": "7.0.2005",
56
+ "@willbooster/wb": "23.4.0",
57
+ "build-ts": "21.0.33",
58
+ "oxlint": "1.92.0",
59
+ "oxlint-tsgolint": "7.0.2006",
60
60
  "yaml": "2.9.1"
61
61
  }
62
62
  }