@sentry/junior 0.1.1 → 0.3.0

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.
@@ -1,6 +1,12 @@
1
1
  import * as Sentry from '@sentry/nextjs';
2
2
 
3
+ /**
4
+ * Initializes Sentry for Next.js runtime contexts used by Junior.
5
+ */
3
6
  declare function register(): Promise<void>;
7
+ /**
8
+ * Re-export of Sentry request error handler for Next.js instrumentation wiring.
9
+ */
4
10
  declare const onRequestError: typeof Sentry.captureRequestError;
5
11
 
6
12
  export { onRequestError, register };
@@ -1,14 +1,22 @@
1
1
  import { NextConfig } from 'next';
2
2
 
3
+ /**
4
+ * Optional overrides for `withJunior`.
5
+ */
3
6
  interface JuniorConfigOptions {
4
7
  dataDir?: string;
5
8
  skillsDir?: string;
6
9
  pluginsDir?: string;
7
- sentry?: boolean;
10
+ pluginPackages?: string[];
8
11
  }
9
12
  type NextConfigFactory = (phase: string, ctx: {
10
13
  defaultConfig: NextConfig;
11
14
  }) => Promise<NextConfig> | NextConfig;
12
- declare function withJunior(nextConfig?: NextConfig | NextConfigFactory, options?: JuniorConfigOptions): NextConfig | NextConfigFactory;
15
+ /**
16
+ * Extends a Next.js config with Junior runtime defaults.
17
+ *
18
+ * Supports both object and function-style Next config exports.
19
+ */
20
+ declare function withJunior(options?: JuniorConfigOptions, nextConfig?: NextConfig | NextConfigFactory): NextConfig | NextConfigFactory;
13
21
 
14
22
  export { type JuniorConfigOptions, withJunior };
@@ -1,59 +1,53 @@
1
+ import {
2
+ discoverInstalledPluginPackageContent,
3
+ discoverNodeModulesDirs,
4
+ isDirectory
5
+ } from "./chunk-SP6LV35L.js";
6
+
1
7
  // src/next-config.ts
2
8
  import { createRequire } from "module";
3
- import { readFileSync, statSync } from "fs";
4
9
  import path from "path";
5
10
  var require2 = createRequire(import.meta.url);
6
- function isDirectory(targetPath) {
7
- try {
8
- return statSync(targetPath).isDirectory();
9
- } catch {
10
- return false;
11
- }
11
+ function unique(values) {
12
+ return [...new Set(values)];
12
13
  }
13
- function isFile(targetPath) {
14
- try {
15
- return statSync(targetPath).isFile();
16
- } catch {
17
- return false;
18
- }
14
+ function sentryConfigured() {
15
+ return Boolean(process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN);
19
16
  }
20
- function discoverInstalledPluginPackageTracingIncludes(cwd = process.cwd()) {
21
- const rootPackageJsonPath = path.join(cwd, "package.json");
22
- let rootPackageJson;
23
- try {
24
- rootPackageJson = JSON.parse(readFileSync(rootPackageJsonPath, "utf8"));
25
- } catch {
26
- return [];
27
- }
28
- const dependencies = [
29
- ...Object.keys(rootPackageJson.dependencies ?? {}),
30
- ...Object.keys(rootPackageJson.optionalDependencies ?? {})
31
- ];
32
- const tracingIncludes = [];
33
- for (const dependency of dependencies) {
34
- const packageDir = path.join(cwd, "node_modules", ...dependency.split("/"));
35
- if (!isDirectory(packageDir)) {
36
- continue;
37
- }
38
- const base = `./node_modules/${dependency}`;
39
- if (isFile(path.join(packageDir, "plugin.yaml"))) {
40
- tracingIncludes.push(`${base}/plugin.yaml`);
41
- }
42
- if (isDirectory(path.join(packageDir, "plugins"))) {
43
- tracingIncludes.push(`${base}/plugins/**/*`);
44
- }
45
- if (isDirectory(path.join(packageDir, "skills"))) {
46
- tracingIncludes.push(`${base}/skills/**/*`);
47
- }
48
- }
49
- return [...new Set(tracingIncludes)].sort((left, right) => left.localeCompare(right));
17
+ function isPackageInstalled(cwd, packageName) {
18
+ const nodeModulesDirs = discoverNodeModulesDirs(cwd);
19
+ return nodeModulesDirs.some(
20
+ (nodeModulesDir) => isDirectory(path.join(nodeModulesDir, ...packageName.split("/")))
21
+ );
50
22
  }
51
23
  function applyJuniorConfig(nextConfig, options) {
24
+ const existingServerRuntimeConfig = nextConfig?.serverRuntimeConfig ?? {};
52
25
  const dataDir = options?.dataDir ?? "./app/data";
53
26
  const skillsDir = options?.skillsDir ?? "./app/skills";
54
27
  const pluginsDir = options?.pluginsDir ?? "./app/plugins";
28
+ const configuredPluginPackages = unique(options?.pluginPackages ?? []);
29
+ const discoveredPlugins = discoverInstalledPluginPackageContent(process.cwd(), { packageNames: configuredPluginPackages });
30
+ const unresolvedConfiguredPackages = configuredPluginPackages.filter(
31
+ (packageName) => !discoveredPlugins.packageNames.includes(packageName)
32
+ );
33
+ const invalidPluginPackages = unresolvedConfiguredPackages.filter(
34
+ (packageName) => isPackageInstalled(process.cwd(), packageName)
35
+ );
36
+ const missingPluginPackages = unresolvedConfiguredPackages.filter(
37
+ (packageName) => !invalidPluginPackages.includes(packageName)
38
+ );
39
+ if (invalidPluginPackages.length > 0) {
40
+ throw new Error(
41
+ `withJunior pluginPackages contains installed packages that are not valid Junior plugins: ${invalidPluginPackages.join(", ")}`
42
+ );
43
+ }
44
+ if (missingPluginPackages.length > 0) {
45
+ throw new Error(
46
+ `withJunior pluginPackages contains unresolved packages: ${missingPluginPackages.join(", ")}`
47
+ );
48
+ }
55
49
  const defaultDataTracingIncludes = options?.dataDir ? [`${dataDir}/**/*`] : ["./app/SOUL.md", "./app/ABOUT.md"];
56
- const pluginPackageTracingIncludes = discoverInstalledPluginPackageTracingIncludes();
50
+ const pluginPackageTracingIncludes = discoveredPlugins.tracingIncludes;
57
51
  const tracingIncludes = Array.from(/* @__PURE__ */ new Set([
58
52
  ...defaultDataTracingIncludes,
59
53
  `${skillsDir}/**/*`,
@@ -69,32 +63,39 @@ function applyJuniorConfig(nextConfig, options) {
69
63
  ...nextConfig,
70
64
  serverExternalPackages: Array.from(/* @__PURE__ */ new Set([
71
65
  ...nextConfig?.serverExternalPackages ?? [],
66
+ "@vercel/queue",
72
67
  "@vercel/sandbox",
73
68
  "bash-tool",
74
69
  "just-bash",
70
+ "@mariozechner/pi-agent-core",
71
+ "@mariozechner/pi-ai",
75
72
  "@chat-adapter/slack",
76
73
  "@slack/web-api"
77
74
  ])),
78
75
  outputFileTracingIncludes: {
79
76
  ...nextConfig?.outputFileTracingIncludes,
80
77
  "/*": mergedGlobalTracingIncludes
78
+ },
79
+ serverRuntimeConfig: {
80
+ ...existingServerRuntimeConfig,
81
+ juniorPluginPackages: configuredPluginPackages
81
82
  }
82
83
  };
83
- if (options?.sentry) {
84
- const { withSentryConfig } = require2("@sentry/nextjs");
85
- return withSentryConfig(config, {
86
- org: process.env.SENTRY_ORG,
87
- project: process.env.SENTRY_PROJECT,
88
- authToken: process.env.SENTRY_AUTH_TOKEN,
89
- silent: !process.env.CI,
90
- sourcemaps: {
91
- disable: false
92
- }
93
- });
84
+ if (!sentryConfigured()) {
85
+ return config;
94
86
  }
95
- return config;
87
+ const { withSentryConfig } = require2("@sentry/nextjs");
88
+ return withSentryConfig(config, {
89
+ org: process.env.SENTRY_ORG,
90
+ project: process.env.SENTRY_PROJECT,
91
+ authToken: process.env.SENTRY_AUTH_TOKEN,
92
+ silent: !process.env.CI,
93
+ sourcemaps: {
94
+ disable: false
95
+ }
96
+ });
96
97
  }
97
- function withJunior(nextConfig, options) {
98
+ function withJunior(options, nextConfig) {
98
99
  if (typeof nextConfig === "function") {
99
100
  return async (phase, ctx) => {
100
101
  const resolved = await nextConfig(phase, ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -39,9 +39,7 @@
39
39
  "just-bash": "^2.12.0",
40
40
  "node-html-markdown": "^2.0.0",
41
41
  "yaml": "^2.8.2",
42
- "zod": "^4.3.6",
43
- "@sentry/junior-github": "0.1.1",
44
- "@sentry/junior-sentry": "0.1.1"
42
+ "zod": "^4.3.6"
45
43
  },
46
44
  "peerDependencies": {
47
45
  "@sentry/nextjs": ">=10.0.0",
@@ -65,10 +63,7 @@
65
63
  "vitest-evals": "^0.6.0"
66
64
  },
67
65
  "scripts": {
68
- "dev": "next dev",
69
- "build": "next build",
70
- "build:pkg": "tsup",
71
- "start": "next start",
66
+ "build": "tsup",
72
67
  "test": "pnpm run test:slack-boundary && vitest run",
73
68
  "test:watch": "vitest",
74
69
  "preevals": "pnpm run test:slack-boundary",