@vpxa/aikit 0.1.313 → 0.1.315

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.313",
3
+ "version": "0.1.315",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -1602,7 +1602,7 @@ blockquote {
1602
1602
  `)}function j(e){return e?.trim()?e.trim():``}function $t(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?{display:e}:{dateTime:t.toISOString(),display:new Intl.DateTimeFormat(void 0,{month:`long`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}).format(t)}}function M(e){let t=e.brand??`AI KIT`,r=e.showToolbox??!0,i=e.sharedChromeActions??(r?Xt:[]),a=[j(e.actionsHtml),Qt(e.transport,i,r),e.showThemeToggle===!1?``:[` <button type="button" class="${A.themeToggle}" aria-label="Switch to dark theme" aria-pressed="false">`,` <span class="${A.themeToggleIcon} ${A.themeToggleIconSun}" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></span>`,` <span class="${A.themeToggleIcon} ${A.themeToggleIconMoon}" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg></span>`,` </button>`].join(`
1603
1603
  `)].filter(Boolean).join(`
1604
1604
  `);return[` <header class="${A.header}">`,` <div class="${A.brand}">${n(t)}</div>`,` <div class="${A.title}">`,` <span class="${A.titleText}">${n(e.title)}</span>`,...e.subtitle?[` <span class="${A.subtitle}">${n(e.subtitle)}</span>`]:[],` </div>`,` <div class="${A.actions}">`,a,` </div>`,` </header>`].join(`
1605
- `)}function N(e={}){let t=$t(e.generatedAt),r=e.showInstallGuide??!0,i=e.installUrl??`https://hermes-agent.nousresearch.com`,a=t?[`Generated by `,`<span class="${A.footerBrand}">AI KIT</span>`,` at `,t.dateTime?`<time class="${A.footerTimestamp}" datetime="${n(t.dateTime)}">${n(t.display)}</time>`:`<span class="${A.footerTimestamp}">${n(t.display)}</span>`].join(``):`Generated by <span class="${A.footerBrand}">AI KIT</span>`,o=j(e.contentHtml),s=r?`<span class="${A.footerSlot}"><a href="${n(i)}" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--aikit-border)">Get AI Kit →</a></span>`:``;return[` <footer class="${A.footer}">`,` <div class="${A.footerMeta}">`,` <span class="${A.footerText}">${a}</span>`,...o?[` <span class="${A.footerSlot}">${o}</span>`]:[],s,` </div>`,` </footer>`].join(`
1605
+ `)}function N(e={}){let t=$t(e.generatedAt),r=e.showInstallGuide??!1,i=e.installUrl??`https://vpxa.io/ai-kit`,a=t?[`Generated by `,`<span class="${A.footerBrand}">AI KIT</span>`,` at `,t.dateTime?`<time class="${A.footerTimestamp}" datetime="${n(t.dateTime)}">${n(t.display)}</time>`:`<span class="${A.footerTimestamp}">${n(t.display)}</span>`].join(``):`Generated by <span class="${A.footerBrand}">AI KIT</span>`,o=j(e.contentHtml),s=r?`<span class="${A.footerSlot}"><a href="${n(i)}" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--aikit-border)">Get AI Kit →</a></span>`:``;return[` <footer class="${A.footer}">`,` <div class="${A.footerMeta}">`,` <span class="${A.footerText}">${a}</span>`,...o?[` <span class="${A.footerSlot}">${o}</span>`]:[],s,` </div>`,` </footer>`].join(`
1606
1606
  `)}const P=`
1607
1607
  .aikit-header,
1608
1608
  .aikit-toolbox-menu,
@@ -0,0 +1,367 @@
1
+ "use strict";var AnnotationInit=(()=>{var N=Object.defineProperty;var A=(i,t,e)=>t in i?N(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var d=(i,t,e)=>A(i,typeof t!="symbol"?t+"":t,e);function v(i,t){if(document.getElementById(i))return;let e=document.createElement("style");e.id=i,e.textContent=t,document.head.appendChild(e)}var C=document.createElement("div");function g(i){return C.textContent=i,C.innerHTML}var H="aikit-annotation-popover",O=`
2
+ .cp-backdrop {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ width: 100%;
7
+ height: 100%;
8
+ z-index: 999;
9
+ background: transparent;
10
+ }
11
+ .cp-popover {
12
+ position: absolute;
13
+ z-index: 1000;
14
+ width: 320px;
15
+ max-width: calc(100vw - 32px);
16
+ background: var(--dt-bg-secondary);
17
+ border: 1px solid var(--dt-border-default);
18
+ border-radius: var(--dt-radius-md);
19
+ box-shadow: var(--dt-shadow-md);
20
+ padding: var(--dt-space-3);
21
+ font-family: inherit;
22
+ }
23
+ .cp-header {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 6px;
27
+ margin-bottom: 8px;
28
+ font-size: var(--dt-font-size-sm);
29
+ font-weight: 600;
30
+ color: var(--dt-text-primary);
31
+ }
32
+ .cp-excerpt {
33
+ font-size: var(--dt-font-size-xs);
34
+ color: var(--dt-text-secondary);
35
+ margin-bottom: 8px;
36
+ padding: var(--dt-space-2);
37
+ border: 1px solid var(--dt-border-muted);
38
+ border-radius: var(--dt-radius-sm);
39
+ background: var(--dt-bg-primary);
40
+ font-family: var(--dt-font-mono);
41
+ word-break: break-all;
42
+ max-height: 60px;
43
+ overflow-y: auto;
44
+ }
45
+ .cp-textarea {
46
+ width: 100%;
47
+ min-height: 60px;
48
+ font-size: var(--dt-font-size-sm);
49
+ border: 1px solid var(--dt-border-default);
50
+ border-radius: var(--dt-radius-sm);
51
+ padding: 6px;
52
+ resize: vertical;
53
+ box-sizing: border-box;
54
+ background: var(--dt-bg-primary);
55
+ color: var(--dt-text-primary);
56
+ font-family: inherit;
57
+ }
58
+ .cp-textarea:focus {
59
+ outline: none;
60
+ border-color: var(--dt-accent-fg);
61
+ }
62
+ .cp-actions {
63
+ display: flex;
64
+ justify-content: flex-end;
65
+ gap: 8px;
66
+ margin-top: 8px;
67
+ }
68
+ .cp-btn {
69
+ font-size: var(--dt-font-size-sm);
70
+ padding: 6px 12px;
71
+ border-radius: var(--dt-radius-md);
72
+ cursor: pointer;
73
+ transition: background var(--dt-transition-fast), border-color var(--dt-transition-fast);
74
+ }
75
+ .cp-btn--cancel {
76
+ background: transparent;
77
+ border: 1px solid var(--dt-border-default);
78
+ color: var(--dt-text-secondary);
79
+ }
80
+ .cp-btn--cancel:hover {
81
+ background: var(--dt-annotation-hover);
82
+ }
83
+ .cp-btn--comment {
84
+ background: var(--dt-accent-emphasis);
85
+ color: var(--dt-accent-foreground, #ffffff);
86
+ border: none;
87
+ }
88
+ .cp-btn--comment:hover {
89
+ filter: brightness(1.1);
90
+ }
91
+ .cp-btn--remove {
92
+ background: transparent;
93
+ border: 1px solid var(--dt-annotation-deletion);
94
+ color: var(--dt-annotation-deletion);
95
+ }
96
+ .cp-btn--remove:hover {
97
+ background: var(--dt-annotation-deletion-bg);
98
+ }
99
+ `,b=class{constructor(t,e){d(this,"el");d(this,"textarea");d(this,"result");d(this,"backdrop");d(this,"options");this.result=t,this.options=e,v(H,O),this.backdrop=document.createElement("div"),this.backdrop.className="cp-backdrop",this.el=document.createElement("div"),this.el.className="cp-popover",this.el.setAttribute("role","dialog"),this.el.setAttribute("aria-label","Feedback on selection"),this.el.innerHTML=`
100
+ <div class="cp-header">Feedback</div>
101
+ <div class="cp-excerpt">${this.escapeText(t.text)}</div>
102
+ <textarea class="cp-textarea" placeholder="Add a comment (optional)..." aria-label="Comment text"></textarea>
103
+ <div class="cp-actions">
104
+ <button class="cp-btn cp-btn--cancel" aria-label="Cancel">Cancel</button>
105
+ <button class="cp-btn cp-btn--remove" aria-label="Remove selection without comment">Remove</button>
106
+ <button class="cp-btn cp-btn--comment" aria-label="Submit comment">Comment</button>
107
+ </div>
108
+ `,this.textarea=this.el.querySelector(".cp-textarea");let n=this.el.querySelector(".cp-btn--comment"),r=this.el.querySelector(".cp-btn--remove"),a=this.el.querySelector(".cp-btn--cancel");this.backdrop.addEventListener("click",()=>this.handleCancel()),n.addEventListener("click",()=>this.handleComment()),r.addEventListener("click",()=>this.handleRemove()),a.addEventListener("click",()=>this.handleCancel()),this.textarea.addEventListener("keydown",o=>this.handleKeyDown(o)),document.body.appendChild(this.backdrop),document.body.appendChild(this.el),this.positionNearSelection(),this.textarea.focus(),this.el.addEventListener("keydown",o=>{if(o.key!=="Tab")return;let s=this.el.querySelectorAll('button, textarea, [tabindex]:not([tabindex="-1"])');if(s.length===0)return;let l=s[0],p=s[s.length-1];o.shiftKey&&document.activeElement===l?(o.preventDefault(),p.focus()):!o.shiftKey&&document.activeElement===p&&(o.preventDefault(),l.focus())})}destroy(){this.backdrop.remove(),this.el.remove()}escapeText(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}positionNearSelection(){let t=this.result.range.getBoundingClientRect(),e=window.scrollX,n=window.scrollY,r=this.el.offsetWidth||320,a=this.el.offsetHeight||260,o=8,s=t.left+e+t.width/2-r/2;s=Math.max(o,s),s=Math.min(s,window.innerWidth+e-r-o);let l=window.innerHeight+n,p=t.bottom+n+o,c;p+a<=l?c=p:(c=t.top+n-a-o,c=Math.max(o,c)),this.el.style.left=`${s}px`,this.el.style.top=`${c}px`}handleComment(){let t=this.textarea.value.trim();this.options.onSubmit(this.result,t)}handleRemove(){let t=this.textarea.value.trim();this.options.onRemove(this.result,t)}handleCancel(){this.options.onDismiss()}handleKeyDown(t){t.key==="Escape"?(t.preventDefault(),this.handleCancel()):(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.handleComment())}};var x=class{constructor(t){d(this,"store");this.store=t}exportMarkdown(){let e=[...this.store.getState().annotations].sort((o,s)=>o.createdAt-s.createdAt);if(e.length===0)return"No feedback provided.";let n=e.filter(o=>o.type==="COMMENT"),r=e.filter(o=>o.type==="DELETION"),a=["## Reviewer Feedback",""];if(n.length>0){a.push("### Comments","");for(let o of n){let s=o.originalText.length>80?`${o.originalText.slice(0,80)}\u2026`:o.originalText;a.push(`- **${o.comment}**`),a.push(` > "${s}"`),a.push("")}}if(r.length>0){a.push("### Deletions","");for(let o of r){let s=o.originalText.length>80?`${o.originalText.slice(0,80)}\u2026`:o.originalText;a.push("- Remove this"),a.push(` > "${s}"`),a.push("")}}return a.join(`
109
+ `).trimEnd()}exportJSON(){let e=[...this.store.getState().annotations].sort((n,r)=>n.createdAt-r.createdAt);return JSON.stringify(e,null,2)}submitFeedback(t){let e=this.exportMarkdown(),n=this.exportJSON(),r=e==="No feedback provided."?e:`${e}
110
+
111
+ \`\`\`json
112
+ ${n}
113
+ \`\`\``;t("annotations",r)}getTotalCount(){let t=this.store.getState(),e=t.annotations.filter(r=>r.type==="COMMENT").length,n=t.annotations.filter(r=>r.type==="DELETION").length;return{comments:e,deletions:n,total:t.annotations.length}}};var M="aikit-annotation-highlight";function B(){if(document.getElementById(M))return;let i=document.createElement("style");i.id=M,i.textContent=`
114
+ mark.hl-COMMENT {
115
+ background: var(--dt-annotation-comment-bg, rgba(88, 166, 255, 0.15));
116
+ border-bottom: 2px solid var(--dt-annotation-comment, #58a6ff);
117
+ color: var(--dt-annotation-comment, #58a6ff);
118
+ border-radius: 2px;
119
+ cursor: pointer;
120
+ transition: opacity 0.2s ease;
121
+ }
122
+ mark.hl-DELETION {
123
+ background: var(--dt-annotation-deletion-bg, rgba(248, 81, 73, 0.15));
124
+ text-decoration: line-through;
125
+ text-decoration-color: var(--dt-annotation-deletion, #f85149);
126
+ color: var(--dt-annotation-deletion, #f85149);
127
+ border-radius: 2px;
128
+ cursor: pointer;
129
+ transition: opacity 0.2s ease;
130
+ }
131
+ mark.hl-COMMENT:hover, mark.hl-DELETION:hover {
132
+ opacity: 0.8;
133
+ }
134
+ mark.hl-COMMENT.hl-selected {
135
+ opacity: 1 !important;
136
+ outline: 2px solid var(--dt-annotation-comment, #58a6ff);
137
+ outline-offset: 1px;
138
+ border-radius: 3px;
139
+ }
140
+ mark.hl-DELETION.hl-selected {
141
+ opacity: 1 !important;
142
+ outline: 2px solid var(--dt-annotation-deletion, #f85149);
143
+ outline-offset: 1px;
144
+ border-radius: 3px;
145
+ }
146
+ mark.annotation-pulse {
147
+ animation: annotation-pulse 0.6s ease;
148
+ }
149
+ @keyframes annotation-pulse {
150
+ 0% { transform: scale(1); }
151
+ 50% { transform: scale(1.05); }
152
+ 100% { transform: scale(1); }
153
+ }
154
+ `,document.head.appendChild(i)}var y=class{constructor(t,e){d(this,"container");d(this,"store");d(this,"unsubscribe",null);this.container=t,this.store=e}start(){B(),this.unsubscribe=this.store.subscribe(t=>{switch(t.type){case"annotation-added":this.createHighlight(t.annotation);break;case"annotation-removed":this.removeHighlight(t.id);break;case"selection-changed":this.updateSelection(t.id),t.id!==null&&this.scrollToAnnotation(t.id);break}})}stop(){this.unsubscribe?.(),this.unsubscribe=null,this.clearAll()}findTextNodeRange(t,e,n){let r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null),a=0,o=null,s=0,l=null,p=0,c=r.nextNode();for(;c;){let f=(c.textContent||"").length,u=a+f;if(o===null&&u>e&&(o=c,s=e-a),u>=n){l=c,p=n-a;break}a=u,c=r.nextNode()}if(!o||!l)return null;let m=document.createRange();return m.setStart(o,Math.min(s,(o.textContent||"").length)),m.setEnd(l,Math.min(p,(l.textContent||"").length)),m}createHighlight(t){let e=this.container.querySelector(`[data-block-id="${t.blockId}"]`);if(!e){console.warn(`[HighlightManager] Block not found for annotation ${t.id}: ${t.blockId}`);return}let n=this.findTextNodeRange(e,t.startOffset,t.endOffset);if(!n){console.warn(`[HighlightManager] Could not resolve text range for annotation ${t.id}`);return}let r=document.createElement("mark");r.className=`hl-${t.type}`,r.dataset.annotationId=t.id,r.addEventListener("click",()=>{this.store.select(t.id)});try{n.surroundContents(r)}catch{try{if(n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.splitText(n.endOffset),n.startContainer.nodeType===Node.TEXT_NODE){let a=n.startContainer;n.startOffset>0&&a.splitText(n.startOffset);let o=document.createRange();o.setStart(a.nextSibling||a,0),o.setEnd(n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.previousSibling||n.endContainer,n.endOffset),o.surroundContents(r)}else throw new Error("Non-text range")}catch{let a=n.extractContents();r.append(a),n.insertNode(r)}}}removeHighlight(t){let e=this.container.querySelector(`mark[data-annotation-id="${t}"]`);if(!e)return;let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e),n.nodeType===Node.ELEMENT_NODE&&n.normalize()}}updateSelection(t){let e=this.container.querySelectorAll("mark[data-annotation-id]");for(let n of e)n.classList.toggle("hl-selected",n.dataset.annotationId===t)}scrollToAnnotation(t){let e=this.container.querySelector(`mark[data-annotation-id="${t}"]`);e&&(e.scrollIntoView({behavior:"smooth",block:"center"}),e.classList.add("annotation-pulse"),setTimeout(()=>{e.classList.remove("annotation-pulse")},600))}clearAll(){let t=this.container.querySelectorAll("mark[data-annotation-id]");for(let e of t){let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e),n.nodeType===Node.ELEMENT_NODE&&n.normalize()}}}};var I=new Set(["button","input","textarea","select"]),E=class{constructor(t){d(this,"options");d(this,"boundHandleMouseUp");this.options=t,this.boundHandleMouseUp=this.handleMouseUp.bind(this),this.options.container.addEventListener("mouseup",this.boundHandleMouseUp,{passive:!0})}destroy(){this.options.container.removeEventListener("mouseup",this.boundHandleMouseUp)}handleMouseUp(t){if(this.options.mode()==="selection")return;let e=t.target;if(!e||this.isExcludedElement(e))return;let n=this.getSelectionRange();if(!n)return;let r=this.findBlockId(n.startContainer);if(!r)return;let a=this.findBlockContainer(n.startContainer),o=this.findBlockContainer(n.endContainer);if(a!==o)return;let s=this.computeBlockOffset(n.startContainer,n.startOffset),l=this.computeBlockOffset(n.endContainer,n.endOffset);if(s===null||l===null)return;let p={blockId:r,startOffset:s,endOffset:l,text:n.toString(),range:n};this.options.onSelection(p),this.clearSelection()}getSelectionRange(){let t=window.getSelection();return!t||t.isCollapsed||t.rangeCount===0?null:t.getRangeAt(0)}findBlockId(t){let e=t;for(;e;){if(e instanceof HTMLElement&&e.hasAttribute("data-block-id"))return e.getAttribute("data-block-id");e=e.parentNode}return null}computeBlockOffset(t,e){let n=this.findBlockContainer(t);if(!n)return null;let r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null),a=0,o=r.nextNode();for(;o;){if(o===t)return a+e;a+=(o.textContent||"").length,o=r.nextNode()}return null}findBlockContainer(t){let e=t;for(;e;){if(e instanceof HTMLElement&&e.hasAttribute("data-block-id"))return e;e=e.parentNode}return null}clearSelection(){let t=window.getSelection();t&&t.removeAllRanges()}isExcludedElement(t){let e=t;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e?I.has(e.tagName.toLowerCase()):!1}};var D="aikit-annotation-sidebar",R=`
155
+ .as-sidebar {
156
+ width: var(--dt-annotation-sidebar-width, 300px);
157
+ background: var(--dt-bg-secondary);
158
+ border-left: 1px solid var(--dt-border-default);
159
+ display: flex;
160
+ flex-direction: column;
161
+ box-sizing: border-box;
162
+ flex-shrink: 0;
163
+ }
164
+
165
+ .as-header {
166
+ display: flex;
167
+ align-items: center;
168
+ gap: 8px;
169
+ padding: var(--dt-space-3);
170
+ border-bottom: 1px solid var(--dt-border-default);
171
+ flex-shrink: 0;
172
+ }
173
+
174
+ .as-header-title {
175
+ font-size: var(--dt-font-size-base);
176
+ font-weight: 600;
177
+ color: var(--dt-text-primary);
178
+ }
179
+
180
+ .as-count-badge {
181
+ font-size: var(--dt-font-size-xs);
182
+ font-weight: 600;
183
+ color: var(--dt-text-secondary);
184
+ background: var(--dt-bg-primary);
185
+ border: 1px solid var(--dt-border-default);
186
+ border-radius: 999px;
187
+ padding: 1px 8px;
188
+ line-height: 1.4;
189
+ }
190
+
191
+ .as-header-spacer {
192
+ flex: 1;
193
+ }
194
+
195
+ /* \u2500\u2500 Feedback toggle in header \u2500\u2500 */
196
+ .as-mode-toggle {
197
+ display: inline-flex;
198
+ align-items: center;
199
+ gap: 4px;
200
+ padding: 4px 8px;
201
+ border-radius: var(--dt-radius-sm);
202
+ border: 1px solid var(--dt-border-default);
203
+ background: transparent;
204
+ color: var(--dt-text-secondary);
205
+ font-size: var(--dt-font-size-xs);
206
+ cursor: pointer;
207
+ transition: background var(--dt-transition-fast), border-color var(--dt-transition-fast), color var(--dt-transition-fast);
208
+ }
209
+ .as-mode-toggle:hover {
210
+ background: var(--dt-annotation-hover);
211
+ color: var(--dt-text-primary);
212
+ }
213
+ .as-mode-toggle--active {
214
+ border-color: var(--dt-accent-fg);
215
+ color: var(--dt-accent-fg);
216
+ background: var(--dt-accent-subtle);
217
+ }
218
+
219
+ .as-close-btn {
220
+ background: none;
221
+ border: none;
222
+ cursor: pointer;
223
+ color: var(--dt-text-tertiary);
224
+ font-size: 16px;
225
+ line-height: 1;
226
+ padding: 2px 6px;
227
+ border-radius: var(--dt-radius-sm);
228
+ }
229
+ .as-close-btn:hover {
230
+ color: var(--dt-text-primary);
231
+ background: var(--dt-annotation-hover);
232
+ }
233
+
234
+ /* \u2500\u2500 Scrollable annotation list \u2500\u2500 */
235
+ .as-list {
236
+ flex: 1;
237
+ overflow-y: auto;
238
+ padding: var(--dt-space-2);
239
+ }
240
+
241
+ .as-card {
242
+ padding: var(--dt-space-2);
243
+ margin-bottom: var(--dt-space-2);
244
+ border: 1px solid var(--dt-border-default);
245
+ border-radius: var(--dt-radius-md);
246
+ background: var(--dt-bg-primary);
247
+ cursor: pointer;
248
+ transition: background 0.15s;
249
+ position: relative;
250
+ }
251
+
252
+ .as-card--COMMENT {
253
+ border-left: 2px solid var(--dt-annotation-comment, #58a6ff);
254
+ }
255
+ .as-card--DELETION {
256
+ border-left: 2px solid var(--dt-annotation-deletion, #f85149);
257
+ }
258
+
259
+ .as-card:hover {
260
+ background: var(--dt-annotation-hover);
261
+ }
262
+
263
+ .as-card--COMMENT.as-card--selected {
264
+ outline: 2px solid var(--dt-annotation-comment, #58a6ff);
265
+ outline-offset: -2px;
266
+ }
267
+ .as-card--DELETION.as-card--selected {
268
+ outline: 2px solid var(--dt-annotation-deletion, #f85149);
269
+ outline-offset: -2px;
270
+ }
271
+
272
+ .as-card-excerpt {
273
+ font-size: var(--dt-font-size-sm);
274
+ color: var(--dt-text-primary);
275
+ font-family: var(--dt-font-mono);
276
+ overflow: hidden;
277
+ text-overflow: ellipsis;
278
+ white-space: nowrap;
279
+ max-width: 100%;
280
+ }
281
+
282
+ .as-card-comment {
283
+ font-size: var(--dt-font-size-sm);
284
+ color: var(--dt-text-secondary);
285
+ margin-top: 4px;
286
+ overflow: hidden;
287
+ text-overflow: ellipsis;
288
+ white-space: nowrap;
289
+ max-width: 100%;
290
+ }
291
+
292
+ /* Expanded comment detail \u2014 shown when card is clicked */
293
+ .as-card-comment-detail {
294
+ display: none;
295
+ margin-top: 6px;
296
+ padding: var(--dt-space-2);
297
+ border: 1px solid var(--dt-border-muted);
298
+ border-radius: var(--dt-radius-sm);
299
+ background: var(--dt-bg-secondary);
300
+ font-size: var(--dt-font-size-sm);
301
+ color: var(--dt-text-primary);
302
+ line-height: 1.5;
303
+ word-break: break-word;
304
+ white-space: pre-wrap;
305
+ max-height: 200px;
306
+ overflow-y: auto;
307
+ }
308
+ .as-card-comment-detail--open {
309
+ display: block;
310
+ }
311
+
312
+ .as-delete-btn {
313
+ position: absolute;
314
+ top: 4px;
315
+ right: 4px;
316
+ background: none;
317
+ border: none;
318
+ cursor: pointer;
319
+ color: var(--dt-text-tertiary);
320
+ font-size: 14px;
321
+ line-height: 1;
322
+ padding: 2px 4px;
323
+ border-radius: var(--dt-radius-sm);
324
+ }
325
+ .as-delete-btn:hover {
326
+ color: var(--dt-annotation-deletion);
327
+ background: var(--dt-annotation-hover);
328
+ }
329
+
330
+ .as-empty {
331
+ text-align: center;
332
+ color: var(--dt-text-tertiary);
333
+ font-size: var(--dt-font-size-sm);
334
+ padding: var(--dt-space-6) var(--dt-space-2);
335
+ }
336
+ `,z='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/></svg>',k=class{constructor(t){d(this,"el");d(this,"store");d(this,"exporter");d(this,"unsubscribe",null);d(this,"listEl");d(this,"modeToggleBtn");this.store=t.store,this.exporter=t.exporter,this.el=this.render(),this.listEl=this.el.querySelector(".as-list"),this.modeToggleBtn=this.el.querySelector(".as-mode-toggle"),this.unsubscribe=this.store.subscribe(n=>{switch(n.type){case"annotation-added":case"annotation-removed":case"annotation-updated":this.renderList(),this.updateHeader();break;case"selection-changed":this.updateCardSelection(n.id);break;case"sidebar-toggled":this.updateVisibility();break;case"mode-changed":this.updateModeToggle();break}}),(t.mountTarget??document.body).appendChild(this.el),this.updateVisibility(),this.updateModeToggle()}destroy(){this.unsubscribe?.(),this.el.remove()}render(){v(D,R);let t=document.createElement("div");t.className="as-sidebar",t.setAttribute("role","complementary"),t.setAttribute("aria-label","Annotations");let e=this.exporter.getTotalCount();return t.innerHTML=`
337
+ <div class="as-header">
338
+ <span class="as-header-title">Annotations</span>
339
+ <span class="as-count-badge" aria-live="polite">${e.total}</span>
340
+ <span class="as-header-spacer"></span>
341
+ <button class="as-mode-toggle" aria-label="Toggle annotation mode">${z} Feedback</button>
342
+ <button class="as-close-btn" aria-label="Close sidebar">&times;</button>
343
+ </div>
344
+ <div class="as-list" role="list" aria-label="Annotation list"></div>
345
+ `,t.querySelector(".as-close-btn").addEventListener("click",a=>{a.stopPropagation(),this.store.toggleSidebar(!1)}),t.querySelector(".as-mode-toggle").addEventListener("click",a=>{a.stopPropagation();let o=this.store.getState().mode==="feedback"?"selection":"feedback";this.store.setMode(o)}),t}renderList(){let e=this.store.getState().annotations;if(this.listEl.innerHTML="",e.length===0){let r=document.createElement("div");r.className="as-empty",r.textContent="No annotations yet. Select text in Feedback mode.",this.listEl.appendChild(r);return}let n=[...e].sort((r,a)=>a.createdAt-r.createdAt);for(let r of n)this.listEl.appendChild(this.renderAnnotationItem(r))}renderAnnotationItem(t){let e=document.createElement("div");e.className=`as-card as-card--${t.type}`,e.dataset.annotationId=t.id,this.store.getState().selectedId===t.id&&e.classList.add("as-card--selected");let r=t.originalText.length>60?`${t.originalText.slice(0,60)}\u2026`:t.originalText;return e.innerHTML=`
346
+ <div class="as-card-excerpt">${g(r)}</div>
347
+ ${t.comment?`<div class="as-card-comment">${g(t.comment)}</div>`:""}
348
+ <div class="as-card-comment-detail">${t.comment?g(t.comment):'<em style="color:var(--dt-text-tertiary)">No comment \u2014 marked text only</em>'}</div>
349
+ <button class="as-delete-btn" aria-label="Delete annotation">&times;</button>
350
+ `,e.addEventListener("click",()=>{this.store.select(t.id);let o=e.querySelector(".as-card-comment-detail");if(o){o.classList.toggle("as-card-comment-detail--open");let s=this.listEl.querySelectorAll(".as-card-comment-detail--open");for(let l of s)l!==o&&l.classList.remove("as-card-comment-detail--open")}}),e.querySelector(".as-delete-btn").addEventListener("click",o=>{o.stopPropagation(),this.handleDelete(t.id)}),e}handleDelete(t){this.store.remove(t)}updateVisibility(){let t=this.store.getState();this.el.style.display=t.isSidebarOpen?"flex":"none"}updateHeader(){let t=this.el.querySelector(".as-count-badge");if(t){let e=this.exporter.getTotalCount();t.textContent=String(e.total)}}updateModeToggle(){let t=this.store.getState().mode==="feedback";this.modeToggleBtn.classList.toggle("as-mode-toggle--active",t),this.modeToggleBtn.setAttribute("aria-pressed",String(t)),this.modeToggleBtn.setAttribute("aria-label",t?"Disable annotation mode":"Enable annotation mode")}updateCardSelection(t){let e=this.el.querySelectorAll(".as-card");for(let n of e){let r=n.dataset.annotationId;n.classList.toggle("as-card--selected",r!==void 0&&r===t)}}};var T=class{constructor(){d(this,"annotations",[]);d(this,"selectedId",null);d(this,"mode","selection");d(this,"isSidebarOpen",!1);d(this,"subscribers",new Set);d(this,"idCounter",0)}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(t){for(let e of this.subscribers)e(t)}generateId(){return this.idCounter+=1,`ann-${this.idCounter}`}openSidebar(){this.isSidebarOpen=!0,this.notify({type:"sidebar-toggled",open:!0})}add(t,e,n,r,a,o,s,l,p){let c={id:this.generateId(),type:t,blockId:e,startOffset:n,endOffset:r,originalText:a,comment:o,section:s,contextBefore:l,contextAfter:p,createdAt:Date.now()};return this.annotations.push(c),this.annotations.length===1&&(this.isSidebarOpen=!0,this.notify({type:"sidebar-toggled",open:!0})),this.notify({type:"annotation-added",annotation:c}),c}update(t,e){let n=this.annotations.find(r=>r.id===t);n&&(Object.assign(n,e),this.notify({type:"annotation-updated",id:t,changes:e}))}remove(t){let e=this.annotations.findIndex(n=>n.id===t);e!==-1&&(this.annotations.splice(e,1),this.notify({type:"annotation-removed",id:t}))}select(t){this.selectedId=t,this.notify({type:"selection-changed",id:t})}setMode(t){t!==this.mode&&(this.mode=t,this.notify({type:"mode-changed",mode:t}))}toggleSidebar(t){this.isSidebarOpen=t!==void 0?t:!this.isSidebarOpen,this.notify({type:"sidebar-toggled",open:this.isSidebarOpen})}getState(){return{annotations:[...this.annotations],selectedId:this.selectedId,mode:this.mode,isSidebarOpen:this.isSidebarOpen}}destroy(){this.subscribers.clear(),this.annotations=[],this.selectedId=null,this.mode="selection",this.isSidebarOpen=!1,this.idCounter=0}};var L=25,$="aikit-annotation-guide",j=`
351
+ .as-guide {
352
+ margin: 0 0 var(--dt-space-3) 0;
353
+ padding: var(--dt-space-2) var(--dt-space-3);
354
+ border: 1px solid var(--dt-border-default);
355
+ border-radius: var(--dt-radius-md);
356
+ background: var(--dt-bg-secondary);
357
+ font-family: var(--dt-font-mono);
358
+ font-size: var(--dt-font-size-xs);
359
+ color: var(--dt-text-secondary);
360
+ line-height: 1.5;
361
+ display: none;
362
+ flex-shrink: 0;
363
+ }
364
+ .as-guide--visible {
365
+ display: block;
366
+ }
367
+ `;function q(i){let{range:t}=i,e,n=t.startContainer;for(;n;){if(n instanceof HTMLElement&&n.tagName.toLowerCase().match(/^h[1-6]$/)){e=n.textContent?.trim()||void 0;break}n=n.parentNode}let r,a;try{if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset>0){let o=t.startContainer.textContent||"",s=Math.max(0,t.startOffset-L);r=o.slice(s,t.startOffset)}if(t.endContainer.nodeType===Node.TEXT_NODE&&t.endOffset<(t.endContainer.textContent?.length||0)){let o=t.endContainer.textContent||"",s=Math.min(o.length,t.endOffset+L);a=o.slice(t.endOffset,s)}}catch{}return{section:e,contextBefore:r,contextAfter:a}}function w(i){let{container:t,mountTarget:e}=i,n=null,r=new T;r.setMode("feedback");let a=new x(r);v($,j);let o=document.createElement("div");o.className="as-guide",o.textContent="\u27B3 Ready. Select text to annotate or disable Feedback in the sidebar.",t.prepend(o);let s=()=>{let m=r.getState();o.classList.toggle("as-guide--visible",m.mode==="feedback"&&m.annotations.length===0)};s(),r.subscribe(()=>s());let l=new y(t,r);l.start();let p=new E({container:t,mode:()=>r.getState().mode,onSelection:m=>{let f=q(m);n?.destroy();let u=new b(m,{onSubmit:(h,S)=>{r.add("COMMENT",h.blockId,h.startOffset,h.endOffset,h.text,S||void 0,f.section,f.contextBefore,f.contextAfter),u.destroy(),n===u&&(n=null)},onRemove:(h,S)=>{r.add("DELETION",h.blockId,h.startOffset,h.endOffset,h.text,S||void 0,f.section,f.contextBefore,f.contextAfter),u.destroy(),n===u&&(n=null)},onDismiss:()=>{u.destroy(),n===u&&(n=null)}});n=u}}),c=new k({store:r,exporter:a,mountTarget:e});return r.openSidebar(),{destroy(){n?.destroy(),n=null,o.remove(),p.destroy(),l.stop(),c.destroy(),r.destroy()},getStore(){return r},getExporter(){return a}}}document.addEventListener("DOMContentLoaded",()=>{let i=document.querySelector(".main-content")||document.querySelector("main")||document.querySelector(".content");if(!i)return;let t=i.parentElement;t?.classList.contains("main-layout")||(t=document.createElement("div"),t.className="main-layout",i.parentNode?.insertBefore(t,i),t.appendChild(i));let e=i.parentElement;e&&!e.classList.contains("content-column")&&(e=document.createElement("div"),e.className="content-column",i.parentNode?.insertBefore(e,i),e.appendChild(i),t.appendChild(e));let n=w({container:i,mountTarget:t});window.__annotationLayer=n});})();
@@ -5,4 +5,4 @@ import{fileURLToPath as e,pathToFileURL as t}from"node:url";import{parseArgs as
5
5
  `).length,fileHash:this.hash(e.content),indexedAt:t,origin:`curated`,tags:e.frontmatter.tags,category:e.frontmatter.category,version:e.frontmatter.version}});try{return await this.store.upsert(i,r),e.length}catch(t){R.error(`Failed to upsert curated batch`,{batchSize:e.length,...a(t)});for(let t of e)n.push(`${t.relativePath}: upsert failed`);return 0}}catch(r){if(e.length===1)return R.error(`Failed to embed curated item`,{relativePath:e[0].relativePath,...a(r)}),n.push(`${e[0].relativePath}: reindex failed`),0;R.warn(`Curated embed batch failed, retrying with smaller chunks`,{batchSize:e.length,...a(r)});let i=Math.ceil(e.length/2),o=e.slice(0,i),s=e.slice(i);return await this.embedAndUpsertBatch(o,t,n)+await this.embedAndUpsertBatch(s,t,n)}}gitCommitKnowledge(e,t,n){try{if(!p(this.curatedDir))return;let r=this.knowledgeRefForPath(e);if(!r)return;m(r,`entry.md`,t,n,this.curatedDir)}catch{}}gitDeleteKnowledgeRef(e){try{if(!p(this.curatedDir))return;let t=this.knowledgeRefForPath(e);if(!t)return;h([`update-ref`,`-d`,t],this.curatedDir)}catch{}}knowledgeRefForPath(e){let t=e.replace(/\.md$/,``).split(`/`).map(e=>g(e)).join(`/`);return t.split(`/`).every(e=>f.test(e))?`${L}/${t}`:null}async indexCuratedFile(e,t,n){let r=await this.embedder.embed(t),i=`.ai/curated/${e}`,a=new Date().toISOString(),o={id:this.hashId(i,0),content:t,sourcePath:i,contentType:`curated-knowledge`,headingPath:n.title,chunkIndex:0,totalChunks:1,startLine:1,endLine:t.split(`
6
6
  `).length,fileHash:this.hash(t),indexedAt:a,origin:`curated`,tags:n.tags,category:n.category,version:n.version};await this.store.upsert([o],[r])}async indexCuratedFileBestEffort(e,t,n,i){if(r.instance().isDegraded(`embedder`)){R.debug(`Skipping vector indexing — embedder degraded`,{relativePath:e,operation:i,subsystem:`embedder`});return}try{await this.indexCuratedFile(e,t,n)}catch(t){R.warn(`Curated file persisted but vector indexing deferred`,{relativePath:e,operation:i,...a(t)})}}async discoverCategories(){return this.adapter.listDirectories()}guardPath(e){let t=e.replace(/^\.ai\/curated\//,``);if(t.endsWith(`.md`)||(t+=`.md`),t.includes(`..`)||c(t))throw Error(`Invalid path: ${t}. Must be relative within .ai/curated/ directory.`);let n=t.split(`/`)[0];return this.validateCategoryName(n),t}validateCategoryName(e){if(!/^[a-z][a-z0-9-]*$/.test(e))throw Error(`Invalid category name: "${e}". Must be lowercase kebab-case (e.g., "decisions", "api-contracts").`)}validateContentSize(e){if(Buffer.byteLength(e,`utf-8`)>I)throw Error(`Content exceeds maximum size of ${I/1024}KB`)}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,80)}normalizeTags(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}sameTags(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}ensureCategoryPath(e,t){if(!e.startsWith(`${t}/`))throw Error(`Curated path "${e}" must stay within category "${t}"`)}async uniqueRelativePath(e,t){let n=`${e}/${t}.md`;if(!await this.adapter.exists(n))return n;for(let n=2;n<=100;n++){let r=`${e}/${t}-${n}.md`;if(!await this.adapter.exists(r))return r}throw Error(`Too many entries with slug "${t}" in category "${e}"`)}hash(e){return d(`sha256`).update(e).digest(`hex`).slice(0,16)}hashId(e,t){return this.hash(`${e}::${t}`)}serializeFile(e,t){return`${[`---`,`title: "${t.title.replace(/"/g,`\\"`)}"`,`category: ${t.category}`,`tags: [${t.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${t.created}`,`updated: ${t.updated}`,`version: ${t.version}`,`origin: ${t.origin}`,`changelog:`,...t.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
7
7
  `)}\n\n${e}\n`}parseFile(e){let t=e.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);if(!t)return{frontmatter:{title:`Untitled`,category:`notes`,tags:[],created:``,updated:``,version:1,origin:`curated`,changelog:[]},content:e};let n=t[1],r=t[2].trim(),i={},a=[],o=n.split(`
8
- `),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const B=i(`server`);function V(e,t){return t?{version:e,...a(t)}:{version:e}}function H(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function U(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function W(){return U()?n({allowPositionals:!0,options:{transport:{type:`string`,default:H()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:H(),port:process.env.AIKIT_PORT??`3210`}}async function G(){let e=C(),t=W();if(process.on(`unhandledRejection`,t=>{B.error(`Unhandled rejection`,V(e,t))}),process.on(`uncaughtException`,t=>{B.error(`Uncaught exception — exiting`,V(e,t)),process.exit(1)}),B.info(`Starting MCP AI Kit server`,{version:e}),t.transport===`http`){let{startHttpMode:n}=await import(`./server-http-GaLD7IIy.js`);await n(e,t.port)}else{let{startStdioMode:t}=await import(`./server-stdio-fTUlwk5u.js`);await t(e)}}G();export{w as a,O as i,F as n,T as o,P as r,D as s,z as t};
8
+ `),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const B=i(`server`);function V(e,t){return t?{version:e,...a(t)}:{version:e}}function H(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function U(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function W(){return U()?n({allowPositionals:!0,options:{transport:{type:`string`,default:H()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:H(),port:process.env.AIKIT_PORT??`3210`}}async function G(){let e=C(),t=W();if(process.on(`unhandledRejection`,t=>{B.error(`Unhandled rejection`,V(e,t))}),process.on(`uncaughtException`,t=>{B.error(`Uncaught exception — exiting`,V(e,t)),process.exit(1)}),B.info(`Starting MCP AI Kit server`,{version:e}),t.transport===`http`){let{startHttpMode:n}=await import(`./server-http-DffHa_R7.js`);await n(e,t.port)}else{let{startStdioMode:t}=await import(`./server-stdio-BCmXwa7R.js`);await t(e)}}G();export{w as a,O as i,F as n,T as o,P as r,D as s,z as t};
@@ -1 +1 @@
1
- import{a as e,i as t,n,r,t as i}from"./server-utils-De-aZNQa.js";import{n as a,r as o,t as s}from"./workspace-bootstrap-BPWA6BVf.js";import{t as c}from"./curated-manager-BrgM_znO.js";import{pathToFileURL as l}from"node:url";import{parseArgs as u}from"node:util";import{createLogger as d,serializeError as f}from"../../core/dist/index.js";const p=d(`server`);function m(e,t){return t?{version:e,...f(t)}:{version:e}}function h(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function g(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function _(){return g()?u({allowPositionals:!0,options:{transport:{type:`string`,default:h()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:h(),port:process.env.AIKIT_PORT??`3210`}}async function v(){let e=t(),n=_();if(process.on(`unhandledRejection`,t=>{p.error(`Unhandled rejection`,m(e,t))}),process.on(`uncaughtException`,t=>{p.error(`Uncaught exception — exiting`,m(e,t)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:e}),n.transport===`http`){let{startHttpMode:t}=await import(`./server-http-D34e6iap.js`);await t(e,n.port)}else{let{startStdioMode:t}=await import(`./server-stdio-BCpG8h95.js`);await t(e)}}export{c as CuratedKnowledgeManager,s as applyWorkspaceRoots,a as bootstrapWorkspaceRoots,i as createSlidingWindowRateLimiter,n as getSessionIdHeader,v as main,r as readPositiveIntEnv,t as readVersion,e as resolveCorsOrigin,o as selectWorkspaceRoot};
1
+ import{a as e,i as t,n,r,t as i}from"./server-utils-De-aZNQa.js";import{n as a,r as o,t as s}from"./workspace-bootstrap-BPWA6BVf.js";import{t as c}from"./curated-manager-BrgM_znO.js";import{pathToFileURL as l}from"node:url";import{parseArgs as u}from"node:util";import{createLogger as d,serializeError as f}from"../../core/dist/index.js";const p=d(`server`);function m(e,t){return t?{version:e,...f(t)}:{version:e}}function h(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function g(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function _(){return g()?u({allowPositionals:!0,options:{transport:{type:`string`,default:h()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:h(),port:process.env.AIKIT_PORT??`3210`}}async function v(){let e=t(),n=_();if(process.on(`unhandledRejection`,t=>{p.error(`Unhandled rejection`,m(e,t))}),process.on(`uncaughtException`,t=>{p.error(`Uncaught exception — exiting`,m(e,t)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:e}),n.transport===`http`){let{startHttpMode:t}=await import(`./server-http-DVx48qhg.js`);await t(e,n.port)}else{let{startStdioMode:t}=await import(`./server-stdio-D_r13voI.js`);await t(e)}}export{c as CuratedKnowledgeManager,s as applyWorkspaceRoots,a as bootstrapWorkspaceRoots,i as createSlidingWindowRateLimiter,n as getSessionIdHeader,v as main,r as readPositiveIntEnv,t as readVersion,e as resolveCorsOrigin,o as selectWorkspaceRoot};