Skip to content

feat: add IIntentExtractor interface and config fields (GIT-97)#65

Merged
TonyCasey merged 2 commits intomainfrom
git-97
Feb 15, 2026
Merged

feat: add IIntentExtractor interface and config fields (GIT-97)#65
TonyCasey merged 2 commits intomainfrom
git-97

Conversation

@TonyCasey
Copy link
Copy Markdown
Owner

@TonyCasey TonyCasey commented Feb 15, 2026

Summary

  • Add IIntentExtractor interface for extracting searchable keywords from user prompts
  • Extend IPromptSubmitConfig with new fields: extractIntent, intentTimeout, minWords, memoryLimit
  • Update config defaults to enable prompt-submit hook by default

Changes

  • src/domain/interfaces/IIntentExtractor.ts - New interface
  • src/domain/interfaces/IHookConfig.ts - Extended config interface
  • src/hooks/utils/config.ts - Updated defaults
  • tests/unit/hooks/utils/config.test.ts - Updated test assertions

Test plan

  • Type check passes
  • Lint passes
  • Unit tests pass (438 tests)

Closes GIT-97

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Intent extraction enabled by default to automatically identify intent from user input.
  • Configuration

    • New settings to control intent extraction: timeout, minimum input word count, and memory result limits.
  • Tests

    • Unit tests updated to reflect the new default behavior and additional configuration fields.

- Add IIntentExtractor interface for keyword extraction from prompts
- Extend IPromptSubmitConfig with extractIntent, intentTimeout, minWords,
  and memoryLimit fields
- Update config defaults: enable promptSubmit by default, extractIntent=true,
  intentTimeout=3000ms, minWords=5, memoryLimit=20
- Update config tests for new defaults

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AI-Agent: Claude-Code/2.1.42
AI-Model: claude-opus-4-5-20251101
AI-Decision: add IIntentExtractor interface and config fields (GIT-97). - Add IIntentExtractor interface for keyword extraction from prompts
AI-Confidence: medium
AI-Tags: domain, hooks, utils, tests, unit
AI-Lifecycle: project
AI-Memory-Id: c64a5417
AI-Source: heuristic
Copilot AI review requested due to automatic review settings February 15, 2026 00:28
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Adds an intent-extraction interface and enables per-prompt intent extraction via four new IPromptSubmitConfig properties; updates default hook configuration to enable the feature and adjusts unit tests to validate the new defaults.

Changes

Cohort / File(s) Summary
Hook config interface
src/domain/interfaces/IHookConfig.ts
Added four readonly properties to IPromptSubmitConfig: extractIntent, intentTimeout, minWords, memoryLimit. Comment on surfaceContext adjusted.
Intent extractor interfaces
src/domain/interfaces/IIntentExtractor.ts
New intent extraction contract: IIntentExtractorInput (prompt), IntentSkipReason union, IIntentExtractorResult discriminated union (skipped true/false with reasons/intents), and IIntentExtractor with extract(...) returning a promise of result.
Hook defaults
src/hooks/utils/config.ts
Default promptSubmit config changed: enabled set to true and new fields added with defaults (extractIntent: true, intentTimeout: 3000, minWords: 5, memoryLimit: 20).
Tests
tests/unit/hooks/utils/config.test.ts
Updated tests to expect promptSubmit.enabled === true and to assert the new default fields and values in both default and merged-config scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main additions: IIntentExtractor interface and new config fields, matching the core changes across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch git-97

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds foundational support for intent extraction in the prompt-submit hook by introducing the IIntentExtractor interface and extending the IPromptSubmitConfig with configuration fields for LLM-based intent extraction, minimum word thresholds, and memory limits. The PR also changes the default behavior to enable the prompt-submit hook by default.

Changes:

  • Introduces IIntentExtractor interface defining the contract for extracting searchable keywords from user prompts
  • Extends IPromptSubmitConfig with four new fields: extractIntent, intentTimeout, minWords, and memoryLimit
  • Updates default configuration to enable prompt-submit hook and set intent extraction defaults

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/domain/interfaces/IIntentExtractor.ts New interface defining input/output contracts for intent extraction service with support for skip scenarios
src/domain/interfaces/IHookConfig.ts Extends IPromptSubmitConfig with intent extraction configuration fields and updates surfaceContext documentation
src/hooks/utils/config.ts Updates defaults to enable prompt-submit hook and configures intent extraction with 3s timeout, 5-word minimum, and 20-memory limit
tests/unit/hooks/utils/config.test.ts Adds test assertions for new config fields to verify defaults are loaded correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +37
* Result of intent extraction.
*/
export interface IIntentExtractorResult {
/**
* Extracted keywords for memory search.
* null if extraction was skipped or no keywords found.
*/
readonly intent: string | null;
/** Whether extraction was skipped. */
readonly skipped: boolean;
/**
* Reason for skipping.
* - 'too_short': Prompt has fewer words than minWords threshold.
* - 'confirmation': Prompt is a simple confirmation (yes/no/ok/etc).
* - 'no_llm': No LLM client available.
* - 'llm_skip': LLM returned SKIP (no extractable keywords).
* - 'timeout': LLM call timed out.
* - 'error': LLM call failed with error.
*/
readonly reason?: 'too_short' | 'confirmation' | 'no_llm' | 'llm_skip' | 'timeout' | 'error';
}
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface allows inconsistent states between intent, skipped, and reason fields. Consider adding documentation or using a discriminated union to enforce consistency. For example:

  • When skipped is true, intent should always be null and reason should be defined
  • When skipped is false, intent may be null or a string, and reason should be undefined

A discriminated union approach would make these relationships explicit and prevent invalid states at compile time.

Suggested change
* Result of intent extraction.
*/
export interface IIntentExtractorResult {
/**
* Extracted keywords for memory search.
* null if extraction was skipped or no keywords found.
*/
readonly intent: string | null;
/** Whether extraction was skipped. */
readonly skipped: boolean;
/**
* Reason for skipping.
* - 'too_short': Prompt has fewer words than minWords threshold.
* - 'confirmation': Prompt is a simple confirmation (yes/no/ok/etc).
* - 'no_llm': No LLM client available.
* - 'llm_skip': LLM returned SKIP (no extractable keywords).
* - 'timeout': LLM call timed out.
* - 'error': LLM call failed with error.
*/
readonly reason?: 'too_short' | 'confirmation' | 'no_llm' | 'llm_skip' | 'timeout' | 'error';
}
* Reason for skipping intent extraction.
*/
export type IntentSkipReason =
| 'too_short'
| 'confirmation'
| 'no_llm'
| 'llm_skip'
| 'timeout'
| 'error';
/**
* Result of intent extraction.
*
* This is a discriminated union keyed by `skipped`:
* - When `skipped` is `true`, `intent` is always `null` and `reason` is defined.
* - When `skipped` is `false`, `intent` may be `null` or a string, and `reason` is undefined.
*/
export type IIntentExtractorResult =
| {
/** Whether extraction was skipped. */
readonly skipped: true;
/**
* Extracted keywords for memory search.
* Always null when extraction is skipped.
*/
readonly intent: null;
/**
* Reason for skipping.
* - 'too_short': Prompt has fewer words than minWords threshold.
* - 'confirmation': Prompt is a simple confirmation (yes/no/ok/etc).
* - 'no_llm': No LLM client available.
* - 'llm_skip': LLM returned SKIP (no extractable keywords).
* - 'timeout': LLM call timed out.
* - 'error': LLM call failed with error.
*/
readonly reason: IntentSkipReason;
}
| {
/** Whether extraction was skipped. */
readonly skipped: false;
/**
* Extracted keywords for memory search.
* null if no keywords were found.
*/
readonly intent: string | null;
/**
* Reason is not present when extraction is not skipped.
*/
readonly reason?: undefined;
};

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +38
/** Enable LLM-based intent extraction for smarter memory retrieval. */
readonly extractIntent: boolean;
/** Timeout in ms for intent extraction LLM call. Default: 3000. */
readonly intentTimeout: number;
/** Minimum word count to trigger intent extraction. Default: 5. */
readonly minWords: number;
/** Maximum memories to return. Default: 20. */
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on surfaceContext had "Reserved — not yet wired to handler" removed, but these new fields (extractIntent, intentTimeout, minWords, memoryLimit) are also not yet wired to PromptSubmitHandler. For consistency with other config fields in this file, consider marking these as "Reserved — not yet wired to handler" until the implementation is added. This follows the pattern used for recordPrompts on line 28 and other fields like memoryLimit in ISessionStartConfig on line 10.

Suggested change
/** Enable LLM-based intent extraction for smarter memory retrieval. */
readonly extractIntent: boolean;
/** Timeout in ms for intent extraction LLM call. Default: 3000. */
readonly intentTimeout: number;
/** Minimum word count to trigger intent extraction. Default: 5. */
readonly minWords: number;
/** Maximum memories to return. Default: 20. */
/** Enable LLM-based intent extraction for smarter memory retrieval. Reserved — not yet wired to handler. */
readonly extractIntent: boolean;
/** Timeout in ms for intent extraction LLM call. Default: 3000. Reserved — not yet wired to handler. */
readonly intentTimeout: number;
/** Minimum word count to trigger intent extraction. Default: 5. Reserved — not yet wired to handler. */
readonly minWords: number;
/** Maximum memories to return. Default: 20. Reserved — not yet wired to handler. */

Copilot uses AI. Check for mistakes.
Comment thread src/domain/interfaces/IHookConfig.ts Outdated
readonly surfaceContext: boolean;
/** Enable LLM-based intent extraction for smarter memory retrieval. */
readonly extractIntent: boolean;
/** Timeout in ms for intent extraction LLM call. Default: 3000. */
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with enrichTimeout documentation on line 58, consider adding "Must be under hook timeout (10s)" to clarify the constraint. This helps users understand the operational limit when configuring this timeout value.

Suggested change
/** Timeout in ms for intent extraction LLM call. Default: 3000. */
/** Timeout in ms for intent extraction LLM call. Default: 3000. Must be under hook timeout (10s). */

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/domain/interfaces/IIntentExtractor.ts`:
- Around line 19-36: The current IIntentExtractorResult allows inconsistent
states between skipped, intent, and reason; change it to a discriminated union
type: one variant (e.g., { skipped: true; intent: null; reason:
'too_short'|'confirmation'|'no_llm'|'llm_skip'|'timeout'|'error' }) and another
variant (e.g., { skipped: false; intent: string; reason?: undefined }) to
enforce valid combinations; update the exported type name IIntentExtractorResult
and ensure code using properties (e.g., checks on skipped, access to intent, and
usage in the intent extractor implementation) uses type-narrowing (if/skipped
switch) so callers get correct typings.

Comment thread src/domain/interfaces/IIntentExtractor.ts Outdated
Address review feedback:
- Change IIntentExtractorResult from interface to discriminated union
  for better type safety (skipped=true implies intent=null and reason defined)
- Add IntentSkipReason type alias
- Add hook timeout constraint to intentTimeout doc comment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AI-Agent: Claude-Code/2.1.42
AI-Model: claude-opus-4-5-20251101
AI-Convention: use discriminated union for IIntentExtractorResult. Address review feedback:
AI-Confidence: low
AI-Tags: domain, typescript
AI-Lifecycle: project
AI-Memory-Id: e04f84fb
AI-Source: heuristic
@TonyCasey
Copy link
Copy Markdown
Owner Author

Addressed review feedback:

  1. Discriminated union - Changed IIntentExtractorResult from interface to discriminated union with two variants keyed by skipped. Added IntentSkipReason type alias.

  2. 'Reserved' annotation - Skipped since these fields are wired up in GIT-99 (part of this PR series), so the annotation would be immediately outdated.

  3. Hook timeout constraint - Added 'Must be under hook timeout (10s)' to intentTimeout doc comment for consistency with enrichTimeout.

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.

2 participants