Skip to content

feat: add AI context resolver utility and tests#5

Closed
flooryyyy wants to merge 1 commit intomainfrom
codex/create-aicontext-utility-with-tests
Closed

feat: add AI context resolver utility and tests#5
flooryyyy wants to merge 1 commit intomainfrom
codex/create-aicontext-utility-with-tests

Conversation

@flooryyyy
Copy link
Copy Markdown
Owner

Motivation

  • Provide a deterministic utility to assemble AI prompt context from a user's selection and project graph so downstream AI features get stable, relevant input.
  • Enforce exclusion rules and skip blank blocks to avoid leaking unwanted nodes or empty content into prompts.
  • Respect a character budget with graceful truncation so callers can request context limited to token/char constraints.

Description

  • Added src/app/components/project/utils/aiContext.ts which exports resolveAiContext and related types and implements a deterministic BFS-like traversal seeded by selectedIds with adjacency targets sorted for stable ordering.
  • The resolver applies excludeIds and excludeTypes, skips blocks with empty title/content, formats blocks as # Title\n\nContent when appropriate, and returns { text, orderedIds, truncated }.
  • The function enforces a maxChars budget and truncates entries with an ellipsis when necessary using truncateWithEllipsis while preserving separators (\n\n by default).
  • Added unit tests in src/app/components/project/utils/aiContext.test.ts that verify traversal ordering, exclusion behavior, formatting, and truncation semantics.

Testing

  • Ran the focused test file with npm test -- src/app/components/project/utils/aiContext.test.ts, which passed both tests.
  • The full test suite was run as part of the commit step (vitest run) and completed successfully with all tests passing (57 tests passed).

Codex Task

@flooryyyy flooryyyy closed this Apr 10, 2026
@flooryyyy flooryyyy deleted the codex/create-aicontext-utility-with-tests branch April 10, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant