makecoder 4.0.31 → 4.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cc.mjs +2 -2
- package/dist/coder.js +12 -12
- package/dist/darwin-arm64/cc.js +3 -3
- package/dist/darwin-x64/cc.js +3 -3
- package/dist/linux-x64/cc.js +3 -3
- package/dist/win32-x64/cc.js +3 -3
- package/package.json +4 -4
package/dist/cc.mjs
CHANGED
|
@@ -20,13 +20,13 @@ import{createRequire as vP5}from"node:module";var MP5=Object.create;var{getProto
|
|
|
20
20
|
Object.assign(A, {
|
|
21
21
|
post(...args) {
|
|
22
22
|
const [url, payload, ...remainArgs] = args;
|
|
23
|
-
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.
|
|
23
|
+
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.32' + '&session_id=' + I8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
|
|
24
24
|
if (process.env.CODER_APIKEY) {
|
|
25
25
|
const headerValues = payload.headers.values;
|
|
26
26
|
headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
payload.headers.values.set('X-Coder-Version', '4.0.
|
|
29
|
+
payload.headers.values.set('X-Coder-Version', '4.0.32');
|
|
30
30
|
payload.headers.values.set('X-Coder-Platform', process.platform);
|
|
31
31
|
payload.headers.values.set('X-Coder-Arch', process.arch);
|
|
32
32
|
|
package/dist/coder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var It=Object.create;var ve=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var m=(h,e)=>()=>(e||h((e={exports:{}}).exports,e),e.exports);var Dt=(h,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vt(e))!$t.call(h,o)&&o!==t&&ve(h,o,{get:()=>e[o],enumerable:!(s=Et(e,o))||s.enumerable});return h};var Pt=(h,e,t)=>(t=h!=null?It(xt(h)):{},Dt(e||!h||!h.__esModule?ve(t,"default",{value:h,enumerable:!0}):t,h));var q=m((ks,_t)=>{_t.exports={name:"makecoder",version:"4.0.
|
|
2
|
+
var It=Object.create;var ve=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var m=(h,e)=>()=>(e||h((e={exports:{}}).exports,e),e.exports);var Dt=(h,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of vt(e))!$t.call(h,o)&&o!==t&&ve(h,o,{get:()=>e[o],enumerable:!(s=Et(e,o))||s.enumerable});return h};var Pt=(h,e,t)=>(t=h!=null?It(xt(h)):{},Dt(e||!h||!h.__esModule?ve(t,"default",{value:h,enumerable:!0}):t,h));var q=m((ks,_t)=>{_t.exports={name:"makecoder",version:"4.0.32",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","codex","agent"],author:"makecoder",license:"MIT",repository:{type:"git",url:"https://github.com/makecoderai/coder.git"},homepage:"https://github.com/makecoderai/coder",dependencies:{"node-fetch":"^3.3.2",open:"^10.1.0",zod:"^3.25.76"},optionalDependencies:{bun:">=1.3.12"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","claude","scripts/postinstall.js"]}});var Pe=m((Ts,De)=>{var O=require("fs"),xe=require("path"),Ot=require("os"),kt=new Set(["auth","skills","wiki","channel"]),$e=new Set(["claude","gemini","codex"]),Tt=new Set(["pub","auth","update","skills","wiki","channel"]),Z=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=xe.join(Ot.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=xe.dirname(this.configPath);try{return O.existsSync(e)||O.mkdirSync(e,{recursive:!0}),O.existsSync(this.configPath)||O.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2)),JSON.parse(O.readFileSync(this.configPath,"utf8"))}catch{return{...this.defaultConfig}}}getApiKeyFromConfig(e){return e.auth?.apikey?e.auth.apikey:e.auth?.ak&&e.auth?.sk?`${e.auth.ak}.${e.auth.sk}`:null}saveAuthToConfig(e){let t=this.loadConfig();t.auth={apikey:e};try{return O.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth={apikey:null};try{return O.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch{return!1}}async parse(e=process.argv.slice(2)){let t=this.loadConfig(),s={agent:t.agent||"claude",remainingArgs:[]},o=0;if(e.length>0){if($e.has(e[0]))s.agent=e[0],s.agentSetBySubcommand=!0,o=1;else if(Tt.has(e[0])){if(s.command=e[0],o=1,e[0]==="auth"){let n=e[1];n==="--help"||n==="-h"?s.authSubcommand="--help":(s.authSubcommand=n,s.authRemainingArgs=e.slice(2)),o=e.length}else if(e[0]==="skills"){let n=e[1];s.skillsSubcommand=n==="--help"||n==="-h"?void 0:n,s.skillsArg=e[2],s.skillsRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="wiki"){let n=e[1];s.wikiSubcommand=n==="--help"||n==="-h"?void 0:n,s.wikiArg=e[2],s.wikiRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="channel"){let n=e[1];n==="--help"||n==="-h"?s.channelSubcommand="--help":n==="list"||n==="show"||n==="add"||n==="remove"||n==="update"?(s.channelSubcommand=n,s.channelArg=e[2],s.channelRemainingArgs=e.slice(2)):s.channelRemainingArgs=e.slice(1),o=e.length}}}for(;o<e.length;){let n=e[o];if(n==="--agent"){if(s.agentSetBySubcommand)throw new Error(`\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u5B50\u547D\u4EE4 '${s.agent}' \u548C --agent\uFF0C\u8BF7\u9009\u62E9\u5176\u4E00`);let i=e[o+1];if(!i||!$e.has(i))throw new Error("--agent \u9700\u8981\u6307\u5B9A\u4EE3\u7406\u7C7B\u578B\uFF08claude|gemini|codex\uFF09");s.agent=i,o+=2}else if(n==="--apikey"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--apikey \u9700\u8981\u63D0\u4F9B API Key \u503C");if(i.indexOf(".")===-1)throw new Error("API Key \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <ak>.<sk>");s.apikey=i,o+=2}else if(n==="--name"){let i=e[o+1];i&&!i.startsWith("--")?(s.pubName=i,o+=2):o+=1}else if(n==="--allow-clone")s.allowClone=!0,o+=1;else if(n==="--meta-data"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--meta-data \u9700\u8981\u4E00\u4E2A JSON \u5B57\u7B26\u4E32\u503C");try{JSON.parse(i)}catch(a){throw new Error(`--meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${a.message}`)}s.pubMetaData=i,o+=2}else{s.remainingArgs=e.slice(o);break}}if(s.command!=="auth"&&!s.apikey){let n=this.getApiKeyFromConfig(t);s.apikey=n||process.env.CODER_APIKEY||null}s.codevServer=process.env.CODEV_SERVER||t.codevServer||"https://makecoder.com/bigapis/codev/v1";let r=s.remainingArgs.includes("--version")||s.remainingArgs.includes("-v")||s.remainingArgs.includes("--help")||s.remainingArgs.includes("-h");return!kt.has(s.command)&&!r&&!s.apikey&&await this._oauthLogin(s),s}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
|
|
3
3
|
`),console.log("\u8BF7\u5148\u767B\u5F55:"),console.log(` coder auth login
|
|
4
4
|
`),console.log("\u6216\u76F4\u63A5\u63D0\u4F9B API Key:"),console.log(` coder auth login --apikey <your-api-key>
|
|
5
5
|
`),console.log(`\u83B7\u53D6 API Key: https://makecoder.com/my/apikeys
|
|
@@ -8,12 +8,12 @@ var It=Object.create;var ve=Object.defineProperty;var Et=Object.getOwnPropertyDe
|
|
|
8
8
|
Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
|
|
9
9
|
Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};ke.exports=ee});var se=m((qs,Te)=>{var g=process.env.CODEV_DEBUG==="True",te=class{constructor(e={}){this.queue=[],this.processing=!1,this.shuttingDown=!1,this.shutdownTimeout=e.shutdownTimeout||5e3,this.maxRetries=e.maxRetries||3,this.retryDelay=e.retryDelay||1e3,this.onProcessMessage=e.onProcessMessage||null,this.shutdownPromise=null,this.currentlyProcessing=null}enqueue(e){if(this.shuttingDown)return g&&console.log("Queue is shutting down, skipping new messages"),null;let t={id:Date.now()+Math.random(),data:e,timestamp:Date.now(),retryCount:0,processing:!1};return this.queue.push(t),g&&console.log(`Message enqueued, queue length: ${this.queue.length}`),this.processQueue(),t.id}dequeue(){let e=this.queue.shift();return g&&e&&console.log(`Message dequeued, remaining queue length: ${this.queue.length}`),e}removeById(e){let t=this.queue.findIndex(s=>s.id===e);return t>-1?(this.queue.splice(t,1),g&&console.log(`Message ${e} removed from queue`),!0):!1}async processQueue(){if(!(this.processing||this.queue.length===0)){this.processing=!0;try{for(;this.queue.length>0&&!this.shuttingDown;){let e=this.queue[0];e.processing=!0;try{this.onProcessMessage&&await this.onProcessMessage(e),this.dequeue()}catch(t){if(g&&console.error(`Failed to process message: ${t.message}`),e.retryCount++,g&&console.log("Start Retry:",e.retryCount,"times..."),e.retryCount>=this.maxRetries)g&&console.error("Message exceeded max retries, removing from queue"),this.dequeue();else{e.processing=!1;let s=this.shuttingDown?100:this.retryDelay*e.retryCount;await new Promise(o=>setTimeout(o,s))}}}}finally{this.processing=!1}}}getQueueSize(){return this.queue.length}clear(){this.queue=[],g&&console.log("Message queue cleared")}setMessageProcessor(e){this.onProcessMessage=e}async waitForProcessingMessages(e=5e3){let t=this.queue.filter(o=>o.processing);if(t.length===0)return;g&&console.log(`Waiting for ${t.length} processing messages to complete (timeout: ${e}ms)`);let s=Date.now();for(;Date.now()-s<e;){if(this.queue.filter(r=>r.processing).length===0){g&&console.log(`All processing messages completed in ${Date.now()-s}ms`);return}await new Promise(r=>setTimeout(r,50))}if(g){let o=this.queue.filter(r=>r.processing);console.log(`Timeout waiting for processing messages. ${o.length} messages still processing`)}}async gracefulShutdown(e={}){if(this.shutdownPromise)return this.shutdownPromise;let{timeoutMs:t=this.shutdownTimeout,batchSize:s=10,fastMode:o=!1}=e;return this.shutdownPromise=new Promise(async r=>{this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(t*.3,3e3));let n=this.queue.filter(p=>!p.processing),i=n.length;g&&(console.log(`Starting graceful shutdown with ${i} pending messages (${this.queue.length-i} already processing)`),console.log(`Mode: ${o?"fast (parallel)":"sequential"}, timeout: ${t}ms`));let a=Date.now(),c=0,l=0;try{if(o){let p=await this.processAllParallel(t-(Date.now()-a),n);c=p.processed,l=p.failed}else{let p=await this.processInBatches(s,t-(Date.now()-a),n);c=p.processed,l=p.failed}}catch(p){g&&console.error("Error during shutdown processing:",p.message)}let u=Date.now()-a,d=this.queue.length;g&&(console.log(`Shutdown completed in ${u}ms:`),console.log(` - Total: ${i} messages`),console.log(` - Processed: ${c}`),console.log(` - Failed: ${l}`),console.log(` - Remaining: ${d}`)),r({totalMessages:i,processedMessages:c,failedMessages:l,remainingMessages:d,duration:u,allMessagesSent:d===0&&l===0})}),this.shutdownPromise}async processAllParallel(e){if(this.queue.length===0)return{processed:0,failed:0};g&&console.log(`Processing ${this.queue.length} messages in parallel...`);let t=[...this.queue];this.queue=[];let s=t.map(async a=>{try{return this.onProcessMessage&&await this.onProcessMessage(a),{success:!0,messageId:a.id}}catch(c){return g&&console.warn(`Message ${a.id} processing failed: ${c.message}`),{success:!1,messageId:a.id,error:c}}}),o=new Promise(a=>{setTimeout(()=>a({timedOut:!0}),e)}),r=await Promise.race([Promise.allSettled(s).then(a=>({results:a})),o]);if(r.timedOut)return g&&console.log(`Parallel processing timed out after ${e}ms`),{processed:0,failed:t.length};let n=r.results.filter(a=>a.status==="fulfilled"&&a.value?.success).length,i=t.length-n;return{processed:n,failed:i}}async processInBatches(e,t){if(this.queue.length===0)return{processed:0,failed:0};g&&console.log(`Processing ${this.queue.length} messages in batches of ${e}...`);let s=Date.now(),o=0,r=0;for(;this.queue.length>0&&Date.now()-s<t;){let n=this.queue.splice(0,e),i=n.map(async u=>{try{return this.onProcessMessage&&await this.onProcessMessage(u),{success:!0}}catch(d){return g&&console.warn(`Batch message processing failed: ${d.message}`),{success:!1,error:d}}}),c=(await Promise.allSettled(i)).filter(u=>u.status==="fulfilled"&&u.value?.success).length,l=n.length-c;o+=c,r+=l,g&&n.length>0&&console.log(`Batch completed: ${c}/${n.length} successful`),this.queue.length>0&&await new Promise(u=>setTimeout(u,10))}return this.queue.length>0&&(r+=this.queue.length,g&&console.log(`${this.queue.length} messages not processed due to timeout`),this.queue=[]),{processed:o,failed:r}}async forceFlushAndShutdown(e=2e3){this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(e*.4,1e3));let t=this.queue.filter(a=>!a.processing);g&&console.log(`Force flush: attempting to send ${t.length} pending messages within ${e}ms (${this.queue.length-t.length} already processing)`);let s=Date.now(),o=t.map(async a=>{try{return this.onProcessMessage&&Date.now()-s<e?(await this.onProcessMessage(a),{success:!0,messageId:a.id}):{success:!1,messageId:a.id,reason:"timeout"}}catch(c){return{success:!1,messageId:a.id,error:c.message}}}),r=e-(Date.now()-s),n=new Promise(a=>{setTimeout(()=>a({timedOut:!0}),Math.max(100,r))}),i=await Promise.race([Promise.allSettled(o).then(a=>({results:a})),n]);if(t.forEach(a=>{let c=this.queue.findIndex(l=>l.id===a.id);c>-1&&this.queue.splice(c,1)}),this.processing=!1,i.timedOut)return g&&console.log(`Force flush timed out after ${e}ms`),{success:!1,reason:"timeout",attemptedCount:t.length};{let a=i.results.filter(c=>c.status==="fulfilled"&&c.value.success).length;return g&&console.log(`Force flush completed: ${a}/${t.length} messages sent`),{success:a===t.length,successCount:a,totalCount:t.length,results:i.results}}}forceShutdown(){this.shuttingDown=!0,this.queue=[],this.processing=!1,g&&console.log("Force shutdown: Queue cleared")}};Te.exports=te});var ne=m((Fs,qe)=>{var Ft=require("http"),Nt=require("https"),{URL:Ae}=require("url"),{version:Ut}=q(),Me=process.env.CODEV_DEBUG==="True",oe=class{constructor(e={}){this.baseUrl=e.baseUrl||"",this.timeout=e.timeout||3e4,this.defaultHeaders={"Content-Type":"application/json","User-Agent":`codev-cli/${Ut}`,...e.headers}}setBaseUrl(e){this.baseUrl=e}setDefaultHeaders(e){this.defaultHeaders={...this.defaultHeaders,...e}}async post(e,t,s={}){let o=this.resolveUrl(e),r={...this.defaultHeaders,...s.headers};return new Promise((n,i)=>{this.validateRequest(o,t,i);let a=this.serializeData(t,i);if(!a)return;r["Content-Length"]=Buffer.byteLength(a);let c=this.buildRequestOptions(o,"POST",r),l=this.getHttpModule(o);Me&&console.debug(`HTTP POST to ${o} with data length: ${a.length}`);let u=l.request(c,d=>{this.handleResponse(d,n,i)});this.attachErrorHandlers(u,o,i),u.setTimeout(this.timeout),u.write(a),u.end()})}resolveUrl(e){return e.startsWith("http")?e:`${this.baseUrl}${e.startsWith("/")?"":"/"}${e}`}validateRequest(e,t,s){return!e||typeof e!="string"?(s(new Error(`Invalid URL: ${e}`)),!1):t?!0:(s(new Error("No data provided for HTTP POST")),!1)}serializeData(e,t){try{return typeof e=="string"?e:JSON.stringify(e)}catch(s){return t(new Error(`Failed to serialize data: ${s.message}`)),null}}buildRequestOptions(e,t,s){let o=new Ae(e),r=o.protocol==="https:";return{hostname:o.hostname,port:o.port||(r?443:80),path:o.pathname+o.search,method:t,headers:s}}getHttpModule(e){return new Ae(e).protocol==="https:"?Nt:Ft}handleResponse(e,t,s){Me&&console.debug(`HTTP response status: ${e.statusCode}`);let o="";e.on("data",r=>{o+=r}),e.on("end",()=>{e.statusCode>=200&&e.statusCode<300?t({statusCode:e.statusCode,data:o,headers:e.headers}):s(new Error(`HTTP request returned status ${e.statusCode}: ${o}`))})}attachErrorHandlers(e,t,s){e.on("error",o=>{s(new Error(`HTTP POST request failed: ${o.message}`))}),e.on("timeout",()=>{s(new Error(`HTTP POST request timed out for URL: ${t}`)),e.destroy()})}};qe.exports=oe});var ie=m((Ns,Fe)=>{var re=class{constructor(){this.apikey=null}setCredentials(e){this.apikey=e||null}hasCredentials(){return!!this.apikey}generateAuthHeaders(){return this.apikey?{AUTHORIZATION:`Bearer ${this.apikey}`}:{}}clearCredentials(){this.apikey=null}};Fe.exports=re});var ce=m((Us,Ne)=>{var R=process.env.CODEV_DEBUG==="True",ae=class{constructor(e={}){this.currentSessionId=null,this.previousSessionId=null,this.onSessionSwitch=e.onSessionSwitch||null,this.terminateSignal=e.terminateSignal||"CODEV_TERMINATE_SIGNAL"}handleSessionSwitch(e){if(!e)return R&&console.warn("Received empty session ID"),!1;let t=this.previousSessionId!==null&&this.previousSessionId!==e;return t&&(R&&console.log(`Session switch detected: ${this.previousSessionId} -> ${e}`),this.onSessionSwitch&&this.onSessionSwitch({type:this.terminateSignal,reason:"User switch session",agent:"claude",previousSessionId:this.previousSessionId,newSessionId:e})),this.previousSessionId=this.currentSessionId,this.currentSessionId=e,t}getCurrentSessionId(){return this.currentSessionId}getPreviousSessionId(){return this.previousSessionId}hasActiveSession(){return!!this.currentSessionId}terminateCurrentSession(e="Session terminated",t=null,s=null){if(!this.hasActiveSession())return R&&console.log("No active session to terminate"),null;let o={type:this.terminateSignal,reason:s?`terminated by signal: ${s}`:e,code:t,signal:s,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId};return R&&console.log("Terminating session:",o),this.previousSessionId=null,this.currentSessionId=null,o}createErrorTermination(e){return this.hasActiveSession()?{type:this.terminateSignal,error:e.message,stack:e.stack,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId}:null}reset(){R&&console.log("Resetting session manager"),this.currentSessionId=null,this.previousSessionId=null}setSessionSwitchCallback(e){this.onSessionSwitch=e}getSessionInfo(){return{currentSessionId:this.currentSessionId,previousSessionId:this.previousSessionId,hasActiveSession:this.hasActiveSession()}}};Ne.exports=ae});var ue=m((Ls,Ue)=>{var T=require("fs"),F=require("path"),Lt=require("events"),Bt=require("crypto"),C=process.env.CODEV_DEBUG==="True",le=class extends Lt{constructor(e={}){super(),this.watchPaths=e.watchPaths||[],this.excludePatterns=e.excludePatterns||[/node_modules/,/\.git/,/\.DS_Store/,/\.tmp/,/\.log$/,/\.swp$/,/codev\.log/],this.includePatterns=e.includePatterns||[/\.(js|jsx|ts|tsx|py|java|c|cpp|h|hpp|go|rs|rb|php|html|css|scss|sass|less|json|xml|yaml|yml|md|txt)$/],this.watchers=new Map,this.isWatching=!1,this.debounceTimeout=e.debounceTimeout||300,this.pendingChanges=new Map,this.fileContentHashes=new Map,this.enableContentComparison=e.enableContentComparison!==!1,this.onFileChange=e.onFileChange||null}calculateFileHash(e){try{let t=T.readFileSync(e,"utf8");return Bt.createHash("sha256").update(t).digest("hex")}catch{return null}}hasContentChanged(e){if(!this.enableContentComparison)return!0;let t=this.calculateFileHash(e),s=this.fileContentHashes.get(e);return t===null?s!==void 0?(this.fileContentHashes.delete(e),!0):!1:s===void 0||t!==s?(this.fileContentHashes.set(e,t),!0):!1}preloadFileHashes(e){if(!(!this.enableContentComparison||!T.existsSync(e)))try{let t=T.readdirSync(e,{withFileTypes:!0});for(let s of t){let o=F.join(e,s.name);s.isFile()&&this.shouldWatchFile(o)?(this.calculateFileHash(o),this.fileContentHashes.set(o,this.calculateFileHash(o))):s.isDirectory()&&!this.shouldExcludeDirectory(o)&&this.preloadFileHashes(o)}}catch(t){C&&console.warn(`Failed to preload hashes for ${e}:`,t.message)}}shouldExcludeDirectory(e){let t=e.replace(/\\/g,"/");for(let s of this.excludePatterns)if(s.test(t)||s.test(F.basename(e)))return!0;return!1}startWatching(e=null){if(this.isWatching){C&&console.log("FileWatchService is already watching");return}let t=e||this.watchPaths;if(t.length===0){C&&console.log("No watch paths specified");return}this.isWatching=!0;for(let s of t)this.enableContentComparison&&this.preloadFileHashes(s),this.watchDirectory(s);C&&(console.log(`FileWatchService started watching ${t.length} paths`),this.enableContentComparison&&console.log(`Preloaded hashes for ${this.fileContentHashes.size} files`))}stopWatching(){if(this.isWatching){this.isWatching=!1;for(let[e,t]of this.watchers)try{t.close(),C&&console.log(`Stopped watching: ${e}`)}catch(s){C&&console.error(`Error stopping watcher for ${e}:`,s.message)}this.watchers.clear(),this.pendingChanges.clear(),this.fileContentHashes.clear(),C&&console.log("FileWatchService stopped watching all paths")}}watchDirectory(e){if(!T.existsSync(e)){C&&console.warn(`Watch path does not exist: ${e}`);return}if(!T.statSync(e).isDirectory()){C&&console.warn(`Watch path is not a directory: ${e}`);return}try{let s=T.watch(e,{recursive:!0,persistent:!1},(o,r)=>{if(!r)return;let n=F.join(e,r);this.handleFileChange(o,n,e)});this.watchers.set(e,s),C&&console.log(`Started watching directory: ${e}`),s.on("error",o=>{C&&console.error(`Watcher error for ${e}:`,o.message),this.watchers.delete(e)})}catch(s){C&&console.error(`Failed to start watching ${e}:`,s.message)}}handleFileChange(e,t,s){if(!this.shouldWatchFile(t))return;let o=`${e}:${t}`;this.pendingChanges.has(o)&&clearTimeout(this.pendingChanges.get(o)),this.pendingChanges.set(o,setTimeout(()=>{this.pendingChanges.delete(o),this.processFileChange(e,t,s)},this.debounceTimeout))}processFileChange(e,t,s){if(!this.isWatching)return;let o="modified",r=!1;try{T.statSync(t),r=!0,e==="rename"?o="created":e==="change"&&(o="modified")}catch{e==="rename"&&(o="deleted")}if(r&&(o==="modified"||o==="created")&&!this.hasContentChanged(t)){C&&console.log(`Ignoring false change for: ${F.relative(s,t)}`);return}!r&&o==="deleted"&&this.fileContentHashes.delete(t);let n={type:"CODEV_FILE_CHANGE_DETECTTED",data:{eventType:e,changeType:o,filePath:t,relativePath:F.relative(s,t),watchPath:s,fileExists:r,timestamp:Date.now(),sessionId:process.env.SESSION_ID||"default"}};if(C&&console.log(`File ${o}: ${n.data.relativePath}`),this.emit("fileChange",n),this.onFileChange&&typeof this.onFileChange=="function")try{this.onFileChange(n)}catch(i){C&&console.error("Error in file change callback:",i.message)}}shouldWatchFile(e){let t=F.basename(e),s=e.replace(/\\/g,"/");for(let o of this.excludePatterns)if(o.test(s)||o.test(t))return!1;if(this.includePatterns.length===0)return!0;for(let o of this.includePatterns)if(o.test(s)||o.test(t))return!0;return!1}addWatchPath(e){this.watchPaths.includes(e)||(this.watchPaths.push(e),this.isWatching&&this.watchDirectory(e))}removeWatchPath(e){let t=this.watchPaths.indexOf(e);if(t>-1&&(this.watchPaths.splice(t,1),this.watchers.has(e)))try{this.watchers.get(e).close(),this.watchers.delete(e),C&&console.log(`Removed watch path: ${e}`)}catch(s){C&&console.error(`Error removing watch path ${e}:`,s.message)}}getStatus(){return{isWatching:this.isWatching,watchPaths:[...this.watchPaths],activeWatchers:this.watchers.size,pendingChanges:this.pendingChanges.size}}setFileChangeCallback(e){this.onFileChange=e}};Ue.exports=le});var Be=m((js,Le)=>{var Rt=B(),jt=require("path"),Bs=require("fs"),Rs=require("os"),Wt=se(),Ht=ne(),Gt=ie(),zt=ce(),Vt=ue(),S=process.env.CODEV_DEBUG==="True",de=class extends Rt{constructor(){super({configDir:".",configFile:".claude.json",defaultModel:"Claude Sonnet 4.6",executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"codev",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:e,CLAUDE_CODE_ATTRIBUTION_HEADER:"0"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}}),this.fileWatchService=null,this.shutdownInProgress=!1,this.initializeServices()}initializeServices(){this.httpClient=new Ht({timeout:1e4}),this.authService=new Gt({validateCredentials:!1}),this.sessionManager=new zt({onSessionSwitch:e=>{this.sendTerminationMessage(e)}}),this.messageQueue=new Wt({maxRetries:2,retryDelay:500,shutdownTimeout:3e3,onProcessMessage:e=>this.processMessage(e)}),this.initializeFileWatchService()}resloveSettingFilePath(e){return jt.join(e,this.config.configDir,".claude","settings.json")}initializeFileWatchService(){if(!process.env.SESSION_ID){S&&console.log("FileWatchService disabled: SESSION_ID environment variable not found");return}try{this.fileWatchService=new Vt({watchPaths:this.getFileWatchPaths(),onFileChange:e=>this.handleFileChange(e),debounceTimeout:300}),S&&console.log("FileWatchService initialized with SESSION_ID:",process.env.SESSION_ID)}catch(e){S&&console.error("Failed to initialize FileWatchService:",e.message)}}getFileWatchPaths(){let e=[],t=process.cwd();e.push(t);let s=process.env.CODEV_WATCH_PATHS;if(s){let o=s.split(",").map(r=>r.trim());e.push(...o)}return e}handleFileChange(e){if(S&&console.log("File change detected:",e.data.relativePath),this.shutdownInProgress)return;let t={message:e,sessionId:e.data.sessionId||process.env.SESSION_ID};this.messageQueue.enqueue(t)}startFileWatching(){this.fileWatchService&&!this.fileWatchService.isWatching&&(this.fileWatchService.startWatching(),S&&console.log("File watching started"))}stopFileWatching(){this.fileWatchService&&this.fileWatchService.isWatching&&(this.fileWatchService.stopWatching(),S&&console.log("File watching stopped"))}onChildMessage(e){e&&e.type==="claude:send-msg"&&this.handleClaudeSendMessage(e.data),super.onChildMessage(e)}handleClaudeSendMessage(e){if(S&&console.log("Handling claude:send-msg message:",e),!e||typeof e!="object"){console.error(`handleClaudeSendMessage: Invalid message data. Expected object, got: ${typeof e}`);return}if(this.shutdownInProgress){S&&console.log("Shutdown in progress, ignoring new message");return}let t=e.sessionId||process.env.SESSION_ID;this.sessionManager.handleSessionSwitch(t),this.messageQueue.enqueue(e)}async processMessage(e){let t=e.data.message,s=e.data.sessionId||process.env.SESSION_ID;if(!s)throw new Error("No session ID available");let o;try{o=typeof t=="string"?JSON.parse(t):t}catch(i){throw new Error(`Failed to parse message data: ${i.message}`)}let r=`/conversations/${s}/@append?task_type=codev`,n=this.authService.hasCredentials()?this.authService.generateAuthHeaders():{};S&&(console.debug("Sending message to:",r),console.debug("Send Message: ",JSON.stringify(o))),e.type!=="CODEV_TERMINATE_SIGNAL"&&(this.sessionManager.currentSessionId=s)}sendTerminationMessage(e){let t={message:e,sessionId:e.sessionId||this.sessionManager.getCurrentSessionId()};this.messageQueue.enqueue(t)}async handleChildProcessExit(e,t){S&&console.log(`Child process exited with code: ${e}, signal: ${t}`),this.stopFileWatching();let s=this.messageQueue.getQueueSize(),o=this.sessionManager.terminateCurrentSession("process exited normally",e,t);if(o&&this.sendTerminationMessage(o),s>0||o){S&&console.log("Starting graceful shutdown of message queue...");try{let r=!t||t==="SIGTERM",n=this.messageQueue.getQueueSize(),i={timeoutMs:r?8e3:3e3,batchSize:Math.min(n,15),fastMode:!r||n>30};S&&console.log("Shutdown options:",i);let a=await this.messageQueue.gracefulShutdown(i);S&&console.log("Message queue shutdown completed:",a),a.failedMessages>0&&S&&console.warn(`Shutdown summary: ${a.processedMessages} sent, ${a.failedMessages} failed, ${a.remainingMessages} remaining`)}catch(r){S&&console.error("Error during message queue shutdown:",r.message)}}}handleChildProcessError(e){S&&console.error(`Child process error: ${e.message}`);let t=this.sessionManager.createErrorTermination(e);t&&this.sendTerminationMessage(t)}async forceFlushMessages(e=3e3){if(this.messageQueue.getQueueSize()===0)return{success:!0,message:"No messages to flush"};S&&console.log(`Force flushing ${this.messageQueue.getQueueSize()} messages...`);try{return await this.messageQueue.forceFlushAndShutdown(e)}catch(t){return S&&console.error("Force flush failed:",t.message),{success:!1,error:t.message}}}async launch(e={}){let{codevServer:t,apikey:s=null}=e;return this.httpClient.setBaseUrl(t),s&&this.authService.setCredentials(s),this.startFileWatching(),super.launch(e)}};Le.exports=de});var je=m((Ws,Re)=>{var Kt=B(),{spawn:Jt,execFileSync:Qt}=require("child_process"),z=require("path"),V=require("fs"),Yt=se(),Xt=ne(),Zt=ie(),es=ce(),ts=ue(),{isPrintMode:ss}=U(),b=process.env.CODEV_DEBUG==="True",he=class extends Kt{constructor(){let e=`${process.platform}-${process.arch}`;super({configDir:".",configFile:".claude.json",defaultModel:"Claude Sonnet 4.6",executablePaths:[`${e}/cc.js`,`../dist/${e}/cc.js`,`/tmp/claude-code-${e}/package/extracted/src/entrypoints/cc.js`],environmentVariables:t=>({ANTHROPIC_BASE_URL:`${t}/claude`,ANTHROPIC_API_KEY:"codev",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:t,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_INSTALLATION_CHECKS:"1"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}}),this.fileWatchService=null,this.shutdownInProgress=!1,this.initializeServices()}initializeServices(){this.httpClient=new Xt({timeout:1e4}),this.authService=new Zt({validateCredentials:!1}),this.sessionManager=new es({onSessionSwitch:e=>{this.sendTerminationMessage(e)}}),this.messageQueue=new Yt({maxRetries:2,retryDelay:500,shutdownTimeout:3e3,onProcessMessage:e=>this.processMessage(e)}),this.initializeFileWatchService()}resloveSettingFilePath(e){return z.join(e,this.config.configDir,".claude","settings.json")}initializeFileWatchService(){if(!process.env.SESSION_ID){b&&console.log("FileWatchService disabled: SESSION_ID environment variable not found");return}try{this.fileWatchService=new ts({watchPaths:this.getFileWatchPaths(),onFileChange:e=>this.handleFileChange(e),debounceTimeout:300}),b&&console.log("FileWatchService initialized with SESSION_ID:",process.env.SESSION_ID)}catch(e){b&&console.error("Failed to initialize FileWatchService:",e.message)}}getFileWatchPaths(){let e=[],t=process.cwd();e.push(t);let s=process.env.CODEV_WATCH_PATHS;if(s){let o=s.split(",").map(r=>r.trim());e.push(...o)}return e}handleFileChange(e){if(b&&console.log("File change detected:",e.data.relativePath),this.shutdownInProgress)return;let t={message:e,sessionId:e.data.sessionId||process.env.SESSION_ID};this.messageQueue.enqueue(t)}startFileWatching(){this.fileWatchService&&!this.fileWatchService.isWatching&&(this.fileWatchService.startWatching(),b&&console.log("File watching started"))}stopFileWatching(){this.fileWatchService&&this.fileWatchService.isWatching&&(this.fileWatchService.stopWatching(),b&&console.log("File watching stopped"))}onChildMessage(e){e&&e.type==="claude:send-msg"&&this.handleClaudeSendMessage(e.data),super.onChildMessage(e)}handleClaudeSendMessage(e){if(b&&console.log("Handling claude:send-msg message:",e),!e||typeof e!="object"){console.error(`handleClaudeSendMessage: Invalid message data. Expected object, got: ${typeof e}`);return}if(this.shutdownInProgress){b&&console.log("Shutdown in progress, ignoring new message");return}let t=e.sessionId||process.env.SESSION_ID;this.sessionManager.handleSessionSwitch(t),this.messageQueue.enqueue(e)}async processMessage(e){let t=e.data.message,s=e.data.sessionId||process.env.SESSION_ID;if(!s)throw new Error("No session ID available");let o;try{o=typeof t=="string"?JSON.parse(t):t}catch(i){throw new Error(`Failed to parse message data: ${i.message}`)}let r=`/conversations/${s}/@append?task_type=codev`,n=this.authService.hasCredentials()?this.authService.generateAuthHeaders():{};b&&(console.debug("Sending message to:",r),console.debug("Send Message: ",JSON.stringify(o))),e.type!=="CODEV_TERMINATE_SIGNAL"&&(this.sessionManager.currentSessionId=s)}sendTerminationMessage(e){let t={message:e,sessionId:e.sessionId||this.sessionManager.getCurrentSessionId()};this.messageQueue.enqueue(t)}async handleChildProcessExit(e,t){b&&console.log(`Child process exited with code: ${e}, signal: ${t}`),this.stopFileWatching();let s=this.messageQueue.getQueueSize(),o=this.sessionManager.terminateCurrentSession("process exited normally",e,t);if(o&&this.sendTerminationMessage(o),s>0||o){b&&console.log("Starting graceful shutdown of message queue...");try{let r=!t||t==="SIGTERM",n=this.messageQueue.getQueueSize(),i={timeoutMs:r?8e3:3e3,batchSize:Math.min(n,15),fastMode:!r||n>30},a=await this.messageQueue.gracefulShutdown(i);b&&console.log("Message queue shutdown completed:",a)}catch(r){b&&console.error("Error during message queue shutdown:",r.message)}}}handleChildProcessError(e){b&&console.error(`Child process error: ${e.message}`);let t=this.sessionManager.createErrorTermination(e);t&&this.sendTerminationMessage(t)}async launch(e={}){let{codevServer:t,apikey:s=null}=e;return this.httpClient.setBaseUrl(t),s&&this.authService.setCredentials(s),this.startFileWatching(),this._launchWithBun(e)}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return Qt(t,["--version"],{stdio:"ignore"}),t}catch{}let s=z.join(__dirname,"..","..","node_modules",".bin",t);if(V.existsSync(s))return s;let o=this._getBunPlatformPackage();if(o)try{let r=z.dirname(require.resolve(`${o}/package.json`)),n=z.join(r,"bin",t);if(V.existsSync(n))return n}catch{}try{let r=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(V.existsSync(r))return r}catch{}throw new Error("bun is not installed. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash")}_getBunPlatformPackage(){let e=process.platform,t=process.arch;return{"darwin-arm64":"@oven-sh/bun-darwin-aarch64","darwin-x64":"@oven-sh/bun-darwin-x64","linux-arm64":"@oven-sh/bun-linux-aarch64","linux-x64":"@oven-sh/bun-linux-x64","win32-x64":"@oven-sh/bun-windows-x64"}[`${e}-${t}`]||null}async _launchWithBun(e={}){let{remainingArgs:t=[],codevServer:s,apikey:o=null,extraEnv:r={}}=e;try{await this.ensureConfig(1e3);let n=this.findExecutablePath(),i=this._resolveBunPath();return b&&(console.log(`executablePath (bun): ${n}`),console.log(`bunPath: ${i}`)),new Promise((a,c)=>{let l={...process.env,...this.config.environmentVariables(s),CODER_EXECPATH:V.realpathSync(process.argv[1]),...r};o&&(l.CODER_APIKEY=o);let u=[n,...t],d=Jt(i,u,{env:l,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(d),d.on("error",p=>{p.code==="ENOENT"?console.error("bun binary not found. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash"):console.error(`Failed to start bun: ${p.message}`),c(p)}),d.on("exit",async(p,y)=>{ss(t)||y&&console.log(`terminated by signal: ${y}`)}),process.on("SIGINT",async()=>{console.log(`
|
|
10
10
|
Terminating ...`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
|
|
11
|
-
Terminating ...`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};Re.exports=he});var He=m((Gs,We)=>{var os=B(),Hs=require("path"),pe=class extends os{constructor(){super({configDir:".gemini",configFile:"settings.json",defaultModel:"gemini-2.5-pro",executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{ide:{hasSeenNudge:!0},telemetry:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}};We.exports=pe});var ze=m((zs,Ge)=>{var ns=B(),j=require("path")
|
|
11
|
+
Terminating ...`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};Re.exports=he});var He=m((Gs,We)=>{var os=B(),Hs=require("path"),pe=class extends os{constructor(){super({configDir:".gemini",configFile:"settings.json",defaultModel:"gemini-2.5-pro",executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{ide:{hasSeenNudge:!0},telemetry:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}};We.exports=pe});var ze=m((zs,Ge)=>{var ns=B(),j=require("path"),$=require("fs"),rs=require("os"),{spawn:is}=require("child_process"),K=process.env.CODEV_DEBUG==="True",fe=class extends ns{constructor(){super({configDir:".codex",configFile:"config.toml",defaultModel:"o4-mini",executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:e=>({OPENAI_BASE_URL:`${e}/codex`,OPENAI_API_KEY:"codev-proxy-key",DEBUG:K?"true":"false",CODEX_QUIET_MODE:"0",OPENAI_DISABLE_TELEMETRY:"true",CODEX_DISABLE_PROJECT_DOC:"0",CODEV_SERVER:e,CODEX_DISABLE_WEBSOCKET:"1"}),defaultConfig:{model:"gpt-5-codex",approvalMode:"suggest",fullAutoErrorMode:"ask-user",notify:[],history:{maxSize:1e3,saveHistory:!0,sensitivePatterns:[],persistence:"save-all"}}})}checkCodexAvailability(){try{let e=this.findExecutablePath();return $.existsSync(e)}catch{return!1}}resloveSettingFilePath(e){return j.join(e,this.config.configDir,"config.toml")}async ensureConfig(e,t=0){let s=j.join(rs.homedir(),this.config.configDir,this.config.configFile),o=j.dirname(s);try{$.existsSync(o)||$.mkdirSync(o,{recursive:!0});let r=`${e}/codex`;if($.existsSync(s)){let n=$.readFileSync(s,"utf8"),i=`openai_base_url = "${r}"`,a=n.search(/^\[/m),c=a===-1?n:n.slice(0,a),l=a===-1?"":n.slice(a);/^openai_base_url\s*=/m.test(c)?n=c.replace(/^openai_base_url\s*=.*/m,i)+l:n=c.trimEnd()+`
|
|
12
12
|
`+i+`
|
|
13
13
|
`+(l?`
|
|
14
|
-
`+l:"")
|
|
14
|
+
`+l:""),$.writeFileSync(s,n),K&&console.log(`Updated openai_base_url in ${s}`)}else{let n=this.config.defaultConfig||{},i=this.generateTOMLConfig(n,r);$.writeFileSync(s,i),K&&console.log(`Created Codex config file: ${s}`)}t>0&&await new Promise(n=>setTimeout(n,t))}catch(r){console.warn(`Failed to update ${this.config.configFile}: ${r.message}`)}}generateTOMLConfig(e,t){return`model = "${e.model||"gpt-5-codex"}"
|
|
15
15
|
openai_base_url = "${t}"
|
|
16
|
-
`}findExecutablePath(){let e=j.dirname(require.main.filename);for(let t of this.config.executablePaths){let s=j.resolve(e,t);if(
|
|
16
|
+
`}findExecutablePath(){let e=j.dirname(require.main.filename);for(let t of this.config.executablePaths){let s=j.resolve(e,t);if($.existsSync(s))return s}throw new Error(`Could not find Codex executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}async launch(e={}){let{remainingArgs:t=[],codevServer:s,apikey:o=null}=e;try{if(!this.checkCodexAvailability())throw new Error("Codex executable not found. Please ensure makecoder is properly installed: npm install -g makecoder@latest");await this.ensureConfig(s,1e3);let r=this.findExecutablePath();return K&&console.log(`executablePath: ${r}`),new Promise((n,i)=>{let a={...process.env,...this.config.environmentVariables(s)};o&&(a.CODER_APIKEY=o);let c=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&c.push("--inspect-brk"),c.push(r,...t);let l=is("node",c,{env:a,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(l),l.on("error",u=>{console.error(`Failed to start Codex: ${u.message}`),i(u)}),l.on("exit",async(u,d)=>{d&&console.log(`terminated by signal: ${d}`)}),process.on("SIGINT",async()=>{console.log(`
|
|
17
17
|
Terminating ...`),l.kill("SIGTERM"),setTimeout(()=>{l.killed||l.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
|
|
18
18
|
Terminating ...`),l.kill("SIGTERM"),setTimeout(()=>{l.killed||l.kill("SIGKILL")},8e3)})})}catch(r){throw r}}};Ge.exports=fe});var Qe=m((Vs,Je)=>{var W=require("fs"),Ve=require("path"),{spawn:Ke}=require("child_process"),ge=class{constructor(){this.extensionId="codev.codev-background";let e=require.main?Ve.dirname(require.main.filename):__dirname;this.extensionPath=Ve.resolve(e,"vendor/claude-code.vsix"),this._codeCommand=null}async resolveCodeCommand(){if(this._codeCommand)return this._codeCommand;if(process.env.IS_AISTUDIO==="True"){let e="/usr/lib/aistudio/lib/vscode/bin/remote-cli/aistudio";if(W.existsSync(e))try{return W.accessSync(e,W.constants.F_OK|W.constants.X_OK),this._codeCommand=e,process.env.CODEV_DEBUG&&console.log(`Using AI Studio VSCode path: ${e}`),this._codeCommand}catch(t){process.env.CODEV_DEBUG&&console.log(`AI Studio path exists but not executable: ${t.message}`)}else process.env.CODEV_DEBUG&&console.log(`AI Studio path not found: ${e}`)}try{let{spawn:e}=require("child_process");return new Promise(t=>{let s=e("which",["code"],{stdio:["ignore","pipe","ignore"]}),o="";s.stdout.on("data",r=>{o+=r.toString().trim()}),s.on("close",r=>{r===0&&o?(this._codeCommand=o,process.env.CODEV_DEBUG&&console.log(`Resolved code command path: ${o}`),t(this._codeCommand)):(this._codeCommand="code",t(this._codeCommand))}),s.on("error",()=>{this._codeCommand="code",t(this._codeCommand)}),setTimeout(()=>{s.kill(),this._codeCommand="code",t(this._codeCommand)},3e3)})}catch{return this._codeCommand="code",this._codeCommand}}async shouldInstallExtension(){try{return process.env.IS_AISTUDIO!=="True"?(process.env.CODEV_DEBUG&&console.log("Not in AI Studio environment (IS_AISTUDIO!=True), skipping extension installation"),!1):await this.isVSCodeAvailable()?await this.isExtensionInstalled()?(process.env.CODEV_DEBUG&&console.log(`Extension ${this.extensionId} already installed`),!1):!!W.existsSync(this.extensionPath):(process.env.CODEV_DEBUG&&console.log("VSCode not available, skipping extension installation"),!1)}catch(e){return process.env.CODEV_DEBUG&&console.error(`Error checking extension installation status: ${e.message}`),!1}}async installExtension(){try{return console.log("Installing Codev VSCode extension..."),await this.executeVSCodeCommand(["--install-extension",this.extensionPath])?(console.log("\u2705 Codev VSCode extension installed successfully"),!0):(console.warn("\u274C Failed to install Codev VSCode extension"),!1)}catch(e){return console.warn(`Error installing VSCode extension: ${e.message}`),!1}}async isVSCodeAvailable(){try{let e=process.env.IS_AISTUDIO==="True"?["--help"]:["--version"],t=await this.executeVSCodeCommand(e,{timeout:1e4});if(process.env.CODEV_DEBUG&&(console.log(`VSCode availability check (${e.join(" ")}): ${t?"available":"unavailable"}`),process.env.IS_AISTUDIO==="True")){let{spawn:s}=require("child_process");try{s("which",["code"],{stdio:["ignore","pipe","ignore"]}).stdout.on("data",r=>{console.log("which code:",r.toString().trim())})}catch(o){console.log("which command failed:",o.message)}}return t}catch(e){return process.env.CODEV_DEBUG&&console.error("VSCode availability check error:",e.message),!1}}async isExtensionInstalled(){let e=await this.resolveCodeCommand();try{return new Promise(t=>{try{let s={stdio:["ignore","pipe","ignore"],shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${e} --list-extensions`);let o=Ke(e,["--list-extensions"],s),r="";o.stdout.on("data",n=>{r+=n.toString()}),o.on("close",n=>{if(n===0){let i=r.split(`
|
|
19
19
|
`).map(a=>a.trim());t(i.includes(this.extensionId))}else t(!1)}),o.on("error",n=>{process.env.CODEV_DEBUG&&(console.error("VSCode list extensions error:",n.message),console.error("Error code:",n.code),console.error("Error errno:",n.errno),console.error("Error syscall:",n.syscall)),t(!1)}),setTimeout(()=>{try{o.kill()}catch{}t(!1)},1e4)}catch(s){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode list extensions:",s.message),t(!1)}})}catch{return!1}}async executeVSCodeCommand(e,t={}){let s=await this.resolveCodeCommand();return new Promise(o=>{try{let r={stdio:"ignore",shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${s} ${e.join(" ")}`);let n=Ke(s,e,r);n.on("close",a=>{o(a===0)}),n.on("error",a=>{process.env.CODEV_DEBUG&&(console.error("VSCode command error:",a.message),console.error("Error code:",a.code),console.error("Error errno:",a.errno),console.error("Error syscall:",a.syscall)),o(!1)});let i=t.timeout||3e4;setTimeout(()=>{try{n.kill()}catch{}o(!1)},i)}catch(r){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode command:",r.message),o(!1)}})}async ensureExtensionInstalled(){try{process.env.CODEV_DEBUG&&console.log("VSCode Extension Service: Checking extension status..."),await this.shouldInstallExtension()&&await this.installExtension()}catch(e){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",e)}}};Je.exports=ge});var Ze=m((Ks,Xe)=>{var I=require("fs"),A=require("path"),as=require("readline"),{execSync:J}=require("child_process"),Ye=require("os"),me=class{constructor(){this.serverUrl="https://makecoder.com/bigapis/codev/v1/coderpub"}getClaudeJsonlPath(e,t=!1){let s=e.replace(/[/_]/g,"-"),o=A.join(Ye.homedir(),".claude","projects",s);if(t&&(console.log(`
|
|
@@ -27,18 +27,18 @@ Terminating ...`),l.kill("SIGTERM"),setTimeout(()=>{l.killed||l.kill("SIGKILL")}
|
|
|
27
27
|
\u2705 \u53D1\u5E03\u6210\u529F!`),console.log(`\u{1F4CC} \u7248\u672C: ${c.data.version}`),console.log(`\u{1F310} \u8BBF\u95EE\u5730\u5740: https://${r}.coder.pub/`),0):(console.error(`
|
|
28
28
|
\u274C \u53D1\u5E03\u5931\u8D25: ${c.message||c.reason}`),1)}catch(i){return console.error(`
|
|
29
29
|
\u274C ${i.message}`),1}finally{n&&this.cleanup(n)}}showHelp(){console.log(["Usage: coder pub [options]","","\u53D1\u5E03\u5F53\u524D\u76EE\u5F55\u4E3A MakeCoder \u7F51\u9875\u5E94\u7528","","Options:"," --name <name> \u5E94\u7528\u540D\u79F0\uFF08\u5FC5\u9700\uFF09"," --allow-clone \u5305\u542B Claude Code \u751F\u6210\u8BB0\u5F55\uFF0C\u5141\u8BB8\u4ED6\u4EBA\u514B\u9686"," --help, -h \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F","","Description:"," \u5C06\u5F53\u524D\u76EE\u5F55\u7684\u4EE3\u7801\u53D1\u5E03\u4E3A MakeCoder \u5E73\u53F0\u4E0A\u7684\u7F51\u9875\u5E94\u7528\u3002"," \u5E94\u7528\u5C06\u5728 https://<name>.coder.pub/ \u4E0A\u53EF\u8BBF\u95EE\u3002","","Examples:"," coder pub --name myapp \u53D1\u5E03\u5E94\u7528\uFF0C\u8BBF\u95EE\u5730\u5740: https://myapp.coder.pub/"," coder pub --name myapp --allow-clone \u53D1\u5E03\u5E94\u7528\u5E76\u5305\u542B\u751F\u6210\u8BB0\u5F55","","Notes:"," - \u5E94\u7528\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26"," - \u4F7F\u7528 git archive \u521B\u5EFA\u538B\u7F29\u5305\uFF08\u81EA\u52A8\u6392\u9664 .gitignore \u4E2D\u7684\u6587\u4EF6\uFF09"," - \u5982\u679C\u4E0D\u662F git \u4ED3\u5E93\uFF0C\u5C06\u4F7F\u7528\u666E\u901A zip \u547D\u4EE4"].join(`
|
|
30
|
-
`))}};Xe.exports=me});var st=m((Js,tt)=>{var et=require("https"),E=require("fs"),
|
|
31
|
-
`);for(let a of i)console.log(` ${a.slug.padEnd(20)} ${a.summary}`);s(0)}catch(n){console.error(`\u274C \u89E3\u6790\u54CD\u5E94\u5931\u8D25: ${n.message}`),s(1)}})}).on("error",o=>{console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${o.message}`),s(1)})})}async publish(e,t){let{execSync:s}=require("child_process"),o=require("os"),r="global",n="PUBLIC",i=null,a=null,c=null,l=null;for(let f=0;f<e.length;f++)if(e[f]==="--namespace"||e[f]==="-n")r=e[++f];else if(e[f]==="--visibility"||e[f]==="-v")n=e[++f];else if(e[f]==="--meta-data"){let w=e[++f];try{JSON.parse(w)}catch(
|
|
30
|
+
`))}};Xe.exports=me});var st=m((Js,tt)=>{var et=require("https"),E=require("fs"),D=require("path"),cs=require("os"),x="https://makecoder.com/skillhub",ye=class{getSkillDirs(){let e=cs.homedir();return[D.join(e,".agents","skills")]}fetchWithAuth(e,t){return new Promise((s,o)=>{let r=new URL(e),n={hostname:r.hostname,port:r.port||443,path:r.pathname+r.search,method:"GET",headers:t?{Authorization:`Bearer ${t}`}:{}};et.get(n,i=>{if(i.statusCode>=300&&i.statusCode<400&&i.headers.location)return this.fetchWithAuth(i.headers.location,t).then(s).catch(o);let a="";i.on("data",c=>{a+=c}),i.on("end",()=>s({status:i.statusCode,body:a}))}).on("error",o)})}async handle({skillsSubcommand:e,skillsArg:t,skillsRemainingArgs:s,apikey:o}){let{execFileSync:r}=require("child_process");if(!e||e==="--help"||e==="-h")return this.showHelp(),0;if(e==="publish")return await this.publish(s||[],o);if(e==="unpublish")return await this.unpublish(t,o);if(e==="list")return await this.listMySkills(o);if(e==="namespaces")return await this.listNamespaces(o);if(t&&e!=="search"&&!/^[@a-zA-Z0-9_\-/.]+$/.test(t))return console.error("\u274C skill \u540D\u79F0\u5305\u542B\u975E\u6CD5\u5B57\u7B26"),1;if(e==="search")return t?await this.search(t):(console.error("\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD"),1);if(e==="remove")return t?this.remove(t):(console.error("\u274C \u8BF7\u6307\u5B9A skill \u540D\u79F0"),1);if((e==="add"||e==="update")&&t&&o)return await this.install(t,o);try{let n;if(e==="add"){if(!t)return console.error("\u274C \u8BF7\u6307\u5B9A skill \u540D\u79F0"),1;n=["skills","add",x,"--skill",t,"-g"]}else if(e==="update")n=t?["skills","update","--skill",t,"-g"]:["skills","update","-g"];else return console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),1;return r("npx",n,{stdio:"inherit"}),0}catch(n){return console.error(`\u274C \u6267\u884C\u5931\u8D25: ${n.message}`),1}}async install(e,t){let s=x.replace(/\/$/,"");console.log(`\u{1F50D} \u6B63\u5728\u4ECE ${x} \u67E5\u627E skill...`);let o;try{let c=await this.fetchWithAuth(`${s}/.well-known/agent-skills/index.json?skill=${encodeURIComponent(e)}`,t);if(c.status===404)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;if(c.status!==200)return console.error(`\u274C \u65E0\u6CD5\u83B7\u53D6 skill \u4FE1\u606F (HTTP ${c.status})`),1;o=JSON.parse(c.body)}catch(c){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${c.message}`),1}let r=(o.skills||[])[0];if(!r)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;let n=Array.from(new Set(["SKILL.md",...r.files||[]])),i=`${s}/.well-known/agent-skills/${r.name}`,a={};for(let c of n)try{let l=await this.fetchWithAuth(`${i}/${c}`,t);if(l.status!==200){console.warn(`\u26A0\uFE0F \u8DF3\u8FC7 ${c} (HTTP ${l.status})`);continue}a[c]=l.body}catch(l){console.warn(`\u26A0\uFE0F \u4E0B\u8F7D ${c} \u5931\u8D25: ${l.message}`)}console.log(`\u{1F4E6} \u6B63\u5728\u5B89\u88C5 ${r.name}...`);for(let c of this.getSkillDirs()){let l=D.join(c,r.name);E.mkdirSync(l,{recursive:!0});for(let[u,d]of Object.entries(a)){let p=D.join(l,u);E.mkdirSync(D.dirname(p),{recursive:!0}),E.writeFileSync(p,d,"utf8")}}return console.log(`\u2705 ${r.name} \u5B89\u88C5\u5B8C\u6210`),0}remove(e){let t=!1;for(let s of this.getSkillDirs()){let o=D.join(s,e);E.existsSync(o)&&(E.rmSync(o,{recursive:!0,force:!0}),console.log(` \u{1F5D1}\uFE0F ${o}`),t=!0)}return t?(console.log(`\u2705 ${e} \u5DF2\u5220\u9664`),0):(console.error(`\u274C \u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 skill: ${e}`),1)}async search(e){let t=`${x}/api/web/skills?q=${encodeURIComponent(e)}&sort=relevance&page=0&size=12`;return new Promise(s=>{et.get(t,o=>{let r="";o.on("data",n=>{r+=n}),o.on("end",()=>{try{let n=JSON.parse(r);if(n.code!==0)return console.error(`\u274C \u67E5\u8BE2\u5931\u8D25: ${n.msg}`),s(1);let i=n.data.items;if(i.length===0)return console.log(`\u6CA1\u6709\u627E\u5230\u4E0E "${e}" \u76F8\u5173\u7684 skill`),s(0);console.log(`\u627E\u5230 ${n.data.total} \u4E2A\u7ED3\u679C:
|
|
31
|
+
`);for(let a of i)console.log(` ${a.slug.padEnd(20)} ${a.summary}`);s(0)}catch(n){console.error(`\u274C \u89E3\u6790\u54CD\u5E94\u5931\u8D25: ${n.message}`),s(1)}})}).on("error",o=>{console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${o.message}`),s(1)})})}async publish(e,t){let{execSync:s}=require("child_process"),o=require("os"),r="global",n="PUBLIC",i=null,a=null,c=null,l=null;for(let f=0;f<e.length;f++)if(e[f]==="--namespace"||e[f]==="-n")r=e[++f];else if(e[f]==="--visibility"||e[f]==="-v")n=e[++f];else if(e[f]==="--meta-data"){let w=e[++f];try{JSON.parse(w)}catch(v){return console.error(`\u274C --meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${v.message}`),1}i=w}else if(!e[f].startsWith("-")){let w=e[f];E.existsSync(w)&&E.statSync(w).isDirectory()?l=w:a=w}if(!t)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let u=r.startsWith("@")?r.slice(1):r;u==="global"||(n="NAMESPACE_ONLY");let p=["PUBLIC","NAMESPACE_ONLY","PRIVATE"];if(!p.includes(n))return console.error(`\u274C visibility \u5FC5\u987B\u662F: ${p.join(", ")}`),1;if(a){if(!E.existsSync(a))return console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${a}`),1}else{let f=l?D.resolve(l):process.cwd();c=D.join(o.tmpdir(),`skill-pub-${Date.now()}.zip`),console.log(`\u{1F4E6} \u6B63\u5728\u6253\u5305 ${f}...`);try{E.existsSync(D.join(f,".git"))?(s(`git archive -o "${c}" HEAD`,{cwd:f,stdio:"pipe"}),console.log(" \u4F7F\u7528 git archive\uFF08\u5DF2\u6392\u9664 .gitignore \u6587\u4EF6\uFF09")):s(`zip -r "${c}" . -x ".git/*" -x "node_modules/*" -x ".env" -x "*.log"`,{cwd:f,stdio:"pipe"})}catch(w){return console.error(`\u274C \u6253\u5305\u5931\u8D25: ${w.message}`),1}a=c}let y=`${x}/api/v1/skills/${encodeURIComponent(u)}/publish?visibility=${encodeURIComponent(n)}`,H=t;console.log(`\u{1F680} \u6B63\u5728\u53D1\u5E03\u5230 ${x}...`),console.log(` namespace: ${u}`),console.log(` visibility: ${n}`);try{let f=i?` -F "meta_data=${i.replace(/"/g,'\\"')}"`:"",w=`curl -s -X POST "${y}" -H "Authorization: Bearer ${H}" -F "file=@${a}"${f}`,v=s(w,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),_=JSON.parse(v);if(_.code===0){let G=_.data;return console.log(`
|
|
32
32
|
\u2705 \u53D1\u5E03\u6210\u529F!`),console.log(` ${G.namespace}/${G.slug}@${G.version}`),G.status==="PUBLISHED"?console.log(" \u72B6\u6001: \u5DF2\u53D1\u5E03"):console.log(" \u72B6\u6001: \u5F85\u5BA1\u6838"),0}else return console.error(`
|
|
33
|
-
\u274C \u53D1\u5E03\u5931\u8D25: ${_.msg||JSON.stringify(_)}`),1}catch(f){let w=f.stdout;if(w)try{let
|
|
34
|
-
\u274C \u53D1\u5E03\u5931\u8D25: ${
|
|
35
|
-
`);for(let c of i){let l=`${c.namespace}/${c.slug}`.padEnd(36),u=`\u2B50 ${c.starCount??0}`.padEnd(8),d=`\u2193 ${c.downloadCount??0}`.padEnd(10);console.log(` ${l} ${u} ${d} [${c.status}]`),c.displayName&&c.displayName!==c.slug&&console.log(` ${"".padEnd(36)} ${c.displayName}`)}return 0}catch(r){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${r.message}`),1}}async listNamespaces(e){let{execSync:t}=require("child_process");if(!e)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let s=`${
|
|
33
|
+
\u274C \u53D1\u5E03\u5931\u8D25: ${_.msg||JSON.stringify(_)}`),1}catch(f){let w=f.stdout;if(w)try{let v=JSON.parse(w);return console.error(`
|
|
34
|
+
\u274C \u53D1\u5E03\u5931\u8D25: ${v.msg||w}`),1}catch{}return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${f.message}`),1}finally{c&&E.existsSync(c)&&E.unlinkSync(c)}}async unpublish(e,t){let{execSync:s}=require("child_process");if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A skill: coder skills unpublish <namespace>/<slug>"),1;if(!t)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let o=e.split("/");if(o.length!==2||!o[0]||!o[1])return console.error("\u274C \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <namespace>/<slug>\uFF0C\u4F8B\u5982: global/my-skill"),1;let[r,n]=o,i=r.startsWith("@")?r.slice(1):r,a=`${x}/api/v1/skills/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,c=t;console.log(`\u{1F5D1}\uFE0F \u6B63\u5728\u4E0B\u67B6 ${i}/${n}...`);try{let l=s(`curl -s -X DELETE "${a}" -H "Authorization: Bearer ${c}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),u=JSON.parse(l);return u.code===0?(console.log(`\u2705 \u5DF2\u4E0B\u67B6 ${i}/${n}`),0):(console.error(`\u274C \u4E0B\u67B6\u5931\u8D25: ${u.msg||JSON.stringify(u)}`),1)}catch(l){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${l.message}`),1}}async listMySkills(e){let{execSync:t}=require("child_process");if(!e)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let s=`${x}/api/v1/me/skills?size=50`,o=e;try{let r=t(`curl -s "${s}" -H "Authorization: Bearer ${o}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),n=JSON.parse(r);if(n.code!==0)return console.error(`\u274C \u83B7\u53D6\u5931\u8D25: ${n.msg}`),1;let i=n.data?.items||[],a=n.data?.total||0;if(i.length===0)return console.log("\u6682\u65E0\u5DF2\u53D1\u5E03\u7684 skill"),0;console.log(`\u5171 ${a} \u4E2A skill:
|
|
35
|
+
`);for(let c of i){let l=`${c.namespace}/${c.slug}`.padEnd(36),u=`\u2B50 ${c.starCount??0}`.padEnd(8),d=`\u2193 ${c.downloadCount??0}`.padEnd(10);console.log(` ${l} ${u} ${d} [${c.status}]`),c.displayName&&c.displayName!==c.slug&&console.log(` ${"".padEnd(36)} ${c.displayName}`)}return 0}catch(r){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${r.message}`),1}}async listNamespaces(e){let{execSync:t}=require("child_process");if(!e)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let s=`${x}/api/v1/me/namespaces`,o=e;try{let r=t(`curl -s "${s}" -H "Authorization: Bearer ${o}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),n=JSON.parse(r);if(n.code!==0)return console.error(`\u274C \u83B7\u53D6\u5931\u8D25: ${n.msg}`),1;let i=n.data||[];if(i.length===0)return console.log("\u6682\u65E0\u547D\u540D\u7A7A\u95F4"),0;console.log(`\u5171 ${i.length} \u4E2A\u547D\u540D\u7A7A\u95F4:
|
|
36
36
|
`);for(let a of i){let c=a.type==="GLOBAL"?"\u5168\u5C40":"\u56E2\u961F";console.log(` @${a.slug.padEnd(20)} ${a.displayName.padEnd(20)} [${c}] ${a.status}`)}return 0}catch(r){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${r.message}`),1}}showHelp(){console.log(["Usage: coder skills [subcommand] [options]","","Subcommands:"," add <name> \u5B89\u88C5 skill"," remove <name> \u5378\u8F7D skill"," update [name] \u66F4\u65B0 skill\uFF08\u4E0D\u6307\u5B9A\u540D\u79F0\u5219\u66F4\u65B0\u5168\u90E8\uFF09"," search <keyword> \u641C\u7D22 skill"," list \u67E5\u770B\u6211\u53D1\u5E03\u7684 skill"," publish [options] [<dir-or-zip>] \u53D1\u5E03 skill \u5230 skillhub"," unpublish <namespace>/<slug> \u4E0B\u67B6 skill"," namespaces \u67E5\u770B\u6211\u7684\u547D\u540D\u7A7A\u95F4","","Publish Options:"," --namespace <ns> \u76EE\u6807\u547D\u540D\u7A7A\u95F4\uFF08\u9ED8\u8BA4: global\uFF09"," --visibility <v> \u53EF\u89C1\u6027: PUBLIC | NAMESPACE_ONLY | PRIVATE"," \uFF08\u9ED8\u8BA4: PUBLIC\uFF0C\u975E global \u547D\u540D\u7A7A\u95F4\u65F6\u81EA\u52A8\u9501\u5B9A\u4E3A NAMESPACE_ONLY\uFF09"," --meta-data <json> \u9644\u52A0\u81EA\u5B9A\u4E49\u5143\u6570\u636E JSON","","Examples:"," coder skills add vue \u5B89\u88C5 vue skill"," coder skills search react \u641C\u7D22 react skills"," coder skills list \u67E5\u770B\u6211\u53D1\u5E03\u7684 skill"," coder skills publish ./my-skill-dir \u4ECE\u76EE\u5F55\u53D1\u5E03"," coder skills publish --namespace myteam ./my-skill-dir"," coder skills publish --visibility PRIVATE my-skill.zip",` coder skills publish --meta-data '{"category":"tool"}' ./my-skill-dir`," coder skills unpublish global/my-skill"," coder skills namespaces \u67E5\u770B\u6211\u7684\u547D\u540D\u7A7A\u95F4"].join(`
|
|
37
|
-
`))}};tt.exports=ye});var rt=m((Qs,nt)=>{var ls=require("https"),Q="https://makecoder.com/wiki",us=`${Q}/api`,P=h=>`${Q}/doc/${h}`,ot=h=>`${Q}/collection/${h}`,we=class{post(e,t,s){return new Promise((o,r)=>{let n=JSON.stringify(t),i=new URL(`${us}/${e}`),a={hostname:i.hostname,port:i.port||443,path:i.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(n),Authorization:`Bearer ${s}`}},c=ls.request(a,l=>{let u="";l.on("data",d=>u+=d),l.on("end",()=>o({status:l.statusCode,body:u}))});c.on("error",r),c.write(n),c.end()})}parseJson(e){try{return JSON.parse(e)}catch{return null}}async handle({wikiSubcommand:e,wikiArg:t,wikiRemainingArgs:s,apikey:o}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;let r=o;if(!r)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let n=s||[];return e==="list"?await this.list(t,n,r):e==="create-collection"?await this.createCollection(n,r):e==="update-collection"?await this.updateCollection(t,n,r):e==="delete-collection"?await this.deleteCollection(t,r):e==="get"?await this.get(t,r):e==="publish"?await this.publish(t,n,r):e==="update"?await this.update(n,r):e==="delete"?await this.delete(t,n,r):e==="move"?await this.move(n,r):e==="archive"?await this.archive(t,r):e==="restore"?await this.restore(t,r):e==="drafts"?await this.drafts(r):e==="recent"?await this.recent(r):e==="search"?t?await this.search([t,...n],r):(console.error("\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD"),1):e==="stars"?await this.stars(r):e==="star"?await this.star(t,n,r):e==="unstar"?await this.unstar(t,r):e==="pins"?await this.pins(t,r):e==="pin"?await this.pin(t,n,r):e==="unpin"?await this.unpin(t,r):e==="comments"?await this.comments(t,r):e==="comment"?await this.comment(t,n,r):(console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),1)}async list(e,t,s){let o=t.indexOf("-d"),r=o!==-1?parseInt(t[o+1],10):null;if(!e){let c=await this.post("collections.list",{limit:100,offset:0},s),l=this.parseJson(c.body);if(!l?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",c.body),1;let u=l.data.collections||l.data||[];return u.length?(this.printTable(u.map(d=>({collectionId:d.id,\
|
|
37
|
+
`))}};tt.exports=ye});var rt=m((Qs,nt)=>{var ls=require("https"),Q="https://makecoder.com/wiki",us=`${Q}/api`,P=h=>`${Q}/doc/${h}`,ot=h=>`${Q}/collection/${h}`,we=class{post(e,t,s){return new Promise((o,r)=>{let n=JSON.stringify(t),i=new URL(`${us}/${e}`),a={hostname:i.hostname,port:i.port||443,path:i.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(n),Authorization:`Bearer ${s}`}},c=ls.request(a,l=>{let u="";l.on("data",d=>u+=d),l.on("end",()=>o({status:l.statusCode,body:u}))});c.on("error",r),c.write(n),c.end()})}parseJson(e){try{return JSON.parse(e)}catch{return null}}async handle({wikiSubcommand:e,wikiArg:t,wikiRemainingArgs:s,apikey:o}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;let r=o;if(!r)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let n=s||[];return e==="list"?await this.list(t,n,r):e==="create-collection"?await this.createCollection(n,r):e==="update-collection"?await this.updateCollection(t,n,r):e==="delete-collection"?await this.deleteCollection(t,r):e==="get"?await this.get(t,r):e==="publish"?await this.publish(t,n,r):e==="update"?await this.update(n,r):e==="delete"?await this.delete(t,n,r):e==="move"?await this.move(n,r):e==="archive"?await this.archive(t,r):e==="restore"?await this.restore(t,r):e==="drafts"?await this.drafts(r):e==="recent"?await this.recent(r):e==="search"?t?await this.search([t,...n],r):(console.error("\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD"),1):e==="stars"?await this.stars(r):e==="star"?await this.star(t,n,r):e==="unstar"?await this.unstar(t,r):e==="pins"?await this.pins(t,r):e==="pin"?await this.pin(t,n,r):e==="unpin"?await this.unpin(t,r):e==="comments"?await this.comments(t,r):e==="comment"?await this.comment(t,n,r):(console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),1)}async list(e,t,s){let o=t.indexOf("-d"),r=o!==-1?parseInt(t[o+1],10):null;if(!e){let c=await this.post("collections.list",{limit:100,offset:0},s),l=this.parseJson(c.body);if(!l?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",c.body),1;let u=l.data.collections||l.data||[];return u.length?(this.printTable(u.map(d=>({collectionId:d.id,\u96C6\u5408\u540D\u79F0:d.name,\u63CF\u8FF0:d.description||"",URL:ot(d.urlId||d.id)}))),0):(console.log("\u6682\u65E0\u96C6\u5408"),0)}if(r===null){let c=await this.post("documents.list",{collectionId:e,sort:"updatedAt",direction:"DESC"},s),l=this.parseJson(c.body);if(!l?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",c.body),1;let u=l.data.documents||l.data||[];return u.length?(this.printTable(u.map(d=>({docId:d.id,\u6807\u9898:d.title,URL:P(d.urlId||d.id)}))),0):(console.log("\u6682\u65E0\u6587\u6863"),0)}let n=await this.post("collections.documents",{id:e},s),i=this.parseJson(n.body);if(!i?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",n.body),1;let a=r===-1?1/0:r;return this.printTree(i.data,"",a,0),0}printTree(e,t,s,o){if(Array.isArray(e))for(let r=0;r<e.length;r++){let n=e[r],i=r===e.length-1,a=i?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",c=n.url?`${Q}${n.url}`:P(n.id);console.log(`${t}${a}${n.title||n.id} \x1B[90m${c}\x1B[0m`),n.children?.length&&o+1<s&&this.printTree(n.children,t+(i?" ":"\u2502 "),s,o+1)}}printTable(e){if(!e.length)return;let t=Object.keys(e[0]),s=i=>[...String(i)].reduce((a,c)=>a+(c.charCodeAt(0)>127?2:1),0),o=(i,a)=>i+" ".repeat(Math.max(0,a-s(i))),r=t.map(i=>Math.max(s(i),...e.map(a=>s(a[i]||"")))),n=r.map(i=>"-".repeat(i)).join("-+-");console.log(t.map((i,a)=>o(i,r[a])).join(" | ")),console.log(n);for(let i of e)console.log(t.map((a,c)=>o(String(i[a]||""),r[c])).join(" | "))}async createCollection(e,t){let s=e.indexOf("--permission"),o="read_write";s!==-1&&(o=e[s+1]||"read_write",e.splice(s,2));let r=e[0];if(!r)return console.error("\u274C \u8BF7\u6307\u5B9A\u96C6\u5408\u540D\u79F0"),1;let n=e.slice(1).join(" "),i={name:r,description:n,sharing:!0};o==="null"||o==="none"?i.permission=null:i.permission=o;let a=await this.post("collections.create",i,t),c=this.parseJson(a.body);return c?.data?(console.log(`\u2705 \u96C6\u5408\u5DF2\u521B\u5EFA: ${c.data.id} \u2014 ${c.data.name}`),0):(console.error("\u274C \u521B\u5EFA\u5931\u8D25:",a.body),1)}async updateCollection(e,t,s){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID"),1;let o={id:e},r=t.indexOf("--name");r!==-1&&(o.name=t[r+1]);let n=t.indexOf("--description");n!==-1&&(o.description=t[n+1]);let i=t.indexOf("--permission");if(i!==-1){let d=t[i+1];o.permission=d==="null"||d==="none"?null:d}let a=t.indexOf("--color");a!==-1&&(o.color=t[a+1]);let c=t.indexOf("--sharing");if(c!==-1&&(o.sharing=t[c+1]==="true"),Object.keys(o).length<=1)return console.error("\u274C \u8BF7\u81F3\u5C11\u6307\u5B9A\u4E00\u4E2A\u8981\u66F4\u65B0\u7684\u5B57\u6BB5\uFF08--name, --description, --permission, --color, --sharing\uFF09"),1;let l=await this.post("collections.update",o,s),u=this.parseJson(l.body);return u?.data?(console.log(`\u2705 \u96C6\u5408\u5DF2\u66F4\u65B0: ${u.data.id} \u2014 ${u.data.name}`),0):(console.error("\u274C \u66F4\u65B0\u96C6\u5408\u5931\u8D25:",l.body),1)}async deleteCollection(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID"),1;let s=await this.post("collections.delete",{id:e},t);return this.parseJson(s.body)?.ok===!1||s.status>=400?(console.error("\u274C \u5220\u9664\u96C6\u5408\u5931\u8D25:",s.body),1):(console.log("\u2705 \u96C6\u5408\u5DF2\u5220\u9664"),0)}async get(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let s=await this.post("documents.info",{id:e},t),o=this.parseJson(s.body);if(!o?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",s.body),1;let r=o.data;return console.log(`\u6807\u9898: ${r.title}`),console.log(`ID: ${r.id}`),console.log(`\u96C6\u5408: ${r.collectionId}`),console.log(`\u66F4\u65B0: ${r.updatedAt}`),r.text&&console.log(`
|
|
38
38
|
${r.text}`),0}async publish(e,t,s){let o=require("fs"),r=require("path");if(!e)return console.error(`\u274C \u7528\u6CD5: wiki publish <collectionId> <title> [text]
|
|
39
|
-
wiki publish <collectionId> --file <path> [--parent <parentDocId>]`),1;let n,i,a,c=t.indexOf("--file"),l=t.indexOf("--parent");if(l!==-1&&(a=t[l+1]),c!==-1){let w=t[c+1];if(!w)return console.error("\u274C \u8BF7\u6307\u5B9A --file \u8DEF\u5F84"),1;let
|
|
39
|
+
wiki publish <collectionId> --file <path> [--parent <parentDocId>]`),1;let n,i,a,c=t.indexOf("--file"),l=t.indexOf("--parent");if(l!==-1&&(a=t[l+1]),c!==-1){let w=t[c+1];if(!w)return console.error("\u274C \u8BF7\u6307\u5B9A --file \u8DEF\u5F84"),1;let v=r.resolve(w);if(!o.existsSync(v))return console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${v}`),1;i=o.readFileSync(v,"utf8");let _=i.match(/^#\s+(.+)/m);if(!_)return console.error("\u274C \u6587\u4EF6\u7F3A\u5C11 H1 \u6807\u9898\uFF08# \u6807\u9898\uFF09\uFF0C\u8BF7\u6DFB\u52A0\u540E\u91CD\u8BD5"),1;n=_[1].trim(),i=i.replace(/^#\s+.+\n?/,"").trimStart()}else if(n=t[0],i=t.slice(1).join(" "),!n)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863\u6807\u9898"),1;let u={collectionId:e,title:n,text:"",publish:!0};a&&(u.parentDocumentId=a);let d=await this.post("documents.create",u,s),p=this.parseJson(d.body);if(!p?.data)return console.error("\u274C \u521B\u5EFA\u6587\u6863\u5931\u8D25:",d.body),1;let y=p.data.id;console.log(` \u521B\u5EFA\u6587\u6863: ${y}`);let H=await this.post("documents.update",{id:y,title:n,text:i,publish:!0},s),f=this.parseJson(H.body);return f?.data?(console.log(`\u2705 \u6587\u6863\u5DF2\u53D1\u5E03: ${f.data.title}
|
|
40
40
|
${P(f.data.urlId||y)}`),0):(console.error("\u274C \u66F4\u65B0\u5185\u5BB9\u5931\u8D25:",H.body),1)}async update(e,t){let s=require("fs"),o=require("path"),r=e[0];if(!r)return console.error("\u274C \u7528\u6CD5: wiki update <docId> <title> [text] | <docId> --file <path>"),1;let n,i,a=e.indexOf("--file");if(a!==-1){let d=e[a+1];if(!d)return console.error("\u274C \u8BF7\u6307\u5B9A --file \u8DEF\u5F84"),1;let p=o.resolve(d);if(!s.existsSync(p))return console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${p}`),1;i=s.readFileSync(p,"utf8");let y=i.match(/^#\s+(.+)/m);if(!y)return console.error("\u274C \u6587\u4EF6\u7F3A\u5C11 H1 \u6807\u9898\uFF08# \u6807\u9898\uFF09\uFF0C\u8BF7\u6DFB\u52A0\u540E\u91CD\u8BD5"),1;n=y[1].trim(),i=i.replace(/^#\s+.+\n?/,"").trimStart()}else if(n=e[1],i=e.slice(2).join(" "),!n)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863\u6807\u9898"),1;let c={id:r,title:n,publish:!0};i&&(c.text=i);let l=await this.post("documents.update",c,t),u=this.parseJson(l.body);return u?.data?(console.log(`\u2705 \u6587\u6863\u5DF2\u66F4\u65B0: ${u.data.title}`),0):(console.error("\u274C \u66F4\u65B0\u5931\u8D25:",l.body),1)}async delete(e,t,s){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let o=t.includes("--permanent"),r=await this.post("documents.delete",{id:e,...o?{permanent:!0}:{}},s);return this.parseJson(r.body)?.ok===!1||r.status>=400?(console.error("\u274C \u5220\u9664\u5931\u8D25:",r.body),1):(console.log(`\u2705 \u6587\u6863\u5DF2${o?"\u6C38\u4E45":""}\u5220\u9664`),0)}async move(e,t){let[s,o,r]=e;if(!s||!o)return console.error("\u274C \u7528\u6CD5: wiki move <docId> <collectionId> [parentDocId]"),1;let n={id:s,collectionId:o};r&&(n.parentDocumentId=r);let i=await this.post("documents.move",n,t);return this.parseJson(i.body)?.data?(console.log("\u2705 \u6587\u6863\u5DF2\u79FB\u52A8"),0):(console.error("\u274C \u79FB\u52A8\u5931\u8D25:",i.body),1)}async archive(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let s=await this.post("documents.archive",{id:e},t);return this.parseJson(s.body)?.data?(console.log("\u2705 \u6587\u6863\u5DF2\u5F52\u6863"),0):(console.error("\u274C \u5F52\u6863\u5931\u8D25:",s.body),1)}async restore(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let s=await this.post("documents.restore",{id:e},t);return this.parseJson(s.body)?.data?(console.log("\u2705 \u6587\u6863\u5DF2\u6062\u590D"),0):(console.error("\u274C \u6062\u590D\u5931\u8D25:",s.body),1)}async drafts(e){let t=await this.post("documents.drafts",{sort:"updatedAt",direction:"DESC"},e),s=this.parseJson(t.body);if(!s?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",t.body),1;let o=s.data.documents||s.data||[];return o.length?(this.printTable(o.map(r=>({ID:r.id,\u6807\u9898:r.title,URL:P(r.urlId||r.id)}))),0):(console.log("\u6682\u65E0\u8349\u7A3F"),0)}async recent(e){let t=await this.post("documents.viewed",{sort:"updatedAt",direction:"DESC"},e),s=this.parseJson(t.body);if(!s?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",t.body),1;let o=s.data.documents||s.data||[];return o.length?(this.printTable(o.map(r=>({ID:r.id,\u6807\u9898:r.title,URL:P(r.urlId||r.id)}))),0):(console.log("\u6682\u65E0\u6D4F\u89C8\u8BB0\u5F55"),0)}async search(e,t){let s=e.join(" "),o=await this.post("documents.search",{query:s,snippetMinWords:20,snippetMaxWords:30},t),r=this.parseJson(o.body);if(!r?.data)return console.error("\u274C \u641C\u7D22\u5931\u8D25:",o.body),1;let n=r.data||[];return n.length?(console.log(`\u627E\u5230 ${n.length} \u4E2A\u7ED3\u679C:
|
|
41
|
-
`),this.printTable(n.map(i=>{let a=i.document||i;return{docId:a.id,\u6807\u9898:a.title,URL:P(a.urlId||a.id)}})),0):(console.log(`\u6CA1\u6709\u627E\u5230\u4E0E "${s}" \u76F8\u5173\u7684\u6587\u6863`),0)}async stars(e){let t=await this.post("stars.list",{},e),s=this.parseJson(t.body);if(!s?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",t.body),1;let o=s.data.stars||s.data||[];return o.length?(this.printTable(o.map(r=>({starId:r.id,\u6807\u9898:r.document?.title||r.collection?.name||"",URL:r.document?P(r.document.urlId||r.document.id):r.collection?ot(r.collection.urlId||r.collection.id):""}))),0):(console.log("\u6682\u65E0\u6536\u85CF"),0)}async star(e,t,s){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863\u6216\
|
|
41
|
+
`),this.printTable(n.map(i=>{let a=i.document||i;return{docId:a.id,\u6807\u9898:a.title,URL:P(a.urlId||a.id)}})),0):(console.log(`\u6CA1\u6709\u627E\u5230\u4E0E "${s}" \u76F8\u5173\u7684\u6587\u6863`),0)}async stars(e){let t=await this.post("stars.list",{},e),s=this.parseJson(t.body);if(!s?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",t.body),1;let o=s.data.stars||s.data||[];return o.length?(this.printTable(o.map(r=>({starId:r.id,\u6807\u9898:r.document?.title||r.collection?.name||"",URL:r.document?P(r.document.urlId||r.document.id):r.collection?ot(r.collection.urlId||r.collection.id):""}))),0):(console.log("\u6682\u65E0\u6536\u85CF"),0)}async star(e,t,s){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863\u6216\u96C6\u5408 ID"),1;let r=t.includes("--collection")?{collectionId:e}:{documentId:e},n=await this.post("stars.create",r,s);return this.parseJson(n.body)?.data?(console.log("\u2705 \u5DF2\u6536\u85CF"),0):(console.error("\u274C \u6536\u85CF\u5931\u8D25:",n.body),1)}async unstar(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6536\u85CF ID"),1;let s=await this.post("stars.delete",{id:e},t);return s.status>=400?(console.error("\u274C \u53D6\u6D88\u6536\u85CF\u5931\u8D25:",s.body),1):(console.log("\u2705 \u5DF2\u53D6\u6D88\u6536\u85CF"),0)}async pins(e,t){let s=e?{collectionId:e}:{},o=await this.post("pins.list",s,t),r=this.parseJson(o.body);if(!r?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",o.body),1;let n=r.data.pins||r.data||[];return n.length?(this.printTable(n.map(i=>({pinId:i.id,\u6807\u9898:i.document?.title||i.documentId,URL:P(i.document?.urlId||i.documentId)}))),0):(console.log("\u6682\u65E0\u7F6E\u9876"),0)}async pin(e,t,s){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let o={documentId:e,...t[0]?{collectionId:t[0]}:{}},r=await this.post("pins.create",o,s),n=this.parseJson(r.body);return n?.data?(console.log(`\u2705 \u5DF2\u7F6E\u9876: ${n.data.id}`),0):(console.error("\u274C \u7F6E\u9876\u5931\u8D25:",r.body),1)}async unpin(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u7F6E\u9876 ID"),1;let s=await this.post("pins.delete",{id:e},t);return s.status>=400?(console.error("\u274C \u53D6\u6D88\u7F6E\u9876\u5931\u8D25:",s.body),1):(console.log("\u2705 \u5DF2\u53D6\u6D88\u7F6E\u9876"),0)}async comments(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID"),1;let s=await this.post("comments.list",{documentId:e,sort:"createdAt",direction:"ASC"},t),o=this.parseJson(s.body);if(!o?.data)return console.error("\u274C \u8BF7\u6C42\u5931\u8D25:",s.body),1;let r=o.data.comments||o.data||[];if(!r.length)return console.log("\u6682\u65E0\u8BC4\u8BBA"),0;for(let n of r){let i=this.extractCommentText(n.data);console.log(` [${n.id}] ${n.createdBy?.name||"?"}: ${i}`)}return 0}async comment(e,t,s){let o=t.join(" ");if(!e||!o)return console.error("\u274C \u7528\u6CD5: wiki comment <docId> <text>"),1;let r={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:o}]}]},n=await this.post("comments.create",{documentId:e,data:r},s),i=this.parseJson(n.body);return i?.data?(console.log(`\u2705 \u8BC4\u8BBA\u5DF2\u53D1\u5E03: ${i.data.id}`),0):(console.error("\u274C \u8BC4\u8BBA\u5931\u8D25:",n.body),1)}extractCommentText(e){return e?.content?e.content.flatMap(t=>t.content||[]).filter(t=>t.type==="text").map(t=>t.text).join(""):""}showHelp(){console.log(["Usage: coder wiki [subcommand] [options]","","Collection Management:"," list \u5217\u51FA\u6240\u6709\u96C6\u5408"," list <collectionId> \u5217\u51FA\u96C6\u5408\u4E0B\u7684\u6839\u6587\u6863\uFF08\u8868\u683C\uFF09"," list <collectionId> -d <depth> \u5C55\u5F00\u6587\u6863\u6811\uFF08-d -1 \u5168\u90E8\u5C55\u5F00\uFF09"," create-collection <name> [desc] [--permission <perm>]"," \u521B\u5EFA\u96C6\u5408"," perm: read_write (\u53EF\u8BFB\u5199\uFF0C\u9ED8\u8BA4)"," read (\u53EA\u8BFB)"," null (\u4EC5\u6307\u5B9A\u6210\u5458\u53EF\u8BBF\u95EE)"," update-collection <id> [--name <n>] [--description <d>] [--permission <p>] [--color <c>] [--sharing <bool>]"," \u66F4\u65B0\u96C6\u5408"," delete-collection <collectionId> \u5220\u9664\u96C6\u5408","","Document Management:"," get <docId> \u67E5\u770B\u6587\u6863"," publish <collectionId> <title> [text] \u521B\u5EFA\u5E76\u53D1\u5E03\u6587\u6863"," publish <collectionId> --file <path> [--parent <parentDocId>]"," \u4ECE Markdown \u6587\u4EF6\u53D1\u5E03\uFF08\u9700\u542B H1 \u6807\u9898\uFF09"," update <docId> <title> [text] \u66F4\u65B0\u6587\u6863"," update <docId> --file <path> \u4ECE Markdown \u6587\u4EF6\u66F4\u65B0\u6587\u6863\uFF08\u9700\u542B H1 \u6807\u9898\uFF09"," delete <docId> [--permanent] \u5220\u9664\u6587\u6863"," move <docId> <collectionId> [parentId] \u79FB\u52A8\u6587\u6863"," archive <docId> \u5F52\u6863\u6587\u6863"," restore <docId> \u6062\u590D\u6587\u6863","","Discovery:"," drafts \u8349\u7A3F\u5217\u8868"," recent \u6700\u8FD1\u6D4F\u89C8"," search <keyword> \u5168\u6587\u641C\u7D22","","Collections & Favorites:"," stars \u6536\u85CF\u5217\u8868"," star <id> [--collection] \u6536\u85CF\u6587\u6863\u6216\u96C6\u5408"," unstar <starId> \u53D6\u6D88\u6536\u85CF"," pins [collectionId] \u7F6E\u9876\u5217\u8868"," pin <docId> [collectionId] \u7F6E\u9876\u6587\u6863"," unpin <pinId> \u53D6\u6D88\u7F6E\u9876","","Comments:"," comments <docId> \u67E5\u770B\u8BC4\u8BBA"," comment <docId> <text> \u53D1\u8868\u8BC4\u8BBA","","Examples:"," coder wiki list \u5217\u51FA\u6240\u6709\u96C6\u5408"," coder wiki list <collectionId> \u5217\u51FA\u96C6\u5408\u4E0B\u7684\u6587\u6863"," coder wiki list <collectionId> -d 2 \u5C55\u5F00\u6811\uFF08\u6DF1\u5EA6 2\uFF09"," coder wiki list <collectionId> -d -1 \u5C55\u5F00\u5B8C\u6574\u6811",' coder wiki publish <collectionId> "\u6807\u9898" "\u5185\u5BB9"'," coder wiki publish <collectionId> --file ./doc.md",' coder wiki search "\u5173\u952E\u8BCD"',' coder wiki comment <docId> "\u5F88\u6709\u5E2E\u52A9\uFF01"'].join(`
|
|
42
42
|
`))}};nt.exports=we});var ut=m((Ys,lt)=>{var M=require("fs"),N=require("path"),ct=require("os"),ds=require("readline"),Y=N.join(ct.homedir(),".coder","config.json"),it=process.env.MCP_CHANNEL_DIR||N.join(ct.homedir(),".claude","mcp-channel"),at=["wecom"];function X(h){return!h||h.length<=8?"****":h.slice(0,3)+"****"+h.slice(-3)}var Se=class{load(){try{return JSON.parse(M.readFileSync(Y,"utf8"))}catch{return{}}}save(e){let t=N.dirname(Y);M.existsSync(t)||M.mkdirSync(t,{recursive:!0}),M.writeFileSync(Y,JSON.stringify(e,null,2)+`
|
|
43
43
|
`)}getChannels(){return this.load().channels??[]}saveChannels(e){let t=this.load();t.channels=e,this.save(t)}async handle({channelSubcommand:e,channelArg:t,channelRemainingArgs:s,remainingArgs:o,claudeLauncher:r,parsedArgs:n}){return e?e==="--help"||e==="-h"?(this.showHelp(),0):e==="list"?this.list(t):e==="show"?this.show(t):e==="add"?this.add(t,s||[]):e==="remove"?this.remove(t):e==="update"?this.update(t,s||[]):(console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),1):this.launch(s||[],r,n)}async launch(e,t,s){let o=this.getChannels().filter(p=>p.enabled!==!1);if(!o.length&&(console.log(`\u5C1A\u672A\u7ED1\u5B9A\u4EFB\u4F55\u6E20\u9053\uFF0C\u5F00\u59CB\u5F15\u5BFC\u914D\u7F6E...
|
|
44
44
|
`),!await this.promptSetupChannel()||(o=this.getChannels().filter(y=>y.enabled!==!1),!o.length)))return 1;let r=null,n=e.indexOf("--channel-id");n!==-1&&(r=e[n+1],e=e.filter((p,y)=>y!==n&&y!==n+1));let i;if(r){if(i=o.find(p=>p.id===r),!i)return console.error(`\u274C \u6E20\u9053\u4E0D\u5B58\u5728: ${r}`),1}else if(o.length===1)i=o[0];else if(i=await this.promptSelectChannel(o),!i)return 1;let a=N.join(it,i.type);if(!M.existsSync(a))return console.error(`\u274C MCP \u76EE\u5F55\u4E0D\u5B58\u5728: ${a}`),1;let c=["--plugin-dir",a,"--dangerously-load-development-channels",`plugin:${i.type}@${i.type}`],l={WECOM_CHANNEL_FILE:Y,WECOM_CHANNEL_KEY:i.id};i.botId&&(l.WECOM_BOT_ID=i.botId),i.secret&&(l.WECOM_BOT_SECRET=i.secret),s.remainingArgs=[...c,...e,...s.remainingArgs||[]],s.extraEnv={...s.extraEnv||{},...l};let u=i.name||i.id,d=i.botId?X(i.botId):"(\u672A\u914D\u7F6E)";return console.log(`
|
package/dist/darwin-arm64/cc.js
CHANGED
|
@@ -23,13 +23,13 @@ var y84=Object.create;var{getPrototypeOf:h84,defineProperty:yfH,getOwnPropertyNa
|
|
|
23
23
|
Object.assign(A, {
|
|
24
24
|
post(...args) {
|
|
25
25
|
const [url, payload, ...remainArgs] = args;
|
|
26
|
-
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.
|
|
26
|
+
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.32' + '&session_id=' + k_() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
|
|
27
27
|
if (process.env.CODER_APIKEY) {
|
|
28
28
|
const headerValues = payload.headers.values;
|
|
29
29
|
headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
payload.headers.values.set('X-Coder-Version', '4.0.
|
|
32
|
+
payload.headers.values.set('X-Coder-Version', '4.0.32');
|
|
33
33
|
payload.headers.values.set('X-Coder-Platform', process.platform);
|
|
34
34
|
payload.headers.values.set('X-Coder-Arch', process.arch);
|
|
35
35
|
|
|
@@ -4977,7 +4977,7 @@ ${_.trim()}`);return K.join(q?" ":`
|
|
|
4977
4977
|
`)}function o73(H,_,q=!1){if(H instanceof hN){if(H.interrupted)throw new Mo(`Shell command interrupted for pattern "${_}": [Command interrupted]`);let T=Bt7(H.stdout,H.stderr,q);throw new Mo(`Shell command failed for pattern "${_}": ${T}`)}let K=GH(H),O=q?`[Error: ${K}]`:`[Error]
|
|
4978
4978
|
${K}`;throw new Mo(O)}var pt7,mt7,i73,r73;var RrH=R(()=>{CL();cH();W_();E8();Hj();KL();TO();pt7=require("crypto"),mt7=(()=>{let H;return()=>{if(!H)H=(kJH(),Kq(EX_)).PowerShellTool;return H}})(),i73=/```!\s*\n?([\s\S]*?)\n?```/g,r73=/(?<=^|\s)!`([^`]+)`/gm});var Ut7=R(()=>{cH();W_()});function a73(H,_){if(_==="policySettings")return!1;return H==="skills"||H==="commands_DEPRECATED"||H==="plugin"}function GP_(H,_){switch(H){case"policySettings":return qz.join(cf(),".claude",_);case"userSettings":return qz.join(p6(),_);case"projectSettings":return`.claude/${_}`;case"plugin":return"plugin";default:return""}}function ph8(H){return[H.name,H.description,H.whenToUse].filter(Boolean).join(" ")}function RP_(H,_){return LO(ph8(H),_)}async function s73(H){try{return await Ft7.realpath(H)}catch{return null}}function t73(H,_){if(!H.hooks)return;let q=DC().safeParse(H.hooks);if(!q.success){N(`Invalid hooks in skill '${_}': ${q.error.message}`);return}return q.data}function e73(H){if(!H.paths)return;let _=Jz_(H.paths).map((q)=>{return q.endsWith("/**")?q.slice(0,-3):q}).filter((q)=>q.length>0);if(_.length===0||_.every((q)=>q==="**"))return;return _}function Bh8(H,_,q,K="Skill"){let O=mv(H.description,q),T=O??tHH(_,K),z=H["user-invocable"]===void 0?!0:dUH(H["user-invocable"]),A=H.model,$;if(typeof A==="string"&&A.trim().length>0){let j=A.trim();$=j==="inherit"?void 0:wK(j)}let Y=H.effort,w=Y!==void 0?XI(Y):void 0;if(Y!==void 0&&w===void 0)N(`Skill ${q} has invalid effort '${Y}'. Valid options: ${eF.join(", ")} or an integer`);return{displayName:H.name!=null?String(H.name):void 0,description:T,hasUserSpecifiedDescription:O!==null,allowedTools:qe(H["allowed-tools"]),argumentHint:H["argument-hint"]!=null?String(H["argument-hint"]):void 0,argumentNames:rH6(H.arguments),whenToUse:H.when_to_use!=null?String(H.when_to_use):void 0,version:H.version!=null?String(H.version):void 0,model:$,disableModelInvocation:dUH(H["disable-model-invocation"]),userInvocable:z,hooks:t73(H,q),executionContext:H.context==="fork"?"fork":void 0,agent:H.agent!=null?String(H.agent):void 0,effort:w,shell:at_(H.shell,q),createdBy:H.created_by==="dream-proposal"||H.improved_by==="dream-proposal"?"dream-proposal":void 0,declaredFields:ot_(H)}}function Uh8({skillName:H,displayName:_,description:q,hasUserSpecifiedDescription:K,markdownContent:O,allowedTools:T,argumentHint:z,argumentNames:A,whenToUse:$,version:Y,model:w,disableModelInvocation:j,userInvocable:J,source:D,baseDir:M,loadedFrom:f,hooks:X,executionContext:P,agent:Z,paths:W,effort:G,shell:k,createdBy:L,declaredFields:v}){if(M&&T.length>0){let S=M;T=T.map((h)=>h.replace(/\$\{CLAUDE_SKILL_DIR\}/g,()=>S))}return{type:"prompt",name:H,description:q,hasUserSpecifiedDescription:K,allowedTools:T,argumentHint:z,argNames:A.length>0?A:void 0,whenToUse:$,version:Y,model:w,disableModelInvocation:j,userInvocable:J,context:P,agent:Z,effort:G,paths:W,declaredFields:v,contentLength:O.length,isHidden:!J,progressMessage:"running",userFacingName(){return _||H},source:D,loadedFrom:f,createdBy:L,hooks:X,skillRoot:M,async getPromptForCommand(S,h){let I=M?`Base directory for this skill: ${M}
|
|
4979
4979
|
|
|
4980
|
-
${O}`:O;if(I=aFH(I,S,!0,A,oH6),M){let C=M;I=I.replaceAll("${CLAUDE_SKILL_DIR}",C)}if(I=I.replace(/\$\{CLAUDE_SESSION_ID\}/g,k_()),I=I.replaceAll("${CLAUDE_EFFORT}",iR(w??h.options.mainLoopModel,G??h.getEffortValue())),a73(f,D)&&uY6())I=mY6(I);else if(f!=="mcp")I=await sHH(I,{...h,getToolPermissionContext(){let C=h.getToolPermissionContext();return{...C,alwaysAllowRules:{...C.alwaysAllowRules,command:T}}},getAppState(){let C=h.getAppState();return{...C,toolPermissionContext:{...C.toolPermissionContext,alwaysAllowRules:{...C.toolPermissionContext.alwaysAllowRules,command:T}}}}},`/${H}`,k);return[{type:"text",text:I}]}}}async function brH(H,_){let q=x_(),K;try{K=await q.readdir(H)}catch(z){if(!x9(z))N(`Failed to read skills directory ${H}: ${z}`,{level:"error"}),J6("skill_load_dir","skill_load_readdir_failed");return[]}let O=null,T=await Promise.all(K.map(async(z)=>{try{if(!z.isDirectory()&&!z.isSymbolicLink())return null;let A=qz.join(H,z.name),$=qz.join(A,"SKILL.md"),Y;try{Y=await q.readFile($,{encoding:"utf-8"})}catch(X){if(!$6(X))N(`[skills] failed to read ${$}: ${X}`,{level:"warn"}),O="skill_load_read_failed";return null}let{frontmatter:w,content:j}=nw(Y,$,{normalizeKeys:!0}),J=g4H($,j),D=z.name;HGH("skill",w);let M=Bh8(w,J,D),f=e73(w);return{skill:Uh8({...M,skillName:D,markdownContent:J,source:_,baseDir:A,loadedFrom:"skills",paths:f}),filePath:$}}catch(A){return N(`[skills] failed to parse ${qz.join(H,z.name,"SKILL.md")}: ${A}`,{level:"error"}),O="skill_load_parse_failed",null}}));if(O)xH("skill_load_dir",O);else EH("skill_load_dir");return T.filter((z)=>z!==null)}function Fh8(H){return/^skill\.md$/i.test(qz.basename(H))}function HK3(H){let _=new Map;for(let K of H){let O=qz.dirname(K.filePath),T=_.get(O)??[];T.push(K),_.set(O,T)}let q=[];for(let[K,O]of _){let T=O.filter((z)=>Fh8(z.filePath));if(T.length>0){let z=T[0];if(T.length>1)N(`Multiple skill files found in ${K}, using ${qz.basename(z.filePath)}`);q.push(z)}else q.push(...O)}return q}function Qt7(H,_){let q=_.endsWith(qz.sep)?_.slice(0,-1):_;if(!H.startsWith(q+qz.sep))return"";let K=H.slice(q.length+1);return K?K.split(qz.sep).join(":"):""}function _K3(H,_){let q=qz.dirname(H),K=qz.dirname(q),O=qz.basename(q),T=Qt7(K,_);return T?`${T}:${O}`:O}function qK3(H,_){let q=qz.basename(H),K=qz.dirname(H),O=q.replace(/\.md$/,""),T=Qt7(K,_);return T?`${T}:${O}`:O}function KK3(H){return Fh8(H.filePath)?_K3(H.filePath,H.baseDir):qK3(H.filePath,H.baseDir)}async function OK3(H){try{let _=await km("commands",H),q=HK3(_),K=[],O=!1;for(let{baseDir:T,filePath:z,frontmatter:A,content:$,source:Y}of q)try{let j=Fh8(z)?qz.dirname(z):void 0,J=KK3({baseDir:T,filePath:z,frontmatter:A,content:$,source:Y});HGH("skill",A);let D=Bh8(A,$,J,"Custom command");K.push({skill:Uh8({...D,skillName:J,displayName:void 0,markdownContent:g4H(z,$),source:Y,baseDir:j,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:z})}catch(w){N(`[skills] failed to load command from ${z}: ${w}`,{level:"error"}),O=!0}if(O)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else EH("skill_load_commands_dir");return K}catch(_){return yH(_),J6("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function ww6(){gh8.cache?.clear?.(),km.cache?.clear?.(),Gf.conditionalSkills.clear(),Gf.activatedConditionalSkillNames.clear()}function Qh8(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function dt7(H){Gf=H}function ct7(H){return dh8.subscribe(()=>{try{H()}catch(_){yH(_)}})}async function PiH(H,_){let q=x_(),K=_.endsWith(qz.sep)?_.slice(0,-1):_,O=[];for(let T of H){let z=qz.dirname(T);while(z.startsWith(K+qz.sep)){let A=qz.join(z,".claude","skills");if(!Gf.dynamicSkillDirs.has(A)){Gf.dynamicSkillDirs.add(A);try{if(await q.stat(A),await yu6(z,K)){N(`[skills] Skipped gitignored skills dir: ${A}`);continue}O.push(A)}catch{}}let $=qz.dirname(z);if($===z)break;z=$}}return O.sort((T,z)=>z.split(qz.sep).length-T.split(qz.sep).length)}async function WiH(H){if(!Nj("projectSettings")||ZX("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let _=new Set(Gf.dynamicSkills.keys()),q=await Promise.all(H.map((O)=>brH(O,"projectSettings")));for(let O=q.length-1;O>=0;O--)for(let{skill:T}of q[O]??[])if(T.type==="prompt")Gf.dynamicSkills.set(T.name,T);let K=q.flat().length;if(K>0){let O=[...Gf.dynamicSkills.keys()].filter((T)=>!_.has(T));if(N(`[skills] Dynamically discovered ${K} skills from ${H.length} directories`),O.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:_.size,newCount:Gf.dynamicSkills.size,addedCount:O.length,directoryCount:H.length})}dh8.emit()}function lt7(){return Array.from(Gf.dynamicSkills.values())}function ZiH(H,_){if(Gf.conditionalSkills.size===0)return[];let q=[];for(let[K,O]of Gf.conditionalSkills){if(O.type!=="prompt"||!O.paths||O.paths.length===0)continue;let T=gt7.default().add(O.paths);for(let z of H){let A=qz.isAbsolute(z)?qz.relative(_,z):z;if(!A||A.startsWith("..")||qz.isAbsolute(A))continue;if(T.ignores(A)){Gf.dynamicSkills.set(K,O),Gf.conditionalSkills.delete(K),Gf.activatedConditionalSkillNames.add(K),q.push(K),N(`[skills] Activated conditional skill '${K}' (matched path: ${A})`);break}}}if(q.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:Gf.dynamicSkills.size-q.length,newCount:Gf.dynamicSkills.size,addedCount:q.length,directoryCount:0}),dh8.emit();return q}function nt7(){return Array.from(Gf.conditionalSkills.values())}function it7(){Gf.dynamicSkillDirs.clear(),Gf.dynamicSkills.clear(),Gf.conditionalSkills.clear(),Gf.activatedConditionalSkillNames.clear()}var Ft7,gt7,qz,gh8,Gf,dh8;var kQ=R(()=>{Z7();$_();jz_();z6();M_();SE();dA_();e8();cH();yY();F_();W_();L0();hq();XC_();O6();yg();kq();RrH();pO();jU();Ln();oN();b$();ry8();OL();iy8();Ut7();Ft7=require("fs/promises"),gt7=m(v0H(),1),qz=require("path");gh8=X6(async(H)=>{let _=qz.join(p6(),"skills"),q=qz.join(cf(),".claude","skills"),K=ch8("skills",H);N(`Loading skills from: managed=${q}, user=${_}, project=[${K.join(", ")}]`);let O=yN(),T=ZX("skills"),z=Nj("projectSettings")&&!T;if(M1()){if(O.length===0||!z)return N(`[bare] Skipping skill dir discovery (${O.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(O.map((G)=>brH(qz.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[A,$,Y,w,j]=await Promise.all([CH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(q,"policySettings"),Nj("userSettings")&&!T?brH(_,"userSettings"):Promise.resolve([]),z?Promise.all(K.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),z?Promise.all(O.map((W)=>brH(qz.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),T?Promise.resolve([]):OK3(H)]),J=[...A,...$,...Y.flat(),...w.flat(),...j],D=await Promise.all(J.map(({skill:W,filePath:G})=>W.type==="prompt"?s73(G):Promise.resolve(null))),M=new Map,f=[];for(let W=0;W<J.length;W++){let G=J[W];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:k}=G,L=D[W];if(L===null||L===void 0){f.push(k);continue}let v=M.get(L);if(v!==void 0){N(`Skipping duplicate skill '${k.name}' from ${k.source} (same file already loaded from ${v})`);continue}M.set(L,k.source),f.push(k)}jYH("skill",f.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let X=J.length-f.length;if(X>0)N(`Deduplicated ${X} skills (same file)`);let P=[],Z=[];for(let W of f)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!Gf.activatedConditionalSkillNames.has(W.name))Z.push(W);else P.push(W);for(let W of Z)Gf.conditionalSkills.set(W.name,W);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${f.length} unique skills (${P.length} unconditional, ${Z.length} conditional, managed: ${A.length}, user: ${$.length}, project: ${Y.flat().length}, additional: ${w.flat().length}, legacy commands: ${j.length})`),P});Gf=Qh8(),dh8=k7();zl9({createSkillCommand:Uh8,parseSkillFrontmatterFields:Bh8})});function TK3(H){return H.split(gJH.win32.sep).join(gJH.posix.sep)}function o4H(H){let _=TK3(H);return lh8?_.toLowerCase():_}function LP_(H){let _=p6(),q=o4H(H),K=o4H(_);if(!q.startsWith(K))return null;if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function Jw6(H){let _=H.split(gJH.win32.sep).join(gJH.posix.sep);if(_.includes(".jsonl")||_.includes("projects")&&_.includes("*.jsonl"))return"session_transcript";return null}function kNH(H){if(b4())return JF(H);return!1}function rt7(H){if(jw6.isTeamMemFile(H))return"team";if(kNH(H))return"personal";return null}function zK3(H){if(b4())return kP_(H);return!1}function VNH(H){if(kNH(H))return!0;if(jw6.isTeamMemFile(H))return!0;if(LP_(H)!==null)return!0;if(zK3(H))return!0;return!1}function ih8(H){let _=gJH.normalize(H),q=o4H(_);if(b4()&&(q.includes("/agent-memory/")||q.includes("/agent-memory-local/")))return!0;if(jw6.isTeamMemoryEnabled()&&jw6.isTeamMemPath(_))return!0;if(b4()){let A=Bz(),$=o4H(A.replace(/[/\\]+$/,"")),Y=o4H(A);if(q===$||q.startsWith(Y))return!0}let K=o4H(p6()),O=o4H(jF()),T=q.startsWith(K),z=q.startsWith(O);if(!T&&!z)return!1;if(T&&q.includes("/projects/"))return!0;if(b4()&&q.includes("/memory/"))return!0;return!1}function ot7(H){let _=p6(),q=jF(),K=b4()?Bz().replace(/[/\\]+$/,""):"",O=o4H(H);if(![_,q,K].filter(Boolean).some(($)=>{if(O.includes(o4H($)))return!0;if(lh8)return O.includes(zP($).toLowerCase());return!1}))return!1;let A=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!A)return!1;for(let $ of A){let Y=$.replace(/[,;|&>]+$/,""),w=lh8?wPH(Y):Y;if(VNH(w)||ih8(w))return!0}return!1}function at7(H){if(Jw6(H)!==null)return!0;if(b4()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gJH,jw6,lh8=!1;var xrH=R(()=>{ZT();kn();F_();jC();gJH=require("path"),jw6=(AV(),Kq(_g))});function Dw6(H){let _=`${LiH()}/`,q=".output";if(H.startsWith(_)&&H.endsWith(".output")){let K=H.slice(_.length,-7);if(K.length>0&&K.length<=20&&/^[a-zA-Z0-9_-]+$/.test(K))return K}return null}function st7({file_path:H,offset:_,limit:q,pages:K},{verbose:O}){if(!H)return null;if(Dw6(H))return"";let T=O?H:a1(H);if(K)return A4.createElement(A4.Fragment,null,A4.createElement(uV,{filePath:H},T),` \xB7 pages ${K}`);if(O&&(_||q)){let z=_??1,A=q?`lines ${z}-${z+q-1}`:`from line ${z}`;return A4.createElement(A4.Fragment,null,A4.createElement(uV,{filePath:H},T),` \xB7 ${A}`)}return A4.createElement(uV,{filePath:H},T)}function tt7({file_path:H}){let _=H?Dw6(H):null;if(!_)return null;return A4.createElement(V,{dimColor:!0}," ",_)}function et7(H){switch(H.type){case"image":{let{originalSize:_}=H.file,q=l7(_);return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read image (",q,")"))}case"notebook":{let{cells:_}=H.file;if(!_||_.length<1)return A4.createElement(V,{color:"error"},"No cells found in notebook");return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},_.length)," cells"))}case"pdf":{let{originalSize:_}=H.file,q=l7(_);return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read PDF (",q,")"))}case"parts":return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:_}=H.file;return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},_)," ",_===1?"line":"lines"))}case"file_unchanged":return A4.createElement(Z6,{height:1},A4.createElement(V,{dimColor:!0},"Unchanged since last read"))}}function He7(H,{verbose:_}){if(!_&&typeof H==="string"){if(H.includes(cN))return A4.createElement(Z6,null,A4.createElement(V,{color:"error"},"File not found"));if(NK(H,"tool_use_error"))return A4.createElement(Z6,null,A4.createElement(V,{color:"error"},"Error reading file"))}return A4.createElement(sJ,{result:H,verbose:_})}function _e7(H){if(H?.file_path?.startsWith(CY()))return"Reading Plan";if(H?.file_path&&Dw6(H.file_path))return"Read agent output";return"Read"}function rh8(H){if(!H?.file_path)return null;let _=Dw6(H.file_path);if(_)return _;return a1(H.file_path)}var A4;var qe7=R(()=>{E8();Xb();ljH();bK();dH();w4();Rq();Tf();sD();A4=m(DH(),1)});function $K3(H){if(AK3.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function wK3(H){let _=NNH.basename(H),q=/^(.+)([ \u202F])(AM|PM)(\.png)$/,K=_.match(q);if(!K)return;let O=K[2],T=O===" "?YK3:" ";return H.replace(`${O}${K[3]}${K[4]}`,`${T}${K[3]}${K[4]}`)}function jK3(H){let _=p6();if(!H.startsWith(_))return null;let q=H.split(Xw6.win32.sep).join(Xw6.posix.sep);if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function MK3(){return pRH()?hL9:N98}function fK3(H){return lS_({...H,tabAwareSeparator:pRH()})}function XK3(H){let _=ze7.get(H);if(_===void 0)return"";return _r9(_)}async function Ke7(H,_,q){let K=q??a7H().maxTokens,O=hl9(H,_);if(!O||O<=K/4)return;let z=await Ae7(H)??O;if(z>K)throw new IY6(z,K)}function Mw6(H,_,q,K){return{type:"image",file:{base64:H.toString("base64"),type:`image/${_}`,originalSize:q,dimensions:K}}}async function Oe7(H,_,q,K,O,T,z,A,$,Y,w,j){if(K==="ipynb"){let v=await RU7(q),S=SH(v),h=Buffer.byteLength(S);if(h>A){let p=j4()?`Use ${yq} with jq to read specific portions:
|
|
4980
|
+
${O}`:O;if(I=aFH(I,S,!0,A,oH6),M){let C=M;I=I.replaceAll("${CLAUDE_SKILL_DIR}",C)}if(I=I.replace(/\$\{CLAUDE_SESSION_ID\}/g,k_()),I=I.replaceAll("${CLAUDE_EFFORT}",iR(w??h.options.mainLoopModel,G??h.getEffortValue())),a73(f,D)&&uY6())I=mY6(I);else if(f!=="mcp")I=await sHH(I,{...h,getToolPermissionContext(){let C=h.getToolPermissionContext();return{...C,alwaysAllowRules:{...C.alwaysAllowRules,command:T}}},getAppState(){let C=h.getAppState();return{...C,toolPermissionContext:{...C.toolPermissionContext,alwaysAllowRules:{...C.toolPermissionContext.alwaysAllowRules,command:T}}}}},`/${H}`,k);return[{type:"text",text:I}]}}}async function brH(H,_){let q=x_(),K;try{K=await q.readdir(H)}catch(z){if(!x9(z))N(`Failed to read skills directory ${H}: ${z}`,{level:"error"}),J6("skill_load_dir","skill_load_readdir_failed");return[]}let O=null,T=await Promise.all(K.map(async(z)=>{try{if(!z.isDirectory()&&!z.isSymbolicLink())return null;let A=qz.join(H,z.name),$=qz.join(A,"SKILL.md"),Y;try{Y=await q.readFile($,{encoding:"utf-8"})}catch(X){if(!$6(X))N(`[skills] failed to read ${$}: ${X}`,{level:"warn"}),O="skill_load_read_failed";return null}let{frontmatter:w,content:j}=nw(Y,$,{normalizeKeys:!0}),J=g4H($,j),D=z.name;HGH("skill",w);let M=Bh8(w,J,D),f=e73(w);return{skill:Uh8({...M,skillName:D,markdownContent:J,source:_,baseDir:A,loadedFrom:"skills",paths:f}),filePath:$}}catch(A){return N(`[skills] failed to parse ${qz.join(H,z.name,"SKILL.md")}: ${A}`,{level:"error"}),O="skill_load_parse_failed",null}}));if(O)xH("skill_load_dir",O);else EH("skill_load_dir");return T.filter((z)=>z!==null)}function Fh8(H){return/^skill\.md$/i.test(qz.basename(H))}function HK3(H){let _=new Map;for(let K of H){let O=qz.dirname(K.filePath),T=_.get(O)??[];T.push(K),_.set(O,T)}let q=[];for(let[K,O]of _){let T=O.filter((z)=>Fh8(z.filePath));if(T.length>0){let z=T[0];if(T.length>1)N(`Multiple skill files found in ${K}, using ${qz.basename(z.filePath)}`);q.push(z)}else q.push(...O)}return q}function Qt7(H,_){let q=_.endsWith(qz.sep)?_.slice(0,-1):_;if(!H.startsWith(q+qz.sep))return"";let K=H.slice(q.length+1);return K?K.split(qz.sep).join(":"):""}function _K3(H,_){let q=qz.dirname(H),K=qz.dirname(q),O=qz.basename(q),T=Qt7(K,_);return T?`${T}:${O}`:O}function qK3(H,_){let q=qz.basename(H),K=qz.dirname(H),O=q.replace(/\.md$/,""),T=Qt7(K,_);return T?`${T}:${O}`:O}function KK3(H){return Fh8(H.filePath)?_K3(H.filePath,H.baseDir):qK3(H.filePath,H.baseDir)}async function OK3(H){try{let _=await km("commands",H),q=HK3(_),K=[],O=!1;for(let{baseDir:T,filePath:z,frontmatter:A,content:$,source:Y}of q)try{let j=Fh8(z)?qz.dirname(z):void 0,J=KK3({baseDir:T,filePath:z,frontmatter:A,content:$,source:Y});HGH("skill",A);let D=Bh8(A,$,J,"Custom command");K.push({skill:Uh8({...D,skillName:J,displayName:void 0,markdownContent:g4H(z,$),source:Y,baseDir:j,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:z})}catch(w){N(`[skills] failed to load command from ${z}: ${w}`,{level:"error"}),O=!0}if(O)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else EH("skill_load_commands_dir");return K}catch(_){return yH(_),J6("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function ww6(){gh8.cache?.clear?.(),km.cache?.clear?.(),Gf.conditionalSkills.clear(),Gf.activatedConditionalSkillNames.clear()}function Qh8(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function dt7(H){Gf=H}function ct7(H){return dh8.subscribe(()=>{try{H()}catch(_){yH(_)}})}async function PiH(H,_){let q=x_(),K=_.endsWith(qz.sep)?_.slice(0,-1):_,O=[];for(let T of H){let z=qz.dirname(T);while(z.startsWith(K+qz.sep)){let A=qz.join(z,".claude","skills");if(!Gf.dynamicSkillDirs.has(A)){Gf.dynamicSkillDirs.add(A);try{if(await q.stat(A),await yu6(z,K)){N(`[skills] Skipped gitignored skills dir: ${A}`);continue}O.push(A)}catch{}}let $=qz.dirname(z);if($===z)break;z=$}}return O.sort((T,z)=>z.split(qz.sep).length-T.split(qz.sep).length)}async function WiH(H){if(!Nj("projectSettings")||ZX("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let _=new Set(Gf.dynamicSkills.keys()),q=await Promise.all(H.map((O)=>brH(O,"projectSettings")));for(let O=q.length-1;O>=0;O--)for(let{skill:T}of q[O]??[])if(T.type==="prompt")Gf.dynamicSkills.set(T.name,T);let K=q.flat().length;if(K>0){let O=[...Gf.dynamicSkills.keys()].filter((T)=>!_.has(T));if(N(`[skills] Dynamically discovered ${K} skills from ${H.length} directories`),O.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:_.size,newCount:Gf.dynamicSkills.size,addedCount:O.length,directoryCount:H.length})}dh8.emit()}function lt7(){return Array.from(Gf.dynamicSkills.values())}function ZiH(H,_){if(Gf.conditionalSkills.size===0)return[];let q=[];for(let[K,O]of Gf.conditionalSkills){if(O.type!=="prompt"||!O.paths||O.paths.length===0)continue;let T=gt7.default().add(O.paths);for(let z of H){let A=qz.isAbsolute(z)?qz.relative(_,z):z;if(!A||A.startsWith("..")||qz.isAbsolute(A))continue;if(T.ignores(A)){Gf.dynamicSkills.set(K,O),Gf.conditionalSkills.delete(K),Gf.activatedConditionalSkillNames.add(K),q.push(K),N(`[skills] Activated conditional skill '${K}' (matched path: ${A})`);break}}}if(q.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:Gf.dynamicSkills.size-q.length,newCount:Gf.dynamicSkills.size,addedCount:q.length,directoryCount:0}),dh8.emit();return q}function nt7(){return Array.from(Gf.conditionalSkills.values())}function it7(){Gf.dynamicSkillDirs.clear(),Gf.dynamicSkills.clear(),Gf.conditionalSkills.clear(),Gf.activatedConditionalSkillNames.clear()}var Ft7,gt7,qz,gh8,Gf,dh8;var kQ=R(()=>{Z7();$_();jz_();z6();M_();SE();dA_();e8();cH();yY();F_();W_();L0();hq();XC_();O6();yg();kq();RrH();pO();jU();Ln();oN();b$();ry8();OL();iy8();Ut7();Ft7=require("fs/promises"),gt7=m(v0H(),1),qz=require("path");gh8=X6(async(H)=>{let _=qz.join(p6(),"skills"),q=qz.join(cf(),".claude","skills"),K=ch8("skills",H);N(`Loading skills from: managed=${q}, user=${_}, project=[${K.join(", ")}]`);let O=yN(),T=ZX("skills"),z=Nj("projectSettings")&&!T;if(M1()){if(O.length===0||!z)return N(`[bare] Skipping skill dir discovery (${O.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(O.map((G)=>brH(qz.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[A,$,Y,w,j]=await Promise.all([CH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(q,"policySettings"),Nj("userSettings")&&!T?Promise.all([brH(_,"userSettings"),brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings")]).then(([_a,_b])=>[..._a,..._b]):brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings"),z?Promise.all(K.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),z?Promise.all(O.map((W)=>brH(qz.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),T?Promise.resolve([]):OK3(H)]),J=[...A,...$,...Y.flat(),...w.flat(),...j],D=await Promise.all(J.map(({skill:W,filePath:G})=>W.type==="prompt"?s73(G):Promise.resolve(null))),M=new Map,f=[];for(let W=0;W<J.length;W++){let G=J[W];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:k}=G,L=D[W];if(L===null||L===void 0){f.push(k);continue}let v=M.get(L);if(v!==void 0){N(`Skipping duplicate skill '${k.name}' from ${k.source} (same file already loaded from ${v})`);continue}M.set(L,k.source),f.push(k)}jYH("skill",f.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let X=J.length-f.length;if(X>0)N(`Deduplicated ${X} skills (same file)`);let P=[],Z=[];for(let W of f)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!Gf.activatedConditionalSkillNames.has(W.name))Z.push(W);else P.push(W);for(let W of Z)Gf.conditionalSkills.set(W.name,W);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${f.length} unique skills (${P.length} unconditional, ${Z.length} conditional, managed: ${A.length}, user: ${$.length}, project: ${Y.flat().length}, additional: ${w.flat().length}, legacy commands: ${j.length})`),P});Gf=Qh8(),dh8=k7();zl9({createSkillCommand:Uh8,parseSkillFrontmatterFields:Bh8})});function TK3(H){return H.split(gJH.win32.sep).join(gJH.posix.sep)}function o4H(H){let _=TK3(H);return lh8?_.toLowerCase():_}function LP_(H){let _=p6(),q=o4H(H),K=o4H(_);if(!q.startsWith(K))return null;if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function Jw6(H){let _=H.split(gJH.win32.sep).join(gJH.posix.sep);if(_.includes(".jsonl")||_.includes("projects")&&_.includes("*.jsonl"))return"session_transcript";return null}function kNH(H){if(b4())return JF(H);return!1}function rt7(H){if(jw6.isTeamMemFile(H))return"team";if(kNH(H))return"personal";return null}function zK3(H){if(b4())return kP_(H);return!1}function VNH(H){if(kNH(H))return!0;if(jw6.isTeamMemFile(H))return!0;if(LP_(H)!==null)return!0;if(zK3(H))return!0;return!1}function ih8(H){let _=gJH.normalize(H),q=o4H(_);if(b4()&&(q.includes("/agent-memory/")||q.includes("/agent-memory-local/")))return!0;if(jw6.isTeamMemoryEnabled()&&jw6.isTeamMemPath(_))return!0;if(b4()){let A=Bz(),$=o4H(A.replace(/[/\\]+$/,"")),Y=o4H(A);if(q===$||q.startsWith(Y))return!0}let K=o4H(p6()),O=o4H(jF()),T=q.startsWith(K),z=q.startsWith(O);if(!T&&!z)return!1;if(T&&q.includes("/projects/"))return!0;if(b4()&&q.includes("/memory/"))return!0;return!1}function ot7(H){let _=p6(),q=jF(),K=b4()?Bz().replace(/[/\\]+$/,""):"",O=o4H(H);if(![_,q,K].filter(Boolean).some(($)=>{if(O.includes(o4H($)))return!0;if(lh8)return O.includes(zP($).toLowerCase());return!1}))return!1;let A=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!A)return!1;for(let $ of A){let Y=$.replace(/[,;|&>]+$/,""),w=lh8?wPH(Y):Y;if(VNH(w)||ih8(w))return!0}return!1}function at7(H){if(Jw6(H)!==null)return!0;if(b4()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gJH,jw6,lh8=!1;var xrH=R(()=>{ZT();kn();F_();jC();gJH=require("path"),jw6=(AV(),Kq(_g))});function Dw6(H){let _=`${LiH()}/`,q=".output";if(H.startsWith(_)&&H.endsWith(".output")){let K=H.slice(_.length,-7);if(K.length>0&&K.length<=20&&/^[a-zA-Z0-9_-]+$/.test(K))return K}return null}function st7({file_path:H,offset:_,limit:q,pages:K},{verbose:O}){if(!H)return null;if(Dw6(H))return"";let T=O?H:a1(H);if(K)return A4.createElement(A4.Fragment,null,A4.createElement(uV,{filePath:H},T),` \xB7 pages ${K}`);if(O&&(_||q)){let z=_??1,A=q?`lines ${z}-${z+q-1}`:`from line ${z}`;return A4.createElement(A4.Fragment,null,A4.createElement(uV,{filePath:H},T),` \xB7 ${A}`)}return A4.createElement(uV,{filePath:H},T)}function tt7({file_path:H}){let _=H?Dw6(H):null;if(!_)return null;return A4.createElement(V,{dimColor:!0}," ",_)}function et7(H){switch(H.type){case"image":{let{originalSize:_}=H.file,q=l7(_);return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read image (",q,")"))}case"notebook":{let{cells:_}=H.file;if(!_||_.length<1)return A4.createElement(V,{color:"error"},"No cells found in notebook");return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},_.length)," cells"))}case"pdf":{let{originalSize:_}=H.file,q=l7(_);return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read PDF (",q,")"))}case"parts":return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:_}=H.file;return A4.createElement(Z6,{height:1},A4.createElement(V,null,"Read ",A4.createElement(V,{bold:!0},_)," ",_===1?"line":"lines"))}case"file_unchanged":return A4.createElement(Z6,{height:1},A4.createElement(V,{dimColor:!0},"Unchanged since last read"))}}function He7(H,{verbose:_}){if(!_&&typeof H==="string"){if(H.includes(cN))return A4.createElement(Z6,null,A4.createElement(V,{color:"error"},"File not found"));if(NK(H,"tool_use_error"))return A4.createElement(Z6,null,A4.createElement(V,{color:"error"},"Error reading file"))}return A4.createElement(sJ,{result:H,verbose:_})}function _e7(H){if(H?.file_path?.startsWith(CY()))return"Reading Plan";if(H?.file_path&&Dw6(H.file_path))return"Read agent output";return"Read"}function rh8(H){if(!H?.file_path)return null;let _=Dw6(H.file_path);if(_)return _;return a1(H.file_path)}var A4;var qe7=R(()=>{E8();Xb();ljH();bK();dH();w4();Rq();Tf();sD();A4=m(DH(),1)});function $K3(H){if(AK3.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function wK3(H){let _=NNH.basename(H),q=/^(.+)([ \u202F])(AM|PM)(\.png)$/,K=_.match(q);if(!K)return;let O=K[2],T=O===" "?YK3:" ";return H.replace(`${O}${K[3]}${K[4]}`,`${T}${K[3]}${K[4]}`)}function jK3(H){let _=p6();if(!H.startsWith(_))return null;let q=H.split(Xw6.win32.sep).join(Xw6.posix.sep);if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function MK3(){return pRH()?hL9:N98}function fK3(H){return lS_({...H,tabAwareSeparator:pRH()})}function XK3(H){let _=ze7.get(H);if(_===void 0)return"";return _r9(_)}async function Ke7(H,_,q){let K=q??a7H().maxTokens,O=hl9(H,_);if(!O||O<=K/4)return;let z=await Ae7(H)??O;if(z>K)throw new IY6(z,K)}function Mw6(H,_,q,K){return{type:"image",file:{base64:H.toString("base64"),type:`image/${_}`,originalSize:q,dimensions:K}}}async function Oe7(H,_,q,K,O,T,z,A,$,Y,w,j){if(K==="ipynb"){let v=await RU7(q),S=SH(v),h=Buffer.byteLength(S);if(h>A){let p=j4()?`Use ${yq} with jq to read specific portions:
|
|
4981
4981
|
cat "${H}" | jq '.cells[:20]' # First 20 cells
|
|
4982
4982
|
cat "${H}" | jq '.cells[100:120]' # Cells 100-120
|
|
4983
4983
|
cat "${H}" | jq '.cells | length' # Count total cells
|
package/dist/darwin-x64/cc.js
CHANGED
|
@@ -23,13 +23,13 @@ var y_K=Object.create;var{getPrototypeOf:h_K,defineProperty:kjH,getOwnPropertyNa
|
|
|
23
23
|
Object.assign(A, {
|
|
24
24
|
post(...args) {
|
|
25
25
|
const [url, payload, ...remainArgs] = args;
|
|
26
|
-
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.
|
|
26
|
+
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.32' + '&session_id=' + V6() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
|
|
27
27
|
if (process.env.CODER_APIKEY) {
|
|
28
28
|
const headerValues = payload.headers.values;
|
|
29
29
|
headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
payload.headers.values.set('X-Coder-Version', '4.0.
|
|
32
|
+
payload.headers.values.set('X-Coder-Version', '4.0.32');
|
|
33
33
|
payload.headers.values.set('X-Coder-Platform', process.platform);
|
|
34
34
|
payload.headers.values.set('X-Coder-Arch', process.arch);
|
|
35
35
|
|
|
@@ -4977,7 +4977,7 @@ ${_.trim()}`);return q.join(A?" ":`
|
|
|
4977
4977
|
`)}function s17(H,_,A=!1){if(H instanceof yv){if(H.interrupted)throw new Jo(`Shell command interrupted for pattern "${_}": [Command interrupted]`);let L=Bt1(H.stdout,H.stderr,A);throw new Jo(`Shell command failed for pattern "${_}": ${L}`)}let q=TH(H),K=A?`[Error: ${q}]`:`[Error]
|
|
4978
4978
|
${q}`;throw new Jo(K)}var Ut1,pt1,o17,a17;var ErH=E(()=>{RZ();cH();W6();h_();_Y();qZ();L5();Ut1=require("crypto"),pt1=(()=>{let H;return()=>{if(!H)H=(VDH(),qA(hP6)).PowerShellTool;return H}})(),o17=/```!\s*\n?([\s\S]*?)\n?```/g,a17=/(?<=^|\s)!`([^`]+)`/gm});var Ft1=E(()=>{cH();W6()});function t17(H,_){if(_==="policySettings")return!1;return H==="skills"||H==="commands_DEPRECATED"||H==="plugin"}function TX6(H,_){switch(H){case"policySettings":return qM.join(lj(),".claude",_);case"userSettings":return qM.join(p8(),_);case"projectSettings":return`.claude/${_}`;case"plugin":return"plugin";default:return""}}function py_(H){return[H.name,H.description,H.whenToUse].filter(Boolean).join(" ")}function EX6(H,_){return Z5(py_(H),_)}async function e17(H){try{return await gt1.realpath(H)}catch{return null}}function Hq7(H,_){if(!H.hooks)return;let A=wR().safeParse(H.hooks);if(!A.success){v(`Invalid hooks in skill '${_}': ${A.error.message}`);return}return A.data}function _q7(H){if(!H.paths)return;let _=DM6(H.paths).map((A)=>{return A.endsWith("/**")?A.slice(0,-3):A}).filter((A)=>A.length>0);if(_.length===0||_.every((A)=>A==="**"))return;return _}function Uy_(H,_,A,q="Skill"){let K=mN(H.description,A),L=K??tHH(_,q),f=H["user-invocable"]===void 0?!0:dBH(H["user-invocable"]),M=H.model,$;if(typeof M==="string"&&M.trim().length>0){let Y=M.trim();$=Y==="inherit"?void 0:zq(Y)}let O=H.effort,z=O!==void 0?PC(O):void 0;if(O!==void 0&&z===void 0)v(`Skill ${A} has invalid effort '${O}'. Valid options: ${eF.join(", ")} or an integer`);return{displayName:H.name!=null?String(H.name):void 0,description:L,hasUserSpecifiedDescription:K!==null,allowedTools:Ae(H["allowed-tools"]),argumentHint:H["argument-hint"]!=null?String(H["argument-hint"]):void 0,argumentNames:aH8(H.arguments),whenToUse:H.when_to_use!=null?String(H.when_to_use):void 0,version:H.version!=null?String(H.version):void 0,model:$,disableModelInvocation:dBH(H["disable-model-invocation"]),userInvocable:f,hooks:Hq7(H,A),executionContext:H.context==="fork"?"fork":void 0,agent:H.agent!=null?String(H.agent):void 0,effort:z,shell:tt6(H.shell,A),createdBy:H.created_by==="dream-proposal"||H.improved_by==="dream-proposal"?"dream-proposal":void 0,declaredFields:st6(H)}}function By_({skillName:H,displayName:_,description:A,hasUserSpecifiedDescription:q,markdownContent:K,allowedTools:L,argumentHint:f,argumentNames:M,whenToUse:$,version:O,model:z,disableModelInvocation:Y,userInvocable:D,source:w,baseDir:J,loadedFrom:j,hooks:P,executionContext:X,agent:G,paths:W,effort:T,shell:V,createdBy:Z,declaredFields:N}){if(J&&L.length>0){let S=J;L=L.map((y)=>y.replace(/\$\{CLAUDE_SKILL_DIR\}/g,()=>S))}return{type:"prompt",name:H,description:A,hasUserSpecifiedDescription:q,allowedTools:L,argumentHint:f,argNames:M.length>0?M:void 0,whenToUse:$,version:O,model:z,disableModelInvocation:Y,userInvocable:D,context:X,agent:G,effort:T,paths:W,declaredFields:N,contentLength:K.length,isHidden:!D,progressMessage:"running",userFacingName(){return _||H},source:w,loadedFrom:j,createdBy:Z,hooks:P,skillRoot:J,async getPromptForCommand(S,y){let C=J?`Base directory for this skill: ${J}
|
|
4979
4979
|
|
|
4980
|
-
${K}`:K;if(C=aFH(C,S,!0,M,sH8),J){let R=J;C=C.replaceAll("${CLAUDE_SKILL_DIR}",R)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,V6()),C=C.replaceAll("${CLAUDE_EFFORT}",iE(z??y.options.mainLoopModel,T??y.getEffortValue())),t17(j,w)&&pO8())C=UO8(C);else if(j!=="mcp")C=await sHH(C,{...y,getToolPermissionContext(){let R=y.getToolPermissionContext();return{...R,alwaysAllowRules:{...R.alwaysAllowRules,command:L}}},getAppState(){let R=y.getAppState();return{...R,toolPermissionContext:{...R.toolPermissionContext,alwaysAllowRules:{...R.toolPermissionContext.alwaysAllowRules,command:L}}}}},`/${H}`,V);return[{type:"text",text:C}]}}}async function brH(H,_){let A=x6(),q;try{q=await A.readdir(H)}catch(f){if(!x9(f))v(`Failed to read skills directory ${H}: ${f}`,{level:"error"}),D8("skill_load_dir","skill_load_readdir_failed");return[]}let K=null,L=await Promise.all(q.map(async(f)=>{try{if(!f.isDirectory()&&!f.isSymbolicLink())return null;let M=qM.join(H,f.name),$=qM.join(M,"SKILL.md"),O;try{O=await A.readFile($,{encoding:"utf-8"})}catch(P){if(!$8(P))v(`[skills] failed to read ${$}: ${P}`,{level:"warn"}),K="skill_load_read_failed";return null}let{frontmatter:z,content:Y}=iz(O,$,{normalizeKeys:!0}),D=gKH($,Y),w=f.name;HTH("skill",z);let J=Uy_(z,D,w),j=_q7(z);return{skill:By_({...J,skillName:w,markdownContent:D,source:_,baseDir:M,loadedFrom:"skills",paths:j}),filePath:$}}catch(M){return v(`[skills] failed to parse ${qM.join(H,f.name,"SKILL.md")}: ${M}`,{level:"error"}),K="skill_load_parse_failed",null}}));if(K)xH("skill_load_dir",K);else hH("skill_load_dir");return L.filter((f)=>f!==null)}function Fy_(H){return/^skill\.md$/i.test(qM.basename(H))}function Aq7(H){let _=new Map;for(let q of H){let K=qM.dirname(q.filePath),L=_.get(K)??[];L.push(q),_.set(K,L)}let A=[];for(let[q,K]of _){let L=K.filter((f)=>Fy_(f.filePath));if(L.length>0){let f=L[0];if(L.length>1)v(`Multiple skill files found in ${q}, using ${qM.basename(f.filePath)}`);A.push(f)}else A.push(...K)}return A}function dt1(H,_){let A=_.endsWith(qM.sep)?_.slice(0,-1):_;if(!H.startsWith(A+qM.sep))return"";let q=H.slice(A.length+1);return q?q.split(qM.sep).join(":"):""}function qq7(H,_){let A=qM.dirname(H),q=qM.dirname(A),K=qM.basename(A),L=dt1(q,_);return L?`${L}:${K}`:K}function Kq7(H,_){let A=qM.basename(H),q=qM.dirname(H),K=A.replace(/\.md$/,""),L=dt1(q,_);return L?`${L}:${K}`:K}function Lq7(H){return Fy_(H.filePath)?qq7(H.filePath,H.baseDir):Kq7(H.filePath,H.baseDir)}async function fq7(H){try{let _=await Vm("commands",H),A=Aq7(_),q=[],K=!1;for(let{baseDir:L,filePath:f,frontmatter:M,content:$,source:O}of A)try{let Y=Fy_(f)?qM.dirname(f):void 0,D=Lq7({baseDir:L,filePath:f,frontmatter:M,content:$,source:O});HTH("skill",M);let w=Uy_(M,$,D,"Custom command");q.push({skill:By_({...w,skillName:D,displayName:void 0,markdownContent:gKH(f,$),source:O,baseDir:Y,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:f})}catch(z){v(`[skills] failed to load command from ${f}: ${z}`,{level:"error"}),K=!0}if(K)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else hH("skill_load_commands_dir");return q}catch(_){return kH(_),D8("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function Dz8(){gy_.cache?.clear?.(),Vm.cache?.clear?.(),Ej.conditionalSkills.clear(),Ej.activatedConditionalSkillNames.clear()}function Qy_(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function ct1(H){Ej=H}function lt1(H){return dy_.subscribe(()=>{try{H()}catch(_){kH(_)}})}async function XiH(H,_){let A=x6(),q=_.endsWith(qM.sep)?_.slice(0,-1):_,K=[];for(let L of H){let f=qM.dirname(L);while(f.startsWith(q+qM.sep)){let M=qM.join(f,".claude","skills");if(!Ej.dynamicSkillDirs.has(M)){Ej.dynamicSkillDirs.add(M);try{if(await A.stat(M),await hu8(f,q)){v(`[skills] Skipped gitignored skills dir: ${M}`);continue}K.push(M)}catch{}}let $=qM.dirname(f);if($===f)break;f=$}}return K.sort((L,f)=>f.split(qM.sep).length-L.split(qM.sep).length)}async function WiH(H){if(!NY("projectSettings")||GP("skills")){v("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let _=new Set(Ej.dynamicSkills.keys()),A=await Promise.all(H.map((K)=>brH(K,"projectSettings")));for(let K=A.length-1;K>=0;K--)for(let{skill:L}of A[K]??[])if(L.type==="prompt")Ej.dynamicSkills.set(L.name,L);let q=A.flat().length;if(q>0){let K=[...Ej.dynamicSkills.keys()].filter((L)=>!_.has(L));if(v(`[skills] Dynamically discovered ${q} skills from ${H.length} directories`),K.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:_.size,newCount:Ej.dynamicSkills.size,addedCount:K.length,directoryCount:H.length})}dy_.emit()}function nt1(){return Array.from(Ej.dynamicSkills.values())}function GiH(H,_){if(Ej.conditionalSkills.size===0)return[];let A=[];for(let[q,K]of Ej.conditionalSkills){if(K.type!=="prompt"||!K.paths||K.paths.length===0)continue;let L=Qt1.default().add(K.paths);for(let f of H){let M=qM.isAbsolute(f)?qM.relative(_,f):f;if(!M||M.startsWith("..")||qM.isAbsolute(M))continue;if(L.ignores(M)){Ej.dynamicSkills.set(q,K),Ej.conditionalSkills.delete(q),Ej.activatedConditionalSkillNames.add(q),A.push(q),v(`[skills] Activated conditional skill '${q}' (matched path: ${M})`);break}}}if(A.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:Ej.dynamicSkills.size-A.length,newCount:Ej.dynamicSkills.size,addedCount:A.length,directoryCount:0}),dy_.emit();return A}function it1(){return Array.from(Ej.conditionalSkills.values())}function rt1(){Ej.dynamicSkillDirs.clear(),Ej.dynamicSkills.clear(),Ej.conditionalSkills.clear(),Ej.activatedConditionalSkillNames.clear()}var gt1,Qt1,qM,gy_,Ej,dy_;var VQ=E(()=>{G1();$6();YM6();f8();J6();Sh();d36();e_();cH();yO();F6();W6();Z0();yA();PR6();K8();kg();VA();ErH();p5();YB();Zn();ov();x$();rk_();KZ();ik_();Ft1();gt1=require("fs/promises"),Qt1=m(N0H(),1),qM=require("path");gy_=P8(async(H)=>{let _=qM.join(p8(),"skills"),A=qM.join(lj(),".claude","skills"),q=cy_("skills",H);v(`Loading skills from: managed=${A}, user=${_}, project=[${q.join(", ")}]`);let K=kv(),L=GP("skills"),f=NY("projectSettings")&&!L;if(JL()){if(K.length===0||!f)return v(`[bare] Skipping skill dir discovery (${K.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(K.map((T)=>brH(qM.join(T,".claude","skills"),"projectSettings")))).flat().map((T)=>T.skill)}let[M,$,O,z,Y]=await Promise.all([RH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(A,"policySettings"),NY("userSettings")&&!L?brH(_,"userSettings"):Promise.resolve([]),f?Promise.all(q.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),f?Promise.all(K.map((W)=>brH(qM.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),L?Promise.resolve([]):fq7(H)]),D=[...M,...$,...O.flat(),...z.flat(),...Y],w=await Promise.all(D.map(({skill:W,filePath:T})=>W.type==="prompt"?e17(T):Promise.resolve(null))),J=new Map,j=[];for(let W=0;W<D.length;W++){let T=D[W];if(T===void 0||T.skill.type!=="prompt")continue;let{skill:V}=T,Z=w[W];if(Z===null||Z===void 0){j.push(V);continue}let N=J.get(Z);if(N!==void 0){v(`Skipping duplicate skill '${V.name}' from ${V.source} (same file already loaded from ${N})`);continue}J.set(Z,V.source),j.push(V)}YOH("skill",j.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let P=D.length-j.length;if(P>0)v(`Deduplicated ${P} skills (same file)`);let X=[],G=[];for(let W of j)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!Ej.activatedConditionalSkillNames.has(W.name))G.push(W);else X.push(W);for(let W of G)Ej.conditionalSkills.set(W.name,W);if(G.length>0)v(`[skills] ${G.length} conditional skills stored (activated when matching files are touched)`);return v(`Loaded ${j.length} unique skills (${X.length} unconditional, ${G.length} conditional, managed: ${M.length}, user: ${$.length}, project: ${O.flat().length}, additional: ${z.flat().length}, legacy commands: ${Y.length})`),X});Ej=Qy_(),dy_=V1();fl9({createSkillCommand:By_,parseSkillFrontmatterFields:Uy_})});function Mq7(H){return H.split(gDH.win32.sep).join(gDH.posix.sep)}function oKH(H){let _=Mq7(H);return ly_?_.toLowerCase():_}function ZX6(H){let _=p8(),A=oKH(H),q=oKH(_);if(!A.startsWith(q))return null;if(A.includes("/projects/")&&A.endsWith(".jsonl"))return"session_transcript";return null}function Jz8(H){let _=H.split(gDH.win32.sep).join(gDH.posix.sep);if(_.includes(".jsonl")||_.includes("projects")&&_.includes("*.jsonl"))return"session_transcript";return null}function VvH(H){if(bK())return DF(H);return!1}function ot1(H){if(wz8.isTeamMemFile(H))return"team";if(VvH(H))return"personal";return null}function $q7(H){if(bK())return VX6(H);return!1}function IvH(H){if(VvH(H))return!0;if(wz8.isTeamMemFile(H))return!0;if(ZX6(H)!==null)return!0;if($q7(H))return!0;return!1}function iy_(H){let _=gDH.normalize(H),A=oKH(_);if(bK()&&(A.includes("/agent-memory/")||A.includes("/agent-memory-local/")))return!0;if(wz8.isTeamMemoryEnabled()&&wz8.isTeamMemPath(_))return!0;if(bK()){let M=BM(),$=oKH(M.replace(/[/\\]+$/,"")),O=oKH(M);if(A===$||A.startsWith(O))return!0}let q=oKH(p8()),K=oKH(YF()),L=A.startsWith(q),f=A.startsWith(K);if(!L&&!f)return!1;if(L&&A.includes("/projects/"))return!0;if(bK()&&A.includes("/memory/"))return!0;return!1}function at1(H){let _=p8(),A=YF(),q=bK()?BM().replace(/[/\\]+$/,""):"",K=oKH(H);if(![_,A,q].filter(Boolean).some(($)=>{if(K.includes(oKH($)))return!0;if(ly_)return K.includes(fX($).toLowerCase());return!1}))return!1;let M=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!M)return!1;for(let $ of M){let O=$.replace(/[,;|&>]+$/,""),z=ly_?zXH(O):O;if(IvH(z)||iy_(z))return!0}return!1}function st1(H){if(Jz8(H)!==null)return!0;if(bK()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gDH,wz8,ly_=!1;var xrH=E(()=>{Gf();Vn();F6();YR();gDH=require("path"),wz8=(MI(),qA(_g))});function jz8(H){let _=`${ZiH()}/`,A=".output";if(H.startsWith(_)&&H.endsWith(".output")){let q=H.slice(_.length,-7);if(q.length>0&&q.length<=20&&/^[a-zA-Z0-9_-]+$/.test(q))return q}return null}function tt1({file_path:H,offset:_,limit:A,pages:q},{verbose:K}){if(!H)return null;if(jz8(H))return"";let L=K?H:aL(H);if(q)return MK.createElement(MK.Fragment,null,MK.createElement(uI,{filePath:H},L),` \xB7 pages ${q}`);if(K&&(_||A)){let f=_??1,M=A?`lines ${f}-${f+A-1}`:`from line ${f}`;return MK.createElement(MK.Fragment,null,MK.createElement(uI,{filePath:H},L),` \xB7 ${M}`)}return MK.createElement(uI,{filePath:H},L)}function et1({file_path:H}){let _=H?jz8(H):null;if(!_)return null;return MK.createElement(I,{dimColor:!0}," ",_)}function He1(H){switch(H.type){case"image":{let{originalSize:_}=H.file,A=l1(_);return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read image (",A,")"))}case"notebook":{let{cells:_}=H.file;if(!_||_.length<1)return MK.createElement(I,{color:"error"},"No cells found in notebook");return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},_.length)," cells"))}case"pdf":{let{originalSize:_}=H.file,A=l1(_);return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read PDF (",A,")"))}case"parts":return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l1(H.file.originalSize),")"));case"text":{let{numLines:_}=H.file;return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},_)," ",_===1?"line":"lines"))}case"file_unchanged":return MK.createElement(G8,{height:1},MK.createElement(I,{dimColor:!0},"Unchanged since last read"))}}function _e1(H,{verbose:_}){if(!_&&typeof H==="string"){if(H.includes(cv))return MK.createElement(G8,null,MK.createElement(I,{color:"error"},"File not found"));if(vq(H,"tool_use_error"))return MK.createElement(G8,null,MK.createElement(I,{color:"error"},"Error reading file"))}return MK.createElement(tD,{result:H,verbose:_})}function Ae1(H){if(H?.file_path?.startsWith(CO()))return"Reading Plan";if(H?.file_path&&jz8(H.file_path))return"Read agent output";return"Read"}function ry_(H){if(!H?.file_path)return null;let _=jz8(H.file_path);if(_)return _;return aL(H.file_path)}var MK;var qe1=E(()=>{h_();Pb();lYH();bq();dH();zK();EA();fj();tw();MK=m(wH(),1)});function zq7(H){if(Oq7.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function Dq7(H){let _=vvH.basename(H),A=/^(.+)([ \u202F])(AM|PM)(\.png)$/,q=_.match(A);if(!q)return;let K=q[2],L=K===" "?Yq7:" ";return H.replace(`${K}${q[3]}${q[4]}`,`${L}${q[3]}${q[4]}`)}function wq7(H){let _=p8();if(!H.startsWith(_))return null;let A=H.split(Wz8.win32.sep).join(Wz8.posix.sep);if(A.includes("/projects/")&&A.endsWith(".jsonl"))return"session_transcript";return null}function Pq7(){return pEH()?yZ9:k9_}function Xq7(H){return lS6({...H,tabAwareSeparator:pEH()})}function Wq7(H){let _=Me1.get(H);if(_===void 0)return"";return _r9(_)}async function Ke1(H,_,A){let q=A??a1H().maxTokens,K=yl9(H,_);if(!K||K<=q/4)return;let f=await $e1(H)??K;if(f>q)throw new xO8(f,q)}function Pz8(H,_,A,q){return{type:"image",file:{base64:H.toString("base64"),type:`image/${_}`,originalSize:A,dimensions:q}}}async function Le1(H,_,A,q,K,L,f,M,$,O,z,Y){if(q==="ipynb"){let N=await ZB1(A),S=SH(N),y=Buffer.byteLength(S);if(y>M){let p=YK()?`Use ${kA} with jq to read specific portions:
|
|
4980
|
+
${K}`:K;if(C=aFH(C,S,!0,M,sH8),J){let R=J;C=C.replaceAll("${CLAUDE_SKILL_DIR}",R)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,V6()),C=C.replaceAll("${CLAUDE_EFFORT}",iE(z??y.options.mainLoopModel,T??y.getEffortValue())),t17(j,w)&&pO8())C=UO8(C);else if(j!=="mcp")C=await sHH(C,{...y,getToolPermissionContext(){let R=y.getToolPermissionContext();return{...R,alwaysAllowRules:{...R.alwaysAllowRules,command:L}}},getAppState(){let R=y.getAppState();return{...R,toolPermissionContext:{...R.toolPermissionContext,alwaysAllowRules:{...R.toolPermissionContext.alwaysAllowRules,command:L}}}}},`/${H}`,V);return[{type:"text",text:C}]}}}async function brH(H,_){let A=x6(),q;try{q=await A.readdir(H)}catch(f){if(!x9(f))v(`Failed to read skills directory ${H}: ${f}`,{level:"error"}),D8("skill_load_dir","skill_load_readdir_failed");return[]}let K=null,L=await Promise.all(q.map(async(f)=>{try{if(!f.isDirectory()&&!f.isSymbolicLink())return null;let M=qM.join(H,f.name),$=qM.join(M,"SKILL.md"),O;try{O=await A.readFile($,{encoding:"utf-8"})}catch(P){if(!$8(P))v(`[skills] failed to read ${$}: ${P}`,{level:"warn"}),K="skill_load_read_failed";return null}let{frontmatter:z,content:Y}=iz(O,$,{normalizeKeys:!0}),D=gKH($,Y),w=f.name;HTH("skill",z);let J=Uy_(z,D,w),j=_q7(z);return{skill:By_({...J,skillName:w,markdownContent:D,source:_,baseDir:M,loadedFrom:"skills",paths:j}),filePath:$}}catch(M){return v(`[skills] failed to parse ${qM.join(H,f.name,"SKILL.md")}: ${M}`,{level:"error"}),K="skill_load_parse_failed",null}}));if(K)xH("skill_load_dir",K);else hH("skill_load_dir");return L.filter((f)=>f!==null)}function Fy_(H){return/^skill\.md$/i.test(qM.basename(H))}function Aq7(H){let _=new Map;for(let q of H){let K=qM.dirname(q.filePath),L=_.get(K)??[];L.push(q),_.set(K,L)}let A=[];for(let[q,K]of _){let L=K.filter((f)=>Fy_(f.filePath));if(L.length>0){let f=L[0];if(L.length>1)v(`Multiple skill files found in ${q}, using ${qM.basename(f.filePath)}`);A.push(f)}else A.push(...K)}return A}function dt1(H,_){let A=_.endsWith(qM.sep)?_.slice(0,-1):_;if(!H.startsWith(A+qM.sep))return"";let q=H.slice(A.length+1);return q?q.split(qM.sep).join(":"):""}function qq7(H,_){let A=qM.dirname(H),q=qM.dirname(A),K=qM.basename(A),L=dt1(q,_);return L?`${L}:${K}`:K}function Kq7(H,_){let A=qM.basename(H),q=qM.dirname(H),K=A.replace(/\.md$/,""),L=dt1(q,_);return L?`${L}:${K}`:K}function Lq7(H){return Fy_(H.filePath)?qq7(H.filePath,H.baseDir):Kq7(H.filePath,H.baseDir)}async function fq7(H){try{let _=await Vm("commands",H),A=Aq7(_),q=[],K=!1;for(let{baseDir:L,filePath:f,frontmatter:M,content:$,source:O}of A)try{let Y=Fy_(f)?qM.dirname(f):void 0,D=Lq7({baseDir:L,filePath:f,frontmatter:M,content:$,source:O});HTH("skill",M);let w=Uy_(M,$,D,"Custom command");q.push({skill:By_({...w,skillName:D,displayName:void 0,markdownContent:gKH(f,$),source:O,baseDir:Y,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:f})}catch(z){v(`[skills] failed to load command from ${f}: ${z}`,{level:"error"}),K=!0}if(K)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else hH("skill_load_commands_dir");return q}catch(_){return kH(_),D8("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function Dz8(){gy_.cache?.clear?.(),Vm.cache?.clear?.(),Ej.conditionalSkills.clear(),Ej.activatedConditionalSkillNames.clear()}function Qy_(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function ct1(H){Ej=H}function lt1(H){return dy_.subscribe(()=>{try{H()}catch(_){kH(_)}})}async function XiH(H,_){let A=x6(),q=_.endsWith(qM.sep)?_.slice(0,-1):_,K=[];for(let L of H){let f=qM.dirname(L);while(f.startsWith(q+qM.sep)){let M=qM.join(f,".claude","skills");if(!Ej.dynamicSkillDirs.has(M)){Ej.dynamicSkillDirs.add(M);try{if(await A.stat(M),await hu8(f,q)){v(`[skills] Skipped gitignored skills dir: ${M}`);continue}K.push(M)}catch{}}let $=qM.dirname(f);if($===f)break;f=$}}return K.sort((L,f)=>f.split(qM.sep).length-L.split(qM.sep).length)}async function WiH(H){if(!NY("projectSettings")||GP("skills")){v("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let _=new Set(Ej.dynamicSkills.keys()),A=await Promise.all(H.map((K)=>brH(K,"projectSettings")));for(let K=A.length-1;K>=0;K--)for(let{skill:L}of A[K]??[])if(L.type==="prompt")Ej.dynamicSkills.set(L.name,L);let q=A.flat().length;if(q>0){let K=[...Ej.dynamicSkills.keys()].filter((L)=>!_.has(L));if(v(`[skills] Dynamically discovered ${q} skills from ${H.length} directories`),K.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:_.size,newCount:Ej.dynamicSkills.size,addedCount:K.length,directoryCount:H.length})}dy_.emit()}function nt1(){return Array.from(Ej.dynamicSkills.values())}function GiH(H,_){if(Ej.conditionalSkills.size===0)return[];let A=[];for(let[q,K]of Ej.conditionalSkills){if(K.type!=="prompt"||!K.paths||K.paths.length===0)continue;let L=Qt1.default().add(K.paths);for(let f of H){let M=qM.isAbsolute(f)?qM.relative(_,f):f;if(!M||M.startsWith("..")||qM.isAbsolute(M))continue;if(L.ignores(M)){Ej.dynamicSkills.set(q,K),Ej.conditionalSkills.delete(q),Ej.activatedConditionalSkillNames.add(q),A.push(q),v(`[skills] Activated conditional skill '${q}' (matched path: ${M})`);break}}}if(A.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:Ej.dynamicSkills.size-A.length,newCount:Ej.dynamicSkills.size,addedCount:A.length,directoryCount:0}),dy_.emit();return A}function it1(){return Array.from(Ej.conditionalSkills.values())}function rt1(){Ej.dynamicSkillDirs.clear(),Ej.dynamicSkills.clear(),Ej.conditionalSkills.clear(),Ej.activatedConditionalSkillNames.clear()}var gt1,Qt1,qM,gy_,Ej,dy_;var VQ=E(()=>{G1();$6();YM6();f8();J6();Sh();d36();e_();cH();yO();F6();W6();Z0();yA();PR6();K8();kg();VA();ErH();p5();YB();Zn();ov();x$();rk_();KZ();ik_();Ft1();gt1=require("fs/promises"),Qt1=m(N0H(),1),qM=require("path");gy_=P8(async(H)=>{let _=qM.join(p8(),"skills"),A=qM.join(lj(),".claude","skills"),q=cy_("skills",H);v(`Loading skills from: managed=${A}, user=${_}, project=[${q.join(", ")}]`);let K=kv(),L=GP("skills"),f=NY("projectSettings")&&!L;if(JL()){if(K.length===0||!f)return v(`[bare] Skipping skill dir discovery (${K.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(K.map((T)=>brH(qM.join(T,".claude","skills"),"projectSettings")))).flat().map((T)=>T.skill)}let[M,$,O,z,Y]=await Promise.all([RH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(A,"policySettings"),NY("userSettings")&&!L?Promise.all([brH(_,"userSettings"),brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings")]).then(([_a,_b])=>[..._a,..._b]):brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings"),f?Promise.all(q.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),f?Promise.all(K.map((W)=>brH(qM.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),L?Promise.resolve([]):fq7(H)]),D=[...M,...$,...O.flat(),...z.flat(),...Y],w=await Promise.all(D.map(({skill:W,filePath:T})=>W.type==="prompt"?e17(T):Promise.resolve(null))),J=new Map,j=[];for(let W=0;W<D.length;W++){let T=D[W];if(T===void 0||T.skill.type!=="prompt")continue;let{skill:V}=T,Z=w[W];if(Z===null||Z===void 0){j.push(V);continue}let N=J.get(Z);if(N!==void 0){v(`Skipping duplicate skill '${V.name}' from ${V.source} (same file already loaded from ${N})`);continue}J.set(Z,V.source),j.push(V)}YOH("skill",j.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let P=D.length-j.length;if(P>0)v(`Deduplicated ${P} skills (same file)`);let X=[],G=[];for(let W of j)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!Ej.activatedConditionalSkillNames.has(W.name))G.push(W);else X.push(W);for(let W of G)Ej.conditionalSkills.set(W.name,W);if(G.length>0)v(`[skills] ${G.length} conditional skills stored (activated when matching files are touched)`);return v(`Loaded ${j.length} unique skills (${X.length} unconditional, ${G.length} conditional, managed: ${M.length}, user: ${$.length}, project: ${O.flat().length}, additional: ${z.flat().length}, legacy commands: ${Y.length})`),X});Ej=Qy_(),dy_=V1();fl9({createSkillCommand:By_,parseSkillFrontmatterFields:Uy_})});function Mq7(H){return H.split(gDH.win32.sep).join(gDH.posix.sep)}function oKH(H){let _=Mq7(H);return ly_?_.toLowerCase():_}function ZX6(H){let _=p8(),A=oKH(H),q=oKH(_);if(!A.startsWith(q))return null;if(A.includes("/projects/")&&A.endsWith(".jsonl"))return"session_transcript";return null}function Jz8(H){let _=H.split(gDH.win32.sep).join(gDH.posix.sep);if(_.includes(".jsonl")||_.includes("projects")&&_.includes("*.jsonl"))return"session_transcript";return null}function VvH(H){if(bK())return DF(H);return!1}function ot1(H){if(wz8.isTeamMemFile(H))return"team";if(VvH(H))return"personal";return null}function $q7(H){if(bK())return VX6(H);return!1}function IvH(H){if(VvH(H))return!0;if(wz8.isTeamMemFile(H))return!0;if(ZX6(H)!==null)return!0;if($q7(H))return!0;return!1}function iy_(H){let _=gDH.normalize(H),A=oKH(_);if(bK()&&(A.includes("/agent-memory/")||A.includes("/agent-memory-local/")))return!0;if(wz8.isTeamMemoryEnabled()&&wz8.isTeamMemPath(_))return!0;if(bK()){let M=BM(),$=oKH(M.replace(/[/\\]+$/,"")),O=oKH(M);if(A===$||A.startsWith(O))return!0}let q=oKH(p8()),K=oKH(YF()),L=A.startsWith(q),f=A.startsWith(K);if(!L&&!f)return!1;if(L&&A.includes("/projects/"))return!0;if(bK()&&A.includes("/memory/"))return!0;return!1}function at1(H){let _=p8(),A=YF(),q=bK()?BM().replace(/[/\\]+$/,""):"",K=oKH(H);if(![_,A,q].filter(Boolean).some(($)=>{if(K.includes(oKH($)))return!0;if(ly_)return K.includes(fX($).toLowerCase());return!1}))return!1;let M=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!M)return!1;for(let $ of M){let O=$.replace(/[,;|&>]+$/,""),z=ly_?zXH(O):O;if(IvH(z)||iy_(z))return!0}return!1}function st1(H){if(Jz8(H)!==null)return!0;if(bK()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gDH,wz8,ly_=!1;var xrH=E(()=>{Gf();Vn();F6();YR();gDH=require("path"),wz8=(MI(),qA(_g))});function jz8(H){let _=`${ZiH()}/`,A=".output";if(H.startsWith(_)&&H.endsWith(".output")){let q=H.slice(_.length,-7);if(q.length>0&&q.length<=20&&/^[a-zA-Z0-9_-]+$/.test(q))return q}return null}function tt1({file_path:H,offset:_,limit:A,pages:q},{verbose:K}){if(!H)return null;if(jz8(H))return"";let L=K?H:aL(H);if(q)return MK.createElement(MK.Fragment,null,MK.createElement(uI,{filePath:H},L),` \xB7 pages ${q}`);if(K&&(_||A)){let f=_??1,M=A?`lines ${f}-${f+A-1}`:`from line ${f}`;return MK.createElement(MK.Fragment,null,MK.createElement(uI,{filePath:H},L),` \xB7 ${M}`)}return MK.createElement(uI,{filePath:H},L)}function et1({file_path:H}){let _=H?jz8(H):null;if(!_)return null;return MK.createElement(I,{dimColor:!0}," ",_)}function He1(H){switch(H.type){case"image":{let{originalSize:_}=H.file,A=l1(_);return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read image (",A,")"))}case"notebook":{let{cells:_}=H.file;if(!_||_.length<1)return MK.createElement(I,{color:"error"},"No cells found in notebook");return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},_.length)," cells"))}case"pdf":{let{originalSize:_}=H.file,A=l1(_);return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read PDF (",A,")"))}case"parts":return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l1(H.file.originalSize),")"));case"text":{let{numLines:_}=H.file;return MK.createElement(G8,{height:1},MK.createElement(I,null,"Read ",MK.createElement(I,{bold:!0},_)," ",_===1?"line":"lines"))}case"file_unchanged":return MK.createElement(G8,{height:1},MK.createElement(I,{dimColor:!0},"Unchanged since last read"))}}function _e1(H,{verbose:_}){if(!_&&typeof H==="string"){if(H.includes(cv))return MK.createElement(G8,null,MK.createElement(I,{color:"error"},"File not found"));if(vq(H,"tool_use_error"))return MK.createElement(G8,null,MK.createElement(I,{color:"error"},"Error reading file"))}return MK.createElement(tD,{result:H,verbose:_})}function Ae1(H){if(H?.file_path?.startsWith(CO()))return"Reading Plan";if(H?.file_path&&jz8(H.file_path))return"Read agent output";return"Read"}function ry_(H){if(!H?.file_path)return null;let _=jz8(H.file_path);if(_)return _;return aL(H.file_path)}var MK;var qe1=E(()=>{h_();Pb();lYH();bq();dH();zK();EA();fj();tw();MK=m(wH(),1)});function zq7(H){if(Oq7.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function Dq7(H){let _=vvH.basename(H),A=/^(.+)([ \u202F])(AM|PM)(\.png)$/,q=_.match(A);if(!q)return;let K=q[2],L=K===" "?Yq7:" ";return H.replace(`${K}${q[3]}${q[4]}`,`${L}${q[3]}${q[4]}`)}function wq7(H){let _=p8();if(!H.startsWith(_))return null;let A=H.split(Wz8.win32.sep).join(Wz8.posix.sep);if(A.includes("/projects/")&&A.endsWith(".jsonl"))return"session_transcript";return null}function Pq7(){return pEH()?yZ9:k9_}function Xq7(H){return lS6({...H,tabAwareSeparator:pEH()})}function Wq7(H){let _=Me1.get(H);if(_===void 0)return"";return _r9(_)}async function Ke1(H,_,A){let q=A??a1H().maxTokens,K=yl9(H,_);if(!K||K<=q/4)return;let f=await $e1(H)??K;if(f>q)throw new xO8(f,q)}function Pz8(H,_,A,q){return{type:"image",file:{base64:H.toString("base64"),type:`image/${_}`,originalSize:A,dimensions:q}}}async function Le1(H,_,A,q,K,L,f,M,$,O,z,Y){if(q==="ipynb"){let N=await ZB1(A),S=SH(N),y=Buffer.byteLength(S);if(y>M){let p=YK()?`Use ${kA} with jq to read specific portions:
|
|
4981
4981
|
cat "${H}" | jq '.cells[:20]' # First 20 cells
|
|
4982
4982
|
cat "${H}" | jq '.cells[100:120]' # Cells 100-120
|
|
4983
4983
|
cat "${H}" | jq '.cells | length' # Count total cells
|
package/dist/linux-x64/cc.js
CHANGED
|
@@ -23,13 +23,13 @@ var Z69=Object.create;var{getPrototypeOf:G69,defineProperty:hXH,getOwnPropertyNa
|
|
|
23
23
|
Object.assign(A, {
|
|
24
24
|
post(...args) {
|
|
25
25
|
const [url, payload, ...remainArgs] = args;
|
|
26
|
-
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.
|
|
26
|
+
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.32' + '&session_id=' + v$() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
|
|
27
27
|
if (process.env.CODER_APIKEY) {
|
|
28
28
|
const headerValues = payload.headers.values;
|
|
29
29
|
headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
payload.headers.values.set('X-Coder-Version', '4.0.
|
|
32
|
+
payload.headers.values.set('X-Coder-Version', '4.0.32');
|
|
33
33
|
payload.headers.values.set('X-Coder-Platform', process.platform);
|
|
34
34
|
payload.headers.values.set('X-Coder-Arch', process.arch);
|
|
35
35
|
|
|
@@ -4979,7 +4979,7 @@ ${$.trim()}`);return K.join(q?" ":`
|
|
|
4979
4979
|
`)}function p75(H,$,q=!1){if(H instanceof yN){if(H.interrupted)throw new Mo(`Shell command interrupted for pattern "${$}": [Command interrupted]`);let A=ht7(H.stdout,H.stderr,q);throw new Mo(`Shell command failed for pattern "${$}": ${A}`)}let K=GH(H),_=q?`[Error: ${K}]`:`[Error]
|
|
4980
4980
|
${K}`;throw new Mo(_)}var yt7,Et7,m75,B75;var TrH=T(()=>{SV();cH();W$();I6();$w();qV();AA();yt7=require("crypto"),Et7=(()=>{let H;return()=>{if(!H)H=(vDH(),Kq(IL$)).PowerShellTool;return H}})(),m75=/```!\s*\n?([\s\S]*?)\n?```/g,B75=/(?<=^|\s)!`([^`]+)`/gm});var It7=T(()=>{cH();W$()});function U75(H,$){if($==="policySettings")return!1;return H==="skills"||H==="commands_DEPRECATED"||H==="plugin"}function GP$(H,$){switch(H){case"policySettings":return qY.join(cX(),".claude",$);case"userSettings":return qY.join(m8(),$);case"projectSettings":return`.claude/${$}`;case"plugin":return"plugin";default:return""}}function uh6(H){return[H.name,H.description,H.whenToUse].filter(Boolean).join(" ")}function TP$(H,$){return VA(uh6(H),$)}async function F75(H){try{return await St7.realpath(H)}catch{return null}}function g75(H,$){if(!H.hooks)return;let q=OR().safeParse(H.hooks);if(!q.success){N(`Invalid hooks in skill '${$}': ${q.error.message}`);return}return q.data}function Q75(H){if(!H.paths)return;let $=DY$(H.paths).map((q)=>{return q.endsWith("/**")?q.slice(0,-3):q}).filter((q)=>q.length>0);if($.length===0||$.every((q)=>q==="**"))return;return $}function mh6(H,$,q,K="Skill"){let _=xE(H.description,q),A=_??oHH($,K),z=H["user-invocable"]===void 0?!0:dUH(H["user-invocable"]),Y=H.model,f;if(typeof Y==="string"&&Y.trim().length>0){let w=Y.trim();f=w==="inherit"?void 0:M4(w)}let O=H.effort,M=O!==void 0?DC(O):void 0;if(O!==void 0&&M===void 0)N(`Skill ${q} has invalid effort '${O}'. Valid options: ${aF.join(", ")} or an integer`);return{displayName:H.name!=null?String(H.name):void 0,description:A,hasUserSpecifiedDescription:_!==null,allowedTools:et(H["allowed-tools"]),argumentHint:H["argument-hint"]!=null?String(H["argument-hint"]):void 0,argumentNames:nH8(H.arguments),whenToUse:H.when_to_use!=null?String(H.when_to_use):void 0,version:H.version!=null?String(H.version):void 0,model:f,disableModelInvocation:dUH(H["disable-model-invocation"]),userInvocable:z,hooks:g75(H,q),executionContext:H.context==="fork"?"fork":void 0,agent:H.agent!=null?String(H.agent):void 0,effort:M,shell:rt$(H.shell,q),createdBy:H.created_by==="dream-proposal"||H.improved_by==="dream-proposal"?"dream-proposal":void 0,declaredFields:it$(H)}}function Bh6({skillName:H,displayName:$,description:q,hasUserSpecifiedDescription:K,markdownContent:_,allowedTools:A,argumentHint:z,argumentNames:Y,whenToUse:f,version:O,model:M,disableModelInvocation:w,userInvocable:D,source:j,baseDir:J,loadedFrom:X,hooks:L,executionContext:P,agent:Z,paths:W,effort:G,shell:v,createdBy:V,declaredFields:E}){if(J&&A.length>0){let S=J;A=A.map((h)=>h.replace(/\$\{CLAUDE_SKILL_DIR\}/g,()=>S))}return{type:"prompt",name:H,description:q,hasUserSpecifiedDescription:K,allowedTools:A,argumentHint:z,argNames:Y.length>0?Y:void 0,whenToUse:f,version:O,model:M,disableModelInvocation:w,userInvocable:D,context:P,agent:Z,effort:G,paths:W,declaredFields:E,contentLength:_.length,isHidden:!D,progressMessage:"running",userFacingName(){return $||H},source:j,loadedFrom:X,createdBy:V,hooks:L,skillRoot:J,async getPromptForCommand(S,h){let C=J?`Base directory for this skill: ${J}
|
|
4981
4981
|
|
|
4982
|
-
${_}`:_;if(C=aFH(C,S,!0,Y,iH8),J){let R=J;C=C.replaceAll("${CLAUDE_SKILL_DIR}",R)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,v$()),C=C.replaceAll("${CLAUDE_EFFORT}",nT(M??h.options.mainLoopModel,G??h.getEffortValue())),U75(X,j)&&bO8())C=xO8(C);else if(X!=="mcp")C=await rHH(C,{...h,getToolPermissionContext(){let R=h.getToolPermissionContext();return{...R,alwaysAllowRules:{...R.alwaysAllowRules,command:A}}},getAppState(){let R=h.getAppState();return{...R,toolPermissionContext:{...R.toolPermissionContext,alwaysAllowRules:{...R.toolPermissionContext.alwaysAllowRules,command:A}}}}},`/${H}`,v);return[{type:"text",text:C}]}}}async function brH(H,$){let q=b$(),K;try{K=await q.readdir(H)}catch(z){if(!xK(z))N(`Failed to read skills directory ${H}: ${z}`,{level:"error"}),w8("skill_load_dir","skill_load_readdir_failed");return[]}let _=null,A=await Promise.all(K.map(async(z)=>{try{if(!z.isDirectory()&&!z.isSymbolicLink())return null;let Y=qY.join(H,z.name),f=qY.join(Y,"SKILL.md"),O;try{O=await q.readFile(f,{encoding:"utf-8"})}catch(L){if(!f8(L))N(`[skills] failed to read ${f}: ${L}`,{level:"warn"}),_="skill_load_read_failed";return null}let{frontmatter:M,content:w}=iM(O,f,{normalizeKeys:!0}),D=p9H(f,w),j=z.name;q0H("skill",M);let J=mh6(M,D,j),X=Q75(M);return{skill:Bh6({...J,skillName:j,markdownContent:D,source:$,baseDir:Y,loadedFrom:"skills",paths:X}),filePath:f}}catch(Y){return N(`[skills] failed to parse ${qY.join(H,z.name,"SKILL.md")}: ${Y}`,{level:"error"}),_="skill_load_parse_failed",null}}));if(_)xH("skill_load_dir",_);else SH("skill_load_dir");return A.filter((z)=>z!==null)}function ph6(H){return/^skill\.md$/i.test(qY.basename(H))}function d75(H){let $=new Map;for(let K of H){let _=qY.dirname(K.filePath),A=$.get(_)??[];A.push(K),$.set(_,A)}let q=[];for(let[K,_]of $){let A=_.filter((z)=>ph6(z.filePath));if(A.length>0){let z=A[0];if(A.length>1)N(`Multiple skill files found in ${K}, using ${qY.basename(z.filePath)}`);q.push(z)}else q.push(..._)}return q}function Ct7(H,$){let q=$.endsWith(qY.sep)?$.slice(0,-1):$;if(!H.startsWith(q+qY.sep))return"";let K=H.slice(q.length+1);return K?K.split(qY.sep).join(":"):""}function c75(H,$){let q=qY.dirname(H),K=qY.dirname(q),_=qY.basename(q),A=Ct7(K,$);return A?`${A}:${_}`:_}function l75(H,$){let q=qY.basename(H),K=qY.dirname(H),_=q.replace(/\.md$/,""),A=Ct7(K,$);return A?`${A}:${_}`:_}function n75(H){return ph6(H.filePath)?c75(H.filePath,H.baseDir):l75(H.filePath,H.baseDir)}async function i75(H){try{let $=await Zm("commands",H),q=d75($),K=[],_=!1;for(let{baseDir:A,filePath:z,frontmatter:Y,content:f,source:O}of q)try{let w=ph6(z)?qY.dirname(z):void 0,D=n75({baseDir:A,filePath:z,frontmatter:Y,content:f,source:O});q0H("skill",Y);let j=mh6(Y,f,D,"Custom command");K.push({skill:Bh6({...j,skillName:D,displayName:void 0,markdownContent:p9H(z,f),source:O,baseDir:w,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:z})}catch(M){N(`[skills] failed to load command from ${z}: ${M}`,{level:"error"}),_=!0}if(_)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else SH("skill_load_commands_dir");return K}catch($){return yH($),w8("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function fM8(){Uh6.cache?.clear?.(),Zm.cache?.clear?.(),GX.conditionalSkills.clear(),GX.activatedConditionalSkillNames.clear()}function Fh6(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function bt7(H){GX=H}function xt7(H){return gh6.subscribe(()=>{try{H()}catch($){yH($)}})}async function PiH(H,$){let q=b$(),K=$.endsWith(qY.sep)?$.slice(0,-1):$,_=[];for(let A of H){let z=qY.dirname(A);while(z.startsWith(K+qY.sep)){let Y=qY.join(z,".claude","skills");if(!GX.dynamicSkillDirs.has(Y)){GX.dynamicSkillDirs.add(Y);try{if(await q.stat(Y),await Eu8(z,K)){N(`[skills] Skipped gitignored skills dir: ${Y}`);continue}_.push(Y)}catch{}}let f=qY.dirname(z);if(f===z)break;z=f}}return _.sort((A,z)=>z.split(qY.sep).length-A.split(qY.sep).length)}async function WiH(H){if(!Ew("projectSettings")||WL("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let $=new Set(GX.dynamicSkills.keys()),q=await Promise.all(H.map((_)=>brH(_,"projectSettings")));for(let _=q.length-1;_>=0;_--)for(let{skill:A}of q[_]??[])if(A.type==="prompt")GX.dynamicSkills.set(A.name,A);let K=q.flat().length;if(K>0){let _=[...GX.dynamicSkills.keys()].filter((A)=>!$.has(A));if(N(`[skills] Dynamically discovered ${K} skills from ${H.length} directories`),_.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:$.size,newCount:GX.dynamicSkills.size,addedCount:_.length,directoryCount:H.length})}gh6.emit()}function ut7(){return Array.from(GX.dynamicSkills.values())}function ZiH(H,$){if(GX.conditionalSkills.size===0)return[];let q=[];for(let[K,_]of GX.conditionalSkills){if(_.type!=="prompt"||!_.paths||_.paths.length===0)continue;let A=Rt7.default().add(_.paths);for(let z of H){let Y=qY.isAbsolute(z)?qY.relative($,z):z;if(!Y||Y.startsWith("..")||qY.isAbsolute(Y))continue;if(A.ignores(Y)){GX.dynamicSkills.set(K,_),GX.conditionalSkills.delete(K),GX.activatedConditionalSkillNames.add(K),q.push(K),N(`[skills] Activated conditional skill '${K}' (matched path: ${Y})`);break}}}if(q.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:GX.dynamicSkills.size-q.length,newCount:GX.dynamicSkills.size,addedCount:q.length,directoryCount:0}),gh6.emit();return q}function mt7(){return Array.from(GX.conditionalSkills.values())}function Bt7(){GX.dynamicSkillDirs.clear(),GX.dynamicSkills.clear(),GX.conditionalSkills.clear(),GX.activatedConditionalSkillNames.clear()}var St7,Rt7,qY,Uh6,GX,gh6;var GQ=T(()=>{Z7();f$();wY$();z8();J$();EI();df$();e6();cH();hO();F$();W$();TZ();hq();XR$();_8();kg();vq();TrH();BA();YU();Wn();rN();x3();ny6();KV();ly6();It7();St7=require("fs/promises"),Rt7=m(yZH(),1),qY=require("path");Uh6=L8(async(H)=>{let $=qY.join(m8(),"skills"),q=qY.join(cX(),".claude","skills"),K=Qh6("skills",H);N(`Loading skills from: managed=${q}, user=${$}, project=[${K.join(", ")}]`);let _=EN(),A=WL("skills"),z=Ew("projectSettings")&&!A;if(x1()){if(_.length===0||!z)return N(`[bare] Skipping skill dir discovery (${_.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(_.map((G)=>brH(qY.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[Y,f,O,M,w]=await Promise.all([RH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(q,"policySettings"),Ew("userSettings")&&!A?brH($,"userSettings"):Promise.resolve([]),z?Promise.all(K.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),z?Promise.all(_.map((W)=>brH(qY.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),A?Promise.resolve([]):i75(H)]),D=[...Y,...f,...O.flat(),...M.flat(),...w],j=await Promise.all(D.map(({skill:W,filePath:G})=>W.type==="prompt"?F75(G):Promise.resolve(null))),J=new Map,X=[];for(let W=0;W<D.length;W++){let G=D[W];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:v}=G,V=j[W];if(V===null||V===void 0){X.push(v);continue}let E=J.get(V);if(E!==void 0){N(`Skipping duplicate skill '${v.name}' from ${v.source} (same file already loaded from ${E})`);continue}J.set(V,v.source),X.push(v)}wOH("skill",X.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let L=D.length-X.length;if(L>0)N(`Deduplicated ${L} skills (same file)`);let P=[],Z=[];for(let W of X)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!GX.activatedConditionalSkillNames.has(W.name))Z.push(W);else P.push(W);for(let W of Z)GX.conditionalSkills.set(W.name,W);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${X.length} unique skills (${P.length} unconditional, ${Z.length} conditional, managed: ${Y.length}, user: ${f.length}, project: ${O.flat().length}, additional: ${M.flat().length}, legacy commands: ${w.length})`),P});GX=Fh6(),gh6=v7();acK({createSkillCommand:Bh6,parseSkillFrontmatterFields:mh6})});function r75(H){return H.split(gDH.win32.sep).join(gDH.posix.sep)}function n9H(H){let $=r75(H);return dh6?$.toLowerCase():$}function VP$(H){let $=m8(),q=n9H(H),K=n9H($);if(!q.startsWith(K))return null;if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function MM8(H){let $=H.split(gDH.win32.sep).join(gDH.posix.sep);if($.includes(".jsonl")||$.includes("projects")&&$.includes("*.jsonl"))return"session_transcript";return null}function NNH(H){if(b9())return OF(H);return!1}function pt7(H){if(OM8.isTeamMemFile(H))return"team";if(NNH(H))return"personal";return null}function o75(H){if(b9())return vP$(H);return!1}function ENH(H){if(NNH(H))return!0;if(OM8.isTeamMemFile(H))return!0;if(VP$(H)!==null)return!0;if(o75(H))return!0;return!1}function lh6(H){let $=gDH.normalize(H),q=n9H($);if(b9()&&(q.includes("/agent-memory/")||q.includes("/agent-memory-local/")))return!0;if(OM8.isTeamMemoryEnabled()&&OM8.isTeamMemPath($))return!0;if(b9()){let Y=UY(),f=n9H(Y.replace(/[/\\]+$/,"")),O=n9H(Y);if(q===f||q.startsWith(O))return!0}let K=n9H(m8()),_=n9H(fF()),A=q.startsWith(K),z=q.startsWith(_);if(!A&&!z)return!1;if(A&&q.includes("/projects/"))return!0;if(b9()&&q.includes("/memory/"))return!0;return!1}function Ut7(H){let $=m8(),q=fF(),K=b9()?UY().replace(/[/\\]+$/,""):"",_=n9H(H);if(![$,q,K].filter(Boolean).some((f)=>{if(_.includes(n9H(f)))return!0;if(dh6)return _.includes(AP(f).toLowerCase());return!1}))return!1;let Y=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!Y)return!1;for(let f of Y){let O=f.replace(/[,;|&>]+$/,""),M=dh6?wPH(O):O;if(ENH(M)||lh6(M))return!0}return!1}function Ft7(H){if(MM8(H)!==null)return!0;if(b9()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gDH,OM8,dh6=!1;var xrH=T(()=>{Wz();Zn();F$();YR();gDH=require("path"),OM8=(zk(),Kq(tF))});function wM8(H){let $=`${ViH()}/`,q=".output";if(H.startsWith($)&&H.endsWith(".output")){let K=H.slice($.length,-7);if(K.length>0&&K.length<=20&&/^[a-zA-Z0-9_-]+$/.test(K))return K}return null}function gt7({file_path:H,offset:$,limit:q,pages:K},{verbose:_}){if(!H)return null;if(wM8(H))return"";let A=_?H:a1(H);if(K)return Y9.createElement(Y9.Fragment,null,Y9.createElement(xk,{filePath:H},A),` \xB7 pages ${K}`);if(_&&($||q)){let z=$??1,Y=q?`lines ${z}-${z+q-1}`:`from line ${z}`;return Y9.createElement(Y9.Fragment,null,Y9.createElement(xk,{filePath:H},A),` \xB7 ${Y}`)}return Y9.createElement(xk,{filePath:H},A)}function Qt7({file_path:H}){let $=H?wM8(H):null;if(!$)return null;return Y9.createElement(k,{dimColor:!0}," ",$)}function dt7(H){switch(H.type){case"image":{let{originalSize:$}=H.file,q=l7($);return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read image (",q,")"))}case"notebook":{let{cells:$}=H.file;if(!$||$.length<1)return Y9.createElement(k,{color:"error"},"No cells found in notebook");return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},$.length)," cells"))}case"pdf":{let{originalSize:$}=H.file,q=l7($);return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read PDF (",q,")"))}case"parts":return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:$}=H.file;return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},$)," ",$===1?"line":"lines"))}case"file_unchanged":return Y9.createElement(Z8,{height:1},Y9.createElement(k,{dimColor:!0},"Unchanged since last read"))}}function ct7(H,{verbose:$}){if(!$&&typeof H==="string"){if(H.includes(dN))return Y9.createElement(Z8,null,Y9.createElement(k,{color:"error"},"File not found"));if(N4(H,"tool_use_error"))return Y9.createElement(Z8,null,Y9.createElement(k,{color:"error"},"Error reading file"))}return Y9.createElement(tD,{result:H,verbose:$})}function lt7(H){if(H?.file_path?.startsWith(CO()))return"Reading Plan";if(H?.file_path&&wM8(H.file_path))return"Read agent output";return"Read"}function nh6(H){if(!H?.file_path)return null;let $=wM8(H.file_path);if($)return $;return a1(H.file_path)}var Y9;var nt7=T(()=>{I6();Db();lwH();b4();dH();M9();Tq();AX();sj();Y9=m(jH(),1)});function s75(H){if(a75.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function e75(H){let $=yNH.basename(H),q=/^(.+)([ \u202F])(AM|PM)(\.png)$/,K=$.match(q);if(!K)return;let _=K[2],A=_===" "?t75:" ";return H.replace(`${_}${K[3]}${K[4]}`,`${A}${K[3]}${K[4]}`)}function H45(H){let $=m8();if(!H.startsWith($))return null;let q=H.split(JM8.win32.sep).join(JM8.posix.sep);if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function K45(){return UTH()?GVK:TK6}function _45(H){return cS$({...H,tabAwareSeparator:UTH()})}function A45(H){let $=at7.get(H);if($===void 0)return"";return liK($)}async function it7(H,$,q){let K=q??i7H().maxTokens,_=WlK(H,$);if(!_||_<=K/4)return;let z=await st7(H)??_;if(z>K)throw new SO8(z,K)}function DM8(H,$,q,K){return{type:"image",file:{base64:H.toString("base64"),type:`image/${$}`,originalSize:q,dimensions:K}}}async function rt7(H,$,q,K,_,A,z,Y,f,O,M,w){if(K==="ipynb"){let E=await wU7(q),S=IH(E),h=Buffer.byteLength(S);if(h>Y){let B=w9()?`Use ${yq} with jq to read specific portions:
|
|
4982
|
+
${_}`:_;if(C=aFH(C,S,!0,Y,iH8),J){let R=J;C=C.replaceAll("${CLAUDE_SKILL_DIR}",R)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,v$()),C=C.replaceAll("${CLAUDE_EFFORT}",nT(M??h.options.mainLoopModel,G??h.getEffortValue())),U75(X,j)&&bO8())C=xO8(C);else if(X!=="mcp")C=await rHH(C,{...h,getToolPermissionContext(){let R=h.getToolPermissionContext();return{...R,alwaysAllowRules:{...R.alwaysAllowRules,command:A}}},getAppState(){let R=h.getAppState();return{...R,toolPermissionContext:{...R.toolPermissionContext,alwaysAllowRules:{...R.toolPermissionContext.alwaysAllowRules,command:A}}}}},`/${H}`,v);return[{type:"text",text:C}]}}}async function brH(H,$){let q=b$(),K;try{K=await q.readdir(H)}catch(z){if(!xK(z))N(`Failed to read skills directory ${H}: ${z}`,{level:"error"}),w8("skill_load_dir","skill_load_readdir_failed");return[]}let _=null,A=await Promise.all(K.map(async(z)=>{try{if(!z.isDirectory()&&!z.isSymbolicLink())return null;let Y=qY.join(H,z.name),f=qY.join(Y,"SKILL.md"),O;try{O=await q.readFile(f,{encoding:"utf-8"})}catch(L){if(!f8(L))N(`[skills] failed to read ${f}: ${L}`,{level:"warn"}),_="skill_load_read_failed";return null}let{frontmatter:M,content:w}=iM(O,f,{normalizeKeys:!0}),D=p9H(f,w),j=z.name;q0H("skill",M);let J=mh6(M,D,j),X=Q75(M);return{skill:Bh6({...J,skillName:j,markdownContent:D,source:$,baseDir:Y,loadedFrom:"skills",paths:X}),filePath:f}}catch(Y){return N(`[skills] failed to parse ${qY.join(H,z.name,"SKILL.md")}: ${Y}`,{level:"error"}),_="skill_load_parse_failed",null}}));if(_)xH("skill_load_dir",_);else SH("skill_load_dir");return A.filter((z)=>z!==null)}function ph6(H){return/^skill\.md$/i.test(qY.basename(H))}function d75(H){let $=new Map;for(let K of H){let _=qY.dirname(K.filePath),A=$.get(_)??[];A.push(K),$.set(_,A)}let q=[];for(let[K,_]of $){let A=_.filter((z)=>ph6(z.filePath));if(A.length>0){let z=A[0];if(A.length>1)N(`Multiple skill files found in ${K}, using ${qY.basename(z.filePath)}`);q.push(z)}else q.push(..._)}return q}function Ct7(H,$){let q=$.endsWith(qY.sep)?$.slice(0,-1):$;if(!H.startsWith(q+qY.sep))return"";let K=H.slice(q.length+1);return K?K.split(qY.sep).join(":"):""}function c75(H,$){let q=qY.dirname(H),K=qY.dirname(q),_=qY.basename(q),A=Ct7(K,$);return A?`${A}:${_}`:_}function l75(H,$){let q=qY.basename(H),K=qY.dirname(H),_=q.replace(/\.md$/,""),A=Ct7(K,$);return A?`${A}:${_}`:_}function n75(H){return ph6(H.filePath)?c75(H.filePath,H.baseDir):l75(H.filePath,H.baseDir)}async function i75(H){try{let $=await Zm("commands",H),q=d75($),K=[],_=!1;for(let{baseDir:A,filePath:z,frontmatter:Y,content:f,source:O}of q)try{let w=ph6(z)?qY.dirname(z):void 0,D=n75({baseDir:A,filePath:z,frontmatter:Y,content:f,source:O});q0H("skill",Y);let j=mh6(Y,f,D,"Custom command");K.push({skill:Bh6({...j,skillName:D,displayName:void 0,markdownContent:p9H(z,f),source:O,baseDir:w,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:z})}catch(M){N(`[skills] failed to load command from ${z}: ${M}`,{level:"error"}),_=!0}if(_)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else SH("skill_load_commands_dir");return K}catch($){return yH($),w8("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function fM8(){Uh6.cache?.clear?.(),Zm.cache?.clear?.(),GX.conditionalSkills.clear(),GX.activatedConditionalSkillNames.clear()}function Fh6(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function bt7(H){GX=H}function xt7(H){return gh6.subscribe(()=>{try{H()}catch($){yH($)}})}async function PiH(H,$){let q=b$(),K=$.endsWith(qY.sep)?$.slice(0,-1):$,_=[];for(let A of H){let z=qY.dirname(A);while(z.startsWith(K+qY.sep)){let Y=qY.join(z,".claude","skills");if(!GX.dynamicSkillDirs.has(Y)){GX.dynamicSkillDirs.add(Y);try{if(await q.stat(Y),await Eu8(z,K)){N(`[skills] Skipped gitignored skills dir: ${Y}`);continue}_.push(Y)}catch{}}let f=qY.dirname(z);if(f===z)break;z=f}}return _.sort((A,z)=>z.split(qY.sep).length-A.split(qY.sep).length)}async function WiH(H){if(!Ew("projectSettings")||WL("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let $=new Set(GX.dynamicSkills.keys()),q=await Promise.all(H.map((_)=>brH(_,"projectSettings")));for(let _=q.length-1;_>=0;_--)for(let{skill:A}of q[_]??[])if(A.type==="prompt")GX.dynamicSkills.set(A.name,A);let K=q.flat().length;if(K>0){let _=[...GX.dynamicSkills.keys()].filter((A)=>!$.has(A));if(N(`[skills] Dynamically discovered ${K} skills from ${H.length} directories`),_.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:$.size,newCount:GX.dynamicSkills.size,addedCount:_.length,directoryCount:H.length})}gh6.emit()}function ut7(){return Array.from(GX.dynamicSkills.values())}function ZiH(H,$){if(GX.conditionalSkills.size===0)return[];let q=[];for(let[K,_]of GX.conditionalSkills){if(_.type!=="prompt"||!_.paths||_.paths.length===0)continue;let A=Rt7.default().add(_.paths);for(let z of H){let Y=qY.isAbsolute(z)?qY.relative($,z):z;if(!Y||Y.startsWith("..")||qY.isAbsolute(Y))continue;if(A.ignores(Y)){GX.dynamicSkills.set(K,_),GX.conditionalSkills.delete(K),GX.activatedConditionalSkillNames.add(K),q.push(K),N(`[skills] Activated conditional skill '${K}' (matched path: ${Y})`);break}}}if(q.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:GX.dynamicSkills.size-q.length,newCount:GX.dynamicSkills.size,addedCount:q.length,directoryCount:0}),gh6.emit();return q}function mt7(){return Array.from(GX.conditionalSkills.values())}function Bt7(){GX.dynamicSkillDirs.clear(),GX.dynamicSkills.clear(),GX.conditionalSkills.clear(),GX.activatedConditionalSkillNames.clear()}var St7,Rt7,qY,Uh6,GX,gh6;var GQ=T(()=>{Z7();f$();wY$();z8();J$();EI();df$();e6();cH();hO();F$();W$();TZ();hq();XR$();_8();kg();vq();TrH();BA();YU();Wn();rN();x3();ny6();KV();ly6();It7();St7=require("fs/promises"),Rt7=m(yZH(),1),qY=require("path");Uh6=L8(async(H)=>{let $=qY.join(m8(),"skills"),q=qY.join(cX(),".claude","skills"),K=Qh6("skills",H);N(`Loading skills from: managed=${q}, user=${$}, project=[${K.join(", ")}]`);let _=EN(),A=WL("skills"),z=Ew("projectSettings")&&!A;if(x1()){if(_.length===0||!z)return N(`[bare] Skipping skill dir discovery (${_.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(_.map((G)=>brH(qY.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[Y,f,O,M,w]=await Promise.all([RH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):brH(q,"policySettings"),Ew("userSettings")&&!A?Promise.all([brH($,"userSettings"),brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings")]).then(([_a,_b])=>[..._a,..._b]):brH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings"),z?Promise.all(K.map((W)=>brH(W,"projectSettings"))):Promise.resolve([]),z?Promise.all(_.map((W)=>brH(qY.join(W,".claude","skills"),"projectSettings"))):Promise.resolve([]),A?Promise.resolve([]):i75(H)]),D=[...Y,...f,...O.flat(),...M.flat(),...w],j=await Promise.all(D.map(({skill:W,filePath:G})=>W.type==="prompt"?F75(G):Promise.resolve(null))),J=new Map,X=[];for(let W=0;W<D.length;W++){let G=D[W];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:v}=G,V=j[W];if(V===null||V===void 0){X.push(v);continue}let E=J.get(V);if(E!==void 0){N(`Skipping duplicate skill '${v.name}' from ${v.source} (same file already loaded from ${E})`);continue}J.set(V,v.source),X.push(v)}wOH("skill",X.map((W)=>({name:W.name,source:W.source})),{resolves:!1});let L=D.length-X.length;if(L>0)N(`Deduplicated ${L} skills (same file)`);let P=[],Z=[];for(let W of X)if(W.type==="prompt"&&W.paths&&W.paths.length>0&&!GX.activatedConditionalSkillNames.has(W.name))Z.push(W);else P.push(W);for(let W of Z)GX.conditionalSkills.set(W.name,W);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${X.length} unique skills (${P.length} unconditional, ${Z.length} conditional, managed: ${Y.length}, user: ${f.length}, project: ${O.flat().length}, additional: ${M.flat().length}, legacy commands: ${w.length})`),P});GX=Fh6(),gh6=v7();acK({createSkillCommand:Bh6,parseSkillFrontmatterFields:mh6})});function r75(H){return H.split(gDH.win32.sep).join(gDH.posix.sep)}function n9H(H){let $=r75(H);return dh6?$.toLowerCase():$}function VP$(H){let $=m8(),q=n9H(H),K=n9H($);if(!q.startsWith(K))return null;if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function MM8(H){let $=H.split(gDH.win32.sep).join(gDH.posix.sep);if($.includes(".jsonl")||$.includes("projects")&&$.includes("*.jsonl"))return"session_transcript";return null}function NNH(H){if(b9())return OF(H);return!1}function pt7(H){if(OM8.isTeamMemFile(H))return"team";if(NNH(H))return"personal";return null}function o75(H){if(b9())return vP$(H);return!1}function ENH(H){if(NNH(H))return!0;if(OM8.isTeamMemFile(H))return!0;if(VP$(H)!==null)return!0;if(o75(H))return!0;return!1}function lh6(H){let $=gDH.normalize(H),q=n9H($);if(b9()&&(q.includes("/agent-memory/")||q.includes("/agent-memory-local/")))return!0;if(OM8.isTeamMemoryEnabled()&&OM8.isTeamMemPath($))return!0;if(b9()){let Y=UY(),f=n9H(Y.replace(/[/\\]+$/,"")),O=n9H(Y);if(q===f||q.startsWith(O))return!0}let K=n9H(m8()),_=n9H(fF()),A=q.startsWith(K),z=q.startsWith(_);if(!A&&!z)return!1;if(A&&q.includes("/projects/"))return!0;if(b9()&&q.includes("/memory/"))return!0;return!1}function Ut7(H){let $=m8(),q=fF(),K=b9()?UY().replace(/[/\\]+$/,""):"",_=n9H(H);if(![$,q,K].filter(Boolean).some((f)=>{if(_.includes(n9H(f)))return!0;if(dh6)return _.includes(AP(f).toLowerCase());return!1}))return!1;let Y=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!Y)return!1;for(let f of Y){let O=f.replace(/[,;|&>]+$/,""),M=dh6?wPH(O):O;if(ENH(M)||lh6(M))return!0}return!1}function Ft7(H){if(MM8(H)!==null)return!0;if(b9()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var gDH,OM8,dh6=!1;var xrH=T(()=>{Wz();Zn();F$();YR();gDH=require("path"),OM8=(zk(),Kq(tF))});function wM8(H){let $=`${ViH()}/`,q=".output";if(H.startsWith($)&&H.endsWith(".output")){let K=H.slice($.length,-7);if(K.length>0&&K.length<=20&&/^[a-zA-Z0-9_-]+$/.test(K))return K}return null}function gt7({file_path:H,offset:$,limit:q,pages:K},{verbose:_}){if(!H)return null;if(wM8(H))return"";let A=_?H:a1(H);if(K)return Y9.createElement(Y9.Fragment,null,Y9.createElement(xk,{filePath:H},A),` \xB7 pages ${K}`);if(_&&($||q)){let z=$??1,Y=q?`lines ${z}-${z+q-1}`:`from line ${z}`;return Y9.createElement(Y9.Fragment,null,Y9.createElement(xk,{filePath:H},A),` \xB7 ${Y}`)}return Y9.createElement(xk,{filePath:H},A)}function Qt7({file_path:H}){let $=H?wM8(H):null;if(!$)return null;return Y9.createElement(k,{dimColor:!0}," ",$)}function dt7(H){switch(H.type){case"image":{let{originalSize:$}=H.file,q=l7($);return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read image (",q,")"))}case"notebook":{let{cells:$}=H.file;if(!$||$.length<1)return Y9.createElement(k,{color:"error"},"No cells found in notebook");return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},$.length)," cells"))}case"pdf":{let{originalSize:$}=H.file,q=l7($);return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read PDF (",q,")"))}case"parts":return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:$}=H.file;return Y9.createElement(Z8,{height:1},Y9.createElement(k,null,"Read ",Y9.createElement(k,{bold:!0},$)," ",$===1?"line":"lines"))}case"file_unchanged":return Y9.createElement(Z8,{height:1},Y9.createElement(k,{dimColor:!0},"Unchanged since last read"))}}function ct7(H,{verbose:$}){if(!$&&typeof H==="string"){if(H.includes(dN))return Y9.createElement(Z8,null,Y9.createElement(k,{color:"error"},"File not found"));if(N4(H,"tool_use_error"))return Y9.createElement(Z8,null,Y9.createElement(k,{color:"error"},"Error reading file"))}return Y9.createElement(tD,{result:H,verbose:$})}function lt7(H){if(H?.file_path?.startsWith(CO()))return"Reading Plan";if(H?.file_path&&wM8(H.file_path))return"Read agent output";return"Read"}function nh6(H){if(!H?.file_path)return null;let $=wM8(H.file_path);if($)return $;return a1(H.file_path)}var Y9;var nt7=T(()=>{I6();Db();lwH();b4();dH();M9();Tq();AX();sj();Y9=m(jH(),1)});function s75(H){if(a75.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function e75(H){let $=yNH.basename(H),q=/^(.+)([ \u202F])(AM|PM)(\.png)$/,K=$.match(q);if(!K)return;let _=K[2],A=_===" "?t75:" ";return H.replace(`${_}${K[3]}${K[4]}`,`${A}${K[3]}${K[4]}`)}function H45(H){let $=m8();if(!H.startsWith($))return null;let q=H.split(JM8.win32.sep).join(JM8.posix.sep);if(q.includes("/projects/")&&q.endsWith(".jsonl"))return"session_transcript";return null}function K45(){return UTH()?GVK:TK6}function _45(H){return cS$({...H,tabAwareSeparator:UTH()})}function A45(H){let $=at7.get(H);if($===void 0)return"";return liK($)}async function it7(H,$,q){let K=q??i7H().maxTokens,_=WlK(H,$);if(!_||_<=K/4)return;let z=await st7(H)??_;if(z>K)throw new SO8(z,K)}function DM8(H,$,q,K){return{type:"image",file:{base64:H.toString("base64"),type:`image/${$}`,originalSize:q,dimensions:K}}}async function rt7(H,$,q,K,_,A,z,Y,f,O,M,w){if(K==="ipynb"){let E=await wU7(q),S=IH(E),h=Buffer.byteLength(S);if(h>Y){let B=w9()?`Use ${yq} with jq to read specific portions:
|
|
4983
4983
|
cat "${H}" | jq '.cells[:20]' # First 20 cells
|
|
4984
4984
|
cat "${H}" | jq '.cells[100:120]' # Cells 100-120
|
|
4985
4985
|
cat "${H}" | jq '.cells | length' # Count total cells
|
package/dist/win32-x64/cc.js
CHANGED
|
@@ -23,13 +23,13 @@ var Hq4=Object.create;var{getPrototypeOf:qq4,defineProperty:NWH,getOwnPropertyNa
|
|
|
23
23
|
Object.assign(A, {
|
|
24
24
|
post(...args) {
|
|
25
25
|
const [url, payload, ...remainArgs] = args;
|
|
26
|
-
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.
|
|
26
|
+
const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.32' + '&session_id=' + v8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
|
|
27
27
|
if (process.env.CODER_APIKEY) {
|
|
28
28
|
const headerValues = payload.headers.values;
|
|
29
29
|
headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
payload.headers.values.set('X-Coder-Version', '4.0.
|
|
32
|
+
payload.headers.values.set('X-Coder-Version', '4.0.32');
|
|
33
33
|
payload.headers.values.set('X-Coder-Platform', process.platform);
|
|
34
34
|
payload.headers.values.set('X-Coder-Arch', process.arch);
|
|
35
35
|
|
|
@@ -5033,7 +5033,7 @@ ${q.trim()}`);return $.join(K?" ":`
|
|
|
5033
5033
|
`)}function v7A(H,q,K=!1){if(H instanceof EN){if(H.interrupted)throw new Mo(`Shell command interrupted for pattern "${q}": [Command interrupted]`);let A=Mt7(H.stdout,H.stderr,K);throw new Mo(`Shell command failed for pattern "${q}": ${A}`)}let $=GH(H),_=K?`[Error: ${$}]`:`[Error]
|
|
5034
5034
|
${$}`;throw new Mo(_)}var Yt7,zt7,V7A,T7A;var WrH=V(()=>{ST();cH();L8();Sq();tO();qT();Af();Yt7=require("crypto"),zt7=(()=>{let H;return()=>{if(!H)H=(TjH(),$K(EX8)).PowerShellTool;return H}})(),V7A=/```!\s*\n?([\s\S]*?)\n?```/g,T7A=/(?<=^|\s)!`([^`]+)`/gm});var Ot7=V(()=>{cH();L8()});function k7A(H,q){if(q==="policySettings")return!1;return H==="skills"||H==="commands_DEPRECATED"||H==="plugin"}function J28(H,q){switch(H){case"policySettings":return $z.join(cW(),".claude",q);case"userSettings":return $z.join(m6(),q);case"projectSettings":return`.claude/${q}`;case"plugin":return"plugin";default:return""}}function Eyq(H){return[H.name,H.description,H.whenToUse].filter(Boolean).join(" ")}function L28(H,q){return Tf(Eyq(H),q)}async function N7A(H){try{return await wt7.realpath(H)}catch{return null}}function E7A(H,q){if(!H.hooks)return;let K=MI().safeParse(H.hooks);if(!K.success){N(`Invalid hooks in skill '${q}': ${K.error.message}`);return}return K.data}function h7A(H){if(!H.paths)return;let q=Mz8(H.paths).map((K)=>{return K.endsWith("/**")?K.slice(0,-3):K}).filter((K)=>K.length>0);if(q.length===0||q.every((K)=>K==="**"))return;return q}function hyq(H,q,K,$="Skill"){let _=bE(H.description,K),A=_??oHH(q,$),f=H["user-invocable"]===void 0?!0:mUH(H["user-invocable"]),z=H.model,Y;if(typeof z==="string"&&z.trim().length>0){let w=z.trim();Y=w==="inherit"?void 0:O_(w)}let M=H.effort,O=M!==void 0?jC(M):void 0;if(M!==void 0&&O===void 0)N(`Skill ${K} has invalid effort '${M}'. Valid options: ${oF.join(", ")} or an integer`);return{displayName:H.name!=null?String(H.name):void 0,description:A,hasUserSpecifiedDescription:_!==null,allowedTools:tt(H["allowed-tools"]),argumentHint:H["argument-hint"]!=null?String(H["argument-hint"]):void 0,argumentNames:gH6(H.arguments),whenToUse:H.when_to_use!=null?String(H.when_to_use):void 0,version:H.version!=null?String(H.version):void 0,model:Y,disableModelInvocation:mUH(H["disable-model-invocation"]),userInvocable:f,hooks:E7A(H,K),executionContext:H.context==="fork"?"fork":void 0,agent:H.agent!=null?String(H.agent):void 0,effort:O,shell:dt8(H.shell,K),createdBy:H.created_by==="dream-proposal"||H.improved_by==="dream-proposal"?"dream-proposal":void 0,declaredFields:Qt8(H)}}function yyq({skillName:H,displayName:q,description:K,hasUserSpecifiedDescription:$,markdownContent:_,allowedTools:A,argumentHint:f,argumentNames:z,whenToUse:Y,version:M,model:O,disableModelInvocation:w,userInvocable:j,source:D,baseDir:P,loadedFrom:W,hooks:X,executionContext:J,agent:Z,paths:L,effort:G,shell:v,createdBy:T,declaredFields:E}){if(P&&A.length>0){let R=P.replaceAll("\\","/");A=A.map((y)=>y.replace(/\$\{CLAUDE_SKILL_DIR\}/g,()=>R))}return{type:"prompt",name:H,description:K,hasUserSpecifiedDescription:$,allowedTools:A,argumentHint:f,argNames:z.length>0?z:void 0,whenToUse:Y,version:M,model:O,disableModelInvocation:w,userInvocable:j,context:J,agent:Z,effort:G,paths:L,declaredFields:E,contentLength:_.length,isHidden:!j,progressMessage:"running",userFacingName(){return q||H},source:D,loadedFrom:W,createdBy:T,hooks:X,skillRoot:P,async getPromptForCommand(R,y){let C=P?`Base directory for this skill: ${P}
|
|
5035
5035
|
|
|
5036
|
-
${_}`:_;if(C=dFH(C,R,!0,z,QH6),P){let I=P.replaceAll("\\","/");C=C.replaceAll("${CLAUDE_SKILL_DIR}",I)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,v8()),C=C.replaceAll("${CLAUDE_EFFORT}",lV(O??y.options.mainLoopModel,G??y.getEffortValue())),k7A(W,D)&&hM6())C=yM6(C);else if(W!=="mcp")C=await rHH(C,{...y,getToolPermissionContext(){let I=y.getToolPermissionContext();return{...I,alwaysAllowRules:{...I.alwaysAllowRules,command:A}}},getAppState(){let I=y.getAppState();return{...I,toolPermissionContext:{...I.toolPermissionContext,alwaysAllowRules:{...I.toolPermissionContext.alwaysAllowRules,command:A}}}}},`/${H}`,v);return[{type:"text",text:C}]}}}async function hrH(H,q){let K=x8(),$;try{$=await K.readdir(H)}catch(f){if(!x$(f))N(`Failed to read skills directory ${H}: ${f}`,{level:"error"}),w6("skill_load_dir","skill_load_readdir_failed");return[]}let _=null,A=await Promise.all($.map(async(f)=>{try{if(!f.isDirectory()&&!f.isSymbolicLink())return null;let z=$z.join(H,f.name),Y=$z.join(z,"SKILL.md"),M;try{M=await K.readFile(Y,{encoding:"utf-8"})}catch(X){if(!O6(X))N(`[skills] failed to read ${Y}: ${X}`,{level:"warn"}),_="skill_load_read_failed";return null}let{frontmatter:O,content:w}=nO(M,Y,{normalizeKeys:!0}),j=B4H(Y,w),D=f.name;e0H("skill",O);let P=hyq(O,j,D),W=h7A(O);return{skill:yyq({...P,skillName:D,markdownContent:j,source:q,baseDir:z,loadedFrom:"skills",paths:W}),filePath:Y}}catch(z){return N(`[skills] failed to parse ${$z.join(H,f.name,"SKILL.md")}: ${z}`,{level:"error"}),_="skill_load_parse_failed",null}}));if(_)xH("skill_load_dir",_);else RH("skill_load_dir");return A.filter((f)=>f!==null)}function Syq(H){return/^skill\.md$/i.test($z.basename(H))}function y7A(H){let q=new Map;for(let $ of H){let _=$z.dirname($.filePath),A=q.get(_)??[];A.push($),q.set(_,A)}let K=[];for(let[$,_]of q){let A=_.filter((f)=>Syq(f.filePath));if(A.length>0){let f=A[0];if(A.length>1)N(`Multiple skill files found in ${$}, using ${$z.basename(f.filePath)}`);K.push(f)}else K.push(..._)}return K}function Dt7(H,q){let K=q.endsWith($z.sep)?q.slice(0,-1):q;if(!H.startsWith(K+$z.sep))return"";let $=H.slice(K.length+1);return $?$.split($z.sep).join(":"):""}function S7A(H,q){let K=$z.dirname(H),$=$z.dirname(K),_=$z.basename(K),A=Dt7($,q);return A?`${A}:${_}`:_}function R7A(H,q){let K=$z.basename(H),$=$z.dirname(H),_=K.replace(/\.md$/,""),A=Dt7($,q);return A?`${A}:${_}`:_}function I7A(H){return Syq(H.filePath)?S7A(H.filePath,H.baseDir):R7A(H.filePath,H.baseDir)}async function C7A(H){try{let q=await Lm("commands",H),K=y7A(q),$=[],_=!1;for(let{baseDir:A,filePath:f,frontmatter:z,content:Y,source:M}of K)try{let w=Syq(f)?$z.dirname(f):void 0,j=I7A({baseDir:A,filePath:f,frontmatter:z,content:Y,source:M});e0H("skill",z);let D=hyq(z,Y,j,"Custom command");$.push({skill:yyq({...D,skillName:j,displayName:void 0,markdownContent:B4H(f,Y),source:M,baseDir:w,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:f})}catch(O){N(`[skills] failed to load command from ${f}: ${O}`,{level:"error"}),_=!0}if(_)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else RH("skill_load_commands_dir");return $}catch(q){return hH(q),w6("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function KO6(){Ryq.cache?.clear?.(),Lm.cache?.clear?.(),GW.conditionalSkills.clear(),GW.activatedConditionalSkillNames.clear()}function Iyq(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function Pt7(H){GW=H}function Wt7(H){return Cyq.subscribe(()=>{try{H()}catch(q){hH(q)}})}async function wiH(H,q){let K=x8(),$=q.endsWith($z.sep)?q.slice(0,-1):q,_=[];for(let A of H){let f=$z.dirname(A);while(f.startsWith($+$z.sep)){let z=$z.join(f,".claude","skills");if(!GW.dynamicSkillDirs.has(z)){GW.dynamicSkillDirs.add(z);try{if(await K.stat(z),await Gu6(f,$)){N(`[skills] Skipped gitignored skills dir: ${z}`);continue}_.push(z)}catch{}}let Y=$z.dirname(f);if(Y===f)break;f=Y}}return _.sort((A,f)=>f.split($z.sep).length-A.split($z.sep).length)}async function jiH(H){if(!Tw("projectSettings")||LX("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let q=new Set(GW.dynamicSkills.keys()),K=await Promise.all(H.map((_)=>hrH(_,"projectSettings")));for(let _=K.length-1;_>=0;_--)for(let{skill:A}of K[_]??[])if(A.type==="prompt")GW.dynamicSkills.set(A.name,A);let $=K.flat().length;if($>0){let _=[...GW.dynamicSkills.keys()].filter((A)=>!q.has(A));if(N(`[skills] Dynamically discovered ${$} skills from ${H.length} directories`),_.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:q.size,newCount:GW.dynamicSkills.size,addedCount:_.length,directoryCount:H.length})}Cyq.emit()}function Xt7(){return Array.from(GW.dynamicSkills.values())}function DiH(H,q){if(GW.conditionalSkills.size===0)return[];let K=[];for(let[$,_]of GW.conditionalSkills){if(_.type!=="prompt"||!_.paths||_.paths.length===0)continue;let A=jt7.default().add(_.paths);for(let f of H){let z=$z.isAbsolute(f)?$z.relative(q,f):f;if(!z||z.startsWith("..")||$z.isAbsolute(z))continue;if(A.ignores(z)){GW.dynamicSkills.set($,_),GW.conditionalSkills.delete($),GW.activatedConditionalSkillNames.add($),K.push($),N(`[skills] Activated conditional skill '${$}' (matched path: ${z})`);break}}}if(K.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:GW.dynamicSkills.size-K.length,newCount:GW.dynamicSkills.size,addedCount:K.length,directoryCount:0}),Cyq.emit();return K}function Jt7(){return Array.from(GW.conditionalSkills.values())}function Lt7(){GW.dynamicSkillDirs.clear(),GW.dynamicSkills.clear(),GW.conditionalSkills.clear(),GW.activatedConditionalSkillNames.clear()}var wt7,jt7,$z,Ryq,GW,Cyq;var GQ=V(()=>{Z7();Y8();Yz8();f6();P8();NS();FY8();eq();cH();yM();F8();L8();VZ();yK();DI8();_6();kg();vK();WrH();pf();AU();Ln();iN();x3();phq();KT();mhq();Ot7();wt7=require("fs/promises"),jt7=m(kZH(),1),$z=require("path");Ryq=W6(async(H)=>{let q=$z.join(m6(),"skills"),K=$z.join(cW(),".claude","skills"),$=byq("skills",H);N(`Loading skills from: managed=${K}, user=${q}, project=[${$.join(", ")}]`);let _=NN(),A=LX("skills"),f=Tw("projectSettings")&&!A;if(x9()){if(_.length===0||!f)return N(`[bare] Skipping skill dir discovery (${_.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(_.map((G)=>hrH($z.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[z,Y,M,O,w]=await Promise.all([IH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):hrH(K,"policySettings"),Tw("userSettings")&&!A?hrH(q,"userSettings"):Promise.resolve([]),f?Promise.all($.map((L)=>hrH(L,"projectSettings"))):Promise.resolve([]),f?Promise.all(_.map((L)=>hrH($z.join(L,".claude","skills"),"projectSettings"))):Promise.resolve([]),A?Promise.resolve([]):C7A(H)]),j=[...z,...Y,...M.flat(),...O.flat(),...w],D=await Promise.all(j.map(({skill:L,filePath:G})=>L.type==="prompt"?N7A(G):Promise.resolve(null))),P=new Map,W=[];for(let L=0;L<j.length;L++){let G=j[L];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:v}=G,T=D[L];if(T===null||T===void 0){W.push(v);continue}let E=P.get(T);if(E!==void 0){N(`Skipping duplicate skill '${v.name}' from ${v.source} (same file already loaded from ${E})`);continue}P.set(T,v.source),W.push(v)}jMH("skill",W.map((L)=>({name:L.name,source:L.source})),{resolves:!1});let X=j.length-W.length;if(X>0)N(`Deduplicated ${X} skills (same file)`);let J=[],Z=[];for(let L of W)if(L.type==="prompt"&&L.paths&&L.paths.length>0&&!GW.activatedConditionalSkillNames.has(L.name))Z.push(L);else J.push(L);for(let L of Z)GW.conditionalSkills.set(L.name,L);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${W.length} unique skills (${J.length} unconditional, ${Z.length} conditional, managed: ${z.length}, user: ${Y.length}, project: ${M.flat().length}, additional: ${O.flat().length}, legacy commands: ${w.length})`),J});GW=Iyq(),Cyq=v7();yc$({createSkillCommand:yyq,parseSkillFrontmatterFields:hyq})});function b7A(H){return H.split(FjH.win32.sep).join(FjH.posix.sep)}function n4H(H){let q=b7A(H);return xyq?q.toLowerCase():q}function Z28(H){let q=m6(),K=n4H(H),$=n4H(q);if(!K.startsWith($))return null;if(K.includes("/projects/")&&K.endsWith(".jsonl"))return"session_transcript";return null}function _O6(H){let q=H.split(FjH.win32.sep).join(FjH.posix.sep);if(q.includes(".jsonl")||q.includes("projects")&&q.includes("*.jsonl"))return"session_transcript";return null}function vNH(H){if(b4())return YF(H);return!1}function Zt7(H){if($O6.isTeamMemFile(H))return"team";if(vNH(H))return"personal";return null}function x7A(H){if(b4())return G28(H);return!1}function kNH(H){if(vNH(H))return!0;if($O6.isTeamMemFile(H))return!0;if(Z28(H)!==null)return!0;if(x7A(H))return!0;return!1}function myq(H){let q=FjH.normalize(H),K=n4H(q);if(b4()&&(K.includes("/agent-memory/")||K.includes("/agent-memory-local/")))return!0;if($O6.isTeamMemoryEnabled()&&$O6.isTeamMemPath(q))return!0;if(b4()){let z=Bz(),Y=n4H(z.replace(/[/\\]+$/,"")),M=n4H(z);if(K===Y||K.startsWith(M))return!0}let $=n4H(m6()),_=n4H(zF()),A=K.startsWith($),f=K.startsWith(_);if(!A&&!f)return!1;if(A&&K.includes("/projects/"))return!0;if(b4()&&K.includes("/memory/"))return!0;return!1}function Gt7(H){let q=m6(),K=zF(),$=b4()?Bz().replace(/[/\\]+$/,""):"",_=n4H(H);if(![q,K,$].filter(Boolean).some((Y)=>{if(_.includes(n4H(Y)))return!0;if(xyq)return _.includes(A2(Y).toLowerCase());return!1}))return!1;let z=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!z)return!1;for(let Y of z){let M=Y.replace(/[,;|&>]+$/,""),O=xyq?Y2H(M):M;if(kNH(O)||myq(O))return!0}return!1}function Vt7(H){if(_O6(H)!==null)return!0;if(b4()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var FjH,$O6,xyq=!0;var yrH=V(()=>{Z5();Zn();F8();fI();FjH=require("path"),$O6=(Ak(),$K(sF))});function AO6(H){let q=`${XiH()}/`,K=".output";if(H.startsWith(q)&&H.endsWith(".output")){let $=H.slice(q.length,-7);if($.length>0&&$.length<=20&&/^[a-zA-Z0-9_-]+$/.test($))return $}return null}function Tt7({file_path:H,offset:q,limit:K,pages:$},{verbose:_}){if(!H)return null;if(AO6(H))return"";let A=_?H:a9(H);if($)return z4.createElement(z4.Fragment,null,z4.createElement(bk,{filePath:H},A),` \xB7 pages ${$}`);if(_&&(q||K)){let f=q??1,z=K?`lines ${f}-${f+K-1}`:`from line ${f}`;return z4.createElement(z4.Fragment,null,z4.createElement(bk,{filePath:H},A),` \xB7 ${z}`)}return z4.createElement(bk,{filePath:H},A)}function vt7({file_path:H}){let q=H?AO6(H):null;if(!q)return null;return z4.createElement(k,{dimColor:!0}," ",q)}function kt7(H){switch(H.type){case"image":{let{originalSize:q}=H.file,K=l7(q);return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read image (",K,")"))}case"notebook":{let{cells:q}=H.file;if(!q||q.length<1)return z4.createElement(k,{color:"error"},"No cells found in notebook");return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},q.length)," cells"))}case"pdf":{let{originalSize:q}=H.file,K=l7(q);return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read PDF (",K,")"))}case"parts":return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:q}=H.file;return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},q)," ",q===1?"line":"lines"))}case"file_unchanged":return z4.createElement(Z6,{height:1},z4.createElement(k,{dimColor:!0},"Unchanged since last read"))}}function Nt7(H,{verbose:q}){if(!q&&typeof H==="string"){if(H.includes(QN))return z4.createElement(Z6,null,z4.createElement(k,{color:"error"},"File not found"));if(N_(H,"tool_use_error"))return z4.createElement(Z6,null,z4.createElement(k,{color:"error"},"Error reading file"))}return z4.createElement(ej,{result:H,verbose:q})}function Et7(H){if(H?.file_path?.startsWith(CM()))return"Reading Plan";if(H?.file_path&&AO6(H.file_path))return"Read agent output";return"Read"}function pyq(H){if(!H?.file_path)return null;let q=AO6(H.file_path);if(q)return q;return a9(H.file_path)}var z4;var ht7=V(()=>{Sq();jb();cwH();b_();dH();O4();VK();AW();tD();z4=m(DH(),1)});function m7A(H){if(u7A.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function B7A(H){let q=NNH.basename(H),K=/^(.+)([ \u202F])(AM|PM)(\.png)$/,$=q.match(K);if(!$)return;let _=$[2],A=_===" "?p7A:" ";return H.replace(`${_}${$[3]}${$[4]}`,`${A}${$[3]}${$[4]}`)}function U7A(H){let q=m6();if(!H.startsWith(q))return null;let K=H.split(YO6.win32.sep).join(YO6.posix.sep);if(K.includes("/projects/")&&K.endsWith(".jsonl"))return"session_transcript";return null}function Q7A(){return pVH()?tV$:P$q}function d7A(H){return dR8({...H,tabAwareSeparator:pVH()})}function c7A(H){let q=It7.get(H);if(q===void 0)return"";return vi$(q)}async function yt7(H,q,K){let $=K??n7H().maxTokens,_=ac$(H,q);if(!_||_<=$/4)return;let f=await Ct7(H)??_;if(f>$)throw new kM6(f,$)}function fO6(H,q,K,$){return{type:"image",file:{base64:H.toString("base64"),type:`image/${q}`,originalSize:K,dimensions:$}}}async function St7(H,q,K,$,_,A,f,z,Y,M,O,w){if($==="ipynb"){let E=await nB7(K),R=SH(E),y=Buffer.byteLength(R);if(y>z){let p=w4()?`Use ${hK} with jq to read specific portions:
|
|
5036
|
+
${_}`:_;if(C=dFH(C,R,!0,z,QH6),P){let I=P.replaceAll("\\","/");C=C.replaceAll("${CLAUDE_SKILL_DIR}",I)}if(C=C.replace(/\$\{CLAUDE_SESSION_ID\}/g,v8()),C=C.replaceAll("${CLAUDE_EFFORT}",lV(O??y.options.mainLoopModel,G??y.getEffortValue())),k7A(W,D)&&hM6())C=yM6(C);else if(W!=="mcp")C=await rHH(C,{...y,getToolPermissionContext(){let I=y.getToolPermissionContext();return{...I,alwaysAllowRules:{...I.alwaysAllowRules,command:A}}},getAppState(){let I=y.getAppState();return{...I,toolPermissionContext:{...I.toolPermissionContext,alwaysAllowRules:{...I.toolPermissionContext.alwaysAllowRules,command:A}}}}},`/${H}`,v);return[{type:"text",text:C}]}}}async function hrH(H,q){let K=x8(),$;try{$=await K.readdir(H)}catch(f){if(!x$(f))N(`Failed to read skills directory ${H}: ${f}`,{level:"error"}),w6("skill_load_dir","skill_load_readdir_failed");return[]}let _=null,A=await Promise.all($.map(async(f)=>{try{if(!f.isDirectory()&&!f.isSymbolicLink())return null;let z=$z.join(H,f.name),Y=$z.join(z,"SKILL.md"),M;try{M=await K.readFile(Y,{encoding:"utf-8"})}catch(X){if(!O6(X))N(`[skills] failed to read ${Y}: ${X}`,{level:"warn"}),_="skill_load_read_failed";return null}let{frontmatter:O,content:w}=nO(M,Y,{normalizeKeys:!0}),j=B4H(Y,w),D=f.name;e0H("skill",O);let P=hyq(O,j,D),W=h7A(O);return{skill:yyq({...P,skillName:D,markdownContent:j,source:q,baseDir:z,loadedFrom:"skills",paths:W}),filePath:Y}}catch(z){return N(`[skills] failed to parse ${$z.join(H,f.name,"SKILL.md")}: ${z}`,{level:"error"}),_="skill_load_parse_failed",null}}));if(_)xH("skill_load_dir",_);else RH("skill_load_dir");return A.filter((f)=>f!==null)}function Syq(H){return/^skill\.md$/i.test($z.basename(H))}function y7A(H){let q=new Map;for(let $ of H){let _=$z.dirname($.filePath),A=q.get(_)??[];A.push($),q.set(_,A)}let K=[];for(let[$,_]of q){let A=_.filter((f)=>Syq(f.filePath));if(A.length>0){let f=A[0];if(A.length>1)N(`Multiple skill files found in ${$}, using ${$z.basename(f.filePath)}`);K.push(f)}else K.push(..._)}return K}function Dt7(H,q){let K=q.endsWith($z.sep)?q.slice(0,-1):q;if(!H.startsWith(K+$z.sep))return"";let $=H.slice(K.length+1);return $?$.split($z.sep).join(":"):""}function S7A(H,q){let K=$z.dirname(H),$=$z.dirname(K),_=$z.basename(K),A=Dt7($,q);return A?`${A}:${_}`:_}function R7A(H,q){let K=$z.basename(H),$=$z.dirname(H),_=K.replace(/\.md$/,""),A=Dt7($,q);return A?`${A}:${_}`:_}function I7A(H){return Syq(H.filePath)?S7A(H.filePath,H.baseDir):R7A(H.filePath,H.baseDir)}async function C7A(H){try{let q=await Lm("commands",H),K=y7A(q),$=[],_=!1;for(let{baseDir:A,filePath:f,frontmatter:z,content:Y,source:M}of K)try{let w=Syq(f)?$z.dirname(f):void 0,j=I7A({baseDir:A,filePath:f,frontmatter:z,content:Y,source:M});e0H("skill",z);let D=hyq(z,Y,j,"Custom command");$.push({skill:yyq({...D,skillName:j,displayName:void 0,markdownContent:B4H(f,Y),source:M,baseDir:w,loadedFrom:"commands_DEPRECATED",paths:void 0}),filePath:f})}catch(O){N(`[skills] failed to load command from ${f}: ${O}`,{level:"error"}),_=!0}if(_)xH("skill_load_commands_dir","skill_load_commands_parse_failed");else RH("skill_load_commands_dir");return $}catch(q){return hH(q),w6("skill_load_commands_dir","skill_load_commands_dir_failed"),[]}}function KO6(){Ryq.cache?.clear?.(),Lm.cache?.clear?.(),GW.conditionalSkills.clear(),GW.activatedConditionalSkillNames.clear()}function Iyq(){return{dynamicSkillDirs:new Set,dynamicSkills:new Map,conditionalSkills:new Map,activatedConditionalSkillNames:new Set}}function Pt7(H){GW=H}function Wt7(H){return Cyq.subscribe(()=>{try{H()}catch(q){hH(q)}})}async function wiH(H,q){let K=x8(),$=q.endsWith($z.sep)?q.slice(0,-1):q,_=[];for(let A of H){let f=$z.dirname(A);while(f.startsWith($+$z.sep)){let z=$z.join(f,".claude","skills");if(!GW.dynamicSkillDirs.has(z)){GW.dynamicSkillDirs.add(z);try{if(await K.stat(z),await Gu6(f,$)){N(`[skills] Skipped gitignored skills dir: ${z}`);continue}_.push(z)}catch{}}let Y=$z.dirname(f);if(Y===f)break;f=Y}}return _.sort((A,f)=>f.split($z.sep).length-A.split($z.sep).length)}async function jiH(H){if(!Tw("projectSettings")||LX("skills")){N("[skills] Dynamic skill discovery skipped: projectSettings disabled or plugin-only policy");return}if(H.length===0)return;let q=new Set(GW.dynamicSkills.keys()),K=await Promise.all(H.map((_)=>hrH(_,"projectSettings")));for(let _=K.length-1;_>=0;_--)for(let{skill:A}of K[_]??[])if(A.type==="prompt")GW.dynamicSkills.set(A.name,A);let $=K.flat().length;if($>0){let _=[...GW.dynamicSkills.keys()].filter((A)=>!q.has(A));if(N(`[skills] Dynamically discovered ${$} skills from ${H.length} directories`),_.length>0)Q("tengu_dynamic_skills_changed",{source:"file_operation",previousCount:q.size,newCount:GW.dynamicSkills.size,addedCount:_.length,directoryCount:H.length})}Cyq.emit()}function Xt7(){return Array.from(GW.dynamicSkills.values())}function DiH(H,q){if(GW.conditionalSkills.size===0)return[];let K=[];for(let[$,_]of GW.conditionalSkills){if(_.type!=="prompt"||!_.paths||_.paths.length===0)continue;let A=jt7.default().add(_.paths);for(let f of H){let z=$z.isAbsolute(f)?$z.relative(q,f):f;if(!z||z.startsWith("..")||$z.isAbsolute(z))continue;if(A.ignores(z)){GW.dynamicSkills.set($,_),GW.conditionalSkills.delete($),GW.activatedConditionalSkillNames.add($),K.push($),N(`[skills] Activated conditional skill '${$}' (matched path: ${z})`);break}}}if(K.length>0)Q("tengu_dynamic_skills_changed",{source:"conditional_paths",previousCount:GW.dynamicSkills.size-K.length,newCount:GW.dynamicSkills.size,addedCount:K.length,directoryCount:0}),Cyq.emit();return K}function Jt7(){return Array.from(GW.conditionalSkills.values())}function Lt7(){GW.dynamicSkillDirs.clear(),GW.dynamicSkills.clear(),GW.conditionalSkills.clear(),GW.activatedConditionalSkillNames.clear()}var wt7,jt7,$z,Ryq,GW,Cyq;var GQ=V(()=>{Z7();Y8();Yz8();f6();P8();NS();FY8();eq();cH();yM();F8();L8();VZ();yK();DI8();_6();kg();vK();WrH();pf();AU();Ln();iN();x3();phq();KT();mhq();Ot7();wt7=require("fs/promises"),jt7=m(kZH(),1),$z=require("path");Ryq=W6(async(H)=>{let q=$z.join(m6(),"skills"),K=$z.join(cW(),".claude","skills"),$=byq("skills",H);N(`Loading skills from: managed=${K}, user=${q}, project=[${$.join(", ")}]`);let _=NN(),A=LX("skills"),f=Tw("projectSettings")&&!A;if(x9()){if(_.length===0||!f)return N(`[bare] Skipping skill dir discovery (${_.length===0?"no --add-dir":"projectSettings disabled or skillsLocked"})`),[];return(await Promise.all(_.map((G)=>hrH($z.join(G,".claude","skills"),"projectSettings")))).flat().map((G)=>G.skill)}let[z,Y,M,O,w]=await Promise.all([IH(process.env.CLAUDE_CODE_DISABLE_POLICY_SKILLS)?Promise.resolve([]):hrH(K,"policySettings"),Tw("userSettings")&&!A?Promise.all([hrH(q,"userSettings"),hrH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings")]).then(([_a,_b])=>[..._a,..._b]):hrH(require("path").join(require("os").homedir(),".agents","skills"),"userSettings"),f?Promise.all($.map((L)=>hrH(L,"projectSettings"))):Promise.resolve([]),f?Promise.all(_.map((L)=>hrH($z.join(L,".claude","skills"),"projectSettings"))):Promise.resolve([]),A?Promise.resolve([]):C7A(H)]),j=[...z,...Y,...M.flat(),...O.flat(),...w],D=await Promise.all(j.map(({skill:L,filePath:G})=>L.type==="prompt"?N7A(G):Promise.resolve(null))),P=new Map,W=[];for(let L=0;L<j.length;L++){let G=j[L];if(G===void 0||G.skill.type!=="prompt")continue;let{skill:v}=G,T=D[L];if(T===null||T===void 0){W.push(v);continue}let E=P.get(T);if(E!==void 0){N(`Skipping duplicate skill '${v.name}' from ${v.source} (same file already loaded from ${E})`);continue}P.set(T,v.source),W.push(v)}jMH("skill",W.map((L)=>({name:L.name,source:L.source})),{resolves:!1});let X=j.length-W.length;if(X>0)N(`Deduplicated ${X} skills (same file)`);let J=[],Z=[];for(let L of W)if(L.type==="prompt"&&L.paths&&L.paths.length>0&&!GW.activatedConditionalSkillNames.has(L.name))Z.push(L);else J.push(L);for(let L of Z)GW.conditionalSkills.set(L.name,L);if(Z.length>0)N(`[skills] ${Z.length} conditional skills stored (activated when matching files are touched)`);return N(`Loaded ${W.length} unique skills (${J.length} unconditional, ${Z.length} conditional, managed: ${z.length}, user: ${Y.length}, project: ${M.flat().length}, additional: ${O.flat().length}, legacy commands: ${w.length})`),J});GW=Iyq(),Cyq=v7();yc$({createSkillCommand:yyq,parseSkillFrontmatterFields:hyq})});function b7A(H){return H.split(FjH.win32.sep).join(FjH.posix.sep)}function n4H(H){let q=b7A(H);return xyq?q.toLowerCase():q}function Z28(H){let q=m6(),K=n4H(H),$=n4H(q);if(!K.startsWith($))return null;if(K.includes("/projects/")&&K.endsWith(".jsonl"))return"session_transcript";return null}function _O6(H){let q=H.split(FjH.win32.sep).join(FjH.posix.sep);if(q.includes(".jsonl")||q.includes("projects")&&q.includes("*.jsonl"))return"session_transcript";return null}function vNH(H){if(b4())return YF(H);return!1}function Zt7(H){if($O6.isTeamMemFile(H))return"team";if(vNH(H))return"personal";return null}function x7A(H){if(b4())return G28(H);return!1}function kNH(H){if(vNH(H))return!0;if($O6.isTeamMemFile(H))return!0;if(Z28(H)!==null)return!0;if(x7A(H))return!0;return!1}function myq(H){let q=FjH.normalize(H),K=n4H(q);if(b4()&&(K.includes("/agent-memory/")||K.includes("/agent-memory-local/")))return!0;if($O6.isTeamMemoryEnabled()&&$O6.isTeamMemPath(q))return!0;if(b4()){let z=Bz(),Y=n4H(z.replace(/[/\\]+$/,"")),M=n4H(z);if(K===Y||K.startsWith(M))return!0}let $=n4H(m6()),_=n4H(zF()),A=K.startsWith($),f=K.startsWith(_);if(!A&&!f)return!1;if(A&&K.includes("/projects/"))return!0;if(b4()&&K.includes("/memory/"))return!0;return!1}function Gt7(H){let q=m6(),K=zF(),$=b4()?Bz().replace(/[/\\]+$/,""):"",_=n4H(H);if(![q,K,$].filter(Boolean).some((Y)=>{if(_.includes(n4H(Y)))return!0;if(xyq)return _.includes(A2(Y).toLowerCase());return!1}))return!1;let z=H.match(/(?:[A-Za-z]:[/\\]|\/)[^\s'"]+/g);if(!z)return!1;for(let Y of z){let M=Y.replace(/[,;|&>]+$/,""),O=xyq?Y2H(M):M;if(kNH(O)||myq(O))return!0}return!1}function Vt7(H){if(_O6(H)!==null)return!0;if(b4()&&(H.replaceAll("\\","/").includes("agent-memory/")||H.replaceAll("\\","/").includes("agent-memory-local/")))return!0;return!1}var FjH,$O6,xyq=!0;var yrH=V(()=>{Z5();Zn();F8();fI();FjH=require("path"),$O6=(Ak(),$K(sF))});function AO6(H){let q=`${XiH()}/`,K=".output";if(H.startsWith(q)&&H.endsWith(".output")){let $=H.slice(q.length,-7);if($.length>0&&$.length<=20&&/^[a-zA-Z0-9_-]+$/.test($))return $}return null}function Tt7({file_path:H,offset:q,limit:K,pages:$},{verbose:_}){if(!H)return null;if(AO6(H))return"";let A=_?H:a9(H);if($)return z4.createElement(z4.Fragment,null,z4.createElement(bk,{filePath:H},A),` \xB7 pages ${$}`);if(_&&(q||K)){let f=q??1,z=K?`lines ${f}-${f+K-1}`:`from line ${f}`;return z4.createElement(z4.Fragment,null,z4.createElement(bk,{filePath:H},A),` \xB7 ${z}`)}return z4.createElement(bk,{filePath:H},A)}function vt7({file_path:H}){let q=H?AO6(H):null;if(!q)return null;return z4.createElement(k,{dimColor:!0}," ",q)}function kt7(H){switch(H.type){case"image":{let{originalSize:q}=H.file,K=l7(q);return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read image (",K,")"))}case"notebook":{let{cells:q}=H.file;if(!q||q.length<1)return z4.createElement(k,{color:"error"},"No cells found in notebook");return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},q.length)," cells"))}case"pdf":{let{originalSize:q}=H.file,K=l7(q);return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read PDF (",K,")"))}case"parts":return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},H.file.count)," ",H.file.count===1?"page":"pages"," (",l7(H.file.originalSize),")"));case"text":{let{numLines:q}=H.file;return z4.createElement(Z6,{height:1},z4.createElement(k,null,"Read ",z4.createElement(k,{bold:!0},q)," ",q===1?"line":"lines"))}case"file_unchanged":return z4.createElement(Z6,{height:1},z4.createElement(k,{dimColor:!0},"Unchanged since last read"))}}function Nt7(H,{verbose:q}){if(!q&&typeof H==="string"){if(H.includes(QN))return z4.createElement(Z6,null,z4.createElement(k,{color:"error"},"File not found"));if(N_(H,"tool_use_error"))return z4.createElement(Z6,null,z4.createElement(k,{color:"error"},"Error reading file"))}return z4.createElement(ej,{result:H,verbose:q})}function Et7(H){if(H?.file_path?.startsWith(CM()))return"Reading Plan";if(H?.file_path&&AO6(H.file_path))return"Read agent output";return"Read"}function pyq(H){if(!H?.file_path)return null;let q=AO6(H.file_path);if(q)return q;return a9(H.file_path)}var z4;var ht7=V(()=>{Sq();jb();cwH();b_();dH();O4();VK();AW();tD();z4=m(DH(),1)});function m7A(H){if(u7A.has(H))return!0;if(H.startsWith("/proc/")&&(H.endsWith("/fd/0")||H.endsWith("/fd/1")||H.endsWith("/fd/2")))return!0;if(/^\/proc\/[^/]+\/(environ|cmdline|auxv|maps|mem|stat)$/.test(H))return!0;return!1}function B7A(H){let q=NNH.basename(H),K=/^(.+)([ \u202F])(AM|PM)(\.png)$/,$=q.match(K);if(!$)return;let _=$[2],A=_===" "?p7A:" ";return H.replace(`${_}${$[3]}${$[4]}`,`${A}${$[3]}${$[4]}`)}function U7A(H){let q=m6();if(!H.startsWith(q))return null;let K=H.split(YO6.win32.sep).join(YO6.posix.sep);if(K.includes("/projects/")&&K.endsWith(".jsonl"))return"session_transcript";return null}function Q7A(){return pVH()?tV$:P$q}function d7A(H){return dR8({...H,tabAwareSeparator:pVH()})}function c7A(H){let q=It7.get(H);if(q===void 0)return"";return vi$(q)}async function yt7(H,q,K){let $=K??n7H().maxTokens,_=ac$(H,q);if(!_||_<=$/4)return;let f=await Ct7(H)??_;if(f>$)throw new kM6(f,$)}function fO6(H,q,K,$){return{type:"image",file:{base64:H.toString("base64"),type:`image/${q}`,originalSize:K,dimensions:$}}}async function St7(H,q,K,$,_,A,f,z,Y,M,O,w){if($==="ipynb"){let E=await nB7(K),R=SH(E),y=Buffer.byteLength(R);if(y>z){let p=w4()?`Use ${hK} with jq to read specific portions:
|
|
5037
5037
|
cat "${H}" | jq '.cells[:20]' # First 20 cells
|
|
5038
5038
|
cat "${H}" | jq '.cells[100:120]' # Cells 100-120
|
|
5039
5039
|
cat "${H}" | jq '.cells | length' # Count total cells
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makecoder",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.32",
|
|
4
4
|
"description": "MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",
|
|
5
5
|
"main": "./dist/coder.js",
|
|
6
6
|
"bin": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
38
|
"bun": ">=1.3.12",
|
|
39
|
-
"makecoder-codex-darwin-arm64": "4.0.
|
|
40
|
-
"makecoder-codex-linux-x64": "4.0.
|
|
41
|
-
"makecoder-codex-win32-x64": "4.0.
|
|
39
|
+
"makecoder-codex-darwin-arm64": "4.0.32",
|
|
40
|
+
"makecoder-codex-linux-x64": "4.0.32",
|
|
41
|
+
"makecoder-codex-win32-x64": "4.0.32"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=20.0.0"
|