Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/src/commands/validate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { resolve } from "node:path";
import { resolveProjectConfig, UserError, validateProjectConfig } from "@openagentpack/sdk";
import { ensureCredentials } from "../credentials.ts";
import { log } from "../logger.ts";

export async function validateCommand(options: { file: string }) {
ensureCredentials();
const configPath = resolve(options.file);
log.info(`Validating ${configPath}...`);
const { config } = await resolveProjectConfig(options.file);
Expand Down
34 changes: 31 additions & 3 deletions packages/cli/tests/unit/cli-contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ vaults:
return configPath;
}

async function runAgents(args: string[], env: Record<string, string> = {}) {
const proc = Bun.spawn([process.execPath, "run", "bin/agents.ts", ...args], {
cwd: REPO_ROOT,
async function runAgents(args: string[], env: Record<string, string> = {}, cwd = REPO_ROOT) {
const entry = cwd === REPO_ROOT ? "bin/agents.ts" : join(REPO_ROOT, "bin/agents.ts");
const proc = Bun.spawn([process.execPath, "run", entry, ...args], {
cwd,
stdout: "pipe",
stderr: "pipe",
env: {
Expand Down Expand Up @@ -430,6 +431,33 @@ test("validate reports reference errors through the core runtime", async () => {
expect(result.stderr).toContain("references unknown environment 'ghost'");
});

test("validate loads .env before resolving provider placeholders", async () => {
const dir = await makeTempDir();
await Bun.write(
join(dir, "agents.yaml"),
`version: "1"

providers:
qoder:
api_key: \${QODER_PAT}

defaults:
provider: qoder

agents:
assistant:
model: ultimate
instructions: "You are helpful."
`,
);
await Bun.write(join(dir, ".env"), "QODER_PAT=test-token\n");

const result = await runAgents(["validate", "--file", "agents.yaml"], { QODER_PAT: "" }, dir);

expect(result.exitCode).toBe(0);
expect(result.stderr).toContain("Configuration is valid");
});

test("models list keeps missing config guidance in the core runtime", async () => {
const result = await runAgents(["models", "list", "--file", "/missing/agents.yaml"]);

Expand Down