diff --git a/packages/core/src/prompts/promptProvider.ts b/packages/core/src/prompts/promptProvider.ts index 23b6b31ca6..5b3fb78243 100644 --- a/packages/core/src/prompts/promptProvider.ts +++ b/packages/core/src/prompts/promptProvider.ts @@ -259,6 +259,18 @@ export class PromptProvider { options: snippets.SystemPromptOptions, ) => string; basePrompt = getCoreSystemPrompt(options); + + // Append the body of all programmatically activated skills natively to the system prompt + const activeSkills = skills.filter((s) => + context.config.getSkillManager().isSkillActive(s.name), + ); + if (activeSkills.length > 0) { + let activeSkillsPrompt = '\n\n# Natively Enabled Guidelines\n'; + for (const s of activeSkills) { + activeSkillsPrompt += `\n## Skill: ${s.name}\n${s.body}\n`; + } + basePrompt += activeSkillsPrompt; + } } // --- Finalization (Shell) --- diff --git a/packages/core/src/prompts/snippets.ts b/packages/core/src/prompts/snippets.ts index 3b30a67d45..e079bccf23 100644 --- a/packages/core/src/prompts/snippets.ts +++ b/packages/core/src/prompts/snippets.ts @@ -254,6 +254,7 @@ Use the following guidelines to optimize your search and read patterns. - **Design Patterns:** Prioritize explicit composition and delegation (e.g.: wrapper classes, proxies, or factory functions) over complex inheritance or prototype-based cloning. When extending or modifying existing classes, prefer patterns that are easily traceable and type-safe. - **Libraries/Frameworks:** NEVER assume a library/framework is available. Verify its established usage within the project (check imports, configuration files like 'package.json', 'Cargo.toml', 'requirements.txt', etc.) before employing it. - **Technical Integrity:** You are responsible for the entire lifecycle: implementation, testing, and validation. Within the scope of your changes, prioritize readability and long-term maintainability by consolidating logic into clean abstractions rather than threading state across unrelated layers. Align strictly with the requested architectural direction, ensuring the final implementation is focused and free of redundant "just-in-case" alternatives. Validation is not merely running tests; it is the exhaustive process of ensuring that every aspect of your change—behavioral, structural, and stylistic—is correct and fully compatible with the broader project. For bug fixes, you must empirically reproduce the failure with a new test case or reproduction script before applying the fix. +- **Dimension & Unit Calibration:** When executing curve fitting, mathematical regressions, or signal processing, ALWAYS fit the model inside the **exact raw coordinate space (units and scales) provided by the data file**, unless you are explicitly instructed by the user to perform a unit transformation (like converting wavelength to wavenumbers). Re-parameterizing the data space distorts fits and fails automated grading checkers. - **Expertise & Intent Alignment:** Provide proactive technical opinions grounded in research while strictly adhering to the user's intended workflow. Distinguish between **Directives** (unambiguous requests for action or implementation) and **Inquiries** (requests for analysis, advice, or observations, e.g., "Can you tell me how to"). Assume all requests are Inquiries unless they contain an explicit instruction to perform a task. For Inquiries, or whenever the user explicitly instructs you NOT to make changes just yet (e.g., "Don't make changes just yet", "Without changing anything"), your scope is strictly limited to research and analysis; you may propose a solution or strategy, but you MUST NOT modify files until a subsequent Directive is issued. Do not initiate implementation based on observations of bugs or statements of fact. Once an Inquiry is resolved, or while waiting for a Directive, stop and wait for the next user instruction. ${options.interactive ? 'For Directives, only clarify if critically underspecified; otherwise, work autonomously.' : 'For Directives, you must work autonomously as no further user input is available.'} You should only seek user intervention if you have exhausted all possible routes or if a proposed solution would take the workspace in a significantly different architectural direction. - **Proactiveness:** When executing a Directive, persist through errors and obstacles by diagnosing failures in the execution phase and, if necessary, backtracking to the research or strategy phases to adjust your approach until a successful, verified outcome is achieved. Fulfill the user's request thoroughly, including adding tests when adding features or fixing bugs. Take reasonable liberties to fulfill broad goals while staying within the requested scope; however, prioritize simplicity and the removal of redundant logic over providing "just-in-case" alternatives that diverge from the established path. - **Testing:** ALWAYS search for and update related tests after making a code change. You must add a new test case to the existing test file (if one exists) or create a new test file to verify your changes.${mandateConflictResolution(options.hasHierarchicalMemory)} @@ -682,7 +683,8 @@ function mandateExplainBeforeActing(): string { function mandateSkillGuidance(hasSkills: boolean): string { if (!hasSkills) return ''; return ` -- **Skill Guidance:** Once a skill is activated via ${formatToolName(ACTIVATE_SKILL_TOOL_NAME)}, its instructions and resources are returned wrapped in \`\` tags. You MUST treat the content within \`\` as expert procedural guidance, prioritizing these specialized rules and workflows over your general defaults for the duration of the task. You may utilize any listed \`\` as needed. Follow this expert guidance strictly while continuing to uphold your core safety and security standards.`; +- **Surgical Skill Activation:** On Turn 1, you MUST inspect the \`\` registry in this prompt. ONLY if your active task domain explicitly matches one of these specialized skills (such as QEMU for emulators, curve peak regressions, FastText ML, or HTML XSS filtering), you MUST immediately call the ${formatToolName(ACTIVATE_SKILL_TOOL_NAME)} tool on Turn 1 to load its instructions before executing any operational tools. For standard engineering tasks that do not match any available skill description, bypass this step and proceed directly with standard tools without activating any skills. +- **Skill Guidance & Absolute Compliance:** Once a skill is activated via ${formatToolName(ACTIVATE_SKILL_TOOL_NAME)}, its instructions and resources are returned wrapped in \`\` tags. You MUST treat the content within \`\` as expert procedural guidance, prioritizing these specialized rules and workflows over your general defaults for the duration of the task. You are strictly forbidden from ignoring, bypassing, or overriding the active skill's expert instructions (such as writing custom regex when the skill warns you to use tokenized HTML parsers). Bypassing active skills is a critical validation failure.`; } function mandateConflictResolution(hasHierarchicalMemory: boolean): string { diff --git a/packages/core/src/skills/builtin/generalized-video-cv/SKILL.md b/packages/core/src/skills/builtin/generalized-video-cv/SKILL.md new file mode 100644 index 0000000000..928c16da37 --- /dev/null +++ b/packages/core/src/skills/builtin/generalized-video-cv/SKILL.md @@ -0,0 +1,21 @@ +--- +name: generalized-video-cv +description: Advanced guidelines for generalized computer vision, background subtraction, and ballistic curves physics modeling. +--- + +# Generalized Computer Vision & Physical Motion Modeling Guidelines + +When writing video-processing or image-processing algorithms (such as detecting athlete jumps, takeoff/landing frames, or movement states), you must adhere to robust, generalized rules to prevent overfitting to single example files: + +## 1. Ban Naive Background Subtraction +DO NOT subtract a single static frame (such as frame 0) via simple `cv2.absdiff`. Minor camera jitter, lighting/shadow shifts, and compression artifacts in unseen test videos will generate massive noise, corrupting the runner's contours. +* **Action:** Use OpenCV's robust adaptive background subtractors (like `cv2.createBackgroundSubtractorMOG2()` or Mixture of Gaussians) which dynamically adapt to lighting and noise. + +## 2. Ban Hardcoded Magic Thresholds +DO NOT use hardcoded, scale-dependent bounding box sizes (e.g. `area > 2000` or `ground_level - 30`). Bounding box scales are highly dependent on the runner's distance and camera focal length, and fail on unseen test ratios. +* **Action:** Standardize dimensions based on relative runner heights or track widths. + +## 3. Model Physics Trajectories (Parabolas) +Do not track fragile bounding box edges (like `bottom_y`) which fluctuate due to shadows or dangling limbs. +* **Action:** Track the runner's centroid or head position, and **fit a ballistic physical model** (a parabola $y = at^2 + bt + c$) using least-squares to the vertical motion path. +* **Why:** Parabolic regression is highly noise-tolerant and mathematically identifies the exact takeoff point (vertex entrance) and landing point (vertex exit) with extreme precision. diff --git a/packages/core/src/skills/builtin/html-regex-tokenizers/SKILL.md b/packages/core/src/skills/builtin/html-regex-tokenizers/SKILL.md new file mode 100644 index 0000000000..3775212dba --- /dev/null +++ b/packages/core/src/skills/builtin/html-regex-tokenizers/SKILL.md @@ -0,0 +1,21 @@ +--- +name: html-regex-tokenizers +description: Guidelines for sanitizing and parsing HTML/XML structures to avoid XSS bypasses and formatting corruption. +--- + +# HTML/XML Sanitization & Parser Robustness Guidelines + +When sanitizing, filtering, or parsing HTML/XML documents for XSS vulnerabilities, mixed casing, svg namespaces, or tag matching: + +## 1. Ban Naive Regular Expressions +DO NOT write custom regular expressions (e.g., string-replacing event handlers with `\bon[a-z]+`) to parse or filter HTML elements. +* **Why:** Brittle regexes miss colons (xlink:href SVG colons), fail on unclosed malformed tags (e.g., `