add more codex logic

This commit is contained in:
Shawn Morreau
2025-11-12 19:22:48 -05:00
parent 71698d3e07
commit 7aaebe9584
9 changed files with 948 additions and 907 deletions
+27 -1
View File
@@ -1,7 +1,9 @@
import type { AgentName } from "../main.ts";
import { log } from "./cli.ts";
import type { RepoContext } from "./github.ts";
export interface RepoSettings {
defaultAgent: string | null;
defaultAgent: AgentName | null;
webAccessLevel: "full_access" | "limited";
webAccessAllowTrusted: boolean;
webAccessDomains: string;
@@ -21,6 +23,30 @@ export const DEFAULT_REPO_SETTINGS: RepoSettings = {
workflows: [],
};
/**
* Fetch repository settings with fallback handling
* Uses API if token is available, otherwise returns defaults
*/
export async function fetchRepoSettings({
token,
repoContext,
isFallbackToken,
}: {
token: string;
repoContext: RepoContext;
isFallbackToken: boolean;
}): Promise<RepoSettings> {
if (isFallbackToken) {
log.info("Using default repository settings (app not installed)");
return DEFAULT_REPO_SETTINGS;
}
log.info("Fetching repository settings...");
const settings = await getRepoSettings(token, repoContext);
log.info("Repository settings fetched");
return settings;
}
/**
* Fetch repository settings from the Pullfrog API with fallback to defaults
* Returns agent, permissions, and workflows (excludes triggers)
+18
View File
@@ -3,6 +3,8 @@
*/
import * as core from "@actions/core";
import { spawnSync } from "child_process";
import { existsSync } from "fs";
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
const isDebugEnabled = process.env.LOG_LEVEL === "debug";
@@ -262,3 +264,19 @@ export const log = {
*/
endGroup,
};
/**
* Finds a CLI executable path by checking if it's installed globally
* @param name The name of the CLI executable to find
* @returns The path to the CLI executable, or null if not found
*/
export function findCliPath(name: string): string | null {
const result = spawnSync("which", [name], { encoding: "utf-8" });
if (result.status === 0 && result.stdout) {
const cliPath = result.stdout.trim();
if (cliPath && existsSync(cliPath)) {
return cliPath;
}
}
return null;
}