* Add XPath query for node selection - packages/core/src/xpath.ts: XPath engine using fontoxpath with custom DOM facade over SceneGraph nodes - RPC command: 'query' with selector, page, limit params - CLI command: 'open-pencil query <file> <xpath>' with --json, --page, --limit - AI/MCP tool: 'query_nodes' with XPath examples in description - Queryable attributes: name, width, height, x, y, visible, opacity, cornerRadius, fontSize, fontFamily, fontWeight, layoutMode, itemSpacing, padding*, strokeWeight, rotation, locked, blendMode, text, lineHeight, letterSpacing * Add tests and docs for XPath query - 9 unit tests for queryByXPath/matchByXPath core functions - 6 tool tests for query_nodes AI/MCP tool - README: query examples in CLI section - VitePress docs: patterns, queryable attributes, example output - CHANGELOG: feature entry * Lazy-load fontoxpath to avoid bundling in desktop app - Dynamic import() instead of static import for fontoxpath - queryByXPath/matchByXPath now async (they were sync before) - RpcCommand.execute allows R | Promise<R> for async commands - Fix 2 lint errors (unnecessary optional chain, always-truthy) - Update all tests and CLI to await results
38 lines
840 B
TypeScript
Executable file
38 lines
840 B
TypeScript
Executable file
#!/usr/bin/env bun
|
|
import { defineCommand, runMain } from 'citty'
|
|
|
|
import analyze from './commands/analyze'
|
|
import evalCmd from './commands/eval'
|
|
import exportCmd from './commands/export'
|
|
import find from './commands/find'
|
|
import info from './commands/info'
|
|
import query from './commands/query'
|
|
import node from './commands/node'
|
|
import pages from './commands/pages'
|
|
import tree from './commands/tree'
|
|
import variables from './commands/variables'
|
|
|
|
const { version } = await import('../package.json')
|
|
|
|
const main = defineCommand({
|
|
meta: {
|
|
name: 'open-pencil',
|
|
description: 'OpenPencil CLI — inspect, export, and lint .fig design files',
|
|
version
|
|
},
|
|
subCommands: {
|
|
analyze,
|
|
eval: evalCmd,
|
|
export: exportCmd,
|
|
find,
|
|
info,
|
|
query,
|
|
node,
|
|
pages,
|
|
tree,
|
|
variables
|
|
}
|
|
})
|
|
|
|
void runMain(main)
|