safeword 0.8.7 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{check-PPVIEF3Q.js → check-4HX4SNVV.js} +27 -27
  2. package/dist/check-4HX4SNVV.js.map +1 -0
  3. package/dist/{chunk-W66Z3C5H.js → chunk-FJYRWU2V.js} +5 -5
  4. package/dist/chunk-FJYRWU2V.js.map +1 -0
  5. package/dist/chunk-POPS3ZRQ.js +1219 -0
  6. package/dist/chunk-POPS3ZRQ.js.map +1 -0
  7. package/dist/cli.js +5 -9
  8. package/dist/cli.js.map +1 -1
  9. package/dist/{diff-S3ICSYQY.js → diff-7QIV6Z5B.js} +14 -16
  10. package/dist/diff-7QIV6Z5B.js.map +1 -0
  11. package/dist/index.d.ts +2 -7
  12. package/dist/reset-RP7AGR2Y.js +73 -0
  13. package/dist/reset-RP7AGR2Y.js.map +1 -0
  14. package/dist/setup-ZYRPDTQI.js +91 -0
  15. package/dist/setup-ZYRPDTQI.js.map +1 -0
  16. package/dist/upgrade-K2FFESUH.js +76 -0
  17. package/dist/upgrade-K2FFESUH.js.map +1 -0
  18. package/package.json +2 -2
  19. package/templates/SAFEWORD.md +5 -2
  20. package/templates/commands/cleanup-zombies.md +48 -0
  21. package/templates/guides/cli-reference.md +9 -11
  22. package/templates/guides/zombie-process-cleanup.md +40 -24
  23. package/templates/scripts/cleanup-zombies.sh +222 -0
  24. package/dist/check-PPVIEF3Q.js.map +0 -1
  25. package/dist/chunk-34PU3QZI.js +0 -1047
  26. package/dist/chunk-34PU3QZI.js.map +0 -1
  27. package/dist/chunk-3OK3NQEW.js +0 -476
  28. package/dist/chunk-3OK3NQEW.js.map +0 -1
  29. package/dist/chunk-BFBUEJDH.js +0 -88
  30. package/dist/chunk-BFBUEJDH.js.map +0 -1
  31. package/dist/chunk-W66Z3C5H.js.map +0 -1
  32. package/dist/diff-S3ICSYQY.js.map +0 -1
  33. package/dist/reset-ZST2SGZ2.js +0 -74
  34. package/dist/reset-ZST2SGZ2.js.map +0 -1
  35. package/dist/setup-ANAIEP3D.js +0 -100
  36. package/dist/setup-ANAIEP3D.js.map +0 -1
  37. package/dist/sync-V6D7QTMO.js +0 -9
  38. package/dist/sync-V6D7QTMO.js.map +0 -1
  39. package/dist/upgrade-QFIGWZ5I.js +0 -76
  40. package/dist/upgrade-QFIGWZ5I.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/output.ts","../src/utils/git.ts","../src/utils/context.ts","../src/reconcile.ts"],"sourcesContent":["/**\n * Console output utilities for consistent CLI messaging\n */\n\n/**\n * Print info message\n */\nexport function info(message: string): void {\n console.log(message);\n}\n\n/**\n * Print success message\n */\nexport function success(message: string): void {\n console.log(`✓ ${message}`);\n}\n\n/**\n * Print warning message\n */\nexport function warn(message: string): void {\n console.warn(`⚠ ${message}`);\n}\n\n/**\n * Print error message to stderr\n */\nexport function error(message: string): void {\n console.error(`✗ ${message}`);\n}\n\n/**\n * Print a blank line\n */\nexport function blank(): void {\n console.log('');\n}\n\n/**\n * Print a section header\n */\nexport function header(title: string): void {\n console.log(`\\n${title}`);\n console.log('─'.repeat(title.length));\n}\n\n/**\n * Print a list item\n */\nexport function listItem(item: string, indent = 2): void {\n console.log(`${' '.repeat(indent)}• ${item}`);\n}\n\n/**\n * Print key-value pair\n */\nexport function keyValue(key: string, value: string): void {\n console.log(` ${key}: ${value}`);\n}\n","/**\n * Git utilities for CLI operations\n */\n\nimport { join } from 'node:path';\nimport { exists } from './fs.js';\n\n/**\n * Check if directory is a git repository\n */\nexport function isGitRepo(cwd: string): boolean {\n return exists(join(cwd, '.git'));\n}\n","/**\n * Project Context Utilities\n *\n * Shared helpers for creating ProjectContext objects used by reconcile().\n */\n\nimport { join } from 'node:path';\nimport { readJson } from './fs.js';\nimport { isGitRepo } from './git.js';\nimport { detectProjectType, type PackageJson } from './project-detector.js';\nimport type { ProjectContext } from '../schema.js';\n\n/**\n * Create a ProjectContext from the current working directory.\n *\n * Reads package.json and detects project type for use with reconcile().\n */\nexport function createProjectContext(cwd: string): ProjectContext {\n const packageJson = readJson<PackageJson>(join(cwd, 'package.json'));\n\n return {\n cwd,\n projectType: detectProjectType(packageJson ?? {}, cwd),\n devDeps: packageJson?.devDependencies ?? {},\n isGitRepo: isGitRepo(cwd),\n };\n}\n","/**\n * Reconciliation Engine\n *\n * Computes and executes plans based on SAFEWORD_SCHEMA and project state.\n * This is the single source of truth for all file/dir/config operations.\n */\n\nimport { join } from 'node:path';\nimport {\n exists,\n ensureDir,\n writeFile,\n readFile,\n readFileSafe,\n readJson,\n writeJson,\n remove,\n removeIfEmpty,\n makeScriptsExecutable,\n getTemplatesDir,\n} from './utils/fs.js';\nimport type {\n SafewordSchema,\n ProjectContext,\n FileDefinition,\n JsonMergeDefinition,\n TextPatchDefinition,\n} from './schema.js';\nimport type { ProjectType } from './utils/project-detector.js';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst HUSKY_DIR = '.husky';\n\n/** Check if path should be skipped in non-git repos (husky files) */\nfunction shouldSkipForNonGit(path: string, isGitRepo: boolean): boolean {\n return path.startsWith(HUSKY_DIR) && !isGitRepo;\n}\n\n/** Plan mkdir actions for directories that don't exist */\nfunction planMissingDirs(\n dirs: string[],\n cwd: string,\n isGitRepo: boolean,\n): { actions: Action[]; created: string[] } {\n const actions: Action[] = [];\n const created: string[] = [];\n for (const dir of dirs) {\n if (shouldSkipForNonGit(dir, isGitRepo)) continue;\n if (!exists(join(cwd, dir))) {\n actions.push({ type: 'mkdir', path: dir });\n created.push(dir);\n }\n }\n return { actions, created };\n}\n\n/** Plan text-patch actions for files missing the marker */\nfunction planTextPatches(patches: Record<string, TextPatchDefinition>, cwd: string): Action[] {\n const actions: Action[] = [];\n for (const [filePath, def] of Object.entries(patches)) {\n const content = readFileSafe(join(cwd, filePath)) ?? '';\n if (!content.includes(def.marker)) {\n actions.push({ type: 'text-patch', path: filePath, definition: def });\n }\n }\n return actions;\n}\n\n/** Plan rmdir actions for directories that exist */\nfunction planExistingDirsRemoval(\n dirs: string[],\n cwd: string,\n): { actions: Action[]; removed: string[] } {\n const actions: Action[] = [];\n const removed: string[] = [];\n for (const dir of dirs) {\n if (exists(join(cwd, dir))) {\n actions.push({ type: 'rmdir', path: dir });\n removed.push(dir);\n }\n }\n return { actions, removed };\n}\n\n/** Plan rm actions for files that exist */\nfunction planExistingFilesRemoval(\n files: string[],\n cwd: string,\n): { actions: Action[]; removed: string[] } {\n const actions: Action[] = [];\n const removed: string[] = [];\n for (const filePath of files) {\n if (exists(join(cwd, filePath))) {\n actions.push({ type: 'rm', path: filePath });\n removed.push(filePath);\n }\n }\n return { actions, removed };\n}\n\n/** Check if a .claude path needs parent dir cleanup */\nfunction getClaudeParentDirForCleanup(filePath: string): string | null {\n if (!filePath.startsWith('.claude/')) return null;\n const parentDir = filePath.slice(0, Math.max(0, filePath.lastIndexOf('/')));\n if (\n !parentDir ||\n parentDir === '.claude' ||\n parentDir === '.claude/skills' ||\n parentDir === '.claude/commands'\n ) {\n return null;\n }\n return parentDir;\n}\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type ReconcileMode = 'install' | 'upgrade' | 'uninstall' | 'uninstall-full';\n\nexport type Action =\n | { type: 'mkdir'; path: string }\n | { type: 'rmdir'; path: string }\n | { type: 'write'; path: string; content: string }\n | { type: 'rm'; path: string }\n | { type: 'chmod'; paths: string[] }\n | { type: 'json-merge'; path: string; definition: JsonMergeDefinition }\n | { type: 'json-unmerge'; path: string; definition: JsonMergeDefinition }\n | { type: 'text-patch'; path: string; definition: TextPatchDefinition }\n | { type: 'text-unpatch'; path: string; definition: TextPatchDefinition };\n\nexport interface ReconcileResult {\n actions: Action[];\n applied: boolean;\n created: string[];\n updated: string[];\n removed: string[];\n packagesToInstall: string[];\n packagesToRemove: string[];\n}\n\nexport interface ReconcileOptions {\n dryRun?: boolean;\n}\n\n// ============================================================================\n// Main reconcile function\n// ============================================================================\n\nexport async function reconcile(\n schema: SafewordSchema,\n mode: ReconcileMode,\n ctx: ProjectContext,\n options?: ReconcileOptions,\n): Promise<ReconcileResult> {\n const dryRun = options?.dryRun ?? false;\n\n const plan = computePlan(schema, mode, ctx);\n\n if (dryRun) {\n return {\n actions: plan.actions,\n applied: false,\n created: plan.wouldCreate,\n updated: plan.wouldUpdate,\n removed: plan.wouldRemove,\n packagesToInstall: plan.packagesToInstall,\n packagesToRemove: plan.packagesToRemove,\n };\n }\n\n const result = executePlan(plan, ctx);\n\n return {\n actions: plan.actions,\n applied: true,\n created: result.created,\n updated: result.updated,\n removed: result.removed,\n packagesToInstall: plan.packagesToInstall,\n packagesToRemove: plan.packagesToRemove,\n };\n}\n\n// ============================================================================\n// Plan computation\n// ============================================================================\n\ninterface ReconcilePlan {\n actions: Action[];\n wouldCreate: string[];\n wouldUpdate: string[];\n wouldRemove: string[];\n packagesToInstall: string[];\n packagesToRemove: string[];\n}\n\nfunction planDeprecatedFilesRemoval(\n deprecatedFiles: string[],\n cwd: string,\n): { actions: Action[]; removed: string[] } {\n const actions: Action[] = [];\n const removed: string[] = [];\n for (const filePath of deprecatedFiles) {\n if (exists(join(cwd, filePath))) {\n actions.push({ type: 'rm', path: filePath });\n removed.push(filePath);\n }\n }\n return { actions, removed };\n}\n\nfunction computePlan(\n schema: SafewordSchema,\n mode: ReconcileMode,\n ctx: ProjectContext,\n): ReconcilePlan {\n switch (mode) {\n case 'install': {\n return computeInstallPlan(schema, ctx);\n }\n case 'upgrade': {\n return computeUpgradePlan(schema, ctx);\n }\n case 'uninstall': {\n return computeUninstallPlan(schema, ctx, false);\n }\n case 'uninstall-full': {\n return computeUninstallPlan(schema, ctx, true);\n }\n }\n}\n\nfunction computeInstallPlan(schema: SafewordSchema, ctx: ProjectContext): ReconcilePlan {\n const actions: Action[] = [];\n const wouldCreate: string[] = [];\n\n // 1. Create all directories (skip .husky if not a git repo)\n const allDirs = [...schema.ownedDirs, ...schema.sharedDirs, ...schema.preservedDirs];\n const missingDirs = planMissingDirs(allDirs, ctx.cwd, ctx.isGitRepo);\n actions.push(...missingDirs.actions);\n wouldCreate.push(...missingDirs.created);\n\n // 2. Write all owned files (skip .husky files if not a git repo)\n for (const [filePath, def] of Object.entries(schema.ownedFiles)) {\n if (shouldSkipForNonGit(filePath, ctx.isGitRepo)) continue;\n\n const content = resolveFileContent(def, ctx);\n actions.push({ type: 'write', path: filePath, content });\n wouldCreate.push(filePath);\n }\n\n // 3. Write managed files (only if missing)\n for (const [filePath, def] of Object.entries(schema.managedFiles)) {\n const fullPath = join(ctx.cwd, filePath);\n if (!exists(fullPath)) {\n const content = resolveFileContent(def, ctx);\n actions.push({ type: 'write', path: filePath, content });\n wouldCreate.push(filePath);\n }\n }\n\n // 4. chmod hook/lib directories (only .husky if git repo)\n const chmodPaths = ['.safeword/hooks', '.safeword/hooks/cursor', '.safeword/lib'];\n if (ctx.isGitRepo) chmodPaths.push(HUSKY_DIR);\n actions.push({ type: 'chmod', paths: chmodPaths });\n\n // 5. JSON merges\n for (const [filePath, def] of Object.entries(schema.jsonMerges)) {\n actions.push({ type: 'json-merge', path: filePath, definition: def });\n }\n\n // 6. Text patches\n for (const [filePath, def] of Object.entries(schema.textPatches)) {\n actions.push({ type: 'text-patch', path: filePath, definition: def });\n if (def.createIfMissing && !exists(join(ctx.cwd, filePath))) {\n wouldCreate.push(filePath);\n }\n }\n\n // 7. Compute packages to install (husky/lint-staged skipped if no git repo)\n const packagesToInstall = computePackagesToInstall(\n schema,\n ctx.projectType,\n ctx.devDeps,\n ctx.isGitRepo,\n );\n\n return {\n actions,\n wouldCreate,\n wouldUpdate: [],\n wouldRemove: [],\n packagesToInstall,\n packagesToRemove: [],\n };\n}\n\nfunction computeUpgradePlan(schema: SafewordSchema, ctx: ProjectContext): ReconcilePlan {\n const actions: Action[] = [];\n const wouldCreate: string[] = [];\n const wouldUpdate: string[] = [];\n\n // 1. Ensure directories exist (skip .husky if not a git repo)\n const allDirs = [...schema.ownedDirs, ...schema.sharedDirs, ...schema.preservedDirs];\n const missingDirs = planMissingDirs(allDirs, ctx.cwd, ctx.isGitRepo);\n actions.push(...missingDirs.actions);\n wouldCreate.push(...missingDirs.created);\n\n // 2. Update owned files if content changed (skip .husky files if not a git repo)\n for (const [filePath, def] of Object.entries(schema.ownedFiles)) {\n if (shouldSkipForNonGit(filePath, ctx.isGitRepo)) continue;\n\n const fullPath = join(ctx.cwd, filePath);\n const newContent = resolveFileContent(def, ctx);\n\n if (!fileNeedsUpdate(fullPath, newContent)) continue;\n\n actions.push({ type: 'write', path: filePath, content: newContent });\n if (exists(fullPath)) {\n wouldUpdate.push(filePath);\n } else {\n wouldCreate.push(filePath);\n }\n }\n\n // 3. Update managed files only if content matches current template\n for (const [filePath, def] of Object.entries(schema.managedFiles)) {\n const fullPath = join(ctx.cwd, filePath);\n const newContent = resolveFileContent(def, ctx);\n\n if (!exists(fullPath)) {\n // Missing - create it\n actions.push({ type: 'write', path: filePath, content: newContent });\n wouldCreate.push(filePath);\n }\n // If file exists, don't update during upgrade - user may have customized it\n }\n\n // 4. Remove deprecated files (renamed or removed in newer versions)\n const deprecatedFiles = planDeprecatedFilesRemoval(schema.deprecatedFiles, ctx.cwd);\n actions.push(...deprecatedFiles.actions);\n const wouldRemove = deprecatedFiles.removed;\n\n // 5. chmod (only .husky if git repo)\n const chmodPathsUpgrade = ['.safeword/hooks', '.safeword/hooks/cursor', '.safeword/lib'];\n if (ctx.isGitRepo) chmodPathsUpgrade.push(HUSKY_DIR);\n actions.push({ type: 'chmod', paths: chmodPathsUpgrade });\n\n // 6. JSON merges (always apply to ensure keys are present)\n for (const [filePath, def] of Object.entries(schema.jsonMerges)) {\n actions.push({ type: 'json-merge', path: filePath, definition: def });\n }\n\n // 7. Text patches (only if marker missing)\n actions.push(...planTextPatches(schema.textPatches, ctx.cwd));\n\n // 8. Compute packages to install (husky/lint-staged skipped if no git repo)\n const packagesToInstall = computePackagesToInstall(\n schema,\n ctx.projectType,\n ctx.devDeps,\n ctx.isGitRepo,\n );\n\n return {\n actions,\n wouldCreate,\n wouldUpdate,\n wouldRemove,\n packagesToInstall,\n packagesToRemove: [],\n };\n}\n\nfunction computeUninstallPlan(\n schema: SafewordSchema,\n ctx: ProjectContext,\n full: boolean,\n): ReconcilePlan {\n const actions: Action[] = [];\n const wouldRemove: string[] = [];\n\n // 1. Remove all owned files and track parent dirs for cleanup\n const ownedFiles = planExistingFilesRemoval(Object.keys(schema.ownedFiles), ctx.cwd);\n actions.push(...ownedFiles.actions);\n wouldRemove.push(...ownedFiles.removed);\n\n // Collect parent dirs that need cleanup (for .claude/* skill dirs)\n const dirsToCleanup = new Set<string>();\n for (const filePath of ownedFiles.removed) {\n const parentDir = getClaudeParentDirForCleanup(filePath);\n if (parentDir) dirsToCleanup.add(parentDir);\n }\n const cleanupDirs = planExistingDirsRemoval([...dirsToCleanup], ctx.cwd);\n actions.push(...cleanupDirs.actions);\n wouldRemove.push(...cleanupDirs.removed);\n\n // 2. JSON unmerges\n for (const [filePath, def] of Object.entries(schema.jsonMerges)) {\n actions.push({ type: 'json-unmerge', path: filePath, definition: def });\n }\n\n // 3. Text unpatches\n for (const [filePath, def] of Object.entries(schema.textPatches)) {\n const fullPath = join(ctx.cwd, filePath);\n if (exists(fullPath)) {\n const content = readFileSafe(fullPath) ?? '';\n if (content.includes(def.marker)) {\n actions.push({ type: 'text-unpatch', path: filePath, definition: def });\n }\n }\n }\n\n // 4. Remove preserved directories first (reverse order, only if empty)\n const preserved = planExistingDirsRemoval(schema.preservedDirs.toReversed(), ctx.cwd);\n actions.push(...preserved.actions);\n wouldRemove.push(...preserved.removed);\n\n // 5. Remove owned directories (reverse order ensures children before parents)\n const owned = planExistingDirsRemoval(schema.ownedDirs.toReversed(), ctx.cwd);\n actions.push(...owned.actions);\n wouldRemove.push(...owned.removed);\n\n // 6. Full uninstall: remove managed files\n if (full) {\n const managed = planExistingFilesRemoval(Object.keys(schema.managedFiles), ctx.cwd);\n actions.push(...managed.actions);\n wouldRemove.push(...managed.removed);\n }\n\n // 7. Compute packages to remove (full only)\n const packagesToRemove = full\n ? computePackagesToRemove(schema, ctx.projectType, ctx.devDeps)\n : [];\n\n return {\n actions,\n wouldCreate: [],\n wouldUpdate: [],\n wouldRemove,\n packagesToInstall: [],\n packagesToRemove,\n };\n}\n\n// ============================================================================\n// Plan execution\n// ============================================================================\n\ninterface ExecutionResult {\n created: string[];\n updated: string[];\n removed: string[];\n}\n\nfunction executePlan(plan: ReconcilePlan, ctx: ProjectContext): ExecutionResult {\n const created: string[] = [];\n const updated: string[] = [];\n const removed: string[] = [];\n const result = { created, updated, removed };\n\n for (const action of plan.actions) {\n executeAction(action, ctx, result);\n }\n\n return result;\n}\n\nfunction executeAction(action: Action, ctx: ProjectContext, result: ExecutionResult): void {\n switch (action.type) {\n case 'mkdir': {\n ensureDir(join(ctx.cwd, action.path));\n result.created.push(action.path);\n break;\n }\n\n case 'rmdir': {\n // Use removeIfEmpty to preserve directories with user content\n if (removeIfEmpty(join(ctx.cwd, action.path))) {\n result.removed.push(action.path);\n }\n break;\n }\n\n case 'write': {\n executeWrite(ctx.cwd, action.path, action.content, result);\n break;\n }\n\n case 'rm': {\n remove(join(ctx.cwd, action.path));\n result.removed.push(action.path);\n break;\n }\n\n case 'chmod': {\n for (const path of action.paths) {\n const fullPath = join(ctx.cwd, path);\n if (exists(fullPath)) makeScriptsExecutable(fullPath);\n }\n break;\n }\n\n case 'json-merge': {\n executeJsonMerge(ctx.cwd, action.path, action.definition, ctx);\n break;\n }\n\n case 'json-unmerge': {\n executeJsonUnmerge(ctx.cwd, action.path, action.definition);\n break;\n }\n\n case 'text-patch': {\n executeTextPatch(ctx.cwd, action.path, action.definition);\n break;\n }\n\n case 'text-unpatch': {\n executeTextUnpatch(ctx.cwd, action.path, action.definition);\n break;\n }\n }\n}\n\nfunction executeWrite(cwd: string, path: string, content: string, result: ExecutionResult): void {\n const fullPath = join(cwd, path);\n const existed = exists(fullPath);\n writeFile(fullPath, content);\n (existed ? result.updated : result.created).push(path);\n}\n\n// ============================================================================\n// Helper functions\n// ============================================================================\n\nfunction resolveFileContent(def: FileDefinition, ctx: ProjectContext): string {\n if (def.template) {\n const templatesDir = getTemplatesDir();\n return readFile(join(templatesDir, def.template));\n }\n\n if (def.content) {\n return typeof def.content === 'function' ? def.content() : def.content;\n }\n\n if (def.generator) {\n return def.generator(ctx);\n }\n\n throw new Error('FileDefinition must have template, content, or generator');\n}\n\nfunction fileNeedsUpdate(installedPath: string, newContent: string): boolean {\n if (!exists(installedPath)) return true;\n const currentContent = readFileSafe(installedPath);\n return currentContent?.trim() !== newContent.trim();\n}\n\n// Packages that require git repo\nconst GIT_ONLY_PACKAGES = new Set(['husky', 'lint-staged']);\n\nexport function computePackagesToInstall(\n schema: SafewordSchema,\n projectType: ProjectType,\n installedDevDeps: Record<string, string>,\n isGitRepo = true,\n): string[] {\n let needed = [...schema.packages.base];\n\n // Filter out git-only packages when not in a git repo\n if (!isGitRepo) {\n needed = needed.filter(pkg => !GIT_ONLY_PACKAGES.has(pkg));\n }\n\n for (const [key, deps] of Object.entries(schema.packages.conditional)) {\n if (projectType[key as keyof ProjectType]) {\n needed.push(...deps);\n }\n }\n\n return needed.filter(pkg => !(pkg in installedDevDeps));\n}\n\nfunction computePackagesToRemove(\n schema: SafewordSchema,\n projectType: ProjectType,\n installedDevDeps: Record<string, string>,\n): string[] {\n const safewordPackages = [...schema.packages.base];\n\n for (const [key, deps] of Object.entries(schema.packages.conditional)) {\n if (projectType[key as keyof ProjectType]) {\n safewordPackages.push(...deps);\n }\n }\n\n // Only remove packages that are actually installed\n return safewordPackages.filter(pkg => pkg in installedDevDeps);\n}\n\nfunction executeJsonMerge(\n cwd: string,\n path: string,\n def: JsonMergeDefinition,\n ctx: ProjectContext,\n): void {\n const fullPath = join(cwd, path);\n const existing = readJson<Record<string, unknown>>(fullPath) ?? {};\n const merged = def.merge(existing, ctx);\n\n // Skip write if content is unchanged (avoids formatting churn)\n if (JSON.stringify(existing) === JSON.stringify(merged)) return;\n\n writeJson(fullPath, merged);\n}\n\nfunction executeJsonUnmerge(cwd: string, path: string, def: JsonMergeDefinition): void {\n const fullPath = join(cwd, path);\n if (!exists(fullPath)) return;\n\n const existing = readJson<Record<string, unknown>>(fullPath);\n if (!existing) return;\n\n const unmerged = def.unmerge(existing);\n\n // Check if file should be removed\n if (def.removeFileIfEmpty) {\n const remainingKeys = Object.keys(unmerged).filter(\n k => unmerged[k] !== undefined && unmerged[k] !== null,\n );\n if (remainingKeys.length === 0) {\n remove(fullPath);\n return;\n }\n }\n\n writeJson(fullPath, unmerged);\n}\n\nfunction executeTextPatch(cwd: string, path: string, def: TextPatchDefinition): void {\n const fullPath = join(cwd, path);\n let content = readFileSafe(fullPath) ?? '';\n\n // Check if already patched\n if (content.includes(def.marker)) return;\n\n // Apply patch\n content = def.operation === 'prepend' ? def.content + content : content + def.content;\n\n writeFile(fullPath, content);\n}\n\nfunction executeTextUnpatch(cwd: string, path: string, def: TextPatchDefinition): void {\n const fullPath = join(cwd, path);\n const content = readFileSafe(fullPath);\n if (!content) return;\n\n // Remove the patched content\n // First try to remove the full content block\n let unpatched = content.replace(def.content, '');\n\n // If full content wasn't found but marker exists, remove lines containing the marker\n if (unpatched === content && content.includes(def.marker)) {\n // Remove lines containing the marker\n const lines = content.split('\\n');\n const filtered = lines.filter(line => !line.includes(def.marker));\n unpatched = filtered.join('\\n').replace(/^\\n+/, ''); // Remove leading empty lines\n }\n\n writeFile(fullPath, unpatched);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAOO,SAAS,KAAK,SAAuB;AAC1C,UAAQ,IAAI,OAAO;AACrB;AAKO,SAAS,QAAQ,SAAuB;AAC7C,UAAQ,IAAI,UAAK,OAAO,EAAE;AAC5B;AAKO,SAAS,KAAK,SAAuB;AAC1C,UAAQ,KAAK,UAAK,OAAO,EAAE;AAC7B;AAKO,SAAS,MAAM,SAAuB;AAC3C,UAAQ,MAAM,UAAK,OAAO,EAAE;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IAAI;AAC/B,MAAI,UAAU,aAAa,QAAQ,KAAK;AAGxC,MAAI,QAAQ,SAAS,IAAI,MAAM,EAAG;AAGlC,YAAU,IAAI,cAAc,YAAY,IAAI,UAAU,UAAU,UAAU,IAAI;AAE9E,YAAU,UAAU,OAAO;AAC7B;AAEA,SAAS,mBAAmB,KAAa,MAAc,KAAgC;AACrF,QAAM,WAAWA,MAAK,KAAK,IAAI;AAC/B,QAAM,UAAU,aAAa,QAAQ;AACrC,MAAI,CAAC,QAAS;AAId,MAAI,YAAY,QAAQ,QAAQ,IAAI,SAAS,EAAE;AAG/C,MAAI,cAAc,WAAW,QAAQ,SAAS,IAAI,MAAM,GAAG;AAEzD,UAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,UAAM,WAAW,MAAM,OAAO,UAAQ,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC;AAChE,gBAAY,SAAS,KAAK,IAAI,EAAE,QAAQ,QAAQ,EAAE;AAAA,EACpD;AAEA,YAAU,UAAU,SAAS;AAC/B;","names":["join","join","join","isGitRepo","join"]}
@@ -1,88 +0,0 @@
1
- import {
2
- detectProjectType,
3
- exists,
4
- getBaseEslintPackages,
5
- getConditionalEslintPackages,
6
- readJson
7
- } from "./chunk-34PU3QZI.js";
8
-
9
- // src/commands/sync.ts
10
- import { join } from "path";
11
- import { execSync } from "child_process";
12
- function getRequiredPlugins(projectType) {
13
- const plugins = [...getBaseEslintPackages()];
14
- for (const [key, isActive] of Object.entries(projectType)) {
15
- if (isActive) {
16
- plugins.push(...getConditionalEslintPackages(key));
17
- }
18
- }
19
- return plugins;
20
- }
21
- function getMissingPackages(required, installed) {
22
- return required.filter((pkg) => !(pkg in installed));
23
- }
24
- async function sync(options = {}) {
25
- const cwd = process.cwd();
26
- const safewordDir = join(cwd, ".safeword");
27
- const packageJsonPath = join(cwd, "package.json");
28
- if (!exists(safewordDir)) {
29
- if (!options.quiet) {
30
- console.error("Not a safeword project. Run `safeword setup` first.");
31
- }
32
- process.exit(1);
33
- }
34
- if (!exists(packageJsonPath)) {
35
- if (!options.quiet) {
36
- console.error("No package.json found.");
37
- }
38
- process.exit(1);
39
- }
40
- const packageJson = readJson(packageJsonPath);
41
- if (!packageJson) {
42
- process.exit(1);
43
- }
44
- const projectType = detectProjectType(packageJson);
45
- const devDeps = packageJson.devDependencies || {};
46
- const requiredPlugins = getRequiredPlugins(projectType);
47
- const missingPlugins = getMissingPackages(requiredPlugins, devDeps);
48
- if (missingPlugins.length === 0) {
49
- return;
50
- }
51
- if (!options.quiet) {
52
- console.log(`Installing missing ESLint plugins: ${missingPlugins.join(", ")}`);
53
- }
54
- try {
55
- execSync(`npm install -D ${missingPlugins.join(" ")}`, {
56
- cwd,
57
- stdio: options.quiet ? "pipe" : "inherit"
58
- });
59
- } catch {
60
- const pluginList = missingPlugins.join(" ");
61
- console.error(`
62
- \u2717 Failed to install ESLint plugins
63
- `);
64
- console.error(`Your project needs: ${pluginList}`);
65
- console.error(`
66
- Run manually when online:`);
67
- console.error(` npm install -D ${pluginList}
68
- `);
69
- process.exit(1);
70
- }
71
- if (options.stage) {
72
- try {
73
- execSync("git add package.json package-lock.json", {
74
- cwd,
75
- stdio: "pipe"
76
- });
77
- } catch {
78
- }
79
- }
80
- if (!options.quiet) {
81
- console.log(`\u2713 Installed ${missingPlugins.length} ESLint plugin(s)`);
82
- }
83
- }
84
-
85
- export {
86
- sync
87
- };
88
- //# sourceMappingURL=chunk-BFBUEJDH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/sync.ts"],"sourcesContent":["/**\n * Sync command - Keep linting plugins in sync with project dependencies\n *\n * Detects frameworks in package.json and ensures the corresponding ESLint plugins\n * are installed. Designed to be called from Husky pre-commit hook.\n *\n * Behavior:\n * - Fast exit when nothing needs to change\n * - Installs missing plugins\n * - Optionally stages modified files (--stage flag for pre-commit)\n * - Clear error message if installation fails\n */\n\nimport { join } from 'node:path';\nimport { execSync } from 'node:child_process';\nimport { exists, readJson } from '../utils/fs.js';\nimport {\n detectProjectType,\n type PackageJson,\n type ProjectType,\n} from '../utils/project-detector.js';\nimport { getBaseEslintPackages, getConditionalEslintPackages } from '../schema.js';\n\nexport interface SyncOptions {\n quiet?: boolean;\n stage?: boolean;\n}\n\n/**\n * Get required ESLint packages based on project type.\n * Derives from schema - single source of truth, no separate list to maintain.\n */\nfunction getRequiredPlugins(projectType: ProjectType): string[] {\n const plugins: string[] = [...getBaseEslintPackages()];\n\n // Add conditional ESLint packages based on detected project type\n // Note: Next.js already sets react=true in project-detector.ts\n for (const [key, isActive] of Object.entries(projectType)) {\n if (isActive) {\n plugins.push(...getConditionalEslintPackages(key));\n }\n }\n\n return plugins;\n}\n\n/**\n * Check which packages are missing from devDependencies\n */\nfunction getMissingPackages(required: string[], installed: Record<string, string>): string[] {\n return required.filter(pkg => !(pkg in installed));\n}\n\n/**\n * Sync linting configuration with current project dependencies\n */\nexport async function sync(options: SyncOptions = {}): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n const packageJsonPath = join(cwd, 'package.json');\n\n // Must be in a safeword project\n if (!exists(safewordDir)) {\n if (!options.quiet) {\n console.error('Not a safeword project. Run `safeword setup` first.');\n }\n process.exit(1);\n }\n\n if (!exists(packageJsonPath)) {\n if (!options.quiet) {\n console.error('No package.json found.');\n }\n process.exit(1);\n }\n\n const packageJson = readJson<PackageJson>(packageJsonPath);\n if (!packageJson) {\n process.exit(1);\n }\n\n // Detect current project type\n const projectType = detectProjectType(packageJson);\n const devDeps = packageJson.devDependencies || {};\n\n // Check for missing plugins\n const requiredPlugins = getRequiredPlugins(projectType);\n const missingPlugins = getMissingPackages(requiredPlugins, devDeps);\n\n // Fast exit if nothing to install\n if (missingPlugins.length === 0) {\n return;\n }\n\n // Install missing plugins\n if (!options.quiet) {\n console.log(`Installing missing ESLint plugins: ${missingPlugins.join(', ')}`);\n }\n\n try {\n // eslint-disable-next-line sonarjs/os-command -- npm install with known package names\n execSync(`npm install -D ${missingPlugins.join(' ')}`, {\n cwd,\n stdio: options.quiet ? 'pipe' : 'inherit',\n });\n } catch {\n // Clear error message for network/install failures\n const pluginList = missingPlugins.join(' ');\n console.error(`\\n✗ Failed to install ESLint plugins\\n`);\n console.error(`Your project needs: ${pluginList}`);\n console.error(`\\nRun manually when online:`);\n console.error(` npm install -D ${pluginList}\\n`);\n process.exit(1);\n }\n\n // Stage modified files if --stage flag is set (for pre-commit hook)\n if (options.stage) {\n try {\n // eslint-disable-next-line sonarjs/no-os-command-from-path -- git with fixed args\n execSync('git add package.json package-lock.json', {\n cwd,\n stdio: 'pipe',\n });\n } catch {\n // Not in a git repo or git add failed - ignore\n }\n }\n\n if (!options.quiet) {\n console.log(`✓ Installed ${missingPlugins.length} ESLint plugin(s)`);\n }\n}\n"],"mappings":";;;;;;;;;AAaA,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAkBzB,SAAS,mBAAmB,aAAoC;AAC9D,QAAM,UAAoB,CAAC,GAAG,sBAAsB,CAAC;AAIrD,aAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,WAAW,GAAG;AACzD,QAAI,UAAU;AACZ,cAAQ,KAAK,GAAG,6BAA6B,GAAG,CAAC;AAAA,IACnD;AAAA,EACF;AAEA,SAAO;AACT;AAKA,SAAS,mBAAmB,UAAoB,WAA6C;AAC3F,SAAO,SAAS,OAAO,SAAO,EAAE,OAAO,UAAU;AACnD;AAKA,eAAsB,KAAK,UAAuB,CAAC,GAAkB;AACnE,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,KAAK,KAAK,WAAW;AACzC,QAAM,kBAAkB,KAAK,KAAK,cAAc;AAGhD,MAAI,CAAC,OAAO,WAAW,GAAG;AACxB,QAAI,CAAC,QAAQ,OAAO;AAClB,cAAQ,MAAM,qDAAqD;AAAA,IACrE;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,CAAC,OAAO,eAAe,GAAG;AAC5B,QAAI,CAAC,QAAQ,OAAO;AAClB,cAAQ,MAAM,wBAAwB;AAAA,IACxC;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,cAAc,SAAsB,eAAe;AACzD,MAAI,CAAC,aAAa;AAChB,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,cAAc,kBAAkB,WAAW;AACjD,QAAM,UAAU,YAAY,mBAAmB,CAAC;AAGhD,QAAM,kBAAkB,mBAAmB,WAAW;AACtD,QAAM,iBAAiB,mBAAmB,iBAAiB,OAAO;AAGlE,MAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,EACF;AAGA,MAAI,CAAC,QAAQ,OAAO;AAClB,YAAQ,IAAI,sCAAsC,eAAe,KAAK,IAAI,CAAC,EAAE;AAAA,EAC/E;AAEA,MAAI;AAEF,aAAS,kBAAkB,eAAe,KAAK,GAAG,CAAC,IAAI;AAAA,MACrD;AAAA,MACA,OAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC,CAAC;AAAA,EACH,QAAQ;AAEN,UAAM,aAAa,eAAe,KAAK,GAAG;AAC1C,YAAQ,MAAM;AAAA;AAAA,CAAwC;AACtD,YAAQ,MAAM,uBAAuB,UAAU,EAAE;AACjD,YAAQ,MAAM;AAAA,0BAA6B;AAC3C,YAAQ,MAAM,oBAAoB,UAAU;AAAA,CAAI;AAChD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI,QAAQ,OAAO;AACjB,QAAI;AAEF,eAAS,0CAA0C;AAAA,QACjD;AAAA,QACA,OAAO;AAAA,MACT,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,OAAO;AAClB,YAAQ,IAAI,oBAAe,eAAe,MAAM,mBAAmB;AAAA,EACrE;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/version.ts"],"sourcesContent":["/**\n * Version comparison utilities\n */\n\n/**\n * Compare two semver versions\n * @returns -1 if a < b, 0 if a == b, 1 if a > b\n */\nexport function compareVersions(a: string, b: string): -1 | 0 | 1 {\n const aParts = a.split('.').map(Number);\n const bParts = b.split('.').map(Number);\n\n for (let i = 0; i < 3; i++) {\n const aVal = aParts[i] ?? 0;\n const bVal = bParts[i] ?? 0;\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n }\n\n return 0;\n}\n\n/**\n * Check if latest version is newer than current\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n return compareVersions(current, latest) === -1;\n}\n"],"mappings":";AAQO,SAAS,gBAAgB,GAAW,GAAuB;AAChE,QAAM,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,MAAM;AACtC,QAAM,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,MAAM;AAEtC,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAM,OAAO,OAAO,CAAC,KAAK;AAC1B,UAAM,OAAO,OAAO,CAAC,KAAK;AAC1B,QAAI,OAAO,KAAM,QAAO;AACxB,QAAI,OAAO,KAAM,QAAO;AAAA,EAC1B;AAEA,SAAO;AACT;AAKO,SAAS,eAAe,SAAiB,QAAyB;AACvE,SAAO,gBAAgB,SAAS,MAAM,MAAM;AAC9C;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/diff.ts"],"sourcesContent":["/**\n * Diff command - Preview changes that would be made by upgrade\n *\n * Uses reconcile() with dryRun to compute what would change.\n */\n\nimport { join } from 'node:path';\nimport { VERSION } from '../version.js';\nimport { exists, readFileSafe } from '../utils/fs.js';\nimport { info, success, error, header, listItem } from '../utils/output.js';\nimport { createProjectContext } from '../utils/context.js';\nimport { reconcile, type Action } from '../reconcile.js';\nimport { SAFEWORD_SCHEMA } from '../schema.js';\n\nexport interface DiffOptions {\n verbose?: boolean;\n}\n\ninterface FileDiff {\n path: string;\n status: 'added' | 'modified' | 'unchanged';\n currentContent?: string;\n newContent?: string;\n}\n\n/**\n * Create a unified diff between two strings\n */\nfunction createUnifiedDiff(oldContent: string, newContent: string, filename: string): string {\n const oldLines = oldContent.split('\\n');\n const newLines = newContent.split('\\n');\n\n const lines: string[] = [`--- a/${filename}`, `+++ b/${filename}`];\n\n // Simple diff - show all changes\n let hasChanges = false;\n\n const maxLines = Math.max(oldLines.length, newLines.length);\n\n for (let i = 0; i < maxLines; i++) {\n const oldLine = oldLines[i];\n const newLine = newLines[i];\n\n if (oldLine === newLine) {\n lines.push(` ${oldLine ?? ''}`);\n } else {\n hasChanges = true;\n if (oldLine !== undefined) {\n lines.push(`-${oldLine}`);\n }\n if (newLine !== undefined) {\n lines.push(`+${newLine}`);\n }\n }\n }\n\n if (!hasChanges) {\n return '';\n }\n\n // Add context marker\n lines.splice(2, 0, `@@ -1,${oldLines.length} +1,${newLines.length} @@`);\n\n return lines.join('\\n');\n}\n\n/** List files by category */\nfunction listFileCategory(categoryName: string, files: FileDiff[]): void {\n if (files.length === 0) return;\n info(`\\n${categoryName}:`);\n for (const file of files) {\n listItem(file.path);\n }\n}\n\n/** Show verbose diff output for modified files */\nfunction showModifiedDiffs(files: FileDiff[]): void {\n for (const file of files) {\n if (!file.currentContent || !file.newContent) continue;\n info(`\\n${file.path}:`);\n const diffOutput = createUnifiedDiff(file.currentContent, file.newContent, file.path);\n if (diffOutput) {\n console.log(diffOutput);\n }\n }\n}\n\n/** Show verbose output for added files (truncated preview) */\nfunction showAddedPreviews(files: FileDiff[]): void {\n for (const file of files) {\n if (!file.newContent) continue;\n info(`\\n${file.path}: (new file)`);\n const allLines = file.newContent.split('\\n');\n const lines = allLines.slice(0, 10);\n for (const line of lines) {\n console.log(`+${line}`);\n }\n if (allLines.length > 10) {\n console.log('... (truncated)');\n }\n }\n}\n\n/** Show packages to install */\nfunction showPackagesToInstall(packages: string[]): void {\n if (packages.length === 0) return;\n info('\\nPackages to install:');\n for (const pkg of packages) {\n listItem(pkg);\n }\n}\n\n/**\n * Convert reconcile actions to file diffs\n */\nfunction actionsToDiffs(actions: Action[], cwd: string): FileDiff[] {\n const diffs: FileDiff[] = [];\n const seenPaths = new Set<string>();\n\n for (const action of actions) {\n if (action.type === 'write') {\n if (seenPaths.has(action.path)) continue;\n seenPaths.add(action.path);\n\n const fullPath = join(cwd, action.path);\n const currentContent = readFileSafe(fullPath);\n\n if (currentContent === null) {\n diffs.push({\n path: action.path,\n status: 'added',\n newContent: action.content,\n });\n } else if (currentContent.trim() !== action.content.trim()) {\n diffs.push({\n path: action.path,\n status: 'modified',\n currentContent,\n newContent: action.content,\n });\n } else {\n diffs.push({\n path: action.path,\n status: 'unchanged',\n currentContent,\n newContent: action.content,\n });\n }\n }\n }\n\n return diffs;\n}\n\nexport async function diff(options: DiffOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n error('Not configured. Run `safeword setup` first.');\n process.exit(1);\n }\n\n // Read project version\n const versionPath = join(safewordDir, 'version');\n const projectVersion = readFileSafe(versionPath)?.trim() ?? 'unknown';\n\n header('Safeword Diff');\n info(`Changes from v${projectVersion} → v${VERSION}`);\n\n // Use reconcile with dryRun to compute changes\n const ctx = createProjectContext(cwd);\n const result = await reconcile(SAFEWORD_SCHEMA, 'upgrade', ctx, { dryRun: true });\n\n // Convert actions to file diffs\n const diffs = actionsToDiffs(result.actions, cwd);\n\n const added = diffs.filter(d => d.status === 'added');\n const modified = diffs.filter(d => d.status === 'modified');\n const unchanged = diffs.filter(d => d.status === 'unchanged');\n\n // Summary\n info(\n `\\nSummary: ${added.length} added, ${modified.length} modified, ${unchanged.length} unchanged`,\n );\n\n // Package changes\n if (result.packagesToInstall.length > 0) {\n info(`\\nPackages to install: ${result.packagesToInstall.length}`);\n }\n\n // List by category\n listFileCategory('Added', added);\n listFileCategory('Modified', modified);\n listFileCategory('Unchanged', unchanged);\n\n // Verbose output - show actual diffs\n if (options.verbose) {\n header('Detailed Changes');\n showModifiedDiffs(modified);\n showAddedPreviews(added);\n showPackagesToInstall(result.packagesToInstall);\n }\n\n if (added.length === 0 && modified.length === 0 && result.packagesToInstall.length === 0) {\n success('\\nNo changes needed - configuration is up to date');\n } else {\n info('\\nRun `safeword upgrade` to apply these changes');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS,YAAY;AAsBrB,SAAS,kBAAkB,YAAoB,YAAoB,UAA0B;AAC3F,QAAM,WAAW,WAAW,MAAM,IAAI;AACtC,QAAM,WAAW,WAAW,MAAM,IAAI;AAEtC,QAAM,QAAkB,CAAC,SAAS,QAAQ,IAAI,SAAS,QAAQ,EAAE;AAGjE,MAAI,aAAa;AAEjB,QAAM,WAAW,KAAK,IAAI,SAAS,QAAQ,SAAS,MAAM;AAE1D,WAAS,IAAI,GAAG,IAAI,UAAU,KAAK;AACjC,UAAM,UAAU,SAAS,CAAC;AAC1B,UAAM,UAAU,SAAS,CAAC;AAE1B,QAAI,YAAY,SAAS;AACvB,YAAM,KAAK,IAAI,WAAW,EAAE,EAAE;AAAA,IAChC,OAAO;AACL,mBAAa;AACb,UAAI,YAAY,QAAW;AACzB,cAAM,KAAK,IAAI,OAAO,EAAE;AAAA,MAC1B;AACA,UAAI,YAAY,QAAW;AACzB,cAAM,KAAK,IAAI,OAAO,EAAE;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAGA,QAAM,OAAO,GAAG,GAAG,SAAS,SAAS,MAAM,OAAO,SAAS,MAAM,KAAK;AAEtE,SAAO,MAAM,KAAK,IAAI;AACxB;AAGA,SAAS,iBAAiB,cAAsB,OAAyB;AACvE,MAAI,MAAM,WAAW,EAAG;AACxB,OAAK;AAAA,EAAK,YAAY,GAAG;AACzB,aAAW,QAAQ,OAAO;AACxB,aAAS,KAAK,IAAI;AAAA,EACpB;AACF;AAGA,SAAS,kBAAkB,OAAyB;AAClD,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,KAAK,kBAAkB,CAAC,KAAK,WAAY;AAC9C,SAAK;AAAA,EAAK,K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AACvB,0BAAsB,OAAO,iBAAiB;AAAA,EAChD;AAEA,MAAI,MAAM,WAAW,KAAK,SAAS,WAAW,KAAK,OAAO,kBAAkB,WAAW,GAAG;AACxF,YAAQ,mDAAmD;AAAA,EAC7D,OAAO;AACL,SAAK,iDAAiD;AAAA,EACxD;AACF;","names":[]}
@@ -1,74 +0,0 @@
1
- import {
2
- createProjectContext,
3
- error,
4
- header,
5
- info,
6
- listItem,
7
- reconcile,
8
- success,
9
- warn
10
- } from "./chunk-3OK3NQEW.js";
11
- import {
12
- SAFEWORD_SCHEMA,
13
- exists
14
- } from "./chunk-34PU3QZI.js";
15
- import "./chunk-ORQHKDT2.js";
16
-
17
- // src/commands/reset.ts
18
- import { join } from "path";
19
- import { execSync } from "child_process";
20
- async function reset(options) {
21
- const cwd = process.cwd();
22
- const safewordDir = join(cwd, ".safeword");
23
- if (!exists(safewordDir)) {
24
- info("Nothing to remove. Project is not configured with safeword.");
25
- return;
26
- }
27
- const fullReset = options.full ?? false;
28
- header("Safeword Reset");
29
- if (fullReset) {
30
- info("Performing full reset (including linting configuration)...");
31
- } else {
32
- info("Removing safeword configuration...");
33
- }
34
- try {
35
- const mode = fullReset ? "uninstall-full" : "uninstall";
36
- const ctx = createProjectContext(cwd);
37
- const result = await reconcile(SAFEWORD_SCHEMA, mode, ctx);
38
- if (fullReset && result.packagesToRemove.length > 0) {
39
- info("\nUninstalling devDependencies...");
40
- try {
41
- const uninstallCmd = `npm uninstall ${result.packagesToRemove.join(" ")}`;
42
- info(`Running: ${uninstallCmd}`);
43
- execSync(uninstallCmd, { cwd, stdio: "inherit" });
44
- success("Uninstalled safeword devDependencies");
45
- } catch {
46
- warn("Failed to uninstall some packages. Run manually:");
47
- listItem(`npm uninstall ${result.packagesToRemove.join(" ")}`);
48
- }
49
- }
50
- header("Reset Complete");
51
- if (result.removed.length > 0) {
52
- info("\nRemoved:");
53
- for (const item of result.removed) {
54
- listItem(item);
55
- }
56
- }
57
- if (!fullReset) {
58
- info("\nPreserved (use --full to remove):");
59
- listItem("eslint.config.mjs");
60
- listItem(".prettierrc");
61
- listItem(".markdownlint-cli2.jsonc");
62
- listItem("package.json (scripts, lint-staged config)");
63
- listItem("devDependencies (eslint, prettier, husky, lint-staged, etc.)");
64
- }
65
- success("\nSafeword configuration removed");
66
- } catch (err) {
67
- error(`Reset failed: ${err instanceof Error ? err.message : "Unknown error"}`);
68
- process.exit(1);
69
- }
70
- }
71
- export {
72
- reset
73
- };
74
- //# sourceMappingURL=reset-ZST2SGZ2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/reset.ts"],"sourcesContent":["/**\n * Reset command - Remove safeword configuration from project\n *\n * Uses reconcile() with mode='uninstall' or 'uninstall-full' to remove configuration.\n *\n * By default, preserves linting configuration (eslint, prettier, etc.)\n * Use --full to also remove linting config and uninstall npm packages\n */\n\nimport { join } from 'node:path';\nimport { execSync } from 'node:child_process';\nimport { exists } from '../utils/fs.js';\nimport { info, success, warn, error, header, listItem } from '../utils/output.js';\nimport { createProjectContext } from '../utils/context.js';\nimport { reconcile } from '../reconcile.js';\nimport { SAFEWORD_SCHEMA } from '../schema.js';\n\nexport interface ResetOptions {\n yes?: boolean;\n full?: boolean;\n}\n\nexport async function reset(options: ResetOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n info('Nothing to remove. Project is not configured with safeword.');\n return;\n }\n\n const fullReset = options.full ?? false;\n\n header('Safeword Reset');\n if (fullReset) {\n info('Performing full reset (including linting configuration)...');\n } else {\n info('Removing safeword configuration...');\n }\n\n try {\n // Use reconcile with appropriate mode\n const mode = fullReset ? 'uninstall-full' : 'uninstall';\n const ctx = createProjectContext(cwd);\n const result = await reconcile(SAFEWORD_SCHEMA, mode, ctx);\n\n // Handle npm uninstall for full reset\n if (fullReset && result.packagesToRemove.length > 0) {\n info('\\nUninstalling devDependencies...');\n\n try {\n const uninstallCmd = `npm uninstall ${result.packagesToRemove.join(' ')}`;\n info(`Running: ${uninstallCmd}`);\n execSync(uninstallCmd, { cwd, stdio: 'inherit' });\n success('Uninstalled safeword devDependencies');\n } catch {\n warn('Failed to uninstall some packages. Run manually:');\n listItem(`npm uninstall ${result.packagesToRemove.join(' ')}`);\n }\n }\n\n // Print summary\n header('Reset Complete');\n\n if (result.removed.length > 0) {\n info('\\nRemoved:');\n for (const item of result.removed) {\n listItem(item);\n }\n }\n\n // Note about preserved linting (only shown if not full reset)\n if (!fullReset) {\n info('\\nPreserved (use --full to remove):');\n listItem('eslint.config.mjs');\n listItem('.prettierrc');\n listItem('.markdownlint-cli2.jsonc');\n listItem('package.json (scripts, lint-staged config)');\n listItem('devDependencies (eslint, prettier, husky, lint-staged, etc.)');\n }\n\n success('\\nSafeword configuration removed');\n } catch (err) {\n error(`Reset failed: ${err instanceof Error ? err.message : 'Unknown error'}`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAYzB,eAAsB,MAAM,SAAsC;AAChE,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,KAAK,KAAK,WAAW;AAGzC,MAAI,CAAC,OAAO,WAAW,GAAG;AACxB,SAAK,6DAA6D;AAClE;AAAA,EACF;AAEA,QAAM,YAAY,QAAQ,QAAQ;AAElC,SAAO,gBAAgB;AACvB,MAAI,WAAW;AACb,SAAK,4DAA4D;AAAA,EACnE,OAAO;AACL,SAAK,oCAAoC;AAAA,EAC3C;AAEA,MAAI;AAEF,UAAM,OAAO,YAAY,mBAAmB;AAC5C,UAAM,MAAM,qBAAqB,GAAG;AACpC,UAAM,SAAS,MAAM,UAAU,iBAAiB,MAAM,GAAG;AAGzD,QAAI,aAAa,OAAO,iBAAiB,SAAS,GAAG;AACnD,WAAK,mCAAmC;AAExC,UAAI;AACF,cAAM,eAAe,iBAAiB,OAAO,iBAAiB,KAAK,GAAG,CAAC;AACvE,aAAK,YAAY,YAAY,EAAE;AAC/B,iBAAS,cAAc,EAAE,KAAK,OAAO,UAAU,CAAC;AAChD,gBAAQ,sCAAsC;AAAA,MAChD,QAAQ;AACN,aAAK,kDAAkD;AACvD,iBAAS,iBAAiB,OAAO,iBAAiB,KAAK,GAAG,CAAC,EAAE;AAAA,MAC/D;AAAA,IACF;AAGA,WAAO,gBAAgB;AAEvB,QAAI,OAAO,QAAQ,SAAS,GAAG;AAC7B,WAAK,YAAY;AACjB,iBAAW,QAAQ,OAAO,SAAS;AACjC,iBAAS,IAAI;AAAA,MACf;AAAA,IACF;AAGA,QAAI,CAAC,WAAW;AACd,WAAK,qCAAqC;AAC1C,eAAS,mBAAmB;AAC5B,eAAS,aAAa;AACtB,eAAS,0BAA0B;AACnC,eAAS,4CAA4C;AACrD,eAAS,8DAA8D;AAAA,IACzE;AAEA,YAAQ,kCAAkC;AAAA,EAC5C,SAAS,KAAK;AACZ,UAAM,iBAAiB,eAAe,QAAQ,IAAI,UAAU,eAAe,EAAE;AAC7E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1,100 +0,0 @@
1
- import {
2
- createProjectContext,
3
- error,
4
- header,
5
- info,
6
- isGitRepo,
7
- listItem,
8
- reconcile,
9
- success,
10
- warn
11
- } from "./chunk-3OK3NQEW.js";
12
- import {
13
- SAFEWORD_SCHEMA,
14
- exists,
15
- writeJson
16
- } from "./chunk-34PU3QZI.js";
17
- import {
18
- VERSION
19
- } from "./chunk-ORQHKDT2.js";
20
-
21
- // src/commands/setup.ts
22
- import { join, basename } from "path";
23
- import { execSync } from "child_process";
24
- function printChangesSummary(created, updated, packageJsonCreated) {
25
- if (created.length > 0 || packageJsonCreated) {
26
- info("\nCreated:");
27
- if (packageJsonCreated) listItem("package.json");
28
- for (const file of created) listItem(file);
29
- }
30
- if (updated.length > 0) {
31
- info("\nModified:");
32
- for (const file of updated) listItem(file);
33
- }
34
- }
35
- async function setup(options) {
36
- const cwd = process.cwd();
37
- const safewordDir = join(cwd, ".safeword");
38
- if (exists(safewordDir)) {
39
- error("Already configured. Run `safeword upgrade` to update.");
40
- process.exit(1);
41
- }
42
- const packageJsonPath = join(cwd, "package.json");
43
- let packageJsonCreated = false;
44
- if (!exists(packageJsonPath)) {
45
- const dirName = basename(cwd) || "project";
46
- const defaultPackageJson = {
47
- name: dirName,
48
- version: "0.1.0",
49
- scripts: {}
50
- };
51
- writeJson(packageJsonPath, defaultPackageJson);
52
- packageJsonCreated = true;
53
- }
54
- const isNonInteractive = options.yes || !process.stdin.isTTY;
55
- header("Safeword Setup");
56
- info(`Version: ${VERSION}`);
57
- if (packageJsonCreated) {
58
- info("Created package.json (none found)");
59
- }
60
- try {
61
- info("\nCreating safeword configuration...");
62
- const ctx = createProjectContext(cwd);
63
- const result = await reconcile(SAFEWORD_SCHEMA, "install", ctx);
64
- success("Created .safeword directory and configuration");
65
- if (result.packagesToInstall.length > 0) {
66
- info("\nInstalling linting dependencies...");
67
- try {
68
- const installCmd = `npm install -D ${result.packagesToInstall.join(" ")}`;
69
- info(`Running: ${installCmd}`);
70
- execSync(installCmd, { cwd, stdio: "inherit" });
71
- success("Installed linting dependencies");
72
- } catch {
73
- warn("Failed to install dependencies. Run manually:");
74
- listItem(`npm install -D ${result.packagesToInstall.join(" ")}`);
75
- }
76
- }
77
- if (!isGitRepo(cwd)) {
78
- if (isNonInteractive) {
79
- warn("Skipped Husky setup (no git repository)");
80
- } else {
81
- warn("Skipped Husky setup (no .git directory)");
82
- info("Initialize git and run safeword upgrade to enable pre-commit hooks");
83
- }
84
- }
85
- header("Setup Complete");
86
- printChangesSummary(result.created, result.updated, packageJsonCreated);
87
- info("\nNext steps:");
88
- listItem("Run `safeword check` to verify setup");
89
- listItem("Commit the new files to git");
90
- success(`
91
- Safeword ${VERSION} installed successfully!`);
92
- } catch (error_) {
93
- error(`Setup failed: ${error_ instanceof Error ? error_.message : "Unknown error"}`);
94
- process.exit(1);
95
- }
96
- }
97
- export {
98
- setup
99
- };
100
- //# sourceMappingURL=setup-ANAIEP3D.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/setup.ts"],"sourcesContent":["/**\n * Setup command - Initialize safeword in a project\n *\n * Uses reconcile() with mode='install' to create all managed files.\n */\n\nimport { join, basename } from 'node:path';\nimport { VERSION } from '../version.js';\nimport { exists, writeJson } from '../utils/fs.js';\nimport { info, success, warn, error, header, listItem } from '../utils/output.js';\nimport { isGitRepo } from '../utils/git.js';\nimport { createProjectContext } from '../utils/context.js';\nimport { reconcile } from '../reconcile.js';\nimport { SAFEWORD_SCHEMA } from '../schema.js';\nimport { execSync } from 'node:child_process';\n\nexport interface SetupOptions {\n yes?: boolean;\n}\n\ninterface PackageJson {\n name?: string;\n version?: string;\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n 'lint-staged'?: Record<string, string[]>;\n}\n\n/** Print file changes summary */\nfunction printChangesSummary(\n created: string[],\n updated: string[],\n packageJsonCreated: boolean,\n): void {\n if (created.length > 0 || packageJsonCreated) {\n info('\\nCreated:');\n if (packageJsonCreated) listItem('package.json');\n for (const file of created) listItem(file);\n }\n\n if (updated.length > 0) {\n info('\\nModified:');\n for (const file of updated) listItem(file);\n }\n}\n\nexport async function setup(options: SetupOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if already configured\n if (exists(safewordDir)) {\n error('Already configured. Run `safeword upgrade` to update.');\n process.exit(1);\n }\n\n // Check for package.json, create if missing\n const packageJsonPath = join(cwd, 'package.json');\n let packageJsonCreated = false;\n if (!exists(packageJsonPath)) {\n const dirName = basename(cwd) || 'project';\n const defaultPackageJson: PackageJson = {\n name: dirName,\n version: '0.1.0',\n scripts: {},\n };\n writeJson(packageJsonPath, defaultPackageJson);\n packageJsonCreated = true;\n }\n\n const isNonInteractive = options.yes || !process.stdin.isTTY;\n\n header('Safeword Setup');\n info(`Version: ${VERSION}`);\n\n if (packageJsonCreated) {\n info('Created package.json (none found)');\n }\n\n try {\n // Use reconcile with mode='install' to create all managed files\n info('\\nCreating safeword configuration...');\n const ctx = createProjectContext(cwd);\n const result = await reconcile(SAFEWORD_SCHEMA, 'install', ctx);\n\n success('Created .safeword directory and configuration');\n\n // Install npm dependencies\n if (result.packagesToInstall.length > 0) {\n info('\\nInstalling linting dependencies...');\n\n try {\n const installCmd = `npm install -D ${result.packagesToInstall.join(' ')}`;\n info(`Running: ${installCmd}`);\n // eslint-disable-next-line sonarjs/os-command -- npm install with known package names\n execSync(installCmd, { cwd, stdio: 'inherit' });\n success('Installed linting dependencies');\n } catch {\n warn('Failed to install dependencies. Run manually:');\n listItem(`npm install -D ${result.packagesToInstall.join(' ')}`);\n }\n }\n\n // Report Husky status\n if (!isGitRepo(cwd)) {\n if (isNonInteractive) {\n warn('Skipped Husky setup (no git repository)');\n } else {\n warn('Skipped Husky setup (no .git directory)');\n info('Initialize git and run safeword upgrade to enable pre-commit hooks');\n }\n }\n\n // Print summary\n header('Setup Complete');\n printChangesSummary(result.created, result.updated, packageJsonCreated);\n\n info('\\nNext steps:');\n listItem('Run `safeword check` to verify setup');\n listItem('Commit the new files to git');\n\n success(`\\nSafeword ${VERSION} installed successfully!`);\n } catch (error_) {\n error(`Setup failed: ${error_ instanceof Error ? error_.message : 'Unknown error'}`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,MAAM,gBAAgB;AAQ/B,SAAS,gBAAgB;AAgBzB,SAAS,oBACP,SACA,SACA,oBACM;AACN,MAAI,QAAQ,SAAS,KAAK,oBAAoB;AAC5C,SAAK,YAAY;AACjB,QAAI,mBAAoB,UAAS,cAAc;AAC/C,eAAW,QAAQ,QAAS,UAAS,IAAI;AAAA,EAC3C;AAEA,MAAI,QAAQ,SAAS,GAAG;AACtB,SAAK,aAAa;AAClB,eAAW,QAAQ,QAAS,UAAS,IAAI;AAAA,EAC3C;AACF;AAEA,eAAsB,MAAM,SAAsC;AAChE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AC3E;AAAA,IACF;AAGA,WAAO,gBAAgB;AACvB,wBAAoB,OAAO,SAAS,OAAO,SAAS,kBAAkB;AAEtE,SAAK,eAAe;AACpB,aAAS,sCAAsC;AAC/C,aAAS,6BAA6B;AAEtC,YAAQ;AAAA,WAAc,OAAO,0BAA0B;AAAA,EACzD,SAAS,QAAQ;AACf,UAAM,iBAAiB,kBAAkB,QAAQ,OAAO,UAAU,eAAe,EAAE;AACnF,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1,9 +0,0 @@
1
- import {
2
- sync
3
- } from "./chunk-BFBUEJDH.js";
4
- import "./chunk-34PU3QZI.js";
5
- import "./chunk-ORQHKDT2.js";
6
- export {
7
- sync
8
- };
9
- //# sourceMappingURL=sync-V6D7QTMO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,76 +0,0 @@
1
- import {
2
- compareVersions
3
- } from "./chunk-W66Z3C5H.js";
4
- import {
5
- sync
6
- } from "./chunk-BFBUEJDH.js";
7
- import {
8
- createProjectContext,
9
- error,
10
- header,
11
- info,
12
- listItem,
13
- reconcile,
14
- success
15
- } from "./chunk-3OK3NQEW.js";
16
- import {
17
- SAFEWORD_SCHEMA,
18
- exists,
19
- readFileSafe
20
- } from "./chunk-34PU3QZI.js";
21
- import {
22
- VERSION
23
- } from "./chunk-ORQHKDT2.js";
24
-
25
- // src/commands/upgrade.ts
26
- import { join } from "path";
27
- async function upgrade() {
28
- const cwd = process.cwd();
29
- const safewordDir = join(cwd, ".safeword");
30
- if (!exists(safewordDir)) {
31
- error("Not configured. Run `safeword setup` first.");
32
- process.exit(1);
33
- }
34
- const versionPath = join(safewordDir, "version");
35
- const projectVersion = readFileSafe(versionPath)?.trim() ?? "0.0.0";
36
- if (compareVersions(VERSION, projectVersion) < 0) {
37
- error(`CLI v${VERSION} is older than project v${projectVersion}.`);
38
- error("Update the CLI first: npm install -g safeword");
39
- process.exit(1);
40
- }
41
- header("Safeword Upgrade");
42
- info(`Upgrading from v${projectVersion} to v${VERSION}`);
43
- try {
44
- const ctx = createProjectContext(cwd);
45
- const result = await reconcile(SAFEWORD_SCHEMA, "upgrade", ctx);
46
- header("Upgrade Complete");
47
- info(`
48
- Version: v${projectVersion} \u2192 v${VERSION}`);
49
- if (result.created.length > 0) {
50
- info("\nCreated:");
51
- for (const file of result.created) {
52
- listItem(file);
53
- }
54
- }
55
- if (result.updated.length > 0) {
56
- info("\nUpdated:");
57
- for (const file of result.updated) {
58
- listItem(file);
59
- }
60
- }
61
- if (result.packagesToInstall.length > 0) {
62
- info(`
63
- Syncing ${result.packagesToInstall.length} package(s)...`);
64
- await sync();
65
- }
66
- success(`
67
- Safeword upgraded to v${VERSION}`);
68
- } catch (error_) {
69
- error(`Upgrade failed: ${error_ instanceof Error ? error_.message : "Unknown error"}`);
70
- process.exit(1);
71
- }
72
- }
73
- export {
74
- upgrade
75
- };
76
- //# sourceMappingURL=upgrade-QFIGWZ5I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/upgrade.ts"],"sourcesContent":["/**\n * Upgrade command - Update safeword configuration to latest version\n *\n * Uses reconcile() with mode='upgrade' to update all managed files.\n */\n\nimport { join } from 'node:path';\nimport { VERSION } from '../version.js';\nimport { exists, readFileSafe } from '../utils/fs.js';\nimport { info, success, error, header, listItem } from '../utils/output.js';\nimport { compareVersions } from '../utils/version.js';\nimport { createProjectContext } from '../utils/context.js';\nimport { reconcile } from '../reconcile.js';\nimport { SAFEWORD_SCHEMA } from '../schema.js';\nimport { sync } from './sync.js';\n\nexport async function upgrade(): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n error('Not configured. Run `safeword setup` first.');\n process.exit(1);\n }\n\n // Read project version\n const versionPath = join(safewordDir, 'version');\n const projectVersion = readFileSafe(versionPath)?.trim() ?? '0.0.0';\n\n // Check for downgrade\n if (compareVersions(VERSION, projectVersion) < 0) {\n error(`CLI v${VERSION} is older than project v${projectVersion}.`);\n error('Update the CLI first: npm install -g safeword');\n process.exit(1);\n }\n\n header('Safeword Upgrade');\n info(`Upgrading from v${projectVersion} to v${VERSION}`);\n\n try {\n // Use reconcile with mode='upgrade' to update all managed files\n const ctx = createProjectContext(cwd);\n const result = await reconcile(SAFEWORD_SCHEMA, 'upgrade', ctx);\n\n // Print summary\n header('Upgrade Complete');\n\n info(`\\nVersion: v${projectVersion} → v${VERSION}`);\n\n if (result.created.length > 0) {\n info('\\nCreated:');\n for (const file of result.created) {\n listItem(file);\n }\n }\n\n if (result.updated.length > 0) {\n info('\\nUpdated:');\n for (const file of result.updated) {\n listItem(file);\n }\n }\n\n // Auto-sync: install missing ESLint packages\n if (result.packagesToInstall.length > 0) {\n info(`\\nSyncing ${result.packagesToInstall.length} package(s)...`);\n await sync();\n }\n\n success(`\\nSafeword upgraded to v${VERSION}`);\n } catch (error_) {\n error(`Upgrade failed: ${error_ instanceof Error ? error_.message : 'Unknown error'}`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,YAAY;AAUrB,eAAsB,UAAyB;AAC7C,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,KAAK,KAAK,WAAW;AAGzC,MAAI,CAAC,OAAO,WAAW,GAAG;AACxB,UAAM,6CAA6C;AACnD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,cAAc,KAAK,aAAa,SAAS;AAC/C,QAAM,iBAAiB,aAAa,WAAW,GAAG,KAAK,KAAK;AAG5D,MAAI,gBAAgB,SAAS,cAAc,IAAI,GAAG;AAChD,UAAM,QAAQ,OAAO,2BAA2B,cAAc,GAAG;AACjE,UAAM,+CAA+C;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO,kBAAkB;AACzB,OAAK,mBAAmB,cAAc,QAAQ,OAAO,EAAE;AAEvD,MAAI;AAEF,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