Skip to content

Commit b13005e

Browse files
sotateksotatek
authored andcommitted
refactor: remove docsDir from InitTemplateConfig, use paths.docs only
Since the feature hasn't shipped yet, there's no need for backward compatibility with docsDir in templates. This eliminates the dual-schema confusion and simplifies the fallback chain.
1 parent 953e00c commit b13005e

3 files changed

Lines changed: 4 additions & 41 deletions

File tree

packages/cli/src/__tests__/lib/InitTemplate.test.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ environments:
8888
);
8989
});
9090

91-
it('loads template with custom docsDir', async () => {
92-
mockFs.pathExists.mockResolvedValue(true as never);
93-
mockFs.readFile.mockResolvedValue(`
94-
docsDir: .ai-docs
95-
environments:
96-
- claude
97-
phases:
98-
- requirements
99-
` as never);
100-
101-
const result = await loadInitTemplate('/tmp/init.yaml');
102-
103-
expect(result.docsDir).toBe('.ai-docs');
104-
expect(result.environments).toEqual(['claude']);
105-
});
106-
10791
it('loads template with paths.docs config', async () => {
10892
mockFs.pathExists.mockResolvedValue(true as never);
10993
mockFs.readFile.mockResolvedValue(`
@@ -142,23 +126,14 @@ paths:
142126
);
143127
});
144128

145-
it('throws when docsDir is empty string', async () => {
129+
it('rejects docsDir as unknown field', async () => {
146130
mockFs.pathExists.mockResolvedValue(true as never);
147131
mockFs.readFile.mockResolvedValue(`
148-
docsDir: " "
132+
docsDir: .ai-docs
149133
` as never);
150134

151135
await expect(loadInitTemplate('/tmp/init.yaml')).rejects.toThrow(
152-
'"docsDir" must be a non-empty string'
153-
);
154-
});
155-
156-
it('throws when docsDir is not a string', async () => {
157-
mockFs.pathExists.mockResolvedValue(true as never);
158-
mockFs.readFile.mockResolvedValue(JSON.stringify({ docsDir: 123 }) as never);
159-
160-
await expect(loadInitTemplate('/tmp/init.json')).rejects.toThrow(
161-
'"docsDir" must be a non-empty string'
136+
'unknown field(s): docsDir'
162137
);
163138
});
164139

packages/cli/src/commands/init.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ export async function initCommand(options: InitOptions) {
214214
docsDir = options.docsDir.trim();
215215
} else if (templateConfig?.paths?.docs) {
216216
docsDir = templateConfig.paths.docs;
217-
} else if (templateConfig?.docsDir) {
218-
docsDir = templateConfig.docsDir;
219217
}
220218

221219
const phaseTemplateManager = new TemplateManager({ docsDir });

packages/cli/src/lib/InitTemplate.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface InitTemplateSkill {
1111

1212
export interface InitTemplateConfig {
1313
version?: number | string;
14-
docsDir?: string;
1514
paths?: {
1615
docs?: string;
1716
};
@@ -20,7 +19,7 @@ export interface InitTemplateConfig {
2019
skills?: InitTemplateSkill[];
2120
}
2221

23-
const ALLOWED_TEMPLATE_FIELDS = new Set(['version', 'docsDir', 'paths', 'environments', 'phases', 'skills']);
22+
const ALLOWED_TEMPLATE_FIELDS = new Set(['version', 'paths', 'environments', 'phases', 'skills']);
2423

2524
function validationError(templatePath: string, message: string): Error {
2625
return new Error(`Invalid template at ${templatePath}: ${message}`);
@@ -98,15 +97,6 @@ function validateTemplate(raw: unknown, resolvedPath: string): InitTemplateConfi
9897
}
9998
}
10099

101-
if (candidate.docsDir !== undefined) {
102-
if (typeof candidate.docsDir !== 'string' || candidate.docsDir.trim().length === 0) {
103-
throw validationError(resolvedPath, '"docsDir" must be a non-empty string');
104-
}
105-
if (!result.paths?.docs) {
106-
result.docsDir = candidate.docsDir.trim();
107-
}
108-
}
109-
110100
if (candidate.environments !== undefined) {
111101
if (!Array.isArray(candidate.environments)) {
112102
throw validationError(resolvedPath, '"environments" must be an array of environment codes');

0 commit comments

Comments
 (0)