@bridge_gpt/mcp-server 0.2.53 → 0.2.54

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 (40) hide show
  1. package/README.md +86 -10
  2. package/build/agent-launchers/claude.js +3 -3
  3. package/build/agent-launchers/prompt.js +8 -11
  4. package/build/base-ref.js +33 -9
  5. package/build/bounded-wait.js +174 -0
  6. package/build/commands.generated.js +1 -1
  7. package/build/conductor/bridge-api-client.js +36 -8
  8. package/build/conductor/epic-runtime.js +133 -97
  9. package/build/conductor/readiness.js +85 -0
  10. package/build/conductor/run-branch.js +137 -0
  11. package/build/conductor/test-run-branch-vectors.js +165 -0
  12. package/build/conductor-bin.js +5 -5
  13. package/build/doctor.js +68 -1
  14. package/build/drive-epic.js +287 -51
  15. package/build/executor/claim-scope.js +104 -0
  16. package/build/executor/cli.js +14 -25
  17. package/build/executor/env-file-guard.js +82 -3
  18. package/build/executor/job-runner.js +60 -0
  19. package/build/index.js +128 -400
  20. package/build/local-artifact-storage.js +130 -0
  21. package/build/pipelines.generated.js +16 -9
  22. package/build/plane/cli.js +285 -36
  23. package/build/plane/manifest.js +209 -1
  24. package/build/plane/member-roster.js +70 -0
  25. package/build/plane/shutdown.js +14 -1
  26. package/build/plane/status.js +35 -1
  27. package/build/plane/supervisor.js +546 -164
  28. package/build/plane/types.js +25 -2
  29. package/build/polling-policy.js +72 -0
  30. package/build/readme.generated.js +1 -1
  31. package/build/review-generation.js +219 -0
  32. package/build/run-unit-tests-launcher.js +5 -0
  33. package/build/setup-epic.js +514 -23
  34. package/build/ticket-key-utils.js +4 -3
  35. package/build/ticket-review-artifact-gate.js +461 -0
  36. package/build/upgrade-cli.js +5 -26
  37. package/build/version.generated.js +3 -3
  38. package/docs/install/mcp-tool-integrations.md +23 -1
  39. package/package.json +1 -1
  40. package/pipelines/review-ticket.json +17 -4
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Structured local artifact persistence primitives (BAPI-1121).
3
+ *
4
+ * WHY THIS EXISTS. `wait_for_ticket_review`'s generation-aware artifact gate
5
+ * (`ticket-review-artifact-gate.ts`) needs a write/removal outcome it can
6
+ * branch on — did the accepted clarify leg actually land on disk, did the
7
+ * withheld critique file actually get removed — without parsing a
8
+ * human-readable note string. The pre-existing `saveLocally` in `index.ts`
9
+ * returns exactly that kind of note, and every existing artifact tool (the
10
+ * six single-artifact request/get tools, the BAPI-342 heavy-read saves, the
11
+ * combined ticket-review fan-out) depends on its exact rendered shape. This
12
+ * module extracts the underlying write mechanics into one place, so both the
13
+ * legacy byte-compatible `saveLocally` and the new structured primitives the
14
+ * gate uses share a single implementation rather than diverging.
15
+ *
16
+ * WHY A SEPARATE MODULE. `index.ts` is the file every other module is
17
+ * imported INTO; a helper defined there cannot be imported back into a module
18
+ * `index.ts` itself imports without an import cycle. This module has no
19
+ * dependency on `index.ts`, so `index.ts` imports `saveLocally` from here
20
+ * (BAPI-1121) instead of defining it locally, and the artifact gate imports
21
+ * the structured primitives directly.
22
+ */
23
+ import { writeFile, mkdir, rename, unlink } from "fs/promises";
24
+ import path from "path";
25
+ import { randomUUID } from "node:crypto";
26
+ /**
27
+ * Write `content` to `dir/filename` via per-file temporary staging followed by
28
+ * an atomic rename, so a concurrent reader can never observe a partially
29
+ * written file and a failed write never leaves a corrupt final artifact.
30
+ *
31
+ * The staging filename includes a random suffix so concurrent writes to the
32
+ * same final filename (unusual, but not prevented at this layer) cannot stage
33
+ * onto the same temporary path.
34
+ *
35
+ * Throws on failure — this is the shared low-level primitive both
36
+ * {@link saveLocally} (byte-compatible legacy notes) and
37
+ * {@link writeCanonicalArtifact} (sanitized structured outcome) wrap
38
+ * differently, because they render a failure to their callers in two
39
+ * deliberately different shapes.
40
+ */
41
+ async function writeFileAtomic(dir, filename, content) {
42
+ const finalPath = path.join(dir, filename);
43
+ const stagingPath = path.join(dir, `.${filename}.${randomUUID()}.tmp`);
44
+ await mkdir(dir, { recursive: true });
45
+ try {
46
+ await writeFile(stagingPath, content, "utf-8");
47
+ await rename(stagingPath, finalPath);
48
+ }
49
+ catch (err) {
50
+ // Best-effort cleanup of an orphaned staging file. Cleanup failure (or the
51
+ // staging file never having been created) does not change the outcome
52
+ // that matters: the original write/rename error propagates below.
53
+ try {
54
+ await unlink(stagingPath);
55
+ }
56
+ catch {
57
+ // Nothing to clean up, or cleanup itself failed — either way the
58
+ // original error is what the caller needs to see.
59
+ }
60
+ throw err;
61
+ }
62
+ return finalPath;
63
+ }
64
+ /**
65
+ * Byte-compatible replacement for the pre-BAPI-1121 `saveLocally` in
66
+ * `index.ts`. Preserves the exact call shape (`dir`, `filename`, `content` ->
67
+ * a rendered note string) and the exact rendered success/failure notes every
68
+ * existing artifact-tool caller depends on — including the raw error suffix
69
+ * on failure, which existing tests assert verbatim. The only behavioral
70
+ * change is that the write is now staged-then-renamed rather than written
71
+ * in place, which is externally invisible on success and, on failure, means
72
+ * no partial file is ever left at `dir/filename` (an improvement, not a
73
+ * compatibility break).
74
+ */
75
+ export async function saveLocally(dir, filename, content) {
76
+ try {
77
+ const finalPath = await writeFileAtomic(dir, filename, content);
78
+ return `\n\n---\nSaved to ${finalPath}`;
79
+ }
80
+ catch (writeErr) {
81
+ const filePath = path.join(dir, filename);
82
+ return `\n\n---\nNote: Failed to save file to ${filePath}: ${writeErr}`;
83
+ }
84
+ }
85
+ /**
86
+ * Structured canonical write for the generation-aware artifact gate. Returns
87
+ * `{ ok, path, message }` rather than throwing or requiring the caller to
88
+ * parse a note string. The public `message` is sanitized to the path and
89
+ * outcome only; any detailed local diagnostic (the underlying filesystem
90
+ * error) goes only to `console.error`, never through MCP.
91
+ */
92
+ export async function writeCanonicalArtifact(dir, filename, content) {
93
+ const finalPath = path.join(dir, filename);
94
+ try {
95
+ await writeFileAtomic(dir, filename, content);
96
+ return { ok: true, path: finalPath, message: `Saved to ${finalPath}` };
97
+ }
98
+ catch (err) {
99
+ console.error(`[local-artifact-storage] write failed for ${finalPath}:`, err);
100
+ return { ok: false, path: finalPath, message: `Failed to save file to ${finalPath}` };
101
+ }
102
+ }
103
+ /**
104
+ * Remove the exact canonical path for a withheld or stale artifact.
105
+ *
106
+ * Idempotent by design: an already-absent target (`ENOENT`) is reported as a
107
+ * SUCCESSFUL cleanup outcome, not an error — a retried removal, or a removal
108
+ * that runs after an earlier successful one, must never report failure. Only
109
+ * an actual removal failure (permissions, a directory at that path, etc.) is
110
+ * reported as `ok: false`.
111
+ *
112
+ * Removes exactly the given path — no globbing, no directory recursion, no
113
+ * inference of sibling files to clean up. The caller is responsible for
114
+ * passing the exact canonical target; this primitive never widens the blast
115
+ * radius of a removal on its own.
116
+ */
117
+ export async function removeCanonicalArtifact(targetPath) {
118
+ try {
119
+ await unlink(targetPath);
120
+ return { ok: true, path: targetPath, message: `Removed ${targetPath}` };
121
+ }
122
+ catch (err) {
123
+ const code = err?.code;
124
+ if (code === "ENOENT") {
125
+ return { ok: true, path: targetPath, message: `${targetPath} was already absent` };
126
+ }
127
+ console.error(`[local-artifact-storage] removal failed for ${targetPath}:`, err);
128
+ return { ok: false, path: targetPath, message: `Failed to remove ${targetPath}` };
129
+ }
130
+ }