Commit Graph

18 Commits

Author SHA1 Message Date
Dhanji R. Prasanna
65b2ec368f Add Action Envelope section back to native prompt
Restored the Action Envelope instructions with a clear, complete example
showing how to write envelope.yaml for rulespec verification.
2026-02-05 22:27:29 +11:00
Dhanji R. Prasanna
3823f8b5f3 Optimize native system prompt - 48% size reduction
Removed redundant and vague content from prompts/system/native.md:
- Simplified intro from 17 lines to 3 lines
- Reduced Code Search section to one line
- Removed duplicate Plan Mode example (kept one)
- Removed Action Envelope section (rarely used correctly)
- Removed verbose Memory Format details (tool description covers it)
- Removed Response Guidelines (obvious to modern LLMs)

Size: 8,620 chars -> 4,498 chars

Also updated:
- G3_IDENTITY_LINE constant for agent mode compatibility
- Test assertions to check for new prompt markers
- System prompt validation to use new marker string
2026-02-05 22:16:34 +11:00
Dhanji R. Prasanna
7e2d9bc22c Enforce rulespec creation with plan_write for new plans
Solves the tautology problem where the LLM would write invariants after
implementation, making them match what was done rather than constrain it.

Changes:
- plan_write now accepts 'rulespec' parameter
- New plans REQUIRE rulespec (fails with helpful error if missing)
- Plan updates don't require rulespec (backward compatible)
- Rulespec is parsed, validated, and written atomically with plan
- Updated system prompt with clear examples for new vs update
- Updated tool definition schema
- Updated all affected tests

New flow: task → plan+rulespec → user reviews BOTH → approve → implement
2026-02-05 21:12:02 +11:00
Dhanji R. Prasanna
788debb93a remove cruft from system prompt 2026-02-05 14:01:26 +11:00
Dhanji R. Prasanna
68fd7b96c1 Remove accidental Emacs lock file 2026-02-05 14:01:03 +11:00
Dhanji R. Prasanna
6cb70f26fa Fix empty Language-Specific Guidance header in system prompt
When a Rust-only workspace was detected, the Language-Specific Guidance
header was appearing with no content because Rust has an empty prompt
string (agent-specific prompts handle Rust instead).

The fix filters out empty prompt strings in get_language_prompts_for_workspace()
so the header only appears when there's actual guidance content.

Added test to verify Rust-only workspaces return None.
2026-02-05 14:00:52 +11:00
Dhanji R. Prasanna
9443f9333b refactor: Remove hardcoded Web Research section from system prompt
- Web Research instructions now come from skills/research/SKILL.md
- Skills are dynamically loaded and injected via generate_skills_prompt()
- Remove test_both_prompts_have_web_research test (no longer applicable)
- Remove unused G3Status::research_complete() function

This completes the externalization of research as a skill.
2026-02-05 13:41:53 +11:00
Dhanji R. Prasanna
39e586982c feat: Externalize research tool as embedded skill
Replaces the built-in research/research_status tools with a portable
skill-based approach:

- Add embedded skills infrastructure (skills compiled into binary)
- Add repo-local skills/ directory support (highest priority)
- Create research skill with SKILL.md and g3-research shell script
- Script extraction to .g3/bin/ with version tracking
- Filesystem-based handoff via .g3/research/<id>/status.json
- Remove PendingResearchManager and all research tool code
- Update system prompt to reference skill instead of tool

Benefits:
- No special tool infrastructure needed (just shell + read_file)
- Context-efficient (reports stay on disk until needed)
- Crash-resilient (state persisted to filesystem)
- Portable (skill can be overridden per-workspace)

Breaking change: research tool calls now return a deprecation message
pointing to the research skill.
2026-02-05 13:23:26 +11:00
Dhanji R. Prasanna
8bbaf6f02e Tighten system prompt and tool definitions
Prompt changes (native.md):
- Remove duplicate 'Temporary files' section
- Consolidate 'remember' instructions into single authoritative location
- Remove motivational 'Benefits' list from Plan Mode
- Add 'Code Search Tool Selection' guidance (code_search vs rg)

Tool changes (tool_definitions.rs, tool_dispatch.rs):
- Remove screenshot tool (webdriver_screenshot remains)
- Remove coverage tool
- Reduce plan_write description from 22 lines to 1 line
- Update tool count tests (16 -> 14 core tools)

Net result: ~6 lines removed from prompt, ~56 lines removed from
tool definitions, clearer tool selection guidance added.
2026-02-05 12:36:49 +11:00
Dhanji R. Prasanna
b6d25824f3 Tighten system prompt 2026-02-05 12:01:01 +11:00
Dhanji R. Prasanna
3d3f68e6da Externalize native system prompt to markdown file
- Move system prompt for native tool calling models to prompts/system/native.md
- Use include_str! to embed at compile time
- Remove concatenated SHARED_* string constants
- Prompt is now readable/editable as a complete markdown document
- Non-native prompt still uses Rust constants (acceptable for now)
2026-02-05 11:46:49 +11:00
Dhanji R. Prasanna
616e0898c7 Add performance deep cuts and parameterize guidance
Performance:
- Beware list-ref in a loop (O(n²) trap)
- Consolidated performance section with data structure selection rationale
- for/fold for single-pass result building

Parameters and dynamic scope:
- Good uses: ports, logging, config, test fixtures
- Bad uses: hidden global state, implicit argument passing
- Document when functions read from parameters

Also simplified Continuations section (parameterize now has its own section).
2026-01-15 13:49:29 +05:30
Dhanji R. Prasanna
52cd19a015 Refine carmack.racket.md with deeper Racket idioms
Major improvements:
- Iteration idioms: for/fold example, for*/list, in-naturals for indices
- Data structure mutability: when to use mutable hash/vector/box
- let/let*/define style: use let* when order matters
- Contracts section: when to use define/contract, ->i, boundary focus
- Naming: -ref/-set/-update suffixes for custom types
- Size heuristics: semantic ('one abstraction per module') not numeric
- Module hygiene: explicit provides only, contract-out when correctness matters

Removed:
- Packages/tooling section (covered in base racket.md injection)

Now 119 lines of actionable, non-obvious Racket guidance.
2026-01-15 13:49:29 +05:30
Dhanji R. Prasanna
e222b9affc Add non-obvious Racket style guide recommendations
From docs.racket-lang.org/style, added only the non-obvious tips:
- Prefer define over let/let* (reduces indentation)
- Put provide before require (interface at top)
- Use racket/base for libraries (faster loading)
- Naming: prefix functions with data type (board-free-spaces)
- Use in-list/in-vector explicitly in for loops (performance)
- Use module+ test submodules with raco test
- Size limits: ~500 lines/module, ~66 lines/function

Skipped basic conventions LLMs already know (predicate suffixes, etc).
2026-01-15 13:49:29 +05:30
Dhanji R. Prasanna
5ad9fb3718 Improve carmack.racket.md with code examples and Racket-specific guidance
Changes:
- Add concrete code examples for match/cond and contract-out
- Add Phase separation section (for-syntax vs runtime)
- Add Continuations section (call/ec over call/cc, parameterize)
- Add Concurrency section (places, threads, channels, sync)
- Add Gotchas section (eq?/equal?/eqv?, null?/empty?, string=?)
- Tighten Packages/tooling (raco pkg install --auto, info.rkt)

Removed generic advice:
- 'Don't swallow exceptions' (obvious)
- 'Add docstrings/comments' (obvious)
- 'Include runnable examples' (obvious)
- 'Optimize the bottleneck only' (obvious)
- Entire 'Output expectations' section (meta, not Racket-specific)
- Removed oddly specific 'file/sha1, file-watch' reference
2026-01-15 13:49:29 +05:30
Dhanji R. Prasanna
65807eea99 Add carmack.rust.md agent-specific language prompt
Rust-specific readability guidance for the carmack agent including:
- let...else example for shallow control flow
- Async: don't block the runtime (tokio::fs, spawn_blocking, Send)
- Visibility: prefer pub(crate), private fields with accessors
- Generics: impl Trait over explicit params, avoid complex where clauses
- Improved iterator guidance: if you need a comment, use a loop
- UTF-8 string slicing warnings
- Ownership/lifetime pragmatism
- Anti-patterns: no macros/typestate/proc-macros unless already in repo

Also adds Rust detection to LANGUAGE_PROMPTS (empty base prompt,
agent-specific prompts handle the guidance).
2026-01-15 13:49:29 +05:30
Dhanji R. Prasanna
eefc067aae Add carmack.racket.md agent-specific language prompt
Racket-specific guidance for the carmack agent including:
- Idiomatic Racket patterns (match, for/*, cond)
- Module organization with explicit provide lists
- Contracts and type boundaries
- Data modeling with structs
- Error handling best practices
- IO, paths, and portability
- Performance considerations
- Macro guidelines
- Testing with rackunit
2026-01-15 06:43:20 +05:30
Dhanji R. Prasanna
afec65fd50 Add language-specific prompt injection for toolchain guidance
- Add language_prompts module that auto-detects programming languages in workspace
- Scan for language files with depth limit (2) to inject relevant toolchain prompts
- Add prompts/langs/ directory for language-specific markdown files
- Include Racket/raco toolchain guidance as first language prompt
- Update combine_project_content() to accept language_content parameter
- Integrate language detection into main CLI flow and agent mode
- Update project memory with new feature documentation
2026-01-14 21:00:52 +05:30