@mirnoorata/codexa 0.2.2 → 0.4.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 (67) hide show
  1. package/README.md +110 -31
  2. package/dist/cli/hooks.js +11 -6
  3. package/dist/cli/hooks.js.map +1 -1
  4. package/dist/cli.js +13 -4
  5. package/dist/cli.js.map +1 -1
  6. package/dist/eval/scoring.js +17 -0
  7. package/dist/eval/scoring.js.map +1 -1
  8. package/dist/implicit-baseline.d.ts +8 -0
  9. package/dist/implicit-baseline.js +94 -0
  10. package/dist/implicit-baseline.js.map +1 -0
  11. package/dist/init.d.ts +3 -0
  12. package/dist/init.js +129 -15
  13. package/dist/init.js.map +1 -1
  14. package/dist/mcp/compaction.d.ts +1 -0
  15. package/dist/mcp/compaction.js +24 -0
  16. package/dist/mcp/compaction.js.map +1 -1
  17. package/dist/mcp/envelope.d.ts +4 -1
  18. package/dist/mcp/envelope.js +45 -5
  19. package/dist/mcp/envelope.js.map +1 -1
  20. package/dist/mcp/prompts.d.ts +1 -1
  21. package/dist/mcp/prompts.js +5 -2
  22. package/dist/mcp/prompts.js.map +1 -1
  23. package/dist/mcp/tool-registry.d.ts +20 -19
  24. package/dist/mcp/tool-registry.js +24 -19
  25. package/dist/mcp/tool-registry.js.map +1 -1
  26. package/dist/mcp/tools.d.ts +1 -0
  27. package/dist/mcp/tools.js +11 -2
  28. package/dist/mcp/tools.js.map +1 -1
  29. package/dist/mcp-tool-catalog.d.ts +1 -1
  30. package/dist/mcp-tool-catalog.js +1 -1
  31. package/dist/mcp-tool-catalog.js.map +1 -1
  32. package/dist/mcp.js +10 -5
  33. package/dist/mcp.js.map +1 -1
  34. package/dist/query/post-edit/decision.d.ts +1 -0
  35. package/dist/query/post-edit/decision.js +13 -4
  36. package/dist/query/post-edit/decision.js.map +1 -1
  37. package/dist/query/post-edit.js +46 -16
  38. package/dist/query/post-edit.js.map +1 -1
  39. package/dist/task-snapshots.js +29 -0
  40. package/dist/task-snapshots.js.map +1 -1
  41. package/dist/types.d.ts +2 -0
  42. package/dist/types.js.map +1 -1
  43. package/integrations/.claude-plugin/marketplace.json +23 -0
  44. package/integrations/claude-code/.claude-plugin/plugin.json +16 -0
  45. package/integrations/claude-code/.mcp.json +8 -0
  46. package/integrations/claude-code/README.md +177 -0
  47. package/integrations/claude-code/commands/codexa-brief.md +14 -0
  48. package/integrations/claude-code/commands/codexa-impact.md +14 -0
  49. package/integrations/claude-code/commands/codexa-plan.md +20 -0
  50. package/integrations/claude-code/commands/codexa-review.md +23 -0
  51. package/integrations/claude-code/commands/codexa-status.md +10 -0
  52. package/integrations/claude-code/hooks/hooks.json +39 -0
  53. package/integrations/claude-code/scripts/cmd/brief.sh +18 -0
  54. package/integrations/claude-code/scripts/cmd/impact.sh +35 -0
  55. package/integrations/claude-code/scripts/cmd/lib.sh +136 -0
  56. package/integrations/claude-code/scripts/cmd/plan.sh +52 -0
  57. package/integrations/claude-code/scripts/cmd/review.sh +66 -0
  58. package/integrations/claude-code/scripts/cmd/status.sh +52 -0
  59. package/integrations/claude-code/scripts/codexa-mcp.js +111 -0
  60. package/integrations/claude-code/scripts/lib/codexa-repo.sh +773 -0
  61. package/integrations/claude-code/scripts/pre-edit.sh +116 -0
  62. package/integrations/claude-code/scripts/session-start.sh +201 -0
  63. package/integrations/claude-code/scripts/stop.sh +443 -0
  64. package/integrations/claude-code/tests/cmd-smoke.sh +310 -0
  65. package/integrations/claude-code/tests/hook-smoke.sh +1412 -0
  66. package/package.json +6 -3
  67. package/plugins/codexa/.codex-plugin/plugin.json +1 -1
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ // MCP launcher for the Codexa Claude Code plugin. Claude Code starts plugin
3
+ // MCP servers with the session's project directory as cwd; this script
4
+ // resolves the repository from there, resolves the Codexa CLI (explicit
5
+ // override, walked-up package/checkout dist, global install), and execs
6
+ // `codexa serve` over stdio. Self-contained on purpose: when the plugin is
7
+ // installed from a marketplace only this directory is copied, so it cannot
8
+ // reference files outside the plugin root.
9
+ import { spawn, spawnSync } from "node:child_process";
10
+ import { existsSync } from "node:fs";
11
+ import path from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+
14
+ const explicitRepo = process.argv[2];
15
+ const autoRefresh = process.env.CODEXA_PLUGIN_AUTO_REFRESH !== "0";
16
+ const repoRoot = resolveRepoRoot(explicitRepo);
17
+ if (!repoRoot) {
18
+ console.error(
19
+ "codexa plugin MCP could not find a git repository. Set CODEXA_REPO to the repository root or start Claude Code inside the repository."
20
+ );
21
+ process.exit(1);
22
+ }
23
+
24
+ const launch = resolveCodexaLaunch(repoRoot, autoRefresh);
25
+ const child = spawn(launch.command, launch.args, {
26
+ cwd: repoRoot,
27
+ stdio: ["inherit", "inherit", "inherit"],
28
+ env: process.env
29
+ });
30
+
31
+ child.on("exit", (code, signal) => {
32
+ if (signal) {
33
+ process.kill(process.pid, signal);
34
+ return;
35
+ }
36
+ process.exit(code ?? 1);
37
+ });
38
+
39
+ child.on("error", (error) => {
40
+ console.error(`codexa plugin MCP failed to start ${launch.command}: ${error.message}`);
41
+ process.exit(1);
42
+ });
43
+
44
+ function resolveCodexaLaunch(repoRoot, autoRefresh) {
45
+ // Claude Code has no client-side tool allowlist, so the profile is applied
46
+ // server-side. Default core matches `codexa init`'s default and the
47
+ // plugin's token-discipline pitch; CODEXA_PLUGIN_TOOLS=full widens it.
48
+ const toolProfile = process.env.CODEXA_PLUGIN_TOOLS === "full" ? "full" : "core";
49
+ const serveArgs = ["serve", repoRoot, autoRefresh ? "--auto-refresh" : "--no-auto-refresh", "--tools", toolProfile];
50
+ const overrideCli = process.env.CODEXA_CLI;
51
+ if (overrideCli && existsSync(overrideCli)) {
52
+ return { command: process.execPath, args: [overrideCli, ...serveArgs] };
53
+ }
54
+ // npm package layout: integrations/claude-code/scripts -> package root.
55
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
56
+ const bundledCli = path.resolve(scriptDir, "../../../dist/cli.js");
57
+ if (existsSync(bundledCli)) {
58
+ return { command: process.execPath, args: [bundledCli, ...serveArgs] };
59
+ }
60
+ if (commandExists("codexa")) {
61
+ return { command: "codexa", args: serveArgs };
62
+ }
63
+ if (process.env.CODEXA_PLUGIN_ALLOW_NPX_FALLBACK === "1") {
64
+ return { command: "npx", args: ["-y", "@mirnoorata/codexa", ...serveArgs] };
65
+ }
66
+ console.error(
67
+ "codexa plugin MCP could not find the Codexa CLI. Install it with `npm install -g @mirnoorata/codexa`, set CODEXA_CLI to a dist/cli.js path, or set CODEXA_PLUGIN_ALLOW_NPX_FALLBACK=1 to allow npm registry fallback."
68
+ );
69
+ process.exit(1);
70
+ }
71
+
72
+ function commandExists(command) {
73
+ const probe = process.platform === "win32" ? "where" : "which";
74
+ try {
75
+ return spawnSync(probe, [command], { stdio: "ignore" }).status === 0;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ function resolveRepoRoot(explicit) {
82
+ // Claude Code starts plugin MCP servers with the session's project
83
+ // directory as cwd; that is the authoritative signal. $PWD is deliberately
84
+ // NOT consulted — it is inherited shell state and can point at an
85
+ // unrelated repository.
86
+ const candidates = [explicit, process.env.CODEXA_REPO, process.env.CLAUDE_PROJECT_DIR, process.cwd()].filter(
87
+ (value) => typeof value === "string" && value.trim().length > 0
88
+ );
89
+ for (const candidate of candidates) {
90
+ const root = gitRoot(path.resolve(candidate));
91
+ if (root) {
92
+ return root;
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+
98
+ function gitRoot(candidate) {
99
+ if (!existsSync(candidate)) {
100
+ return null;
101
+ }
102
+ const result = spawnSync("git", ["-C", candidate, "rev-parse", "--show-toplevel"], {
103
+ encoding: "utf8",
104
+ stdio: ["ignore", "pipe", "ignore"]
105
+ });
106
+ if (result.status !== 0) {
107
+ return null;
108
+ }
109
+ const root = result.stdout.trim();
110
+ return root ? path.resolve(root) : null;
111
+ }