refactor(rebrand): rename & rebrand CI → CIAgent across all source and test files
- Type renames: CIConfig → CIAgentConfig, DEFAULT_CI_CONFIG → DEFAULT_CIAGENT_CONFIG - Type renames: CiMetadata → CIAgentMetadata, ParsedCiCommit → ParsedCIAgentCommit - Function renames: initCI → initCIAgent, isCIInitialized → isCIAgentInitialized - Function renames: extractCiBlock → extractCIAgentBlock, parseCiBlock → parseCIAgentBlock - Class renames: CiFiles → CIAgentFiles - Import paths: ci-files.js → ciagent-files.js - Directory paths: .ci/ → .ciagent/ across all source and test files - Check names: ".ci directory exists" → ".ciagent directory exists" - Check names: "CI config valid" → "CIAgent config valid" - Temp dir names: ci-*-test- → ciagent-*-test- - CLI examples: "ci init" → "ciagent init" - Fix deepMerge infinite recursion bug in config.ts - ---ci---/---/ci--- block markers preserved unchanged - All 31 test suites, 370 tests passing ---ci--- phase: 1 milestone: v0.5 plan: 07 task: 07-01-01 status: execute ---/ci---
This commit is contained in:
+37
-37
@@ -1,45 +1,45 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import * as os from "node:os";
|
||||
import { initCI, loadConfig, saveConfig, isCIInitialized, ensureCIDir } from "../core/config.js";
|
||||
import { DEFAULT_CI_CONFIG } from "../types/config.js";
|
||||
import { initCIAgent, loadConfig, saveConfig, isCIAgentInitialized, ensureCIDir } from "../core/config.js";
|
||||
import { DEFAULT_CIAGENT_CONFIG } from "../types/config.js";
|
||||
|
||||
describe("CI Config", () => {
|
||||
describe("CIAgent Config", () => {
|
||||
let tempDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ci-config-test-"));
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ciagent-config-test-"));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe("initCI", () => {
|
||||
it("initializes a new CI project with default config", () => {
|
||||
const config = initCI(tempDir);
|
||||
describe("initCIAgent", () => {
|
||||
it("initializes a new CIAgent project with default config", () => {
|
||||
const config = initCIAgent(tempDir);
|
||||
expect(config.autonomy.level).toBe("full");
|
||||
expect(isCIInitialized(tempDir)).toBe(true);
|
||||
expect(isCIAgentInitialized(tempDir)).toBe(true);
|
||||
});
|
||||
|
||||
it("initializes with custom config merged on top of defaults", () => {
|
||||
const config = initCI(tempDir, {
|
||||
autonomy: { ...DEFAULT_CI_CONFIG.autonomy, level: "guided" },
|
||||
const config = initCIAgent(tempDir, {
|
||||
autonomy: { ...DEFAULT_CIAGENT_CONFIG.autonomy, level: "guided" },
|
||||
});
|
||||
expect(config.autonomy.level).toBe("guided");
|
||||
expect(config.autonomy.clarify_budget).toBe(10);
|
||||
expect(config.model_profile).toBe("quality");
|
||||
});
|
||||
|
||||
it("creates .ci/ directory structure", () => {
|
||||
initCI(tempDir);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ci"))).toBe(true);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ci", "config.json"))).toBe(true);
|
||||
it("creates .ciagent/ directory structure", () => {
|
||||
initCIAgent(tempDir);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ciagent"))).toBe(true);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ciagent", "config.json"))).toBe(true);
|
||||
});
|
||||
|
||||
it("deep merges nested config", () => {
|
||||
const config = initCI(tempDir, {
|
||||
autonomy: { ...DEFAULT_CI_CONFIG.autonomy, level: "supervised" },
|
||||
const config = initCIAgent(tempDir, {
|
||||
autonomy: { ...DEFAULT_CIAGENT_CONFIG.autonomy, level: "supervised" },
|
||||
});
|
||||
expect(config.autonomy.level).toBe("supervised");
|
||||
expect(config.autonomy.max_revision_iterations).toBe(3);
|
||||
@@ -47,7 +47,7 @@ describe("CI Config", () => {
|
||||
});
|
||||
|
||||
it("initializes with project slug", () => {
|
||||
const config = initCI(tempDir, undefined, "task-api", "Task API");
|
||||
const config = initCIAgent(tempDir, undefined, "task-api", "Task API");
|
||||
expect(config.projects).toHaveLength(1);
|
||||
expect(config.projects[0].slug).toBe("task-api");
|
||||
expect(config.projects[0].name).toBe("Task API");
|
||||
@@ -56,20 +56,20 @@ describe("CI Config", () => {
|
||||
});
|
||||
|
||||
it("does not re-add existing project slug", () => {
|
||||
initCI(tempDir, undefined, "task-api", "Task API");
|
||||
const config = initCI(tempDir, undefined, "task-api", "Task API V2");
|
||||
initCIAgent(tempDir, undefined, "task-api", "Task API");
|
||||
const config = initCIAgent(tempDir, undefined, "task-api", "Task API V2");
|
||||
expect(config.projects).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("defaults projects and active_project when no slug provided", () => {
|
||||
const config = initCI(tempDir);
|
||||
const config = initCIAgent(tempDir);
|
||||
expect(config.projects).toEqual([]);
|
||||
expect(config.active_project).toBe("");
|
||||
});
|
||||
|
||||
it("preserves existing projects when adding new one", () => {
|
||||
const config1 = initCI(tempDir, undefined, "task-api", "Task API");
|
||||
const config2 = initCI(tempDir, {
|
||||
const config1 = initCIAgent(tempDir, undefined, "task-api", "Task API");
|
||||
const config2 = initCIAgent(tempDir, {
|
||||
...config1,
|
||||
projects: [...config1.projects, { slug: "auth-svc", name: "Auth Service" }],
|
||||
}, "auth-svc", "Auth Service");
|
||||
@@ -81,11 +81,11 @@ describe("CI Config", () => {
|
||||
describe("loadConfig", () => {
|
||||
it("returns default config when no config file exists", () => {
|
||||
const config = loadConfig(tempDir);
|
||||
expect(config).toEqual(DEFAULT_CI_CONFIG);
|
||||
expect(config).toEqual(DEFAULT_CIAGENT_CONFIG);
|
||||
});
|
||||
|
||||
it("loads and deep merges config from file", () => {
|
||||
initCI(tempDir, { autonomy: { ...DEFAULT_CI_CONFIG.autonomy, decision_confidence_threshold: 0.85 } });
|
||||
initCIAgent(tempDir, { autonomy: { ...DEFAULT_CIAGENT_CONFIG.autonomy, decision_confidence_threshold: 0.85 } });
|
||||
const config = loadConfig(tempDir);
|
||||
expect(config.autonomy.decision_confidence_threshold).toBe(0.85);
|
||||
expect(config.autonomy.level).toBe("full");
|
||||
@@ -93,7 +93,7 @@ describe("CI Config", () => {
|
||||
});
|
||||
|
||||
it("preserves nested objects that are not overridden", () => {
|
||||
initCI(tempDir, { git: { ...DEFAULT_CI_CONFIG.git, auto_push: true } });
|
||||
initCIAgent(tempDir, { git: { ...DEFAULT_CIAGENT_CONFIG.git, auto_push: true } });
|
||||
const config = loadConfig(tempDir);
|
||||
expect(config.git.auto_push).toBe(true);
|
||||
expect(config.git.auto_commit).toBe(true);
|
||||
@@ -101,7 +101,7 @@ describe("CI Config", () => {
|
||||
});
|
||||
|
||||
it("loads projects array from config", () => {
|
||||
initCI(tempDir, undefined, "task-api", "Task API");
|
||||
initCIAgent(tempDir, undefined, "task-api", "Task API");
|
||||
const config = loadConfig(tempDir);
|
||||
expect(config.projects).toHaveLength(1);
|
||||
expect(config.active_project).toBe("task-api");
|
||||
@@ -112,8 +112,8 @@ describe("CI Config", () => {
|
||||
it("saves and reloads config correctly", () => {
|
||||
ensureCIDir(tempDir);
|
||||
const customConfig = {
|
||||
...DEFAULT_CI_CONFIG,
|
||||
autonomy: { ...DEFAULT_CI_CONFIG.autonomy, level: "guided" as const },
|
||||
...DEFAULT_CIAGENT_CONFIG,
|
||||
autonomy: { ...DEFAULT_CIAGENT_CONFIG.autonomy, level: "guided" as const },
|
||||
};
|
||||
saveConfig(tempDir, customConfig);
|
||||
const loaded = loadConfig(tempDir);
|
||||
@@ -123,7 +123,7 @@ describe("CI Config", () => {
|
||||
it("saves and reloads config with projects", () => {
|
||||
ensureCIDir(tempDir);
|
||||
const config = {
|
||||
...DEFAULT_CI_CONFIG,
|
||||
...DEFAULT_CIAGENT_CONFIG,
|
||||
projects: [{ slug: "my-app", name: "My App", default: true }],
|
||||
active_project: "my-app",
|
||||
};
|
||||
@@ -134,27 +134,27 @@ describe("CI Config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isCIInitialized", () => {
|
||||
describe("isCIAgentInitialized", () => {
|
||||
it("returns false for uninitialized directory", () => {
|
||||
expect(isCIInitialized(tempDir)).toBe(false);
|
||||
expect(isCIAgentInitialized(tempDir)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true after initCI", () => {
|
||||
initCI(tempDir);
|
||||
expect(isCIInitialized(tempDir)).toBe(true);
|
||||
it("returns true after initCIAgent", () => {
|
||||
initCIAgent(tempDir);
|
||||
expect(isCIAgentInitialized(tempDir)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ensureCIDir", () => {
|
||||
it("creates .ci directory", () => {
|
||||
it("creates .ciagent directory", () => {
|
||||
ensureCIDir(tempDir);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ci"))).toBe(true);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ciagent"))).toBe(true);
|
||||
});
|
||||
|
||||
it("is idempotent", () => {
|
||||
ensureCIDir(tempDir);
|
||||
ensureCIDir(tempDir);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ci"))).toBe(true);
|
||||
expect(fs.existsSync(path.join(tempDir, ".ciagent"))).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user