@sentry/junior 0.118.0 → 0.120.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.
Files changed (56) hide show
  1. package/dist/{agent-hooks-J2FB7XD6.js → agent-hooks-5DDPWRYO.js} +8 -8
  2. package/dist/api/conversations/detail.d.ts +17 -0
  3. package/dist/api/conversations/event-list.d.ts +17 -0
  4. package/dist/api/schema/conversation.d.ts +68 -0
  5. package/dist/api/schema.js +1 -1
  6. package/dist/api.js +103 -82
  7. package/dist/app.js +24 -24
  8. package/dist/build/copy-build-content.d.ts +2 -2
  9. package/dist/{catalog-runtime-UHHLU53I.js → catalog-runtime-5KR5XBMJ.js} +7 -7
  10. package/dist/chat/discovery.d.ts +2 -0
  11. package/dist/chat/mcp/tool-manager.d.ts +14 -1
  12. package/dist/chat/plugins/types.d.ts +3 -9
  13. package/dist/chat/plugins/user-pages.d.ts +2 -1
  14. package/dist/chat/slack/tools/canvas/api.d.ts +2 -9
  15. package/dist/chat/slack/tools/canvas/markdown.d.ts +9 -0
  16. package/dist/{chunk-GT2ZUALJ.js → chunk-24B5R6OU.js} +92 -6
  17. package/dist/{chunk-L72GDKSN.js → chunk-6WX5SPI3.js} +1 -1
  18. package/dist/{chunk-3N3FMCKN.js → chunk-ALAKN7LR.js} +1 -1
  19. package/dist/{chunk-MLZFK4KP.js → chunk-ALYQOZG7.js} +1 -1
  20. package/dist/{chunk-6BGUAOYP.js → chunk-BHXW734F.js} +13 -7
  21. package/dist/{chunk-4LPPH7Y6.js → chunk-DJDGDJDF.js} +4 -4
  22. package/dist/{chunk-HWUBBHLK.js → chunk-DMKHRBI6.js} +4 -3
  23. package/dist/{chunk-QWCF4RAC.js → chunk-DWOH57FW.js} +1 -1
  24. package/dist/{chunk-7GADTCNS.js → chunk-EIVE6GL4.js} +3 -3
  25. package/dist/{chunk-6K2QE2UI.js → chunk-ERYVNWNE.js} +250 -37
  26. package/dist/{chunk-UXLYAVYL.js → chunk-GNNV3UTY.js} +1 -1
  27. package/dist/chunk-H4HBKISO.js +417 -0
  28. package/dist/{chunk-FXOYURO4.js → chunk-HDFGNU5E.js} +1 -0
  29. package/dist/{chunk-PJPKHGLG.js → chunk-JQWP6V22.js} +4 -11
  30. package/dist/{chunk-KC5EE27Y.js → chunk-M243JMZH.js} +2 -2
  31. package/dist/{chunk-7SM3P4XR.js → chunk-O2ULQJWR.js} +82 -1
  32. package/dist/{chunk-B3IT5END.js → chunk-OOUNJNMR.js} +16 -152
  33. package/dist/{chunk-HN6LFYG3.js → chunk-Q3RL6A4E.js} +2 -2
  34. package/dist/{chunk-3MUSSFMP.js → chunk-QOQPPRFS.js} +221 -14
  35. package/dist/{chunk-S6R23MFB.js → chunk-TKUCRFNX.js} +12 -225
  36. package/dist/{chunk-PWRFTDTY.js → chunk-VURFJVFH.js} +2 -2
  37. package/dist/{chunk-3LGCVRBQ.js → chunk-XAI2HNAY.js} +9 -5
  38. package/dist/{chunk-4SOQPUF4.js → chunk-YEAOUT5W.js} +1 -1
  39. package/dist/cli/chat.js +24 -24
  40. package/dist/cli/check.js +8 -8
  41. package/dist/cli/init.js +2 -2
  42. package/dist/cli/plugins.js +13 -13
  43. package/dist/cli/snapshot-create.js +11 -11
  44. package/dist/cli/upgrade.js +8 -8
  45. package/dist/{db-PMRHFSYL.js → db-T4ZY64PB.js} +6 -6
  46. package/dist/{discovery-RMHYSRL7.js → discovery-GUFTFBTL.js} +3 -1
  47. package/dist/instrumentation.js +3 -3
  48. package/dist/nitro.js +24 -7
  49. package/dist/{oauth-callback-server-QJUC7S4X.js → oauth-callback-server-LQ6DFI26.js} +17 -17
  50. package/dist/{runner-PZMV6JQW.js → runner-D3ZU6TJH.js} +10 -10
  51. package/dist/{skills-W4JETYSV.js → skills-JMXY7LIY.js} +8 -8
  52. package/dist/{validation-IJLNHZSU.js → validation-OEPJS7JX.js} +8 -8
  53. package/dist/version.js +1 -1
  54. package/package.json +8 -7
  55. package/skills/jr-rpc/SKILL.md +40 -0
  56. package/dist/chunk-3V7OFJZC.js +0 -264
package/dist/nitro.js CHANGED
@@ -13,11 +13,12 @@ import {
13
13
  resolvePluginModule
14
14
  } from "./chunk-Y2CM7HXH.js";
15
15
  import {
16
- discoverInstalledPluginPackageContent,
16
+ discoverInstalledPluginPackageContent
17
+ } from "./chunk-OOUNJNMR.js";
18
+ import {
17
19
  isValidPackageName,
18
20
  resolvePackageDir
19
- } from "./chunk-B3IT5END.js";
20
- import "./chunk-3V7OFJZC.js";
21
+ } from "./chunk-H4HBKISO.js";
21
22
  import {
22
23
  JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
23
24
  JUNIOR_HEARTBEAT_CRON_SCHEDULE,
@@ -25,8 +26,8 @@ import {
25
26
  JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
26
27
  JUNIOR_RETENTION_CRON_SCHEDULE,
27
28
  JUNIOR_RETENTION_ROUTE
28
- } from "./chunk-QWCF4RAC.js";
29
- import "./chunk-HWUBBHLK.js";
29
+ } from "./chunk-DWOH57FW.js";
30
+ import "./chunk-DMKHRBI6.js";
30
31
  import "./chunk-MLKGABMK.js";
31
32
 
32
33
  // src/nitro.ts
@@ -55,9 +56,25 @@ function globToRegex(pattern) {
55
56
 
56
57
  // src/build/copy-build-content.ts
57
58
  var DASHBOARD_PACKAGE_NAME = "@sentry/junior-dashboard";
59
+ var JUNIOR_PACKAGE_NAME = "@sentry/junior";
58
60
  var DASHBOARD_ASSET_NAMES = ["client.js", "tailwind.css"];
59
- function copyAppAndPluginContent(cwd, serverRoot, packageNames) {
61
+ function copyRuntimeContent(cwd, serverRoot, packageNames) {
60
62
  copyIfExists(path.join(cwd, "app"), path.join(serverRoot, "app"));
63
+ const juniorPackageDir = resolvePackageDir(cwd, JUNIOR_PACKAGE_NAME);
64
+ if (!juniorPackageDir) {
65
+ throw new Error(
66
+ `Cannot resolve ${JUNIOR_PACKAGE_NAME} while copying runtime content`
67
+ );
68
+ }
69
+ const builtInSkillsDir = path.join(juniorPackageDir, "skills");
70
+ if (!copyIfExists(
71
+ builtInSkillsDir,
72
+ path.join(serverRoot, "node_modules", JUNIOR_PACKAGE_NAME, "skills")
73
+ )) {
74
+ throw new Error(
75
+ `${JUNIOR_PACKAGE_NAME} is missing its built-in skills directory`
76
+ );
77
+ }
61
78
  const packagedContent = discoverInstalledPluginPackageContent(cwd, {
62
79
  packageNames
63
80
  });
@@ -428,7 +445,7 @@ function juniorNitro(options = {}) {
428
445
  const copyBuildContent = async () => {
429
446
  const pluginSet = await loadConfiguredPluginSet();
430
447
  const compiledPluginCatalogConfig = pluginCatalogConfigFromPluginSet(pluginSet);
431
- copyAppAndPluginContent(
448
+ copyRuntimeContent(
432
449
  cwd,
433
450
  nitro.options.output.serverDir,
434
451
  compiledPluginCatalogConfig?.packages
@@ -2,38 +2,38 @@ import {
2
2
  GET,
3
3
  GET2,
4
4
  syncLocalOAuthCredential
5
- } from "./chunk-3MUSSFMP.js";
5
+ } from "./chunk-QOQPPRFS.js";
6
6
  import "./chunk-FA6POGLH.js";
7
- import "./chunk-6BGUAOYP.js";
7
+ import "./chunk-BHXW734F.js";
8
8
  import "./chunk-4CODA7P5.js";
9
9
  import "./chunk-6ZK6FZIV.js";
10
10
  import "./chunk-5I6ORJUY.js";
11
11
  import {
12
12
  createUserTokenStore
13
- } from "./chunk-S6R23MFB.js";
14
- import "./chunk-PJPKHGLG.js";
13
+ } from "./chunk-TKUCRFNX.js";
14
+ import "./chunk-JQWP6V22.js";
15
15
  import "./chunk-MU6HHZEN.js";
16
16
  import "./chunk-PDO5BLNM.js";
17
- import "./chunk-GT2ZUALJ.js";
18
- import "./chunk-KC5EE27Y.js";
17
+ import "./chunk-24B5R6OU.js";
18
+ import "./chunk-M243JMZH.js";
19
19
  import "./chunk-GCGJGSQL.js";
20
- import "./chunk-3N3FMCKN.js";
21
- import "./chunk-PWRFTDTY.js";
20
+ import "./chunk-ALAKN7LR.js";
21
+ import "./chunk-VURFJVFH.js";
22
22
  import "./chunk-VFUK3X5B.js";
23
- import "./chunk-FXOYURO4.js";
24
- import "./chunk-7GADTCNS.js";
25
- import "./chunk-UXLYAVYL.js";
26
- import "./chunk-3LGCVRBQ.js";
23
+ import "./chunk-HDFGNU5E.js";
24
+ import "./chunk-EIVE6GL4.js";
25
+ import "./chunk-GNNV3UTY.js";
26
+ import "./chunk-XAI2HNAY.js";
27
27
  import "./chunk-W3U3YQYI.js";
28
28
  import "./chunk-HZF5P5UN.js";
29
- import "./chunk-MLZFK4KP.js";
29
+ import "./chunk-ALYQOZG7.js";
30
30
  import "./chunk-OB42YVAE.js";
31
31
  import "./chunk-F3B2YJ76.js";
32
32
  import "./chunk-6GWA276C.js";
33
- import "./chunk-B3IT5END.js";
34
- import "./chunk-3V7OFJZC.js";
35
- import "./chunk-QWCF4RAC.js";
36
- import "./chunk-HWUBBHLK.js";
33
+ import "./chunk-OOUNJNMR.js";
34
+ import "./chunk-H4HBKISO.js";
35
+ import "./chunk-DWOH57FW.js";
36
+ import "./chunk-DMKHRBI6.js";
37
37
  import "./chunk-MLKGABMK.js";
38
38
 
39
39
  // src/chat/local/oauth-callback-server.ts
@@ -5,7 +5,7 @@ import {
5
5
  finalizeFailedTurnReplyWithEvent,
6
6
  processPluginTask,
7
7
  scheduleSessionCompletedPluginTasks
8
- } from "./chunk-6BGUAOYP.js";
8
+ } from "./chunk-BHXW734F.js";
9
9
  import "./chunk-5I6ORJUY.js";
10
10
  import {
11
11
  authorizationId
@@ -32,27 +32,27 @@ import {
32
32
  trimTrailingAssistantMessages,
33
33
  updateConversationStats,
34
34
  upsertConversationMessage
35
- } from "./chunk-PJPKHGLG.js";
35
+ } from "./chunk-JQWP6V22.js";
36
36
  import "./chunk-MU6HHZEN.js";
37
37
  import "./chunk-PDO5BLNM.js";
38
- import "./chunk-GT2ZUALJ.js";
38
+ import "./chunk-24B5R6OU.js";
39
39
  import {
40
40
  getConversationEventStore
41
- } from "./chunk-KC5EE27Y.js";
41
+ } from "./chunk-M243JMZH.js";
42
42
  import "./chunk-GCGJGSQL.js";
43
- import "./chunk-3N3FMCKN.js";
44
- import "./chunk-PWRFTDTY.js";
43
+ import "./chunk-ALAKN7LR.js";
44
+ import "./chunk-VURFJVFH.js";
45
45
  import "./chunk-VFUK3X5B.js";
46
- import "./chunk-FXOYURO4.js";
46
+ import "./chunk-HDFGNU5E.js";
47
47
  import "./chunk-HZF5P5UN.js";
48
48
  import {
49
49
  logException
50
- } from "./chunk-MLZFK4KP.js";
50
+ } from "./chunk-ALYQOZG7.js";
51
51
  import "./chunk-OB42YVAE.js";
52
52
  import "./chunk-F3B2YJ76.js";
53
53
  import "./chunk-6GWA276C.js";
54
- import "./chunk-QWCF4RAC.js";
55
- import "./chunk-HWUBBHLK.js";
54
+ import "./chunk-DWOH57FW.js";
55
+ import "./chunk-DMKHRBI6.js";
56
56
  import "./chunk-MLKGABMK.js";
57
57
 
58
58
  // src/chat/local/runner.ts
@@ -6,19 +6,19 @@ import {
6
6
  parseSkillInvocation,
7
7
  resetSkillDiscoveryCache,
8
8
  stripFrontmatter
9
- } from "./chunk-7GADTCNS.js";
10
- import "./chunk-UXLYAVYL.js";
11
- import "./chunk-3LGCVRBQ.js";
9
+ } from "./chunk-EIVE6GL4.js";
10
+ import "./chunk-GNNV3UTY.js";
11
+ import "./chunk-XAI2HNAY.js";
12
12
  import "./chunk-W3U3YQYI.js";
13
13
  import "./chunk-HZF5P5UN.js";
14
- import "./chunk-MLZFK4KP.js";
14
+ import "./chunk-ALYQOZG7.js";
15
15
  import "./chunk-OB42YVAE.js";
16
16
  import "./chunk-F3B2YJ76.js";
17
17
  import "./chunk-6GWA276C.js";
18
- import "./chunk-B3IT5END.js";
19
- import "./chunk-3V7OFJZC.js";
20
- import "./chunk-QWCF4RAC.js";
21
- import "./chunk-HWUBBHLK.js";
18
+ import "./chunk-OOUNJNMR.js";
19
+ import "./chunk-H4HBKISO.js";
20
+ import "./chunk-DWOH57FW.js";
21
+ import "./chunk-DMKHRBI6.js";
22
22
  import "./chunk-MLKGABMK.js";
23
23
  export {
24
24
  discoverSkills,
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  validatePluginEgressCredentialHooks,
3
3
  validatePluginRegistrations
4
- } from "./chunk-4SOQPUF4.js";
5
- import "./chunk-UXLYAVYL.js";
6
- import "./chunk-3LGCVRBQ.js";
4
+ } from "./chunk-YEAOUT5W.js";
5
+ import "./chunk-GNNV3UTY.js";
6
+ import "./chunk-XAI2HNAY.js";
7
7
  import "./chunk-W3U3YQYI.js";
8
8
  import "./chunk-HZF5P5UN.js";
9
- import "./chunk-MLZFK4KP.js";
9
+ import "./chunk-ALYQOZG7.js";
10
10
  import "./chunk-OB42YVAE.js";
11
11
  import "./chunk-F3B2YJ76.js";
12
12
  import "./chunk-6GWA276C.js";
13
- import "./chunk-B3IT5END.js";
14
- import "./chunk-3V7OFJZC.js";
15
- import "./chunk-QWCF4RAC.js";
16
- import "./chunk-HWUBBHLK.js";
13
+ import "./chunk-OOUNJNMR.js";
14
+ import "./chunk-H4HBKISO.js";
15
+ import "./chunk-DWOH57FW.js";
16
+ import "./chunk-DMKHRBI6.js";
17
17
  import "./chunk-MLKGABMK.js";
18
18
  export {
19
19
  validatePluginEgressCredentialHooks,
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-HWUBBHLK.js";
3
+ } from "./chunk-DMKHRBI6.js";
4
4
  import "./chunk-MLKGABMK.js";
5
5
  export {
6
6
  JUNIOR_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.118.0",
3
+ "version": "0.120.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -48,7 +48,8 @@
48
48
  "files": [
49
49
  "dist",
50
50
  "bin",
51
- "migrations"
51
+ "migrations",
52
+ "skills"
52
53
  ],
53
54
  "dependencies": {
54
55
  "@ai-sdk/gateway": "^3.0.119",
@@ -78,7 +79,7 @@
78
79
  "pg": "^8.16.3",
79
80
  "yaml": "^2.9.0",
80
81
  "zod": "^4.4.3",
81
- "@sentry/junior-plugin-api": "0.118.0"
82
+ "@sentry/junior-plugin-api": "0.120.0"
82
83
  },
83
84
  "devDependencies": {
84
85
  "@emnapi/core": "^1.10.0",
@@ -95,9 +96,9 @@
95
96
  "typescript": "^6.0.3",
96
97
  "vercel": "^54.4.0",
97
98
  "vitest": "^4.1.7",
98
- "@sentry/junior-github": "0.118.0",
99
- "@sentry/junior-scheduler": "0.118.0",
100
- "@sentry/junior-memory": "0.118.0",
99
+ "@sentry/junior-github": "0.120.0",
100
+ "@sentry/junior-scheduler": "0.120.0",
101
+ "@sentry/junior-memory": "0.120.0",
101
102
  "@sentry/junior-testing": "0.0.0"
102
103
  },
103
104
  "scripts": {
@@ -108,7 +109,7 @@
108
109
  "test": "vitest run --maxWorkers=4",
109
110
  "test:watch": "vitest",
110
111
  "typecheck": "tsc --noEmit",
111
- "skills:check": "node scripts/check-skills.mjs",
112
+ "skills:check": "node --test scripts/check-skills.test.mjs && node scripts/check-skills.mjs",
112
113
  "test:coverage": "vitest run --maxWorkers=4 --coverage --reporter=default --reporter=junit --outputFile.junit=coverage/results.junit.xml"
113
114
  }
114
115
  }
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: jr-rpc
3
+ description: Manage low-level config and plugin introspection flows via jr-rpc bash commands. Use only when the user explicitly asks to read or update provider defaults/config or list installed plugins. Do not use for PR, branch, push, or auth-order questions; load the matching provider skill instead.
4
+ allowed-tools: bash
5
+ ---
6
+
7
+ # jr-rpc
8
+
9
+ Manage low-level config and plugin introspection flows for the current agent turn.
10
+
11
+ ## Plugins
12
+
13
+ `jr-rpc plugins list` — list installed plugins visible to the current Junior runtime.
14
+
15
+ Command syntax:
16
+
17
+ - `jr-rpc plugins list`
18
+
19
+ ## Configuration
20
+
21
+ `jr-rpc config get|set|unset|list` — read and write channel-scoped configuration values.
22
+
23
+ Command syntax:
24
+
25
+ - `jr-rpc config get <key>`
26
+ - `jr-rpc config set <key> <value> [--json]`
27
+ - `jr-rpc config unset <key>`
28
+ - `jr-rpc config list [--prefix <value>]`
29
+
30
+ Rules:
31
+
32
+ - Choose config keys from the runtime `<providers>` catalog: `<provider>.<config_key>`.
33
+ - For "default repo" requests, use the provider target key, for example `github.repo`.
34
+ - Run the exact standalone command. Do not probe, install, or repair `jr-rpc`; the runtime handles it only when invoked directly.
35
+
36
+ ## Guardrails
37
+
38
+ - Use exact config keys from the loaded skill or provider catalog; do not invent them.
39
+ - Do not use this skill to choose a provider for an unrelated operational task. Load the matching domain skill first, then run the real provider command.
40
+ - Do not print credential values.
@@ -1,264 +0,0 @@
1
- // src/chat/discovery.ts
2
- import fs, { statSync } from "fs";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- function isDirectory(targetPath) {
6
- try {
7
- return statSync(targetPath).isDirectory();
8
- } catch {
9
- return false;
10
- }
11
- }
12
- function isFile(targetPath) {
13
- try {
14
- return statSync(targetPath).isFile();
15
- } catch {
16
- return false;
17
- }
18
- }
19
- function normalizePath(targetPath) {
20
- return path.resolve(targetPath);
21
- }
22
- function uniqueResolvedPathsInOrder(values) {
23
- const seen = /* @__PURE__ */ new Set();
24
- const resolved = [];
25
- for (const value of values) {
26
- const normalized = normalizePath(value);
27
- if (seen.has(normalized)) {
28
- continue;
29
- }
30
- seen.add(normalized);
31
- resolved.push(normalized);
32
- }
33
- return resolved;
34
- }
35
- function isNodeModulesPath(candidatePath) {
36
- return path.basename(candidatePath) === "node_modules";
37
- }
38
- function isInsidePnpmStore(candidatePath) {
39
- return candidatePath.split(path.sep).includes(".pnpm");
40
- }
41
- function runningFromInstalledPackage() {
42
- const currentFile = fileURLToPath(import.meta.url);
43
- const marker = `${path.sep}node_modules${path.sep}@sentry${path.sep}junior${path.sep}`;
44
- return currentFile.includes(marker);
45
- }
46
- function listInstalledPackageNodeModulesDirs() {
47
- if (!runningFromInstalledPackage()) {
48
- return [];
49
- }
50
- const dirs = [];
51
- let current = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
52
- while (true) {
53
- if (isNodeModulesPath(current) && !isInsidePnpmStore(current) && isDirectory(current)) {
54
- dirs.push(current);
55
- }
56
- const parent = path.dirname(current);
57
- if (parent === current) {
58
- break;
59
- }
60
- current = parent;
61
- }
62
- return dirs;
63
- }
64
- function listCwdAncestorNodeModulesDirs(cwd) {
65
- const resolvedCwd = normalizePath(cwd);
66
- const dirs = [];
67
- let current = resolvedCwd;
68
- while (true) {
69
- const nodeModulesDir = path.join(current, "node_modules");
70
- if (isDirectory(nodeModulesDir)) {
71
- dirs.push(nodeModulesDir);
72
- }
73
- if (isFile(path.join(current, "package.json"))) {
74
- break;
75
- }
76
- const parent = path.dirname(current);
77
- if (parent === current) {
78
- break;
79
- }
80
- current = parent;
81
- }
82
- return dirs;
83
- }
84
- function discoverNodeModulesDirs(cwd = process.cwd(), options) {
85
- const explicit = options?.candidateDirs?.filter((dir) => isDirectory(dir)) ?? [];
86
- if (explicit.length > 0) {
87
- return uniqueResolvedPathsInOrder(explicit);
88
- }
89
- return uniqueResolvedPathsInOrder([
90
- ...listInstalledPackageNodeModulesDirs(),
91
- ...listCwdAncestorNodeModulesDirs(cwd)
92
- ]);
93
- }
94
- function discoverProjectRoots(cwd = process.cwd(), options) {
95
- const roots = discoverNodeModulesDirs(
96
- cwd,
97
- options?.nodeModulesDirs ? { candidateDirs: options.nodeModulesDirs } : void 0
98
- ).map((nodeModulesDir) => path.dirname(nodeModulesDir));
99
- return uniqueResolvedPathsInOrder([cwd, ...roots]);
100
- }
101
- function unique(values) {
102
- return [...new Set(values)];
103
- }
104
- function pathExists(targetPath) {
105
- try {
106
- fs.accessSync(targetPath);
107
- return true;
108
- } catch {
109
- return false;
110
- }
111
- }
112
- function hasAnyDataMarkers(appDir) {
113
- return pathExists(path.join(appDir, "SOUL.md")) || pathExists(path.join(appDir, "WORLD.md"));
114
- }
115
- function scoreAppCandidate(appDir) {
116
- let score = 0;
117
- if (pathExists(path.join(appDir, "SOUL.md"))) {
118
- score += 4;
119
- }
120
- if (pathExists(path.join(appDir, "WORLD.md"))) {
121
- score += 2;
122
- }
123
- if (pathExists(path.join(appDir, "skills"))) {
124
- score += 1;
125
- }
126
- if (pathExists(path.join(appDir, "plugins"))) {
127
- score += 1;
128
- }
129
- return score;
130
- }
131
- function resolveCandidateAppDirs(cwd, projectRoots) {
132
- const roots = projectRoots ?? discoverProjectRoots(cwd);
133
- const resolved = [];
134
- const seen = /* @__PURE__ */ new Set();
135
- for (const root of roots) {
136
- const appDir = path.resolve(root, "app");
137
- if (!pathExists(appDir)) {
138
- continue;
139
- }
140
- if (seen.has(appDir)) {
141
- continue;
142
- }
143
- seen.add(appDir);
144
- resolved.push(appDir);
145
- }
146
- return resolved;
147
- }
148
- function homeDir() {
149
- return resolveHomeDir();
150
- }
151
- function resolveHomeDir(cwd = process.cwd(), options) {
152
- const resolvedCwd = path.resolve(cwd);
153
- const directApp = path.resolve(resolvedCwd, "app");
154
- if (pathExists(directApp) && hasAnyDataMarkers(directApp)) {
155
- return directApp;
156
- }
157
- const candidates = resolveCandidateAppDirs(
158
- resolvedCwd,
159
- options?.projectRoots
160
- );
161
- if (candidates.length === 0) {
162
- return directApp;
163
- }
164
- candidates.sort((left, right) => {
165
- const leftScore = scoreAppCandidate(left);
166
- const rightScore = scoreAppCandidate(right);
167
- if (leftScore !== rightScore) {
168
- return rightScore - leftScore;
169
- }
170
- const leftDistance = path.relative(resolvedCwd, left).split(path.sep).length;
171
- const rightDistance = path.relative(resolvedCwd, right).split(path.sep).length;
172
- if (leftDistance !== rightDistance) {
173
- return leftDistance - rightDistance;
174
- }
175
- return left.localeCompare(right);
176
- });
177
- return candidates[0];
178
- }
179
- function resolveContentRoots(subdir) {
180
- if (subdir === "data") {
181
- return [homeDir()];
182
- }
183
- return [path.join(homeDir(), subdir)];
184
- }
185
- function dataDir() {
186
- return resolveContentRoots("data")[0];
187
- }
188
- function soulPath() {
189
- return path.join(dataDir(), "SOUL.md");
190
- }
191
- function worldPath() {
192
- return path.join(dataDir(), "WORLD.md");
193
- }
194
- function descriptionPath() {
195
- return path.join(dataDir(), "DESCRIPTION.md");
196
- }
197
- function skillsDir() {
198
- return resolveContentRoots("skills")[0];
199
- }
200
- function pluginsDir() {
201
- return resolveContentRoots("plugins")[0];
202
- }
203
- function dataRoots() {
204
- return unique(resolveContentRoots("data"));
205
- }
206
- function skillRoots() {
207
- return unique(resolveContentRoots("skills"));
208
- }
209
- function pluginRoots() {
210
- return unique(resolveContentRoots("plugins"));
211
- }
212
- function soulPathCandidates() {
213
- const candidates = dataRoots().map((root) => path.join(root, "SOUL.md"));
214
- return unique(candidates);
215
- }
216
- function worldPathCandidates() {
217
- const candidates = dataRoots().map((root) => path.join(root, "WORLD.md"));
218
- return unique(candidates);
219
- }
220
- function descriptionPathCandidates() {
221
- const candidates = dataRoots().map(
222
- (root) => path.join(root, "DESCRIPTION.md")
223
- );
224
- return unique(candidates);
225
- }
226
- var RESERVED_APP_FILES = /* @__PURE__ */ new Set([
227
- "SOUL.md",
228
- "WORLD.md",
229
- "DESCRIPTION.md",
230
- "ABOUT.md"
231
- ]);
232
- function listReferenceFiles() {
233
- const appDir = homeDir();
234
- try {
235
- const entries = fs.readdirSync(appDir, { withFileTypes: true });
236
- return entries.filter(
237
- (entry) => entry.isFile() && entry.name.endsWith(".md") && !RESERVED_APP_FILES.has(entry.name)
238
- ).map((entry) => path.join(appDir, entry.name)).sort();
239
- } catch {
240
- return [];
241
- }
242
- }
243
-
244
- export {
245
- isDirectory,
246
- isFile,
247
- discoverNodeModulesDirs,
248
- discoverProjectRoots,
249
- homeDir,
250
- resolveHomeDir,
251
- dataDir,
252
- soulPath,
253
- worldPath,
254
- descriptionPath,
255
- skillsDir,
256
- pluginsDir,
257
- dataRoots,
258
- skillRoots,
259
- pluginRoots,
260
- soulPathCandidates,
261
- worldPathCandidates,
262
- descriptionPathCandidates,
263
- listReferenceFiles
264
- };