androidboss 0.1.0 → 0.1.1
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/androidboss.mjs
CHANGED
|
@@ -219,7 +219,7 @@ ${f2.content}`),...r.notices.map(n2=>`// ${n2.level}: ${n2.text}`)].join(`
|
|
|
219
219
|
`)||"No behavior changes between those versions.",{changes:changes2})}),server}var UsageError=class extends Error{},camel=s=>s.replace(/-([a-z0-9])/g,(_,c)=>c.toUpperCase()),kebab=s=>s.replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`),types=s=>s?s.anyOf?s.anyOf.flatMap(types):Array.isArray(s.type)?s.type:s.type?[s.type]:s.enum?["string"]:[]:[];function scalar(raw,schema,flag){let t=types(schema);if(t.includes("integer")||t.includes("number")){let n2=Number(raw);if(raw.trim()===""||!Number.isFinite(n2))throw new UsageError(`${flag} needs a number, not "${raw}".`);return n2}if(t.includes("boolean")&&(raw==="true"||raw==="false"))return raw==="true";if(t.includes("object")&&/^\s*\{/.test(raw))return parseJson(raw,flag);if(schema?.enum&&!schema.enum.includes(raw))throw new UsageError(`${flag} must be one of: ${schema.enum.join(", ")}.`);return raw}function parseJson(raw,flag){try{return JSON.parse(raw)}catch{throw new UsageError(`${flag} isn't valid JSON.`)}}function parseToolArgs(schema,argv,io2){let props=schema.properties??{},args={},json=!1,stdinUsed=!1,stdin=flag=>{if(stdinUsed)throw new UsageError(`Only one option can read standard input (${flag}).`);stdinUsed=!0;let text2=io2.readStdin();if(text2===void 0)throw new UsageError(`${flag} is "-", but nothing was piped in.`);return text2},resolve=(raw,flag)=>{if(raw==="-")return stdin(flag);if(raw.startsWith("@@"))return raw.slice(1);if(raw.startsWith("@")&&raw.length>1)try{return io2.readFile(raw.slice(1))}catch(e){throw new UsageError(`Can't read ${raw.slice(1)}: ${e.message}`)}return raw};for(let i=0;i<argv.length;i++){let token=argv[i];if(token==="--json"){json=!0;continue}if(!token.startsWith("--"))throw new UsageError(`Unexpected "${token}". Options start with --; run "androidboss help <tool>".`);let[name2,inline]=token.slice(2).split(/=(.*)/s,2),[head,...path]=name2.split("."),key=camel(head),prop=props[key];if(!prop)throw new UsageError(`Unknown option --${head}. Options: ${Object.keys(props).map(k=>`--${kebab(k)}`).join(", ")||"none"}.`);let flag=`--${kebab(key)}`,t=types(prop),raw=inline;if(raw===void 0){let next=argv[i+1];if(next===void 0||next.startsWith("--")&&next!=="--"){if(t.includes("boolean")&&!path.length){args[key]=!0;continue}throw new UsageError(`${flag} needs a value.`)}raw=next,i++}let value=resolve(raw,flag);if(path.length){if(!t.includes("object"))throw new UsageError(`${flag} isn't an object, so --${head}.${path.join(".")} doesn't apply.`);let obj=args[key]??={},v=value==="true"?!0:value==="false"?!1:value;obj[path.join(".")]=v}else if(t.includes("array")){let list=args[key]??=[];if(/^\s*\[/.test(value)){let parsed=parseJson(value,flag);if(!Array.isArray(parsed))throw new UsageError(`${flag} needs a JSON array.`);list.push(...parsed)}else types(prop.items).includes("object")?list.push(parseJson(value,flag)):list.push(...value.split(",").map(s=>s.trim()).filter(Boolean).map(s=>scalar(s,prop.items,flag)))}else t.includes("object")?args[key]=parseJson(value,flag):args[key]=scalar(value,prop,flag)}let missing=(schema.required??[]).filter(k=>args[k]===void 0);if(missing.length===1&&!stdinUsed&&types(props[missing[0]]).includes("string")&&!props[missing[0]].enum){let text2=io2.readStdin();text2!==void 0&&(args[missing[0]]=text2)}let still=(schema.required??[]).filter(k=>args[k]===void 0);if(still.length)throw new UsageError(`Missing ${still.map(k=>`--${kebab(k)}`).join(", ")}.`);return{args,json}}function describeOptions(schema){let required2=new Set(schema.required??[]);return Object.entries(schema.properties??{}).map(([k,p])=>{let t=p.enum?p.enum.join("|"):types(p).filter(x=>x!=="null").join("|")||"value",item=p.items?p.items.enum?p.items.enum.join("|"):types(p.items).join("|"):"",objectItems=types(p.items).includes("object"),kind=types(p).includes("array")?objectItems?"json":`${item||"value"},\u2026`:types(p).includes("object")?"json":t,shape=objectItems&&p.items?.properties?`
|
|
220
220
|
Each: {${Object.entries(p.items.properties).map(([f2,s])=>`"${f2}": ${s.enum?s.enum.join("|"):types(s).join("|")}`).join(", ")}}. Repeat the option or pass a JSON array.`:types(p).includes("object")&&!types(p).includes("array")?`
|
|
221
221
|
As JSON, or one key at a time: --${kebab(k)}.<key> <value>.`:"";return` --${kebab(k)} <${kind}>${required2.has(k)?" (required)":""}${p.description?`
|
|
222
|
-
${p.description}`:""}${shape}`})}var VERSION="0.1.
|
|
222
|
+
${p.description}`:""}${shape}`})}var VERSION="0.1.1",localServer=()=>createServer(void 0,LOCAL_LIMIT),USAGE=`androidboss ${VERSION}: Android and Kotlin Multiplatform tools from androidboss.info, run on your machine.
|
|
223
223
|
|
|
224
224
|
Usage:
|
|
225
225
|
androidboss <tool> [--option value]... [--json]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "androidboss",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Android and Kotlin Multiplatform tools from androidboss.info in your terminal, and as a local MCP server for coding agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AndroidBoss (https://androidboss.info/)",
|