Commit Graph

11 Commits

  • fix(typebox): migrate to v1 with extension compat (#3474)
    * fix(typebox): migrate to v1 with extension compat
    
    Replace AJV-based validation with TypeBox-native validation, keep legacy extension imports working (including @sinclair/typebox/compiler), and restore coercion for serialized/plain JSON schemas.
    
    This change closes #3112.
    
    * fix(typebox): use canonical imports and harden coercion
    
    Switch first-party code to canonical typebox imports while retaining legacy extension aliases in the loader.
    
    Remove obsolete runtime codegen guards, expand serialized JSON-schema coercion coverage, and update related tests and fixtures.
    
    Fixes #3112.
    
    ---------
    
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • fix(coding-agent): do not inject bunfs script path into subagent prompts (#3002)
    The presence of `process.argv[1]` in the current invocation does not
    imply that the current `pi` process is being invoked as a script.
    Specifically, in the case of a bun compiled binary, `process.argv[1]`
    will be the virtual path `/$bunfs/root/pi`, which is not a real file on
    the filesystem.  This causes the subagent extension to inject this path
    into the child `pi` invocation, which is interpreted as part of the
    prompt, which confuses the subagent.
    
    This change uses the script only if it is not a bunfs virtual script
    
    Co-authored-by: nathyong <nathyong@noreply.github.com>
  • fix(coding-agent): built-in tools work like extension tools
    Export readToolDefinition / createReadToolDefinition and the equivalent built-in ToolDefinition APIs from @mariozechner/pi-coding-agent.
  • fix(subagent): list available agents in unknown-agent error (#1414)
    The invalid-params error paths already listed available agents,
    but the unknown-agent path in runSingleAgent just returned
    'Unknown agent: claude' with no hint what exists.
    
    Now: 'Unknown agent: "claude". Available agents: "worker".'
    
    Model would guess names like "claude", "default", or skill names
    like "brave-search". Now it self-corrects on the next call.
    
    Tested with Opus 4.6: without fix, model gave up on subagent
    and ran the tool calls itself instead. With fix, 1 wasted call.
  • fix(coding-agent): align ToolDefinition.execute signature with AgentTool
    BREAKING CHANGE: ToolDefinition.execute parameter order changed from
    (id, params, onUpdate, ctx, signal) to (id, params, signal, onUpdate, ctx).
    
    This aligns with AgentTool.execute so wrapping built-in tools no longer
    requires parameter reordering. Update extensions by swapping signal and
    onUpdate parameters.
  • Centralize frontmatter parsing + parse frontmatter with yaml library (#728)
    * Add frontmatter utility and tidy coding agent prompts
    
    * Add frontmatter parsing utilities and tests
    
    * Parse frontmatter with YAML parser
    
    * Simplify frontmatter parsing utilities
    
    * strip body in 1 place
    
    * Improve frontmatter parsing error handling
    
    * Normalize multiline skill and select-list descriptions
  • Merge hooks and custom-tools into unified extensions system (#454)
    Breaking changes:
    - Settings: 'hooks' and 'customTools' arrays replaced with 'extensions'
    - CLI: '--hook' and '--tool' flags replaced with '--extension' / '-e'
    - API: HookMessage renamed to CustomMessage, role 'hookMessage' to 'custom'
    - API: FileSlashCommand renamed to PromptTemplate
    - API: discoverSlashCommands() renamed to discoverPromptTemplates()
    - Directories: commands/ renamed to prompts/ for prompt templates
    
    Migration:
    - Session version bumped to 3 (auto-migrates v2 sessions)
    - Old 'hookMessage' role entries converted to 'custom'
    
    Structural changes:
    - src/core/hooks/ and src/core/custom-tools/ merged into src/core/extensions/
    - src/core/slash-commands.ts renamed to src/core/prompt-templates.ts
    - examples/hooks/ and examples/custom-tools/ merged into examples/extensions/
    - docs/hooks.md and docs/custom-tools.md merged into docs/extensions.md
    
    New test coverage:
    - test/extensions-runner.test.ts (10 tests)
    - test/extensions-discovery.test.ts (26 tests)
    - test/prompt-templates.test.ts