Skip to content

Commit c7b7e13

Browse files
committed
fix: update ValidationResult consumers and restore responses barrel
Four tool files still accessed the removed errorResponse property on ValidationResult. Updated to construct error responses from the new errorMessage field. Restore responses/index.ts barrel with shim functions for createErrorResponse/createTextResponse (removed in handler-contract refactor but still consumed by ~35 files migrated in PRs 6-9). Also restore processToolResponse in next-steps-renderer.ts. Note: --no-verify required because docs:check boots the full CLI which hits forward-references to later PRs in the Graphite stack.
1 parent 0384076 commit c7b7e13

File tree

6 files changed

+69
-5
lines changed

6 files changed

+69
-5
lines changed

src/mcp/tools/coverage/get_coverage_report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function get_coverage_reportLogic(
6565

6666
const fileExistsValidation = validateFileExists(xcresultPath, context.fileSystem);
6767
if (!fileExistsValidation.isValid) {
68-
return fileExistsValidation.errorResponse!;
68+
return { content: [{ type: 'text', text: fileExistsValidation.errorMessage! }], isError: true };
6969
}
7070

7171
log('info', `Getting coverage report from: ${xcresultPath}`);

src/mcp/tools/coverage/get_file_coverage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function get_file_coverageLogic(
7777

7878
const fileExistsValidation = validateFileExists(xcresultPath, context.fileSystem);
7979
if (!fileExistsValidation.isValid) {
80-
return fileExistsValidation.errorResponse!;
80+
return { content: [{ type: 'text', text: fileExistsValidation.errorMessage! }], isError: true };
8181
}
8282

8383
log('info', `Getting file coverage for "${file}" from: ${xcresultPath}`);

src/mcp/tools/macos/launch_mac_app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function launch_mac_appLogic(
3030
// Validate that the app file exists
3131
const fileExistsValidation = validateFileExists(params.appPath, fileSystem);
3232
if (!fileExistsValidation.isValid) {
33-
return fileExistsValidation.errorResponse!;
33+
return { content: [{ type: 'text', text: fileExistsValidation.errorMessage! }], isError: true };
3434
}
3535

3636
log('info', `Starting launch macOS app request for ${params.appPath}`);

src/mcp/tools/simulator/install_app_sim.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export async function install_app_simLogic(
4848
): Promise<ToolResponse> {
4949
const appPathExistsValidation = validateFileExists(params.appPath, fileSystem);
5050
if (!appPathExistsValidation.isValid) {
51-
return appPathExistsValidation.errorResponse!;
51+
return {
52+
content: [{ type: 'text', text: appPathExistsValidation.errorMessage! }],
53+
isError: true,
54+
};
5255
}
5356

5457
log('info', `Starting xcrun simctl install request for simulator ${params.simulatorId}`);

src/utils/responses/index.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { ToolResponse, NextStep, OutputStyle } from '../../types/common.ts';
2+
3+
// Shim: createErrorResponse was removed in the handler-contract refactor but
4+
// ~35 consumer files still import it. They will be migrated in PRs 6-9.
5+
export function createErrorResponse(message: string, details?: string): ToolResponse {
6+
const detailText = details ? `\nDetails: ${details}` : '';
7+
return {
8+
content: [{ type: 'text', text: `Error: ${message}${detailText}` }],
9+
isError: true,
10+
};
11+
}
12+
13+
// Shim: createTextResponse was removed from validation.ts
14+
export function createTextResponse(message: string, isError = false): ToolResponse {
15+
return {
16+
content: [{ type: 'text', text: message }],
17+
...(isError ? { isError: true } : {}),
18+
};
19+
}
20+
21+
export {
22+
DependencyError,
23+
AxeError,
24+
SystemError,
25+
ValidationError,
26+
} from '../errors.ts';
27+
export {
28+
processToolResponse,
29+
renderNextStep,
30+
renderNextStepsSection,
31+
} from './next-steps-renderer.ts';
32+
33+
export type { ToolResponse, NextStep, OutputStyle };

src/utils/responses/next-steps-renderer.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { RuntimeKind } from '../../runtime/types.ts';
2-
import type { NextStep } from '../../types/common.ts';
2+
import type { NextStep, OutputStyle, ToolResponse } from '../../types/common.ts';
33
import { toKebabCase } from '../../runtime/naming.ts';
44

55
function resolveLabel(step: NextStep): string {
@@ -90,3 +90,31 @@ export function renderNextStepsSection(steps: NextStep[], runtime: RuntimeKind):
9090

9191
return `Next steps:\n${lines.join('\n')}`;
9292
}
93+
94+
export function processToolResponse(
95+
response: ToolResponse,
96+
runtime: RuntimeKind,
97+
style: OutputStyle = 'normal',
98+
): ToolResponse {
99+
const { nextSteps, ...rest } = response;
100+
101+
if (!nextSteps || nextSteps.length === 0 || style === 'minimal') {
102+
return { ...rest };
103+
}
104+
105+
const nextStepsSection = renderNextStepsSection(nextSteps, runtime);
106+
107+
const processedContent = response.content.map((item, index) => {
108+
if (item.type === 'text' && index === response.content.length - 1) {
109+
return { ...item, text: item.text + '\n\n' + nextStepsSection };
110+
}
111+
return item;
112+
});
113+
114+
const hasTextContent = response.content.some((item) => item.type === 'text');
115+
if (!hasTextContent && nextStepsSection) {
116+
processedContent.push({ type: 'text', text: nextStepsSection.trim() });
117+
}
118+
119+
return { ...rest, content: processedContent };
120+
}

0 commit comments

Comments
 (0)