Skip to content

feat: forward prompts to Gortex for task-relevant symbol hints - #56

Merged
vitaliyslion merged 1 commit into
mainfrom
feat/prompt-hints
Oct 27, 2026
Merged

vitaliyslion merged 1 commit into
mainfrom
feat/prompt-hints

Conversation

@vitaliyslion

Copy link
Copy Markdown
Collaborator

Summary

Each prompt typed while Pi is idle now goes to gortex hook --agent=pi as a prompt event. The symbols Gortex finds relevant are attached to the turn as a hidden gortex message, as Claude Code's UserPromptSubmit hook does.

  • Raw text from input (src/index.ts): the prompt is captured on Pi's input event, before skill or template expansion, and sent with cwd and session_id. /skill:name args therefore reaches Gortex as typed, and its existing / prefix check skips it. Claude Code's hook gets the same raw line. The call starts on input, so the probe runs alongside expansion and, on the first turn, alongside the readiness barrier.
  • Attached on before_agent_start: the reply's additional_context is appended after the prompt.
    • On the first turn it shares one message with the warnings and the briefing, briefing first.
    • details.briefing keeps its meaning, so resending the briefing after compaction is unchanged.
  • Cache-safe: hints are only ever appended, never edited or removed. Replacing an earlier hint would invalidate the provider cache from that point on every turn.
  • Skipped:
    • steering and follow-up messages typed mid-run, which never reach before_agent_start;
    • sessions without graph tools, since the hints name tools the model cannot call;
    • an empty or failed reply, which adds nothing (fail open).
  • Envelope (src/hook.ts): PiEnvelope gains prompt.
  • Docs: a README feature line, and one paragraph in docs/architecture.md (Orientation injection) on the append-only rule.

No Gortex change is needed: bridgePrompt already answers the prompt slot.

Known limit, upstream: Gortex's prompt search only returns hits for prompts close to a symbol name (callHook). A sentence such as "where is waitForGortexTools handled" comes back empty, on Claude Code's path as well.

Reproduction

Real Pi 1.3.0 loading this checkout (pi --no-extensions -e builtin:mcp -e ./index.ts), against a live gortex v0.64.8 daemon, with four prompts continued on one session:

Prompt Session entry after the prompt Cache read
waitForGortexTools - reply with just the word OK, use no tools Briefing only (Gortex: no hits for a sentence) 0
callHook Hint message listing callHook 8448
/skill:nonexistent callHook Nothing 14080
waitForGortexTools Hint message listing waitForGortexTools 18688

Each turn read the whole previous conversation from cache.

Closes #43

Testing

  • npm run check passes (190 tests)
  • New behaviour has a suite that drives it through Pi's ExtensionRunner (see docs/tests.md):
    • test/prompt.test.ts covers:
      • the first turn merging briefing and hints;
      • later turns only appending, with earlier messages unchanged;
      • session_id and cwd on the envelope;
      • /skill: sent unexpanded;
      • no call for steer and followUp input;
      • no message for an empty reply or a non-JSON reply;
      • no call without graph tools.
    • The harness can send input events and has a prompt() helper. The hook double can answer per envelope event.
    • Against the previous source, the 5 positive cases fail.
  • Tried by hand in Pi (pi -e /path/to/checkout), Pi 1.3.0 on Linux against a live gortex daemon: every row of the table above. The briefing still arrives on the first turn.

Checklist

  • No runtime dependencies added
  • README configuration table updated, if config changed (no config change)
  • docs/architecture.md updated briefly, only if a design decision changed: prompt hints are append-only and sent before skill expansion
  • Works on Windows paths and process spawning, if touching either: neither is touched. The new call goes through the existing callHook seam and only adds an envelope field. The windows-latest CI job runs the new suite.

Each prompt typed while Pi is idle goes to gortex hook as a prompt
event, captured on input so skills and templates arrive as typed and
Gortex's slash-command skip applies. The hints in the reply are appended
after the prompt as a hidden gortex message, merged with the briefing on
the first turn. They are never edited later, which keeps the provider's
prompt cache intact.

Mid-run steering and follow-up messages, sessions without graph tools,
and empty or failed replies add nothing.

Closes #43
@vitaliyslion
vitaliyslion merged commit d965a3e into main Oct 27, 2026
3 checks passed
@vitaliyslion
vitaliyslion deleted the feat/prompt-hints branch October 27, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forward user prompts to Gortex for task-relevant symbol hints

1 participant