@krapht/ork 1.0.0-alpha.2 → 1.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -7
- package/dist/__build_info__-D6mXC4cD.mjs +228 -0
- package/dist/apply-Mb0fNpCX.mjs +17 -0
- package/dist/argument-error-CihH46Le.mjs +27 -0
- package/dist/attach-C1OnxyMh.mjs +92 -0
- package/dist/attach-CEGbRg1D.mjs +1230 -0
- package/dist/bin.mjs +1312 -2390
- package/dist/brief-DH66xmj8.mjs +115 -0
- package/dist/{decide-CGyx9rv7.mjs → builtin-files-Cf-NZDqM.mjs} +3 -51
- package/dist/chips-BqcT58qr.mjs +43 -0
- package/dist/command-tree-CEkzWNy6.mjs +63 -0
- package/dist/{completion-CSU5vkEt.mjs → completion-DS0gCZRm.mjs} +200 -30
- package/dist/context-CGPh12HV.mjs +106 -0
- package/dist/detached-Dakw5RZj.mjs +38 -0
- package/dist/extra-arguments-BxQMXARO.mjs +13 -0
- package/dist/{find-D6Gj1sxg.mjs → find-BTikxc54.mjs} +2 -2
- package/dist/flags-C8yCq0j5.mjs +145 -0
- package/dist/follow-ups-CtlhHbwe.mjs +563 -0
- package/dist/format-BB4E-T6x.mjs +249 -0
- package/dist/{help-groups-BwYoAWsh.mjs → help-groups-BpRgBSTh.mjs} +42 -76
- package/dist/in-a-run-CbnKjO7t.mjs +27 -0
- package/dist/install-CWcpX5g4.mjs +211 -0
- package/dist/{limits-B1-DYc3d.mjs → limits-VQqsBoQk.mjs} +2 -2
- package/dist/{mcp-DE_EmyVm.mjs → mcp-wGfkMCVF.mjs} +6 -6
- package/dist/once-BHxSdZz_.mjs +112 -0
- package/dist/orphan-guard-BFKg8VSd.mjs +58 -0
- package/dist/output-B1kwo0YU.mjs +439 -0
- package/dist/outputs-text-CNTJ7Qq_.mjs +19 -0
- package/dist/{pause-CL6N_Xrj.mjs → pause-C_Wxh-KM.mjs} +7 -4
- package/dist/print-DNYzq4Rr.mjs +19 -0
- package/dist/project-records-XY3ku95x.mjs +233 -0
- package/dist/refusals-DQQX3AIb.mjs +116 -0
- package/dist/{relay-0SD0erwf.mjs → relay-BA6tsnpc.mjs} +2 -2
- package/dist/run-Bvvg-fiF.mjs +234 -0
- package/dist/run-DBUAq-Uu.mjs +1452 -0
- package/dist/send-nrKtak5F.mjs +105 -0
- package/dist/{src-Dujmvv4s.mjs → src-8cOPOgrT.mjs} +12523 -5507
- package/dist/{src-BbyEoMn4.mjs → src-CmEvHdju.mjs} +797 -233
- package/dist/src-D4JSymhK.mjs +3104 -0
- package/dist/{src-DOcK8Jfp.mjs → src-I_RyKu6_.mjs} +1022 -590
- package/dist/store-CDpk8Wtz.mjs +16 -0
- package/dist/ui/THIRD_PARTY_LICENSES.txt +612 -0
- package/dist/ui/assets/app--FijEXiJ.css +1 -0
- package/dist/ui/assets/app-BowhjEAe.js +112 -0
- package/dist/ui/assets/{index-9dFha9Qn.js → index-CrMa2oHB.js} +3 -3
- package/dist/ui/assets/theme-CdXvqTQ6.js +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/{ui-CTmO2Xzu.mjs → ui-DY3Dnpho.mjs} +54 -25
- package/dist/usage-1VwSg_Qt.mjs +257 -0
- package/dist/validate-BxayjjkV.mjs +632 -0
- package/dist/verdict-CMvPCpWC.mjs +84 -0
- package/dist/{watch-CtbgDAcz.mjs → watch-CT0EtLPZ.mjs} +45 -17
- package/dist/{workflows-D1_WVukk.mjs → workflows-DHHi-APg.mjs} +30 -5
- package/dist/worktrees-CZvbHzbN.mjs +302 -0
- package/package.json +10 -8
- package/dist/__build_info__-fy6L1Mrd.mjs +0 -615
- package/dist/clean-DaHjs__2.mjs +0 -88
- package/dist/context-DT8MfEIR.mjs +0 -274
- package/dist/format-Dnfv8zMT.mjs +0 -427
- package/dist/in-a-run-pLAZeNys.mjs +0 -22
- package/dist/list-BrH8KRSJ.mjs +0 -110
- package/dist/output-BLQWD6MJ.mjs +0 -950
- package/dist/remove-BeGdqroy.mjs +0 -194
- package/dist/report-DK4LGqwF.mjs +0 -129
- package/dist/send-C8tunWhv.mjs +0 -163
- package/dist/src-CCUKRX51.mjs +0 -1204
- package/dist/ui/assets/app-BNT0SuIz.css +0 -1
- package/dist/ui/assets/app-T7wVAhgx.js +0 -67
- package/dist/ui/assets/theme-3xH5jxKs.js +0 -1
- package/dist/usage-DYUmP0i4.mjs +0 -419
- package/dist/worktrees-DdMYoNOC.mjs +0 -212
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var L=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function R(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,L)}catch(e){L(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function z(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else R(z.bind(null,e))}var B={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=B,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=z,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=R,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),d=o(((e,t)=>{t.exports=u()})),f=l(d(),1),p=f.createContext(void 0),m={disableStyleElements:!1};function h(){return f.useContext(p)??m}var g=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),_=o(((e,t)=>{t.exports=g()})),v=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),y=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=v()}));function b(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function x(e,t=`|`){return e.map(e=>ie(e)).join(t)}function S(e,t){return typeof t==`bigint`?t.toString():t}var C=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function w(e){return new C(e)}function T(e){return e==null}function E(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function D(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function O(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function k(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function A(e){return k(e._zod.def)??e._zod.def.shape}function j(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return O(this,t,e),e},enumerable:!0,configurable:!0})}function M(e,t,n){t in e?O(e,t,n):e[t]=n}function N(e,t,n,r){let i=A(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?j(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):M(e,a,r?r(n.value,a):n.value))}}function P(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?j(e,n,()=>t[n]):M(e,n,r.value))}}function F(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function I(e){return JSON.stringify(e)}function L(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var R=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var B=w(()=>{if(Q.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function V(e){if(z(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return z(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ee(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var te=new Set([`string`,`number`,`symbol`]);function ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function H(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function re(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ie(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function ae(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var oe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},se={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ce(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return N(i,e,U(e,t)),H(e,F(n,{shape:i,checks:[]}))}function U(e,t){let n=A(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function le(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(U(e,t)),a={};return N(a,e,Reflect.ownKeys(A(e)).filter(e=>!i.has(e))),H(e,F(n,{shape:a,checks:[]}))}function ue(e,t){if(!V(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=A(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return H(e,F(e._zod.def,{shape:W(e,t)}))}function W(e,t){let n={};return N(n,e,Reflect.ownKeys(A(e))),P(n,t),n}function de(e,t){if(!V(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return H(e,F(e._zod.def,{shape:W(e,t)}))}function fe(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return N(n,e,Reflect.ownKeys(A(e))),N(n,t,Reflect.ownKeys(A(t))),H(e,F(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pe(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(U(t,n)):void 0,o={};return N(o,t,Reflect.ownKeys(A(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),H(t,F(t._zod.def,{shape:o,checks:[]}))}function me(e,t,n){let r=n?new Set(U(t,n)):void 0,i={};return N(i,t,Reflect.ownKeys(A(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),H(t,F(t._zod.def,{shape:i}))}function he(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ge(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function _e(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function G(e){return typeof e==`string`?e:e?.message}function ve(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function ye(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function be(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:G(e.inst?._zod.def?.error?.(e))??G(a?.(e))??G(t?.error?.(e))??G(n.customError?.(e))??G(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var xe=/[\uD800-\uDBFF]/;function Se(e){let t=e.length;if(!xe.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Ce(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function we(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Te(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Ee(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ke(e,n,r.value)}}function K(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function De(e,t,n){return K(e,t,n,!1)}function Oe(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return K(this,n,r(this))},set(e){K(this,n,e)}})}return t}function ke(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:K(this,t,n.bind(this))},set(e){K(this,t,e)}})}function Ae(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var q,J=!1,je={configurable:!0,get(){J=!0}};function Me(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&q!==e._zod?q=void 0:(q=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,je);let e=J;J=!1;try{let r=n(this);return J?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),J||=e,r}catch(n){throw delete this[t],J||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Ne(e,t,n,r){let i=Ae(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Pe=`~constantCatch`;function Fe(e){let t=()=>e;return t[Pe]=!0,t}var Y,X={value:void 0,enumerable:!1},Z=`captureStackTrace`in Error?Error:null;function Ie(e){let t=Z;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Z=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Le(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){X.value=new a(r);try{Object.defineProperty(n,"_zod",X)}finally{X.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Ee(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ie(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Re=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ze=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Y=globalThis).__zod_globalConfig??(Y.__zod_globalConfig={});var Q=globalThis.__zod_globalConfig;function Be(e){return e&&Object.assign(Q,e),Q}var Ve=`(prefers-color-scheme: light)`,He=`(prefers-contrast: more)`,Ue=(e,t)=>{let n=t(Ve)?`light`:`dark`;return{theme:e===`system`?n:e,contrast:t(He)?`more`:`standard`}},We=(e,t)=>{e.dataset.theme=t.theme,e.dataset.contrast=t.contrast},$=(e,t)=>{We(e.document.documentElement,Ue(t,t=>e.matchMedia(t).matches))},Ge=(e,t)=>{let n=[Ve,He].map(t=>e.matchMedia(t)),r=()=>{$(e,t())};r();for(let e of n)e.addEventListener(`change`,r);return()=>{for(let e of n)e.removeEventListener(`change`,r)}};export{ve as $,De as A,T as B,ne as C,D,be as E,x as F,pe as G,ae as H,S as I,te as J,ce as K,fe as L,z as M,V as N,b as O,Te as P,ee as Q,F as R,I as S,ue as T,K as U,le as V,we as W,me as X,k as Y,de as Z,H as _,Le as a,h as at,Me as b,se as c,s as ct,B as d,L as et,O as f,E as g,R as h,ze as i,p as it,Ne as j,Ce as k,oe as l,l as lt,w as m,Ge as n,y as nt,Be as o,d as ot,ye as p,_e as q,Re as r,_ as rt,Q as s,o as st,$ as t,ie as tt,he as u,Se as v,ge as w,Oe as x,Fe as y,re as z};
|
package/dist/ui/index.html
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
href="/favicon.svg"
|
|
20
20
|
type="image/svg+xml"
|
|
21
21
|
/>
|
|
22
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/theme-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-CrMa2oHB.js"></script>
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/assets/theme-CdXvqTQ6.js">
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-BPIbqRRb.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { p as scrubberOfRun } from "./src-I_RyKu6_.mjs";
|
|
2
|
+
import { n as ORK_VERSION, t as ORK_NAME } from "./__build_info__-D6mXC4cD.mjs";
|
|
3
|
+
import { c as write, l as writeErr, s as style } from "./output-B1kwo0YU.mjs";
|
|
4
|
+
import { o as mayShowSignIn } from "./in-a-run-CbnKjO7t.mjs";
|
|
5
|
+
import { i as uiFilePath, l as newToken, n as startServer, r as runningServer, t as DEFAULT_PORT, u as createClient } from "./src-CmEvHdju.mjs";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { constants } from "node:os";
|
|
7
8
|
import { spawn } from "node:child_process";
|
|
@@ -105,7 +106,8 @@ const childMessage = (value) => {
|
|
|
105
106
|
const startMessage = (value) => isRecord(value) && value["type"] === "ork-ui-start" && typeof value["port"] === "number" && typeof value["token"] === "string" ? {
|
|
106
107
|
type: "ork-ui-start",
|
|
107
108
|
port: value["port"],
|
|
108
|
-
token: value["token"]
|
|
109
|
+
token: value["token"],
|
|
110
|
+
...typeof value["session"] === "string" ? { session: value["session"] } : {}
|
|
109
111
|
} : null;
|
|
110
112
|
// src/browser/serve.ts
|
|
111
113
|
/**
|
|
@@ -190,11 +192,13 @@ const serve = async (start, end) => {
|
|
|
190
192
|
version: ORK_VERSION,
|
|
191
193
|
port: start.port,
|
|
192
194
|
token: start.token,
|
|
195
|
+
...start.session === void 0 ? {} : { sessionSecret: start.session },
|
|
193
196
|
ui: uiFolders(),
|
|
194
197
|
update: { name: ORK_NAME },
|
|
195
198
|
restart: () => {
|
|
196
199
|
send({ type: "ork-ui-restart" }).then(end);
|
|
197
|
-
}
|
|
200
|
+
},
|
|
201
|
+
noteScrub: (run, registered) => scrubberOfRun(run, registered)
|
|
198
202
|
});
|
|
199
203
|
} catch (error) {
|
|
200
204
|
await send({
|
|
@@ -231,13 +235,14 @@ const serveForSupervisor = async () => {
|
|
|
231
235
|
* @file `ork ui`'s process model (ADR-060): the command in the terminal only
|
|
232
236
|
* supervises; its server runs in a child, the launcher the user ran
|
|
233
237
|
* (`process.argv[1]` as given, so after an upgrade it is the new install's)
|
|
234
|
-
* with `ui --serve`. The port
|
|
235
|
-
* When the page asks for a restart,
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* kills it and exits
|
|
238
|
+
* with `ui --serve`. The port, the token and the session secret (made here,
|
|
239
|
+
* once) go over the child's IPC channel. When the page asks for a restart,
|
|
240
|
+
* the child says so and exits, and the supervisor starts the launcher again
|
|
241
|
+
* on the same port with the same token and session secret, so the open tab
|
|
242
|
+
* stays signed in. There is only ever one child; Ctrl-C (or SIGTERM) stops it
|
|
243
|
+
* and then the supervisor, which exits with its code. The child may wait for
|
|
244
|
+
* an upgrade to finish first; a second Ctrl-C (or SIGTERM) kills it and exits
|
|
245
|
+
* at once.
|
|
241
246
|
*/
|
|
242
247
|
/**
|
|
243
248
|
* How long an exited child's channel may take to close before the supervisor
|
|
@@ -250,6 +255,7 @@ const signalled = (signal) => 128 + constants.signals[signal];
|
|
|
250
255
|
/** Supervises the server until it stops; resolves the exit code. */
|
|
251
256
|
const supervise = (options) => new Promise((resolve) => {
|
|
252
257
|
const { token, say, sayErr } = options;
|
|
258
|
+
const session = newToken();
|
|
253
259
|
let port = options.port;
|
|
254
260
|
let stopping = false;
|
|
255
261
|
let ended = false;
|
|
@@ -288,7 +294,8 @@ const supervise = (options) => new Promise((resolve) => {
|
|
|
288
294
|
if (message?.type === "ork-ui-hello") child.send({
|
|
289
295
|
type: "ork-ui-start",
|
|
290
296
|
port,
|
|
291
|
-
token
|
|
297
|
+
token,
|
|
298
|
+
session
|
|
292
299
|
});
|
|
293
300
|
else if (message?.type === "ork-ui-ready") {
|
|
294
301
|
ready = true;
|
|
@@ -384,26 +391,48 @@ const onStopSignals = (stop) => {
|
|
|
384
391
|
// src/commands/ui.ts
|
|
385
392
|
/**
|
|
386
393
|
* @file `ork ui`: starts the local server (ADR-039) on loopback and opens it in
|
|
387
|
-
* the browser, signed in with
|
|
388
|
-
* running (`~/.ork/ui.json`), opens that one. The
|
|
389
|
-
* server in a child process, so the page can restart
|
|
390
|
-
* installed `ork` (ADR-060). The server runs nothing: runs it
|
|
391
|
-
* running when it stops, and the CLI works without it.
|
|
394
|
+
* the browser, signed in with a single-use code the server mints (RFC-019);
|
|
395
|
+
* or, when one is already running (`~/.ork/ui.json`), opens that one. The
|
|
396
|
+
* command supervises the server in a child process, so the page can restart
|
|
397
|
+
* it onto a newly installed `ork` (ADR-060). The server runs nothing: runs it
|
|
398
|
+
* starts keep running when it stops, and the CLI works without it.
|
|
399
|
+
*/
|
|
400
|
+
/** The link that signs the browser in; the server swaps its code for a cookie. */
|
|
401
|
+
const signInLink = (port, code) => `http://127.0.0.1:${String(port)}/?code=${code}`;
|
|
402
|
+
/** What `ork ui` says when it can't get a sign-in code from the server. */
|
|
403
|
+
const MINT_FAILED_OLDER = "The running UI is from an older Ork; stop it and run `ork ui`.";
|
|
404
|
+
/**
|
|
405
|
+
* Gets a single-use sign-in code from the server with the API token, and
|
|
406
|
+
* returns the link for it, or the reason there is none. The token only goes in
|
|
407
|
+
* this request's header, never in a link or an argument.
|
|
392
408
|
*/
|
|
393
|
-
|
|
394
|
-
const
|
|
409
|
+
const mintSignInLink = async (port, token, fetchFn) => {
|
|
410
|
+
const answer = await createClient({
|
|
411
|
+
base: `http://127.0.0.1:${String(port)}`,
|
|
412
|
+
token,
|
|
413
|
+
...fetchFn === void 0 ? {} : { fetch: fetchFn }
|
|
414
|
+
}).call("signIn");
|
|
415
|
+
if (answer.ok) return { link: signInLink(port, answer.data.code) };
|
|
416
|
+
return { failure: answer.status === 404 || answer.status === 0 ? MINT_FAILED_OLDER : `Could not get a sign-in code: ${answer.error}` };
|
|
417
|
+
};
|
|
395
418
|
/** `--port`: 0 to 65535 (0 picks a free port); `null` when invalid. */
|
|
396
419
|
const portArg = (value) => {
|
|
397
420
|
if (value === void 0) return DEFAULT_PORT;
|
|
398
421
|
const port = Number(value);
|
|
399
422
|
return Number.isInteger(port) && port >= 0 && port <= 65535 ? port : null;
|
|
400
423
|
};
|
|
401
|
-
/** Opens the link, or prints it when there is no browser to open. */
|
|
402
|
-
const show = async (
|
|
424
|
+
/** Opens the sign-in link, or prints it when there is no browser to open. */
|
|
425
|
+
const show = async (port, token, open) => {
|
|
403
426
|
if (!mayShowSignIn()) {
|
|
404
427
|
writeErr("A program or an agent in a run does not get the sign-in link, which acts as you. Run `ork ui` in your own terminal.");
|
|
405
428
|
return;
|
|
406
429
|
}
|
|
430
|
+
const minted = await mintSignInLink(port, token);
|
|
431
|
+
if ("failure" in minted) {
|
|
432
|
+
writeErr(minted.failure);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const { link } = minted;
|
|
407
436
|
if (!(open && process.stdout.isTTY && await openInBrowser(link))) write(`Open it with this link, which signs you in: ${link}`);
|
|
408
437
|
};
|
|
409
438
|
/** What `ork ui` says once its server serves, the first time or again. */
|
|
@@ -415,7 +444,7 @@ const ready = async ({ port, version, restarted }, token, open) => {
|
|
|
415
444
|
}
|
|
416
445
|
write(`Ork's UI is at ${url}`);
|
|
417
446
|
write(style("dim", "Runs keep running when it stops, and every ork command works without it. Ctrl-C stops it."));
|
|
418
|
-
await show(
|
|
447
|
+
await show(port, token, open);
|
|
419
448
|
};
|
|
420
449
|
const ui = defineCommand({
|
|
421
450
|
meta: {
|
|
@@ -452,7 +481,7 @@ const ui = defineCommand({
|
|
|
452
481
|
const running = runningServer(uiFilePath());
|
|
453
482
|
if (running !== null) {
|
|
454
483
|
write(`Ork's UI is already running at http://127.0.0.1:${String(running.port)} (process ${String(running.pid)}).`);
|
|
455
|
-
await show(
|
|
484
|
+
await show(running.port, running.token, args.open);
|
|
456
485
|
return;
|
|
457
486
|
}
|
|
458
487
|
const token = newToken();
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { Gr as placeFor, H as applyPrune, Jt as usageListTable, R as openStore, U as planPrune, _ as usageReport, g as USAGE_DIMENSIONS } from "./src-8cOPOgrT.mjs";
|
|
2
|
+
import { a as agoTime } from "./refusals-DQQX3AIb.mjs";
|
|
3
|
+
import { C as termOf, c as write, l as writeErr, n as cost, o as shortCount, r as costOf, s as style, t as confirm } from "./output-B1kwo0YU.mjs";
|
|
4
|
+
import { n as chip, t as CHIP_LABELS } from "./chips-BqcT58qr.mjs";
|
|
5
|
+
import { n as limitsHere } from "./limits-VQqsBoQk.mjs";
|
|
6
|
+
import { c as refuseUnknownFlags, i as readListArgs, n as filterArgs, r as projectScope } from "./flags-C8yCq0j5.mjs";
|
|
7
|
+
import { a as header, o as table } from "./format-BB4E-T6x.mjs";
|
|
8
|
+
import { defineCommand } from "citty";
|
|
9
|
+
// src/runs/usage.ts
|
|
10
|
+
/** `950`, `12.3k`, `4.5M`. */
|
|
11
|
+
const tokens = shortCount;
|
|
12
|
+
const percent = (share) => `${String(Math.round(share * 100))}%`;
|
|
13
|
+
const counted = (count, noun) => `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
|
|
14
|
+
const TITLES = {
|
|
15
|
+
day: "By day",
|
|
16
|
+
week: "By week",
|
|
17
|
+
month: "By month",
|
|
18
|
+
workflow: "By workflow",
|
|
19
|
+
node: "Costliest nodes",
|
|
20
|
+
model: "By model",
|
|
21
|
+
driver: "By driver",
|
|
22
|
+
project: "By project"
|
|
23
|
+
};
|
|
24
|
+
/** Seconds of CPU, `12.3 s`; empty with none. */
|
|
25
|
+
const cpuText = (ms) => ms === 0 ? "" : `${(ms / 1e3).toFixed(1)} s`;
|
|
26
|
+
/** `cpu`: a column for the CPU Ork's tool commands used. */
|
|
27
|
+
const usageTable = (term, groups, cpu = false) => table(term, [
|
|
28
|
+
{ flex: true },
|
|
29
|
+
{ align: "right" },
|
|
30
|
+
{ align: "right" },
|
|
31
|
+
{},
|
|
32
|
+
{},
|
|
33
|
+
...cpu ? [{ align: "right" }] : []
|
|
34
|
+
], [[
|
|
35
|
+
header(""),
|
|
36
|
+
header("COST"),
|
|
37
|
+
header("SESSIONS"),
|
|
38
|
+
header("TOKENS"),
|
|
39
|
+
header("CACHE"),
|
|
40
|
+
...cpu ? [header("TOOL CPU")] : []
|
|
41
|
+
], ...groups.map((group) => [
|
|
42
|
+
{ text: group.key },
|
|
43
|
+
{ text: cost(group.costUsd) },
|
|
44
|
+
{ text: String(group.sessions) },
|
|
45
|
+
{ text: `${tokens(group.inputTokens + group.cacheReadTokens + group.cacheWriteTokens)} prompt / ${tokens(group.outputTokens)} out` },
|
|
46
|
+
{ text: percent(group.cacheHitRate) },
|
|
47
|
+
...cpu ? [{ text: cpuText(group.cpuMs) }] : []
|
|
48
|
+
])], " ");
|
|
49
|
+
/** What `ork usage` prints without `--by`. */
|
|
50
|
+
const OVERVIEW = [
|
|
51
|
+
"day",
|
|
52
|
+
"workflow",
|
|
53
|
+
"model",
|
|
54
|
+
"node"
|
|
55
|
+
];
|
|
56
|
+
/** How many rows the overview shows of each; `--by` shows them all. */
|
|
57
|
+
const OVERVIEW_ROWS = 10;
|
|
58
|
+
const shortTime = (iso) => new Date(iso).toLocaleString(void 0, {
|
|
59
|
+
dateStyle: "medium",
|
|
60
|
+
timeStyle: "short"
|
|
61
|
+
});
|
|
62
|
+
/** A warning line: a `WARN` chip when rich, else the line in yellow. */
|
|
63
|
+
const warned = (term, text) => term.rich ? ` ${chip(term, CHIP_LABELS.warn, "warn")} ${text}` : style("yellow", ` ${text}`);
|
|
64
|
+
/**
|
|
65
|
+
* `$0.0000 of $0.0100`: both sides of a dollar cap with the same digits, four
|
|
66
|
+
* when either is under a dollar, else cents (`usd` alone gives `$0.00 of
|
|
67
|
+
* $0.0100`).
|
|
68
|
+
*/
|
|
69
|
+
const capAmounts = (spent, cap) => {
|
|
70
|
+
const places = cap < 1 || spent > 0 && spent < 1 ? 4 : 2;
|
|
71
|
+
return `$${spent.toFixed(places)} of $${cap.toFixed(places)}`;
|
|
72
|
+
};
|
|
73
|
+
/** The limits across runs, above a report; nothing with none set. */
|
|
74
|
+
const formatLimits = ({ problems, caps, tokenCaps = [], plan }, term = termOf(process.stdout)) => {
|
|
75
|
+
if (problems.length === 0 && caps.length === 0 && tokenCaps.length === 0 && plan.length === 0) return [];
|
|
76
|
+
return [
|
|
77
|
+
style("bold", "Limits"),
|
|
78
|
+
...problems.map((problem) => warned(term, problem)),
|
|
79
|
+
...caps.map((cap) => {
|
|
80
|
+
const line = ` ${cap.project === void 0 ? "all projects" : "this project"}, this ${cap.window}: ${capAmounts(cap.spentUsd, cap.capUsd)}, resets ${shortTime(cap.resetsAt)}`;
|
|
81
|
+
return cap.leftUsd <= 0 ? warned(term, line.trimStart()) : line;
|
|
82
|
+
}),
|
|
83
|
+
...tokenCaps.map((cap) => {
|
|
84
|
+
const line = ` ${cap.project === void 0 ? "all projects" : "this project"}, this ${cap.window}: ${tokens(cap.spentTokens)} of ${tokens(cap.capTokens)} tokens, resets ${shortTime(cap.resetsAt)}`;
|
|
85
|
+
return cap.leftTokens <= 0 ? warned(term, line.trimStart()) : line;
|
|
86
|
+
}),
|
|
87
|
+
...plan.map((limit) => warned(term, `Claude plan's ${limit.window.replaceAll("_", " ")} limit ${limit.status === "rejected" ? "was reached" : "is close"}${limit.resetsAt === void 0 ? "" : `, resets ${shortTime(limit.resetsAt)}`}`)),
|
|
88
|
+
""
|
|
89
|
+
];
|
|
90
|
+
};
|
|
91
|
+
/** The report, as the terminal shows it. */
|
|
92
|
+
const formatUsage = (report, scope, by, term = termOf(process.stdout)) => {
|
|
93
|
+
const { totals } = report;
|
|
94
|
+
if (totals.sessions === 0) return [`No Claude sessions in ${scope}.`];
|
|
95
|
+
const lines = [`${style("bold", costOf(totals.costUsd, totals.partial, totals.tokens))} in ${scope}`, `${counted(totals.runs, "run")} · ${counted(totals.sessions, "session")} · ${counted(totals.turns, "turn")} · ${tokens(totals.inputTokens + totals.cacheReadTokens + totals.cacheWriteTokens)} prompt / ${tokens(totals.outputTokens)} out${totals.tokens === void 0 ? "" : ` (${tokens(totals.tokens)} counted)`} · ${percent(totals.cacheHitRate)} from cache`];
|
|
96
|
+
for (const dimension of by === void 0 ? OVERVIEW : [by]) {
|
|
97
|
+
const groups = report.groups[dimension];
|
|
98
|
+
const shown = by === void 0 ? dimension === "day" ? groups.slice(-10) : groups.slice(0, OVERVIEW_ROWS) : groups;
|
|
99
|
+
lines.push("", style("bold", TITLES[dimension]), ...usageTable(term, shown, dimension === "node"));
|
|
100
|
+
if (shown.length < groups.length) lines.push(style("dim", ` and ${String(groups.length - shown.length)} more (--by ${dimension})`));
|
|
101
|
+
}
|
|
102
|
+
const hints = report.hints.length === 0 ? [] : [
|
|
103
|
+
"",
|
|
104
|
+
style("bold", "Worth a look"),
|
|
105
|
+
...report.hints.map((h) => ` ${h.message}`)
|
|
106
|
+
];
|
|
107
|
+
return [
|
|
108
|
+
...lines,
|
|
109
|
+
...hints,
|
|
110
|
+
"",
|
|
111
|
+
style("dim", "Costs are Claude Code's own estimates. On a subscription they are not what you are billed.")
|
|
112
|
+
];
|
|
113
|
+
};
|
|
114
|
+
// src/commands/usage.ts
|
|
115
|
+
/**
|
|
116
|
+
* @file `ork usage` and `ork prune` (specs/usage.md): what runs spent over
|
|
117
|
+
* time, from the store's ledger, and forgetting old runs' transcripts while
|
|
118
|
+
* keeping that ledger.
|
|
119
|
+
*/
|
|
120
|
+
const isDimension = (value) => USAGE_DIMENSIONS.some((dimension) => dimension === value);
|
|
121
|
+
const refuse = (message) => {
|
|
122
|
+
writeErr(message);
|
|
123
|
+
process.exitCode = 1;
|
|
124
|
+
};
|
|
125
|
+
const usage = defineCommand({
|
|
126
|
+
meta: {
|
|
127
|
+
name: "usage",
|
|
128
|
+
description: "Show what this project's runs spent over time"
|
|
129
|
+
},
|
|
130
|
+
plugins: [refuseUnknownFlags],
|
|
131
|
+
args: filterArgs(usageListTable, {
|
|
132
|
+
ids: false,
|
|
133
|
+
limit: false,
|
|
134
|
+
extra: {
|
|
135
|
+
"clear-plan-limits": {
|
|
136
|
+
type: "boolean",
|
|
137
|
+
description: "Forget what Claude Code last said of your plan's limits, for one that has lifted",
|
|
138
|
+
default: false
|
|
139
|
+
},
|
|
140
|
+
by: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: USAGE_DIMENSIONS.join(", ")
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
run: ({ args }) => {
|
|
147
|
+
const asked = args["since"];
|
|
148
|
+
const since = typeof asked === "string" ? asked : "30d";
|
|
149
|
+
const request = readListArgs(usageListTable, {
|
|
150
|
+
...args,
|
|
151
|
+
since
|
|
152
|
+
});
|
|
153
|
+
if (request === void 0) return;
|
|
154
|
+
const rawBy = args["by"];
|
|
155
|
+
const given = typeof rawBy === "string" ? rawBy : void 0;
|
|
156
|
+
if (given !== void 0 && !isDimension(given)) {
|
|
157
|
+
refuse(`--by takes one of ${USAGE_DIMENSIONS.join(", ")}, not \`${given}\`.`);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const by = given;
|
|
161
|
+
const store = openStore();
|
|
162
|
+
try {
|
|
163
|
+
const scope = projectScope(request.filter, store.projects());
|
|
164
|
+
if (scope === void 0) return;
|
|
165
|
+
const named = typeof scope === "object" ? scope.root : void 0;
|
|
166
|
+
const place = scope === "here" ? placeFor(process.cwd(), store.projects()) : store.projects().find((p) => p.root === named);
|
|
167
|
+
const { workflow, until, since: from } = request.filter;
|
|
168
|
+
if (args["clear-plan-limits"] === true) {
|
|
169
|
+
const cleared = store.clearPlanLimits();
|
|
170
|
+
const said = cleared === 0 ? "No plan limit was recorded." : `Cleared ${String(cleared)} plan limit(s).`;
|
|
171
|
+
(args["json"] === true ? writeErr : write)(said);
|
|
172
|
+
}
|
|
173
|
+
const filter = {
|
|
174
|
+
...place === void 0 ? {} : { project: place.root },
|
|
175
|
+
...workflow === void 0 ? {} : { workflow },
|
|
176
|
+
...from === void 0 || from === "all" ? {} : { since: from },
|
|
177
|
+
...until === void 0 ? {} : { until }
|
|
178
|
+
};
|
|
179
|
+
const report = usageReport(store.usage(filter), store.toolCpu(filter));
|
|
180
|
+
const limits = limitsHere(store, place);
|
|
181
|
+
if (args["json"] === true) {
|
|
182
|
+
write(JSON.stringify({
|
|
183
|
+
...report,
|
|
184
|
+
limits
|
|
185
|
+
}, void 0, 2));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
for (const line of formatLimits(limits)) write(line);
|
|
189
|
+
const where = scope === "here" ? "this project" : scope === "all" ? "every project" : `project ${String(request.filter["project"])}`;
|
|
190
|
+
const period = since === "all" ? "" : `, since ${since}`;
|
|
191
|
+
for (const line of formatUsage(report, `${where}${period}`, by)) write(line);
|
|
192
|
+
} finally {
|
|
193
|
+
store.close();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const prune = defineCommand({
|
|
198
|
+
meta: {
|
|
199
|
+
name: "prune",
|
|
200
|
+
description: "Forget old runs' transcripts; what they spent stays"
|
|
201
|
+
},
|
|
202
|
+
args: {
|
|
203
|
+
"older-than": {
|
|
204
|
+
type: "string",
|
|
205
|
+
description: "Runs that ended this long ago: 90d, 12w",
|
|
206
|
+
required: true
|
|
207
|
+
},
|
|
208
|
+
all: {
|
|
209
|
+
type: "boolean",
|
|
210
|
+
description: "Every project's runs",
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
"dry-run": {
|
|
214
|
+
type: "boolean",
|
|
215
|
+
description: "Show what would go, and change nothing",
|
|
216
|
+
default: false
|
|
217
|
+
},
|
|
218
|
+
yes: {
|
|
219
|
+
type: "boolean",
|
|
220
|
+
alias: "y",
|
|
221
|
+
description: "Do not ask",
|
|
222
|
+
default: false
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
run: async ({ args }) => {
|
|
226
|
+
const before = agoTime(args["older-than"], Date.now());
|
|
227
|
+
if (before === null) {
|
|
228
|
+
refuse(`--older-than takes an age (90d, 12w), not \`${args["older-than"]}\`.`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const store = openStore();
|
|
232
|
+
try {
|
|
233
|
+
const filter = {
|
|
234
|
+
before,
|
|
235
|
+
...args.all ? {} : { project: placeFor(process.cwd(), store.projects()).root }
|
|
236
|
+
};
|
|
237
|
+
const plan = await planPrune(store, filter);
|
|
238
|
+
for (const { run, reason } of plan.keep) write(style("dim", `keep ${run.id} (${run.workflow}): ${reason}`));
|
|
239
|
+
for (const run of plan.remove) write(`${args["dry-run"] ? "would remove" : "remove"} ${run.id} (${run.workflow}, ${run.startedAt.slice(0, 10)})`);
|
|
240
|
+
if (plan.remove.length === 0) {
|
|
241
|
+
write("Nothing to prune.");
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (args["dry-run"]) return;
|
|
245
|
+
const question = `Forget ${String(plan.remove.length)} run(s) and their logs for good? They can no longer be resumed or read. [y/N] `;
|
|
246
|
+
if (!args.yes && !await confirm(question)) return;
|
|
247
|
+
const agreed = new Set(plan.remove.map((run) => run.id));
|
|
248
|
+
const outcome = applyPrune(store, { remove: (args.yes ? plan : await planPrune(store, filter)).remove.filter((run) => agreed.has(run.id)) });
|
|
249
|
+
const notShrunk = store.compact();
|
|
250
|
+
write(`Removed ${String(outcome.removed)} run(s) and ${String(outcome.folders)} folder(s). Their usage stays in \`ork usage\`.${notShrunk === null ? "" : ` The store's file did not shrink: ${notShrunk}. The next prune tries again, and its free space is used first.`}`);
|
|
251
|
+
for (const { run, reason } of outcome.failed) refuse(`Run ${run}: ${reason}.`);
|
|
252
|
+
} finally {
|
|
253
|
+
store.close();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
export { prune, usage };
|