refactor: eliminate duplicated logic in inspect, data-inspector, and simple-schema - #331
refactor: eliminate duplicated logic in inspect, data-inspector, and simple-schema#331antfubot wants to merge 1 commit into
Conversation
…simple-schema Extract shared helpers for copy-pasted logic surfaced by jscpd: - inspect RPC functions share one toInvokeResult() envelope helper - data-inspector runQuery/runQueryAtPath share executeQuery() - simple-schema record/array/object share pushFieldIssues() - AgentSmart onInvoke/onRead share runAction()
◈ PR Lens
Architecture 3 components touched across 2 lanes. Data flow
Drill down
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
What
Removes copy-pasted logic surfaced by jscpd across a few source files, extracting a named helper at each seam. Net −72 lines, no behaviour change.
inspectRPC functions — the identical timing + error-envelope block (Date.now()/ try / normalize thrown error intoInvokeResult) was duplicated acrossexecute-command,invoke,invoke-agent-tool, andread-agent-resource. ExtractedtoInvokeResult(run)into_invoke-result.ts; all four delegate to it.data-inspectorquery-engine —runQueryandrunQueryAtPathwere identical except for anavigatestep. Extracted a privateexecuteQuery(target, query, options, select)with a node-selector callback; both are now one-line wrappers.devframesimple-schema —record,array, andobjecteach repeated the "run schema, prefix issue paths" loop. ExtractedpushFieldIssues(issues, key, schema, value).AgentSmart.vue—onInvoke/onReaddiffered only in the RPC call. ExtractedrunAction(id, call)holding the guard/pending/try-catch-finally.Deliberately left as-is
normalize.ts~skeleton.ts— two parallel-but-distinct traversals (different recursion arity, getter-error shapes, truncation markers); a shared helper would obscure each self-contained walker for a marginal gain.CommandsView.vue~FunctionsView.vue— only toolbar/empty-state/list markup overlaps; types, row components, and domain logic differ.rpc.ts/main.tscomposables —AGENTS.mdwants these ported per-plugin to keep plugins independent.Verification
eslintclean on all changed files.This PR was created with the help of an agent.