MCPcopy Create free account
hub / github.com/cloudflare/agents / plannedContentForInstruction

Function plannedContentForInstruction

packages/shell/src/helpers.ts:426–452  ·  view source on GitHub ↗
(
  instruction: StateEditInstruction,
  previous: string | null
)

Source from the content-addressed store, hash-verified

424}
425
426async function plannedContentForInstruction(
427 instruction: StateEditInstruction,
428 previous: string | null
429): Promise<string> {
430 if (instruction.kind === "write") {
431 return instruction.content;
432 }
433
434 if (instruction.kind === "writeJson") {
435 return stringifyJsonFileContent(
436 instruction.value,
437 instruction.path,
438 instruction.options?.spaces
439 );
440 }
441
442 if (previous === null) {
443 throw new Error(`ENOENT: no such file: ${instruction.path}`);
444 }
445
446 return replaceTextContent(
447 previous,
448 instruction.search,
449 instruction.replacement,
450 instruction.options
451 ).content;
452}
453
454function createTextMatcher(query: string, options: StateSearchOptions): RegExp {
455 if (query.length === 0) {

Callers 1

planTextEditsFunction · 0.85

Calls 2

stringifyJsonFileContentFunction · 0.85
replaceTextContentFunction · 0.85

Tested by

no test coverage detected