UNPKG

simple-task-master

Version:
183 lines 6.63 kB
"use strict"; /** * Constants and default values for Simple Task Master */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.TASK_STATUS = exports.OUTPUT_FORMATS = exports.CLI = exports.FILE_PATTERNS = exports.ERROR_MESSAGES = exports.PATHS = exports.FILE_LIMITS = exports.DEFAULT_CONFIG = exports.CURRENT_SCHEMA_VERSION = void 0; const path = __importStar(require("path")); /** * Current schema version */ exports.CURRENT_SCHEMA_VERSION = 1; /** * Default configuration values */ exports.DEFAULT_CONFIG = { /** Default lock timeout in milliseconds (30 seconds) */ LOCK_TIMEOUT_MS: 30000, /** Default maximum task file size in bytes (1MB) */ MAX_TASK_SIZE_BYTES: 1048576, /** Lock check interval in milliseconds */ LOCK_CHECK_INTERVAL_MS: 100, /** Maximum lock acquisition retries (5 seconds total wait) */ MAX_LOCK_RETRIES: 50, /** Schema version */ SCHEMA_VERSION: 1 }; /** * File size limits */ exports.FILE_LIMITS = { /** Maximum task file size in bytes (1MB) */ MAX_TASK_SIZE: 1048576, /** Maximum title length in characters */ MAX_TITLE_LENGTH: 200, /** Maximum description length in bytes (64KB) */ MAX_DESCRIPTION_LENGTH: 65536, /** Maximum number of tags per task */ MAX_TAGS: 50, /** Maximum number of dependencies per task */ MAX_DEPENDENCIES: 100, /** Maximum number of total fields (including unknown fields) per task */ MAX_TOTAL_FIELDS: 100 }; /** * Path constants */ exports.PATHS = { /** Base directory name for STM */ BASE_DIR: '.simple-task-master', /** Tasks subdirectory */ TASKS_DIR: 'tasks', /** Config file name */ CONFIG_FILE: 'config.json', /** Lock file name */ LOCK_FILE: 'lock', /** Get full base directory path */ getBaseDir: (projectRoot) => path.join(projectRoot, exports.PATHS.BASE_DIR), /** Get full tasks directory path */ getTasksDir: (projectRoot) => path.join(projectRoot, exports.PATHS.BASE_DIR, exports.PATHS.TASKS_DIR), /** Get full config file path */ getConfigPath: (projectRoot) => path.join(projectRoot, exports.PATHS.BASE_DIR, exports.PATHS.CONFIG_FILE), /** Get full lock file path */ getLockPath: (projectRoot) => path.join(projectRoot, exports.PATHS.BASE_DIR, exports.PATHS.LOCK_FILE) }; /** * Error messages */ exports.ERROR_MESSAGES = { // Validation errors TITLE_REQUIRED: 'Task title is required', TITLE_TOO_LONG: `Task title exceeds ${exports.FILE_LIMITS.MAX_TITLE_LENGTH} characters`, TITLE_INVALID_CHARS: 'Task title contains invalid filesystem characters', DESCRIPTION_TOO_LONG: `Task description exceeds ${exports.FILE_LIMITS.MAX_DESCRIPTION_LENGTH} bytes`, INVALID_STATUS: 'Task status must be one of: pending, in-progress, done', INVALID_TASK_ID: 'Invalid task ID', TASK_NOT_FOUND: 'Task not found', DEPENDENCY_NOT_FOUND: 'Dependency task not found', CIRCULAR_DEPENDENCY: 'Circular dependency detected', TOO_MANY_TAGS: `Task cannot have more than ${exports.FILE_LIMITS.MAX_TAGS} tags`, TOO_MANY_DEPENDENCIES: `Task cannot have more than ${exports.FILE_LIMITS.MAX_DEPENDENCIES} dependencies`, TOO_MANY_FIELDS: `Task cannot have more than ${exports.FILE_LIMITS.MAX_TOTAL_FIELDS} total fields`, // File system errors TASK_FILE_TOO_LARGE: `Task file exceeds maximum size of ${exports.FILE_LIMITS.MAX_TASK_SIZE} bytes`, DIRECTORY_NOT_INITIALIZED: 'STM directory not initialized. Run "stm init" first', CONFIG_NOT_FOUND: 'Configuration file not found', INVALID_CONFIG: 'Invalid configuration file', // Lock errors LOCK_ACQUISITION_FAILED: 'Failed to acquire lock after maximum retries', LOCK_ALREADY_HELD: 'Lock is already held by another process', STALE_LOCK_DETECTED: 'Stale lock detected and removed', // Schema errors UNSUPPORTED_SCHEMA: 'Unsupported schema version', SCHEMA_MISMATCH: 'Task schema version does not match current version', // Generic errors UNKNOWN_ERROR: 'An unknown error occurred', PERMISSION_DENIED: 'Permission denied', DISK_FULL: 'Disk space exhausted' }; /** * File name patterns */ exports.FILE_PATTERNS = { /** Pattern for task files */ TASK_FILE: /^(\d+)-(.+)\.md$/, /** Invalid filename characters (filesystem-specific) */ INVALID_FILENAME_CHARS: /[<>:"|?*\x00-\x1f]/g, /** ISO 8601 timestamp pattern */ ISO_8601: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/ }; /** * CLI constants */ exports.CLI = { /** Default command timeout in milliseconds */ DEFAULT_TIMEOUT: 5000, /** Exit codes */ EXIT_CODES: { SUCCESS: 0, ERROR: 1, INVALID_USAGE: 2, NOT_FOUND: 3, LOCK_FAILED: 4 } }; /** * Output format constants */ exports.OUTPUT_FORMATS = { /** Newline-delimited JSON */ NDJSON: 'ndjson', /** Pretty table format */ PRETTY: 'pretty', /** YAML format */ YAML: 'yaml', /** Markdown format */ MARKDOWN: 'markdown', /** CSV format */ CSV: 'csv', /** JSON format */ JSON: 'json' }; /** * Task status values */ exports.TASK_STATUS = { PENDING: 'pending', IN_PROGRESS: 'in-progress', DONE: 'done' }; //# sourceMappingURL=constants.js.map