MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / agenticToolGuidance

Function agenticToolGuidance

packages/core/src/agent.ts:483–538  ·  view source on GitHub ↗
(input: {
  inspectWorkspace: boolean;
  featureProfile: PromptFeatureProfile;
  currentDesignName?: string | undefined;
})

Source from the content-addressed store, hash-verified

481}
482
483function agenticToolGuidance(input: {
484 inspectWorkspace: boolean;
485 featureProfile: PromptFeatureProfile;
486 currentDesignName?: string | undefined;
487}): string {
488 const titleStep = isAutoDesignName(input.currentDesignName)
489 ? '1. The current design title is still auto-generated. Call `set_title` once as the first tool call, before `set_todos`, `view`, `scaffold`, or file edits. Use a 2-5 word title that describes what is being designed.'
490 : '1. For a fresh design, call `set_title` once. For continuation or existing-source turns, do not call `set_title` unless the user explicitly asks to rename or pivot to a new artifact.';
491 const tweakStep = explicitDisabled(input.featureProfile.tweaks)
492 ? `${input.inspectWorkspace ? '6' : '5'}. Do not call \`tweaks()\` unless the user explicitly asks for controls later.`
493 : featureModeValue(input.featureProfile.tweaks) === 'enabled'
494 ? `${input.inspectWorkspace ? '6' : '5'}. Create 2-5 high-leverage EDITMODE controls, then call \`tweaks()\`.`
495 : `${input.inspectWorkspace ? '6' : '5'}. Decide agentically whether \`tweaks()\` would materially improve iteration; do not rely on harness guesses.`;
496 const requiredSteps = [
497 titleStep,
498 '2. For multi-step or ambiguous work, call `set_todos` early with a short checklist. Do not delay a ready file mutation solely to add todos.',
499 '3. Load optional resources explicitly before relying on them. Use `skill(name)` for method guidance. When the request matches an available frame, shell, primitive, deck, report, or starter, call `scaffold({kind, destPath})` before writing the primary artifact; do not substitute a virtual `frames/*` or `skills/*` view for scaffolded workspace source.',
500 ...(input.inspectWorkspace
501 ? [
502 '4. When the workspace brief says files or reference materials are present, call `inspect_workspace` before editing, then `view` the specific files you need.',
503 ]
504 : []),
505 `${input.inspectWorkspace ? '5' : '4'}. Match the workspace files to the request. For visual/web work, write/edit the primary preview source at \`${DEFAULT_SOURCE_ENTRY}\`; for document-first work, create the requested Markdown/handoff file without inventing a visual shell.`,
506 tweakStep,
507 `${input.inspectWorkspace ? '7' : '6'}. Call \`preview(path)\` for previewable HTML/JSX/TSX files after the final mutation, then call \`done(path)\` as the final self-check. If done reports errors, fix and retry, but stop after ${MAX_DONE_ERROR_ROUNDS} error rounds.`,
508 ];
509 return [
510 '## Workspace output contract',
511 '',
512 '- The workspace filesystem is the deliverable. Chat text is never the artifact.',
513 `- For visual/web deliverables, write the primary design source to \`${DEFAULT_SOURCE_ENTRY}\` with \`str_replace_based_edit_tool\`.`,
514 '- Multi-deliverable packages are allowed when useful: preview source, DESIGN.md, Markdown handoff docs, data files, and local assets can all belong to one design.',
515 '- For document-first requests such as design briefs, content outlines, or handoff notes, create the requested `.md` file directly and skip `App.jsx` unless a visual preview is also useful.',
516 '- Prefer progressive generation when it is natural: write a coherent first pass, then add sections, data, interactions, and polish in focused edits before previewing.',
517 '- Fresh visual sequence: `set_title` -> optional `set_todos`/`skill` -> required `scaffold` when a matching starter/frame/shell/primitive exists -> `create App.jsx` with a coherent first pass -> focused edits if needed -> `preview(App.jsx)`.',
518 '- Fresh document sequence: `set_title` -> optional `set_todos`/`skill` -> create the requested document file -> `done(path)` self-check.',
519 '- Do not call `preview` while a previewable artifact is still only a scaffold, loading state, skeleton, placeholder, or empty lower section. Preview should represent a coherent first pass unless the user explicitly asked for a loading-state design.',
520 '- Existing-source sequence: optional `set_todos` -> `inspect_workspace` when available -> `view` the source -> `str_replace`/`insert`. Do not edit an existing source from memory, and do not rebuild unless the user explicitly asks.',
521 '- If the design is still named `Untitled design` or `Untitled design N`, naming is not optional: call `set_title` before other work, even when a scaffold or reference source already exists.',
522 '- Use `create` for new files; follow-up edits use `view`, `str_replace`, or `insert`.',
523 '- Do not emit `<artifact>` tags, fenced source blocks, raw HTML/JSX/CSS, or HTML wrappers in chat.',
524 '- Local workspace assets and scaffolded files are allowed. External scripts remain restricted by the base output rules.',
525 '- Interleave major tool groups with one short assistant progress sentence: what you are about to inspect/write/preview/fix, or what the preview showed. Keep it under 18 words and do not reveal hidden reasoning.',
526 '',
527 '## Tool loop',
528 '',
529 ...requiredSteps,
530 '',
531 '## File-edit discipline',
532 '',
533 '- Keep `old_str` small and unique. Large replacements waste context and are fragile.',
534 '- For existing files, call `view` in the same run before `str_replace` or `insert`; use the latest viewed text, not memory.',
535 '- A complete first `create` is acceptable when the target file is ready. Keep follow-up edits focused so they remain reliable.',
536 '- Never view just to check whether an edit succeeded; the tool reports failures.',
537 ].join('\n');
538}
539
540const IMAGE_ASSET_TOOL_GUIDANCE = [

Callers 1

generateViaAgentFunction · 0.85

Calls 3

isAutoDesignNameFunction · 0.85
explicitDisabledFunction · 0.85
featureModeValueFunction · 0.85

Tested by

no test coverage detected