Skip to content

Align entity guidance and documentation across multiple files#122

Merged
Looted merged 11 commits intomasterfrom
develop
Mar 28, 2026
Merged

Align entity guidance and documentation across multiple files#122
Looted merged 11 commits intomasterfrom
develop

Conversation

@Looted
Copy link
Copy Markdown
Owner

@Looted Looted commented Mar 28, 2026

  • Remove stale "RED PHASE" planning note from exportedWinsOverInternal docblock in symbols-ts.test.ts — replaced with accurate description of the live exported-first priority rule
  • Remove stale "RED PHASE" planning note from ambiguousInternalTitlesFailClosed docblock in symbols-ts.test.ts — replaced with accurate description of the now-live fail-closed behaviour for ambiguous internal declarations
  • Remove redundant as unknown as NamedDeclarationCandidate double-cast on methodCandidates.push in symbols-ts.tsMethodDeclaration already satisfies Node which covers the union type
  • All 3 unit tests pass; CLI builds cleanly (tsc, no type errors)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI review requested due to automatic review settings March 28, 2026 08:47
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 PR improves symbol-coordinate refresh and documentation consistency around symbols.yaml, ensuring coordinates can be generated for additional TypeScript declaration shapes and preventing stale/duplicate symbol aliases from persisting in docs.

Changes:

  • Extend TS coordinate matching to fall back to unique non-exported top-level functions and unique class methods when no exported declaration matches.
  • Add regression tests across CLI, MCP, and VS Code extension to validate indexing, CodeLens placement, and coordinate refresh behavior.
  • Update documentation/symbols.yaml to remove a stale alias and refresh generated coordinate fields; add a CLI test to prevent regressions.

Reviewed changes

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

Show a summary per file
File Description
packages/vscode/tests/symbolIndex.test.ts Adds tests for indexing symbols that represent internal helpers and class methods.
packages/vscode/tests/codeLens.test.ts Adds CodeLens placement tests for internal helpers and class-method symbols.
packages/mcp/tests/tools/symbols.test.ts Adds regression coverage for coordinate refresh on exported, non-exported, and class-method symbols.
packages/cli/tests/extractors/symbols-ts.test.ts Adds matcher guardrail tests for exported-vs-internal priority, ambiguity fail-closed behavior, and unsupported shapes.
packages/cli/tests/documentation-consistency.test.ts Adds regression assertions to prevent stale symbol aliases/duplicate titles in docs.
packages/cli/tests/commands/sync.test.ts Adds an end-to-end sync regression test ensuring failed=0 for the newly supported symbol shapes.
packages/cli/src/extractors/symbols-ts.ts Implements the fallback matching logic for internal functions and class methods.
documentation/symbols.yaml Removes stale symbol alias entry and updates generated coordinate fields/timestamps.
.changeset/add-fallback-kibi-cli.md Declares a patch release for kibi-cli reflecting the coordinate-refresh enhancement.

Comment on lines +92 to +98
* `bar`, the matcher MUST return no coordinates (fail closed). Resolving
* ambiguously to one of them would produce silently wrong coordinates.
*
* RED PHASE: The current scanner ignores non-exported declarations, so it
* returns nothing today. This test locks that behaviour so that if the
* scanner is later extended to consider internal declarations, it must also
* implement the fail-closed rule before coordinates are emitted.
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

This docblock says the scanner "ignores non-exported declarations" and that internal resolution is a future extension, but the matcher now explicitly scans non-exported top-level functions (and fails closed on ambiguity). Please update the wording so it matches the current implementation and what the test is actually asserting.

Suggested change
* `bar`, the matcher MUST return no coordinates (fail closed). Resolving
* ambiguously to one of them would produce silently wrong coordinates.
*
* RED PHASE: The current scanner ignores non-exported declarations, so it
* returns nothing today. This test locks that behaviour so that if the
* scanner is later extended to consider internal declarations, it must also
* implement the fail-closed rule before coordinates are emitted.
* `bar`, the matcher MUST return no coordinates (fail closed). Resolving
* ambiguously to one of them would produce silently wrong coordinates.
*
* The matcher now scans non-exported top-level functions, but when multiple
* internal declarations share the same title and there is no exported
* declaration to disambiguate, it must treat the match as ambiguous and
* emit no coordinates. This test locks in that fail-closed behaviour.

Copilot uses AI. Check for mistakes.
if (method.getName() !== title) continue;
const nameNode = method.getNameNode();
if (!nameNode) continue;
methodCandidates.push({ node: method as unknown as NamedDeclarationCandidate, getNameNode: () => nameNode });
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

methodCandidates.push uses an as unknown as NamedDeclarationCandidate cast, but NamedDeclarationCandidate already includes Node, so the cast is redundant and weakens type-safety/readability. Prefer removing the cast (and/or tightening NamedDeclarationCandidate to the specific node types you actually handle).

Suggested change
methodCandidates.push({ node: method as unknown as NamedDeclarationCandidate, getNameNode: () => nameNode });
methodCandidates.push({ node: method, getNameNode: () => nameNode });

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +54
* RED PHASE: The current implementation only scans exported declarations.
* When an internal-then-exported pair exists, if the scanner is ever
* extended to look at internals first, this test locks the priority rule.
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

The comment says "RED PHASE: The current implementation only scans exported declarations", but this PR adds fallback scanning for unique non-exported functions and class methods in findNamedDeclaration. Please update this test docblock to reflect the current behavior (e.g., exported pass first, then internal/method fallback).

Suggested change
* RED PHASE: The current implementation only scans exported declarations.
* When an internal-then-exported pair exists, if the scanner is ever
* extended to look at internals first, this test locks the priority rule.
* The matcher now prefers exported declarations first, and only falls back
* to unique internal functions or class methods when no matching export
* is found. When an internal-then-exported pair exists, this test locks
* in the priority rule that the exported declaration must win.

Copilot uses AI. Check for mistakes.
@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Mar 28, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

@copilot apply changes based on the comments in this thread

Applied all three changes from the review:

  1. symbols-ts.test.ts:52-54 – Updated docblock to say the matcher now prefers exported declarations first and falls back to unique internals/methods, locking the priority rule.
  2. symbols-ts.test.ts:92-98 – Updated docblock to reflect that the matcher now scans non-exported top-level functions but must fail-closed on ambiguity, replacing the stale "RED PHASE" language.
  3. symbols-ts.ts:248 – Removed the redundant as unknown as NamedDeclarationCandidate cast; MethodDeclaration already extends Node which satisfies the union type.

Changes are in commit 78c5d26. Note: the develop branch has direct-push protection — the commit is local and requires the branch protection to allow the push (or a PR to be merged).

@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Mar 28, 2026

@copilot apply changes based on the comments in this thread in a separate PR.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

@Looted I've opened a new pull request, #123, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 28, 2026 10:13
fix(cli): remove stale RED PHASE docblocks and redundant cast in symbol matcher
@Looted Looted merged commit 41ab5fa into master Mar 28, 2026
6 checks passed
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.

3 participants