{"record":{"id":"f8935e82acf5da76","repo":"paperclipai/paperclip","slug":"package-package-json-not-found-at-packagejsonpat","errorCode":null,"errorMessage":"Package package.json not found at ${packageJsonPath}","messagePattern":"Package package\\.json not found at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/plugins/create-paperclip-plugin/src/index.ts","lineNumber":93,"sourceCode":"}\n\nfunction getRepoRootFromSdkPath(sdkPath: string): string {\n  return path.resolve(sdkPath, \"..\", \"..\", \"..\");\n}\n\nfunction getLocalSharedPackagePath(sdkPath: string): string {\n  return path.resolve(getRepoRootFromSdkPath(sdkPath), \"packages\", \"shared\");\n}\n\nfunction isInsideDir(targetPath: string, parentPath: string): boolean {\n  const relative = path.relative(parentPath, targetPath);\n  return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n\nfunction packLocalPackage(packagePath: string, outputDir: string): string {\n  const packageJsonPath = path.join(packagePath, \"package.json\");\n  if (!fs.existsSync(packageJsonPath)) {\n    throw new Error(`Package package.json not found at ${packageJsonPath}`);\n  }\n\n  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\")) as {\n    name?: string;\n    version?: string;\n  };\n  const packageName = packageJson.name ?? path.basename(packagePath);\n  const packageVersion = packageJson.version ?? \"0.0.0\";\n  const tarballFileName = `${packageName.replace(/^@/, \"\").replace(\"/\", \"-\")}-${packageVersion}.tgz`;\n  const sdkBundleDir = path.join(outputDir, \".paperclip-sdk\");\n\n  fs.mkdirSync(sdkBundleDir, { recursive: true });\n  execFileSync(\"pnpm\", [\"build\"], { cwd: packagePath, stdio: \"pipe\" });\n  execFileSync(\"pnpm\", [\"pack\", \"--pack-destination\", sdkBundleDir], { cwd: packagePath, stdio: \"pipe\" });\n\n  const tarballPath = path.join(sdkBundleDir, tarballFileName);\n  if (!fs.existsSync(tarballPath)) {\n    throw new Error(`Packed tarball was not created at ${tarballPath}`);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/create-paperclip-plugin/src/index.ts#L75-L111","documentation":"packLocalPackage expects a real package directory containing package.json; it existsSync-checks the path and throws if absent before attempting to read name/version. This runs during plugin scaffolding when bundling a local shared package (e.g. @paperclip/shared) for the SDK harness.","triggerScenarios":"getLocalSharedPackagePath resolved a directory that does not contain package.json — e.g. the create-paperclip-plugin tool is being run from outside the Paperclip monorepo, the repo layout changed, or the SDK path argument points at the wrong location.","commonSituations":"Running the scaffolder against a fork where packages/shared was renamed/moved; invoking from a shallow checkout missing that directory; wrong --sdk-path argument.","solutions":["Run create-paperclip-plugin from within the Paperclip monorepo root so getRepoRootFromSdkPath resolves correctly.","If passing --sdk-path, point it at the packages/shared directory that contains package.json.","Verify packages/shared/package.json exists in your checkout (git status / missing submodule)."],"exampleFix":"// before: run from a directory whose packages/shared has no package.json\n$ cd /tmp && create-paperclip-plugin ...\n// after\n$ cd /path/to/paperclip-monorepo && create-paperclip-plugin ...","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nfunction ensurePackageJson(pkgDir: string): void {\n  if (!fs.existsSync(path.join(pkgDir, 'package.json'))) {\n    throw new Error(`Cannot scaffold: missing ${path.join(pkgDir, 'package.json')}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the scaffolder from the Paperclip monorepo root.","If passing --sdk-path, point it at packages/shared (which contains package.json).","Confirm the checkout includes the packages directory."],"tags":["scaffolding","filesystem","monorepo","create-paperclip-plugin"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}