@google/jules-fleet 0.0.1-experimental.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.
- package/README.md +205 -0
- package/dist/analyze/formatting.d.ts +19 -0
- package/dist/analyze/goals.d.ts +18 -0
- package/dist/analyze/handler.d.ts +23 -0
- package/dist/analyze/index.d.ts +8 -0
- package/dist/analyze/milestone.d.ts +43 -0
- package/dist/analyze/prompt.d.ts +10 -0
- package/dist/analyze/spec.d.ts +54 -0
- package/dist/analyze/triage-prompt.d.ts +16 -0
- package/dist/cli/analyze.command.d.ts +24 -0
- package/dist/cli/analyze.command.mjs +1015 -0
- package/dist/cli/commands.json +1 -0
- package/dist/cli/configure.command.d.ts +21 -0
- package/dist/cli/configure.command.mjs +623 -0
- package/dist/cli/dispatch.command.d.ts +16 -0
- package/dist/cli/dispatch.command.mjs +777 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.mjs +40 -0
- package/dist/cli/init.command.d.ts +38 -0
- package/dist/cli/init.command.mjs +1287 -0
- package/dist/cli/merge.command.d.ts +36 -0
- package/dist/cli/merge.command.mjs +859 -0
- package/dist/cli/signal.command.d.ts +2 -0
- package/dist/cli/signal.command.mjs +288 -0
- package/dist/configure/handler.d.ts +19 -0
- package/dist/configure/index.d.ts +4 -0
- package/dist/configure/labels.d.ts +6 -0
- package/dist/configure/spec.d.ts +49 -0
- package/dist/dispatch/events.d.ts +12 -0
- package/dist/dispatch/handler.d.ts +21 -0
- package/dist/dispatch/index.d.ts +5 -0
- package/dist/dispatch/spec.d.ts +47 -0
- package/dist/dispatch/status.d.ts +24 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +2105 -0
- package/dist/init/handler.d.ts +22 -0
- package/dist/init/index.d.ts +4 -0
- package/dist/init/ops/commit-files.d.ts +10 -0
- package/dist/init/ops/create-branch.d.ts +16 -0
- package/dist/init/ops/create-pr.d.ts +15 -0
- package/dist/init/ops/pr-body.d.ts +5 -0
- package/dist/init/ops/upload-secrets.d.ts +11 -0
- package/dist/init/spec.d.ts +50 -0
- package/dist/init/templates/analyze.d.ts +2 -0
- package/dist/init/templates/dispatch.d.ts +2 -0
- package/dist/init/templates/example-goal.d.ts +5 -0
- package/dist/init/templates/merge.d.ts +2 -0
- package/dist/init/templates/types.d.ts +6 -0
- package/dist/init/templates.d.ts +10 -0
- package/dist/init/types.d.ts +19 -0
- package/dist/init/wizard/headless.d.ts +8 -0
- package/dist/init/wizard/index.d.ts +3 -0
- package/dist/init/wizard/interactive.d.ts +9 -0
- package/dist/init/wizard/types.d.ts +22 -0
- package/dist/merge/handler.d.ts +21 -0
- package/dist/merge/index.d.ts +5 -0
- package/dist/merge/ops/index.d.ts +4 -0
- package/dist/merge/ops/redispatch.d.ts +8 -0
- package/dist/merge/ops/squash-merge.d.ts +8 -0
- package/dist/merge/ops/update-branch.d.ts +11 -0
- package/dist/merge/ops/wait-for-ci.d.ts +7 -0
- package/dist/merge/select/by-fleet-run.d.ts +8 -0
- package/dist/merge/select/by-label.d.ts +7 -0
- package/dist/merge/select/index.d.ts +2 -0
- package/dist/merge/spec.d.ts +99 -0
- package/dist/shared/auth/cache-plugin.d.ts +9 -0
- package/dist/shared/auth/git.d.ts +22 -0
- package/dist/shared/auth/index.d.ts +4 -0
- package/dist/shared/auth/octokit.d.ts +11 -0
- package/dist/shared/auth/resolve-key.d.ts +11 -0
- package/dist/shared/events/analyze.d.ts +37 -0
- package/dist/shared/events/configure.d.ts +21 -0
- package/dist/shared/events/dispatch.d.ts +26 -0
- package/dist/shared/events/error.d.ts +7 -0
- package/dist/shared/events/index.d.ts +16 -0
- package/dist/shared/events/init.d.ts +49 -0
- package/dist/shared/events/merge.d.ts +72 -0
- package/dist/shared/events.d.ts +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/result/create-result-schemas.d.ts +72 -0
- package/dist/shared/result/fail.d.ts +10 -0
- package/dist/shared/result/index.d.ts +3 -0
- package/dist/shared/result/ok.d.ts +5 -0
- package/dist/shared/schemas/check-run.d.ts +16 -0
- package/dist/shared/schemas/index.d.ts +4 -0
- package/dist/shared/schemas/label.d.ts +16 -0
- package/dist/shared/schemas/pr.d.ts +19 -0
- package/dist/shared/schemas/repo-info.d.ts +16 -0
- package/dist/shared/session-dispatcher.d.ts +18 -0
- package/dist/shared/ui/assert-never.d.ts +13 -0
- package/dist/shared/ui/index.d.ts +18 -0
- package/dist/shared/ui/interactive.d.ts +19 -0
- package/dist/shared/ui/plain.d.ts +16 -0
- package/dist/shared/ui/render/analyze.d.ts +4 -0
- package/dist/shared/ui/render/configure.d.ts +4 -0
- package/dist/shared/ui/render/dispatch.d.ts +4 -0
- package/dist/shared/ui/render/error.d.ts +4 -0
- package/dist/shared/ui/render/init.d.ts +4 -0
- package/dist/shared/ui/render/merge.d.ts +4 -0
- package/dist/shared/ui/session-url.d.ts +13 -0
- package/dist/shared/ui/spec.d.ts +30 -0
- package/dist/signal/handler.d.ts +17 -0
- package/dist/signal/index.d.ts +3 -0
- package/dist/signal/spec.d.ts +60 -0
- package/package.json +76 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { InitInput, InitResult, InitSpec } from './spec.js';
|
|
3
|
+
import type { LabelConfigurator } from './types.js';
|
|
4
|
+
import type { FleetEmitter } from '../shared/events.js';
|
|
5
|
+
export interface InitHandlerDeps {
|
|
6
|
+
octokit: Octokit;
|
|
7
|
+
emit?: FleetEmitter;
|
|
8
|
+
labelConfigurator?: LabelConfigurator;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* InitHandler scaffolds fleet workflow files by creating a PR via GitHub REST API.
|
|
12
|
+
* Never throws — all errors are Result values.
|
|
13
|
+
*
|
|
14
|
+
* Pipeline: createBranch → commitFiles → createInitPR → configureLabels
|
|
15
|
+
*/
|
|
16
|
+
export declare class InitHandler implements InitSpec {
|
|
17
|
+
private octokit;
|
|
18
|
+
private emit;
|
|
19
|
+
private labelConfigurator?;
|
|
20
|
+
constructor(deps: InitHandlerDeps);
|
|
21
|
+
execute(input: InitInput): Promise<InitResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InitResult } from '../spec.js';
|
|
2
|
+
import type { InitContext } from '../types.js';
|
|
3
|
+
import type { WorkflowTemplate } from '../templates/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Commit workflow templates and an example goal to the init branch.
|
|
6
|
+
* Returns the list of files created, or a fail Result.
|
|
7
|
+
*/
|
|
8
|
+
export declare function commitFiles(ctx: InitContext, templates: readonly WorkflowTemplate[], exampleGoal: string): Promise<string[] | InitResult>;
|
|
9
|
+
/** Type guard: returns true if the result is a fail Result */
|
|
10
|
+
export declare function isCommitResult(result: string[] | InitResult): result is InitResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { InitResult } from '../spec.js';
|
|
3
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create the fleet-init branch from the base branch SHA.
|
|
6
|
+
* Returns the branch name on success, or a fail Result.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createBranch(octokit: Octokit, owner: string, repo: string, baseBranch: string, emit: FleetEmitter): Promise<{
|
|
9
|
+
branchName: string;
|
|
10
|
+
baseSha: string;
|
|
11
|
+
} | InitResult>;
|
|
12
|
+
/** Type guard: returns true if the result is a fail Result (not a branch info object) */
|
|
13
|
+
export declare function isBranchResult(result: {
|
|
14
|
+
branchName: string;
|
|
15
|
+
baseSha: string;
|
|
16
|
+
} | InitResult): result is InitResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InitResult } from '../spec.js';
|
|
2
|
+
import type { InitContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create the fleet initialization PR.
|
|
5
|
+
* Returns { prUrl, prNumber } on success, or a fail Result.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createInitPR(ctx: InitContext, baseBranch: string, filesCreated: string[]): Promise<{
|
|
8
|
+
prUrl: string;
|
|
9
|
+
prNumber: number;
|
|
10
|
+
} | InitResult>;
|
|
11
|
+
/** Type guard: returns true if the result is a fail Result */
|
|
12
|
+
export declare function isPRResult(result: {
|
|
13
|
+
prUrl: string;
|
|
14
|
+
prNumber: number;
|
|
15
|
+
} | InitResult): result is InitResult;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
3
|
+
/**
|
|
4
|
+
* Upload a secret to GitHub Actions using NaCl sealed-box encryption.
|
|
5
|
+
*
|
|
6
|
+
* Uses the repo public key endpoint + libsodium-wrappers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function uploadSecret(octokit: Octokit, owner: string, repo: string, secretName: string, secretValue: string, emit: FleetEmitter): Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const InitInputSchema: z.ZodObject<{
|
|
3
|
+
/** Repository in owner/repo format (auto-detected from git if omitted) */
|
|
4
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
5
|
+
/** Repository owner (resolved from repo or git) */
|
|
6
|
+
owner: z.ZodString;
|
|
7
|
+
/** Repository name (resolved from repo or git) */
|
|
8
|
+
repoName: z.ZodString;
|
|
9
|
+
/** Base branch for the PR */
|
|
10
|
+
baseBranch: z.ZodDefault<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
owner: string;
|
|
13
|
+
baseBranch: string;
|
|
14
|
+
repoName: string;
|
|
15
|
+
repo?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
owner: string;
|
|
18
|
+
repoName: string;
|
|
19
|
+
repo?: string | undefined;
|
|
20
|
+
baseBranch?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type InitInput = z.infer<typeof InitInputSchema>;
|
|
23
|
+
export declare const InitErrorCode: z.ZodEnum<["REPO_NOT_FOUND", "BRANCH_CREATE_FAILED", "FILE_COMMIT_FAILED", "PR_CREATE_FAILED", "LABEL_CREATE_FAILED", "GITHUB_API_ERROR", "UNKNOWN_ERROR"]>;
|
|
24
|
+
export type InitErrorCode = z.infer<typeof InitErrorCode>;
|
|
25
|
+
export interface InitSuccess {
|
|
26
|
+
success: true;
|
|
27
|
+
data: {
|
|
28
|
+
/** URL of the created PR */
|
|
29
|
+
prUrl: string;
|
|
30
|
+
/** PR number */
|
|
31
|
+
prNumber: number;
|
|
32
|
+
/** Files committed to the branch */
|
|
33
|
+
filesCreated: string[];
|
|
34
|
+
/** Labels created in the repo */
|
|
35
|
+
labelsCreated: string[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface InitFailure {
|
|
39
|
+
success: false;
|
|
40
|
+
error: {
|
|
41
|
+
code: InitErrorCode;
|
|
42
|
+
message: string;
|
|
43
|
+
recoverable: boolean;
|
|
44
|
+
suggestion?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export type InitResult = InitSuccess | InitFailure;
|
|
48
|
+
export interface InitSpec {
|
|
49
|
+
execute(input: InitInput): Promise<InitResult>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example goal file content committed by `jules-fleet init`.
|
|
3
|
+
* Lives in its own file to keep handler.ts focused on orchestration.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EXAMPLE_GOAL = "---\nmilestone: \"1\"\n---\n\n# Example Fleet Goal\n\nAnalyze the codebase for potential improvements and create\nissues for the engineering team.\n\n## Tools\n- Test Coverage: `npx vitest --coverage --json`\n\n## Assessment Hints\n- Focus on missing error handling in API routes\n- Look for hardcoded configuration values\n\n## Insight Hints\n- Report on overall test coverage metrics\n- Note any unusually complex functions (cyclomatic complexity)\n\n## Constraints\n- Do NOT propose changes already covered by open issues\n- Do NOT propose changes rejected in recently closed issues\n- Keep tasks small and isolated \u2014 one logical change per issue\n";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel re-export for workflow templates.
|
|
3
|
+
* Each template lives in its own file to prevent merge conflicts.
|
|
4
|
+
*/
|
|
5
|
+
export type { WorkflowTemplate } from './templates/types.js';
|
|
6
|
+
export { FLEET_ANALYZE_TEMPLATE } from './templates/analyze.js';
|
|
7
|
+
export { FLEET_DISPATCH_TEMPLATE } from './templates/dispatch.js';
|
|
8
|
+
export { FLEET_MERGE_TEMPLATE } from './templates/merge.js';
|
|
9
|
+
import type { WorkflowTemplate } from './templates/types.js';
|
|
10
|
+
export declare const WORKFLOW_TEMPLATES: readonly WorkflowTemplate[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConfigureResult } from '../configure/spec.js';
|
|
2
|
+
import type { FleetEmitter } from '../shared/events.js';
|
|
3
|
+
/** Interface for label configuration — decouples init from configure slice */
|
|
4
|
+
export interface LabelConfigurator {
|
|
5
|
+
execute(input: {
|
|
6
|
+
resource: 'labels';
|
|
7
|
+
action: 'create';
|
|
8
|
+
owner: string;
|
|
9
|
+
repo: string;
|
|
10
|
+
}): Promise<ConfigureResult>;
|
|
11
|
+
}
|
|
12
|
+
/** Shared context threaded through init operations */
|
|
13
|
+
export interface InitContext {
|
|
14
|
+
octokit: import('octokit').Octokit;
|
|
15
|
+
owner: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
branchName: string;
|
|
18
|
+
emit: FleetEmitter;
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fail } from '../../shared/result/index.js';
|
|
2
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
3
|
+
import type { InitArgs, InitWizardResult } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Validate all required inputs from flags + env vars in non-interactive mode.
|
|
6
|
+
* Fails with actionable errors when required values are missing.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateHeadlessInputs(args: InitArgs, emit: FleetEmitter): Promise<InitWizardResult | ReturnType<typeof fail>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fail } from '../../shared/result/index.js';
|
|
2
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
3
|
+
import type { InitArgs, InitWizardResult } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Collect all init inputs via interactive wizard prompts.
|
|
6
|
+
* Each step checks if the value is already available from flags/env
|
|
7
|
+
* and skips the prompt if so.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runInitWizard(args: InitArgs, emit: FleetEmitter): Promise<InitWizardResult | ReturnType<typeof fail>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Resolved inputs from the wizard or flags+env validation */
|
|
2
|
+
export interface InitWizardResult {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
baseBranch: string;
|
|
6
|
+
authMethod: 'token' | 'app';
|
|
7
|
+
/** Secrets to upload (name → value). Empty if user declines or non-interactive. */
|
|
8
|
+
secretsToUpload: Record<string, string>;
|
|
9
|
+
/** Whether to perform a dry run (list files but don't create PR) */
|
|
10
|
+
dryRun: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Parsed args from citty */
|
|
13
|
+
export interface InitArgs {
|
|
14
|
+
repo?: string;
|
|
15
|
+
base?: string;
|
|
16
|
+
'non-interactive'?: boolean;
|
|
17
|
+
'dry-run'?: boolean;
|
|
18
|
+
auth?: string;
|
|
19
|
+
'app-id'?: string;
|
|
20
|
+
'installation-id'?: string;
|
|
21
|
+
'upload-secrets'?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { MergeInput, MergeResult, MergeSpec } from './spec.js';
|
|
3
|
+
import type { FleetEmitter } from '../shared/events.js';
|
|
4
|
+
export interface MergeHandlerDeps {
|
|
5
|
+
octokit: Octokit;
|
|
6
|
+
emit?: FleetEmitter;
|
|
7
|
+
sleep?: (ms: number) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* MergeHandler implements the sequential merge loop.
|
|
11
|
+
* All GitHub interactions go through Octokit REST API.
|
|
12
|
+
* Never throws — all errors returned as Result.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MergeHandler implements MergeSpec {
|
|
15
|
+
private octokit;
|
|
16
|
+
private emit;
|
|
17
|
+
private sleep;
|
|
18
|
+
constructor(deps: MergeHandlerDeps);
|
|
19
|
+
execute(input: MergeInput): Promise<MergeResult>;
|
|
20
|
+
private selectPRs;
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { MergeInput, MergeResult, MergeSuccess, MergeFailure, MergeSpec, } from './spec.js';
|
|
2
|
+
export { MergeInputSchema, MergeMode, MergeErrorCode } from './spec.js';
|
|
3
|
+
export { MergeHandler } from './handler.js';
|
|
4
|
+
export { selectByLabel } from './select/by-label.js';
|
|
5
|
+
export { selectByFleetRun } from './select/by-fleet-run.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { PR } from '../../shared/schemas/pr.js';
|
|
3
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
4
|
+
/**
|
|
5
|
+
* Closes a conflicting PR and re-dispatches via Jules SDK.
|
|
6
|
+
* Polls for the new PR and returns it, or null on timeout.
|
|
7
|
+
*/
|
|
8
|
+
export declare function redispatch(octokit: Octokit, owner: string, repo: string, oldPr: PR, baseBranch: string, pollTimeoutSeconds: number, emit: FleetEmitter, sleep: (ms: number) => Promise<void>): Promise<PR | null>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
3
|
+
/**
|
|
4
|
+
* Updates a PR branch from its base branch.
|
|
5
|
+
* Returns conflict status so the caller can decide to re-dispatch.
|
|
6
|
+
*/
|
|
7
|
+
export declare function updateBranch(octokit: Octokit, owner: string, repo: string, prNumber: number, emit: FleetEmitter): Promise<{
|
|
8
|
+
ok: boolean;
|
|
9
|
+
conflict: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { FleetEmitter } from '../../shared/events.js';
|
|
3
|
+
/**
|
|
4
|
+
* Polls GitHub Checks API until all checks complete or timeout.
|
|
5
|
+
* Returns 'pass', 'fail', 'none' (no checks configured), or 'timeout'.
|
|
6
|
+
*/
|
|
7
|
+
export declare function waitForCI(octokit: Octokit, owner: string, repo: string, prNumber: number, maxWaitMs: number, emit: FleetEmitter, sleep: (ms: number) => Promise<void>): Promise<'pass' | 'fail' | 'none' | 'timeout'>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { PR } from '../../shared/schemas/pr.js';
|
|
3
|
+
/**
|
|
4
|
+
* Select PRs by fleet-run ID embedded in PR body.
|
|
5
|
+
* Matches `<!-- fleet-run: <ID> -->` marker.
|
|
6
|
+
* Returns PRs sorted by number (oldest first).
|
|
7
|
+
*/
|
|
8
|
+
export declare function selectByFleetRun(octokit: Octokit, owner: string, repo: string, baseBranch: string, runId: string): Promise<PR[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Octokit } from 'octokit';
|
|
2
|
+
import type { PR } from '../../shared/schemas/pr.js';
|
|
3
|
+
/**
|
|
4
|
+
* Select PRs using the `fleet-merge-ready` label.
|
|
5
|
+
* Returns PRs sorted by number (oldest first) for deterministic ordering.
|
|
6
|
+
*/
|
|
7
|
+
export declare function selectByLabel(octokit: Octokit, owner: string, repo: string, baseBranch: string): Promise<PR[]>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MergeMode: z.ZodEnum<["label", "fleet-run"]>;
|
|
3
|
+
export type MergeMode = z.infer<typeof MergeMode>;
|
|
4
|
+
export declare const MergeInputSchema: z.ZodEffects<z.ZodObject<{
|
|
5
|
+
/** PR selection mode */
|
|
6
|
+
mode: z.ZodDefault<z.ZodEnum<["label", "fleet-run"]>>;
|
|
7
|
+
/** Fleet run ID — required when mode is 'fleet-run' */
|
|
8
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
/** Base branch to merge into */
|
|
10
|
+
baseBranch: z.ZodDefault<z.ZodString>;
|
|
11
|
+
/** Use admin privileges to bypass branch protection */
|
|
12
|
+
admin: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
/** Max seconds to wait for CI per PR */
|
|
14
|
+
maxCIWaitSeconds: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
/** Max re-dispatch attempts per PR on conflict */
|
|
16
|
+
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
/** Enable automatic re-dispatch on merge conflict (requires JULES_API_KEY) */
|
|
18
|
+
reDispatch: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
/** Max seconds to wait for re-dispatched PR to appear */
|
|
20
|
+
pollTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
/** Repository owner */
|
|
22
|
+
owner: z.ZodString;
|
|
23
|
+
/** Repository name */
|
|
24
|
+
repo: z.ZodString;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
owner: string;
|
|
27
|
+
repo: string;
|
|
28
|
+
mode: "label" | "fleet-run";
|
|
29
|
+
baseBranch: string;
|
|
30
|
+
admin: boolean;
|
|
31
|
+
maxCIWaitSeconds: number;
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
reDispatch: boolean;
|
|
34
|
+
pollTimeoutSeconds: number;
|
|
35
|
+
runId?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
owner: string;
|
|
38
|
+
repo: string;
|
|
39
|
+
mode?: "label" | "fleet-run" | undefined;
|
|
40
|
+
runId?: string | undefined;
|
|
41
|
+
baseBranch?: string | undefined;
|
|
42
|
+
admin?: boolean | undefined;
|
|
43
|
+
maxCIWaitSeconds?: number | undefined;
|
|
44
|
+
maxRetries?: number | undefined;
|
|
45
|
+
reDispatch?: boolean | undefined;
|
|
46
|
+
pollTimeoutSeconds?: number | undefined;
|
|
47
|
+
}>, {
|
|
48
|
+
owner: string;
|
|
49
|
+
repo: string;
|
|
50
|
+
mode: "label" | "fleet-run";
|
|
51
|
+
baseBranch: string;
|
|
52
|
+
admin: boolean;
|
|
53
|
+
maxCIWaitSeconds: number;
|
|
54
|
+
maxRetries: number;
|
|
55
|
+
reDispatch: boolean;
|
|
56
|
+
pollTimeoutSeconds: number;
|
|
57
|
+
runId?: string | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
owner: string;
|
|
60
|
+
repo: string;
|
|
61
|
+
mode?: "label" | "fleet-run" | undefined;
|
|
62
|
+
runId?: string | undefined;
|
|
63
|
+
baseBranch?: string | undefined;
|
|
64
|
+
admin?: boolean | undefined;
|
|
65
|
+
maxCIWaitSeconds?: number | undefined;
|
|
66
|
+
maxRetries?: number | undefined;
|
|
67
|
+
reDispatch?: boolean | undefined;
|
|
68
|
+
pollTimeoutSeconds?: number | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export type MergeInput = z.infer<typeof MergeInputSchema>;
|
|
71
|
+
export declare const MergeErrorCode: z.ZodEnum<["NO_PRS_FOUND", "CI_FAILED", "CI_TIMEOUT", "MERGE_FAILED", "CONFLICT_RETRIES_EXHAUSTED", "REDISPATCH_TIMEOUT", "GITHUB_API_ERROR", "UNKNOWN_ERROR"]>;
|
|
72
|
+
export type MergeErrorCode = z.infer<typeof MergeErrorCode>;
|
|
73
|
+
export interface MergeSuccess {
|
|
74
|
+
success: true;
|
|
75
|
+
data: {
|
|
76
|
+
/** PRs that were successfully merged */
|
|
77
|
+
merged: number[];
|
|
78
|
+
/** PRs skipped (CI failure, etc.) */
|
|
79
|
+
skipped: number[];
|
|
80
|
+
/** PRs that were re-dispatched due to conflicts */
|
|
81
|
+
redispatched: Array<{
|
|
82
|
+
oldPr: number;
|
|
83
|
+
newPr: number;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface MergeFailure {
|
|
88
|
+
success: false;
|
|
89
|
+
error: {
|
|
90
|
+
code: MergeErrorCode;
|
|
91
|
+
message: string;
|
|
92
|
+
recoverable: boolean;
|
|
93
|
+
suggestion?: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export type MergeResult = MergeSuccess | MergeFailure;
|
|
97
|
+
export interface MergeSpec {
|
|
98
|
+
execute(input: MergeInput): Promise<MergeResult>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Octokit plugin that caches responses using GitHub's ETag mechanism.
|
|
3
|
+
* 304 Not Modified responses don't count against your rate limit.
|
|
4
|
+
*
|
|
5
|
+
* Uses `any` for the octokit param because Octokit.plugin() expects
|
|
6
|
+
* the @octokit/core Octokit type, which is a transitive dep we don't
|
|
7
|
+
* want to declare directly.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cachePlugin(octokit: any): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Parsed git remote info */
|
|
2
|
+
export interface GitRepoInfo {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
fullName: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Detect repository owner and name.
|
|
9
|
+
*
|
|
10
|
+
* Priority:
|
|
11
|
+
* 1. `GITHUB_REPOSITORY` env var (always set in GitHub Actions: "owner/repo")
|
|
12
|
+
* 2. git remote URL parsing (HTTPS or SSH)
|
|
13
|
+
*/
|
|
14
|
+
export declare function getGitRepoInfo(remoteName?: string): Promise<GitRepoInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a git remote URL to extract owner and repo.
|
|
17
|
+
* - https://github.com/owner/repo.git
|
|
18
|
+
* - git@github.com:owner/repo.git
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseGitRemoteUrl(remoteUrl: string): GitRepoInfo;
|
|
21
|
+
/** Gets the current git branch name. */
|
|
22
|
+
export declare function getCurrentBranch(): Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createFleetOctokit, getAuthOptions } from './octokit.js';
|
|
2
|
+
export { getGitRepoInfo, getCurrentBranch, parseGitRemoteUrl, type GitRepoInfo, } from './git.js';
|
|
3
|
+
export { resolvePrivateKey } from './resolve-key.js';
|
|
4
|
+
export { cachePlugin } from './cache-plugin.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Octokit } from 'octokit';
|
|
2
|
+
/**
|
|
3
|
+
* Detect auth mode from environment variables and return Octokit options.
|
|
4
|
+
*
|
|
5
|
+
* Priority:
|
|
6
|
+
* 1. GitHub App (GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY[_BASE64] + GITHUB_APP_INSTALLATION_ID)
|
|
7
|
+
* 2. PAT fallback (GITHUB_TOKEN)
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAuthOptions(): ConstructorParameters<typeof Octokit>[0];
|
|
10
|
+
/** Create a new authenticated Octokit instance with caching. */
|
|
11
|
+
export declare function createFleetOctokit(): InstanceType<typeof Octokit>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a private key from environment variable input.
|
|
3
|
+
*
|
|
4
|
+
* Accepts two formats:
|
|
5
|
+
* 1. Raw PEM (with real newlines or literal \n strings)
|
|
6
|
+
* 2. Base64-encoded PEM (`base64 < key.pem | tr -d '\n'`)
|
|
7
|
+
*
|
|
8
|
+
* @param base64Value - GITHUB_APP_PRIVATE_KEY_BASE64
|
|
9
|
+
* @param rawValue - GITHUB_APP_PRIVATE_KEY
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolvePrivateKey(base64Value: string | undefined, rawValue: string | undefined): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Analyze domain events */
|
|
2
|
+
export type AnalyzeEvent = {
|
|
3
|
+
type: 'analyze:start';
|
|
4
|
+
owner: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
goalCount: number;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'analyze:goal:start';
|
|
9
|
+
file: string;
|
|
10
|
+
index: number;
|
|
11
|
+
total: number;
|
|
12
|
+
milestone?: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'analyze:milestone:resolved';
|
|
15
|
+
title: string;
|
|
16
|
+
id: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'analyze:context:fetched';
|
|
19
|
+
openIssues: number;
|
|
20
|
+
closedIssues: number;
|
|
21
|
+
prs: number;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'analyze:session:dispatching';
|
|
24
|
+
goal: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'analyze:session:started';
|
|
27
|
+
id: string;
|
|
28
|
+
goal: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'analyze:session:failed';
|
|
31
|
+
goal: string;
|
|
32
|
+
error: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'analyze:done';
|
|
35
|
+
sessionsStarted: number;
|
|
36
|
+
goalsProcessed: number;
|
|
37
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Configure domain events */
|
|
2
|
+
export type ConfigureEvent = {
|
|
3
|
+
type: 'configure:start';
|
|
4
|
+
resource: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'configure:label:created';
|
|
9
|
+
name: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'configure:label:exists';
|
|
12
|
+
name: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'configure:secret:uploading';
|
|
15
|
+
name: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'configure:secret:uploaded';
|
|
18
|
+
name: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'configure:done';
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Dispatch domain events */
|
|
2
|
+
export type DispatchEvent = {
|
|
3
|
+
type: 'dispatch:start';
|
|
4
|
+
milestone: string;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'dispatch:scanning';
|
|
7
|
+
} | {
|
|
8
|
+
type: 'dispatch:found';
|
|
9
|
+
count: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'dispatch:issue:dispatching';
|
|
12
|
+
number: number;
|
|
13
|
+
title: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'dispatch:issue:dispatched';
|
|
16
|
+
number: number;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'dispatch:issue:skipped';
|
|
20
|
+
number: number;
|
|
21
|
+
reason: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'dispatch:done';
|
|
24
|
+
dispatched: number;
|
|
25
|
+
skipped: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { InitEvent } from './init.js';
|
|
2
|
+
export type { AnalyzeEvent } from './analyze.js';
|
|
3
|
+
export type { MergeEvent } from './merge.js';
|
|
4
|
+
export type { DispatchEvent } from './dispatch.js';
|
|
5
|
+
export type { ConfigureEvent } from './configure.js';
|
|
6
|
+
export type { ErrorEvent } from './error.js';
|
|
7
|
+
import type { InitEvent } from './init.js';
|
|
8
|
+
import type { AnalyzeEvent } from './analyze.js';
|
|
9
|
+
import type { MergeEvent } from './merge.js';
|
|
10
|
+
import type { DispatchEvent } from './dispatch.js';
|
|
11
|
+
import type { ConfigureEvent } from './configure.js';
|
|
12
|
+
import type { ErrorEvent } from './error.js';
|
|
13
|
+
/** All possible fleet events */
|
|
14
|
+
export type FleetEvent = InitEvent | AnalyzeEvent | MergeEvent | DispatchEvent | ConfigureEvent | ErrorEvent;
|
|
15
|
+
/** Emitter function signature — handlers call this to emit events */
|
|
16
|
+
export type FleetEmitter = (event: FleetEvent) => void;
|