MCPcopy
hub / github.com/codeaashu/claude-code / toApiView

Function toApiView

src/commands/context/context.tsx:18–29  ·  view source on GitHub ↗

* Apply the same context transforms query.ts does before the API call, so * /context shows what the model actually sees rather than the REPL's raw * history. Without projectView the token count overcounts by however much * was collapsed — user sees "180k, 3 spans collapsed" when the API sees 120k

(messages: Message[])

Source from the content-addressed store, hash-verified

16 * was collapsed — user sees "180k, 3 spans collapsed" when the API sees 120k.
17 */
18function toApiView(messages: Message[]): Message[] {
19 let view = getMessagesAfterCompactBoundary(messages);
20 if (feature('CONTEXT_COLLAPSE')) {
21 /* eslint-disable @typescript-eslint/no-require-imports */
22 const {
23 projectView
24 } = require('../../services/contextCollapse/operations.js') as typeof import('../../services/contextCollapse/operations.js');
25 /* eslint-enable @typescript-eslint/no-require-imports */
26 view = projectView(view);
27 }
28 return view;
29}
30export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext): Promise<React.ReactNode> {
31 const {
32 messages,

Callers 1

callFunction · 0.85

Calls 2

featureFunction · 0.85

Tested by

no test coverage detected