@zibby/skills 0.1.68 → 0.1.71

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.
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Derive the human-facing doc web URL from the open-api host + document id.
3
+ * The open-api host (open.feishu.cn / open.larksuite.com) is region-specific;
4
+ * the web doc lives on the corresponding product domain. This is a best-effort
5
+ * canonical URL — a tenant with a vanity subdomain may render its own host, but
6
+ * the product-domain URL still resolves for the user.
7
+ */
8
+ export function docWebUrl(host: any, id: any): string;
9
+ /**
10
+ * Parse a Lark/Feishu doc reference (raw token OR URL) into { type, token }.
11
+ * - .../docx/<token> → { type:'docx', token }
12
+ * - .../wiki/<token> → { type:'wiki', token } (resolved to its docx obj_token)
13
+ * - bare token → { type:'docx', token }
14
+ * Returns null when nothing usable can be extracted. Pure + side-effect-free.
15
+ */
16
+ export function parseLarkDocRef(ref: any): {
17
+ type: string;
18
+ token: string;
19
+ };
20
+ /**
21
+ * Map a small, common subset of markdown into Lark Docx block objects.
22
+ * Each block is a single line: headings (#/##/### → heading1/2/3), bullets
23
+ * (- / *), ordered (1.), everything else a text paragraph. Inline marks are
24
+ * kept as literal text (content is preserved; we don't emit Lark text-element
25
+ * styles — honest + robust). Empty lines are skipped (Lark rejects empty text
26
+ * blocks). Bounded by the caller's chunking to MAX_BLOCK_CHILDREN per request.
27
+ */
28
+ export function markdownToLarkBlocks(markdown: any): {
29
+ [x: string]: number | {
30
+ elements: {
31
+ text_run: {
32
+ content: string;
33
+ };
34
+ }[];
35
+ style: {};
36
+ };
37
+ block_type: number;
38
+ }[];
39
+ export function _resetLarkDocsTokenCache(): void;
40
+ export namespace larkDocsSkill {
41
+ let id: string;
42
+ let serverName: string;
43
+ let allowedTools: string[];
44
+ let requiresIntegration: "lark";
45
+ let description: string;
46
+ let envKeys: any[];
47
+ let promptFragment: string;
48
+ /**
49
+ * Spawn the GENERIC skill MCP server (bin/mcp-skill.mjs) pointing at this
50
+ * module's larkDocsSkill export, so the AGENT gets real mcp__larkdocs__*
51
+ * tools. Auth flows through the INHERITED env (PROJECT_API_TOKEN →
52
+ * resolveIntegrationToken('lark')), so no provider-specific env keys are
53
+ * needed here. When unconnected, handleToolCall returns { ok:false, error }.
54
+ */
55
+ function resolve(): {
56
+ type: string;
57
+ command: string;
58
+ args: any[];
59
+ env: {};
60
+ description: string;
61
+ alwaysLoad: boolean;
62
+ };
63
+ function handleToolCall(name: any, args: any): Promise<string>;
64
+ let tools: ({
65
+ name: string;
66
+ description: string;
67
+ input_schema: {
68
+ type: string;
69
+ properties: {
70
+ documentId: {
71
+ type: string;
72
+ description: string;
73
+ };
74
+ title?: undefined;
75
+ markdown?: undefined;
76
+ text?: undefined;
77
+ folderToken?: undefined;
78
+ fileType?: undefined;
79
+ commentId?: undefined;
80
+ };
81
+ required: string[];
82
+ };
83
+ } | {
84
+ name: string;
85
+ description: string;
86
+ input_schema: {
87
+ type: string;
88
+ properties: {
89
+ title: {
90
+ type: string;
91
+ description: string;
92
+ };
93
+ markdown: {
94
+ type: string;
95
+ description: string;
96
+ };
97
+ text: {
98
+ type: string;
99
+ description: string;
100
+ };
101
+ folderToken: {
102
+ type: string;
103
+ description: string;
104
+ };
105
+ documentId?: undefined;
106
+ fileType?: undefined;
107
+ commentId?: undefined;
108
+ };
109
+ required: string[];
110
+ };
111
+ } | {
112
+ name: string;
113
+ description: string;
114
+ input_schema: {
115
+ type: string;
116
+ properties: {
117
+ documentId: {
118
+ type: string;
119
+ description: string;
120
+ };
121
+ markdown: {
122
+ type: string;
123
+ description: string;
124
+ };
125
+ text: {
126
+ type: string;
127
+ description: string;
128
+ };
129
+ title?: undefined;
130
+ folderToken?: undefined;
131
+ fileType?: undefined;
132
+ commentId?: undefined;
133
+ };
134
+ required: string[];
135
+ };
136
+ } | {
137
+ name: string;
138
+ description: string;
139
+ input_schema: {
140
+ type: string;
141
+ properties: {
142
+ documentId: {
143
+ type: string;
144
+ description: string;
145
+ };
146
+ fileType: {
147
+ type: string;
148
+ description: string;
149
+ };
150
+ title?: undefined;
151
+ markdown?: undefined;
152
+ text?: undefined;
153
+ folderToken?: undefined;
154
+ commentId?: undefined;
155
+ };
156
+ required: string[];
157
+ };
158
+ } | {
159
+ name: string;
160
+ description: string;
161
+ input_schema: {
162
+ type: string;
163
+ properties: {
164
+ documentId: {
165
+ type: string;
166
+ description: string;
167
+ };
168
+ text: {
169
+ type: string;
170
+ description: string;
171
+ };
172
+ fileType: {
173
+ type: string;
174
+ description: string;
175
+ };
176
+ title?: undefined;
177
+ markdown?: undefined;
178
+ folderToken?: undefined;
179
+ commentId?: undefined;
180
+ };
181
+ required: string[];
182
+ };
183
+ } | {
184
+ name: string;
185
+ description: string;
186
+ input_schema: {
187
+ type: string;
188
+ properties: {
189
+ documentId: {
190
+ type: string;
191
+ description: string;
192
+ };
193
+ commentId: {
194
+ type: string;
195
+ description: string;
196
+ };
197
+ text: {
198
+ type: string;
199
+ description: string;
200
+ };
201
+ fileType: {
202
+ type: string;
203
+ description: string;
204
+ };
205
+ title?: undefined;
206
+ markdown?: undefined;
207
+ folderToken?: undefined;
208
+ };
209
+ required: string[];
210
+ };
211
+ })[];
212
+ }
@@ -0,0 +1,11 @@
1
+ import{existsSync as b}from"fs";import{fileURLToPath as S}from"url";import{dirname as v,resolve as R}from"path";import{resolveIntegrationToken as A}from"@zibby/core/backend-client.js";var g=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),C=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});function N(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let t=v(S(import.meta.url)),e=R(t,"..","bin","mcp-skill.mjs");return b(e)?e:null}var I=2e4,x=50,O=6e3*1e3,u=null;async function E(){let{appId:t,appSecret:e,host:n}=await A("lark");if(u&&u.appId===t&&u.expiresAt>Date.now())return{token:u.token,host:n};let o=await(await fetch(`${n}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:t,app_secret:e})})).json();if(o.code!==0)throw new Error(`Lark tenant_access_token failed: ${o.msg||o.code}`);return u={token:o.tenant_access_token,expiresAt:Date.now()+O,appId:t},{token:o.tenant_access_token,host:n}}async function l(t,e,n){let{token:r,host:o}=await E(),i={method:t,headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json; charset=utf-8"}};t!=="GET"&&n!==void 0&&(i.body=JSON.stringify(n));let c=await(await fetch(`${o}${e}`,i)).json();if(c.code!==0)throw new Error(`Lark Docx API ${e} error: ${c.msg||c.code}`);return{data:c.data||{},host:o}}function h(t,e){return String(t||"").includes("feishu")?`https://feishu.cn/docx/${e}`:`https://www.larksuite.com/docx/${e}`}function m(t){if(!t||typeof t!="string")return null;let e=t.trim();if(!e)return null;let n=e.match(/\/(docx|wiki)\/([A-Za-z0-9]+)/);return n?{type:n[1],token:n[2]}:/^[A-Za-z0-9]{10,}$/.test(e)?{type:"docx",token:e}:null}async function k(t){let e=typeof t=="string"?m(t):t;if(!e)throw new Error("A valid Lark doc id or URL is required");if(e.type==="docx")return e.token;let{data:n}=await l("GET",`/open-apis/wiki/v2/spaces/get_node?token=${encodeURIComponent(e.token)}`),r=n?.node||{};if(r.obj_type!=="docx"||!r.obj_token)throw new Error(`Wiki node is not a docx document (obj_type=${r.obj_type||"unknown"})`);return r.obj_token}function L(t){let e=String(t??"").replace(/\r\n/g,`
2
+ `),n=[];for(let r of e.split(`
3
+ `)){let o=r.replace(/\s+$/,"");if(!o.trim())continue;let i=/^(#{1,3})\s+(.*)$/.exec(o),s=/^\s*[-*]\s+(.*)$/.exec(o),c=/^\s*\d+[.)]\s+(.*)$/.exec(o),a,d,p;if(i){let _=i[1].length;a=`heading${_}`,d=2+_,p=i[2]}else s?(a="bullet",d=12,p=s[1]):c?(a="ordered",d=13,p=c[1]):(a="text",d=2,p=o);n.push({block_type:d,[a]:{elements:[{text_run:{content:p}}],style:{}}})}return n}function f(t){let e=typeof t?.markdown=="string"?t.markdown:null,n=typeof t?.text=="string"?t.text:null;return e??n}async function w(t,e){let n;for(let r=0;r<e.length;r+=x){let o=e.slice(r,r+x);n=(await l("POST",`/open-apis/docx/v1/documents/${t}/blocks/${t}/children?document_revision_id=-1`,{children:o})).host}return n}var P="docx",U=50;function T(t){return[{type:"text_run",text_run:{text:String(t??"")}}]}function D(t){return Array.isArray(t)?t.map(e=>e?.text_run?.text??e?.docs_link?.url??(e?.person?`@${e.person.user_id||""}`:"")).join(""):""}function $(t){let e=Array.isArray(t?.reply_list?.replies)?t.reply_list.replies:[];return{commentId:t?.comment_id||"",resolved:!!t?.is_solved,replies:e.map(n=>({replyId:n?.reply_id||"",author:n?.user_id||"",text:D(n?.content?.elements),createTime:n?.create_time||""}))}}function y(t){return typeof t?.fileType=="string"&&t.fileType.trim()?t.fileType.trim():P}var M={id:"lark-docs",serverName:"larkdocs",allowedTools:["mcp__larkdocs__*"],requiresIntegration:g.LARK,description:"Lark / Feishu Docs \u2014 read, create, and append Lark documents (docx).",envKeys:[],promptFragment:`## Lark Docs (connected)
4
+ You can read, create, and append Lark/Feishu documents (docx). This reuses the same connected Lark app as messaging.
5
+ - larkdoc_get: pass a Lark doc id OR a full doc URL (a /docx/ or /wiki/ link); returns { ok, documentId, title, url, text } where text is the doc as plain text (truncated to ~20k chars). Use it as reference context.
6
+ - larkdoc_create: create a new doc from a title + markdown/text (#/##/### headings, - bullets, 1. ordered supported); returns { ok, documentId, url }. Share the url.
7
+ - larkdoc_append: append markdown/text to the end of an existing doc (pass the documentId or doc URL).
8
+ - larkdoc_list_comments: list the comment threads on a doc (pass the documentId or doc URL); returns { ok, comments:[{ commentId, replies:[{ replyId, author, text }] }] }. Use to read the thread you are replying to.
9
+ - larkdoc_reply_comment: reply INSIDE an existing comment thread \u2014 pass { documentId, commentId, text }. Use this to answer a user who @mentioned Zibby in a doc comment (reply in the SAME commentId).
10
+ - larkdoc_add_comment: post a NEW top-level comment on a doc \u2014 pass { documentId, text }.
11
+ These tools return { ok:false, error } on failure \u2014 treat an unavailable Lark connection as "cannot read/deliver to Lark Docs" and continue rather than blocking the task.`,resolve(){let t=N();return t?{type:"stdio",command:"node",args:[t,"../dist/larkDocs.js","larkDocsSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(t,e){try{switch(t){case"larkdoc_get":{let n=e?.documentId||e?.url||e?.id,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=await k(r),i="";try{i=(await l("GET",`/open-apis/docx/v1/documents/${o}`)).data?.document?.title||""}catch{}let{data:s,host:c}=await l("GET",`/open-apis/docx/v1/documents/${o}/raw_content?lang=0`),a=String(s?.content||""),d=!1;return a.length>I&&(a=a.slice(0,I),d=!0),JSON.stringify({ok:!0,documentId:o,title:i,url:h(c,o),text:a,...d?{truncated:!0}:{}})}case"larkdoc_create":{let n=typeof e?.title=="string"&&e.title.trim()?e.title.trim():null;if(!n)return JSON.stringify({ok:!1,error:"title is required"});let{data:r,host:o}=await l("POST","/open-apis/docx/v1/documents",{title:n,...e?.folderToken?{folder_token:String(e.folderToken)}:{}}),i=r?.document?.document_id;if(!i)return JSON.stringify({ok:!1,error:"Lark Docs create returned no document_id"});let s=f(e);if(s&&s.trim()){let c=L(s);c.length&&await w(i,c)}return JSON.stringify({ok:!0,documentId:i,title:n,url:h(o,i)})}case"larkdoc_append":{let n=e?.documentId||e?.url||e?.id,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=f(e);if(!o||!o.trim())return JSON.stringify({ok:!1,error:"markdown or text content is required"});let i=await k(r),s=L(o);if(!s.length)return JSON.stringify({ok:!1,error:"no non-empty content to append"});let c=await w(i,s);return JSON.stringify({ok:!0,documentId:i,url:h(c,i)})}case"larkdoc_list_comments":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=await k(r),i=y(e),s=new URLSearchParams({file_type:i,page_size:String(U)}),{data:c}=await l("GET",`/open-apis/drive/v1/files/${o}/comments?${s.toString()}`),d=(Array.isArray(c?.items)?c.items:[]).map($);return JSON.stringify({ok:!0,documentId:o,count:d.length,comments:d})}case"larkdoc_add_comment":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=f({text:e?.text??e?.body});if(!o||!o.trim())return JSON.stringify({ok:!1,error:"text is required"});let i=await k(r),s=y(e),{data:c}=await l("POST",`/open-apis/drive/v1/files/${i}/comments?file_type=${encodeURIComponent(s)}`,{reply_list:{replies:[{content:{elements:T(o)}}]}});return JSON.stringify({ok:!0,documentId:i,commentId:c?.comment_id||""})}case"larkdoc_reply_comment":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=e?.commentId||e?.comment_id;if(!o)return JSON.stringify({ok:!1,error:"commentId is required"});let i=f({text:e?.text??e?.body});if(!i||!i.trim())return JSON.stringify({ok:!1,error:"text is required"});let s=await k(r),c=y(e),{data:a}=await l("POST",`/open-apis/drive/v1/files/${s}/comments/${encodeURIComponent(o)}/replies?file_type=${encodeURIComponent(c)}`,{content:{elements:T(i)}});return JSON.stringify({ok:!0,documentId:s,commentId:String(o),replyId:a?.reply_id||""})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${t}`})}}catch(n){return JSON.stringify({ok:!1,error:n.message})}},tools:[{name:"larkdoc_get",description:"Read a Lark/Feishu document (docx) as plain text, for use as reference context. Accepts a raw doc id OR a full Lark doc URL (a /docx/ or /wiki/ link \u2014 wiki links are resolved to their backing docx). Returns { ok, documentId, title, url, text }. Text is truncated to ~20k chars.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL (/docx/\u2026 or /wiki/\u2026)."}},required:["documentId"]}},{name:"larkdoc_create",description:"Create a new Lark/Feishu document (docx) with a title and optional content (markdown: #/##/### headings, - bullets, 1. ordered; or plain text). Returns { ok, documentId, url } \u2014 share the url with the user.",input_schema:{type:"object",properties:{title:{type:"string",description:"Document title."},markdown:{type:"string",description:"Document body as markdown (preferred)."},text:{type:"string",description:"Document body as plain text (used when markdown is absent)."},folderToken:{type:"string",description:"Optional Lark drive folder token to create the doc in. Absent = the app root."}},required:["title"]}},{name:"larkdoc_append",description:"Append markdown/text content to the END of an existing Lark/Feishu document (docx). Accepts a documentId or a full Lark doc URL. Returns { ok, documentId, url }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},markdown:{type:"string",description:"Content to append, as markdown (preferred)."},text:{type:"string",description:"Content to append, as plain text (used when markdown is absent)."}},required:["documentId"]}},{name:"larkdoc_list_comments",description:"List the comment threads on a Lark/Feishu document. Accepts a documentId or full doc URL. Returns { ok, comments:[{ commentId, replies:[{ replyId, author, text }] }] }. Use to read the thread you are replying to.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'. Only change for non-docx files (doc/sheet/bitable/file/slides)."}},required:["documentId"]}},{name:"larkdoc_add_comment",description:"Post a NEW top-level comment on a Lark/Feishu document. Accepts a documentId or full doc URL plus text. Returns { ok, documentId, commentId }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},text:{type:"string",description:"The comment body (plain text)."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'."}},required:["documentId","text"]}},{name:"larkdoc_reply_comment",description:"Reply INSIDE an existing comment thread on a Lark/Feishu document. Pass { documentId, commentId, text }. Use to answer a user who @mentioned Zibby in a doc comment (reply in the same commentId). Returns { ok, documentId, commentId, replyId }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},commentId:{type:"string",description:"The comment_id of the thread to reply into (from larkdoc_list_comments or the webhook event)."},text:{type:"string",description:"The reply body (plain text)."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'."}},required:["documentId","commentId","text"]}}]};function K(){u=null}export{K as _resetLarkDocsTokenCache,h as docWebUrl,M as larkDocsSkill,L as markdownToLarkBlocks,m as parseLarkDocRef};
package/dist/notion.d.ts CHANGED
@@ -63,6 +63,9 @@ export namespace notionSkill {
63
63
  databaseId?: undefined;
64
64
  filter?: undefined;
65
65
  maxResults?: undefined;
66
+ blockId?: undefined;
67
+ discussionId?: undefined;
68
+ text?: undefined;
66
69
  };
67
70
  required: string[];
68
71
  };
@@ -86,6 +89,53 @@ export namespace notionSkill {
86
89
  description: string;
87
90
  };
88
91
  pageId?: undefined;
92
+ blockId?: undefined;
93
+ discussionId?: undefined;
94
+ text?: undefined;
95
+ };
96
+ required: string[];
97
+ };
98
+ } | {
99
+ name: string;
100
+ description: string;
101
+ input_schema: {
102
+ type: string;
103
+ properties: {
104
+ blockId: {
105
+ type: string;
106
+ description: string;
107
+ };
108
+ pageId?: undefined;
109
+ databaseId?: undefined;
110
+ filter?: undefined;
111
+ maxResults?: undefined;
112
+ discussionId?: undefined;
113
+ text?: undefined;
114
+ };
115
+ required: string[];
116
+ };
117
+ } | {
118
+ name: string;
119
+ description: string;
120
+ input_schema: {
121
+ type: string;
122
+ properties: {
123
+ discussionId: {
124
+ type: string;
125
+ description: string;
126
+ };
127
+ pageId: {
128
+ type: string;
129
+ description: string;
130
+ };
131
+ text: {
132
+ type: string;
133
+ description: string;
134
+ };
135
+ databaseId?: undefined;
136
+ filter?: undefined;
137
+ maxResults?: undefined;
138
+ blockId?: undefined;
89
139
  };
90
140
  required: string[];
91
141
  };
package/dist/notion.js CHANGED
@@ -1,9 +1,11 @@
1
- import{existsSync as I}from"fs";import{fileURLToPath as $}from"url";import{dirname as A,resolve as w}from"path";import{resolveIntegrationToken as O,clearTokenCache as S}from"@zibby/core/backend-client.js";var m=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});function x(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let t=A($(import.meta.url)),a=w(t,"..","bin","mcp-skill.mjs");return I(a)?a:null}var R="2022-06-28",L="https://api.notion.com/v1",g=2e4,b=25,v=25;function _(t){if(!t||typeof t!="string")return null;let i=t.trim().split(/[?#]/)[0],e=i.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/);if(e)return e[0].toLowerCase();let n=i.match(/[0-9a-fA-F]{32}/g);if(n&&n.length){let r=n[n.length-1].toLowerCase();return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}return null}async function h(t,a={}){let i=async()=>{let{token:e}=await O("notion");if(typeof e!="string"||!e)throw new Error(`Invalid notion token type: ${typeof e}`);let n=await fetch(`${L}${t}`,{method:a.method||"GET",headers:{Authorization:`Bearer ${e}`,"Notion-Version":R,Accept:"application/json",...a.body?{"Content-Type":"application/json"}:{},...a.headers},body:a.body?JSON.stringify(a.body):void 0});if(!n.ok){let s=await n.text().catch(()=>"");throw new Error(`Notion API ${n.status}: ${s.slice(0,300)}`)}let r=await n.text().catch(()=>"");if(!r||!r.trim())return{};try{return JSON.parse(r)}catch{return{raw:r}}};try{return await i()}catch(e){let n=String(e?.message||e||"").toLowerCase();if(!(n.includes("token")||n.includes("401")||n.includes("unauthorized")))throw e;return S("notion"),i()}}function p(t){if(!Array.isArray(t))return"";let a="";for(let i of t){let e=i?.plain_text??i?.text?.content??"";if(!e)continue;let n=i.annotations||{};n.code&&(e=`\`${e}\``),n.bold&&(e=`**${e}**`),n.italic&&(e=`_${e}_`),n.strikethrough&&(e=`~~${e}~~`);let r=i?.href||i?.text?.link?.url;r&&(e=`[${e}](${r})`),a+=e}return a}function P(t,a,i){let e=t?.type,n=t?.[e]||{},r=" ".repeat(Math.max(0,a)),s=(c="rich_text")=>p(n[c]),o;switch(e){case"paragraph":o=s();break;case"heading_1":o=`# ${s()}`;break;case"heading_2":o=`## ${s()}`;break;case"heading_3":o=`### ${s()}`;break;case"bulleted_list_item":o=`${r}- ${s()}`;break;case"numbered_list_item":o=`${r}1. ${s()}`;break;case"to_do":o=`${r}- [${n.checked?"x":" "}] ${s()}`;break;case"toggle":o=`${r}- ${s()}`;break;case"quote":o=`> ${s()}`;break;case"callout":{o=`> ${n.icon?.emoji?`${n.icon.emoji} `:""}${s()}`;break}case"code":{o=`\`\`\`${n.language||""}
2
- ${s()}
3
- \`\`\``;break}case"divider":o="---";break;case"child_page":o=`[child page: ${n.title||""}]`;break;case"child_database":o=`[child database: ${n.title||""}]`;break;case"bookmark":case"embed":case"link_preview":o=n.url?`<${n.url}>`:"";break;case"equation":o=n.expression?`$${n.expression}$`:"";break;case"table":case"column_list":case"column":o="";break;case"table_row":{let c=(n.cells||[]).map(d=>p(d).trim());o=`${r}| ${c.join(" | ")} |`;break}default:o=s();break}let l=[];return o&&o.trim()&&l.push(o),i&&i.trim()&&l.push(i),l.join(`
4
- `)}async function y(t,a,i){let e=[],n,r=0;do{if(i.used>=g)break;let s=new URLSearchParams({page_size:"100"});n&&s.set("start_cursor",n);let o=await h(`/blocks/${t}/children?${s.toString()}`),l=Array.isArray(o.results)?o.results:[];for(let c of l){let d="";c.has_children&&(d=await y(c.id,a+1,i));let u=P(c,a,d);if(u&&(e.push(u),i.used+=u.length+1),i.used>=g)break}n=o.has_more?o.next_cursor:void 0,r+=1}while(n&&r<v);return e.join(`
5
- `)}function k(t){let a=t?.properties||{};for(let i of Object.values(a))if(i?.type==="title"){let e=p(i.title).trim();if(e)return e}return""}function T(t){if(!t||!t.type)return"";switch(t.type){case"title":return p(t.title).trim();case"rich_text":return p(t.rich_text).trim();case"number":return t.number==null?"":String(t.number);case"select":return t.select?.name||"";case"status":return t.status?.name||"";case"multi_select":return(t.multi_select||[]).map(i=>i.name).join(", ");case"checkbox":return t.checkbox?"true":"false";case"url":return t.url||"";case"email":return t.email||"";case"phone_number":return t.phone_number||"";case"date":return t.date?.start||"";case"people":return(t.people||[]).map(i=>i.name||i.id).join(", ");default:return""}}var D={id:"notion",serverName:"notion",allowedTools:["mcp__notion__*"],requiresIntegration:m.NOTION,description:"Notion read-only context (pull a page/database as markdown)",promptFragment:`## Notion (connected, read-only context)
1
+ import{existsSync as x}from"fs";import{fileURLToPath as R}from"url";import{dirname as w,resolve as O}from"path";import{resolveIntegrationToken as S,clearTokenCache as A}from"@zibby/core/backend-client.js";var _=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});function $(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let n=w(R(import.meta.url)),t=O(n,"..","bin","mcp-skill.mjs");return x(t)?t:null}var L="2022-06-28",P="https://api.notion.com/v1",g=2e4,b=25,v=25;function h(n){if(!n||typeof n!="string")return null;let o=n.trim().split(/[?#]/)[0],e=o.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/);if(e)return e[0].toLowerCase();let i=o.match(/[0-9a-fA-F]{32}/g);if(i&&i.length){let s=i[i.length-1].toLowerCase();return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}return null}async function m(n,t={}){let o=async()=>{let{token:e}=await S("notion");if(typeof e!="string"||!e)throw new Error(`Invalid notion token type: ${typeof e}`);let i=await fetch(`${P}${n}`,{method:t.method||"GET",headers:{Authorization:`Bearer ${e}`,"Notion-Version":L,Accept:"application/json",...t.body?{"Content-Type":"application/json"}:{},...t.headers},body:t.body?JSON.stringify(t.body):void 0});if(!i.ok){let a=await i.text().catch(()=>"");throw new Error(`Notion API ${i.status}: ${a.slice(0,300)}`)}let s=await i.text().catch(()=>"");if(!s||!s.trim())return{};try{return JSON.parse(s)}catch{return{raw:s}}};try{return await o()}catch(e){let i=String(e?.message||e||"").toLowerCase();if(!(i.includes("token")||i.includes("401")||i.includes("unauthorized")))throw e;return A("notion"),o()}}function u(n){if(!Array.isArray(n))return"";let t="";for(let o of n){let e=o?.plain_text??o?.text?.content??"";if(!e)continue;let i=o.annotations||{};i.code&&(e=`\`${e}\``),i.bold&&(e=`**${e}**`),i.italic&&(e=`_${e}_`),i.strikethrough&&(e=`~~${e}~~`);let s=o?.href||o?.text?.link?.url;s&&(e=`[${e}](${s})`),t+=e}return t}function T(n,t,o){let e=n?.type,i=n?.[e]||{},s=" ".repeat(Math.max(0,t)),a=(c="rich_text")=>u(i[c]),r;switch(e){case"paragraph":r=a();break;case"heading_1":r=`# ${a()}`;break;case"heading_2":r=`## ${a()}`;break;case"heading_3":r=`### ${a()}`;break;case"bulleted_list_item":r=`${s}- ${a()}`;break;case"numbered_list_item":r=`${s}1. ${a()}`;break;case"to_do":r=`${s}- [${i.checked?"x":" "}] ${a()}`;break;case"toggle":r=`${s}- ${a()}`;break;case"quote":r=`> ${a()}`;break;case"callout":{r=`> ${i.icon?.emoji?`${i.icon.emoji} `:""}${a()}`;break}case"code":{r=`\`\`\`${i.language||""}
2
+ ${a()}
3
+ \`\`\``;break}case"divider":r="---";break;case"child_page":r=`[child page: ${i.title||""}]`;break;case"child_database":r=`[child database: ${i.title||""}]`;break;case"bookmark":case"embed":case"link_preview":r=i.url?`<${i.url}>`:"";break;case"equation":r=i.expression?`$${i.expression}$`:"";break;case"table":case"column_list":case"column":r="";break;case"table_row":{let c=(i.cells||[]).map(l=>u(l).trim());r=`${s}| ${c.join(" | ")} |`;break}default:r=a();break}let d=[];return r&&r.trim()&&d.push(r),o&&o.trim()&&d.push(o),d.join(`
4
+ `)}async function N(n,t,o){let e=[],i,s=0;do{if(o.used>=g)break;let a=new URLSearchParams({page_size:"100"});i&&a.set("start_cursor",i);let r=await m(`/blocks/${n}/children?${a.toString()}`),d=Array.isArray(r.results)?r.results:[];for(let c of d){let l="";c.has_children&&(l=await N(c.id,t+1,o));let p=T(c,t,l);if(p&&(e.push(p),o.used+=p.length+1),o.used>=g)break}i=r.has_more?r.next_cursor:void 0,s+=1}while(i&&s<v);return e.join(`
5
+ `)}function k(n){let t=n?.properties||{};for(let o of Object.values(t))if(o?.type==="title"){let e=u(o.title).trim();if(e)return e}return""}function y(n){let t=String(n??"");if(!t)return[{type:"text",text:{content:""}}];let o=[];for(let e=0;e<t.length;e+=2e3)o.push({type:"text",text:{content:t.slice(e,e+2e3)}});return o}function U(n){return{id:n?.id||"",discussionId:n?.discussion_id||"",text:u(n?.rich_text).trim(),author:n?.created_by?.id||"",createdTime:n?.created_time||""}}function E(n){if(!n||!n.type)return"";switch(n.type){case"title":return u(n.title).trim();case"rich_text":return u(n.rich_text).trim();case"number":return n.number==null?"":String(n.number);case"select":return n.select?.name||"";case"status":return n.status?.name||"";case"multi_select":return(n.multi_select||[]).map(o=>o.name).join(", ");case"checkbox":return n.checkbox?"true":"false";case"url":return n.url||"";case"email":return n.email||"";case"phone_number":return n.phone_number||"";case"date":return n.date?.start||"";case"people":return(n.people||[]).map(o=>o.name||o.id).join(", ");default:return""}}var B={id:"notion",serverName:"notion",allowedTools:["mcp__notion__*"],requiresIntegration:_.NOTION,description:"Notion read-only context (pull a page/database as markdown)",promptFragment:`## Notion (connected, read-only context)
6
6
  You can pull a referenced Notion page in as extra context. This is OPTIONAL \u2014 only use it when the task references a Notion page/URL (e.g. an engineering-standards or design doc to review against).
7
7
  - notion_get_page: pass a Notion page id OR a full Notion URL; returns { id, title, url, text } where text is the page flattened to markdown (truncated to ~20k chars). Use the text as reference context.
8
8
  - notion_query_database: pass a database id/URL; returns a small list of rows ({ id, title, url, props }). Use to find a specific page, then notion_get_page it.
9
- Do not block the task if Notion is unavailable \u2014 these tools return { ok:false, error } on failure; treat a missing page as "no extra context" and continue.`,resolve(){let t=x();return t?{type:"stdio",command:"node",args:[t,"../dist/notion.js","notionSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(t,a){try{switch(t){case"notion_get_page":{let i=a?.pageId||a?.page||a?.url||a?.id,e=_(i);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let n=await h(`/pages/${e}`),r=k(n),s=n?.url||`https://www.notion.so/${e.replace(/-/g,"")}`,l=await y(e,0,{used:0}),c=!1;return l.length>g&&(l=l.slice(0,g),c=!0),JSON.stringify({ok:!0,id:e,title:r,url:s,text:l,...c?{truncated:!0}:{}})}case"notion_query_database":{let i=a?.databaseId||a?.database||a?.url||a?.id,e=_(i);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion database id or URL is required"});let r={page_size:Math.max(1,Math.min(Number(a?.maxResults)||b,b))};a?.filter&&typeof a.filter=="object"&&(r.filter=a.filter);let s=await h(`/databases/${e}/query`,{method:"POST",body:r}),l=(Array.isArray(s.results)?s.results:[]).map(c=>{let d={};for(let[u,N]of Object.entries(c.properties||{})){let f=T(N);f&&(d[u]=f)}return{id:c.id,title:k(c),url:c.url||`https://www.notion.so/${String(c.id||"").replace(/-/g,"")}`,props:d}});return JSON.stringify({ok:!0,id:e,count:l.length,hasMore:!!s.has_more,rows:l})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${t}`})}}catch(i){return JSON.stringify({ok:!1,error:i.message})}},tools:[{name:"notion_get_page",description:"Fetch a Notion page and its content flattened to markdown, for use as read-only context. Accepts a raw page id OR a full Notion URL. Returns { ok, id, title, url, text }. Text is truncated to ~20k chars.",input_schema:{type:"object",properties:{pageId:{type:"string",description:"Notion page id (dashed UUID or 32-char) OR a full Notion page URL."}},required:["pageId"]}},{name:"notion_query_database",description:"Query a Notion database and return a bounded list of rows (id, title, url, key props). Accepts a database id OR full Notion URL. Optional Notion filter object. Returns at most 25 rows.",input_schema:{type:"object",properties:{databaseId:{type:"string",description:"Notion database id (dashed UUID or 32-char) OR a full Notion database URL."},filter:{type:"object",description:"Optional Notion filter object (Notion query filter syntax).",additionalProperties:!0},maxResults:{type:"number",description:"Max rows to return (default 25, max 25)."}},required:["databaseId"]}}]};export{h as notionApi,D as notionSkill,_ as parseNotionId};
9
+ - notion_list_comments: pass a page/block id OR URL; returns the open comment discussions on it ({ id, discussionId, text, author }). Use to read the comment thread you are replying to.
10
+ - notion_add_comment: post a comment. To REPLY in an existing discussion pass { discussionId, text }; to start a NEW top-level comment on a page pass { pageId, text }. Returns { ok, id, discussionId }. Use this to answer a user who @mentioned Zibby in a Notion comment \u2014 reply in the SAME discussionId.
11
+ Do not block the task if Notion is unavailable \u2014 these tools return { ok:false, error } on failure; treat a missing page as "no extra context" and continue.`,resolve(){let n=$();return n?{type:"stdio",command:"node",args:[n,"../dist/notion.js","notionSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(n,t){try{switch(n){case"notion_get_page":{let o=t?.pageId||t?.page||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let i=await m(`/pages/${e}`),s=k(i),a=i?.url||`https://www.notion.so/${e.replace(/-/g,"")}`,d=await N(e,0,{used:0}),c=!1;return d.length>g&&(d=d.slice(0,g),c=!0),JSON.stringify({ok:!0,id:e,title:s,url:a,text:d,...c?{truncated:!0}:{}})}case"notion_query_database":{let o=t?.databaseId||t?.database||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion database id or URL is required"});let s={page_size:Math.max(1,Math.min(Number(t?.maxResults)||b,b))};t?.filter&&typeof t.filter=="object"&&(s.filter=t.filter);let a=await m(`/databases/${e}/query`,{method:"POST",body:s}),d=(Array.isArray(a.results)?a.results:[]).map(c=>{let l={};for(let[p,I]of Object.entries(c.properties||{})){let f=E(I);f&&(l[p]=f)}return{id:c.id,title:k(c),url:c.url||`https://www.notion.so/${String(c.id||"").replace(/-/g,"")}`,props:l}});return JSON.stringify({ok:!0,id:e,count:d.length,hasMore:!!a.has_more,rows:d})}case"notion_list_comments":{let o=t?.blockId||t?.pageId||t?.block||t?.page||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion page/block id or URL is required"});let i=new URLSearchParams({block_id:e,page_size:"100"}),s=await m(`/comments?${i.toString()}`),r=(Array.isArray(s.results)?s.results:[]).map(U);return JSON.stringify({ok:!0,id:e,count:r.length,comments:r})}case"notion_add_comment":{let o=typeof t?.text=="string"?t.text:typeof t?.body=="string"?t.body:"";if(!o||!o.trim())return JSON.stringify({ok:!1,error:"text is required"});let e=t?.discussionId||t?.discussion_id||null,i;if(e)i={discussion_id:String(e),rich_text:y(o)};else{let a=t?.pageId||t?.page||t?.url||t?.id,r=h(a);if(!r)return JSON.stringify({ok:!1,error:"Either discussionId (to reply) or a valid pageId (to start a comment) is required"});i={parent:{page_id:r},rich_text:y(o)}}let s=await m("/comments",{method:"POST",body:i});return JSON.stringify({ok:!0,id:s?.id||"",discussionId:s?.discussion_id||e||""})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${n}`})}}catch(o){return JSON.stringify({ok:!1,error:o.message})}},tools:[{name:"notion_get_page",description:"Fetch a Notion page and its content flattened to markdown, for use as read-only context. Accepts a raw page id OR a full Notion URL. Returns { ok, id, title, url, text }. Text is truncated to ~20k chars.",input_schema:{type:"object",properties:{pageId:{type:"string",description:"Notion page id (dashed UUID or 32-char) OR a full Notion page URL."}},required:["pageId"]}},{name:"notion_query_database",description:"Query a Notion database and return a bounded list of rows (id, title, url, key props). Accepts a database id OR full Notion URL. Optional Notion filter object. Returns at most 25 rows.",input_schema:{type:"object",properties:{databaseId:{type:"string",description:"Notion database id (dashed UUID or 32-char) OR a full Notion database URL."},filter:{type:"object",description:"Optional Notion filter object (Notion query filter syntax).",additionalProperties:!0},maxResults:{type:"number",description:"Max rows to return (default 25, max 25)."}},required:["databaseId"]}},{name:"notion_list_comments",description:"List the open comment discussions on a Notion page/block. Accepts a page/block id OR a full Notion URL. Returns { ok, comments:[{ id, discussionId, text, author }] }. Use to read the comment thread you are replying to.",input_schema:{type:"object",properties:{blockId:{type:"string",description:"Notion page or block id (dashed UUID or 32-char) OR a full Notion URL."}},required:["blockId"]}},{name:"notion_add_comment",description:"Post a comment on Notion. To REPLY within an existing discussion, pass { discussionId, text }. To start a NEW top-level comment on a page, pass { pageId, text }. Returns { ok, id, discussionId }. Use this to answer a user who @mentioned Zibby in a Notion comment (reply in the same discussionId).",input_schema:{type:"object",properties:{discussionId:{type:"string",description:"The discussion_id to reply into (from notion_list_comments). Preferred for replies."},pageId:{type:"string",description:"Page id/URL to start a NEW top-level comment on (used when discussionId is absent)."},text:{type:"string",description:"The comment body (plain text)."}},required:["text"]}}]};export{m as notionApi,B as notionSkill,h as parseNotionId};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/skills",
3
- "version": "0.1.68",
3
+ "version": "0.1.71",
4
4
  "description": "Built-in skill definitions for the Zibby agent-workflow framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -69,6 +69,10 @@
69
69
  "./sentry": {
70
70
  "types": "./dist/sentry.d.ts",
71
71
  "default": "./dist/sentry.js"
72
+ },
73
+ "./review": {
74
+ "types": "./dist/review.d.ts",
75
+ "default": "./dist/review.js"
72
76
  }
73
77
  },
74
78
  "scripts": {
@@ -0,0 +1,2 @@
1
+ export { REVIEW_RECORD_SCHEMA_VERSION, REVIEW_RECORD_KIND, CONTENT_MAX_BYTES, FIELD_MAX_CHARS, SEVERITY_TIERS, FINDING_STATUSES, normalizeSeverity, buildReviewRecord, upsertReplyOutcome, serializeReviewRecord, parseReviewMemory, summarizeForPrompt } from "./reviewRecord.js";
2
+ export { scopeForReviewMemory, storeReviewRecord, recallReviewRecord } from "./reviewMemoryIo.js";
package/dist/review.js ADDED
@@ -0,0 +1,4 @@
1
+ var A=1,l="review-record",O=204800,T=2e3,I=["blocker","should-fix","nit"],_={blocker:0,"should-fix":1,nit:2},g=["open","conceded","held","resolved"];function v(e){let r=String(e??"").trim().toLowerCase();return r?r.includes("\u{1F534}")||r.includes("blocker")||r.includes("critical")||r.includes("high")?"blocker":r.includes("\u{1F7E2}")||r.includes("nit")||r.includes("minor")||r.includes("low")||r.includes("info")?"nit":(r.includes("\u{1F7E1}")||r.includes("should")||r.includes("medium")||r.includes("warn"),"should-fix"):"should-fix"}var c=(e,r)=>{let n=e==null?"":String(e);return n.length>r?n.slice(0,r):n},E=e=>typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?Buffer.byteLength(e,"utf8"):new TextEncoder().encode(e).length;function k({headSha:e=null,verdict:r="COMMENT",objectivesChecked:n=!1,findings:i=[],nowIso:t=null}={}){let s=Array.isArray(i)?i:[];return{schemaVersion:1,kind:l,headSha:e||null,verdict:String(r||"COMMENT"),objectivesChecked:!!n,reviewedAt:t||null,findings:s.map((o,u)=>({id:`f${u+1}`,file:c(o?.file,512),line:o?.line==null?null:o.line,severity:v(o?.severity),category:c(o?.category,64),claim:c(o?.claim,2e3),evidence:c(o?.evidence,2e3),suggestion:c(o?.suggestion,2e3),confidence:typeof o?.confidence=="number"?o.confidence:null,status:"open"}))}}function C(e,{findingId:r,status:n,note:i}={}){if(!e||!Array.isArray(e.findings))return e;let t=g.includes(n)?n:"held";return{...e,findings:e.findings.map(s=>s.id===r?{...s,status:t,replyNote:c(i,2e3)}:s)}}function a(e){if(!e)return"";let r=[...e.findings||[]].sort((s,o)=>{let u=(_[s.severity]??9)-(_[o.severity]??9);if(u!==0)return u;let y=s.file||"",p=o.file||"";if(y!==p)return y<p?-1:1;let m=Number(s.line)||0,R=Number(o.line)||0;return m!==R?m-R:(s.id||"")<(o.id||"")?-1:1}),n={...e,findings:r},i=JSON.stringify(n);if(E(i)<=204800)return i;let t=[...r];for(n={...e,findings:t,truncated:!0};t.length>0&&E(JSON.stringify(n))>204800;)t.pop(),n={...e,findings:t,truncated:!0};return JSON.stringify(n)}var S=e=>e&&typeof e=="object"&&!Array.isArray(e)&&e.kind===l;function d(e){if(e==null)return{kind:"empty"};if(typeof e=="object"){if(!Array.isArray(e)&&typeof e.error=="string")return{kind:"empty"};if(S(e)){let i=Number(e.schemaVersion)>1;return{kind:"record",record:e,future:i}}return{kind:"legacy",legacyNote:h(e)}}if(typeof e!="string")return{kind:"empty"};let r=e.trim();if(!r)return{kind:"empty"};let n;try{n=JSON.parse(r)}catch{return{kind:"legacy",legacyNote:r}}if(n&&typeof n=="object"&&typeof n.error=="string")return{kind:"empty"};if(S(n)){let i=Number(n.schemaVersion)>1;return{kind:"record",record:n,future:i}}return{kind:"legacy",legacyNote:r}}function h(e){try{return JSON.stringify(e)}catch{return String(e)}}function w(e){if(!e||e.kind==="empty")return"";if(e.kind==="legacy")return`Prior review memory (legacy note, advisory only):
2
+ ${e.legacyNote}`;let r=e.record||{};if(e.future)return`Prior review memory (newer format ${r.schemaVersion} \u2014 advisory; verify against the live thread):
3
+ ${h(r).slice(0,2e3)}`;let n=[`Prior review of this change (verdict: ${r.verdict||"COMMENT"}${r.headSha?`, commit ${r.headSha}`:""}):`],i=(r.findings||[]).map(t=>{let s=t.file?`${t.file}${t.line!=null?`:${t.line}`:""}`:"(general)",o=t.status&&t.status!=="open"?` [${t.status}]`:"";return`- [${t.severity}] ${s} \u2014 ${t.claim||""}${o}`});return r.truncated&&i.push("- (\u2026older/lower-severity findings were truncated to fit memory)"),[...n,...i].join(`
4
+ `)}import{existsSync as M,readFileSync as x}from"node:fs";import{homedir as $}from"node:os";import{join as b}from"node:path";function B(){if(process.env.PROJECT_API_TOKEN)return process.env.PROJECT_API_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return process.env.ZIBBY_USER_TOKEN;try{let e=b($(),".zibby","config.json");return M(e)&&JSON.parse(x(e,"utf-8")).sessionToken||null}catch{return null}}function V(){return process.env.ZIBBY_ACCOUNT_API_URL?process.env.ZIBBY_ACCOUNT_API_URL.replace(/\/$/,""):(process.env.ZIBBY_ENV||"prod")==="local"?"http://localhost:3001":process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://api-prod.zibby.app"}function D(){return(typeof process.env.WORKFLOW_TYPE=="string"?process.env.WORKFLOW_TYPE.trim():"")||"agent"}function f(e){return`${D()}:${e}`}async function N(e,r){let n=B();if(!n)return{__noToken:!0};let i=`${V()}/credits/review-memory`,t=await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({op:e,...r})});if(!t.ok){let s=await t.text().catch(()=>"");throw new Error(`review-memory ${e} failed (${t.status}): ${s.slice(0,300)}`)}return t.json()}async function F(e,r){try{let n=a(r);if(!n)return{ok:!1,reason:"empty-record"};let i=await N("store",{scope:f(e),content:n});return i&&i.__noToken?{ok:!1,reason:"no-token"}:{ok:!0}}catch(n){return{ok:!1,reason:n?.message||"store-error"}}}async function L(e){try{let r=await N("recall",{scope:f(e)});if(!r||r.__noToken)return{kind:"empty"};let n=r.found&&r.memory?r.memory:null;if(!n)return{kind:"empty"};let i=n.content!=null?n.content:n.metadata!=null?n.metadata:null;return d(i)}catch{return{kind:"empty"}}}export{O as CONTENT_MAX_BYTES,T as FIELD_MAX_CHARS,g as FINDING_STATUSES,l as REVIEW_RECORD_KIND,A as REVIEW_RECORD_SCHEMA_VERSION,I as SEVERITY_TIERS,k as buildReviewRecord,v as normalizeSeverity,d as parseReviewMemory,L as recallReviewRecord,f as scopeForReviewMemory,a as serializeReviewRecord,F as storeReviewRecord,w as summarizeForPrompt,C as upsertReplyOutcome};
@@ -0,0 +1,43 @@
1
+ /** Effective backend scope for a plain per-PR/MR key. IDENTICAL to kvMemory scopeFor. */
2
+ export function scopeForReviewMemory(key: any): string;
3
+ /**
4
+ * Store a review record under a plain per-PR/MR key. Serializes via
5
+ * serializeReviewRecord (deterministic, byte-capped 200KB) and POSTs
6
+ * { op:'store', scope, content }.
7
+ *
8
+ * BEST-EFFORT: never throws. { ok:true } on success; { ok:false, reason:'no-token' }
9
+ * with no backend credential (local dev / self-host); { ok:false, reason } otherwise.
10
+ * The caller must treat a false result as a no-op — memory NEVER blocks a run.
11
+ */
12
+ export function storeReviewRecord(key: any, record: any): Promise<{
13
+ ok: boolean;
14
+ reason?: undefined;
15
+ } | {
16
+ ok: boolean;
17
+ reason: any;
18
+ }>;
19
+ /**
20
+ * Recall the review record stored under a plain per-PR/MR key. POSTs
21
+ * { op:'recall', scope } and hands the returned `content` to the tolerant
22
+ * parseReviewMemory (which never throws over any input).
23
+ *
24
+ * BEST-EFFORT: never throws. Returns parseReviewMemory's result
25
+ * ({ kind:'empty' | 'record' | 'legacy', ... }); { kind:'empty' } on missing
26
+ * token or ANY failure, so the caller degrades to "no prior memory".
27
+ */
28
+ export function recallReviewRecord(key: any): Promise<{
29
+ kind: string;
30
+ record?: undefined;
31
+ future?: undefined;
32
+ legacyNote?: undefined;
33
+ } | {
34
+ kind: string;
35
+ record: any;
36
+ future: boolean;
37
+ legacyNote?: undefined;
38
+ } | {
39
+ kind: string;
40
+ legacyNote: string;
41
+ record?: undefined;
42
+ future?: undefined;
43
+ }>;
@@ -0,0 +1 @@
1
+ import{existsSync as S,readFileSync as v}from"node:fs";import{homedir as N}from"node:os";import{join as A}from"node:path";var R="review-record";var d={blocker:0,"should-fix":1,nit:2};var y=e=>typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?Buffer.byteLength(e,"utf8"):new TextEncoder().encode(e).length;function m(e){if(!e)return"";let t=[...e.findings||[]].sort((o,s)=>{let c=(d[o.severity]??9)-(d[s.severity]??9);if(c!==0)return c;let u=o.file||"",l=s.file||"";if(u!==l)return u<l?-1:1;let a=Number(o.line)||0,f=Number(s.line)||0;return a!==f?a-f:(o.id||"")<(s.id||"")?-1:1}),n={...e,findings:t},r=JSON.stringify(n);if(y(r)<=204800)return r;let i=[...t];for(n={...e,findings:i,truncated:!0};i.length>0&&y(JSON.stringify(n))>204800;)i.pop(),n={...e,findings:i,truncated:!0};return JSON.stringify(n)}var p=e=>e&&typeof e=="object"&&!Array.isArray(e)&&e.kind===R;function _(e){if(e==null)return{kind:"empty"};if(typeof e=="object"){if(!Array.isArray(e)&&typeof e.error=="string")return{kind:"empty"};if(p(e)){let r=Number(e.schemaVersion)>1;return{kind:"record",record:e,future:r}}return{kind:"legacy",legacyNote:h(e)}}if(typeof e!="string")return{kind:"empty"};let t=e.trim();if(!t)return{kind:"empty"};let n;try{n=JSON.parse(t)}catch{return{kind:"legacy",legacyNote:t}}if(n&&typeof n=="object"&&typeof n.error=="string")return{kind:"empty"};if(p(n)){let r=Number(n.schemaVersion)>1;return{kind:"record",record:n,future:r}}return{kind:"legacy",legacyNote:t}}function h(e){try{return JSON.stringify(e)}catch{return String(e)}}function O(){if(process.env.PROJECT_API_TOKEN)return process.env.PROJECT_API_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return process.env.ZIBBY_USER_TOKEN;try{let e=A(N(),".zibby","config.json");return S(e)&&JSON.parse(v(e,"utf-8")).sessionToken||null}catch{return null}}function k(){return process.env.ZIBBY_ACCOUNT_API_URL?process.env.ZIBBY_ACCOUNT_API_URL.replace(/\/$/,""):(process.env.ZIBBY_ENV||"prod")==="local"?"http://localhost:3001":process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://api-prod.zibby.app"}function T(){return(typeof process.env.WORKFLOW_TYPE=="string"?process.env.WORKFLOW_TYPE.trim():"")||"agent"}function E(e){return`${T()}:${e}`}async function g(e,t){let n=O();if(!n)return{__noToken:!0};let r=`${k()}/credits/review-memory`,i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({op:e,...t})});if(!i.ok){let o=await i.text().catch(()=>"");throw new Error(`review-memory ${e} failed (${i.status}): ${o.slice(0,300)}`)}return i.json()}async function $(e,t){try{let n=m(t);if(!n)return{ok:!1,reason:"empty-record"};let r=await g("store",{scope:E(e),content:n});return r&&r.__noToken?{ok:!1,reason:"no-token"}:{ok:!0}}catch(n){return{ok:!1,reason:n?.message||"store-error"}}}async function b(e){try{let t=await g("recall",{scope:E(e)});if(!t||t.__noToken)return{kind:"empty"};let n=t.found&&t.memory?t.memory:null;if(!n)return{kind:"empty"};let r=n.content!=null?n.content:n.metadata!=null?n.metadata:null;return _(r)}catch{return{kind:"empty"}}}export{b as recallReviewRecord,E as scopeForReviewMemory,$ as storeReviewRecord};
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Normalize the review's free-form / emoji severity into a stable tier.
3
+ * The real review schema defaults severity to '🟡'; reviews also emit 🔴/🟢 and
4
+ * words. Anything unrecognized falls back to 'should-fix' (never throws).
5
+ */
6
+ export function normalizeSeverity(raw: any): "should-fix" | "blocker" | "nit";
7
+ /**
8
+ * Build a fresh review record from the review node's (post-verification)
9
+ * findings. `findings` is the REAL review shape:
10
+ * { file, line?, severity, category, claim, evidence, suggestion?, confidence? }
11
+ * Assigns stable ids (f1..fN), normalizes severity, caps long text, status:'open'.
12
+ * `nowIso` is injected (callers pass new Date().toISOString()) so this stays pure.
13
+ */
14
+ export function buildReviewRecord({ headSha, verdict, objectivesChecked, findings, nowIso, }?: {
15
+ headSha?: any;
16
+ verdict?: string;
17
+ objectivesChecked?: boolean;
18
+ findings?: any[];
19
+ nowIso?: any;
20
+ }): {
21
+ schemaVersion: number;
22
+ kind: string;
23
+ headSha: any;
24
+ verdict: string;
25
+ objectivesChecked: boolean;
26
+ reviewedAt: any;
27
+ findings: {
28
+ id: string;
29
+ file: string;
30
+ line: any;
31
+ severity: string;
32
+ category: string;
33
+ claim: string;
34
+ evidence: string;
35
+ suggestion: string;
36
+ confidence: any;
37
+ status: string;
38
+ }[];
39
+ };
40
+ /**
41
+ * Record the OUTCOME of a comment_reply against a finding. IDEMPOTENT: it SETS
42
+ * findings[id].status (and an optional one-line note) — running the same reply
43
+ * twice (webhook redelivery) yields the identical record, no double-append.
44
+ * Returns a NEW record (does not mutate the input). If findingId is unknown, the
45
+ * record is returned unchanged (best-effort, never throws).
46
+ */
47
+ export function upsertReplyOutcome(record: any, { findingId, status, note }?: {}): any;
48
+ /**
49
+ * Serialize a record to a string that FITS CONTENT_MAX_BYTES. Deterministic:
50
+ * findings are stably sorted by (severityRank, file, line, id); if still over
51
+ * budget, the LOWEST-priority findings are dropped until it fits and
52
+ * `truncated:true` is set. Text fields are already capped by buildReviewRecord.
53
+ */
54
+ export function serializeReviewRecord(record: any): string;
55
+ /**
56
+ * Tolerant reader — NEVER throws. Accepts whatever kv_recall returns for the
57
+ * value (a JSON string, an already-parsed metadata object, a legacy prose
58
+ * string, an {error} envelope, null/'').
59
+ * Returns one of:
60
+ * { kind:'empty' } — nothing usable
61
+ * { kind:'record', record, future?:bool } — a structured record (future=newer schemaVersion)
62
+ * { kind:'legacy', legacyNote:string } — an old freeform note; advisory only
63
+ */
64
+ export function parseReviewMemory(raw: any): {
65
+ kind: string;
66
+ record?: undefined;
67
+ future?: undefined;
68
+ legacyNote?: undefined;
69
+ } | {
70
+ kind: string;
71
+ record: any;
72
+ future: boolean;
73
+ legacyNote?: undefined;
74
+ } | {
75
+ kind: string;
76
+ legacyNote: string;
77
+ record?: undefined;
78
+ future?: undefined;
79
+ };
80
+ /**
81
+ * Render a parsed memory into prompt text for the review/reply LLM. Compact,
82
+ * human-readable, and it NEVER assumes a shape it didn't verify (a future
83
+ * schemaVersion is surfaced as advisory). Empty → '' (caller omits the block).
84
+ */
85
+ export function summarizeForPrompt(parsed: any): string;
86
+ /**
87
+ * reviewRecord — a GENERIC, provider-agnostic structured record for the
88
+ * code-review → comment_reply memory (shared by gitlab-code-review and
89
+ * github-code-review). Replaces the freeform prose kv note with a versioned,
90
+ * queryable record.
91
+ *
92
+ * DELIBERATELY TRANSPORT-AGNOSTIC. This module does NO I/O: it only builds,
93
+ * serializes, parses and renders the record. WHO stores/recalls it (the JS node
94
+ * vs the LLM via kv_store/kv_recall) is a separate wiring decision — these pure
95
+ * functions are correct either way. The per-PR/MR KEY stays provider-specific
96
+ * (reviewMemoryScopeFor in each review-node.js); the record BODY here carries
97
+ * zero provider fields (identity lives in the key, not the body).
98
+ *
99
+ * Contract facts this module mirrors (source of truth = backend
100
+ * src/handlers/review-memory.js + packages/skills/src/kvMemory.js):
101
+ * - kv `content` is a STRING, hard-capped at 200KB (CONTENT_MAX). We serialize
102
+ * to a string and truncate deterministically to fit — an over-cap store is
103
+ * rejected (HTTP 400) and SILENTLY lost, so truncation must happen here,
104
+ * before the write.
105
+ * - kv also has an optional `metadata` OBJECT channel; parseReviewMemory
106
+ * therefore accepts an already-parsed object too, so the record can ride in
107
+ * either channel without changing this code.
108
+ *
109
+ * Reviewed by two adversarial design agents (2026-07-04): schema aligned to the
110
+ * REAL finding shape ({file,line,severity,category,claim,evidence,suggestion,
111
+ * confidence}); replies modeled as an IDEMPOTENT findingId→status set (NOT an
112
+ * append log, which double-appends on webhook redelivery); headSha carried but
113
+ * treated as advisory (its plumbing is deferred — today it is undefined).
114
+ */
115
+ export const REVIEW_RECORD_SCHEMA_VERSION: 1;
116
+ export const REVIEW_RECORD_KIND: "review-record";
117
+ export const CONTENT_MAX_BYTES: number;
118
+ export const FIELD_MAX_CHARS: 2000;
119
+ export const SEVERITY_TIERS: string[];
120
+ export const FINDING_STATUSES: string[];
@@ -0,0 +1,4 @@
1
+ var h=1,m="review-record",_=204800,N=2e3,A=["blocker","should-fix","nit"],a={blocker:0,"should-fix":1,nit:2},S=["open","conceded","held","resolved"];function R(e){let n=String(e??"").trim().toLowerCase();return n?n.includes("\u{1F534}")||n.includes("blocker")||n.includes("critical")||n.includes("high")?"blocker":n.includes("\u{1F7E2}")||n.includes("nit")||n.includes("minor")||n.includes("low")||n.includes("info")?"nit":(n.includes("\u{1F7E1}")||n.includes("should")||n.includes("medium")||n.includes("warn"),"should-fix"):"should-fix"}var u=(e,n)=>{let t=e==null?"":String(e);return t.length>n?t.slice(0,n):t},g=e=>typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?Buffer.byteLength(e,"utf8"):new TextEncoder().encode(e).length;function v({headSha:e=null,verdict:n="COMMENT",objectivesChecked:t=!1,findings:o=[],nowIso:i=null}={}){let s=Array.isArray(o)?o:[];return{schemaVersion:1,kind:m,headSha:e||null,verdict:String(n||"COMMENT"),objectivesChecked:!!t,reviewedAt:i||null,findings:s.map((r,c)=>({id:`f${c+1}`,file:u(r?.file,512),line:r?.line==null?null:r.line,severity:R(r?.severity),category:u(r?.category,64),claim:u(r?.claim,2e3),evidence:u(r?.evidence,2e3),suggestion:u(r?.suggestion,2e3),confidence:typeof r?.confidence=="number"?r.confidence:null,status:"open"}))}}function k(e,{findingId:n,status:t,note:o}={}){if(!e||!Array.isArray(e.findings))return e;let i=S.includes(t)?t:"held";return{...e,findings:e.findings.map(s=>s.id===n?{...s,status:i,replyNote:u(o,2e3)}:s)}}function C(e){if(!e)return"";let n=[...e.findings||[]].sort((s,r)=>{let c=(a[s.severity]??9)-(a[r.severity]??9);if(c!==0)return c;let l=s.file||"",d=r.file||"";if(l!==d)return l<d?-1:1;let f=Number(s.line)||0,y=Number(r.line)||0;return f!==y?f-y:(s.id||"")<(r.id||"")?-1:1}),t={...e,findings:n},o=JSON.stringify(t);if(g(o)<=204800)return o;let i=[...n];for(t={...e,findings:i,truncated:!0};i.length>0&&g(JSON.stringify(t))>204800;)i.pop(),t={...e,findings:i,truncated:!0};return JSON.stringify(t)}var E=e=>e&&typeof e=="object"&&!Array.isArray(e)&&e.kind===m;function I(e){if(e==null)return{kind:"empty"};if(typeof e=="object"){if(!Array.isArray(e)&&typeof e.error=="string")return{kind:"empty"};if(E(e)){let o=Number(e.schemaVersion)>1;return{kind:"record",record:e,future:o}}return{kind:"legacy",legacyNote:p(e)}}if(typeof e!="string")return{kind:"empty"};let n=e.trim();if(!n)return{kind:"empty"};let t;try{t=JSON.parse(n)}catch{return{kind:"legacy",legacyNote:n}}if(t&&typeof t=="object"&&typeof t.error=="string")return{kind:"empty"};if(E(t)){let o=Number(t.schemaVersion)>1;return{kind:"record",record:t,future:o}}return{kind:"legacy",legacyNote:n}}function p(e){try{return JSON.stringify(e)}catch{return String(e)}}function O(e){if(!e||e.kind==="empty")return"";if(e.kind==="legacy")return`Prior review memory (legacy note, advisory only):
2
+ ${e.legacyNote}`;let n=e.record||{};if(e.future)return`Prior review memory (newer format ${n.schemaVersion} \u2014 advisory; verify against the live thread):
3
+ ${p(n).slice(0,2e3)}`;let t=[`Prior review of this change (verdict: ${n.verdict||"COMMENT"}${n.headSha?`, commit ${n.headSha}`:""}):`],o=(n.findings||[]).map(i=>{let s=i.file?`${i.file}${i.line!=null?`:${i.line}`:""}`:"(general)",r=i.status&&i.status!=="open"?` [${i.status}]`:"";return`- [${i.severity}] ${s} \u2014 ${i.claim||""}${r}`});return n.truncated&&o.push("- (\u2026older/lower-severity findings were truncated to fit memory)"),[...t,...o].join(`
4
+ `)}export{_ as CONTENT_MAX_BYTES,N as FIELD_MAX_CHARS,S as FINDING_STATUSES,m as REVIEW_RECORD_KIND,h as REVIEW_RECORD_SCHEMA_VERSION,A as SEVERITY_TIERS,v as buildReviewRecord,R as normalizeSeverity,I as parseReviewMemory,C as serializeReviewRecord,O as summarizeForPrompt,k as upsertReplyOutcome};