@homingbird/mod 0.0.0-stage → 0.1.0-rc.2
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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/plugin.json +33 -0
- package/LICENSE +21 -0
- package/cli/homingbird.mjs +3361 -0
- package/hooks/character-rules.d.mts +13 -0
- package/hooks/character-rules.mjs +2 -0
- package/hooks/character.ts +115 -0
- package/hooks/command-line.ts +83 -0
- package/hooks/desk.ts +408 -0
- package/hooks/drafting.ts +115 -0
- package/hooks/guard.ts +32 -0
- package/hooks/helpers.ts +96 -0
- package/hooks/hooks.json +1 -0
- package/hooks/pane-text/en.ts +59 -0
- package/hooks/pane-text/ko.ts +58 -0
- package/hooks/pane-text.ts +77 -0
- package/hooks/pane.tsx +273 -0
- package/hooks/pip.ts +36 -0
- package/hooks/register.tsx +122 -0
- package/hooks/tool-notices.ts +5 -0
- package/hooks/tools.ts +179 -0
- package/package.json +28 -3
- package/types/index.d.ts +67 -0
- package/README.md +0 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const characterProblems: (input: unknown) => string[]
|
|
2
|
+
export declare const characterLink: (webClientUrl: string, spec: CharacterSpec) => string
|
|
3
|
+
export declare const BUILT_IN_CHARACTERS: ReadonlyArray<CharacterSpec>
|
|
4
|
+
|
|
5
|
+
export interface CharacterSpec {
|
|
6
|
+
readonly version: 1
|
|
7
|
+
readonly base: 'bubble-16'
|
|
8
|
+
readonly id: string
|
|
9
|
+
readonly name: string
|
|
10
|
+
readonly palette: Readonly<Partial<Record<'B' | 'D' | 'O' | 'F' | 'K', string>>>
|
|
11
|
+
readonly noFeet?: boolean
|
|
12
|
+
readonly marks: ReadonlyArray<readonly [number, number, number, number, string]>
|
|
13
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Generated from packages/protocol by its mod-character-rules test. Do not edit.
|
|
2
|
+
var Ue=Object.defineProperty;var He=(e,t)=>{for(var r in t)Ue(e,r,{get:t[r],enumerable:!0})};var F={B:"#8DA4CB",D:"#6D86B0",K:"#1B2333",O:"#F4A259",F:"#F4A259",A:"#F4A259",G:"#9AA9BF",M:"#5C6A80",T:"#3FBFA6",R:"#F25F5C",W:"#FFFFFF",Y:"#FFD879",V:"#E9B04A",N:"#B9772A",L:"#EAF6FF"};var D=(e,t)=>{let[r,n]=[Z(e),Z(t)].sort((o,a)=>a-o);return(r+.05)/(n+.05)},Z=e=>{let[t,r,n]=U(e).map(Ve);return .2126*t+.7152*r+.0722*n},ee=(e,t)=>{let[r,n,o]=U(e),[a,i,s]=U(t);return Math.hypot(r-a,n-i,o-s)};var U=e=>[Number.parseInt(e.slice(1,3),16),Number.parseInt(e.slice(3,5),16),Number.parseInt(e.slice(5,7),16)],Ve=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};var P=[[5,2,6,1,"B"],[3,3,10,1,"B"],[2,4,12,1,"B"],[1,5,13,1,"B"],[1,6,13,1,"B"],[14,6,2,1,"O"],[1,7,13,1,"B"],[14,7,1,1,"O"],[1,8,13,1,"B"],[1,9,13,1,"B"],[1,10,13,1,"B"],[2,11,12,1,"B"],[2,12,11,1,"B"],[1,13,2,1,"B"],[0,14,2,1,"B"]];var te=[[6,13,1,2,"F"],[9,13,1,2,"F"]],We=[[7,13,2,1,"F"]],Qe=[[3,8,4,1,"D"],[4,9,4,1,"D"]],re={up:[[4,0,2,1,"D"],[4,1,3,1,"D"],[5,2,3,1,"D"],[6,3,2,1,"D"]],mid:[[3,7,4,1,"D"],[4,8,4,1,"D"]],down:[[4,9,4,1,"D"],[4,10,3,1,"D"],[5,11,2,2,"D"]]},m=[[11,5,1,2,"K"]],B=[[10,6,2,1,"K"]],g=[[10,6,1,1,"K"],[11,5,1,1,"K"],[12,6,1,1,"K"]],ne=[[11,6,1,1,"K"]],oe=[[10,4,1,1,"K"],[12,4,1,1,"K"],[11,5,1,1,"K"],[10,6,1,1,"K"],[12,6,1,1,"K"]],k=[[10,8,6,4,"Y"],[10,11,6,1,"V"],[10,8,1,1,"N"],[11,9,1,1,"N"],[12,10,2,1,"N"],[14,9,1,1,"N"],[15,8,1,1,"N"]],Je={up:[[0,3,1,1,"G"],[0,9,2,1,"G"]],mid:[[0,5,2,1,"G"],[0,11,1,1,"G"]],down:[[0,7,1,1,"G"],[0,3,2,1,"G"]]},be=[[13,0,3,1,"A"],[15,1,1,1,"A"],[14,2,1,1,"A"],[14,4,1,1,"A"]],Ee=[[11,0,2,1,"R"],[14,0,2,1,"R"],[11,1,5,1,"R"],[12,2,3,1,"R"],[13,3,1,1,"R"]],xe=[[12,1,1,1,"R"],[14,1,1,1,"R"],[12,2,3,1,"R"],[13,3,1,1,"R"]],ge=[[12,0,4,4,"R"],...Array.from({length:6},(e,t)=>[12.5+t*.45,.5+t*.45,.75,.75,"W"]),...Array.from({length:6},(e,t)=>[14.75-t*.45,.5+t*.45,.75,.75,"W"])],ae=[[12,0,4,4,"R"],[12.75,1.5,2.5,1,"W"]],se=[[13,0,2,1,"Y"],[12,1,1,2,"Y"],[13,3,2,1,"Y"]],ie=[[11,0,3,1,"Y"],[11,1,1,1,"Y"],[13,1,1,1,"Y"],[11,2,3,1,"Y"],[14,1,2,1,"Y"],[15,2,1,1,"Y"]],Re=[[11,0,3,1,"M"],[11,1,1,1,"M"],[13,1,1,1,"M"],[11,2,3,1,"M"],[14,3,1,1,"M"]],he=[[10,13,1,1,"G"],[12,12,1,1,"G"],[14,13,1,1,"G"],[12,14,1,1,"G"]],l=[...P,...Qe,...te],qe=[...P,...We],L=e=>[[12,e,4,4,"R"],[13.5,e+.5,1,1.75,"W"],[13.5,e+2.75,1,.75,"W"]],H=e=>e===2?[[13,0,1,3,"T"],[12,1,3,1,"T"]]:e===1?[[13,1,1,1,"T"]]:[],ke=e=>Array.from({length:e},(t,r)=>[6+2*r,0,1,1,"M"]),Se=(e,t)=>[[e,t,4,1,"M"],[e+2,t+1,1,1,"M"],[e+1,t+2,1,1,"M"],[e,t+3,4,1,"M"]],$=e=>[[12,2,1,1,e],[13,3,1,1,e],[14,2,1,1,e],[15,1,1,1,e]],Te=e=>[[12,e,1,1,"L"]],Fe=e=>[[12,0],[14,0],[14,2],[12,2]].map(([t,r],n)=>[t,r,1,1,n===e?"M":"G"]),ce=e=>(e===0?[[3,0],[8,1],[13,0]]:[[5,1],[10,0],[14,2]]).map(([t,r])=>[t,r,1,1,"Y"]),Be=e=>[[2,0,"R"],[6,1,"T"],[10,0,"Y"],[14,1,"A"],[4,2,"T"],[12,3,"R"]].map(([t,r,n])=>[t+e%2,(r+e*2)%5,1,1,n]),V=e=>e.map(([t,r,n,o,a])=>[16-t-n,r,n,o,a]),_=(e,t,r)=>e.map(([n,o,a,i,s])=>[n+t,o+r,a,i,s]),c=(e,t,r=0)=>({rects:e,ms:t,bob:r}),le=()=>["up","mid","down","mid"].map((e,t)=>c([...Je[e],...qe,...m,...re[e],...k],140,t===1||t===2?1:0));var j={idle:[c([...l,...m],1400),c([...l,...B],140),c([...l,...m],900),c([...l,...B],140)],offline:[c([...l,...B,...Se(12,0)],700,1),c([...l,...B],700)],away:[c([...l,...m,...se],900),c([...l,...B,...se],160)],busy:[c([...l,...m,...ae],900),c([...l,...B,...ae],160)],connecting:[0,1,2,3].map(e=>c([...l,...m,...Fe(e)],160)),disconnected:[...[7,8,9].map(e=>c([...l,...ne,...Te(e)],260)),c([...l,...ne],400)],drafting:[...[1,2,3].map(e=>c([...l,...m,...ke(e)],300)),c([...l,...m],300)],"awaiting-approval":[c([...l,...m,...k,...be],500),c([...l,...m,...k],300)],approved:[c([...l,...g,...k],160,1),c([...l,...g,...k,...$("T")],260),c([...l,...g,...k,...$("T")],700)],discarded:[c([...l,...m,...k],300),c([...l,...m,..._(k,0,2)],160),c([...l,...B,...he],220),c([...l,...m],600)],sending:le(),returning:le().map(e=>c(V(e.rects),e.ms,e.bob)),delivered:[c([...l,...m,...$("M")],900),c([...l,...B,...$("M")],140)],read:[c([...l,...g,...H(2)],220),c([...l,...g,...H(1)],220),c([...l,...g],220),c([...l,...g,...H(1)],220)],"new-note":[c([...l,...m,...L(0)],160,1),c([...l,...m,...L(1)],160),c([...l,...m,...L(0)],160),c([...l,...m,...L(0)],700)],failed:[c([...l,...oe,..._(k,0,2),...ce(0)],220),c([...l,...oe,..._(k,0,2),...ce(1)],220)],waving:[c([...P,...te,...g,...re.up],220),c([...l,...g],220)],accepted:[c([...l,...g,...Ee],300),c([...l,...g,...xe],300)],blocked:[c([...l,...m,...ge],700),c([...l,...m],250)],searching:[0,-1,-2,-1].map(e=>c([...l,...m,..._(Re,e,0)],240)),"sign-in":[c([...l,...m,...ie],600),c([...l,...m,..._(ie,0,1)],300)],celebrate:[0,1,2,3].map(e=>c([...l,...g,...Be(e)],160,e%2))},Xe=Object.keys(j);var nt=j.idle[0].rects;var z=e=>()=>Object.assign(r=>Object.freeze({...r??{},_tag:e}),{tag:e,is:r=>ot(r)&&r._tag===e}),ot=e=>typeof e=="object"&&e!==null&&typeof e._tag=="string";var b=e=>we({_tag:"Ok",value:e}),R=e=>we({_tag:"Err",error:e}),x=e=>e._tag==="Ok";function we(e){return Object.defineProperty(e,Symbol.iterator,{value:at})}function*at(){return this._tag==="Ok"?this.value:yield this}var ve=it({_tag:"None"});function it(e){return Object.defineProperty(e,Symbol.iterator,{value:ct})}function*ct(){return this._tag==="Some"?this.value:yield this}var Ce={_tag:"Interrupt"},dt=e=>({_tag:"Die",defect:e}),Pr=new AbortController().signal;var C=e=>ft(async(t,r)=>{if(r.aborted)return ue;try{return await e(t,r)}catch(n){return R(dt(n))}});var Oe=e=>C(()=>b(e));var _r=C(()=>ue),pt=Oe(void 0);var Ie=e=>C((t,r)=>new Promise(n=>{let o=!1,a=()=>{o=!0,i(),n(ue)},i=e(s=>{o||(o=!0,r.removeEventListener("abort",a),n(s))});o||r.addEventListener("abort",a,{once:!0})})),Mr=Ie(()=>()=>{});var mt=()=>e=>Object.assign(C(t=>b(t[e])),{key:e,of:t=>({[e]:t})});var At=e=>t=>C(async(r,n)=>{let o=await t.run(r,n);return x(o)?b(e(o.value)):o});var yt=mt()("clock"),Kr=At(e=>e.now())(yt);var Nr=z("TimeoutError")();var ue=R(Ce);function ft(e){return{run:e,[Symbol.iterator]:bt,pipe:Et}}function*bt(){return yield this}function Et(...e){let t=this;for(let r of e)t=r(t);return t}var xt=e=>({async*[Symbol.asyncIterator](){yield*e}});var jr=xt([]);var d={};He(d,{array:()=>Bt,boolean:()=>Tt,brand:()=>Dt,formatIssues:()=>Pt,int:()=>St,literal:()=>pe,nullable:()=>Ct,number:()=>kt,optional:()=>vt,record:()=>wt,refine:()=>It,string:()=>ht,struct:()=>Pe,toJsonSchema:()=>M,union:()=>_e,unknown:()=>Ft,variants:()=>Ot});var ht=(e={})=>{let{minLength:t,maxLength:r,pattern:n}=e;return S({type:"string",...t!==void 0&&{minLength:t},...r!==void 0&&{maxLength:r},...n!==void 0&&{pattern:n.source}},(o,a)=>typeof o!="string"?f(a,`expected string, got ${O(o)}`):t!==void 0&&o.length<t?f(a,`expected at least ${t} characters`):r!==void 0&&o.length>r?f(a,`expected at most ${r} characters`):n!==void 0&&!n.test(o)?f(a,`expected to match ${n.source}`):b(o))},kt=Me(!1),St=Me(!0),Tt=S({type:"boolean"},(e,t)=>typeof e=="boolean"?b(e):f(t,`expected boolean, got ${O(e)}`)),Ft=S({type:"unknown"},e=>b(e)),pe=(...e)=>S({type:"literal",values:e},(t,r)=>e.includes(t)?b(t):f(r,`expected ${e.map(n=>JSON.stringify(n)).join(" | ")}`)),Bt=(e,t={})=>{let{minItems:r,maxItems:n}=t;return S({type:"array",items:e.ast,...r!==void 0&&{minItems:r},...n!==void 0&&{maxItems:n}},(o,a)=>{if(!Array.isArray(o))return f(a,`expected array, got ${O(o)}`);if(r!==void 0&&o.length<r)return f(a,`expected at least ${r} items`);if(n!==void 0&&o.length>n)return f(a,`expected at most ${n} items`);let i=[],s=[];return o.forEach((y,p)=>{let T=e.at(y,[...a,p]);x(T)?i.push(T.value):s.push(...T.error)}),s.length>0?R(s):b(i)})},wt=e=>S({type:"record",values:e.ast},(t,r)=>{if(!me(t))return f(r,`expected object, got ${O(t)}`);let n=[],o=[];for(let[a,i]of Object.entries(t)){let s=e.at(i,[...r,a]);x(s)?n.push([a,s.value]):o.push(...s.error)}return o.length>0?R(o):b(Object.fromEntries(n))}),vt=e=>({optional:e}),Pe=e=>{let t=Object.entries(e).map(([n,o])=>({key:n,schema:De(o)?o.optional:o,optional:De(o)}));return{...S({type:"struct",fields:Object.fromEntries(t.map(n=>[n.key,{ast:n.schema.ast,optional:n.optional}]))},(n,o)=>{if(!me(n))return f(o,`expected object, got ${O(n)}`);let a={},i=[];for(let s of t){let y=Object.hasOwn(n,s.key)?n[s.key]:void 0;if(y===void 0){s.optional||i.push({path:[...o,s.key],message:"is required"});continue}let p=s.schema.at(y,[...o,s.key]);x(p)?a[s.key]=p.value:i.push(...p.error)}return i.length>0?R(i):b(a)}),fields:e}},_e=(...e)=>S({type:"union",members:e.map(t=>t.ast)},(t,r)=>{let n=[];for(let o of e){let a=o.at(t,r);if(x(a))return a;n.push(...a.error)}return R(n.length>0?n:[{path:r,message:"no union member to match"}])}),Ct=e=>_e(e,pe(null)),Ot=(e,t)=>{let r=Object.keys(t),n=Object.fromEntries(r.map(o=>[o,Pe({[e]:pe(o),...t[o]})]));return S({type:"union",members:r.map(o=>n[o].ast)},(o,a)=>{if(!me(o))return f(a,`expected object, got ${O(o)}`);let i=Object.hasOwn(o,e)?o[e]:void 0;return typeof i!="string"||!Object.hasOwn(n,i)?f([...a,e],`expected ${r.map(s=>JSON.stringify(s)).join(" | ")}`):n[i].at(o,a)})},It=(e,t,r=`expected ${e}`)=>n=>S({type:"refined",inner:n.ast,name:e},(o,a)=>{let i=n.at(o,a);return x(i)?t(i.value)?i:f(a,r):i}),Dt=()=>e=>e,Pt=e=>e.map(t=>t.path.length>0?`${t.path.join(".")}: ${t.message}`:t.message).join("; "),M=e=>{switch(e.type){case"string":return{type:"string",...e.minLength!==void 0&&{minLength:e.minLength},...e.maxLength!==void 0&&{maxLength:e.maxLength},...e.pattern!==void 0&&{pattern:e.pattern}};case"number":return{type:e.integer?"integer":"number",...e.min!==void 0&&{minimum:e.min},...e.max!==void 0&&{maximum:e.max}};case"boolean":return{type:"boolean"};case"unknown":return{};case"literal":return e.values.length===1?{const:e.values[0]}:{enum:e.values};case"array":return{type:"array",items:M(e.items),...e.minItems!==void 0&&{minItems:e.minItems},...e.maxItems!==void 0&&{maxItems:e.maxItems}};case"record":return{type:"object",additionalProperties:M(e.values)};case"struct":return{type:"object",properties:Object.fromEntries(Object.entries(e.fields).map(([t,r])=>[t,M(r.ast)])),required:Object.entries(e.fields).filter(([,t])=>!t.optional).map(([t])=>t)};case"union":return{anyOf:e.members.map(M)};case"refined":return M(e.inner)}};function Me(e){return(t={})=>{let{min:r,max:n}=t;return S({type:"number",integer:e,...r!==void 0&&{min:r},...n!==void 0&&{max:n}},(o,a)=>typeof o!="number"||!Number.isFinite(o)?f(a,`expected ${e?"integer":"number"}, got ${O(o)}`):e&&!Number.isInteger(o)?f(a,"expected integer, got fraction"):r!==void 0&&o<r?f(a,`expected at least ${r}`):n!==void 0&&o>n?f(a,`expected at most ${n}`):b(o))}}function S(e,t){return{ast:e,at:t,decode:r=>t(r,[]),is:r=>x(t(r,[]))}}function f(e,t){return R([{path:e,message:t}])}function O(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function De(e){return"optional"in e}var Jr=z("QueueClosed")();var I=d.struct({version:d.literal(1),base:d.literal("bubble-16"),id:d.string({pattern:/^[a-z0-9][a-z0-9-]{1,31}$/}),name:d.string({minLength:1,maxLength:20}),palette:d.struct({B:d.optional(d.string({pattern:/^#[0-9A-Fa-f]{6}$/})),D:d.optional(d.string({pattern:/^#[0-9A-Fa-f]{6}$/})),O:d.optional(d.string({pattern:/^#[0-9A-Fa-f]{6}$/})),F:d.optional(d.string({pattern:/^#[0-9A-Fa-f]{6}$/})),K:d.optional(d.string({pattern:/^#[0-9A-Fa-f]{6}$/}))}),noFeet:d.optional(d.boolean),marks:d.array(d.refine("mark",Kt,"expected [x, y, w, h, color] with whole numbers and a color")(d.array(d.union(d.int(),d.string()),{minItems:5,maxItems:5})),{maxItems:80})}),Mt=d.toJsonSchema(I.ast);function Kt(e){return e.slice(0,4).every(t=>typeof t=="number")&&typeof e[4]=="string"}var W=[A("pigeon","Pigeon",{},[]),A("cat","Cat",{B:"#F2B46E",D:"#D88F45",O:"#FAD9AE",F:"#D88F45"},[[5,0,1,2,"B"],[6,1,1,1,"B"],[10,0,1,2,"B"],[9,1,1,1,"B"],[6,3,1,1,"#D88F45"],[8,3,1,2,"#D88F45"],[15,6,1,1,"#E97C8B"]]),A("dog","Dog",{B:"#D9B48A",D:"#B08760",O:"#F2E0C8",F:"#B08760"},[[6,2,3,1,"#8A6542"],[7,3,2,3,"#8A6542"],[15,6,1,1,"#3A2A20"]]),A("rabbit","Rabbit",{B:"#E6D8CB",D:"#C9B5A2",O:"#E6D8CB",F:"#C9B5A2"},[[6,0,1,2,"B"],[8,0,1,2,"B"],[6,1,1,1,"#F0AEB9"],[8,1,1,1,"#F0AEB9"],[15,6,1,1,"#E98A9A"]]),A("bear","Bear",{B:"#A07A55",D:"#7F5D3F",O:"#D9BC9C",F:"#7F5D3F"},[[4,1,2,2,"B"],[10,1,2,2,"B"],[15,6,1,1,"#2E2018"]]),A("fox","Fox",{B:"#F08B3C",D:"#CF6B22",O:"#FFF3E6",F:"#4A3428"},[[5,0,1,2,"B"],[6,1,1,1,"B"],[10,0,1,2,"B"],[9,1,1,1,"B"],[5,0,1,1,"#4A3428"],[10,0,1,1,"#4A3428"],[0,14,1,1,"#FFF3E6"],[15,6,1,1,"#2E2018"]]),A("penguin","Penguin",{B:"#34415A",D:"#1E2638"},[[10,4,3,4,"#F4F6FA"],[4,8,7,4,"#F4F6FA"]]),A("duck","Duck",{B:"#F2BE2C",D:"#D9A21A",O:"#F27C2E",F:"#F27C2E"},[[8,1,1,1,"#D9A21A"],[9,0,1,2,"#D9A21A"],[15,7,1,1,"O"]]),A("frog","Frog",{B:"#8DCB78",D:"#6CAE58",O:"#8DCB78",F:"#6CAE58"},[[9,1,3,2,"B"]]),A("owl","Owl",{B:"#A98B6C",D:"#866A4F",O:"#F2C14E",F:"#F2C14E"},[[5,0,1,1,"#866A4F"],[5,1,2,1,"#866A4F"],[10,0,1,1,"#866A4F"],[9,1,2,1,"#866A4F"],[10,4,3,4,"#EBDCC4"],[4,11,1,1,"#866A4F"],[7,11,1,1,"#866A4F"],[10,11,1,1,"#866A4F"]]),A("panda","Panda",{B:"#DADAD5",D:"#2B2B2E",O:"#DADAD5",F:"#2B2B2E",K:"#FFFFFF"},[[4,1,2,2,"#2B2B2E"],[10,1,2,2,"#2B2B2E"],[10,4,3,4,"#2B2B2E"],[15,6,1,1,"#2B2B2E"]]),A("hamster","Hamster",{B:"#E9AE73",D:"#CF8E52",O:"#FFF1E0",F:"#E8A3A8"},[[5,1,2,1,"B"],[9,1,2,1,"B"],[5,1,1,1,"#E8A3A8"],[10,1,1,1,"#E8A3A8"],[15,6,1,1,"#E98A9A"]]),A("goldfish","Goldfish",{B:"#F7893B",D:"#E06A1E",O:"#FFB27A"},[[6,1,3,1,"#E06A1E"],[0,12,2,1,"#FFB27A"],[0,13,3,1,"#FFB27A"],[0,14,2,1,"#FFB27A"],[6,13,3,1,"#E06A1E"]],!0),A("pufferfish","Pufferfish",{B:"#D9B26A",D:"#BF934B",O:"#D9B26A"},[[5,1,1,1,"#B88A2A"],[8,1,1,1,"#B88A2A"],[11,2,1,1,"#B88A2A"],[1,4,1,1,"#B88A2A"],[0,7,1,1,"#B88A2A"],[0,10,1,1,"#B88A2A"],[13,12,1,1,"#B88A2A"],[7,13,1,1,"#B88A2A"]],!0),A("octopus","Octopus",{B:"#B26DC2",D:"#9454A6",O:"#B26DC2"},[[4,13,1,2,"B"],[6,13,1,1,"B"],[8,13,1,2,"B"],[10,13,1,1,"B"],[12,13,1,1,"B"],[6,3,1,1,"#D7A6E2"],[8,4,1,1,"#D7A6E2"]],!0),A("whale","Whale",{B:"#4F7FC4",D:"#3D66A6",O:"#4F7FC4"},[[3,12,9,1,"#CFE0F5"],[7,0,1,2,"#8FD3F4"],[6,0,1,1,"#8FD3F4"],[8,0,1,1,"#8FD3F4"],[0,12,1,1,"B"]],!0),A("turtle","Turtle",{B:"#9ACD8A",D:"#4E7A3E",O:"#9ACD8A",F:"#7FB06E"},[[5,2,4,1,"#4E7A3E"],[3,3,7,1,"#4E7A3E"],[2,4,8,6,"#4E7A3E"],[3,10,6,1,"#4E7A3E"],[4,5,2,2,"#6B9A55"],[7,4,2,2,"#6B9A55"],[6,7,2,2,"#6B9A55"]]),A("hedgehog","Hedgehog",{B:"#D7AE84",D:"#6E5440",O:"#D7AE84",F:"#6E5440"},[[5,2,4,1,"#6E5440"],[2,3,7,1,"#6E5440"],[1,4,7,7,"#6E5440"],[4,1,1,1,"#6E5440"],[7,1,1,1,"#6E5440"],[2,2,1,1,"#6E5440"],[0,5,1,1,"#6E5440"],[0,8,1,1,"#6E5440"],[15,6,1,1,"#2E2018"]]),A("pig","Pig",{B:"#F6B3BF",D:"#E78E9E",O:"#F08FA2",F:"#E78E9E"},[[5,1,2,1,"B"],[5,0,1,1,"B"],[10,1,1,1,"B"],[15,6,1,1,"#C25E72"]]),A("sheep","Sheep",{B:"#DCD3C4",D:"#C7BCA9",O:"#3B3532",F:"#3B3532",K:"#FFFFFF"},[[5,1,1,1,"B"],[7,1,1,1,"B"],[9,1,1,1,"B"],[10,4,4,4,"#3B3532"]]),A("ladybug","Ladybug",{B:"#C8302C",D:"#2A2A2A",O:"#2A2A2A",F:"#2A2A2A",K:"#FFFFFF"},[[10,3,3,1,"#2A2A2A"],[10,4,4,4,"#2A2A2A"],[4,4,2,2,"#2A2A2A"],[7,3,1,1,"#2A2A2A"],[7,6,1,1,"#2A2A2A"],[3,11,2,1,"#2A2A2A"],[11,1,1,2,"#2A2A2A"]]),A("bee","Bee",{B:"#F5B820",D:"#DCEFFF",O:"#2A2A2A",F:"#2A2A2A"},[[4,3,1,9,"#2A2A2A"],[7,2,1,11,"#2A2A2A"],[0,14,1,1,"#2A2A2A"],[11,1,1,2,"#2A2A2A"]]),A("robot","Robot",{B:"#B8C2CF",D:"#8D99A8",O:"#8D99A8",F:"#5F6B7A",K:"#2BB39A"},[[8,0,1,2,"#5F6B7A"],[8,0,1,1,"#F25F5C"],[10,4,3,4,"#2E3A4D"],[3,6,1,1,"#5F6B7A"],[3,11,1,1,"#5F6B7A"]]),A("dinosaur","Dinosaur",{B:"#7CC58A",D:"#5DA86C",O:"#7CC58A",F:"#5DA86C"},[[6,1,1,1,"#F4A259"],[8,1,1,1,"#F4A259"],[3,2,1,1,"#F4A259"],[1,4,1,1,"#F4A259"],[0,6,1,1,"#F4A259"],[0,9,1,1,"#F4A259"]])];function A(e,t,r,n,o=!1){return{version:1,base:"bubble-16",id:e,name:t,palette:r,marks:n,...o&&{noFeet:o}}}var Y=e=>{let t=typeof e=="object"&&e!==null?e:{},r=I.decode(e),n=x(r)?[]:r.error,o=[...Nt(t,n),...Lt(t)],a=$t(t,n);if(a.length>0)return[...o,...a];let i=jt(t);Gt(i)&&t.id!=="pigeon"&&o.push(rr);let s=Array.isArray(t.marks)?t.marks:[],y=s.flatMap(Yt);if(y.length>0)return[...o,...y];let p=Ut(n);return p.length>0?[...o,...p]:[...o,...Ht(s,t.noFeet===!0,i)]},E={nameMax:20,colorsMax:8,markCellsMax:80,outsideCellsMax:16,edgeSpikesMax:10,eyeContrastMin:3,systemDistanceMin:60,systemContrastMin:1.25,visibleShareMin:.5,visibleContrast:1.25},K={iconCorner:()=>Q(G(12,15,0,4)),headTop:()=>Q(G(2,11,0,2)),tail:()=>Q(G(0,2,11,15)),under:()=>Q(G(3,13,13,15)),mouth:()=>G(11,15,8,11)},Nt=(e,t)=>{let r=n=>t.some(o=>o.path[0]===n);return[...r("version")||r("base")?['version must be 1 and base must be "bubble-16"']:[],...r("id")?['id: 2-32 chars of a-z, 0-9 and "-"']:[],...r("name")||String(e.name??"").trim()===""?[`name: 1-${E.nameMax} characters`]:[]].filter((n,o,a)=>a.indexOf(n)===o)},Lt=e=>{let t=String(e.name??"").toLowerCase();return er.some(r=>t.includes(r))?["name: may not contain Claude, Anthropic, Homingbird or Pip"]:[]},$t=(e,t)=>{let r=typeof e.palette=="object"&&e.palette!==null?e.palette:{};return Object.keys(r).flatMap(n=>fe.includes(n)?t.some(a=>a.path[0]==="palette"&&a.path[1]===n)?[`palette.${n}: must be #RRGGBB`]:[]:[`palette: unknown key '${n}' (allowed: B, D, O, F, K)`])},jt=e=>{let t=e.palette??{};return Object.fromEntries(fe.map(r=>[r,(t[r]??Ne[r]).toUpperCase()]))},Gt=e=>["B","D","O"].every(t=>e[t]===Ne[t]),Yt=(e,t)=>{if(!Array.isArray(e)||e.length!==5||!e.slice(0,4).every(Number.isInteger))return[`marks[${t}]: must be [x, y, w, h, color] with whole numbers`];let[r,n,o,a,i]=e;return o<1||a<1||r<0||n<0||r+o>16||n+a>16?[`marks[${t}]: must sit inside the 16x16 grid`]:!fe.includes(i)&&!tr.test(String(i))?[`marks[${t}]: color must be #RRGGBB or one of B, D, O, F, K`]:[]},Ut=e=>e.filter(t=>!["version","base","id","name","palette"].includes(String(t.path[0]))).map(t=>t.path.length>0?`${t.path.join(".")}: ${t.message}`:t.message),Ht=(e,t,r)=>{let n=[],o=new Map;for(let[p,T,q,Ge,X]of e)for(let Ye of ye(p,T,q,Ge))o.set(Ye,(X in r?r[X]:X).toUpperCase());let a=new Set(o.keys()),i=[...a].filter(p=>!J.has(p)),s={iconCorner:K.iconCorner(),headTop:K.headTop(),tail:K.tail(),under:K.under(),mouth:K.mouth()};a.size>E.markCellsMax&&n.push(`marks cover ${a.size} cells; the limit is ${E.markCellsMax}`),i.length>E.outsideCellsMax&&n.push(`${i.length} mark cells sit outside the body; the limit is ${E.outsideCellsMax}`),i.some(p=>s.iconCorner.has(p))&&n.push("marks may not go in the top-right corner outside the body (x 12-15, y 0-4): status icons appear there"),[...a].some(p=>s.mouth.has(p))&&n.push("marks may not go below the beak (x 11-15, y 8-11): characters have no mouths"),i.some(p=>s.under.has(p))&&!t&&n.push('marks under the body need "noFeet": true (they would clash with the feet)'),n.push(...Vt(i,s,t));let y=zt(o,r,t);return n.push(...Wt(y,r)),n},Vt=(e,t,r)=>{let n=s=>t.headTop.has(s)||t.tail.has(s)||r&&t.under.has(s),o=e.filter(s=>!n(s)&&!t.iconCorner.has(s));if(o.length===0)return[];let a=new Set([...J].flatMap(s=>{let[y,p]=Ae(s);return Ke.map(([T,q])=>h(y+T,p+q))})),i=o.filter(s=>!a.has(s)).map(Ae).sort((s,y)=>s[0]-y[0]||s[1]-y[1]);return[...i.length>0?[`marks outside the body must touch the outline or sit in the ears/tail/under zones: [${i.slice(0,4).map(([s,y])=>`(${s}, ${y})`).join(", ")}]`]:[],...o.length>E.edgeSpikesMax?[`${o.length} spike cells along the outline; the limit is ${E.edgeSpikesMax}`]:[]]},zt=(e,t,r)=>{let n=new Map;for(let o of J)n.set(o,Qt.has(o)?t.O:t.B);for(let[o,a]of e)n.set(o,a);if(!r)for(let o of Jt)n.set(o,t.F);return n},Wt=(e,t)=>{let r=[],n=new Set([...e.values(),t.K,t.D]);n.size>E.colorsMax&&r.push(`${n.size} colors; the limit is ${E.colorsMax}`);for(let[i,s]of Zt)ee(t.B,i)<E.systemDistanceMin&&D(t.B,i)<E.systemContrastMin&&r.push(`palette.B ${t.B} is too close to the ${s} color ${i}; it would vanish on the body`);let o=qt.find(([i,s])=>D(t.K,e.get(h(i,s))??t.B)<E.eyeContrastMin);if(o!==void 0){let i=e.get(h(...o))??t.B;r.push(`eye ${t.K} needs ${E.eyeContrastMin.toFixed(1)}:1 contrast with ${i} behind it at (${o[0]}, ${o[1]})`)}let a=[...e.keys()].filter(i=>{let[s,y]=Ae(i);return Ke.some(([p,T])=>!e.has(h(s+p,y+T)))});for(let[i,s]of Xt){let y=a.filter(p=>D(e.get(p),s)>=E.visibleContrast).length;y<E.visibleShareMin*a.length&&r.push(`too faint on ${i} ${s}: only ${y}/${a.length} outline cells stand out`)}return r},h=(e,t)=>`${e},${t}`,Ae=e=>e.split(",").map(Number);function ye(e,t,r,n){return Array.from({length:r*n},(o,a)=>h(e+a%r,t+Math.floor(a/r)))}function G(e,t,r,n){return new Set(ye(e,r,t-e+1,n-r+1))}function Q(e){return new Set([...e].filter(t=>!J.has(t)))}var J=new Set(P.flatMap(([e,t,r,n])=>ye(e,t,r,n))),Qt=new Set([h(14,6),h(15,6),h(14,7)]),Jt=[h(6,13),h(6,14),h(9,13),h(9,14)],qt=[[10,4],[10,6],[11,5],[11,6],[12,4],[12,6]],Ke=[[1,0],[-1,0],[0,1],[0,-1]],Xt=[["Mist","#F2F5FA"],["Night","#22324E"]],Zt=[["#FFD879","envelope"],["#F25F5C","alert badge"],["#3FBFA6","sparkle"]],fe=["B","D","O","F","K"],Ne={B:F.B,D:F.D,O:F.O,F:F.F,K:F.K},er=["claude","anthropic","homingbird","pip"],tr=/^#[0-9A-Fa-f]{6}$/,rr="palette: B, D and O all match Pip; Pip is the brand, make it your own";var Le=[w("pattern","Pattern",[u("stripes","Stripes",[[6,3,1,1,"marking"],[8,3,1,2,"marking"]]),u("bands","Bands",[[4,3,1,9,"marking"],[7,2,1,11,"marking"]]),u("spots","Spots",[[4,4,2,2,"marking"],[7,3,1,1,"marking"],[7,6,1,1,"marking"],[3,11,2,1,"marking"]]),u("speckles","Speckles",N("marking",[4,11],[7,11],[10,11])),u("head-spots","Head spots",N("marking",[6,3],[8,4])),u("shell","Shell",[[5,2,4,1,"marking"],[3,3,7,1,"marking"],[2,4,8,6,"marking"],[3,10,6,1,"marking"],[4,5,2,2,"detail"],[7,4,2,2,"detail"],[6,7,2,2,"detail"]]),u("back-fur","Back fur",[[5,2,4,1,"marking"],[2,3,7,1,"marking"],[1,4,7,7,"marking"]]),u("belly","Belly",[[4,8,7,4,"marking"]]),u("underside","Underside",[[3,12,9,1,"marking"]])]),w("face","Face",[u("patch","Eye patch",[[10,4,3,4,"marking"]]),u("hood","Hood",[[10,3,3,1,"marking"],[10,4,4,4,"marking"]]),u("mask","Mask",[[9,5,5,1,"marking"]])]),w("ears","Ears",[u("pointed","Pointed",[[5,0,1,2,"B"],[6,1,1,1,"B"],[10,0,1,2,"B"],[9,1,1,1,"B"]]),u("pointed-tips","Pointed, dark tips",[[5,0,1,2,"B"],[6,1,1,1,"B"],[10,0,1,2,"B"],[9,1,1,1,"B"],[5,0,1,1,"detail"],[10,0,1,1,"detail"]]),u("round","Round",[[4,1,2,2,"B"],[10,1,2,2,"B"]]),u("round-dark","Round, dark",[[4,1,2,2,"marking"],[10,1,2,2,"marking"]]),u("long","Long",[[6,0,1,2,"B"],[8,0,1,2,"B"],[6,1,1,1,"detail"],[8,1,1,1,"detail"]]),u("small","Small",[[5,1,2,1,"B"],[9,1,2,1,"B"],[5,1,1,1,"detail"],[10,1,1,1,"detail"]]),u("floppy","Floppy",[[6,2,3,1,"marking"],[7,3,2,3,"marking"]]),u("tufts","Tufts",[[5,0,1,1,"D"],[5,1,2,1,"D"],[10,0,1,1,"D"],[9,1,2,1,"D"]])]),w("head","On the head",[u("crest","Crest",[[8,1,1,1,"D"],[9,0,1,2,"D"]]),u("antenna","Antenna",[[8,0,1,2,"marking"],[8,0,1,1,"detail"]]),u("feelers","Feelers",[[11,1,1,2,"marking"]]),u("spout","Spout",[[7,0,1,2,"detail"],[6,0,1,1,"detail"],[8,0,1,1,"detail"]]),u("eye-bump","Eye bump",[[9,1,3,2,"B"]]),u("fin","Top fin",[[6,1,3,1,"D"]]),u("wool","Wool",N("B",[5,1],[7,1],[9,1]))]),w("spikes","Spikes",[u("back","Along the back",N("detail",[6,1],[8,1],[3,2],[1,4],[0,6],[0,9])),u("quills","Quills",N("marking",[4,1],[7,1],[2,2],[0,5],[0,8])),u("all-round","All round",N("marking",[5,1],[8,1],[11,2],[1,4],[0,7],[0,10],[13,12]))]),w("nose","Nose",[u("nose","Nose",[[15,6,1,1,"detail"]]),u("bill","Wide bill",[[15,7,1,1,"O"]])]),w("tail","Tail",[u("tip","Tail tip",[[0,14,1,1,"detail"]]),u("fluke","Fluke",[[0,12,1,1,"B"]]),u("fin","Tail fin",[[0,12,2,1,"detail"],[0,13,3,1,"detail"],[0,14,2,1,"detail"]])]),w("under","Underneath (no feet)",[u("tentacles","Tentacles",[[4,13,1,2,"B"],[6,13,1,1,"B"],[8,13,1,2,"B"],[10,13,1,1,"B"],[12,13,1,1,"B"]]),u("belly-fin","Belly fin",[[6,13,3,1,"D"]])])];function w(e,t,r){return{id:e,label:t,options:[{id:"none",label:"None",marks:[]},...r]}}function u(e,t,r){return{id:e,label:t,marks:r}}function N(e,...t){return t.map(([r,n])=>[r,n,1,1,e])}var cr=e=>{let t=Y(e),r=W.find(n=>n.id===dr(e));return r===void 0||ur(e,r)?t:[...t,`id: "${r.id}" belongs to a built-in character; give your own character another id`]};var lr=W,je=4096;var ur=(e,t)=>{let r=$e(e);return r!==null&&r===$e(t)},dr=e=>typeof e=="object"&&e!==null?e.id:void 0,$e=e=>{let t=I.decode(e);if(t._tag==="Err")return null;let r=t.value;return JSON.stringify([r.id,r.name,Object.entries(r.palette).map(([n,o])=>`${n}${String(o).toUpperCase()}`).sort(),r.noFeet===!0,r.marks.map(([n,o,a,i,s])=>[n,o,a,i,s.toUpperCase()])])};var pr=(e,t)=>`${e.replace(/\/+$/,"")}/#/${mr}/${Ar(t)}`,mr="character",Ar=e=>{let t="";for(let r of new TextEncoder().encode(JSON.stringify(e)))t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")};var io=Math.ceil(je*4/3);export{lr as BUILT_IN_CHARACTERS,pr as characterLink,cr as characterProblems};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ToolSpec } from 'claude-code'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BUILT_IN_CHARACTERS,
|
|
5
|
+
type CharacterSpec,
|
|
6
|
+
characterLink,
|
|
7
|
+
characterProblems,
|
|
8
|
+
} from './character-rules.mjs'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The tools that help a person make their profile character. They check and preview and call nothing:
|
|
12
|
+
* no command, no route. Only the person saves a character, by pressing "Use this character" in the web
|
|
13
|
+
* client (security rule 7).
|
|
14
|
+
*/
|
|
15
|
+
export const CHARACTER_TOOLS = {
|
|
16
|
+
check: {
|
|
17
|
+
name: 'check_character',
|
|
18
|
+
description:
|
|
19
|
+
'Check a Homingbird profile character (a CharacterSpec) against every rule. Returns the problems to fix, or that it passes. It saves nothing.',
|
|
20
|
+
inputSchema: characterInput(),
|
|
21
|
+
},
|
|
22
|
+
preview: {
|
|
23
|
+
name: 'preview_character',
|
|
24
|
+
description:
|
|
25
|
+
'Check a profile character and, when it passes, return the link that opens it in the Homingbird character editor for the person to review. Show them the link. It saves nothing; only the person can, with "Use this character".',
|
|
26
|
+
inputSchema: characterInput(),
|
|
27
|
+
},
|
|
28
|
+
} as const satisfies Readonly<Record<string, ToolSpec>>
|
|
29
|
+
|
|
30
|
+
export const checkCharacter = (input: Readonly<Record<string, unknown>>): string => {
|
|
31
|
+
const character = specIn(input.character)
|
|
32
|
+
const problems = characterProblems(character)
|
|
33
|
+
return problems.length > 0
|
|
34
|
+
? problemsText(problems)
|
|
35
|
+
: `passes: ${describe(character as CharacterSpec)} Show it with preview_character. ${SAVED_ONLY_BY_A_PERSON}`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const previewCharacter = (input: Readonly<Record<string, unknown>>, webClientUrl: string): string => {
|
|
39
|
+
const character = specIn(input.character)
|
|
40
|
+
const problems = characterProblems(character)
|
|
41
|
+
if (problems.length > 0) return problemsText(problems)
|
|
42
|
+
const spec = character as CharacterSpec
|
|
43
|
+
if (webClientUrl === '')
|
|
44
|
+
return `Checked ${describe(spec)} Homingbird is not signed in here, so there is no link; the person can open the character editor under Profile, My character. ${SAVED_ONLY_BY_A_PERSON}`
|
|
45
|
+
return [
|
|
46
|
+
`Checked ${describe(spec)}`,
|
|
47
|
+
`Show this link to the person: ${characterLink(webClientUrl, spec)}`,
|
|
48
|
+
`It opens the character editor with your draft as a layer they can keep or remove. ${SAVED_ONLY_BY_A_PERSON}`,
|
|
49
|
+
].join('\n')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What `/homingbird character` asks the session's model to do, following the make-character skill. */
|
|
53
|
+
export const characterPromptFor = (idea: string): string =>
|
|
54
|
+
[
|
|
55
|
+
'Help me make my Homingbird profile character: a small animal drawn on Pip’s 16x16 bubble body. You draft; I decide.',
|
|
56
|
+
idea === ''
|
|
57
|
+
? 'First ask me, in one or two short questions, what I would like: an animal or creature, one or two colors, and one detail such as ears, a tail tip, spots or an antenna.'
|
|
58
|
+
: `I have this in mind: ${idea}. Ask at most one short question if something important is missing.`,
|
|
59
|
+
'Then write a CharacterSpec, starting from the closest built-in character below, with an id of your own (never a built-in id) and a name of 1 to 20 characters without Claude, Anthropic, Homingbird or Pip.',
|
|
60
|
+
'Check it with check_character; fix every problem and check again. Never show me a character that fails.',
|
|
61
|
+
'When it passes, call preview_character and show me the link: it opens the character editor, and I press "Use this character" there if I like it.',
|
|
62
|
+
'Ask what to change and repeat. Keep replies plain and short.',
|
|
63
|
+
RULES,
|
|
64
|
+
SAVED_ONLY_BY_A_PERSON,
|
|
65
|
+
`Built-in characters, one CharacterSpec per line:\n${BUILT_IN_CHARACTERS.map((preset) => JSON.stringify(preset)).join('\n')}`,
|
|
66
|
+
].join('\n\n')
|
|
67
|
+
|
|
68
|
+
export const SAVED_ONLY_BY_A_PERSON =
|
|
69
|
+
'You cannot save a character, and no tool can: the person saves it by pressing "Use this character" in Homingbird. Never say a character was saved.'
|
|
70
|
+
|
|
71
|
+
function characterInput() {
|
|
72
|
+
return {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
character: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
description:
|
|
78
|
+
'The CharacterSpec: version 1, base "bubble-16", id, name, palette (B body, D wing, O beak, F feet, K eye), optional noFeet, and marks as [x, y, w, h, color].',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
required: ['character'],
|
|
82
|
+
additionalProperties: false,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const specIn = (character: unknown): unknown => {
|
|
87
|
+
if (typeof character !== 'string') return character
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(character)
|
|
90
|
+
} catch {
|
|
91
|
+
return character
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const problemsText = (problems: ReadonlyArray<string>): string =>
|
|
96
|
+
[
|
|
97
|
+
`${problems.length} problem(s). Fix each one and check again; do not show the person a character that fails:`,
|
|
98
|
+
...problems.map((problem) => `- ${problem}`),
|
|
99
|
+
].join('\n')
|
|
100
|
+
|
|
101
|
+
const describe = (spec: CharacterSpec): string => {
|
|
102
|
+
const colors = (['B', 'D', 'O', 'F', 'K'] as const)
|
|
103
|
+
.filter((key) => spec.palette[key] !== undefined)
|
|
104
|
+
.map((key) => `${PART_NAMES[key]} ${spec.palette[key]}`)
|
|
105
|
+
return `${JSON.stringify(spec.name)} (${spec.id}): ${colors.length > 0 ? colors.join(', ') : 'Pip’s colors'}; ${spec.marks.length} marking(s); ${spec.noFeet === true ? 'no feet' : 'with feet'}. It meets every rule: the format, the zones, at most 8 colors and 80 marked cells, the eye contrast, visibility on light and dark, the name, and that it neither copies Pip nor takes a built-in id.`
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const PART_NAMES = { B: 'body', D: 'wing', O: 'beak', F: 'feet', K: 'eye' } as const
|
|
109
|
+
|
|
110
|
+
const RULES = [
|
|
111
|
+
'The format: palette keys are B body, D wing, O beak or muzzle, F feet, K eye; missing keys use Pip’s colors. A mark is [x, y, w, h, color] in whole cells of the 16x16 grid, x 0-15 left to right, y 0-15 top to bottom; color is #RRGGBB or one of B, D, O, F, K. noFeet: true is for swimmers and floaters.',
|
|
112
|
+
'The map: the body fills rows 2-14, the eye is at x 11, y 5-6, the beak at (14,6), (15,6), (14,7). Markings may go anywhere inside the body except the mouth zone (x 11-15, y 8-11). Outside the body only on the head top (x 2-11, y 0-2), the tail (x 0-2, y 11-15), underneath (x 3-13, y 13-15, with noFeet) or as single spikes touching the outline (10 at most); never in the top-right corner (x 12-15, y 0-4).',
|
|
113
|
+
'The limits: 8 colors, 80 marked cells, 16 of them outside the body; the eye 3:1 against what is behind it; half the outline must stand out on #F2F5FA and on #22324E; the body clear of the envelope yellow, alert red and sparkle teal; do not copy Pip’s colors.',
|
|
114
|
+
'Taste: flat colors, few of them. No text, logos, flags or symbols in the pixels, no real people, no other companies’ mascots or characters from games, films or shows, nothing offensive.',
|
|
115
|
+
].join(' ')
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { EngineInterface, PluginOptions } from 'claude-code'
|
|
2
|
+
|
|
3
|
+
export type Engine = Pick<EngineInterface, 'process' | 'plugin' | 'fs'>
|
|
4
|
+
|
|
5
|
+
export type BundleFinder = {
|
|
6
|
+
readonly plugin: Pick<EngineInterface['plugin'], 'root'>
|
|
7
|
+
readonly fs: Pick<EngineInterface['fs'], 'stat'>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type Ran =
|
|
11
|
+
| { readonly kind: 'ok'; readonly value: unknown; readonly text: string }
|
|
12
|
+
| { readonly kind: 'signed-out' }
|
|
13
|
+
| { readonly kind: 'unsupported'; readonly message: string }
|
|
14
|
+
| { readonly kind: 'failed'; readonly message: string }
|
|
15
|
+
| { readonly kind: 'unavailable'; readonly message: string }
|
|
16
|
+
|
|
17
|
+
export async function run($: Engine, options: PluginOptions, args: ReadonlyArray<string>): Promise<Ran> {
|
|
18
|
+
try {
|
|
19
|
+
const command = await commandOf($, options)
|
|
20
|
+
const result = await $.process.run([...command, ...args], { timeoutMs: RUN_TIMEOUT_MS })
|
|
21
|
+
if (result.exitCode === 0) return { kind: 'ok', value: null, text: result.stdout.trim() }
|
|
22
|
+
if (result.exitCode === EXIT_SIGNED_OUT) return { kind: 'signed-out' }
|
|
23
|
+
if (result.exitCode === EXIT_USAGE) return { kind: 'unsupported', message: messageIn(result.stderr) }
|
|
24
|
+
return { kind: 'failed', message: messageIn(result.stderr) }
|
|
25
|
+
} catch (cause) {
|
|
26
|
+
return { kind: 'unavailable', message: `The homingbird command could not be started: ${describe(cause)}` }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function runJson($: Engine, options: PluginOptions, args: ReadonlyArray<string>): Promise<Ran> {
|
|
31
|
+
const ran = await run($, options, [...args, '--json'])
|
|
32
|
+
return ran.kind === 'ok' ? { ...ran, value: lastJsonLine(ran.text) } : ran
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function commandOf($: BundleFinder, options: PluginOptions): Promise<string[]> {
|
|
36
|
+
const configured = configuredCommandOf(options)
|
|
37
|
+
if (configured.length > 0) return configured
|
|
38
|
+
const bundled = `${$.plugin.root}/${BUNDLED_CLI}`
|
|
39
|
+
// messageIn shows the first line of stderr, so a Node warning there would hide the command's own error.
|
|
40
|
+
return (await isFile($, bundled)) ? ['node', '--no-warnings', bundled] : DEFAULT_COMMAND.split(' ')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const lastJsonLine = (text: string): unknown => {
|
|
44
|
+
const line = text.trim().split('\n').at(-1) ?? ''
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(line)
|
|
47
|
+
} catch {
|
|
48
|
+
return null
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const DEFAULT_COMMAND = 'npx -y @homingbird/cli'
|
|
53
|
+
|
|
54
|
+
export const BUNDLED_CLI = 'cli/homingbird.mjs'
|
|
55
|
+
|
|
56
|
+
const RUN_TIMEOUT_MS = 60_000
|
|
57
|
+
const EXIT_USAGE = 2
|
|
58
|
+
const EXIT_SIGNED_OUT = 3
|
|
59
|
+
|
|
60
|
+
const messageIn = (stderr: string): string => {
|
|
61
|
+
const parsed = lastJsonLine(stderr)
|
|
62
|
+
const message =
|
|
63
|
+
typeof parsed === 'object' && parsed !== null ? (parsed as { error?: unknown }).error : undefined
|
|
64
|
+
return typeof message === 'string'
|
|
65
|
+
? message.split('\n')[0]!
|
|
66
|
+
: stderr.trim().split('\n')[0] || 'The homingbird command failed.'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const configuredCommandOf = (options: PluginOptions): string[] =>
|
|
70
|
+
String(options.command ?? '')
|
|
71
|
+
.trim()
|
|
72
|
+
.split(/\s+/)
|
|
73
|
+
.filter((word) => word !== '')
|
|
74
|
+
|
|
75
|
+
async function isFile($: BundleFinder, path: string): Promise<boolean> {
|
|
76
|
+
try {
|
|
77
|
+
return (await $.fs.stat(path)).kind === 'file'
|
|
78
|
+
} catch {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const describe = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause))
|