@evanovation/open-cursor 2.4.15

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 (80) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +270 -0
  3. package/dist/cli/discover.js +527 -0
  4. package/dist/cli/mcptool.js +10339 -0
  5. package/dist/cli/opencode-cursor.js +2989 -0
  6. package/dist/index.js +20588 -0
  7. package/dist/plugin-entry.js +19848 -0
  8. package/package.json +82 -0
  9. package/scripts/cursor-agent-runner.mjs +272 -0
  10. package/scripts/sdk-runner.mjs +412 -0
  11. package/src/acp/metrics.ts +83 -0
  12. package/src/acp/sessions.ts +107 -0
  13. package/src/acp/tools.ts +209 -0
  14. package/src/auth.ts +175 -0
  15. package/src/cli/discover.ts +53 -0
  16. package/src/cli/mcptool.ts +133 -0
  17. package/src/cli/model-discovery.ts +71 -0
  18. package/src/cli/opencode-cursor.ts +1195 -0
  19. package/src/client/cursor-agent-child.ts +459 -0
  20. package/src/client/sdk-child.ts +550 -0
  21. package/src/client/simple.ts +293 -0
  22. package/src/commands/status.ts +39 -0
  23. package/src/index.ts +39 -0
  24. package/src/mcp/client-manager.ts +166 -0
  25. package/src/mcp/config.ts +169 -0
  26. package/src/mcp/tool-bridge.ts +133 -0
  27. package/src/models/config.ts +64 -0
  28. package/src/models/discovery.ts +105 -0
  29. package/src/models/index.ts +3 -0
  30. package/src/models/pricing.ts +196 -0
  31. package/src/models/sync.ts +247 -0
  32. package/src/models/types.ts +11 -0
  33. package/src/models/variants.ts +446 -0
  34. package/src/plugin-entry.ts +28 -0
  35. package/src/plugin-toggle.ts +81 -0
  36. package/src/plugin.ts +2802 -0
  37. package/src/provider/backend.ts +71 -0
  38. package/src/provider/boundary.ts +168 -0
  39. package/src/provider/passthrough-tracker.ts +38 -0
  40. package/src/provider/runtime-interception.ts +818 -0
  41. package/src/provider/tool-loop-guard.ts +644 -0
  42. package/src/provider/tool-schema-compat.ts +800 -0
  43. package/src/provider.ts +268 -0
  44. package/src/proxy/formatter.ts +60 -0
  45. package/src/proxy/handler.ts +29 -0
  46. package/src/proxy/incremental-prompt.ts +74 -0
  47. package/src/proxy/prompt-builder.ts +204 -0
  48. package/src/proxy/server.ts +207 -0
  49. package/src/proxy/session-resume.ts +312 -0
  50. package/src/proxy/tool-loop.ts +359 -0
  51. package/src/proxy/types.ts +13 -0
  52. package/src/services/toast-service.ts +81 -0
  53. package/src/streaming/ai-sdk-parts.ts +109 -0
  54. package/src/streaming/delta-tracker.ts +89 -0
  55. package/src/streaming/line-buffer.ts +44 -0
  56. package/src/streaming/openai-sse.ts +118 -0
  57. package/src/streaming/parser.ts +22 -0
  58. package/src/streaming/types.ts +158 -0
  59. package/src/tools/core/executor.ts +25 -0
  60. package/src/tools/core/registry.ts +27 -0
  61. package/src/tools/core/types.ts +31 -0
  62. package/src/tools/defaults.ts +954 -0
  63. package/src/tools/discovery.ts +140 -0
  64. package/src/tools/executors/cli.ts +59 -0
  65. package/src/tools/executors/local.ts +25 -0
  66. package/src/tools/executors/mcp.ts +39 -0
  67. package/src/tools/executors/sdk.ts +39 -0
  68. package/src/tools/index.ts +8 -0
  69. package/src/tools/registry.ts +34 -0
  70. package/src/tools/router.ts +123 -0
  71. package/src/tools/schema.ts +58 -0
  72. package/src/tools/skills/loader.ts +61 -0
  73. package/src/tools/skills/resolver.ts +21 -0
  74. package/src/tools/types.ts +29 -0
  75. package/src/types.ts +8 -0
  76. package/src/usage.ts +112 -0
  77. package/src/utils/binary.ts +71 -0
  78. package/src/utils/errors.ts +224 -0
  79. package/src/utils/logger.ts +191 -0
  80. package/src/utils/perf.ts +76 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * OpenCode-only entrypoint.
3
+ *
4
+ * When cursor-acp is removed from the `plugin` array in opencode.json,
5
+ * this entrypoint turns into a no-op so users can disable the plugin
6
+ * without deleting the symlink file.
7
+ */
8
+ import type { Plugin } from "@opencode-ai/plugin";
9
+ import { shouldEnableCursorPlugin } from "./plugin-toggle.js";
10
+ import { createLogger } from "./utils/logger.js";
11
+
12
+ const log = createLogger("plugin-entry");
13
+
14
+ const CursorPluginEntry: Plugin = async (input) => {
15
+ const state = shouldEnableCursorPlugin();
16
+ if (!state.enabled) {
17
+ log.info("Plugin disabled in OpenCode config; skipping initialization", {
18
+ configPath: state.configPath,
19
+ reason: state.reason,
20
+ });
21
+ return {};
22
+ }
23
+
24
+ const mod = await import("./plugin.js");
25
+ return mod.CursorPlugin(input);
26
+ };
27
+
28
+ export default CursorPluginEntry;
@@ -0,0 +1,81 @@
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { homedir } from "os";
3
+ import { join, resolve } from "path";
4
+
5
+ const CURSOR_PROVIDER_ID = "cursor-acp";
6
+ const NPM_PACKAGE_NAME = "@evanovation/open-cursor";
7
+
8
+ function matchesPlugin(entry: string): boolean {
9
+ if (entry === CURSOR_PROVIDER_ID) return true;
10
+ if (entry === NPM_PACKAGE_NAME) return true;
11
+ if (entry.startsWith(`${NPM_PACKAGE_NAME}@`)) return true;
12
+ return false;
13
+ }
14
+
15
+ type EnvLike = Record<string, string | undefined>;
16
+
17
+ export function resolveOpenCodeConfigPath(env: EnvLike = process.env): string {
18
+ if (env.OPENCODE_CONFIG && env.OPENCODE_CONFIG.length > 0) {
19
+ return resolve(env.OPENCODE_CONFIG);
20
+ }
21
+
22
+ const configHome = env.XDG_CONFIG_HOME && env.XDG_CONFIG_HOME.length > 0
23
+ ? env.XDG_CONFIG_HOME
24
+ : join(homedir(), ".config");
25
+
26
+ return join(configHome, "opencode", "opencode.json");
27
+ }
28
+
29
+ export function isCursorPluginEnabledInConfig(config: unknown): boolean {
30
+ if (!config || typeof config !== "object") {
31
+ return true;
32
+ }
33
+
34
+ const configObject = config as { plugin?: unknown; provider?: unknown };
35
+
36
+ if (configObject.provider && typeof configObject.provider === "object") {
37
+ if (CURSOR_PROVIDER_ID in (configObject.provider as Record<string, unknown>)) {
38
+ return true;
39
+ }
40
+ }
41
+
42
+ if (Array.isArray(configObject.plugin)) {
43
+ return configObject.plugin.some((entry) => matchesPlugin(entry));
44
+ }
45
+
46
+ return true;
47
+ }
48
+
49
+ export function shouldEnableCursorPlugin(env: EnvLike = process.env): {
50
+ enabled: boolean;
51
+ configPath: string;
52
+ reason: string;
53
+ } {
54
+ const configPath = resolveOpenCodeConfigPath(env);
55
+
56
+ if (!existsSync(configPath)) {
57
+ return {
58
+ enabled: true,
59
+ configPath,
60
+ reason: "config_missing",
61
+ };
62
+ }
63
+
64
+ try {
65
+ const raw = readFileSync(configPath, "utf8");
66
+ const parsed = JSON.parse(raw);
67
+ const enabled = isCursorPluginEnabledInConfig(parsed);
68
+
69
+ return {
70
+ enabled,
71
+ configPath,
72
+ reason: enabled ? "enabled" : "disabled_in_plugin_array",
73
+ };
74
+ } catch {
75
+ return {
76
+ enabled: true,
77
+ configPath,
78
+ reason: "config_unreadable_or_invalid",
79
+ };
80
+ }
81
+ }