@opencoven/coven-code 0.0.1

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 (86) hide show
  1. package/README.md +145 -0
  2. package/bin/coven-code-sdk.mjs +12 -0
  3. package/bin/coven-code.mjs +19 -0
  4. package/docs/CLI.md +192 -0
  5. package/docs/CONFIGURATION.md +107 -0
  6. package/docs/DEVELOPMENT.md +104 -0
  7. package/docs/DOGFOOD-PROTOCOL.md +263 -0
  8. package/docs/MCP-SKILLS-PLUGINS.md +127 -0
  9. package/docs/README.md +38 -0
  10. package/docs/RELEASE.md +33 -0
  11. package/docs/SDK.md +107 -0
  12. package/docs/superpowers/plans/2026-05-25-coven-code-panel-tui.md +904 -0
  13. package/docs/superpowers/plans/2026-05-25-coven-code-rebrand.md +670 -0
  14. package/docs/superpowers/specs/2026-05-25-coven-code-panel-tui-design.md +235 -0
  15. package/docs/superpowers/specs/2026-05-26-slash-first-tui-review.md +63 -0
  16. package/package.json +36 -0
  17. package/src/agent/lane.mjs +136 -0
  18. package/src/agent/local.mjs +95 -0
  19. package/src/cli/dispatch.mjs +66 -0
  20. package/src/cli/execute.mjs +588 -0
  21. package/src/cli/help.mjs +58 -0
  22. package/src/cli/interactive-core.mjs +302 -0
  23. package/src/cli/notifications.mjs +13 -0
  24. package/src/cli/parse.mjs +83 -0
  25. package/src/cli/reasoning.mjs +45 -0
  26. package/src/cli/refs.mjs +162 -0
  27. package/src/cli/repl.mjs +61 -0
  28. package/src/cli/slash-commands.mjs +357 -0
  29. package/src/cli/stream-json.mjs +116 -0
  30. package/src/cli/tui.mjs +757 -0
  31. package/src/commands/agents.mjs +53 -0
  32. package/src/commands/config.mjs +27 -0
  33. package/src/commands/ide.mjs +17 -0
  34. package/src/commands/login.mjs +84 -0
  35. package/src/commands/mcp.mjs +176 -0
  36. package/src/commands/permissions.mjs +328 -0
  37. package/src/commands/plugins.mjs +86 -0
  38. package/src/commands/review.mjs +74 -0
  39. package/src/commands/skill.mjs +23 -0
  40. package/src/commands/threads.mjs +165 -0
  41. package/src/commands/tools.mjs +77 -0
  42. package/src/commands/update.mjs +31 -0
  43. package/src/commands/usage.mjs +34 -0
  44. package/src/constants.mjs +46 -0
  45. package/src/main.mjs +87 -0
  46. package/src/mcp/discover.mjs +154 -0
  47. package/src/mcp/permissions.mjs +52 -0
  48. package/src/mcp/probe.mjs +424 -0
  49. package/src/mcp/registry.mjs +96 -0
  50. package/src/plugins/discover.mjs +880 -0
  51. package/src/sdk-install.mjs +187 -0
  52. package/src/sdk.mjs +314 -0
  53. package/src/settings/load.mjs +134 -0
  54. package/src/settings/paths.mjs +101 -0
  55. package/src/skills/builtin/building-skills/SKILL.md +20 -0
  56. package/src/skills/discover.mjs +95 -0
  57. package/src/threads/store.mjs +176 -0
  58. package/src/tools/builtin/bash.mjs +110 -0
  59. package/src/tools/builtin/create-file.mjs +66 -0
  60. package/src/tools/builtin/edit-file.mjs +76 -0
  61. package/src/tools/builtin/finder.mjs +73 -0
  62. package/src/tools/builtin/glob.mjs +74 -0
  63. package/src/tools/builtin/grep.mjs +82 -0
  64. package/src/tools/builtin/index.mjs +83 -0
  65. package/src/tools/builtin/librarian.mjs +97 -0
  66. package/src/tools/builtin/look-at.mjs +92 -0
  67. package/src/tools/builtin/mcp.mjs +51 -0
  68. package/src/tools/builtin/mermaid.mjs +59 -0
  69. package/src/tools/builtin/oracle.mjs +56 -0
  70. package/src/tools/builtin/painter.mjs +81 -0
  71. package/src/tools/builtin/plugin-tool.mjs +53 -0
  72. package/src/tools/builtin/read-mcp-resource.mjs +63 -0
  73. package/src/tools/builtin/read-web-page.mjs +72 -0
  74. package/src/tools/builtin/read.mjs +59 -0
  75. package/src/tools/builtin/runtime.mjs +215 -0
  76. package/src/tools/builtin/task.mjs +63 -0
  77. package/src/tools/builtin/toolbox-tool.mjs +57 -0
  78. package/src/tools/builtin/undo-edit.mjs +97 -0
  79. package/src/tools/builtin/web-search.mjs +128 -0
  80. package/src/tools/toolbox.mjs +273 -0
  81. package/src/util/fs.mjs +13 -0
  82. package/src/util/glob.mjs +46 -0
  83. package/src/util/html.mjs +21 -0
  84. package/src/util/media.mjs +13 -0
  85. package/src/util/shell.mjs +24 -0
  86. package/src/util/table.mjs +11 -0
@@ -0,0 +1,96 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const MCP_REGISTRY_SETTING = 'covenCode.mcpRegistry';
6
+ const MCP_REGISTRY_URL_SETTING = 'covenCode.mcpRegistry.url';
7
+
8
+ export function mcpRegistryGate(userSettings = {}, workspaceSettings = {}, managedSettings = {}) {
9
+ const policy = registryPolicy(managedSettings) ?? registryPolicy(workspaceSettings) ?? registryPolicy(userSettings);
10
+ if (!policy?.url) return { enabled: false };
11
+ const payload = registryPayload(policy.url);
12
+ if (!payload) return { enabled: true, reachable: false, allowedNames: new Set(), allowedUrls: new Set() };
13
+ try {
14
+ return { enabled: true, reachable: true, ...registryAllowlist(JSON.parse(payload)) };
15
+ } catch {
16
+ return { enabled: true, reachable: false, allowedNames: new Set(), allowedUrls: new Set() };
17
+ }
18
+ }
19
+
20
+ export function mcpRegistryStatus(config = {}, gate = { enabled: false }) {
21
+ if (!gate.enabled) return undefined;
22
+ if (!gate.reachable) return 'registry-blocked';
23
+ return registryAllowsConfig(config, gate) ? undefined : 'registry-blocked';
24
+ }
25
+
26
+ function registryPolicy(settings = {}) {
27
+ const value = settings[MCP_REGISTRY_SETTING];
28
+ if (typeof value === 'string' && value.trim()) return { url: value.trim() };
29
+ if (value && typeof value === 'object' && typeof value.url === 'string' && value.url.trim()) {
30
+ return { url: value.url.trim() };
31
+ }
32
+ const url = settings[MCP_REGISTRY_URL_SETTING];
33
+ if (typeof url === 'string' && url.trim()) return { url: url.trim() };
34
+ return undefined;
35
+ }
36
+
37
+ function registryPayload(url) {
38
+ try {
39
+ if (/^https?:\/\//i.test(url)) return fetchRegistryUrlSync(url);
40
+ if (url.startsWith('file://')) return readFileSync(fileURLToPath(url), 'utf8');
41
+ return readFileSync(url, 'utf8');
42
+ } catch {
43
+ return undefined;
44
+ }
45
+ }
46
+
47
+ function fetchRegistryUrlSync(url) {
48
+ const script = `
49
+ const url = process.env.COVEN_CODE_MCP_REGISTRY_URL;
50
+ const timeout = AbortSignal.timeout(1500);
51
+ try {
52
+ const response = await fetch(url, { signal: timeout });
53
+ if (!response.ok) process.exit(2);
54
+ process.stdout.write(await response.text());
55
+ } catch {
56
+ process.exit(1);
57
+ }
58
+ `;
59
+ const result = spawnSync(process.execPath, ['--input-type=module', '-e', script], {
60
+ env: { ...process.env, COVEN_CODE_MCP_REGISTRY_URL: url },
61
+ encoding: 'utf8',
62
+ timeout: 2500,
63
+ });
64
+ return result.status === 0 ? result.stdout : undefined;
65
+ }
66
+
67
+ function registryAllowlist(payload) {
68
+ const allowedNames = new Set();
69
+ const allowedUrls = new Set();
70
+ const entries = Array.isArray(payload?.servers) ? payload.servers : Array.isArray(payload) ? payload : [];
71
+ for (const entry of entries) {
72
+ const server = entry?.server ?? entry;
73
+ if (!server || typeof server !== 'object') continue;
74
+ if (typeof server.name === 'string') allowedNames.add(server.name);
75
+ for (const remote of Array.isArray(server.remotes) ? server.remotes : []) {
76
+ if (typeof remote?.url === 'string') allowedUrls.add(normalizeRegistryUrl(remote.url));
77
+ }
78
+ }
79
+ return { allowedNames, allowedUrls };
80
+ }
81
+
82
+ function registryAllowsConfig(config = {}, gate = {}) {
83
+ if (typeof config.registryName === 'string' && gate.allowedNames?.has(config.registryName)) return true;
84
+ if (typeof config.url === 'string' && gate.allowedUrls?.has(normalizeRegistryUrl(config.url))) return true;
85
+ return false;
86
+ }
87
+
88
+ function normalizeRegistryUrl(value) {
89
+ try {
90
+ const url = new URL(value);
91
+ url.hash = '';
92
+ return url.href.replace(/\/$/, '');
93
+ } catch {
94
+ return String(value).replace(/\/$/, '');
95
+ }
96
+ }