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:
+25
-25
@@ -1,11 +1,11 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { CIConfig, DEFAULT_CI_CONFIG } from "../types/config.js";
|
||||
import { CIAgentConfig, DEFAULT_CIAGENT_CONFIG } from "../types/config.js";
|
||||
|
||||
const CI_DIR = ".ci";
|
||||
const CI_DIR = ".ciagent";
|
||||
const CONFIG_FILE = "config.json";
|
||||
|
||||
export function getCIConfigPath(projectPath: string): string {
|
||||
export function getCIAgentConfigPath(projectPath: string): string {
|
||||
return path.join(projectPath, CI_DIR, CONFIG_FILE);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export function ensureCIDir(projectPath: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function deepMerge(base: CIConfig, override: Record<string, unknown>): CIConfig {
|
||||
function deepMerge(base: CIAgentConfig, override: Record<string, unknown>): CIAgentConfig {
|
||||
const result = { ...base } as Record<string, unknown>;
|
||||
for (const key of Object.keys(override)) {
|
||||
const baseVal = result[key];
|
||||
@@ -30,43 +30,43 @@ function deepMerge(base: CIConfig, override: Record<string, unknown>): CIConfig
|
||||
overrideVal && typeof overrideVal === "object" && !Array.isArray(overrideVal)
|
||||
) {
|
||||
result[key] = deepMerge(
|
||||
baseVal as unknown as CIConfig,
|
||||
baseVal as unknown as CIAgentConfig,
|
||||
overrideVal as Record<string, unknown>
|
||||
) as unknown;
|
||||
} else if (overrideVal !== undefined) {
|
||||
result[key] = overrideVal;
|
||||
}
|
||||
}
|
||||
return result as unknown as CIConfig;
|
||||
return result as unknown as CIAgentConfig;
|
||||
}
|
||||
|
||||
export function loadConfig(projectPath: string): CIConfig {
|
||||
const configPath = getCIConfigPath(projectPath);
|
||||
export function loadConfig(projectPath: string): CIAgentConfig {
|
||||
const configPath = getCIAgentConfigPath(projectPath);
|
||||
if (!fs.existsSync(configPath)) {
|
||||
return { ...DEFAULT_CI_CONFIG };
|
||||
return { ...DEFAULT_CIAGENT_CONFIG };
|
||||
}
|
||||
const raw = fs.readFileSync(configPath, "utf-8");
|
||||
const parsed = JSON.parse(raw);
|
||||
return deepMerge(DEFAULT_CI_CONFIG, parsed);
|
||||
return deepMerge(DEFAULT_CIAGENT_CONFIG, parsed);
|
||||
}
|
||||
|
||||
export function saveConfig(projectPath: string, config: CIConfig): void {
|
||||
export function saveConfig(projectPath: string, config: CIAgentConfig): void {
|
||||
ensureCIDir(projectPath);
|
||||
const configPath = getCIConfigPath(projectPath);
|
||||
const configPath = getCIAgentConfigPath(projectPath);
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
||||
}
|
||||
|
||||
export function isCIInitialized(projectPath: string): boolean {
|
||||
export function isCIAgentInitialized(projectPath: string): boolean {
|
||||
const ciDir = getCIDir(projectPath);
|
||||
const configPath = getCIConfigPath(projectPath);
|
||||
const configPath = getCIAgentConfigPath(projectPath);
|
||||
return fs.existsSync(ciDir) && fs.existsSync(configPath);
|
||||
}
|
||||
|
||||
export function initCI(projectPath: string, config?: Partial<CIConfig>, projectSlug?: string, projectName?: string): CIConfig {
|
||||
export function initCIAgent(projectPath: string, config?: Partial<CIAgentConfig>, projectSlug?: string, projectName?: string): CIAgentConfig {
|
||||
ensureCIDir(projectPath);
|
||||
|
||||
let projects = config?.projects || DEFAULT_CI_CONFIG.projects;
|
||||
let activeProject = config?.active_project || DEFAULT_CI_CONFIG.active_project;
|
||||
let projects = config?.projects || DEFAULT_CIAGENT_CONFIG.projects;
|
||||
let activeProject = config?.active_project || DEFAULT_CIAGENT_CONFIG.active_project;
|
||||
|
||||
if (projectSlug) {
|
||||
if (!projects.some((p) => p.slug === projectSlug)) {
|
||||
@@ -75,20 +75,20 @@ export function initCI(projectPath: string, config?: Partial<CIConfig>, projectS
|
||||
activeProject = projectSlug;
|
||||
}
|
||||
|
||||
const fullConfig: CIConfig = {
|
||||
...DEFAULT_CI_CONFIG,
|
||||
const fullConfig: CIAgentConfig = {
|
||||
...DEFAULT_CIAGENT_CONFIG,
|
||||
...config,
|
||||
projects,
|
||||
active_project: activeProject,
|
||||
autonomy: { ...DEFAULT_CI_CONFIG.autonomy, ...config?.autonomy },
|
||||
autonomy: { ...DEFAULT_CIAGENT_CONFIG.autonomy, ...config?.autonomy },
|
||||
parallelization: {
|
||||
...DEFAULT_CI_CONFIG.parallelization,
|
||||
...DEFAULT_CIAGENT_CONFIG.parallelization,
|
||||
...config?.parallelization,
|
||||
},
|
||||
verification: { ...DEFAULT_CI_CONFIG.verification, ...config?.verification },
|
||||
security: { ...DEFAULT_CI_CONFIG.security, ...config?.security },
|
||||
git: { ...DEFAULT_CI_CONFIG.git, ...config?.git },
|
||||
backend: { ...DEFAULT_CI_CONFIG.backend, ...config?.backend },
|
||||
verification: { ...DEFAULT_CIAGENT_CONFIG.verification, ...config?.verification },
|
||||
security: { ...DEFAULT_CIAGENT_CONFIG.security, ...config?.security },
|
||||
git: { ...DEFAULT_CIAGENT_CONFIG.git, ...config?.git },
|
||||
backend: { ...DEFAULT_CIAGENT_CONFIG.backend, ...config?.backend },
|
||||
};
|
||||
saveConfig(projectPath, fullConfig);
|
||||
return fullConfig;
|
||||
|
||||
Reference in New Issue
Block a user