@h-rig/bundle-default-lifecycle 0.0.6-alpha.157 → 0.0.6-alpha.158

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 (54) hide show
  1. package/dist/src/cli.d.ts +1 -7
  2. package/dist/src/cli.js +5 -2
  3. package/dist/src/control-plane/completion-verification.js +1591 -118
  4. package/dist/src/control-plane/hooks/inject-context.d.ts +2 -0
  5. package/dist/src/control-plane/hooks/inject-context.js +175 -0
  6. package/dist/src/control-plane/hooks/shared.d.ts +11 -0
  7. package/dist/src/control-plane/hooks/shared.js +44 -0
  8. package/dist/src/control-plane/hooks/submodule-branch.d.ts +2 -0
  9. package/dist/src/control-plane/hooks/submodule-branch.js +432 -0
  10. package/dist/src/control-plane/hooks/task-runtime-start.d.ts +2 -0
  11. package/dist/src/control-plane/hooks/task-runtime-start.js +429 -0
  12. package/dist/src/control-plane/materialize-task-config.d.ts +29 -0
  13. package/dist/src/control-plane/materialize-task-config.js +95 -0
  14. package/dist/src/control-plane/native/git-ops.d.ts +67 -0
  15. package/dist/src/control-plane/native/git-ops.js +1390 -0
  16. package/dist/src/control-plane/policy.d.ts +3 -0
  17. package/dist/src/control-plane/policy.js +226 -0
  18. package/dist/src/control-plane/pr-automation.d.ts +2 -0
  19. package/dist/src/control-plane/pr-automation.js +26 -16
  20. package/dist/src/control-plane/pr-merge-gate-cap.d.ts +10 -0
  21. package/dist/src/control-plane/pr-merge-gate-cap.js +13 -0
  22. package/dist/src/control-plane/task-data.d.ts +13 -0
  23. package/dist/src/control-plane/task-data.js +12 -0
  24. package/dist/src/control-plane/task-verify.js +131 -59
  25. package/dist/src/control-plane/verifier.d.ts +1 -3
  26. package/dist/src/control-plane/verifier.js +133 -57
  27. package/dist/src/defaultPipeline.d.ts +1 -1
  28. package/dist/src/defaultPipeline.js +5 -2
  29. package/dist/src/index.d.ts +0 -2
  30. package/dist/src/index.js +1908 -290
  31. package/dist/src/native/closeout-runners.js +22 -2
  32. package/dist/src/native/github-auth-env.d.ts +2 -0
  33. package/dist/src/native/github-auth-env.js +25 -0
  34. package/dist/src/native/host-git.d.ts +6 -0
  35. package/dist/src/native/host-git.js +62 -0
  36. package/dist/src/native/in-process-closeout.d.ts +1 -3
  37. package/dist/src/native/in-process-closeout.js +0 -794
  38. package/dist/src/pipelineCloseout.js +1905 -185
  39. package/dist/src/plugin.js +2843 -145
  40. package/dist/src/stages/auto-merge.js +28 -16
  41. package/dist/src/stages/commit.js +28 -16
  42. package/dist/src/stages/isolation.d.ts +1 -1
  43. package/dist/src/stages/isolation.js +5 -3
  44. package/dist/src/stages/merge-gate.js +35 -3
  45. package/dist/src/stages/open-pr.js +28 -16
  46. package/dist/src/stages/push.js +28 -16
  47. package/dist/src/stages/source-closeout.js +28 -16
  48. package/package.json +29 -16
  49. package/dist/src/branch-naming.d.ts +0 -15
  50. package/dist/src/branch-naming.js +0 -33
  51. package/dist/src/closeoutEquivalence.d.ts +0 -37
  52. package/dist/src/closeoutEquivalence.js +0 -78
  53. package/dist/src/closeoutShadowHarness.d.ts +0 -27
  54. package/dist/src/closeoutShadowHarness.js +0 -29
@@ -1,6 +1,26 @@
1
1
  // @bun
2
+ // packages/bundle-default-lifecycle/src/native/github-auth-env.ts
3
+ import { existsSync, readFileSync } from "fs";
4
+ function cleanToken(value) {
5
+ const trimmed = value?.trim() ?? "";
6
+ return trimmed.length > 0 ? trimmed : null;
7
+ }
8
+ function authStateToken(env = process.env) {
9
+ const file = env.RIG_GITHUB_AUTH_STATE_FILE?.trim();
10
+ if (!file || !existsSync(file))
11
+ return null;
12
+ try {
13
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
14
+ return cleanToken(typeof parsed.token === "string" ? parsed.token : undefined);
15
+ } catch {
16
+ return null;
17
+ }
18
+ }
19
+ function resolveGitHubAuthToken(env = process.env) {
20
+ return cleanToken(env.RIG_GITHUB_TOKEN) ?? cleanToken(env.GH_TOKEN) ?? cleanToken(env.GITHUB_TOKEN) ?? authStateToken(env);
21
+ }
22
+
2
23
  // packages/bundle-default-lifecycle/src/native/closeout-runners.ts
3
- import { resolveGitHubAuthToken } from "@rig/runtime/control-plane/github/token-env";
4
24
  function commandEnv(env) {
5
25
  const token = resolveGitHubAuthToken(env);
6
26
  return token ? { ...env, RIG_GITHUB_TOKEN: token, GH_TOKEN: token, GITHUB_TOKEN: token } : { ...env };
@@ -9,7 +29,7 @@ function createBunCommandRunner(binary, env) {
9
29
  return async (args, options) => {
10
30
  try {
11
31
  const child = Bun.spawn([binary, ...args], {
12
- cwd: options?.cwd,
32
+ ...options?.cwd !== undefined ? { cwd: options.cwd } : {},
13
33
  env: commandEnv(env),
14
34
  stdin: "ignore",
15
35
  stdout: "pipe",
@@ -0,0 +1,2 @@
1
+ export declare function authStateToken(env?: Record<string, string | undefined>): string | null;
2
+ export declare function resolveGitHubAuthToken(env?: Record<string, string | undefined>): string | null;
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/native/github-auth-env.ts
3
+ import { existsSync, readFileSync } from "fs";
4
+ function cleanToken(value) {
5
+ const trimmed = value?.trim() ?? "";
6
+ return trimmed.length > 0 ? trimmed : null;
7
+ }
8
+ function authStateToken(env = process.env) {
9
+ const file = env.RIG_GITHUB_AUTH_STATE_FILE?.trim();
10
+ if (!file || !existsSync(file))
11
+ return null;
12
+ try {
13
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
14
+ return cleanToken(typeof parsed.token === "string" ? parsed.token : undefined);
15
+ } catch {
16
+ return null;
17
+ }
18
+ }
19
+ function resolveGitHubAuthToken(env = process.env) {
20
+ return cleanToken(env.RIG_GITHUB_TOKEN) ?? cleanToken(env.GH_TOKEN) ?? cleanToken(env.GITHUB_TOKEN) ?? authStateToken(env);
21
+ }
22
+ export {
23
+ resolveGitHubAuthToken,
24
+ authStateToken
25
+ };
@@ -0,0 +1,6 @@
1
+ export declare function isRuntimeGatewayGitPath(candidate: string): boolean;
2
+ export declare function isRuntimeGatewayGhPath(candidate: string): boolean;
3
+ export declare function resolveHostGitBinary(): string;
4
+ export declare function resolveGithubCliBinary(options?: {
5
+ scanPath?: boolean;
6
+ }): string;
@@ -0,0 +1,62 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/native/host-git.ts
3
+ import { existsSync } from "fs";
4
+ import { resolve } from "path";
5
+ function isRuntimeGatewayGitPath(candidate) {
6
+ return /\/\.rig\/bin\/git$/.test(candidate.replace(/\\/g, "/"));
7
+ }
8
+ function isRuntimeGatewayGhPath(candidate) {
9
+ return /\/\.rig\/bin\/gh$/.test(candidate.replace(/\\/g, "/"));
10
+ }
11
+ function resolveHostGitBinary() {
12
+ const candidates = [
13
+ process.env.RIG_GIT_BIN?.trim() || "",
14
+ "/usr/bin/git",
15
+ "/opt/homebrew/bin/git",
16
+ "/usr/local/bin/git"
17
+ ];
18
+ const bunResolved = Bun.which("git");
19
+ if (bunResolved && !isRuntimeGatewayGitPath(bunResolved)) {
20
+ candidates.push(bunResolved);
21
+ }
22
+ for (const candidate of candidates) {
23
+ if (!candidate || isRuntimeGatewayGitPath(candidate)) {
24
+ continue;
25
+ }
26
+ if (existsSync(candidate)) {
27
+ return candidate;
28
+ }
29
+ }
30
+ return "git";
31
+ }
32
+ function resolveGithubCliBinary(options = {}) {
33
+ const candidates = new Set;
34
+ const explicit = process.env.RIG_GH_BIN?.trim();
35
+ if (explicit) {
36
+ candidates.add(explicit);
37
+ }
38
+ for (const candidate of ["/usr/bin/gh", "/opt/homebrew/bin/gh", "/usr/local/bin/gh"]) {
39
+ candidates.add(candidate);
40
+ }
41
+ if (options.scanPath) {
42
+ for (const entry of (process.env.PATH || "").split(":").map((e) => e.trim()).filter(Boolean)) {
43
+ candidates.add(resolve(entry, "gh"));
44
+ }
45
+ }
46
+ const bunResolved = Bun.which("gh");
47
+ if (bunResolved) {
48
+ candidates.add(bunResolved);
49
+ }
50
+ for (const candidate of candidates) {
51
+ if (candidate && existsSync(candidate) && !isRuntimeGatewayGhPath(candidate)) {
52
+ return candidate;
53
+ }
54
+ }
55
+ return "";
56
+ }
57
+ export {
58
+ resolveHostGitBinary,
59
+ resolveGithubCliBinary,
60
+ isRuntimeGatewayGitPath,
61
+ isRuntimeGatewayGhPath
62
+ };
@@ -1,5 +1,4 @@
1
- import type { JournalCapability, RunCloseoutPhase, RunCloseoutPhaseOutcome } from "@rig/contracts";
2
- import type { GitCommandRunner, GitHubCommandRunner, RigAutomationConfig, StrictPrGreptileApiOptions } from "@rig/contracts";
1
+ import type { GitCommandRunner, GitHubCommandRunner, JournalCapability, RigAutomationConfig, RunCloseoutPhase, RunCloseoutPhaseOutcome, StrictPrGreptileApiOptions } from "@rig/contracts";
3
2
  export type RunTaskSourceReflectStatus = "under_review" | "ci_fixing" | "merging" | "closed" | "needs_attention";
4
3
  export type InProcessCloseoutStatus = "merged" | "opened" | "skipped" | "needs-attention";
5
4
  export type InProcessCloseoutResult = {
@@ -37,4 +36,3 @@ export type InProcessCloseoutInput = {
37
36
  errorText?: string | null;
38
37
  }) => Promise<void> | void;
39
38
  };
40
- export declare function runInProcessCloseout(input: InProcessCloseoutInput): Promise<InProcessCloseoutResult>;