Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
jsont is a Terminal User Interface (TUI) JSON viewer built with React and Ink. The application reads JSON data from stdin or files and displays it in various interactive formats including tree view, collapsible view, and schema view with advanced query capabilities using jq and JSONata.
npm run dev - Run the application in development mode using tsxnpm run build - Bundle the application using tsup (supports extensionless imports)npm run start - Run the compiled application from dist/index.jsnpm run test - Run tests in watch modenpm run test:run - Run tests once and exitnpm run test:watch - Run tests in explicit watch modenpm run test:ui - Open Vitest UI for interactive testingnpm run test:ci - Run CI-optimized tests (memory-limited, single-threaded)npm run test:coverage - Run tests with coverage reporting (HTML, JSON, text)npm run test:coverage:ui - Open Vitest UI with coverage for interactive testing and viewingnpm run test -- tree - Run specific test files matching "tree"npm run test -- --coverage - Run tests with coverage reporting (alternative syntax)Memory-Intensive Test Exclusions: Several tests are excluded in CI for memory optimization:
vitest.config.ts exclude list for complete detailsCoverage Reports: Coverage reports are generated in
./coverage/ directory:
./coverage/index.html
./coverage/coverage-final.jsonnpm run check - Run Biome linter and formatter checksnpm run check:write - Run Biome checks and apply safe fixesnpm run type-check - Run TypeScript type checking onlynpm run lint - Lint source code onlynpm run lint:fix - Lint and automatically fix issuesnpm run format - Format source code (read-only)npm run format:write - Format and write source codeecho '{"key": "value"}' | npm run dev cat file.json | npm run dev npm run dev path/to/file.json
The codebase follows a feature-driven clean architecture with clear separation of concerns:
src/index.tsx)handleFatalErrorsrc/core/)AppService orchestrates application lifecycle and initializationterminal.ts, processManager.ts)stdinHandler.ts)errorHandler.ts)lruCache.ts)cliParser.ts)dataConverters/) with SQL, XML, YAML, CSV, JSON Schema supportsrc/features/)Organized by feature domains, each containing:
Key Features:
tree/ - Interactive tree view with keyboard navigationcollapsible/ - Collapsible JSON viewer with syntax highlightingsearch/ - Search functionality across JSON datajq/ - jq query transformation supportschema/ - JSON schema inference and multi-format export (JSON, YAML, CSV, XML, SQL)json-rendering/ - Core JSON parsing and syntax highlightingcommon/ - Shared components (TextInput, BaseViewer, hooks)debug/ - Debug logging and viewer componentsnavigation/ - Goto navigation (gg/G) and keyboard shortcutshelp/ - Context-sensitive help systemstatus/ - Status bar and line number displaysettings/ - Interactive settings TUI with live preview and validationsrc/components/)AppStateProvider)ContentRouter)ModalManager)StatusBarManager)KeyboardManager)src/hooks/)useAppState, useLayoutCalculations)useKeyboardHandler, useSearchHandlers)useTerminalCalculations)useExportHandlers)src/store/)@core/utils/dataConverters/src/store/atoms/ - Atomic state definitions (ui, search, navigation, settings, debug, jq, export)src/store/hooks/ - Typed hooks for accessing atoms (useUI, useSearch, useNavigation, etc.)src/store/Provider.tsx - Jotai provider setupsrc/components/providers/ coordinates global application stateuseInput hook for all keyboard inputsrc/hooks/handlers/ contains specialized input handlers:
globalHandler.ts - Application-wide shortcuts (quit, help, etc.)navigationHandler.ts - Movement and navigation shortcutssearchHandler.ts - Search mode input handlingjqHandler.ts - jq query input handlinghelpHandler.ts - Help system navigationsrc/components/keyboard/KeyboardManager.tsx coordinates handler registration@/*, @core/*, @features/*, @store/*, @components/*, @hooks/*)neverthrow - Result type pattern for error handlingnode-jq - jq query processingjson5 - Enhanced JSON parsinges-toolkit - Modern utility functionsjs-yaml - YAML configuration parsingzod - Runtime type validationjotai - Atomic state managementmutative - Immutable state updatesdefu - Deep object merging for configuration@/*, @core/*, @features/*, @store/*, @components/*, @hooks/*)@/*, @core/*, and @features/* aliasesimport { Box, Text } from "ink"; import type { JsonValue } from "@core/types/index"; import { TreeView } from "@features/tree/components/TreeView"; import { useUI } from "@store/hooks/useUI"; import { formatData } from "./utils/formatter";
.spec.ts suffixindex.ts) for clean module interfacesneverthrow Result type pattern instead of throwing exceptionsResult<T, E> types@tsconfig/strictest for maximum type safetyany types are intentionally used for JSON data handlingThe application implements sophisticated stdin processing to enable keyboard navigation in all input modes:
echo '...' | jsont), stdin is consumed for data, preventing keyboard inputsrc/core/utils/lruCache.ts provides efficient caching with automatic evictionReact.memo, useMemo, and useCallbacknpm run test:ci uses vitest.config.ci.ts with stricter memory limitsNODE_OPTIONS="--max-old-space-size=6144" for heap size controlThe following test categories are excluded in CI for memory optimization:
// Excluded in vitest.config.ci.ts exclude: [ "src/performance.spec.ts", // Performance benchmarks "src/error-scenarios.spec.ts", // Error handling scenarios "src/json-processing.spec.ts", // Large JSON processing "src/core/utils/stdinHandler.spec.ts", // stdin processing "src/library-integration.spec.ts", // Third-party integrations "src/integration/**", // Full integration tests "src/core/utils/dataConverters/SqlConverter.spec.ts", // SQL processing "src/core/services/appService.spec.ts", // App service tests "src/features/json-rendering/utils/syntaxHighlight.spec.ts", // Syntax highlighting "src/core/utils/processManager.spec.ts", // Process management "src/features/collapsible/utils/collapsibleJson.spec.ts", // Large data collapsing ]
~/.config/jsont/config.yamldisplay: interface: showLineNumbers: boolean useUnicodeTree: boolean json: indent: number useTabs: boolean tree: showArrayIndices: boolean showPrimitiveValues: boolean maxValueLength: number keybindings: navigation: up: string down: string pageUp: string pageDown: string
,) key opens interactive settings editor.spec.ts files alongside implementationsrc/integration/src/vitest.setup.ts for test initializationcomponents/, types/, utils/ structuresettingsDefinitions.ts with validationsettings/components/fields/ if needed@core/config/schema.tsconfigMapper.ts// In feature component const handleKeyboardInput = useCallback((input: string, key: KeyboardInput) => { // Handle feature-specific keys return handled; }, []); // Register with parent useEffect(() => { if (onKeyboardHandlerReady) { onKeyboardHandlerReady(handleKeyboardInput); } }, [onKeyboardHandlerReady, handleKeyboardInput]);
The project has plans for UI separation architecture to enable future GUI (Web) version support:
src/core/engine/ will contain UI-agnostic business logic (JsonEngine, TreeEngine, SearchEngine)src/core/adapters/ will provide UI abstraction layer (UIAdapter, UIController)The application uses a layered modal system managed by
ModalManager:
ui.helpVisible is true, Property Details are automatically hidden to prevent layout conflicts// Property Details conditional rendering pattern {(currentMode === "tree" || currentMode === "collapsible") && !ui.helpVisible && ( <PropertyDetailsDisplay ... /> )} // Modal priority rendering pattern {!debugLogViewerVisible && !settingsVisible && !exportDialog.isVisible && children}
uiAtoms)ModalManager with correct priority levelKeyboardManagerD key) to inspect terminal calculationsuseTerminalCalculations for height calculationsModalManagernpm run test:ci for memory-constrained testing@/*, @core/*, @features/* work in build; @store/*, @components/*, @hooks/* work in dev only.spec.ts suffix - All tests are co-located with implementationnpm run check before committing - Ensures code quality standardsnpm run test:ci for memory-constrained environmentsneverthrow Result pattern - Avoid throwing exceptions in favor of explicit error handling