UNPKG

packfs-core

Version:

Semantic filesystem operations for LLM agent frameworks with natural language understanding. See LLM_AGENT_GUIDE.md for copy-paste examples.

112 lines 3.94 kB
/** * Semantic filesystem interface for PackFS * Based on LSFS research: unified intent-based operations instead of traditional POSIX methods */ /** * Abstract semantic filesystem interface * Replaces traditional POSIX-style methods with unified intent-based operations * * Traditional approach had 9+ separate methods: * - readFile(), writeFile(), stat(), exists(), mkdir(), etc. * * LSFS approach unifies these into 5 semantic operations: * - accessFile() - handles read, stat, exists, preview, create_or_get * - updateContent() - handles write, append, create, merge, patch * - organizeFiles() - handles mkdir, move, copy, grouping * - discoverFiles() - handles readdir, find, search * - removeFiles() - handles unlink, rmdir, deletion by criteria */ export class SemanticFileSystemInterface { constructor(config = {}) { this.config = { defaultMaxResults: 100, semanticThreshold: 0.7, enableNaturalLanguage: true, chunkingConfig: { maxChunkSize: 512, overlapSize: 64 }, ...config }; } /** * Get current semantic configuration */ getConfig() { return { ...this.config }; } /** * Update semantic configuration */ updateConfig(updates) { this.config = { ...this.config, ...updates }; } } /** * Validation utilities for semantic intents */ export class SemanticIntentValidator { static validateFileAccessIntent(intent) { const errors = []; if (!intent.purpose) { errors.push('FileAccessIntent must specify purpose'); } if (!intent.target || (!intent.target.path && !intent.target.pattern && !intent.target.semanticQuery && !intent.target.criteria)) { errors.push('FileAccessIntent must specify target (path, pattern, semanticQuery, or criteria)'); } if (intent.purpose === 'create_or_get' && !intent.target.path) { errors.push('create_or_get purpose requires specific path target'); } return errors; } static validateContentUpdateIntent(intent) { const errors = []; if (!intent.purpose) { errors.push('ContentUpdateIntent must specify purpose'); } if (!intent.target || !intent.target.path) { errors.push('ContentUpdateIntent requires specific path target'); } if (!intent.content && intent.purpose !== 'create') { errors.push('ContentUpdateIntent must provide content for non-create operations'); } return errors; } static validateOrganizationIntent(intent) { const errors = []; if (!intent.purpose) { errors.push('OrganizationIntent must specify purpose'); } if (!intent.destination) { errors.push('OrganizationIntent must specify destination'); } if ((intent.purpose === 'move' || intent.purpose === 'copy') && !intent.source) { errors.push('Move and copy operations require source target'); } return errors; } static validateDiscoveryIntent(intent) { const errors = []; if (!intent.purpose) { errors.push('DiscoveryIntent must specify purpose'); } if (!intent.target) { errors.push('DiscoveryIntent must specify target'); } if (intent.purpose === 'list' && !intent.target.path) { errors.push('List operation requires path target'); } return errors; } static validateRemovalIntent(intent) { const errors = []; if (!intent.purpose) { errors.push('RemovalIntent must specify purpose'); } if (!intent.target) { errors.push('RemovalIntent must specify target'); } return errors; } } //# sourceMappingURL=interface.js.map