feat(prompts): inject code-minimalism discipline into codegen#368
Merged
Conversation
Add CODE_MINIMALISM_DISCIPLINE constant (parallel to the existing protocols) and inject it into the generateCodeForFile and generateModifiedCode system prompts, so the executor codegen layer is told to avoid the common AI over-engineering failure modes: speculative abstractions, defensive code for impossible scenarios (validate only at boundaries), gratuitous comments, and scope creep beyond what the task requires. This is orthogonal to the existing "只修改必要部分" (scope of change) and "保持原有代码风格" (style matching) lines. Learned from the Claude Code agentic prompt's "Doing tasks" minimalism bullets. Prompt-only; no schema/tool-routing/executor/planner changes. Adds prompt-capture tests asserting both codegen system prompts carry the discipline, with one distinct anchor phrase per sub-discipline to keep the assertions robust to copy tweaks. Closes #367 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
代码评审报告: feat(prompts): inject code-minimalism discipline into codegen风险等级: 中 级联分析
问题发现模型未返回可结构化的问题发现;已提取可用的决策字段,原始非契约内容未附在评论中。 行级发现
Karpathy 评审
缺失覆盖
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue Or Context
Closes #367.
Summary
CODE_MINIMALISM_DISCIPLINEconstant topackages/core/src/llm/prompts.ts, parallel to the existingPROGRESSIVE_EXPLORATION_PROTOCOL,EXTERNAL_KNOWLEDGE_PROTOCOL, andSECURITY_DISCIPLINE.generateCodeForFileandgenerateModifiedCode) so generated/modified code avoids the common AI over-engineering failure modes: speculative/premature abstractions, defensive code for impossible scenarios (validate only at system boundaries), gratuitous comments, and scope creep beyond the task.只修改必要部分constrains the scope of a change;保持原有代码风格constrains style matching; neither constrains internal over-engineering.generateCodeForFile(new files) previously had no minimalism guidance at all.Learned from the Claude Code agentic prompt's "Doing tasks" minimalism bullets (
Claude-Code-source/src/constants/prompts.ts:201-203,207-208).Impact Scope
Prompt-only change in
packages/core/src/llm/prompts.ts(new constant) andpackages/core/src/llm/code-generation.ts(two system-prompt injections), plus focused tests. No schema, tool routing, executor contract, or planner changes.GitNexus Impact Summary
impact(generateCodeForFile, upstream)andimpact(generateModifiedCode, upstream)both returned LOW with 0 affected processes and 0 affected modules; system-prompt string append only, signatures/return contracts unchanged.gitnexus detect_changes(scope=unstaged) reported affected_count=0, risk_level=low, zero affected processes; changed symbols limited to the two codegen functions and test helpers.Verification
pnpm --filter @frontagent/core test -- code-generation.test.ts— 13/13 pass (6 system-prompt tests: 2 external-knowledge + 2 security + 2 minimalism).pnpm exec biome checkon the 3 changed files — clean.pnpm quality:precommit(lint + typecheck + test + test:workflows) — green (25 turbo tasks successful, workflows 32/32).gitnexus impact(both functions) +gitnexus detect_changes— LOW, 0 affected processes.Checklist