{"record":{"id":"e10b37e4d9d818bb","repo":"paperclipai/paperclip","slug":"directory-already-exists-outputdir","errorCode":null,"errorMessage":"Directory already exists: ${outputDir}","messagePattern":"Directory already exists: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/create-paperclip-plugin/src/index.ts","lineNumber":139,"sourceCode":" * and a local dev server script for hot-reload workflow.\n */\nexport function scaffoldPluginProject(options: ScaffoldPluginOptions): string {\n  const template = options.template ?? \"default\";\n  if (!VALID_TEMPLATES.includes(template)) {\n    throw new Error(`Invalid template '${template}'. Expected one of: ${VALID_TEMPLATES.join(\", \")}`);\n  }\n\n  if (!isValidPluginName(options.pluginName)) {\n    throw new Error(\"Invalid plugin name. Must be lowercase and may include scope, dots, underscores, or hyphens.\");\n  }\n\n  if (options.category && !VALID_CATEGORIES.has(options.category)) {\n    throw new Error(`Invalid category '${options.category}'. Expected one of: ${[...VALID_CATEGORIES].join(\", \")}`);\n  }\n\n  const outputDir = path.resolve(options.outputDir);\n  if (fs.existsSync(outputDir)) {\n    throw new Error(`Directory already exists: ${outputDir}`);\n  }\n\n  const displayName = options.displayName ?? makeDisplayName(options.pluginName);\n  const description = options.description ?? \"A Paperclip plugin\";\n  const author = options.author ?? \"Plugin Author\";\n  const category = options.category ?? (template === \"workspace\" ? \"workspace\" : template === \"environment\" ? \"environment\" : \"connector\");\n  const manifestId = packageToManifestId(options.pluginName);\n  const localSdkPath = path.resolve(options.sdkPath ?? getLocalSdkPackagePath());\n  const localSharedPath = getLocalSharedPackagePath(localSdkPath);\n  const repoRoot = getRepoRootFromSdkPath(localSdkPath);\n  const useWorkspaceSdk = isInsideDir(outputDir, repoRoot);\n\n  fs.mkdirSync(outputDir, { recursive: true });\n\n  const packedSharedTarball = useWorkspaceSdk ? null : packLocalPackage(localSharedPath, outputDir);\n  const sdkDependency = useWorkspaceSdk\n    ? \"workspace:*\"\n    : `file:${toPosixPath(path.relative(outputDir, packLocalPackage(localSdkPath, outputDir)))}`;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/packages/plugins/create-paperclip-plugin/src/index.ts#L121-L157","documentation":"Safety guard in scaffoldPluginProject: the target output directory already exists on disk, and the scaffolder refuses to overwrite it (it only writes into a fresh directory). This protects existing projects from being clobbered by a re-run; choose a different outputDir or remove the existing one first.","triggerScenarios":"Thrown at packages/plugins/create-paperclip-plugin/src/index.ts:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a different output directory or remove the existing one."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}