fix: グローバル設定のpieceが解決チェーンで無視されるバグを修正 (#458)

This commit is contained in:
あいやま EIichi Yamazaki 2026-03-03 19:36:34 +09:00 committed by GitHub
parent d2b48fdd92
commit ed16c05160
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 10 deletions

View File

@ -51,15 +51,15 @@ describe('RESOLUTION_REGISTRY defaultValue removal', () => {
}); });
describe('piece', () => { describe('piece', () => {
it('should resolve piece from project config DEFAULT_PROJECT_CONFIG when not explicitly set', () => { it('should resolve piece as undefined when not set in project or global config', () => {
const value = resolveConfigValue(projectDir, 'piece'); const value = resolveConfigValue(projectDir, 'piece');
expect(value).toBe('default'); expect(value).toBeUndefined();
}); });
it('should report source as project when piece comes from DEFAULT_PROJECT_CONFIG', () => { it('should report source as default when piece is not set anywhere', () => {
const result = resolveConfigValueWithSource(projectDir, 'piece'); const result = resolveConfigValueWithSource(projectDir, 'piece');
expect(result.value).toBe('default'); expect(result.value).toBeUndefined();
expect(result.source).toBe('project'); expect(result.source).toBe('default');
}); });
it('should resolve explicit project piece over default', () => { it('should resolve explicit project piece over default', () => {
@ -76,8 +76,8 @@ describe('RESOLUTION_REGISTRY defaultValue removal', () => {
invalidateGlobalConfigCache(); invalidateGlobalConfigCache();
const result = resolveConfigValueWithSource(projectDir, 'piece'); const result = resolveConfigValueWithSource(projectDir, 'piece');
expect(result.value).toBe('default'); expect(result.value).toBe('global-piece');
expect(result.source).toBe('project'); expect(result.source).toBe('global');
}); });
}); });

View File

@ -87,6 +87,8 @@ export interface PersistedGlobalConfig {
logLevel: 'debug' | 'info' | 'warn' | 'error'; logLevel: 'debug' | 'info' | 'warn' | 'error';
provider?: 'claude' | 'codex' | 'opencode' | 'cursor' | 'copilot' | 'mock'; provider?: 'claude' | 'codex' | 'opencode' | 'cursor' | 'copilot' | 'mock';
model?: string; model?: string;
/** Default piece name for new tasks (resolved via config layers: project > global > 'default') */
piece?: string;
observability?: ObservabilityConfig; observability?: ObservabilityConfig;
analytics?: AnalyticsConfig; analytics?: AnalyticsConfig;
/** Directory for shared clones (worktree_dir in config). If empty, uses ../{clone-name} relative to project */ /** Directory for shared clones (worktree_dir in config). If empty, uses ../{clone-name} relative to project */

View File

@ -444,6 +444,8 @@ export const GlobalConfigSchema = z.object({
log_level: z.enum(['debug', 'info', 'warn', 'error']).optional().default('info'), log_level: z.enum(['debug', 'info', 'warn', 'error']).optional().default('info'),
provider: z.enum(['claude', 'codex', 'opencode', 'cursor', 'copilot', 'mock']).optional().default('claude'), provider: z.enum(['claude', 'codex', 'opencode', 'cursor', 'copilot', 'mock']).optional().default('claude'),
model: z.string().optional(), model: z.string().optional(),
/** Default piece name for new tasks */
piece: z.string().optional(),
observability: ObservabilityConfigSchema.optional(), observability: ObservabilityConfigSchema.optional(),
analytics: AnalyticsConfigSchema.optional(), analytics: AnalyticsConfigSchema.optional(),
/** Directory for shared clones (worktree_dir in config). If empty, uses ../{clone-name} relative to project */ /** Directory for shared clones (worktree_dir in config). If empty, uses ../{clone-name} relative to project */

View File

@ -221,6 +221,7 @@ export class GlobalConfigManager {
logLevel: parsed.log_level, logLevel: parsed.log_level,
provider: parsed.provider, provider: parsed.provider,
model: parsed.model, model: parsed.model,
piece: parsed.piece,
observability: parsed.observability ? { observability: parsed.observability ? {
providerEvents: parsed.observability.provider_events, providerEvents: parsed.observability.provider_events,
} : undefined, } : undefined,
@ -289,6 +290,9 @@ export class GlobalConfigManager {
if (config.model) { if (config.model) {
raw.model = config.model; raw.model = config.model;
} }
if (config.piece) {
raw.piece = config.piece;
}
if (config.observability && config.observability.providerEvents !== undefined) { if (config.observability && config.observability.providerEvents !== undefined) {
raw.observability = { raw.observability = {
provider_events: config.observability.providerEvents, provider_events: config.observability.providerEvents,

View File

@ -18,9 +18,7 @@ import { invalidateResolvedConfigCache } from '../resolutionCache.js';
export type { ProjectLocalConfig } from '../types.js'; export type { ProjectLocalConfig } from '../types.js';
/** Default project configuration */ /** Default project configuration */
const DEFAULT_PROJECT_CONFIG: ProjectLocalConfig = { const DEFAULT_PROJECT_CONFIG: ProjectLocalConfig = {};
piece: 'default',
};
const SUBMODULES_ALL = 'all'; const SUBMODULES_ALL = 'all';